@intentius/chant 0.124.15 → 0.124.16

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 (81) hide show
  1. package/dist/cli/flush.d.ts +16 -0
  2. package/dist/cli/flush.d.ts.map +1 -0
  3. package/dist/cli/flush.js +42 -0
  4. package/dist/cli/handlers/approve.d.ts +98 -0
  5. package/dist/cli/handlers/approve.d.ts.map +1 -0
  6. package/dist/cli/handlers/approve.js +495 -0
  7. package/dist/cli/handlers/operator.d.ts +1 -95
  8. package/dist/cli/handlers/operator.d.ts.map +1 -1
  9. package/dist/cli/handlers/operator.js +4 -488
  10. package/dist/cli/handlers/override-approve.js +1 -1
  11. package/dist/cli/main.d.ts +4 -15
  12. package/dist/cli/main.d.ts.map +1 -1
  13. package/dist/cli/main.js +4 -1062
  14. package/dist/cli/parse-args.d.ts +6 -0
  15. package/dist/cli/parse-args.d.ts.map +1 -0
  16. package/dist/cli/parse-args.js +1028 -0
  17. package/dist/components/fan-out-record.d.ts +1 -1
  18. package/dist/components/fan-out-record.d.ts.map +1 -1
  19. package/dist/components/fan-out-record.js +3 -7
  20. package/dist/components/fan-out-run.d.ts +5 -3
  21. package/dist/components/fan-out-run.d.ts.map +1 -1
  22. package/dist/components/fan-out-run.js +7 -5
  23. package/dist/gated-waves.d.ts +25 -6
  24. package/dist/gated-waves.d.ts.map +1 -1
  25. package/dist/gated-waves.js +21 -6
  26. package/dist/op/activities/activity-contracts.d.ts +4 -4
  27. package/dist/op/op-waves-run.d.ts +1 -1
  28. package/dist/op/op-waves-run.d.ts.map +1 -1
  29. package/dist/op/op-waves-run.js +5 -6
  30. package/dist/op/op-waves.d.ts.map +1 -1
  31. package/dist/op/op-waves.js +4 -8
  32. package/dist/package-version.d.ts +2 -0
  33. package/dist/package-version.d.ts.map +1 -0
  34. package/dist/package-version.js +10 -0
  35. package/dist/wave-engine.d.ts +62 -0
  36. package/dist/wave-engine.d.ts.map +1 -0
  37. package/dist/wave-engine.js +59 -0
  38. package/dist/wave-layout.d.ts +29 -0
  39. package/dist/wave-layout.d.ts.map +1 -0
  40. package/dist/wave-layout.js +41 -0
  41. package/dist/wave-runtime.d.ts +29 -0
  42. package/dist/wave-runtime.d.ts.map +1 -0
  43. package/dist/wave-runtime.js +103 -0
  44. package/dist/wave-runtime.mjs +331 -0
  45. package/dist/workspace/ajv2020.d.ts +5 -0
  46. package/dist/workspace/ajv2020.d.ts.map +1 -0
  47. package/dist/workspace/ajv2020.js +14 -0
  48. package/dist/workspace/declaration.d.ts.map +1 -1
  49. package/dist/workspace/declaration.js +4 -8
  50. package/dist/workspace/kinds.d.ts.map +1 -1
  51. package/dist/workspace/kinds.js +2 -5
  52. package/dist/workspace/points.d.ts.map +1 -1
  53. package/dist/workspace/points.js +2 -5
  54. package/dist/workspace/principal-classes.d.ts.map +1 -1
  55. package/dist/workspace/principal-classes.js +2 -5
  56. package/package.json +5 -3
  57. package/src/cli/flush.ts +44 -0
  58. package/src/cli/handlers/approve.ts +618 -0
  59. package/src/cli/handlers/operator.ts +10 -608
  60. package/src/cli/handlers/override-approve.test.ts +1 -1
  61. package/src/cli/handlers/override-approve.ts +1 -1
  62. package/src/cli/main.ts +5 -816
  63. package/src/cli/parse-args.ts +781 -0
  64. package/src/components/fan-out-record.ts +3 -7
  65. package/src/components/fan-out-run.ts +7 -5
  66. package/src/gate-decision-bundle.test.ts +1 -0
  67. package/src/gated-waves.ts +28 -6
  68. package/src/op/op-waves-run.ts +5 -6
  69. package/src/op/op-waves.ts +4 -8
  70. package/src/package-version.ts +11 -0
  71. package/src/wave-engine.test.ts +107 -0
  72. package/src/wave-engine.ts +98 -0
  73. package/src/wave-layout.ts +44 -0
  74. package/src/wave-runtime-bundle.test.ts +70 -0
  75. package/src/wave-runtime.e2e.test.ts +177 -0
  76. package/src/wave-runtime.ts +104 -0
  77. package/src/workspace/ajv2020.ts +17 -0
  78. package/src/workspace/declaration.ts +4 -10
  79. package/src/workspace/kinds.ts +2 -5
  80. package/src/workspace/points.ts +2 -5
  81. package/src/workspace/principal-classes.ts +2 -5
@@ -0,0 +1,331 @@
1
+ #!/usr/bin/env node
2
+ // @intentius/chant 0.124.16 wave-job runtime (#3896): run wave, run resume, approve, workspace points.
3
+ import { createRequire as __chantCreateRequire } from "node:module";
4
+ const require = __chantCreateRequire(import.meta.url);
5
+ var Ute=Object.create;var X$=Object.defineProperty;var Hte=Object.getOwnPropertyDescriptor;var Vte=Object.getOwnPropertyNames;var qte=Object.getPrototypeOf,Kte=Object.prototype.hasOwnProperty;var v=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(i){throw n=[i],i}};var ie=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(n){throw t=0,n}},_e=(e,t)=>{for(var n in t)X$(e,n,{get:t[n],enumerable:!0})},Jte=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Vte(t))!Kte.call(e,r)&&r!==n&&X$(e,r,{get:()=>t[r],enumerable:!(i=Hte(t,r))||i.enumerable});return e};var Le=(e,t,n)=>(n=e!=null?Ute(qte(e)):{},Jte(t||!e||!e.__esModule?X$(n,"default",{value:e,enumerable:!0}):n,e));function A1(e,t=new Set){let n=[];for(let i of e)if(i.startsWith("--")&&i.includes("=")){let r=i.indexOf("="),o=i.slice(0,r),s=i.slice(r+1);if(t.has(o))throw new Error(`${i} \u2014 ${o} is a boolean flag and does not take a value. Pass ${o} on its own.`);n.push(o,s)}else n.push(i);return n}var Q$,eR=v(()=>{"use strict";Q$=new Set(["build","lint","list","describe","import","audit","migrate","carve","init","update","doctor","dev","run","graph","vendor","lifecycle","lc","components","emulator","serve","operator","approve","workspace"])});function Xte(){return!process.env.NO_COLOR&&process.stdout.isTTY!==!1}function Ms(e,t){return Xte()?`${t}${e}${qo.reset}`:e}function fe(e){let t=[];if(e.file){let n=e.file;e.line!==void 0&&(n+=`:${e.line}`,e.column!==void 0&&(n+=`:${e.column}`)),t.push(Ms(n,qo.cyan)),t.push(" - ")}return t.push(Ms("error",qo.red)),t.push(": "),t.push(e.message),e.hint&&(t.push(`
6
+ `),t.push(Ms(e.hint,qo.gray))),t.join("")}function Hr(e){let t=[];if(e.file){let n=e.file;e.line!==void 0&&(n+=`:${e.line}`,e.column!==void 0&&(n+=`:${e.column}`)),t.push(Ms(n,qo.cyan)),t.push(" - ")}return t.push(Ms("warning",qo.yellow)),t.push(": "),t.push(e.message),e.hint&&(t.push(`
7
+ `),t.push(Ms(e.hint,qo.gray))),t.join("")}function Ip(e){return Ms(e,qo.green)}function ur(e){return Ms(e,qo.gray)}var qo,Kn=v(()=>{"use strict";qo={red:"\x1B[31m",yellow:"\x1B[33m",green:"\x1B[32m",cyan:"\x1B[36m",gray:"\x1B[90m",reset:"\x1B[0m",bold:"\x1B[1m"}});var Tp,Yh=v(()=>{"use strict";Tp="0.124.16"});function M(e,t,n){function i(a,l){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:l,constr:s,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,l);let c=s.prototype,u=Object.keys(c);for(let d=0;d<u.length;d++){let p=u[d];p in a||(a[p]=c[p].bind(a))}}let r=n?.Parent??Object;class o extends r{}Object.defineProperty(o,"name",{value:e});function s(a){var l;let c=n?.Parent?new o:this;i(c,a),(l=c._zod).deferred??(l.deferred=[]);for(let u of c._zod.deferred)u();return c}return Object.defineProperty(s,"init",{value:i}),Object.defineProperty(s,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}function Ht(e){return e&&Object.assign(Dp,e),Dp}var nR,Xh,xi,Fs,Dp,Ml=v(()=>{nR=Object.freeze({status:"aborted"});Xh=Symbol("zod_brand"),xi=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Fs=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}},Dp={}});var le={};_e(le,{BIGINT_FORMAT_RANGES:()=>pR,Class:()=>iR,NUMBER_FORMAT_RANGES:()=>dR,aborted:()=>zs,allowsEval:()=>aR,assert:()=>ine,assertEqual:()=>ene,assertIs:()=>nne,assertNever:()=>rne,assertNotEqual:()=>tne,assignProp:()=>Gs,base64ToUint8Array:()=>D1,base64urlToUint8Array:()=>kne,cached:()=>Bl,captureStackTrace:()=>ey,cleanEnum:()=>vne,cleanRegex:()=>Lp,clone:()=>Jn,cloneDef:()=>sne,createTransparentProxy:()=>pne,defineLazy:()=>He,esc:()=>Qh,escapeRegex:()=>Vr,extend:()=>gne,finalizeIssue:()=>dr,floatSafeRemainder:()=>oR,getElementAtPath:()=>ane,getEnumValues:()=>jp,getLengthableOrigin:()=>Bp,getParsedType:()=>dne,getSizableOrigin:()=>Fp,hexToUint8Array:()=>$ne,isObject:()=>lc,isPlainObject:()=>Ws,issue:()=>Gl,joinValues:()=>V,jsonStringifyReplacer:()=>Fl,merge:()=>yne,mergeDefs:()=>Ko,normalizeParams:()=>ue,nullish:()=>Bs,numKeys:()=>une,objectClone:()=>one,omit:()=>mne,optionalKeys:()=>uR,parsedType:()=>ce,partial:()=>bne,pick:()=>fne,prefixIssues:()=>_r,primitiveTypes:()=>lR,promiseAllObject:()=>cne,propertyKeyTypes:()=>Mp,randomString:()=>lne,required:()=>wne,safeExtend:()=>hne,shallowClone:()=>cR,slugify:()=>sR,stringifyPrimitive:()=>se,uint8ArrayToBase64:()=>N1,uint8ArrayToBase64url:()=>xne,uint8ArrayToHex:()=>Rne,unwrapMessage:()=>Np});function ene(e){return e}function tne(e){return e}function nne(e){}function rne(e){throw new Error("Unexpected value in exhaustive check")}function ine(e){}function jp(e){let t=Object.values(e).filter(i=>typeof i=="number");return Object.entries(e).filter(([i,r])=>t.indexOf(+i)===-1).map(([i,r])=>r)}function V(e,t="|"){return e.map(n=>se(n)).join(t)}function Fl(e,t){return typeof t=="bigint"?t.toString():t}function Bl(e){return{get value(){{let n=e();return Object.defineProperty(this,"value",{value:n}),n}throw new Error("cached value already set")}}}function Bs(e){return e==null}function Lp(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function oR(e,t){let n=(e.toString().split(".")[1]||"").length,i=t.toString(),r=(i.split(".")[1]||"").length;if(r===0&&/\d?e-\d?/.test(i)){let l=i.match(/\d?e-(\d?)/);l?.[1]&&(r=Number.parseInt(l[1]))}let o=n>r?n:r,s=Number.parseInt(e.toFixed(o).replace(".","")),a=Number.parseInt(t.toFixed(o).replace(".",""));return s%a/10**o}function He(e,t,n){let i;Object.defineProperty(e,t,{get(){if(i!==T1)return i===void 0&&(i=T1,i=n()),i},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function one(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Gs(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ko(...e){let t={};for(let n of e){let i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function sne(e){return Ko(e._zod.def)}function ane(e,t){return t?t.reduce((n,i)=>n?.[i],e):e}function cne(e){let t=Object.keys(e),n=t.map(i=>e[i]);return Promise.all(n).then(i=>{let r={};for(let o=0;o<t.length;o++)r[t[o]]=i[o];return r})}function lne(e=10){let t="abcdefghijklmnopqrstuvwxyz",n="";for(let i=0;i<e;i++)n+=t[Math.floor(Math.random()*t.length)];return n}function Qh(e){return JSON.stringify(e)}function sR(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function lc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ws(e){if(lc(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let n=t.prototype;return!(lc(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function cR(e){return Ws(e)?{...e}:Array.isArray(e)?[...e]:e}function une(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function Vr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Jn(e,t,n){let i=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(i._zod.parent=e),i}function ue(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function pne(e){let t;return new Proxy({},{get(n,i,r){return t??(t=e()),Reflect.get(t,i,r)},set(n,i,r,o){return t??(t=e()),Reflect.set(t,i,r,o)},has(n,i){return t??(t=e()),Reflect.has(t,i)},deleteProperty(n,i){return t??(t=e()),Reflect.deleteProperty(t,i)},ownKeys(n){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,i){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,i)},defineProperty(n,i,r){return t??(t=e()),Reflect.defineProperty(t,i,r)}})}function se(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function uR(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function fne(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let o=Ko(e._zod.def,{get shape(){let s={};for(let a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(s[a]=n.shape[a])}return Gs(this,"shape",s),s},checks:[]});return Jn(e,o)}function mne(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let o=Ko(e._zod.def,{get shape(){let s={...e._zod.def.shape};for(let a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete s[a]}return Gs(this,"shape",s),s},checks:[]});return Jn(e,o)}function gne(e,t){if(!Ws(t))throw new Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let o=e._zod.def.shape;for(let s in t)if(Object.getOwnPropertyDescriptor(o,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let r=Ko(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t};return Gs(this,"shape",o),o}});return Jn(e,r)}function hne(e,t){if(!Ws(t))throw new Error("Invalid input to safeExtend: expected a plain object");let n=Ko(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return Gs(this,"shape",i),i}});return Jn(e,n)}function yne(e,t){let n=Ko(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t._zod.def.shape};return Gs(this,"shape",i),i},get catchall(){return t._zod.def.catchall},checks:[]});return Jn(e,n)}function bne(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let s=Ko(t._zod.def,{get shape(){let a=t._zod.def.shape,l={...a};if(n)for(let c in n){if(!(c in a))throw new Error(`Unrecognized key: "${c}"`);n[c]&&(l[c]=e?new e({type:"optional",innerType:a[c]}):a[c])}else for(let c in a)l[c]=e?new e({type:"optional",innerType:a[c]}):a[c];return Gs(this,"shape",l),l},checks:[]});return Jn(t,s)}function wne(e,t,n){let i=Ko(t._zod.def,{get shape(){let r=t._zod.def.shape,o={...r};if(n)for(let s in n){if(!(s in o))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(o[s]=new e({type:"nonoptional",innerType:r[s]}))}else for(let s in r)o[s]=new e({type:"nonoptional",innerType:r[s]});return Gs(this,"shape",o),o}});return Jn(t,i)}function zs(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function _r(e,t){return t.map(n=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function Np(e){return typeof e=="string"?e:e?.message}function dr(e,t,n){let i={...e,path:e.path??[]};if(!e.message){let r=Np(e.inst?._zod.def?.error?.(e))??Np(t?.error?.(e))??Np(n.customError?.(e))??Np(n.localeError?.(e))??"Invalid input";i.message=r}return delete i.inst,delete i.continue,t?.reportInput||delete i.input,i}function Fp(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function Bp(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ce(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function Gl(...e){let[t,n,i]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:i}:{...t}}function vne(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function D1(e){let t=atob(e),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return n}function N1(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function kne(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return D1(t+n)}function xne(e){return N1(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function $ne(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let n=new Uint8Array(t.length/2);for(let i=0;i<t.length;i+=2)n[i/2]=Number.parseInt(t.slice(i,i+2),16);return n}function Rne(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var T1,ey,aR,dne,Mp,lR,dR,pR,iR,Ae=v(()=>{T1=Symbol("evaluating");ey="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};aR=Bl(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});dne=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},Mp=new Set(["string","number","symbol"]),lR=new Set(["string","number","bigint","boolean","symbol","undefined"]);dR={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},pR={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};iR=class{constructor(...t){}}});function Wp(e,t=n=>n.message){let n={},i=[];for(let r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):i.push(t(r));return{formErrors:i,fieldErrors:n}}function zp(e,t=n=>n.message){let n={_errors:[]},i=r=>{for(let o of r.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(s=>i({issues:s}));else if(o.code==="invalid_key")i({issues:o.issues});else if(o.code==="invalid_element")i({issues:o.issues});else if(o.path.length===0)n._errors.push(t(o));else{let s=n,a=0;for(;a<o.path.length;){let l=o.path[a];a===o.path.length-1?(s[l]=s[l]||{_errors:[]},s[l]._errors.push(t(o))):s[l]=s[l]||{_errors:[]},s=s[l],a++}}};return i(e),n}function fR(e,t=n=>n.message){let n={errors:[]},i=(r,o=[])=>{var s,a;for(let l of r.issues)if(l.code==="invalid_union"&&l.errors.length)l.errors.map(c=>i({issues:c},l.path));else if(l.code==="invalid_key")i({issues:l.issues},l.path);else if(l.code==="invalid_element")i({issues:l.issues},l.path);else{let c=[...o,...l.path];if(c.length===0){n.errors.push(t(l));continue}let u=n,d=0;for(;d<c.length;){let p=c[d],f=d===c.length-1;typeof p=="string"?(u.properties??(u.properties={}),(s=u.properties)[p]??(s[p]={errors:[]}),u=u.properties[p]):(u.items??(u.items=[]),(a=u.items)[p]??(a[p]={errors:[]}),u=u.items[p]),f&&u.errors.push(t(l)),d++}}};return i(e),n}function L1(e){let t=[],n=e.map(i=>typeof i=="object"?i.key:i);for(let i of n)typeof i=="number"?t.push(`[${i}]`):typeof i=="symbol"?t.push(`[${JSON.stringify(String(i))}]`):/[^\w$]/.test(i)?t.push(`[${JSON.stringify(i)}]`):(t.length&&t.push("."),t.push(i));return t.join("")}function mR(e){let t=[],n=[...e.issues].sort((i,r)=>(i.path??[]).length-(r.path??[]).length);for(let i of n)t.push(`\u2716 ${i.message}`),i.path?.length&&t.push(` \u2192 at ${L1(i.path)}`);return t.join(`
8
+ `)}var j1,Gp,pr,gR=v(()=>{Ml();Ae();j1=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Fl,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Gp=M("$ZodError",j1),pr=M("$ZodError",j1,{Parent:Error})});var Wl,ty,zl,ny,Ul,hR,Hl,yR,ry,Ene,iy,Ane,oy,Pne,sy,One,ay,Cne,cy,_ne,ly,Ine,uy,Tne,bR=v(()=>{Ml();gR();Ae();Wl=e=>(t,n,i,r)=>{let o=i?Object.assign(i,{async:!1}):{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new xi;if(s.issues.length){let a=new(r?.Err??e)(s.issues.map(l=>dr(l,o,Ht())));throw ey(a,r?.callee),a}return s.value},ty=Wl(pr),zl=e=>async(t,n,i,r)=>{let o=i?Object.assign(i,{async:!0}):{async:!0},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let a=new(r?.Err??e)(s.issues.map(l=>dr(l,o,Ht())));throw ey(a,r?.callee),a}return s.value},ny=zl(pr),Ul=e=>(t,n,i)=>{let r=i?{...i,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},r);if(o instanceof Promise)throw new xi;return o.issues.length?{success:!1,error:new(e??Gp)(o.issues.map(s=>dr(s,r,Ht())))}:{success:!0,data:o.value}},hR=Ul(pr),Hl=e=>async(t,n,i)=>{let r=i?Object.assign(i,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},r);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(s=>dr(s,r,Ht())))}:{success:!0,data:o.value}},yR=Hl(pr),ry=e=>(t,n,i)=>{let r=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return Wl(e)(t,n,r)},Ene=ry(pr),iy=e=>(t,n,i)=>Wl(e)(t,n,i),Ane=iy(pr),oy=e=>async(t,n,i)=>{let r=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return zl(e)(t,n,r)},Pne=oy(pr),sy=e=>async(t,n,i)=>zl(e)(t,n,i),One=sy(pr),ay=e=>(t,n,i)=>{let r=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return Ul(e)(t,n,r)},Cne=ay(pr),cy=e=>(t,n,i)=>Ul(e)(t,n,i),_ne=cy(pr),ly=e=>async(t,n,i)=>{let r=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return Hl(e)(t,n,r)},Ine=ly(pr),uy=e=>async(t,n,i)=>Hl(e)(t,n,i),Tne=uy(pr)});var qr={};_e(qr,{base64:()=>DR,base64url:()=>dy,bigint:()=>BR,boolean:()=>WR,browserEmail:()=>Gne,cidrv4:()=>IR,cidrv6:()=>TR,cuid:()=>wR,cuid2:()=>vR,date:()=>jR,datetime:()=>MR,domain:()=>Une,duration:()=>SR,e164:()=>NR,email:()=>AR,emoji:()=>PR,extendedDuration:()=>Dne,guid:()=>ER,hex:()=>Hne,hostname:()=>zne,html5Email:()=>Mne,idnEmail:()=>Bne,integer:()=>GR,ipv4:()=>OR,ipv6:()=>CR,ksuid:()=>$R,lowercase:()=>HR,mac:()=>_R,md5_base64:()=>qne,md5_base64url:()=>Kne,md5_hex:()=>Vne,nanoid:()=>RR,null:()=>zR,number:()=>py,rfc5322Email:()=>Fne,sha1_base64:()=>Zne,sha1_base64url:()=>Yne,sha1_hex:()=>Jne,sha256_base64:()=>Qne,sha256_base64url:()=>ere,sha256_hex:()=>Xne,sha384_base64:()=>nre,sha384_base64url:()=>rre,sha384_hex:()=>tre,sha512_base64:()=>ore,sha512_base64url:()=>sre,sha512_hex:()=>ire,string:()=>FR,time:()=>LR,ulid:()=>kR,undefined:()=>UR,unicodeEmail:()=>M1,uppercase:()=>VR,uuid:()=>uc,uuid4:()=>Nne,uuid6:()=>jne,uuid7:()=>Lne,xid:()=>xR});function PR(){return new RegExp(Wne,"u")}function B1(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function LR(e){return new RegExp(`^${B1(e)}$`)}function MR(e){let t=B1({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let i=`${t}(?:${n.join("|")})`;return new RegExp(`^${F1}T(?:${i})$`)}function Up(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function Hp(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var wR,vR,kR,xR,$R,RR,SR,Dne,ER,uc,Nne,jne,Lne,AR,Mne,Fne,M1,Bne,Gne,Wne,OR,CR,_R,IR,TR,DR,dy,zne,Une,NR,F1,jR,FR,BR,GR,py,WR,zR,UR,HR,VR,Hne,Vne,qne,Kne,Jne,Zne,Yne,Xne,Qne,ere,tre,nre,rre,ire,ore,sre,fy=v(()=>{Ae();wR=/^[cC][^\s-]{8,}$/,vR=/^[0-9a-z]+$/,kR=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,xR=/^[0-9a-vA-V]{20}$/,$R=/^[A-Za-z0-9]{27}$/,RR=/^[a-zA-Z0-9_-]{21}$/,SR=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Dne=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,ER=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,uc=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Nne=uc(4),jne=uc(6),Lne=uc(7),AR=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Mne=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,Fne=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,M1=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,Bne=M1,Gne=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,Wne="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";OR=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,CR=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,_R=e=>{let t=Vr(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},IR=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,TR=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,DR=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,dy=/^[A-Za-z0-9_-]*$/,zne=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,Une=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,NR=/^\+[1-9]\d{6,14}$/,F1="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",jR=new RegExp(`^${F1}$`);FR=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},BR=/^-?\d+n?$/,GR=/^-?\d+$/,py=/^-?\d+(?:\.\d+)?$/,WR=/^(?:true|false)$/i,zR=/^null$/i,UR=/^undefined$/i,HR=/^[^A-Z]*$/,VR=/^[^a-z]*$/,Hne=/^[0-9a-fA-F]*$/;Vne=/^[0-9a-fA-F]{32}$/,qne=Up(22,"=="),Kne=Hp(22),Jne=/^[0-9a-fA-F]{40}$/,Zne=Up(27,"="),Yne=Hp(27),Xne=/^[0-9a-fA-F]{64}$/,Qne=Up(43,"="),ere=Hp(43),tre=/^[0-9a-fA-F]{96}$/,nre=Up(64,""),rre=Hp(64),ire=/^[0-9a-fA-F]{128}$/,ore=Up(86,"=="),sre=Hp(86)});function G1(e,t,n){e.issues.length&&t.issues.push(..._r(n,e.issues))}var Et,W1,my,gy,qR,KR,JR,ZR,YR,XR,QR,eS,tS,Vl,nS,rS,iS,oS,sS,aS,cS,lS,uS,hy=v(()=>{Ml();fy();Ae();Et=M("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),W1={number:"number",bigint:"bigint",object:"date"},my=M("$ZodCheckLessThan",(e,t)=>{Et.init(e,t);let n=W1[typeof t.value];e._zod.onattach.push(i=>{let r=i._zod.bag,o=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<o&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=i=>{(t.inclusive?i.value<=t.value:i.value<t.value)||i.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),gy=M("$ZodCheckGreaterThan",(e,t)=>{Et.init(e,t);let n=W1[typeof t.value];e._zod.onattach.push(i=>{let r=i._zod.bag,o=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=i=>{(t.inclusive?i.value>=t.value:i.value>t.value)||i.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),qR=M("$ZodCheckMultipleOf",(e,t)=>{Et.init(e,t),e._zod.onattach.push(n=>{var i;(i=n._zod.bag).multipleOf??(i.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):oR(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),KR=M("$ZodCheckNumberFormat",(e,t)=>{Et.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),i=n?"int":"number",[r,o]=dR[t.format];e._zod.onattach.push(s=>{let a=s._zod.bag;a.format=t.format,a.minimum=r,a.maximum=o,n&&(a.pattern=GR)}),e._zod.check=s=>{let a=s.value;if(n){if(!Number.isInteger(a)){s.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});return}}a<r&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),a>o&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),JR=M("$ZodCheckBigIntFormat",(e,t)=>{Et.init(e,t);let[n,i]=pR[t.format];e._zod.onattach.push(r=>{let o=r._zod.bag;o.format=t.format,o.minimum=n,o.maximum=i}),e._zod.check=r=>{let o=r.value;o<n&&r.issues.push({origin:"bigint",input:o,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),o>i&&r.issues.push({origin:"bigint",input:o,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),ZR=M("$ZodCheckMaxSize",(e,t)=>{var n;Et.init(e,t),(n=e._zod.def).when??(n.when=i=>{let r=i.value;return!Bs(r)&&r.size!==void 0}),e._zod.onattach.push(i=>{let r=i._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(i._zod.bag.maximum=t.maximum)}),e._zod.check=i=>{let r=i.value;r.size<=t.maximum||i.issues.push({origin:Fp(r),code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),YR=M("$ZodCheckMinSize",(e,t)=>{var n;Et.init(e,t),(n=e._zod.def).when??(n.when=i=>{let r=i.value;return!Bs(r)&&r.size!==void 0}),e._zod.onattach.push(i=>{let r=i._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(i._zod.bag.minimum=t.minimum)}),e._zod.check=i=>{let r=i.value;r.size>=t.minimum||i.issues.push({origin:Fp(r),code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),XR=M("$ZodCheckSizeEquals",(e,t)=>{var n;Et.init(e,t),(n=e._zod.def).when??(n.when=i=>{let r=i.value;return!Bs(r)&&r.size!==void 0}),e._zod.onattach.push(i=>{let r=i._zod.bag;r.minimum=t.size,r.maximum=t.size,r.size=t.size}),e._zod.check=i=>{let r=i.value,o=r.size;if(o===t.size)return;let s=o>t.size;i.issues.push({origin:Fp(r),...s?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),QR=M("$ZodCheckMaxLength",(e,t)=>{var n;Et.init(e,t),(n=e._zod.def).when??(n.when=i=>{let r=i.value;return!Bs(r)&&r.length!==void 0}),e._zod.onattach.push(i=>{let r=i._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(i._zod.bag.maximum=t.maximum)}),e._zod.check=i=>{let r=i.value;if(r.length<=t.maximum)return;let s=Bp(r);i.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),eS=M("$ZodCheckMinLength",(e,t)=>{var n;Et.init(e,t),(n=e._zod.def).when??(n.when=i=>{let r=i.value;return!Bs(r)&&r.length!==void 0}),e._zod.onattach.push(i=>{let r=i._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(i._zod.bag.minimum=t.minimum)}),e._zod.check=i=>{let r=i.value;if(r.length>=t.minimum)return;let s=Bp(r);i.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),tS=M("$ZodCheckLengthEquals",(e,t)=>{var n;Et.init(e,t),(n=e._zod.def).when??(n.when=i=>{let r=i.value;return!Bs(r)&&r.length!==void 0}),e._zod.onattach.push(i=>{let r=i._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=i=>{let r=i.value,o=r.length;if(o===t.length)return;let s=Bp(r),a=o>t.length;i.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),Vl=M("$ZodCheckStringFormat",(e,t)=>{var n,i;Et.init(e,t),e._zod.onattach.push(r=>{let o=r._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(i=e._zod).check??(i.check=()=>{})}),nS=M("$ZodCheckRegex",(e,t)=>{Vl.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),rS=M("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=HR),Vl.init(e,t)}),iS=M("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=VR),Vl.init(e,t)}),oS=M("$ZodCheckIncludes",(e,t)=>{Et.init(e,t);let n=Vr(t.includes),i=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=i,e._zod.onattach.push(r=>{let o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(i)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),sS=M("$ZodCheckStartsWith",(e,t)=>{Et.init(e,t);let n=new RegExp(`^${Vr(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(i=>{let r=i._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=i=>{i.value.startsWith(t.prefix)||i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:i.value,inst:e,continue:!t.abort})}}),aS=M("$ZodCheckEndsWith",(e,t)=>{Et.init(e,t);let n=new RegExp(`.*${Vr(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(i=>{let r=i._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=i=>{i.value.endsWith(t.suffix)||i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:i.value,inst:e,continue:!t.abort})}});cS=M("$ZodCheckProperty",(e,t)=>{Et.init(e,t),e._zod.check=n=>{let i=t.schema._zod.run({value:n.value[t.property],issues:[]},{});if(i instanceof Promise)return i.then(r=>G1(r,n,t.property));G1(i,n,t.property)}}),lS=M("$ZodCheckMimeType",(e,t)=>{Et.init(e,t);let n=new Set(t.mime);e._zod.onattach.push(i=>{i._zod.bag.mime=t.mime}),e._zod.check=i=>{n.has(i.value.type)||i.issues.push({code:"invalid_value",values:t.mime,input:i.value.type,inst:e,continue:!t.abort})}}),uS=M("$ZodCheckOverwrite",(e,t)=>{Et.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}})});var Vp,dS=v(()=>{Vp=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let i=t.split(`
9
+ `).filter(s=>s),r=Math.min(...i.map(s=>s.length-s.trimStart().length)),o=i.map(s=>s.slice(r)).map(s=>" ".repeat(this.indent*2)+s);for(let s of o)this.content.push(s)}compile(){let t=Function,n=this?.args,r=[...(this?.content??[""]).map(o=>` ${o}`)];return new t(...n,r.join(`
10
+ `))}}});var pS,fS=v(()=>{pS={major:4,minor:3,patch:6}});function NS(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}function tF(e){if(!dy.test(e))return!1;let t=e.replace(/[-_]/g,i=>i==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return NS(n)}function nF(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[i]=n;if(!i)return!1;let r=JSON.parse(atob(i));return!("typ"in r&&r?.typ!=="JWT"||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}}function U1(e,t,n){e.issues.length&&t.issues.push(..._r(n,e.issues)),t.value[n]=e.value}function ky(e,t,n,i,r){if(e.issues.length){if(r&&!(n in i))return;t.issues.push(..._r(n,e.issues))}e.value===void 0?n in i&&(t.value[n]=void 0):t.value[n]=e.value}function rF(e){let t=Object.keys(e.shape);for(let i of t)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${i}": expected a Zod schema`);let n=uR(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function iF(e,t,n,i,r,o){let s=[],a=r.keySet,l=r.catchall._zod,c=l.def.type,u=l.optout==="optional";for(let d in t){if(a.has(d))continue;if(c==="never"){s.push(d);continue}let p=l.run({value:t[d],issues:[]},i);p instanceof Promise?e.push(p.then(f=>ky(f,n,d,t,u))):ky(p,n,d,t,u)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:o}),e.length?Promise.all(e).then(()=>n):n}function H1(e,t,n,i){for(let o of e)if(o.issues.length===0)return t.value=o.value,t;let r=e.filter(o=>!zs(o));return r.length===1?(t.value=r[0].value,r[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(s=>dr(s,i,Ht())))}),t)}function V1(e,t,n,i){let r=e.filter(o=>o.issues.length===0);return r.length===1?(t.value=r[0].value,t):(r.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(s=>dr(s,i,Ht())))}):t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:[],inclusive:!1}),t)}function mS(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Ws(e)&&Ws(t)){let n=Object.keys(t),i=Object.keys(e).filter(o=>n.indexOf(o)!==-1),r={...e,...t};for(let o of i){let s=mS(e[o],t[o]);if(!s.valid)return{valid:!1,mergeErrorPath:[o,...s.mergeErrorPath]};r[o]=s.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let i=0;i<e.length;i++){let r=e[i],o=t[i],s=mS(r,o);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function q1(e,t,n){let i=new Map,r;for(let a of t.issues)if(a.code==="unrecognized_keys"){r??(r=a);for(let l of a.keys)i.has(l)||i.set(l,{}),i.get(l).l=!0}else e.issues.push(a);for(let a of n.issues)if(a.code==="unrecognized_keys")for(let l of a.keys)i.has(l)||i.set(l,{}),i.get(l).r=!0;else e.issues.push(a);let o=[...i].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(o.length&&r&&e.issues.push({...r,keys:o}),zs(e))return e;let s=mS(t.value,n.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}function yy(e,t,n){e.issues.length&&t.issues.push(..._r(n,e.issues)),t.value[n]=e.value}function K1(e,t,n,i,r,o,s){e.issues.length&&(Mp.has(typeof i)?n.issues.push(..._r(i,e.issues)):n.issues.push({code:"invalid_key",origin:"map",input:r,inst:o,issues:e.issues.map(a=>dr(a,s,Ht()))})),t.issues.length&&(Mp.has(typeof i)?n.issues.push(..._r(i,t.issues)):n.issues.push({origin:"map",code:"invalid_element",input:r,inst:o,key:i,issues:t.issues.map(a=>dr(a,s,Ht()))})),n.value.set(e.value,t.value)}function J1(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}function Z1(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}function Y1(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}function X1(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function by(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}function wy(e,t,n){if(e.issues.length)return e.aborted=!0,e;if((n.direction||"forward")==="forward"){let r=t.transform(e.value,e);return r instanceof Promise?r.then(o=>vy(e,o,t.out,n)):vy(e,r,t.out,n)}else{let r=t.reverseTransform(e.value,e);return r instanceof Promise?r.then(o=>vy(e,o,t.in,n)):vy(e,r,t.in,n)}}function vy(e,t,n,i){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},i)}function Q1(e){return e.value=Object.freeze(e.value),e}function eF(e,t,n,i){if(!e){let r={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(r.params=i._zod.def.params),t.issues.push(Gl(r))}}var Ne,dc,vt,gS,hS,yS,bS,wS,vS,kS,xS,$S,RS,SS,ES,AS,PS,OS,CS,_S,IS,TS,DS,jS,LS,MS,FS,BS,xy,GS,qp,$y,WS,zS,US,HS,VS,qS,KS,JS,ZS,YS,oF,XS,Kp,QS,eE,tE,Ry,nE,rE,iE,oE,sE,aE,cE,Sy,lE,uE,dE,pE,fE,mE,gE,hE,yE,Jp,bE,wE,vE,kE,xE,$E,RE=v(()=>{hy();Ml();dS();bR();fy();Ae();fS();Ae();Ne=M("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=pS;let i=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&i.unshift(e);for(let r of i)for(let o of r._zod.onattach)o(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let r=(s,a,l)=>{let c=zs(s),u;for(let d of a){if(d._zod.def.when){if(!d._zod.def.when(s))continue}else if(c)continue;let p=s.issues.length,f=d._zod.check(s);if(f instanceof Promise&&l?.async===!1)throw new xi;if(u||f instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await f,s.issues.length!==p&&(c||(c=zs(s,p)))});else{if(s.issues.length===p)continue;c||(c=zs(s,p))}}return u?u.then(()=>s):s},o=(s,a,l)=>{if(zs(s))return s.aborted=!0,s;let c=r(a,i,l);if(c instanceof Promise){if(l.async===!1)throw new xi;return c.then(u=>e._zod.parse(u,l))}return e._zod.parse(c,l)};e._zod.run=(s,a)=>{if(a.skipChecks)return e._zod.parse(s,a);if(a.direction==="backward"){let c=e._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});return c instanceof Promise?c.then(u=>o(u,s,a)):o(c,s,a)}let l=e._zod.parse(s,a);if(l instanceof Promise){if(a.async===!1)throw new xi;return l.then(c=>r(c,i,a))}return r(l,i,a)}}He(e,"~standard",()=>({validate:r=>{try{let o=hR(e,r);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return yR(e,r).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),dc=M("$ZodString",(e,t)=>{Ne.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??FR(e._zod.bag),e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),vt=M("$ZodStringFormat",(e,t)=>{Vl.init(e,t),dc.init(e,t)}),gS=M("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=ER),vt.init(e,t)}),hS=M("$ZodUUID",(e,t)=>{if(t.version){let i={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(i===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=uc(i))}else t.pattern??(t.pattern=uc());vt.init(e,t)}),yS=M("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=AR),vt.init(e,t)}),bS=M("$ZodURL",(e,t)=>{vt.init(e,t),e._zod.check=n=>{try{let i=n.value.trim(),r=new URL(i);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(r.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=r.href:n.value=i;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),wS=M("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=PR()),vt.init(e,t)}),vS=M("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=RR),vt.init(e,t)}),kS=M("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=wR),vt.init(e,t)}),xS=M("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=vR),vt.init(e,t)}),$S=M("$ZodULID",(e,t)=>{t.pattern??(t.pattern=kR),vt.init(e,t)}),RS=M("$ZodXID",(e,t)=>{t.pattern??(t.pattern=xR),vt.init(e,t)}),SS=M("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=$R),vt.init(e,t)}),ES=M("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=MR(t)),vt.init(e,t)}),AS=M("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=jR),vt.init(e,t)}),PS=M("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=LR(t)),vt.init(e,t)}),OS=M("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=SR),vt.init(e,t)}),CS=M("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=OR),vt.init(e,t),e._zod.bag.format="ipv4"}),_S=M("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=CR),vt.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),IS=M("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=_R(t.delimiter)),vt.init(e,t),e._zod.bag.format="mac"}),TS=M("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=IR),vt.init(e,t)}),DS=M("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=TR),vt.init(e,t),e._zod.check=n=>{let i=n.value.split("/");try{if(i.length!==2)throw new Error;let[r,o]=i;if(!o)throw new Error;let s=Number(o);if(`${s}`!==o)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${r}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});jS=M("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=DR),vt.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{NS(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});LS=M("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=dy),vt.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{tF(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),MS=M("$ZodE164",(e,t)=>{t.pattern??(t.pattern=NR),vt.init(e,t)});FS=M("$ZodJWT",(e,t)=>{vt.init(e,t),e._zod.check=n=>{nF(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),BS=M("$ZodCustomStringFormat",(e,t)=>{vt.init(e,t),e._zod.check=n=>{t.fn(n.value)||n.issues.push({code:"invalid_format",format:t.format,input:n.value,inst:e,continue:!t.abort})}}),xy=M("$ZodNumber",(e,t)=>{Ne.init(e,t),e._zod.pattern=e._zod.bag.pattern??py,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let r=n.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;let o=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...o?{received:o}:{}}),n}}),GS=M("$ZodNumberFormat",(e,t)=>{KR.init(e,t),xy.init(e,t)}),qp=M("$ZodBoolean",(e,t)=>{Ne.init(e,t),e._zod.pattern=WR,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=!!n.value}catch{}let r=n.value;return typeof r=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}}),$y=M("$ZodBigInt",(e,t)=>{Ne.init(e,t),e._zod.pattern=BR,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch{}return typeof n.value=="bigint"||n.issues.push({expected:"bigint",code:"invalid_type",input:n.value,inst:e}),n}}),WS=M("$ZodBigIntFormat",(e,t)=>{JR.init(e,t),$y.init(e,t)}),zS=M("$ZodSymbol",(e,t)=>{Ne.init(e,t),e._zod.parse=(n,i)=>{let r=n.value;return typeof r=="symbol"||n.issues.push({expected:"symbol",code:"invalid_type",input:r,inst:e}),n}}),US=M("$ZodUndefined",(e,t)=>{Ne.init(e,t),e._zod.pattern=UR,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(n,i)=>{let r=n.value;return typeof r>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:r,inst:e}),n}}),HS=M("$ZodNull",(e,t)=>{Ne.init(e,t),e._zod.pattern=zR,e._zod.values=new Set([null]),e._zod.parse=(n,i)=>{let r=n.value;return r===null||n.issues.push({expected:"null",code:"invalid_type",input:r,inst:e}),n}}),VS=M("$ZodAny",(e,t)=>{Ne.init(e,t),e._zod.parse=n=>n}),qS=M("$ZodUnknown",(e,t)=>{Ne.init(e,t),e._zod.parse=n=>n}),KS=M("$ZodNever",(e,t)=>{Ne.init(e,t),e._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)}),JS=M("$ZodVoid",(e,t)=>{Ne.init(e,t),e._zod.parse=(n,i)=>{let r=n.value;return typeof r>"u"||n.issues.push({expected:"void",code:"invalid_type",input:r,inst:e}),n}}),ZS=M("$ZodDate",(e,t)=>{Ne.init(e,t),e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=new Date(n.value)}catch{}let r=n.value,o=r instanceof Date;return o&&!Number.isNaN(r.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:r,...o?{received:"Invalid Date"}:{},inst:e}),n}});YS=M("$ZodArray",(e,t)=>{Ne.init(e,t),e._zod.parse=(n,i)=>{let r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),n;n.value=Array(r.length);let o=[];for(let s=0;s<r.length;s++){let a=r[s],l=t.element._zod.run({value:a,issues:[]},i);l instanceof Promise?o.push(l.then(c=>U1(c,n,s))):U1(l,n,s)}return o.length?Promise.all(o).then(()=>n):n}});oF=M("$ZodObject",(e,t)=>{if(Ne.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let a=t.shape;Object.defineProperty(t,"shape",{get:()=>{let l={...a};return Object.defineProperty(t,"shape",{value:l}),l}})}let i=Bl(()=>rF(t));He(e._zod,"propValues",()=>{let a=t.shape,l={};for(let c in a){let u=a[c]._zod;if(u.values){l[c]??(l[c]=new Set);for(let d of u.values)l[c].add(d)}}return l});let r=lc,o=t.catchall,s;e._zod.parse=(a,l)=>{s??(s=i.value);let c=a.value;if(!r(c))return a.issues.push({expected:"object",code:"invalid_type",input:c,inst:e}),a;a.value={};let u=[],d=s.shape;for(let p of s.keys){let f=d[p],g=f._zod.optout==="optional",h=f._zod.run({value:c[p],issues:[]},l);h instanceof Promise?u.push(h.then(b=>ky(b,a,p,c,g))):ky(h,a,p,c,g)}return o?iF(u,c,a,l,i.value,e):u.length?Promise.all(u).then(()=>a):a}}),XS=M("$ZodObjectJIT",(e,t)=>{oF.init(e,t);let n=e._zod.parse,i=Bl(()=>rF(t)),r=p=>{let f=new Vp(["shape","payload","ctx"]),g=i.value,h=k=>{let R=Qh(k);return`shape[${R}]._zod.run({ value: input[${R}], issues: [] }, ctx)`};f.write("const input = payload.value;");let b=Object.create(null),w=0;for(let k of g.keys)b[k]=`key_${w++}`;f.write("const newResult = {};");for(let k of g.keys){let R=b[k],$=Qh(k),T=p[k]?._zod?.optout==="optional";f.write(`const ${R} = ${h(k)};`),T?f.write(`
11
+ if (${R}.issues.length) {
12
+ if (${$} in input) {
13
+ payload.issues = payload.issues.concat(${R}.issues.map(iss => ({
14
+ ...iss,
15
+ path: iss.path ? [${$}, ...iss.path] : [${$}]
16
+ })));
17
+ }
18
+ }
19
+
20
+ if (${R}.value === undefined) {
21
+ if (${$} in input) {
22
+ newResult[${$}] = undefined;
23
+ }
24
+ } else {
25
+ newResult[${$}] = ${R}.value;
26
+ }
27
+
28
+ `):f.write(`
29
+ if (${R}.issues.length) {
30
+ payload.issues = payload.issues.concat(${R}.issues.map(iss => ({
31
+ ...iss,
32
+ path: iss.path ? [${$}, ...iss.path] : [${$}]
33
+ })));
34
+ }
35
+
36
+ if (${R}.value === undefined) {
37
+ if (${$} in input) {
38
+ newResult[${$}] = undefined;
39
+ }
40
+ } else {
41
+ newResult[${$}] = ${R}.value;
42
+ }
43
+
44
+ `)}f.write("payload.value = newResult;"),f.write("return payload;");let x=f.compile();return(k,R)=>x(p,k,R)},o,s=lc,a=!Dp.jitless,c=a&&aR.value,u=t.catchall,d;e._zod.parse=(p,f)=>{d??(d=i.value);let g=p.value;return s(g)?a&&c&&f?.async===!1&&f.jitless!==!0?(o||(o=r(t.shape)),p=o(p,f),u?iF([],g,p,f,d,e):p):n(p,f):(p.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),p)}});Kp=M("$ZodUnion",(e,t)=>{Ne.init(e,t),He(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),He(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),He(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),He(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){let r=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${r.map(o=>Lp(o.source)).join("|")})$`)}});let n=t.options.length===1,i=t.options[0]._zod.run;e._zod.parse=(r,o)=>{if(n)return i(r,o);let s=!1,a=[];for(let l of t.options){let c=l._zod.run({value:r.value,issues:[]},o);if(c instanceof Promise)a.push(c),s=!0;else{if(c.issues.length===0)return c;a.push(c)}}return s?Promise.all(a).then(l=>H1(l,r,e,o)):H1(a,r,e,o)}});QS=M("$ZodXor",(e,t)=>{Kp.init(e,t),t.inclusive=!1;let n=t.options.length===1,i=t.options[0]._zod.run;e._zod.parse=(r,o)=>{if(n)return i(r,o);let s=!1,a=[];for(let l of t.options){let c=l._zod.run({value:r.value,issues:[]},o);c instanceof Promise?(a.push(c),s=!0):a.push(c)}return s?Promise.all(a).then(l=>V1(l,r,e,o)):V1(a,r,e,o)}}),eE=M("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Kp.init(e,t);let n=e._zod.parse;He(e._zod,"propValues",()=>{let r={};for(let o of t.options){let s=o._zod.propValues;if(!s||Object.keys(s).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(let[a,l]of Object.entries(s)){r[a]||(r[a]=new Set);for(let c of l)r[a].add(c)}}return r});let i=Bl(()=>{let r=t.options,o=new Map;for(let s of r){let a=s._zod.propValues?.[t.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let l of a){if(o.has(l))throw new Error(`Duplicate discriminator value "${String(l)}"`);o.set(l,s)}}return o});e._zod.parse=(r,o)=>{let s=r.value;if(!lc(s))return r.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),r;let a=i.value.get(s?.[t.discriminator]);return a?a._zod.run(r,o):t.unionFallback?n(r,o):(r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:s,path:[t.discriminator],inst:e}),r)}}),tE=M("$ZodIntersection",(e,t)=>{Ne.init(e,t),e._zod.parse=(n,i)=>{let r=n.value,o=t.left._zod.run({value:r,issues:[]},i),s=t.right._zod.run({value:r,issues:[]},i);return o instanceof Promise||s instanceof Promise?Promise.all([o,s]).then(([l,c])=>q1(n,l,c)):q1(n,o,s)}});Ry=M("$ZodTuple",(e,t)=>{Ne.init(e,t);let n=t.items;e._zod.parse=(i,r)=>{let o=i.value;if(!Array.isArray(o))return i.issues.push({input:o,inst:e,expected:"tuple",code:"invalid_type"}),i;i.value=[];let s=[],a=[...n].reverse().findIndex(u=>u._zod.optin!=="optional"),l=a===-1?0:n.length-a;if(!t.rest){let u=o.length>n.length,d=o.length<l-1;if(u||d)return i.issues.push({...u?{code:"too_big",maximum:n.length,inclusive:!0}:{code:"too_small",minimum:n.length},input:o,inst:e,origin:"array"}),i}let c=-1;for(let u of n){if(c++,c>=o.length&&c>=l)continue;let d=u._zod.run({value:o[c],issues:[]},r);d instanceof Promise?s.push(d.then(p=>yy(p,i,c))):yy(d,i,c)}if(t.rest){let u=o.slice(n.length);for(let d of u){c++;let p=t.rest._zod.run({value:d,issues:[]},r);p instanceof Promise?s.push(p.then(f=>yy(f,i,c))):yy(p,i,c)}}return s.length?Promise.all(s).then(()=>i):i}});nE=M("$ZodRecord",(e,t)=>{Ne.init(e,t),e._zod.parse=(n,i)=>{let r=n.value;if(!Ws(r))return n.issues.push({expected:"record",code:"invalid_type",input:r,inst:e}),n;let o=[],s=t.keyType._zod.values;if(s){n.value={};let a=new Set;for(let c of s)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){a.add(typeof c=="number"?c.toString():c);let u=t.valueType._zod.run({value:r[c],issues:[]},i);u instanceof Promise?o.push(u.then(d=>{d.issues.length&&n.issues.push(..._r(c,d.issues)),n.value[c]=d.value})):(u.issues.length&&n.issues.push(..._r(c,u.issues)),n.value[c]=u.value)}let l;for(let c in r)a.has(c)||(l=l??[],l.push(c));l&&l.length>0&&n.issues.push({code:"unrecognized_keys",input:r,inst:e,keys:l})}else{n.value={};for(let a of Reflect.ownKeys(r)){if(a==="__proto__")continue;let l=t.keyType._zod.run({value:a,issues:[]},i);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&py.test(a)&&l.issues.length){let d=t.keyType._zod.run({value:Number(a),issues:[]},i);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");d.issues.length===0&&(l=d)}if(l.issues.length){t.mode==="loose"?n.value[a]=r[a]:n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(d=>dr(d,i,Ht())),input:a,path:[a],inst:e});continue}let u=t.valueType._zod.run({value:r[a],issues:[]},i);u instanceof Promise?o.push(u.then(d=>{d.issues.length&&n.issues.push(..._r(a,d.issues)),n.value[l.value]=d.value})):(u.issues.length&&n.issues.push(..._r(a,u.issues)),n.value[l.value]=u.value)}}return o.length?Promise.all(o).then(()=>n):n}}),rE=M("$ZodMap",(e,t)=>{Ne.init(e,t),e._zod.parse=(n,i)=>{let r=n.value;if(!(r instanceof Map))return n.issues.push({expected:"map",code:"invalid_type",input:r,inst:e}),n;let o=[];n.value=new Map;for(let[s,a]of r){let l=t.keyType._zod.run({value:s,issues:[]},i),c=t.valueType._zod.run({value:a,issues:[]},i);l instanceof Promise||c instanceof Promise?o.push(Promise.all([l,c]).then(([u,d])=>{K1(u,d,n,s,r,e,i)})):K1(l,c,n,s,r,e,i)}return o.length?Promise.all(o).then(()=>n):n}});iE=M("$ZodSet",(e,t)=>{Ne.init(e,t),e._zod.parse=(n,i)=>{let r=n.value;if(!(r instanceof Set))return n.issues.push({input:r,inst:e,expected:"set",code:"invalid_type"}),n;let o=[];n.value=new Set;for(let s of r){let a=t.valueType._zod.run({value:s,issues:[]},i);a instanceof Promise?o.push(a.then(l=>J1(l,n))):J1(a,n)}return o.length?Promise.all(o).then(()=>n):n}});oE=M("$ZodEnum",(e,t)=>{Ne.init(e,t);let n=jp(t.entries),i=new Set(n);e._zod.values=i,e._zod.pattern=new RegExp(`^(${n.filter(r=>Mp.has(typeof r)).map(r=>typeof r=="string"?Vr(r):r.toString()).join("|")})$`),e._zod.parse=(r,o)=>{let s=r.value;return i.has(s)||r.issues.push({code:"invalid_value",values:n,input:s,inst:e}),r}}),sE=M("$ZodLiteral",(e,t)=>{if(Ne.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");let n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(i=>typeof i=="string"?Vr(i):i?Vr(i.toString()):String(i)).join("|")})$`),e._zod.parse=(i,r)=>{let o=i.value;return n.has(o)||i.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),i}}),aE=M("$ZodFile",(e,t)=>{Ne.init(e,t),e._zod.parse=(n,i)=>{let r=n.value;return r instanceof File||n.issues.push({expected:"file",code:"invalid_type",input:r,inst:e}),n}}),cE=M("$ZodTransform",(e,t)=>{Ne.init(e,t),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new Fs(e.constructor.name);let r=t.transform(n.value,n);if(i.async)return(r instanceof Promise?r:Promise.resolve(r)).then(s=>(n.value=s,n));if(r instanceof Promise)throw new xi;return n.value=r,n}});Sy=M("$ZodOptional",(e,t)=>{Ne.init(e,t),e._zod.optin="optional",e._zod.optout="optional",He(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),He(e._zod,"pattern",()=>{let n=t.innerType._zod.pattern;return n?new RegExp(`^(${Lp(n.source)})?$`):void 0}),e._zod.parse=(n,i)=>{if(t.innerType._zod.optin==="optional"){let r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(o=>Z1(o,n.value)):Z1(r,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,i)}}),lE=M("$ZodExactOptional",(e,t)=>{Sy.init(e,t),He(e._zod,"values",()=>t.innerType._zod.values),He(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,i)=>t.innerType._zod.run(n,i)}),uE=M("$ZodNullable",(e,t)=>{Ne.init(e,t),He(e._zod,"optin",()=>t.innerType._zod.optin),He(e._zod,"optout",()=>t.innerType._zod.optout),He(e._zod,"pattern",()=>{let n=t.innerType._zod.pattern;return n?new RegExp(`^(${Lp(n.source)}|null)$`):void 0}),He(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,i)=>n.value===null?n:t.innerType._zod.run(n,i)}),dE=M("$ZodDefault",(e,t)=>{Ne.init(e,t),e._zod.optin="optional",He(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)return n.value=t.defaultValue,n;let r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(o=>Y1(o,t)):Y1(r,t)}});pE=M("$ZodPrefault",(e,t)=>{Ne.init(e,t),e._zod.optin="optional",He(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,i)=>(i.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,i))}),fE=M("$ZodNonOptional",(e,t)=>{Ne.init(e,t),He(e._zod,"values",()=>{let n=t.innerType._zod.values;return n?new Set([...n].filter(i=>i!==void 0)):void 0}),e._zod.parse=(n,i)=>{let r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(o=>X1(o,e)):X1(r,e)}});mE=M("$ZodSuccess",(e,t)=>{Ne.init(e,t),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new Fs("ZodSuccess");let r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(o=>(n.value=o.issues.length===0,n)):(n.value=r.issues.length===0,n)}}),gE=M("$ZodCatch",(e,t)=>{Ne.init(e,t),He(e._zod,"optin",()=>t.innerType._zod.optin),He(e._zod,"optout",()=>t.innerType._zod.optout),He(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(o=>(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(s=>dr(s,i,Ht()))},input:n.value}),n.issues=[]),n)):(n.value=r.value,r.issues.length&&(n.value=t.catchValue({...n,error:{issues:r.issues.map(o=>dr(o,i,Ht()))},input:n.value}),n.issues=[]),n)}}),hE=M("$ZodNaN",(e,t)=>{Ne.init(e,t),e._zod.parse=(n,i)=>((typeof n.value!="number"||!Number.isNaN(n.value))&&n.issues.push({input:n.value,inst:e,expected:"nan",code:"invalid_type"}),n)}),yE=M("$ZodPipe",(e,t)=>{Ne.init(e,t),He(e._zod,"values",()=>t.in._zod.values),He(e._zod,"optin",()=>t.in._zod.optin),He(e._zod,"optout",()=>t.out._zod.optout),He(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,i)=>{if(i.direction==="backward"){let o=t.out._zod.run(n,i);return o instanceof Promise?o.then(s=>by(s,t.in,i)):by(o,t.in,i)}let r=t.in._zod.run(n,i);return r instanceof Promise?r.then(o=>by(o,t.out,i)):by(r,t.out,i)}});Jp=M("$ZodCodec",(e,t)=>{Ne.init(e,t),He(e._zod,"values",()=>t.in._zod.values),He(e._zod,"optin",()=>t.in._zod.optin),He(e._zod,"optout",()=>t.out._zod.optout),He(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,i)=>{if((i.direction||"forward")==="forward"){let o=t.in._zod.run(n,i);return o instanceof Promise?o.then(s=>wy(s,t,i)):wy(o,t,i)}else{let o=t.out._zod.run(n,i);return o instanceof Promise?o.then(s=>wy(s,t,i)):wy(o,t,i)}}});bE=M("$ZodReadonly",(e,t)=>{Ne.init(e,t),He(e._zod,"propValues",()=>t.innerType._zod.propValues),He(e._zod,"values",()=>t.innerType._zod.values),He(e._zod,"optin",()=>t.innerType?._zod?.optin),He(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(Q1):Q1(r)}});wE=M("$ZodTemplateLiteral",(e,t)=>{Ne.init(e,t);let n=[];for(let i of t.parts)if(typeof i=="object"&&i!==null){if(!i._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...i._zod.traits].shift()}`);let r=i._zod.pattern instanceof RegExp?i._zod.pattern.source:i._zod.pattern;if(!r)throw new Error(`Invalid template literal part: ${i._zod.traits}`);let o=r.startsWith("^")?1:0,s=r.endsWith("$")?r.length-1:r.length;n.push(r.slice(o,s))}else if(i===null||lR.has(typeof i))n.push(Vr(`${i}`));else throw new Error(`Invalid template literal part: ${i}`);e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(i,r)=>typeof i.value!="string"?(i.issues.push({input:i.value,inst:e,expected:"string",code:"invalid_type"}),i):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(i.value)||i.issues.push({input:i.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),i)}),vE=M("$ZodFunction",(e,t)=>(Ne.init(e,t),e._def=t,e._zod.def=t,e.implement=n=>{if(typeof n!="function")throw new Error("implement() must be called with a function");return function(...i){let r=e._def.input?ty(e._def.input,i):i,o=Reflect.apply(n,this,r);return e._def.output?ty(e._def.output,o):o}},e.implementAsync=n=>{if(typeof n!="function")throw new Error("implementAsync() must be called with a function");return async function(...i){let r=e._def.input?await ny(e._def.input,i):i,o=await Reflect.apply(n,this,r);return e._def.output?await ny(e._def.output,o):o}},e._zod.parse=(n,i)=>typeof n.value!="function"?(n.issues.push({code:"invalid_type",expected:"function",input:n.value,inst:e}),n):(e._def.output&&e._def.output._zod.def.type==="promise"?n.value=e.implementAsync(n.value):n.value=e.implement(n.value),n),e.input=(...n)=>{let i=e.constructor;return Array.isArray(n[0])?new i({type:"function",input:new Ry({type:"tuple",items:n[0],rest:n[1]}),output:e._def.output}):new i({type:"function",input:n[0],output:e._def.output})},e.output=n=>{let i=e.constructor;return new i({type:"function",input:e._def.input,output:n})},e)),kE=M("$ZodPromise",(e,t)=>{Ne.init(e,t),e._zod.parse=(n,i)=>Promise.resolve(n.value).then(r=>t.innerType._zod.run({value:r,issues:[]},i))}),xE=M("$ZodLazy",(e,t)=>{Ne.init(e,t),He(e._zod,"innerType",()=>t.getter()),He(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),He(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),He(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),He(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(n,i)=>e._zod.innerType._zod.run(n,i)}),$E=M("$ZodCustom",(e,t)=>{Et.init(e,t),Ne.init(e,t),e._zod.parse=(n,i)=>n,e._zod.check=n=>{let i=n.value,r=t.fn(i);if(r instanceof Promise)return r.then(o=>eF(o,n,i,e));eF(r,n,i,e)}})});function sF(){return{localeError:cre()}}var cre,aF=v(()=>{Ae();cre=()=>{let e={string:{unit:"\u062D\u0631\u0641",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},file:{unit:"\u0628\u0627\u064A\u062A",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},array:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},set:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"}};function t(r){return e[r]??null}let n={regex:"\u0645\u062F\u062E\u0644",email:"\u0628\u0631\u064A\u062F \u0625\u0644\u0643\u062A\u0631\u0648\u0646\u064A",url:"\u0631\u0627\u0628\u0637",emoji:"\u0625\u064A\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u064A\u062E \u0648\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",date:"\u062A\u0627\u0631\u064A\u062E \u0628\u0645\u0639\u064A\u0627\u0631 ISO",time:"\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",duration:"\u0645\u062F\u0629 \u0628\u0645\u0639\u064A\u0627\u0631 ISO",ipv4:"\u0639\u0646\u0648\u0627\u0646 IPv4",ipv6:"\u0639\u0646\u0648\u0627\u0646 IPv6",cidrv4:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv4",cidrv6:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv6",base64:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64-encoded",base64url:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64url-encoded",json_string:"\u0646\u064E\u0635 \u0639\u0644\u0649 \u0647\u064A\u0626\u0629 JSON",e164:"\u0631\u0642\u0645 \u0647\u0627\u062A\u0641 \u0628\u0645\u0639\u064A\u0627\u0631 E.164",jwt:"JWT",template_literal:"\u0645\u062F\u062E\u0644"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 instanceof ${r.expected}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${a}`:`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${o}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${a}`}case"invalid_value":return r.values.length===1?`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${se(r.values[0])}`:`\u0627\u062E\u062A\u064A\u0627\u0631 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062A\u0648\u0642\u0639 \u0627\u0646\u062A\u0642\u0627\u0621 \u0623\u062D\u062F \u0647\u0630\u0647 \u0627\u0644\u062E\u064A\u0627\u0631\u0627\u062A: ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?` \u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${r.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${o} ${r.maximum.toString()} ${s.unit??"\u0639\u0646\u0635\u0631"}`:`\u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${r.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${o} ${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${r.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${o} ${r.minimum.toString()} ${s.unit}`:`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${r.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${o} ${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0628\u062F\u0623 \u0628\u0640 "${r.prefix}"`:o.format==="ends_with"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0646\u062A\u0647\u064A \u0628\u0640 "${o.suffix}"`:o.format==="includes"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u062A\u0636\u0645\u0651\u064E\u0646 "${o.includes}"`:o.format==="regex"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0637\u0627\u0628\u0642 \u0627\u0644\u0646\u0645\u0637 ${o.pattern}`:`${n[o.format]??r.format} \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644`}case"not_multiple_of":return`\u0631\u0642\u0645 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0645\u0646 \u0645\u0636\u0627\u0639\u0641\u0627\u062A ${r.divisor}`;case"unrecognized_keys":return`\u0645\u0639\u0631\u0641${r.keys.length>1?"\u0627\u062A":""} \u063A\u0631\u064A\u0628${r.keys.length>1?"\u0629":""}: ${V(r.keys,"\u060C ")}`;case"invalid_key":return`\u0645\u0639\u0631\u0641 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${r.origin}`;case"invalid_union":return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644";case"invalid_element":return`\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${r.origin}`;default:return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644"}}}});function cF(){return{localeError:lre()}}var lre,lF=v(()=>{Ae();lre=()=>{let e={string:{unit:"simvol",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"element",verb:"olmal\u0131d\u0131r"},set:{unit:"element",verb:"olmal\u0131d\u0131r"}};function t(r){return e[r]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n instanceof ${r.expected}, daxil olan ${a}`:`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${o}, daxil olan ${a}`}case"invalid_value":return r.values.length===1?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${se(r.values[0])}`:`Yanl\u0131\u015F se\xE7im: a\u015Fa\u011F\u0131dak\u0131lardan biri olmal\u0131d\u0131r: ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${r.origin??"d\u0259y\u0259r"} ${o}${r.maximum.toString()} ${s.unit??"element"}`:`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${r.origin??"d\u0259y\u0259r"} ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${r.origin} ${o}${r.minimum.toString()} ${s.unit}`:`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${r.origin} ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Yanl\u0131\u015F m\u0259tn: "${o.prefix}" il\u0259 ba\u015Flamal\u0131d\u0131r`:o.format==="ends_with"?`Yanl\u0131\u015F m\u0259tn: "${o.suffix}" il\u0259 bitm\u0259lidir`:o.format==="includes"?`Yanl\u0131\u015F m\u0259tn: "${o.includes}" daxil olmal\u0131d\u0131r`:o.format==="regex"?`Yanl\u0131\u015F m\u0259tn: ${o.pattern} \u015Fablonuna uy\u011Fun olmal\u0131d\u0131r`:`Yanl\u0131\u015F ${n[o.format]??r.format}`}case"not_multiple_of":return`Yanl\u0131\u015F \u0259d\u0259d: ${r.divisor} il\u0259 b\xF6l\xFCn\u0259 bil\u0259n olmal\u0131d\u0131r`;case"unrecognized_keys":return`Tan\u0131nmayan a\xE7ar${r.keys.length>1?"lar":""}: ${V(r.keys,", ")}`;case"invalid_key":return`${r.origin} daxilind\u0259 yanl\u0131\u015F a\xE7ar`;case"invalid_union":return"Yanl\u0131\u015F d\u0259y\u0259r";case"invalid_element":return`${r.origin} daxilind\u0259 yanl\u0131\u015F d\u0259y\u0259r`;default:return"Yanl\u0131\u015F d\u0259y\u0259r"}}}});function uF(e,t,n,i){let r=Math.abs(e),o=r%10,s=r%100;return s>=11&&s<=19?i:o===1?t:o>=2&&o<=4?n:i}function dF(){return{localeError:ure()}}var ure,pF=v(()=>{Ae();ure=()=>{let e={string:{unit:{one:"\u0441\u0456\u043C\u0432\u0430\u043B",few:"\u0441\u0456\u043C\u0432\u0430\u043B\u044B",many:"\u0441\u0456\u043C\u0432\u0430\u043B\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u044B",many:"\u0431\u0430\u0439\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"}};function t(r){return e[r]??null}let n={regex:"\u0443\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0430\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0456 \u0447\u0430\u0441",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0447\u0430\u0441",duration:"ISO \u043F\u0440\u0430\u0446\u044F\u0433\u043B\u0430\u0441\u0446\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0430\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0430\u0441",cidrv4:"IPv4 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",base64:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64",base64url:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64url",json_string:"JSON \u0440\u0430\u0434\u043E\u043A",e164:"\u043D\u0443\u043C\u0430\u0440 E.164",jwt:"JWT",template_literal:"\u0443\u0432\u043E\u0434"},i={nan:"NaN",number:"\u043B\u0456\u043A",array:"\u043C\u0430\u0441\u0456\u045E"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F instanceof ${r.expected}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${a}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F ${o}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${a}`}case"invalid_value":return r.values.length===1?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F ${se(r.values[0])}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0432\u0430\u0440\u044B\u044F\u043D\u0442: \u0447\u0430\u043A\u0430\u045E\u0441\u044F \u0430\u0434\u0437\u0456\u043D \u0437 ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);if(s){let a=Number(r.maximum),l=uF(a,s.unit.one,s.unit.few,s.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${s.verb} ${o}${r.maximum.toString()} ${l}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);if(s){let a=Number(r.minimum),l=uF(a,s.unit.one,s.unit.few,s.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${r.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${s.verb} ${o}${r.minimum.toString()} ${l}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${r.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u043F\u0430\u0447\u044B\u043D\u0430\u0446\u0446\u0430 \u0437 "${o.prefix}"`:o.format==="ends_with"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u0430\u043A\u0430\u043D\u0447\u0432\u0430\u0446\u0446\u0430 \u043D\u0430 "${o.suffix}"`:o.format==="includes"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u043C\u044F\u0448\u0447\u0430\u0446\u044C "${o.includes}"`:o.format==="regex"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0430\u0434\u043F\u0430\u0432\u044F\u0434\u0430\u0446\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${o.pattern}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B ${n[o.format]??r.format}`}case"not_multiple_of":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043B\u0456\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0431\u044B\u0446\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${r.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u0430\u0437\u043D\u0430\u043D\u044B ${r.keys.length>1?"\u043A\u043B\u044E\u0447\u044B":"\u043A\u043B\u044E\u0447"}: ${V(r.keys,", ")}`;case"invalid_key":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043A\u043B\u044E\u0447 \u0443 ${r.origin}`;case"invalid_union":return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434";case"invalid_element":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u0430\u0435 \u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435 \u045E ${r.origin}`;default:return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434"}}}});function fF(){return{localeError:dre()}}var dre,mF=v(()=>{Ae();dre=()=>{let e={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},file:{unit:"\u0431\u0430\u0439\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"}};function t(r){return e[r]??null}let n={regex:"\u0432\u0445\u043E\u0434",email:"\u0438\u043C\u0435\u0439\u043B \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0436\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u043F\u0440\u043E\u0434\u044A\u043B\u0436\u0438\u0442\u0435\u043B\u043D\u043E\u0441\u0442",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"base64-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",base64url:"base64url-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",json_string:"JSON \u043D\u0438\u0437",e164:"E.164 \u043D\u043E\u043C\u0435\u0440",jwt:"JWT",template_literal:"\u0432\u0445\u043E\u0434"},i={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D instanceof ${r.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${a}`:`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${o}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${a}`}case"invalid_value":return r.values.length===1?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${se(r.values[0])}`:`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u043E\u043F\u0446\u0438\u044F: \u043E\u0447\u0430\u043A\u0432\u0430\u043D\u043E \u0435\u0434\u043D\u043E \u043E\u0442 ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${r.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${o}${r.maximum.toString()} ${s.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430"}`:`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${r.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0431\u044A\u0434\u0435 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${r.origin} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${o}${r.minimum.toString()} ${s.unit}`:`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${r.origin} \u0434\u0430 \u0431\u044A\u0434\u0435 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;if(o.format==="starts_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u0432\u0430 \u0441 "${o.prefix}"`;if(o.format==="ends_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u0432\u044A\u0440\u0448\u0432\u0430 \u0441 "${o.suffix}"`;if(o.format==="includes")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0432\u043A\u043B\u044E\u0447\u0432\u0430 "${o.includes}"`;if(o.format==="regex")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0441\u044A\u0432\u043F\u0430\u0434\u0430 \u0441 ${o.pattern}`;let s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D";return o.format==="emoji"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),o.format==="datetime"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),o.format==="date"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),o.format==="time"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),o.format==="duration"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),`${s} ${n[o.format]??r.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E \u0447\u0438\u0441\u043B\u043E: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0431\u044A\u0434\u0435 \u043A\u0440\u0430\u0442\u043D\u043E \u043D\u0430 ${r.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0437\u043F\u043E\u0437\u043D\u0430\u0442${r.keys.length>1?"\u0438":""} \u043A\u043B\u044E\u0447${r.keys.length>1?"\u043E\u0432\u0435":""}: ${V(r.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043A\u043B\u044E\u0447 \u0432 ${r.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434";case"invalid_element":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442 \u0432 ${r.origin}`;default:return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434"}}}});function gF(){return{localeError:pre()}}var pre,hF=v(()=>{Ae();pre=()=>{let e={string:{unit:"car\xE0cters",verb:"contenir"},file:{unit:"bytes",verb:"contenir"},array:{unit:"elements",verb:"contenir"},set:{unit:"elements",verb:"contenir"}};function t(r){return e[r]??null}let n={regex:"entrada",email:"adre\xE7a electr\xF2nica",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i hora ISO",date:"data ISO",time:"hora ISO",duration:"durada ISO",ipv4:"adre\xE7a IPv4",ipv6:"adre\xE7a IPv6",cidrv4:"rang IPv4",cidrv6:"rang IPv6",base64:"cadena codificada en base64",base64url:"cadena codificada en base64url",json_string:"cadena JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Tipus inv\xE0lid: s'esperava instanceof ${r.expected}, s'ha rebut ${a}`:`Tipus inv\xE0lid: s'esperava ${o}, s'ha rebut ${a}`}case"invalid_value":return r.values.length===1?`Valor inv\xE0lid: s'esperava ${se(r.values[0])}`:`Opci\xF3 inv\xE0lida: s'esperava una de ${V(r.values," o ")}`;case"too_big":{let o=r.inclusive?"com a m\xE0xim":"menys de",s=t(r.origin);return s?`Massa gran: s'esperava que ${r.origin??"el valor"} contingu\xE9s ${o} ${r.maximum.toString()} ${s.unit??"elements"}`:`Massa gran: s'esperava que ${r.origin??"el valor"} fos ${o} ${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?"com a m\xEDnim":"m\xE9s de",s=t(r.origin);return s?`Massa petit: s'esperava que ${r.origin} contingu\xE9s ${o} ${r.minimum.toString()} ${s.unit}`:`Massa petit: s'esperava que ${r.origin} fos ${o} ${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Format inv\xE0lid: ha de comen\xE7ar amb "${o.prefix}"`:o.format==="ends_with"?`Format inv\xE0lid: ha d'acabar amb "${o.suffix}"`:o.format==="includes"?`Format inv\xE0lid: ha d'incloure "${o.includes}"`:o.format==="regex"?`Format inv\xE0lid: ha de coincidir amb el patr\xF3 ${o.pattern}`:`Format inv\xE0lid per a ${n[o.format]??r.format}`}case"not_multiple_of":return`N\xFAmero inv\xE0lid: ha de ser m\xFAltiple de ${r.divisor}`;case"unrecognized_keys":return`Clau${r.keys.length>1?"s":""} no reconeguda${r.keys.length>1?"s":""}: ${V(r.keys,", ")}`;case"invalid_key":return`Clau inv\xE0lida a ${r.origin}`;case"invalid_union":return"Entrada inv\xE0lida";case"invalid_element":return`Element inv\xE0lid a ${r.origin}`;default:return"Entrada inv\xE0lida"}}}});function yF(){return{localeError:fre()}}var fre,bF=v(()=>{Ae();fre=()=>{let e={string:{unit:"znak\u016F",verb:"m\xEDt"},file:{unit:"bajt\u016F",verb:"m\xEDt"},array:{unit:"prvk\u016F",verb:"m\xEDt"},set:{unit:"prvk\u016F",verb:"m\xEDt"}};function t(r){return e[r]??null}let n={regex:"regul\xE1rn\xED v\xFDraz",email:"e-mailov\xE1 adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"datum a \u010Das ve form\xE1tu ISO",date:"datum ve form\xE1tu ISO",time:"\u010Das ve form\xE1tu ISO",duration:"doba trv\xE1n\xED ISO",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",cidrv4:"rozsah IPv4",cidrv6:"rozsah IPv6",base64:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64",base64url:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64url",json_string:"\u0159et\u011Bzec ve form\xE1tu JSON",e164:"\u010D\xEDslo E.164",jwt:"JWT",template_literal:"vstup"},i={nan:"NaN",number:"\u010D\xEDslo",string:"\u0159et\u011Bzec",function:"funkce",array:"pole"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no instanceof ${r.expected}, obdr\u017Eeno ${a}`:`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${o}, obdr\u017Eeno ${a}`}case"invalid_value":return r.values.length===1?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${se(r.values[0])}`:`Neplatn\xE1 mo\u017Enost: o\u010Dek\xE1v\xE1na jedna z hodnot ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${r.origin??"hodnota"} mus\xED m\xEDt ${o}${r.maximum.toString()} ${s.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${r.origin??"hodnota"} mus\xED b\xFDt ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${r.origin??"hodnota"} mus\xED m\xEDt ${o}${r.minimum.toString()} ${s.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${r.origin??"hodnota"} mus\xED b\xFDt ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED za\u010D\xEDnat na "${o.prefix}"`:o.format==="ends_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED kon\u010Dit na "${o.suffix}"`:o.format==="includes"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED obsahovat "${o.includes}"`:o.format==="regex"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED odpov\xEDdat vzoru ${o.pattern}`:`Neplatn\xFD form\xE1t ${n[o.format]??r.format}`}case"not_multiple_of":return`Neplatn\xE9 \u010D\xEDslo: mus\xED b\xFDt n\xE1sobkem ${r.divisor}`;case"unrecognized_keys":return`Nezn\xE1m\xE9 kl\xED\u010De: ${V(r.keys,", ")}`;case"invalid_key":return`Neplatn\xFD kl\xED\u010D v ${r.origin}`;case"invalid_union":return"Neplatn\xFD vstup";case"invalid_element":return`Neplatn\xE1 hodnota v ${r.origin}`;default:return"Neplatn\xFD vstup"}}}});function wF(){return{localeError:mre()}}var mre,vF=v(()=>{Ae();mre=()=>{let e={string:{unit:"tegn",verb:"havde"},file:{unit:"bytes",verb:"havde"},array:{unit:"elementer",verb:"indeholdt"},set:{unit:"elementer",verb:"indeholdt"}};function t(r){return e[r]??null}let n={regex:"input",email:"e-mailadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkesl\xE6t",date:"ISO-dato",time:"ISO-klokkesl\xE6t",duration:"ISO-varighed",ipv4:"IPv4-omr\xE5de",ipv6:"IPv6-omr\xE5de",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodet streng",base64url:"base64url-kodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"},i={nan:"NaN",string:"streng",number:"tal",boolean:"boolean",array:"liste",object:"objekt",set:"s\xE6t",file:"fil"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Ugyldigt input: forventede instanceof ${r.expected}, fik ${a}`:`Ugyldigt input: forventede ${o}, fik ${a}`}case"invalid_value":return r.values.length===1?`Ugyldig v\xE6rdi: forventede ${se(r.values[0])}`:`Ugyldigt valg: forventede en af f\xF8lgende ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin),a=i[r.origin]??r.origin;return s?`For stor: forventede ${a??"value"} ${s.verb} ${o} ${r.maximum.toString()} ${s.unit??"elementer"}`:`For stor: forventede ${a??"value"} havde ${o} ${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin),a=i[r.origin]??r.origin;return s?`For lille: forventede ${a} ${s.verb} ${o} ${r.minimum.toString()} ${s.unit}`:`For lille: forventede ${a} havde ${o} ${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Ugyldig streng: skal starte med "${o.prefix}"`:o.format==="ends_with"?`Ugyldig streng: skal ende med "${o.suffix}"`:o.format==="includes"?`Ugyldig streng: skal indeholde "${o.includes}"`:o.format==="regex"?`Ugyldig streng: skal matche m\xF8nsteret ${o.pattern}`:`Ugyldig ${n[o.format]??r.format}`}case"not_multiple_of":return`Ugyldigt tal: skal v\xE6re deleligt med ${r.divisor}`;case"unrecognized_keys":return`${r.keys.length>1?"Ukendte n\xF8gler":"Ukendt n\xF8gle"}: ${V(r.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8gle i ${r.origin}`;case"invalid_union":return"Ugyldigt input: matcher ingen af de tilladte typer";case"invalid_element":return`Ugyldig v\xE6rdi i ${r.origin}`;default:return"Ugyldigt input"}}}});function kF(){return{localeError:gre()}}var gre,xF=v(()=>{Ae();gre=()=>{let e={string:{unit:"Zeichen",verb:"zu haben"},file:{unit:"Bytes",verb:"zu haben"},array:{unit:"Elemente",verb:"zu haben"},set:{unit:"Elemente",verb:"zu haben"}};function t(r){return e[r]??null}let n={regex:"Eingabe",email:"E-Mail-Adresse",url:"URL",emoji:"Emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-Datum und -Uhrzeit",date:"ISO-Datum",time:"ISO-Uhrzeit",duration:"ISO-Dauer",ipv4:"IPv4-Adresse",ipv6:"IPv6-Adresse",cidrv4:"IPv4-Bereich",cidrv6:"IPv6-Bereich",base64:"Base64-codierter String",base64url:"Base64-URL-codierter String",json_string:"JSON-String",e164:"E.164-Nummer",jwt:"JWT",template_literal:"Eingabe"},i={nan:"NaN",number:"Zahl",array:"Array"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Ung\xFCltige Eingabe: erwartet instanceof ${r.expected}, erhalten ${a}`:`Ung\xFCltige Eingabe: erwartet ${o}, erhalten ${a}`}case"invalid_value":return r.values.length===1?`Ung\xFCltige Eingabe: erwartet ${se(r.values[0])}`:`Ung\xFCltige Option: erwartet eine von ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`Zu gro\xDF: erwartet, dass ${r.origin??"Wert"} ${o}${r.maximum.toString()} ${s.unit??"Elemente"} hat`:`Zu gro\xDF: erwartet, dass ${r.origin??"Wert"} ${o}${r.maximum.toString()} ist`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`Zu klein: erwartet, dass ${r.origin} ${o}${r.minimum.toString()} ${s.unit} hat`:`Zu klein: erwartet, dass ${r.origin} ${o}${r.minimum.toString()} ist`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Ung\xFCltiger String: muss mit "${o.prefix}" beginnen`:o.format==="ends_with"?`Ung\xFCltiger String: muss mit "${o.suffix}" enden`:o.format==="includes"?`Ung\xFCltiger String: muss "${o.includes}" enthalten`:o.format==="regex"?`Ung\xFCltiger String: muss dem Muster ${o.pattern} entsprechen`:`Ung\xFCltig: ${n[o.format]??r.format}`}case"not_multiple_of":return`Ung\xFCltige Zahl: muss ein Vielfaches von ${r.divisor} sein`;case"unrecognized_keys":return`${r.keys.length>1?"Unbekannte Schl\xFCssel":"Unbekannter Schl\xFCssel"}: ${V(r.keys,", ")}`;case"invalid_key":return`Ung\xFCltiger Schl\xFCssel in ${r.origin}`;case"invalid_union":return"Ung\xFCltige Eingabe";case"invalid_element":return`Ung\xFCltiger Wert in ${r.origin}`;default:return"Ung\xFCltige Eingabe"}}}});function Ey(){return{localeError:hre()}}var hre,SE=v(()=>{Ae();hre=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(r){return e[r]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return`Invalid input: expected ${o}, received ${a}`}case"invalid_value":return r.values.length===1?`Invalid input: expected ${se(r.values[0])}`:`Invalid option: expected one of ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`Too big: expected ${r.origin??"value"} to have ${o}${r.maximum.toString()} ${s.unit??"elements"}`:`Too big: expected ${r.origin??"value"} to be ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`Too small: expected ${r.origin} to have ${o}${r.minimum.toString()} ${s.unit}`:`Too small: expected ${r.origin} to be ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Invalid string: must start with "${o.prefix}"`:o.format==="ends_with"?`Invalid string: must end with "${o.suffix}"`:o.format==="includes"?`Invalid string: must include "${o.includes}"`:o.format==="regex"?`Invalid string: must match pattern ${o.pattern}`:`Invalid ${n[o.format]??r.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${r.divisor}`;case"unrecognized_keys":return`Unrecognized key${r.keys.length>1?"s":""}: ${V(r.keys,", ")}`;case"invalid_key":return`Invalid key in ${r.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${r.origin}`;default:return"Invalid input"}}}});function $F(){return{localeError:yre()}}var yre,RF=v(()=>{Ae();yre=()=>{let e={string:{unit:"karaktrojn",verb:"havi"},file:{unit:"bajtojn",verb:"havi"},array:{unit:"elementojn",verb:"havi"},set:{unit:"elementojn",verb:"havi"}};function t(r){return e[r]??null}let n={regex:"enigo",email:"retadreso",url:"URL",emoji:"emo\u011Dio",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datotempo",date:"ISO-dato",time:"ISO-tempo",duration:"ISO-da\u016Dro",ipv4:"IPv4-adreso",ipv6:"IPv6-adreso",cidrv4:"IPv4-rango",cidrv6:"IPv6-rango",base64:"64-ume kodita karaktraro",base64url:"URL-64-ume kodita karaktraro",json_string:"JSON-karaktraro",e164:"E.164-nombro",jwt:"JWT",template_literal:"enigo"},i={nan:"NaN",number:"nombro",array:"tabelo",null:"senvalora"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Nevalida enigo: atendi\u011Dis instanceof ${r.expected}, ricevi\u011Dis ${a}`:`Nevalida enigo: atendi\u011Dis ${o}, ricevi\u011Dis ${a}`}case"invalid_value":return r.values.length===1?`Nevalida enigo: atendi\u011Dis ${se(r.values[0])}`:`Nevalida opcio: atendi\u011Dis unu el ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`Tro granda: atendi\u011Dis ke ${r.origin??"valoro"} havu ${o}${r.maximum.toString()} ${s.unit??"elementojn"}`:`Tro granda: atendi\u011Dis ke ${r.origin??"valoro"} havu ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`Tro malgranda: atendi\u011Dis ke ${r.origin} havu ${o}${r.minimum.toString()} ${s.unit}`:`Tro malgranda: atendi\u011Dis ke ${r.origin} estu ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Nevalida karaktraro: devas komenci\u011Di per "${o.prefix}"`:o.format==="ends_with"?`Nevalida karaktraro: devas fini\u011Di per "${o.suffix}"`:o.format==="includes"?`Nevalida karaktraro: devas inkluzivi "${o.includes}"`:o.format==="regex"?`Nevalida karaktraro: devas kongrui kun la modelo ${o.pattern}`:`Nevalida ${n[o.format]??r.format}`}case"not_multiple_of":return`Nevalida nombro: devas esti oblo de ${r.divisor}`;case"unrecognized_keys":return`Nekonata${r.keys.length>1?"j":""} \u015Dlosilo${r.keys.length>1?"j":""}: ${V(r.keys,", ")}`;case"invalid_key":return`Nevalida \u015Dlosilo en ${r.origin}`;case"invalid_union":return"Nevalida enigo";case"invalid_element":return`Nevalida valoro en ${r.origin}`;default:return"Nevalida enigo"}}}});function SF(){return{localeError:bre()}}var bre,EF=v(()=>{Ae();bre=()=>{let e={string:{unit:"caracteres",verb:"tener"},file:{unit:"bytes",verb:"tener"},array:{unit:"elementos",verb:"tener"},set:{unit:"elementos",verb:"tener"}};function t(r){return e[r]??null}let n={regex:"entrada",email:"direcci\xF3n de correo electr\xF3nico",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"fecha y hora ISO",date:"fecha ISO",time:"hora ISO",duration:"duraci\xF3n ISO",ipv4:"direcci\xF3n IPv4",ipv6:"direcci\xF3n IPv6",cidrv4:"rango IPv4",cidrv6:"rango IPv6",base64:"cadena codificada en base64",base64url:"URL codificada en base64",json_string:"cadena JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},i={nan:"NaN",string:"texto",number:"n\xFAmero",boolean:"booleano",array:"arreglo",object:"objeto",set:"conjunto",file:"archivo",date:"fecha",bigint:"n\xFAmero grande",symbol:"s\xEDmbolo",undefined:"indefinido",null:"nulo",function:"funci\xF3n",map:"mapa",record:"registro",tuple:"tupla",enum:"enumeraci\xF3n",union:"uni\xF3n",literal:"literal",promise:"promesa",void:"vac\xEDo",never:"nunca",unknown:"desconocido",any:"cualquiera"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Entrada inv\xE1lida: se esperaba instanceof ${r.expected}, recibido ${a}`:`Entrada inv\xE1lida: se esperaba ${o}, recibido ${a}`}case"invalid_value":return r.values.length===1?`Entrada inv\xE1lida: se esperaba ${se(r.values[0])}`:`Opci\xF3n inv\xE1lida: se esperaba una de ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin),a=i[r.origin]??r.origin;return s?`Demasiado grande: se esperaba que ${a??"valor"} tuviera ${o}${r.maximum.toString()} ${s.unit??"elementos"}`:`Demasiado grande: se esperaba que ${a??"valor"} fuera ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin),a=i[r.origin]??r.origin;return s?`Demasiado peque\xF1o: se esperaba que ${a} tuviera ${o}${r.minimum.toString()} ${s.unit}`:`Demasiado peque\xF1o: se esperaba que ${a} fuera ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Cadena inv\xE1lida: debe comenzar con "${o.prefix}"`:o.format==="ends_with"?`Cadena inv\xE1lida: debe terminar en "${o.suffix}"`:o.format==="includes"?`Cadena inv\xE1lida: debe incluir "${o.includes}"`:o.format==="regex"?`Cadena inv\xE1lida: debe coincidir con el patr\xF3n ${o.pattern}`:`Inv\xE1lido ${n[o.format]??r.format}`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: debe ser m\xFAltiplo de ${r.divisor}`;case"unrecognized_keys":return`Llave${r.keys.length>1?"s":""} desconocida${r.keys.length>1?"s":""}: ${V(r.keys,", ")}`;case"invalid_key":return`Llave inv\xE1lida en ${i[r.origin]??r.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido en ${i[r.origin]??r.origin}`;default:return"Entrada inv\xE1lida"}}}});function AF(){return{localeError:wre()}}var wre,PF=v(()=>{Ae();wre=()=>{let e={string:{unit:"\u06A9\u0627\u0631\u0627\u06A9\u062A\u0631",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},file:{unit:"\u0628\u0627\u06CC\u062A",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},array:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},set:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"}};function t(r){return e[r]??null}let n={regex:"\u0648\u0631\u0648\u062F\u06CC",email:"\u0622\u062F\u0631\u0633 \u0627\u06CC\u0645\u06CC\u0644",url:"URL",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u06CC\u062E \u0648 \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",date:"\u062A\u0627\u0631\u06CC\u062E \u0627\u06CC\u0632\u0648",time:"\u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",duration:"\u0645\u062F\u062A \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",ipv4:"IPv4 \u0622\u062F\u0631\u0633",ipv6:"IPv6 \u0622\u062F\u0631\u0633",cidrv4:"IPv4 \u062F\u0627\u0645\u0646\u0647",cidrv6:"IPv6 \u062F\u0627\u0645\u0646\u0647",base64:"base64-encoded \u0631\u0634\u062A\u0647",base64url:"base64url-encoded \u0631\u0634\u062A\u0647",json_string:"JSON \u0631\u0634\u062A\u0647",e164:"E.164 \u0639\u062F\u062F",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u06CC"},i={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0622\u0631\u0627\u06CC\u0647"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A instanceof ${r.expected} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${a} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`:`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${o} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${a} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`}case"invalid_value":return r.values.length===1?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${se(r.values[0])} \u0645\u06CC\u200C\u0628\u0648\u062F`:`\u06AF\u0632\u06CC\u0646\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A \u06CC\u06A9\u06CC \u0627\u0632 ${V(r.values,"|")} \u0645\u06CC\u200C\u0628\u0648\u062F`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${r.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${o}${r.maximum.toString()} ${s.unit??"\u0639\u0646\u0635\u0631"} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${r.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${o}${r.maximum.toString()} \u0628\u0627\u0634\u062F`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${r.origin} \u0628\u0627\u06CC\u062F ${o}${r.minimum.toString()} ${s.unit} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${r.origin} \u0628\u0627\u06CC\u062F ${o}${r.minimum.toString()} \u0628\u0627\u0634\u062F`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${o.prefix}" \u0634\u0631\u0648\u0639 \u0634\u0648\u062F`:o.format==="ends_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${o.suffix}" \u062A\u0645\u0627\u0645 \u0634\u0648\u062F`:o.format==="includes"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0634\u0627\u0645\u0644 "${o.includes}" \u0628\u0627\u0634\u062F`:o.format==="regex"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC ${o.pattern} \u0645\u0637\u0627\u0628\u0642\u062A \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F`:`${n[o.format]??r.format} \u0646\u0627\u0645\u0639\u062A\u0628\u0631`}case"not_multiple_of":return`\u0639\u062F\u062F \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0645\u0636\u0631\u0628 ${r.divisor} \u0628\u0627\u0634\u062F`;case"unrecognized_keys":return`\u06A9\u0644\u06CC\u062F${r.keys.length>1?"\u0647\u0627\u06CC":""} \u0646\u0627\u0634\u0646\u0627\u0633: ${V(r.keys,", ")}`;case"invalid_key":return`\u06A9\u0644\u06CC\u062F \u0646\u0627\u0634\u0646\u0627\u0633 \u062F\u0631 ${r.origin}`;case"invalid_union":return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631";case"invalid_element":return`\u0645\u0642\u062F\u0627\u0631 \u0646\u0627\u0645\u0639\u062A\u0628\u0631 \u062F\u0631 ${r.origin}`;default:return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631"}}}});function OF(){return{localeError:vre()}}var vre,CF=v(()=>{Ae();vre=()=>{let e={string:{unit:"merkki\xE4",subject:"merkkijonon"},file:{unit:"tavua",subject:"tiedoston"},array:{unit:"alkiota",subject:"listan"},set:{unit:"alkiota",subject:"joukon"},number:{unit:"",subject:"luvun"},bigint:{unit:"",subject:"suuren kokonaisluvun"},int:{unit:"",subject:"kokonaisluvun"},date:{unit:"",subject:"p\xE4iv\xE4m\xE4\xE4r\xE4n"}};function t(r){return e[r]??null}let n={regex:"s\xE4\xE4nn\xF6llinen lauseke",email:"s\xE4hk\xF6postiosoite",url:"URL-osoite",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-aikaleima",date:"ISO-p\xE4iv\xE4m\xE4\xE4r\xE4",time:"ISO-aika",duration:"ISO-kesto",ipv4:"IPv4-osoite",ipv6:"IPv6-osoite",cidrv4:"IPv4-alue",cidrv6:"IPv6-alue",base64:"base64-koodattu merkkijono",base64url:"base64url-koodattu merkkijono",json_string:"JSON-merkkijono",e164:"E.164-luku",jwt:"JWT",template_literal:"templaattimerkkijono"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Virheellinen tyyppi: odotettiin instanceof ${r.expected}, oli ${a}`:`Virheellinen tyyppi: odotettiin ${o}, oli ${a}`}case"invalid_value":return r.values.length===1?`Virheellinen sy\xF6te: t\xE4ytyy olla ${se(r.values[0])}`:`Virheellinen valinta: t\xE4ytyy olla yksi seuraavista: ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`Liian suuri: ${s.subject} t\xE4ytyy olla ${o}${r.maximum.toString()} ${s.unit}`.trim():`Liian suuri: arvon t\xE4ytyy olla ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`Liian pieni: ${s.subject} t\xE4ytyy olla ${o}${r.minimum.toString()} ${s.unit}`.trim():`Liian pieni: arvon t\xE4ytyy olla ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Virheellinen sy\xF6te: t\xE4ytyy alkaa "${o.prefix}"`:o.format==="ends_with"?`Virheellinen sy\xF6te: t\xE4ytyy loppua "${o.suffix}"`:o.format==="includes"?`Virheellinen sy\xF6te: t\xE4ytyy sis\xE4lt\xE4\xE4 "${o.includes}"`:o.format==="regex"?`Virheellinen sy\xF6te: t\xE4ytyy vastata s\xE4\xE4nn\xF6llist\xE4 lauseketta ${o.pattern}`:`Virheellinen ${n[o.format]??r.format}`}case"not_multiple_of":return`Virheellinen luku: t\xE4ytyy olla luvun ${r.divisor} monikerta`;case"unrecognized_keys":return`${r.keys.length>1?"Tuntemattomat avaimet":"Tuntematon avain"}: ${V(r.keys,", ")}`;case"invalid_key":return"Virheellinen avain tietueessa";case"invalid_union":return"Virheellinen unioni";case"invalid_element":return"Virheellinen arvo joukossa";default:return"Virheellinen sy\xF6te"}}}});function _F(){return{localeError:kre()}}var kre,IF=v(()=>{Ae();kre=()=>{let e={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function t(r){return e[r]??null}let n={regex:"entr\xE9e",email:"adresse e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date et heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",jwt:"JWT",template_literal:"entr\xE9e"},i={nan:"NaN",number:"nombre",array:"tableau"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Entr\xE9e invalide : instanceof ${r.expected} attendu, ${a} re\xE7u`:`Entr\xE9e invalide : ${o} attendu, ${a} re\xE7u`}case"invalid_value":return r.values.length===1?`Entr\xE9e invalide : ${se(r.values[0])} attendu`:`Option invalide : une valeur parmi ${V(r.values,"|")} attendue`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`Trop grand : ${r.origin??"valeur"} doit ${s.verb} ${o}${r.maximum.toString()} ${s.unit??"\xE9l\xE9ment(s)"}`:`Trop grand : ${r.origin??"valeur"} doit \xEAtre ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`Trop petit : ${r.origin} doit ${s.verb} ${o}${r.minimum.toString()} ${s.unit}`:`Trop petit : ${r.origin} doit \xEAtre ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${o.prefix}"`:o.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${o.suffix}"`:o.format==="includes"?`Cha\xEEne invalide : doit inclure "${o.includes}"`:o.format==="regex"?`Cha\xEEne invalide : doit correspondre au mod\xE8le ${o.pattern}`:`${n[o.format]??r.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${r.divisor}`;case"unrecognized_keys":return`Cl\xE9${r.keys.length>1?"s":""} non reconnue${r.keys.length>1?"s":""} : ${V(r.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${r.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${r.origin}`;default:return"Entr\xE9e invalide"}}}});function TF(){return{localeError:xre()}}var xre,DF=v(()=>{Ae();xre=()=>{let e={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function t(r){return e[r]??null}let n={regex:"entr\xE9e",email:"adresse courriel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date-heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",jwt:"JWT",template_literal:"entr\xE9e"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Entr\xE9e invalide : attendu instanceof ${r.expected}, re\xE7u ${a}`:`Entr\xE9e invalide : attendu ${o}, re\xE7u ${a}`}case"invalid_value":return r.values.length===1?`Entr\xE9e invalide : attendu ${se(r.values[0])}`:`Option invalide : attendu l'une des valeurs suivantes ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"\u2264":"<",s=t(r.origin);return s?`Trop grand : attendu que ${r.origin??"la valeur"} ait ${o}${r.maximum.toString()} ${s.unit}`:`Trop grand : attendu que ${r.origin??"la valeur"} soit ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?"\u2265":">",s=t(r.origin);return s?`Trop petit : attendu que ${r.origin} ait ${o}${r.minimum.toString()} ${s.unit}`:`Trop petit : attendu que ${r.origin} soit ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${o.prefix}"`:o.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${o.suffix}"`:o.format==="includes"?`Cha\xEEne invalide : doit inclure "${o.includes}"`:o.format==="regex"?`Cha\xEEne invalide : doit correspondre au motif ${o.pattern}`:`${n[o.format]??r.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${r.divisor}`;case"unrecognized_keys":return`Cl\xE9${r.keys.length>1?"s":""} non reconnue${r.keys.length>1?"s":""} : ${V(r.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${r.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${r.origin}`;default:return"Entr\xE9e invalide"}}}});function NF(){return{localeError:$re()}}var $re,jF=v(()=>{Ae();$re=()=>{let e={string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA",gender:"f"},number:{label:"\u05DE\u05E1\u05E4\u05E8",gender:"m"},boolean:{label:"\u05E2\u05E8\u05DA \u05D1\u05D5\u05DC\u05D9\u05D0\u05E0\u05D9",gender:"m"},bigint:{label:"BigInt",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA",gender:"m"},array:{label:"\u05DE\u05E2\u05E8\u05DA",gender:"m"},object:{label:"\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8",gender:"m"},null:{label:"\u05E2\u05E8\u05DA \u05E8\u05D9\u05E7 (null)",gender:"m"},undefined:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05DE\u05D5\u05D2\u05D3\u05E8 (undefined)",gender:"m"},symbol:{label:"\u05E1\u05D9\u05DE\u05D1\u05D5\u05DC (Symbol)",gender:"m"},function:{label:"\u05E4\u05D5\u05E0\u05E7\u05E6\u05D9\u05D4",gender:"f"},map:{label:"\u05DE\u05E4\u05D4 (Map)",gender:"f"},set:{label:"\u05E7\u05D1\u05D5\u05E6\u05D4 (Set)",gender:"f"},file:{label:"\u05E7\u05D5\u05D1\u05E5",gender:"m"},promise:{label:"Promise",gender:"m"},NaN:{label:"NaN",gender:"m"},unknown:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05D9\u05D3\u05D5\u05E2",gender:"m"},value:{label:"\u05E2\u05E8\u05DA",gender:"m"}},t={string:{unit:"\u05EA\u05D5\u05D5\u05D9\u05DD",shortLabel:"\u05E7\u05E6\u05E8",longLabel:"\u05D0\u05E8\u05D5\u05DA"},file:{unit:"\u05D1\u05D9\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},array:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},set:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},number:{unit:"",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"}},n=c=>c?e[c]:void 0,i=c=>{let u=n(c);return u?u.label:c??e.unknown.label},r=c=>`\u05D4${i(c)}`,o=c=>(n(c)?.gender??"m")==="f"?"\u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05D9\u05D5\u05EA":"\u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA",s=c=>c?t[c]??null:null,a={regex:{label:"\u05E7\u05DC\u05D8",gender:"m"},email:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05D0\u05D9\u05DE\u05D9\u05D9\u05DC",gender:"f"},url:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05E8\u05E9\u05EA",gender:"f"},emoji:{label:"\u05D0\u05D9\u05DE\u05D5\u05D2'\u05D9",gender:"m"},uuid:{label:"UUID",gender:"m"},nanoid:{label:"nanoid",gender:"m"},guid:{label:"GUID",gender:"m"},cuid:{label:"cuid",gender:"m"},cuid2:{label:"cuid2",gender:"m"},ulid:{label:"ULID",gender:"m"},xid:{label:"XID",gender:"m"},ksuid:{label:"KSUID",gender:"m"},datetime:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA \u05D5\u05D6\u05DE\u05DF ISO",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA ISO",gender:"m"},time:{label:"\u05D6\u05DE\u05DF ISO",gender:"m"},duration:{label:"\u05DE\u05E9\u05DA \u05D6\u05DE\u05DF ISO",gender:"m"},ipv4:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv4",gender:"f"},ipv6:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv6",gender:"f"},cidrv4:{label:"\u05D8\u05D5\u05D5\u05D7 IPv4",gender:"m"},cidrv6:{label:"\u05D8\u05D5\u05D5\u05D7 IPv6",gender:"m"},base64:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64",gender:"f"},base64url:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64 \u05DC\u05DB\u05EA\u05D5\u05D1\u05D5\u05EA \u05E8\u05E9\u05EA",gender:"f"},json_string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA JSON",gender:"f"},e164:{label:"\u05DE\u05E1\u05E4\u05E8 E.164",gender:"m"},jwt:{label:"JWT",gender:"m"},ends_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},includes:{label:"\u05E7\u05DC\u05D8",gender:"m"},lowercase:{label:"\u05E7\u05DC\u05D8",gender:"m"},starts_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},uppercase:{label:"\u05E7\u05DC\u05D8",gender:"m"}},l={nan:"NaN"};return c=>{switch(c.code){case"invalid_type":{let u=c.expected,d=l[u??""]??i(u),p=ce(c.input),f=l[p]??e[p]?.label??p;return/^[A-Z]/.test(c.expected)?`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA instanceof ${c.expected}, \u05D4\u05EA\u05E7\u05D1\u05DC ${f}`:`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${d}, \u05D4\u05EA\u05E7\u05D1\u05DC ${f}`}case"invalid_value":{if(c.values.length===1)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05E2\u05E8\u05DA \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA ${se(c.values[0])}`;let u=c.values.map(f=>se(f));if(c.values.length===2)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${u[0]} \u05D0\u05D5 ${u[1]}`;let d=u[u.length-1];return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${u.slice(0,-1).join(", ")} \u05D0\u05D5 ${d}`}case"too_big":{let u=s(c.origin),d=r(c.origin??"value");if(c.origin==="string")return`${u?.longLabel??"\u05D0\u05E8\u05D5\u05DA"} \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${c.maximum.toString()} ${u?.unit??""} ${c.inclusive?"\u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA":"\u05DC\u05DB\u05DC \u05D4\u05D9\u05D5\u05EA\u05E8"}`.trim();if(c.origin==="number"){let g=c.inclusive?`\u05E7\u05D8\u05DF \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${c.maximum}`:`\u05E7\u05D8\u05DF \u05DE-${c.maximum}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${g}`}if(c.origin==="array"||c.origin==="set"){let g=c.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA",h=c.inclusive?`${c.maximum} ${u?.unit??""} \u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA`:`\u05E4\u05D7\u05D5\u05EA \u05DE-${c.maximum} ${u?.unit??""}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${d} ${g} \u05DC\u05D4\u05DB\u05D9\u05DC ${h}`.trim()}let p=c.inclusive?"<=":"<",f=o(c.origin??"value");return u?.unit?`${u.longLabel} \u05DE\u05D3\u05D9: ${d} ${f} ${p}${c.maximum.toString()} ${u.unit}`:`${u?.longLabel??"\u05D2\u05D3\u05D5\u05DC"} \u05DE\u05D3\u05D9: ${d} ${f} ${p}${c.maximum.toString()}`}case"too_small":{let u=s(c.origin),d=r(c.origin??"value");if(c.origin==="string")return`${u?.shortLabel??"\u05E7\u05E6\u05E8"} \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${c.minimum.toString()} ${u?.unit??""} ${c.inclusive?"\u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8":"\u05DC\u05E4\u05D7\u05D5\u05EA"}`.trim();if(c.origin==="number"){let g=c.inclusive?`\u05D2\u05D3\u05D5\u05DC \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${c.minimum}`:`\u05D2\u05D3\u05D5\u05DC \u05DE-${c.minimum}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${g}`}if(c.origin==="array"||c.origin==="set"){let g=c.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA";if(c.minimum===1&&c.inclusive){let b=(c.origin==="set","\u05DC\u05E4\u05D7\u05D5\u05EA \u05E4\u05E8\u05D9\u05D8 \u05D0\u05D7\u05D3");return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} ${g} \u05DC\u05D4\u05DB\u05D9\u05DC ${b}`}let h=c.inclusive?`${c.minimum} ${u?.unit??""} \u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8`:`\u05D9\u05D5\u05EA\u05E8 \u05DE-${c.minimum} ${u?.unit??""}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} ${g} \u05DC\u05D4\u05DB\u05D9\u05DC ${h}`.trim()}let p=c.inclusive?">=":">",f=o(c.origin??"value");return u?.unit?`${u.shortLabel} \u05DE\u05D3\u05D9: ${d} ${f} ${p}${c.minimum.toString()} ${u.unit}`:`${u?.shortLabel??"\u05E7\u05D8\u05DF"} \u05DE\u05D3\u05D9: ${d} ${f} ${p}${c.minimum.toString()}`}case"invalid_format":{let u=c;if(u.format==="starts_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D7\u05D9\u05DC \u05D1 "${u.prefix}"`;if(u.format==="ends_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05E1\u05EA\u05D9\u05D9\u05DD \u05D1 "${u.suffix}"`;if(u.format==="includes")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05DB\u05DC\u05D5\u05DC "${u.includes}"`;if(u.format==="regex")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D0\u05D9\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA ${u.pattern}`;let d=a[u.format],p=d?.label??u.format,g=(d?.gender??"m")==="f"?"\u05EA\u05E7\u05D9\u05E0\u05D4":"\u05EA\u05E7\u05D9\u05DF";return`${p} \u05DC\u05D0 ${g}`}case"not_multiple_of":return`\u05DE\u05E1\u05E4\u05E8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DE\u05DB\u05E4\u05DC\u05D4 \u05E9\u05DC ${c.divisor}`;case"unrecognized_keys":return`\u05DE\u05E4\u05EA\u05D7${c.keys.length>1?"\u05D5\u05EA":""} \u05DC\u05D0 \u05DE\u05D6\u05D5\u05D4${c.keys.length>1?"\u05D9\u05DD":"\u05D4"}: ${V(c.keys,", ")}`;case"invalid_key":return"\u05E9\u05D3\u05D4 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8";case"invalid_union":return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF";case"invalid_element":return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1${r(c.origin??"array")}`;default:return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF"}}}});function LF(){return{localeError:Rre()}}var Rre,MF=v(()=>{Ae();Rre=()=>{let e={string:{unit:"karakter",verb:"legyen"},file:{unit:"byte",verb:"legyen"},array:{unit:"elem",verb:"legyen"},set:{unit:"elem",verb:"legyen"}};function t(r){return e[r]??null}let n={regex:"bemenet",email:"email c\xEDm",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO id\u0151b\xE9lyeg",date:"ISO d\xE1tum",time:"ISO id\u0151",duration:"ISO id\u0151intervallum",ipv4:"IPv4 c\xEDm",ipv6:"IPv6 c\xEDm",cidrv4:"IPv4 tartom\xE1ny",cidrv6:"IPv6 tartom\xE1ny",base64:"base64-k\xF3dolt string",base64url:"base64url-k\xF3dolt string",json_string:"JSON string",e164:"E.164 sz\xE1m",jwt:"JWT",template_literal:"bemenet"},i={nan:"NaN",number:"sz\xE1m",array:"t\xF6mb"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k instanceof ${r.expected}, a kapott \xE9rt\xE9k ${a}`:`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${o}, a kapott \xE9rt\xE9k ${a}`}case"invalid_value":return r.values.length===1?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${se(r.values[0])}`:`\xC9rv\xE9nytelen opci\xF3: valamelyik \xE9rt\xE9k v\xE1rt ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`T\xFAl nagy: ${r.origin??"\xE9rt\xE9k"} m\xE9rete t\xFAl nagy ${o}${r.maximum.toString()} ${s.unit??"elem"}`:`T\xFAl nagy: a bemeneti \xE9rt\xE9k ${r.origin??"\xE9rt\xE9k"} t\xFAl nagy: ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${r.origin} m\xE9rete t\xFAl kicsi ${o}${r.minimum.toString()} ${s.unit}`:`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${r.origin} t\xFAl kicsi ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\xC9rv\xE9nytelen string: "${o.prefix}" \xE9rt\xE9kkel kell kezd\u0151dnie`:o.format==="ends_with"?`\xC9rv\xE9nytelen string: "${o.suffix}" \xE9rt\xE9kkel kell v\xE9gz\u0151dnie`:o.format==="includes"?`\xC9rv\xE9nytelen string: "${o.includes}" \xE9rt\xE9ket kell tartalmaznia`:o.format==="regex"?`\xC9rv\xE9nytelen string: ${o.pattern} mint\xE1nak kell megfelelnie`:`\xC9rv\xE9nytelen ${n[o.format]??r.format}`}case"not_multiple_of":return`\xC9rv\xE9nytelen sz\xE1m: ${r.divisor} t\xF6bbsz\xF6r\xF6s\xE9nek kell lennie`;case"unrecognized_keys":return`Ismeretlen kulcs${r.keys.length>1?"s":""}: ${V(r.keys,", ")}`;case"invalid_key":return`\xC9rv\xE9nytelen kulcs ${r.origin}`;case"invalid_union":return"\xC9rv\xE9nytelen bemenet";case"invalid_element":return`\xC9rv\xE9nytelen \xE9rt\xE9k: ${r.origin}`;default:return"\xC9rv\xE9nytelen bemenet"}}}});function FF(e,t,n){return Math.abs(e)===1?t:n}function ql(e){if(!e)return"";let t=["\u0561","\u0565","\u0568","\u056B","\u0578","\u0578\u0582","\u0585"],n=e[e.length-1];return e+(t.includes(n)?"\u0576":"\u0568")}function BF(){return{localeError:Sre()}}var Sre,GF=v(()=>{Ae();Sre=()=>{let e={string:{unit:{one:"\u0576\u0577\u0561\u0576",many:"\u0576\u0577\u0561\u0576\u0576\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},file:{unit:{one:"\u0562\u0561\u0575\u0569",many:"\u0562\u0561\u0575\u0569\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},array:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},set:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"}};function t(r){return e[r]??null}let n={regex:"\u0574\u0578\u0582\u057F\u0584",email:"\u0567\u056C. \u0570\u0561\u057D\u0581\u0565",url:"URL",emoji:"\u0567\u0574\u0578\u057B\u056B",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E \u0587 \u056A\u0561\u0574",date:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E",time:"ISO \u056A\u0561\u0574",duration:"ISO \u057F\u0587\u0578\u0572\u0578\u0582\u0569\u0575\u0578\u0582\u0576",ipv4:"IPv4 \u0570\u0561\u057D\u0581\u0565",ipv6:"IPv6 \u0570\u0561\u057D\u0581\u0565",cidrv4:"IPv4 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",cidrv6:"IPv6 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",base64:"base64 \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",base64url:"base64url \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",json_string:"JSON \u057F\u0578\u0572",e164:"E.164 \u0570\u0561\u0574\u0561\u0580",jwt:"JWT",template_literal:"\u0574\u0578\u0582\u057F\u0584"},i={nan:"NaN",number:"\u0569\u056B\u057E",array:"\u0566\u0561\u0576\u0563\u057E\u0561\u056E"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 instanceof ${r.expected}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${a}`:`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${o}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${a}`}case"invalid_value":return r.values.length===1?`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${se(r.values[1])}`:`\u054D\u056D\u0561\u056C \u057F\u0561\u0580\u0562\u0565\u0580\u0561\u056F\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 \u0570\u0565\u057F\u0587\u0575\u0561\u056C\u0576\u0565\u0580\u056B\u0581 \u0574\u0565\u056F\u0568\u055D ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);if(s){let a=Number(r.maximum),l=FF(a,s.unit.one,s.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${ql(r.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${o}${r.maximum.toString()} ${l}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${ql(r.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056C\u056B\u0576\u056B ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);if(s){let a=Number(r.minimum),l=FF(a,s.unit.one,s.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${ql(r.origin)} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${o}${r.minimum.toString()} ${l}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${ql(r.origin)} \u056C\u056B\u0576\u056B ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057D\u056F\u057D\u057E\u056B "${o.prefix}"-\u0578\u057E`:o.format==="ends_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0561\u057E\u0561\u0580\u057F\u057E\u056B "${o.suffix}"-\u0578\u057E`:o.format==="includes"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057A\u0561\u0580\u0578\u0582\u0576\u0561\u056F\u056B "${o.includes}"`:o.format==="regex"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0570\u0561\u0574\u0561\u057A\u0561\u057F\u0561\u057D\u056D\u0561\u0576\u056B ${o.pattern} \u0571\u0587\u0561\u0579\u0561\u0583\u056B\u0576`:`\u054D\u056D\u0561\u056C ${n[o.format]??r.format}`}case"not_multiple_of":return`\u054D\u056D\u0561\u056C \u0569\u056B\u057E\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0562\u0561\u0566\u0574\u0561\u057A\u0561\u057F\u056B\u056F \u056C\u056B\u0576\u056B ${r.divisor}-\u056B`;case"unrecognized_keys":return`\u0549\u0573\u0561\u0576\u0561\u0579\u057E\u0561\u056E \u0562\u0561\u0576\u0561\u056C\u056B${r.keys.length>1?"\u0576\u0565\u0580":""}. ${V(r.keys,", ")}`;case"invalid_key":return`\u054D\u056D\u0561\u056C \u0562\u0561\u0576\u0561\u056C\u056B ${ql(r.origin)}-\u0578\u0582\u0574`;case"invalid_union":return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574";case"invalid_element":return`\u054D\u056D\u0561\u056C \u0561\u0580\u056A\u0565\u0584 ${ql(r.origin)}-\u0578\u0582\u0574`;default:return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574"}}}});function WF(){return{localeError:Ere()}}var Ere,zF=v(()=>{Ae();Ere=()=>{let e={string:{unit:"karakter",verb:"memiliki"},file:{unit:"byte",verb:"memiliki"},array:{unit:"item",verb:"memiliki"},set:{unit:"item",verb:"memiliki"}};function t(r){return e[r]??null}let n={regex:"input",email:"alamat email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tanggal dan waktu format ISO",date:"tanggal format ISO",time:"jam format ISO",duration:"durasi format ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"rentang alamat IPv4",cidrv6:"rentang alamat IPv6",base64:"string dengan enkode base64",base64url:"string dengan enkode base64url",json_string:"string JSON",e164:"angka E.164",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Input tidak valid: diharapkan instanceof ${r.expected}, diterima ${a}`:`Input tidak valid: diharapkan ${o}, diterima ${a}`}case"invalid_value":return r.values.length===1?`Input tidak valid: diharapkan ${se(r.values[0])}`:`Pilihan tidak valid: diharapkan salah satu dari ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`Terlalu besar: diharapkan ${r.origin??"value"} memiliki ${o}${r.maximum.toString()} ${s.unit??"elemen"}`:`Terlalu besar: diharapkan ${r.origin??"value"} menjadi ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`Terlalu kecil: diharapkan ${r.origin} memiliki ${o}${r.minimum.toString()} ${s.unit}`:`Terlalu kecil: diharapkan ${r.origin} menjadi ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`String tidak valid: harus dimulai dengan "${o.prefix}"`:o.format==="ends_with"?`String tidak valid: harus berakhir dengan "${o.suffix}"`:o.format==="includes"?`String tidak valid: harus menyertakan "${o.includes}"`:o.format==="regex"?`String tidak valid: harus sesuai pola ${o.pattern}`:`${n[o.format]??r.format} tidak valid`}case"not_multiple_of":return`Angka tidak valid: harus kelipatan dari ${r.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali ${r.keys.length>1?"s":""}: ${V(r.keys,", ")}`;case"invalid_key":return`Kunci tidak valid di ${r.origin}`;case"invalid_union":return"Input tidak valid";case"invalid_element":return`Nilai tidak valid di ${r.origin}`;default:return"Input tidak valid"}}}});function UF(){return{localeError:Are()}}var Are,HF=v(()=>{Ae();Are=()=>{let e={string:{unit:"stafi",verb:"a\xF0 hafa"},file:{unit:"b\xE6ti",verb:"a\xF0 hafa"},array:{unit:"hluti",verb:"a\xF0 hafa"},set:{unit:"hluti",verb:"a\xF0 hafa"}};function t(r){return e[r]??null}let n={regex:"gildi",email:"netfang",url:"vefsl\xF3\xF0",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dagsetning og t\xEDmi",date:"ISO dagsetning",time:"ISO t\xEDmi",duration:"ISO t\xEDmalengd",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded strengur",base64url:"base64url-encoded strengur",json_string:"JSON strengur",e164:"E.164 t\xF6lugildi",jwt:"JWT",template_literal:"gildi"},i={nan:"NaN",number:"n\xFAmer",array:"fylki"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Rangt gildi: \xDE\xFA sl\xF3st inn ${a} \xFEar sem \xE1 a\xF0 vera instanceof ${r.expected}`:`Rangt gildi: \xDE\xFA sl\xF3st inn ${a} \xFEar sem \xE1 a\xF0 vera ${o}`}case"invalid_value":return r.values.length===1?`Rangt gildi: gert r\xE1\xF0 fyrir ${se(r.values[0])}`:`\xD3gilt val: m\xE1 vera eitt af eftirfarandi ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${r.origin??"gildi"} hafi ${o}${r.maximum.toString()} ${s.unit??"hluti"}`:`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${r.origin??"gildi"} s\xE9 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${r.origin} hafi ${o}${r.minimum.toString()} ${s.unit}`:`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${r.origin} s\xE9 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 byrja \xE1 "${o.prefix}"`:o.format==="ends_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 enda \xE1 "${o.suffix}"`:o.format==="includes"?`\xD3gildur strengur: ver\xF0ur a\xF0 innihalda "${o.includes}"`:o.format==="regex"?`\xD3gildur strengur: ver\xF0ur a\xF0 fylgja mynstri ${o.pattern}`:`Rangt ${n[o.format]??r.format}`}case"not_multiple_of":return`R\xF6ng tala: ver\xF0ur a\xF0 vera margfeldi af ${r.divisor}`;case"unrecognized_keys":return`\xD3\xFEekkt ${r.keys.length>1?"ir lyklar":"ur lykill"}: ${V(r.keys,", ")}`;case"invalid_key":return`Rangur lykill \xED ${r.origin}`;case"invalid_union":return"Rangt gildi";case"invalid_element":return`Rangt gildi \xED ${r.origin}`;default:return"Rangt gildi"}}}});function VF(){return{localeError:Pre()}}var Pre,qF=v(()=>{Ae();Pre=()=>{let e={string:{unit:"caratteri",verb:"avere"},file:{unit:"byte",verb:"avere"},array:{unit:"elementi",verb:"avere"},set:{unit:"elementi",verb:"avere"}};function t(r){return e[r]??null}let n={regex:"input",email:"indirizzo email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e ora ISO",date:"data ISO",time:"ora ISO",duration:"durata ISO",ipv4:"indirizzo IPv4",ipv6:"indirizzo IPv6",cidrv4:"intervallo IPv4",cidrv6:"intervallo IPv6",base64:"stringa codificata in base64",base64url:"URL codificata in base64",json_string:"stringa JSON",e164:"numero E.164",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"numero",array:"vettore"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Input non valido: atteso instanceof ${r.expected}, ricevuto ${a}`:`Input non valido: atteso ${o}, ricevuto ${a}`}case"invalid_value":return r.values.length===1?`Input non valido: atteso ${se(r.values[0])}`:`Opzione non valida: atteso uno tra ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`Troppo grande: ${r.origin??"valore"} deve avere ${o}${r.maximum.toString()} ${s.unit??"elementi"}`:`Troppo grande: ${r.origin??"valore"} deve essere ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`Troppo piccolo: ${r.origin} deve avere ${o}${r.minimum.toString()} ${s.unit}`:`Troppo piccolo: ${r.origin} deve essere ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Stringa non valida: deve iniziare con "${o.prefix}"`:o.format==="ends_with"?`Stringa non valida: deve terminare con "${o.suffix}"`:o.format==="includes"?`Stringa non valida: deve includere "${o.includes}"`:o.format==="regex"?`Stringa non valida: deve corrispondere al pattern ${o.pattern}`:`Invalid ${n[o.format]??r.format}`}case"not_multiple_of":return`Numero non valido: deve essere un multiplo di ${r.divisor}`;case"unrecognized_keys":return`Chiav${r.keys.length>1?"i":"e"} non riconosciut${r.keys.length>1?"e":"a"}: ${V(r.keys,", ")}`;case"invalid_key":return`Chiave non valida in ${r.origin}`;case"invalid_union":return"Input non valido";case"invalid_element":return`Valore non valido in ${r.origin}`;default:return"Input non valido"}}}});function KF(){return{localeError:Ore()}}var Ore,JF=v(()=>{Ae();Ore=()=>{let e={string:{unit:"\u6587\u5B57",verb:"\u3067\u3042\u308B"},file:{unit:"\u30D0\u30A4\u30C8",verb:"\u3067\u3042\u308B"},array:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"},set:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"}};function t(r){return e[r]??null}let n={regex:"\u5165\u529B\u5024",email:"\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9",url:"URL",emoji:"\u7D75\u6587\u5B57",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u6642",date:"ISO\u65E5\u4ED8",time:"ISO\u6642\u523B",duration:"ISO\u671F\u9593",ipv4:"IPv4\u30A2\u30C9\u30EC\u30B9",ipv6:"IPv6\u30A2\u30C9\u30EC\u30B9",cidrv4:"IPv4\u7BC4\u56F2",cidrv6:"IPv6\u7BC4\u56F2",base64:"base64\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",base64url:"base64url\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",json_string:"JSON\u6587\u5B57\u5217",e164:"E.164\u756A\u53F7",jwt:"JWT",template_literal:"\u5165\u529B\u5024"},i={nan:"NaN",number:"\u6570\u5024",array:"\u914D\u5217"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u7121\u52B9\u306A\u5165\u529B: instanceof ${r.expected}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${a}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u5165\u529B: ${o}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${a}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`}case"invalid_value":return r.values.length===1?`\u7121\u52B9\u306A\u5165\u529B: ${se(r.values[0])}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u9078\u629E: ${V(r.values,"\u3001")}\u306E\u3044\u305A\u308C\u304B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"too_big":{let o=r.inclusive?"\u4EE5\u4E0B\u3067\u3042\u308B":"\u3088\u308A\u5C0F\u3055\u3044",s=t(r.origin);return s?`\u5927\u304D\u3059\u304E\u308B\u5024: ${r.origin??"\u5024"}\u306F${r.maximum.toString()}${s.unit??"\u8981\u7D20"}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5927\u304D\u3059\u304E\u308B\u5024: ${r.origin??"\u5024"}\u306F${r.maximum.toString()}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"too_small":{let o=r.inclusive?"\u4EE5\u4E0A\u3067\u3042\u308B":"\u3088\u308A\u5927\u304D\u3044",s=t(r.origin);return s?`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${r.origin}\u306F${r.minimum.toString()}${s.unit}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${r.origin}\u306F${r.minimum.toString()}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${o.prefix}"\u3067\u59CB\u307E\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:o.format==="ends_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${o.suffix}"\u3067\u7D42\u308F\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:o.format==="includes"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${o.includes}"\u3092\u542B\u3080\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:o.format==="regex"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: \u30D1\u30BF\u30FC\u30F3${o.pattern}\u306B\u4E00\u81F4\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u7121\u52B9\u306A${n[o.format]??r.format}`}case"not_multiple_of":return`\u7121\u52B9\u306A\u6570\u5024: ${r.divisor}\u306E\u500D\u6570\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"unrecognized_keys":return`\u8A8D\u8B58\u3055\u308C\u3066\u3044\u306A\u3044\u30AD\u30FC${r.keys.length>1?"\u7FA4":""}: ${V(r.keys,"\u3001")}`;case"invalid_key":return`${r.origin}\u5185\u306E\u7121\u52B9\u306A\u30AD\u30FC`;case"invalid_union":return"\u7121\u52B9\u306A\u5165\u529B";case"invalid_element":return`${r.origin}\u5185\u306E\u7121\u52B9\u306A\u5024`;default:return"\u7121\u52B9\u306A\u5165\u529B"}}}});function ZF(){return{localeError:Cre()}}var Cre,YF=v(()=>{Ae();Cre=()=>{let e={string:{unit:"\u10E1\u10D8\u10DB\u10D1\u10DD\u10DA\u10DD",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},file:{unit:"\u10D1\u10D0\u10D8\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},array:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},set:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"}};function t(r){return e[r]??null}let n={regex:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0",email:"\u10D4\u10DA-\u10E4\u10DD\u10E1\u10E2\u10D8\u10E1 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",url:"URL",emoji:"\u10D4\u10DB\u10DD\u10EF\u10D8",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8-\u10D3\u10E0\u10DD",date:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8",time:"\u10D3\u10E0\u10DD",duration:"\u10EE\u10D0\u10DC\u10D2\u10E0\u10EB\u10DA\u10D8\u10D5\u10DD\u10D1\u10D0",ipv4:"IPv4 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",ipv6:"IPv6 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",cidrv4:"IPv4 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",cidrv6:"IPv6 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",base64:"base64-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8",base64url:"base64url-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8",json_string:"JSON \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8",e164:"E.164 \u10DC\u10DD\u10DB\u10D4\u10E0\u10D8",jwt:"JWT",template_literal:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"},i={nan:"NaN",number:"\u10E0\u10D8\u10EA\u10EE\u10D5\u10D8",string:"\u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8",boolean:"\u10D1\u10E3\u10DA\u10D4\u10D0\u10DC\u10D8",function:"\u10E4\u10E3\u10DC\u10E5\u10EA\u10D8\u10D0",array:"\u10DB\u10D0\u10E1\u10D8\u10D5\u10D8"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 instanceof ${r.expected}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${a}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${o}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${a}`}case"invalid_value":return r.values.length===1?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${se(r.values[0])}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D0\u10E0\u10D8\u10D0\u10DC\u10E2\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8\u10D0 \u10D4\u10E0\u10D7-\u10D4\u10E0\u10D7\u10D8 ${V(r.values,"|")}-\u10D3\u10D0\u10DC`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${r.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} ${s.verb} ${o}${r.maximum.toString()} ${s.unit}`:`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${r.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} \u10D8\u10E7\u10DD\u10E1 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${r.origin} ${s.verb} ${o}${r.minimum.toString()} ${s.unit}`:`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${r.origin} \u10D8\u10E7\u10DD\u10E1 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10EC\u10E7\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${o.prefix}"-\u10D8\u10D7`:o.format==="ends_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10DB\u10D7\u10D0\u10D5\u10E0\u10D3\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${o.suffix}"-\u10D8\u10D7`:o.format==="includes"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1 "${o.includes}"-\u10E1`:o.format==="regex"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D4\u10E1\u10D0\u10D1\u10D0\u10DB\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 \u10E8\u10D0\u10D1\u10DA\u10DD\u10DC\u10E1 ${o.pattern}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 ${n[o.format]??r.format}`}case"not_multiple_of":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E0\u10D8\u10EA\u10EE\u10D5\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10E7\u10DD\u10E1 ${r.divisor}-\u10D8\u10E1 \u10EF\u10D4\u10E0\u10D0\u10D3\u10D8`;case"unrecognized_keys":return`\u10E3\u10EA\u10DC\u10DD\u10D1\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1${r.keys.length>1?"\u10D4\u10D1\u10D8":"\u10D8"}: ${V(r.keys,", ")}`;case"invalid_key":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1\u10D8 ${r.origin}-\u10E8\u10D8`;case"invalid_union":return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0";case"invalid_element":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0 ${r.origin}-\u10E8\u10D8`;default:return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"}}}});function Ay(){return{localeError:_re()}}var _re,EE=v(()=>{Ae();_re=()=>{let e={string:{unit:"\u178F\u17BD\u17A2\u1780\u17D2\u179F\u179A",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},file:{unit:"\u1794\u17C3",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},array:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},set:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"}};function t(r){return e[r]??null}let n={regex:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B",email:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793\u17A2\u17CA\u17B8\u1798\u17C2\u179B",url:"URL",emoji:"\u179F\u1789\u17D2\u1789\u17B6\u17A2\u17B6\u179A\u1798\u17D2\u1798\u178E\u17CD",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 \u1793\u17B7\u1784\u1798\u17C9\u17C4\u1784 ISO",date:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 ISO",time:"\u1798\u17C9\u17C4\u1784 ISO",duration:"\u179A\u1799\u17C8\u1796\u17C1\u179B ISO",ipv4:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",ipv6:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",cidrv4:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",cidrv6:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",base64:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64",base64url:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64url",json_string:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A JSON",e164:"\u179B\u17C1\u1781 E.164",jwt:"JWT",template_literal:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B"},i={nan:"NaN",number:"\u179B\u17C1\u1781",array:"\u17A2\u17B6\u179A\u17C1 (Array)",null:"\u1782\u17D2\u1798\u17B6\u1793\u178F\u1798\u17D2\u179B\u17C3 (null)"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A instanceof ${r.expected} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${a}`:`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${o} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${a}`}case"invalid_value":return r.values.length===1?`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${se(r.values[0])}`:`\u1787\u1798\u17D2\u179A\u17BE\u179F\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1787\u17B6\u1798\u17BD\u1799\u1780\u17D2\u1793\u17BB\u1784\u1785\u17C6\u178E\u17C4\u1798 ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${r.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${o} ${r.maximum.toString()} ${s.unit??"\u1792\u17B6\u178F\u17BB"}`:`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${r.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${o} ${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${r.origin} ${o} ${r.minimum.toString()} ${s.unit}`:`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${r.origin} ${o} ${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1785\u17B6\u1794\u17CB\u1795\u17D2\u178F\u17BE\u1798\u178A\u17C4\u1799 "${o.prefix}"`:o.format==="ends_with"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1794\u1789\u17D2\u1785\u1794\u17CB\u178A\u17C4\u1799 "${o.suffix}"`:o.format==="includes"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1798\u17B6\u1793 "${o.includes}"`:o.format==="regex"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1795\u17D2\u1782\u17BC\u1795\u17D2\u1782\u1784\u1793\u17B9\u1784\u1791\u1798\u17D2\u179A\u1784\u17CB\u178A\u17C2\u179B\u1794\u17B6\u1793\u1780\u17C6\u178E\u178F\u17CB ${o.pattern}`:`\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 ${n[o.format]??r.format}`}case"not_multiple_of":return`\u179B\u17C1\u1781\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1787\u17B6\u1796\u17A0\u17BB\u1782\u17BB\u178E\u1793\u17C3 ${r.divisor}`;case"unrecognized_keys":return`\u179A\u1780\u1783\u17BE\u1789\u179F\u17C4\u1798\u17B7\u1793\u179F\u17D2\u1782\u17B6\u179B\u17CB\u17D6 ${V(r.keys,", ")}`;case"invalid_key":return`\u179F\u17C4\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${r.origin}`;case"invalid_union":return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C";case"invalid_element":return`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${r.origin}`;default:return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C"}}}});function XF(){return Ay()}var QF=v(()=>{EE()});function eB(){return{localeError:Ire()}}var Ire,tB=v(()=>{Ae();Ire=()=>{let e={string:{unit:"\uBB38\uC790",verb:"to have"},file:{unit:"\uBC14\uC774\uD2B8",verb:"to have"},array:{unit:"\uAC1C",verb:"to have"},set:{unit:"\uAC1C",verb:"to have"}};function t(r){return e[r]??null}let n={regex:"\uC785\uB825",email:"\uC774\uBA54\uC77C \uC8FC\uC18C",url:"URL",emoji:"\uC774\uBAA8\uC9C0",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \uB0A0\uC9DC\uC2DC\uAC04",date:"ISO \uB0A0\uC9DC",time:"ISO \uC2DC\uAC04",duration:"ISO \uAE30\uAC04",ipv4:"IPv4 \uC8FC\uC18C",ipv6:"IPv6 \uC8FC\uC18C",cidrv4:"IPv4 \uBC94\uC704",cidrv6:"IPv6 \uBC94\uC704",base64:"base64 \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",base64url:"base64url \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",json_string:"JSON \uBB38\uC790\uC5F4",e164:"E.164 \uBC88\uD638",jwt:"JWT",template_literal:"\uC785\uB825"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 instanceof ${r.expected}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${a}\uC785\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 ${o}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${a}\uC785\uB2C8\uB2E4`}case"invalid_value":return r.values.length===1?`\uC798\uBABB\uB41C \uC785\uB825: \uAC12\uC740 ${se(r.values[0])} \uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC635\uC158: ${V(r.values,"\uB610\uB294 ")} \uC911 \uD558\uB098\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"too_big":{let o=r.inclusive?"\uC774\uD558":"\uBBF8\uB9CC",s=o==="\uBBF8\uB9CC"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",a=t(r.origin),l=a?.unit??"\uC694\uC18C";return a?`${r.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${r.maximum.toString()}${l} ${o}${s}`:`${r.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${r.maximum.toString()} ${o}${s}`}case"too_small":{let o=r.inclusive?"\uC774\uC0C1":"\uCD08\uACFC",s=o==="\uC774\uC0C1"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",a=t(r.origin),l=a?.unit??"\uC694\uC18C";return a?`${r.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${r.minimum.toString()}${l} ${o}${s}`:`${r.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${r.minimum.toString()} ${o}${s}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${o.prefix}"(\uC73C)\uB85C \uC2DC\uC791\uD574\uC57C \uD569\uB2C8\uB2E4`:o.format==="ends_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${o.suffix}"(\uC73C)\uB85C \uB05D\uB098\uC57C \uD569\uB2C8\uB2E4`:o.format==="includes"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${o.includes}"\uC744(\uB97C) \uD3EC\uD568\uD574\uC57C \uD569\uB2C8\uB2E4`:o.format==="regex"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: \uC815\uADDC\uC2DD ${o.pattern} \uD328\uD134\uACFC \uC77C\uCE58\uD574\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C ${n[o.format]??r.format}`}case"not_multiple_of":return`\uC798\uBABB\uB41C \uC22B\uC790: ${r.divisor}\uC758 \uBC30\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"unrecognized_keys":return`\uC778\uC2DD\uD560 \uC218 \uC5C6\uB294 \uD0A4: ${V(r.keys,", ")}`;case"invalid_key":return`\uC798\uBABB\uB41C \uD0A4: ${r.origin}`;case"invalid_union":return"\uC798\uBABB\uB41C \uC785\uB825";case"invalid_element":return`\uC798\uBABB\uB41C \uAC12: ${r.origin}`;default:return"\uC798\uBABB\uB41C \uC785\uB825"}}}});function nB(e){let t=Math.abs(e),n=t%10,i=t%100;return i>=11&&i<=19||n===0?"many":n===1?"one":"few"}function rB(){return{localeError:Tre()}}var Zp,Tre,iB=v(()=>{Ae();Zp=e=>e.charAt(0).toUpperCase()+e.slice(1);Tre=()=>{let e={string:{unit:{one:"simbolis",few:"simboliai",many:"simboli\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne ilgesn\u0117 kaip",notInclusive:"turi b\u016Bti trumpesn\u0117 kaip"},bigger:{inclusive:"turi b\u016Bti ne trumpesn\u0117 kaip",notInclusive:"turi b\u016Bti ilgesn\u0117 kaip"}}},file:{unit:{one:"baitas",few:"baitai",many:"bait\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne didesnis kaip",notInclusive:"turi b\u016Bti ma\u017Eesnis kaip"},bigger:{inclusive:"turi b\u016Bti ne ma\u017Eesnis kaip",notInclusive:"turi b\u016Bti didesnis kaip"}}},array:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}},set:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}}};function t(r,o,s,a){let l=e[r]??null;return l===null?l:{unit:l.unit[o],verb:l.verb[a][s?"inclusive":"notInclusive"]}}let n={regex:"\u012Fvestis",email:"el. pa\u0161to adresas",url:"URL",emoji:"jaustukas",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO data ir laikas",date:"ISO data",time:"ISO laikas",duration:"ISO trukm\u0117",ipv4:"IPv4 adresas",ipv6:"IPv6 adresas",cidrv4:"IPv4 tinklo prefiksas (CIDR)",cidrv6:"IPv6 tinklo prefiksas (CIDR)",base64:"base64 u\u017Ekoduota eilut\u0117",base64url:"base64url u\u017Ekoduota eilut\u0117",json_string:"JSON eilut\u0117",e164:"E.164 numeris",jwt:"JWT",template_literal:"\u012Fvestis"},i={nan:"NaN",number:"skai\u010Dius",bigint:"sveikasis skai\u010Dius",string:"eilut\u0117",boolean:"login\u0117 reik\u0161m\u0117",undefined:"neapibr\u0117\u017Eta reik\u0161m\u0117",function:"funkcija",symbol:"simbolis",array:"masyvas",object:"objektas",null:"nulin\u0117 reik\u0161m\u0117"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Gautas tipas ${a}, o tik\u0117tasi - instanceof ${r.expected}`:`Gautas tipas ${a}, o tik\u0117tasi - ${o}`}case"invalid_value":return r.values.length===1?`Privalo b\u016Bti ${se(r.values[0])}`:`Privalo b\u016Bti vienas i\u0161 ${V(r.values,"|")} pasirinkim\u0173`;case"too_big":{let o=i[r.origin]??r.origin,s=t(r.origin,nB(Number(r.maximum)),r.inclusive??!1,"smaller");if(s?.verb)return`${Zp(o??r.origin??"reik\u0161m\u0117")} ${s.verb} ${r.maximum.toString()} ${s.unit??"element\u0173"}`;let a=r.inclusive?"ne didesnis kaip":"ma\u017Eesnis kaip";return`${Zp(o??r.origin??"reik\u0161m\u0117")} turi b\u016Bti ${a} ${r.maximum.toString()} ${s?.unit}`}case"too_small":{let o=i[r.origin]??r.origin,s=t(r.origin,nB(Number(r.minimum)),r.inclusive??!1,"bigger");if(s?.verb)return`${Zp(o??r.origin??"reik\u0161m\u0117")} ${s.verb} ${r.minimum.toString()} ${s.unit??"element\u0173"}`;let a=r.inclusive?"ne ma\u017Eesnis kaip":"didesnis kaip";return`${Zp(o??r.origin??"reik\u0161m\u0117")} turi b\u016Bti ${a} ${r.minimum.toString()} ${s?.unit}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Eilut\u0117 privalo prasid\u0117ti "${o.prefix}"`:o.format==="ends_with"?`Eilut\u0117 privalo pasibaigti "${o.suffix}"`:o.format==="includes"?`Eilut\u0117 privalo \u012Ftraukti "${o.includes}"`:o.format==="regex"?`Eilut\u0117 privalo atitikti ${o.pattern}`:`Neteisingas ${n[o.format]??r.format}`}case"not_multiple_of":return`Skai\u010Dius privalo b\u016Bti ${r.divisor} kartotinis.`;case"unrecognized_keys":return`Neatpa\u017Eint${r.keys.length>1?"i":"as"} rakt${r.keys.length>1?"ai":"as"}: ${V(r.keys,", ")}`;case"invalid_key":return"Rastas klaidingas raktas";case"invalid_union":return"Klaidinga \u012Fvestis";case"invalid_element":{let o=i[r.origin]??r.origin;return`${Zp(o??r.origin??"reik\u0161m\u0117")} turi klaiding\u0105 \u012Fvest\u012F`}default:return"Klaidinga \u012Fvestis"}}}});function oB(){return{localeError:Dre()}}var Dre,sB=v(()=>{Ae();Dre=()=>{let e={string:{unit:"\u0437\u043D\u0430\u0446\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},file:{unit:"\u0431\u0430\u0458\u0442\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},array:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},set:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"}};function t(r){return e[r]??null}let n={regex:"\u0432\u043D\u0435\u0441",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u043D\u0430 \u0435-\u043F\u043E\u0448\u0442\u0430",url:"URL",emoji:"\u0435\u043C\u043E\u045F\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0443\u043C \u0438 \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0443\u043C",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u0432\u0440\u0435\u043C\u0435\u0442\u0440\u0430\u0435\u045A\u0435",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441\u0430",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441\u0430",cidrv4:"IPv4 \u043E\u043F\u0441\u0435\u0433",cidrv6:"IPv6 \u043E\u043F\u0441\u0435\u0433",base64:"base64-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",base64url:"base64url-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",json_string:"JSON \u043D\u0438\u0437\u0430",e164:"E.164 \u0431\u0440\u043E\u0458",jwt:"JWT",template_literal:"\u0432\u043D\u0435\u0441"},i={nan:"NaN",number:"\u0431\u0440\u043E\u0458",array:"\u043D\u0438\u0437\u0430"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 instanceof ${r.expected}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${a}`:`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${o}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${a}`}case"invalid_value":return r.values.length===1?`Invalid input: expected ${se(r.values[0])}`:`\u0413\u0440\u0435\u0448\u0430\u043D\u0430 \u043E\u043F\u0446\u0438\u0458\u0430: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 \u0435\u0434\u043D\u0430 ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${r.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0438\u043C\u0430 ${o}${r.maximum.toString()} ${s.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0438"}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${r.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0431\u0438\u0434\u0435 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${r.origin} \u0434\u0430 \u0438\u043C\u0430 ${o}${r.minimum.toString()} ${s.unit}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${r.origin} \u0434\u0430 \u0431\u0438\u0434\u0435 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u043D\u0443\u0432\u0430 \u0441\u043E "${o.prefix}"`:o.format==="ends_with"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u0432\u0440\u0448\u0443\u0432\u0430 \u0441\u043E "${o.suffix}"`:o.format==="includes"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0432\u043A\u043B\u0443\u0447\u0443\u0432\u0430 "${o.includes}"`:o.format==="regex"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u043E\u0434\u0433\u043E\u0430\u0440\u0430 \u043D\u0430 \u043F\u0430\u0442\u0435\u0440\u043D\u043E\u0442 ${o.pattern}`:`Invalid ${n[o.format]??r.format}`}case"not_multiple_of":return`\u0413\u0440\u0435\u0448\u0435\u043D \u0431\u0440\u043E\u0458: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0431\u0438\u0434\u0435 \u0434\u0435\u043B\u0438\u0432 \u0441\u043E ${r.divisor}`;case"unrecognized_keys":return`${r.keys.length>1?"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D\u0438 \u043A\u043B\u0443\u0447\u0435\u0432\u0438":"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D \u043A\u043B\u0443\u0447"}: ${V(r.keys,", ")}`;case"invalid_key":return`\u0413\u0440\u0435\u0448\u0435\u043D \u043A\u043B\u0443\u0447 \u0432\u043E ${r.origin}`;case"invalid_union":return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441";case"invalid_element":return`\u0413\u0440\u0435\u0448\u043D\u0430 \u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442 \u0432\u043E ${r.origin}`;default:return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441"}}}});function aB(){return{localeError:Nre()}}var Nre,cB=v(()=>{Ae();Nre=()=>{let e={string:{unit:"aksara",verb:"mempunyai"},file:{unit:"bait",verb:"mempunyai"},array:{unit:"elemen",verb:"mempunyai"},set:{unit:"elemen",verb:"mempunyai"}};function t(r){return e[r]??null}let n={regex:"input",email:"alamat e-mel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tarikh masa ISO",date:"tarikh ISO",time:"masa ISO",duration:"tempoh ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"julat IPv4",cidrv6:"julat IPv6",base64:"string dikodkan base64",base64url:"string dikodkan base64url",json_string:"string JSON",e164:"nombor E.164",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"nombor"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Input tidak sah: dijangka instanceof ${r.expected}, diterima ${a}`:`Input tidak sah: dijangka ${o}, diterima ${a}`}case"invalid_value":return r.values.length===1?`Input tidak sah: dijangka ${se(r.values[0])}`:`Pilihan tidak sah: dijangka salah satu daripada ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`Terlalu besar: dijangka ${r.origin??"nilai"} ${s.verb} ${o}${r.maximum.toString()} ${s.unit??"elemen"}`:`Terlalu besar: dijangka ${r.origin??"nilai"} adalah ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`Terlalu kecil: dijangka ${r.origin} ${s.verb} ${o}${r.minimum.toString()} ${s.unit}`:`Terlalu kecil: dijangka ${r.origin} adalah ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`String tidak sah: mesti bermula dengan "${o.prefix}"`:o.format==="ends_with"?`String tidak sah: mesti berakhir dengan "${o.suffix}"`:o.format==="includes"?`String tidak sah: mesti mengandungi "${o.includes}"`:o.format==="regex"?`String tidak sah: mesti sepadan dengan corak ${o.pattern}`:`${n[o.format]??r.format} tidak sah`}case"not_multiple_of":return`Nombor tidak sah: perlu gandaan ${r.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali: ${V(r.keys,", ")}`;case"invalid_key":return`Kunci tidak sah dalam ${r.origin}`;case"invalid_union":return"Input tidak sah";case"invalid_element":return`Nilai tidak sah dalam ${r.origin}`;default:return"Input tidak sah"}}}});function lB(){return{localeError:jre()}}var jre,uB=v(()=>{Ae();jre=()=>{let e={string:{unit:"tekens",verb:"heeft"},file:{unit:"bytes",verb:"heeft"},array:{unit:"elementen",verb:"heeft"},set:{unit:"elementen",verb:"heeft"}};function t(r){return e[r]??null}let n={regex:"invoer",email:"emailadres",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum en tijd",date:"ISO datum",time:"ISO tijd",duration:"ISO duur",ipv4:"IPv4-adres",ipv6:"IPv6-adres",cidrv4:"IPv4-bereik",cidrv6:"IPv6-bereik",base64:"base64-gecodeerde tekst",base64url:"base64 URL-gecodeerde tekst",json_string:"JSON string",e164:"E.164-nummer",jwt:"JWT",template_literal:"invoer"},i={nan:"NaN",number:"getal"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Ongeldige invoer: verwacht instanceof ${r.expected}, ontving ${a}`:`Ongeldige invoer: verwacht ${o}, ontving ${a}`}case"invalid_value":return r.values.length===1?`Ongeldige invoer: verwacht ${se(r.values[0])}`:`Ongeldige optie: verwacht \xE9\xE9n van ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin),a=r.origin==="date"?"laat":r.origin==="string"?"lang":"groot";return s?`Te ${a}: verwacht dat ${r.origin??"waarde"} ${o}${r.maximum.toString()} ${s.unit??"elementen"} ${s.verb}`:`Te ${a}: verwacht dat ${r.origin??"waarde"} ${o}${r.maximum.toString()} is`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin),a=r.origin==="date"?"vroeg":r.origin==="string"?"kort":"klein";return s?`Te ${a}: verwacht dat ${r.origin} ${o}${r.minimum.toString()} ${s.unit} ${s.verb}`:`Te ${a}: verwacht dat ${r.origin} ${o}${r.minimum.toString()} is`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Ongeldige tekst: moet met "${o.prefix}" beginnen`:o.format==="ends_with"?`Ongeldige tekst: moet op "${o.suffix}" eindigen`:o.format==="includes"?`Ongeldige tekst: moet "${o.includes}" bevatten`:o.format==="regex"?`Ongeldige tekst: moet overeenkomen met patroon ${o.pattern}`:`Ongeldig: ${n[o.format]??r.format}`}case"not_multiple_of":return`Ongeldig getal: moet een veelvoud van ${r.divisor} zijn`;case"unrecognized_keys":return`Onbekende key${r.keys.length>1?"s":""}: ${V(r.keys,", ")}`;case"invalid_key":return`Ongeldige key in ${r.origin}`;case"invalid_union":return"Ongeldige invoer";case"invalid_element":return`Ongeldige waarde in ${r.origin}`;default:return"Ongeldige invoer"}}}});function dB(){return{localeError:Lre()}}var Lre,pB=v(()=>{Ae();Lre=()=>{let e={string:{unit:"tegn",verb:"\xE5 ha"},file:{unit:"bytes",verb:"\xE5 ha"},array:{unit:"elementer",verb:"\xE5 inneholde"},set:{unit:"elementer",verb:"\xE5 inneholde"}};function t(r){return e[r]??null}let n={regex:"input",email:"e-postadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslett",date:"ISO-dato",time:"ISO-klokkeslett",duration:"ISO-varighet",ipv4:"IPv4-omr\xE5de",ipv6:"IPv6-omr\xE5de",cidrv4:"IPv4-spekter",cidrv6:"IPv6-spekter",base64:"base64-enkodet streng",base64url:"base64url-enkodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"tall",array:"liste"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Ugyldig input: forventet instanceof ${r.expected}, fikk ${a}`:`Ugyldig input: forventet ${o}, fikk ${a}`}case"invalid_value":return r.values.length===1?`Ugyldig verdi: forventet ${se(r.values[0])}`:`Ugyldig valg: forventet en av ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`For stor(t): forventet ${r.origin??"value"} til \xE5 ha ${o}${r.maximum.toString()} ${s.unit??"elementer"}`:`For stor(t): forventet ${r.origin??"value"} til \xE5 ha ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`For lite(n): forventet ${r.origin} til \xE5 ha ${o}${r.minimum.toString()} ${s.unit}`:`For lite(n): forventet ${r.origin} til \xE5 ha ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Ugyldig streng: m\xE5 starte med "${o.prefix}"`:o.format==="ends_with"?`Ugyldig streng: m\xE5 ende med "${o.suffix}"`:o.format==="includes"?`Ugyldig streng: m\xE5 inneholde "${o.includes}"`:o.format==="regex"?`Ugyldig streng: m\xE5 matche m\xF8nsteret ${o.pattern}`:`Ugyldig ${n[o.format]??r.format}`}case"not_multiple_of":return`Ugyldig tall: m\xE5 v\xE6re et multiplum av ${r.divisor}`;case"unrecognized_keys":return`${r.keys.length>1?"Ukjente n\xF8kler":"Ukjent n\xF8kkel"}: ${V(r.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8kkel i ${r.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${r.origin}`;default:return"Ugyldig input"}}}});function fB(){return{localeError:Mre()}}var Mre,mB=v(()=>{Ae();Mre=()=>{let e={string:{unit:"harf",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"unsur",verb:"olmal\u0131d\u0131r"},set:{unit:"unsur",verb:"olmal\u0131d\u0131r"}};function t(r){return e[r]??null}let n={regex:"giren",email:"epostag\xE2h",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO heng\xE2m\u0131",date:"ISO tarihi",time:"ISO zaman\u0131",duration:"ISO m\xFCddeti",ipv4:"IPv4 ni\u015F\xE2n\u0131",ipv6:"IPv6 ni\u015F\xE2n\u0131",cidrv4:"IPv4 menzili",cidrv6:"IPv6 menzili",base64:"base64-\u015Fifreli metin",base64url:"base64url-\u015Fifreli metin",json_string:"JSON metin",e164:"E.164 say\u0131s\u0131",jwt:"JWT",template_literal:"giren"},i={nan:"NaN",number:"numara",array:"saf",null:"gayb"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`F\xE2sit giren: umulan instanceof ${r.expected}, al\u0131nan ${a}`:`F\xE2sit giren: umulan ${o}, al\u0131nan ${a}`}case"invalid_value":return r.values.length===1?`F\xE2sit giren: umulan ${se(r.values[0])}`:`F\xE2sit tercih: m\xFBteberler ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`Fazla b\xFCy\xFCk: ${r.origin??"value"}, ${o}${r.maximum.toString()} ${s.unit??"elements"} sahip olmal\u0131yd\u0131.`:`Fazla b\xFCy\xFCk: ${r.origin??"value"}, ${o}${r.maximum.toString()} olmal\u0131yd\u0131.`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`Fazla k\xFC\xE7\xFCk: ${r.origin}, ${o}${r.minimum.toString()} ${s.unit} sahip olmal\u0131yd\u0131.`:`Fazla k\xFC\xE7\xFCk: ${r.origin}, ${o}${r.minimum.toString()} olmal\u0131yd\u0131.`}case"invalid_format":{let o=r;return o.format==="starts_with"?`F\xE2sit metin: "${o.prefix}" ile ba\u015Flamal\u0131.`:o.format==="ends_with"?`F\xE2sit metin: "${o.suffix}" ile bitmeli.`:o.format==="includes"?`F\xE2sit metin: "${o.includes}" ihtiv\xE2 etmeli.`:o.format==="regex"?`F\xE2sit metin: ${o.pattern} nak\u015F\u0131na uymal\u0131.`:`F\xE2sit ${n[o.format]??r.format}`}case"not_multiple_of":return`F\xE2sit say\u0131: ${r.divisor} kat\u0131 olmal\u0131yd\u0131.`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar ${r.keys.length>1?"s":""}: ${V(r.keys,", ")}`;case"invalid_key":return`${r.origin} i\xE7in tan\u0131nmayan anahtar var.`;case"invalid_union":return"Giren tan\u0131namad\u0131.";case"invalid_element":return`${r.origin} i\xE7in tan\u0131nmayan k\u0131ymet var.`;default:return"K\u0131ymet tan\u0131namad\u0131."}}}});function gB(){return{localeError:Fre()}}var Fre,hB=v(()=>{Ae();Fre=()=>{let e={string:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},file:{unit:"\u0628\u0627\u06CC\u067C\u0633",verb:"\u0648\u0644\u0631\u064A"},array:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},set:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"}};function t(r){return e[r]??null}let n={regex:"\u0648\u0631\u0648\u062F\u064A",email:"\u0628\u0631\u06CC\u069A\u0646\u0627\u0644\u06CC\u06A9",url:"\u06CC\u0648 \u0622\u0631 \u0627\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0646\u06CC\u067C\u0647 \u0627\u0648 \u0648\u062E\u062A",date:"\u0646\u06D0\u067C\u0647",time:"\u0648\u062E\u062A",duration:"\u0645\u0648\u062F\u0647",ipv4:"\u062F IPv4 \u067E\u062A\u0647",ipv6:"\u062F IPv6 \u067E\u062A\u0647",cidrv4:"\u062F IPv4 \u0633\u0627\u062D\u0647",cidrv6:"\u062F IPv6 \u0633\u0627\u062D\u0647",base64:"base64-encoded \u0645\u062A\u0646",base64url:"base64url-encoded \u0645\u062A\u0646",json_string:"JSON \u0645\u062A\u0646",e164:"\u062F E.164 \u0634\u0645\u06D0\u0631\u0647",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u064A"},i={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0627\u0631\u06D0"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F instanceof ${r.expected} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${a} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`:`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${o} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${a} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`}case"invalid_value":return r.values.length===1?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${se(r.values[0])} \u0648\u0627\u06CC`:`\u0646\u0627\u0633\u0645 \u0627\u0646\u062A\u062E\u0627\u0628: \u0628\u0627\u06CC\u062F \u06CC\u0648 \u0644\u0647 ${V(r.values,"|")} \u0685\u062E\u0647 \u0648\u0627\u06CC`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${r.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${o}${r.maximum.toString()} ${s.unit??"\u0639\u0646\u0635\u0631\u0648\u0646\u0647"} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${r.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${o}${r.maximum.toString()} \u0648\u064A`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${r.origin} \u0628\u0627\u06CC\u062F ${o}${r.minimum.toString()} ${s.unit} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${r.origin} \u0628\u0627\u06CC\u062F ${o}${r.minimum.toString()} \u0648\u064A`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${o.prefix}" \u0633\u0631\u0647 \u067E\u06CC\u0644 \u0634\u064A`:o.format==="ends_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${o.suffix}" \u0633\u0631\u0647 \u067E\u0627\u06CC \u062A\u0647 \u0648\u0631\u0633\u064A\u0696\u064A`:o.format==="includes"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F "${o.includes}" \u0648\u0644\u0631\u064A`:o.format==="regex"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F ${o.pattern} \u0633\u0631\u0647 \u0645\u0637\u0627\u0628\u0642\u062A \u0648\u0644\u0631\u064A`:`${n[o.format]??r.format} \u0646\u0627\u0633\u0645 \u062F\u06CC`}case"not_multiple_of":return`\u0646\u0627\u0633\u0645 \u0639\u062F\u062F: \u0628\u0627\u06CC\u062F \u062F ${r.divisor} \u0645\u0636\u0631\u0628 \u0648\u064A`;case"unrecognized_keys":return`\u0646\u0627\u0633\u0645 ${r.keys.length>1?"\u06A9\u0644\u06CC\u0689\u0648\u0646\u0647":"\u06A9\u0644\u06CC\u0689"}: ${V(r.keys,", ")}`;case"invalid_key":return`\u0646\u0627\u0633\u0645 \u06A9\u0644\u06CC\u0689 \u067E\u0647 ${r.origin} \u06A9\u06D0`;case"invalid_union":return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A";case"invalid_element":return`\u0646\u0627\u0633\u0645 \u0639\u0646\u0635\u0631 \u067E\u0647 ${r.origin} \u06A9\u06D0`;default:return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A"}}}});function yB(){return{localeError:Bre()}}var Bre,bB=v(()=>{Ae();Bre=()=>{let e={string:{unit:"znak\xF3w",verb:"mie\u0107"},file:{unit:"bajt\xF3w",verb:"mie\u0107"},array:{unit:"element\xF3w",verb:"mie\u0107"},set:{unit:"element\xF3w",verb:"mie\u0107"}};function t(r){return e[r]??null}let n={regex:"wyra\u017Cenie",email:"adres email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i godzina w formacie ISO",date:"data w formacie ISO",time:"godzina w formacie ISO",duration:"czas trwania ISO",ipv4:"adres IPv4",ipv6:"adres IPv6",cidrv4:"zakres IPv4",cidrv6:"zakres IPv6",base64:"ci\u0105g znak\xF3w zakodowany w formacie base64",base64url:"ci\u0105g znak\xF3w zakodowany w formacie base64url",json_string:"ci\u0105g znak\xF3w w formacie JSON",e164:"liczba E.164",jwt:"JWT",template_literal:"wej\u015Bcie"},i={nan:"NaN",number:"liczba",array:"tablica"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano instanceof ${r.expected}, otrzymano ${a}`:`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${o}, otrzymano ${a}`}case"invalid_value":return r.values.length===1?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${se(r.values[0])}`:`Nieprawid\u0142owa opcja: oczekiwano jednej z warto\u015Bci ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`Za du\u017Ca warto\u015B\u0107: oczekiwano, \u017Ce ${r.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${o}${r.maximum.toString()} ${s.unit??"element\xF3w"}`:`Zbyt du\u017C(y/a/e): oczekiwano, \u017Ce ${r.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`Za ma\u0142a warto\u015B\u0107: oczekiwano, \u017Ce ${r.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${o}${r.minimum.toString()} ${s.unit??"element\xF3w"}`:`Zbyt ma\u0142(y/a/e): oczekiwano, \u017Ce ${r.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zaczyna\u0107 si\u0119 od "${o.prefix}"`:o.format==="ends_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi ko\u0144czy\u0107 si\u0119 na "${o.suffix}"`:o.format==="includes"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zawiera\u0107 "${o.includes}"`:o.format==="regex"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi odpowiada\u0107 wzorcowi ${o.pattern}`:`Nieprawid\u0142ow(y/a/e) ${n[o.format]??r.format}`}case"not_multiple_of":return`Nieprawid\u0142owa liczba: musi by\u0107 wielokrotno\u015Bci\u0105 ${r.divisor}`;case"unrecognized_keys":return`Nierozpoznane klucze${r.keys.length>1?"s":""}: ${V(r.keys,", ")}`;case"invalid_key":return`Nieprawid\u0142owy klucz w ${r.origin}`;case"invalid_union":return"Nieprawid\u0142owe dane wej\u015Bciowe";case"invalid_element":return`Nieprawid\u0142owa warto\u015B\u0107 w ${r.origin}`;default:return"Nieprawid\u0142owe dane wej\u015Bciowe"}}}});function wB(){return{localeError:Gre()}}var Gre,vB=v(()=>{Ae();Gre=()=>{let e={string:{unit:"caracteres",verb:"ter"},file:{unit:"bytes",verb:"ter"},array:{unit:"itens",verb:"ter"},set:{unit:"itens",verb:"ter"}};function t(r){return e[r]??null}let n={regex:"padr\xE3o",email:"endere\xE7o de e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e hora ISO",date:"data ISO",time:"hora ISO",duration:"dura\xE7\xE3o ISO",ipv4:"endere\xE7o IPv4",ipv6:"endere\xE7o IPv6",cidrv4:"faixa de IPv4",cidrv6:"faixa de IPv6",base64:"texto codificado em base64",base64url:"URL codificada em base64",json_string:"texto JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},i={nan:"NaN",number:"n\xFAmero",null:"nulo"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Tipo inv\xE1lido: esperado instanceof ${r.expected}, recebido ${a}`:`Tipo inv\xE1lido: esperado ${o}, recebido ${a}`}case"invalid_value":return r.values.length===1?`Entrada inv\xE1lida: esperado ${se(r.values[0])}`:`Op\xE7\xE3o inv\xE1lida: esperada uma das ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`Muito grande: esperado que ${r.origin??"valor"} tivesse ${o}${r.maximum.toString()} ${s.unit??"elementos"}`:`Muito grande: esperado que ${r.origin??"valor"} fosse ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`Muito pequeno: esperado que ${r.origin} tivesse ${o}${r.minimum.toString()} ${s.unit}`:`Muito pequeno: esperado que ${r.origin} fosse ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Texto inv\xE1lido: deve come\xE7ar com "${o.prefix}"`:o.format==="ends_with"?`Texto inv\xE1lido: deve terminar com "${o.suffix}"`:o.format==="includes"?`Texto inv\xE1lido: deve incluir "${o.includes}"`:o.format==="regex"?`Texto inv\xE1lido: deve corresponder ao padr\xE3o ${o.pattern}`:`${n[o.format]??r.format} inv\xE1lido`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${r.divisor}`;case"unrecognized_keys":return`Chave${r.keys.length>1?"s":""} desconhecida${r.keys.length>1?"s":""}: ${V(r.keys,", ")}`;case"invalid_key":return`Chave inv\xE1lida em ${r.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido em ${r.origin}`;default:return"Campo inv\xE1lido"}}}});function kB(e,t,n,i){let r=Math.abs(e),o=r%10,s=r%100;return s>=11&&s<=19?i:o===1?t:o>=2&&o<=4?n:i}function xB(){return{localeError:Wre()}}var Wre,$B=v(()=>{Ae();Wre=()=>{let e={string:{unit:{one:"\u0441\u0438\u043C\u0432\u043E\u043B",few:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",many:"\u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u0430",many:"\u0431\u0430\u0439\u0442"},verb:"\u0438\u043C\u0435\u0442\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"}};function t(r){return e[r]??null}let n={regex:"\u0432\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0438 \u0432\u0440\u0435\u043C\u044F",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u044F",duration:"ISO \u0434\u043B\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64",base64url:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64url",json_string:"JSON \u0441\u0442\u0440\u043E\u043A\u0430",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",jwt:"JWT",template_literal:"\u0432\u0432\u043E\u0434"},i={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0441\u0438\u0432"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C instanceof ${r.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${a}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${o}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${a}`}case"invalid_value":return r.values.length===1?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${se(r.values[0])}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0430\u0440\u0438\u0430\u043D\u0442: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C \u043E\u0434\u043D\u043E \u0438\u0437 ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);if(s){let a=Number(r.maximum),l=kB(a,s.unit.one,s.unit.few,s.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${o}${r.maximum.toString()} ${l}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);if(s){let a=Number(r.minimum),l=kB(a,s.unit.one,s.unit.few,s.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${r.origin} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${o}${r.minimum.toString()} ${l}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${r.origin} \u0431\u0443\u0434\u0435\u0442 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u043D\u0430\u0447\u0438\u043D\u0430\u0442\u044C\u0441\u044F \u0441 "${o.prefix}"`:o.format==="ends_with"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0437\u0430\u043A\u0430\u043D\u0447\u0438\u0432\u0430\u0442\u044C\u0441\u044F \u043D\u0430 "${o.suffix}"`:o.format==="includes"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u0434\u0435\u0440\u0436\u0430\u0442\u044C "${o.includes}"`:o.format==="regex"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043E\u0432\u0430\u0442\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${o.pattern}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 ${n[o.format]??r.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0447\u0438\u0441\u043B\u043E: \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${r.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u043E\u0437\u043D\u0430\u043D\u043D${r.keys.length>1?"\u044B\u0435":"\u044B\u0439"} \u043A\u043B\u044E\u0447${r.keys.length>1?"\u0438":""}: ${V(r.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043A\u043B\u044E\u0447 \u0432 ${r.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435";case"invalid_element":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0432 ${r.origin}`;default:return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435"}}}});function RB(){return{localeError:zre()}}var zre,SB=v(()=>{Ae();zre=()=>{let e={string:{unit:"znakov",verb:"imeti"},file:{unit:"bajtov",verb:"imeti"},array:{unit:"elementov",verb:"imeti"},set:{unit:"elementov",verb:"imeti"}};function t(r){return e[r]??null}let n={regex:"vnos",email:"e-po\u0161tni naslov",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum in \u010Das",date:"ISO datum",time:"ISO \u010Das",duration:"ISO trajanje",ipv4:"IPv4 naslov",ipv6:"IPv6 naslov",cidrv4:"obseg IPv4",cidrv6:"obseg IPv6",base64:"base64 kodiran niz",base64url:"base64url kodiran niz",json_string:"JSON niz",e164:"E.164 \u0161tevilka",jwt:"JWT",template_literal:"vnos"},i={nan:"NaN",number:"\u0161tevilo",array:"tabela"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Neveljaven vnos: pri\u010Dakovano instanceof ${r.expected}, prejeto ${a}`:`Neveljaven vnos: pri\u010Dakovano ${o}, prejeto ${a}`}case"invalid_value":return r.values.length===1?`Neveljaven vnos: pri\u010Dakovano ${se(r.values[0])}`:`Neveljavna mo\u017Enost: pri\u010Dakovano eno izmed ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`Preveliko: pri\u010Dakovano, da bo ${r.origin??"vrednost"} imelo ${o}${r.maximum.toString()} ${s.unit??"elementov"}`:`Preveliko: pri\u010Dakovano, da bo ${r.origin??"vrednost"} ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`Premajhno: pri\u010Dakovano, da bo ${r.origin} imelo ${o}${r.minimum.toString()} ${s.unit}`:`Premajhno: pri\u010Dakovano, da bo ${r.origin} ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Neveljaven niz: mora se za\u010Deti z "${o.prefix}"`:o.format==="ends_with"?`Neveljaven niz: mora se kon\u010Dati z "${o.suffix}"`:o.format==="includes"?`Neveljaven niz: mora vsebovati "${o.includes}"`:o.format==="regex"?`Neveljaven niz: mora ustrezati vzorcu ${o.pattern}`:`Neveljaven ${n[o.format]??r.format}`}case"not_multiple_of":return`Neveljavno \u0161tevilo: mora biti ve\u010Dkratnik ${r.divisor}`;case"unrecognized_keys":return`Neprepoznan${r.keys.length>1?"i klju\u010Di":" klju\u010D"}: ${V(r.keys,", ")}`;case"invalid_key":return`Neveljaven klju\u010D v ${r.origin}`;case"invalid_union":return"Neveljaven vnos";case"invalid_element":return`Neveljavna vrednost v ${r.origin}`;default:return"Neveljaven vnos"}}}});function EB(){return{localeError:Ure()}}var Ure,AB=v(()=>{Ae();Ure=()=>{let e={string:{unit:"tecken",verb:"att ha"},file:{unit:"bytes",verb:"att ha"},array:{unit:"objekt",verb:"att inneh\xE5lla"},set:{unit:"objekt",verb:"att inneh\xE5lla"}};function t(r){return e[r]??null}let n={regex:"regulj\xE4rt uttryck",email:"e-postadress",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datum och tid",date:"ISO-datum",time:"ISO-tid",duration:"ISO-varaktighet",ipv4:"IPv4-intervall",ipv6:"IPv6-intervall",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodad str\xE4ng",base64url:"base64url-kodad str\xE4ng",json_string:"JSON-str\xE4ng",e164:"E.164-nummer",jwt:"JWT",template_literal:"mall-literal"},i={nan:"NaN",number:"antal",array:"lista"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Ogiltig inmatning: f\xF6rv\xE4ntat instanceof ${r.expected}, fick ${a}`:`Ogiltig inmatning: f\xF6rv\xE4ntat ${o}, fick ${a}`}case"invalid_value":return r.values.length===1?`Ogiltig inmatning: f\xF6rv\xE4ntat ${se(r.values[0])}`:`Ogiltigt val: f\xF6rv\xE4ntade en av ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`F\xF6r stor(t): f\xF6rv\xE4ntade ${r.origin??"v\xE4rdet"} att ha ${o}${r.maximum.toString()} ${s.unit??"element"}`:`F\xF6r stor(t): f\xF6rv\xE4ntat ${r.origin??"v\xE4rdet"} att ha ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`F\xF6r lite(t): f\xF6rv\xE4ntade ${r.origin??"v\xE4rdet"} att ha ${o}${r.minimum.toString()} ${s.unit}`:`F\xF6r lite(t): f\xF6rv\xE4ntade ${r.origin??"v\xE4rdet"} att ha ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Ogiltig str\xE4ng: m\xE5ste b\xF6rja med "${o.prefix}"`:o.format==="ends_with"?`Ogiltig str\xE4ng: m\xE5ste sluta med "${o.suffix}"`:o.format==="includes"?`Ogiltig str\xE4ng: m\xE5ste inneh\xE5lla "${o.includes}"`:o.format==="regex"?`Ogiltig str\xE4ng: m\xE5ste matcha m\xF6nstret "${o.pattern}"`:`Ogiltig(t) ${n[o.format]??r.format}`}case"not_multiple_of":return`Ogiltigt tal: m\xE5ste vara en multipel av ${r.divisor}`;case"unrecognized_keys":return`${r.keys.length>1?"Ok\xE4nda nycklar":"Ok\xE4nd nyckel"}: ${V(r.keys,", ")}`;case"invalid_key":return`Ogiltig nyckel i ${r.origin??"v\xE4rdet"}`;case"invalid_union":return"Ogiltig input";case"invalid_element":return`Ogiltigt v\xE4rde i ${r.origin??"v\xE4rdet"}`;default:return"Ogiltig input"}}}});function PB(){return{localeError:Hre()}}var Hre,OB=v(()=>{Ae();Hre=()=>{let e={string:{unit:"\u0B8E\u0BB4\u0BC1\u0BA4\u0BCD\u0BA4\u0BC1\u0B95\u0BCD\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},file:{unit:"\u0BAA\u0BC8\u0B9F\u0BCD\u0B9F\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},array:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},set:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"}};function t(r){return e[r]??null}let n={regex:"\u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1",email:"\u0BAE\u0BBF\u0BA9\u0BCD\u0BA9\u0B9E\u0BCD\u0B9A\u0BB2\u0BCD \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0BA4\u0BC7\u0BA4\u0BBF \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",date:"ISO \u0BA4\u0BC7\u0BA4\u0BBF",time:"ISO \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",duration:"ISO \u0B95\u0BBE\u0BB2 \u0B85\u0BB3\u0BB5\u0BC1",ipv4:"IPv4 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",ipv6:"IPv6 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",cidrv4:"IPv4 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",cidrv6:"IPv6 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",base64:"base64-encoded \u0B9A\u0BB0\u0BAE\u0BCD",base64url:"base64url-encoded \u0B9A\u0BB0\u0BAE\u0BCD",json_string:"JSON \u0B9A\u0BB0\u0BAE\u0BCD",e164:"E.164 \u0B8E\u0BA3\u0BCD",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"\u0B8E\u0BA3\u0BCD",array:"\u0B85\u0BA3\u0BBF",null:"\u0BB5\u0BC6\u0BB1\u0BC1\u0BAE\u0BC8"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 instanceof ${r.expected}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${a}`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${o}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${a}`}case"invalid_value":return r.values.length===1?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${se(r.values[0])}`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0BB0\u0BC1\u0BAA\u0BCD\u0BAA\u0BAE\u0BCD: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${V(r.values,"|")} \u0B87\u0BB2\u0BCD \u0B92\u0BA9\u0BCD\u0BB1\u0BC1`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${r.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${o}${r.maximum.toString()} ${s.unit??"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD"} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${r.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${o}${r.maximum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${r.origin} ${o}${r.minimum.toString()} ${s.unit} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${r.origin} ${o}${r.minimum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${o.prefix}" \u0B87\u0BB2\u0BCD \u0BA4\u0BCA\u0B9F\u0B99\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:o.format==="ends_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${o.suffix}" \u0B87\u0BB2\u0BCD \u0BAE\u0BC1\u0B9F\u0BBF\u0BB5\u0B9F\u0BC8\u0BAF \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:o.format==="includes"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${o.includes}" \u0B90 \u0B89\u0BB3\u0BCD\u0BB3\u0B9F\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:o.format==="regex"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: ${o.pattern} \u0BAE\u0BC1\u0BB1\u0BC8\u0BAA\u0BBE\u0B9F\u0BCD\u0B9F\u0BC1\u0B9F\u0BA9\u0BCD \u0BAA\u0BCA\u0BB0\u0BC1\u0BA8\u0BCD\u0BA4 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 ${n[o.format]??r.format}`}case"not_multiple_of":return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B8E\u0BA3\u0BCD: ${r.divisor} \u0B87\u0BA9\u0BCD \u0BAA\u0BB2\u0BAE\u0BBE\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;case"unrecognized_keys":return`\u0B85\u0B9F\u0BC8\u0BAF\u0BBE\u0BB3\u0BAE\u0BCD \u0BA4\u0BC6\u0BB0\u0BBF\u0BAF\u0BBE\u0BA4 \u0BB5\u0BBF\u0B9A\u0BC8${r.keys.length>1?"\u0B95\u0BB3\u0BCD":""}: ${V(r.keys,", ")}`;case"invalid_key":return`${r.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0B9A\u0BC8`;case"invalid_union":return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1";case"invalid_element":return`${r.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1`;default:return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1"}}}});function CB(){return{localeError:Vre()}}var Vre,_B=v(()=>{Ae();Vre=()=>{let e={string:{unit:"\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},file:{unit:"\u0E44\u0E1A\u0E15\u0E4C",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},array:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},set:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"}};function t(r){return e[r]??null}let n={regex:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19",email:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48\u0E2D\u0E35\u0E40\u0E21\u0E25",url:"URL",emoji:"\u0E2D\u0E34\u0E42\u0E21\u0E08\u0E34",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",date:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E41\u0E1A\u0E1A ISO",time:"\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",duration:"\u0E0A\u0E48\u0E27\u0E07\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",ipv4:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv4",ipv6:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv6",cidrv4:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv4",cidrv6:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv6",base64:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64",base64url:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64 \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A URL",json_string:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A JSON",e164:"\u0E40\u0E1A\u0E2D\u0E23\u0E4C\u0E42\u0E17\u0E23\u0E28\u0E31\u0E1E\u0E17\u0E4C\u0E23\u0E30\u0E2B\u0E27\u0E48\u0E32\u0E07\u0E1B\u0E23\u0E30\u0E40\u0E17\u0E28 (E.164)",jwt:"\u0E42\u0E17\u0E40\u0E04\u0E19 JWT",template_literal:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19"},i={nan:"NaN",number:"\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02",array:"\u0E2D\u0E32\u0E23\u0E4C\u0E40\u0E23\u0E22\u0E4C (Array)",null:"\u0E44\u0E21\u0E48\u0E21\u0E35\u0E04\u0E48\u0E32 (null)"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 instanceof ${r.expected} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${a}`:`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${o} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${a}`}case"invalid_value":return r.values.length===1?`\u0E04\u0E48\u0E32\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${se(r.values[0])}`:`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19\u0E2B\u0E19\u0E36\u0E48\u0E07\u0E43\u0E19 ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19":"\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32",s=t(r.origin);return s?`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${r.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${r.maximum.toString()} ${s.unit??"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23"}`:`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${r.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?"\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22":"\u0E21\u0E32\u0E01\u0E01\u0E27\u0E48\u0E32",s=t(r.origin);return s?`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${r.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${r.minimum.toString()} ${s.unit}`:`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${r.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E02\u0E36\u0E49\u0E19\u0E15\u0E49\u0E19\u0E14\u0E49\u0E27\u0E22 "${o.prefix}"`:o.format==="ends_with"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E25\u0E07\u0E17\u0E49\u0E32\u0E22\u0E14\u0E49\u0E27\u0E22 "${o.suffix}"`:o.format==="includes"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35 "${o.includes}" \u0E2D\u0E22\u0E39\u0E48\u0E43\u0E19\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21`:o.format==="regex"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14 ${o.pattern}`:`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: ${n[o.format]??r.format}`}case"not_multiple_of":return`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E08\u0E33\u0E19\u0E27\u0E19\u0E17\u0E35\u0E48\u0E2B\u0E32\u0E23\u0E14\u0E49\u0E27\u0E22 ${r.divisor} \u0E44\u0E14\u0E49\u0E25\u0E07\u0E15\u0E31\u0E27`;case"unrecognized_keys":return`\u0E1E\u0E1A\u0E04\u0E35\u0E22\u0E4C\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E23\u0E39\u0E49\u0E08\u0E31\u0E01: ${V(r.keys,", ")}`;case"invalid_key":return`\u0E04\u0E35\u0E22\u0E4C\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${r.origin}`;case"invalid_union":return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E22\u0E39\u0E40\u0E19\u0E35\u0E22\u0E19\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E44\u0E27\u0E49";case"invalid_element":return`\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${r.origin}`;default:return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07"}}}});function IB(){return{localeError:qre()}}var qre,TB=v(()=>{Ae();qre=()=>{let e={string:{unit:"karakter",verb:"olmal\u0131"},file:{unit:"bayt",verb:"olmal\u0131"},array:{unit:"\xF6\u011Fe",verb:"olmal\u0131"},set:{unit:"\xF6\u011Fe",verb:"olmal\u0131"}};function t(r){return e[r]??null}let n={regex:"girdi",email:"e-posta adresi",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO tarih ve saat",date:"ISO tarih",time:"ISO saat",duration:"ISO s\xFCre",ipv4:"IPv4 adresi",ipv6:"IPv6 adresi",cidrv4:"IPv4 aral\u0131\u011F\u0131",cidrv6:"IPv6 aral\u0131\u011F\u0131",base64:"base64 ile \u015Fifrelenmi\u015F metin",base64url:"base64url ile \u015Fifrelenmi\u015F metin",json_string:"JSON dizesi",e164:"E.164 say\u0131s\u0131",jwt:"JWT",template_literal:"\u015Eablon dizesi"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Ge\xE7ersiz de\u011Fer: beklenen instanceof ${r.expected}, al\u0131nan ${a}`:`Ge\xE7ersiz de\u011Fer: beklenen ${o}, al\u0131nan ${a}`}case"invalid_value":return r.values.length===1?`Ge\xE7ersiz de\u011Fer: beklenen ${se(r.values[0])}`:`Ge\xE7ersiz se\xE7enek: a\u015Fa\u011F\u0131dakilerden biri olmal\u0131: ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`\xC7ok b\xFCy\xFCk: beklenen ${r.origin??"de\u011Fer"} ${o}${r.maximum.toString()} ${s.unit??"\xF6\u011Fe"}`:`\xC7ok b\xFCy\xFCk: beklenen ${r.origin??"de\u011Fer"} ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`\xC7ok k\xFC\xE7\xFCk: beklenen ${r.origin} ${o}${r.minimum.toString()} ${s.unit}`:`\xC7ok k\xFC\xE7\xFCk: beklenen ${r.origin} ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Ge\xE7ersiz metin: "${o.prefix}" ile ba\u015Flamal\u0131`:o.format==="ends_with"?`Ge\xE7ersiz metin: "${o.suffix}" ile bitmeli`:o.format==="includes"?`Ge\xE7ersiz metin: "${o.includes}" i\xE7ermeli`:o.format==="regex"?`Ge\xE7ersiz metin: ${o.pattern} desenine uymal\u0131`:`Ge\xE7ersiz ${n[o.format]??r.format}`}case"not_multiple_of":return`Ge\xE7ersiz say\u0131: ${r.divisor} ile tam b\xF6l\xFCnebilmeli`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar${r.keys.length>1?"lar":""}: ${V(r.keys,", ")}`;case"invalid_key":return`${r.origin} i\xE7inde ge\xE7ersiz anahtar`;case"invalid_union":return"Ge\xE7ersiz de\u011Fer";case"invalid_element":return`${r.origin} i\xE7inde ge\xE7ersiz de\u011Fer`;default:return"Ge\xE7ersiz de\u011Fer"}}}});function Py(){return{localeError:Kre()}}var Kre,AE=v(()=>{Ae();Kre=()=>{let e={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},file:{unit:"\u0431\u0430\u0439\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"}};function t(r){return e[r]??null}let n={regex:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u0435\u043B\u0435\u043A\u0442\u0440\u043E\u043D\u043D\u043E\u0457 \u043F\u043E\u0448\u0442\u0438",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0434\u0430\u0442\u0430 \u0442\u0430 \u0447\u0430\u0441 ISO",date:"\u0434\u0430\u0442\u0430 ISO",time:"\u0447\u0430\u0441 ISO",duration:"\u0442\u0440\u0438\u0432\u0430\u043B\u0456\u0441\u0442\u044C ISO",ipv4:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv4",ipv6:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv6",cidrv4:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv4",cidrv6:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv6",base64:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64",base64url:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64url",json_string:"\u0440\u044F\u0434\u043E\u043A JSON",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",jwt:"JWT",template_literal:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"},i={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F instanceof ${r.expected}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${a}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${o}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${a}`}case"invalid_value":return r.values.length===1?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${se(r.values[0])}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0430 \u043E\u043F\u0446\u0456\u044F: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F \u043E\u0434\u043D\u0435 \u0437 ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} ${s.verb} ${o}${r.maximum.toString()} ${s.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432"}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} \u0431\u0443\u0434\u0435 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${r.origin} ${s.verb} ${o}${r.minimum.toString()} ${s.unit}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${r.origin} \u0431\u0443\u0434\u0435 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043F\u043E\u0447\u0438\u043D\u0430\u0442\u0438\u0441\u044F \u0437 "${o.prefix}"`:o.format==="ends_with"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0437\u0430\u043A\u0456\u043D\u0447\u0443\u0432\u0430\u0442\u0438\u0441\u044F \u043D\u0430 "${o.suffix}"`:o.format==="includes"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043C\u0456\u0441\u0442\u0438\u0442\u0438 "${o.includes}"`:o.format==="regex"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0442\u0438 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${o.pattern}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 ${n[o.format]??r.format}`}case"not_multiple_of":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0447\u0438\u0441\u043B\u043E: \u043F\u043E\u0432\u0438\u043D\u043D\u043E \u0431\u0443\u0442\u0438 \u043A\u0440\u0430\u0442\u043D\u0438\u043C ${r.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u043E\u0437\u043F\u0456\u0437\u043D\u0430\u043D\u0438\u0439 \u043A\u043B\u044E\u0447${r.keys.length>1?"\u0456":""}: ${V(r.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u043A\u043B\u044E\u0447 \u0443 ${r.origin}`;case"invalid_union":return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456";case"invalid_element":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F \u0443 ${r.origin}`;default:return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"}}}});function DB(){return Py()}var NB=v(()=>{AE()});function jB(){return{localeError:Jre()}}var Jre,LB=v(()=>{Ae();Jre=()=>{let e={string:{unit:"\u062D\u0631\u0648\u0641",verb:"\u06C1\u0648\u0646\u0627"},file:{unit:"\u0628\u0627\u0626\u0679\u0633",verb:"\u06C1\u0648\u0646\u0627"},array:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"},set:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"}};function t(r){return e[r]??null}let n={regex:"\u0627\u0646 \u067E\u0679",email:"\u0627\u06CC \u0645\u06CC\u0644 \u0627\u06CC\u0688\u0631\u06CC\u0633",url:"\u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",uuidv4:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 4",uuidv6:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 6",nanoid:"\u0646\u06CC\u0646\u0648 \u0622\u0626\u06CC \u0688\u06CC",guid:"\u062C\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid2:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC 2",ulid:"\u06CC\u0648 \u0627\u06CC\u0644 \u0622\u0626\u06CC \u0688\u06CC",xid:"\u0627\u06CC\u06A9\u0633 \u0622\u0626\u06CC \u0688\u06CC",ksuid:"\u06A9\u06D2 \u0627\u06CC\u0633 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",datetime:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0688\u06CC\u0679 \u0679\u0627\u0626\u0645",date:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u062A\u0627\u0631\u06CC\u062E",time:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0648\u0642\u062A",duration:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0645\u062F\u062A",ipv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0627\u06CC\u0688\u0631\u06CC\u0633",ipv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0627\u06CC\u0688\u0631\u06CC\u0633",cidrv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0631\u06CC\u0646\u062C",cidrv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0631\u06CC\u0646\u062C",base64:"\u0628\u06CC\u0633 64 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",base64url:"\u0628\u06CC\u0633 64 \u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",json_string:"\u062C\u06D2 \u0627\u06CC\u0633 \u0627\u0648 \u0627\u06CC\u0646 \u0633\u0679\u0631\u0646\u06AF",e164:"\u0627\u06CC 164 \u0646\u0645\u0628\u0631",jwt:"\u062C\u06D2 \u0688\u0628\u0644\u06CC\u0648 \u0679\u06CC",template_literal:"\u0627\u0646 \u067E\u0679"},i={nan:"NaN",number:"\u0646\u0645\u0628\u0631",array:"\u0622\u0631\u06D2",null:"\u0646\u0644"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: instanceof ${r.expected} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${a} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`:`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${o} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${a} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`}case"invalid_value":return r.values.length===1?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${se(r.values[0])} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`:`\u063A\u0644\u0637 \u0622\u067E\u0634\u0646: ${V(r.values,"|")} \u0645\u06CC\u06BA \u0633\u06D2 \u0627\u06CC\u06A9 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u0628\u06C1\u062A \u0628\u0691\u0627: ${r.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u06D2 ${o}${r.maximum.toString()} ${s.unit??"\u0639\u0646\u0627\u0635\u0631"} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0628\u0691\u0627: ${r.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u0627 ${o}${r.maximum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${r.origin} \u06A9\u06D2 ${o}${r.minimum.toString()} ${s.unit} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${r.origin} \u06A9\u0627 ${o}${r.minimum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${o.prefix}" \u0633\u06D2 \u0634\u0631\u0648\u0639 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:o.format==="ends_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${o.suffix}" \u067E\u0631 \u062E\u062A\u0645 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:o.format==="includes"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${o.includes}" \u0634\u0627\u0645\u0644 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:o.format==="regex"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: \u067E\u06CC\u0679\u0631\u0646 ${o.pattern} \u0633\u06D2 \u0645\u06CC\u0686 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:`\u063A\u0644\u0637 ${n[o.format]??r.format}`}case"not_multiple_of":return`\u063A\u0644\u0637 \u0646\u0645\u0628\u0631: ${r.divisor} \u06A9\u0627 \u0645\u0636\u0627\u0639\u0641 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;case"unrecognized_keys":return`\u063A\u06CC\u0631 \u062A\u0633\u0644\u06CC\u0645 \u0634\u062F\u06C1 \u06A9\u06CC${r.keys.length>1?"\u0632":""}: ${V(r.keys,"\u060C ")}`;case"invalid_key":return`${r.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u06A9\u06CC`;case"invalid_union":return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679";case"invalid_element":return`${r.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u0648\u06CC\u0644\u06CC\u0648`;default:return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679"}}}});function MB(){return{localeError:Zre()}}var Zre,FB=v(()=>{Ae();Zre=()=>{let e={string:{unit:"belgi",verb:"bo\u2018lishi kerak"},file:{unit:"bayt",verb:"bo\u2018lishi kerak"},array:{unit:"element",verb:"bo\u2018lishi kerak"},set:{unit:"element",verb:"bo\u2018lishi kerak"}};function t(r){return e[r]??null}let n={regex:"kirish",email:"elektron pochta manzili",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO sana va vaqti",date:"ISO sana",time:"ISO vaqt",duration:"ISO davomiylik",ipv4:"IPv4 manzil",ipv6:"IPv6 manzil",mac:"MAC manzil",cidrv4:"IPv4 diapazon",cidrv6:"IPv6 diapazon",base64:"base64 kodlangan satr",base64url:"base64url kodlangan satr",json_string:"JSON satr",e164:"E.164 raqam",jwt:"JWT",template_literal:"kirish"},i={nan:"NaN",number:"raqam",array:"massiv"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Noto\u2018g\u2018ri kirish: kutilgan instanceof ${r.expected}, qabul qilingan ${a}`:`Noto\u2018g\u2018ri kirish: kutilgan ${o}, qabul qilingan ${a}`}case"invalid_value":return r.values.length===1?`Noto\u2018g\u2018ri kirish: kutilgan ${se(r.values[0])}`:`Noto\u2018g\u2018ri variant: quyidagilardan biri kutilgan ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`Juda katta: kutilgan ${r.origin??"qiymat"} ${o}${r.maximum.toString()} ${s.unit} ${s.verb}`:`Juda katta: kutilgan ${r.origin??"qiymat"} ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`Juda kichik: kutilgan ${r.origin} ${o}${r.minimum.toString()} ${s.unit} ${s.verb}`:`Juda kichik: kutilgan ${r.origin} ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Noto\u2018g\u2018ri satr: "${o.prefix}" bilan boshlanishi kerak`:o.format==="ends_with"?`Noto\u2018g\u2018ri satr: "${o.suffix}" bilan tugashi kerak`:o.format==="includes"?`Noto\u2018g\u2018ri satr: "${o.includes}" ni o\u2018z ichiga olishi kerak`:o.format==="regex"?`Noto\u2018g\u2018ri satr: ${o.pattern} shabloniga mos kelishi kerak`:`Noto\u2018g\u2018ri ${n[o.format]??r.format}`}case"not_multiple_of":return`Noto\u2018g\u2018ri raqam: ${r.divisor} ning karralisi bo\u2018lishi kerak`;case"unrecognized_keys":return`Noma\u2019lum kalit${r.keys.length>1?"lar":""}: ${V(r.keys,", ")}`;case"invalid_key":return`${r.origin} dagi kalit noto\u2018g\u2018ri`;case"invalid_union":return"Noto\u2018g\u2018ri kirish";case"invalid_element":return`${r.origin} da noto\u2018g\u2018ri qiymat`;default:return"Noto\u2018g\u2018ri kirish"}}}});function BB(){return{localeError:Yre()}}var Yre,GB=v(()=>{Ae();Yre=()=>{let e={string:{unit:"k\xFD t\u1EF1",verb:"c\xF3"},file:{unit:"byte",verb:"c\xF3"},array:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"},set:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"}};function t(r){return e[r]??null}let n={regex:"\u0111\u1EA7u v\xE0o",email:"\u0111\u1ECBa ch\u1EC9 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ng\xE0y gi\u1EDD ISO",date:"ng\xE0y ISO",time:"gi\u1EDD ISO",duration:"kho\u1EA3ng th\u1EDDi gian ISO",ipv4:"\u0111\u1ECBa ch\u1EC9 IPv4",ipv6:"\u0111\u1ECBa ch\u1EC9 IPv6",cidrv4:"d\u1EA3i IPv4",cidrv6:"d\u1EA3i IPv6",base64:"chu\u1ED7i m\xE3 h\xF3a base64",base64url:"chu\u1ED7i m\xE3 h\xF3a base64url",json_string:"chu\u1ED7i JSON",e164:"s\u1ED1 E.164",jwt:"JWT",template_literal:"\u0111\u1EA7u v\xE0o"},i={nan:"NaN",number:"s\u1ED1",array:"m\u1EA3ng"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i instanceof ${r.expected}, nh\u1EADn \u0111\u01B0\u1EE3c ${a}`:`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${o}, nh\u1EADn \u0111\u01B0\u1EE3c ${a}`}case"invalid_value":return r.values.length===1?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${se(r.values[0])}`:`T\xF9y ch\u1ECDn kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i m\u1ED9t trong c\xE1c gi\xE1 tr\u1ECB ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${r.origin??"gi\xE1 tr\u1ECB"} ${s.verb} ${o}${r.maximum.toString()} ${s.unit??"ph\u1EA7n t\u1EED"}`:`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${r.origin??"gi\xE1 tr\u1ECB"} ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${r.origin} ${s.verb} ${o}${r.minimum.toString()} ${s.unit}`:`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${r.origin} ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i b\u1EAFt \u0111\u1EA7u b\u1EB1ng "${o.prefix}"`:o.format==="ends_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i k\u1EBFt th\xFAc b\u1EB1ng "${o.suffix}"`:o.format==="includes"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i bao g\u1ED3m "${o.includes}"`:o.format==="regex"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i kh\u1EDBp v\u1EDBi m\u1EABu ${o.pattern}`:`${n[o.format]??r.format} kh\xF4ng h\u1EE3p l\u1EC7`}case"not_multiple_of":return`S\u1ED1 kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i l\xE0 b\u1ED9i s\u1ED1 c\u1EE7a ${r.divisor}`;case"unrecognized_keys":return`Kh\xF3a kh\xF4ng \u0111\u01B0\u1EE3c nh\u1EADn d\u1EA1ng: ${V(r.keys,", ")}`;case"invalid_key":return`Kh\xF3a kh\xF4ng h\u1EE3p l\u1EC7 trong ${r.origin}`;case"invalid_union":return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7";case"invalid_element":return`Gi\xE1 tr\u1ECB kh\xF4ng h\u1EE3p l\u1EC7 trong ${r.origin}`;default:return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7"}}}});function WB(){return{localeError:Xre()}}var Xre,zB=v(()=>{Ae();Xre=()=>{let e={string:{unit:"\u5B57\u7B26",verb:"\u5305\u542B"},file:{unit:"\u5B57\u8282",verb:"\u5305\u542B"},array:{unit:"\u9879",verb:"\u5305\u542B"},set:{unit:"\u9879",verb:"\u5305\u542B"}};function t(r){return e[r]??null}let n={regex:"\u8F93\u5165",email:"\u7535\u5B50\u90AE\u4EF6",url:"URL",emoji:"\u8868\u60C5\u7B26\u53F7",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u671F\u65F6\u95F4",date:"ISO\u65E5\u671F",time:"ISO\u65F6\u95F4",duration:"ISO\u65F6\u957F",ipv4:"IPv4\u5730\u5740",ipv6:"IPv6\u5730\u5740",cidrv4:"IPv4\u7F51\u6BB5",cidrv6:"IPv6\u7F51\u6BB5",base64:"base64\u7F16\u7801\u5B57\u7B26\u4E32",base64url:"base64url\u7F16\u7801\u5B57\u7B26\u4E32",json_string:"JSON\u5B57\u7B26\u4E32",e164:"E.164\u53F7\u7801",jwt:"JWT",template_literal:"\u8F93\u5165"},i={nan:"NaN",number:"\u6570\u5B57",array:"\u6570\u7EC4",null:"\u7A7A\u503C(null)"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B instanceof ${r.expected}\uFF0C\u5B9E\u9645\u63A5\u6536 ${a}`:`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${o}\uFF0C\u5B9E\u9645\u63A5\u6536 ${a}`}case"invalid_value":return r.values.length===1?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${se(r.values[0])}`:`\u65E0\u6548\u9009\u9879\uFF1A\u671F\u671B\u4EE5\u4E0B\u4E4B\u4E00 ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${r.origin??"\u503C"} ${o}${r.maximum.toString()} ${s.unit??"\u4E2A\u5143\u7D20"}`:`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${r.origin??"\u503C"} ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${r.origin} ${o}${r.minimum.toString()} ${s.unit}`:`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${r.origin} ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${o.prefix}" \u5F00\u5934`:o.format==="ends_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${o.suffix}" \u7ED3\u5C3E`:o.format==="includes"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u5305\u542B "${o.includes}"`:o.format==="regex"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u6EE1\u8DB3\u6B63\u5219\u8868\u8FBE\u5F0F ${o.pattern}`:`\u65E0\u6548${n[o.format]??r.format}`}case"not_multiple_of":return`\u65E0\u6548\u6570\u5B57\uFF1A\u5FC5\u987B\u662F ${r.divisor} \u7684\u500D\u6570`;case"unrecognized_keys":return`\u51FA\u73B0\u672A\u77E5\u7684\u952E(key): ${V(r.keys,", ")}`;case"invalid_key":return`${r.origin} \u4E2D\u7684\u952E(key)\u65E0\u6548`;case"invalid_union":return"\u65E0\u6548\u8F93\u5165";case"invalid_element":return`${r.origin} \u4E2D\u5305\u542B\u65E0\u6548\u503C(value)`;default:return"\u65E0\u6548\u8F93\u5165"}}}});function UB(){return{localeError:Qre()}}var Qre,HB=v(()=>{Ae();Qre=()=>{let e={string:{unit:"\u5B57\u5143",verb:"\u64C1\u6709"},file:{unit:"\u4F4D\u5143\u7D44",verb:"\u64C1\u6709"},array:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"},set:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"}};function t(r){return e[r]??null}let n={regex:"\u8F38\u5165",email:"\u90F5\u4EF6\u5730\u5740",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u65E5\u671F\u6642\u9593",date:"ISO \u65E5\u671F",time:"ISO \u6642\u9593",duration:"ISO \u671F\u9593",ipv4:"IPv4 \u4F4D\u5740",ipv6:"IPv6 \u4F4D\u5740",cidrv4:"IPv4 \u7BC4\u570D",cidrv6:"IPv6 \u7BC4\u570D",base64:"base64 \u7DE8\u78BC\u5B57\u4E32",base64url:"base64url \u7DE8\u78BC\u5B57\u4E32",json_string:"JSON \u5B57\u4E32",e164:"E.164 \u6578\u503C",jwt:"JWT",template_literal:"\u8F38\u5165"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA instanceof ${r.expected}\uFF0C\u4F46\u6536\u5230 ${a}`:`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${o}\uFF0C\u4F46\u6536\u5230 ${a}`}case"invalid_value":return r.values.length===1?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${se(r.values[0])}`:`\u7121\u6548\u7684\u9078\u9805\uFF1A\u9810\u671F\u70BA\u4EE5\u4E0B\u5176\u4E2D\u4E4B\u4E00 ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${r.origin??"\u503C"} \u61C9\u70BA ${o}${r.maximum.toString()} ${s.unit??"\u500B\u5143\u7D20"}`:`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${r.origin??"\u503C"} \u61C9\u70BA ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${r.origin} \u61C9\u70BA ${o}${r.minimum.toString()} ${s.unit}`:`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${r.origin} \u61C9\u70BA ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${o.prefix}" \u958B\u982D`:o.format==="ends_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${o.suffix}" \u7D50\u5C3E`:o.format==="includes"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u5305\u542B "${o.includes}"`:o.format==="regex"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u7B26\u5408\u683C\u5F0F ${o.pattern}`:`\u7121\u6548\u7684 ${n[o.format]??r.format}`}case"not_multiple_of":return`\u7121\u6548\u7684\u6578\u5B57\uFF1A\u5FC5\u9808\u70BA ${r.divisor} \u7684\u500D\u6578`;case"unrecognized_keys":return`\u7121\u6CD5\u8B58\u5225\u7684\u9375\u503C${r.keys.length>1?"\u5011":""}\uFF1A${V(r.keys,"\u3001")}`;case"invalid_key":return`${r.origin} \u4E2D\u6709\u7121\u6548\u7684\u9375\u503C`;case"invalid_union":return"\u7121\u6548\u7684\u8F38\u5165\u503C";case"invalid_element":return`${r.origin} \u4E2D\u6709\u7121\u6548\u7684\u503C`;default:return"\u7121\u6548\u7684\u8F38\u5165\u503C"}}}});function VB(){return{localeError:eie()}}var eie,qB=v(()=>{Ae();eie=()=>{let e={string:{unit:"\xE0mi",verb:"n\xED"},file:{unit:"bytes",verb:"n\xED"},array:{unit:"nkan",verb:"n\xED"},set:{unit:"nkan",verb:"n\xED"}};function t(r){return e[r]??null}let n={regex:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9",email:"\xE0d\xEDr\u1EB9\u0301s\xEC \xECm\u1EB9\u0301l\xEC",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\xE0k\xF3k\xF2 ISO",date:"\u1ECDj\u1ECD\u0301 ISO",time:"\xE0k\xF3k\xF2 ISO",duration:"\xE0k\xF3k\xF2 t\xF3 p\xE9 ISO",ipv4:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv4",ipv6:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv6",cidrv4:"\xE0gb\xE8gb\xE8 IPv4",cidrv6:"\xE0gb\xE8gb\xE8 IPv6",base64:"\u1ECD\u0300r\u1ECD\u0300 t\xED a k\u1ECD\u0301 n\xED base64",base64url:"\u1ECD\u0300r\u1ECD\u0300 base64url",json_string:"\u1ECD\u0300r\u1ECD\u0300 JSON",e164:"n\u1ECD\u0301mb\xE0 E.164",jwt:"JWT",template_literal:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9"},i={nan:"NaN",number:"n\u1ECD\u0301mb\xE0",array:"akop\u1ECD"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi instanceof ${r.expected}, \xE0m\u1ECD\u0300 a r\xED ${a}`:`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${o}, \xE0m\u1ECD\u0300 a r\xED ${a}`}case"invalid_value":return r.values.length===1?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${se(r.values[0])}`:`\xC0\u1E63\xE0y\xE0n a\u1E63\xEC\u1E63e: yan \u1ECD\u0300kan l\xE1ra ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${r.origin??"iye"} ${s.verb} ${o}${r.maximum} ${s.unit}`:`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 ${o}${r.maximum}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${r.origin} ${s.verb} ${o}${r.minimum} ${s.unit}`:`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 ${o}${r.minimum}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\u1EB9\u0300r\u1EB9\u0300 p\u1EB9\u0300l\xFA "${o.prefix}"`:o.format==="ends_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 par\xED p\u1EB9\u0300l\xFA "${o.suffix}"`:o.format==="includes"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 n\xED "${o.includes}"`:o.format==="regex"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\xE1 \xE0p\u1EB9\u1EB9r\u1EB9 mu ${o.pattern}`:`A\u1E63\xEC\u1E63e: ${n[o.format]??r.format}`}case"not_multiple_of":return`N\u1ECD\u0301mb\xE0 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 j\u1EB9\u0301 \xE8y\xE0 p\xEDp\xEDn ti ${r.divisor}`;case"unrecognized_keys":return`B\u1ECDt\xECn\xEC \xE0\xECm\u1ECD\u0300: ${V(r.keys,", ")}`;case"invalid_key":return`B\u1ECDt\xECn\xEC a\u1E63\xEC\u1E63e n\xEDn\xFA ${r.origin}`;case"invalid_union":return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e";case"invalid_element":return`Iye a\u1E63\xEC\u1E63e n\xEDn\xFA ${r.origin}`;default:return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e"}}}});var Yp={};_e(Yp,{ar:()=>sF,az:()=>cF,be:()=>dF,bg:()=>fF,ca:()=>gF,cs:()=>yF,da:()=>wF,de:()=>kF,en:()=>Ey,eo:()=>$F,es:()=>SF,fa:()=>AF,fi:()=>OF,fr:()=>_F,frCA:()=>TF,he:()=>NF,hu:()=>LF,hy:()=>BF,id:()=>WF,is:()=>UF,it:()=>VF,ja:()=>KF,ka:()=>ZF,kh:()=>XF,km:()=>Ay,ko:()=>eB,lt:()=>rB,mk:()=>oB,ms:()=>aB,nl:()=>lB,no:()=>dB,ota:()=>fB,pl:()=>yB,ps:()=>gB,pt:()=>wB,ru:()=>xB,sl:()=>RB,sv:()=>EB,ta:()=>PB,th:()=>CB,tr:()=>IB,ua:()=>DB,uk:()=>Py,ur:()=>jB,uz:()=>MB,vi:()=>BB,yo:()=>VB,zhCN:()=>WB,zhTW:()=>UB});var PE=v(()=>{aF();lF();pF();mF();hF();bF();vF();xF();SE();RF();EF();PF();CF();IF();DF();jF();MF();GF();zF();HF();qF();JF();YF();QF();EE();tB();iB();sB();cB();uB();pB();mB();hB();bB();vB();$B();SB();AB();OB();_B();TB();NB();AE();LB();FB();GB();zB();HB();qB()});function Cy(){return new Oy}var KB,OE,CE,Oy,kn,Xp=v(()=>{OE=Symbol("ZodOutput"),CE=Symbol("ZodInput"),Oy=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){let i=n[0];return this._map.set(t,i),i&&typeof i=="object"&&"id"in i&&this._idmap.set(i.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){let n=t._zod.parent;if(n){let i={...this.get(n)??{}};delete i.id;let r={...i,...this._map.get(t)};return Object.keys(r).length?r:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};(KB=globalThis).__zod_globalRegistry??(KB.__zod_globalRegistry=Cy());kn=globalThis.__zod_globalRegistry});function _E(e,t){return new e({type:"string",...ue(t)})}function IE(e,t){return new e({type:"string",coerce:!0,...ue(t)})}function _y(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...ue(t)})}function Qp(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...ue(t)})}function Iy(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...ue(t)})}function Ty(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ue(t)})}function Dy(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ue(t)})}function Ny(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ue(t)})}function ef(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ue(t)})}function jy(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...ue(t)})}function Ly(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...ue(t)})}function My(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...ue(t)})}function Fy(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...ue(t)})}function By(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...ue(t)})}function Gy(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...ue(t)})}function Wy(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...ue(t)})}function zy(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...ue(t)})}function Uy(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...ue(t)})}function TE(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...ue(t)})}function Hy(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ue(t)})}function Vy(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ue(t)})}function qy(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...ue(t)})}function Ky(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...ue(t)})}function Jy(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...ue(t)})}function Zy(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...ue(t)})}function NE(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ue(t)})}function jE(e,t){return new e({type:"string",format:"date",check:"string_format",...ue(t)})}function LE(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...ue(t)})}function ME(e,t){return new e({type:"string",format:"duration",check:"string_format",...ue(t)})}function FE(e,t){return new e({type:"number",checks:[],...ue(t)})}function BE(e,t){return new e({type:"number",coerce:!0,checks:[],...ue(t)})}function GE(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...ue(t)})}function WE(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...ue(t)})}function zE(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...ue(t)})}function UE(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...ue(t)})}function HE(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...ue(t)})}function VE(e,t){return new e({type:"boolean",...ue(t)})}function qE(e,t){return new e({type:"boolean",coerce:!0,...ue(t)})}function KE(e,t){return new e({type:"bigint",...ue(t)})}function JE(e,t){return new e({type:"bigint",coerce:!0,...ue(t)})}function ZE(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...ue(t)})}function YE(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...ue(t)})}function XE(e,t){return new e({type:"symbol",...ue(t)})}function QE(e,t){return new e({type:"undefined",...ue(t)})}function eA(e,t){return new e({type:"null",...ue(t)})}function tA(e){return new e({type:"any"})}function nA(e){return new e({type:"unknown"})}function rA(e,t){return new e({type:"never",...ue(t)})}function iA(e,t){return new e({type:"void",...ue(t)})}function oA(e,t){return new e({type:"date",...ue(t)})}function sA(e,t){return new e({type:"date",coerce:!0,...ue(t)})}function aA(e,t){return new e({type:"nan",...ue(t)})}function Ji(e,t){return new my({check:"less_than",...ue(t),value:e,inclusive:!1})}function Ir(e,t){return new my({check:"less_than",...ue(t),value:e,inclusive:!0})}function Zi(e,t){return new gy({check:"greater_than",...ue(t),value:e,inclusive:!1})}function Zn(e,t){return new gy({check:"greater_than",...ue(t),value:e,inclusive:!0})}function Yy(e){return Zi(0,e)}function Xy(e){return Ji(0,e)}function Qy(e){return Ir(0,e)}function eb(e){return Zn(0,e)}function Us(e,t){return new qR({check:"multiple_of",...ue(t),value:e})}function Hs(e,t){return new ZR({check:"max_size",...ue(t),maximum:e})}function Yi(e,t){return new YR({check:"min_size",...ue(t),minimum:e})}function pc(e,t){return new XR({check:"size_equals",...ue(t),size:e})}function fc(e,t){return new QR({check:"max_length",...ue(t),maximum:e})}function Jo(e,t){return new eS({check:"min_length",...ue(t),minimum:e})}function mc(e,t){return new tS({check:"length_equals",...ue(t),length:e})}function Kl(e,t){return new nS({check:"string_format",format:"regex",...ue(t),pattern:e})}function Jl(e){return new rS({check:"string_format",format:"lowercase",...ue(e)})}function Zl(e){return new iS({check:"string_format",format:"uppercase",...ue(e)})}function Yl(e,t){return new oS({check:"string_format",format:"includes",...ue(t),includes:e})}function Xl(e,t){return new sS({check:"string_format",format:"starts_with",...ue(t),prefix:e})}function Ql(e,t){return new aS({check:"string_format",format:"ends_with",...ue(t),suffix:e})}function tb(e,t,n){return new cS({check:"property",property:e,schema:t,...ue(n)})}function eu(e,t){return new lS({check:"mime_type",mime:e,...ue(t)})}function $i(e){return new uS({check:"overwrite",tx:e})}function tu(e){return $i(t=>t.normalize(e))}function nu(){return $i(e=>e.trim())}function ru(){return $i(e=>e.toLowerCase())}function iu(){return $i(e=>e.toUpperCase())}function ou(){return $i(e=>sR(e))}function cA(e,t,n){return new e({type:"array",element:t,...ue(n)})}function nie(e,t,n){return new e({type:"union",options:t,...ue(n)})}function rie(e,t,n){return new e({type:"union",options:t,inclusive:!1,...ue(n)})}function iie(e,t,n,i){return new e({type:"union",options:n,discriminator:t,...ue(i)})}function oie(e,t,n){return new e({type:"intersection",left:t,right:n})}function sie(e,t,n,i){let r=n instanceof Ne,o=r?i:n,s=r?n:null;return new e({type:"tuple",items:t,rest:s,...ue(o)})}function aie(e,t,n,i){return new e({type:"record",keyType:t,valueType:n,...ue(i)})}function cie(e,t,n,i){return new e({type:"map",keyType:t,valueType:n,...ue(i)})}function lie(e,t,n){return new e({type:"set",valueType:t,...ue(n)})}function uie(e,t,n){let i=Array.isArray(t)?Object.fromEntries(t.map(r=>[r,r])):t;return new e({type:"enum",entries:i,...ue(n)})}function die(e,t,n){return new e({type:"enum",entries:t,...ue(n)})}function pie(e,t,n){return new e({type:"literal",values:Array.isArray(t)?t:[t],...ue(n)})}function lA(e,t){return new e({type:"file",...ue(t)})}function fie(e,t){return new e({type:"transform",transform:t})}function mie(e,t){return new e({type:"optional",innerType:t})}function gie(e,t){return new e({type:"nullable",innerType:t})}function hie(e,t,n){return new e({type:"default",innerType:t,get defaultValue(){return typeof n=="function"?n():cR(n)}})}function yie(e,t,n){return new e({type:"nonoptional",innerType:t,...ue(n)})}function bie(e,t){return new e({type:"success",innerType:t})}function wie(e,t,n){return new e({type:"catch",innerType:t,catchValue:typeof n=="function"?n:()=>n})}function vie(e,t,n){return new e({type:"pipe",in:t,out:n})}function kie(e,t){return new e({type:"readonly",innerType:t})}function xie(e,t,n){return new e({type:"template_literal",parts:t,...ue(n)})}function $ie(e,t){return new e({type:"lazy",getter:t})}function Rie(e,t){return new e({type:"promise",innerType:t})}function uA(e,t,n){let i=ue(n);return i.abort??(i.abort=!0),new e({type:"custom",check:"custom",fn:t,...i})}function dA(e,t,n){return new e({type:"custom",check:"custom",fn:t,...ue(n)})}function pA(e){let t=JB(n=>(n.addIssue=i=>{if(typeof i=="string")n.issues.push(Gl(i,n.value,t._zod.def));else{let r=i;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=n.value),r.inst??(r.inst=t),r.continue??(r.continue=!t._zod.def.abort),n.issues.push(Gl(r))}},e(n.value,n)));return t}function JB(e,t){let n=new Et({check:"custom",...ue(t)});return n._zod.check=e,n}function fA(e){let t=new Et({check:"describe"});return t._zod.onattach=[n=>{let i=kn.get(n)??{};kn.add(n,{...i,description:e})}],t._zod.check=()=>{},t}function mA(e){let t=new Et({check:"meta"});return t._zod.onattach=[n=>{let i=kn.get(n)??{};kn.add(n,{...i,...e})}],t._zod.check=()=>{},t}function gA(e,t){let n=ue(t),i=n.truthy??["true","1","yes","on","y","enabled"],r=n.falsy??["false","0","no","off","n","disabled"];n.case!=="sensitive"&&(i=i.map(f=>typeof f=="string"?f.toLowerCase():f),r=r.map(f=>typeof f=="string"?f.toLowerCase():f));let o=new Set(i),s=new Set(r),a=e.Codec??Jp,l=e.Boolean??qp,c=e.String??dc,u=new c({type:"string",error:n.error}),d=new l({type:"boolean",error:n.error}),p=new a({type:"pipe",in:u,out:d,transform:((f,g)=>{let h=f;return n.case!=="sensitive"&&(h=h.toLowerCase()),o.has(h)?!0:s.has(h)?!1:(g.issues.push({code:"invalid_value",expected:"stringbool",values:[...o,...s],input:g.value,inst:p,continue:!1}),{})}),reverseTransform:((f,g)=>f===!0?i[0]||"true":r[0]||"false"),error:n.error});return p}function su(e,t,n,i={}){let r=ue(i),o={...ue(i),check:"string_format",type:"string",format:t,fn:typeof n=="function"?n:a=>n.test(a),...r};return n instanceof RegExp&&(o.pattern=n),new e(o)}var DE,ZB=v(()=>{hy();Xp();RE();Ae();DE={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6}});function Vs(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??kn,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function ht(e,t,n={path:[],schemaPath:[]}){var i;let r=e._zod.def,o=t.seen.get(e);if(o)return o.count++,n.schemaPath.includes(e)&&(o.cycle=n.path),o.schema;let s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s);let a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,u);else{let p=s.schema,f=t.processors[r.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);f(e,t,p,u)}let d=e._zod.parent;d&&(s.ref||(s.ref=d),ht(d,t,u),t.seen.get(d).isParent=!0)}let l=t.metadataRegistry.get(e);return l&&Object.assign(s.schema,l),t.io==="input"&&Yn(e)&&(delete s.schema.examples,delete s.schema.default),t.io==="input"&&s.schema._prefault&&((i=s.schema).default??(i.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function qs(e,t){let n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=new Map;for(let s of e.seen.entries()){let a=e.metadataRegistry.get(s[0])?.id;if(a){let l=i.get(a);if(l&&l!==s[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(a,s[0])}}let r=s=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(s[0])?.id,p=e.external.uri??(g=>g);if(d)return{ref:p(d)};let f=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=f,{defId:f,ref:`${p("__shared")}#/${a}/${f}`}}if(s[1]===n)return{ref:"#"};let c=`#/${a}/`,u=s[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:c+u}},o=s=>{if(s[1].schema.$ref)return;let a=s[1],{ref:l,defId:c}=r(s);a.def={...a.schema},c&&(a.defId=c);let u=a.schema;for(let d in u)delete u[d];u.$ref=l};if(e.cycles==="throw")for(let s of e.seen.entries()){let a=s[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
45
+
46
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let a=s[1];if(t===s[0]){o(s);continue}if(e.external){let c=e.external.registry.get(s[0])?.id;if(t!==s[0]&&c){o(s);continue}}if(e.metadataRegistry.get(s[0])?.id){o(s);continue}if(a.cycle){o(s);continue}if(a.count>1&&e.reused==="ref"){o(s);continue}}}function Ks(e,t){let n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=s=>{let a=e.seen.get(s);if(a.ref===null)return;let l=a.def??a.schema,c={...l},u=a.ref;if(a.ref=null,u){i(u);let p=e.seen.get(u),f=p.schema;if(f.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(l.allOf=l.allOf??[],l.allOf.push(f)):Object.assign(l,f),Object.assign(l,c),s._zod.parent===u)for(let h in l)h==="$ref"||h==="allOf"||h in c||delete l[h];if(f.$ref&&p.def)for(let h in l)h==="$ref"||h==="allOf"||h in p.def&&JSON.stringify(l[h])===JSON.stringify(p.def[h])&&delete l[h]}let d=s._zod.parent;if(d&&d!==u){i(d);let p=e.seen.get(d);if(p?.schema.$ref&&(l.$ref=p.schema.$ref,p.def))for(let f in l)f==="$ref"||f==="allOf"||f in p.def&&JSON.stringify(l[f])===JSON.stringify(p.def[f])&&delete l[f]}e.override({zodSchema:s,jsonSchema:l,path:a.path??[]})};for(let s of[...e.seen.entries()].reverse())i(s[0]);let r={};if(e.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let s=e.external.registry.get(t)?.id;if(!s)throw new Error("Schema is missing an `id` property");r.$id=e.external.uri(s)}Object.assign(r,n.def??n.schema);let o=e.external?.defs??{};for(let s of e.seen.entries()){let a=s[1];a.def&&a.defId&&(o[a.defId]=a.def)}e.external||Object.keys(o).length>0&&(e.target==="draft-2020-12"?r.$defs=o:r.definitions=o);try{let s=JSON.parse(JSON.stringify(r));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:au(t,"input",e.processors),output:au(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function Yn(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return Yn(i.element,n);if(i.type==="set")return Yn(i.valueType,n);if(i.type==="lazy")return Yn(i.getter(),n);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault")return Yn(i.innerType,n);if(i.type==="intersection")return Yn(i.left,n)||Yn(i.right,n);if(i.type==="record"||i.type==="map")return Yn(i.keyType,n)||Yn(i.valueType,n);if(i.type==="pipe")return Yn(i.in,n)||Yn(i.out,n);if(i.type==="object"){for(let r in i.shape)if(Yn(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(let r of i.options)if(Yn(r,n))return!0;return!1}if(i.type==="tuple"){for(let r of i.items)if(Yn(r,n))return!0;return!!(i.rest&&Yn(i.rest,n))}return!1}var hA,au,tf=v(()=>{Xp();hA=(e,t={})=>n=>{let i=Vs({...n,processors:t});return ht(e,i),qs(i,e),Ks(i,e)},au=(e,t,n={})=>i=>{let{libraryOptions:r,target:o}=i??{},s=Vs({...r??{},target:o,io:t,processors:n});return ht(e,s),qs(s,e),Ks(s,e)}});function ob(e,t){if("_idmap"in e){let i=e,r=Vs({...t,processors:nb}),o={};for(let l of i._idmap.entries()){let[c,u]=l;ht(u,r)}let s={},a={registry:i,uri:t?.uri,defs:o};r.external=a;for(let l of i._idmap.entries()){let[c,u]=l;qs(r,u),s[c]=Ks(r,u)}if(Object.keys(o).length>0){let l=r.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[l]:o}}return{schemas:s}}let n=Vs({...t,processors:nb});return ht(e,n),qs(n,e),Ks(n,e)}var Sie,yA,bA,wA,vA,kA,xA,$A,RA,SA,EA,AA,PA,OA,CA,_A,IA,TA,DA,NA,jA,LA,MA,FA,BA,GA,rb,WA,zA,UA,HA,VA,qA,KA,JA,ZA,YA,XA,ib,QA,nb,nf=v(()=>{tf();Ae();Sie={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},yA=(e,t,n,i)=>{let r=n;r.type="string";let{minimum:o,maximum:s,format:a,patterns:l,contentEncoding:c}=e._zod.bag;if(typeof o=="number"&&(r.minLength=o),typeof s=="number"&&(r.maxLength=s),a&&(r.format=Sie[a]??a,r.format===""&&delete r.format,a==="time"&&delete r.format),c&&(r.contentEncoding=c),l&&l.size>0){let u=[...l];u.length===1?r.pattern=u[0].source:u.length>1&&(r.allOf=[...u.map(d=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},bA=(e,t,n,i)=>{let r=n,{minimum:o,maximum:s,format:a,multipleOf:l,exclusiveMaximum:c,exclusiveMinimum:u}=e._zod.bag;typeof a=="string"&&a.includes("int")?r.type="integer":r.type="number",typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(r.minimum=u,r.exclusiveMinimum=!0):r.exclusiveMinimum=u),typeof o=="number"&&(r.minimum=o,typeof u=="number"&&t.target!=="draft-04"&&(u>=o?delete r.minimum:delete r.exclusiveMinimum)),typeof c=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(r.maximum=c,r.exclusiveMaximum=!0):r.exclusiveMaximum=c),typeof s=="number"&&(r.maximum=s,typeof c=="number"&&t.target!=="draft-04"&&(c<=s?delete r.maximum:delete r.exclusiveMaximum)),typeof l=="number"&&(r.multipleOf=l)},wA=(e,t,n,i)=>{n.type="boolean"},vA=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},kA=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},xA=(e,t,n,i)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},$A=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},RA=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},SA=(e,t,n,i)=>{n.not={}},EA=(e,t,n,i)=>{},AA=(e,t,n,i)=>{},PA=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},OA=(e,t,n,i)=>{let r=e._zod.def,o=jp(r.entries);o.every(s=>typeof s=="number")&&(n.type="number"),o.every(s=>typeof s=="string")&&(n.type="string"),n.enum=o},CA=(e,t,n,i)=>{let r=e._zod.def,o=[];for(let s of r.values)if(s===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof s=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");o.push(Number(s))}else o.push(s);if(o.length!==0)if(o.length===1){let s=o[0];n.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[s]:n.const=s}else o.every(s=>typeof s=="number")&&(n.type="number"),o.every(s=>typeof s=="string")&&(n.type="string"),o.every(s=>typeof s=="boolean")&&(n.type="boolean"),o.every(s=>s===null)&&(n.type="null"),n.enum=o},_A=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},IA=(e,t,n,i)=>{let r=n,o=e._zod.pattern;if(!o)throw new Error("Pattern not found in template literal");r.type="string",r.pattern=o.source},TA=(e,t,n,i)=>{let r=n,o={type:"string",format:"binary",contentEncoding:"binary"},{minimum:s,maximum:a,mime:l}=e._zod.bag;s!==void 0&&(o.minLength=s),a!==void 0&&(o.maxLength=a),l?l.length===1?(o.contentMediaType=l[0],Object.assign(r,o)):(Object.assign(r,o),r.anyOf=l.map(c=>({contentMediaType:c}))):Object.assign(r,o)},DA=(e,t,n,i)=>{n.type="boolean"},NA=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},jA=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},LA=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},MA=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},FA=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},BA=(e,t,n,i)=>{let r=n,o=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;typeof s=="number"&&(r.minItems=s),typeof a=="number"&&(r.maxItems=a),r.type="array",r.items=ht(o.element,t,{...i,path:[...i.path,"items"]})},GA=(e,t,n,i)=>{let r=n,o=e._zod.def;r.type="object",r.properties={};let s=o.shape;for(let c in s)r.properties[c]=ht(s[c],t,{...i,path:[...i.path,"properties",c]});let a=new Set(Object.keys(s)),l=new Set([...a].filter(c=>{let u=o.shape[c]._zod;return t.io==="input"?u.optin===void 0:u.optout===void 0}));l.size>0&&(r.required=Array.from(l)),o.catchall?._zod.def.type==="never"?r.additionalProperties=!1:o.catchall?o.catchall&&(r.additionalProperties=ht(o.catchall,t,{...i,path:[...i.path,"additionalProperties"]})):t.io==="output"&&(r.additionalProperties=!1)},rb=(e,t,n,i)=>{let r=e._zod.def,o=r.inclusive===!1,s=r.options.map((a,l)=>ht(a,t,{...i,path:[...i.path,o?"oneOf":"anyOf",l]}));o?n.oneOf=s:n.anyOf=s},WA=(e,t,n,i)=>{let r=e._zod.def,o=ht(r.left,t,{...i,path:[...i.path,"allOf",0]}),s=ht(r.right,t,{...i,path:[...i.path,"allOf",1]}),a=c=>"allOf"in c&&Object.keys(c).length===1,l=[...a(o)?o.allOf:[o],...a(s)?s.allOf:[s]];n.allOf=l},zA=(e,t,n,i)=>{let r=n,o=e._zod.def;r.type="array";let s=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",l=o.items.map((p,f)=>ht(p,t,{...i,path:[...i.path,s,f]})),c=o.rest?ht(o.rest,t,{...i,path:[...i.path,a,...t.target==="openapi-3.0"?[o.items.length]:[]]}):null;t.target==="draft-2020-12"?(r.prefixItems=l,c&&(r.items=c)):t.target==="openapi-3.0"?(r.items={anyOf:l},c&&r.items.anyOf.push(c),r.minItems=l.length,c||(r.maxItems=l.length)):(r.items=l,c&&(r.additionalItems=c));let{minimum:u,maximum:d}=e._zod.bag;typeof u=="number"&&(r.minItems=u),typeof d=="number"&&(r.maxItems=d)},UA=(e,t,n,i)=>{let r=n,o=e._zod.def;r.type="object";let s=o.keyType,l=s._zod.bag?.patterns;if(o.mode==="loose"&&l&&l.size>0){let u=ht(o.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(let d of l)r.patternProperties[d.source]=u}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(r.propertyNames=ht(o.keyType,t,{...i,path:[...i.path,"propertyNames"]})),r.additionalProperties=ht(o.valueType,t,{...i,path:[...i.path,"additionalProperties"]});let c=s._zod.values;if(c){let u=[...c].filter(d=>typeof d=="string"||typeof d=="number");u.length>0&&(r.required=u)}},HA=(e,t,n,i)=>{let r=e._zod.def,o=ht(r.innerType,t,i),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=r.innerType,n.nullable=!0):n.anyOf=[o,{type:"null"}]},VA=(e,t,n,i)=>{let r=e._zod.def;ht(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType},qA=(e,t,n,i)=>{let r=e._zod.def;ht(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType,n.default=JSON.parse(JSON.stringify(r.defaultValue))},KA=(e,t,n,i)=>{let r=e._zod.def;ht(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(r.defaultValue)))},JA=(e,t,n,i)=>{let r=e._zod.def;ht(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType;let s;try{s=r.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=s},ZA=(e,t,n,i)=>{let r=e._zod.def,o=t.io==="input"?r.in._zod.def.type==="transform"?r.out:r.in:r.out;ht(o,t,i);let s=t.seen.get(e);s.ref=o},YA=(e,t,n,i)=>{let r=e._zod.def;ht(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType,n.readOnly=!0},XA=(e,t,n,i)=>{let r=e._zod.def;ht(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType},ib=(e,t,n,i)=>{let r=e._zod.def;ht(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType},QA=(e,t,n,i)=>{let r=e._zod.innerType;ht(r,t,i);let o=t.seen.get(e);o.ref=r},nb={string:yA,number:bA,boolean:wA,bigint:vA,symbol:kA,null:xA,undefined:$A,void:RA,never:SA,any:EA,unknown:AA,date:PA,enum:OA,literal:CA,nan:_A,template_literal:IA,file:TA,success:DA,custom:NA,function:jA,transform:LA,map:MA,set:FA,array:BA,object:GA,union:rb,intersection:WA,tuple:zA,record:UA,nullable:HA,nonoptional:VA,default:qA,prefault:KA,catch:JA,pipe:ZA,readonly:YA,promise:XA,optional:ib,lazy:QA}});var sb,YB=v(()=>{nf();tf();sb=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let n=t?.target??"draft-2020-12";n==="draft-4"&&(n="draft-04"),n==="draft-7"&&(n="draft-07"),this.ctx=Vs({processors:nb,target:n,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,n={path:[],schemaPath:[]}){return ht(t,this.ctx,n)}emit(t,n){n&&(n.cycles&&(this.ctx.cycles=n.cycles),n.reused&&(this.ctx.reused=n.reused),n.external&&(this.ctx.external=n.external)),qs(this.ctx,t);let i=Ks(this.ctx,t),{"~standard":r,...o}=i;return o}}});var XB={};var QB=v(()=>{});var Zo={};_e(Zo,{$ZodAny:()=>VS,$ZodArray:()=>YS,$ZodAsyncError:()=>xi,$ZodBase64:()=>jS,$ZodBase64URL:()=>LS,$ZodBigInt:()=>$y,$ZodBigIntFormat:()=>WS,$ZodBoolean:()=>qp,$ZodCIDRv4:()=>TS,$ZodCIDRv6:()=>DS,$ZodCUID:()=>kS,$ZodCUID2:()=>xS,$ZodCatch:()=>gE,$ZodCheck:()=>Et,$ZodCheckBigIntFormat:()=>JR,$ZodCheckEndsWith:()=>aS,$ZodCheckGreaterThan:()=>gy,$ZodCheckIncludes:()=>oS,$ZodCheckLengthEquals:()=>tS,$ZodCheckLessThan:()=>my,$ZodCheckLowerCase:()=>rS,$ZodCheckMaxLength:()=>QR,$ZodCheckMaxSize:()=>ZR,$ZodCheckMimeType:()=>lS,$ZodCheckMinLength:()=>eS,$ZodCheckMinSize:()=>YR,$ZodCheckMultipleOf:()=>qR,$ZodCheckNumberFormat:()=>KR,$ZodCheckOverwrite:()=>uS,$ZodCheckProperty:()=>cS,$ZodCheckRegex:()=>nS,$ZodCheckSizeEquals:()=>XR,$ZodCheckStartsWith:()=>sS,$ZodCheckStringFormat:()=>Vl,$ZodCheckUpperCase:()=>iS,$ZodCodec:()=>Jp,$ZodCustom:()=>$E,$ZodCustomStringFormat:()=>BS,$ZodDate:()=>ZS,$ZodDefault:()=>dE,$ZodDiscriminatedUnion:()=>eE,$ZodE164:()=>MS,$ZodEmail:()=>yS,$ZodEmoji:()=>wS,$ZodEncodeError:()=>Fs,$ZodEnum:()=>oE,$ZodError:()=>Gp,$ZodExactOptional:()=>lE,$ZodFile:()=>aE,$ZodFunction:()=>vE,$ZodGUID:()=>gS,$ZodIPv4:()=>CS,$ZodIPv6:()=>_S,$ZodISODate:()=>AS,$ZodISODateTime:()=>ES,$ZodISODuration:()=>OS,$ZodISOTime:()=>PS,$ZodIntersection:()=>tE,$ZodJWT:()=>FS,$ZodKSUID:()=>SS,$ZodLazy:()=>xE,$ZodLiteral:()=>sE,$ZodMAC:()=>IS,$ZodMap:()=>rE,$ZodNaN:()=>hE,$ZodNanoID:()=>vS,$ZodNever:()=>KS,$ZodNonOptional:()=>fE,$ZodNull:()=>HS,$ZodNullable:()=>uE,$ZodNumber:()=>xy,$ZodNumberFormat:()=>GS,$ZodObject:()=>oF,$ZodObjectJIT:()=>XS,$ZodOptional:()=>Sy,$ZodPipe:()=>yE,$ZodPrefault:()=>pE,$ZodPromise:()=>kE,$ZodReadonly:()=>bE,$ZodRealError:()=>pr,$ZodRecord:()=>nE,$ZodRegistry:()=>Oy,$ZodSet:()=>iE,$ZodString:()=>dc,$ZodStringFormat:()=>vt,$ZodSuccess:()=>mE,$ZodSymbol:()=>zS,$ZodTemplateLiteral:()=>wE,$ZodTransform:()=>cE,$ZodTuple:()=>Ry,$ZodType:()=>Ne,$ZodULID:()=>$S,$ZodURL:()=>bS,$ZodUUID:()=>hS,$ZodUndefined:()=>US,$ZodUnion:()=>Kp,$ZodUnknown:()=>qS,$ZodVoid:()=>JS,$ZodXID:()=>RS,$ZodXor:()=>QS,$brand:()=>Xh,$constructor:()=>M,$input:()=>CE,$output:()=>OE,Doc:()=>Vp,JSONSchema:()=>XB,JSONSchemaGenerator:()=>sb,NEVER:()=>nR,TimePrecision:()=>DE,_any:()=>tA,_array:()=>cA,_base64:()=>qy,_base64url:()=>Ky,_bigint:()=>KE,_boolean:()=>VE,_catch:()=>wie,_check:()=>JB,_cidrv4:()=>Hy,_cidrv6:()=>Vy,_coercedBigint:()=>JE,_coercedBoolean:()=>qE,_coercedDate:()=>sA,_coercedNumber:()=>BE,_coercedString:()=>IE,_cuid:()=>My,_cuid2:()=>Fy,_custom:()=>uA,_date:()=>oA,_decode:()=>iy,_decodeAsync:()=>sy,_default:()=>hie,_discriminatedUnion:()=>iie,_e164:()=>Jy,_email:()=>_y,_emoji:()=>jy,_encode:()=>ry,_encodeAsync:()=>oy,_endsWith:()=>Ql,_enum:()=>uie,_file:()=>lA,_float32:()=>WE,_float64:()=>zE,_gt:()=>Zi,_gte:()=>Zn,_guid:()=>Qp,_includes:()=>Yl,_int:()=>GE,_int32:()=>UE,_int64:()=>ZE,_intersection:()=>oie,_ipv4:()=>zy,_ipv6:()=>Uy,_isoDate:()=>jE,_isoDateTime:()=>NE,_isoDuration:()=>ME,_isoTime:()=>LE,_jwt:()=>Zy,_ksuid:()=>Wy,_lazy:()=>$ie,_length:()=>mc,_literal:()=>pie,_lowercase:()=>Jl,_lt:()=>Ji,_lte:()=>Ir,_mac:()=>TE,_map:()=>cie,_max:()=>Ir,_maxLength:()=>fc,_maxSize:()=>Hs,_mime:()=>eu,_min:()=>Zn,_minLength:()=>Jo,_minSize:()=>Yi,_multipleOf:()=>Us,_nan:()=>aA,_nanoid:()=>Ly,_nativeEnum:()=>die,_negative:()=>Xy,_never:()=>rA,_nonnegative:()=>eb,_nonoptional:()=>yie,_nonpositive:()=>Qy,_normalize:()=>tu,_null:()=>eA,_nullable:()=>gie,_number:()=>FE,_optional:()=>mie,_overwrite:()=>$i,_parse:()=>Wl,_parseAsync:()=>zl,_pipe:()=>vie,_positive:()=>Yy,_promise:()=>Rie,_property:()=>tb,_readonly:()=>kie,_record:()=>aie,_refine:()=>dA,_regex:()=>Kl,_safeDecode:()=>cy,_safeDecodeAsync:()=>uy,_safeEncode:()=>ay,_safeEncodeAsync:()=>ly,_safeParse:()=>Ul,_safeParseAsync:()=>Hl,_set:()=>lie,_size:()=>pc,_slugify:()=>ou,_startsWith:()=>Xl,_string:()=>_E,_stringFormat:()=>su,_stringbool:()=>gA,_success:()=>bie,_superRefine:()=>pA,_symbol:()=>XE,_templateLiteral:()=>xie,_toLowerCase:()=>ru,_toUpperCase:()=>iu,_transform:()=>fie,_trim:()=>nu,_tuple:()=>sie,_uint32:()=>HE,_uint64:()=>YE,_ulid:()=>By,_undefined:()=>QE,_union:()=>nie,_unknown:()=>nA,_uppercase:()=>Zl,_url:()=>ef,_uuid:()=>Iy,_uuidv4:()=>Ty,_uuidv6:()=>Dy,_uuidv7:()=>Ny,_void:()=>iA,_xid:()=>Gy,_xor:()=>rie,clone:()=>Jn,config:()=>Ht,createStandardJSONSchemaMethod:()=>au,createToJSONSchemaMethod:()=>hA,decode:()=>Ane,decodeAsync:()=>One,describe:()=>fA,encode:()=>Ene,encodeAsync:()=>Pne,extractDefs:()=>qs,finalize:()=>Ks,flattenError:()=>Wp,formatError:()=>zp,globalConfig:()=>Dp,globalRegistry:()=>kn,initializeContext:()=>Vs,isValidBase64:()=>NS,isValidBase64URL:()=>tF,isValidJWT:()=>nF,locales:()=>Yp,meta:()=>mA,parse:()=>ty,parseAsync:()=>ny,prettifyError:()=>mR,process:()=>ht,regexes:()=>qr,registry:()=>Cy,safeDecode:()=>_ne,safeDecodeAsync:()=>Tne,safeEncode:()=>Cne,safeEncodeAsync:()=>Ine,safeParse:()=>hR,safeParseAsync:()=>yR,toDotPath:()=>L1,toJSONSchema:()=>ob,treeifyError:()=>fR,util:()=>le,version:()=>pS});var fr=v(()=>{Ml();bR();gR();RE();hy();fS();Ae();fy();PE();Xp();dS();ZB();tf();nf();YB();QB()});var ab={};_e(ab,{endsWith:()=>Ql,gt:()=>Zi,gte:()=>Zn,includes:()=>Yl,length:()=>mc,lowercase:()=>Jl,lt:()=>Ji,lte:()=>Ir,maxLength:()=>fc,maxSize:()=>Hs,mime:()=>eu,minLength:()=>Jo,minSize:()=>Yi,multipleOf:()=>Us,negative:()=>Xy,nonnegative:()=>eb,nonpositive:()=>Qy,normalize:()=>tu,overwrite:()=>$i,positive:()=>Yy,property:()=>tb,regex:()=>Kl,size:()=>pc,slugify:()=>ou,startsWith:()=>Xl,toLowerCase:()=>ru,toUpperCase:()=>iu,trim:()=>nu,uppercase:()=>Zl});var cb=v(()=>{fr()});var cu={};_e(cu,{ZodISODate:()=>ub,ZodISODateTime:()=>lb,ZodISODuration:()=>pb,ZodISOTime:()=>db,date:()=>tP,datetime:()=>eP,duration:()=>rP,time:()=>nP});function eP(e){return NE(lb,e)}function tP(e){return jE(ub,e)}function nP(e){return LE(db,e)}function rP(e){return ME(pb,e)}var lb,ub,db,pb,rf=v(()=>{fr();sf();lb=M("ZodISODateTime",(e,t)=>{ES.init(e,t),kt.init(e,t)});ub=M("ZodISODate",(e,t)=>{AS.init(e,t),kt.init(e,t)});db=M("ZodISOTime",(e,t)=>{PS.init(e,t),kt.init(e,t)});pb=M("ZodISODuration",(e,t)=>{OS.init(e,t),kt.init(e,t)})});var eG,Aie,mr,iP=v(()=>{fr();fr();Ae();eG=(e,t)=>{Gp.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>zp(e,n)},flatten:{value:n=>Wp(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Fl,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Fl,2)}},isEmpty:{get(){return e.issues.length===0}}})},Aie=M("ZodError",eG),mr=M("ZodError",eG,{Parent:Error})});var oP,sP,aP,cP,lP,uP,dP,pP,fP,mP,gP,hP,yP=v(()=>{fr();iP();oP=Wl(mr),sP=zl(mr),aP=Ul(mr),cP=Hl(mr),lP=ry(mr),uP=iy(mr),dP=oy(mr),pP=sy(mr),fP=ay(mr),mP=cy(mr),gP=ly(mr),hP=uy(mr)});var of={};_e(of,{ZodAny:()=>SP,ZodArray:()=>OP,ZodBase64:()=>Pb,ZodBase64URL:()=>Ob,ZodBigInt:()=>mu,ZodBigIntFormat:()=>Ib,ZodBoolean:()=>fu,ZodCIDRv4:()=>Eb,ZodCIDRv6:()=>Ab,ZodCUID:()=>wb,ZodCUID2:()=>vb,ZodCatch:()=>YP,ZodCodec:()=>Bb,ZodCustom:()=>yf,ZodCustomStringFormat:()=>du,ZodDate:()=>pf,ZodDefault:()=>HP,ZodDiscriminatedUnion:()=>_P,ZodE164:()=>Cb,ZodEmail:()=>hb,ZodEmoji:()=>yb,ZodEnum:()=>lu,ZodExactOptional:()=>WP,ZodFile:()=>BP,ZodFunction:()=>sO,ZodGUID:()=>af,ZodIPv4:()=>Rb,ZodIPv6:()=>Sb,ZodIntersection:()=>IP,ZodJWT:()=>_b,ZodKSUID:()=>$b,ZodLazy:()=>rO,ZodLiteral:()=>FP,ZodMAC:()=>bP,ZodMap:()=>LP,ZodNaN:()=>QP,ZodNanoID:()=>bb,ZodNever:()=>AP,ZodNonOptional:()=>Mb,ZodNull:()=>$P,ZodNullable:()=>UP,ZodNumber:()=>pu,ZodNumberFormat:()=>hc,ZodObject:()=>mf,ZodOptional:()=>Lb,ZodPipe:()=>Fb,ZodPrefault:()=>qP,ZodPromise:()=>oO,ZodReadonly:()=>eO,ZodRecord:()=>hf,ZodSet:()=>MP,ZodString:()=>uu,ZodStringFormat:()=>kt,ZodSuccess:()=>ZP,ZodSymbol:()=>kP,ZodTemplateLiteral:()=>nO,ZodTransform:()=>GP,ZodTuple:()=>DP,ZodType:()=>Ge,ZodULID:()=>kb,ZodURL:()=>df,ZodUUID:()=>Xi,ZodUndefined:()=>xP,ZodUnion:()=>gf,ZodUnknown:()=>EP,ZodVoid:()=>PP,ZodXID:()=>xb,ZodXor:()=>CP,_ZodString:()=>gb,_default:()=>VP,_function:()=>sW,any:()=>MG,array:()=>ff,base64:()=>kG,base64url:()=>xG,bigint:()=>TG,boolean:()=>vP,catch:()=>XP,check:()=>aW,cidrv4:()=>wG,cidrv6:()=>vG,codec:()=>rW,cuid:()=>dG,cuid2:()=>pG,custom:()=>cW,date:()=>BG,describe:()=>lW,discriminatedUnion:()=>VG,e164:()=>$G,email:()=>tG,emoji:()=>lG,enum:()=>Nb,exactOptional:()=>zP,file:()=>QG,float32:()=>OG,float64:()=>CG,function:()=>sW,guid:()=>nG,hash:()=>PG,hex:()=>AG,hostname:()=>EG,httpUrl:()=>cG,instanceof:()=>dW,int:()=>mb,int32:()=>_G,int64:()=>DG,intersection:()=>TP,ipv4:()=>hG,ipv6:()=>bG,json:()=>fW,jwt:()=>RG,keyof:()=>GG,ksuid:()=>gG,lazy:()=>iO,literal:()=>XG,looseObject:()=>UG,looseRecord:()=>KG,mac:()=>yG,map:()=>JG,meta:()=>uW,nan:()=>nW,nanoid:()=>uG,nativeEnum:()=>YG,never:()=>Tb,nonoptional:()=>JP,null:()=>RP,nullable:()=>lf,nullish:()=>eW,number:()=>wP,object:()=>WG,optional:()=>cf,partialRecord:()=>qG,pipe:()=>uf,prefault:()=>KP,preprocess:()=>mW,promise:()=>oW,readonly:()=>tO,record:()=>jP,refine:()=>aO,set:()=>ZG,strictObject:()=>zG,string:()=>fb,stringFormat:()=>SG,stringbool:()=>pW,success:()=>tW,superRefine:()=>cO,symbol:()=>jG,templateLiteral:()=>iW,transform:()=>jb,tuple:()=>NP,uint32:()=>IG,uint64:()=>NG,ulid:()=>fG,undefined:()=>LG,union:()=>Db,unknown:()=>gc,url:()=>aG,uuid:()=>rG,uuidv4:()=>iG,uuidv6:()=>oG,uuidv7:()=>sG,void:()=>FG,xid:()=>mG,xor:()=>HG});function fb(e){return _E(uu,e)}function tG(e){return _y(hb,e)}function nG(e){return Qp(af,e)}function rG(e){return Iy(Xi,e)}function iG(e){return Ty(Xi,e)}function oG(e){return Dy(Xi,e)}function sG(e){return Ny(Xi,e)}function aG(e){return ef(df,e)}function cG(e){return ef(df,{protocol:/^https?$/,hostname:qr.domain,...le.normalizeParams(e)})}function lG(e){return jy(yb,e)}function uG(e){return Ly(bb,e)}function dG(e){return My(wb,e)}function pG(e){return Fy(vb,e)}function fG(e){return By(kb,e)}function mG(e){return Gy(xb,e)}function gG(e){return Wy($b,e)}function hG(e){return zy(Rb,e)}function yG(e){return TE(bP,e)}function bG(e){return Uy(Sb,e)}function wG(e){return Hy(Eb,e)}function vG(e){return Vy(Ab,e)}function kG(e){return qy(Pb,e)}function xG(e){return Ky(Ob,e)}function $G(e){return Jy(Cb,e)}function RG(e){return Zy(_b,e)}function SG(e,t,n={}){return su(du,e,t,n)}function EG(e){return su(du,"hostname",qr.hostname,e)}function AG(e){return su(du,"hex",qr.hex,e)}function PG(e,t){let n=t?.enc??"hex",i=`${e}_${n}`,r=qr[i];if(!r)throw new Error(`Unrecognized hash format: ${i}`);return su(du,i,r,t)}function wP(e){return FE(pu,e)}function mb(e){return GE(hc,e)}function OG(e){return WE(hc,e)}function CG(e){return zE(hc,e)}function _G(e){return UE(hc,e)}function IG(e){return HE(hc,e)}function vP(e){return VE(fu,e)}function TG(e){return KE(mu,e)}function DG(e){return ZE(Ib,e)}function NG(e){return YE(Ib,e)}function jG(e){return XE(kP,e)}function LG(e){return QE(xP,e)}function RP(e){return eA($P,e)}function MG(){return tA(SP)}function gc(){return nA(EP)}function Tb(e){return rA(AP,e)}function FG(e){return iA(PP,e)}function BG(e){return oA(pf,e)}function ff(e,t){return cA(OP,e,t)}function GG(e){let t=e._zod.def.shape;return Nb(Object.keys(t))}function WG(e,t){let n={type:"object",shape:e??{},...le.normalizeParams(t)};return new mf(n)}function zG(e,t){return new mf({type:"object",shape:e,catchall:Tb(),...le.normalizeParams(t)})}function UG(e,t){return new mf({type:"object",shape:e,catchall:gc(),...le.normalizeParams(t)})}function Db(e,t){return new gf({type:"union",options:e,...le.normalizeParams(t)})}function HG(e,t){return new CP({type:"union",options:e,inclusive:!1,...le.normalizeParams(t)})}function VG(e,t,n){return new _P({type:"union",options:t,discriminator:e,...le.normalizeParams(n)})}function TP(e,t){return new IP({type:"intersection",left:e,right:t})}function NP(e,t,n){let i=t instanceof Ne,r=i?n:t,o=i?t:null;return new DP({type:"tuple",items:e,rest:o,...le.normalizeParams(r)})}function jP(e,t,n){return new hf({type:"record",keyType:e,valueType:t,...le.normalizeParams(n)})}function qG(e,t,n){let i=Jn(e);return i._zod.values=void 0,new hf({type:"record",keyType:i,valueType:t,...le.normalizeParams(n)})}function KG(e,t,n){return new hf({type:"record",keyType:e,valueType:t,mode:"loose",...le.normalizeParams(n)})}function JG(e,t,n){return new LP({type:"map",keyType:e,valueType:t,...le.normalizeParams(n)})}function ZG(e,t){return new MP({type:"set",valueType:e,...le.normalizeParams(t)})}function Nb(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(i=>[i,i])):e;return new lu({type:"enum",entries:n,...le.normalizeParams(t)})}function YG(e,t){return new lu({type:"enum",entries:e,...le.normalizeParams(t)})}function XG(e,t){return new FP({type:"literal",values:Array.isArray(e)?e:[e],...le.normalizeParams(t)})}function QG(e){return lA(BP,e)}function jb(e){return new GP({type:"transform",transform:e})}function cf(e){return new Lb({type:"optional",innerType:e})}function zP(e){return new WP({type:"optional",innerType:e})}function lf(e){return new UP({type:"nullable",innerType:e})}function eW(e){return cf(lf(e))}function VP(e,t){return new HP({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():le.shallowClone(t)}})}function KP(e,t){return new qP({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():le.shallowClone(t)}})}function JP(e,t){return new Mb({type:"nonoptional",innerType:e,...le.normalizeParams(t)})}function tW(e){return new ZP({type:"success",innerType:e})}function XP(e,t){return new YP({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}function nW(e){return aA(QP,e)}function uf(e,t){return new Fb({type:"pipe",in:e,out:t})}function rW(e,t,n){return new Bb({type:"pipe",in:e,out:t,transform:n.decode,reverseTransform:n.encode})}function tO(e){return new eO({type:"readonly",innerType:e})}function iW(e,t){return new nO({type:"template_literal",parts:e,...le.normalizeParams(t)})}function iO(e){return new rO({type:"lazy",getter:e})}function oW(e){return new oO({type:"promise",innerType:e})}function sW(e){return new sO({type:"function",input:Array.isArray(e?.input)?NP(e?.input):e?.input??ff(gc()),output:e?.output??gc()})}function aW(e){let t=new Et({check:"custom"});return t._zod.check=e,t}function cW(e,t){return uA(yf,e??(()=>!0),t)}function aO(e,t={}){return dA(yf,e,t)}function cO(e){return pA(e)}function dW(e,t={}){let n=new yf({type:"custom",check:"custom",fn:i=>i instanceof e,abort:!0,...le.normalizeParams(t)});return n._zod.bag.Class=e,n._zod.check=i=>{i.value instanceof e||i.issues.push({code:"invalid_type",expected:e.name,input:i.value,inst:n,path:[...n._zod.def.path??[]]})},n}function fW(e){let t=iO(()=>Db([fb(e),wP(),vP(),RP(),ff(t),jP(fb(),t)]));return t}function mW(e,t){return uf(jb(e),t)}var Ge,gb,uu,kt,hb,af,Xi,df,yb,bb,wb,vb,kb,xb,$b,Rb,bP,Sb,Eb,Ab,Pb,Ob,Cb,_b,du,pu,hc,fu,mu,Ib,kP,xP,$P,SP,EP,AP,PP,pf,OP,mf,gf,CP,_P,IP,DP,hf,LP,MP,lu,FP,BP,GP,Lb,WP,UP,HP,qP,Mb,ZP,YP,QP,Fb,Bb,eO,nO,rO,oO,sO,yf,lW,uW,pW,sf=v(()=>{fr();fr();nf();tf();cb();rf();yP();Ge=M("ZodType",(e,t)=>(Ne.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:au(e,"input"),output:au(e,"output")}}),e.toJSONSchema=hA(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(le.mergeDefs(t,{checks:[...t.checks??[],...n.map(i=>typeof i=="function"?{_zod:{check:i,def:{check:"custom"},onattach:[]}}:i)]}),{parent:!0}),e.with=e.check,e.clone=(n,i)=>Jn(e,n,i),e.brand=()=>e,e.register=((n,i)=>(n.add(e,i),e)),e.parse=(n,i)=>oP(e,n,i,{callee:e.parse}),e.safeParse=(n,i)=>aP(e,n,i),e.parseAsync=async(n,i)=>sP(e,n,i,{callee:e.parseAsync}),e.safeParseAsync=async(n,i)=>cP(e,n,i),e.spa=e.safeParseAsync,e.encode=(n,i)=>lP(e,n,i),e.decode=(n,i)=>uP(e,n,i),e.encodeAsync=async(n,i)=>dP(e,n,i),e.decodeAsync=async(n,i)=>pP(e,n,i),e.safeEncode=(n,i)=>fP(e,n,i),e.safeDecode=(n,i)=>mP(e,n,i),e.safeEncodeAsync=async(n,i)=>gP(e,n,i),e.safeDecodeAsync=async(n,i)=>hP(e,n,i),e.refine=(n,i)=>e.check(aO(n,i)),e.superRefine=n=>e.check(cO(n)),e.overwrite=n=>e.check($i(n)),e.optional=()=>cf(e),e.exactOptional=()=>zP(e),e.nullable=()=>lf(e),e.nullish=()=>cf(lf(e)),e.nonoptional=n=>JP(e,n),e.array=()=>ff(e),e.or=n=>Db([e,n]),e.and=n=>TP(e,n),e.transform=n=>uf(e,jb(n)),e.default=n=>VP(e,n),e.prefault=n=>KP(e,n),e.catch=n=>XP(e,n),e.pipe=n=>uf(e,n),e.readonly=()=>tO(e),e.describe=n=>{let i=e.clone();return kn.add(i,{description:n}),i},Object.defineProperty(e,"description",{get(){return kn.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return kn.get(e);let i=e.clone();return kn.add(i,n[0]),i},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),gb=M("_ZodString",(e,t)=>{dc.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(i,r,o)=>yA(e,i,r,o);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...i)=>e.check(Kl(...i)),e.includes=(...i)=>e.check(Yl(...i)),e.startsWith=(...i)=>e.check(Xl(...i)),e.endsWith=(...i)=>e.check(Ql(...i)),e.min=(...i)=>e.check(Jo(...i)),e.max=(...i)=>e.check(fc(...i)),e.length=(...i)=>e.check(mc(...i)),e.nonempty=(...i)=>e.check(Jo(1,...i)),e.lowercase=i=>e.check(Jl(i)),e.uppercase=i=>e.check(Zl(i)),e.trim=()=>e.check(nu()),e.normalize=(...i)=>e.check(tu(...i)),e.toLowerCase=()=>e.check(ru()),e.toUpperCase=()=>e.check(iu()),e.slugify=()=>e.check(ou())}),uu=M("ZodString",(e,t)=>{dc.init(e,t),gb.init(e,t),e.email=n=>e.check(_y(hb,n)),e.url=n=>e.check(ef(df,n)),e.jwt=n=>e.check(Zy(_b,n)),e.emoji=n=>e.check(jy(yb,n)),e.guid=n=>e.check(Qp(af,n)),e.uuid=n=>e.check(Iy(Xi,n)),e.uuidv4=n=>e.check(Ty(Xi,n)),e.uuidv6=n=>e.check(Dy(Xi,n)),e.uuidv7=n=>e.check(Ny(Xi,n)),e.nanoid=n=>e.check(Ly(bb,n)),e.guid=n=>e.check(Qp(af,n)),e.cuid=n=>e.check(My(wb,n)),e.cuid2=n=>e.check(Fy(vb,n)),e.ulid=n=>e.check(By(kb,n)),e.base64=n=>e.check(qy(Pb,n)),e.base64url=n=>e.check(Ky(Ob,n)),e.xid=n=>e.check(Gy(xb,n)),e.ksuid=n=>e.check(Wy($b,n)),e.ipv4=n=>e.check(zy(Rb,n)),e.ipv6=n=>e.check(Uy(Sb,n)),e.cidrv4=n=>e.check(Hy(Eb,n)),e.cidrv6=n=>e.check(Vy(Ab,n)),e.e164=n=>e.check(Jy(Cb,n)),e.datetime=n=>e.check(eP(n)),e.date=n=>e.check(tP(n)),e.time=n=>e.check(nP(n)),e.duration=n=>e.check(rP(n))});kt=M("ZodStringFormat",(e,t)=>{vt.init(e,t),gb.init(e,t)}),hb=M("ZodEmail",(e,t)=>{yS.init(e,t),kt.init(e,t)});af=M("ZodGUID",(e,t)=>{gS.init(e,t),kt.init(e,t)});Xi=M("ZodUUID",(e,t)=>{hS.init(e,t),kt.init(e,t)});df=M("ZodURL",(e,t)=>{bS.init(e,t),kt.init(e,t)});yb=M("ZodEmoji",(e,t)=>{wS.init(e,t),kt.init(e,t)});bb=M("ZodNanoID",(e,t)=>{vS.init(e,t),kt.init(e,t)});wb=M("ZodCUID",(e,t)=>{kS.init(e,t),kt.init(e,t)});vb=M("ZodCUID2",(e,t)=>{xS.init(e,t),kt.init(e,t)});kb=M("ZodULID",(e,t)=>{$S.init(e,t),kt.init(e,t)});xb=M("ZodXID",(e,t)=>{RS.init(e,t),kt.init(e,t)});$b=M("ZodKSUID",(e,t)=>{SS.init(e,t),kt.init(e,t)});Rb=M("ZodIPv4",(e,t)=>{CS.init(e,t),kt.init(e,t)});bP=M("ZodMAC",(e,t)=>{IS.init(e,t),kt.init(e,t)});Sb=M("ZodIPv6",(e,t)=>{_S.init(e,t),kt.init(e,t)});Eb=M("ZodCIDRv4",(e,t)=>{TS.init(e,t),kt.init(e,t)});Ab=M("ZodCIDRv6",(e,t)=>{DS.init(e,t),kt.init(e,t)});Pb=M("ZodBase64",(e,t)=>{jS.init(e,t),kt.init(e,t)});Ob=M("ZodBase64URL",(e,t)=>{LS.init(e,t),kt.init(e,t)});Cb=M("ZodE164",(e,t)=>{MS.init(e,t),kt.init(e,t)});_b=M("ZodJWT",(e,t)=>{FS.init(e,t),kt.init(e,t)});du=M("ZodCustomStringFormat",(e,t)=>{BS.init(e,t),kt.init(e,t)});pu=M("ZodNumber",(e,t)=>{xy.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(i,r,o)=>bA(e,i,r,o),e.gt=(i,r)=>e.check(Zi(i,r)),e.gte=(i,r)=>e.check(Zn(i,r)),e.min=(i,r)=>e.check(Zn(i,r)),e.lt=(i,r)=>e.check(Ji(i,r)),e.lte=(i,r)=>e.check(Ir(i,r)),e.max=(i,r)=>e.check(Ir(i,r)),e.int=i=>e.check(mb(i)),e.safe=i=>e.check(mb(i)),e.positive=i=>e.check(Zi(0,i)),e.nonnegative=i=>e.check(Zn(0,i)),e.negative=i=>e.check(Ji(0,i)),e.nonpositive=i=>e.check(Ir(0,i)),e.multipleOf=(i,r)=>e.check(Us(i,r)),e.step=(i,r)=>e.check(Us(i,r)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});hc=M("ZodNumberFormat",(e,t)=>{GS.init(e,t),pu.init(e,t)});fu=M("ZodBoolean",(e,t)=>{qp.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>wA(e,n,i,r)});mu=M("ZodBigInt",(e,t)=>{$y.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(i,r,o)=>vA(e,i,r,o),e.gte=(i,r)=>e.check(Zn(i,r)),e.min=(i,r)=>e.check(Zn(i,r)),e.gt=(i,r)=>e.check(Zi(i,r)),e.gte=(i,r)=>e.check(Zn(i,r)),e.min=(i,r)=>e.check(Zn(i,r)),e.lt=(i,r)=>e.check(Ji(i,r)),e.lte=(i,r)=>e.check(Ir(i,r)),e.max=(i,r)=>e.check(Ir(i,r)),e.positive=i=>e.check(Zi(BigInt(0),i)),e.negative=i=>e.check(Ji(BigInt(0),i)),e.nonpositive=i=>e.check(Ir(BigInt(0),i)),e.nonnegative=i=>e.check(Zn(BigInt(0),i)),e.multipleOf=(i,r)=>e.check(Us(i,r));let n=e._zod.bag;e.minValue=n.minimum??null,e.maxValue=n.maximum??null,e.format=n.format??null});Ib=M("ZodBigIntFormat",(e,t)=>{WS.init(e,t),mu.init(e,t)});kP=M("ZodSymbol",(e,t)=>{zS.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>kA(e,n,i,r)});xP=M("ZodUndefined",(e,t)=>{US.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>$A(e,n,i,r)});$P=M("ZodNull",(e,t)=>{HS.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>xA(e,n,i,r)});SP=M("ZodAny",(e,t)=>{VS.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>EA(e,n,i,r)});EP=M("ZodUnknown",(e,t)=>{qS.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>AA(e,n,i,r)});AP=M("ZodNever",(e,t)=>{KS.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>SA(e,n,i,r)});PP=M("ZodVoid",(e,t)=>{JS.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>RA(e,n,i,r)});pf=M("ZodDate",(e,t)=>{ZS.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(i,r,o)=>PA(e,i,r,o),e.min=(i,r)=>e.check(Zn(i,r)),e.max=(i,r)=>e.check(Ir(i,r));let n=e._zod.bag;e.minDate=n.minimum?new Date(n.minimum):null,e.maxDate=n.maximum?new Date(n.maximum):null});OP=M("ZodArray",(e,t)=>{YS.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>BA(e,n,i,r),e.element=t.element,e.min=(n,i)=>e.check(Jo(n,i)),e.nonempty=n=>e.check(Jo(1,n)),e.max=(n,i)=>e.check(fc(n,i)),e.length=(n,i)=>e.check(mc(n,i)),e.unwrap=()=>e.element});mf=M("ZodObject",(e,t)=>{XS.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>GA(e,n,i,r),le.defineLazy(e,"shape",()=>t.shape),e.keyof=()=>Nb(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:gc()}),e.loose=()=>e.clone({...e._zod.def,catchall:gc()}),e.strict=()=>e.clone({...e._zod.def,catchall:Tb()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>le.extend(e,n),e.safeExtend=n=>le.safeExtend(e,n),e.merge=n=>le.merge(e,n),e.pick=n=>le.pick(e,n),e.omit=n=>le.omit(e,n),e.partial=(...n)=>le.partial(Lb,e,n[0]),e.required=(...n)=>le.required(Mb,e,n[0])});gf=M("ZodUnion",(e,t)=>{Kp.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>rb(e,n,i,r),e.options=t.options});CP=M("ZodXor",(e,t)=>{gf.init(e,t),QS.init(e,t),e._zod.processJSONSchema=(n,i,r)=>rb(e,n,i,r),e.options=t.options});_P=M("ZodDiscriminatedUnion",(e,t)=>{gf.init(e,t),eE.init(e,t)});IP=M("ZodIntersection",(e,t)=>{tE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>WA(e,n,i,r)});DP=M("ZodTuple",(e,t)=>{Ry.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>zA(e,n,i,r),e.rest=n=>e.clone({...e._zod.def,rest:n})});hf=M("ZodRecord",(e,t)=>{nE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>UA(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});LP=M("ZodMap",(e,t)=>{rE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>MA(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...n)=>e.check(Yi(...n)),e.nonempty=n=>e.check(Yi(1,n)),e.max=(...n)=>e.check(Hs(...n)),e.size=(...n)=>e.check(pc(...n))});MP=M("ZodSet",(e,t)=>{iE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>FA(e,n,i,r),e.min=(...n)=>e.check(Yi(...n)),e.nonempty=n=>e.check(Yi(1,n)),e.max=(...n)=>e.check(Hs(...n)),e.size=(...n)=>e.check(pc(...n))});lu=M("ZodEnum",(e,t)=>{oE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(i,r,o)=>OA(e,i,r,o),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(i,r)=>{let o={};for(let s of i)if(n.has(s))o[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new lu({...t,checks:[],...le.normalizeParams(r),entries:o})},e.exclude=(i,r)=>{let o={...t.entries};for(let s of i)if(n.has(s))delete o[s];else throw new Error(`Key ${s} not found in enum`);return new lu({...t,checks:[],...le.normalizeParams(r),entries:o})}});FP=M("ZodLiteral",(e,t)=>{sE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>CA(e,n,i,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});BP=M("ZodFile",(e,t)=>{aE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>TA(e,n,i,r),e.min=(n,i)=>e.check(Yi(n,i)),e.max=(n,i)=>e.check(Hs(n,i)),e.mime=(n,i)=>e.check(eu(Array.isArray(n)?n:[n],i))});GP=M("ZodTransform",(e,t)=>{cE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>LA(e,n,i,r),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new Fs(e.constructor.name);n.addIssue=o=>{if(typeof o=="string")n.issues.push(le.issue(o,n.value,t));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=e),n.issues.push(le.issue(s))}};let r=t.transform(n.value,n);return r instanceof Promise?r.then(o=>(n.value=o,n)):(n.value=r,n)}});Lb=M("ZodOptional",(e,t)=>{Sy.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>ib(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});WP=M("ZodExactOptional",(e,t)=>{lE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>ib(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});UP=M("ZodNullable",(e,t)=>{uE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>HA(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});HP=M("ZodDefault",(e,t)=>{dE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>qA(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});qP=M("ZodPrefault",(e,t)=>{pE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>KA(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});Mb=M("ZodNonOptional",(e,t)=>{fE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>VA(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});ZP=M("ZodSuccess",(e,t)=>{mE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>DA(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});YP=M("ZodCatch",(e,t)=>{gE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>JA(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});QP=M("ZodNaN",(e,t)=>{hE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>_A(e,n,i,r)});Fb=M("ZodPipe",(e,t)=>{yE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>ZA(e,n,i,r),e.in=t.in,e.out=t.out});Bb=M("ZodCodec",(e,t)=>{Fb.init(e,t),Jp.init(e,t)});eO=M("ZodReadonly",(e,t)=>{bE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>YA(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});nO=M("ZodTemplateLiteral",(e,t)=>{wE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>IA(e,n,i,r)});rO=M("ZodLazy",(e,t)=>{xE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>QA(e,n,i,r),e.unwrap=()=>e._zod.def.getter()});oO=M("ZodPromise",(e,t)=>{kE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>XA(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});sO=M("ZodFunction",(e,t)=>{vE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>jA(e,n,i,r)});yf=M("ZodCustom",(e,t)=>{$E.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>NA(e,n,i,r)});lW=fA,uW=mA;pW=(...e)=>gA({Codec:Bb,Boolean:fu,String:uu},...e)});function Cie(e){Ht({customError:e})}function _ie(){return Ht().customError}var Oie,lO,gW=v(()=>{fr();fr();Oie={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};lO||(lO={})});function Tie(e,t){let n=e.$schema;return n==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":n==="http://json-schema.org/draft-07/schema#"?"draft-7":n==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function Die(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let n=e.slice(1).split("/").filter(Boolean);if(n.length===0)return t.rootSchema;let i=t.version==="draft-2020-12"?"$defs":"definitions";if(n[0]===i){let r=n[1];if(!r||!t.defs[r])throw new Error(`Reference not found: ${e}`);return t.defs[r]}throw new Error(`Reference not found: ${e}`)}function hW(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return ge.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let r=e.$ref;if(t.refs.has(r))return t.refs.get(r);if(t.processing.has(r))return ge.lazy(()=>{if(!t.refs.has(r))throw new Error(`Circular reference not resolved: ${r}`);return t.refs.get(r)});t.processing.add(r);let o=Die(r,t),s=jn(o,t);return t.refs.set(r,s),t.processing.delete(r),s}if(e.enum!==void 0){let r=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&r.length===1&&r[0]===null)return ge.null();if(r.length===0)return ge.never();if(r.length===1)return ge.literal(r[0]);if(r.every(s=>typeof s=="string"))return ge.enum(r);let o=r.map(s=>ge.literal(s));return o.length<2?o[0]:ge.union([o[0],o[1],...o.slice(2)])}if(e.const!==void 0)return ge.literal(e.const);let n=e.type;if(Array.isArray(n)){let r=n.map(o=>{let s={...e,type:o};return hW(s,t)});return r.length===0?ge.never():r.length===1?r[0]:ge.union(r)}if(!n)return ge.any();let i;switch(n){case"string":{let r=ge.string();if(e.format){let o=e.format;o==="email"?r=r.check(ge.email()):o==="uri"||o==="uri-reference"?r=r.check(ge.url()):o==="uuid"||o==="guid"?r=r.check(ge.uuid()):o==="date-time"?r=r.check(ge.iso.datetime()):o==="date"?r=r.check(ge.iso.date()):o==="time"?r=r.check(ge.iso.time()):o==="duration"?r=r.check(ge.iso.duration()):o==="ipv4"?r=r.check(ge.ipv4()):o==="ipv6"?r=r.check(ge.ipv6()):o==="mac"?r=r.check(ge.mac()):o==="cidr"?r=r.check(ge.cidrv4()):o==="cidr-v6"?r=r.check(ge.cidrv6()):o==="base64"?r=r.check(ge.base64()):o==="base64url"?r=r.check(ge.base64url()):o==="e164"?r=r.check(ge.e164()):o==="jwt"?r=r.check(ge.jwt()):o==="emoji"?r=r.check(ge.emoji()):o==="nanoid"?r=r.check(ge.nanoid()):o==="cuid"?r=r.check(ge.cuid()):o==="cuid2"?r=r.check(ge.cuid2()):o==="ulid"?r=r.check(ge.ulid()):o==="xid"?r=r.check(ge.xid()):o==="ksuid"&&(r=r.check(ge.ksuid()))}typeof e.minLength=="number"&&(r=r.min(e.minLength)),typeof e.maxLength=="number"&&(r=r.max(e.maxLength)),e.pattern&&(r=r.regex(new RegExp(e.pattern))),i=r;break}case"number":case"integer":{let r=n==="integer"?ge.number().int():ge.number();typeof e.minimum=="number"&&(r=r.min(e.minimum)),typeof e.maximum=="number"&&(r=r.max(e.maximum)),typeof e.exclusiveMinimum=="number"?r=r.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(r=r.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?r=r.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(r=r.lt(e.maximum)),typeof e.multipleOf=="number"&&(r=r.multipleOf(e.multipleOf)),i=r;break}case"boolean":{i=ge.boolean();break}case"null":{i=ge.null();break}case"object":{let r={},o=e.properties||{},s=new Set(e.required||[]);for(let[l,c]of Object.entries(o)){let u=jn(c,t);r[l]=s.has(l)?u:u.optional()}if(e.propertyNames){let l=jn(e.propertyNames,t),c=e.additionalProperties&&typeof e.additionalProperties=="object"?jn(e.additionalProperties,t):ge.any();if(Object.keys(r).length===0){i=ge.record(l,c);break}let u=ge.object(r).passthrough(),d=ge.looseRecord(l,c);i=ge.intersection(u,d);break}if(e.patternProperties){let l=e.patternProperties,c=Object.keys(l),u=[];for(let p of c){let f=jn(l[p],t),g=ge.string().regex(new RegExp(p));u.push(ge.looseRecord(g,f))}let d=[];if(Object.keys(r).length>0&&d.push(ge.object(r).passthrough()),d.push(...u),d.length===0)i=ge.object({}).passthrough();else if(d.length===1)i=d[0];else{let p=ge.intersection(d[0],d[1]);for(let f=2;f<d.length;f++)p=ge.intersection(p,d[f]);i=p}break}let a=ge.object(r);e.additionalProperties===!1?i=a.strict():typeof e.additionalProperties=="object"?i=a.catchall(jn(e.additionalProperties,t)):i=a.passthrough();break}case"array":{let r=e.prefixItems,o=e.items;if(r&&Array.isArray(r)){let s=r.map(l=>jn(l,t)),a=o&&typeof o=="object"&&!Array.isArray(o)?jn(o,t):void 0;a?i=ge.tuple(s).rest(a):i=ge.tuple(s),typeof e.minItems=="number"&&(i=i.check(ge.minLength(e.minItems))),typeof e.maxItems=="number"&&(i=i.check(ge.maxLength(e.maxItems)))}else if(Array.isArray(o)){let s=o.map(l=>jn(l,t)),a=e.additionalItems&&typeof e.additionalItems=="object"?jn(e.additionalItems,t):void 0;a?i=ge.tuple(s).rest(a):i=ge.tuple(s),typeof e.minItems=="number"&&(i=i.check(ge.minLength(e.minItems))),typeof e.maxItems=="number"&&(i=i.check(ge.maxLength(e.maxItems)))}else if(o!==void 0){let s=jn(o,t),a=ge.array(s);typeof e.minItems=="number"&&(a=a.min(e.minItems)),typeof e.maxItems=="number"&&(a=a.max(e.maxItems)),i=a}else i=ge.array(ge.any());break}default:throw new Error(`Unsupported type: ${n}`)}return e.description&&(i=i.describe(e.description)),e.default!==void 0&&(i=i.default(e.default)),i}function jn(e,t){if(typeof e=="boolean")return e?ge.any():ge.never();let n=hW(e,t),i=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let a=e.anyOf.map(c=>jn(c,t)),l=ge.union(a);n=i?ge.intersection(n,l):l}if(e.oneOf&&Array.isArray(e.oneOf)){let a=e.oneOf.map(c=>jn(c,t)),l=ge.xor(a);n=i?ge.intersection(n,l):l}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)n=i?n:ge.any();else{let a=i?n:jn(e.allOf[0],t),l=i?0:1;for(let c=l;c<e.allOf.length;c++)a=ge.intersection(a,jn(e.allOf[c],t));n=a}e.nullable===!0&&t.version==="openapi-3.0"&&(n=ge.nullable(n)),e.readOnly===!0&&(n=ge.readonly(n));let r={},o=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let a of o)a in e&&(r[a]=e[a]);let s=["contentEncoding","contentMediaType","contentSchema"];for(let a of s)a in e&&(r[a]=e[a]);for(let a of Object.keys(e))Iie.has(a)||(r[a]=e[a]);return Object.keys(r).length>0&&t.registry.add(n,r),n}function yW(e,t){if(typeof e=="boolean")return e?ge.any():ge.never();let n=Tie(e,t?.defaultTarget),i=e.$defs||e.definitions||{},r={version:n,defs:i,refs:new Map,processing:new Set,rootSchema:e,registry:t?.registry??kn};return jn(e,r)}var ge,Iie,bW=v(()=>{Xp();cb();rf();sf();ge={...of,...ab,iso:cu},Iie=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"])});var uO={};_e(uO,{bigint:()=>Mie,boolean:()=>Lie,date:()=>Fie,number:()=>jie,string:()=>Nie});function Nie(e){return IE(uu,e)}function jie(e){return BE(pu,e)}function Lie(e){return qE(fu,e)}function Mie(e){return JE(mu,e)}function Fie(e){return sA(pf,e)}var wW=v(()=>{fr();sf()});var m={};_e(m,{$brand:()=>Xh,$input:()=>CE,$output:()=>OE,NEVER:()=>nR,TimePrecision:()=>DE,ZodAny:()=>SP,ZodArray:()=>OP,ZodBase64:()=>Pb,ZodBase64URL:()=>Ob,ZodBigInt:()=>mu,ZodBigIntFormat:()=>Ib,ZodBoolean:()=>fu,ZodCIDRv4:()=>Eb,ZodCIDRv6:()=>Ab,ZodCUID:()=>wb,ZodCUID2:()=>vb,ZodCatch:()=>YP,ZodCodec:()=>Bb,ZodCustom:()=>yf,ZodCustomStringFormat:()=>du,ZodDate:()=>pf,ZodDefault:()=>HP,ZodDiscriminatedUnion:()=>_P,ZodE164:()=>Cb,ZodEmail:()=>hb,ZodEmoji:()=>yb,ZodEnum:()=>lu,ZodError:()=>Aie,ZodExactOptional:()=>WP,ZodFile:()=>BP,ZodFirstPartyTypeKind:()=>lO,ZodFunction:()=>sO,ZodGUID:()=>af,ZodIPv4:()=>Rb,ZodIPv6:()=>Sb,ZodISODate:()=>ub,ZodISODateTime:()=>lb,ZodISODuration:()=>pb,ZodISOTime:()=>db,ZodIntersection:()=>IP,ZodIssueCode:()=>Oie,ZodJWT:()=>_b,ZodKSUID:()=>$b,ZodLazy:()=>rO,ZodLiteral:()=>FP,ZodMAC:()=>bP,ZodMap:()=>LP,ZodNaN:()=>QP,ZodNanoID:()=>bb,ZodNever:()=>AP,ZodNonOptional:()=>Mb,ZodNull:()=>$P,ZodNullable:()=>UP,ZodNumber:()=>pu,ZodNumberFormat:()=>hc,ZodObject:()=>mf,ZodOptional:()=>Lb,ZodPipe:()=>Fb,ZodPrefault:()=>qP,ZodPromise:()=>oO,ZodReadonly:()=>eO,ZodRealError:()=>mr,ZodRecord:()=>hf,ZodSet:()=>MP,ZodString:()=>uu,ZodStringFormat:()=>kt,ZodSuccess:()=>ZP,ZodSymbol:()=>kP,ZodTemplateLiteral:()=>nO,ZodTransform:()=>GP,ZodTuple:()=>DP,ZodType:()=>Ge,ZodULID:()=>kb,ZodURL:()=>df,ZodUUID:()=>Xi,ZodUndefined:()=>xP,ZodUnion:()=>gf,ZodUnknown:()=>EP,ZodVoid:()=>PP,ZodXID:()=>xb,ZodXor:()=>CP,_ZodString:()=>gb,_default:()=>VP,_function:()=>sW,any:()=>MG,array:()=>ff,base64:()=>kG,base64url:()=>xG,bigint:()=>TG,boolean:()=>vP,catch:()=>XP,check:()=>aW,cidrv4:()=>wG,cidrv6:()=>vG,clone:()=>Jn,codec:()=>rW,coerce:()=>uO,config:()=>Ht,core:()=>Zo,cuid:()=>dG,cuid2:()=>pG,custom:()=>cW,date:()=>BG,decode:()=>uP,decodeAsync:()=>pP,describe:()=>lW,discriminatedUnion:()=>VG,e164:()=>$G,email:()=>tG,emoji:()=>lG,encode:()=>lP,encodeAsync:()=>dP,endsWith:()=>Ql,enum:()=>Nb,exactOptional:()=>zP,file:()=>QG,flattenError:()=>Wp,float32:()=>OG,float64:()=>CG,formatError:()=>zp,fromJSONSchema:()=>yW,function:()=>sW,getErrorMap:()=>_ie,globalRegistry:()=>kn,gt:()=>Zi,gte:()=>Zn,guid:()=>nG,hash:()=>PG,hex:()=>AG,hostname:()=>EG,httpUrl:()=>cG,includes:()=>Yl,instanceof:()=>dW,int:()=>mb,int32:()=>_G,int64:()=>DG,intersection:()=>TP,ipv4:()=>hG,ipv6:()=>bG,iso:()=>cu,json:()=>fW,jwt:()=>RG,keyof:()=>GG,ksuid:()=>gG,lazy:()=>iO,length:()=>mc,literal:()=>XG,locales:()=>Yp,looseObject:()=>UG,looseRecord:()=>KG,lowercase:()=>Jl,lt:()=>Ji,lte:()=>Ir,mac:()=>yG,map:()=>JG,maxLength:()=>fc,maxSize:()=>Hs,meta:()=>uW,mime:()=>eu,minLength:()=>Jo,minSize:()=>Yi,multipleOf:()=>Us,nan:()=>nW,nanoid:()=>uG,nativeEnum:()=>YG,negative:()=>Xy,never:()=>Tb,nonnegative:()=>eb,nonoptional:()=>JP,nonpositive:()=>Qy,normalize:()=>tu,null:()=>RP,nullable:()=>lf,nullish:()=>eW,number:()=>wP,object:()=>WG,optional:()=>cf,overwrite:()=>$i,parse:()=>oP,parseAsync:()=>sP,partialRecord:()=>qG,pipe:()=>uf,positive:()=>Yy,prefault:()=>KP,preprocess:()=>mW,prettifyError:()=>mR,promise:()=>oW,property:()=>tb,readonly:()=>tO,record:()=>jP,refine:()=>aO,regex:()=>Kl,regexes:()=>qr,registry:()=>Cy,safeDecode:()=>mP,safeDecodeAsync:()=>hP,safeEncode:()=>fP,safeEncodeAsync:()=>gP,safeParse:()=>aP,safeParseAsync:()=>cP,set:()=>ZG,setErrorMap:()=>Cie,size:()=>pc,slugify:()=>ou,startsWith:()=>Xl,strictObject:()=>zG,string:()=>fb,stringFormat:()=>SG,stringbool:()=>pW,success:()=>tW,superRefine:()=>cO,symbol:()=>jG,templateLiteral:()=>iW,toJSONSchema:()=>ob,toLowerCase:()=>ru,toUpperCase:()=>iu,transform:()=>jb,treeifyError:()=>fR,trim:()=>nu,tuple:()=>NP,uint32:()=>IG,uint64:()=>NG,ulid:()=>fG,undefined:()=>LG,union:()=>Db,unknown:()=>gc,uppercase:()=>Zl,url:()=>aG,util:()=>le,uuid:()=>rG,uuidv4:()=>iG,uuidv6:()=>oG,uuidv7:()=>sG,void:()=>FG,xid:()=>mG,xor:()=>HG});var dO=v(()=>{fr();sf();cb();iP();yP();gW();fr();SE();fr();nf();bW();PE();rf();rf();wW();Ht(Ey())});var Ln=v(()=>{dO();dO()});function pO(e){let t=0;for(let n=0;n<e.length;n++)t=Math.imul(t,31)+e.charCodeAt(n)|0;return Math.abs(t).toString(16).padStart(8,"0")}function Gb(e){return e.replace(/[^a-zA-Z0-9.-]/g,"-")}function vW(e,t){let n=o=>`SPDXRef-Package-${t}${Gb(o)}`,i=e.map(o=>({name:o.name,SPDXID:n(o.name),versionInfo:o.version??"NOASSERTION",downloadLocation:o.downloadLocation??"NOASSERTION",filesAnalyzed:!1,licenseConcluded:"NOASSERTION",licenseDeclared:"NOASSERTION",copyrightText:"NOASSERTION",...o.purl?{externalRefs:[{referenceCategory:"PACKAGE-MANAGER",referenceType:"purl",referenceLocator:o.purl}]}:{}})),r=e.flatMap(o=>(o.dependsOn??[]).map(s=>({spdxElementId:n(o.name),relationshipType:"DEPENDS_ON",relatedSpdxElement:n(s)})));return{packages:i,relationships:r}}function Bie(e,t=()=>new Date){let n="SPDXRef-DOCUMENT",i=`SPDXRef-Package-${Gb(e.subjectName)}`,{packages:r,relationships:o}=vW(e.packages,""),s=[{spdxElementId:n,relationshipType:"DESCRIBES",relatedSpdxElement:i},...o],a=[];(e.subDocuments??[]).forEach((c,u)=>{let d=`SPDXRef-Package-sub${u}-${Gb(c.subjectName)}`;a.push({name:c.subjectName,SPDXID:d,versionInfo:c.subjectVersion??"NOASSERTION",downloadLocation:"NOASSERTION",filesAnalyzed:!1,licenseConcluded:"NOASSERTION",licenseDeclared:"NOASSERTION",copyrightText:"NOASSERTION",comment:`subjectId: ${c.subjectId}`}),s.push({spdxElementId:i,relationshipType:"CONTAINS",relatedSpdxElement:d});let{packages:p,relationships:f}=vW(c.packages,`sub${u}-`);a.push(...p),s.push(...p.map(g=>({spdxElementId:d,relationshipType:"CONTAINS",relatedSpdxElement:g.SPDXID})),...f)});let l={spdxVersion:"SPDX-2.3",dataLicense:"CC0-1.0",SPDXID:n,name:e.subjectName,documentNamespace:`https://chant.dev/spdxdocs/${Gb(e.subjectName)}-${pO(e.subjectId)}`,creationInfo:{created:t().toISOString(),creators:[`Tool: ${e.generator}`]},packages:[{name:e.subjectName,SPDXID:i,versionInfo:e.subjectVersion??"NOASSERTION",downloadLocation:"NOASSERTION",filesAnalyzed:!1,licenseConcluded:"NOASSERTION",licenseDeclared:"NOASSERTION",copyrightText:"NOASSERTION"},...r,...a],relationships:s};return JSON.stringify(l,null,2)}function kW(e,t){return e.map(n=>({type:n.type==="config"?"application":"library","bom-ref":`${t}${n.name}`,name:n.name,...n.version?{version:n.version}:{},...n.purl?{purl:n.purl}:{}}))}function xW(e,t){return e.filter(n=>(n.dependsOn?.length??0)>0).map(n=>({ref:`${t}${n.name}`,dependsOn:n.dependsOn.map(i=>`${t}${i}`)}))}function Gie(e,t=()=>new Date){let n=`subject:${e.subjectName}`,i=kW(e.packages,""),r=e.subDocuments??[],o=r.map((d,p)=>{let f=`sub${p}:`;return{type:"application","bom-ref":`${f}subject:${d.subjectName}`,name:d.subjectName,...d.subjectVersion?{version:d.subjectVersion}:{},properties:[{name:"chant:subjectId",value:d.subjectId}],components:kW(d.packages,f)}}),s=r.flatMap((d,p)=>{let f=`sub${p}:`;return[{ref:`${f}subject:${d.subjectName}`,dependsOn:d.packages.map(h=>`${f}${h.name}`)},...xW(d.packages,f)]}),a=[...e.packages.map(d=>d.name),...o.map(d=>d["bom-ref"])],l=[{ref:n,dependsOn:a},...xW(e.packages,""),...s],c=r.length>0?[{aggregate:"incomplete",assemblies:[n,...o.map(d=>d["bom-ref"])]}]:void 0,u={bomFormat:"CycloneDX",specVersion:"1.5",serialNumber:`urn:uuid:${Wie(pO(e.subjectId)+pO(e.subjectName))}`,version:1,metadata:{timestamp:t().toISOString(),tools:[{name:e.generator}],component:{type:"application","bom-ref":n,name:e.subjectName,...e.subjectVersion?{version:e.subjectVersion}:{},...o.length>0?{components:o}:{}}},components:i,dependencies:l,...c?{compositions:c}:{}};return JSON.stringify(u,null,2)}function Wie(e){let t=(e+e+e+e).slice(0,32);return`${t.slice(0,8)}-${t.slice(8,12)}-4${t.slice(13,16)}-8${t.slice(17,20)}-${t.slice(20,32)}`}function fO(e,t,n){let i=e==="spdx"?Bie(t,n):Gie(t,n);return{format:e,mediaType:Qi[e],bytes:i}}var Wb=v(()=>{"use strict";Yo()});import{readFileSync as RW,writeFileSync as zie,mkdirSync as Uie}from"node:fs";import{dirname as $W,join as SW}from"node:path";function Hie(e){let t=JSON.parse(e),n=new Map,i=(r,o,s)=>{if(!r)return;let a=`${r}@${o??""}`,l=n.get(a);if(l){s?.length&&(l.dependsOn=[...new Set([...l.dependsOn??[],...s])]);return}n.set(a,{name:r,version:o,type:"npm",purl:o?`pkg:npm/${encodeURIComponent(r)}@${o}`:void 0,dependsOn:s?.length?s:void 0})};if(t.packages)for(let[r,o]of Object.entries(t.packages)){if(r==="")continue;let s=o.name??r.replace(/^.*node_modules\//,"");i(s,o.version,o.dependencies?Object.keys(o.dependencies):void 0)}else if(t.dependencies)for(let[r,o]of Object.entries(t.dependencies))i(r,o.version,o.requires?Object.keys(o.requires):void 0);return[...n.values()].sort((r,o)=>r.name.localeCompare(o.name))}function Vie(e){let t=[],i=e.replace(/<dependencyManagement>[\s\S]*?<\/dependencyManagement>/,"").match(/<dependencies>([\s\S]*?)<\/dependencies>/);if(!i)return t;let r=i[1],o=/<dependency>([\s\S]*?)<\/dependency>/g,s;for(;(s=o.exec(r))!==null;){let a=s[1],l=a.match(/<groupId>([^<]+)<\/groupId>/)?.[1]?.trim(),c=a.match(/<artifactId>([^<]+)<\/artifactId>/)?.[1]?.trim(),u=a.match(/<version>([^<]+)<\/version>/)?.[1]?.trim();if(!l||!c)continue;let d=`${l}:${c}`;t.push({name:d,version:u,type:"maven",purl:u?`pkg:maven/${encodeURIComponent(l)}/${encodeURIComponent(c)}@${u}`:void 0})}return t.sort((a,l)=>a.name.localeCompare(l.name))}function qie(e){for(let[t,n]of[["npm","package-lock.json"],["maven","pom.xml"]]){let i=SW(e,n);try{return RW(i,"utf-8"),{kind:t,path:i}}catch{continue}}}function Kie(e,t){return SW(e,`sbom.${t}.json`)}function Jie(e={}){let t=e.now??(()=>new Date);function n(i,r,o,s=Kr){let a=qie(i);if(!a)throw new Error(`no supported lockfile/manifest found under "${i}" (looked for package-lock.json, pom.xml) \u2014 the hermetic lockfile SBOM backend requires a lockfile on disk; use the deep-scan path (#610) for images with no lockfile`);let l=RW(a.path,"utf-8"),c=a.kind==="npm"?Hie(l):Vie(l),u=a.kind==="npm"?"chant-lockfile-sbom/package-lock.json":"chant-lockfile-sbom/pom.xml",d=fO(s,{subjectName:r,subjectId:o??a.path,packages:c,generator:u},t),p=e.outDir??i;return Uie(p,{recursive:!0}),zie(Kie(p,s),d.bytes),{...d,packageCount:c.length,generator:u}}return{async forImage(i){throw new zb("forImage")},async forJar(i){return n($W(i.jarPath),i.jarPath,i.digest,i.format)},async forZip(i){return n($W(i.zipPath),i.zipPath,i.digest,i.format)},async forDir(i){return n(i.path,i.path,void 0,i.format)}}}var EW,mO=v(()=>{"use strict";Wb();Yo();Yo();EW=Jie()});function AW(){return gO||(gO=EW),gO}var Qi,Kr,zb,gO,Yo=v(()=>{"use strict";mO();Qi={spdx:"application/spdx+json",cyclonedx:"application/vnd.cyclonedx+json"},Kr="spdx",zb=class extends Error{constructor(n){super(`SbomGenerator.${n} has no real implementation configured \u2014 inject a real generator (shelling out to syft/buildx/cyclonedx-maven/cdxgen) or use a mock in tests`);this.method=n;this.name="SbomGeneratorNotImplementedError"}}});import{existsSync as yc}from"fs";import{dirname as bf,join as gu,resolve as PW}from"path";function wf(e){let t=PW(e),n=t;for(;;){let i=gu(n,"chant.config.ts");if(yc(i))return{dir:n,configPath:i};let r=gu(n,"chant.config.json");if(yc(r))return{dir:n,configPath:r};if(yc(gu(n,".git"))||yc(gu(n,"package.json")))return{dir:n};let o=bf(n);if(o===n)return{dir:t};n=o}}function gr(e){let t=PW(e),n;for(let i=t;;i=bf(i)){if(yc(gu(i,".git"))){n=i;break}if(bf(i)===i)break}for(let i=t;;i=bf(i)){let[r,o]=Zie.map(l=>gu(i,l)),s=yc(r),a=yc(o);if(s&&a)return{dir:i,file:r,conflicting:o};if(s)return{dir:i,file:r};if(a)return{dir:i,file:o};if(n===void 0||i===n||bf(i)===i)return}}var Zie,Ri=v(()=>{"use strict";Zie=["chant.workspace.json","chant.workspace.jsonc"]});import*as Yie from"node:module";import{dirname as Xie,join as KLe,sep as Ub}from"node:path";import{fileURLToPath as Qie,pathToFileURL as ZLe}from"node:url";function noe(){return globalThis[toe]}function Mn(){let e=noe();if(!e)return!1;if(e.tsx)return!0;e.tsx=!0;let t=eoe(import.meta.url);return t("tsx/cjs/api").register(),t("tsx/esm/api").register(),!0}function OW(e){let t=Xie(Qie(e));if(!e.endsWith(".js"))return t;let n=`${Ub}dist${Ub}`,i=(t+Ub).lastIndexOf(n);return i<0?t:t.slice(0,i)+`${Ub}src`+t.slice(i+n.length-1)}var eoe,YLe,toe,Si=v(()=>{"use strict";({createRequire:eoe,registerHooks:YLe}=Yie),toe=Symbol.for("chant.compiledCli")});async function CW(e){return Mn(),await import(e)}var _W=v(()=>{"use strict";Si()});var IW=ie((tMe,hO)=>{if(typeof hO=="object")throw new Error("esbuild is not part of chant's wave-job runtime (wave-runtime.mjs): this path needs the full @intentius/chant CLI");hO.exports={}});import{existsSync as yO,mkdtempSync as roe,readFileSync as ioe,realpathSync as NW,rmSync as ooe,statSync as jW,writeFileSync as soe}from"node:fs";import{createRequire as aoe}from"node:module";import{tmpdir as coe}from"node:os";import{dirname as LW,join as vf,resolve as loe}from"node:path";function poe(){let e=globalThis;return e.__chantExternalPackagePathCache??=new Map}function foe(e,t){let n=t;for(;;){let i=vf(n,"node_modules",e);if(yO(i)){let o=vf(i,"package.json");if(!yO(o))return;let s;try{s=JSON.parse(ioe(o,"utf-8"))}catch{return}if(typeof s!="object"||s===null||s.exports!==void 0)return;let a=s.main,c=loe(i,typeof a=="string"?a:"index.js");if(!yO(c)||!jW(c).isFile())return;try{return NW(c)}catch{return}}let r=LW(n);if(r===n)return;n=r}}function moe(){let e=[],t=new Map,n=poe();for(let r of doe)try{let o=n.get(r);if(o===void 0&&!n.has(r)&&(o=foe(r,TW)??uoe.resolve(r,{paths:[TW]}),n.set(r,o)),o===void 0)continue;t.set(r,o),e.push(LW(o))}catch{n.set(r,void 0)}return{plugin:{name:"chant-sandbox-external-trusted-packages",setup(r){for(let[o,s]of t){let a=new RegExp(`^${o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}$`);r.onResolve({filter:a},()=>({path:s,external:!0}))}}},readPaths:e}}async function Hb(e){let t=NW(roe(vf(coe(),"chant-sandbox-"))),n=vf(t,"driver.mts");soe(n,e,"utf-8");let i=vf(t,"child.mjs"),{plugin:r,readPaths:o}=moe(),s=performance.now();try{await DW.build({entryPoints:[n],outfile:i,bundle:!0,platform:"node",format:"esm",absWorkingDir:t,logLevel:"silent",plugins:[r]})}catch(c){throw ooe(t,{recursive:!0,force:!0}),c}let a=performance.now()-s,l=jW(i).size;return{bundlePath:i,bundleDir:t,externalReadPaths:o,durationMs:a,bytes:l}}var DW,TW,uoe,doe,bO=v(()=>{"use strict";DW=Le(IW(),1),TW=import.meta.dirname,uoe=aoe(import.meta.url),doe=["typescript","@cdktn/hcl2json"]});function wO(e){for(let t of Object.keys(kf))delete kf[t];Object.assign(kf,e)}var kf,Vb=v(()=>{"use strict";kf={}});import{dirname as vO,join as eo}from"node:path";function un(e){return JSON.stringify(e)}function FW(e=[]){return["function send(payload) {",...e.map(t=>` ${t}`),' if (typeof process.send !== "function") {'," console.log(JSON.stringify(payload));"," return Promise.resolve();"," }"," return new Promise((resolve) => {"," const lost = (err) => {",' writeSync(2, "chant: the sandboxed child could not hand its result to the parent: " +',' (err && err.message ? err.message : String(err)) + " (chant#2461)\\n");'," process.exit(1);"," };"," try {"," process.send(payload, (err) => (err ? lost(err) : resolve()));"," } catch (err) {"," lost(err);"," }"," });","}"]}function BW(e){let{files:t,buildRoot:n}=e,i=[`import { collectEntities } from ${un(goe)};`,`import { resolveAttrRefs } from ${un(hoe)};`,`import { encodeEntitySet } from ${un(yoe)};`,`import { classifyChildError } from ${un(MW)};`,`import { getProvenance } from ${un(boe)};`,`import { setBuildParams } from ${un(voe)};`,'import { writeSync } from "node:fs";',"",`const BUILD_ROOT = ${un(n)};`,"",`setBuildParams(${un({...kf})});`,"","let importing;","let reported = false;",'process.on("exit", () => {'," if (reported || importing === undefined) return;",` writeSync(2, "chant: this file's module scope never finished evaluating, so the build could not " +`,' "report anything: " + importing + "\\n A top-level `await` that never settles does this. " +',' "Nothing is thrown, so nothing else can name it (chant#2461).\\n");',"});","",...FW(["reported = true;"]),"","function errFile(err) {",' return err && typeof err === "object" && typeof err.file === "string" ? err.file : "";',"}","","async function main() {"," const modules = [];"," const errors = [];"];for(let r of t)i.push(` importing = ${un(r)};`," try {",` const mod = await import(${un(r)});`,` modules.push({ file: ${un(r)}, exports: mod });`," } catch (err) {",` errors.push(classifyChildError(${un(r)}, err).toJSON());`," }"," importing = undefined;");return i.push(""," let entities = new Map();"," try {"," entities = collectEntities(modules, BUILD_ROOT);"," } catch (err) {",' errors.push(classifyChildError(errFile(err), err, "resolution").toJSON());'," await send({ entitySet: { entities: [] }, errors, provenanceByName: {} });"," return;"," }",""," const provenanceByName = {};"," for (const [name, entity] of entities) {"," const prov = getProvenance(entity);"," if (prov?.sourceFile) provenanceByName[name] = prov.sourceFile;"," }",""," try {"," resolveAttrRefs(entities);"," } catch (err) {",' errors.push(classifyChildError("", err, "resolution").toJSON());'," }",""," let entitySet;"," try {"," entitySet = encodeEntitySet(entities);"," } catch (err) {",' errors.push(classifyChildError("", err, "resolution").toJSON());'," await send({ entitySet: { entities: [] }, errors, provenanceByName });"," return;"," }"," await send({ entitySet, errors, provenanceByName });","}","","main().catch((err) =>",' send({ entitySet: { entities: [] }, errors: [classifyChildError("", err).toJSON()], provenanceByName: {}, fatal: true }),',");"),i.join(`
47
+ `)}function GW(e){return[`import { classifyChildError } from ${un(MW)};`,`import { scanConfigWireSafety } from ${un(woe)};`,'import { writeSync } from "node:fs";',"",...FW(),"","async function main() {"," let namespace;"," try {",` namespace = await import(${un(e)});`," } catch (err) {",` await send({ kind: "chant-config", ok: false, error: classifyChildError(${un(e)}, err).toJSON() });`," return;"," }",""," const selected = namespace.default ?? namespace.config ?? namespace;",""," const offenders = scanConfigWireSafety(selected);"," if (offenders.length > 0) {",' await send({ kind: "chant-config", ok: false, offenders });'," return;"," }",""," let config;"," try {"," config = JSON.parse(JSON.stringify(selected ?? {}));"," } catch (err) {",` await send({ kind: "chant-config", ok: false, error: classifyChildError(${un(e)}, err, "resolution").toJSON() });`," return;"," }",' await send({ kind: "chant-config", ok: true, config });',"}","","main().catch((err) =>",` send({ kind: "chant-config", ok: false, error: classifyChildError(${un(e)}, err).toJSON() }),`,");"].join(`
48
+ `)}var qb,hu,goe,hoe,yoe,MW,boe,woe,dMe,pMe,voe,kO=v(()=>{"use strict";Vb();Si();qb=OW(import.meta.url),hu=eo(qb,".."),goe=eo(hu,"collect.ts"),hoe=eo(hu,"resolve.ts"),yoe=eo(hu,"entity-wire-codec.ts"),MW=eo(qb,"child-errors.ts"),boe=eo(vO(hu),"provenance.ts"),woe=eo(qb,"config-wire.ts"),dMe=eo(qb,"policy-wire.ts"),pMe=eo(vO(hu),"lint","post-synth.ts"),voe=eo(vO(hu),"params.ts")});function WW(e,t){let n=t.map(i=>` ${i.path||"<root>"}: ${i.found}`);return[`Cannot evaluate ${e} inside the --sandbox boundary: it holds values that are not data.`,...n,"Under --sandbox the config is evaluated in an isolated child process and only JSON crosses back, so every value must be a string, number, boolean, null, array or plain object. Move the offending value out of chant.config.ts (lint rule plugins and policy checks are referenced by path, not embedded), or drop --sandbox for this build."].join(`
49
+ `)}var zW=v(()=>{"use strict"});import{fork as koe}from"node:child_process";function UW(e){let t="";return{push(n){t+=n.toString();let i=t.indexOf(`
50
+ `);for(;i!==-1;)e(t.slice(0,i)),t=t.slice(i+1),i=t.indexOf(`
51
+ `)},flush(){t.length>0&&(e(t),t="")}}}function xoe(e,t,n,i,r){let o=i.trim(),s=`${e}: child exited before reporting results (code ${t}, signal ${n})`;if(r.length>0){let a=r.map(l=>l&&typeof l=="object"?`{${Object.keys(l).join(", ")}}`:typeof l).join(", ");return`${s}. It sent ${r.length} message(s) the parent did not recognise (${a}), so the payload shape and the parent's check disagree`+(o?`: ${o}`:"")}return o?`${s}: ${o}`:t!==0||n!==null?s:`${s}. It exited cleanly with nothing on stderr, and no message arrived even after its IPC channel closed, so it never sent one: something it awaited never settled. On the run path the usual cause is a project file with a top-level \`await\` that does not settle. Module scope is arbitrary project source, an import of such a file never completes, and a promise that never settles is not a rejection, so the driver's own \`main().catch\` does not see it either. The config driver has nothing to await that can hang, and a failed send exits non-zero with a reason on stderr, so on the config path this has no known cause: please report it with the command that produced it (chant#2461).`}function Roe(e,t,n=$oe){e.on("exit",(i,r)=>{let o=!1,s,a=()=>{o||(o=!0,s!==void 0&&clearTimeout(s),t(i,r))};if(!e.connected){a();return}e.once("disconnect",a),s=setTimeout(a,n)})}function Kb(e,t){let{bundlePath:n,bundleDir:i,projectRealpath:r,externalReadPaths:o,env:s,timeoutMs:a,label:l,send:c,outputPrefix:u}=e;return new Promise((d,p)=>{let f=[i,r,...o].map(_=>`--allow-fs-read=${_}`),g=koe(n,[],{execArgv:["--permission",...f],env:s,stdio:["ignore","pipe","pipe","ipc"]}),h=!1,b="",w=[],x=setTimeout(()=>{h||(h=!0,g.kill(),p(new Error(`${l} timed out after ${a}ms`)))},a);c!==void 0&&g.send(c,_=>{h||!_||(h=!0,clearTimeout(x),g.kill(),p(new Error(`${l}: failed to send the child its input: ${_.message}`)))});let k=_=>{process.stderr.write(`${u} ${_}
52
+ `)},R=UW(k),$=UW(k);g.stdout?.on("data",_=>{R.push(_)}),g.stdout?.on("end",()=>R.flush()),g.stderr?.on("data",_=>{b+=_.toString(),$.push(_)}),g.stderr?.on("end",()=>$.flush()),g.on("message",_=>{if(!h){if(!t(_)){w.push(_);return}h=!0,clearTimeout(x),g.kill(),d(_)}}),g.on("error",_=>{h||(h=!0,clearTimeout(x),p(_))}),Roe(g,(_,T)=>{h||(h=!0,clearTimeout(x),p(new Error(xoe(l,_,T,b,w))))})})}var $oe,xO=v(()=>{"use strict";$oe=2e3});var VW={};_e(VW,{evaluateConfigSandboxed:()=>Ooe});import{realpathSync as Soe,rmSync as Eoe}from"node:fs";import{resolve as HW}from"node:path";function Poe(e){return typeof e=="object"&&e!==null&&e.kind==="chant-config"&&typeof e.ok=="boolean"}async function Ooe(e,t){let n=GW(e),{bundlePath:i,bundleDir:r,externalReadPaths:o,durationMs:s,bytes:a}=await Hb(n);try{let l;try{l=Soe(HW(t))}catch{l=HW(t)}let c={PATH:process.env.PATH??""},u=process.env[yu];u&&(c[yu]=u);let d=await Kb({bundlePath:i,bundleDir:r,projectRealpath:l,externalReadPaths:o,env:c,timeoutMs:Aoe,label:`sandboxed evaluation of ${e}`,outputPrefix:"[sandbox:config]"},Poe);if(!d.ok)throw d.offenders&&d.offenders.length>0?new Error(WW(e,d.offenders)):new Error(d.error?.message?`Failed to evaluate ${e} inside the --sandbox boundary: ${d.error.message}`:`Failed to evaluate ${e} inside the --sandbox boundary`);return{config:d.config??{},bundleMs:s,bundleBytes:a}}finally{Eoe(r,{recursive:!0,force:!0})}}var Aoe,qW=v(()=>{"use strict";bO();kO();zW();xO();bu();Aoe=6e4});import{dirname as Coe}from"node:path";function Ioe(e){return e.default??e.config??e}async function KW(e,t=Coe(e)){if(!_oe)return Ioe(await CW(e));if($O.has(e))return $O.get(e);let{evaluateConfigSandboxed:n}=await Promise.resolve().then(()=>(qW(),VW)),{config:i}=await n(e,t);return $O.set(e,i),i}var _oe,$O,RO=v(()=>{"use strict";_W();_oe=!1,$O=new Map});var QW={};_e(QW,{importLexiconModule:()=>bc,importLexiconPackage:()=>Zr,lexiconDeclarationName:()=>ZW,lexiconModulePath:()=>Ei,lexiconModuleRoot:()=>EO,lexiconNames:()=>Jr,lexiconPackagesToInstall:()=>Woe,lexiconSourceLabel:()=>Goe,packageNameOf:()=>XW,pathLexiconMap:()=>Moe,pathLexiconRoot:()=>Jb,recordedLexiconModules:()=>Foe,registerLexiconDeclarations:()=>Zs,resetLexiconModules:()=>Boe,resolveFromProject:()=>Zb});import{createRequire as Toe}from"node:module";import{dirname as Doe,isAbsolute as vu,join as Noe,relative as JW,resolve as wu,sep as joe}from"node:path";import{pathToFileURL as Loe}from"node:url";function ZW(e){return typeof e=="string"?e:e.name}function Jr(e){return e?.map(ZW)}function SO(e,t){let n=JW(t,e);return n===""||!n.startsWith("..")&&!vu(n)}function Jb(e,t,n="."){let i=vu(e.module)?e.module:wu(t,e.module),r=e.root!==void 0,o=r?vu(e.root)?wu(e.root):wu(t,e.root):Doe(i),s=wu(t),a=wu(t,n),l;return SO(o,s)?SO(a,o)?l=`${o} contains the project's source directory (${a})`:SO(i,o)||(l=`the module ${i} is not inside ${o}`):l=`${o} is outside the project (${s})`,l===void 0?{root:o}:r?{problem:l}:{}}function Zs(e,t,n){let i={};for(let r of e??[]){if(typeof r=="string"){Js.delete(r),xf.delete(r);continue}let o=YW(r,t);Js.set(r.name,o),i[r.name]=o;let{root:s}=Jb(r,t,n);s===void 0?xf.delete(r.name):xf.set(r.name,s)}return i}function YW(e,t){return vu(e.module)?e.module:wu(t,e.module)}function Moe(e,t){let n=new Map;for(let i of e)typeof i!="string"&&n.set(i.name,YW(i,t));return n}function Foe(){return new Map(Js)}function Ei(e){return Js.get(e)}function EO(e){return xf.get(e)}function Boe(){Js.clear(),xf.clear()}async function bc(e){let t=Js.get(e);if(t!==void 0)try{return Mn(),await import(t)}catch(n){throw new Error(`lexicon "${e}" is declared with module ${t}, which could not be loaded: `+(n instanceof Error?n.message:String(n)))}}function Goe(e,t=process.cwd(),n=Js){let i=n.get(e);if(i===void 0)return`@intentius/chant-lexicon-${e}`;let r=JW(t,i);return r===""||r.startsWith("..")||vu(r)?i:`./${r.split(joe).join("/")}`}function Woe(e,t=Js){return e.filter(n=>!t.has(n)).map(n=>`@intentius/chant-lexicon-${n}`)}function XW(e){if(e.startsWith(".")||vu(e)||e.startsWith("file:"))return;let t=e.split("/");return e.startsWith("@")?t.slice(0,2).join("/"):t[0]}function zoe(e,t){let n=e?.code;if(n!=="ERR_MODULE_NOT_FOUND"&&n!=="MODULE_NOT_FOUND")return!1;let i=e instanceof Error?e.message:String(e);return i.includes(`'${t}'`)||i.includes(`"${t}"`)||i.includes(`${t}/`)}function Zb(e,t=process.cwd()){try{return Toe(Noe(t,"package.json")).resolve(e)}catch{return}}async function Zr(e,t=process.cwd()){try{return Mn(),await import(e)}catch(n){let i=XW(e);if(i===void 0||!zoe(n,i))throw n;let r=Zb(e,t);if(r===void 0)throw n;return await import(Loe(r).href)}}var Js,xf,xn=v(()=>{"use strict";Si();Js=new Map,xf=new Map});var Uoe,Hoe,Voe,ku,ez,Yb=v(()=>{"use strict";Ln();Uoe=m.strictObject({env:m.string().min(1)}),Hoe=m.strictObject({capability:m.string().min(1),member:m.string().min(1).optional(),env:m.string().min(1).optional()}),Voe=m.union([Uoe,Hoe]),ku=m.strictObject({url:m.string().min(1),key:Voe.optional(),timeoutMs:m.number().int().positive().optional()}),ez=m.strictObject({backends:m.record(m.string(),ku).optional()})});var tw={};_e(tw,{ChantConfigSchema:()=>Sf,DEFAULT_CHANT_CONFIG:()=>_O,InvalidChantConfigError:()=>xu,environmentEndpoint:()=>sz,environmentName:()=>wc,environmentNames:()=>OO,findProjectConfigPastFragments:()=>Ef,isEnvironmentPattern:()=>$f,isLintOnlyFragment:()=>Qb,isOwnershipParamRef:()=>cz,loadChantConfig:()=>Ys,loadChantConfigUpward:()=>Xb,matchesDeclaredEnvironment:()=>Rf,matchesEnvironmentPattern:()=>CO,ownershipEnvDisagreement:()=>Zoe,resolveAutoReleaseDisabled:()=>Yoe,resolveDiscoveryGlobs:()=>$u,resolveFoldEnabled:()=>uz,resolveKnowledgeDir:()=>Xoe,resolveOwnershipEnv:()=>IO,resolveOwnershipMarker:()=>lz,resolveOwnershipStack:()=>ew,resolveSandboxEnabled:()=>dz,resolveSbomFormat:()=>pz,resolveSigningDefaults:()=>fz,resolveVulnPolicy:()=>mz});import{existsSync as tz,readFileSync as iz}from"fs";import{dirname as oz,join as AO}from"path";function wc(e){return typeof e=="string"?e:e.name}function OO(e){return e?.map(wc)}function $f(e){return e.includes("*")}function CO(e,t){let n=e.split("*");if(n.length===1)return e===t;let i=n[0],r=n[n.length-1];if(!t.startsWith(i))return!1;let o=i.length;for(let s=1;s<n.length-1;s++){let a=n[s];if(a==="")continue;let l=t.indexOf(a,o);if(l===-1)return!1;o=l+a.length}return t.length-o>=r.length&&t.endsWith(r)}function Rf(e,t){let n=OO(e)??[];return n.includes(t)?!0:n.some(i=>$f(i)&&CO(i,t))}function sz(e,t){let n=e?.find(i=>wc(i)===t)??e?.find(i=>$f(wc(i))&&CO(wc(i),t));return n&&typeof n!="string"?n.endpoint:void 0}async function Ys(e){let t=AO(e,"chant.config.ts");if(tz(t)){let i=await KW(t,e);return{config:rz(i,t),configPath:t}}let n=AO(e,"chant.config.json");if(tz(n)){let{readFileSync:i}=await import("fs"),r=i(n,"utf-8"),o=JSON.parse(r);return{config:rz(o,n),configPath:n}}return{config:_O}}async function Xb(e){let{dir:t,configPath:n}=Ef(e);return n&&Joe(n),Ys(t)}function Ef(e){let{dir:t,configPath:n}=wf(e);for(;n&&Qb(n);){let i=oz(t);if(i===t)break;({dir:t,configPath:n}=wf(i))}return{dir:t,configPath:n}}async function $u(e){let{dir:t,configPath:n}=Ef(e);if(!n)return;let i;try{({config:i}=await Ys(t))}catch(s){if(s instanceof xu&&(s.key==="exclude"||s.key==="include"))throw s;return}let r=i.exclude??[],o=i.include??[];if(!(r.length===0&&o.length===0))return{root:t,exclude:r,include:o}}function Qb(e){if(!e.endsWith("chant.config.json"))return!1;try{let t=JSON.parse(iz(e,"utf-8"));if(typeof t!="object"||t===null||Array.isArray(t))return!1;let n=Object.keys(t).filter(i=>!az(i));return n.length>0&&n.every(i=>PO.has(i))}catch{return!1}}function Joe(e){if(e.endsWith("chant.config.json"))try{let t=JSON.parse(iz(e,"utf-8"));if(typeof t!="object"||t===null||Array.isArray(t))return;let n=Object.keys(t).filter(i=>!az(i));if(n.some(i=>!PO.has(i))&&!n.some(i=>nz.has(i))){let i=n.filter(r=>!PO.has(r));console.error(`warning: ${e} is being used as the project config, but declares no project-level key (${[...nz].slice(0,4).join(", ")}, \u2026). ${i.length===1?"The key":"The keys"} ${i.map(r=>`"${r}"`).join(", ")} stopped the walk to the real one \u2014 any config above this file is being ignored. Prefix a comment key with "_", or move the key to the project config. (chant #1711)`)}}catch{}}function cz(e){return typeof e=="object"&&e!==null&&typeof e.param=="string"}function ew(e){let t=e.ownership;if(!(!t||!t.stack||t.enabled===!1))return t.stack}function IO(e,t){let n=e.ownership?.env;if(!cz(n))return n;let i=n.param,r=e.buildParams?.[i];if(!r)throw new Error(`ownership.env references build parameter "${i}", which chant.config.ts's buildParams does not declare`);let o=t?.find(s=>s.name===i);if(!o)throw new Error(`ownership.env references build parameter "${i}", which resolved to no value for this build \u2014 pass --param ${i}=<value>${r.env?`, set ${r.env}`:""}, or give it a default`);return String(o.value)}function lz(e,t){let n=ew(e);if(n!==void 0)return{stack:n,env:IO(e,t)}}function Zoe(e,t){let n=e.ownership?.env;if(typeof n!="string"||ew(e)===void 0)return;let i=t?.find(r=>r.name==="env");if(!(!i||String(i.value)===n))return`ownership.env is "${n}" but the env build parameter resolved to ${JSON.stringify(i.value)} (${i.source}) \u2014 the ownership marker and params.env disagree about which environment this build is for. Use ownership: { env: { param: "env" } } so the marker follows the parameter.`}function Yoe(e,t){return t?!0:e.release?.autoRecord===!1}function uz(e,t){return t!==void 0?t:e.build?.fold!==void 0?e.build.fold:!0}function dz(e,t){return t?!0:e.build?.sandbox===!0}function pz(e,t){return t??e.sbom?.format??Kr}function fz(e){let t=e.signing,n=t?.keyless!==!1;return{keyless:n,...!n&&t?.key?{key:{key:t.key}}:{},identityPolicyDefaults:{expectedIssuer:t?.oidcIssuer,expectedIdentity:t?.identity,identityIsRegexp:t?.identityIsRegexp,key:t?.keyless===!1?t?.key:void 0}}}function mz(e){let t=e.vulnPolicy;if(!t)return{};let n={};return t.failSeverity&&(n.failSeverity=t.failSeverity),t.fixableOnly!==void 0&&(n.fixableOnly=t.fixableOnly),t.warnSeverity&&(n.warnSeverity=t.warnSeverity),t.failOnLicense!==void 0&&(n.failOnLicense=t.failOnLicense),t.failOnUnknownSeverity!==void 0&&(n.failOnUnknownSeverity=t.failOnUnknownSeverity),t.failOnKev!==void 0&&(n.failOnKev=t.failOnKev),t.failEpssAtOrAbove!==void 0&&(n.failEpssAtOrAbove=t.failEpssAtOrAbove),t.warnEpssAtOrAbove!==void 0&&(n.warnEpssAtOrAbove=t.warnEpssAtOrAbove),t.exploitabilityFixableOnly!==void 0&&(n.exploitabilityFixableOnly=t.exploitabilityFixableOnly),t.license&&(n.license=t.license),n}function Xoe(e,t){return AO(t,e.knowledge?.dir??"knowledge")}function rz(e,t){if(typeof e!="object"||e===null)return _O;let n=Sf.safeParse(e);if(!n.success){let a=n.error.issues[0],l=a.path.length>0?a.path.join("."):void 0,c=t?` in ${t}`:"";throw new xu(`Invalid chant config${c}: ${l?`${l}: `:""}${a.message}`,a.path.length>0?String(a.path[0]):void 0)}let i=e.lexicons,r=t!==void 0?oz(t):process.cwd(),o=e.sourceDir;for(let[a,l]of(i??[]).entries()){if(typeof l=="string"||l.root===void 0)continue;let{problem:c}=Jb(l,r,o);if(c!==void 0){let u=t?` in ${t}`:"";throw new xu(`Invalid chant config${u}: lexicons.${a}.root: ${c}`,"lexicons")}}let s=Zs(i,r,o);return Object.keys(s).length>0?{...e,lexicons:Jr(i),lexiconModules:s}:e}var qoe,Koe,Sf,_O,PO,az,nz,xu,Kt=v(()=>{"use strict";Ln();Yo();Ri();RO();xn();Yb();qoe=m.union([m.string().min(1),m.object({name:m.string().min(1),endpoint:m.string().min(1).optional()})]),Koe=m.union([m.string().min(1),m.object({name:m.string().min(1),module:m.string().min(1),root:m.string().min(1).optional()}).strict()]),Sf=m.object({lexicons:m.array(Koe).optional(),capabilities:m.array(m.string().min(1)).optional(),environments:m.array(qoe).optional(),sourceDir:m.string().min(1).optional(),lint:m.record(m.string(),m.unknown()).optional(),ownership:m.object({stack:m.string().min(1).optional(),env:m.union([m.string().min(1),m.object({param:m.string().min(1)})]).optional(),enabled:m.boolean().optional()}).optional(),build:m.object({fold:m.boolean().optional()}).optional(),buildParams:m.record(m.string(),m.object({type:m.enum(["string","number","boolean"]),default:m.union([m.string(),m.number(),m.boolean()]).optional(),enum:m.array(m.union([m.string(),m.number(),m.boolean()])).optional(),env:m.string().min(1).optional(),required:m.boolean().optional(),description:m.string().optional()})).optional(),release:m.object({autoRecord:m.boolean().optional()}).optional(),run:m.object({on:m.string().min(1).optional()}).strict().optional(),sbom:m.object({format:m.enum(["spdx","cyclonedx"]).optional(),enabled:m.boolean().optional()}).optional(),signing:m.object({keyless:m.boolean().optional(),oidcIssuer:m.string().min(1).optional(),identity:m.string().min(1).optional(),identityIsRegexp:m.boolean().optional(),key:m.string().min(1).optional()}).optional(),vulnPolicy:m.object({failSeverity:m.enum(["critical","high","medium","low","negligible","unknown"]).optional(),fixableOnly:m.boolean().optional(),warnSeverity:m.enum(["critical","high","medium","low","negligible","unknown"]).optional(),failOnLicense:m.boolean().optional(),failOnUnknownSeverity:m.boolean().optional(),failOnKev:m.boolean().optional(),failEpssAtOrAbove:m.number().min(0).max(1).optional(),warnEpssAtOrAbove:m.number().min(0).max(1).optional(),exploitabilityFixableOnly:m.boolean().optional(),license:m.object({allow:m.array(m.string()).optional(),deny:m.array(m.string()).optional()}).optional(),scanner:m.enum(["grype","trivy"]).optional(),vexSources:m.array(m.string()).optional()}).optional(),knowledge:m.object({dir:m.string().min(1).optional()}).optional(),codegen:m.object({outDir:m.string().min(1).optional()}).strict().optional(),decide:ez.optional(),exclude:m.array(m.string().min(1)).optional(),include:m.array(m.string().min(1)).optional(),rootOnly:m.boolean().optional()}).passthrough(),_O={};PO=new Set(["$schema","extends","rules","overrides","plugins","policies"]),az=e=>e.startsWith("_");nz=new Set(Object.keys(Sf.shape).filter(e=>e!=="lint"));xu=class extends Error{constructor(n,i){super(n);this.key=i}}});var yu,bu=v(()=>{"use strict";Kt();yu="CHANT_ENV"});var Af=ie((UMe,wz)=>{"use strict";var gz="[^\\\\/]",Qoe="(?=.)",hz="[^/]",TO="(?:\\/|$)",yz="(?:^|\\/)",DO=`\\.{1,2}${TO}`,ese="(?!\\.)",tse=`(?!${yz}${DO})`,nse=`(?!\\.{0,1}${TO})`,rse=`(?!${DO})`,ise="[^.\\/]",ose=`${hz}*?`,sse="/",bz={DOT_LITERAL:"\\.",PLUS_LITERAL:"\\+",QMARK_LITERAL:"\\?",SLASH_LITERAL:"\\/",ONE_CHAR:Qoe,QMARK:hz,END_ANCHOR:TO,DOTS_SLASH:DO,NO_DOT:ese,NO_DOTS:tse,NO_DOT_SLASH:nse,NO_DOTS_SLASH:rse,QMARK_NO_DOT:ise,STAR:ose,START_ANCHOR:yz,SEP:sse},ase={...bz,SLASH_LITERAL:"[\\\\/]",QMARK:gz,STAR:`${gz}*?`,DOTS_SLASH:"\\.{1,2}(?:[\\\\/]|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:[\\\\/]|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:[\\\\/]|$))",QMARK_NO_DOT:"[^.\\\\/]",START_ANCHOR:"(?:^|[\\\\/])",END_ANCHOR:"(?:[\\\\/]|$)",SEP:"\\"},cse={__proto__:null,alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};wz.exports={DEFAULT_MAX_EXTGLOB_RECURSION:0,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:cse,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,extglobChars(e){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${e.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(e){return e===!0?ase:bz}}});var Pf=ie(hr=>{"use strict";var{REGEX_BACKSLASH:lse,REGEX_REMOVE_BACKSLASH:use,REGEX_SPECIAL_CHARS:dse,REGEX_SPECIAL_CHARS_GLOBAL:pse}=Af();hr.isObject=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);hr.hasRegexChars=e=>dse.test(e);hr.isRegexChar=e=>e.length===1&&hr.hasRegexChars(e);hr.escapeRegex=e=>e.replace(pse,"\\$1");hr.toPosixSlashes=e=>e.replace(lse,"/");hr.isWindows=()=>{if(typeof navigator<"u"&&navigator.platform){let e=navigator.platform.toLowerCase();return e==="win32"||e==="windows"}return typeof process<"u"&&process.platform?process.platform==="win32":!1};hr.removeBackslashes=e=>e.replace(use,t=>t==="\\"?"":t);hr.escapeLast=(e,t,n)=>{let i=e.lastIndexOf(t,n);return i===-1?e:e[i-1]==="\\"?hr.escapeLast(e,t,i-1):`${e.slice(0,i)}\\${e.slice(i)}`};hr.removePrefix=(e,t={})=>{let n=e;return n.startsWith("./")&&(n=n.slice(2),t.prefix="./"),n};hr.wrapOutput=(e,t={},n={})=>{let i=n.contains?"":"^",r=n.contains?"":"$",o=`${i}(?:${e})${r}`;return t.negated===!0&&(o=`(?:^(?!${o}).*$)`),o};hr.basename=(e,{windows:t}={})=>{let n=e.split(t?/[\\/]/:"/"),i=n[n.length-1];return i===""?n[n.length-2]:i}});var Az=ie((VMe,Ez)=>{"use strict";var vz=Pf(),{CHAR_ASTERISK:NO,CHAR_AT:fse,CHAR_BACKWARD_SLASH:Of,CHAR_COMMA:mse,CHAR_DOT:jO,CHAR_EXCLAMATION_MARK:LO,CHAR_FORWARD_SLASH:Sz,CHAR_LEFT_CURLY_BRACE:MO,CHAR_LEFT_PARENTHESES:FO,CHAR_LEFT_SQUARE_BRACKET:gse,CHAR_PLUS:hse,CHAR_QUESTION_MARK:kz,CHAR_RIGHT_CURLY_BRACE:yse,CHAR_RIGHT_PARENTHESES:xz,CHAR_RIGHT_SQUARE_BRACKET:bse}=Af(),$z=e=>e===Sz||e===Of,Rz=e=>{e.isPrefix!==!0&&(e.depth=e.isGlobstar?1/0:1)},wse=(e,t)=>{let n=t||{},i=e.length-1,r=n.parts===!0||n.scanToEnd===!0,o=[],s=[],a=[],l=e,c=-1,u=0,d=0,p=!1,f=!1,g=!1,h=!1,b=!1,w=!1,x=!1,k=!1,R=!1,$=!1,_=0,T,C,K={value:"",depth:0,isGlob:!1},O=()=>c>=i,pe=()=>l.charCodeAt(c+1),F=()=>(T=C,l.charCodeAt(++c));for(;c<i;){C=F();let xe;if(C===Of){x=K.backslashes=!0,C=F(),C===MO&&(w=!0);continue}if(w===!0||C===MO){for(_++;O()!==!0&&(C=F());){if(C===Of){x=K.backslashes=!0,F();continue}if(C===MO){_++;continue}if(w!==!0&&C===jO&&(C=F())===jO){if(p=K.isBrace=!0,g=K.isGlob=!0,$=!0,r===!0)continue;break}if(w!==!0&&C===mse){if(p=K.isBrace=!0,g=K.isGlob=!0,$=!0,r===!0)continue;break}if(C===yse&&(_--,_===0)){w=!1,p=K.isBrace=!0,$=!0;break}}if(r===!0)continue;break}if(C===Sz){if(o.push(c),s.push(K),K={value:"",depth:0,isGlob:!1},$===!0)continue;if(T===jO&&c===u+1){u+=2;continue}d=c+1;continue}if(n.noext!==!0&&(C===hse||C===fse||C===NO||C===kz||C===LO)===!0&&pe()===FO){if(g=K.isGlob=!0,h=K.isExtglob=!0,$=!0,C===LO&&c===u&&(R=!0),r===!0){for(;O()!==!0&&(C=F());){if(C===Of){x=K.backslashes=!0,C=F();continue}if(C===xz){g=K.isGlob=!0,$=!0;break}}continue}break}if(C===NO){if(T===NO&&(b=K.isGlobstar=!0),g=K.isGlob=!0,$=!0,r===!0)continue;break}if(C===kz){if(g=K.isGlob=!0,$=!0,r===!0)continue;break}if(C===gse){for(;O()!==!0&&(xe=F());){if(xe===Of){x=K.backslashes=!0,F();continue}if(xe===bse){f=K.isBracket=!0,g=K.isGlob=!0,$=!0;break}}if(r===!0)continue;break}if(n.nonegate!==!0&&C===LO&&c===u){k=K.negated=!0,u++;continue}if(n.noparen!==!0&&C===FO){if(g=K.isGlob=!0,r===!0){for(;O()!==!0&&(C=F());){if(C===FO){x=K.backslashes=!0,C=F();continue}if(C===xz){$=!0;break}}continue}break}if(g===!0){if($=!0,r===!0)continue;break}}n.noext===!0&&(h=!1,g=!1);let Q=l,I="",B="";u>0&&(I=l.slice(0,u),l=l.slice(u),d-=u),Q&&g===!0&&d>0?(Q=l.slice(0,d),B=l.slice(d)):g===!0?(Q="",B=l):Q=l,Q&&Q!==""&&Q!=="/"&&Q!==l&&$z(Q.charCodeAt(Q.length-1))&&(Q=Q.slice(0,-1)),n.unescape===!0&&(B&&(B=vz.removeBackslashes(B)),Q&&x===!0&&(Q=vz.removeBackslashes(Q)));let Z={prefix:I,input:e,start:u,base:Q,glob:B,isBrace:p,isBracket:f,isGlob:g,isExtglob:h,isGlobstar:b,negated:k,negatedExtglob:R};if(n.tokens===!0&&(Z.maxDepth=0,$z(C)||s.push(K),Z.tokens=s),n.parts===!0||n.tokens===!0){let xe;for(let we=0;we<o.length;we++){let Ct=xe?xe+1:u,at=o[we],$e=e.slice(Ct,at);n.tokens&&(we===0&&u!==0?(s[we].isPrefix=!0,s[we].value=I):s[we].value=$e,Rz(s[we]),Z.maxDepth+=s[we].depth),(we!==0||$e!=="")&&a.push($e),xe=at}if(xe&&xe+1<e.length){let we=e.slice(xe+1);a.push(we),n.tokens&&(s[s.length-1].value=we,Rz(s[s.length-1]),Z.maxDepth+=s[s.length-1].depth)}Z.slashes=o,Z.parts=a}return Z};Ez.exports=wse});var Iz=ie((qMe,_z)=>{"use strict";var Cf=Af(),Tr=Pf(),{MAX_LENGTH:nw,POSIX_REGEX_SOURCE:vse,REGEX_NON_SPECIAL_CHARS:kse,REGEX_SPECIAL_CHARS_BACKREF:xse,REPLACEMENTS:Pz}=Cf,$se=(e,t)=>{if(typeof t.expandRange=="function")return t.expandRange(...e,t);e.sort();let n=`[${e.join("-")}]`;try{new RegExp(n)}catch{return e.map(r=>Tr.escapeRegex(r)).join("..")}return n},Ru=(e,t)=>`Missing ${e}: "${t}" - use "\\\\${t}" to match literal characters`,Oz=e=>{let t=[],n=0,i=0,r=0,o="",s=!1;for(let a of e){if(s===!0){o+=a,s=!1;continue}if(a==="\\"){o+=a,s=!0;continue}if(a==='"'){r=r===1?0:1,o+=a;continue}if(r===0){if(a==="[")n++;else if(a==="]"&&n>0)n--;else if(n===0){if(a==="(")i++;else if(a===")"&&i>0)i--;else if(a==="|"&&i===0){t.push(o),o="";continue}}}o+=a}return t.push(o),t},Rse=e=>{let t=!1;for(let n of e){if(t===!0){t=!1;continue}if(n==="\\"){t=!0;continue}if(/[?*+@!()[\]{}]/.test(n))return!1}return!0},Cz=e=>{let t=e.trim(),n=!0;for(;n===!0;)n=!1,/^@\([^\\()[\]{}|]+\)$/.test(t)&&(t=t.slice(2,-1),n=!0);if(Rse(t))return t.replace(/\\(.)/g,"$1")},Sse=e=>{let t=e.map(Cz).filter(Boolean);for(let n=0;n<t.length;n++)for(let i=n+1;i<t.length;i++){let r=t[n],o=t[i],s=r[0];if(!(!s||r!==s.repeat(r.length)||o!==s.repeat(o.length))&&(r===o||r.startsWith(o)||o.startsWith(r)))return!0}return!1},BO=(e,t=!0)=>{if(e[0]!=="+"&&e[0]!=="*"||e[1]!=="(")return;let n=0,i=0,r=0,o=!1;for(let s=1;s<e.length;s++){let a=e[s];if(o===!0){o=!1;continue}if(a==="\\"){o=!0;continue}if(a==='"'){r=r===1?0:1;continue}if(r!==1){if(a==="["){n++;continue}if(a==="]"&&n>0){n--;continue}if(!(n>0)){if(a==="("){i++;continue}if(a===")"&&(i--,i===0))return t===!0&&s!==e.length-1?void 0:{type:e[0],body:e.slice(2,s),end:s}}}}},Ese=e=>{let t=0,n=[];for(;t<e.length;){let r=BO(e.slice(t),!1);if(!r||r.type!=="*")return;let o=Oz(r.body).map(a=>a.trim());if(o.length!==1)return;let s=Cz(o[0]);if(!s||s.length!==1)return;n.push(s),t+=r.end+1}return n.length<1?void 0:`${n.length===1?Tr.escapeRegex(n[0]):`[${n.map(r=>Tr.escapeRegex(r)).join("")}]`}*`},Ase=e=>{let t=0,n=e.trim(),i=BO(n);for(;i;)t++,n=i.body.trim(),i=BO(n);return t},Pse=(e,t)=>{if(t.maxExtglobRecursion===!1)return{risky:!1};let n=typeof t.maxExtglobRecursion=="number"?t.maxExtglobRecursion:Cf.DEFAULT_MAX_EXTGLOB_RECURSION,i=Oz(e).map(r=>r.trim());if(i.length>1&&(i.some(r=>r==="")||i.some(r=>/^[*?]+$/.test(r))||Sse(i)))return{risky:!0};for(let r of i){let o=Ese(r);if(o)return{risky:!0,safeOutput:o};if(Ase(r)>n)return{risky:!0}}return{risky:!1}},GO=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");e=Pz[e]||e;let n={...t},i=typeof n.maxLength=="number"?Math.min(nw,n.maxLength):nw,r=e.length;if(r>i)throw new SyntaxError(`Input length: ${r}, exceeds maximum allowed length: ${i}`);let o={type:"bos",value:"",output:n.prepend||""},s=[o],a=n.capture?"":"?:",l=Cf.globChars(n.windows),c=Cf.extglobChars(l),{DOT_LITERAL:u,PLUS_LITERAL:d,SLASH_LITERAL:p,ONE_CHAR:f,DOTS_SLASH:g,NO_DOT:h,NO_DOT_SLASH:b,NO_DOTS_SLASH:w,QMARK:x,QMARK_NO_DOT:k,STAR:R,START_ANCHOR:$}=l,_=ne=>`(${a}(?:(?!${$}${ne.dot?g:u}).)*?)`,T=n.dot?"":h,C=n.dot?x:k,K=n.bash===!0?_(n):R;n.capture&&(K=`(${K})`),typeof n.noext=="boolean"&&(n.noextglob=n.noext);let O={input:e,index:-1,start:0,dot:n.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:s};e=Tr.removePrefix(e,O),r=e.length;let pe=[],F=[],Q=[],I=o,B,Z=()=>O.index===r-1,xe=O.peek=(ne=1)=>e[O.index+ne],we=O.advance=()=>e[++O.index]||"",Ct=()=>e.slice(O.index+1),at=(ne="",Re=0)=>{O.consumed+=ne,O.index+=Re},$e=ne=>{O.output+=ne.output!=null?ne.output:ne.value,at(ne.value)},Te=()=>{let ne=1;for(;xe()==="!"&&(xe(2)!=="("||xe(3)==="?");)we(),O.start++,ne++;return ne%2===0?!1:(O.negated=!0,O.start++,!0)},nt=ne=>{O[ne]++,Q.push(ne)},St=ne=>{O[ne]--,Q.pop()},Ee=ne=>{if(I.type==="globstar"){let Re=O.braces>0&&(ne.type==="comma"||ne.type==="brace"),X=ne.extglob===!0||pe.length&&(ne.type==="pipe"||ne.type==="paren");ne.type!=="slash"&&ne.type!=="paren"&&!Re&&!X&&(O.output=O.output.slice(0,-I.output.length),I.type="star",I.value="*",I.output=K,O.output+=I.output)}if(pe.length&&ne.type!=="paren"&&(pe[pe.length-1].inner+=ne.value),(ne.value||ne.output)&&$e(ne),I&&I.type==="text"&&ne.type==="text"){I.output=(I.output||I.value)+ne.value,I.value+=ne.value;return}ne.prev=I,s.push(ne),I=ne},zt=(ne,Re)=>{let X={...c[Re],conditions:1,inner:""};X.prev=I,X.parens=O.parens,X.output=O.output,X.startIndex=O.index,X.tokensIndex=s.length;let Ce=(n.capture?"(":"")+X.open;nt("parens"),Ee({type:ne,value:Re,output:O.output?"":f}),Ee({type:"paren",extglob:!0,value:we(),output:Ce}),pe.push(X)},Vn=ne=>{let Re=e.slice(ne.startIndex,O.index+1),X=e.slice(ne.startIndex+2,O.index),Ce=Pse(X,n);if((ne.type==="plus"||ne.type==="star")&&Ce.risky){let Je=Ce.safeOutput?(ne.output?"":f)+(n.capture?`(${Ce.safeOutput})`:Ce.safeOutput):void 0,Bt=s[ne.tokensIndex];Bt.type="text",Bt.value=Re,Bt.output=Je||Tr.escapeRegex(Re);for(let W=ne.tokensIndex+1;W<s.length;W++)s[W].value="",s[W].output="",delete s[W].suffix;O.output=ne.output+Bt.output,O.backtrack=!0,Ee({type:"paren",extglob:!0,value:B,output:""}),St("parens");return}let tt=ne.close+(n.capture?")":""),gt;if(ne.type==="negate"){let Je=K;if(ne.inner&&ne.inner.length>1&&ne.inner.includes("/")&&(Je=_(n)),(Je!==K||Z()||/^\)+$/.test(Ct()))&&(tt=ne.close=`)$))${Je}`),ne.inner.includes("*")&&(gt=Ct())&&/^\.[^\\/.]+$/.test(gt)){let Bt=GO(gt,{...t,fastpaths:!1}).output;tt=ne.close=`)${Bt})${Je})`}ne.prev.type==="bos"&&(O.negatedExtglob=!0)}Ee({type:"paren",extglob:!0,value:B,output:tt}),St("parens")};if(n.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(e)){let ne=!1,Re=e.replace(xse,(X,Ce,tt,gt,Je,Bt)=>gt==="\\"?(ne=!0,X):gt==="?"?Ce?Ce+gt+(Je?x.repeat(Je.length):""):Bt===0?C+(Je?x.repeat(Je.length):""):x.repeat(tt.length):gt==="."?u.repeat(tt.length):gt==="*"?Ce?Ce+gt+(Je?K:""):K:Ce?X:`\\${X}`);return ne===!0&&(n.unescape===!0?Re=Re.replace(/\\/g,""):Re=Re.replace(/\\+/g,X=>X.length%2===0?"\\\\":X?"\\":"")),Re===e&&n.contains===!0?(O.output=e,O):(O.output=Tr.wrapOutput(Re,O,t),O)}for(;!Z();){if(B=we(),B==="\0")continue;if(B==="\\"){let X=xe();if(X==="/"&&n.bash!==!0||X==="."||X===";")continue;if(!X){B+="\\",Ee({type:"text",value:B});continue}let Ce=/^\\+/.exec(Ct()),tt=0;if(Ce&&Ce[0].length>2&&(tt=Ce[0].length,O.index+=tt,tt%2!==0&&(B+="\\")),n.unescape===!0?B=we():B+=we(),O.brackets===0){Ee({type:"text",value:B});continue}}if(O.brackets>0&&(B!=="]"||I.value==="["||I.value==="[^")){if(n.posix!==!1&&B===":"){let X=I.value.slice(1);if(X.includes("[")&&(I.posix=!0,X.includes(":"))){let Ce=I.value.lastIndexOf("["),tt=I.value.slice(0,Ce),gt=I.value.slice(Ce+2),Je=vse[gt];if(Je){I.value=tt+Je,O.backtrack=!0,we(),!o.output&&s.indexOf(I)===1&&(o.output=f);continue}}}(B==="["&&xe()!==":"||B==="-"&&xe()==="]")&&(B=`\\${B}`),B==="]"&&(I.value==="["||I.value==="[^")&&(B=`\\${B}`),n.posix===!0&&B==="!"&&I.value==="["&&(B="^"),I.value+=B,$e({value:B});continue}if(O.quotes===1&&B!=='"'){B=Tr.escapeRegex(B),I.value+=B,$e({value:B});continue}if(B==='"'){O.quotes=O.quotes===1?0:1,n.keepQuotes===!0&&Ee({type:"text",value:B});continue}if(B==="("){nt("parens"),Ee({type:"paren",value:B});continue}if(B===")"){if(O.parens===0&&n.strictBrackets===!0)throw new SyntaxError(Ru("opening","("));let X=pe[pe.length-1];if(X&&O.parens===X.parens+1){Vn(pe.pop());continue}Ee({type:"paren",value:B,output:O.parens?")":"\\)"}),St("parens");continue}if(B==="["){if(n.nobracket===!0||!Ct().includes("]")){if(n.nobracket!==!0&&n.strictBrackets===!0)throw new SyntaxError(Ru("closing","]"));B=`\\${B}`}else nt("brackets");Ee({type:"bracket",value:B});continue}if(B==="]"){if(n.nobracket===!0||I&&I.type==="bracket"&&I.value.length===1){Ee({type:"text",value:B,output:`\\${B}`});continue}if(O.brackets===0){if(n.strictBrackets===!0)throw new SyntaxError(Ru("opening","["));Ee({type:"text",value:B,output:`\\${B}`});continue}St("brackets");let X=I.value.slice(1);if(I.posix!==!0&&X[0]==="^"&&!X.includes("/")&&(B=`/${B}`),I.value+=B,$e({value:B}),n.literalBrackets===!1||Tr.hasRegexChars(X))continue;let Ce=Tr.escapeRegex(I.value);if(O.output=O.output.slice(0,-I.value.length),n.literalBrackets===!0){O.output+=Ce,I.value=Ce;continue}I.value=`(${a}${Ce}|${I.value})`,O.output+=I.value;continue}if(B==="{"&&n.nobrace!==!0){nt("braces");let X={type:"brace",value:B,output:"(",outputIndex:O.output.length,tokensIndex:O.tokens.length};F.push(X),Ee(X);continue}if(B==="}"){let X=F[F.length-1];if(n.nobrace===!0||!X){Ee({type:"text",value:B,output:B});continue}let Ce=")";if(X.dots===!0){let tt=s.slice(),gt=[];for(let Je=tt.length-1;Je>=0&&(s.pop(),tt[Je].type!=="brace");Je--)tt[Je].type!=="dots"&&gt.unshift(tt[Je].value);Ce=$se(gt,n),O.backtrack=!0}if(X.comma!==!0&&X.dots!==!0){let tt=O.output.slice(0,X.outputIndex),gt=O.tokens.slice(X.tokensIndex);X.value=X.output="\\{",B=Ce="\\}",O.output=tt;for(let Je of gt)O.output+=Je.output||Je.value}Ee({type:"brace",value:B,output:Ce}),St("braces"),F.pop();continue}if(B==="|"){pe.length>0&&pe[pe.length-1].conditions++,Ee({type:"text",value:B});continue}if(B===","){let X=B,Ce=F[F.length-1];Ce&&Q[Q.length-1]==="braces"&&(Ce.comma=!0,X="|"),Ee({type:"comma",value:B,output:X});continue}if(B==="/"){if(I.type==="dot"&&O.index===O.start+1){O.start=O.index+1,O.consumed="",O.output="",s.pop(),I=o;continue}Ee({type:"slash",value:B,output:p});continue}if(B==="."){if(O.braces>0&&I.type==="dot"){I.value==="."&&(I.output=u);let X=F[F.length-1];I.type="dots",I.output+=B,I.value+=B,X.dots=!0;continue}if(O.braces+O.parens===0&&I.type!=="bos"&&I.type!=="slash"){Ee({type:"text",value:B,output:u});continue}Ee({type:"dot",value:B,output:u});continue}if(B==="?"){if(!(I&&I.value==="(")&&n.noextglob!==!0&&xe()==="("&&xe(2)!=="?"){zt("qmark",B);continue}if(I&&I.type==="paren"){let Ce=xe(),tt=B;(I.value==="("&&!/[!=<:]/.test(Ce)||Ce==="<"&&!/<([!=]|\w+>)/.test(Ct()))&&(tt=`\\${B}`),Ee({type:"text",value:B,output:tt});continue}if(n.dot!==!0&&(I.type==="slash"||I.type==="bos")){Ee({type:"qmark",value:B,output:k});continue}Ee({type:"qmark",value:B,output:x});continue}if(B==="!"){if(n.noextglob!==!0&&xe()==="("&&(xe(2)!=="?"||!/[!=<:]/.test(xe(3)))){zt("negate",B);continue}if(n.nonegate!==!0&&O.index===0){Te();continue}}if(B==="+"){if(n.noextglob!==!0&&xe()==="("&&xe(2)!=="?"){zt("plus",B);continue}if(I&&I.value==="("||n.regex===!1){Ee({type:"plus",value:B,output:d});continue}if(I&&(I.type==="bracket"||I.type==="paren"||I.type==="brace")||O.parens>0){Ee({type:"plus",value:B});continue}Ee({type:"plus",value:d});continue}if(B==="@"){if(n.noextglob!==!0&&xe()==="("&&xe(2)!=="?"){Ee({type:"at",extglob:!0,value:B,output:""});continue}Ee({type:"text",value:B});continue}if(B!=="*"){(B==="$"||B==="^")&&(B=`\\${B}`);let X=kse.exec(Ct());X&&(B+=X[0],O.index+=X[0].length),Ee({type:"text",value:B});continue}if(I&&(I.type==="globstar"||I.star===!0)){I.type="star",I.star=!0,I.value+=B,I.output=K,O.backtrack=!0,O.globstar=!0,at(B);continue}let ne=Ct();if(n.noextglob!==!0&&/^\([^?]/.test(ne)){zt("star",B);continue}if(I.type==="star"){if(n.noglobstar===!0){at(B);continue}let X=I.prev,Ce=X.prev,tt=X.type==="slash"||X.type==="bos",gt=Ce&&(Ce.type==="star"||Ce.type==="globstar");if(n.bash===!0&&(!tt||ne[0]&&ne[0]!=="/")){Ee({type:"star",value:B,output:""});continue}let Je=O.braces>0&&(X.type==="comma"||X.type==="brace"),Bt=pe.length&&(X.type==="pipe"||X.type==="paren");if(!tt&&X.type!=="paren"&&!Je&&!Bt){Ee({type:"star",value:B,output:""});continue}for(;ne.slice(0,3)==="/**";){let W=e[O.index+4];if(W&&W!=="/")break;ne=ne.slice(3),at("/**",3)}if(X.type==="bos"&&Z()){I.type="globstar",I.value+=B,I.output=_(n),O.output=I.output,O.globstar=!0,at(B);continue}if(X.type==="slash"&&X.prev.type!=="bos"&&!gt&&Z()){O.output=O.output.slice(0,-(X.output+I.output).length),X.output=`(?:${X.output}`,I.type="globstar",I.output=_(n)+(n.strictSlashes?")":"|$)"),I.value+=B,O.globstar=!0,O.output+=X.output+I.output,at(B);continue}if(X.type==="slash"&&X.prev.type!=="bos"&&ne[0]==="/"){let W=ne[1]!==void 0?"|$":"";O.output=O.output.slice(0,-(X.output+I.output).length),X.output=`(?:${X.output}`,I.type="globstar",I.output=`${_(n)}${p}|${p}${W})`,I.value+=B,O.output+=X.output+I.output,O.globstar=!0,at(B+we()),Ee({type:"slash",value:"/",output:""});continue}if(X.type==="bos"&&ne[0]==="/"){I.type="globstar",I.value+=B,I.output=`(?:^|${p}|${_(n)}${p})`,O.output=I.output,O.globstar=!0,at(B+we()),Ee({type:"slash",value:"/",output:""});continue}O.output=O.output.slice(0,-I.output.length),I.type="globstar",I.output=_(n),I.value+=B,O.output+=I.output,O.globstar=!0,at(B);continue}let Re={type:"star",value:B,output:K};if(n.bash===!0){Re.output=".*?",(I.type==="bos"||I.type==="slash")&&(Re.output=T+Re.output),Ee(Re);continue}if(I&&(I.type==="bracket"||I.type==="paren")&&n.regex===!0){Re.output=B,Ee(Re);continue}(O.index===O.start||I.type==="slash"||I.type==="dot")&&(I.type==="dot"?(O.output+=b,I.output+=b):n.dot===!0?(O.output+=w,I.output+=w):(O.output+=T,I.output+=T),xe()!=="*"&&(O.output+=f,I.output+=f)),Ee(Re)}for(;O.brackets>0;){if(n.strictBrackets===!0)throw new SyntaxError(Ru("closing","]"));O.output=Tr.escapeLast(O.output,"["),St("brackets")}for(;O.parens>0;){if(n.strictBrackets===!0)throw new SyntaxError(Ru("closing",")"));O.output=Tr.escapeLast(O.output,"("),St("parens")}for(;O.braces>0;){if(n.strictBrackets===!0)throw new SyntaxError(Ru("closing","}"));O.output=Tr.escapeLast(O.output,"{"),St("braces")}if(n.strictSlashes!==!0&&(I.type==="star"||I.type==="bracket")&&Ee({type:"maybe_slash",value:"",output:`${p}?`}),O.backtrack===!0){O.output="";for(let ne of O.tokens)O.output+=ne.output!=null?ne.output:ne.value,ne.suffix&&(O.output+=ne.suffix)}return O};GO.fastpaths=(e,t)=>{let n={...t},i=typeof n.maxLength=="number"?Math.min(nw,n.maxLength):nw,r=e.length;if(r>i)throw new SyntaxError(`Input length: ${r}, exceeds maximum allowed length: ${i}`);e=Pz[e]||e;let{DOT_LITERAL:o,SLASH_LITERAL:s,ONE_CHAR:a,DOTS_SLASH:l,NO_DOT:c,NO_DOTS:u,NO_DOTS_SLASH:d,STAR:p,START_ANCHOR:f}=Cf.globChars(n.windows),g=n.dot?u:c,h=n.dot?d:c,b=n.capture?"":"?:",w={negated:!1,prefix:""},x=n.bash===!0?".*?":p;n.capture&&(x=`(${x})`);let k=T=>T.noglobstar===!0?x:`(${b}(?:(?!${f}${T.dot?l:o}).)*?)`,R=T=>{switch(T){case"*":return`${g}${a}${x}`;case".*":return`${o}${a}${x}`;case"*.*":return`${g}${x}${o}${a}${x}`;case"*/*":return`${g}${x}${s}${a}${h}${x}`;case"**":return g+k(n);case"**/*":return`(?:${g}${k(n)}${s})?${h}${a}${x}`;case"**/*.*":return`(?:${g}${k(n)}${s})?${h}${x}${o}${a}${x}`;case"**/.*":return`(?:${g}${k(n)}${s})?${o}${a}${x}`;default:{let C=/^(.*?)\.(\w+)$/.exec(T);if(!C)return;let K=R(C[1]);return K?K+o+C[2]:void 0}}},$=Tr.removePrefix(e,w),_=R($);return _&&n.strictSlashes!==!0&&(_+=`${s}?`),_};_z.exports=GO});var Nz=ie((KMe,Dz)=>{"use strict";var Ose=Az(),WO=Iz(),Tz=Pf(),Cse=Af(),_se=e=>e&&typeof e=="object"&&!Array.isArray(e),Jt=(e,t,n=!1)=>{if(Array.isArray(e)){let u=e.map(p=>Jt(p,t,n));return p=>{for(let f of u){let g=f(p);if(g)return g}return!1}}let i=_se(e)&&e.tokens&&e.input;if(e===""||typeof e!="string"&&!i)throw new TypeError("Expected pattern to be a non-empty string");let r=t||{},o=r.windows,s=i?Jt.compileRe(e,t):Jt.makeRe(e,t,!1,!0),a=s.state;delete s.state;let l=()=>!1;if(r.ignore){let u={...t,ignore:null,onMatch:null,onResult:null};l=Jt(r.ignore,u,n)}let c=(u,d=!1)=>{let{isMatch:p,match:f,output:g}=Jt.test(u,s,t,{glob:e,posix:o}),h={glob:e,state:a,regex:s,posix:o,input:u,output:g,match:f,isMatch:p};return typeof r.onResult=="function"&&r.onResult(h),p===!1?(h.isMatch=!1,d?h:!1):l(u)?(typeof r.onIgnore=="function"&&r.onIgnore(h),h.isMatch=!1,d?h:!1):(typeof r.onMatch=="function"&&r.onMatch(h),d?h:!0)};return n&&(c.state=a),c};Jt.test=(e,t,n,{glob:i,posix:r}={})=>{if(typeof e!="string")throw new TypeError("Expected input to be a string");if(e==="")return{isMatch:!1,output:""};let o=n||{},s=o.format||(r?Tz.toPosixSlashes:null),a=e===i,l=a&&s?s(e):e;return a===!1&&(l=s?s(e):e,a=l===i),(a===!1||o.capture===!0)&&(o.matchBase===!0||o.basename===!0?a=Jt.matchBase(e,t,n,r):a=t.exec(l)),{isMatch:!!a,match:a,output:l}};Jt.matchBase=(e,t,n)=>(t instanceof RegExp?t:Jt.makeRe(t,n)).test(Tz.basename(e));Jt.isMatch=(e,t,n)=>Jt(t,n)(e);Jt.parse=(e,t)=>Array.isArray(e)?e.map(n=>Jt.parse(n,t)):WO(e,{...t,fastpaths:!1});Jt.scan=(e,t)=>Ose(e,t);Jt.compileRe=(e,t,n=!1,i=!1)=>{if(n===!0)return e.output;let r=t||{},o=r.contains?"":"^",s=r.contains?"":"$",a=`${o}(?:${e.output})${s}`;e&&e.negated===!0&&(a=`^(?!${a}).*$`);let l=Jt.toRegex(a,t);return i===!0&&(l.state=e),l};Jt.makeRe=(e,t={},n=!1,i=!1)=>{if(!e||typeof e!="string")throw new TypeError("Expected a non-empty string");let r={negated:!1,fastpaths:!0};return t.fastpaths!==!1&&(e[0]==="."||e[0]==="*")&&(r.output=WO.fastpaths(e,t)),r.output||(r=WO(e,t)),Jt.compileRe(r,t,n,i)};Jt.toRegex=(e,t)=>{try{let n=t||{};return new RegExp(e,n.flags||(n.nocase?"i":""))}catch(n){if(t&&t.debug===!0)throw n;return/$^/}};Jt.constants=Cse;Dz.exports=Jt});var _f=ie((JMe,Mz)=>{"use strict";var jz=Nz(),Ise=Pf();function Lz(e,t,n=!1){return t&&(t.windows===null||t.windows===void 0)&&(t={...t,windows:Ise.isWindows()}),jz(e,t,n)}Object.assign(Lz,jz);Mz.exports=Lz});import{dirname as Tse}from"path";import{fileURLToPath as Dse}from"url";import{createHash as Nse}from"crypto";import{execFile as jse}from"child_process";function UO(){return rw=new zO,rw}function ot(){return rw||UO()}function HO(e){return Tse(Dse(e))}var Fz,zO,rw,to=v(()=>{"use strict";Fz=Le(_f(),1),zO=class{constructor(){this.name="node";this.hashAlgorithm="sha256";this.commands={runner:"node",exec:"npx",packCmd:["npm","pack"]}}hash(t){return Nse("sha256").update(t).digest("hex")}globMatch(t,n){return(0,Fz.default)(t)(n)}async spawn(t,n){return new Promise(i=>{let r=jse(t[0],t.slice(1),{cwd:n?.cwd,maxBuffer:10485760,...n?.env?{env:{...process.env,...n.env}}:{}},(o,s,a)=>{i({stdout:s??"",stderr:a??"",exitCode:o?o.code??1:0})});r.stdin&&(r.stdin.on("error",()=>{}),r.stdin.end(n?.stdin??""))})}}});import{createHmac as Lse,timingSafeEqual as n1e}from"node:crypto";function VO(e=iw){let t=e.toLowerCase();return{signature:`${t}-signature`,timestamp:`${t}-timestamp`,event:`${t}-event`,delivery:`${t}-delivery`}}function qO(e,t,n){return`sha256=${Lse("sha256",e).update(`${String(t)}.${n}`,"utf8").digest("hex")}`}var iw,KO=v(()=>{"use strict";iw="x-chant"});import{createHash as Mse,randomUUID as Fse}from"node:crypto";function Gse(e){let t={};e.CI_JOB_URL?t.url=e.CI_JOB_URL:e.GITHUB_SERVER_URL&&e.GITHUB_REPOSITORY&&e.GITHUB_RUN_ID?t.url=`${e.GITHUB_SERVER_URL}/${e.GITHUB_REPOSITORY}/actions/runs/${e.GITHUB_RUN_ID}`:e.CI_PIPELINE_URL&&(t.url=e.CI_PIPELINE_URL),e.GITLAB_CI==="true"?t.forge="gitlab":e.GITEA_ACTIONS==="true"||e.FORGEJO_ACTIONS==="true"?t.forge="forgejo":e.GITHUB_ACTIONS==="true"&&(t.forge="github");let n=e.GITHUB_REPOSITORY||e.CI_PROJECT_PATH;n&&(t.repository=n);let i=e.GITHUB_SHA||e.CI_COMMIT_SHA;return i&&(t.commit=i),t}function Wz(e,t={}){let n=t.env??process.env,{id:i,project:r,targets:o,run:s,...a}=e,l={...Gse(n),...s??{}},c=r??l.repository??"this project",u=e.digest??e.drift?.fingerprint??l.commit,d=i??(u?Mse("sha256").update(JSON.stringify([e.source,c,e.event,e.wave?.number??null,e.environment??null,u])).digest("hex"):Fse());return{schema:Bse,id:d,at:(t.now??new Date).toISOString(),...a,project:c,targets:o??[],...Object.keys(l).length>0?{run:l}:{}}}function zz(e){if(e.summary)return`${e.source}: ${e.summary}`;let t=e.wave?`wave ${e.wave.number}${e.wave.name?` (${e.wave.name})`:""} of ${e.project}`:e.environment?`${e.environment} in ${e.project}`:e.project;return`${e.source}: ${t} ${Wse[e.event]}`}function Uz(e){let t=[];return e.approve?.review&&t.push({title:"Review and approve",value:`pull request ${e.approve.review.pr}, then run it again`,link:e.approve.review.url}),e.drift?(e.drift.changed.length>0&&t.push({title:"Drifted",value:e.drift.changed.join(", ")}),e.drift.missing?.length&&t.push({title:"Missing",value:e.drift.missing.join(", ")}),e.drift.failed?.length&&t.push({title:"Not refreshed",value:e.drift.failed.join(", ")})):e.targets.length>0&&t.push({title:"Targets",value:e.targets.join(", ")}),e.digest&&t.push({title:"Digest",value:e.digest}),e.approve&&t.push({title:e.approve.review?"Or approve":"Approve",value:e.approve.command}),e.reason&&t.push({title:"Reason",value:e.reason}),e.run?.url&&t.push({title:"Run",value:e.run.url,link:e.run.url}),e.reportUrl&&t.push({title:"Report",value:e.reportUrl,link:e.reportUrl}),t}function zse(e){let t=[`*${zz(e)}*`];for(let n of Uz(e))n.title==="Review and approve"?t.push(`${n.title}: <${n.link}|pull request ${e.approve.review.pr}>, then run it again`):n.title==="Approve"||n.title==="Or approve"||n.title==="Digest"?t.push(`${n.title}: \`${n.value}\``):n.link?t.push(`${n.title}: <${n.link}>`):t.push(`${n.title}: ${n.value}`);return{text:t.join(`
53
+ `)}}function Use(e){let t=Uz(e),n=[...e.approve?.review?[{type:"Action.OpenUrl",title:"Review and approve",url:e.approve.review.url}]:[],...e.run?.url?[{type:"Action.OpenUrl",title:"Open the run",url:e.run.url}]:[]];return{type:"message",attachments:[{contentType:"application/vnd.microsoft.card.adaptive",contentUrl:null,content:{$schema:"http://adaptivecards.io/schemas/adaptive-card.json",type:"AdaptiveCard",version:"1.4",body:[{type:"TextBlock",text:zz(e),weight:"Bolder",wrap:!0},{type:"FactSet",facts:t.map(i=>({title:i.title,value:i.link&&i.title==="Review and approve"?`${i.value}: ${i.link}`:i.value}))}],...n.length>0?{actions:n}:{}}}]}}function ow(e,t="notify"){if(typeof e!="object"||e===null||Array.isArray(e))return`${t}: expected { webhook, key, slack, teams, events }`;let n=e;for(let i of Object.keys(n))if(!Gz.includes(i))return`${t}.${i}: unknown setting (expected ${Gz.join(", ")})`;for(let i of["webhook","key","slack","teams"]){let r=n[i];if(r!==void 0&&(typeof r!="string"||!Hse.test(r)))return`${t}.${i}: the name of the environment variable that holds the ${i==="key"?"signing key":"URL"}, never the ${i==="key"?"key":"URL"} itself`}if(n.webhook!==void 0&&n.key===void 0)return`${t}.key: a webhook needs a signing key; name the variable that holds it`;if(n.key!==void 0&&n.webhook===void 0)return`${t}.webhook: a key is for a webhook; name the variable that holds its URL`;if(n.webhook===void 0&&n.slack===void 0&&n.teams===void 0)return`${t}: name a webhook (with its key), a slack or a teams URL variable`;if(n.events!==void 0&&!(Array.isArray(n.events)&&n.events.every(i=>Bz.includes(i))))return`${t}.events: a list of ${Bz.join(", ")}`}function Vse(e,t,n={}){let i=JSON.stringify(e),r=n.now??Math.floor(Date.now()/1e3),o=VO(n.prefix??iw);return{body:i,headers:{"content-type":"application/json","user-agent":n.userAgent??e.source,[o.event]:e.event,[o.delivery]:e.id,[o.timestamp]:String(r),[o.signature]:qO(t,r,i)}}}function Hz(e,t){let n=e;for(let i of t)i&&(n=n.split(i).join("<url>"));return n.replace(/https?:\/\/\S+/g,"<url>")}async function qse(e,t,n,i,r){let o="not attempted";for(let s=0;s<i;s++){s>0&&await r(500*s);try{let a=await e(t,{method:"POST",...n,signal:AbortSignal.timeout(1e4)});if(a.ok)return;if(o=`HTTP ${String(a.status)}`,a.status<500)return o}catch(a){o=Hz(a instanceof Error?a.message:String(a),[t])}}return o}async function Vz(e,t,n={}){if(!e||!t)return[];if(e.events&&!e.events.includes(t.event))return[];let i=n.env??process.env,r=n.fetch??((d,p)=>globalThis.fetch(d,p)),o=Math.max(1,n.attempts??3),s=n.sleep??(d=>new Promise(p=>setTimeout(p,d))),a=n.log??(d=>process.stderr.write(d+`
54
+ `)),l=[],c=async(d,p,f)=>{let g;try{let h=i[p];if(!h)g={target:d,ok:!1,detail:`${p} is not set`};else{let b=f();if(typeof b=="string")g={target:d,ok:!1,detail:b};else{let w=await qse(r,h,b,o,s);g={target:d,ok:w===void 0,detail:w??"delivered"}}}}catch(h){g={target:d,ok:!1,detail:Hz(h instanceof Error?h.message:String(h),[i[p]??""])}}g.ok||a(`notify: the ${t.event} event was not delivered to ${Kse[d]}: ${g.detail}`),l.push(g)},u=d=>({headers:{"content-type":"application/json"},body:JSON.stringify(d)});return e.webhook&&await c("webhook",e.webhook,()=>{let d=e.key?i[e.key]:void 0;return d?Vse(t,d,{...n.now!==void 0?{now:n.now}:{},...n.prefix?{prefix:n.prefix}:{},...n.userAgent?{userAgent:n.userAgent}:{}}):`${e.key??"the key variable"} is not set, and an event is never sent unsigned`}),e.slack&&await c("slack",e.slack,()=>u((n.render?.slack??zse)(t))),e.teams&&await c("teams",e.teams,()=>u((n.render?.teams??Use)(t))),l}var Bse,Bz,Wse,Hse,Gz,Kse,sw=v(()=>{"use strict";KO();KO();Bse="chant.notify/v1",Bz=["waiting","refused","failed","drift"];Wse={waiting:"waits for an approval",refused:"was refused",failed:"failed",drift:"drifted"};Hse=/^[A-Za-z_][A-Za-z0-9_]*$/,Gz=["webhook","key","slack","teams","events"];Kse={webhook:"the webhook",slack:"Slack",teams:"Teams"}});function qz(e,t,n,i={}){let o=e.waves[t-1]?.name,s=`wave ${t}${o?` (${o})`:""} of ${e.name}`;if(n.error!==void 0)return{source:"chant",event:"failed",summary:`${s} failed`,wave:{number:t,...o?{name:o}:{}},targets:[],reason:n.error,exitCode:1};let{result:a}=n,l=a.decision,c={source:"chant",wave:{number:t,...o?{name:o}:{},...l?.gate?{gate:l.gate}:{}},...l?.digest?{digest:l.digest}:{},exitCode:a.exitCode};if(a.exitCode===3){if(!l)return;let u=a.hooks.filter(p=>p.outcome==="held");if(i.share!==void 0&&u.length===0)return;let d=l.review?.pr!==void 0&&l.review.url?{review:{pr:l.review.pr,url:l.review.url}}:{};return{...c,event:"waiting",status:"waiting",summary:`${s} waits for an approval`,targets:l.members.map(p=>p.member),approve:{command:l.approve??`chant approve ${l.op} ${l.gate} --plan ${l.digest}`,...d},...l.heldOn?{reason:`held on ${l.heldOn.op} / ${l.heldOn.gate} by ${l.heldOn.hook}`}:l.heldBy?.length?{reason:`held by ${l.heldBy.join(", ")}`}:l.review?.reason?{reason:l.review.reason}:{}}}if(a.exitCode===8&&l?.refused?.reason==="point")return{...c,event:"refused",status:"point",summary:`${s} refused: decision point ${l.point?.name??""} answered ${JSON.stringify(l.point?.answer?.answer??null)}`,targets:l.refused.runs,...l.refused.message?{reason:l.refused.message}:{}};if(a.exitCode===7&&l?.refused)return{...c,event:"refused",status:l.refused.reason==="override-moved"?"override-moved":"denied",summary:`${s} refused: the policy denied ${l.refused.runs.join(", ")}`,targets:l.refused.runs,reason:l.refused.reason==="override-moved"?"an override stands for an earlier plan or other rules, so it counts for nothing":"the policy denied these runs, and no override counts for them"};if(!(a.exitCode===6&&a.outcome?.outcome==="stood-down")){if(a.exitCode===5&&a.outcome?.outcome==="held"){let u=a.outcome.holder;return{...c,event:"refused",status:"held",summary:`${s} applied nothing: another run${u?` (${u.run})`:""} holds what it changes`,targets:l?.members.map(d=>d.member)??[],reason:a.outcome.reason??`another run${u?`, ${u.run},`:""} holds what the apply changes; apply again once it is done`}}if(a.exitCode===4)return{...c,event:"refused",status:"moved",summary:`${s}${i.share!==void 0?`, share ${i.share},`:""} refused ${a.moved.length} run${a.moved.length===1?"":"s"} whose plan moved since the wave was decided`,targets:a.moved,reason:"their plans moved since the wave was decided, so they were not applied"};if(a.exitCode!==0){let u=a.hooks.filter(d=>d.outcome==="failed").map(d=>`${d.moment} hook ${d.name}${d.target?` (${d.target})`:""}`);return a.failed.length===0&&u.length>0?{...c,event:"failed",status:"failed",summary:`${s} failed: ${u.join(", ")} failed`,targets:[],reason:`${u.join(", ")} exited non-zero`}:{...c,event:"failed",status:"failed",summary:`${s} failed: ${a.failed.length>0?`${a.failed.join(", ")} did not apply`:`exit ${a.exitCode}`}`,targets:a.failed,...a.failed.length>0?{reason:`the apply command failed for ${a.failed.join(", ")}`}:{}}}}}async function aw(e,t,n,i={},r={}){if(!e.notify||ow(e.notify)!==void 0)return[];try{let o=qz(e,t,n,i);return o?await Vz(e.notify,Wz(o,{...r.env?{env:r.env}:{}}),r):[]}catch(o){return(r.log??(s=>process.stderr.write(s+`
55
+ `)))(`notify: nothing was sent: ${o instanceof Error?o.message:String(o)}`),[]}}var JO=v(()=>{"use strict";sw()});var Jz={};_e(Jz,{DEPRECATED_GATE_KEY_WARNING:()=>Kz,FAN_OUT_GATE_OP:()=>Su,OVERRIDE_GATE_OP:()=>Xs,WORKSPACE_UPGRADE_GATE_OP:()=>Eu,gateName:()=>vc,isNeverOverMcpGateOp:()=>ZO,opUsesDeprecatedGateKey:()=>Zse,usesDeprecatedGateKey:()=>YO});function ZO(e){return e===Su||e===Eu||e===Xs||Jse.test(e)}function vc(e){return e.gate??e.signalName??""}function YO(e){return e.gate===void 0&&typeof e.signalName=="string"}function Zse(e){let t=i=>i.kind==="gate"?YO(i):i.kind==="effect"?i.steps.some(t):!1,n=i=>(i??[]).some(r=>r.steps.some(t));return n(e.phases)||n(e.onFailure)}var Su,Eu,Xs,Jse,Kz,Ai=v(()=>{"use strict";Su="fan-out",Eu="workspace-upgrade",Xs="policy-override",Jse=/^pr-\d+(?:-[a-z0-9][a-z0-9-]*)?$/;Kz='Gate steps still using "signalName": the key is now "gate" (chant #2202). "signalName" is accepted through 0.59.0 and removed in 0.60.0.'});function Au(e){return typeof e=="object"&&e!==null&&Pi in e&&e[Pi]===!0}var Pi,Xo=v(()=>{"use strict";Pi=Symbol.for("chant.intrinsic")});var Zz,Qo,Pu=v(()=>{"use strict";Xo();Qo=class{constructor(t,n){this[Zz]=!0;this.parent=new WeakRef(t),this.attribute=n}_setLogicalName(t){this.logicalName=t}getLogicalName(){return this.logicalName}toString(){let t=this.logicalName?`${this.logicalName}.${this.attribute}`:`.${this.attribute}`;throw new Error(`A resource attribute reference (${t}) has no string form: it stands for a value the build resolves later, and interpolating it into a plain template literal would produce "[object Object]". Use the lexicon's own intrinsic, whose interior handles references \u2014 \`Sub\`\${\u2026}\`\` for CloudFormation \u2014 or move the reference out of the template.`)}[(Zz=Pi,Symbol.toPrimitive)](){return this.toString()}toJSON(){if(!this.logicalName)throw new Error(`Cannot serialize AttrRef for attribute "${this.attribute}": logical name not set`);return{__attrRef:{entity:this.logicalName,attribute:this.attribute}}}}});function dn(e){return e instanceof Qo?!0:typeof e=="object"&&e!==null&&"parent"in e&&"attribute"in e&&"_setLogicalName"in e&&typeof e.parent=="object"&&typeof e.attribute=="string"}function pn(e,t){return t&&typeof t=="object"&&!Array.isArray(t)?Object.fromEntries(Object.entries(t).sort(([n],[i])=>n.localeCompare(i))):t}function Yz(e){let t=[],n=e;for(let i in n)if(Object.prototype.hasOwnProperty.call(n,i)){let r=n[i];dn(r)&&t.push(i)}return t}var XO,Wt=v(()=>{"use strict";Pu();XO=Symbol.for("chant.logicalName")});function Yr(e){return e!==void 0&&Yse.has(e)}function es(){if(QO!=="cli")return QO;let e=process.env[Xse];return e==="mcp"||e==="acp"?e:QO}function Xz(e,t){if(Yr(t)&&e===t)return`the gate was reached over ${t} and this resolution arrived over ${t} too, so the same caller wrote both halves`}var Yse,cw,QO,Xse,kc=v(()=>{"use strict";Yse=new Set(["mcp","acp"]);cw="unattested",QO="cli",Xse="CHANT_GATE_ORIGIN"});var eC,Qz=v(()=>{eC={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://intentius.io/chant/schemas/workspace/declaration/v1/chant.workspace.schema.json",title:"chant.workspace.json",description:"A workspace declaration, schema 1 (#2524 D1, D2; ws-051). Only this file makes a directory a workspace. It may also be named chant.workspace.jsonc, which allows comments and trailing commas; having both is an error. Unknown fields are refused, except fields whose names start with x-. A field added later within schema 1 is optional, and a declaration that uses one sets minReader to the first chant that knows it, so an older chant says so instead of misreading the file. Uniqueness of names and the placement rules are checked in code, since JSON Schema cannot say them.",type:"object",required:["name","schema","members"],properties:{$schema:{type:"string",description:"An editor hint. chant ignores it."},$comment:{type:"string",description:"A note for people. chant ignores it."},name:{$ref:"#/$defs/name",description:"The workspace's name. With a git revision it identifies the workspace to readers (#2524 D15)."},schema:{const:1,description:"The declaration format version."},minReader:{$ref:"#/$defs/version",description:"The oldest chant that may read this declaration. An older chant refuses it with reader-too-old."},members:{type:"array",description:"Members and example groups, in the order readers list them.",items:{$ref:"#/$defs/entry"}},pins:{type:"array",description:"The toolchain and plugins that read this workspace, pinned (#2524 D3, threat model). Member kinds come only from pinned packages, read as data from their ./workspace-kinds subpath (#2535).",items:{$ref:"#/$defs/pin"}},quorum:{type:"integer",minimum:0,description:"How many agree verdicts besides the decider's a record needs, for every record kind with a reviews list (#2671). chant workspace records reports each record's quorum against it. Two when absent. Added in schema 1 by chant 0.86.0, so a declaration that sets it sets minReader to 0.86.0 or newer. A per-kind quorum comes later (#2650 C14)."},records:{type:"array",description:"The workspace's own record kinds, each a kind file relative to the workspace root (#2680): the kinds whose records belong to no one member, such as a decisions directory at the root. A member names its own in its records. chant workspace ls lists them, and chant workspace records and graph --intent read every declared kind when --kind is not given. Added in schema 1 by chant 0.86.0, so a declaration that uses it sets minReader to 0.86.0 or newer.",items:{$ref:"#/$defs/recordKind"}},hosts:{type:"array",description:"The hosts boxes run on (#2727). A host is one machine reached under one hostname: boxes on it share its ports, its state root and, in a browser, its cookie jar, so chant workspace check compares the boxes on one host and never boxes on different hosts. A member's box block names its host. Added in schema 1 by chant 0.91.0, so a declaration that uses it sets minReader to 0.91.0 or newer.",items:{$ref:"#/$defs/host"}},diagrams:{type:"array",description:"The workspace's own diagram artifacts (#2764): the diagrams that belong to no one member, such as a diagrams directory at the root. A member names its own in its diagrams. chant workspace ls lists every declared diagram, and chant workspace check reports one whose render is stale for its source when the entry records a sourceHash. Added in schema 1 by chant 0.91.0, so a declaration that uses it sets minReader to 0.91.0 or newer.",items:{$ref:"#/$defs/diagram"}},checks:{type:"object",description:"Severity for the declaration checks that allow it, keyed by WSP id (#2535, ws-028): error, warning, info or off. chant workspace check refuses an id it does not know, and one whose severity is fixed.",propertyNames:{pattern:"^WSP[0-9]{3}$"},additionalProperties:{$ref:"#/$defs/severity"}},changes:{type:"object",additionalProperties:!1,description:"The forward coverage check, chant workspace check --changes <base>..<head> (#2773): each path a diff changes is mapped to the current records whose constrains cover it. severity says what a finding does: off reports none, warn (the default) reports them and passes, fail reports them and fails. ignore lists globs over files whose changes need no record, such as lockfiles and generated output. Added in schema 1 by chant 0.92.0, so a declaration that uses it sets minReader to 0.92.0 or newer.",properties:{severity:{enum:["off","warn","fail"],description:"What a change-uncovered or change-out-of-scope finding does. warn when absent."},ignore:{type:"array",description:"Globs over file paths from the workspace root: * and ? within one segment, ** across segments. A changed path one matches is listed as ignored and never reported.",items:{$ref:"#/$defs/fileGlob"}}}},writeScope:{type:"object",propertyNames:{$ref:"#/$defs/className"},additionalProperties:{$ref:"#/$defs/classScope",description:"A domain class a pinned package supplies at its ./workspace-principals subpath (#3080, ws-079): principals holding the role the class names in the trust policy at base, and none of the agent, runner and service roles. A key no pinned package supplies fails chant workspace check with WSP003, and a writer judged human is refused with write-scope-class-unknown, since it may be in that class. Added in schema 1 by chant 0.102.0, so a declaration that uses one sets minReader to 0.102.0 or newer."},description:"Who may write what (#2524 D5, #2548, ws-067): for each principal class, the members whose files it may write and the record kinds it may write, with which verbs. A class is human, agent, runner or service, or a domain class a pinned package supplies (#3080). A class with no entry is not restricted. An agent is always bound to its session's member (agents); its entry can only narrow the record kinds and verbs. chant workspace records new, amend, review and close and the MCP record tools refuse a write outside the writer's scope with write-scope-member or write-scope-kind, and chant workspace check --changes reports each commit that writes outside its author's scope, read from the declaration and the trust policy at the range's base, and a write to a path the class's protected list covers with write-scope-protected (#3146). Added in schema 1 by chant 0.101.0, so a declaration that uses it sets minReader to 0.101.0 or newer.",properties:{human:{$ref:"#/$defs/classScope",description:"Principals holding none of the agent, runner and service roles, and none of the roles a domain class names, in the trust policy at base."},agent:{$ref:"#/$defs/agentScope",description:"An agent session (agents), or a principal holding the agent role in the trust policy at base."},runner:{$ref:"#/$defs/classScope",description:"Principals holding the runner role in the trust policy at base, such as a CI job's signing identity."},service:{$ref:"#/$defs/classScope",description:"Principals holding the service role in the trust policy at base."}}},agents:{type:"array",description:"The agent sessions the workspace declares (#2524 D20, #2548, ws-067, ws-101). Each is bound to the members it names, one with member or several with members: it writes the files of any of them and the records of kinds any of them or the workspace declares, as writeScope.agent allows. A session resumes from chant workspace agent <name> --json, which prints its member, its scope and the spec, read from the repository alone. A write names its session with the CHANT_AGENT environment variable, or a commit with a Chant-Agent trailer. Added in schema 1 by chant 0.101.0, so a declaration that uses it sets minReader to 0.101.0 or newer.",items:{$ref:"#/$defs/agent"}},identity:{type:"object",additionalProperties:!1,description:"Who a person-attributed record or gate approval may name, and which gates need a signed approval (#3163, ws-080). Read from the declaration at base, like writeScope, so a change can't loosen its own rule. A person is named by a forge identity (github:<login>, gitlab:<login>, or <forge>@<host>:<login> for forgejo, gitea or a self-hosted github or gitlab) that the surface which signed them in maps their session to, or by a principal .chant/allowed_signers lists at base. chant never authenticates a person: a forge identity is recorded as the surface gives it, and only a seal verified against the signers at base attests it. Added in schema 1 by chant 0.102.0, so a declaration that uses it sets minReader to 0.102.0 or newer.",properties:{attribution:{enum:["any","identified"],description:"any (the default): a record's by, decided_by, reviewer or answerer and a gate approval's actor may be any name, such as a roster name. identified: each must be a forge identity, a principal the signers file at base lists, or a principal holding the agent, runner or service role at base or listed by a declared agent session; chant workspace records new and review, points answer and chant approve refuse any other name with principal-unidentified."},gates:{type:"object",description:"Gates, by name, that pass only on a signed approval: chant approve --sign with a key the signers file at base lists for the approver. The rule applies to a gate of that name in every member, Op and component. An unsigned approval, or one whose signer is not in class, is recorded nowhere and never counts toward the gate.",propertyNames:{type:"string",minLength:1},additionalProperties:{type:"object",additionalProperties:!1,properties:{class:{$ref:"#/$defs/className",description:"The principal class the signer must be in, read from the role grants at base (#3080, ws-079): human, runner, service, or a domain class a pinned package supplies. A class no pinned package supplies lets no approval through (fail closed). Absent: any signer the signers file lists."}}}}}},ci:{type:"object",additionalProperties:!1,patternProperties:{"^x-":!0},description:"What the workspace's CI decides about its commits (#3573, ws-103). Added in schema 1 by chant 0.108.0, so a declaration that uses it sets minReader to 0.108.0 or newer.",properties:{green:{$ref:"#/$defs/ciGreen"}}}},patternProperties:{"^x-":!0},additionalProperties:!1,$defs:{name:{type:"string",pattern:"^[a-z0-9][a-z0-9-]{0,39}$",description:"Lowercase letters, digits and hyphens, starting with a letter or digit, at most 40 characters. _workspace and _members are reserved; the pattern already rules them out."},kindName:{type:"string",pattern:"^[a-z][a-z0-9-]{0,39}$"},className:{type:"string",pattern:"^(?!x-)[a-z][a-z0-9-]{0,39}$",description:"A principal class: human, agent, runner, service, or a domain class a pinned package supplies (#3080)."},version:{type:"string",pattern:"^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(-[0-9A-Za-z.-]+)?$"},dir:{type:"string",description:'A directory relative to the workspace root, with / separators: "." for the root itself, otherwise no leading /, no . or .. segments and no trailing /.',pattern:"^(\\.|(?!\\.\\.?(/|$))[^/\\\\]+(/(?!\\.\\.?(/|$))[^/\\\\]+)*)$"},glob:{type:"string",description:"A glob over directories, relative to the workspace root: * and ? within one segment, ** across segments, [...] classes. No leading /, no . or .. segments.",pattern:"^(?!\\.\\.?(/|$))[^/\\\\]+(/(?!\\.\\.?(/|$))[^/\\\\]+)*$"},severity:{enum:["error","warning","info","off"]},suppress:{type:"array",description:"Declaration checks suppressed for this entry (#2535). Each names a WSP id and says why. A suppressed finding is still reported, as suppressed, and never fails check.",items:{type:"object",required:["check","because"],properties:{check:{type:"string",pattern:"^WSP[0-9]{3}$"},because:{type:"string",minLength:1}},patternProperties:{"^x-":!0},additionalProperties:!1}},outputName:{type:"string",minLength:1,maxLength:255,pattern:"^[^\\u0000-\\u001f]+$",description:"An output's name, compared exactly."},link:{type:"object",description:"A member link: this member reads output of member (#2539), or sends its telemetry to a pipeline of its collector (#2558).",required:["member","output"],properties:{member:{$ref:"#/$defs/name",description:"The producer: another member of this workspace."},output:{$ref:"#/$defs/outputName",description:"The producer's output, matched exactly. It must be one the producer's kind exposes. For a telemetry link, the id of a pipeline or an exporter in the producer's collector."},kind:{$ref:"#/$defs/kindName",description:"The link kind. output, the default: the consumer reads the named output. telemetry (#2558): the consumer sends its telemetry to the named pipeline or exporter of the producer's collector, and chant workspace graph checks that it exists and, when protocol is given, that it speaks it. A declaration that uses telemetry sets minReader to 0.101.0 or newer."},protocol:{enum:["grpc","http/protobuf","http/json"],description:"For a telemetry link, the OTLP protocol the consumer sends, as OTEL_EXPORTER_OTLP_PROTOCOL names it. Refused on any other kind. Added in schema 1 by chant 0.101.0."}},patternProperties:{"^x-":!0},additionalProperties:!1},entry:{description:"A member, or an example group when kind is examples (ws-051).",type:"object",required:["kind"],properties:{kind:{$ref:"#/$defs/kindName"}},if:{type:"object",properties:{kind:{const:"examples"}},required:["kind"]},then:{$ref:"#/$defs/group"},else:{$ref:"#/$defs/member"}},member:{type:"object",description:"A member (#2524 D2). Its directory leaves the root project, and it gets its own build, lint and ledger.",required:["name","dir","kind"],properties:{name:{$ref:"#/$defs/name",description:"Frozen once the member deploys; a rename is an alias record."},dir:{$ref:"#/$defs/dir"},kind:{$ref:"#/$defs/kindName",description:"How to read the member: chant, workspace, other, or a kind a pinned plugin supplies (#2535)."},roles:{type:"array",description:"Roles the member plays. A role may point at a path inside the member.",items:{oneOf:[{$ref:"#/$defs/kindName"},{type:"object",required:["name"],properties:{name:{$ref:"#/$defs/kindName"},path:{$ref:"#/$defs/dir",description:"Relative to the member's directory."}},patternProperties:{"^x-":!0},additionalProperties:!1}]}},generated:{type:"array",description:"Files in the member's directory that a command writes (#2524 D14, #2541). chant workspace check fails when one differs from what its generator writes, unless the entry is marked handWritten with a reason. The lineage lock classes the same files as generated. skills/*/SKILL.md, which chant update writes, is listed implicitly for a chant member.",items:{$ref:"#/$defs/generatedFile"}},outputs:{type:"array",uniqueItems:!0,description:"The outputs this member exposes as link targets (#2539), for a member whose kind takes them from the entry: other, or a kind a pinned package supplies. A chant member's outputs are read from its source, and a nested workspace exposes none.",items:{$ref:"#/$defs/outputName"}},fields:{$ref:"#/$defs/memberFields"},links:{type:"array",description:"Member links (#2524 D6, #2539): the outputs of other members this member reads. A link is stated once, here on the consumer, and matched exactly against the producer's outputs. chant workspace check resolves it in source.",items:{$ref:"#/$defs/link"}},records:{type:"array",description:"The record kinds this member holds, each a kind file relative to the member's directory (#2680). chant workspace ls lists them, and chant workspace records and graph --intent read every declared kind when --kind is not given. Added in schema 1 by chant 0.86.0, so a declaration that uses it sets minReader to 0.86.0 or newer.",items:{$ref:"#/$defs/recordKind"}},diagrams:{type:"array",description:"The diagram artifacts this member holds (#2764). chant workspace ls lists every declared diagram, and chant workspace check reports one whose render is stale for its source when the entry records a sourceHash. Added in schema 1 by chant 0.91.0, so a declaration that uses it sets minReader to 0.91.0 or newer.",items:{$ref:"#/$defs/diagram"}},box:{$ref:"#/$defs/box"},upstream:{type:"string",minLength:1,description:"Where an embedded member's files come from. Versions live in the lock."},travel:{type:"boolean",description:"Whether the member goes with an export (#2524 D10, #2552). chant workspace export writes only members that set travel to true into the export member, and refuses to name one that does not. Added in schema 1 by chant 0.101.0, so a declaration that uses it sets minReader to 0.101.0 or newer."},because:{type:"string",minLength:1,description:"Why the member is there. Required for kind other."},suppress:{$ref:"#/$defs/suppress"}},patternProperties:{"^x-":!0},additionalProperties:!1,if:{type:"object",properties:{kind:{const:"other"}},required:["kind"]},then:{type:"object",properties:{because:{type:"string"}},required:["because"]}},memberFields:{type:"object",description:"Values for the fields the member's kind declares (#3151), such as an app member's scripts, env and health. Each is a string, integer or boolean, or an object of those for a field the kind declares as an object. chant workspace check fails when the kind declares no such field or a value is of the wrong type (WSP005), and chant workspace status --json prints every field the kind declares with its defaults filled in. Added in schema 1 by chant 0.103.0, so a declaration that uses it sets minReader to 0.103.0 or newer.",propertyNames:{pattern:"^[a-z][A-Za-z0-9]{0,39}$"},additionalProperties:{oneOf:[{type:"string"},{type:"integer"},{type:"boolean"},{type:"object",propertyNames:{pattern:"^[a-z][A-Za-z0-9]{0,39}$"},additionalProperties:{oneOf:[{type:"string"},{type:"integer"},{type:"boolean"}]}}]}},group:{type:"object",description:"An example group (ws-051): every directory the glob matches that holds a chant project is built and linted. A group has no ledger, releases or links, and its matches are never members. A match may sit inside a member's directory; that member leaves it to the group.",required:["name","kind","glob"],properties:{name:{$ref:"#/$defs/name"},kind:{const:"examples"},glob:{oneOf:[{$ref:"#/$defs/glob"},{type:"array",minItems:1,uniqueItems:!0,items:{$ref:"#/$defs/glob"}}]},suppress:{$ref:"#/$defs/suppress"}},patternProperties:{"^x-":!0},additionalProperties:!1},path:{type:"string",description:"A file or directory path with / separators: no leading /, no . or .. segments and no trailing /.",pattern:"^(?!\\.\\.?(/|$))[^/\\\\]+(/(?!\\.\\.?(/|$))[^/\\\\]+)*$"},box:{type:"object",description:"The member is a box, or holds a box's declarations (#2726). A box holds no credential: each capability it needs outside itself is reached through a broker, a runtime such as a lobby or a door, which holds the credential and enforces the scope. chant workspace check fails when a file in the member's directory carries a literal secret (WSP121) and when a capability names no broker (WSP122). chant workspace status --json lists the capabilities, so a broker can read the scopes. Its host, slot, ports, state and cookies state the box's isolation (#2727): chant derives each value from the box's identity, its host, the member's name and its slot, and prints them in chant workspace status --json, so a runtime reads them instead of choosing its own. chant workspace check fails when two boxes on a host resolve to the same value (WSP123) and when a box hard-codes a machine path (WSP124). A member that builds the fountain lexicon's Box declares the callback token fountain gives its persistent sandbox as the capability fountain-callback, brokered by fountain, with scope owner, or chant workspace check fails (WSP125, #2780). Its intent names the decision record that says what the box is for (#2850): chant workspace status --json reports the record's state and answer, and chant workspace check fails when no decision record has the id (WSP126) and warns when the record constrains no member or path of this workspace (WSP127, #2857). Its services list what the box runs under its supervisor (#2880), which the fly lexicon observes, restarts and applies through sprite-env, and which chant workspace status --json prints. Its factory declares what the box builds, how a build is checked, which member declares the builder agents and where a finished build is published (#3146, ws-077), its listing what the box shows of itself (#3146), and its replicate where the box's work in progress is pushed so a lost box loses none of it (#3172, ws-085). Added in schema 1 by chant 0.91.0, so a declaration that uses it sets minReader to 0.91.0 or newer.",properties:{intent:{type:"string",minLength:1,description:"The id of the decision record that says what the box is for (#2850), a record of a declared kind named decision. A new box starts as a question: the record is proposed with a null choice until the person who answers it decides it. The record constrains a member or path of this workspace, with member:<a member's name> or a path: entry at, above or inside a member's directory. It need not be this member: the intent can constrain the app the box runs when that app is another member (#2857). When it constrains this member, chant workspace graph --intent shows it for the box's files. Added by chant 0.94.0, so a declaration that uses it sets minReader to 0.94.0 or newer."},services:{type:"array",description:"The services the box runs under its supervisor, sprite-env on a sprite (#2880). Each name is given once, every needs entry names a service of this list, the needs form no cycle, and at most one service sets httpPort; a declaration that breaks one of these can't be read (declaration-invalid). The fly lexicon's spriteServicesObserve and spriteServiceRestart read the list with box: true, and spriteApplyServices with box: true creates and replaces the services through sprite-env. None when omitted. Added by chant 0.95.0, so a declaration that uses it sets minReader to 0.95.0 or newer.",items:{$ref:"#/$defs/boxService"}},factory:{$ref:"#/$defs/boxFactory"},listing:{$ref:"#/$defs/boxListing"},publisher:{type:"string",minLength:1,pattern:"\\S",description:"The command that publishes the box's work (#3165, ws-088): it applies a built work item to the box's checkout and, when factory.publish names a target, pushes it and opens the pull request, and it sends the records a person kept uncommitted. It is run from the workspace root by chant workspace box publish, split into words as a shell splits plain words (quotes group, a backslash escapes) but never given to a shell, with a JSON request on stdin; box-publish.schema.json says what it reads and prints. An orchestrator such as studio supplies it. chant workspace status --json prints it under the member's box, so a surface offers a publish only when a box names one. Added in schema 1 by chant 0.103.0, so a declaration that uses it sets minReader to 0.103.0 or newer."},replicate:{$ref:"#/$defs/boxReplicate"},ship:{$ref:"#/$defs/boxShip"},capabilities:{type:"array",description:"Each capability the box reaches outside itself, named once. None when omitted.",items:{$ref:"#/$defs/capability"}},host:{$ref:"#/$defs/name",description:"The host the box runs on, one of the top-level hosts (#2727). The box's name is the member's name."},slot:{type:"integer",minimum:0,description:"The box's number on its host (#2727). Its ports come from the slot's block of the host's range."},ports:{type:"object",description:"The ports the box listens on, each a name and its offset in the box's block (#2727). The port is the block's first port plus the offset.",propertyNames:{$ref:"#/$defs/kindName"},additionalProperties:{type:"integer",minimum:0,maximum:65534}},state:{type:"object",description:"State the box keeps outside its checkout, such as hud's identity and database, each a name and a path relative to the box's state directory (#2727). The name is usually the environment variable the runtime sets, such as HUD_IDENTITY_PATH. A path that is absolute, starts with ~ or an environment reference, or has a .. segment is a WSP124 finding.",propertyNames:{type:"string",pattern:"^[A-Za-z_][A-Za-z0-9_-]{0,63}$"},additionalProperties:{type:"string",minLength:1}},cookies:{type:"array",description:"Session cookie names the box's runtimes set, such as hud_session (#2727). A browser scopes a cookie to a host, not a port, so each resolves to <cookie>_<member name>.",uniqueItems:!0,items:{type:"string",pattern:"^[A-Za-z][A-Za-z0-9_-]{0,63}$"}}},dependentRequired:{host:["slot"],slot:["host"],ports:["host"],state:["host"],cookies:["host"]},patternProperties:{"^x-":!0},additionalProperties:!1},boxFactory:{type:"object",description:"What the box builds and how (#3146, ws-077), replacing studio's x-factory. Opt-in: a box block without it declares no factory, and nothing here is required of a workspace that doesn't build with agents (#3174). At most one box block in a declaration declares a factory. builds and builders name declared members, or the declaration can't be read (declaration-invalid). chant workspace status --json and chant workspace graph --json print it under the member's box. The factory need not build an app: builds may name any member kind, such as chant or terraform, and the check may be a plan, a lint or a conformance run. Added in schema 1 by chant 0.102.0, so a declaration that uses it sets minReader to 0.102.0 or newer.",required:["builds"],properties:{builds:{type:"array",minItems:1,uniqueItems:!0,description:"The members the factory builds, each a declared member of any kind. A work item a person asks for here constrains member:<the first>.",items:{$ref:"#/$defs/name"}},check:{description:"The command whose exit code is a build's verdict, run from the workspace root after the work item's own checks: a command, or { run, kind } saying what it is. kind is test when omitted.",oneOf:[{type:"string",minLength:1},{type:"object",required:["run"],properties:{run:{type:"string",minLength:1,description:"The command, run from the workspace root."},kind:{enum:["test","build","lint","plan","conformance"],description:"What the command is: an app's tests, a build, a lint, a lifecycle plan or a conformance run. test when omitted."}},patternProperties:{"^x-":!0},additionalProperties:!1}]},checks:{$ref:"#/$defs/path",description:"The directory, from the workspace root, where a work item's builder writes the check for its item. When omitted the orchestrator chooses, such as <the first member of builds>/checks."},builders:{$ref:"#/$defs/name",description:"The member that declares the builder agents, such as the one whose agents/ holds them. tiers says which of them builds at which tier (#3152)."},tiers:{type:"array",minItems:1,description:"Which builder agent builds at which tier (#3152, ws-094), replacing studio's studio/role and studio/tier Agent metadata. Each entry names a tier, in the vocabulary of the work kind's work.tier.tiers (#3147), and an agent the builders member declares, by its name. An entry with kinds builds only members of those kinds, so an infra builder and an app builder can share a tier; an entry without kinds builds the tier for every other kind. A tier has at most one entry without kinds and at most one per kind, tiers needs builders, and a session names a declared agent session, or the declaration can't be read (declaration-invalid). chant workspace status --json prints builderFor, the agent for each built member and tier. Added in schema 1 by chant 0.103.0, so a declaration that uses it sets minReader to 0.103.0 or newer.",items:{type:"object",required:["tier","agent"],properties:{tier:{$ref:"#/$defs/kindName",description:"The tier, such as small, medium or large: a word of the work kind's work.tier.tiers, which a work item's tier or the slice-tier decision point answers."},agent:{type:"string",minLength:1,pattern:"^[^\\u0000-\\u001f]+$",description:"The builder agent's name, as the builders member declares it (such as an Agent of the fountain lexicon in its agents/)."},kinds:{type:"array",minItems:1,uniqueItems:!0,items:{$ref:"#/$defs/kindName"},description:"The member kinds this agent builds at the tier, such as app or terraform. Without it, every kind no other entry of the tier names."},session:{$ref:"#/$defs/name",description:"The declared agent session (agents) the builder writes as, so its write scope is that session's. Optional: without it the orchestrator chooses."}},patternProperties:{"^x-":!0},additionalProperties:!1}},publish:{type:"object",description:"Where a finished build is published: its branch is pushed and a pull request opened against repo's base. The repo is the record, so an orchestrator reads this instead of being told the target in its environment.",required:["repo"],properties:{forge:{enum:["github"],description:"The forge repo is on. github when omitted."},repo:{type:"string",pattern:"^[A-Za-z0-9][A-Za-z0-9-]{0,38}/[A-Za-z0-9._-]{1,100}$",description:"The repository the pull request is opened on, as owner/name."},base:{type:"string",minLength:1,description:"The branch the pull request targets. The repository's default branch when omitted."},branchPrefix:{type:"string",minLength:1,pattern:"^[A-Za-z0-9._/-]+$",description:"What the published branch's name starts with; the work item's id follows, as in box/ and then box/work-012. chant/work/ when omitted, the work lease's own branch."},head:{type:"string",pattern:"^[A-Za-z0-9][A-Za-z0-9-]{0,38}/[A-Za-z0-9._-]{1,100}$",description:"The repository the branch is pushed to when it isn't repo, as owner/name: a fork, so the pull request comes from <head owner>:<branch>. A runtime that publishes for one contributor's fork supplies that per contributor instead (arugula-salad/studio#242); this names a fork the whole workspace publishes from."}},patternProperties:{"^x-":!0},additionalProperties:!1}},patternProperties:{"^x-":!0},additionalProperties:!1},boxListing:{type:"object",description:"What the box shows of itself on a home site that lists boxes (#3146, #3154): whether it is listed, its title and one line, and a cover image kept as a file in the repo. A box's listing is configuration, so changing it is a reviewed change (ws-074). chant workspace status --json and chant workspace graph --json print it under the member's box, with the cover's sha256. Added in schema 1 by chant 0.102.0, so a declaration that uses it sets minReader to 0.102.0 or newer.",properties:{published:{type:"boolean",description:"Whether the box is listed. true when omitted: a box is listed unless its owner takes it out."},title:{type:"string",maxLength:60,pattern:"^[^\\u0000-\\u001f\\u007f-\\u009f]*$",description:"The box's title, one line of at most 60 characters. Empty when omitted, and a reader then shows a name of its own."},line:{type:"string",maxLength:140,pattern:"^[^\\u0000-\\u001f\\u007f-\\u009f]*$",description:"One line saying what the box is, at most 140 characters. Empty when omitted."},cover:{$ref:"#/$defs/path",description:"A PNG, JPEG or WebP picture of the box, as a file from the workspace root. None when omitted."}},patternProperties:{"^x-":!0},additionalProperties:!1},boxReplicate:{type:"object",description:"Where the box's work in progress is replicated, so a box that is lost, reclaimed or corrupted before anyone commits loses nothing (#3172, ws-085). Work in progress is the work branches (chant/work/...), the kept attempts (refs/chant/kept/..., #3147), the snapshots chant workspace wip save takes of each branch's working tree, uncommitted records included (refs/chant/wip/<branch>), and the ledger branch, chant/lifecycle. chant pushes them to remote under their own names and never forces a push. Opt-in: a box block without it replicates nothing. At most one box block in a declaration declares one, or the declaration can't be read (declaration-invalid). chant workspace status --json prints it under the member's box, with every default filled in, and reports in replication how far each ref is from the remote. Added in schema 1 by chant 0.103.0, so a declaration that uses it sets minReader to 0.103.0 or newer.",properties:{remote:{type:"string",pattern:"^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$",description:"The git remote to push to, by name: the repository's own remote, such as origin, or a mirror the host adds to the box's checkout with its credential, since a box holds none (#2726). origin when omitted."},refs:{type:"array",minItems:1,uniqueItems:!0,description:"What is replicated: work (the branches under chant/work/), kept (the kept attempts under refs/chant/kept/), wip (the snapshots under refs/chant/wip/) and ledger (the chant/lifecycle branch). All four when omitted.",items:{enum:["work","kept","wip","ledger"]}},on:{type:"array",uniqueItems:!0,description:"When chant pushes on its own: save, after each chant workspace wip save, and release, after a work lease is released (chant workspace work release, or a run of an Op under a work lease ending, which is when a kept attempt is written). Both when omitted; an empty list leaves every push to chant workspace wip push. A record write never pushes, because chant's record writes never run git (ws-074).",items:{enum:["save","release"]}},every:{type:"string",pattern:"^[1-9][0-9]*(s|m|h)$",description:"How often the host runs chant workspace wip push on a schedule of its own, such as 10m, beside the pushes on save and release. chant runs no scheduler; it only states the interval. None when omitted."}},patternProperties:{"^x-":!0},additionalProperties:!1},boxShip:{type:"object",description:"How the box ships its staged work to its own site (ws-100): the people working on a box see the working tree at once, everyone else sees the last release, and a person ships. op is the Op in the box member that does it: its own steps commit the staged tree as one commit by the person shipping (named to it in CHANT_SHIP_BY) with a Chant-Record trailer for each work item it lands, then release that commit to the box's site, stopping at gate, and record the release in env's release ledger. chant runs none of it; a surface runs chant run <op> in the member's directory and approves the gate as for any Op. chant workspace status --json prints it under the member's box with the commit the site serves (the latest release in env's ledger) and what is waiting to ship (the files changed between that commit and the working tree, bookkeeping left out). Added in schema 1 by chant 0.104.0, so a declaration that uses it sets minReader to 0.104.0 or newer.",required:["op"],properties:{op:{type:"string",pattern:"^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$",description:"The name of the Op in the box member that ships, as chant run takes it."},gate:{type:"string",pattern:"^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$",description:"The gate the Op stops at for a person's approval. ship when omitted."},env:{type:"string",pattern:"^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$",description:"The environment whose release ledger, under the box member, the Op records each release in. box when omitted."},bookkeeping:{type:"array",uniqueItems:!0,description:"Path prefixes from the workspace root whose changes are bookkeeping, such as the record directories, and never count as waiting to ship. None when omitted.",items:{type:"string",minLength:1,pattern:"^(?!/)(?!.*(^|/)\\.\\.(/|$))[^\\n]+$"}}},patternProperties:{"^x-":!0},additionalProperties:!1},boxService:{type:"object",description:"A service a box runs under its supervisor (#2880).",required:["name","cmd"],properties:{name:{$ref:"#/$defs/kindName",description:"The service's name in the supervisor. Unique within the box."},cmd:{type:"string",minLength:1,description:"The command the supervisor runs (sprite-env services create --cmd). ${HOME} and other ${VAR} references are expanded from the environment of the process that applies the list, so the declaration holds no machine path."},needs:{type:"array",uniqueItems:!0,description:"Names of services of the same box that start before this one (sprite-env services create --needs).",items:{$ref:"#/$defs/kindName"}},httpPort:{$ref:"#/$defs/port",description:"The port the supervisor routes the sprite's URL to (sprite-env services create --http-port). At most one service of a box sets it."},duration:{type:"string",pattern:"^[0-9]+(\\.[0-9]+)?(ms|s|m)$",description:"How long the service must stay up after it is created or started, such as 3s (sprite-env services create --duration)."},health:{type:"string",pattern:"^https?://",description:"A URL that answers 200 while the service works. spriteServicesObserve probes it, and spriteServiceRestart waits for it after a restart. Without it, the supervisor's state decides."},optional:{type:"boolean",description:"True for a service something else creates by name, such as a site a release Op makes: spriteApplyServices creates it only when its only names it, and spriteServicesObserve skips it while the supervisor has no such service."}},patternProperties:{"^x-":!0},additionalProperties:!1},capability:{type:"object",description:"A capability a box needs and does not hold the credential for, such as inference, fountain or a third-party API (#2726).",required:["name"],properties:{name:{$ref:"#/$defs/kindName",description:"The capability, such as inference or fountain. Unique within the box."},broker:{type:"string",minLength:1,description:"What brokers the capability: the runtime that holds the credential and swaps the box's own token for it, such as lobby or door. It may name a member of this workspace, or a runtime outside it. Without it the capability is unbrokered, and chant workspace check fails with WSP122."},scope:{type:"array",uniqueItems:!0,description:"What of the box's own the broker lets it reach, which the broker enforces. For Fountain: agent (start conversations with its own agent), vault (attach its own vault), conversations and sandboxes (its own). The words are the broker's; chant records them.",items:{type:"string",minLength:1,pattern:"^[^\\u0000-\\u001f]+$"}}},patternProperties:{"^x-":!0},additionalProperties:!1},recordKind:{type:"object",description:"A record kind the workspace declares (#2680): a kind file that exports recordKind. chant workspace check fails (WSP115) when the file is missing or does not load as a record kind.",required:["kind"],properties:{kind:{$ref:"#/$defs/path",description:"The kind file, relative to the member's directory, or to the workspace root for the workspace's own records. A path is listed once across the declaration."},name:{$ref:"#/$defs/kindName",description:"The name readers show for the kind. Without it, the kind file's own recordKind.name. Unique across the declaration."}},patternProperties:{"^x-":!0},additionalProperties:!1},diagram:{type:"object",description:"A diagram artifact the workspace declares (#2764): a rendered image with a source, pinned to the renderer that made it. A mermaid or excalidraw diagram may name no render: a reader draws it from its source. chant never runs the renderer.",required:["name","title","renderer"],if:{type:"object",properties:{renderer:{type:"object",properties:{tool:{enum:["mermaid","excalidraw"]}},required:["tool"]}},required:["renderer"]},then:{type:"object",properties:{source:{$ref:"#/$defs/path"}},required:["source"]},else:{type:"object",properties:{render:{$ref:"#/$defs/path"}},required:["render"]},properties:{name:{$ref:"#/$defs/name",description:"Unique across the declaration."},title:{type:"string",minLength:1,description:"Shown above the diagram."},source:{oneOf:[{$ref:"#/$defs/path"},{type:"null"}],description:"The source file, from the workspace root, with / separators. Null for an SVG with no source. Default null."},render:{oneOf:[{$ref:"#/$defs/path"},{type:"null"}],description:"The rendered image, from the workspace root, with / separators. Required for d2 and graphviz. A mermaid or excalidraw diagram needs a source instead and may leave render out or null, from chant 0.96.0: a reader such as hud draws it from the source (an excalidraw diagram may still commit an exported SVG for docs)."},renderer:{$ref:"#/$defs/diagramRenderer"},sourceHash:{type:["string","null"],pattern:"^[0-9a-f]{64}$",description:"sha256 hex of the source's bytes when render was last produced from it, or for a mermaid or excalidraw diagram without a render, when the source was last pinned. chant workspace check compares this against the source in the tree read and reports drift (WSP133) on a mismatch; without it, or without a source, the render is never checked for drift. Default null."}},patternProperties:{"^x-":!0},additionalProperties:!1},diagramRenderer:{type:"object",description:"The renderer a diagram's render was made with. chant records the pin; it never installs or runs the renderer (ws-052).",required:["tool","version"],properties:{tool:{enum:["d2","mermaid","graphviz","excalidraw"]},version:{$ref:"#/$defs/version",description:"The exact release the render was made with, such as 0.9.0. For mermaid or excalidraw, the release of the library a reader draws the source with, such as 11.4.1."},args:{type:"array",description:'Passed before the input and output paths, in order, such as ["--layout=elk", "--theme=0", "--pad=40", "--omit-version"]. Empty when absent.',items:{type:"string"}}},patternProperties:{"^x-":!0},additionalProperties:!1},generatedFile:{type:"object",description:"One generated file of a member (#2524 D14, #2541).",required:["path","generator"],properties:{path:{$ref:"#/$defs/path",description:"The file, relative to the member's directory."},generator:{type:"string",minLength:1,description:"The command line that writes the file, run in the member's directory with the member's own node_modules/.bin first on PATH, such as chant build ci --lexicon github -o ci.yml. When it passes -o or --output with this file's path, chant workspace check --generated points that flag at a temporary file. Otherwise the generator writes in place and check restores the tree afterwards."},sources:{type:"array",description:"The files or directories the generator reads, relative to the workspace root, since a generator often reads other members.",items:{$ref:"#/$defs/path"}},handWritten:{type:"object",description:"The file is kept by hand instead of regenerated. chant workspace check reports it with the reason and never runs its generator, and the lock classes it owned.",required:["because"],properties:{because:{type:"string",minLength:1}},patternProperties:{"^x-":!0},additionalProperties:!1}},patternProperties:{"^x-":!0},additionalProperties:!1},pin:{description:"An npm package at an exact version, or a local plugin by path. integrity is a Subresource Integrity digest.",oneOf:[{type:"object",required:["package","version"],properties:{package:{type:"string",pattern:"^(@[a-z0-9-~][a-z0-9-._~]*/)?[a-z0-9-~][a-z0-9-._~]*$"},version:{$ref:"#/$defs/version"},integrity:{type:"string",pattern:"^sha(256|384|512)-[A-Za-z0-9+/]+={0,2}$"}},patternProperties:{"^x-":!0},additionalProperties:!1},{type:"object",required:["path"],properties:{path:{$ref:"#/$defs/dir"},integrity:{type:"string",pattern:"^sha(256|384|512)-[A-Za-z0-9+/]+={0,2}$"}},patternProperties:{"^x-":!0},additionalProperties:!1}]},host:{type:"object",description:"A host boxes run on (#2727).",required:["name","ports"],properties:{name:{$ref:"#/$defs/name",description:"The host's name, unique among hosts. A box block names it in host."},ports:{type:"object",description:"The TCP ports boxes on this host take theirs from. Slot n owns the block from + n * perBox to from + (n + 1) * perBox - 1, which must end at or before to.",required:["from","to","perBox"],properties:{from:{$ref:"#/$defs/port",description:"The first port of the range."},to:{$ref:"#/$defs/port",description:"The last port of the range, inclusive."},perBox:{type:"integer",minimum:1,maximum:65535,description:"How many ports each box's block holds. A box's port offsets are below it."}},additionalProperties:!1},stateRoot:{type:"string",minLength:1,description:"Where boxes on this host keep state, as an environment reference such as ${XDG_STATE_HOME}/chant/boxes, which the runtime expands on the machine. A box's state directory is <stateRoot>/<member name>. A literal machine path, such as /Users/... or anything under $HOME, is a WSP124 finding. Default ${XDG_STATE_HOME}/chant/boxes."}},patternProperties:{"^x-":!0},additionalProperties:!1},port:{type:"integer",minimum:1,maximum:65535},fileGlob:{type:"string",description:"A glob over file paths, relative to the workspace root: * and ? within one segment, ** across segments, [...] classes and {a,b} alternatives. No leading /, no . or .. segments.",pattern:"^(?!\\.\\.?(/|$))[^/\\\\]+(/(?!\\.\\.?(/|$))[^/\\\\]+)*$"},recordScope:{type:"object",description:"Record kind names, as the kind file's recordKind.name or the name the declaration gives it, each with the verbs the class may write it with: new, amend, review and close (a review session). A kind left out may not be written at all. A record file a commit deletes is never in scope.",propertyNames:{$ref:"#/$defs/kindName"},additionalProperties:{type:"array",uniqueItems:!0,items:{enum:["new","amend","review","close"]}}},protectedPath:{description:"A protected path: a glob from the workspace root, or { path, except } for a JSON file whose listed top-level keys, or the values JSON Pointers name, may still change.",oneOf:[{$ref:"#/$defs/fileGlob"},{type:"object",required:["path"],properties:{path:{$ref:"#/$defs/fileGlob"},except:{type:"array",minItems:1,uniqueItems:!0,description:"What a write may change in the JSON file: a top-level key, or, for an entry starting with /, the values a JSON Pointer matches, where a * token matches every key or array index at its level, such as /members/*/box/listing for every box's listing (#3308). A change anywhere else in the file, or to a file that doesn't parse as a JSON object before and after, is still outside the scope.",items:{type:"string",minLength:1}}},patternProperties:{"^x-":!0},additionalProperties:!1}]},classScope:{type:"object",description:"A principal class's write scope.",properties:{members:{description:"The members whose files the class may write, by name, or * for every path. Without it, every path. A path in no member is in scope only under *.",oneOf:[{const:"*"},{type:"array",uniqueItems:!0,items:{$ref:"#/$defs/name"}}]},protected:{type:"array",description:"Paths the class may not write, even inside a member it may (#3146, ws-077): each a glob from the workspace root, or { path, except } for a JSON file the class may change only in the top-level keys except names. An entry protects the files it matches and everything under a directory it matches. A record file is judged by records, not here. Added in schema 1 by chant 0.102.0, so a declaration that uses it sets minReader to 0.102.0 or newer.",items:{$ref:"#/$defs/protectedPath"}},records:{$ref:"#/$defs/recordScope",description:"The record kinds the class may write, and how. Without it, every kind in reach, with every verb. A kind a member declares is in reach when that member is; the workspace's own kinds always are."}},patternProperties:{"^x-":!0},additionalProperties:!1},agentScope:{type:"object",description:"The agent class's write scope. Its members are always the members its session is bound to, so only the record kinds and the protected paths can be set.",properties:{protected:{type:"array",description:"Paths the class may not write, even inside a member it may (#3146, ws-077): each a glob from the workspace root, or { path, except } for a JSON file the class may change only in the top-level keys except names. An entry protects the files it matches and everything under a directory it matches. A record file is judged by records, not here. Added in schema 1 by chant 0.102.0, so a declaration that uses it sets minReader to 0.102.0 or newer.",items:{$ref:"#/$defs/protectedPath"}},records:{$ref:"#/$defs/recordScope",description:"The record kinds an agent may write, and how. Without it, every kind in reach of its member, with every verb."}},patternProperties:{"^x-":!0},additionalProperties:!1},agent:{type:"object",description:"An agent session (#2548). It names its members with exactly one of member and members (ws-101).",required:["name"],oneOf:[{properties:{member:!0},required:["member"]},{properties:{members:!0},required:["members"]}],properties:{name:{$ref:"#/$defs/name",description:"The session's name, unique among agents: what CHANT_AGENT and a Chant-Agent trailer give."},member:{$ref:"#/$defs/name",description:"The one member the session is bound to. It must be a declared member, not an example group. A session bound to several names them with members instead."},members:{type:"array",minItems:1,uniqueItems:!0,items:{$ref:"#/$defs/name"},description:"The members the session is bound to, when it writes in more than one, such as a factory that builds an app and writes its evidence records in a design member (ws-101, arugula-salad/studio#402). Each must be a declared member, not an example group. The session may write the files of any of them and the records of kinds any of them or the workspace declares, and the write scope is judged against all of them together. Added in schema 1 by chant 0.105.0, so a declaration that uses it sets minReader to 0.105.0 or newer."},principals:{type:"array",uniqueItems:!0,items:{type:"string",minLength:1},description:"Principals that write only as this session: a commit attested by one, or a write whose by names one, is judged as the session. A principal is listed by one session at most."}},patternProperties:{"^x-":!0},additionalProperties:!1},ciGreen:{type:"object",description:"Which commits passed CI (#3573, ws-103). chant ci tick tags each first-parent commit of branch, within window, whose required phases all passed with ci/green/<sha>, and a green commit that later fails a required phase with ci/revoked/<sha>. Both are annotated tags made once and never moved or deleted by chant. chant ci last-green prints the newest commit with a green tag and no revoked tag.",required:["branch","phases","require"],properties:{branch:{type:"string",minLength:1,pattern:"^[^\\s~^:?*\\[\\\\]+$",description:"The branch whose commits are tagged, such as main. Only its first-parent commits count."},window:{type:"string",pattern:"^[1-9][0-9]*(m|h|d)$",description:"How far back a tick looks, by committer time, such as 24h, 90m or 7d. 24h when absent."},phases:{type:"object",minProperties:1,description:"The phases, by name. Each is a list of check-run name patterns, or { runs, skipped }. A pattern matches a check run's whole name, with * standing for any run of characters. A phase passes when every check run its patterns match finished with success, judged by each run's latest attempt.",propertyNames:{$ref:"#/$defs/ciPhaseName"},additionalProperties:{$ref:"#/$defs/ciPhase"}},require:{type:"array",minItems:1,uniqueItems:!0,description:"The phases a commit must pass to be tagged green, by name. Each must be a declared phase.",items:{$ref:"#/$defs/ciPhaseName"}}},patternProperties:{"^x-":!0},additionalProperties:!1},ciPhaseName:{type:"string",pattern:"^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$"},ciPhase:{oneOf:[{$ref:"#/$defs/ciRunPatterns"},{type:"object",required:["runs"],properties:{runs:{$ref:"#/$defs/ciRunPatterns"},skipped:{enum:["pass","fail"],description:"What a check run that finished as skipped counts as. fail (the default): it never passes. pass: it passes, for a job a path filter runs only on some commits."}},patternProperties:{"^x-":!0},additionalProperties:!1}]},ciRunPatterns:{type:"array",minItems:1,uniqueItems:!0,items:{type:"string",minLength:1,description:"A check run's name, such as lint, or a pattern with *, such as e2e (*)."}}}}});var nC={};_e(nC,{gitTop:()=>Ou,gitTree:()=>Cu,joinPath:()=>ze,resolveCommit:()=>tC,skippedDir:()=>ts,workingTree:()=>$n});import{execFileSync as nU}from"node:child_process";import{readdirSync as eae,readFileSync as eU,statSync as tU}from"node:fs";import{join as If}from"node:path";function ze(...e){return e.filter(t=>t!==""&&t!==".").join("/")}function $n(e){return{label:"",stat(t){try{let n=tU(If(e,t));return n.isDirectory()?"dir":n.isFile()?"file":void 0}catch{return}},list(t){let n;try{n=eae(If(e,t),{withFileTypes:!0})}catch{return}let i=[];for(let r of n){let o=r.isDirectory()?"dir":r.isFile()?"file":void 0;if(!o&&r.isSymbolicLink())try{let s=tU(If(e,t,r.name));o=s.isDirectory()?"dir":s.isFile()?"file":void 0}catch{}o&&i.push({name:r.name,type:o})}return i},read(t){return eU(If(e,t),"utf-8")},bytes(t){return eU(If(e,t))}}}function lw(e,t){return nU("git",t,{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","pipe"],maxBuffer:512*1024*1024})}function Ou(e){try{return lw(e,["rev-parse","--show-toplevel"]).trim()}catch{return}}function tC(e,t){if(!t.startsWith("-"))try{return lw(e,["rev-parse","--verify","--quiet",`${t}^{commit}`]).trim()}catch{return}}function Cu(e,t,n=""){let i=new Map([["","dir"]]),r=new Map([["",[]]]),o=lw(e,["ls-tree","-r","-t","-z","--full-tree",t]);for(let s of o.split("\0")){if(!s)continue;let a=s.indexOf(" "),l=s.slice(0,a).split(" ")[1],c=s.slice(a+1),u;if(n==="")u=c;else if(c.startsWith(`${n}/`))u=c.slice(n.length+1);else continue;let d=l==="tree"?"dir":l==="blob"?"file":void 0;if(!d)continue;i.set(u,d);let p=u.lastIndexOf("/"),f=p<0?"":u.slice(0,p);r.has(f)||r.set(f,[]),r.get(f).push({name:u.slice(p+1),type:d}),d==="dir"&&!r.has(u)&&r.set(u,[])}return{label:` at ${t.slice(0,8)}`,stat:s=>i.get(s),list:s=>i.get(s)==="dir"?[...r.get(s)??[]]:void 0,read(s){if(i.get(s)!=="file")throw new Error(`${s} is not a file${` at ${t.slice(0,8)}`}`);return lw(e,["cat-file","blob",`${t}:${ze(n,s)}`])},bytes(s){if(i.get(s)!=="file")throw new Error(`${s} is not a file${` at ${t.slice(0,8)}`}`);return nU("git",["cat-file","blob",`${t}:${ze(n,s)}`],{cwd:e,stdio:["ignore","pipe","pipe"],maxBuffer:512*1024*1024})}}}function ts(e){return e==="node_modules"||e.startsWith(".")}var Zt=v(()=>{"use strict"});function iU(e,t){let i=t.split("/").map(a=>a==="**"?"**":tae(a)?a:(0,rU.default)(a,{dot:!1})),r=new Set,o=a=>(e.list(a)??[]).filter(l=>l.type==="dir"&&!ts(l.name)).map(l=>l.name),s=(a,l)=>{if(l===i.length){a!==""&&r.add(a);return}let c=i[l];if(c==="**"){s(a,l+1);for(let u of o(a))s(ze(a,u),l);return}if(typeof c=="string"){let u=ze(a,c);e.stat(u)==="dir"&&s(u,l+1);return}for(let u of o(a))c(u)&&s(ze(a,u),l+1)};return s("",0),[...r].sort()}var rU,tae,oU=v(()=>{"use strict";rU=Le(_f(),1);Zt();tae=e=>!/[*?[\]{}()!+@]/.test(e)});var rC,sU=v(()=>{rC={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://intentius.io/chant/schemas/workspace/kinds/v1/workspace-kinds.schema.json",title:"workspace-kinds.json",description:"Member kinds a plugin supplies (#2524 D3, #2535, ws-031). A package publishes this file as data at its ./workspace-kinds subpath. chant reads it with the file system and never imports the package, so reading kinds never loads a lexicon.",type:"object",required:["schema","kinds"],properties:{$schema:{type:"string",description:"An editor hint. chant ignores it."},$comment:{type:"string",description:"A note for people. chant ignores it."},schema:{const:1,description:"The kinds format version."},kinds:{type:"array",minItems:1,items:{$ref:"#/$defs/kind"}}},patternProperties:{"^x-":!0},additionalProperties:!1,$defs:{kind:{type:"object",required:["name","description","precedence","probe"],properties:{name:{type:"string",pattern:"^[a-z][a-z0-9-]{0,39}$",description:"The kind's name, as a member's kind field names it. chant, workspace, other and examples are built in and can't be supplied."},description:{type:"string",minLength:1,description:"One line saying what the member's directory holds, for listings and error messages."},precedence:{type:"integer",minimum:1,maximum:999,description:"When the probes of several kinds claim one directory, the highest precedence decides. Two claiming kinds with the same highest precedence are a tie, and a tie fails. The built-in chant kind has 500 and workspace has 1000."},probe:{$ref:"#/$defs/probe"},outputs:{type:"array",uniqueItems:!0,description:"The outputs every member of this kind exposes as link targets (#2524 D6, #2539). A member entry of the kind may list more in its own outputs field. Without this field the kind exposes only what each entry lists.",items:{type:"string",minLength:1,maxLength:255,pattern:"^[^\\u0000-\\u001f]+$"}},graph:{$ref:"#/$defs/graph"},fields:{$ref:"#/$defs/fields"}},patternProperties:{"^x-":!0},additionalProperties:!1},probe:{type:"object",description:"What the probe checks in a member's directory. It runs no code. It passes when any of its clauses does, and it needs at least one.",minProperties:1,properties:{anyFile:{type:"array",minItems:1,uniqueItems:!0,description:"The directory passes when a file matching one of these names sits directly in it. A * in a name matches any run of characters, so *.tf matches every Terraform file.",items:{$ref:"#/$defs/fileName"}},anyBlock:{type:"object",description:"The directory passes when a file directly in it, whose name matches one of in, has a line opening an unlabelled block named in blocks: leading space, the name, optional space, then {. No file is parsed.",required:["in","blocks"],properties:{in:{type:"array",minItems:1,uniqueItems:!0,items:{$ref:"#/$defs/fileName"}},blocks:{type:"array",minItems:1,uniqueItems:!0,items:{type:"string",pattern:"^[A-Za-z_][A-Za-z0-9_-]{0,63}$"}}},additionalProperties:!1},anyJsonKey:{type:"object",description:"The directory passes when a file directly in it, whose name matches one of in, parses as JSON and has a value at one of pointers, each a JSON Pointer such as /scripts/start (#3151). A file that is not JSON is no evidence either way. Added by chant 0.103.0.",required:["in","pointers"],properties:{in:{type:"array",minItems:1,uniqueItems:!0,items:{$ref:"#/$defs/fileName"}},pointers:{type:"array",minItems:1,uniqueItems:!0,items:{type:"string",pattern:"^(/[^/]+)+$"}}},additionalProperties:!1}},additionalProperties:!1},fileName:{type:"string",description:"A file name, with no directory part. A * matches any run of characters.",pattern:"^(?!\\.\\.?$)[^/\\\\]+$"},graph:{type:"object",description:"How chant workspace graph reads a member of this kind (#2874). chant writes a reader project of its own outside the workspace, with a chant.config.json that declares lexicon and puts config under that lexicon's key, and runs the member's chant graph there. In every string key and value of config, {member} becomes the member's name, {dir} its absolute directory and {workspace} the absolute workspace root. Without this field a member of the kind is listed with kind-not-run.",required:["lexicon","config"],properties:{lexicon:{type:"string",pattern:"^[a-z][a-z0-9-]{0,39}$",description:"The lexicon that reads the member, by name. The package that supplies the kind must be @intentius/chant-lexicon-<lexicon>, so the lexicon chant loads is the one the declaration pins."},config:{type:"object",description:"The lexicon's config namespace for the reader project, such as terraform's roots. Placeholders are substituted; nothing else is interpreted."}},patternProperties:{"^x-":!0},additionalProperties:!1},fields:{type:"object",description:"The fields a member entry of this kind may set under its own fields block, each with a type and, optionally, a default (#3151). chant workspace check fails a member whose fields name one the kind doesn't declare or give a value of the wrong type (WSP005), and chant workspace status --json prints every declared field with the defaults filled in. Added by chant 0.103.0; an older chant can't read a kinds file that uses it.",minProperties:1,propertyNames:{$ref:"#/$defs/fieldName"},additionalProperties:{oneOf:[{$ref:"#/$defs/scalarField"},{$ref:"#/$defs/objectField"}]}},fieldName:{type:"string",pattern:"^[a-z][A-Za-z0-9]{0,39}$"},scalarField:{type:"object",required:["type","description"],properties:{type:{enum:["string","integer","boolean"]},description:{type:"string",minLength:1},default:{oneOf:[{type:"string"},{type:"integer"},{type:"boolean"}],description:"The value a member that doesn't set the field gets. Its type is the field's. Without it the field reads as null when unset."},pattern:{type:"string",minLength:1,description:"For a string field: a regular expression the value must match."}},additionalProperties:!1},objectField:{type:"object",required:["type","description","properties"],properties:{type:{const:"object"},description:{type:"string",minLength:1},properties:{type:"object",minProperties:1,propertyNames:{$ref:"#/$defs/fieldName"},additionalProperties:{$ref:"#/$defs/scalarField"},description:"The object's own fields, each a string, integer or boolean field. A member sets any of them; the rest take their defaults."}},additionalProperties:!1}}}});import{createHash as iC}from"node:crypto";import{lstatSync as rae,readdirSync as iae,readFileSync as aU}from"node:fs";import{join as cU}from"node:path";function sae(e){let t=oae.exec(e);return t?{algorithm:t[1],digest:t[2]}:void 0}function lU(e,t,n){for(let i of iae(e,{withFileTypes:!0})){let r=t===""?i.name:`${t}/${i.name}`;if(i.isSymbolicLink())throw new _u(`${r} is a symbolic link, which a pinned plugin may not contain`);i.isDirectory()?aae.has(i.name)||lU(cU(e,i.name),r,n):i.isFile()&&n.push(r)}}function cae(e){let t=[];return lU(e,"",t),t.sort((n,i)=>n<i?-1:n>i?1:0)}function lae(e,t="sha256"){let n;try{n=rae(e)}catch{throw new _u("it does not exist")}if(n.isSymbolicLink())throw new _u("it is a symbolic link, which a pinned plugin may not be");if(n.isFile())return{integrity:`${t}-${iC(t).update(aU(e)).digest("base64")}`,files:1};let i=cae(e),r=i.map(o=>`${iC(t).update(aU(cU(e,...o.split("/")))).digest("hex")} ${o}
56
+ `).join("");return{integrity:`${t}-${iC(t).update(r,"utf8").digest("base64")}`,files:i.length}}function uU(e,t,n){let i=sae(t);if(!i)return{ok:!1,message:`${n}: integrity ${JSON.stringify(t)} is not sha256-, sha384- or sha512- and a base64 digest`};let r;try{r=lae(e,i.algorithm).integrity}catch(o){if(!(o instanceof _u))throw o;return{ok:!1,message:`${n}: can't check its integrity, ${o.message}`}}return r===t?{ok:!0}:{ok:!1,message:`${n}: integrity mismatch, so nothing is read from it. The pin says ${t} and the plugin hashes to ${r}. If the change is intended, run \`chant workspace pin ${n}\` and put the value it prints in the pin; otherwise restore the plugin`}}var oae,aae,_u,dU=v(()=>{"use strict";oae=/^(sha(?:256|384|512))-([A-Za-z0-9+/]+={0,2})$/;aae=new Set(["node_modules",".git"]),_u=class extends Error{}});import{createHash as uae,createPublicKey as oC,verify as sC}from"node:crypto";function no(e){let t=e.relayedBy!==void 0?`
57
+ relayed-by ${e.relayedBy}`:"";return Buffer.from(`${e.op}
58
+ ${e.gate}
59
+ ${e.environment??""}
60
+ ${e.planDigest??""}
61
+ ${e.resolvedBy}
62
+ ${e.timestamp}${t}`,"utf-8")}function Df(e){let t=0,n=i=>{let r=i??n(4).readUInt32BE(0);if(t+r>e.length)throw new Error("the signature is truncated");return e.subarray(t,t+=r)};return n}function aC(e){return`SHA256:${pw("sha256",e).toString("base64").replace(/=+$/,"")}`}function pae(e){let t=Df(e),n=t().toString();if(n==="ssh-ed25519"||n==="sk-ssh-ed25519@openssh.com"){let i=oC({key:{kty:"OKP",crv:"Ed25519",x:Tf(t())},format:"jwk"});return{type:n,key:i,...n.startsWith("sk-")?{application:t()}:{}}}if(n.startsWith("ecdsa-sha2-")||n==="sk-ecdsa-sha2-nistp256@openssh.com"){let i=dae[t().toString()];if(!i)throw new Error(`unsupported curve in ${n}`);let r=t();if(r[0]!==4||r.length!==1+2*i.size)throw new Error("the ECDSA key is not an uncompressed point");let o=oC({key:{kty:"EC",crv:i.crv,x:Tf(r.subarray(1,1+i.size)),y:Tf(r.subarray(1+i.size))},format:"jwk"});return{type:n,key:o,ecdsa:i,...n.startsWith("sk-")?{application:t()}:{}}}if(n==="ssh-rsa"){let i=fw(t()),r=fw(t());return{type:n,key:oC({key:{kty:"RSA",e:Tf(i),n:Tf(r)},format:"jwk"})}}throw new Error(`unsupported key type ${n}`)}function Qs(e,t,n,i){try{let r=/-----BEGIN SSH SIGNATURE-----([^-]*)-----END SSH SIGNATURE-----/.exec(e)?.[1];if(r===void 0)return{ok:!1,reason:"it is not an armored ssh signature"};let o=Df(Buffer.from(r.replace(/\s+/g,""),"base64"));if(o(6).toString()!=="SSHSIG"||o(4).readUInt32BE(0)!==1)return{ok:!1,reason:"it is not an SSHSIG, version 1"};let s=o(),a=o(),l=o(),c=o().toString(),u=o();if(a.toString()!==n)return{ok:!1,reason:`it is signed in the ${a.toString()} namespace, not ${n}`};if(c!=="sha256"&&c!=="sha512")return{ok:!1,reason:`it hashes with ${c}, and only sha256 and sha512 are accepted`};if(!i.some($=>$.equals(s)))return{ok:!1,reason:"signed by a key the policy at base does not list for the approver"};let d=Buffer.concat([Buffer.from("SSHSIG"),uw(a),uw(l),uw(c),uw(pw(c,t))]),{type:p,key:f,ecdsa:g,application:h}=pae(s),b=Df(u),w=b().toString(),x=b(),k=aC(s),R=$=>$?{ok:!0,key:k}:{ok:!1,reason:"the signature does not match the signed fields"};if(p==="ssh-rsa")return w!=="rsa-sha2-256"&&w!=="rsa-sha2-512"?{ok:!1,reason:`an RSA signature of type ${w} is not accepted`}:R(sC(`sha${w.slice(9)}`,d,f,x));if(w!==p)return{ok:!1,reason:`a ${w} signature from a ${p} key`};if(h!==void 0){let $=b(1);if(!($[0]&1))return{ok:!1,reason:"the security key was not touched (the user-presence flag is unset)"};d=Buffer.concat([pw("sha256",h),$,b(4),pw("sha256",d)])}if(g){let $=Df(x),_=fw($(),g.size),T=fw($(),g.size);return R(sC(h!==void 0?"sha256":g.hash,d,{key:f,dsaEncoding:"ieee-p1363"},Buffer.concat([_,T])))}return R(sC(null,d,f,x))}catch(r){return{ok:!1,reason:r instanceof Error?r.message:String(r)}}}function pU(e){try{let t=/-----BEGIN SSH SIGNATURE-----([^-]*)-----END SSH SIGNATURE-----/.exec(e)?.[1];if(t===void 0)return null;let n=Df(Buffer.from(t.replace(/\s+/g,""),"base64"));return n(6).toString()!=="SSHSIG"||n(4).readUInt32BE(0)!==1?null:Buffer.from(n())}catch{return null}}function Nf(e,t){if(e===void 0)return!0;let n=!1;for(let i of e.split(",")){let r=i.startsWith("!"),o=r?i.slice(1):i;if(new RegExp(`^${o.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".")}$`).test(t)){if(r)return!1;n=!0}}return n}function ea(e,t){let n=`${e.signersPath} at base`;if(!e.active){let a=e.problems.length>0?`: ${e.problems.join("; ")}`:"";return`the gate is sealed, and there is no signers file (${e.signersPath}) at base ${e.base?.slice(0,12)??""}`.trim()+a}let i=`the approval of gate ${t.gate} by ${t.resolvedBy}`;if(t.seal===void 0||t.seal===null)return`${i} carries no seal`;let r=t.seal;if(typeof r!="object"||Array.isArray(r)||typeof r.signer!="string"||typeof r.signature!="string")return`the seal on ${i} is malformed: it needs signer and signature`;if(dw(r.signer)!==dw(t.resolvedBy))return`the seal on ${i} is by ${r.signer}, and its approver is ${t.resolvedBy||"empty"}`;let o=e.signers.filter(a=>dw(a.principal)===dw(t.resolvedBy)&&Nf(a.namespaces,Rn)).map(a=>Buffer.from(a.key.split(" ")[1]??"","base64"));if(o.length===0)return`${t.resolvedBy} has no key in ${n}, so the seal can't count`;let s=Qs(r.signature,no(t),Rn,o);return s.ok?null:`the seal does not verify for ${t.resolvedBy} against ${n}: ${s.reason}`}var Rn,uw,pw,Tf,fw,dae,dw,ta=v(()=>{"use strict";Rn="chant-gate";uw=e=>{let t=Buffer.from(e),n=Buffer.alloc(4);return n.writeUInt32BE(t.length),Buffer.concat([n,t])},pw=(e,t)=>uae(e).update(t).digest(),Tf=e=>e.toString("base64url"),fw=(e,t)=>{let n=e;for(;n.length>1&&n[0]===0;)n=n.subarray(1);return t===void 0||n.length>=t?n:Buffer.concat([Buffer.alloc(t-n.length),n])};dae={nistp256:{crv:"P-256",size:32,hash:"sha256"},nistp384:{crv:"P-384",size:48,hash:"sha384"},nistp521:{crv:"P-521",size:66,hash:"sha512"}};dw=e=>e.normalize("NFKC").trim().toLowerCase()});function jf(e,t,n){if(n===null)return[];let i=Iu(n);return e.filter(r=>r.role!==null&&(t[r.role]??[]).some(o=>Iu(o)===i)).map(r=>r.name)}function Tu(e,t){let{gate:n,signers:i}=e,r=e.class;if(r!==null&&!e.classes.some(l=>l.name===r))return`identity.gates.${n} names the class ${r}, which ${e.unknownClass??"no pinned package supplies"}, so no approval can show it is in that class (known classes: ${e.classes.map(l=>l.name).join(", ")})`;if(!i.active)return`gate ${n} needs a signed approval, and there is no signers file (${i.signersPath}) at base to check one against`;let o=fae(n,i,t);if(o!==null)return o;if(r===null)return null;let s=jf(e.classes,e.roles,t.resolvedBy);return(r==="human"?s.length===0:s.includes(r))?null:`${t.resolvedBy} is not in the class ${r} that gate ${n} needs: no role grant at base puts them there`}function fae(e,t,n){let i=`the approval of gate ${n.gate} by ${n.resolvedBy}`;if(n.seal===void 0||n.seal===null)return`the approval by ${n.resolvedBy} is not signed; gate ${e} needs chant approve --sign`;let r=n.seal;if(typeof r!="object"||Array.isArray(r)||typeof r.signer!="string"||typeof r.signature!="string")return`the seal on ${i} is malformed: it needs signer and signature`;if(Iu(r.signer)!==Iu(n.resolvedBy))return`the seal on ${i} is by ${r.signer}, and its approver is ${n.resolvedBy||"empty"}`;let o=`${t.signersPath} at base`,s=t.signers.filter(c=>Iu(c.principal)===Iu(n.resolvedBy));if(s.length===0)return`${n.resolvedBy} has no key in ${o}, so the seal can't count`;let a=s.filter(c=>Nf(c.namespaces,Rn)).map(c=>Buffer.from(c.key.split(" ")[1]??"","base64")),l=Qs(r.signature,no(n),Rn,a);return l.ok?null:`the seal does not verify for ${n.resolvedBy} against ${o}: ${l.reason}`}var cC,ro,Iu,xc=v(()=>{"use strict";ta();cC=["human","agent","runner","service"],ro=[{name:"human",description:"a principal holding none of the roles of another class",role:null,source:"core"},{name:"agent",description:"a principal holding the agent role, or a write naming an agent session",role:"agent",source:"core"},{name:"runner",description:"a principal holding the runner role, such as a CI job's signing identity",role:"runner",source:"core"},{name:"service",description:"a principal holding the service role",role:"service",source:"core"}],Iu=e=>e.normalize("NFKC").trim().toLowerCase()});import{existsSync as mae,readFileSync as gae,statSync as hae}from"node:fs";import{dirname as fU,join as lC,posix as yae,resolve as bae}from"node:path";function Lf(e){return t=>{try{return gae(lC(e,...t.split("/")),"utf-8")}catch{return}}}function na(e,t){for(let n=bae(t);;n=fU(n)){let i=lC(n,"node_modules",...e.split("/"));try{if(hae(i).isDirectory()&&mae(lC(i,"package.json")))return i}catch{}if(fU(n)===n)return}}function uC(e,t){let n=e.exports;if(!n||typeof n!="object"||Array.isArray(n))return;let i=n[t];if(i===void 0)return;let r=i;if(r&&typeof r=="object"&&!Array.isArray(r)){let o=r;r=o.default??o.import??o.require}return typeof r!="string"?{problem:`exports["${t}"] must name one file, as a string or a "default" condition`}:!r.startsWith("./")||!r.endsWith(".json")?{problem:`exports["${t}"] is ${r}; it must name a .json file inside the package, since chant reads plugin data as data and never runs a package's code`}:r}function kae(e,t){let n=[],i=(r,o)=>n.push(`${t}: ${r||"the principals file"} ${o}`);if(!mU(e))return i("","must be object"),n;for(let r of Object.keys(e))gU(r,["$schema","$comment","schema","classes"])&&i("",`must NOT have additional property ${r}`);for(let r of["$schema","$comment"])r in e&&typeof e[r]!="string"&&i(`/${r}`,"must be string");return"schema"in e?e.schema!==1&&i("/schema","must be equal to constant 1"):i("","must have required property 'schema'"),"classes"in e?Array.isArray(e.classes)?(e.classes.length<1&&i("/classes","must NOT have fewer than 1 items"),e.classes.forEach((r,o)=>{let s=`/classes/${o}`;if(!mU(r))return i(s,"must be object");for(let a of Object.keys(r))gU(a,["name","description","role"])&&i(s,`must NOT have additional property ${a}`);for(let a of["name","description","role"])a in r||i(s,`must have required property '${a}'`);"name"in r&&(typeof r.name!="string"||!wae.test(r.name))&&i(`${s}/name`,"must be a class name"),"description"in r&&(typeof r.description!="string"||[...r.description].length<1)&&i(`${s}/description`,"must be a non-empty string"),"role"in r&&(typeof r.role!="string"||!vae.test(r.role))&&i(`${s}/role`,"must be a role name")})):i("/classes","must be array"):i("","must have required property 'classes'"),[...new Set(n)]}function dC(e,t){let n=[],i=[],r=new Set,o=new Set;for(let s of e.classes){if(cC.includes(s.name)){n.push(`${t}: class ${s.name} is a core class and can't be supplied by a package`);continue}if(xae.has(s.role)){n.push(`${t}: class ${s.name} names the role ${s.role}, which puts a principal in the core ${s.role} class`);continue}if(r.has(s.name)){n.push(`${t}: class ${s.name} is listed twice`);continue}if(o.has(s.role)){n.push(`${t}: class ${s.name} names the role ${s.role}, which another class in the file names; a role puts a principal in one class`);continue}r.add(s.name),o.add(s.role),i.push({name:s.name,description:s.description,role:s.role,source:t})}return{classes:i,problems:n}}function pC(e,t){let n;try{n=JSON.parse(e)}catch(r){return{classes:[],problems:[`${t}: the principals file is not JSON (${r.message})`]}}let i=kae(n,t);return i.length>0?{classes:[],problems:i}:dC(n,t)}function Mf(e,t,n){let i=e("package.json");if(i===void 0)return{classes:[],problems:[`${t}: no readable package.json`]};let r;try{r=JSON.parse(i)}catch{return{classes:[],problems:[`${t}: package.json is not JSON`]}}let o=uC(r,mw);if(o===void 0)return{classes:[],problems:[]};if(typeof o!="string")return{classes:[],problems:[`${t}: ${o.problem}`]};let s=yae.normalize(o.slice(2));if(s.startsWith("../")||s==="..")return{classes:[],problems:[`${t}: exports["${mw}"] points outside the package`]};let a=e(s);return a===void 0?{classes:[],problems:[`${t}: exports["${mw}"] names ${o}, which does not exist`]}:n(a,t)}function gw(e){let t=[],n=[],i=new Map,r=new Map,o=new Set;for(let{pin:s,source:a,read:l}of e){for(let c of l.problems)t.push({pin:s,message:c});for(let c of l.classes){let u=i.get(c.name),d=r.get(c.role);if(u!==void 0||d!==void 0){if(o.add(c.name),u!==void 0)t.push({pin:s,message:`class ${c.name} is supplied by both ${u} and ${a}; a class name has one source`});else{let p=n.find(f=>f.role===c.role);o.add(p.name),t.push({pin:s,message:`class ${c.name} (${a}) names the role ${c.role}, which class ${p.name} (${d}) names; a role puts a principal in one class`})}continue}i.set(c.name,a),r.set(c.role,a),n.push(c)}}return{classes:n.filter(s=>!o.has(s.name)),problems:t}}var mw,wae,vae,mU,gU,xae,Du=v(()=>{"use strict";xc();mw="./workspace-principals";wae=/^(?!x-)[a-z][a-z0-9-]{0,39}$/u,vae=/^[a-z][a-z0-9-]*$/u,mU=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),gU=(e,t)=>!t.includes(e)&&!e.startsWith("x-");xae=new Set(ro.map(e=>e.role).filter(e=>e!==null))});var Gf=ie(lt=>{"use strict";Object.defineProperty(lt,"__esModule",{value:!0});lt.regexpCode=lt.getEsmExportName=lt.getProperty=lt.safeStringify=lt.stringify=lt.strConcat=lt.addCodeArg=lt.str=lt._=lt.nil=lt._Code=lt.Name=lt.IDENTIFIER=lt._CodeOrName=void 0;var Ff=class{};lt._CodeOrName=Ff;lt.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var $c=class extends Ff{constructor(t){if(super(),!lt.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};lt.Name=$c;var Xr=class extends Ff{constructor(t){super(),this._items=typeof t=="string"?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;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((n,i)=>`${n}${i}`,"")}get names(){var t;return(t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((n,i)=>(i instanceof $c&&(n[i.str]=(n[i.str]||0)+1),n),{})}};lt._Code=Xr;lt.nil=new Xr("");function hU(e,...t){let n=[e[0]],i=0;for(;i<t.length;)mC(n,t[i]),n.push(e[++i]);return new Xr(n)}lt._=hU;var fC=new Xr("+");function yU(e,...t){let n=[Bf(e[0])],i=0;for(;i<t.length;)n.push(fC),mC(n,t[i]),n.push(fC,Bf(e[++i]));return $ae(n),new Xr(n)}lt.str=yU;function mC(e,t){t instanceof Xr?e.push(...t._items):t instanceof $c?e.push(t):e.push(Eae(t))}lt.addCodeArg=mC;function $ae(e){let t=1;for(;t<e.length-1;){if(e[t]===fC){let n=Rae(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]="+"}t++}}function Rae(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof $c||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 $c))return`"${e}${t.slice(1)}`}function Sae(e,t){return t.emptyStr()?e:e.emptyStr()?t:yU`${e}${t}`}lt.strConcat=Sae;function Eae(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:Bf(Array.isArray(e)?e.join(","):e)}function Aae(e){return new Xr(Bf(e))}lt.stringify=Aae;function Bf(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}lt.safeStringify=Bf;function Pae(e){return typeof e=="string"&&lt.IDENTIFIER.test(e)?new Xr(`.${e}`):hU`[${e}]`}lt.getProperty=Pae;function Oae(e){if(typeof e=="string"&&lt.IDENTIFIER.test(e))return new Xr(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}lt.getEsmExportName=Oae;function Cae(e){return new Xr(e.toString())}lt.regexpCode=Cae});var yC=ie(br=>{"use strict";Object.defineProperty(br,"__esModule",{value:!0});br.ValueScope=br.ValueScopeName=br.Scope=br.varKinds=br.UsedValueState=void 0;var yr=Gf(),gC=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}},hw;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(hw||(br.UsedValueState=hw={}));br.varKinds={const:new yr.Name("const"),let:new yr.Name("let"),var:new yr.Name("var")};var yw=class{constructor({prefixes:t,parent:n}={}){this._names={},this._prefixes=t,this._parent=n}toName(t){return t instanceof yr.Name?t:this.name(t)}name(t){return new yr.Name(this._newName(t))}_newName(t){let n=this._names[t]||this._nameGroup(t);return`${t}${n.index++}`}_nameGroup(t){var n,i;if(!((i=(n=this._parent)===null||n===void 0?void 0:n._prefixes)===null||i===void 0)&&i.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}}};br.Scope=yw;var bw=class extends yr.Name{constructor(t,n){super(n),this.prefix=t}setValue(t,{property:n,itemIndex:i}){this.value=t,this.scopePath=(0,yr._)`.${new yr.Name(n)}[${i}]`}};br.ValueScopeName=bw;var _ae=(0,yr._)`\n`,hC=class extends yw{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?_ae:yr.nil}}get(){return this._scope}name(t){return new bw(t,this._newName(t))}value(t,n){var i;if(n.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let r=this.toName(t),{prefix:o}=r,s=(i=n.key)!==null&&i!==void 0?i:n.ref,a=this._values[o];if(a){let u=a.get(s);if(u)return u}else a=this._values[o]=new Map;a.set(s,r);let l=this._scope[o]||(this._scope[o]=[]),c=l.length;return l[c]=n.ref,r.setValue(n,{property:o,itemIndex:c}),r}getValue(t,n){let i=this._values[t];if(i)return i.get(n)}scopeRefs(t,n=this._values){return this._reduceValues(n,i=>{if(i.scopePath===void 0)throw new Error(`CodeGen: name "${i}" has no value`);return(0,yr._)`${t}${i.scopePath}`})}scopeCode(t=this._values,n,i){return this._reduceValues(t,r=>{if(r.value===void 0)throw new Error(`CodeGen: name "${r}" has no value`);return r.value.code},n,i)}_reduceValues(t,n,i={},r){let o=yr.nil;for(let s in t){let a=t[s];if(!a)continue;let l=i[s]=i[s]||new Map;a.forEach(c=>{if(l.has(c))return;l.set(c,hw.Started);let u=n(c);if(u){let d=this.opts.es5?br.varKinds.var:br.varKinds.const;o=(0,yr._)`${o}${d} ${c} = ${u};${this.opts._n}`}else if(u=r?.(c))o=(0,yr._)`${o}${u}${this.opts._n}`;else throw new gC(c);l.set(c,hw.Completed)})}return o}};br.ValueScope=hC});var Fe=ie(Ze=>{"use strict";Object.defineProperty(Ze,"__esModule",{value:!0});Ze.or=Ze.and=Ze.not=Ze.CodeGen=Ze.operators=Ze.varKinds=Ze.ValueScopeName=Ze.ValueScope=Ze.Scope=Ze.Name=Ze.regexpCode=Ze.stringify=Ze.getProperty=Ze.nil=Ze.strConcat=Ze.str=Ze._=void 0;var rt=Gf(),Oi=yC(),ra=Gf();Object.defineProperty(Ze,"_",{enumerable:!0,get:function(){return ra._}});Object.defineProperty(Ze,"str",{enumerable:!0,get:function(){return ra.str}});Object.defineProperty(Ze,"strConcat",{enumerable:!0,get:function(){return ra.strConcat}});Object.defineProperty(Ze,"nil",{enumerable:!0,get:function(){return ra.nil}});Object.defineProperty(Ze,"getProperty",{enumerable:!0,get:function(){return ra.getProperty}});Object.defineProperty(Ze,"stringify",{enumerable:!0,get:function(){return ra.stringify}});Object.defineProperty(Ze,"regexpCode",{enumerable:!0,get:function(){return ra.regexpCode}});Object.defineProperty(Ze,"Name",{enumerable:!0,get:function(){return ra.Name}});var xw=yC();Object.defineProperty(Ze,"Scope",{enumerable:!0,get:function(){return xw.Scope}});Object.defineProperty(Ze,"ValueScope",{enumerable:!0,get:function(){return xw.ValueScope}});Object.defineProperty(Ze,"ValueScopeName",{enumerable:!0,get:function(){return xw.ValueScopeName}});Object.defineProperty(Ze,"varKinds",{enumerable:!0,get:function(){return xw.varKinds}});Ze.operators={GT:new rt._Code(">"),GTE:new rt._Code(">="),LT:new rt._Code("<"),LTE:new rt._Code("<="),EQ:new rt._Code("==="),NEQ:new rt._Code("!=="),NOT:new rt._Code("!"),OR:new rt._Code("||"),AND:new rt._Code("&&"),ADD:new rt._Code("+")};var ns=class{optimizeNodes(){return this}optimizeNames(t,n){return this}},bC=class extends ns{constructor(t,n,i){super(),this.varKind=t,this.name=n,this.rhs=i}render({es5:t,_n:n}){let i=t?Oi.varKinds.var:this.varKind,r=this.rhs===void 0?"":` = ${this.rhs}`;return`${i} ${this.name}${r};`+n}optimizeNames(t,n){if(t[this.name.str])return this.rhs&&(this.rhs=ju(this.rhs,t,n)),this}get names(){return this.rhs instanceof rt._CodeOrName?this.rhs.names:{}}},ww=class extends ns{constructor(t,n,i){super(),this.lhs=t,this.rhs=n,this.sideEffects=i}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,n){if(!(this.lhs instanceof rt.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=ju(this.rhs,t,n),this}get names(){let t=this.lhs instanceof rt.Name?{}:{...this.lhs.names};return kw(t,this.rhs)}},wC=class extends ww{constructor(t,n,i,r){super(t,i,r),this.op=n}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},vC=class extends ns{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},kC=class extends ns{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},xC=class extends ns{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},$C=class extends ns{constructor(t){super(),this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,n){return this.code=ju(this.code,t,n),this}get names(){return this.code instanceof rt._CodeOrName?this.code.names:{}}},Wf=class extends ns{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce((n,i)=>n+i.render(t),"")}optimizeNodes(){let{nodes:t}=this,n=t.length;for(;n--;){let i=t[n].optimizeNodes();Array.isArray(i)?t.splice(n,1,...i):i?t[n]=i:t.splice(n,1)}return t.length>0?this:void 0}optimizeNames(t,n){let{nodes:i}=this,r=i.length;for(;r--;){let o=i[r];o.optimizeNames(t,n)||(Iae(t,o.names),i.splice(r,1))}return i.length>0?this:void 0}get names(){return this.nodes.reduce((t,n)=>Ec(t,n.names),{})}},rs=class extends Wf{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},RC=class extends Wf{},Nu=class extends rs{};Nu.kind="else";var Rc=class e extends rs{constructor(t,n){super(n),this.condition=t}render(t){let n=`if(${this.condition})`+super.render(t);return this.else&&(n+="else "+this.else.render(t)),n}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let i=n.optimizeNodes();n=this.else=Array.isArray(i)?new Nu(i):i}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(bU(t),n instanceof e?[n]:n.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(t,n){var i;if(this.else=(i=this.else)===null||i===void 0?void 0:i.optimizeNames(t,n),!!(super.optimizeNames(t,n)||this.else))return this.condition=ju(this.condition,t,n),this}get names(){let t=super.names;return kw(t,this.condition),this.else&&Ec(t,this.else.names),t}};Rc.kind="if";var Sc=class extends rs{};Sc.kind="for";var SC=class extends Sc{constructor(t){super(),this.iteration=t}render(t){return`for(${this.iteration})`+super.render(t)}optimizeNames(t,n){if(super.optimizeNames(t,n))return this.iteration=ju(this.iteration,t,n),this}get names(){return Ec(super.names,this.iteration.names)}},EC=class extends Sc{constructor(t,n,i,r){super(),this.varKind=t,this.name=n,this.from=i,this.to=r}render(t){let n=t.es5?Oi.varKinds.var:this.varKind,{name:i,from:r,to:o}=this;return`for(${n} ${i}=${r}; ${i}<${o}; ${i}++)`+super.render(t)}get names(){let t=kw(super.names,this.from);return kw(t,this.to)}},vw=class extends Sc{constructor(t,n,i,r){super(),this.loop=t,this.varKind=n,this.name=i,this.iterable=r}render(t){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,n){if(super.optimizeNames(t,n))return this.iterable=ju(this.iterable,t,n),this}get names(){return Ec(super.names,this.iterable.names)}},zf=class extends rs{constructor(t,n,i){super(),this.name=t,this.args=n,this.async=i}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};zf.kind="func";var Uf=class extends Wf{render(t){return"return "+super.render(t)}};Uf.kind="return";var AC=class extends rs{render(t){let n="try"+super.render(t);return this.catch&&(n+=this.catch.render(t)),this.finally&&(n+=this.finally.render(t)),n}optimizeNodes(){var t,n;return super.optimizeNodes(),(t=this.catch)===null||t===void 0||t.optimizeNodes(),(n=this.finally)===null||n===void 0||n.optimizeNodes(),this}optimizeNames(t,n){var i,r;return super.optimizeNames(t,n),(i=this.catch)===null||i===void 0||i.optimizeNames(t,n),(r=this.finally)===null||r===void 0||r.optimizeNames(t,n),this}get names(){let t=super.names;return this.catch&&Ec(t,this.catch.names),this.finally&&Ec(t,this.finally.names),t}},Hf=class extends rs{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};Hf.kind="catch";var Vf=class extends rs{render(t){return"finally"+super.render(t)}};Vf.kind="finally";var PC=class{constructor(t,n={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...n,_n:n.lines?`
63
+ `:""},this._extScope=t,this._scope=new Oi.Scope({parent:t}),this._nodes=[new RC]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,n){let i=this._extScope.value(t,n);return(this._values[i.prefix]||(this._values[i.prefix]=new Set)).add(i),i}getScopeValue(t,n){return this._extScope.getValue(t,n)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,n,i,r){let o=this._scope.toName(n);return i!==void 0&&r&&(this._constants[o.str]=i),this._leafNode(new bC(t,o,i)),o}const(t,n,i){return this._def(Oi.varKinds.const,t,n,i)}let(t,n,i){return this._def(Oi.varKinds.let,t,n,i)}var(t,n,i){return this._def(Oi.varKinds.var,t,n,i)}assign(t,n,i){return this._leafNode(new ww(t,n,i))}add(t,n){return this._leafNode(new wC(t,Ze.operators.ADD,n))}code(t){return typeof t=="function"?t():t!==rt.nil&&this._leafNode(new $C(t)),this}object(...t){let n=["{"];for(let[i,r]of t)n.length>1&&n.push(","),n.push(i),(i!==r||this.opts.es5)&&(n.push(":"),(0,rt.addCodeArg)(n,r));return n.push("}"),new rt._Code(n)}if(t,n,i){if(this._blockNode(new Rc(t)),n&&i)this.code(n).else().code(i).endIf();else if(n)this.code(n).endIf();else if(i)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new Rc(t))}else(){return this._elseNode(new Nu)}endIf(){return this._endBlockNode(Rc,Nu)}_for(t,n){return this._blockNode(t),n&&this.code(n).endFor(),this}for(t,n){return this._for(new SC(t),n)}forRange(t,n,i,r,o=this.opts.es5?Oi.varKinds.var:Oi.varKinds.let){let s=this._scope.toName(t);return this._for(new EC(o,s,n,i),()=>r(s))}forOf(t,n,i,r=Oi.varKinds.const){let o=this._scope.toName(t);if(this.opts.es5){let s=n instanceof rt.Name?n:this.var("_arr",n);return this.forRange("_i",0,(0,rt._)`${s}.length`,a=>{this.var(o,(0,rt._)`${s}[${a}]`),i(o)})}return this._for(new vw("of",r,o,n),()=>i(o))}forIn(t,n,i,r=this.opts.es5?Oi.varKinds.var:Oi.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,rt._)`Object.keys(${n})`,i);let o=this._scope.toName(t);return this._for(new vw("in",r,o,n),()=>i(o))}endFor(){return this._endBlockNode(Sc)}label(t){return this._leafNode(new vC(t))}break(t){return this._leafNode(new kC(t))}return(t){let n=new Uf;if(this._blockNode(n),this.code(t),n.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(Uf)}try(t,n,i){if(!n&&!i)throw new Error('CodeGen: "try" without "catch" and "finally"');let r=new AC;if(this._blockNode(r),this.code(t),n){let o=this.name("e");this._currNode=r.catch=new Hf(o),n(o)}return i&&(this._currNode=r.finally=new Vf,this.code(i)),this._endBlockNode(Hf,Vf)}throw(t){return this._leafNode(new xC(t))}block(t,n){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(n),this}endBlock(t){let n=this._blockStarts.pop();if(n===void 0)throw new Error("CodeGen: not in self-balancing block");let i=this._nodes.length-n;if(i<0||t!==void 0&&i!==t)throw new Error(`CodeGen: wrong number of nodes: ${i} vs ${t} expected`);return this._nodes.length=n,this}func(t,n=rt.nil,i,r){return this._blockNode(new zf(t,n,i)),r&&this.code(r).endFunc(),this}endFunc(){return this._endBlockNode(zf)}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,n){let i=this._currNode;if(i instanceof t||n&&i instanceof n)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${n?`${t.kind}/${n.kind}`:t.kind}"`)}_elseNode(t){let n=this._currNode;if(!(n instanceof Rc))throw new Error('CodeGen: "else" without "if"');return this._currNode=n.else=t,this}get _root(){return this._nodes[0]}get _currNode(){let t=this._nodes;return t[t.length-1]}set _currNode(t){let n=this._nodes;n[n.length-1]=t}};Ze.CodeGen=PC;function Ec(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function kw(e,t){return t instanceof rt._CodeOrName?Ec(e,t.names):e}function ju(e,t,n){if(e instanceof rt.Name)return i(e);if(!r(e))return e;return new rt._Code(e._items.reduce((o,s)=>(s instanceof rt.Name&&(s=i(s)),s instanceof rt._Code?o.push(...s._items):o.push(s),o),[]));function i(o){let s=n[o.str];return s===void 0||t[o.str]!==1?o:(delete t[o.str],s)}function r(o){return o instanceof rt._Code&&o._items.some(s=>s instanceof rt.Name&&t[s.str]===1&&n[s.str]!==void 0)}}function Iae(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function bU(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,rt._)`!${OC(e)}`}Ze.not=bU;var Tae=wU(Ze.operators.AND);function Dae(...e){return e.reduce(Tae)}Ze.and=Dae;var Nae=wU(Ze.operators.OR);function jae(...e){return e.reduce(Nae)}Ze.or=jae;function wU(e){return(t,n)=>t===rt.nil?n:n===rt.nil?t:(0,rt._)`${OC(t)} ${e} ${OC(n)}`}function OC(e){return e instanceof rt.Name?e:(0,rt._)`(${e})`}});var Xe=ie(Ye=>{"use strict";Object.defineProperty(Ye,"__esModule",{value:!0});Ye.checkStrictMode=Ye.getErrorPath=Ye.Type=Ye.useFunc=Ye.setEvaluated=Ye.evaluatedPropsToName=Ye.mergeEvaluated=Ye.eachItem=Ye.unescapeJsonPointer=Ye.escapeJsonPointer=Ye.escapeFragment=Ye.unescapeFragment=Ye.schemaRefOrVal=Ye.schemaHasRulesButRef=Ye.schemaHasRules=Ye.checkUnknownRules=Ye.alwaysValidSchema=Ye.toHash=void 0;var At=Fe(),Lae=Gf();function Mae(e){let t={};for(let n of e)t[n]=!0;return t}Ye.toHash=Mae;function Fae(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(xU(e,t),!$U(t,e.self.RULES.all))}Ye.alwaysValidSchema=Fae;function xU(e,t=e.schema){let{opts:n,self:i}=e;if(!n.strictSchema||typeof t=="boolean")return;let r=i.RULES.keywords;for(let o in t)r[o]||EU(e,`unknown keyword: "${o}"`)}Ye.checkUnknownRules=xU;function $U(e,t){if(typeof e=="boolean")return!e;for(let n in e)if(t[n])return!0;return!1}Ye.schemaHasRules=$U;function Bae(e,t){if(typeof e=="boolean")return!e;for(let n in e)if(n!=="$ref"&&t.all[n])return!0;return!1}Ye.schemaHasRulesButRef=Bae;function Gae({topSchemaRef:e,schemaPath:t},n,i,r){if(!r){if(typeof n=="number"||typeof n=="boolean")return n;if(typeof n=="string")return(0,At._)`${n}`}return(0,At._)`${e}${t}${(0,At.getProperty)(i)}`}Ye.schemaRefOrVal=Gae;function Wae(e){return RU(decodeURIComponent(e))}Ye.unescapeFragment=Wae;function zae(e){return encodeURIComponent(_C(e))}Ye.escapeFragment=zae;function _C(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}Ye.escapeJsonPointer=_C;function RU(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}Ye.unescapeJsonPointer=RU;function Uae(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}Ye.eachItem=Uae;function vU({mergeNames:e,mergeToName:t,mergeValues:n,resultToName:i}){return(r,o,s,a)=>{let l=s===void 0?o:s instanceof At.Name?(o instanceof At.Name?e(r,o,s):t(r,o,s),s):o instanceof At.Name?(t(r,s,o),o):n(o,s);return a===At.Name&&!(l instanceof At.Name)?i(r,l):l}}Ye.mergeEvaluated={props:vU({mergeNames:(e,t,n)=>e.if((0,At._)`${n} !== true && ${t} !== undefined`,()=>{e.if((0,At._)`${t} === true`,()=>e.assign(n,!0),()=>e.assign(n,(0,At._)`${n} || {}`).code((0,At._)`Object.assign(${n}, ${t})`))}),mergeToName:(e,t,n)=>e.if((0,At._)`${n} !== true`,()=>{t===!0?e.assign(n,!0):(e.assign(n,(0,At._)`${n} || {}`),IC(e,n,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:SU}),items:vU({mergeNames:(e,t,n)=>e.if((0,At._)`${n} !== true && ${t} !== undefined`,()=>e.assign(n,(0,At._)`${t} === true ? true : ${n} > ${t} ? ${n} : ${t}`)),mergeToName:(e,t,n)=>e.if((0,At._)`${n} !== true`,()=>e.assign(n,t===!0?!0:(0,At._)`${n} > ${t} ? ${n} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function SU(e,t){if(t===!0)return e.var("props",!0);let n=e.var("props",(0,At._)`{}`);return t!==void 0&&IC(e,n,t),n}Ye.evaluatedPropsToName=SU;function IC(e,t,n){Object.keys(n).forEach(i=>e.assign((0,At._)`${t}${(0,At.getProperty)(i)}`,!0))}Ye.setEvaluated=IC;var kU={};function Hae(e,t){return e.scopeValue("func",{ref:t,code:kU[t.code]||(kU[t.code]=new Lae._Code(t.code))})}Ye.useFunc=Hae;var CC;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(CC||(Ye.Type=CC={}));function Vae(e,t,n){if(e instanceof At.Name){let i=t===CC.Num;return n?i?(0,At._)`"[" + ${e} + "]"`:(0,At._)`"['" + ${e} + "']"`:i?(0,At._)`"/" + ${e}`:(0,At._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return n?(0,At.getProperty)(e).toString():"/"+_C(e)}Ye.getErrorPath=Vae;function EU(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,n===!0)throw new Error(t);e.self.logger.warn(t)}}Ye.checkStrictMode=EU});var Qr=ie(TC=>{"use strict";Object.defineProperty(TC,"__esModule",{value:!0});var Fn=Fe(),qae={data:new Fn.Name("data"),valCxt:new Fn.Name("valCxt"),instancePath:new Fn.Name("instancePath"),parentData:new Fn.Name("parentData"),parentDataProperty:new Fn.Name("parentDataProperty"),rootData:new Fn.Name("rootData"),dynamicAnchors:new Fn.Name("dynamicAnchors"),vErrors:new Fn.Name("vErrors"),errors:new Fn.Name("errors"),this:new Fn.Name("this"),self:new Fn.Name("self"),scope:new Fn.Name("scope"),json:new Fn.Name("json"),jsonPos:new Fn.Name("jsonPos"),jsonLen:new Fn.Name("jsonLen"),jsonPart:new Fn.Name("jsonPart")};TC.default=qae});var qf=ie(Bn=>{"use strict";Object.defineProperty(Bn,"__esModule",{value:!0});Bn.extendErrors=Bn.resetErrorsCount=Bn.reportExtraError=Bn.reportError=Bn.keyword$DataError=Bn.keywordError=void 0;var st=Fe(),$w=Xe(),Xn=Qr();Bn.keywordError={message:({keyword:e})=>(0,st.str)`must pass "${e}" keyword validation`};Bn.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,st.str)`"${e}" keyword must be ${t} ($data)`:(0,st.str)`"${e}" keyword is invalid ($data)`};function Kae(e,t=Bn.keywordError,n,i){let{it:r}=e,{gen:o,compositeRule:s,allErrors:a}=r,l=OU(e,t,n);i??(s||a)?AU(o,l):PU(r,(0,st._)`[${l}]`)}Bn.reportError=Kae;function Jae(e,t=Bn.keywordError,n){let{it:i}=e,{gen:r,compositeRule:o,allErrors:s}=i,a=OU(e,t,n);AU(r,a),o||s||PU(i,Xn.default.vErrors)}Bn.reportExtraError=Jae;function Zae(e,t){e.assign(Xn.default.errors,t),e.if((0,st._)`${Xn.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,st._)`${Xn.default.vErrors}.length`,t),()=>e.assign(Xn.default.vErrors,null)))}Bn.resetErrorsCount=Zae;function Yae({gen:e,keyword:t,schemaValue:n,data:i,errsCount:r,it:o}){if(r===void 0)throw new Error("ajv implementation error");let s=e.name("err");e.forRange("i",r,Xn.default.errors,a=>{e.const(s,(0,st._)`${Xn.default.vErrors}[${a}]`),e.if((0,st._)`${s}.instancePath === undefined`,()=>e.assign((0,st._)`${s}.instancePath`,(0,st.strConcat)(Xn.default.instancePath,o.errorPath))),e.assign((0,st._)`${s}.schemaPath`,(0,st.str)`${o.errSchemaPath}/${t}`),o.opts.verbose&&(e.assign((0,st._)`${s}.schema`,n),e.assign((0,st._)`${s}.data`,i))})}Bn.extendErrors=Yae;function AU(e,t){let n=e.const("err",t);e.if((0,st._)`${Xn.default.vErrors} === null`,()=>e.assign(Xn.default.vErrors,(0,st._)`[${n}]`),(0,st._)`${Xn.default.vErrors}.push(${n})`),e.code((0,st._)`${Xn.default.errors}++`)}function PU(e,t){let{gen:n,validateName:i,schemaEnv:r}=e;r.$async?n.throw((0,st._)`new ${e.ValidationError}(${t})`):(n.assign((0,st._)`${i}.errors`,t),n.return(!1))}var Ac={keyword:new st.Name("keyword"),schemaPath:new st.Name("schemaPath"),params:new st.Name("params"),propertyName:new st.Name("propertyName"),message:new st.Name("message"),schema:new st.Name("schema"),parentSchema:new st.Name("parentSchema")};function OU(e,t,n){let{createErrors:i}=e.it;return i===!1?(0,st._)`{}`:Xae(e,t,n)}function Xae(e,t,n={}){let{gen:i,it:r}=e,o=[Qae(r,n),ece(e,n)];return tce(e,t,o),i.object(...o)}function Qae({errorPath:e},{instancePath:t}){let n=t?(0,st.str)`${e}${(0,$w.getErrorPath)(t,$w.Type.Str)}`:e;return[Xn.default.instancePath,(0,st.strConcat)(Xn.default.instancePath,n)]}function ece({keyword:e,it:{errSchemaPath:t}},{schemaPath:n,parentSchema:i}){let r=i?t:(0,st.str)`${t}/${e}`;return n&&(r=(0,st.str)`${r}${(0,$w.getErrorPath)(n,$w.Type.Str)}`),[Ac.schemaPath,r]}function tce(e,{params:t,message:n},i){let{keyword:r,data:o,schemaValue:s,it:a}=e,{opts:l,propertyName:c,topSchemaRef:u,schemaPath:d}=a;i.push([Ac.keyword,r],[Ac.params,typeof t=="function"?t(e):t||(0,st._)`{}`]),l.messages&&i.push([Ac.message,typeof n=="function"?n(e):n]),l.verbose&&i.push([Ac.schema,s],[Ac.parentSchema,(0,st._)`${u}${d}`],[Xn.default.data,o]),c&&i.push([Ac.propertyName,c])}});var _U=ie(Lu=>{"use strict";Object.defineProperty(Lu,"__esModule",{value:!0});Lu.boolOrEmptySchema=Lu.topBoolOrEmptySchema=void 0;var nce=qf(),rce=Fe(),ice=Qr(),oce={message:"boolean schema is false"};function sce(e){let{gen:t,schema:n,validateName:i}=e;n===!1?CU(e,!1):typeof n=="object"&&n.$async===!0?t.return(ice.default.data):(t.assign((0,rce._)`${i}.errors`,null),t.return(!0))}Lu.topBoolOrEmptySchema=sce;function ace(e,t){let{gen:n,schema:i}=e;i===!1?(n.var(t,!1),CU(e)):n.var(t,!0)}Lu.boolOrEmptySchema=ace;function CU(e,t){let{gen:n,data:i}=e,r={gen:n,keyword:"false schema",data:i,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,nce.reportError)(r,oce,void 0,t)}});var DC=ie(Mu=>{"use strict";Object.defineProperty(Mu,"__esModule",{value:!0});Mu.getRules=Mu.isJSONType=void 0;var cce=["string","number","integer","boolean","null","object","array"],lce=new Set(cce);function uce(e){return typeof e=="string"&&lce.has(e)}Mu.isJSONType=uce;function dce(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}Mu.getRules=dce});var NC=ie(ia=>{"use strict";Object.defineProperty(ia,"__esModule",{value:!0});ia.shouldUseRule=ia.shouldUseGroup=ia.schemaHasRulesForType=void 0;function pce({schema:e,self:t},n){let i=t.RULES.types[n];return i&&i!==!0&&IU(e,i)}ia.schemaHasRulesForType=pce;function IU(e,t){return t.rules.some(n=>TU(e,n))}ia.shouldUseGroup=IU;function TU(e,t){var n;return e[t.keyword]!==void 0||((n=t.definition.implements)===null||n===void 0?void 0:n.some(i=>e[i]!==void 0))}ia.shouldUseRule=TU});var Kf=ie(Gn=>{"use strict";Object.defineProperty(Gn,"__esModule",{value:!0});Gn.reportTypeError=Gn.checkDataTypes=Gn.checkDataType=Gn.coerceAndCheckDataType=Gn.getJSONTypes=Gn.getSchemaTypes=Gn.DataType=void 0;var fce=DC(),mce=NC(),gce=qf(),Ue=Fe(),DU=Xe(),Fu;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Fu||(Gn.DataType=Fu={}));function hce(e){let t=NU(e.type);if(t.includes("null")){if(e.nullable===!1)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===!0&&t.push("null")}return t}Gn.getSchemaTypes=hce;function NU(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(fce.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}Gn.getJSONTypes=NU;function yce(e,t){let{gen:n,data:i,opts:r}=e,o=bce(t,r.coerceTypes),s=t.length>0&&!(o.length===0&&t.length===1&&(0,mce.schemaHasRulesForType)(e,t[0]));if(s){let a=LC(t,i,r.strictNumbers,Fu.Wrong);n.if(a,()=>{o.length?wce(e,t,o):MC(e)})}return s}Gn.coerceAndCheckDataType=yce;var jU=new Set(["string","number","integer","boolean","null"]);function bce(e,t){return t?e.filter(n=>jU.has(n)||t==="array"&&n==="array"):[]}function wce(e,t,n){let{gen:i,data:r,opts:o}=e,s=i.let("dataType",(0,Ue._)`typeof ${r}`),a=i.let("coerced",(0,Ue._)`undefined`);o.coerceTypes==="array"&&i.if((0,Ue._)`${s} == 'object' && Array.isArray(${r}) && ${r}.length == 1`,()=>i.assign(r,(0,Ue._)`${r}[0]`).assign(s,(0,Ue._)`typeof ${r}`).if(LC(t,r,o.strictNumbers),()=>i.assign(a,r))),i.if((0,Ue._)`${a} !== undefined`);for(let c of n)(jU.has(c)||c==="array"&&o.coerceTypes==="array")&&l(c);i.else(),MC(e),i.endIf(),i.if((0,Ue._)`${a} !== undefined`,()=>{i.assign(r,a),vce(e,a)});function l(c){switch(c){case"string":i.elseIf((0,Ue._)`${s} == "number" || ${s} == "boolean"`).assign(a,(0,Ue._)`"" + ${r}`).elseIf((0,Ue._)`${r} === null`).assign(a,(0,Ue._)`""`);return;case"number":i.elseIf((0,Ue._)`${s} == "boolean" || ${r} === null
64
+ || (${s} == "string" && ${r} && ${r} == +${r})`).assign(a,(0,Ue._)`+${r}`);return;case"integer":i.elseIf((0,Ue._)`${s} === "boolean" || ${r} === null
65
+ || (${s} === "string" && ${r} && ${r} == +${r} && !(${r} % 1))`).assign(a,(0,Ue._)`+${r}`);return;case"boolean":i.elseIf((0,Ue._)`${r} === "false" || ${r} === 0 || ${r} === null`).assign(a,!1).elseIf((0,Ue._)`${r} === "true" || ${r} === 1`).assign(a,!0);return;case"null":i.elseIf((0,Ue._)`${r} === "" || ${r} === 0 || ${r} === false`),i.assign(a,null);return;case"array":i.elseIf((0,Ue._)`${s} === "string" || ${s} === "number"
66
+ || ${s} === "boolean" || ${r} === null`).assign(a,(0,Ue._)`[${r}]`)}}}function vce({gen:e,parentData:t,parentDataProperty:n},i){e.if((0,Ue._)`${t} !== undefined`,()=>e.assign((0,Ue._)`${t}[${n}]`,i))}function jC(e,t,n,i=Fu.Correct){let r=i===Fu.Correct?Ue.operators.EQ:Ue.operators.NEQ,o;switch(e){case"null":return(0,Ue._)`${t} ${r} null`;case"array":o=(0,Ue._)`Array.isArray(${t})`;break;case"object":o=(0,Ue._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":o=s((0,Ue._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":o=s();break;default:return(0,Ue._)`typeof ${t} ${r} ${e}`}return i===Fu.Correct?o:(0,Ue.not)(o);function s(a=Ue.nil){return(0,Ue.and)((0,Ue._)`typeof ${t} == "number"`,a,n?(0,Ue._)`isFinite(${t})`:Ue.nil)}}Gn.checkDataType=jC;function LC(e,t,n,i){if(e.length===1)return jC(e[0],t,n,i);let r,o=(0,DU.toHash)(e);if(o.array&&o.object){let s=(0,Ue._)`typeof ${t} != "object"`;r=o.null?s:(0,Ue._)`!${t} || ${s}`,delete o.null,delete o.array,delete o.object}else r=Ue.nil;o.number&&delete o.integer;for(let s in o)r=(0,Ue.and)(r,jC(s,t,n,i));return r}Gn.checkDataTypes=LC;var kce={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,Ue._)`{type: ${e}}`:(0,Ue._)`{type: ${t}}`};function MC(e){let t=xce(e);(0,gce.reportError)(t,kce)}Gn.reportTypeError=MC;function xce(e){let{gen:t,data:n,schema:i}=e,r=(0,DU.schemaRefOrVal)(e,i,"type");return{gen:t,keyword:"type",data:n,schema:i.type,schemaCode:r,schemaValue:r,parentSchema:i,params:{},it:e}}});var MU=ie(Rw=>{"use strict";Object.defineProperty(Rw,"__esModule",{value:!0});Rw.assignDefaults=void 0;var Bu=Fe(),$ce=Xe();function Rce(e,t){let{properties:n,items:i}=e.schema;if(t==="object"&&n)for(let r in n)LU(e,r,n[r].default);else t==="array"&&Array.isArray(i)&&i.forEach((r,o)=>LU(e,o,r.default))}Rw.assignDefaults=Rce;function LU(e,t,n){let{gen:i,compositeRule:r,data:o,opts:s}=e;if(n===void 0)return;let a=(0,Bu._)`${o}${(0,Bu.getProperty)(t)}`;if(r){(0,$ce.checkStrictMode)(e,`default is ignored for: ${a}`);return}let l=(0,Bu._)`${a} === undefined`;s.useDefaults==="empty"&&(l=(0,Bu._)`${l} || ${a} === null || ${a} === ""`),i.if(l,(0,Bu._)`${a} = ${(0,Bu.stringify)(n)}`)}});var ei=ie(xt=>{"use strict";Object.defineProperty(xt,"__esModule",{value:!0});xt.validateUnion=xt.validateArray=xt.usePattern=xt.callValidateCode=xt.schemaProperties=xt.allSchemaProperties=xt.noPropertyInData=xt.propertyInData=xt.isOwnProperty=xt.hasPropFunc=xt.reportMissingProp=xt.checkMissingProp=xt.checkReportMissingProp=void 0;var Nt=Fe(),FC=Xe(),oa=Qr(),Sce=Xe();function Ece(e,t){let{gen:n,data:i,it:r}=e;n.if(GC(n,i,t,r.opts.ownProperties),()=>{e.setParams({missingProperty:(0,Nt._)`${t}`},!0),e.error()})}xt.checkReportMissingProp=Ece;function Ace({gen:e,data:t,it:{opts:n}},i,r){return(0,Nt.or)(...i.map(o=>(0,Nt.and)(GC(e,t,o,n.ownProperties),(0,Nt._)`${r} = ${o}`)))}xt.checkMissingProp=Ace;function Pce(e,t){e.setParams({missingProperty:t},!0),e.error()}xt.reportMissingProp=Pce;function FU(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Nt._)`Object.prototype.hasOwnProperty`})}xt.hasPropFunc=FU;function BC(e,t,n){return(0,Nt._)`${FU(e)}.call(${t}, ${n})`}xt.isOwnProperty=BC;function Oce(e,t,n,i){let r=(0,Nt._)`${t}${(0,Nt.getProperty)(n)} !== undefined`;return i?(0,Nt._)`${r} && ${BC(e,t,n)}`:r}xt.propertyInData=Oce;function GC(e,t,n,i){let r=(0,Nt._)`${t}${(0,Nt.getProperty)(n)} === undefined`;return i?(0,Nt.or)(r,(0,Nt.not)(BC(e,t,n))):r}xt.noPropertyInData=GC;function BU(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}xt.allSchemaProperties=BU;function Cce(e,t){return BU(t).filter(n=>!(0,FC.alwaysValidSchema)(e,t[n]))}xt.schemaProperties=Cce;function _ce({schemaCode:e,data:t,it:{gen:n,topSchemaRef:i,schemaPath:r,errorPath:o},it:s},a,l,c){let u=c?(0,Nt._)`${e}, ${t}, ${i}${r}`:t,d=[[oa.default.instancePath,(0,Nt.strConcat)(oa.default.instancePath,o)],[oa.default.parentData,s.parentData],[oa.default.parentDataProperty,s.parentDataProperty],[oa.default.rootData,oa.default.rootData]];s.opts.dynamicRef&&d.push([oa.default.dynamicAnchors,oa.default.dynamicAnchors]);let p=(0,Nt._)`${u}, ${n.object(...d)}`;return l!==Nt.nil?(0,Nt._)`${a}.call(${l}, ${p})`:(0,Nt._)`${a}(${p})`}xt.callValidateCode=_ce;var Ice=(0,Nt._)`new RegExp`;function Tce({gen:e,it:{opts:t}},n){let i=t.unicodeRegExp?"u":"",{regExp:r}=t.code,o=r(n,i);return e.scopeValue("pattern",{key:o.toString(),ref:o,code:(0,Nt._)`${r.code==="new RegExp"?Ice:(0,Sce.useFunc)(e,r)}(${n}, ${i})`})}xt.usePattern=Tce;function Dce(e){let{gen:t,data:n,keyword:i,it:r}=e,o=t.name("valid");if(r.allErrors){let a=t.let("valid",!0);return s(()=>t.assign(a,!1)),a}return t.var(o,!0),s(()=>t.break()),o;function s(a){let l=t.const("len",(0,Nt._)`${n}.length`);t.forRange("i",0,l,c=>{e.subschema({keyword:i,dataProp:c,dataPropType:FC.Type.Num},o),t.if((0,Nt.not)(o),a)})}}xt.validateArray=Dce;function Nce(e){let{gen:t,schema:n,keyword:i,it:r}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");if(n.some(l=>(0,FC.alwaysValidSchema)(r,l))&&!r.opts.unevaluated)return;let s=t.let("valid",!1),a=t.name("_valid");t.block(()=>n.forEach((l,c)=>{let u=e.subschema({keyword:i,schemaProp:c,compositeRule:!0},a);t.assign(s,(0,Nt._)`${s} || ${a}`),e.mergeValidEvaluated(u,a)||t.if((0,Nt.not)(s))})),e.result(s,()=>e.reset(),()=>e.error(!0))}xt.validateUnion=Nce});var zU=ie(io=>{"use strict";Object.defineProperty(io,"__esModule",{value:!0});io.validateKeywordUsage=io.validSchemaType=io.funcKeywordCode=io.macroKeywordCode=void 0;var Qn=Fe(),Pc=Qr(),jce=ei(),Lce=qf();function Mce(e,t){let{gen:n,keyword:i,schema:r,parentSchema:o,it:s}=e,a=t.macro.call(s.self,r,o,s),l=WU(n,i,a);s.opts.validateSchema!==!1&&s.self.validateSchema(a,!0);let c=n.name("valid");e.subschema({schema:a,schemaPath:Qn.nil,errSchemaPath:`${s.errSchemaPath}/${i}`,topSchemaRef:l,compositeRule:!0},c),e.pass(c,()=>e.error(!0))}io.macroKeywordCode=Mce;function Fce(e,t){var n;let{gen:i,keyword:r,schema:o,parentSchema:s,$data:a,it:l}=e;Gce(l,t);let c=!a&&t.compile?t.compile.call(l.self,o,s,l):t.validate,u=WU(i,r,c),d=i.let("valid");e.block$data(d,p),e.ok((n=t.valid)!==null&&n!==void 0?n:d);function p(){if(t.errors===!1)h(),t.modifying&&GU(e),b(()=>e.error());else{let w=t.async?f():g();t.modifying&&GU(e),b(()=>Bce(e,w))}}function f(){let w=i.let("ruleErrs",null);return i.try(()=>h((0,Qn._)`await `),x=>i.assign(d,!1).if((0,Qn._)`${x} instanceof ${l.ValidationError}`,()=>i.assign(w,(0,Qn._)`${x}.errors`),()=>i.throw(x))),w}function g(){let w=(0,Qn._)`${u}.errors`;return i.assign(w,null),h(Qn.nil),w}function h(w=t.async?(0,Qn._)`await `:Qn.nil){let x=l.opts.passContext?Pc.default.this:Pc.default.self,k=!("compile"in t&&!a||t.schema===!1);i.assign(d,(0,Qn._)`${w}${(0,jce.callValidateCode)(e,u,x,k)}`,t.modifying)}function b(w){var x;i.if((0,Qn.not)((x=t.valid)!==null&&x!==void 0?x:d),w)}}io.funcKeywordCode=Fce;function GU(e){let{gen:t,data:n,it:i}=e;t.if(i.parentData,()=>t.assign(n,(0,Qn._)`${i.parentData}[${i.parentDataProperty}]`))}function Bce(e,t){let{gen:n}=e;n.if((0,Qn._)`Array.isArray(${t})`,()=>{n.assign(Pc.default.vErrors,(0,Qn._)`${Pc.default.vErrors} === null ? ${t} : ${Pc.default.vErrors}.concat(${t})`).assign(Pc.default.errors,(0,Qn._)`${Pc.default.vErrors}.length`),(0,Lce.extendErrors)(e)},()=>e.error())}function Gce({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function WU(e,t,n){if(n===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof n=="function"?{ref:n}:{ref:n,code:(0,Qn.stringify)(n)})}function Wce(e,t,n=!1){return!t.length||t.some(i=>i==="array"?Array.isArray(e):i==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==i||n&&typeof e>"u")}io.validSchemaType=Wce;function zce({schema:e,opts:t,self:n,errSchemaPath:i},r,o){if(Array.isArray(r.keyword)?!r.keyword.includes(o):r.keyword!==o)throw new Error("ajv implementation error");let s=r.dependencies;if(s?.some(a=>!Object.prototype.hasOwnProperty.call(e,a)))throw new Error(`parent schema must have dependencies of ${o}: ${s.join(",")}`);if(r.validateSchema&&!r.validateSchema(e[o])){let l=`keyword "${o}" value is invalid at path "${i}": `+n.errorsText(r.validateSchema.errors);if(t.validateSchema==="log")n.logger.error(l);else throw new Error(l)}}io.validateKeywordUsage=zce});var HU=ie(sa=>{"use strict";Object.defineProperty(sa,"__esModule",{value:!0});sa.extendSubschemaMode=sa.extendSubschemaData=sa.getSubschema=void 0;var oo=Fe(),UU=Xe();function Uce(e,{keyword:t,schemaProp:n,schema:i,schemaPath:r,errSchemaPath:o,topSchemaRef:s}){if(t!==void 0&&i!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){let a=e.schema[t];return n===void 0?{schema:a,schemaPath:(0,oo._)`${e.schemaPath}${(0,oo.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:a[n],schemaPath:(0,oo._)`${e.schemaPath}${(0,oo.getProperty)(t)}${(0,oo.getProperty)(n)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,UU.escapeFragment)(n)}`}}if(i!==void 0){if(r===void 0||o===void 0||s===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:i,schemaPath:r,topSchemaRef:s,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')}sa.getSubschema=Uce;function Hce(e,t,{dataProp:n,dataPropType:i,data:r,dataTypes:o,propertyName:s}){if(r!==void 0&&n!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=t;if(n!==void 0){let{errorPath:c,dataPathArr:u,opts:d}=t,p=a.let("data",(0,oo._)`${t.data}${(0,oo.getProperty)(n)}`,!0);l(p),e.errorPath=(0,oo.str)`${c}${(0,UU.getErrorPath)(n,i,d.jsPropertySyntax)}`,e.parentDataProperty=(0,oo._)`${n}`,e.dataPathArr=[...u,e.parentDataProperty]}if(r!==void 0){let c=r instanceof oo.Name?r:a.let("data",r,!0);l(c),s!==void 0&&(e.propertyName=s)}o&&(e.dataTypes=o);function l(c){e.data=c,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,c]}}sa.extendSubschemaData=Hce;function Vce(e,{jtdDiscriminator:t,jtdMetadata:n,compositeRule:i,createErrors:r,allErrors:o}){i!==void 0&&(e.compositeRule=i),r!==void 0&&(e.createErrors=r),o!==void 0&&(e.allErrors=o),e.jtdDiscriminator=t,e.jtdMetadata=n}sa.extendSubschemaMode=Vce});var WC=ie((Y1e,VU)=>{"use strict";VU.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t=="object"&&typeof n=="object"){if(t.constructor!==n.constructor)return!1;var i,r,o;if(Array.isArray(t)){if(i=t.length,i!=n.length)return!1;for(r=i;r--!==0;)if(!e(t[r],n[r]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(o=Object.keys(t),i=o.length,i!==Object.keys(n).length)return!1;for(r=i;r--!==0;)if(!Object.prototype.hasOwnProperty.call(n,o[r]))return!1;for(r=i;r--!==0;){var s=o[r];if(!e(t[s],n[s]))return!1}return!0}return t!==t&&n!==n}});var KU=ie((X1e,qU)=>{"use strict";var aa=qU.exports=function(e,t,n){typeof t=="function"&&(n=t,t={}),n=t.cb||n;var i=typeof n=="function"?n:n.pre||function(){},r=n.post||function(){};Sw(t,i,r,e,"",e)};aa.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};aa.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};aa.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};aa.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function Sw(e,t,n,i,r,o,s,a,l,c){if(i&&typeof i=="object"&&!Array.isArray(i)){t(i,r,o,s,a,l,c);for(var u in i){var d=i[u];if(Array.isArray(d)){if(u in aa.arrayKeywords)for(var p=0;p<d.length;p++)Sw(e,t,n,d[p],r+"/"+u+"/"+p,o,r,u,i,p)}else if(u in aa.propsKeywords){if(d&&typeof d=="object")for(var f in d)Sw(e,t,n,d[f],r+"/"+u+"/"+qce(f),o,r,u,i,f)}else(u in aa.keywords||e.allKeys&&!(u in aa.skipKeywords))&&Sw(e,t,n,d,r+"/"+u,o,r,u,i)}n(i,r,o,s,a,l,c)}}function qce(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var Jf=ie(wr=>{"use strict";Object.defineProperty(wr,"__esModule",{value:!0});wr.getSchemaRefs=wr.resolveUrl=wr.normalizeId=wr._getFullPath=wr.getFullPath=wr.inlineRef=void 0;var Kce=Xe(),Jce=WC(),Zce=KU(),Yce=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function Xce(e,t=!0){return typeof e=="boolean"?!0:t===!0?!zC(e):t?JU(e)<=t:!1}wr.inlineRef=Xce;var Qce=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function zC(e){for(let t in e){if(Qce.has(t))return!0;let n=e[t];if(Array.isArray(n)&&n.some(zC)||typeof n=="object"&&zC(n))return!0}return!1}function JU(e){let t=0;for(let n in e){if(n==="$ref")return 1/0;if(t++,!Yce.has(n)&&(typeof e[n]=="object"&&(0,Kce.eachItem)(e[n],i=>t+=JU(i)),t===1/0))return 1/0}return t}function ZU(e,t="",n){n!==!1&&(t=Gu(t));let i=e.parse(t);return YU(e,i)}wr.getFullPath=ZU;function YU(e,t){return e.serialize(t).split("#")[0]+"#"}wr._getFullPath=YU;var ele=/#\/?$/;function Gu(e){return e?e.replace(ele,""):""}wr.normalizeId=Gu;function tle(e,t,n){return n=Gu(n),e.resolve(t,n)}wr.resolveUrl=tle;var nle=/^[a-z_][-a-z0-9._]*$/i;function rle(e,t){if(typeof e=="boolean")return{};let{schemaId:n,uriResolver:i}=this.opts,r=Gu(e[n]||t),o={"":r},s=ZU(i,r,!1),a={},l=new Set;return Zce(e,{allKeys:!0},(d,p,f,g)=>{if(g===void 0)return;let h=s+p,b=o[g];typeof d[n]=="string"&&(b=w.call(this,d[n])),x.call(this,d.$anchor),x.call(this,d.$dynamicAnchor),o[p]=b;function w(k){let R=this.opts.uriResolver.resolve;if(k=Gu(b?R(b,k):k),l.has(k))throw u(k);l.add(k);let $=this.refs[k];return typeof $=="string"&&($=this.refs[$]),typeof $=="object"?c(d,$.schema,k):k!==Gu(h)&&(k[0]==="#"?(c(d,a[k],k),a[k]=d):this.refs[k]=h),k}function x(k){if(typeof k=="string"){if(!nle.test(k))throw new Error(`invalid anchor "${k}"`);w.call(this,`#${k}`)}}}),a;function c(d,p,f){if(p!==void 0&&!Jce(d,p))throw u(f)}function u(d){return new Error(`reference "${d}" resolves to more than one schema`)}}wr.getSchemaRefs=rle});var Wu=ie(ca=>{"use strict";Object.defineProperty(ca,"__esModule",{value:!0});ca.getData=ca.KeywordCxt=ca.validateFunctionCode=void 0;var n2=_U(),XU=Kf(),HC=NC(),Ew=Kf(),ile=MU(),Yf=zU(),UC=HU(),Pe=Fe(),je=Qr(),ole=Jf(),is=Xe(),Zf=qf();function sle(e){if(o2(e)&&(s2(e),i2(e))){lle(e);return}r2(e,()=>(0,n2.topBoolOrEmptySchema)(e))}ca.validateFunctionCode=sle;function r2({gen:e,validateName:t,schema:n,schemaEnv:i,opts:r},o){r.code.es5?e.func(t,(0,Pe._)`${je.default.data}, ${je.default.valCxt}`,i.$async,()=>{e.code((0,Pe._)`"use strict"; ${QU(n,r)}`),cle(e,r),e.code(o)}):e.func(t,(0,Pe._)`${je.default.data}, ${ale(r)}`,i.$async,()=>e.code(QU(n,r)).code(o))}function ale(e){return(0,Pe._)`{${je.default.instancePath}="", ${je.default.parentData}, ${je.default.parentDataProperty}, ${je.default.rootData}=${je.default.data}${e.dynamicRef?(0,Pe._)`, ${je.default.dynamicAnchors}={}`:Pe.nil}}={}`}function cle(e,t){e.if(je.default.valCxt,()=>{e.var(je.default.instancePath,(0,Pe._)`${je.default.valCxt}.${je.default.instancePath}`),e.var(je.default.parentData,(0,Pe._)`${je.default.valCxt}.${je.default.parentData}`),e.var(je.default.parentDataProperty,(0,Pe._)`${je.default.valCxt}.${je.default.parentDataProperty}`),e.var(je.default.rootData,(0,Pe._)`${je.default.valCxt}.${je.default.rootData}`),t.dynamicRef&&e.var(je.default.dynamicAnchors,(0,Pe._)`${je.default.valCxt}.${je.default.dynamicAnchors}`)},()=>{e.var(je.default.instancePath,(0,Pe._)`""`),e.var(je.default.parentData,(0,Pe._)`undefined`),e.var(je.default.parentDataProperty,(0,Pe._)`undefined`),e.var(je.default.rootData,je.default.data),t.dynamicRef&&e.var(je.default.dynamicAnchors,(0,Pe._)`{}`)})}function lle(e){let{schema:t,opts:n,gen:i}=e;r2(e,()=>{n.$comment&&t.$comment&&c2(e),mle(e),i.let(je.default.vErrors,null),i.let(je.default.errors,0),n.unevaluated&&ule(e),a2(e),yle(e)})}function ule(e){let{gen:t,validateName:n}=e;e.evaluated=t.const("evaluated",(0,Pe._)`${n}.evaluated`),t.if((0,Pe._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,Pe._)`${e.evaluated}.props`,(0,Pe._)`undefined`)),t.if((0,Pe._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,Pe._)`${e.evaluated}.items`,(0,Pe._)`undefined`))}function QU(e,t){let n=typeof e=="object"&&e[t.schemaId];return n&&(t.code.source||t.code.process)?(0,Pe._)`/*# sourceURL=${n} */`:Pe.nil}function dle(e,t){if(o2(e)&&(s2(e),i2(e))){ple(e,t);return}(0,n2.boolOrEmptySchema)(e,t)}function i2({schema:e,self:t}){if(typeof e=="boolean")return!e;for(let n in e)if(t.RULES.all[n])return!0;return!1}function o2(e){return typeof e.schema!="boolean"}function ple(e,t){let{schema:n,gen:i,opts:r}=e;r.$comment&&n.$comment&&c2(e),gle(e),hle(e);let o=i.const("_errs",je.default.errors);a2(e,o),i.var(t,(0,Pe._)`${o} === ${je.default.errors}`)}function s2(e){(0,is.checkUnknownRules)(e),fle(e)}function a2(e,t){if(e.opts.jtd)return e2(e,[],!1,t);let n=(0,XU.getSchemaTypes)(e.schema),i=(0,XU.coerceAndCheckDataType)(e,n);e2(e,n,!i,t)}function fle(e){let{schema:t,errSchemaPath:n,opts:i,self:r}=e;t.$ref&&i.ignoreKeywordsWithRef&&(0,is.schemaHasRulesButRef)(t,r.RULES)&&r.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}function mle(e){let{schema:t,opts:n}=e;t.default!==void 0&&n.useDefaults&&n.strictSchema&&(0,is.checkStrictMode)(e,"default is ignored in the schema root")}function gle(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,ole.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function hle(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function c2({gen:e,schemaEnv:t,schema:n,errSchemaPath:i,opts:r}){let o=n.$comment;if(r.$comment===!0)e.code((0,Pe._)`${je.default.self}.logger.log(${o})`);else if(typeof r.$comment=="function"){let s=(0,Pe.str)`${i}/$comment`,a=e.scopeValue("root",{ref:t.root});e.code((0,Pe._)`${je.default.self}.opts.$comment(${o}, ${s}, ${a}.schema)`)}}function yle(e){let{gen:t,schemaEnv:n,validateName:i,ValidationError:r,opts:o}=e;n.$async?t.if((0,Pe._)`${je.default.errors} === 0`,()=>t.return(je.default.data),()=>t.throw((0,Pe._)`new ${r}(${je.default.vErrors})`)):(t.assign((0,Pe._)`${i}.errors`,je.default.vErrors),o.unevaluated&&ble(e),t.return((0,Pe._)`${je.default.errors} === 0`))}function ble({gen:e,evaluated:t,props:n,items:i}){n instanceof Pe.Name&&e.assign((0,Pe._)`${t}.props`,n),i instanceof Pe.Name&&e.assign((0,Pe._)`${t}.items`,i)}function e2(e,t,n,i){let{gen:r,schema:o,data:s,allErrors:a,opts:l,self:c}=e,{RULES:u}=c;if(o.$ref&&(l.ignoreKeywordsWithRef||!(0,is.schemaHasRulesButRef)(o,u))){r.block(()=>u2(e,"$ref",u.all.$ref.definition));return}l.jtd||wle(e,t),r.block(()=>{for(let p of u.rules)d(p);d(u.post)});function d(p){(0,HC.shouldUseGroup)(o,p)&&(p.type?(r.if((0,Ew.checkDataType)(p.type,s,l.strictNumbers)),t2(e,p),t.length===1&&t[0]===p.type&&n&&(r.else(),(0,Ew.reportTypeError)(e)),r.endIf()):t2(e,p),a||r.if((0,Pe._)`${je.default.errors} === ${i||0}`))}}function t2(e,t){let{gen:n,schema:i,opts:{useDefaults:r}}=e;r&&(0,ile.assignDefaults)(e,t.type),n.block(()=>{for(let o of t.rules)(0,HC.shouldUseRule)(i,o)&&u2(e,o.keyword,o.definition,t.type)})}function wle(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(vle(e,t),e.opts.allowUnionTypes||kle(e,t),xle(e,e.dataTypes))}function vle(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(n=>{l2(e.dataTypes,n)||VC(e,`type "${n}" not allowed by context "${e.dataTypes.join(",")}"`)}),Rle(e,t)}}function kle(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&VC(e,"use allowUnionTypes to allow union type keyword")}function xle(e,t){let n=e.self.RULES.all;for(let i in n){let r=n[i];if(typeof r=="object"&&(0,HC.shouldUseRule)(e.schema,r)){let{type:o}=r.definition;o.length&&!o.some(s=>$le(t,s))&&VC(e,`missing type "${o.join(",")}" for keyword "${i}"`)}}}function $le(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function l2(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function Rle(e,t){let n=[];for(let i of e.dataTypes)l2(t,i)?n.push(i):t.includes("integer")&&i==="number"&&n.push("integer");e.dataTypes=n}function VC(e,t){let n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${n}" (strictTypes)`,(0,is.checkStrictMode)(e,t,e.opts.strictTypes)}var Aw=class{constructor(t,n,i){if((0,Yf.validateKeywordUsage)(t,n,i),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=i,this.data=t.data,this.schema=t.schema[i],this.$data=n.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,is.schemaRefOrVal)(t,this.schema,i,this.$data),this.schemaType=n.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=n,this.$data)this.schemaCode=t.gen.const("vSchema",d2(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,Yf.validSchemaType)(this.schema,n.schemaType,n.allowUndefined))throw new Error(`${i} value must be ${JSON.stringify(n.schemaType)}`);("code"in n?n.trackErrors:n.errors!==!1)&&(this.errsCount=t.gen.const("_errs",je.default.errors))}result(t,n,i){this.failResult((0,Pe.not)(t),n,i)}failResult(t,n,i){this.gen.if(t),i?i():this.error(),n?(this.gen.else(),n(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,n){this.failResult((0,Pe.not)(t),void 0,n)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);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:n}=this;this.fail((0,Pe._)`${n} !== undefined && (${(0,Pe.or)(this.invalid$data(),t)})`)}error(t,n,i){if(n){this.setParams(n),this._error(t,i),this.setParams({});return}this._error(t,i)}_error(t,n){(t?Zf.reportExtraError:Zf.reportError)(this,this.def.error,n)}$dataError(){(0,Zf.reportError)(this,this.def.$dataError||Zf.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Zf.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,n){n?Object.assign(this.params,t):this.params=t}block$data(t,n,i=Pe.nil){this.gen.block(()=>{this.check$data(t,i),n()})}check$data(t=Pe.nil,n=Pe.nil){if(!this.$data)return;let{gen:i,schemaCode:r,schemaType:o,def:s}=this;i.if((0,Pe.or)((0,Pe._)`${r} === undefined`,n)),t!==Pe.nil&&i.assign(t,!0),(o.length||s.validateSchema)&&(i.elseIf(this.invalid$data()),this.$dataError(),t!==Pe.nil&&i.assign(t,!1)),i.else()}invalid$data(){let{gen:t,schemaCode:n,schemaType:i,def:r,it:o}=this;return(0,Pe.or)(s(),a());function s(){if(i.length){if(!(n instanceof Pe.Name))throw new Error("ajv implementation error");let l=Array.isArray(i)?i:[i];return(0,Pe._)`${(0,Ew.checkDataTypes)(l,n,o.opts.strictNumbers,Ew.DataType.Wrong)}`}return Pe.nil}function a(){if(r.validateSchema){let l=t.scopeValue("validate$data",{ref:r.validateSchema});return(0,Pe._)`!${l}(${n})`}return Pe.nil}}subschema(t,n){let i=(0,UC.getSubschema)(this.it,t);(0,UC.extendSubschemaData)(i,this.it,t),(0,UC.extendSubschemaMode)(i,t);let r={...this.it,...i,items:void 0,props:void 0};return dle(r,n),r}mergeEvaluated(t,n){let{it:i,gen:r}=this;i.opts.unevaluated&&(i.props!==!0&&t.props!==void 0&&(i.props=is.mergeEvaluated.props(r,t.props,i.props,n)),i.items!==!0&&t.items!==void 0&&(i.items=is.mergeEvaluated.items(r,t.items,i.items,n)))}mergeValidEvaluated(t,n){let{it:i,gen:r}=this;if(i.opts.unevaluated&&(i.props!==!0||i.items!==!0))return r.if(n,()=>this.mergeEvaluated(t,Pe.Name)),!0}};ca.KeywordCxt=Aw;function u2(e,t,n,i){let r=new Aw(e,n,t);"code"in n?n.code(r,i):r.$data&&n.validate?(0,Yf.funcKeywordCode)(r,n):"macro"in n?(0,Yf.macroKeywordCode)(r,n):(n.compile||n.validate)&&(0,Yf.funcKeywordCode)(r,n)}var Sle=/^\/(?:[^~]|~0|~1)*$/,Ele=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function d2(e,{dataLevel:t,dataNames:n,dataPathArr:i}){let r,o;if(e==="")return je.default.rootData;if(e[0]==="/"){if(!Sle.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);r=e,o=je.default.rootData}else{let c=Ele.exec(e);if(!c)throw new Error(`Invalid JSON-pointer: ${e}`);let u=+c[1];if(r=c[2],r==="#"){if(u>=t)throw new Error(l("property/index",u));return i[t-u]}if(u>t)throw new Error(l("data",u));if(o=n[t-u],!r)return o}let s=o,a=r.split("/");for(let c of a)c&&(o=(0,Pe._)`${o}${(0,Pe.getProperty)((0,is.unescapeJsonPointer)(c))}`,s=(0,Pe._)`${s} && ${o}`);return s;function l(c,u){return`Cannot access ${c} ${u} levels up, current level is ${t}`}}ca.getData=d2});var Xf=ie(KC=>{"use strict";Object.defineProperty(KC,"__esModule",{value:!0});var qC=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};KC.default=qC});var zu=ie(YC=>{"use strict";Object.defineProperty(YC,"__esModule",{value:!0});var JC=Jf(),ZC=class extends Error{constructor(t,n,i,r){super(r||`can't resolve reference ${i} from id ${n}`),this.missingRef=(0,JC.resolveUrl)(t,n,i),this.missingSchema=(0,JC.normalizeId)((0,JC.getFullPath)(t,this.missingRef))}};YC.default=ZC});var Qf=ie(ti=>{"use strict";Object.defineProperty(ti,"__esModule",{value:!0});ti.resolveSchema=ti.getCompilingSchema=ti.resolveRef=ti.compileSchema=ti.SchemaEnv=void 0;var Ci=Fe(),Ale=Xf(),Oc=Qr(),_i=Jf(),p2=Xe(),Ple=Wu(),Uu=class{constructor(t){var n;this.refs={},this.dynamicAnchors={};let i;typeof t.schema=="object"&&(i=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(n=t.baseId)!==null&&n!==void 0?n:(0,_i.normalizeId)(i?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=i?.$async,this.refs={}}};ti.SchemaEnv=Uu;function QC(e){let t=f2.call(this,e);if(t)return t;let n=(0,_i.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:i,lines:r}=this.opts.code,{ownProperties:o}=this.opts,s=new Ci.CodeGen(this.scope,{es5:i,lines:r,ownProperties:o}),a;e.$async&&(a=s.scopeValue("Error",{ref:Ale.default,code:(0,Ci._)`require("ajv/dist/runtime/validation_error").default`}));let l=s.scopeName("validate");e.validateName=l;let c={gen:s,allErrors:this.opts.allErrors,data:Oc.default.data,parentData:Oc.default.parentData,parentDataProperty:Oc.default.parentDataProperty,dataNames:[Oc.default.data],dataPathArr:[Ci.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:s.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,Ci.stringify)(e.schema)}:{ref:e.schema}),validateName:l,ValidationError:a,schema:e.schema,schemaEnv:e,rootId:n,baseId:e.baseId||n,schemaPath:Ci.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,Ci._)`""`,opts:this.opts,self:this},u;try{this._compilations.add(e),(0,Ple.validateFunctionCode)(c),s.optimize(this.opts.code.optimize);let d=s.toString();u=`${s.scopeRefs(Oc.default.scope)}return ${d}`,this.opts.code.process&&(u=this.opts.code.process(u,e));let f=new Function(`${Oc.default.self}`,`${Oc.default.scope}`,u)(this,this.scope.get());if(this.scope.value(l,{ref:f}),f.errors=null,f.schema=e.schema,f.schemaEnv=e,e.$async&&(f.$async=!0),this.opts.code.source===!0&&(f.source={validateName:l,validateCode:d,scopeValues:s._values}),this.opts.unevaluated){let{props:g,items:h}=c;f.evaluated={props:g instanceof Ci.Name?void 0:g,items:h instanceof Ci.Name?void 0:h,dynamicProps:g instanceof Ci.Name,dynamicItems:h instanceof Ci.Name},f.source&&(f.source.evaluated=(0,Ci.stringify)(f.evaluated))}return e.validate=f,e}catch(d){throw delete e.validate,delete e.validateName,u&&this.logger.error("Error compiling schema, function code:",u),d}finally{this._compilations.delete(e)}}ti.compileSchema=QC;function Ole(e,t,n){var i;n=(0,_i.resolveUrl)(this.opts.uriResolver,t,n);let r=e.refs[n];if(r)return r;let o=Ile.call(this,e,n);if(o===void 0){let s=(i=e.localRefs)===null||i===void 0?void 0:i[n],{schemaId:a}=this.opts;s&&(o=new Uu({schema:s,schemaId:a,root:e,baseId:t}))}if(o!==void 0)return e.refs[n]=Cle.call(this,o)}ti.resolveRef=Ole;function Cle(e){return(0,_i.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:QC.call(this,e)}function f2(e){for(let t of this._compilations)if(_le(t,e))return t}ti.getCompilingSchema=f2;function _le(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function Ile(e,t){let n;for(;typeof(n=this.refs[t])=="string";)t=n;return n||this.schemas[t]||Pw.call(this,e,t)}function Pw(e,t){let n=this.opts.uriResolver.parse(t),i=(0,_i._getFullPath)(this.opts.uriResolver,n),r=(0,_i.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&i===r)return XC.call(this,n,e);let o=(0,_i.normalizeId)(i),s=this.refs[o]||this.schemas[o];if(typeof s=="string"){let a=Pw.call(this,e,s);return typeof a?.schema!="object"?void 0:XC.call(this,n,a)}if(typeof s?.schema=="object"){if(s.validate||QC.call(this,s),o===(0,_i.normalizeId)(t)){let{schema:a}=s,{schemaId:l}=this.opts,c=a[l];return c&&(r=(0,_i.resolveUrl)(this.opts.uriResolver,r,c)),new Uu({schema:a,schemaId:l,root:e,baseId:r})}return XC.call(this,n,s)}}ti.resolveSchema=Pw;var Tle=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function XC(e,{baseId:t,schema:n,root:i}){var r;if(((r=e.fragment)===null||r===void 0?void 0:r[0])!=="/")return;for(let a of e.fragment.slice(1).split("/")){if(typeof n=="boolean")return;let l=n[(0,p2.unescapeFragment)(a)];if(l===void 0)return;n=l;let c=typeof n=="object"&&n[this.opts.schemaId];!Tle.has(a)&&c&&(t=(0,_i.resolveUrl)(this.opts.uriResolver,t,c))}let o;if(typeof n!="boolean"&&n.$ref&&!(0,p2.schemaHasRulesButRef)(n,this.RULES)){let a=(0,_i.resolveUrl)(this.opts.uriResolver,t,n.$ref);o=Pw.call(this,i,a)}let{schemaId:s}=this.opts;if(o=o||new Uu({schema:n,schemaId:s,root:i,baseId:t}),o.schema!==o.root.schema)return o}});var m2=ie((iFe,Dle)=>{Dle.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var n_=ie((oFe,v2)=>{"use strict";var Nle=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),h2=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),e_=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),y2=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),jle=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function t_(e){let t="",n=0,i=0;for(i=0;i<e.length;i++)if(n=e[i].charCodeAt(0),n!==48){if(!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return"";t+=e[i];break}for(i+=1;i<e.length;i++){if(n=e[i].charCodeAt(0),!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return"";t+=e[i]}return t}var Lle=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function g2(e){return e.length=0,!0}function Mle(e,t,n){if(e.length){let i=t_(e);if(i!=="")t.push(i);else return n.error=!0,!1;e.length=0}return!0}function Fle(e){let t=0,n={error:!1,address:"",zone:""},i=[],r=[],o=!1,s=!1,a=Mle;for(let l=0;l<e.length;l++){let c=e[l];if(!(c==="["||c==="]"))if(c===":"){if(o===!0&&(s=!0),!a(r,i,n))break;if(++t>7){n.error=!0;break}l>0&&e[l-1]===":"&&(o=!0),i.push(":");continue}else if(c==="%"){if(!a(r,i,n))break;a=g2}else{r.push(c);continue}}return r.length&&(a===g2?n.zone=r.join(""):s?i.push(r.join("")):i.push(t_(r))),n.address=i.join(""),n}function b2(e){if(Ble(e,":")<2)return{host:e,isIPV6:!1};let t=Fle(e);if(t.error)return{host:e,isIPV6:!1};{let n=t.address,i=t.address;return t.zone&&(n+="%"+t.zone,i+="%25"+t.zone),{host:n,isIPV6:!0,escapedHost:i}}}function Ble(e,t){let n=0;for(let i=0;i<e.length;i++)e[i]===t&&n++;return n}function Gle(e){let t=e,n=[],i=-1,r=0;for(;r=t.length;){if(r===1){if(t===".")break;if(t==="/"){n.push("/");break}else{n.push(t);break}}else if(r===2){if(t[0]==="."){if(t[1]===".")break;if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&(t[1]==="."||t[1]==="/")){n.push("/");break}}else if(r===3&&t==="/.."){n.length!==0&&n.pop(),n.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),n.length!==0&&n.pop();continue}}if((i=t.indexOf("/",1))===-1){n.push(t);break}else n.push(t.slice(0,i)),t=t.slice(i)}return n.join("")}var Wle={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},zle=/[@/?#:]/g,Ule=/[@/?#]/g;function w2(e,t){let n=t?Ule:zle;return n.lastIndex=0,e.replace(n,i=>Wle[i])}function Hle(e,t=!1){if(e.indexOf("%")===-1)return e;let n="";for(let i=0;i<e.length;i++){if(e[i]==="%"&&i+2<e.length){let r=e.slice(i+1,i+3);if(e_(r)){let o=r.toUpperCase(),s=String.fromCharCode(parseInt(o,16));t&&y2(s)?n+=s:n+="%"+o,i+=2;continue}}n+=e[i]}return n}function Vle(e){let t="";for(let n=0;n<e.length;n++){if(e[n]==="%"&&n+2<e.length){let i=e.slice(n+1,n+3);if(e_(i)){let r=i.toUpperCase(),o=String.fromCharCode(parseInt(r,16));o!=="."&&y2(o)?t+=o:t+="%"+r,n+=2;continue}}jle(e[n])?t+=e[n]:t+=escape(e[n])}return t}function qle(e){let t="";for(let n=0;n<e.length;n++){if(e[n]==="%"&&n+2<e.length){let i=e.slice(n+1,n+3);if(e_(i)){t+="%"+i.toUpperCase(),n+=2;continue}}t+=escape(e[n])}return t}function Kle(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push("@")),e.host!==void 0){let n=unescape(e.host);if(!h2(n)){let i=b2(n);i.isIPV6===!0?n=`[${i.escapedHost}]`:n=w2(n,!1)}t.push(n)}return(typeof e.port=="number"||typeof e.port=="string")&&(t.push(":"),t.push(String(e.port))),t.length?t.join(""):void 0}v2.exports={nonSimpleDomain:Lle,recomposeAuthority:Kle,reescapeHostDelimiters:w2,normalizePercentEncoding:Hle,normalizePathEncoding:Vle,escapePreservingEscapes:qle,removeDotSegments:Gle,isIPv4:h2,isUUID:Nle,normalizeIPv6:b2,stringArrayToHexStripped:t_}});var S2=ie((sFe,R2)=>{"use strict";var{isUUID:Jle}=n_(),Zle=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,Yle=["http","https","ws","wss","urn","urn:uuid"];function Xle(e){return Yle.indexOf(e)!==-1}function r_(e){return e.secure===!0?!0:e.secure===!1?!1: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"):!1}function k2(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function x2(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 Qle(e){return e.secure=r_(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function eue(e){if((e.port===(r_(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,n]=e.resourceName.split("?");e.path=t&&t!=="/"?t:void 0,e.query=n,e.resourceName=void 0}return e.fragment=void 0,e}function tue(e,t){if(!e.path)return e.error="URN can not be parsed",e;let n=e.path.match(Zle);if(n){let i=t.scheme||e.scheme||"urn";e.nid=n[1].toLowerCase(),e.nss=n[2];let r=`${i}:${t.nid||e.nid}`,o=i_(r);e.path=void 0,o&&(e=o.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e}function nue(e,t){if(e.nid===void 0)throw new Error("URN without nid cannot be serialized");let n=t.scheme||e.scheme||"urn",i=e.nid.toLowerCase(),r=`${n}:${t.nid||i}`,o=i_(r);o&&(e=o.serialize(e,t));let s=e,a=e.nss;return s.path=`${i||t.nid}:${a}`,t.skipEscape=!0,s}function rue(e,t){let n=e;return n.uuid=n.nss,n.nss=void 0,!t.tolerant&&(!n.uuid||!Jle(n.uuid))&&(n.error=n.error||"UUID is not valid."),n}function iue(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var $2={scheme:"http",domainHost:!0,parse:k2,serialize:x2},oue={scheme:"https",domainHost:$2.domainHost,parse:k2,serialize:x2},Ow={scheme:"ws",domainHost:!0,parse:Qle,serialize:eue},sue={scheme:"wss",domainHost:Ow.domainHost,parse:Ow.parse,serialize:Ow.serialize},aue={scheme:"urn",parse:tue,serialize:nue,skipNormalize:!0},cue={scheme:"urn:uuid",parse:rue,serialize:iue,skipNormalize:!0},Cw={http:$2,https:oue,ws:Ow,wss:sue,urn:aue,"urn:uuid":cue};Object.setPrototypeOf(Cw,null);function i_(e){return e&&(Cw[e]||Cw[e.toLowerCase()])||void 0}R2.exports={wsIsSecure:r_,SCHEMES:Cw,isValidSchemeName:Xle,getSchemeHandler:i_}});var _2=ie((aFe,_w)=>{"use strict";var{normalizeIPv6:lue,removeDotSegments:em,recomposeAuthority:uue,normalizePercentEncoding:due,normalizePathEncoding:pue,escapePreservingEscapes:fue,reescapeHostDelimiters:mue,isIPv4:gue,nonSimpleDomain:hue}=n_(),{SCHEMES:yue,getSchemeHandler:A2}=S2();function bue(e,t){return typeof e=="string"?e=$ue(e,t):typeof e=="object"&&(e=Hu(Cc(e,t),t)),e}function wue(e,t,n){let i=n?Object.assign({scheme:"null"},n):{scheme:"null"},r=P2(Hu(e,i),Hu(t,i),i,!0);return i.skipEscape=!0,Cc(r,i)}function P2(e,t,n,i){let r={};return i||(e=Hu(Cc(e,n),n),t=Hu(Cc(t,n),n)),n=n||{},!n.tolerant&&t.scheme?(r.scheme=t.scheme,r.userinfo=t.userinfo,r.host=t.host,r.port=t.port,r.path=em(t.path||""),r.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(r.userinfo=t.userinfo,r.host=t.host,r.port=t.port,r.path=em(t.path||""),r.query=t.query):(t.path?(t.path[0]==="/"?r.path=em(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?r.path="/"+t.path:e.path?r.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:r.path=t.path,r.path=em(r.path)),r.query=t.query):(r.path=e.path,t.query!==void 0?r.query=t.query:r.query=e.query),r.userinfo=e.userinfo,r.host=e.host,r.port=e.port),r.scheme=e.scheme),r.fragment=t.fragment,r}function vue(e,t,n){let i=E2(e,n),r=E2(t,n);return i!==void 0&&r!==void 0&&i.toLowerCase()===r.toLowerCase()}function Cc(e,t){let n={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:""},i=Object.assign({},t),r=[],o=A2(i.scheme||n.scheme);o&&o.serialize&&o.serialize(n,i),n.path!==void 0&&(i.skipEscape?n.path=due(n.path):(n.path=fue(n.path),n.scheme!==void 0&&(n.path=n.path.split("%3A").join(":")))),i.reference!=="suffix"&&n.scheme&&r.push(n.scheme,":");let s=uue(n);if(s!==void 0&&(i.reference!=="suffix"&&r.push("//"),r.push(s),n.path&&n.path[0]!=="/"&&r.push("/")),n.path!==void 0){let a=n.path;!i.absolutePath&&(!o||!o.absolutePath)&&(a=em(a)),s===void 0&&a[0]==="/"&&a[1]==="/"&&(a="/%2F"+a.slice(2)),r.push(a)}return n.query!==void 0&&r.push("?",n.query),n.fragment!==void 0&&r.push("#",n.fragment),r.join("")}var kue=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function xue(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof e.port=="number"&&(e.port<0||e.port>65535))return"URI port is malformed."}function O2(e,t){let n=Object.assign({},t),i={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},r=!1,o=!1;n.reference==="suffix"&&(n.scheme?e=n.scheme+":"+e:e="//"+e);let s=e.match(kue);if(s){i.scheme=s[1],i.userinfo=s[3],i.host=s[4],i.port=parseInt(s[5],10),i.path=s[6]||"",i.query=s[7],i.fragment=s[8],isNaN(i.port)&&(i.port=s[5]);let a=xue(i,s);if(a!==void 0&&(i.error=i.error||a,r=!0),i.host)if(gue(i.host)===!1){let u=lue(i.host);i.host=u.host.toLowerCase(),o=u.isIPV6}else o=!0;i.scheme===void 0&&i.userinfo===void 0&&i.host===void 0&&i.port===void 0&&i.query===void 0&&!i.path?i.reference="same-document":i.scheme===void 0?i.reference="relative":i.fragment===void 0?i.reference="absolute":i.reference="uri",n.reference&&n.reference!=="suffix"&&n.reference!==i.reference&&(i.error=i.error||"URI is not a "+n.reference+" reference.");let l=A2(n.scheme||i.scheme);if(!n.unicodeSupport&&(!l||!l.unicodeSupport)&&i.host&&(n.domainHost||l&&l.domainHost)&&o===!1&&hue(i.host))try{i.host=URL.domainToASCII(i.host.toLowerCase())}catch(c){i.error=i.error||"Host's domain name can not be converted to ASCII: "+c}if((!l||l&&!l.skipNormalize)&&(e.indexOf("%")!==-1&&(i.scheme!==void 0&&(i.scheme=unescape(i.scheme)),i.host!==void 0&&(i.host=mue(unescape(i.host),o))),i.path&&(i.path=pue(i.path)),i.fragment))try{i.fragment=encodeURI(decodeURIComponent(i.fragment))}catch{i.error=i.error||"URI malformed"}l&&l.parse&&l.parse(i,n)}else i.error=i.error||"URI can not be parsed.";return{parsed:i,malformedAuthorityOrPort:r}}function Hu(e,t){return O2(e,t).parsed}function $ue(e,t){return C2(e,t).normalized}function C2(e,t){let{parsed:n,malformedAuthorityOrPort:i}=O2(e,t);return{normalized:i?e:Cc(n,t),malformedAuthorityOrPort:i}}function E2(e,t){if(typeof e=="string"){let{normalized:n,malformedAuthorityOrPort:i}=C2(e,t);return i?void 0:n}if(typeof e=="object")return Cc(e,t)}var o_={SCHEMES:yue,normalize:bue,resolve:wue,resolveComponent:P2,equal:vue,serialize:Cc,parse:Hu};_w.exports=o_;_w.exports.default=o_;_w.exports.fastUri=o_});var T2=ie(s_=>{"use strict";Object.defineProperty(s_,"__esModule",{value:!0});var I2=_2();I2.code='require("ajv/dist/runtime/uri").default';s_.default=I2});var l_=ie(Sn=>{"use strict";Object.defineProperty(Sn,"__esModule",{value:!0});Sn.CodeGen=Sn.Name=Sn.nil=Sn.stringify=Sn.str=Sn._=Sn.KeywordCxt=void 0;var Rue=Wu();Object.defineProperty(Sn,"KeywordCxt",{enumerable:!0,get:function(){return Rue.KeywordCxt}});var Vu=Fe();Object.defineProperty(Sn,"_",{enumerable:!0,get:function(){return Vu._}});Object.defineProperty(Sn,"str",{enumerable:!0,get:function(){return Vu.str}});Object.defineProperty(Sn,"stringify",{enumerable:!0,get:function(){return Vu.stringify}});Object.defineProperty(Sn,"nil",{enumerable:!0,get:function(){return Vu.nil}});Object.defineProperty(Sn,"Name",{enumerable:!0,get:function(){return Vu.Name}});Object.defineProperty(Sn,"CodeGen",{enumerable:!0,get:function(){return Vu.CodeGen}});var Sue=Xf(),M2=zu(),Eue=DC(),tm=Qf(),Aue=Fe(),nm=Jf(),Iw=Kf(),c_=Xe(),D2=m2(),Pue=T2(),F2=(e,t)=>new RegExp(e,t);F2.code="new RegExp";var Oue=["removeAdditional","useDefaults","coerceTypes"],Cue=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),_ue={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."},Iue={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},N2=200;function Tue(e){var t,n,i,r,o,s,a,l,c,u,d,p,f,g,h,b,w,x,k,R,$,_,T,C,K;let O=e.strict,pe=(t=e.code)===null||t===void 0?void 0:t.optimize,F=pe===!0||pe===void 0?1:pe||0,Q=(i=(n=e.code)===null||n===void 0?void 0:n.regExp)!==null&&i!==void 0?i:F2,I=(r=e.uriResolver)!==null&&r!==void 0?r:Pue.default;return{strictSchema:(s=(o=e.strictSchema)!==null&&o!==void 0?o:O)!==null&&s!==void 0?s:!0,strictNumbers:(l=(a=e.strictNumbers)!==null&&a!==void 0?a:O)!==null&&l!==void 0?l:!0,strictTypes:(u=(c=e.strictTypes)!==null&&c!==void 0?c:O)!==null&&u!==void 0?u:"log",strictTuples:(p=(d=e.strictTuples)!==null&&d!==void 0?d:O)!==null&&p!==void 0?p:"log",strictRequired:(g=(f=e.strictRequired)!==null&&f!==void 0?f:O)!==null&&g!==void 0?g:!1,code:e.code?{...e.code,optimize:F,regExp:Q}:{optimize:F,regExp:Q},loopRequired:(h=e.loopRequired)!==null&&h!==void 0?h:N2,loopEnum:(b=e.loopEnum)!==null&&b!==void 0?b:N2,meta:(w=e.meta)!==null&&w!==void 0?w:!0,messages:(x=e.messages)!==null&&x!==void 0?x:!0,inlineRefs:(k=e.inlineRefs)!==null&&k!==void 0?k:!0,schemaId:(R=e.schemaId)!==null&&R!==void 0?R:"$id",addUsedSchema:($=e.addUsedSchema)!==null&&$!==void 0?$:!0,validateSchema:(_=e.validateSchema)!==null&&_!==void 0?_:!0,validateFormats:(T=e.validateFormats)!==null&&T!==void 0?T:!0,unicodeRegExp:(C=e.unicodeRegExp)!==null&&C!==void 0?C:!0,int32range:(K=e.int32range)!==null&&K!==void 0?K:!0,uriResolver:I}}var rm=class{constructor(t={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...Tue(t)};let{es5:n,lines:i}=this.opts.code;this.scope=new Aue.ValueScope({scope:{},prefixes:Cue,es5:n,lines:i}),this.logger=Fue(t.logger);let r=t.validateFormats;t.validateFormats=!1,this.RULES=(0,Eue.getRules)(),j2.call(this,_ue,t,"NOT SUPPORTED"),j2.call(this,Iue,t,"DEPRECATED","warn"),this._metaOpts=Lue.call(this),t.formats&&Nue.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&jue.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),Due.call(this),t.validateFormats=r}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:t,meta:n,schemaId:i}=this.opts,r=D2;i==="id"&&(r={...D2},r.id=r.$id,delete r.$id),n&&t&&this.addMetaSchema(r,r[i],!1)}defaultMeta(){let{meta:t,schemaId:n}=this.opts;return this.opts.defaultMeta=typeof t=="object"?t[n]||t:void 0}validate(t,n){let i;if(typeof t=="string"){if(i=this.getSchema(t),!i)throw new Error(`no schema with key or ref "${t}"`)}else i=this.compile(t);let r=i(n);return"$async"in i||(this.errors=i.errors),r}compile(t,n){let i=this._addSchema(t,n);return i.validate||this._compileSchemaEnv(i)}compileAsync(t,n){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:i}=this.opts;return r.call(this,t,n);async function r(u,d){await o.call(this,u.$schema);let p=this._addSchema(u,d);return p.validate||s.call(this,p)}async function o(u){u&&!this.getSchema(u)&&await r.call(this,{$ref:u},!0)}async function s(u){try{return this._compileSchemaEnv(u)}catch(d){if(!(d instanceof M2.default))throw d;return a.call(this,d),await l.call(this,d.missingSchema),s.call(this,u)}}function a({missingSchema:u,missingRef:d}){if(this.refs[u])throw new Error(`AnySchema ${u} is loaded but ${d} cannot be resolved`)}async function l(u){let d=await c.call(this,u);this.refs[u]||await o.call(this,d.$schema),this.refs[u]||this.addSchema(d,u,n)}async function c(u){let d=this._loading[u];if(d)return d;try{return await(this._loading[u]=i(u))}finally{delete this._loading[u]}}}addSchema(t,n,i,r=this.opts.validateSchema){if(Array.isArray(t)){for(let s of t)this.addSchema(s,void 0,i,r);return this}let o;if(typeof t=="object"){let{schemaId:s}=this.opts;if(o=t[s],o!==void 0&&typeof o!="string")throw new Error(`schema ${s} must be string`)}return n=(0,nm.normalizeId)(n||o),this._checkUnique(n),this.schemas[n]=this._addSchema(t,i,n,r,!0),this}addMetaSchema(t,n,i=this.opts.validateSchema){return this.addSchema(t,n,!0,i),this}validateSchema(t,n){if(typeof t=="boolean")return!0;let i;if(i=t.$schema,i!==void 0&&typeof i!="string")throw new Error("$schema must be a string");if(i=i||this.opts.defaultMeta||this.defaultMeta(),!i)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let r=this.validate(i,t);if(!r&&n){let o="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(o);else throw new Error(o)}return r}getSchema(t){let n;for(;typeof(n=L2.call(this,t))=="string";)t=n;if(n===void 0){let{schemaId:i}=this.opts,r=new tm.SchemaEnv({schema:{},schemaId:i});if(n=tm.resolveSchema.call(this,r,t),!n)return;this.refs[t]=n}return n.validate||this._compileSchemaEnv(n)}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 n=L2.call(this,t);return typeof n=="object"&&this._cache.delete(n.schema),delete this.schemas[t],delete this.refs[t],this}case"object":{let n=t;this._cache.delete(n);let i=t[this.opts.schemaId];return i&&(i=(0,nm.normalizeId)(i),delete this.schemas[i],delete this.refs[i]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(t){for(let n of t)this.addKeyword(n);return this}addKeyword(t,n){let i;if(typeof t=="string")i=t,typeof n=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),n.keyword=i);else if(typeof t=="object"&&n===void 0){if(n=t,i=n.keyword,Array.isArray(i)&&!i.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(Gue.call(this,i,n),!n)return(0,c_.eachItem)(i,o=>a_.call(this,o)),this;zue.call(this,n);let r={...n,type:(0,Iw.getJSONTypes)(n.type),schemaType:(0,Iw.getJSONTypes)(n.schemaType)};return(0,c_.eachItem)(i,r.type.length===0?o=>a_.call(this,o,r):o=>r.type.forEach(s=>a_.call(this,o,r,s))),this}getKeyword(t){let n=this.RULES.all[t];return typeof n=="object"?n.definition:!!n}removeKeyword(t){let{RULES:n}=this;delete n.keywords[t],delete n.all[t];for(let i of n.rules){let r=i.rules.findIndex(o=>o.keyword===t);r>=0&&i.rules.splice(r,1)}return this}addFormat(t,n){return typeof n=="string"&&(n=new RegExp(n)),this.formats[t]=n,this}errorsText(t=this.errors,{separator:n=", ",dataVar:i="data"}={}){return!t||t.length===0?"No errors":t.map(r=>`${i}${r.instancePath} ${r.message}`).reduce((r,o)=>r+n+o)}$dataMetaSchema(t,n){let i=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(let r of n){let o=r.split("/").slice(1),s=t;for(let a of o)s=s[a];for(let a in i){let l=i[a];if(typeof l!="object")continue;let{$data:c}=l.definition,u=s[a];c&&u&&(s[a]=B2(u))}}return t}_removeAllSchemas(t,n){for(let i in t){let r=t[i];(!n||n.test(i))&&(typeof r=="string"?delete t[i]:r&&!r.meta&&(this._cache.delete(r.schema),delete t[i]))}}_addSchema(t,n,i,r=this.opts.validateSchema,o=this.opts.addUsedSchema){let s,{schemaId:a}=this.opts;if(typeof t=="object")s=t[a];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 l=this._cache.get(t);if(l!==void 0)return l;i=(0,nm.normalizeId)(s||i);let c=nm.getSchemaRefs.call(this,t,i);return l=new tm.SchemaEnv({schema:t,schemaId:a,meta:n,baseId:i,localRefs:c}),this._cache.set(l.schema,l),o&&!i.startsWith("#")&&(i&&this._checkUnique(i),this.refs[i]=l),r&&this.validateSchema(t,!0),l}_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):tm.compileSchema.call(this,t),!t.validate)throw new Error("ajv implementation error");return t.validate}_compileMetaSchema(t){let n=this.opts;this.opts=this._metaOpts;try{tm.compileSchema.call(this,t)}finally{this.opts=n}}};rm.ValidationError=Sue.default;rm.MissingRefError=M2.default;Sn.default=rm;function j2(e,t,n,i="error"){for(let r in e){let o=r;o in t&&this.logger[i](`${n}: option ${r}. ${e[o]}`)}}function L2(e){return e=(0,nm.normalizeId)(e),this.schemas[e]||this.refs[e]}function Due(){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 Nue(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function jue(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 n=e[t];n.keyword||(n.keyword=t),this.addKeyword(n)}}function Lue(){let e={...this.opts};for(let t of Oue)delete e[t];return e}var Mue={log(){},warn(){},error(){}};function Fue(e){if(e===!1)return Mue;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 Bue=/^[a-z_$][a-z0-9_$:-]*$/i;function Gue(e,t){let{RULES:n}=this;if((0,c_.eachItem)(e,i=>{if(n.keywords[i])throw new Error(`Keyword ${i} is already defined`);if(!Bue.test(i))throw new Error(`Keyword ${i} has invalid name`)}),!!t&&t.$data&&!("code"in t||"validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function a_(e,t,n){var i;let r=t?.post;if(n&&r)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:o}=this,s=r?o.post:o.rules.find(({type:l})=>l===n);if(s||(s={type:n,rules:[]},o.rules.push(s)),o.keywords[e]=!0,!t)return;let a={keyword:e,definition:{...t,type:(0,Iw.getJSONTypes)(t.type),schemaType:(0,Iw.getJSONTypes)(t.schemaType)}};t.before?Wue.call(this,s,a,t.before):s.rules.push(a),o.all[e]=a,(i=t.implements)===null||i===void 0||i.forEach(l=>this.addKeyword(l))}function Wue(e,t,n){let i=e.rules.findIndex(r=>r.keyword===n);i>=0?e.rules.splice(i,0,t):(e.rules.push(t),this.logger.warn(`rule ${n} is not defined`))}function zue(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=B2(t)),e.validateSchema=this.compile(t,!0))}var Uue={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function B2(e){return{anyOf:[e,Uue]}}});var G2=ie(u_=>{"use strict";Object.defineProperty(u_,"__esModule",{value:!0});var Hue={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};u_.default=Hue});var Nw=ie(_c=>{"use strict";Object.defineProperty(_c,"__esModule",{value:!0});_c.callRef=_c.getValidate=void 0;var Vue=zu(),W2=ei(),vr=Fe(),qu=Qr(),z2=Qf(),Tw=Xe(),que={keyword:"$ref",schemaType:"string",code(e){let{gen:t,schema:n,it:i}=e,{baseId:r,schemaEnv:o,validateName:s,opts:a,self:l}=i,{root:c}=o;if((n==="#"||n==="#/")&&r===c.baseId)return d();let u=z2.resolveRef.call(l,c,r,n);if(u===void 0)throw new Vue.default(i.opts.uriResolver,r,n);if(u instanceof z2.SchemaEnv)return p(u);return f(u);function d(){if(o===c)return Dw(e,s,o,o.$async);let g=t.scopeValue("root",{ref:c});return Dw(e,(0,vr._)`${g}.validate`,c,c.$async)}function p(g){let h=U2(e,g);Dw(e,h,g,g.$async)}function f(g){let h=t.scopeValue("schema",a.code.source===!0?{ref:g,code:(0,vr.stringify)(g)}:{ref:g}),b=t.name("valid"),w=e.subschema({schema:g,dataTypes:[],schemaPath:vr.nil,topSchemaRef:h,errSchemaPath:n},b);e.mergeEvaluated(w),e.ok(b)}}};function U2(e,t){let{gen:n}=e;return t.validate?n.scopeValue("validate",{ref:t.validate}):(0,vr._)`${n.scopeValue("wrapper",{ref:t})}.validate`}_c.getValidate=U2;function Dw(e,t,n,i){let{gen:r,it:o}=e,{allErrors:s,schemaEnv:a,opts:l}=o,c=l.passContext?qu.default.this:vr.nil;i?u():d();function u(){if(!a.$async)throw new Error("async schema referenced by sync schema");let g=r.let("valid");r.try(()=>{r.code((0,vr._)`await ${(0,W2.callValidateCode)(e,t,c)}`),f(t),s||r.assign(g,!0)},h=>{r.if((0,vr._)`!(${h} instanceof ${o.ValidationError})`,()=>r.throw(h)),p(h),s||r.assign(g,!1)}),e.ok(g)}function d(){e.result((0,W2.callValidateCode)(e,t,c),()=>f(t),()=>p(t))}function p(g){let h=(0,vr._)`${g}.errors`;r.assign(qu.default.vErrors,(0,vr._)`${qu.default.vErrors} === null ? ${h} : ${qu.default.vErrors}.concat(${h})`),r.assign(qu.default.errors,(0,vr._)`${qu.default.vErrors}.length`)}function f(g){var h;if(!o.opts.unevaluated)return;let b=(h=n?.validate)===null||h===void 0?void 0:h.evaluated;if(o.props!==!0)if(b&&!b.dynamicProps)b.props!==void 0&&(o.props=Tw.mergeEvaluated.props(r,b.props,o.props));else{let w=r.var("props",(0,vr._)`${g}.evaluated.props`);o.props=Tw.mergeEvaluated.props(r,w,o.props,vr.Name)}if(o.items!==!0)if(b&&!b.dynamicItems)b.items!==void 0&&(o.items=Tw.mergeEvaluated.items(r,b.items,o.items));else{let w=r.var("items",(0,vr._)`${g}.evaluated.items`);o.items=Tw.mergeEvaluated.items(r,w,o.items,vr.Name)}}}_c.callRef=Dw;_c.default=que});var p_=ie(d_=>{"use strict";Object.defineProperty(d_,"__esModule",{value:!0});var Kue=G2(),Jue=Nw(),Zue=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",Kue.default,Jue.default];d_.default=Zue});var H2=ie(f_=>{"use strict";Object.defineProperty(f_,"__esModule",{value:!0});var jw=Fe(),la=jw.operators,Lw={maximum:{okStr:"<=",ok:la.LTE,fail:la.GT},minimum:{okStr:">=",ok:la.GTE,fail:la.LT},exclusiveMaximum:{okStr:"<",ok:la.LT,fail:la.GTE},exclusiveMinimum:{okStr:">",ok:la.GT,fail:la.LTE}},Yue={message:({keyword:e,schemaCode:t})=>(0,jw.str)`must be ${Lw[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,jw._)`{comparison: ${Lw[e].okStr}, limit: ${t}}`},Xue={keyword:Object.keys(Lw),type:"number",schemaType:"number",$data:!0,error:Yue,code(e){let{keyword:t,data:n,schemaCode:i}=e;e.fail$data((0,jw._)`${n} ${Lw[t].fail} ${i} || isNaN(${n})`)}};f_.default=Xue});var V2=ie(m_=>{"use strict";Object.defineProperty(m_,"__esModule",{value:!0});var im=Fe(),Que={message:({schemaCode:e})=>(0,im.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,im._)`{multipleOf: ${e}}`},ede={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:Que,code(e){let{gen:t,data:n,schemaCode:i,it:r}=e,o=r.opts.multipleOfPrecision,s=t.let("res"),a=o?(0,im._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${o}`:(0,im._)`${s} !== parseInt(${s})`;e.fail$data((0,im._)`(${i} === 0 || (${s} = ${n}/${i}, ${a}))`)}};m_.default=ede});var K2=ie(g_=>{"use strict";Object.defineProperty(g_,"__esModule",{value:!0});function q2(e){let t=e.length,n=0,i=0,r;for(;i<t;)n++,r=e.charCodeAt(i++),r>=55296&&r<=56319&&i<t&&(r=e.charCodeAt(i),(r&64512)===56320&&i++);return n}g_.default=q2;q2.code='require("ajv/dist/runtime/ucs2length").default'});var J2=ie(h_=>{"use strict";Object.defineProperty(h_,"__esModule",{value:!0});var Ic=Fe(),tde=Xe(),nde=K2(),rde={message({keyword:e,schemaCode:t}){let n=e==="maxLength"?"more":"fewer";return(0,Ic.str)`must NOT have ${n} than ${t} characters`},params:({schemaCode:e})=>(0,Ic._)`{limit: ${e}}`},ide={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:rde,code(e){let{keyword:t,data:n,schemaCode:i,it:r}=e,o=t==="maxLength"?Ic.operators.GT:Ic.operators.LT,s=r.opts.unicode===!1?(0,Ic._)`${n}.length`:(0,Ic._)`${(0,tde.useFunc)(e.gen,nde.default)}(${n})`;e.fail$data((0,Ic._)`${s} ${o} ${i}`)}};h_.default=ide});var Z2=ie(y_=>{"use strict";Object.defineProperty(y_,"__esModule",{value:!0});var ode=ei(),sde=Xe(),Ku=Fe(),ade={message:({schemaCode:e})=>(0,Ku.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Ku._)`{pattern: ${e}}`},cde={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:ade,code(e){let{gen:t,data:n,$data:i,schema:r,schemaCode:o,it:s}=e,a=s.opts.unicodeRegExp?"u":"";if(i){let{regExp:l}=s.opts.code,c=l.code==="new RegExp"?(0,Ku._)`new RegExp`:(0,sde.useFunc)(t,l),u=t.let("valid");t.try(()=>t.assign(u,(0,Ku._)`${c}(${o}, ${a}).test(${n})`),()=>t.assign(u,!1)),e.fail$data((0,Ku._)`!${u}`)}else{let l=(0,ode.usePattern)(e,r);e.fail$data((0,Ku._)`!${l}.test(${n})`)}}};y_.default=cde});var Y2=ie(b_=>{"use strict";Object.defineProperty(b_,"__esModule",{value:!0});var om=Fe(),lde={message({keyword:e,schemaCode:t}){let n=e==="maxProperties"?"more":"fewer";return(0,om.str)`must NOT have ${n} than ${t} properties`},params:({schemaCode:e})=>(0,om._)`{limit: ${e}}`},ude={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:lde,code(e){let{keyword:t,data:n,schemaCode:i}=e,r=t==="maxProperties"?om.operators.GT:om.operators.LT;e.fail$data((0,om._)`Object.keys(${n}).length ${r} ${i}`)}};b_.default=ude});var X2=ie(w_=>{"use strict";Object.defineProperty(w_,"__esModule",{value:!0});var sm=ei(),am=Fe(),dde=Xe(),pde={message:({params:{missingProperty:e}})=>(0,am.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,am._)`{missingProperty: ${e}}`},fde={keyword:"required",type:"object",schemaType:"array",$data:!0,error:pde,code(e){let{gen:t,schema:n,schemaCode:i,data:r,$data:o,it:s}=e,{opts:a}=s;if(!o&&n.length===0)return;let l=n.length>=a.loopRequired;if(s.allErrors?c():u(),a.strictRequired){let f=e.parentSchema.properties,{definedProperties:g}=e.it;for(let h of n)if(f?.[h]===void 0&&!g.has(h)){let b=s.schemaEnv.baseId+s.errSchemaPath,w=`required property "${h}" is not defined at "${b}" (strictRequired)`;(0,dde.checkStrictMode)(s,w,s.opts.strictRequired)}}function c(){if(l||o)e.block$data(am.nil,d);else for(let f of n)(0,sm.checkReportMissingProp)(e,f)}function u(){let f=t.let("missing");if(l||o){let g=t.let("valid",!0);e.block$data(g,()=>p(f,g)),e.ok(g)}else t.if((0,sm.checkMissingProp)(e,n,f)),(0,sm.reportMissingProp)(e,f),t.else()}function d(){t.forOf("prop",i,f=>{e.setParams({missingProperty:f}),t.if((0,sm.noPropertyInData)(t,r,f,a.ownProperties),()=>e.error())})}function p(f,g){e.setParams({missingProperty:f}),t.forOf(f,i,()=>{t.assign(g,(0,sm.propertyInData)(t,r,f,a.ownProperties)),t.if((0,am.not)(g),()=>{e.error(),t.break()})},am.nil)}}};w_.default=fde});var Q2=ie(v_=>{"use strict";Object.defineProperty(v_,"__esModule",{value:!0});var cm=Fe(),mde={message({keyword:e,schemaCode:t}){let n=e==="maxItems"?"more":"fewer";return(0,cm.str)`must NOT have ${n} than ${t} items`},params:({schemaCode:e})=>(0,cm._)`{limit: ${e}}`},gde={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:mde,code(e){let{keyword:t,data:n,schemaCode:i}=e,r=t==="maxItems"?cm.operators.GT:cm.operators.LT;e.fail$data((0,cm._)`${n}.length ${r} ${i}`)}};v_.default=gde});var Mw=ie(k_=>{"use strict";Object.defineProperty(k_,"__esModule",{value:!0});var eH=WC();eH.code='require("ajv/dist/runtime/equal").default';k_.default=eH});var tH=ie($_=>{"use strict";Object.defineProperty($_,"__esModule",{value:!0});var x_=Kf(),En=Fe(),hde=Xe(),yde=Mw(),bde={message:({params:{i:e,j:t}})=>(0,En.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,En._)`{i: ${e}, j: ${t}}`},wde={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:bde,code(e){let{gen:t,data:n,$data:i,schema:r,parentSchema:o,schemaCode:s,it:a}=e;if(!i&&!r)return;let l=t.let("valid"),c=o.items?(0,x_.getSchemaTypes)(o.items):[];e.block$data(l,u,(0,En._)`${s} === false`),e.ok(l);function u(){let g=t.let("i",(0,En._)`${n}.length`),h=t.let("j");e.setParams({i:g,j:h}),t.assign(l,!0),t.if((0,En._)`${g} > 1`,()=>(d()?p:f)(g,h))}function d(){return c.length>0&&!c.some(g=>g==="object"||g==="array")}function p(g,h){let b=t.name("item"),w=(0,x_.checkDataTypes)(c,b,a.opts.strictNumbers,x_.DataType.Wrong),x=t.const("indices",(0,En._)`{}`);t.for((0,En._)`;${g}--;`,()=>{t.let(b,(0,En._)`${n}[${g}]`),t.if(w,(0,En._)`continue`),c.length>1&&t.if((0,En._)`typeof ${b} == "string"`,(0,En._)`${b} += "_"`),t.if((0,En._)`typeof ${x}[${b}] == "number"`,()=>{t.assign(h,(0,En._)`${x}[${b}]`),e.error(),t.assign(l,!1).break()}).code((0,En._)`${x}[${b}] = ${g}`)})}function f(g,h){let b=(0,hde.useFunc)(t,yde.default),w=t.name("outer");t.label(w).for((0,En._)`;${g}--;`,()=>t.for((0,En._)`${h} = ${g}; ${h}--;`,()=>t.if((0,En._)`${b}(${n}[${g}], ${n}[${h}])`,()=>{e.error(),t.assign(l,!1).break(w)})))}}};$_.default=wde});var nH=ie(S_=>{"use strict";Object.defineProperty(S_,"__esModule",{value:!0});var R_=Fe(),vde=Xe(),kde=Mw(),xde={message:"must be equal to constant",params:({schemaCode:e})=>(0,R_._)`{allowedValue: ${e}}`},$de={keyword:"const",$data:!0,error:xde,code(e){let{gen:t,data:n,$data:i,schemaCode:r,schema:o}=e;i||o&&typeof o=="object"?e.fail$data((0,R_._)`!${(0,vde.useFunc)(t,kde.default)}(${n}, ${r})`):e.fail((0,R_._)`${o} !== ${n}`)}};S_.default=$de});var rH=ie(E_=>{"use strict";Object.defineProperty(E_,"__esModule",{value:!0});var lm=Fe(),Rde=Xe(),Sde=Mw(),Ede={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,lm._)`{allowedValues: ${e}}`},Ade={keyword:"enum",schemaType:"array",$data:!0,error:Ede,code(e){let{gen:t,data:n,$data:i,schema:r,schemaCode:o,it:s}=e;if(!i&&r.length===0)throw new Error("enum must have non-empty array");let a=r.length>=s.opts.loopEnum,l,c=()=>l??(l=(0,Rde.useFunc)(t,Sde.default)),u;if(a||i)u=t.let("valid"),e.block$data(u,d);else{if(!Array.isArray(r))throw new Error("ajv implementation error");let f=t.const("vSchema",o);u=(0,lm.or)(...r.map((g,h)=>p(f,h)))}e.pass(u);function d(){t.assign(u,!1),t.forOf("v",o,f=>t.if((0,lm._)`${c()}(${n}, ${f})`,()=>t.assign(u,!0).break()))}function p(f,g){let h=r[g];return typeof h=="object"&&h!==null?(0,lm._)`${c()}(${n}, ${f}[${g}])`:(0,lm._)`${n} === ${h}`}}};E_.default=Ade});var P_=ie(A_=>{"use strict";Object.defineProperty(A_,"__esModule",{value:!0});var Pde=H2(),Ode=V2(),Cde=J2(),_de=Z2(),Ide=Y2(),Tde=X2(),Dde=Q2(),Nde=tH(),jde=nH(),Lde=rH(),Mde=[Pde.default,Ode.default,Cde.default,_de.default,Ide.default,Tde.default,Dde.default,Nde.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},jde.default,Lde.default];A_.default=Mde});var C_=ie(um=>{"use strict";Object.defineProperty(um,"__esModule",{value:!0});um.validateAdditionalItems=void 0;var Tc=Fe(),O_=Xe(),Fde={message:({params:{len:e}})=>(0,Tc.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Tc._)`{limit: ${e}}`},Bde={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:Fde,code(e){let{parentSchema:t,it:n}=e,{items:i}=t;if(!Array.isArray(i)){(0,O_.checkStrictMode)(n,'"additionalItems" is ignored when "items" is not an array of schemas');return}iH(e,i)}};function iH(e,t){let{gen:n,schema:i,data:r,keyword:o,it:s}=e;s.items=!0;let a=n.const("len",(0,Tc._)`${r}.length`);if(i===!1)e.setParams({len:t.length}),e.pass((0,Tc._)`${a} <= ${t.length}`);else if(typeof i=="object"&&!(0,O_.alwaysValidSchema)(s,i)){let c=n.var("valid",(0,Tc._)`${a} <= ${t.length}`);n.if((0,Tc.not)(c),()=>l(c)),e.ok(c)}function l(c){n.forRange("i",t.length,a,u=>{e.subschema({keyword:o,dataProp:u,dataPropType:O_.Type.Num},c),s.allErrors||n.if((0,Tc.not)(c),()=>n.break())})}}um.validateAdditionalItems=iH;um.default=Bde});var __=ie(dm=>{"use strict";Object.defineProperty(dm,"__esModule",{value:!0});dm.validateTuple=void 0;var oH=Fe(),Fw=Xe(),Gde=ei(),Wde={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:n}=e;if(Array.isArray(t))return sH(e,"additionalItems",t);n.items=!0,!(0,Fw.alwaysValidSchema)(n,t)&&e.ok((0,Gde.validateArray)(e))}};function sH(e,t,n=e.schema){let{gen:i,parentSchema:r,data:o,keyword:s,it:a}=e;u(r),a.opts.unevaluated&&n.length&&a.items!==!0&&(a.items=Fw.mergeEvaluated.items(i,n.length,a.items));let l=i.name("valid"),c=i.const("len",(0,oH._)`${o}.length`);n.forEach((d,p)=>{(0,Fw.alwaysValidSchema)(a,d)||(i.if((0,oH._)`${c} > ${p}`,()=>e.subschema({keyword:s,schemaProp:p,dataProp:p},l)),e.ok(l))});function u(d){let{opts:p,errSchemaPath:f}=a,g=n.length,h=g===d.minItems&&(g===d.maxItems||d[t]===!1);if(p.strictTuples&&!h){let b=`"${s}" is ${g}-tuple, but minItems or maxItems/${t} are not specified or different at path "${f}"`;(0,Fw.checkStrictMode)(a,b,p.strictTuples)}}}dm.validateTuple=sH;dm.default=Wde});var aH=ie(I_=>{"use strict";Object.defineProperty(I_,"__esModule",{value:!0});var zde=__(),Ude={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,zde.validateTuple)(e,"items")};I_.default=Ude});var lH=ie(T_=>{"use strict";Object.defineProperty(T_,"__esModule",{value:!0});var cH=Fe(),Hde=Xe(),Vde=ei(),qde=C_(),Kde={message:({params:{len:e}})=>(0,cH.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,cH._)`{limit: ${e}}`},Jde={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:Kde,code(e){let{schema:t,parentSchema:n,it:i}=e,{prefixItems:r}=n;i.items=!0,!(0,Hde.alwaysValidSchema)(i,t)&&(r?(0,qde.validateAdditionalItems)(e,r):e.ok((0,Vde.validateArray)(e)))}};T_.default=Jde});var uH=ie(D_=>{"use strict";Object.defineProperty(D_,"__esModule",{value:!0});var ni=Fe(),Bw=Xe(),Zde={message:({params:{min:e,max:t}})=>t===void 0?(0,ni.str)`must contain at least ${e} valid item(s)`:(0,ni.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,ni._)`{minContains: ${e}}`:(0,ni._)`{minContains: ${e}, maxContains: ${t}}`},Yde={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:Zde,code(e){let{gen:t,schema:n,parentSchema:i,data:r,it:o}=e,s,a,{minContains:l,maxContains:c}=i;o.opts.next?(s=l===void 0?1:l,a=c):s=1;let u=t.const("len",(0,ni._)`${r}.length`);if(e.setParams({min:s,max:a}),a===void 0&&s===0){(0,Bw.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&s>a){(0,Bw.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,Bw.alwaysValidSchema)(o,n)){let h=(0,ni._)`${u} >= ${s}`;a!==void 0&&(h=(0,ni._)`${h} && ${u} <= ${a}`),e.pass(h);return}o.items=!0;let d=t.name("valid");a===void 0&&s===1?f(d,()=>t.if(d,()=>t.break())):s===0?(t.let(d,!0),a!==void 0&&t.if((0,ni._)`${r}.length > 0`,p)):(t.let(d,!1),p()),e.result(d,()=>e.reset());function p(){let h=t.name("_valid"),b=t.let("count",0);f(h,()=>t.if(h,()=>g(b)))}function f(h,b){t.forRange("i",0,u,w=>{e.subschema({keyword:"contains",dataProp:w,dataPropType:Bw.Type.Num,compositeRule:!0},h),b()})}function g(h){t.code((0,ni._)`${h}++`),a===void 0?t.if((0,ni._)`${h} >= ${s}`,()=>t.assign(d,!0).break()):(t.if((0,ni._)`${h} > ${a}`,()=>t.assign(d,!1).break()),s===1?t.assign(d,!0):t.if((0,ni._)`${h} >= ${s}`,()=>t.assign(d,!0)))}}};D_.default=Yde});var Gw=ie(so=>{"use strict";Object.defineProperty(so,"__esModule",{value:!0});so.validateSchemaDeps=so.validatePropertyDeps=so.error=void 0;var N_=Fe(),Xde=Xe(),pm=ei();so.error={message:({params:{property:e,depsCount:t,deps:n}})=>{let i=t===1?"property":"properties";return(0,N_.str)`must have ${i} ${n} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:n,missingProperty:i}})=>(0,N_._)`{property: ${e},
67
+ missingProperty: ${i},
68
+ depsCount: ${t},
69
+ deps: ${n}}`};var Qde={keyword:"dependencies",type:"object",schemaType:"object",error:so.error,code(e){let[t,n]=epe(e);dH(e,t),pH(e,n)}};function epe({schema:e}){let t={},n={};for(let i in e){if(i==="__proto__")continue;let r=Array.isArray(e[i])?t:n;r[i]=e[i]}return[t,n]}function dH(e,t=e.schema){let{gen:n,data:i,it:r}=e;if(Object.keys(t).length===0)return;let o=n.let("missing");for(let s in t){let a=t[s];if(a.length===0)continue;let l=(0,pm.propertyInData)(n,i,s,r.opts.ownProperties);e.setParams({property:s,depsCount:a.length,deps:a.join(", ")}),r.allErrors?n.if(l,()=>{for(let c of a)(0,pm.checkReportMissingProp)(e,c)}):(n.if((0,N_._)`${l} && (${(0,pm.checkMissingProp)(e,a,o)})`),(0,pm.reportMissingProp)(e,o),n.else())}}so.validatePropertyDeps=dH;function pH(e,t=e.schema){let{gen:n,data:i,keyword:r,it:o}=e,s=n.name("valid");for(let a in t)(0,Xde.alwaysValidSchema)(o,t[a])||(n.if((0,pm.propertyInData)(n,i,a,o.opts.ownProperties),()=>{let l=e.subschema({keyword:r,schemaProp:a},s);e.mergeValidEvaluated(l,s)},()=>n.var(s,!0)),e.ok(s))}so.validateSchemaDeps=pH;so.default=Qde});var mH=ie(j_=>{"use strict";Object.defineProperty(j_,"__esModule",{value:!0});var fH=Fe(),tpe=Xe(),npe={message:"property name must be valid",params:({params:e})=>(0,fH._)`{propertyName: ${e.propertyName}}`},rpe={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:npe,code(e){let{gen:t,schema:n,data:i,it:r}=e;if((0,tpe.alwaysValidSchema)(r,n))return;let o=t.name("valid");t.forIn("key",i,s=>{e.setParams({propertyName:s}),e.subschema({keyword:"propertyNames",data:s,dataTypes:["string"],propertyName:s,compositeRule:!0},o),t.if((0,fH.not)(o),()=>{e.error(!0),r.allErrors||t.break()})}),e.ok(o)}};j_.default=rpe});var M_=ie(L_=>{"use strict";Object.defineProperty(L_,"__esModule",{value:!0});var Ww=ei(),Ii=Fe(),ipe=Qr(),zw=Xe(),ope={message:"must NOT have additional properties",params:({params:e})=>(0,Ii._)`{additionalProperty: ${e.additionalProperty}}`},spe={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:ope,code(e){let{gen:t,schema:n,parentSchema:i,data:r,errsCount:o,it:s}=e;if(!o)throw new Error("ajv implementation error");let{allErrors:a,opts:l}=s;if(s.props=!0,l.removeAdditional!=="all"&&(0,zw.alwaysValidSchema)(s,n))return;let c=(0,Ww.allSchemaProperties)(i.properties),u=(0,Ww.allSchemaProperties)(i.patternProperties);d(),e.ok((0,Ii._)`${o} === ${ipe.default.errors}`);function d(){t.forIn("key",r,b=>{!c.length&&!u.length?g(b):t.if(p(b),()=>g(b))})}function p(b){let w;if(c.length>8){let x=(0,zw.schemaRefOrVal)(s,i.properties,"properties");w=(0,Ww.isOwnProperty)(t,x,b)}else c.length?w=(0,Ii.or)(...c.map(x=>(0,Ii._)`${b} === ${x}`)):w=Ii.nil;return u.length&&(w=(0,Ii.or)(w,...u.map(x=>(0,Ii._)`${(0,Ww.usePattern)(e,x)}.test(${b})`))),(0,Ii.not)(w)}function f(b){t.code((0,Ii._)`delete ${r}[${b}]`)}function g(b){if(l.removeAdditional==="all"||l.removeAdditional&&n===!1){f(b);return}if(n===!1){e.setParams({additionalProperty:b}),e.error(),a||t.break();return}if(typeof n=="object"&&!(0,zw.alwaysValidSchema)(s,n)){let w=t.name("valid");l.removeAdditional==="failing"?(h(b,w,!1),t.if((0,Ii.not)(w),()=>{e.reset(),f(b)})):(h(b,w),a||t.if((0,Ii.not)(w),()=>t.break()))}}function h(b,w,x){let k={keyword:"additionalProperties",dataProp:b,dataPropType:zw.Type.Str};x===!1&&Object.assign(k,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(k,w)}}};L_.default=spe});var yH=ie(B_=>{"use strict";Object.defineProperty(B_,"__esModule",{value:!0});var ape=Wu(),gH=ei(),F_=Xe(),hH=M_(),cpe={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:n,parentSchema:i,data:r,it:o}=e;o.opts.removeAdditional==="all"&&i.additionalProperties===void 0&&hH.default.code(new ape.KeywordCxt(o,hH.default,"additionalProperties"));let s=(0,gH.allSchemaProperties)(n);for(let d of s)o.definedProperties.add(d);o.opts.unevaluated&&s.length&&o.props!==!0&&(o.props=F_.mergeEvaluated.props(t,(0,F_.toHash)(s),o.props));let a=s.filter(d=>!(0,F_.alwaysValidSchema)(o,n[d]));if(a.length===0)return;let l=t.name("valid");for(let d of a)c(d)?u(d):(t.if((0,gH.propertyInData)(t,r,d,o.opts.ownProperties)),u(d),o.allErrors||t.else().var(l,!0),t.endIf()),e.it.definedProperties.add(d),e.ok(l);function c(d){return o.opts.useDefaults&&!o.compositeRule&&n[d].default!==void 0}function u(d){e.subschema({keyword:"properties",schemaProp:d,dataProp:d},l)}}};B_.default=cpe});var kH=ie(G_=>{"use strict";Object.defineProperty(G_,"__esModule",{value:!0});var bH=ei(),Uw=Fe(),wH=Xe(),vH=Xe(),lpe={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:n,data:i,parentSchema:r,it:o}=e,{opts:s}=o,a=(0,bH.allSchemaProperties)(n),l=a.filter(h=>(0,wH.alwaysValidSchema)(o,n[h]));if(a.length===0||l.length===a.length&&(!o.opts.unevaluated||o.props===!0))return;let c=s.strictSchema&&!s.allowMatchingProperties&&r.properties,u=t.name("valid");o.props!==!0&&!(o.props instanceof Uw.Name)&&(o.props=(0,vH.evaluatedPropsToName)(t,o.props));let{props:d}=o;p();function p(){for(let h of a)c&&f(h),o.allErrors?g(h):(t.var(u,!0),g(h),t.if(u))}function f(h){for(let b in c)new RegExp(h).test(b)&&(0,wH.checkStrictMode)(o,`property ${b} matches pattern ${h} (use allowMatchingProperties)`)}function g(h){t.forIn("key",i,b=>{t.if((0,Uw._)`${(0,bH.usePattern)(e,h)}.test(${b})`,()=>{let w=l.includes(h);w||e.subschema({keyword:"patternProperties",schemaProp:h,dataProp:b,dataPropType:vH.Type.Str},u),o.opts.unevaluated&&d!==!0?t.assign((0,Uw._)`${d}[${b}]`,!0):!w&&!o.allErrors&&t.if((0,Uw.not)(u),()=>t.break())})})}}};G_.default=lpe});var xH=ie(W_=>{"use strict";Object.defineProperty(W_,"__esModule",{value:!0});var upe=Xe(),dpe={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:n,it:i}=e;if((0,upe.alwaysValidSchema)(i,n)){e.fail();return}let r=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},r),e.failResult(r,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};W_.default=dpe});var $H=ie(z_=>{"use strict";Object.defineProperty(z_,"__esModule",{value:!0});var ppe=ei(),fpe={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:ppe.validateUnion,error:{message:"must match a schema in anyOf"}};z_.default=fpe});var RH=ie(U_=>{"use strict";Object.defineProperty(U_,"__esModule",{value:!0});var Hw=Fe(),mpe=Xe(),gpe={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,Hw._)`{passingSchemas: ${e.passing}}`},hpe={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:gpe,code(e){let{gen:t,schema:n,parentSchema:i,it:r}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");if(r.opts.discriminator&&i.discriminator)return;let o=n,s=t.let("valid",!1),a=t.let("passing",null),l=t.name("_valid");e.setParams({passing:a}),t.block(c),e.result(s,()=>e.reset(),()=>e.error(!0));function c(){o.forEach((u,d)=>{let p;(0,mpe.alwaysValidSchema)(r,u)?t.var(l,!0):p=e.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},l),d>0&&t.if((0,Hw._)`${l} && ${s}`).assign(s,!1).assign(a,(0,Hw._)`[${a}, ${d}]`).else(),t.if(l,()=>{t.assign(s,!0),t.assign(a,d),p&&e.mergeEvaluated(p,Hw.Name)})})}}};U_.default=hpe});var SH=ie(H_=>{"use strict";Object.defineProperty(H_,"__esModule",{value:!0});var ype=Xe(),bpe={keyword:"allOf",schemaType:"array",code(e){let{gen:t,schema:n,it:i}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");let r=t.name("valid");n.forEach((o,s)=>{if((0,ype.alwaysValidSchema)(i,o))return;let a=e.subschema({keyword:"allOf",schemaProp:s},r);e.ok(r),e.mergeEvaluated(a)})}};H_.default=bpe});var PH=ie(V_=>{"use strict";Object.defineProperty(V_,"__esModule",{value:!0});var Vw=Fe(),AH=Xe(),wpe={message:({params:e})=>(0,Vw.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,Vw._)`{failingKeyword: ${e.ifClause}}`},vpe={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:wpe,code(e){let{gen:t,parentSchema:n,it:i}=e;n.then===void 0&&n.else===void 0&&(0,AH.checkStrictMode)(i,'"if" without "then" and "else" is ignored');let r=EH(i,"then"),o=EH(i,"else");if(!r&&!o)return;let s=t.let("valid",!0),a=t.name("_valid");if(l(),e.reset(),r&&o){let u=t.let("ifClause");e.setParams({ifClause:u}),t.if(a,c("then",u),c("else",u))}else r?t.if(a,c("then")):t.if((0,Vw.not)(a),c("else"));e.pass(s,()=>e.error(!0));function l(){let u=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);e.mergeEvaluated(u)}function c(u,d){return()=>{let p=e.subschema({keyword:u},a);t.assign(s,a),e.mergeValidEvaluated(p,s),d?t.assign(d,(0,Vw._)`${u}`):e.setParams({ifClause:u})}}}};function EH(e,t){let n=e.schema[t];return n!==void 0&&!(0,AH.alwaysValidSchema)(e,n)}V_.default=vpe});var OH=ie(q_=>{"use strict";Object.defineProperty(q_,"__esModule",{value:!0});var kpe=Xe(),xpe={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:n}){t.if===void 0&&(0,kpe.checkStrictMode)(n,`"${e}" without "if" is ignored`)}};q_.default=xpe});var J_=ie(K_=>{"use strict";Object.defineProperty(K_,"__esModule",{value:!0});var $pe=C_(),Rpe=aH(),Spe=__(),Epe=lH(),Ape=uH(),Ppe=Gw(),Ope=mH(),Cpe=M_(),_pe=yH(),Ipe=kH(),Tpe=xH(),Dpe=$H(),Npe=RH(),jpe=SH(),Lpe=PH(),Mpe=OH();function Fpe(e=!1){let t=[Tpe.default,Dpe.default,Npe.default,jpe.default,Lpe.default,Mpe.default,Ope.default,Cpe.default,Ppe.default,_pe.default,Ipe.default];return e?t.push(Rpe.default,Epe.default):t.push($pe.default,Spe.default),t.push(Ape.default),t}K_.default=Fpe});var Y_=ie(fm=>{"use strict";Object.defineProperty(fm,"__esModule",{value:!0});fm.dynamicAnchor=void 0;var Z_=Fe(),Bpe=Qr(),CH=Qf(),Gpe=Nw(),Wpe={keyword:"$dynamicAnchor",schemaType:"string",code:e=>_H(e,e.schema)};function _H(e,t){let{gen:n,it:i}=e;i.schemaEnv.root.dynamicAnchors[t]=!0;let r=(0,Z_._)`${Bpe.default.dynamicAnchors}${(0,Z_.getProperty)(t)}`,o=i.errSchemaPath==="#"?i.validateName:zpe(e);n.if((0,Z_._)`!${r}`,()=>n.assign(r,o))}fm.dynamicAnchor=_H;function zpe(e){let{schemaEnv:t,schema:n,self:i}=e.it,{root:r,baseId:o,localRefs:s,meta:a}=t.root,{schemaId:l}=i.opts,c=new CH.SchemaEnv({schema:n,schemaId:l,root:r,baseId:o,localRefs:s,meta:a});return CH.compileSchema.call(i,c),(0,Gpe.getValidate)(e,c)}fm.default=Wpe});var X_=ie(mm=>{"use strict";Object.defineProperty(mm,"__esModule",{value:!0});mm.dynamicRef=void 0;var IH=Fe(),Upe=Qr(),TH=Nw(),Hpe={keyword:"$dynamicRef",schemaType:"string",code:e=>DH(e,e.schema)};function DH(e,t){let{gen:n,keyword:i,it:r}=e;if(t[0]!=="#")throw new Error(`"${i}" only supports hash fragment reference`);let o=t.slice(1);if(r.allErrors)s();else{let l=n.let("valid",!1);s(l),e.ok(l)}function s(l){if(r.schemaEnv.root.dynamicAnchors[o]){let c=n.let("_v",(0,IH._)`${Upe.default.dynamicAnchors}${(0,IH.getProperty)(o)}`);n.if(c,a(c,l),a(r.validateName,l))}else a(r.validateName,l)()}function a(l,c){return c?()=>n.block(()=>{(0,TH.callRef)(e,l),n.let(c,!0)}):()=>(0,TH.callRef)(e,l)}}mm.dynamicRef=DH;mm.default=Hpe});var NH=ie(Q_=>{"use strict";Object.defineProperty(Q_,"__esModule",{value:!0});var Vpe=Y_(),qpe=Xe(),Kpe={keyword:"$recursiveAnchor",schemaType:"boolean",code(e){e.schema?(0,Vpe.dynamicAnchor)(e,""):(0,qpe.checkStrictMode)(e.it,"$recursiveAnchor: false is ignored")}};Q_.default=Kpe});var jH=ie(e0=>{"use strict";Object.defineProperty(e0,"__esModule",{value:!0});var Jpe=X_(),Zpe={keyword:"$recursiveRef",schemaType:"string",code:e=>(0,Jpe.dynamicRef)(e,e.schema)};e0.default=Zpe});var LH=ie(t0=>{"use strict";Object.defineProperty(t0,"__esModule",{value:!0});var Ype=Y_(),Xpe=X_(),Qpe=NH(),efe=jH(),tfe=[Ype.default,Xpe.default,Qpe.default,efe.default];t0.default=tfe});var FH=ie(n0=>{"use strict";Object.defineProperty(n0,"__esModule",{value:!0});var MH=Gw(),nfe={keyword:"dependentRequired",type:"object",schemaType:"object",error:MH.error,code:e=>(0,MH.validatePropertyDeps)(e)};n0.default=nfe});var BH=ie(r0=>{"use strict";Object.defineProperty(r0,"__esModule",{value:!0});var rfe=Gw(),ife={keyword:"dependentSchemas",type:"object",schemaType:"object",code:e=>(0,rfe.validateSchemaDeps)(e)};r0.default=ife});var GH=ie(i0=>{"use strict";Object.defineProperty(i0,"__esModule",{value:!0});var ofe=Xe(),sfe={keyword:["maxContains","minContains"],type:"array",schemaType:"number",code({keyword:e,parentSchema:t,it:n}){t.contains===void 0&&(0,ofe.checkStrictMode)(n,`"${e}" without "contains" is ignored`)}};i0.default=sfe});var WH=ie(o0=>{"use strict";Object.defineProperty(o0,"__esModule",{value:!0});var afe=FH(),cfe=BH(),lfe=GH(),ufe=[afe.default,cfe.default,lfe.default];o0.default=ufe});var UH=ie(s0=>{"use strict";Object.defineProperty(s0,"__esModule",{value:!0});var ua=Fe(),zH=Xe(),dfe=Qr(),pfe={message:"must NOT have unevaluated properties",params:({params:e})=>(0,ua._)`{unevaluatedProperty: ${e.unevaluatedProperty}}`},ffe={keyword:"unevaluatedProperties",type:"object",schemaType:["boolean","object"],trackErrors:!0,error:pfe,code(e){let{gen:t,schema:n,data:i,errsCount:r,it:o}=e;if(!r)throw new Error("ajv implementation error");let{allErrors:s,props:a}=o;a instanceof ua.Name?t.if((0,ua._)`${a} !== true`,()=>t.forIn("key",i,d=>t.if(c(a,d),()=>l(d)))):a!==!0&&t.forIn("key",i,d=>a===void 0?l(d):t.if(u(a,d),()=>l(d))),o.props=!0,e.ok((0,ua._)`${r} === ${dfe.default.errors}`);function l(d){if(n===!1){e.setParams({unevaluatedProperty:d}),e.error(),s||t.break();return}if(!(0,zH.alwaysValidSchema)(o,n)){let p=t.name("valid");e.subschema({keyword:"unevaluatedProperties",dataProp:d,dataPropType:zH.Type.Str},p),s||t.if((0,ua.not)(p),()=>t.break())}}function c(d,p){return(0,ua._)`!${d} || !${d}[${p}]`}function u(d,p){let f=[];for(let g in d)d[g]===!0&&f.push((0,ua._)`${p} !== ${g}`);return(0,ua.and)(...f)}}};s0.default=ffe});var VH=ie(a0=>{"use strict";Object.defineProperty(a0,"__esModule",{value:!0});var Dc=Fe(),HH=Xe(),mfe={message:({params:{len:e}})=>(0,Dc.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Dc._)`{limit: ${e}}`},gfe={keyword:"unevaluatedItems",type:"array",schemaType:["boolean","object"],error:mfe,code(e){let{gen:t,schema:n,data:i,it:r}=e,o=r.items||0;if(o===!0)return;let s=t.const("len",(0,Dc._)`${i}.length`);if(n===!1)e.setParams({len:o}),e.fail((0,Dc._)`${s} > ${o}`);else if(typeof n=="object"&&!(0,HH.alwaysValidSchema)(r,n)){let l=t.var("valid",(0,Dc._)`${s} <= ${o}`);t.if((0,Dc.not)(l),()=>a(l,o)),e.ok(l)}r.items=!0;function a(l,c){t.forRange("i",c,s,u=>{e.subschema({keyword:"unevaluatedItems",dataProp:u,dataPropType:HH.Type.Num},l),r.allErrors||t.if((0,Dc.not)(l),()=>t.break())})}}};a0.default=gfe});var qH=ie(c0=>{"use strict";Object.defineProperty(c0,"__esModule",{value:!0});var hfe=UH(),yfe=VH(),bfe=[hfe.default,yfe.default];c0.default=bfe});var KH=ie(l0=>{"use strict";Object.defineProperty(l0,"__esModule",{value:!0});var Yt=Fe(),wfe={message:({schemaCode:e})=>(0,Yt.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,Yt._)`{format: ${e}}`},vfe={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:wfe,code(e,t){let{gen:n,data:i,$data:r,schema:o,schemaCode:s,it:a}=e,{opts:l,errSchemaPath:c,schemaEnv:u,self:d}=a;if(!l.validateFormats)return;r?p():f();function p(){let g=n.scopeValue("formats",{ref:d.formats,code:l.code.formats}),h=n.const("fDef",(0,Yt._)`${g}[${s}]`),b=n.let("fType"),w=n.let("format");n.if((0,Yt._)`typeof ${h} == "object" && !(${h} instanceof RegExp)`,()=>n.assign(b,(0,Yt._)`${h}.type || "string"`).assign(w,(0,Yt._)`${h}.validate`),()=>n.assign(b,(0,Yt._)`"string"`).assign(w,h)),e.fail$data((0,Yt.or)(x(),k()));function x(){return l.strictSchema===!1?Yt.nil:(0,Yt._)`${s} && !${w}`}function k(){let R=u.$async?(0,Yt._)`(${h}.async ? await ${w}(${i}) : ${w}(${i}))`:(0,Yt._)`${w}(${i})`,$=(0,Yt._)`(typeof ${w} == "function" ? ${R} : ${w}.test(${i}))`;return(0,Yt._)`${w} && ${w} !== true && ${b} === ${t} && !${$}`}}function f(){let g=d.formats[o];if(!g){x();return}if(g===!0)return;let[h,b,w]=k(g);h===t&&e.pass(R());function x(){if(l.strictSchema===!1){d.logger.warn($());return}throw new Error($());function $(){return`unknown format "${o}" ignored in schema at path "${c}"`}}function k($){let _=$ instanceof RegExp?(0,Yt.regexpCode)($):l.code.formats?(0,Yt._)`${l.code.formats}${(0,Yt.getProperty)(o)}`:void 0,T=n.scopeValue("formats",{key:o,ref:$,code:_});return typeof $=="object"&&!($ instanceof RegExp)?[$.type||"string",$.validate,(0,Yt._)`${T}.validate`]:["string",$,T]}function R(){if(typeof g=="object"&&!(g instanceof RegExp)&&g.async){if(!u.$async)throw new Error("async format in sync schema");return(0,Yt._)`await ${w}(${i})`}return typeof b=="function"?(0,Yt._)`${w}(${i})`:(0,Yt._)`${w}.test(${i})`}}}};l0.default=vfe});var d0=ie(u0=>{"use strict";Object.defineProperty(u0,"__esModule",{value:!0});var kfe=KH(),xfe=[kfe.default];u0.default=xfe});var p0=ie(Ju=>{"use strict";Object.defineProperty(Ju,"__esModule",{value:!0});Ju.contentVocabulary=Ju.metadataVocabulary=void 0;Ju.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Ju.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var ZH=ie(f0=>{"use strict";Object.defineProperty(f0,"__esModule",{value:!0});var $fe=p_(),Rfe=P_(),Sfe=J_(),Efe=LH(),Afe=WH(),Pfe=qH(),Ofe=d0(),JH=p0(),Cfe=[Efe.default,$fe.default,Rfe.default,(0,Sfe.default)(!0),Ofe.default,JH.metadataVocabulary,JH.contentVocabulary,Afe.default,Pfe.default];f0.default=Cfe});var XH=ie(qw=>{"use strict";Object.defineProperty(qw,"__esModule",{value:!0});qw.DiscrError=void 0;var YH;(function(e){e.Tag="tag",e.Mapping="mapping"})(YH||(qw.DiscrError=YH={}))});var h0=ie(g0=>{"use strict";Object.defineProperty(g0,"__esModule",{value:!0});var Zu=Fe(),m0=XH(),QH=Qf(),_fe=zu(),Ife=Xe(),Tfe={message:({params:{discrError:e,tagName:t}})=>e===m0.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:n}})=>(0,Zu._)`{error: ${e}, tag: ${n}, tagValue: ${t}}`},Dfe={keyword:"discriminator",type:"object",schemaType:"object",error:Tfe,code(e){let{gen:t,data:n,schema:i,parentSchema:r,it:o}=e,{oneOf:s}=r;if(!o.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=i.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(i.mapping)throw new Error("discriminator: mapping is not supported");if(!s)throw new Error("discriminator: requires oneOf keyword");let l=t.let("valid",!1),c=t.const("tag",(0,Zu._)`${n}${(0,Zu.getProperty)(a)}`);t.if((0,Zu._)`typeof ${c} == "string"`,()=>u(),()=>e.error(!1,{discrError:m0.DiscrError.Tag,tag:c,tagName:a})),e.ok(l);function u(){let f=p();t.if(!1);for(let g in f)t.elseIf((0,Zu._)`${c} === ${g}`),t.assign(l,d(f[g]));t.else(),e.error(!1,{discrError:m0.DiscrError.Mapping,tag:c,tagName:a}),t.endIf()}function d(f){let g=t.name("valid"),h=e.subschema({keyword:"oneOf",schemaProp:f},g);return e.mergeEvaluated(h,Zu.Name),g}function p(){var f;let g={},h=w(r),b=!0;for(let R=0;R<s.length;R++){let $=s[R];if($?.$ref&&!(0,Ife.schemaHasRulesButRef)($,o.self.RULES)){let T=$.$ref;if($=QH.resolveRef.call(o.self,o.schemaEnv.root,o.baseId,T),$ instanceof QH.SchemaEnv&&($=$.schema),$===void 0)throw new _fe.default(o.opts.uriResolver,o.baseId,T)}let _=(f=$?.properties)===null||f===void 0?void 0:f[a];if(typeof _!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);b=b&&(h||w($)),x(_,R)}if(!b)throw new Error(`discriminator: "${a}" must be required`);return g;function w({required:R}){return Array.isArray(R)&&R.includes(a)}function x(R,$){if(R.const)k(R.const,$);else if(R.enum)for(let _ of R.enum)k(_,$);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function k(R,$){if(typeof R!="string"||R in g)throw new Error(`discriminator: "${a}" values must be unique strings`);g[R]=$}}}};g0.default=Dfe});var eV=ie((aBe,Nfe)=>{Nfe.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/schema",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":!0,"https://json-schema.org/draft/2020-12/vocab/applicator":!0,"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0,"https://json-schema.org/draft/2020-12/vocab/validation":!0,"https://json-schema.org/draft/2020-12/vocab/meta-data":!0,"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0,"https://json-schema.org/draft/2020-12/vocab/content":!0},$dynamicAnchor:"meta",title:"Core and Validation specifications meta-schema",allOf:[{$ref:"meta/core"},{$ref:"meta/applicator"},{$ref:"meta/unevaluated"},{$ref:"meta/validation"},{$ref:"meta/meta-data"},{$ref:"meta/format-annotation"},{$ref:"meta/content"}],type:["object","boolean"],$comment:"This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.",properties:{definitions:{$comment:'"definitions" has been replaced by "$defs".',type:"object",additionalProperties:{$dynamicRef:"#meta"},deprecated:!0,default:{}},dependencies:{$comment:'"dependencies" has been split and replaced by "dependentSchemas" and "dependentRequired" in order to serve their differing semantics.',type:"object",additionalProperties:{anyOf:[{$dynamicRef:"#meta"},{$ref:"meta/validation#/$defs/stringArray"}]},deprecated:!0,default:{}},$recursiveAnchor:{$comment:'"$recursiveAnchor" has been replaced by "$dynamicAnchor".',$ref:"meta/core#/$defs/anchorString",deprecated:!0},$recursiveRef:{$comment:'"$recursiveRef" has been replaced by "$dynamicRef".',$ref:"meta/core#/$defs/uriReferenceString",deprecated:!0}}}});var tV=ie((cBe,jfe)=>{jfe.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/applicator",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/applicator":!0},$dynamicAnchor:"meta",title:"Applicator vocabulary meta-schema",type:["object","boolean"],properties:{prefixItems:{$ref:"#/$defs/schemaArray"},items:{$dynamicRef:"#meta"},contains:{$dynamicRef:"#meta"},additionalProperties:{$dynamicRef:"#meta"},properties:{type:"object",additionalProperties:{$dynamicRef:"#meta"},default:{}},patternProperties:{type:"object",additionalProperties:{$dynamicRef:"#meta"},propertyNames:{format:"regex"},default:{}},dependentSchemas:{type:"object",additionalProperties:{$dynamicRef:"#meta"},default:{}},propertyNames:{$dynamicRef:"#meta"},if:{$dynamicRef:"#meta"},then:{$dynamicRef:"#meta"},else:{$dynamicRef:"#meta"},allOf:{$ref:"#/$defs/schemaArray"},anyOf:{$ref:"#/$defs/schemaArray"},oneOf:{$ref:"#/$defs/schemaArray"},not:{$dynamicRef:"#meta"}},$defs:{schemaArray:{type:"array",minItems:1,items:{$dynamicRef:"#meta"}}}}});var nV=ie((lBe,Lfe)=>{Lfe.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/unevaluated",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0},$dynamicAnchor:"meta",title:"Unevaluated applicator vocabulary meta-schema",type:["object","boolean"],properties:{unevaluatedItems:{$dynamicRef:"#meta"},unevaluatedProperties:{$dynamicRef:"#meta"}}}});var rV=ie((uBe,Mfe)=>{Mfe.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/content",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/content":!0},$dynamicAnchor:"meta",title:"Content vocabulary meta-schema",type:["object","boolean"],properties:{contentEncoding:{type:"string"},contentMediaType:{type:"string"},contentSchema:{$dynamicRef:"#meta"}}}});var iV=ie((dBe,Ffe)=>{Ffe.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/core",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":!0},$dynamicAnchor:"meta",title:"Core vocabulary meta-schema",type:["object","boolean"],properties:{$id:{$ref:"#/$defs/uriReferenceString",$comment:"Non-empty fragments not allowed.",pattern:"^[^#]*#?$"},$schema:{$ref:"#/$defs/uriString"},$ref:{$ref:"#/$defs/uriReferenceString"},$anchor:{$ref:"#/$defs/anchorString"},$dynamicRef:{$ref:"#/$defs/uriReferenceString"},$dynamicAnchor:{$ref:"#/$defs/anchorString"},$vocabulary:{type:"object",propertyNames:{$ref:"#/$defs/uriString"},additionalProperties:{type:"boolean"}},$comment:{type:"string"},$defs:{type:"object",additionalProperties:{$dynamicRef:"#meta"}}},$defs:{anchorString:{type:"string",pattern:"^[A-Za-z_][-A-Za-z0-9._]*$"},uriString:{type:"string",format:"uri"},uriReferenceString:{type:"string",format:"uri-reference"}}}});var oV=ie((pBe,Bfe)=>{Bfe.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/format-annotation",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0},$dynamicAnchor:"meta",title:"Format vocabulary meta-schema for annotation results",type:["object","boolean"],properties:{format:{type:"string"}}}});var sV=ie((fBe,Gfe)=>{Gfe.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/meta-data",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/meta-data":!0},$dynamicAnchor:"meta",title:"Meta-data vocabulary meta-schema",type:["object","boolean"],properties:{title:{type:"string"},description:{type:"string"},default:!0,deprecated:{type:"boolean",default:!1},readOnly:{type:"boolean",default:!1},writeOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0}}}});var aV=ie((mBe,Wfe)=>{Wfe.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/validation",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/validation":!0},$dynamicAnchor:"meta",title:"Validation vocabulary meta-schema",type:["object","boolean"],properties:{type:{anyOf:[{$ref:"#/$defs/simpleTypes"},{type:"array",items:{$ref:"#/$defs/simpleTypes"},minItems:1,uniqueItems:!0}]},const:!0,enum:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/$defs/nonNegativeInteger"},minLength:{$ref:"#/$defs/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},maxItems:{$ref:"#/$defs/nonNegativeInteger"},minItems:{$ref:"#/$defs/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},maxContains:{$ref:"#/$defs/nonNegativeInteger"},minContains:{$ref:"#/$defs/nonNegativeInteger",default:1},maxProperties:{$ref:"#/$defs/nonNegativeInteger"},minProperties:{$ref:"#/$defs/nonNegativeIntegerDefault0"},required:{$ref:"#/$defs/stringArray"},dependentRequired:{type:"object",additionalProperties:{$ref:"#/$defs/stringArray"}}},$defs:{nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{$ref:"#/$defs/nonNegativeInteger",default:0},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}}}});var cV=ie(y0=>{"use strict";Object.defineProperty(y0,"__esModule",{value:!0});var zfe=eV(),Ufe=tV(),Hfe=nV(),Vfe=rV(),qfe=iV(),Kfe=oV(),Jfe=sV(),Zfe=aV(),Yfe=["/properties"];function Xfe(e){return[zfe,Ufe,Hfe,Vfe,qfe,t(this,Kfe),Jfe,t(this,Zfe)].forEach(n=>this.addMetaSchema(n,void 0,!1)),this;function t(n,i){return e?n.$dataMetaSchema(i,Yfe):i}}y0.default=Xfe});var lV=ie((jt,w0)=>{"use strict";Object.defineProperty(jt,"__esModule",{value:!0});jt.MissingRefError=jt.ValidationError=jt.CodeGen=jt.Name=jt.nil=jt.stringify=jt.str=jt._=jt.KeywordCxt=jt.Ajv2020=void 0;var Qfe=l_(),eme=ZH(),tme=h0(),nme=cV(),b0="https://json-schema.org/draft/2020-12/schema",Yu=class extends Qfe.default{constructor(t={}){super({...t,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),eme.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(tme.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:t,meta:n}=this.opts;n&&(nme.default.call(this,t),this.refs["http://json-schema.org/schema"]=b0)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(b0)?b0:void 0)}};jt.Ajv2020=Yu;w0.exports=jt=Yu;w0.exports.Ajv2020=Yu;Object.defineProperty(jt,"__esModule",{value:!0});jt.default=Yu;var rme=Wu();Object.defineProperty(jt,"KeywordCxt",{enumerable:!0,get:function(){return rme.KeywordCxt}});var Xu=Fe();Object.defineProperty(jt,"_",{enumerable:!0,get:function(){return Xu._}});Object.defineProperty(jt,"str",{enumerable:!0,get:function(){return Xu.str}});Object.defineProperty(jt,"stringify",{enumerable:!0,get:function(){return Xu.stringify}});Object.defineProperty(jt,"nil",{enumerable:!0,get:function(){return Xu.nil}});Object.defineProperty(jt,"Name",{enumerable:!0,get:function(){return Xu.Name}});Object.defineProperty(jt,"CodeGen",{enumerable:!0,get:function(){return Xu.CodeGen}});var ime=Xf();Object.defineProperty(jt,"ValidationError",{enumerable:!0,get:function(){return ime.default}});var ome=zu();Object.defineProperty(jt,"MissingRefError",{enumerable:!0,get:function(){return ome.default}})});function da(){let e=lV();return e.default??e}var gm=v(()=>{"use strict"});import{readFileSync as k0}from"node:fs";import{isAbsolute as sme,join as x0,relative as ame,resolve as cme}from"node:path";function dV(e=[]){let t=new Map;for(let n of[...uV,...e]){if(t.has(n.name))throw new Error(`kind ${n.name} is registered twice`);t.set(n.name,n)}return{get:n=>t.get(n),names:()=>[...t.values()].filter(n=>n.shape==="member").map(n=>n.name).sort(),all:()=>[...t.values()]}}function pV(){return dV()}function fV(e,t,n){if("directory"in e.probe)return!0;if("chantProject"in e.probe)return R0(t,n);let{anyFile:i,anyBlock:r,anyJsonKey:o}=e.probe;if(i&&v0(t,n,i).length>0)return!0;if(o)for(let s of v0(t,n,o.in))try{let a=JSON.parse(t.read(s));if(o.pointers.some(l=>dme(a,l)!==void 0))return!0}catch{}if(r){let s=new RegExp(`^\\s*(?:${r.blocks.map(mV).join("|")})\\s*\\{`,"m");for(let a of v0(t,n,r.in))try{if(s.test(t.read(a)))return!0}catch{}}return!1}function v0(e,t,n){let i=[],r=n.filter(o=>o.includes("*"));for(let o of n)!o.includes("*")&&e.stat(ze(t,o))==="file"&&i.push(ze(t,o));if(r.length>0){let o=r.map(s=>new RegExp(`^${s.split("*").map(mV).join("[^/]*")}$`));for(let s of e.list(t)??[])s.type==="file"&&o.some(a=>a.test(s.name))&&i.push(ze(t,s.name))}return i.sort()}function dme(e,t){let n=e;for(let i of t.split("/").slice(1)){let r=i.replace(/~1/g,"/").replace(/~0/g,"~");if(n===null||typeof n!="object"||!Object.prototype.hasOwnProperty.call(n,r))return;n=n[r]}return n}function mV(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function R0(e,t){let n=ze(t,"package.json");if(e.stat(n)==="file")try{let r=JSON.parse(e.read(n));for(let o of["dependencies","devDependencies","peerDependencies"]){let s=r[o];if(s&&typeof s=="object"&&Object.keys(s).some(mme))return!0}}catch{}let i=(r,o)=>{let s=e.list(r)??[];return s.some(a=>a.type==="file"&&pme.includes(a.name))?!0:o===fme?!1:s.some(a=>a.type==="dir"&&!ts(a.name)&&i(ze(r,a.name),o+1))};return i(t,0)}function mme(e){return e==="@intentius/chant"||e.startsWith("@intentius/chant-lexicon-")}function gme(){if(Kw)return Kw;let e=da();return Kw=new e({allErrors:!0,strict:!0}).compile(rC),Kw}function hme(e,t){let n;try{n=JSON.parse(e)}catch(a){return{kinds:[],problems:[`${t}: the kinds file is not JSON (${a.message})`]}}let i=gme();if(!i(n)){let a=(i.errors??[]).map(l=>`${t}: ${l.instancePath||"the kinds file"} ${l.message??"is invalid"}`);return{kinds:[],problems:[...new Set(a)]}}let r=[],o=[],s=new Set;for(let a of n.kinds){if(ume.includes(a.name)){r.push(`${t}: kind ${a.name} is built in and can't be supplied by a package`);continue}if(s.has(a.name)){r.push(`${t}: kind ${a.name} is listed twice`);continue}s.add(a.name),o.push({name:a.name,description:a.description,probe:{...a.probe.anyFile?{anyFile:[...a.probe.anyFile]}:{},...a.probe.anyBlock?{anyBlock:{in:[...a.probe.anyBlock.in],blocks:[...a.probe.anyBlock.blocks]}}:{},...a.probe.anyJsonKey?{anyJsonKey:{in:[...a.probe.anyJsonKey.in],pointers:[...a.probe.anyJsonKey.pointers]}}:{}},precedence:a.precedence,shape:"member",outputs:{from:"declared",names:[...a.outputs??[]]},source:t,...a.graph?{graph:{lexicon:a.graph.lexicon,config:structuredClone(a.graph.config)}}:{},...a.fields?{fields:structuredClone(a.fields)}:{}});for(let l of vme(a.fields??{}))r.push(`${t}: kind ${a.name} ${l}`)}return{kinds:o,problems:r}}function yme(e,t=$0){return uC(e,t)}function bme(e,t){let n=x0(e,"package.json"),i;try{i=JSON.parse(k0(n,"utf-8"))}catch{return{kinds:[],problems:[`${t??e}: no readable package.json in ${e}`],file:void 0}}let r=t??(typeof i.name=="string"?i.name:e),o=yme(i);if(o===void 0)return{kinds:[],problems:[],file:void 0};if(typeof o!="string")return{kinds:[],problems:[`${r}: ${o.problem}`],file:void 0};let s=cme(e,o),a=ame(e,s);if(a.startsWith("..")||sme(a))return{kinds:[],problems:[`${r}: exports["${$0}"] points outside the package`],file:void 0};let l;try{l=k0(s,"utf-8")}catch{return{kinds:[],problems:[`${r}: exports["${$0}"] names ${o}, which does not exist`],file:s}}let c=hme(l,r),u=typeof i.name=="string"?i.name:void 0;for(let d of c.kinds)d.packageDir=e,d.graph&&u!==Jw(d.graph.lexicon)&&(c.problems.push(`${r}: kind ${d.name} reads its members with lexicon ${d.graph.lexicon}, which is ${Jw(d.graph.lexicon)}, and this package is ${u??"unnamed"}; the kind is kept, and workspace graph lists its members with kind-not-run`),delete d.graph);return{...c,file:s}}function Jw(e){return`@intentius/chant-lexicon-${e}`}function gV(e,t){let n=r=>r.replace(/\{(member|dir|workspace)\}/g,(o,s)=>t[s]),i=r=>typeof r=="string"?n(r):Array.isArray(r)?r.map(i):r!==null&&typeof r=="object"?Object.fromEntries(Object.entries(r).map(([o,s])=>[n(o),i(s)])):r;return i(e)}function S0(e,t){if(e.package){let n=na(e.package,t);if(!n)return{problem:`pinned package ${e.package} is not installed; install it to read the kinds it supplies`};let i;try{i=JSON.parse(k0(x0(n,"package.json"),"utf-8")).version}catch{i=void 0}return e.version&&i!==e.version?{problem:`${e.package} is pinned at ${e.version}, and ${String(i??"an unknown version")} is installed`}:{dir:n,source:e.package}}if(e.path){let n=x0(t,...e.path.split("/"));if(e.integrity){let i=uU(n,e.integrity,e.path);if(!i.ok)return{problem:i.message}}return{dir:n,source:e.path}}return null}function pa(e,t){let n=[],i=[],r=new Map,o=new Set;return e.forEach((s,a)=>{let l=S0(s,t);if(l===null)return;if("problem"in l){n.push({pin:a,message:l.problem});return}let{dir:c,source:u}=l,d=bme(c,u);for(let p of d.problems)n.push({pin:a,message:p});for(let p of d.kinds){let f=r.get(p.name);if(f){o.add(p.name),n.push({pin:a,message:`kind ${p.name} is supplied by both ${f} and ${u}; a kind name has one source`});continue}r.set(p.name,u),i.push(p)}}),{registry:dV(i.filter(s=>!o.has(s.name))),problems:n}}function wme(e,t){if(!(e.type==="integer"?typeof t=="number"&&Number.isInteger(t):typeof t===e.type))return`is ${JSON.stringify(t)}, and the field is ${e.type==="integer"?"an integer":`a ${e.type}`}`;if(e.pattern!==void 0&&typeof t=="string"){let i;try{i=new RegExp(e.pattern,"u")}catch{return}if(!i.test(t))return`is ${JSON.stringify(t)}, which does not match ${e.pattern}`}}function vme(e){let t=[],n=(i,r)=>{if(r.pattern!==void 0)try{new RegExp(r.pattern,"u")}catch{t.push(`declares field ${i} with pattern ${r.pattern}, which is not a regular expression`);return}if(r.default===void 0)return;let o=wme(r,r.default);o&&t.push(`declares field ${i} whose default ${o}`)};for(let[i,r]of Object.entries(e))if(r.type==="object")for(let[o,s]of Object.entries(r.properties))n(`${i}.${o}`,s);else n(i,r);return t}var RBe,$0,Zw,lme,uV,ume,pme,fme,Kw,ao=v(()=>{"use strict";sU();Zt();dU();Du();gm();RBe=rC.$id,$0="./workspace-kinds",Zw="examples",lme="design",uV=[{name:"chant",description:"a chant project, with a chant.config.ts or chant.config.json in its directory",probe:{anyFile:["chant.config.ts","chant.config.json"]},precedence:500,shape:"member",outputs:{from:"chant-source"},source:"builtin"},{name:"workspace",description:"a nested workspace, with its own chant.workspace.json; the outer one reads it through its own chant workspace graph and never writes inside it",probe:{anyFile:["chant.workspace.json","chant.workspace.jsonc"]},precedence:1e3,shape:"member",outputs:{from:"none"},source:"builtin"},{name:"other",description:"a directory chant does not read; the entry says why in `because`",probe:{directory:!0},precedence:0,shape:"member",outputs:{from:"declared",names:[]},source:"builtin"},{name:lme,description:"a data member holding the design artifacts the workspace owns; chant reads its files for record pins and builds nothing",probe:{directory:!0},precedence:0,shape:"member",outputs:{from:"declared",names:[]},source:"builtin"},{name:Zw,description:"an example group: every directory its glob matches that holds a chant project is built and linted",probe:{chantProject:!0},precedence:0,shape:"group",outputs:{from:"none"},source:"builtin"}],ume=uV.map(e=>e.name);pme=["chant.config.ts","chant.config.json"],fme=4});function Qu(e){return String(e).replace(/~/g,"~0").replace(/\//g,"~1")}function fa(e,t){let n=[0];for(let b=0;b<e.length;b++)e.charCodeAt(b)===10&&n.push(b+1);let i=b=>{let w=0,x=n.length-1;for(;w<x;){let k=w+x+1>>1;n[k]<=b?w=k:x=k-1}return{line:w+1,column:b-n[w]+1}},r=new Map,o=new Map,s=new Map,a=e.charCodeAt(0)===65279?1:0,l=(b,w=a)=>{throw new Yw(b,w)},c=b=>b>=e.length?"the end of the file":`${JSON.stringify(e[b])}`;function u(){for(;;){let b=e[a];if(b===" "||b===" "||b===`
70
+ `||b==="\r")a++;else if(b==="/"&&(e[a+1]==="/"||e[a+1]==="*"))if(t.jsonc||l("comments are only allowed in chant.workspace.jsonc"),e[a+1]==="/")for(;a<e.length&&e[a]!==`
71
+ `;)a++;else{let w=e.indexOf("*/",a+2);w<0&&l("unterminated /* comment"),a=w+2}else return}}function d(){let b=a;for(a++;;){a>=e.length&&l("unterminated string",b);let w=e.charCodeAt(a);if(w===34)break;w<32&&l("control character in a string; escape it",a),a+=w===92?2:1}a++;try{return JSON.parse(e.slice(b,a))}catch{return l("invalid escape in a string",b)}}function p(b){u(),r.set(b,a);let w=f(b);return o.set(b,a),w}function f(b){let w=e[a];if(w==="{")return g(b);if(w==="[")return h(b);if(w==='"')return d();for(let[k,R]of[["true",!0],["false",!1],["null",null]])if(e.startsWith(k,a))return a+=k.length,R;let x=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/.exec(e.slice(a,a+64));return x?(a+=x[0].length,Number(x[0])):l(`expected a value, found ${c(a)}`)}function g(b){let w={},x=new Set;if(a++,u(),e[a]==="}")return a++,w;for(;;){u(),e[a]!=='"'&&l(`expected a quoted key, found ${c(a)}`);let k=a,R=d();x.has(R)&&l(`duplicate key ${JSON.stringify(R)}`,k),x.add(R);let $=`${b}/${Qu(R)}`;if(s.set($,k),u(),e[a]!==":"&&l(`expected ":" after key ${JSON.stringify(R)}, found ${c(a)}`),a++,Object.defineProperty(w,R,{value:p($),enumerable:!0,writable:!0,configurable:!0}),u(),e[a]===","){if(a++,u(),e[a]==="}")return t.jsonc||l("trailing comma; only chant.workspace.jsonc allows one"),a++,w;continue}if(e[a]==="}")return a++,w;l(`expected "," or "}", found ${c(a)}`)}}function h(b){let w=[];if(a++,u(),e[a]==="]")return a++,w;for(;;){if(w.push(p(`${b}/${w.length}`)),u(),e[a]===","){if(a++,u(),e[a]==="]")return t.jsonc||l("trailing comma; only chant.workspace.jsonc allows one"),a++,w;continue}if(e[a]==="]")return a++,w;l(`expected "," or "]", found ${c(a)}`)}}try{u(),a>=e.length&&l("the file is empty");let b=p("");return u(),a<e.length&&l(`unexpected ${c(a)} after the value`),{ok:!0,value:b,locate(w,x){if(x&&s.has(w))return i(s.get(w));for(let k=w;;k=k.slice(0,k.lastIndexOf("/"))){let R=r.get(k);if(R!==void 0)return i(R);if(k==="")return i(0)}},span(w){let x=r.get(w),k=o.get(w);if(!(x===void 0||k===void 0))return{key:s.get(w)??null,start:x,end:k}}}}catch(b){if(!(b instanceof Yw))throw b;return{ok:!1,message:b.message,location:i(b.offset)}}}var Yw,ed=v(()=>{"use strict";Yw=class extends Error{constructor(n,i){super(n);this.offset=i}}});function hV(){return"0.124.16"}var yV=v(()=>{"use strict"});var _0={};_e(_0,{CHANT_PACKAGE:()=>nd,DECLARATION_FILES:()=>td,DECLARATION_SCHEMA_ID:()=>kme,DECLARATION_SCHEMA_VERSION:()=>xme,DEFAULT_CI_WINDOW:()=>xV,DEFAULT_PUBLISH_BRANCH_PREFIX:()=>EV,DEFAULT_REPLICATE_REMOTE:()=>SV,DEFAULT_SHIP_ENV:()=>RV,DEFAULT_SHIP_GATE:()=>$V,DEFAULT_STATE_ROOT:()=>AV,DIAGRAM_TOOLS:()=>Eme,FACTORY_CHECK_KINDS:()=>Ame,NAME_PATTERN:()=>$me,PRINCIPAL_CLASSES:()=>Rme,REPLICATE_REF_CLASSES:()=>E0,REPLICATE_TRIGGERS:()=>A0,RESERVED_NAMES:()=>kV,WORKSPACE_ERROR_CODES:()=>co,WRITE_VERBS:()=>Sme,WorkspaceReadError:()=>ve,boxServicesProblem:()=>IV,compareVersions:()=>PV,declaredDiagrams:()=>O0,declaredRecordKinds:()=>Ti,extensionsAt:()=>hm,findDeclarationDir:()=>C0,isInside:()=>kr,ownerOf:()=>TV,parseDeclaration:()=>CV,pinnedChant:()=>Qw,readDeclaration:()=>Lt,readerVersion:()=>Xt,resolveGroups:()=>ma,rootExclusions:()=>ev});function Xt(){return bV??=hV(),bV}function PV(e,t){let n=P0.exec(e),i=P0.exec(t);if(!n||!i)throw new Error(`not a version: ${n?t:e}`);for(let r=1;r<=3;r++){let o=Number(n[r])-Number(i[r]);if(o!==0)return o}return n[4]===i[4]?0:n[4]===void 0?1:i[4]===void 0||n[4]<i[4]?-1:1}function Pme(){if(Xw)return Xw;let e=da();return Xw=new e({allErrors:!0,strict:!0}).compile(eC),Xw}function Ome(e,t){let n=/#\/\$defs\/([A-Za-z]+)\//.exec(e.schemaPath)?.[1];if(e.keyword==="pattern"){let i=JSON.stringify(t);return n==="name"&&typeof t=="string"&&kV.includes(t)?`${i} is reserved; pick another name`:n==="name"?`${i} is not a valid name: use lowercase letters, digits and hyphens, starting with a letter or digit, at most 40 characters`:n==="kindName"?`${i} is not a valid kind or role name`:n==="dir"?`${i} is not a directory inside the workspace: use a relative path with / separators, and no . or .. segments`:n==="path"?`${i} is not a path inside the member or workspace: use a relative path with / separators, and no . or .. segments`:n==="glob"?`${i} is not a glob inside the workspace: use a relative pattern with / separators, and no . or .. segments`:n==="version"?`${i} is not a version such as 1.2.3`:`${i} is not allowed here`}if(e.keyword==="additionalProperties")return`unknown field ${JSON.stringify(e.params.additionalProperty)}; only fields named x-... may be added`;if(e.keyword==="required"){let i=String(e.params.missingProperty);return i==="because"&&e.instancePath.endsWith("/handWritten")?'a hand-written generated file needs "because", saying why it is kept by hand':i==="because"?'a member of kind other needs "because", saying why it is there':`missing required field ${JSON.stringify(i)}`}return e.keyword==="const"&&e.instancePath==="/schema"?"schema must be 1, the only declaration format this chant reads":e.message??"is invalid"}function OV(e,t){let n=e;for(let i of t.split("/").slice(1)){let r=i.replace(/~1/g,"/").replace(/~0/g,"~");if(n===null||typeof n!="object")return;n=n[r]}return n}function Qw(e){if(!Array.isArray(e.pins))return;let t=e.pins.findIndex(n=>n!==null&&typeof n=="object"&&n.package===nd&&typeof n.version=="string");return t<0?void 0:{version:e.pins[t].version,index:t}}function CV(e,t,n=Xt(),i={}){let r=fa(e,{jsonc:t.endsWith(".jsonc")});if(!r.ok)throw new ve("declaration-unparseable",r.message,{file:t,...r.location});let o=(F,Q=!1)=>({file:t,...r.locate(F,Q)}),s=r.value;if(s===null||typeof s!="object"||Array.isArray(s))throw new ve("declaration-invalid","the declaration must be a JSON object",o(""));let a=s,l=i.rootChant?Qw(a):void 0;if(l&&l.version!==n)throw new ve("root-chant-required",`this declaration pins ${nd} ${l.version}, and this is chant ${n}; the root's chant reads it, so install ${nd}@${l.version} at the workspace root`,o(`/pins/${l.index}/version`));if(typeof a.minReader=="string"&&P0.test(a.minReader)&&PV(n,a.minReader)<0)throw new ve("reader-too-old",`this declaration needs chant ${a.minReader} or newer to read it, and this is chant ${n}`,o("/minReader"));let c=Pme();if(!c(s)){let F=(c.errors??[]).filter(we=>!Cme.has(we.keyword));F.sort((we,Ct)=>Ct.instancePath.split("/").length-we.instancePath.split("/").length);let Q=F[0]??c.errors[0],I=Q.keyword==="additionalProperties",B=I?`${Q.instancePath}/${Qu(String(Q.params.additionalProperty))}`:Q.instancePath,Z=Q.instancePath===""?"":` (at ${Q.instancePath})`,xe=F.length>1?`; ${F.length-1} more problem${F.length>2?"s":""} after this one`:"";throw new ve("declaration-invalid",`${Ome(Q,OV(s,Q.instancePath))}${Z}${xe}`,o(B,I))}let u=a.members.map((F,Q)=>{let I=`/members/${Q}`,B=(F.suppress??[]).map(Te=>({check:Te.check,because:Te.because}));if(F.kind===Zw){let Te=F.glob;return{type:"group",name:F.name,kind:Zw,globs:typeof Te=="string"?[Te]:[...Te],suppress:B,pointer:I,globLocation:r.locate(`${I}/glob`)}}let Z=(F.roles??[]).map(Te=>typeof Te=="string"?{name:Te,path:null}:{name:Te.name,path:Te.path??null}),xe=(F.generated??[]).map((Te,nt)=>({path:Te.path,generator:Te.generator,sources:[...Te.sources??[]],handWritten:Te.handWritten?{because:Te.handWritten.because}:null,pointer:`${I}/generated/${nt}`})),we=(F.links??[]).map((Te,nt)=>({member:Te.member,output:Te.output,kind:Te.kind??null,protocol:Te.protocol??null,pointer:`${I}/links/${nt}`})),Ct=wV(F.records,F.dir,F.name,`${I}/records`),at=vV(F.diagrams,F.name,`${I}/diagrams`),$e=jme(F.box,`${I}/box`);return{type:"member",name:F.name,dir:F.dir,kind:F.kind,roles:Z,generated:xe,outputs:F.outputs===void 0?null:[...F.outputs],fields:F.fields===void 0?null:structuredClone(F.fields),links:we,records:Ct,diagrams:at,box:$e,upstream:F.upstream??null,because:F.because??null,travel:F.travel===!0,suppress:B,pointer:I}}),d=new Map;for(let F of u){let Q=d.get(F.name);if(Q)throw new ve("declaration-invalid",`the name ${JSON.stringify(F.name)} is already used by the entry at ${Q.pointer}`,o(`${F.pointer}/name`));d.set(F.name,F)}let p=u.filter(F=>F.type==="member"),f=new Map;for(let F of p){let Q=f.get(F.dir);if(Q)throw new ve("placement-invalid",`member ${F.name} has the same directory as member ${Q.name} (${F.dir})`,o(`${F.pointer}/dir`));f.set(F.dir,F)}for(let F of p){let Q=p.find(I=>I!==F&&I.dir!=="."&&kr(F.dir,I.dir));if(Q)throw new ve("placement-invalid",`member ${F.name} (${F.dir}) sits inside member ${Q.name} (${Q.dir}); only the root member "." may contain other members`,o(`${F.pointer}/dir`))}for(let F of p){let Q=new Map;for(let I of F.generated){let B=Q.get(I.path);if(B)throw new ve("declaration-invalid",`member ${F.name} lists the generated file ${I.path} twice; the first is at ${B.pointer}`,o(`${I.pointer}/path`));Q.set(I.path,I);let Z=F.dir==="."?I.path:`${F.dir}/${I.path}`,xe=p.find(we=>we!==F&&we.dir!=="."&&kr(we.dir,F.dir)&&kr(Z,we.dir));if(xe)throw new ve("placement-invalid",`member ${F.name} lists the generated file ${I.path}, which sits inside member ${xe.name} (${xe.dir}); list it there`,o(`${I.pointer}/path`))}}let g=wV(a.records,".",null,"/records"),h=new Map,b=new Map;for(let F of[...g,...p.flatMap(Q=>Q.records)]){let Q=h.get(F.path);if(Q)throw new ve("declaration-invalid",`the record kind ${F.path} is already declared at ${Q.pointer}`,o(`${F.pointer}/kind`));if(h.set(F.path,F),F.name===null)continue;let I=b.get(F.name);if(I)throw new ve("declaration-invalid",`the record kind name ${JSON.stringify(F.name)} is already given at ${I.pointer}`,o(`${F.pointer}/name`));b.set(F.name,F)}for(let F of p){let Q=new Map;for(let B of F.box?.capabilities??[]){let Z=Q.get(B.name);if(Z)throw new ve("declaration-invalid",`member ${F.name}'s box lists the capability ${B.name} twice; the first is at ${Z.pointer}`,o(`${B.pointer}/name`));Q.set(B.name,B)}let I=F.box?IV(F.name,F.box.services):null;if(I)throw new ve("declaration-invalid",I.message,o(I.pointer))}let w=Lme(p);if(w)throw new ve("declaration-invalid",w.message,o(w.pointer));let x=p.filter(F=>F.box?.replicate);if(x.length>1)throw new ve("declaration-invalid",`members ${x[0].name} and ${x[1].name} both declare replicate in their box block; a checkout's work in progress goes to one remote, so a workspace has one replicate policy`,o(x[1].box.replicate.pointer));let k=vV(a.diagrams,null,"/diagrams"),R=new Map;for(let F of[...k,...p.flatMap(Q=>Q.diagrams)]){let Q=R.get(F.name);if(Q)throw new ve("declaration-invalid",`the diagram name ${JSON.stringify(F.name)} is already used by the diagram at ${Q.pointer}`,o(`${F.pointer}/name`));R.set(F.name,F)}let $=Bme(a,p,o),_=_me(a.writeScope,p,o),T=Dme(a.agents,p,o),C=Mme(p,T);if(C)throw new ve("declaration-invalid",C.message,o(C.pointer));let K=Tme(a.ci,o),O=(a.pins??[]).map(F=>({package:F.package??null,version:F.version??null,path:F.path??null,integrity:F.integrity??null})),pe={name:a.name,schema:a.schema,minReader:a.minReader??null,entries:u,members:p,groups:u.filter(F=>F.type==="group"),pins:O,checks:{...a.checks??{}},quorum:typeof a.quorum=="number"?a.quorum:null,records:g,diagrams:k,hosts:$,changes:Nme(a.changes),writeScope:_,agents:T,identity:Ime(a.identity),ci:K,file:t};return _V.set(pe,s),pe}function hm(e,t){let n=OV(_V.get(e),t);return n===null||typeof n!="object"||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).filter(([i])=>i.startsWith("x-")))}function _me(e,t,n){if(e===void 0)return null;let i=e,r={};for(let[o,s]of Object.entries(i)){let a=`/writeScope/${o}`,l=s.members===void 0||s.members==="*"?null:[...s.members];for(let[d,p]of(l??[]).entries())if(!t.some(f=>f.name===p))throw new ve("declaration-invalid",`writeScope.${o} names the member ${JSON.stringify(p)}, which the declaration does not declare; declared members: ${t.map(f=>f.name).join(", ")||"none"}`,n(`${a}/members/${d}`));let c=s.records===void 0?null:Object.fromEntries(Object.entries(s.records).map(([d,p])=>[d,[...p]])),u=(s.protected??[]).map(d=>typeof d=="string"?{path:d,except:[]}:{path:d.path,except:[...d.except??[]]});r[o]={members:l,records:c,protected:u,pointer:a}}return r}function Ime(e){if(e===void 0)return null;let t=e,n={};for(let[i,r]of Object.entries(t.gates??{}))n[i]={gate:i,class:r.class??null,pointer:`/identity/gates/${i.replace(/~/g,"~0").replace(/\//g,"~1")}`};return{attribution:t.attribution??"any",gates:n}}function Tme(e,t){if(e===void 0)return null;let n=e;if(n.green===void 0)return{green:null};let i=n.green,r=Object.entries(i.phases).map(([o,s])=>({name:o,runs:[...Array.isArray(s)?s:s.runs],skipped:Array.isArray(s)?"fail":s.skipped??"fail",pointer:`/ci/green/phases/${Qu(o)}`}));for(let[o,s]of i.require.entries())if(!r.some(a=>a.name===s))throw new ve("declaration-invalid",`ci.green.require names the phase ${JSON.stringify(s)}, which ci.green.phases does not declare; declared phases: ${r.map(a=>a.name).join(", ")}`,t(`/ci/green/require/${o}`));return{green:{branch:i.branch,window:i.window??xV,phases:r,require:[...i.require],pointer:"/ci/green"}}}function Dme(e,t,n){let i=(e??[]).map((s,a)=>{let l=s.members!==void 0?[...s.members]:[s.member];return{name:s.name,members:l,member:l[0],principals:[...s.principals??[]],pointer:`/agents/${a}`,listed:s.members!==void 0}}),r=new Map,o=new Map;for(let{listed:s,...a}of i){let l=r.get(a.name);if(l)throw new ve("declaration-invalid",`the agent name ${JSON.stringify(a.name)} is already used by the agent at ${l.pointer}`,n(`${a.pointer}/name`));r.set(a.name,a);for(let[c,u]of a.members.entries())if(!t.some(d=>d.name===u))throw new ve("declaration-invalid",`agent ${a.name} is bound to ${JSON.stringify(u)}, which is not a declared member; an agent session is bound to members, not an example group`,n(s?`${a.pointer}/members/${c}`:`${a.pointer}/member`));for(let[c,u]of a.principals.entries()){let d=o.get(u);if(d)throw new ve("declaration-invalid",`the principal ${JSON.stringify(u)} is already listed by agent ${d.name}`,n(`${a.pointer}/principals/${c}`));o.set(u,a)}}return[...r.values()]}function Nme(e){return e===void 0?null:{severity:e.severity??"warn",ignore:[...e.ignore??[]]}}function wV(e,t,n,i){return(e??[]).map((r,o)=>({kind:r.kind,path:t==="."?r.kind:`${t}/${r.kind}`,name:r.name??null,member:n,pointer:`${i}/${o}`}))}function vV(e,t,n){return(e??[]).map((i,r)=>({name:i.name,title:i.title,source:i.source??null,render:i.render??null,renderer:{tool:i.renderer.tool,version:i.renderer.version,args:[...i.renderer.args??[]]},sourceHash:i.sourceHash??null,member:t,pointer:`${n}/${r}`}))}function jme(e,t){if(e===void 0)return null;let n=e,i=n.factory,r=n.listing,o=n.replicate;return{capabilities:(n.capabilities??[]).map((s,a)=>({name:s.name,broker:s.broker??null,scope:[...s.scope??[]],pointer:`${t}/capabilities/${a}`})),isolation:n.host===void 0?null:{host:n.host,slot:n.slot,ports:{...n.ports??{}},state:{...n.state??{}},cookies:[...n.cookies??[]]},intent:n.intent??null,services:(n.services??[]).map((s,a)=>({name:s.name,cmd:s.cmd,needs:[...s.needs??[]],httpPort:s.httpPort??null,duration:s.duration??null,health:s.health??null,optional:s.optional??!1,pointer:`${t}/services/${a}`})),factory:i===void 0?null:{builds:[...i.builds],check:i.check===void 0?null:typeof i.check=="string"?{run:i.check,kind:"test"}:{run:i.check.run,kind:i.check.kind??"test"},checks:i.checks??null,builders:i.builders??null,tiers:(i.tiers??[]).map(s=>({tier:s.tier,agent:s.agent,kinds:s.kinds===void 0?null:[...s.kinds],session:s.session??null})),publish:i.publish===void 0?null:{forge:i.publish.forge??"github",repo:i.publish.repo,base:i.publish.base??null,branchPrefix:i.publish.branchPrefix??EV,head:i.publish.head??null},pointer:`${t}/factory`},listing:r===void 0?null:{published:r.published??!0,title:r.title??"",line:r.line??"",cover:r.cover??null},publisher:n.publisher??null,ship:n.ship===void 0?null:{op:n.ship.op,gate:n.ship.gate??$V,env:n.ship.env??RV,bookkeeping:(n.ship.bookkeeping??[]).map(s=>s.replace(/^\.\//,"").replace(/\/+$/,"")),pointer:`${t}/ship`},replicate:o===void 0?null:{remote:o.remote??SV,refs:E0.filter(s=>(o.refs??E0).includes(s)),on:A0.filter(s=>(o.on??A0).includes(s)),every:o.every??null,pointer:`${t}/replicate`},pointer:t}}function Lme(e){let t=e.filter(s=>s.box?.factory);if(t.length>1)return{message:`members ${t[0].name} and ${t[1].name} both declare a factory in their box block; a workspace has one factory, so an orchestrator reads one`,pointer:t[1].box.factory.pointer};let n=t[0]?.box?.factory;if(!n)return null;let i=()=>e.map(s=>s.name).join(", "),r=n.builds.findIndex(s=>!e.some(a=>a.name===s));if(r>=0)return{message:`the factory builds ${JSON.stringify(n.builds[r])}, which is not a declared member; declared members: ${i()}`,pointer:`${n.pointer}/builds/${r}`};if(n.builders!==null&&!e.some(s=>s.name===n.builders))return{message:`the factory's builders names ${JSON.stringify(n.builders)}, which is not a declared member; declared members: ${i()}`,pointer:`${n.pointer}/builders`};if(n.tiers.length>0&&n.builders===null)return{message:"the factory declares tiers and no builders; tiers name agents the builders member declares, so name it",pointer:`${n.pointer}/tiers`};let o=new Map;for(let[s,a]of n.tiers.entries())for(let l of a.kinds??[null]){let c=`${a.tier}\0${l??""}`,u=o.get(c);if(u!==void 0){let d=l===null?"with no kinds":`for kind ${l}`;return{message:`tiers/${u} and tiers/${s} both name a builder at tier ${a.tier} ${d}; a tier has one builder per kind, so one entry answers it`,pointer:`${n.pointer}/tiers/${s}`}}o.set(c,s)}return null}function Mme(e,t){let n=e.find(i=>i.box?.factory)?.box?.factory;if(!n)return null;for(let[i,r]of n.tiers.entries())if(r.session!==null&&!t.some(o=>o.name===r.session)){let o=t.map(s=>s.name).join(", ")||"none";return{message:`tiers/${i} names the session ${JSON.stringify(r.session)}, which is not a declared agent session; declared sessions: ${o}`,pointer:`${n.pointer}/tiers/${i}/session`}}return null}function IV(e,t){let n=new Map;for(let o of t){let s=n.get(o.name);if(s)return{message:`member ${e}'s box declares the service ${o.name} twice; the first is at ${s.pointer}`,pointer:`${o.pointer}/name`};n.set(o.name,o)}let i;for(let o of t)if(o.httpPort!==null){if(i)return{message:`member ${e}'s box gives both ${i.name} (port ${i.httpPort}) and ${o.name} (port ${o.httpPort}) an httpPort, and the supervisor routes the sprite's URL to one service`,pointer:`${o.pointer}/httpPort`};i=o}for(let o of t){let s=o.needs.findIndex(a=>!n.has(a));if(s>=0){let a=t.map(l=>l.name).join(", ");return{message:`member ${e}'s box service ${o.name} needs ${JSON.stringify(o.needs[s])}, which the block does not declare; declared services: ${a}`,pointer:`${o.pointer}/needs/${s}`}}}let r=Fme(t);if(r){let o=n.get(r[0]);return{message:`member ${e}'s box services need each other in a cycle: ${r.join(" -> ")}`,pointer:`${o.pointer}/needs`}}return null}function Fme(e){let t=new Map(e.map(r=>[r.name,r])),n=new Map,i=(r,o)=>{let s=n.get(r);if(s==="done")return null;if(s==="visiting")return[...o.slice(o.indexOf(r)),r];n.set(r,"visiting");for(let a of t.get(r)?.needs??[]){let l=i(a,[...o,r]);if(l)return l}return n.set(r,"done"),null};for(let r of e){let o=i(r.name,[]);if(o)return o}return null}function Bme(e,t,n){let i=(e.hosts??[]).map((s,a)=>({name:s.name,ports:{...s.ports},stateRoot:s.stateRoot??null,pointer:`/hosts/${a}`})),r=(s,a)=>new ve("declaration-invalid",s,n(a)),o=new Map;for(let s of i){let a=o.get(s.name);if(a)throw r(`the host name ${JSON.stringify(s.name)} is already used by the host at ${a.pointer}`,`${s.pointer}/name`);if(o.set(s.name,s),s.ports.from>s.ports.to)throw r(`host ${s.name}'s port range starts at ${s.ports.from}, after its end ${s.ports.to}`,`${s.pointer}/ports`)}for(let s of t){let a=s.box?.isolation;if(!a)continue;let l=s.box.pointer,c=o.get(a.host);if(!c){let g=i.map(h=>h.name).join(", ")||"none are declared";throw r(`member ${s.name}'s box names the host ${JSON.stringify(a.host)}, which hosts does not declare; declared hosts: ${g}`,`${l}/host`)}let{from:u,to:d,perBox:p}=c.ports,f=u+(a.slot+1)*p-1;if(f>d){let g=Math.floor((d-u+1)/p);throw r(`member ${s.name}'s box has slot ${a.slot} on host ${c.name}, which needs ports ${u+a.slot*p} to ${f}, past the end of the host's range (${d}); the range holds ${g} slot${g===1?"":"s"}`,`${l}/slot`)}for(let[g,h]of Object.entries(a.ports))if(h>=p)throw r(`member ${s.name}'s box gives port ${g} offset ${h}, and host ${c.name} gives each box ${p} port${p===1?"":"s"} (offsets 0 to ${p-1})`,`${l}/ports/${Qu(g)}`)}return i}function Ti(e){return[...e.records,...e.members.flatMap(t=>t.records)]}function O0(e){return[...e.diagrams,...e.members.flatMap(t=>t.diagrams)]}function kr(e,t){return t==="."?!0:e===t||e.startsWith(`${t}/`)}function Lt(e,t="",n={}){let i=td.map(r=>ze(t,r)).filter(r=>e.stat(r)==="file");if(i.length===0)throw new ve("declaration-missing",`no ${td.join(" or ")} in ${t||"the workspace root"}${e.label}`);if(i.length>1)throw new ve("declaration-ambiguous",`both ${i.join(" and ")} exist${e.label}; keep one of them`,{file:i[1],line:1,column:1});return CV(e.read(i[0]),i[0],Xt(),n)}function C0(e,t){for(let n=t;;n=n.includes("/")?n.slice(0,n.lastIndexOf("/")):""){if(td.some(i=>e.stat(ze(n,i))==="file"))return n;if(n==="")return}}function ma(e,t){let n=o=>({file:e.file,...o.globLocation}),i=new Map,r=[];for(let o of e.groups){let s=[...new Set(o.globs.flatMap(c=>iU(t,c)))].sort(),a=[],l=[];for(let c of s){if(!R0(t,c)){l.push(c);continue}let u=p=>new ve("placement-invalid",`group ${o.name} matches ${c}, ${p}`,n(o));for(let p of e.members)if(p.dir!=="."){if(p.dir===c)throw u(`which is member ${p.name}'s directory; a match is never a member`);if(kr(p.dir,c))throw u(`which contains member ${p.name} (${p.dir})`);if(p.kind==="workspace"&&kr(c,p.dir))throw u(`which sits inside the nested workspace ${p.name}; that workspace declares its own examples`)}let d=i.get(c);if(d)throw u(`which group ${d.name} also matches`);i.set(c,o),a.push(c)}r.push({group:o,matches:a,skipped:l})}return r}function TV(e,t,n){for(let r of t){let o=r.matches.find(s=>kr(n,s));if(o)return{group:r.group,match:o}}let i;for(let r of e.members)kr(n,r.dir)&&(!i||i.dir==="."||r.dir!=="."&&r.dir.length>i.dir.length)&&(i=r);return i?{member:i}:void 0}function ev(e,t){let n=[];for(let i of e.members)i.dir!=="."&&n.push({dir:i.dir,owner:i.name});for(let i of t)for(let r of i.matches)e.members.some(o=>o.dir!=="."&&kr(r,o.dir))||n.push({dir:r,owner:i.group.name});return n.sort((i,r)=>i.dir<r.dir?-1:i.dir>r.dir?1:0)}var kme,td,xme,kV,$me,co,ve,Rme,Sme,xV,Eme,$V,RV,E0,A0,SV,Ame,EV,AV,nd,bV,P0,Xw,Cme,_V,_t=v(()=>{"use strict";Qz();oU();ao();ed();Zt();gm();yV();kme=eC.$id,td=["chant.workspace.json","chant.workspace.jsonc"],xme=1,kV=["_workspace","_members"],$me=/^[a-z0-9][a-z0-9-]{0,39}$/,co=["declaration-missing","declaration-ambiguous","declaration-unparseable","declaration-invalid","placement-invalid","reader-too-old","root-chant-required","not-a-git-repository","revision-unknown"],ve=class extends Error{constructor(n,i,r){super(i);this.code=n;this.location=r;this.name="WorkspaceReadError"}describe(){let n=this.location;return n?`${n.file}:${n.line}:${n.column}: ${this.message}`:this.message}},Rme=["human","agent","runner","service"],Sme=["new","amend","review","close"],xV="24h",Eme=["d2","mermaid","graphviz","excalidraw"],$V="ship",RV="box",E0=["work","kept","wip","ledger"],A0=["save","release"],SV="origin",Ame=["test","build","lint","plan","conformance"],EV="chant/work/",AV="${XDG_STATE_HOME}/chant/boxes",nd="@intentius/chant";P0=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?$/;Cme=new Set(["if","then","else","oneOf","anyOf"]);_V=new WeakMap});import{existsSync as Gme}from"node:fs";import{dirname as Wme,join as zme,relative as Ume,resolve as Hme,sep as Vme}from"node:path";function D0(e){return e.map(t=>`${DV}/${t}/`).join("")}function ri(e){let t=Hme(e),n=I0.get(t);return n||(n=Kme(t),I0.set(t,n),n.catch(()=>I0.delete(t))),n}function qme(e,t){let n=Ume(e,t);return n===""?"":n.split(Vme).join("/")}async function Kme(e){let t=gr(e);return t?jV(t.dir,e):NV}async function jV(e,t){let{readDeclaration:n,resolveGroups:i,ownerOf:r,WorkspaceReadError:o}=await Promise.resolve().then(()=>(_t(),_0)),{workingTree:s}=await Promise.resolve().then(()=>(Zt(),nC)),a;try{let d=s(e),p=n(d),f=r(p,i(p,d),qme(e,t));a=f&&"member"in f&&f.member.dir!=="."?[f.member.name]:[]}catch(d){throw d instanceof o?new T0(`cannot place this project's lifecycle ledger: ${d.describe()}. A project inside a workspace writes under ${DV}/<member>/ on chant/lifecycle, and chant does not guess the member. Fix the declaration and retry.`):d}let l=NV,c=Wme(e);if(c!==e&&!Gme(zme(e,".git"))){let d=gr(c);d&&(l=await jV(d.dir,e))}let u=[...l.members,...a];return{members:u,prefix:D0(u)}}var DV,NV,T0,I0,ga=v(()=>{"use strict";Ri();DV="_members",NV={members:[],prefix:""};T0=class extends Error{constructor(t){super(t),this.name="MemberLedgerError"}},I0=new Map});function N0(e){return e===rd}var rd,tv=v(()=>{"use strict";rd="recorded locally (no remote for chant/lifecycle)"});var z0={};_e(z0,{LifecycleLedgerUnreadableError:()=>ym,RefCASConflictError:()=>Vt,StaleLifecycleBranchError:()=>id,StaleLockError:()=>Nc,appendReleaseRecordLine:()=>zV,deleteRefCAS:()=>ad,describeLifecyclePush:()=>G0,fetchLifecycle:()=>qV,fetchLifecycleStatus:()=>ya,fetchRef:()=>oge,fetchRefInto:()=>YV,fetchRefIntoStatus:()=>rv,getHeadCommit:()=>iv,getRemoteLifecycleBranchSha:()=>VV,gitLedgerReadPort:()=>cge,ledgerDir:()=>ii,listFilesInDir:()=>Lc,listLedgerEnvironments:()=>HV,listLedgerTrees:()=>B0,listSnapshots:()=>tge,pushLifecycle:()=>Mc,pushLifecycleReport:()=>ha,pushLifecycleStatus:()=>od,pushRef:()=>ige,pushRefStatus:()=>bm,readBlobBySha:()=>fn,readBlobFromPath:()=>nn,readEnvironmentSnapshots:()=>ege,readPathSha:()=>xr,readRefSha:()=>Fc,readReleaseLedgerLines:()=>UV,readSnapshot:()=>WV,readSnapshotAt:()=>Qme,requireLifecycleLedger:()=>oi,snapshotStorageKey:()=>BV,updateRefCAS:()=>sd,writeBlob:()=>W0,writeBlobToPath:()=>An,writeLedgerFiles:()=>F0,writeSnapshot:()=>GV});async function ii(e,t){return`${await Jme(t)}${e}`}async function Jme(e){return e?.ledgerPrefix!==void 0?e.ledgerPrefix:e?.member!==void 0?D0((typeof e.member=="string"?[e.member]:[...e.member]).filter(t=>t!==".")):(await ri(e?.cwd??process.cwd())).prefix}async function Xme(e){let t=ot();if((await t.spawn(["git","var","GIT_COMMITTER_IDENT"],{cwd:e,env:Di})).exitCode===0)return[];let i=[];for(let[r,o,s]of[["user.name","CHANT_LIFECYCLE_COMMITTER_NAME",Zme],["user.email","CHANT_LIFECYCLE_COMMITTER_EMAIL",Yme]]){let a=await t.spawn(["git","config","--get",r],{cwd:e,env:Di});a.exitCode===0&&a.stdout.trim()!==""||i.push("-c",`${r}=${process.env[o]?.trim()||s}`)}return i}function j0(e,t,n){return new Error(`cannot write ${t} on the ${yt} branch: ${e} failed: ${(n??"").trim()}`)}async function An(e,t,n,i,r){let o=await ii(e,r);return F0([{path:`${o}/${t}`,content:n,...r?.expectPriorPathSha!==void 0?{expectPriorSha:r.expectPriorPathSha}:{}}],i,r)}async function F0(e,t,n){let i=ot(),r=n?.cwd;if(e.length===0)throw new Error("writeLedgerFiles needs at least one file");let o=e[0].path;for(let u of e){let d=u.path.split("/");if(d.length<2||d.some(p=>p===""))throw new Error(`cannot write ${u.path} on the ${yt} branch: a ledger path is <dir>/<file>`)}let s=[];for(let u of e){let d=await i.spawn(["git","hash-object","-w","--stdin"],{cwd:r,stdin:u.content});if(d.exitCode!==0)throw j0("git hash-object",u.path,d.stderr);s.push({path:u.path,sha:d.stdout.trim()})}let a=await Xme(r);await jc(r)===null&&await oi({...r?{cwd:r}:{}});let l=new Map(e.map(u=>[u.path,u.expectPriorSha])),c;for(let u=1;u<=FV;u++){let d=await jc(r),p=new Map,f=async R=>{let $=p.get(R);return $||($=d?await sge(d,R,r):new Map,p.set(R,$)),$};for(let R of s){let{dir:$,name:_}=LV(R.path),T=(await f($)).get(_),C=T?.type==="blob"?T.sha:null,K=l.get(R.path);if(K!==void 0&&C!==K)throw c??new Vt(`refs/heads/${yt}`,K,"target path changed concurrently");l.set(R.path,C)}for(let R of s){let{dir:$,name:_}=LV(R.path);(await f($)).set(_,{mode:"100644",type:"blob",sha:R.sha});for(let T=$;T!=="";T=L0(T))await f(L0(T))}let g=[...p.keys()].sort((R,$)=>MV($)-MV(R)||(R<$?-1:1)),h="";for(let R of g){let $=[...p.get(R)].map(([C,K])=>`${K.mode} ${K.type} ${K.sha} ${C}`).join(`
72
+ `),_=await i.spawn(["git","mktree"],{cwd:r,stdin:`${$}
73
+ `});if(_.exitCode!==0)throw j0(`git mktree (${R===""?"root":R})`,o,_.stderr);let T=_.stdout.trim();R===""?h=T:p.get(L0(R)).set(age(R),{mode:"040000",type:"tree",sha:T})}let b=d,w=b?["-p",b]:[],x=await i.spawn(["git",...a,"commit-tree",...w,"-m",t,h],{cwd:r});if(x.exitCode!==0)throw j0("git commit-tree",o,x.stderr);let k=x.stdout.trim();try{return await sd(`refs/heads/${yt}`,k,b,{cwd:r}),k}catch(R){if(!(R instanceof Vt))throw R;c=R}}throw c}async function nn(e,t,n){let i=ot(),r=await ii(e,n),o=await i.spawn(["git","show",`${yt}:${r}/${t}`],{cwd:n?.cwd});return o.exitCode!==0?null:o.stdout}async function xr(e,t,n){let i=ot(),r=await ii(e,n),o=await i.spawn(["git","rev-parse","--verify",`${yt}:${r}/${t}`],{cwd:n?.cwd});return o.exitCode!==0?null:o.stdout.trim()||null}function BV(e,t){return t?`${t}__${e}`:e}async function GV(e,t,n,i){return An(e,`${t}.json`,n,"State snapshot",i)}async function WV(e,t,n){return nn(e,`${t}.json`,n)}async function Qme(e,t,n,i){let r=ot(),o=await ii(e,i),s=await r.spawn(["git","show",`${n}:${o}/${t}.json`],{cwd:i?.cwd});return s.exitCode!==0?null:s.stdout}async function zV(e,t,n){let i="releases.jsonl",r;for(let o=1;o<=FV;o++)try{let s=await xr(e,i,n),a=s?await fn(s,n):null,l=`${a?`${a.replace(/\n$/,"")}
74
+ `:""}${t}
75
+ `;return await An(e,i,l,"Release record",{...n,expectPriorPathSha:s})}catch(s){if(!(s instanceof Vt))throw s;r=s}throw r}async function UV(e,t){let n=await nn(e,"releases.jsonl",t);return n?n.split(`
76
+ `).map(i=>i.trim()).filter(Boolean):[]}async function HV(e){let t=[];for(let n of await B0(e))await nn(n,"releases.jsonl",e)&&t.push(n);return t.sort()}async function B0(e){if(!await jc(e?.cwd))return[];let n=ot(),i=await ii("",e),r=await n.spawn(["git","ls-tree","--full-tree",i===""?yt:`${yt}:${i}`],{cwd:e?.cwd});if(r.exitCode!==0)return[];let o=[];for(let s of r.stdout.trim().split(`
77
+ `).filter(Boolean)){let a=s.match(/^(\d+)\s+(\w+)\s+([0-9a-f]+)\t(.+)$/);a&&a[2]==="tree"&&o.push(a[4])}return o}async function Lc(e,t){if(!await jc(t?.cwd))return[];let i=ot(),r=await ii(e,t),o=await i.spawn(["git","ls-tree","--full-tree","--name-only",`${yt}:${r}/`],{cwd:t?.cwd});return o.exitCode!==0?[]:o.stdout.trim().split(`
78
+ `).filter(Boolean)}async function ege(e,t){let n=ot(),i=new Map,r=await ii(e,t),o=await n.spawn(["git","ls-tree","--full-tree","--name-only",`${yt}:${r}/`],{cwd:t?.cwd});if(o.exitCode!==0)return i;let s=o.stdout.trim().split(`
79
+ `).filter(Boolean);for(let a of s)if(a.endsWith(".json")){let l=a.replace(/\.json$/,""),c=await WV(e,l,t);c&&i.set(l,c)}return i}async function tge(e){let t=ot(),n=await ii("",e),i=await t.spawn(["git","log","--format=%H %aI %s",yt,...n===""?[]:["--",`:(top)${n}`]],{cwd:e?.cwd});return i.exitCode!==0?[]:i.stdout.trim().split(`
80
+ `).filter(Boolean).map(r=>{let[o,s,...a]=r.split(" ");return{commit:o,date:s,message:a.join(" ")}})}async function VV(e,t){let n=ot(),i=`refs/remotes/${e}/${yt}`,r=await n.spawn(["git","rev-parse","--verify",i],{cwd:t?.cwd});return r.exitCode!==0?null:r.stdout.trim()||null}async function M0(e,t,n){await ot().spawn(["git","update-ref",`refs/remotes/${e}/${yt}`,t],{cwd:n,env:Di})}async function od(e){let t=ot(),n=e?.cwd,i=await JV(n);if(i===null)return{status:"no-remote"};if("failed"in i)return{status:"failed",remote:"(unknown)",stderr:i.stderr};let{remote:r}=i,o=await VV(r,e),s=`refs/heads/${yt}:${o??""}`,a=await jc(n),l=await t.spawn(["git","push",`--force-with-lease=${s}`,r,`${yt}:${yt}`],{cwd:n,env:Di});if(l.exitCode!==0){let c=(l.stderr??"").trim();return c.includes("stale info")||c.includes("rejected")||c.includes("non-fast-forward")?{status:"stale",remote:r,expected:o,stderr:c}:{status:"failed",remote:r,stderr:c}}return a&&await M0(r,a,n),{status:"pushed",remote:r,commit:a??""}}async function Mc(e){let t=await od(e);if(t.status==="stale")throw new id(t.expected,t.stderr);return t.status==="pushed"}function G0(e){let t=n=>n?`; git said: ${n.split(`
81
+ `).find(i=>i.trim())??n}`:"";switch(e.status){case"pushed":return null;case"no-remote":return`this repository has no remote, so ${yt} stays local`;case"stale":return`"${e.remote}" holds ${yt} commits this checkout has not fetched, so the push was refused; fetch ${yt} and write again${t(e.stderr)}`;case"failed":return`the push of ${yt} to "${e.remote}" failed${t(e.stderr)}`}}async function ha(e){try{let t=await od(e);switch(t.status){case"pushed":return{pushed:!0};case"no-remote":return{pushed:!1,pushWarning:rd};case"stale":return{pushed:!1,pushWarning:new id(t.expected,t.stderr).message};case"failed":return{pushed:!1,pushWarning:G0(t)??"the push did not land"}}}catch(t){return{pushed:!1,pushWarning:t instanceof Error?t.message:String(t)}}}async function qV(e){return(await ya(e)).status==="fetched"}async function JV(e){let n=await ot().spawn(["git","remote"],{cwd:e,env:Di});if(n.exitCode!==0)return{failed:!0,stderr:(n.stderr??"").trim()};let i=n.stdout.trim().split(`
82
+ `).map(r=>r.trim()).filter(Boolean);return i.length===0?null:{remote:i.includes("origin")?"origin":i[0]}}async function ya(e){let t=ot(),n=e?.cwd,i=await JV(n);if(i===null)return{status:"no-remote"};if("failed"in i)return{status:"unreachable",remote:"(unknown)",stderr:i.stderr};let{remote:r}=i,o=await t.spawn(["git","fetch",r,`${yt}:${yt}`],{cwd:n,env:Di});if(o.exitCode===0){let u=await jc(n);return u&&await M0(r,u,n),{status:"fetched"}}let s=(o.stderr??"").trim();if(KV.test(s))return{status:"absent",remote:r};if(!nge.test(s))return{status:"unreachable",remote:r,stderr:s};let a=await t.spawn(["git","fetch","--force",r,`${yt}:${nv}`],{cwd:n,env:Di});if(a.exitCode!==0)return{status:"unreachable",remote:r,stderr:(a.stderr??"").trim()||s};let l=await t.spawn(["git","merge-base","--is-ancestor",nv,`refs/heads/${yt}`],{cwd:n,env:Di}),c=l.exitCode===0?(await t.spawn(["git","rev-parse","--verify",nv],{cwd:n,env:Di})).stdout.trim():"";return await t.spawn(["git","update-ref","-d",nv],{cwd:n,env:Di}),l.exitCode===0?(c&&await M0(r,c,n),{status:"ahead",remote:r}):{status:"diverged",remote:r,stderr:s}}async function oi(e){let t=await jc(e?.cwd)!==null,n=await ya(e);if(n.status==="diverged")throw new ym("diverged",n.remote,n.stderr,`has diverged from the copy on "${n.remote}" \u2014 neither contains the other`);if(n.status==="unreachable"&&!t)throw new ym("unreachable",n.remote,n.stderr,`is not in this checkout and could not be fetched from "${n.remote}"`)}async function Fc(e,t){let i=await ot().spawn(["git","rev-parse","--verify",e],{cwd:t?.cwd});return i.exitCode!==0?null:i.stdout.trim()||null}async function ZV(e,t,n,i){let r=n.match(rge);return r?new Nc(e,r[1],n):await Fc(e,i)!==t?new Vt(e,t,n):new Error(`git update-ref failed for ref "${e}": ${n.trim()}`)}async function sd(e,t,n,i){let o=await ot().spawn(["git","update-ref",e,t,n??""],{cwd:i?.cwd});if(o.exitCode!==0)throw await ZV(e,n,o.stderr??"",i)}async function ad(e,t,n){let r=await ot().spawn(["git","update-ref","-d",e,t],{cwd:n?.cwd});if(r.exitCode!==0)throw await ZV(e,t,r.stderr??"",n)}async function W0(e,t){let i=await ot().spawn(["git","hash-object","-w","--stdin"],{cwd:t?.cwd,stdin:e});if(i.exitCode!==0)throw new Error(`git hash-object failed: ${i.stderr}`);return i.stdout.trim()}async function fn(e,t){let i=await ot().spawn(["git","cat-file","blob",e],{cwd:t?.cwd});return i.exitCode!==0?null:i.stdout}async function ige(e,t){return await bm(e,t)==="pushed"}async function bm(e,t){let n=ot(),i=await n.spawn(["git","remote"],{cwd:t?.cwd});if(i.exitCode!==0||!i.stdout.trim())return"no-remote";let r=i.stdout.trim().split(`
83
+ `)[0],o;if(t?.expect!==void 0)o=t.expect;else{let u=`refs/remotes/${r}/${e.replace(/^refs\//,"")}`,d=await n.spawn(["git","rev-parse","--verify",u],{cwd:t?.cwd});o=d.exitCode===0?d.stdout.trim():null}let s=`${e}:${o??""}`,a=await Fc(e,t);if(a===null&&o===null)return"pushed";let l=a===null?`:${e}`:`${e}:${e}`;return(await n.spawn(["git","push",`--force-with-lease=${s}`,r,l],{cwd:t?.cwd})).exitCode===0?"pushed":"rejected"}async function YV(e,t,n){return await rv(e,t,n)==="fetched"}async function rv(e,t,n){let i=ot(),r=await i.spawn(["git","remote"],{cwd:n?.cwd});if(r.exitCode!==0||!r.stdout.trim())return"no-remote";let o=r.stdout.trim().split(`
84
+ `)[0],s=await i.spawn(["git","fetch",o,`+${e}:${t}`],{cwd:n?.cwd,env:Di});return s.exitCode===0?"fetched":KV.test(s.stderr??"")?"missing":"failed"}async function oge(e,t){return YV(e,e,t)}async function iv(e){let n=await ot().spawn(["git","rev-parse","HEAD"],{cwd:e?.cwd});if(n.exitCode!==0)throw new Error(`git rev-parse HEAD failed: ${n.stderr}`);return n.stdout.trim()}async function jc(e){let n=await ot().spawn(["git","rev-parse","--verify",`refs/heads/${yt}`],{cwd:e});return n.exitCode!==0?null:n.stdout.trim()}async function sge(e,t,n){let i=ot(),r=new Map,o=await i.spawn(["git","ls-tree","--full-tree",t===""?e:`${e}:${t}/`],{cwd:n});if(o.exitCode!==0)return r;for(let s of o.stdout.split(`
85
+ `)){let a=s.match(/^(\d+)\s+(\w+)\s+([0-9a-f]+)\t(.+)$/);a&&r.set(a[4],{mode:a[1],type:a[2],sha:a[3]})}return r}function LV(e){let t=e.lastIndexOf("/");return{dir:e.slice(0,t),name:e.slice(t+1)}}function L0(e){let t=e.lastIndexOf("/");return t<0?"":e.slice(0,t)}function age(e){return e.slice(e.lastIndexOf("/")+1)}function MV(e){return e===""?0:e.split("/").length}function cge(e){return{read:(t,n)=>nn(t,n,e),list:t=>Lc(t,e),trees:()=>B0(e)}}var yt,Zme,Yme,FV,id,KV,nge,Di,nv,ym,Vt,Nc,rge,$t=v(()=>{"use strict";to();ga();tv();yt="chant/lifecycle";Zme="chant",Yme="chant@localhost";FV=5;id=class extends Error{constructor(t,n){super(`chant/lifecycle remote branch has moved since this run started \u2014 another snapshot was pushed concurrently. git stderr: ${n.trim()}`),this.name="StaleLifecycleBranchError",this.expected=t}};KV=/couldn't find remote ref|no such ref was fetched/i,nge=/non-fast-forward|rejected/i,Di={LC_ALL:"C",LANGUAGE:""};nv="refs/chant/lifecycle-probe";ym=class extends Error{constructor(n,i,r,o){super(`the ${yt} ledger branch ${o}, so what is on it cannot be read. Refusing rather than treating an unreadable ledger as an empty one.`+(n==="diverged"?`
86
+ Two histories claim to be the ledger; appending to either one drops the other's facts. Inspect both before doing anything else:
87
+ git fetch ${i} ${yt}:refs/chant/remote-ledger
88
+ git log --oneline ${yt} refs/chant/remote-ledger`:`
89
+ Fetch it and retry: git fetch ${i} ${yt}:${yt}`)+(r?`
90
+ git said: ${r.split(`
91
+ `)[0]}`:""));this.reason=n;this.remote=i;this.stderr=r;this.name="LifecycleLedgerUnreadableError"}};Vt=class extends Error{constructor(n,i,r){super(`ref "${n}" moved concurrently \u2014 expected ${i??"(ref must not exist)"}, but another writer updated it first. git stderr: ${r.trim()}`);this.ref=n;this.expected=i;this.name="RefCASConflictError"}},Nc=class extends Error{constructor(n,i,r){super(`ref "${n}" has a stale lock file at ${i} \u2014 a previous git process (e.g. a killed \`chant operator\`) was interrupted mid-write and left it behind. Fix: remove it (\`rm ${i}\`) and retry. git stderr: ${r.trim()}`);this.ref=n;this.lockPath=i;this.name="StaleLockError"}},rge=/Unable to create '([^']+)':\s*File exists/});function os(e=process.env){let t=/^(\d+)\/(merge|head)$/.exec(e.GITHUB_REF_NAME??"")?.[1];if(t&&e.GITHUB_REPOSITORY)return`${(e.GITHUB_SERVER_URL??"https://github.com").replace(/\/$/,"")}/${e.GITHUB_REPOSITORY}/pull/${t}`;if(e.CI_MERGE_REQUEST_PROJECT_URL&&e.CI_MERGE_REQUEST_IID)return`${e.CI_MERGE_REQUEST_PROJECT_URL.replace(/\/$/,"")}/-/merge_requests/${e.CI_MERGE_REQUEST_IID}`}function ov(e){try{let t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}var cd,U0=v(()=>{"use strict";cd="48h"});import{createHash as XV}from"node:crypto";function Dr(e){return`sha256:${XV("sha256").update(e,"utf8").digest("hex")}`}function ld(e){return XV("sha256").update(e).digest("hex")}var ss=v(()=>{"use strict"});function wm(e){return"props"in e}function qt(e){return typeof e!="object"||e===null?!1:e[Ni]===!0?!0:uge(e)}function uge(e){for(let t of Object.getOwnPropertySymbols(e)){let n=Object.getOwnPropertyDescriptor(e,t);if(!(n===void 0||n.enumerable||n.value!==!0)&&t.description?.endsWith(lge)===!0)return!0}return!1}var Ni,lge,Pn=v(()=>{"use strict";Ni=Symbol.for("chant.declarable");lge=".declarable"});function V0(e){return typeof e=="object"&&e!==null&&QV in e&&e[QV]===!0}function eq(e){let t=new Map,n=new Map;for(let[i,r]of e)V0(r)?n.set(i,r):t.set(i,r);return{applyBound:t,receipts:n}}function $r(e){let t=H0(e,"$",new Set);if(t===void 0)throw new Error("canonicalJson: value at $ is not representable in JSON");return t}function H0(e,t,n){if(e!==null&&(typeof e=="object"||typeof e=="function")){let r=e.toJSON;typeof r=="function"&&(e=r.call(e))}if(e===void 0)return;if(e===null)return"null";switch(typeof e){case"boolean":return e?"true":"false";case"number":if(!Number.isFinite(e))throw new Error(`canonicalJson: non-finite number at ${t}`);return String(e);case"string":return JSON.stringify(e);case"bigint":throw new Error(`canonicalJson: bigint at ${t} is not representable in JSON`);case"function":case"symbol":throw new Error(`canonicalJson: ${typeof e} at ${t} is not representable in JSON`)}let i=e;if(n.has(i))throw new Error(`canonicalJson: circular structure at ${t}`);n.add(i);try{if(Array.isArray(i))return`[${i.map((a,l)=>H0(a,`${t}[${l}]`,n)??"null").join(",")}]`;let r=Object.keys(i).sort(),o=[];for(let s of r){let a=H0(i[s],`${t}.${s}`,n);a!==void 0&&o.push(`${JSON.stringify(s)}:${a}`)}return`{${o.join(",")}}`}finally{n.delete(i)}}var QV,er=v(()=>{"use strict";ss();Pn();Xo();QV=Symbol.for("chant.effect-receipt")});function ud(e,t){return K0+Dr($r({kind:e,subject:t})).slice(dge.length)}function J0(e){return typeof e=="string"&&q0.test(e)}function mt(e,t){if(e===t)return!0;if(e===void 0||t===void 0)return!1;let n=q0.exec(e),i=q0.exec(t);return n!==null&&i!==null&&n[1]===i[1]}var K0,dge,q0,On=v(()=>{"use strict";er();ss();K0="jcs1-sha256:",dge="sha256:",q0=/^(?:jcs1-)?sha256:([0-9a-f]{64})$/});function Wn(e,t){return new Date(e.expiresAt).getTime()<=new Date(t).getTime()}function Cn(e,t){let n;for(let i of e)i.gate===t&&(!n||new Date(i.timestamp).getTime()>=new Date(n.timestamp).getTime())&&(n=i);return n}function dd(e,t,n){let i=new Date(n).getTime(),r;for(let o of e)o.gate===t&&(new Date(o.timestamp).getTime()<i||(!r||new Date(o.timestamp).getTime()>=new Date(r.timestamp).getTime())&&(r=o));return r}function Nr(e,t,n,i){if(i===void 0){let a=dd(e,t,n);return a?{resolution:a}:{}}let r=new Date(n).getTime(),o,s;for(let a of e){if(a.gate!==t||new Date(a.timestamp).getTime()<r)continue;let l=c=>!c||new Date(a.timestamp).getTime()>=new Date(c.timestamp).getTime();mt(a.planDigest,i)?l(o)&&(o=a):l(s)&&(s=a)}return o?{resolution:o}:s?{mismatched:s}:{}}var Bc=v(()=>{"use strict";On()});var nq={};_e(nq,{DEFAULT_GATE_EXPIRY:()=>cd,GATES_DIR:()=>av,appendGateResolution:()=>km,appendPendingGate:()=>pd,gateLedgerPath:()=>fge,isApprovalUrl:()=>ov,isPendingGateExpired:()=>Wn,latestPendingGate:()=>Cn,latestResolutionForPlan:()=>Nr,latestResolutionSince:()=>dd,parseGateLedger:()=>Z0,readGateLedger:()=>jr,readGateResolutions:()=>mge,resolveApprovalUrl:()=>os});function sv(e){return`${e}.jsonl`}function fge(e,t=""){return`${t}${vm}/${sv(e)}`}async function km(e,t){let n={version:1,...e};return{commit:await tq(n,"Gate resolution record",t),record:n}}async function pd(e,t){let n={version:1,kind:"pending",origin:es(),...ZO(e.op)?{neverOverMcp:!0}:{},...e};return{commit:await tq(n,"Pending gate record",t),record:n}}async function tq(e,t,n){let i=JSON.stringify(e,pn),r;for(let o=1;o<=pge;o++)try{let s=await xr(vm,sv(e.op),n),a=s?await fn(s,n):null,l=`${a?`${a.replace(/\n$/,"")}
92
+ `:""}${i}
93
+ `;return await An(vm,sv(e.op),l,t,{...n,expectPriorPathSha:s})}catch(s){if(!(s instanceof Vt))throw s;r=s}throw r}async function jr(e,t){let n=await nn(vm,sv(e),t);return n?Z0(n):{resolutions:[],pending:[],malformed:0}}function Z0(e){let t=e.split(`
94
+ `).map(o=>o.trim()).filter(Boolean),n=[],i=[],r=0;for(let o of t)try{let s=JSON.parse(o);if(!(s.version===1&&typeof s.op=="string"&&typeof s.gate=="string"&&typeof s.timestamp=="string")){r++;continue}let l=s.planDigest;if(l!==void 0&&typeof l!="string"){r++;continue}let c=s.environment;if(c!==void 0&&typeof c!="string"){r++;continue}if(s.kind==="pending"){if(typeof s.expiresAt!="string"){r++;continue}let u=s,d=s.wave;d!==void 0&&!(d&&typeof d=="object"&&typeof d.number=="number"&&typeof d.name=="string")&&delete u.wave;let p=s.heldBy;p!==void 0&&!(p&&typeof p=="object"&&typeof p.hook=="string"&&typeof p.moment=="string")&&delete u.heldBy,i.push(u);continue}if(typeof s.resolvedBy!="string"){r++;continue}n.push(s)}catch{r++}return{resolutions:n,pending:i,malformed:r}}async function mge(e,t){let{resolutions:n,malformed:i}=await jr(e,t);return{records:n,malformed:i}}var vm,av,pge,ji=v(()=>{"use strict";Ai();Wt();kc();$t();U0();Bc();vm="_gates",av=vm,pge=5});function Gc(e){return{dir:`_gates/${e}`,file:"applied.jsonl"}}function lv(e){let t=[];for(let n of e.split(`
95
+ `).map(i=>i.trim()).filter(Boolean)){let i;try{i=JSON.parse(n)}catch{continue}i?.version===1&&i.kind==="applied"&&typeof i.op=="string"&&typeof i.gate=="string"&&typeof i.planDigest=="string"&&typeof i.approvedAt=="string"&&typeof i.timestamp=="string"&&t.push({approvedBy:"",...i})}return t}function rq(e){let t=[],n=[];for(let i of e.split(`
96
+ `).map(r=>r.trim()).filter(Boolean)){let r;try{r=JSON.parse(i)}catch{continue}r?.version!==1||typeof r.gate!="string"||typeof r.planDigest!="string"||typeof r.timestamp!="string"||((r.kind==="applied"||r.kind==="changes")&&typeof r.approvedAt=="string"?t.push({op:"",approvedBy:"",...r}):r.kind==="finished"&&typeof r.applied=="string"&&(r.result==="applied"||r.result==="failed")&&n.push({op:"",...r}))}return{applied:t,finished:n}}function iq(e,t){return e.find(n=>n.gate===t.gate&&mt(n.planDigest,t.planDigest)&&cv(n.applied)===cv(t.timestamp))}function Lr(e,t){let n=t.planDigest;return n===void 0?!1:e.some(i=>i.gate===t.gate&&mt(i.planDigest,n)&&(t.timestamp!==void 0&&cv(i.approvedAt)>=cv(t.timestamp)||t.review?.head!==void 0&&i.review?.head===t.review.head))}function oq(e,t){return e.map((n,i)=>({ref:`${t??`_gates/${n.op}/applied.jsonl`}#${i+1}`,at:n.timestamp,gate:n.gate,op:n.op,digest:n.planDigest,approval:"required",detail:{approvedAt:n.approvedAt,approvedBy:n.approvedBy,...n.wave?{wave:n.wave}:{},...n.review?{review:n.review}:{},...n.runId?{runId:n.runId}:{},...n.commit?{commit:n.commit}:{}}}))}var cv,Wc=v(()=>{"use strict";On();cv=e=>new Date(e).getTime()});var lo=v(()=>{"use strict"});function Li(e){let t={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},n=0,i=!1;for(let r of e.matchAll(/(\d+)(ms|s|m|h|d)/g))n+=Number(r[1])*t[r[2]],i=!0;if(!i)throw new Error(`unparseable duration: "${e}"`);return n}var as=v(()=>{"use strict"});var uv,sq,fGe,fd=v(()=>{"use strict";as();uv={fastIdempotent:{timeout:"5m",retry:{maximumAttempts:3,initialInterval:"5s",backoffCoefficient:2}},longInfra:{timeout:"20m",retry:{maximumAttempts:3,initialInterval:"30s",backoffCoefficient:2}},k8sWait:{timeout:"15m",retry:{maximumAttempts:3,initialInterval:"10s",backoffCoefficient:2,nonRetryableErrorTypes:["ReadinessFailedError"]}},atMostOnce:{timeout:"20m",retry:{maximumAttempts:1}},humanGate:{timeout:"48h",retry:{maximumAttempts:1}},argoSync:{timeout:"30m",retry:{maximumAttempts:5,initialInterval:"10s",backoffCoefficient:2,maximumInterval:"1m",nonRetryableErrorTypes:["ArgoSyncFailedError"]}},policyCheck:{timeout:"5m",retry:{maximumAttempts:1}}},sq=Object.keys(uv),fGe=6*36e5});function Pt(e,t,n,i){return{[hge]:!0,name:e,args:t,...n?{returns:n}:{},...i?.entities&&i.entities.length>0?{entities:i.entities}:{}}}var hge,xm=v(()=>{"use strict";lo();fd();hge=Symbol.for("chant.op.activityContract")});var Mi=v(()=>{"use strict";lo();xm()});var dv=v(()=>{"use strict"});import{createHash as bge}from"node:crypto";function $m(e){return`sha256:${bge("sha256").update(JSON.stringify(e??{},wge)).digest("hex")}`}function wge(e,t){return t&&typeof t=="object"&&!Array.isArray(t)?Object.fromEntries(Object.entries(t).sort(([n],[i])=>n<i?-1:n>i?1:0)):t}async function Y0(e){let t=Ei(e)??`@intentius/chant-lexicon-${e}/gate-policy`,n;try{n=await Zr(t)}catch(i){throw new Error(`the gate's policy is evaluated by ${t}, which could not be loaded: `+(i instanceof Error?i.message:String(i)))}if(typeof n.evaluateGatePolicy!="function")throw new Error(`${t} exports no evaluateGatePolicy function`);return n}function X0(e){return{principal:{kind:e.approver.kind,name:e.resolvedBy,roles:e.approver.roles??[]},action:"PassGate",resource:{op:e.op,gate:e.gate},context:{...e.context??{},...e.planDigest!==void 0?{planDigest:e.planDigest}:{}}}}var Rm=v(()=>{"use strict";xn();Mi();dv()});function ba(e=process.env){if(e.GITLAB_CI==="true")return!e.CI_API_V4_URL||!e.CI_PROJECT_ID||!e.CI_PIPELINE_ID||!e.CI_JOB_ID?void 0:{forge:"gitlab",api:fv(e.CI_API_V4_URL),repo:e.CI_PROJECT_ID,run:e.CI_PIPELINE_ID,job:e.CI_JOB_ID,...e.CI_JOB_NAME?{jobName:e.CI_JOB_NAME}:{},...e.CI_JOB_URL?{url:e.CI_JOB_URL}:{}};if(e.GITHUB_ACTIONS!=="true"||!e.GITHUB_REPOSITORY||!e.GITHUB_RUN_ID)return;let t=e.FORGEJO_ACTIONS==="true"||e.GITEA_ACTIONS==="true",n=e.GITHUB_SERVER_URL?fv(e.GITHUB_SERVER_URL):void 0,i=n?`${n}/${e.GITHUB_REPOSITORY}/actions/runs/${e.GITHUB_RUN_ID}`:void 0;if(t){let o=vge(e),s=e.GITHUB_API_URL??(n?`${n}/api/v1`:void 0);return!s||!o||!e.GITHUB_REF_NAME?void 0:{forge:"forgejo",api:fv(s),repo:e.GITHUB_REPOSITORY,run:e.GITHUB_RUN_ID,workflow:o,ref:e.GITHUB_REF_NAME,...i?{url:i}:{}}}let r=Number(e.GITHUB_RUN_ATTEMPT);return{forge:"github",api:fv(e.GITHUB_API_URL??"https://api.github.com"),repo:e.GITHUB_REPOSITORY,run:e.GITHUB_RUN_ID,...Number.isInteger(r)&&r>0?{attempt:r}:{},...i?{url:i}:{}}}function vge(e){let t=e.GITHUB_WORKFLOW_REF?.split("@")[0]?.split("/").pop();if(t&&/\.ya?ml$/.test(t))return t;let n=e.GITHUB_WORKFLOW;return n&&/\.ya?ml$/.test(n)?n.split("/").pop():void 0}function zc(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.api!="string"||typeof t.repo!="string"||typeof t.run!="string"?!1:t.forge==="github"?!0:t.forge==="gitlab"?typeof t.job=="string":t.forge==="forgejo"?typeof t.workflow=="string"&&typeof t.ref=="string":!1}var fv,gd=v(()=>{"use strict";fv=e=>e.replace(/\/+$/,"")});var Q0,lq=v(()=>{Q0={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://intentius.io/chant/schemas/workspace/principals/v1/workspace-principals.schema.json",title:"workspace-principals.json",description:"Principal classes a plugin supplies (#2524 D5, #3080, ws-079). A package publishes this file as data at its ./workspace-principals subpath, beside ./workspace-kinds. chant reads it with the file system and never imports the package. A class is a name for the principals holding one role in the trust policy at base; the declaration's writeScope may then give it an entry.",type:"object",required:["schema","classes"],properties:{$schema:{type:"string",description:"An editor hint. chant ignores it."},$comment:{type:"string",description:"A note for people. chant ignores it."},schema:{const:1,description:"The principal classes format version."},classes:{type:"array",minItems:1,items:{$ref:"#/$defs/class"}}},patternProperties:{"^x-":!0},additionalProperties:!1,$defs:{class:{type:"object",required:["name","description","role"],properties:{name:{type:"string",pattern:"^(?!x-)[a-z][a-z0-9-]{0,39}$",description:"The class's name, as a key of the declaration's writeScope names it. human, agent, runner and service are the core classes and can't be supplied."},description:{type:"string",minLength:1,description:"One line saying who is in the class, for listings and error messages."},role:{type:"string",pattern:"^[a-z][a-z0-9-]*$",description:"The role whose grant in the trust policy at base (.chant/trust.json roles) puts a principal in this class. The agent, runner and service roles belong to the core classes and can't be named here. One role puts a principal in one class."}},patternProperties:{"^x-":!0},additionalProperties:!1}}}});function uq(e=[]){let t=[...ro,...e],n=new Map(t.map(i=>[i.name,i]));return{get:i=>n.get(i),names:()=>t.map(i=>i.name),all:()=>t}}function wa(){return uq()}function Sm(e){return e.roles}function Em(e,t,n){return jf(e.all(),Sm(t),n)}function dq(e,t,n=wa()){return Em(n,e,t)[0]??"human"}function xge(){if(mv)return mv;let e=da();return mv=new e({allErrors:!0,strict:!0}).compile(Q0),mv}function $ge(e,t){let n;try{n=JSON.parse(e)}catch(r){return{classes:[],problems:[`${t}: the principals file is not JSON (${r.message})`]}}let i=xge();if(!i(n)){let r=(i.errors??[]).map(o=>`${t}: ${o.instancePath||"the principals file"} ${o.message??"is invalid"}`);return{classes:[],problems:[...new Set(r)]}}return dC(n,t)}function Rge(e,t){return n=>{let i=ze(t,n);if(e.stat(i)==="file")try{return e.read(i)}catch{return}}}function Sge(e,t){return Mf(e,t,$ge)}function pq(e,t,n={}){let i=[],r=[];e.forEach((s,a)=>{let l,c;if(s.path&&n.tree)l=Rge(n.tree,s.path),c=s.path;else{let u=S0(s,t);if(u===null)return;if("problem"in u){i.push({pin:a,message:u.problem});return}l=Lf(u.dir),c=u.source}r.push({pin:a,source:c,read:Sge(l,c)})});let o=gw(r);return{registry:uq(o.classes),problems:[...i,...o.problems].sort((s,a)=>s.pin-a.pin)}}function eI(e,t){return Object.keys(e??{}).filter(n=>t.get(n)===void 0)}var MGe,mv,tI=v(()=>{"use strict";Du();ao();lq();Zt();xc();gm();Du();xc();Du();MGe=Q0.$id});function Ege(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Am(){if(fq)return va;fq=1;function e(s){return typeof s>"u"||s===null}function t(s){return typeof s=="object"&&s!==null}function n(s){return Array.isArray(s)?s:e(s)?[]:[s]}function i(s,a){if(a){let l=Object.keys(a);for(let c=0,u=l.length;c<u;c+=1){let d=l[c];s[d]=a[d]}}return s}function r(s,a){let l="";for(let c=0;c<a;c+=1)l+=s;return l}function o(s){return s===0&&Number.NEGATIVE_INFINITY===1/s}return va.isNothing=e,va.isObject=t,va.toArray=n,va.repeat=r,va.isNegativeZero=o,va.extend=i,va}function Pm(){if(mq)return nI;mq=1;function e(n,i){let r="",o=n.reason||"(unknown reason)";return n.mark?(n.mark.name&&(r+='in "'+n.mark.name+'" '),r+="("+(n.mark.line+1)+":"+(n.mark.column+1)+")",!i&&n.mark.snippet&&(r+=`
97
+
98
+ `+n.mark.snippet),o+" "+r):o}function t(n,i){Error.call(this),this.name="YAMLException",this.reason=n,this.mark=i,this.message=e(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t.prototype.toString=function(i){return this.name+": "+e(this,i)},nI=t,nI}function Age(){if(gq)return rI;gq=1;let e=Am();function t(r,o,s,a,l){let c="",u="",d=Math.floor(l/2)-1;return a-o>d&&(c=" ... ",o=a-d+c.length),s-a>d&&(u=" ...",s=a+d-u.length),{str:c+r.slice(o,s).replace(/\t/g,"\u2192")+u,pos:a-o+c.length}}function n(r,o){return e.repeat(" ",o-r.length)+r}function i(r,o){if(o=Object.create(o||null),!r.buffer)return null;o.maxLength||(o.maxLength=79),typeof o.indent!="number"&&(o.indent=1),typeof o.linesBefore!="number"&&(o.linesBefore=3),typeof o.linesAfter!="number"&&(o.linesAfter=2);let s=/\r?\n|\r|\0/g,a=[0],l=[],c,u=-1;for(;c=s.exec(r.buffer);)l.push(c.index),a.push(c.index+c[0].length),r.position<=c.index&&u<0&&(u=a.length-2);u<0&&(u=a.length-1);let d="",p=Math.min(r.line+o.linesAfter,l.length).toString().length,f=o.maxLength-(o.indent+p+3);for(let h=1;h<=o.linesBefore&&!(u-h<0);h++){let b=t(r.buffer,a[u-h],l[u-h],r.position-(a[u]-a[u-h]),f);d=e.repeat(" ",o.indent)+n((r.line-h+1).toString(),p)+" | "+b.str+`
99
+ `+d}let g=t(r.buffer,a[u],l[u],r.position,f);d+=e.repeat(" ",o.indent)+n((r.line+1).toString(),p)+" | "+g.str+`
100
+ `,d+=e.repeat("-",o.indent+p+3+g.pos)+`^
101
+ `;for(let h=1;h<=o.linesAfter&&!(u+h>=l.length);h++){let b=t(r.buffer,a[u+h],l[u+h],r.position-(a[u]-a[u+h]),f);d+=e.repeat(" ",o.indent)+n((r.line+h+1).toString(),p)+" | "+b.str+`
102
+ `}return d.replace(/\n$/,"")}return rI=i,rI}function tr(){if(hq)return iI;hq=1;let e=Pm(),t=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function i(o){let s={};return o!==null&&Object.keys(o).forEach(function(a){o[a].forEach(function(l){s[String(l)]=a})}),s}function r(o,s){if(s=s||{},Object.keys(s).forEach(function(a){if(t.indexOf(a)===-1)throw new e('Unknown option "'+a+'" is met in definition of "'+o+'" YAML type.')}),this.options=s,this.tag=o,this.kind=s.kind||null,this.resolve=s.resolve||function(){return!0},this.construct=s.construct||function(a){return a},this.instanceOf=s.instanceOf||null,this.predicate=s.predicate||null,this.represent=s.represent||null,this.representName=s.representName||null,this.defaultStyle=s.defaultStyle||null,this.multi=s.multi||!1,this.styleAliases=i(s.styleAliases||null),n.indexOf(this.kind)===-1)throw new e('Unknown kind "'+this.kind+'" is specified for "'+o+'" YAML type.')}return iI=r,iI}function Mq(){if(yq)return oI;yq=1;let e=Pm(),t=tr();function n(o,s){let a=[];return o[s].forEach(function(l){let c=a.length;a.forEach(function(u,d){u.tag===l.tag&&u.kind===l.kind&&u.multi===l.multi&&(c=d)}),a[c]=l}),a}function i(){let o={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function s(a){a.multi?(o.multi[a.kind].push(a),o.multi.fallback.push(a)):o[a.kind][a.tag]=o.fallback[a.tag]=a}for(let a=0,l=arguments.length;a<l;a+=1)arguments[a].forEach(s);return o}function r(o){return this.extend(o)}return r.prototype.extend=function(s){let a=[],l=[];if(s instanceof t)l.push(s);else if(Array.isArray(s))l=l.concat(s);else if(s&&(Array.isArray(s.implicit)||Array.isArray(s.explicit)))s.implicit&&(a=a.concat(s.implicit)),s.explicit&&(l=l.concat(s.explicit));else throw new e("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");a.forEach(function(u){if(!(u instanceof t))throw new e("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(u.loadKind&&u.loadKind!=="scalar")throw new e("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(u.multi)throw new e("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),l.forEach(function(u){if(!(u instanceof t))throw new e("Specified list of YAML types (or a single Type object) contains a non-Type object.")});let c=Object.create(r.prototype);return c.implicit=(this.implicit||[]).concat(a),c.explicit=(this.explicit||[]).concat(l),c.compiledImplicit=n(c,"implicit"),c.compiledExplicit=n(c,"explicit"),c.compiledTypeMap=i(c.compiledImplicit,c.compiledExplicit),c},oI=r,oI}function Fq(){if(bq)return sI;bq=1;let e=tr();return sI=new e("tag:yaml.org,2002:str",{kind:"scalar",construct:function(t){return t!==null?t:""}}),sI}function Bq(){if(wq)return aI;wq=1;let e=tr();return aI=new e("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(t){return t!==null?t:[]}}),aI}function Gq(){if(vq)return cI;vq=1;let e=tr();return cI=new e("tag:yaml.org,2002:map",{kind:"mapping",construct:function(t){return t!==null?t:{}}}),cI}function Wq(){if(kq)return lI;kq=1;let e=Mq();return lI=new e({explicit:[Fq(),Bq(),Gq()]}),lI}function zq(){if(xq)return uI;xq=1;let e=tr();function t(r){if(r===null)return!0;let o=r.length;return o===1&&r==="~"||o===4&&(r==="null"||r==="Null"||r==="NULL")}function n(){return null}function i(r){return r===null}return uI=new e("tag:yaml.org,2002:null",{kind:"scalar",resolve:t,construct:n,predicate:i,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"}),uI}function Uq(){if($q)return dI;$q=1;let e=tr();function t(r){if(r===null)return!1;let o=r.length;return o===4&&(r==="true"||r==="True"||r==="TRUE")||o===5&&(r==="false"||r==="False"||r==="FALSE")}function n(r){return r==="true"||r==="True"||r==="TRUE"}function i(r){return Object.prototype.toString.call(r)==="[object Boolean]"}return dI=new e("tag:yaml.org,2002:bool",{kind:"scalar",resolve:t,construct:n,predicate:i,represent:{lowercase:function(r){return r?"true":"false"},uppercase:function(r){return r?"TRUE":"FALSE"},camelcase:function(r){return r?"True":"False"}},defaultStyle:"lowercase"}),dI}function Hq(){if(Rq)return pI;Rq=1;let e=Am(),t=tr();function n(c){return c>=48&&c<=57||c>=65&&c<=70||c>=97&&c<=102}function i(c){return c>=48&&c<=55}function r(c){return c>=48&&c<=57}function o(c){if(c===null)return!1;let u=c.length,d=0,p=!1;if(!u)return!1;let f=c[d];if((f==="-"||f==="+")&&(f=c[++d]),f==="0"){if(d+1===u)return!0;if(f=c[++d],f==="b"){for(d++;d<u;d++){if(f=c[d],f!=="0"&&f!=="1")return!1;p=!0}return p&&isFinite(s(c))}if(f==="x"){for(d++;d<u;d++){if(!n(c.charCodeAt(d)))return!1;p=!0}return p&&isFinite(s(c))}if(f==="o"){for(d++;d<u;d++){if(!i(c.charCodeAt(d)))return!1;p=!0}return p&&isFinite(s(c))}}for(;d<u;d++){if(!r(c.charCodeAt(d)))return!1;p=!0}return p?isFinite(s(c)):!1}function s(c){let u=c,d=1,p=u[0];if((p==="-"||p==="+")&&(p==="-"&&(d=-1),u=u.slice(1),p=u[0]),u==="0")return 0;if(p==="0"){if(u[1]==="b")return d*parseInt(u.slice(2),2);if(u[1]==="x")return d*parseInt(u.slice(2),16);if(u[1]==="o")return d*parseInt(u.slice(2),8)}return d*parseInt(u,10)}function a(c){return s(c)}function l(c){return Object.prototype.toString.call(c)==="[object Number]"&&c%1===0&&!e.isNegativeZero(c)}return pI=new t("tag:yaml.org,2002:int",{kind:"scalar",resolve:o,construct:a,predicate:l,represent:{binary:function(c){return c>=0?"0b"+c.toString(2):"-0b"+c.toString(2).slice(1)},octal:function(c){return c>=0?"0o"+c.toString(8):"-0o"+c.toString(8).slice(1)},decimal:function(c){return c.toString(10)},hexadecimal:function(c){return c>=0?"0x"+c.toString(16).toUpperCase():"-0x"+c.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),pI}function Vq(){if(Sq)return fI;Sq=1;let e=Am(),t=tr(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),i=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function r(c){return c===null||!n.test(c)?!1:isFinite(parseFloat(c,10))?!0:i.test(c)}function o(c){let u=c.toLowerCase(),d=u[0]==="-"?-1:1;return"+-".indexOf(u[0])>=0&&(u=u.slice(1)),u===".inf"?d===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:u===".nan"?NaN:d*parseFloat(u,10)}let s=/^[-+]?[0-9]+e/;function a(c,u){if(isNaN(c))switch(u){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===c)switch(u){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===c)switch(u){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(e.isNegativeZero(c))return"-0.0";let d=c.toString(10);return s.test(d)?d.replace("e",".e"):d}function l(c){return Object.prototype.toString.call(c)==="[object Number]"&&(c%1!==0||e.isNegativeZero(c))}return fI=new t("tag:yaml.org,2002:float",{kind:"scalar",resolve:r,construct:o,predicate:l,represent:a,defaultStyle:"lowercase"}),fI}function qq(){return Eq||(Eq=1,mI=Wq().extend({implicit:[zq(),Uq(),Hq(),Vq()]})),mI}function Kq(){return Aq||(Aq=1,gI=qq()),gI}function Jq(){if(Pq)return hI;Pq=1;let e=tr(),t=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function i(s){return s===null?!1:t.exec(s)!==null||n.exec(s)!==null}function r(s){let a=0,l=null,c=t.exec(s);if(c===null&&(c=n.exec(s)),c===null)throw new Error("Date resolve error");let u=+c[1],d=+c[2]-1,p=+c[3];if(!c[4])return new Date(Date.UTC(u,d,p));let f=+c[4],g=+c[5],h=+c[6];if(c[7]){for(a=c[7].slice(0,3);a.length<3;)a+="0";a=+a}if(c[9]){let w=+c[10],x=+(c[11]||0);l=(w*60+x)*6e4,c[9]==="-"&&(l=-l)}let b=new Date(Date.UTC(u,d,p,f,g,h,a));return l&&b.setTime(b.getTime()-l),b}function o(s){return s.toISOString()}return hI=new e("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:i,construct:r,instanceOf:Date,represent:o}),hI}function Zq(){if(Oq)return yI;Oq=1;let e=tr();function t(n){return n==="<<"||n===null}return yI=new e("tag:yaml.org,2002:merge",{kind:"scalar",resolve:t}),yI}function Yq(){if(Cq)return bI;Cq=1;let e=tr(),t=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
103
+ \r`;function n(s){if(s===null)return!1;let a=0,l=s.length,c=t;for(let u=0;u<l;u++){let d=c.indexOf(s.charAt(u));if(!(d>64)){if(d<0)return!1;a+=6}}return a%8===0}function i(s){let a=s.replace(/[\r\n=]/g,""),l=a.length,c=t,u=0,d=[];for(let f=0;f<l;f++)f%4===0&&f&&(d.push(u>>16&255),d.push(u>>8&255),d.push(u&255)),u=u<<6|c.indexOf(a.charAt(f));let p=l%4*6;return p===0?(d.push(u>>16&255),d.push(u>>8&255),d.push(u&255)):p===18?(d.push(u>>10&255),d.push(u>>2&255)):p===12&&d.push(u>>4&255),new Uint8Array(d)}function r(s){let a="",l=0,c=s.length,u=t;for(let p=0;p<c;p++)p%3===0&&p&&(a+=u[l>>18&63],a+=u[l>>12&63],a+=u[l>>6&63],a+=u[l&63]),l=(l<<8)+s[p];let d=c%3;return d===0?(a+=u[l>>18&63],a+=u[l>>12&63],a+=u[l>>6&63],a+=u[l&63]):d===2?(a+=u[l>>10&63],a+=u[l>>4&63],a+=u[l<<2&63],a+=u[64]):d===1&&(a+=u[l>>2&63],a+=u[l<<4&63],a+=u[64],a+=u[64]),a}function o(s){return Object.prototype.toString.call(s)==="[object Uint8Array]"}return bI=new e("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:i,predicate:o,represent:r}),bI}function Xq(){if(_q)return wI;_q=1;let e=tr(),t=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function i(o){if(o===null)return!0;let s={},a=o;for(let l=0,c=a.length;l<c;l+=1){let u=a[l],d=!1;if(n.call(u)!=="[object Object]")return!1;let p;for(p in u)if(t.call(u,p))if(!d)d=!0;else return!1;if(!d||t.call(s,p))return!1;Object.defineProperty(s,p,{value:!0})}return!0}function r(o){return o!==null?o:[]}return wI=new e("tag:yaml.org,2002:omap",{kind:"sequence",resolve:i,construct:r}),wI}function Qq(){if(Iq)return vI;Iq=1;let e=tr(),t=Object.prototype.toString;function n(r){if(r===null)return!0;let o=r,s=new Array(o.length);for(let a=0,l=o.length;a<l;a+=1){let c=o[a];if(t.call(c)!=="[object Object]")return!1;let u=Object.keys(c);if(u.length!==1)return!1;s[a]=[u[0],c[u[0]]]}return!0}function i(r){if(r===null)return[];let o=r,s=new Array(o.length);for(let a=0,l=o.length;a<l;a+=1){let c=o[a],u=Object.keys(c);s[a]=[u[0],c[u[0]]]}return s}return vI=new e("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:n,construct:i}),vI}function eK(){if(Tq)return kI;Tq=1;let e=tr(),t=Object.prototype.hasOwnProperty;function n(r){if(r===null)return!0;let o=r;for(let s in o)if(t.call(o,s)&&o[s]!==null)return!1;return!0}function i(r){return r!==null?r:{}}return kI=new e("tag:yaml.org,2002:set",{kind:"mapping",resolve:n,construct:i}),kI}function RI(){return Dq||(Dq=1,xI=Kq().extend({implicit:[Jq(),Zq()],explicit:[Yq(),Xq(),Qq(),eK()]})),xI}function Pge(){if(Nq)return gv;Nq=1;let e=Am(),t=Pm(),n=Age(),i=RI(),r=Object.prototype.hasOwnProperty,o=1,s=2,a=3,l=4,c=1,u=2,d=3,p=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,f=/[\x85\u2028\u2029]/,g=/[,\[\]{}]/,h=/^(?:!|!!|![0-9A-Za-z-]+!)$/,b=/^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i;function w(y){return Object.prototype.toString.call(y)}function x(y){return y===10||y===13}function k(y){return y===9||y===32}function R(y){return y===9||y===32||y===10||y===13}function $(y){return y===44||y===91||y===93||y===123||y===125}function _(y){if(y>=48&&y<=57)return y-48;let N=y|32;return N>=97&&N<=102?N-97+10:-1}function T(y){return y===120?2:y===117?4:y===85?8:0}function C(y){return y>=48&&y<=57?y-48:-1}function K(y){switch(y){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return`
104
+ `;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"\x85";case 95:return"\xA0";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function O(y){return y<=65535?String.fromCharCode(y):String.fromCharCode((y-65536>>10)+55296,(y-65536&1023)+56320)}function pe(y,N,q){N==="__proto__"?Object.defineProperty(y,N,{configurable:!0,enumerable:!0,writable:!0,value:q}):y[N]=q}let F=new Array(256),Q=new Array(256);for(let y=0;y<256;y++)F[y]=K(y)?1:0,Q[y]=K(y);function I(y,N){this.input=y,this.filename=N.filename||null,this.schema=N.schema||i,this.onWarning=N.onWarning||null,this.legacy=N.legacy||!1,this.json=N.json||!1,this.listener=N.listener||null,this.maxDepth=typeof N.maxDepth=="number"?N.maxDepth:100,this.maxTotalMergeKeys=typeof N.maxTotalMergeKeys=="number"?N.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=y.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function B(y,N){let q={name:y.filename,buffer:y.input.slice(0,-1),position:y.position,line:y.line,column:y.position-y.lineStart};return q.snippet=n(q),new t(N,q)}function Z(y,N){throw B(y,N)}function xe(y,N){y.onWarning&&y.onWarning.call(null,B(y,N))}function we(y,N,q){let Y=y.anchorMapTransactions;if(Y.length!==0){let z=Y[Y.length-1];r.call(z,N)||(z[N]={existed:r.call(y.anchorMap,N),value:y.anchorMap[N]})}y.anchorMap[N]=q}function Ct(y){y.anchorMapTransactions.push(Object.create(null))}function at(y){let N=y.anchorMapTransactions.pop(),q=y.anchorMapTransactions;if(q.length===0)return;let Y=q[q.length-1],z=Object.keys(N);for(let E=0,G=z.length;E<G;E+=1){let H=z[E];r.call(Y,H)||(Y[H]=N[H])}}function $e(y){let N=y.anchorMapTransactions.pop(),q=Object.keys(N);for(let Y=q.length-1;Y>=0;Y-=1){let z=N[q[Y]];z.existed?y.anchorMap[q[Y]]=z.value:delete y.anchorMap[q[Y]]}}function Te(y){return{position:y.position,line:y.line,lineStart:y.lineStart,lineIndent:y.lineIndent,firstTabInLine:y.firstTabInLine,tag:y.tag,anchor:y.anchor,kind:y.kind,result:y.result}}function nt(y,N){y.position=N.position,y.line=N.line,y.lineStart=N.lineStart,y.lineIndent=N.lineIndent,y.firstTabInLine=N.firstTabInLine,y.tag=N.tag,y.anchor=N.anchor,y.kind=N.kind,y.result=N.result}let St={YAML:function(N,q,Y){N.version!==null&&Z(N,"duplication of %YAML directive"),Y.length!==1&&Z(N,"YAML directive accepts exactly one argument");let z=/^([0-9]+)\.([0-9]+)$/.exec(Y[0]);z===null&&Z(N,"ill-formed argument of the YAML directive");let E=parseInt(z[1],10),G=parseInt(z[2],10);E!==1&&Z(N,"unacceptable YAML version of the document"),N.version=Y[0],N.checkLineBreaks=G<2,G!==1&&G!==2&&xe(N,"unsupported YAML version of the document")},TAG:function(N,q,Y){let z;Y.length!==2&&Z(N,"TAG directive accepts exactly two arguments");let E=Y[0];z=Y[1],h.test(E)||Z(N,"ill-formed tag handle (first argument) of the TAG directive"),r.call(N.tagMap,E)&&Z(N,'there is a previously declared suffix for "'+E+'" tag handle'),b.test(z)||Z(N,"ill-formed tag prefix (second argument) of the TAG directive");try{z=decodeURIComponent(z)}catch{Z(N,"tag prefix is malformed: "+z)}N.tagMap[E]=z}};function Ee(y,N,q,Y){if(N<q){let z=y.input.slice(N,q);if(Y)for(let E=0,G=z.length;E<G;E+=1){let H=z.charCodeAt(E);H===9||H>=32&&H<=1114111||Z(y,"expected valid JSON character")}else p.test(z)&&Z(y,"the stream contains non-printable characters");y.result+=z}}function zt(y){y.totalMergeKeys++,y.maxTotalMergeKeys!==-1&&y.totalMergeKeys>y.maxTotalMergeKeys&&Z(y,"merge keys exceeded maxTotalMergeKeys ("+y.maxTotalMergeKeys+")")}function Vn(y,N,q,Y){e.isObject(q)||Z(y,"cannot merge mappings; the provided source object is unacceptable"),zt(y);let z=Object.keys(q);for(let E=0,G=z.length;E<G;E+=1){let H=z[E];zt(y),r.call(N,H)||(pe(N,H,q[H]),Y[H]=!0)}}function ne(y,N,q,Y,z,E,G,H,ee){if(Array.isArray(z)){z=Array.prototype.slice.call(z);for(let te=0,oe=z.length;te<oe;te+=1)Array.isArray(z[te])&&Z(y,"nested arrays are not supported inside keys"),typeof z=="object"&&w(z[te])==="[object Object]"&&(z[te]="[object Object]")}if(typeof z=="object"&&w(z)==="[object Object]"&&(z="[object Object]"),z=String(z),N===null&&(N={}),Y==="tag:yaml.org,2002:merge")if(Array.isArray(E)){E.length>100&&Z(y,"abnormal merge sequence size");for(let te=0,oe=E.length;te<oe;te+=1)Vn(y,N,E[te],q)}else Vn(y,N,E,q);else!y.json&&!r.call(q,z)&&r.call(N,z)&&(y.line=G||y.line,y.lineStart=H||y.lineStart,y.position=ee||y.position,Z(y,"duplicated mapping key")),pe(N,z,E),delete q[z];return N}function Re(y){let N=y.input.charCodeAt(y.position);N===10?y.position++:N===13?(y.position++,y.input.charCodeAt(y.position)===10&&y.position++):Z(y,"a line break is expected"),y.line+=1,y.lineStart=y.position,y.firstTabInLine=-1}function X(y,N,q){let Y=0,z=y.input.charCodeAt(y.position);for(;z!==0;){for(;k(z);)z===9&&y.firstTabInLine===-1&&(y.firstTabInLine=y.position),z=y.input.charCodeAt(++y.position);if(N&&z===35)do z=y.input.charCodeAt(++y.position);while(z!==10&&z!==13&&z!==0);if(x(z))for(Re(y),z=y.input.charCodeAt(y.position),Y++,y.lineIndent=0;z===32;)y.lineIndent++,z=y.input.charCodeAt(++y.position);else break}return q!==-1&&Y!==0&&y.lineIndent<q&&xe(y,"deficient indentation"),Y}function Ce(y){let N=y.position,q=y.input.charCodeAt(N);return!!((q===45||q===46)&&q===y.input.charCodeAt(N+1)&&q===y.input.charCodeAt(N+2)&&(N+=3,q=y.input.charCodeAt(N),q===0||R(q)))}function tt(y,N){N===1?y.result+=" ":N>1&&(y.result+=e.repeat(`
105
+ `,N-1))}function gt(y,N,q){let Y,z,E,G,H,ee,te=y.kind,oe=y.result,S=y.input.charCodeAt(y.position);if(R(S)||$(S)||S===35||S===38||S===42||S===33||S===124||S===62||S===39||S===34||S===37||S===64||S===96)return!1;if(S===63||S===45){let A=y.input.charCodeAt(y.position+1);if(R(A)||q&&$(A))return!1}for(y.kind="scalar",y.result="",Y=z=y.position,E=!1;S!==0;){if(S===58){let A=y.input.charCodeAt(y.position+1);if(R(A)||q&&$(A))break}else if(S===35){let A=y.input.charCodeAt(y.position-1);if(R(A))break}else{if(y.position===y.lineStart&&Ce(y)||q&&$(S))break;if(x(S))if(G=y.line,H=y.lineStart,ee=y.lineIndent,X(y,!1,-1),y.lineIndent>=N){E=!0,S=y.input.charCodeAt(y.position);continue}else{y.position=z,y.line=G,y.lineStart=H,y.lineIndent=ee;break}}E&&(Ee(y,Y,z,!1),tt(y,y.line-G),Y=z=y.position,E=!1),k(S)||(z=y.position+1),S=y.input.charCodeAt(++y.position)}return Ee(y,Y,z,!1),y.result?!0:(y.kind=te,y.result=oe,!1)}function Je(y,N){let q,Y,z=y.input.charCodeAt(y.position);if(z!==39)return!1;for(y.kind="scalar",y.result="",y.position++,q=Y=y.position;(z=y.input.charCodeAt(y.position))!==0;)if(z===39)if(Ee(y,q,y.position,!0),z=y.input.charCodeAt(++y.position),z===39)q=y.position,y.position++,Y=y.position;else return!0;else x(z)?(Ee(y,q,Y,!0),tt(y,X(y,!1,N)),q=Y=y.position):y.position===y.lineStart&&Ce(y)?Z(y,"unexpected end of the document within a single quoted scalar"):(y.position++,k(z)||(Y=y.position));Z(y,"unexpected end of the stream within a single quoted scalar")}function Bt(y,N){let q,Y,z,E=y.input.charCodeAt(y.position);if(E!==34)return!1;for(y.kind="scalar",y.result="",y.position++,q=Y=y.position;(E=y.input.charCodeAt(y.position))!==0;){if(E===34)return Ee(y,q,y.position,!0),y.position++,!0;if(E===92){if(Ee(y,q,y.position,!0),E=y.input.charCodeAt(++y.position),x(E))X(y,!1,N);else if(E<256&&F[E])y.result+=Q[E],y.position++;else if((z=T(E))>0){let G=z,H=0;for(;G>0;G--)E=y.input.charCodeAt(++y.position),(z=_(E))>=0?H=(H<<4)+z:Z(y,"expected hexadecimal character");y.result+=O(H),y.position++}else Z(y,"unknown escape sequence");q=Y=y.position}else x(E)?(Ee(y,q,Y,!0),tt(y,X(y,!1,N)),q=Y=y.position):y.position===y.lineStart&&Ce(y)?Z(y,"unexpected end of the document within a double quoted scalar"):(y.position++,k(E)||(Y=y.position))}Z(y,"unexpected end of the stream within a double quoted scalar")}function W(y,N){let q=!0,Y,z,E,G=y.tag,H,ee=y.anchor,te,oe,S,A,P=Object.create(null),j,U,L,re=y.input.charCodeAt(y.position);if(re===91)te=93,A=!1,H=[];else if(re===123)te=125,A=!0,H={};else return!1;for(y.anchor!==null&&we(y,y.anchor,H),re=y.input.charCodeAt(++y.position);re!==0;){if(X(y,!0,N),re=y.input.charCodeAt(y.position),re===te)return y.position++,y.tag=G,y.anchor=ee,y.kind=A?"mapping":"sequence",y.result=H,!0;if(q?re===44&&Z(y,"expected the node content, but found ','"):Z(y,"missed comma between flow collection entries"),U=j=L=null,oe=S=!1,re===63){let me=y.input.charCodeAt(y.position+1);R(me)&&(oe=S=!0,y.position++,X(y,!0,N))}Y=y.line,z=y.lineStart,E=y.position,qn(y,N,o,!1,!0),U=y.tag,j=y.result,X(y,!0,N),re=y.input.charCodeAt(y.position),(S||y.line===Y)&&re===58&&(oe=!0,re=y.input.charCodeAt(++y.position),X(y,!0,N),qn(y,N,o,!1,!0),L=y.result),A?ne(y,H,P,U,j,L,Y,z,E):oe?H.push(ne(y,null,P,U,j,L,Y,z,E)):H.push(j),X(y,!0,N),re=y.input.charCodeAt(y.position),re===44?(q=!0,re=y.input.charCodeAt(++y.position)):q=!1}Z(y,"unexpected end of the stream within a flow collection")}function de(y,N){let q,Y=c,z=!1,E=!1,G=N,H=0,ee=!1,te,oe=y.input.charCodeAt(y.position);if(oe===124)q=!1;else if(oe===62)q=!0;else return!1;for(y.kind="scalar",y.result="";oe!==0;)if(oe=y.input.charCodeAt(++y.position),oe===43||oe===45)c===Y?Y=oe===43?d:u:Z(y,"repeat of a chomping mode identifier");else if((te=C(oe))>=0)te===0?Z(y,"bad explicit indentation width of a block scalar; it cannot be less than one"):E?Z(y,"repeat of an indentation width identifier"):(G=N+te-1,E=!0);else break;if(k(oe)){do oe=y.input.charCodeAt(++y.position);while(k(oe));if(oe===35)do oe=y.input.charCodeAt(++y.position);while(!x(oe)&&oe!==0)}for(;oe!==0;){for(Re(y),y.lineIndent=0,oe=y.input.charCodeAt(y.position);(!E||y.lineIndent<G)&&oe===32;)y.lineIndent++,oe=y.input.charCodeAt(++y.position);if(!E&&y.lineIndent>G&&(G=y.lineIndent),x(oe)){H++;continue}if(!E&&G===0&&Z(y,"missing indentation for block scalar"),y.lineIndent<G){Y===d?y.result+=e.repeat(`
106
+ `,z?1+H:H):Y===c&&z&&(y.result+=`
107
+ `);break}q?k(oe)?(ee=!0,y.result+=e.repeat(`
108
+ `,z?1+H:H)):ee?(ee=!1,y.result+=e.repeat(`
109
+ `,H+1)):H===0?z&&(y.result+=" "):y.result+=e.repeat(`
110
+ `,H):y.result+=e.repeat(`
111
+ `,z?1+H:H),z=!0,E=!0,H=0;let S=y.position;for(;!x(oe)&&oe!==0;)oe=y.input.charCodeAt(++y.position);Ee(y,S,y.position,!1)}return!0}function Oe(y,N){let q=y.tag,Y=y.anchor,z=[],E=!1;if(y.firstTabInLine!==-1)return!1;y.anchor!==null&&we(y,y.anchor,z);let G=y.input.charCodeAt(y.position);for(;G!==0&&(y.firstTabInLine!==-1&&(y.position=y.firstTabInLine,Z(y,"tab characters must not be used in indentation")),G===45);){let H=y.input.charCodeAt(y.position+1);if(!R(H))break;if(E=!0,y.position++,X(y,!0,-1)&&y.lineIndent<=N){z.push(null),G=y.input.charCodeAt(y.position);continue}let ee=y.line;if(qn(y,N,a,!1,!0),z.push(y.result),X(y,!0,-1),G=y.input.charCodeAt(y.position),(y.line===ee||y.lineIndent>N)&&G!==0)Z(y,"bad indentation of a sequence entry");else if(y.lineIndent<N)break}return E?(y.tag=q,y.anchor=Y,y.kind="sequence",y.result=z,!0):!1}function pt(y,N,q){let Y,z,E,G,H=y.tag,ee=y.anchor,te={},oe=Object.create(null),S=null,A=null,P=null,j=!1,U=!1;if(y.firstTabInLine!==-1)return!1;y.anchor!==null&&we(y,y.anchor,te);let L=y.input.charCodeAt(y.position);for(;L!==0;){!j&&y.firstTabInLine!==-1&&(y.position=y.firstTabInLine,Z(y,"tab characters must not be used in indentation"));let re=y.input.charCodeAt(y.position+1),me=y.line;if((L===63||L===58)&&R(re))L===63?(j&&(ne(y,te,oe,S,A,null,z,E,G),S=A=P=null),U=!0,j=!0,Y=!0):j?(j=!1,Y=!0):Z(y,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),y.position+=1,L=re;else{if(z=y.line,E=y.lineStart,G=y.position,!qn(y,q,s,!1,!0))break;if(y.line===me){for(L=y.input.charCodeAt(y.position);k(L);)L=y.input.charCodeAt(++y.position);if(L===58)L=y.input.charCodeAt(++y.position),R(L)||Z(y,"a whitespace character is expected after the key-value separator within a block mapping"),j&&(ne(y,te,oe,S,A,null,z,E,G),S=A=P=null),U=!0,j=!1,Y=!1,S=y.tag,A=y.result;else if(U)Z(y,"can not read an implicit mapping pair; a colon is missed");else return y.tag=H,y.anchor=ee,!0}else if(U)Z(y,"can not read a block mapping entry; a multiline key may not be an implicit key");else return y.tag=H,y.anchor=ee,!0}if((y.line===me||y.lineIndent>N)&&(j&&(z=y.line,E=y.lineStart,G=y.position),qn(y,N,l,!0,Y)&&(j?A=y.result:P=y.result),j||(ne(y,te,oe,S,A,P,z,E,G),S=A=P=null),X(y,!0,-1),L=y.input.charCodeAt(y.position)),(y.line===me||y.lineIndent>N)&&L!==0)Z(y,"bad indentation of a mapping entry");else if(y.lineIndent<N)break}return j&&ne(y,te,oe,S,A,null,z,E,G),U&&(y.tag=H,y.anchor=ee,y.kind="mapping",y.result=te),U}function et(y){let N=!1,q=!1,Y,z,E=y.input.charCodeAt(y.position);if(E!==33)return!1;y.tag!==null&&Z(y,"duplication of a tag property"),E=y.input.charCodeAt(++y.position),E===60?(N=!0,E=y.input.charCodeAt(++y.position)):E===33?(q=!0,Y="!!",E=y.input.charCodeAt(++y.position)):Y="!";let G=y.position;if(N){do E=y.input.charCodeAt(++y.position);while(E!==0&&E!==62);y.position<y.length?(z=y.input.slice(G,y.position),E=y.input.charCodeAt(++y.position)):Z(y,"unexpected end of the stream within a verbatim tag")}else{for(;E!==0&&!R(E);)E===33&&(q?Z(y,"tag suffix cannot contain exclamation marks"):(Y=y.input.slice(G-1,y.position+1),h.test(Y)||Z(y,"named tag handle cannot contain such characters"),q=!0,G=y.position+1)),E=y.input.charCodeAt(++y.position);z=y.input.slice(G,y.position),g.test(z)&&Z(y,"tag suffix cannot contain flow indicator characters")}z&&!b.test(z)&&Z(y,"tag name cannot contain such characters: "+z);try{z=decodeURIComponent(z)}catch{Z(y,"tag name is malformed: "+z)}return N?y.tag=z:r.call(y.tagMap,Y)?y.tag=y.tagMap[Y]+z:Y==="!"?y.tag="!"+z:Y==="!!"?y.tag="tag:yaml.org,2002:"+z:Z(y,'undeclared tag handle "'+Y+'"'),!0}function Ut(y){let N=y.input.charCodeAt(y.position);if(N!==38)return!1;y.anchor!==null&&Z(y,"duplication of an anchor property"),N=y.input.charCodeAt(++y.position);let q=y.position;for(;N!==0&&!R(N)&&!$(N);)N=y.input.charCodeAt(++y.position);return y.position===q&&Z(y,"name of an anchor node must contain at least one character"),y.anchor=y.input.slice(q,y.position),!0}function Tt(y){let N=y.input.charCodeAt(y.position);if(N!==42)return!1;N=y.input.charCodeAt(++y.position);let q=y.position;for(;N!==0&&!R(N)&&!$(N);)N=y.input.charCodeAt(++y.position);y.position===q&&Z(y,"name of an alias node must contain at least one character");let Y=y.input.slice(q,y.position);return r.call(y.anchorMap,Y)||Z(y,'unidentified alias "'+Y+'"'),y.result=y.anchorMap[Y],X(y,!0,-1),!0}function wt(y,N,q,Y){let z=Te(y);return Ct(y),nt(y,N),y.tag=null,y.anchor=null,y.kind=null,y.result=null,pt(y,q,Y)&&y.kind==="mapping"?(at(y),!0):($e(y),nt(y,z),!1)}function qn(y,N,q,Y,z){let E,G,H=1,ee=!1,te=!1,oe=null,S,A,P;y.depth>=y.maxDepth&&Z(y,"nesting exceeded maxDepth ("+y.maxDepth+")"),y.depth+=1,y.listener!==null&&y.listener("open",y),y.tag=null,y.anchor=null,y.kind=null,y.result=null;let j=E=G=l===q||a===q;if(Y&&X(y,!0,-1)&&(ee=!0,y.lineIndent>N?H=1:y.lineIndent===N?H=0:y.lineIndent<N&&(H=-1)),H===1)for(;;){let U=y.input.charCodeAt(y.position),L=Te(y);if(ee&&(U===33&&y.tag!==null||U===38&&y.anchor!==null)||!et(y)&&!Ut(y))break;oe===null&&(oe=L),X(y,!0,-1)?(ee=!0,G=j,y.lineIndent>N?H=1:y.lineIndent===N?H=0:y.lineIndent<N&&(H=-1)):G=!1}if(G&&(G=ee||z),H===1||l===q)if(o===q||s===q?A=N:A=N+1,P=y.position-y.lineStart,H===1)if(G&&(Oe(y,P)||pt(y,P,A))||W(y,A))te=!0;else{let U=y.input.charCodeAt(y.position);oe!==null&&j&&!G&&U!==124&&U!==62&&wt(y,oe,oe.position-oe.lineStart,A)||E&&de(y,A)||Je(y,A)||Bt(y,A)?te=!0:Tt(y)?(te=!0,(y.tag!==null||y.anchor!==null)&&Z(y,"alias node should not have any properties")):gt(y,A,o===q)&&(te=!0,y.tag===null&&(y.tag="?")),y.anchor!==null&&we(y,y.anchor,y.result)}else H===0&&(te=G&&Oe(y,P));if(y.tag===null)y.anchor!==null&&we(y,y.anchor,y.result);else if(y.tag==="?"){y.result!==null&&y.kind!=="scalar"&&Z(y,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+y.kind+'"');for(let U=0,L=y.implicitTypes.length;U<L;U+=1)if(S=y.implicitTypes[U],S.resolve(y.result)){y.result=S.construct(y.result),y.tag=S.tag,y.anchor!==null&&we(y,y.anchor,y.result);break}}else if(y.tag!=="!"){if(r.call(y.typeMap[y.kind||"fallback"],y.tag))S=y.typeMap[y.kind||"fallback"][y.tag];else{S=null;let U=y.typeMap.multi[y.kind||"fallback"];for(let L=0,re=U.length;L<re;L+=1)if(y.tag.slice(0,U[L].tag.length)===U[L].tag){S=U[L];break}}S||Z(y,"unknown tag !<"+y.tag+">"),y.result!==null&&S.kind!==y.kind&&Z(y,"unacceptable node kind for !<"+y.tag+'> tag; it should be "'+S.kind+'", not "'+y.kind+'"'),S.resolve(y.result,y.tag)?(y.result=S.construct(y.result,y.tag),y.anchor!==null&&we(y,y.anchor,y.result)):Z(y,"cannot resolve a node with !<"+y.tag+"> explicit tag")}return y.listener!==null&&y.listener("close",y),y.depth-=1,y.tag!==null||y.anchor!==null||te}function Ar(y){let N=y.position,q=!1,Y;for(y.version=null,y.checkLineBreaks=y.legacy,y.tagMap=Object.create(null),y.anchorMap=Object.create(null);(Y=y.input.charCodeAt(y.position))!==0&&(X(y,!0,-1),Y=y.input.charCodeAt(y.position),!(y.lineIndent>0||Y!==37));){q=!0,Y=y.input.charCodeAt(++y.position);let z=y.position;for(;Y!==0&&!R(Y);)Y=y.input.charCodeAt(++y.position);let E=y.input.slice(z,y.position),G=[];for(E.length<1&&Z(y,"directive name must not be less than one character in length");Y!==0;){for(;k(Y);)Y=y.input.charCodeAt(++y.position);if(Y===35){do Y=y.input.charCodeAt(++y.position);while(Y!==0&&!x(Y));break}if(x(Y))break;for(z=y.position;Y!==0&&!R(Y);)Y=y.input.charCodeAt(++y.position);G.push(y.input.slice(z,y.position))}Y!==0&&Re(y),r.call(St,E)?St[E](y,E,G):xe(y,'unknown document directive "'+E+'"')}if(X(y,!0,-1),y.lineIndent===0&&y.input.charCodeAt(y.position)===45&&y.input.charCodeAt(y.position+1)===45&&y.input.charCodeAt(y.position+2)===45?(y.position+=3,X(y,!0,-1)):q&&Z(y,"directives end mark is expected"),qn(y,y.lineIndent-1,l,!1,!0),X(y,!0,-1),y.checkLineBreaks&&f.test(y.input.slice(N,y.position))&&xe(y,"non-ASCII line breaks are interpreted as content"),y.documents.push(y.result),y.position===y.lineStart&&Ce(y)){y.input.charCodeAt(y.position)===46&&(y.position+=3,X(y,!0,-1));return}y.position<y.length-1&&Z(y,"end of the stream or a document separator is expected")}function Pr(y,N){y=String(y),N=N||{},y.length!==0&&(y.charCodeAt(y.length-1)!==10&&y.charCodeAt(y.length-1)!==13&&(y+=`
112
+ `),y.charCodeAt(0)===65279&&(y=y.slice(1)));let q=new I(y,N),Y=y.indexOf("\0");for(Y!==-1&&(q.position=Y,Z(q,"null byte is not allowed in input")),q.input+="\0";q.input.charCodeAt(q.position)===32;)q.lineIndent+=1,q.position+=1;for(;q.position<q.length-1;)Ar(q);return q.documents}function vi(y,N,q){N!==null&&typeof N=="object"&&typeof q>"u"&&(q=N,N=null);let Y=Pr(y,q);if(typeof N!="function")return Y;for(let z=0,E=Y.length;z<E;z+=1)N(Y[z])}function Ho(y,N){let q=Pr(y,N);if(q.length!==0){if(q.length===1)return q[0];throw new t("expected a single document in the stream, but found more")}}return gv.loadAll=vi,gv.load=Ho,gv}function Oge(){if(jq)return $I;jq=1;let e=Am(),t=Pm(),n=RI(),i=Object.prototype.toString,r=Object.prototype.hasOwnProperty,o=65279,s=9,a=10,l=13,c=32,u=33,d=34,p=35,f=37,g=38,h=39,b=42,w=44,x=45,k=58,R=61,$=62,_=63,T=64,C=91,K=93,O=96,pe=123,F=124,Q=125,I={};I[0]="\\0",I[7]="\\a",I[8]="\\b",I[9]="\\t",I[10]="\\n",I[11]="\\v",I[12]="\\f",I[13]="\\r",I[27]="\\e",I[34]='\\"',I[92]="\\\\",I[133]="\\N",I[160]="\\_",I[8232]="\\L",I[8233]="\\P";let B=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],Z=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function xe(E,G){if(G===null)return{};let H={},ee=Object.keys(G);for(let te=0,oe=ee.length;te<oe;te+=1){let S=ee[te],A=String(G[S]);S.slice(0,2)==="!!"&&(S="tag:yaml.org,2002:"+S.slice(2));let P=E.compiledTypeMap.fallback[S];P&&r.call(P.styleAliases,A)&&(A=P.styleAliases[A]),H[S]=A}return H}function we(E){let G,H,ee=E.toString(16).toUpperCase();if(E<=255)G="x",H=2;else if(E<=65535)G="u",H=4;else if(E<=4294967295)G="U",H=8;else throw new t("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+G+e.repeat("0",H-ee.length)+ee}let Ct=1,at=2;function $e(E){this.schema=E.schema||n,this.indent=Math.max(1,E.indent||2),this.noArrayIndent=E.noArrayIndent||!1,this.skipInvalid=E.skipInvalid||!1,this.flowLevel=e.isNothing(E.flowLevel)?-1:E.flowLevel,this.styleMap=xe(this.schema,E.styles||null),this.sortKeys=E.sortKeys||!1,this.lineWidth=E.lineWidth||80,this.noRefs=E.noRefs||!1,this.noCompatMode=E.noCompatMode||!1,this.condenseFlow=E.condenseFlow||!1,this.quotingType=E.quotingType==='"'?at:Ct,this.forceQuotes=E.forceQuotes||!1,this.replacer=typeof E.replacer=="function"?E.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function Te(E,G){let H=e.repeat(" ",G),ee=0,te="",oe=E.length;for(;ee<oe;){let S,A=E.indexOf(`
113
+ `,ee);A===-1?(S=E.slice(ee),ee=oe):(S=E.slice(ee,A+1),ee=A+1),S.length&&S!==`
114
+ `&&(te+=H),te+=S}return te}function nt(E,G){return`
115
+ `+e.repeat(" ",E.indent*G)}function St(E,G){for(let H=0,ee=E.implicitTypes.length;H<ee;H+=1)if(E.implicitTypes[H].resolve(G))return!0;return!1}function Ee(E){return E===c||E===s}function zt(E){return E>=32&&E<=126||E>=161&&E<=55295&&E!==8232&&E!==8233||E>=57344&&E<=65533&&E!==o||E>=65536&&E<=1114111}function Vn(E){return zt(E)&&E!==o&&E!==l&&E!==a}function ne(E,G,H){let ee=Vn(E),te=ee&&!Ee(E);return(H?ee:ee&&E!==w&&E!==C&&E!==K&&E!==pe&&E!==Q)&&E!==p&&!(G===k&&!te)||Vn(G)&&!Ee(G)&&E===p||G===k&&te}function Re(E){return zt(E)&&E!==o&&!Ee(E)&&E!==x&&E!==_&&E!==k&&E!==w&&E!==C&&E!==K&&E!==pe&&E!==Q&&E!==p&&E!==g&&E!==b&&E!==u&&E!==F&&E!==R&&E!==$&&E!==h&&E!==d&&E!==f&&E!==T&&E!==O}function X(E){return!Ee(E)&&E!==k}function Ce(E,G){let H=E.charCodeAt(G),ee;return H>=55296&&H<=56319&&G+1<E.length&&(ee=E.charCodeAt(G+1),ee>=56320&&ee<=57343)?(H-55296)*1024+ee-56320+65536:H}function tt(E){return/^\n* /.test(E)}let gt=1,Je=2,Bt=3,W=4,de=5;function Oe(E,G,H,ee,te,oe,S,A){let P,j=0,U=null,L=!1,re=!1,me=ee!==-1,Be=-1,Gt=Re(Ce(E,0))&&X(Ce(E,E.length-1));if(G||S)for(P=0;P<E.length;j>=65536?P+=2:P++){if(j=Ce(E,P),!zt(j))return de;Gt=Gt&&ne(j,U,A),U=j}else{for(P=0;P<E.length;j>=65536?P+=2:P++){if(j=Ce(E,P),j===a)L=!0,me&&(re=re||P-Be-1>ee&&E[Be+1]!==" ",Be=P);else if(!zt(j))return de;Gt=Gt&&ne(j,U,A),U=j}re=re||me&&P-Be-1>ee&&E[Be+1]!==" "}return!L&&!re?Gt&&!S&&!te(E)?gt:oe===at?de:Je:H>9&&tt(E)?de:S?oe===at?de:Je:re?W:Bt}function pt(E,G,H,ee,te){E.dump=(function(){if(G.length===0)return E.quotingType===at?'""':"''";if(!E.noCompatMode&&(B.indexOf(G)!==-1||Z.test(G)))return E.quotingType===at?'"'+G+'"':"'"+G+"'";let oe=E.indent*Math.max(1,H),S=E.lineWidth===-1?-1:Math.max(Math.min(E.lineWidth,40),E.lineWidth-oe),A=ee||E.flowLevel>-1&&H>=E.flowLevel;function P(j){return St(E,j)}switch(Oe(G,A,E.indent,S,P,E.quotingType,E.forceQuotes&&!ee,te)){case gt:return G;case Je:return"'"+G.replace(/'/g,"''")+"'";case Bt:return"|"+et(G,E.indent)+Ut(Te(G,oe));case W:return">"+et(G,E.indent)+Ut(Te(Tt(G,S),oe));case de:return'"'+qn(G)+'"';default:throw new t("impossible error: invalid scalar style")}})()}function et(E,G){let H=tt(E)?String(G):"",ee=E[E.length-1]===`
116
+ `,oe=ee&&(E[E.length-2]===`
117
+ `||E===`
118
+ `)?"+":ee?"":"-";return H+oe+`
119
+ `}function Ut(E){return E[E.length-1]===`
120
+ `?E.slice(0,-1):E}function Tt(E,G){let H=/(\n+)([^\n]*)/g,ee=(function(){let A=E.indexOf(`
121
+ `);return A=A!==-1?A:E.length,H.lastIndex=A,wt(E.slice(0,A),G)})(),te=E[0]===`
122
+ `||E[0]===" ",oe,S;for(;S=H.exec(E);){let A=S[1],P=S[2];oe=P[0]===" ",ee+=A+(!te&&!oe&&P!==""?`
123
+ `:"")+wt(P,G),te=oe}return ee}function wt(E,G){if(E===""||E[0]===" ")return E;let H=/ [^ ]/g,ee,te=0,oe,S=0,A=0,P="";for(;ee=H.exec(E);)A=ee.index,A-te>G&&(oe=S>te?S:A,P+=`
124
+ `+E.slice(te,oe),te=oe+1),S=A;return P+=`
125
+ `,E.length-te>G&&S>te?P+=E.slice(te,S)+`
126
+ `+E.slice(S+1):P+=E.slice(te),P.slice(1)}function qn(E){let G="",H=0;for(let ee=0;ee<E.length;H>=65536?ee+=2:ee++){H=Ce(E,ee);let te=I[H];!te&&zt(H)?(G+=E[ee],H>=65536&&(G+=E[ee+1])):G+=te||we(H)}return G}function Ar(E,G,H){let ee="",te=E.tag;for(let oe=0,S=H.length;oe<S;oe+=1){let A=H[oe];E.replacer&&(A=E.replacer.call(H,String(oe),A)),(N(E,G,A,!1,!1)||typeof A>"u"&&N(E,G,null,!1,!1))&&(ee!==""&&(ee+=","+(E.condenseFlow?"":" ")),ee+=E.dump)}E.tag=te,E.dump="["+ee+"]"}function Pr(E,G,H,ee){let te="",oe=E.tag;for(let S=0,A=H.length;S<A;S+=1){let P=H[S];E.replacer&&(P=E.replacer.call(H,String(S),P)),(N(E,G+1,P,!0,!0,!1,!0)||typeof P>"u"&&N(E,G+1,null,!0,!0,!1,!0))&&((!ee||te!=="")&&(te+=nt(E,G)),E.dump&&a===E.dump.charCodeAt(0)?te+="-":te+="- ",te+=E.dump)}E.tag=oe,E.dump=te||"[]"}function vi(E,G,H){let ee="",te=E.tag,oe=Object.keys(H);for(let S=0,A=oe.length;S<A;S+=1){let P="";ee!==""&&(P+=", "),E.condenseFlow&&(P+='"');let j=oe[S],U=H[j];E.replacer&&(U=E.replacer.call(H,j,U)),N(E,G,j,!1,!1)&&(E.dump.length>1024&&(P+="? "),P+=E.dump+(E.condenseFlow?'"':"")+":"+(E.condenseFlow?"":" "),N(E,G,U,!1,!1)&&(P+=E.dump,ee+=P))}E.tag=te,E.dump="{"+ee+"}"}function Ho(E,G,H,ee){let te="",oe=E.tag,S=Object.keys(H);if(E.sortKeys===!0)S.sort();else if(typeof E.sortKeys=="function")S.sort(E.sortKeys);else if(E.sortKeys)throw new t("sortKeys must be a boolean or a function");for(let A=0,P=S.length;A<P;A+=1){let j="";(!ee||te!=="")&&(j+=nt(E,G));let U=S[A],L=H[U];if(E.replacer&&(L=E.replacer.call(H,U,L)),!N(E,G+1,U,!0,!0,!0))continue;let re=E.tag!==null&&E.tag!=="?"||E.dump&&E.dump.length>1024;re&&(E.dump&&a===E.dump.charCodeAt(0)?j+="?":j+="? "),j+=E.dump,re&&(j+=nt(E,G)),N(E,G+1,L,!0,re)&&(E.dump&&a===E.dump.charCodeAt(0)?j+=":":j+=": ",j+=E.dump,te+=j)}E.tag=oe,E.dump=te||"{}"}function y(E,G,H){let ee=H?E.explicitTypes:E.implicitTypes;for(let te=0,oe=ee.length;te<oe;te+=1){let S=ee[te];if((S.instanceOf||S.predicate)&&(!S.instanceOf||typeof G=="object"&&G instanceof S.instanceOf)&&(!S.predicate||S.predicate(G))){if(H?S.multi&&S.representName?E.tag=S.representName(G):E.tag=S.tag:E.tag="?",S.represent){let A=E.styleMap[S.tag]||S.defaultStyle,P;if(i.call(S.represent)==="[object Function]")P=S.represent(G,A);else if(r.call(S.represent,A))P=S.represent[A](G,A);else throw new t("!<"+S.tag+'> tag resolver accepts not "'+A+'" style');E.dump=P}return!0}}return!1}function N(E,G,H,ee,te,oe,S){E.tag=null,E.dump=H,y(E,H,!1)||y(E,H,!0);let A=i.call(E.dump),P=ee;ee&&(ee=E.flowLevel<0||E.flowLevel>G);let j=A==="[object Object]"||A==="[object Array]",U,L;if(j&&(U=E.duplicates.indexOf(H),L=U!==-1),(E.tag!==null&&E.tag!=="?"||L||E.indent!==2&&G>0)&&(te=!1),L&&E.usedDuplicates[U])E.dump="*ref_"+U;else{if(j&&L&&!E.usedDuplicates[U]&&(E.usedDuplicates[U]=!0),A==="[object Object]")ee&&Object.keys(E.dump).length!==0?(Ho(E,G,E.dump,te),L&&(E.dump="&ref_"+U+E.dump)):(vi(E,G,E.dump),L&&(E.dump="&ref_"+U+" "+E.dump));else if(A==="[object Array]")ee&&E.dump.length!==0?(E.noArrayIndent&&!S&&G>0?Pr(E,G-1,E.dump,te):Pr(E,G,E.dump,te),L&&(E.dump="&ref_"+U+E.dump)):(Ar(E,G,E.dump),L&&(E.dump="&ref_"+U+" "+E.dump));else if(A==="[object String]")E.tag!=="?"&&pt(E,E.dump,G,oe,P);else{if(A==="[object Undefined]")return!1;if(E.skipInvalid)return!1;throw new t("unacceptable kind of an object to dump "+A)}if(E.tag!==null&&E.tag!=="?"){let re=encodeURI(E.tag[0]==="!"?E.tag.slice(1):E.tag).replace(/!/g,"%21");E.tag[0]==="!"?re="!"+re:re.slice(0,18)==="tag:yaml.org,2002:"?re="!!"+re.slice(18):re="!<"+re+">",E.dump=re+" "+E.dump}}return!0}function q(E,G){let H=[],ee=[];Y(E,H,ee);let te=ee.length;for(let oe=0;oe<te;oe+=1)G.duplicates.push(H[ee[oe]]);G.usedDuplicates=new Array(te)}function Y(E,G,H){if(E!==null&&typeof E=="object"){let ee=G.indexOf(E);if(ee!==-1)H.indexOf(ee)===-1&&H.push(ee);else if(G.push(E),Array.isArray(E))for(let te=0,oe=E.length;te<oe;te+=1)Y(E[te],G,H);else{let te=Object.keys(E);for(let oe=0,S=te.length;oe<S;oe+=1)Y(E[te[oe]],G,H)}}}function z(E,G){G=G||{};let H=new $e(G);H.noRefs||q(E,H);let ee=E;return H.replacer&&(ee=H.replacer.call({"":ee},"",ee)),N(H,0,ee,!0,!0)?H.dump+`
127
+ `:""}return $I.dump=z,$I}function Cge(){if(Lq)return zn;Lq=1;let e=Pge(),t=Oge();function n(i,r){return function(){throw new Error("Function yaml."+i+" is removed in js-yaml 4. Use yaml."+r+" instead, which is now safe by default.")}}return zn.Type=tr(),zn.Schema=Mq(),zn.FAILSAFE_SCHEMA=Wq(),zn.JSON_SCHEMA=qq(),zn.CORE_SCHEMA=Kq(),zn.DEFAULT_SCHEMA=RI(),zn.load=e.load,zn.loadAll=e.loadAll,zn.dump=t.dump,zn.YAMLException=Pm(),zn.types={binary:Yq(),float:Vq(),map:Gq(),null:zq(),pairs:Qq(),set:eK(),timestamp:Jq(),bool:Uq(),int:Hq(),merge:Zq(),omap:Xq(),seq:Bq(),str:Fq()},zn.safeLoad=n("safeLoad","load"),zn.safeLoadAll=n("safeLoadAll","loadAll"),zn.safeDump=n("safeDump","dump"),zn}var zn,gv,va,fq,nI,mq,rI,gq,iI,hq,oI,yq,sI,bq,aI,wq,cI,vq,lI,kq,uI,xq,dI,$q,pI,Rq,fI,Sq,mI,Eq,gI,Aq,hI,Pq,yI,Oq,bI,Cq,wI,_q,vI,Iq,kI,Tq,xI,Dq,Nq,$I,jq,Lq,_ge,hd,zGe,UGe,HGe,VGe,qGe,KGe,JGe,ZGe,YGe,XGe,QGe,eWe,tWe,nWe,SI=v(()=>{zn={},gv={},va={};$I={};_ge=Cge(),hd=Ege(_ge),{Type:zGe,Schema:UGe,FAILSAFE_SCHEMA:HGe,JSON_SCHEMA:VGe,CORE_SCHEMA:qGe,DEFAULT_SCHEMA:KGe,load:JGe,loadAll:ZGe,dump:YGe,YAMLException:XGe,types:QGe,safeLoad:eWe,safeLoadAll:tWe,safeDump:nWe}=hd});function _n(e){return typeof e=="string"&&Tge.test(e)}function Om(e,t){let n=e?.[t];if(!Array.isArray(n))return[];let i=[];for(let r of n){if(r===null||typeof r!="object"||Array.isArray(r))continue;let{path:o,sha256:s}=r;_n(o)&&typeof s=="string"&&Dge.test(s)&&i.push({path:o,sha256:s})}return i}function EI(e,t){if(e.stat(t)!=="file")return;let n=e.bytes?e.bytes(t):Buffer.from(e.read(t),"utf-8");return ld(n)}function tK(e,t){let n=[],i=[];for(let r of e){let o=EI(t,r.path)??null,s=o===null?"missing":o===r.sha256?"pinned":"drifted";n.push({...r,actual:o,state:s}),s==="missing"?i.push({code:"asset-missing",message:`evidence pins ${r.path}, which does not exist`}):s==="drifted"&&i.push({code:"asset-drift",message:`${r.path} changed since it was pinned: sha256 ${r.sha256.slice(0,12)} is pinned, the file${t.label} hashes to ${o.slice(0,12)}`})}return{assets:n,warnings:i}}function Mr(e,t){let n=null;for(let i of t)(i.dir==="."||e===i.dir||e.startsWith(`${i.dir}/`))&&(!n||n.dir==="."||i.dir.length>n.dir.length)&&(n=i);return n?.name??null}function cs(e,t){return t===e||t.startsWith(`${e}/`)}function nK(e,t,n,i,r){let o=[];for(let s of t){if(s.id===null||s.supersededBy!==null)continue;let a={origin:"declared",resolves:"source",recordKind:e,record:s.id,recordPath:s.path};for(let c of s.assets)o.push({kind:"asset",...a,target:c.path,member:Mr(c.path,r),status:c.state,reason:c.state==="missing"?`${c.path} does not exist${i.label}`:c.state==="drifted"?`${c.path} changed since ${s.id} pinned it`:c.state==="stale"?`${c.path} has not changed since a record ${s.id} supersedes pinned it`:null,sha256:c.sha256,actual:c.actual});let l=n?s.data?.[n]:void 0;if(Array.isArray(l)){for(let c of l)if(typeof c=="string"){if(c.startsWith("member:")){let u=c.slice(7),d=r.some(p=>p.name===u);o.push({kind:"constrains",...a,target:c,member:d?u:null,status:d?"resolved":"missing",reason:d?null:`${u} is not a member of this workspace`})}else if(c.startsWith("path:")){let u=c.slice(5);if(!_n(u))continue;let d=i.stat(u)!==void 0;o.push({kind:"constrains",...a,target:c,member:Mr(u,r),status:d?"resolved":"missing",reason:d?null:`${u} does not exist${i.label}`})}}}}return o}var Ige,Tge,Dge,uo=v(()=>{"use strict";ss();Ige=String.raw`(?!/)(?!(?:[^/]*/)*\.{1,2}(?:/|$))(?!.*//)[^\\\u0000-\u001f]*[^/\\\u0000-\u001f]`,Tge=new RegExp(`^${Ige}$`,"u"),Dge=/^[0-9a-f]{64}$/});function hv(e,t,n="markdown-front-matter"){return yd(e,t,n)}function rK(e,t,n,i){let r=e.session;if(!r)return;let o=new Set(e.closedStates),s=new Set((i??[]).flatMap(l=>l.records.map(c=>c.id)).filter(l=>l!==null)),a=new Map;for(let{s:l,reviewsField:c}of(i??[]).flatMap(u=>u.records.map(d=>({s:d,reviewsField:u.reviews})))){if(l.id===null)continue;let u=l.data?.[c];Array.isArray(u)&&u.forEach((d,p)=>{if(d===null||typeof d!="object")return;let f=d;if(typeof f.session!="string")return;let g=a.get(f.session)??[];g.push({id:l.id,path:l.path,index:p,reviewer:typeof f.reviewer=="string"?f.reviewer:null,verdict:typeof f.verdict=="string"?f.verdict:null}),a.set(f.session,g)})}for(let l of t){if(l.citedBy=l.id===null?[]:a.get(l.id)??[],l.data===null)continue;if(l.state!==null&&o.has(l.state)){let u=l.data[r.seal],d=n.get(l.path);if(typeof u=="string"&&d!==void 0){let p=hv(d,r.seal,e.format);p!==u&&l.reasons.push({code:"session-seal-mismatch",message:/^[0-9a-f]{64}$/.test(u)?`${r.seal} is ${u}, a seal by the text rule chant used before #2546, and the session seals to ${p} now: seal it again by hand, since a closed session is never rewritten by chant`:`${r.seal} is ${u}, but the session seals to ${p}: the session changed after it closed`})}}if(i===null)continue;let c=l.data[r.verdicts];Array.isArray(c)&&c.forEach((u,d)=>{if(u===null||typeof u!="object")return;let p=u.record;typeof p=="string"&&!s.has(p)&&l.reasons.push({code:"session-verdict-unknown-record",message:`${r.verdicts}[${d}] names ${p}, which no ${Cm(r).join(" or ")} record has`})})}}var AI=v(()=>{"use strict";mn()});import{readFileSync as Nge}from"node:fs";import{homedir as jge}from"node:os";import{isAbsolute as Lge,join as Mge,resolve as Fge}from"node:path";import{fileURLToPath as Bge}from"node:url";function sK(e,t){let n=e?.[t];return n!==null&&typeof n=="object"&&!Array.isArray(n)?n:void 0}function aK(e,t){let n=oK.safeParse(e);return n.success?[]:n.error.issues.map(i=>`/${[t,...i.path].join("/")} ${i.message}`)}function Wge(e,t){if(e.path!==void 0){let n=e.path;return n==="~"||n.startsWith("~/")?Mge(jge(),n.slice(1)):Lge(n)?n:Fge(t,n)}if(e.uri!==void 0&&e.uri.startsWith("file:"))try{return Bge(e.uri)}catch{return}}function cK(e,t,n){let i=oK.shape.transcript.safeParse(e.transcript);if(!i.success||i.data===void 0)return;let r=i.data,o=Wge(r,n);if(o===void 0)return;let s;try{s=Nge(o)}catch{return}let a=ld(s);if(a===r.sha256)return;let l=r.path??r.uri;return`${t}.transcript ${l} is pinned at sha256 ${r.sha256.slice(0,12)}, and the file here hashes to ${a.slice(0,12)}: it is not the transcript the record means`}var Gge,po,iK,oK,lK=v(()=>{"use strict";Ln();ss();Gge=["cli","mcp","harvest"],po=m.string().min(1),iK=m.string().regex(/^[0-9a-f]{64}$/,"must be the lowercase hex SHA-256 of the transcript's bytes"),oK=m.object({via:m.enum(Gge).optional(),client:m.object({name:po,version:po.optional(),title:po.optional()}).strict().optional(),harness:po.optional(),model:po.optional(),session:m.union([po,m.null(),m.object({id:po.optional(),record:po.optional()}).strict().refine(e=>e.id!==void 0||e.record!==void 0,{message:"names neither the harness's session id nor a chant session record"})]).optional(),turns:m.object({from:m.number().int().min(0),to:m.number().int().min(0)}).strict().refine(e=>e.to>=e.from,{message:"ends before it starts"}).optional(),transcript:m.union([m.object({path:po,sha256:iK}).strict(),m.object({uri:po,sha256:iK}).strict()]).optional()})});var dK=ie(PI=>{"use strict";Object.defineProperty(PI,"__esModule",{value:!0});var zge=p_(),Uge=P_(),Hge=J_(),Vge=d0(),uK=p0(),qge=[zge.default,Uge.default,(0,Hge.default)(),Vge.default,uK.metadataVocabulary,uK.contentVocabulary];PI.default=qge});var pK=ie((hWe,Kge)=>{Kge.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:!0,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:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},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:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},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:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},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:!0}});var mK=ie((Mt,OI)=>{"use strict";Object.defineProperty(Mt,"__esModule",{value:!0});Mt.MissingRefError=Mt.ValidationError=Mt.CodeGen=Mt.Name=Mt.nil=Mt.stringify=Mt.str=Mt._=Mt.KeywordCxt=Mt.Ajv=void 0;var Jge=l_(),Zge=dK(),Yge=h0(),fK=pK(),Xge=["/properties"],yv="http://json-schema.org/draft-07/schema",bd=class extends Jge.default{_addVocabularies(){super._addVocabularies(),Zge.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(Yge.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(fK,Xge):fK;this.addMetaSchema(t,yv,!1),this.refs["http://json-schema.org/schema"]=yv}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(yv)?yv:void 0)}};Mt.Ajv=bd;OI.exports=Mt=bd;OI.exports.Ajv=bd;Object.defineProperty(Mt,"__esModule",{value:!0});Mt.default=bd;var Qge=Wu();Object.defineProperty(Mt,"KeywordCxt",{enumerable:!0,get:function(){return Qge.KeywordCxt}});var wd=Fe();Object.defineProperty(Mt,"_",{enumerable:!0,get:function(){return wd._}});Object.defineProperty(Mt,"str",{enumerable:!0,get:function(){return wd.str}});Object.defineProperty(Mt,"stringify",{enumerable:!0,get:function(){return wd.stringify}});Object.defineProperty(Mt,"nil",{enumerable:!0,get:function(){return wd.nil}});Object.defineProperty(Mt,"Name",{enumerable:!0,get:function(){return wd.Name}});Object.defineProperty(Mt,"CodeGen",{enumerable:!0,get:function(){return wd.CodeGen}});var ehe=Xf();Object.defineProperty(Mt,"ValidationError",{enumerable:!0,get:function(){return ehe.default}});var the=zu();Object.defineProperty(Mt,"MissingRefError",{enumerable:!0,get:function(){return the.default}})});var _I={};_e(_I,{EVIDENCE_RESULTS:()=>rhe,VERIFICATION_TYPES:()=>hK,WORK_WARNING_CODES:()=>CI,acceptanceCriteria:()=>yK,applyWork:()=>ihe,idList:()=>Rr,isDecided:()=>Uc,workAcceptance:()=>bK,workAnswers:()=>nhe});import{dirname as gK}from"node:path";function nhe(e,t){let n=new Map;for(let i of t)n.set(i,[]);for(let i of e)if(!(i.id===null||i.data===null))for(let r of Rr(i.data,"constrains")){let o=n.get(r);if(!o||o.some(a=>a.id===i.id))continue;let s=i.data.answer;o.push({id:i.id,point:typeof i.data.point=="string"?i.data.point:null,state:i.state,answer:typeof s=="string"||typeof s=="boolean"?s:null,answeredBy:Rr(i.data,"answered_by")})}return n}function yK(e,t){let n=e?.[t];return Array.isArray(n)?n.filter(i=>i!==null&&typeof i=="object"&&typeof i.id=="string"&&typeof i.text=="string"&&hK.includes(i.verification)):[]}function bK(e,t,n){if(!Array.isArray(e?.[t.field]))return{acceptance:null,selfVerified:[]};let i=yK(e,t.field),r=typeof e?.[t.implementer]=="string"?an(e[t.implementer]):null,o=Array.isArray(e?.[n])?e[n]:[],s=[],a=i.map(l=>{let c=!1;for(let u of o){if(u===null||typeof u!="object")continue;let d=u;if(!(d.criterion!==l.id||d.result!=="pass"||d.verification!==l.verification)){if(l.verification==="manual"){if(typeof d.by!="string")continue;if(r!==null&&an(d.by)===r){s.includes(l.id)||s.push(l.id);continue}}c=!0}}return{id:l.id,verification:l.verification,met:c}});return{acceptance:{met:a.filter(l=>l.met).length,total:a.length,criteria:a},selfVerified:s}}function Rr(e,t){let n=e?.[t];return Array.isArray(n)?n.filter(i=>typeof i=="string"):[]}function Uc(e,t){return t===null?!1:e.approval?(e.approval[t]??0)>0:(e.closedStates??[]).includes(t)}async function ihe(e,t,n){let{kind:i}=e,r=i.work,o=await gn(r.decisions,gK(e.file)),s=await ka(o,{root:n.root,source:n.source}),a=new Map;for(let f of s.records)f.id!==null&&!a.has(f.id)&&a.set(f.id,f);let l=new Map;for(let f of t)f.id!==null&&!l.has(f.id)&&l.set(f.id,f);let c=new Set(i.closedStates),u;if(r.contract){let f=await gn(r.contract.kind,gK(e.file)),g=await ka(f,{root:n.root,source:n.source}),h=new Map;for(let b of g.records)b.id!==null&&!h.has(b.id)&&h.set(b.id,b);u={kind:f,byId:h}}let d=new Set;for(let f of l.keys()){let g=new Set,h=[...Rr(l.get(f).data,r.needs)];for(;h.length>0;){let b=h.pop();if(b===f){d.add(f);break}g.has(b)||(g.add(b),h.push(...Rr(l.get(b)?.data??null,r.needs)))}}let p=new Map;for(let f of t){if(f.data===null)continue;let g=Rr(f.data,r.needs),h=Rr(f.data,r.implements);f.blockedBy=g.filter(R=>l.get(R)?.state!==r.done).map(R=>({id:R,state:l.get(R)?.state??null})),f.implements=h.map(R=>({id:R,state:a.get(R)?.state??null})),f.ready=f.state===r.open&&f.blockedBy.length===0&&f.reasons.length===0&&f.supersededBy===null&&!(f.id!==null&&d.has(f.id)),f.warnings=f.warnings.filter(R=>R.code!=="record-no-evidence");let b=g.filter(R=>!l.has(R));b.length>0&&f.warnings.push({code:"work-needs-unknown",message:`needs ${b.join(", ")}, which no work record has, so the item stays blocked`});let w=h.filter(R=>!a.has(R));w.length>0&&f.warnings.push({code:"work-implements-unknown",message:`implements ${w.join(", ")}, which no decision in ${r.decisions} has`}),f.id!==null&&d.has(f.id)&&f.warnings.push({code:"work-needs-cycle",message:`${f.id} needs itself through its needs links, so it can never be ready`});let x=f.implements.filter(R=>R.state!==null&&!Uc(o.kind,R.state));x.length>0&&f.warnings.push({code:"work-implements-undecided",message:`implements ${x.map(R=>`${R.id}, which is ${R.state}`).join("; ")}: the work may carry out a choice nobody has made`});let k=i.pins?f.data[i.pins.field]:void 0;if(f.state===r.done&&i.pins&&!(Array.isArray(k)&&k.length>0)&&f.warnings.push({code:"work-done-unpinned",message:`${f.id??f.path} is ${r.done} and ${i.pins.field} is empty or missing: nothing shows the work was done`}),r.acceptance&&i.pins){let{acceptance:R,selfVerified:$}=bK(f.data,r.acceptance,i.pins.field);f.acceptance=R,$.length>0&&f.warnings.push({code:"work-acceptance-self-verified",message:`the manual verdict on ${$.join(", ")} is by ${String(f.data[r.acceptance.implementer])}, the implementer, so it does not count: a manual verdict comes from someone else`});let _=R?.criteria.filter(T=>!T.met)??[];f.state===r.done&&_.length>0&&f.warnings.push({code:"work-acceptance-unmet",message:`${f.id??f.path} is ${r.done}, and no passing evidence meets ${_.map(T=>`${T.id} (${T.verification})`).join(", ")}`})}if(u&&r.contract){let R=f.data[r.contract.field];if(typeof R=="string"&&R!==""){let $=u.byId.get(R);f.contract={id:R,state:$?.state??null},$?Uc(u.kind.kind,$.state)||f.warnings.push({code:"work-contract-undecided",message:`names the contract ${R}, which is ${$.state??"in no state"}: the work may build a contract nobody approved`}):f.warnings.push({code:"work-contract-unknown",message:`names the contract ${R}, which no record in ${r.contract.kind} has`})}else f.contract=null}if(r.tier){let R=f.data[r.tier.field];typeof R=="string"&&!r.tier.tiers.includes(R)&&f.warnings.push({code:"work-tier-unknown",message:`names the builder tier ${R}, which the kind's tiers (${r.tier.tiers.join(", ")}) do not list`})}if(f.state!==null&&c.has(f.state)&&typeof f.data[r.closedOn]!="string"&&f.warnings.push({code:"work-closed-without-date",message:`${f.id??f.path} is ${f.state} and has no ${r.closedOn}`}),f.id!==null&&l.get(f.id)===f)for(let R of h){let $=p.get(R)??[];$.some(_=>_.id===f.id)||$.push({id:f.id,state:f.state}),p.set(R,$)}}return{decisions:s.records.filter(f=>f.id!==null&&a.get(f.id)===f).map(f=>({id:f.id,path:f.path,state:f.state,supersededBy:f.supersededBy,implementedBy:p.get(f.id)??[]}))}}var CI,hK,rhe,vd=v(()=>{"use strict";mn();CI=["work-needs-unknown","work-implements-unknown","work-needs-cycle","work-implements-undecided","work-done-unpinned","work-closed-without-date","work-done-gap-open","work-acceptance-unmet","work-acceptance-self-verified","work-contract-unknown","work-contract-undecided","work-tier-unknown"];hK=["unit","integration","e2e","runtime","manual"],rhe=["pass","fail"]});var II,wK=v(()=>{II={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://intentius.io/chant/schemas/workspace/decision-points/v1/decision-points.schema.json",title:"Decision points",description:"A workspace's decision points (ws-058, #2738): the recurring questions it asks of its own graph, declared as data in a JSON file that an answer record kind names in `answers.points`. Each point is a typed question (`noul`, `choice` with 2 to 255 options, or `score` with 2 to 10 ordered levels, the question types of the POST /v1/systemone wire format, #2491), the inputs it reads, each named as a read-contract output, and an ordered chain of deciders: `table` rows, `model` deciders with a backend, a pinned model id and a threshold, and a `quorum` of people, always last. What JSON Schema cannot say is checked in code (`points.ts`): an input's output is one the read contract has, a table row tests declared inputs and answers a candidate, a field belongs to its decider's kind, a model id is pinned rather than an alias, and the chain ends in its one quorum. A point declared `adhoc` (#3403) leaves out its question's criteria: the question's text and candidates come with each ask (`points ask --candidates`), and its chain is one quorum. Unknown fields are refused, except fields whose names start with x-.",type:"object",required:["points"],properties:{$schema:{type:"string"},points:{type:"object",minProperties:1,propertyNames:{pattern:"^[a-z][a-z0-9-]*$"},additionalProperties:{$ref:"#/$defs/point"}}},patternProperties:{"^x-":!0},additionalProperties:!1,$defs:{text:{type:"string",minLength:1},point:{type:"object",required:["title","question","inputs","deciders"],properties:{title:{$ref:"#/$defs/text"},adhoc:{type:"boolean",description:"An ad-hoc point (#3403): the question declares its type and what the asks are for, and no criteria. Each ask gives the question's text and its candidates, and the answer record keeps them, so people's answer is checked against them. Its chain is one quorum."},question:{$ref:"#/$defs/question"},inputs:{type:"object",description:"The state the deciders see, input name to description. A name is a read-contract output (record, decision, work-item, finding, region, commit, node, member, gate, release, environment, component, ask), optionally followed by dotted field names, such as work-item.fits_small: a field of that output, or a value the caller derives from it. The caller supplies the values; a table row can only test these names.",minProperties:1,propertyNames:{pattern:"^[A-Za-z_][A-Za-z0-9_-]*(\\.[A-Za-z_][A-Za-z0-9_]*)*$"},additionalProperties:{type:"string"}},deciders:{type:"array",minItems:1,items:{$ref:"#/$defs/decider"}}},patternProperties:{"^x-":!0},additionalProperties:!1,if:{properties:{adhoc:{const:!0}},required:["adhoc"]},then:{properties:{question:{not:{required:["criteria"]}}}},else:{properties:{question:{required:["criteria"]}}}},question:{type:"object",required:["type","instructions"],properties:{type:{enum:["noul","choice","score"]},instructions:{$ref:"#/$defs/text"},criteria:{description:"The candidates. noul: {true, false} descriptions. choice: option to description, 2 to 255 options. score: 2 to 10 ordered levels.",type:["object","array"]}},additionalProperties:!1,allOf:[{if:{properties:{type:{const:"noul"}}},then:{properties:{criteria:{type:"object",required:["true","false"],properties:{true:{type:"string"},false:{type:"string"}},additionalProperties:!1}}}},{if:{properties:{type:{const:"choice"}}},then:{properties:{criteria:{type:"object",minProperties:2,maxProperties:255,additionalProperties:{type:"string"}}}}},{if:{properties:{type:{const:"score"}}},then:{properties:{criteria:{type:"array",minItems:2,maxItems:10,uniqueItems:!0,items:{$ref:"#/$defs/text"}}}}}]},scalar:{type:["string","number","boolean","null"]},condition:{description:"A value the input must equal, or one comparison.",oneOf:[{$ref:"#/$defs/scalar"},{type:"object",minProperties:1,maxProperties:1,properties:{eq:{$ref:"#/$defs/scalar"},ne:{$ref:"#/$defs/scalar"},lt:{type:"number"},lte:{type:"number"},gt:{type:"number"},gte:{type:"number"},in:{type:"array",items:{$ref:"#/$defs/scalar"}}},additionalProperties:!1}]},row:{type:"object",required:["when","answer"],properties:{when:{type:"object",description:"Every named input must meet its condition. An empty object matches every state.",additionalProperties:{$ref:"#/$defs/condition"}},answer:{type:["string","boolean"]},note:{type:"string"}},additionalProperties:!1},decider:{type:"object",required:["kind"],properties:{kind:{enum:["table","model","quorum"]},rows:{type:"array",minItems:1,items:{$ref:"#/$defs/row"}},backend:{type:"string",pattern:"^[a-z][a-z0-9-]*$",description:"model: which backend answers, such as systemone (any server with the POST /v1/systemone wire format). chant never calls it: the decide Op activity or a runtime's decider does."},model:{type:"string",minLength:1,description:"model: the pinned model id the backend is asked for, such as jev-1.13.0. An alias such as jev-latest is refused."},threshold:{type:"number",exclusiveMinimum:0,maximum:1,description:"model: the least confidence that makes the answer a proposal. Below it the answer is not observed and the next decider is asked."},unreachable:{enum:["escalate","fail"],description:"model: what happens when the backend can't be reached or gives no usable answer: escalate to the next decider (the default), or fail the ask and write nothing."},count:{type:"integer",minimum:1,description:"quorum: how many distinct people must answer."},roles:{type:"array",minItems:1,items:{$ref:"#/$defs/text"},description:"quorum: the trust policy roles whose holders count."},note:{type:"string"}},additionalProperties:!1,allOf:[{if:{properties:{kind:{const:"table"}}},then:{required:["rows"]}},{if:{properties:{kind:{const:"model"}}},then:{required:["backend","model","threshold"]}},{if:{properties:{kind:{const:"quorum"}}},then:{required:["count"]}}]}}}});var CK={};_e(CK,{ANSWER_WARNING_CODES:()=>yhe,DECISION_POINTS_SCHEMA_ID:()=>dhe,DeciderFailed:()=>kd,POINT_INPUT_OUTPUTS:()=>xK,POINT_INPUT_OUTPUT_NAMES:()=>DI,PointsError:()=>Hc,answerId:()=>LI,answerReason:()=>AK,applyAnswers:()=>bhe,askedOf:()=>Tm,askedQuestion:()=>$d,candidates:()=>fo,canonical:()=>Im,inputOutput:()=>Vc,inputsHash:()=>NI,matches:()=>EK,observe:()=>OK,parseAsked:()=>jI,parsePoints:()=>RK,pointOf:()=>xd,pointVersion:()=>xa,pointsFileOf:()=>Sd,quorumOf:()=>Rd,readPointsThrough:()=>Ed,runChain:()=>MI,schemaProblems:()=>$K,wireQuestion:()=>PK});import{createHash as she}from"node:crypto";import{dirname as ahe,posix as TI,relative as che,resolve as lhe,sep as uhe}from"node:path";function Vc(e){let t=e.indexOf(".");return t<0?e:e.slice(0,t)}function fo(e){return e.type==="noul"?[!0,!1]:e.type==="choice"?Object.keys(e.criteria??{}):[...e.criteria??[]]}function fhe(e){let t=[];for(let[n,i]of Object.entries(e)){let r=(...l)=>["points",n,...l].join("."),o=Object.keys(i.inputs);for(let l of o){let c=Vc(l);DI.includes(c)||t.push({field:r("inputs",l),message:`names ${JSON.stringify(c)}, which is not a read-contract output; an input is one of ${DI.join(", ")}, optionally with dotted field names`})}i.adhoc&&(i.deciders.length!==1||i.deciders[0].kind!=="quorum")&&t.push({field:r("deciders"),message:"is an ad-hoc point's chain, and an ad-hoc point is decided by people alone: its chain is one quorum, since no table row or model can know candidates that come with the ask"});let s=fo(i.question),a=i.deciders.length-1;i.deciders.forEach((l,c)=>{let u=l;for(let[d,p]of Object.entries(vK))if(d!==l.kind)for(let f of p)u[f]!==void 0&&!vK[l.kind].includes(f)&&t.push({field:r("deciders",c,f),message:`is only for a ${d} decider, and this one is a ${l.kind}`});l.kind==="quorum"&&c!==a&&t.push({field:r("deciders",c),message:"is a quorum, and a quorum is the last decider: nobody is asked after people"}),l.kind==="model"&&phe.test(l.model)&&t.push({field:r("deciders",c,"model"),message:`${JSON.stringify(l.model)} is an alias, and an alias moves when a new release ships: pin a versioned model id`}),l.kind==="table"&&l.rows.forEach((d,p)=>{s.includes(d.answer)||t.push({field:r("deciders",c,"rows",p,"answer"),message:`must be one of ${s.map(f=>JSON.stringify(f)).join(", ")}, not ${JSON.stringify(d.answer)}`});for(let f of Object.keys(d.when))o.includes(f)||t.push({field:r("deciders",c,"rows",p,"when",f),message:`is not one of this point's inputs (${o.join(", ")})`})})}),i.deciders[a]?.kind!=="quorum"&&t.push({field:r("deciders"),message:"must end in a quorum: when no table row or model answers, people do"})}return t}function mhe(){if(bv)return bv;let e=da();return bv=new e({allErrors:!0,strict:!1}).compile(II),bv}function $K(e){let t=mhe();if(t(e))return[];let n=new Set,i=[];for(let r of t.errors??[]){if(ghe.has(r.keyword))continue;let o=r.instancePath.split("/").slice(1).map(c=>c.replace(/~1/g,"/").replace(/~0/g,"~")),s=o.length?o.join("."):null,a=r.keyword==="additionalProperties"?`has an unknown field ${JSON.stringify(r.params.additionalProperty)}; only fields named x-... may be added`:r.keyword==="required"?`is missing ${JSON.stringify(r.params.missingProperty)}`:r.keyword==="propertyNames"?`has a name that is not allowed: ${JSON.stringify(r.params.propertyName)}`:r.keyword==="not"?"has criteria, and an ad-hoc point's candidates come with each ask (#3403): leave criteria out":r.message??"is invalid",l=`${s}\0${a}`;n.has(l)||(n.add(l),i.push({field:s,message:a}))}return i}function RK(e,t){let n;try{n=JSON.parse(e)}catch(s){throw new Hc(t,[{field:null,message:`is not JSON: ${s instanceof Error?s.message:String(s)}`}])}let i=$K(n);if(i.length>0)throw new Hc(t,i);let r=n.points,o=fhe(r);if(o.length>0)throw new Hc(t,o);return r}function xd(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function Im(e){if(Array.isArray(e))return`[${e.map(Im).join(",")}]`;if(e!==null&&typeof e=="object"){let t=e;return`{${Object.keys(t).sort().filter(n=>t[n]!==void 0).map(n=>`${JSON.stringify(n)}:${Im(t[n])}`).join(",")}}`}return JSON.stringify(e)}function $d(e,t){return t?{type:e.question.type,instructions:t.question,criteria:t.criteria}:e.question}function jI(e,t){if(t===null||typeof t!="object"||Array.isArray(t))return{problems:["the candidates must be a JSON object with question and criteria"]};let n=t,i=[],r=Object.keys(n).filter(l=>l!=="question"&&l!=="criteria");r.length>0&&i.push(`the candidates take question and criteria, not ${r.join(", ")}`),kK(n.question)||i.push("question must be the question's text");let o=n.criteria,s=e.question.type;if(s==="score")(!Array.isArray(o)||o.length<2||o.length>10||!o.every(kK)||new Set(o).size!==o.length)&&i.push("criteria must be 2 to 10 distinct levels, in order, for a score question");else if(o===null||typeof o!="object"||Array.isArray(o))i.push(`criteria must be an object of ${s==="noul"?"true and false":"options"}, each with what it means`);else{let l=Object.entries(o);if(l.every(([c,u])=>c!==""&&typeof u=="string")||i.push("each criterion must be a non-empty name with what it means as a string"),s==="noul"){let c=l.map(([u])=>u).sort();(c.length!==2||c[0]!=="false"||c[1]!=="true")&&i.push("criteria must describe true and false, and nothing else, for a noul question")}else(l.length<2||l.length>255)&&i.push("criteria must give 2 to 255 options for a choice question")}if(i.length>0)return{problems:i};let a=Array.isArray(o)?[...o]:{...o};return{asked:{question:n.question.trim(),criteria:a}}}function Tm(e){let t=e.asked;if(t===null||typeof t!="object"||Array.isArray(t)||typeof t.question!="string")return;let n=t.criteria;if(Array.isArray(n))return{question:t.question,criteria:n.filter(i=>typeof i=="string")};if(n!==null&&typeof n=="object")return{question:t.question,criteria:Object.fromEntries(Object.entries(n).filter(([,i])=>typeof i=="string"))}}function Rd(e){let t=e.deciders[e.deciders.length-1];return t?.kind==="quorum"?{count:t.count,...t.roles?{roles:t.roles}:{}}:{count:1}}function hhe(e,t){if(e===null||typeof e!="object")return t===e;let[[n,i]]=Object.entries(e),r=typeof t=="number";switch(n){case"eq":return t===i;case"ne":return t!==i;case"lt":return r&&t<i;case"lte":return r&&t<=i;case"gt":return r&&t>i;case"gte":return r&&t>=i;case"in":return i.includes(t);default:return!1}}function AK(e){let t=e?.reason;if(typeof t!="string")return;let n=t.trim();return n===""?void 0:n}function PK(e){return{type:e.type,instructions:e.instructions,criteria:e.criteria??{}}}function OK(e,t,n){let i=fo(e);if(!t||t.type==="unsupported")return{observed:!1,reason:"the backend does not support this question type"};if(e.type==="noul"){let c=Number(t.noul);if(!(c>=0&&c<=1))return{observed:!1,reason:"the answer carries no probability"};let u={true:_m(c),false:_m(1-c)},d=_m(Math.max(c,1-c));return c>=n?{observed:!0,answer:!0,probabilities:u,confidence:d}:1-c>=n?{observed:!0,answer:!1,probabilities:u,confidence:d}:{observed:!1,answer:c>=.5,probabilities:u,confidence:d,reason:`confidence ${d} is below the threshold ${n}`}}let r=t,o=Object.fromEntries(Object.entries(r.probabilities??{}).map(([c,u])=>[c,Number(u)]).filter(([,c])=>Number.isFinite(c)&&c>=0&&c<=1).map(([c,u])=>[c,_m(u)])),s=e.type==="choice"?r.choice:Object.entries(o).sort((c,u)=>u[1]-c[1])[0]?.[0],a=Number(r.confidence),l=_m(r.confidence!==void 0&&Number.isFinite(a)?a:Math.max(0,...Object.values(o)));return typeof s!="string"||!i.includes(s)?{observed:!1,answer:typeof s=="string"?s:null,probabilities:o,confidence:l,reason:`the answer ${JSON.stringify(s??null)} is not a candidate`}:l>=n?{observed:!0,answer:s,probabilities:o,confidence:l}:{observed:!1,answer:s,probabilities:o,confidence:l,reason:`confidence ${l} is below the threshold ${n}`}}async function MI(e,t,n,i){let r=[];for(let o of t.deciders)if(o.kind==="table"){let s=o.rows.findIndex(a=>EK(a.when,n));if(s>=0)return{status:"answered",answer:o.rows[s].answer,decider:{kind:"table",row:s},...o.rows[s].note?{note:o.rows[s].note}:{},escalations:r};r.push({kind:"table",reason:"no row matches these inputs"})}else if(o.kind==="model"){if(!i){r.push({kind:"model",backend:o.backend,model:o.model,threshold:o.threshold,reason:"not asked: no model backend was given to this ask"});continue}let s;try{s=await i({point:e,backend:o.backend,model:o.model,question:PK(t.question),state:n})}catch(c){let u=`${o.backend} could not answer: ${c instanceof Error?c.message:String(c)}`;if(o.unreachable==="fail")throw new kd(`${e}: ${u}, and the point fails closed (unreachable: "fail")`);r.push({kind:"model",backend:o.backend,model:o.model,threshold:o.threshold,reason:`not observed: ${u}`});continue}if(s.model!==o.model){r.push({kind:"model",backend:o.backend,model:s.model,threshold:o.threshold,reason:`not observed: ${s.model} answered, and the point pins ${o.model}`});continue}let a=OK(t.question,s.answer,o.threshold),l=AK(s.answer);if(a.observed)return{status:"proposed",answer:a.answer,decider:{kind:"model",backend:o.backend,model:s.model},probabilities:a.probabilities,confidence:a.confidence,threshold:o.threshold,...l!==void 0?{reason:l}:{},escalations:r};r.push({kind:"model",backend:o.backend,model:s.model,answer:a.answer??null,...a.probabilities?{probabilities:a.probabilities}:{},...a.confidence!==void 0?{confidence:a.confidence}:{},threshold:o.threshold,reason:`not observed: ${a.reason}`,...l!==void 0?{model_reason:l}:{}})}else return{status:"escalated",decider:{kind:"quorum",count:o.count,...o.roles?{roles:o.roles}:{}},escalations:r};return{status:"escalated",decider:{kind:"quorum",count:1},escalations:r}}function Sd(e,t){let n=lhe(ahe(e.file),e.kind.answers.points);return che(t,n).split(uhe).join(TI.sep)}function Ed(e,t){if(!e.list(TI.dirname(t))?.includes(TI.basename(t)))return{error:`the points file ${t} does not exist${e.label}`,problems:[{field:null,message:`does not exist${e.label}`}]};let i;try{i=e.read(t)}catch(r){return{error:`the points file ${t} can't be read: ${r instanceof Error?r.message:String(r)}`,problems:[{field:null,message:"can't be read"}]}}try{return{points:RK(i,t)}}catch(r){if(r instanceof Hc)return{error:`the points file is not valid: ${r.message}`,problems:r.problems};throw r}}function bhe(e,t,n){let i=Sd(e,n.root),r=Ed(n.source,i);for(let o of t){if(o.data===null)continue;if("error"in r){o.warnings.push({code:"answer-points-unreadable",message:r.error});continue}let s=o.data.point;if(typeof s!="string")continue;let a=xd(r.points,s);if(!a){o.warnings.push({code:"answer-point-unknown",message:`answers ${s}, which ${i} does not declare`});continue}typeof o.data.point_version=="string"&&o.data.point_version!==xa(a)&&o.warnings.push({code:"answer-point-changed",message:`answers ${s} as it was declared at ${o.data.point_version.slice(0,12)}, and ${i} declares it at ${xa(a).slice(0,12)} now: ask again for the question as it stands`})}}var dhe,xK,DI,Hc,vK,phe,bv,ghe,SK,xa,NI,kK,LI,EK,_m,kd,yhe,Dm=v(()=>{"use strict";wK();gm();dhe=II.$id,xK={record:{schema:"records",def:"record",description:"a record of any kind, as records --json lists it"},decision:{schema:"records",def:"record",description:"a decision record, as records --json lists it"},"work-item":{schema:"records",def:"record",description:"a work item record, as records --json lists it (#2683)"},finding:{schema:"intent",def:"finding",description:"a finding of graph --intent, or of check --changes (#2794)"},region:{schema:"intent",def:"region",description:"the region an intent graph covers"},commit:{schema:"intent",def:"commit",description:"a commit in an intent graph's window"},node:{schema:"intent",def:"node",description:"any node of an intent graph, by its id and kind: a commit, decision, unit, artifact or the region itself, as an intent walk asks of it (#3351)"},ask:{schema:"points",def:"question",description:"an ad-hoc question as its asker knows it (#3403): the asker's own id for the ask, such as hud's request id for an agent's question, and who asked"},member:{schema:"ls",def:"member",description:"a member, as ls lists it"},gate:{schema:"status",def:"gate",description:"a gate, as status lists it"},release:{schema:"status",def:"release",description:"a release, as status lists it; a release plan's fields until the lifecycle ledger lists plans (#2717)"},environment:{schema:"status",def:"environment",description:"an environment, as status lists it"},component:{schema:"composites",def:"component",description:"a component, as graph --composites lists it"}},DI=Object.keys(xK);Hc=class extends Error{constructor(n,i){super(`${n}: ${i.map(r=>r.field?`${r.field} ${r.message}`:r.message).join("; ")}`);this.file=n;this.problems=i;this.name="PointsError"}};vK={table:["rows"],model:["backend","model","threshold","unreachable"],quorum:["count","roles"]},phe=/(^|[-_./])(latest|preview|stable|current)$/i;ghe=new Set(["if","then","else","oneOf","anyOf","allOf"]);SK=e=>she("sha256").update(e,"utf8").digest("hex"),xa=e=>SK(Im(e)),NI=(e,t,n,i)=>SK(Im({point:e,version:t,inputs:n,asked:i}));kK=e=>typeof e=="string"&&e.trim()!=="";LI=(e,t)=>`${e}-${t.slice(0,12)}`;EK=(e,t)=>Object.entries(e).every(([n,i])=>Object.prototype.hasOwnProperty.call(t,n)&&hhe(i,t[n]));_m=e=>Math.round(e*1e6)/1e6;kd=class extends Error{constructor(t){super(t),this.name="DeciderFailed"}};yhe=["answer-points-unreadable","answer-point-unknown","answer-point-changed"]});import{createHash as whe}from"node:crypto";import{readFileSync as vhe,statSync as khe}from"node:fs";import{dirname as wv,posix as xhe,relative as $he,resolve as Nm,sep as _K}from"node:path";function qc(e){if(!e.reviews)return null;let t=[e.reviews.field,rn];return e.reviews.ratified!==void 0&&e.stateField!==void 0&&t.push(e.stateField),e.seal!==void 0&&t.push(e.seal.field),t}function Cm(e){return"kinds"in e.subjects?e.subjects.kinds:[e.subjects.kind]}async function kv(e,t,n){if(!e.kind.session)return;let i=[];for(let r of Cm(e.kind.session)){let o=await gn(Nm(wv(e.file),r),t);i.push({kind:r,records:(await ka(o,{root:t,source:n})).records,reviews:o.kind.reviews?.field??"reviews"})}return i}async function FI(e){let t=`record-kind:${e}`;Zs([{name:t,module:e}],wv(e));try{let n=await bc(t);if(!n)throw new Error(`${e} was not registered`);return n}finally{Zs([t],wv(e))}}async function gn(e,t=process.cwd()){let n=Nm(t,e),i;try{khe(n),i=await FI(n)}catch(c){throw new Ve("kind-unreadable",`kind file ${e} could not be loaded: ${jm(c)}`)}let r=Ehe.safeParse(i.recordKind);if(!r.success){let c=i.recordKind===void 0?"it has no recordKind export":r.error.issues.map(u=>`${u.path.join(".")||"recordKind"}: ${u.message}`).join("; ");throw new Ve("kind-invalid",`kind file ${e} is not a record kind: ${c}`)}let o=r.data,s=wv(n),a=IK(o,s,e,o.schema),l=(o.schema.refs??[]).map(c=>IK(o,s,e,c));return{kind:o,file:n,dir:Nm(s,o.location.dir),schema:a,refs:l}}function IK(e,t,n,i){let r;try{r=JSON.parse(vhe(Nm(t,i.path),"utf-8"))}catch(o){throw new Ve("schema-unreadable",`schema ${i.path} named by ${n} could not be read: ${jm(o)}`)}if(r===null||typeof r!="object"||r.$id!==i.id)throw new Ve("schema-id-mismatch",`kind ${e.name} names schema ${i.id}, but ${i.path} has $id ${JSON.stringify(r?.$id)}`);return r}function ls(e){let n=e.replace(/\r\n?/g,`
128
+ `).match(/^---\n([\s\S]*?)\n---(?:\n|$)/);if(!n)return{ok:!1,message:"no front matter: the file must start with a --- line and close it with another"};let i;try{i=hd.load(n[1],{schema:hd.JSON_SCHEMA})}catch(o){return{ok:!1,message:`front matter is not valid YAML: ${jm(o).split(`
129
+ `)[0]}`}}if(i===null||typeof i!="object"||Array.isArray(i))return{ok:!1,message:"front matter must be a mapping"};let r=vv(i,"",new Set);return r?{ok:!1,message:r}:{ok:!0,value:i}}function NK(e){let t;try{t=JSON.parse(e)}catch(r){return{ok:!1,message:`not valid JSON: ${jm(r).split(`
130
+ `)[0]}`}}if(t===null||typeof t!="object"||Array.isArray(t))return{ok:!1,message:"a JSON record must be one object at the top level"};let n=jK(e);if(n.duplicate)return{ok:!1,message:`${n.duplicate.at||"/"}: member name ${JSON.stringify(n.duplicate.name)} repeats, which I-JSON refuses`};let i=vv(t,"",new Set);return i?{ok:!1,message:i}:{ok:!0,value:t}}function xv(e,t){return e==="json"?NK(t):ls(t)}function jK(e){let t=[],n=[],i,r=-1,o=a=>{n.length===1&&i&&(t.push({...i,end:a}),i=void 0)},s=0;for(;s<e.length;){let a=e[s];if(a==='"'){let l=s+1;for(;e[l]!=='"';)l+=e[l]==="\\"?2:1;let c=e.slice(s,l+1),u=l+1;for(;u<e.length&&/[ \t\n\r]/.test(e[u]);)u++;let d=n[n.length-1];if(e[u]===":"&&d?.names){let p=JSON.parse(c);if(d.names.has(p))return{members:t,duplicate:{name:p,at:d.path}};d.names.add(p),d.key=p,n.length===1&&(i={name:p,start:s}),s=u+1;continue}o(l+1),s=l+1;continue}if(a==="{"||a==="["){let l=n[n.length-1],c=l?`${l.path}/${l.names?l.key:l.index}`:"";n.push({names:a==="{"?new Set:null,path:c,index:0}),s++;continue}if(a==="}"||a==="]"){n.pop(),o(s+1),s++;continue}if(a===","){let l=n[n.length-1];l&&!l.names&&l.index++,s++;continue}if(/[ \t\n\r:]/.test(a)){s++;continue}for(r=s;s<e.length&&!/[ \t\n\r,\]}]/.test(e[s]);)s++;r<s&&o(s)}return{members:t}}function vv(e,t,n){if(!(e===null||typeof e=="string"||typeof e=="boolean")){if(typeof e=="number")return Number.isFinite(e)?void 0:`${t||"/"}: ${e} is not a JSON number`;if(typeof e!="object")return`${t||"/"}: a ${typeof e} is not a JSON value`;if(n.has(e))return`${t||"/"}: YAML aliases are not allowed`;if(n.add(e),Array.isArray(e)){for(let i=0;i<e.length;i++){let r=vv(e[i],`${t}/${i}`,n);if(r)return r}return}if(Object.getPrototypeOf(e)!==Object.prototype)return`${t||"/"}: not a plain mapping`;for(let[i,r]of Object.entries(e)){let o=vv(r,`${t}/${i}`,n);if(o)return o}}}function Kc(e,t="reviews",n="markdown-front-matter"){let i=e.replace(/\r\n?/g,`
131
+ `),r=t===null?[]:typeof t=="string"?[t]:t,o=n==="json"?r.reduce(Phe,i):Ohe(i,r);return whe("sha256").update(o,"utf8").digest("hex")}function yd(e,t,n="markdown-front-matter"){let i=e.replace(/\r\n?/g,`
132
+ `),r=xv(n,i);if(!r.ok)return null;let o={...r.value};delete o[t];let s=n==="json"?o:{body:BI(i),core:o};return Dr($r(s))}function BI(e){let t=e.replace(/\r\n?/g,`
133
+ `),n=t.match(/^---\n[\s\S]*?\n---(?:\n|$)/);return n?t.slice(n[0].length):""}function Phe(e,t){if(!NK(e).ok)return e;let{members:i}=jK(e),r=i.findIndex(l=>l.name===t);if(r<0)return e;let o=i[r],s=o.start;for(;s>0&&/[ \t\n]/.test(e[s-1]);)s--;let a=o.end;if(r+1<i.length){let l=a;for(;/[ \t\n]/.test(e[l]);)l++;a=l+1}else if(r>0){let l=s-1;for(;l>0&&e[l]!==",";)l--;for(;l>0&&/[ \t\n]/.test(e[l-1]);)l--;s=l}return e.slice(0,s)+e.slice(a)}function Ohe(e,t){if(t.length===0)return e;let n=e.split(`
134
+ `);if(n[0]!=="---")return e;let i=n.indexOf("---",1);if(i<0)return e;let r=t.map(a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).map(a=>`${a}|"${a}"|'${a}'`),o=new RegExp(`^(?:${r.join("|")})[ \\t]*:(?:[ \\t]|$)`),s=[];for(let a=0;a<n.length;a++){if(a>0&&a<i&&o.test(n[a])){for(;a+1<i&&/^(?:$|[ \t#-])/.test(n[a+1]);)a++;continue}s.push(n[a])}return s.join(`
135
+ `)}function an(e){return e.normalize("NFKC").trim().toLowerCase()}function Che(e,t){return t.seal===void 0||t.seal===null?{attested:e?!1:null,code:"seal-missing",message:`the verdict by ${t.reviewer} carries no seal`}:{attested:null,code:"seal-unverifiable",message:`the seal by ${t.reviewer} was not checked`}}function $v(e,t,n){if(!e.reviews||t.data===null)return null;let i=t.data[e.reviews.field],r=t.data[e.reviews.decider],o=typeof r=="string"?an(r):null,s=t.id!==void 0?t.id:e.idField!==void 0?t.data[e.idField]:null,a=typeof s=="string"?s:null,l=[],c=[];(Array.isArray(i)?i:[]).forEach((g,h)=>{if(g===null||typeof g!="object")return;let b=g;if(typeof b.reviewer!="string"||typeof b.verdict!="string"||!_he.has(b.verdict))return;let w=typeof b.digest=="string"?b.digest:null,x={record:a,reviewer:b.reviewer,verdict:b.verdict,on:b.on,digest:w,seal:b.seal},{attested:k,...R}=n.verifySeal?n.verifySeal(x):Che(n.attestation,x),$={index:h,principal:an(b.reviewer),reviewer:b.reviewer,verdict:b.verdict,digest:w,attested:k,attestation:R};$.principal===o?$.reason={code:"review-decider",message:`${$.reviewer} decided this record, and the quorum counts verdicts besides the decider's`}:n.agents.has($.principal)?$.reason={code:"review-agent",message:`${$.reviewer} holds the agent role in the trust policy at base, and an agent's verdict does not count`}:$.digest!==null&&$.digest!==t.digest?$.reason={code:"review-older-digest",message:`${$.reviewer} judged the text at digest ${$.digest.slice(0,12)}, and the record's text is now at ${t.digest.slice(0,12)}`}:n.attestation&&k!==!0&&($.reason={code:"review-unattested",message:`an attestation policy is active at base, and ${R.message}`}),l.push($),$.verdict==="dissent"&&b.addressed_by==null&&b.withdrawn_on==null&&c.push({index:h,principal:$.principal,reviewer:$.reviewer,note:typeof b.note=="string"?b.note:null,...typeof b.proposes=="string"?{proposes:b.proposes}:{}})});let u=new Map;for(let g of l)g.reason||u.set(g.principal,g);for(let g of l){if(g.reason||u.get(g.principal)===g)continue;let h=u.get(g.principal);g.reason={code:"review-duplicate",message:`the later verdict by ${JSON.stringify(h.reviewer)} (entry ${h.index}) replaces this one, and a principal counts once`}}let d=l.filter(g=>!g.reason),p=d.filter(g=>g.verdict==="agree").length,f=p>=n.need;return{need:n.need,needFrom:n.needFrom,agreed:p,counted:d,notCounted:l.filter(g=>g.reason),openConcerns:c,met:f,metWithObjections:f&&c.length>0}}function Ihe(e){let t=[],n=new Map;for(let i of e){let r=i.keyword==="if"?i.params?.failingKeyword:void 0,o=r?i.parentSchema?.[r]?.description:void 0;if(!r||typeof o!="string")continue;let s=i.data!==null&&typeof i.data=="object"?i.data:{};n.set(i,o.replace(/\{([A-Za-z0-9_]+)\}/g,(a,l)=>typeof s[l]=="string"?s[l]:a)),t.push(`${i.schemaPath.replace(/\/if$/,"")}/${r}/`)}return e.filter(i=>n.has(i)||!t.some(r=>i.schemaPath.startsWith(r))).map(i=>`${i.instancePath||"/"} ${n.get(i)??i.message??"is invalid"}`)}async function The(e,t=[]){let n=await Promise.resolve().then(()=>Le(mK(),1)),i=n.default.default??n.default,r;try{let o=new i({allErrors:!0,strict:!1,verbose:!0});for(let s of t)o.addSchema(s);r=o.compile(e)}catch(o){throw new Ve("schema-invalid",`the kind's schema does not compile: ${jm(o)}`)}return o=>r(o)?{ok:!0}:{ok:!1,errors:Ihe(r.errors??[])}}function GI(e,t){if(!e.supersedes||t===null)return[];let{field:n,key:i}=e.supersedes,r=t[n];return i===void 0&&typeof r=="string"?[r]:Array.isArray(r)?(i===void 0?r:r.map(s=>s!==null&&typeof s=="object"?s[i]:void 0)).filter(s=>typeof s=="string"):[]}function Dhe(e,t){if(!e.remediates||t===null)return[];let{field:n,key:i}=e.remediates,r=t[n];return i===void 0&&typeof r=="string"?[r]:Array.isArray(r)?(i===void 0?r:r.map(s=>s!==null&&typeof s=="object"?s[i]:void 0)).filter(s=>typeof s=="string"):[]}function Nhe(e){let t=e.slice(e.lastIndexOf("/")+1),n=t.indexOf(".");return n<0?t:t.slice(0,n)}async function ka(e,t){let{kind:n}=e,i=jhe($he(t.root,e.dir))||".",r=t.source.list(i);if(r===void 0)throw new Ve("location-missing",`records directory ${i} does not exist${t.source.label}`);let o=new RegExp(n.location.match),s=await The(e.schema,e.refs),a=t.workspaceRoot??".",l=a==="."?t.root:Nm(t.root,...a.split("/")),c=[],u=new Map;for(let w of r.filter(x=>o.test(x)).sort()){let x=i==="."?w:`${i}/${w}`,k=t.source.read(x),R={id:null,path:x,state:null,valid:!0,reasons:[],supersededBy:null,remediatedBy:[],data:null,assets:[],warnings:[],digest:Kc(k,qc(n),n.format)};c.push(R),n.session&&u.set(x,k);let $=xv(n.format,k);if(!$.ok){R.reasons.push({code:"record-unparseable",message:$.message});continue}if(R.data=$.value,n.idFrom==="sha256"){R.id=ld(t.source.bytes(x));let C=Nhe(x);if(C!==R.id){let K=a==="."?x:x.startsWith(`${a}/`)?x.slice(a.length+1):x;TK.test(C)&&R.assets.push({path:K,sha256:C,actual:R.id,state:"drifted"}),R.warnings.push({code:"asset-drift",message:TK.test(C)?`${K} is named for sha256 ${C.slice(0,12)}, and its bytes${t.source.label} hash to ${R.id.slice(0,12)}`:`${K} is content-addressed, and its name claims no sha256: its bytes${t.source.label} hash to ${R.id.slice(0,12)}`})}}else{let C=$.value[n.idField];typeof C=="string"&&(R.id=C)}let _=n.stateField===void 0?void 0:$.value[n.stateField];typeof _=="string"&&(R.state=_);let T=s($.value);if(T.ok||R.reasons.push({code:"record-schema-invalid",message:T.errors.join("; ")}),n.source){let C=sK($.value,n.source.field);if(C){let K=aK(C,n.source.field);K.length>0&&R.reasons.push({code:"record-schema-invalid",message:K.join("; ")});let O=cK(C,n.source.field,l);O&&R.warnings.push({code:"source-transcript-drift",message:O})}}if(n.seal&&!n.session&&R.state!==null&&(n.closedStates??[]).includes(R.state)){let C=$.value[n.seal.field],K=typeof C=="string"?yd(k,n.seal.field,n.format):null;typeof C=="string"&&K!==C&&R.reasons.push({code:"record-seal-mismatch",message:`${n.seal.field} is ${C}, but the record seals to ${K}: it changed after it closed`})}if(n.pins){let C=$.value[n.pins.field];if(Array.isArray(C)&&C.length===0&&R.warnings.push({code:"record-no-evidence",message:`${n.pins.field} is empty: the record cites nothing and pins no file`}),t.assets){let K=tK(Om($.value,n.pins.field),t.assets);R.assets.push(...K.assets),R.warnings.push(...K.warnings)}}if(n.reviews){let C=$.value[n.reviews.field],K=(Array.isArray(C)?C:[]).filter(O=>O!==null&&typeof O=="object"&&!Array.isArray(O)&&O.digest===void 0).map(O=>typeof O.reviewer=="string"?O.reviewer:"an unnamed reviewer");K.length>0&&R.warnings.push({code:"review-undigested",message:`the ${K.length===1?"verdict":"verdicts"} by ${K.join(", ")} name no digest: ${K.length===1?"it counts":"they count"}, and an amendment will not stop ${K.length===1?"it":"them"} counting`})}}let d=new Map;for(let w of c){if(w.id===null)continue;let x=d.get(w.id);x?w.reasons.push({code:"record-id-duplicate",message:`id ${w.id} is already used by ${x.path}`}):d.set(w.id,w)}let p=new Set(n.closedStates??[]),f=w=>w===null?0:n.approval?.[w]??0,g=(w,x)=>n.approval?f(w.state)>0&&f(w.state)>=f(x.state):w.state!==null&&p.has(w.state);for(let w of c)for(let x of GI(n,w.data)){let k=d.get(x);if(!k){w.reasons.push({code:"record-supersedes-unknown",message:`supersedes ${x}, which no record has`});continue}if(k!==w){if(!g(w,k)){n.approval&&w.warnings.push({code:"record-supersedes-pending",message:`supersedes ${x}, which is ${k.state??"stateless"}; a ${w.state??"stateless"} record can't supersede it, so the link takes effect once this record is approved at least as strongly`});continue}if(k.supersededBy!==null&&k.supersededBy!==w.id){w.reasons.push({code:"record-supersedes-conflict",message:`supersedes ${x}, which ${k.supersededBy} already supersedes`});continue}k.supersededBy=w.id}}for(let w of c)for(let x of Dhe(n,w.data)){let k=d.get(x);if(!k){w.reasons.push({code:"record-remediates-unknown",message:`remediates ${x}, which no record has`});continue}if(k!==w){if(k.state===null||!p.has(k.state)){w.reasons.push({code:"record-remediates-not-closed",message:`remediates ${x}, which is ${k.state??"stateless"}, not closed; a record still open is amended instead`});continue}w.id!==null&&!k.remediatedBy.includes(w.id)&&k.remediatedBy.push(w.id)}}for(let w of c)for(let x of w.assets){if(x.state!=="pinned")continue;let k=c.find(_=>_.supersededBy!==null&&_.supersededBy===w.id&&_.assets.some(T=>T.path===x.path&&T.sha256===x.sha256));if(!k)continue;let R=t.history?.fileChanged(x.path)??null,$=t.history?t.history.recorded(w.path):null;R!==null&&$!==null&&R>$||(x.state="stale",w.warnings.push({code:"asset-stale",message:`${x.path} is pinned at the hash ${k.id} pinned, and it has not changed since: ${w.id} supersedes ${k.id}, and the artifact did not follow`}))}rK(n,c,u,t.subjects??null);let h=n.work?await(await Promise.resolve().then(()=>(vd(),_I))).applyWork(e,c,t):void 0;n.answers&&(await Promise.resolve().then(()=>(Dm(),CK))).applyAnswers(e,c,t);for(let w of c)w.valid=w.reasons.length===0;let b=t.current?c.filter(w=>w.supersededBy===null):c;return{records:b,summary:{total:b.length,valid:b.filter(w=>w.valid).length,invalid:b.filter(w=>!w.valid).length,superseded:c.filter(w=>w.supersededBy!==null).length},...h?{decisions:h.decisions}:{}}}function jm(e){return e instanceof Error?e.message:String(e)}function jhe(e){return _K==="/"?e:e.split(_K).join(xhe.sep)}var $a,rn,DK,Ve,Rhe,She,Ehe,Ahe,LK,_he,TK,mn=v(()=>{"use strict";ss();er();SI();Ln();xn();uo();AI();lK();$a=["record-unparseable","record-schema-invalid","record-id-duplicate","record-supersedes-unknown","record-supersedes-conflict","record-remediates-unknown","record-remediates-not-closed","record-seal-mismatch","session-seal-mismatch","session-verdict-unknown-record"],rn="seal";DK=["kind-unreadable","kind-invalid","schema-unreadable","schema-id-mismatch","schema-invalid","location-missing","not-a-git-repository","revision-unknown"],Ve=class extends Error{constructor(n,i){super(i);this.code=n;this.name="RecordReadError"}},Rhe=/^[a-z][a-z0-9-]*$/,She=["markdown-front-matter","json"],Ehe=m.object({name:m.string().regex(Rhe),location:m.object({dir:m.string().min(1),match:m.string().min(1)}).strict(),format:m.enum(She),schema:m.object({id:m.string().min(1),path:m.string().min(1),refs:m.array(m.object({id:m.string().min(1),path:m.string().min(1)}).strict()).optional()}).strict(),idField:m.string().min(1).optional(),idFrom:m.literal("sha256").optional(),stateField:m.string().min(1).optional(),states:m.array(m.string().min(1)).min(1).optional(),closedStates:m.array(m.string().min(1)).optional(),supersedes:m.object({field:m.string().min(1),key:m.string().min(1).optional()}).strict().optional(),remediates:m.object({field:m.string().min(1),key:m.string().min(1).optional()}).strict().optional(),approval:m.record(m.string(),m.number().int().min(0)).optional(),pins:m.object({field:m.string().min(1)}).strict().optional(),constrains:m.object({field:m.string().min(1)}).strict().optional(),outOfScope:m.object({field:m.string().min(1)}).strict().optional(),reviews:m.object({field:m.string().min(1),decider:m.string().min(1),ratified:m.string().min(1).optional()}).strict().optional(),proposedBy:m.object({field:m.string().min(1)}).strict().optional(),source:m.object({field:m.string().min(1)}).strict().optional(),session:m.object({verdicts:m.string().min(1),seal:m.string().min(1),subjects:m.union([m.object({kind:m.string().min(1)}).strict(),m.object({kinds:m.array(m.string().min(1)).min(1)}).strict().refine(e=>new Set(e.kinds).size===e.kinds.length,{message:"session.subjects.kinds lists each kind file once",path:["kinds"]})]),openedRev:m.string().min(1).optional(),closedRev:m.string().min(1).optional(),closedOn:m.string().min(1).optional()}).strict().optional(),work:m.object({needs:m.string().min(1),implements:m.string().min(1),decisions:m.string().min(1),open:m.string().min(1),done:m.string().min(1),closedOn:m.string().min(1),acceptance:m.object({field:m.string().min(1),implementer:m.string().min(1)}).strict().optional(),contract:m.object({field:m.string().min(1),kind:m.string().min(1)}).strict().optional(),tier:m.object({field:m.string().min(1),tiers:m.array(m.string().min(1)).min(1),limits:m.record(m.string().min(1),m.object({criteria:m.number().int().min(0).optional(),files:m.number().int().min(0).optional(),words:m.number().int().min(0).optional()}).strict()).optional()}).strict().refine(e=>new Set(e.tiers).size===e.tiers.length,{message:"work.tier.tiers lists each tier once",path:["tiers"]}).optional(),attempts:m.object({field:m.string().min(1),max:m.number().int().min(1)}).strict().optional(),answers:m.string().min(1).optional()}).strict().optional(),answers:m.object({points:m.string().min(1)}).strict().optional(),seal:m.object({field:m.string().min(1)}).strict().optional(),spec:m.boolean().optional()}).strict().refine(e=>e.states!==void 0||e.seal===void 0,{message:"a kind without states cannot have seal: a record is sealed when it enters a closed state",path:["seal"]}).refine(e=>e.seal===void 0||e.session===void 0||e.seal.field===e.session.seal,{message:"seal.field and session.seal name the field that holds a closed session's seal, and must be the same",path:["seal"]}).refine(e=>e.idField===void 0!=(e.idFrom===void 0),{message:"a kind names its id with exactly one of idField and idFrom",path:["idField"]}).refine(e=>new Set([e.stateField===void 0,e.states===void 0,e.closedStates===void 0]).size===1,{message:"stateField, states and closedStates are given together or not at all",path:["states"]}).refine(e=>e.states!==void 0||e.supersedes===void 0,{message:"a kind without states cannot have supersedes: a link takes effect only from a closed or ranked state",path:["supersedes"]}).refine(e=>e.states!==void 0||e.remediates===void 0,{message:"a kind without states cannot have remediates: a link only ever targets a record in a closed state",path:["remediates"]}).refine(e=>e.states!==void 0||e.session===void 0,{message:"a session kind must have states: a session is sealed when it reaches a closed state",path:["session"]}).refine(e=>e.states!==void 0||e.approval===void 0,{message:"a kind without states cannot have approval ranks",path:["approval"]}).refine(e=>e.states!==void 0||e.proposedBy===void 0,{message:"a kind without states cannot have proposedBy: there is no first state for a record to open in",path:["proposedBy"]}).refine(e=>e.reviews?.ratified===void 0||(e.states??[]).includes(e.reviews.ratified),{message:"reviews.ratified must be one of states: it names the state a record enters once its quorum is met",path:["reviews","ratified"]}).refine(e=>(e.closedStates??[]).every(t=>(e.states??[]).includes(t)),{message:"every closed state must be listed in states",path:["closedStates"]}).refine(e=>Object.keys(e.approval??{}).every(t=>(e.states??[]).includes(t)),{message:"every state approval ranks must be listed in states",path:["approval"]}).refine(e=>!e.work||e.states!==void 0&&e.states.includes(e.work.open)&&e.states.includes(e.work.done),{message:"a work kind must have states, and its work open and done states must be listed in them",path:["work"]}).refine(e=>!e.work?.acceptance||e.pins!==void 0,{message:"a work kind with acceptance criteria must have pins: a criterion is met by the evidence in its pins field",path:["work","acceptance"]}).refine(e=>!e.answers||e.format==="markdown-front-matter"&&e.idField==="id"&&e.stateField==="state"&&Ahe.every(t=>e.states?.includes(t))&&(e.closedStates??[]).includes("answered"),{message:'an answer kind is markdown-front-matter with idField "id", stateField "state", the states escalated, proposed and answered, and answered closed',path:["answers"]}),Ahe=["escalated","proposed","answered"];LK=2;_he=new Set(["agree","dissent","abstain"]);TK=/^[0-9a-f]{64}$/});import{execFileSync as FK}from"node:child_process";import{readdirSync as Lhe,readFileSync as MK}from"node:fs";import{join as WI}from"node:path";function Ad(e){return{label:"",list(t){try{return Lhe(WI(e,t),{withFileTypes:!0}).filter(n=>n.isFile()).map(n=>n.name)}catch{return}},read(t){return MK(WI(e,t),"utf-8")},bytes(t){return MK(WI(e,t))}}}function Rv(e,t,n){return FK("git",t,{cwd:e,encoding:"utf-8",input:n,stdio:["pipe","pipe","pipe"],maxBuffer:256*1024*1024})}function Un(e){try{return Rv(e,["rev-parse","--show-toplevel"]).trim()}catch{return}}function Jc(e,t){if(t.startsWith("-"))throw new Ve("revision-unknown",`--at ${t} is not a revision`);try{return Rv(e,["rev-parse","--verify","--quiet",`${t}^{commit}`]).trim()}catch{throw new Ve("revision-unknown",`--at ${t} names no commit in this repository`)}}function Ra(e,t){let n=new Map,i=r=>{let o=n.get(r);if(o===void 0)throw new Error(`${r} was not listed at ${t}`);return o};return{label:` at ${t.slice(0,8)}`,list(r){let o=r==="."?`${t}^{tree}`:`${t}:${r}`;try{if(Rv(e,["cat-file","-t",o]).trim()!=="tree")return}catch{return}let s=Rv(e,["ls-tree","-z",o]).split("\0").filter(Boolean).map(a=>{let l=a.indexOf(" "),[,c,u]=a.slice(0,l).split(" ");return{type:c,oid:u,name:a.slice(l+1)}}).filter(a=>a.type==="blob");if(s.length>0){let a=Buffer.from(FK("git",["cat-file","--batch"],{cwd:e,input:s.map(c=>c.oid).join(`
136
+ `)+`
137
+ `,maxBuffer:268435456})),l=0;for(let c of s){let u=a.indexOf(10,l),d=Number(a.subarray(l,u).toString("utf-8").split(" ")[2]),p=u+1;n.set(r==="."?c.name:`${r}/${c.name}`,a.subarray(p,p+d)),l=p+d+1}}return s.map(a=>a.name)},read(r){return i(r).toString("utf-8")},bytes:i}}var mo=v(()=>{"use strict";mn()});import{posix as Mhe}from"node:path";function Fhe(e){let t=[],n="",i=!1,r=!1;for(let o of e)o==='"'?(i=!i,n+=o,r=!0):!i&&(o===" "||o===" ")?(r&&t.push(n),n="",r=!1):(n+=o,r=!0);return r&&t.push(n),t}function Bhe(e){let t=new Map,n="",i=!1,r=()=>{if(!n)return;let o=n.indexOf("="),s=(o<0?n:n.slice(0,o)).toLowerCase(),a=o<0?"":n.slice(o+1).replace(/^"|"$/g,"");t.set(s,a),n=""};for(let o of e)o==='"'&&(i=!i),o===","&&!i?r():n+=o;return r(),t}function us(e){let t=[],n=[],i=e.replace(/\r\n?/g,`
138
+ `).split(`
139
+ `);for(let r=0;r<i.length;r++){let o=r+1,s=i[r].trim();if(!s||s.startsWith("#"))continue;let a=Fhe(s);if(a.length<3){n.push({line:o,reason:"expected principals, optional options, a key type and a key"});continue}let[l,c]=a,u=!BK.has(c),d=u?a[2]:c,p=u?a[3]:a[2];if(!BK.has(d)||!p||!/^[A-Za-z0-9+/]+={0,2}$/.test(p)){n.push({line:o,reason:`no supported public key (${d??"none"})`});continue}let f=u?Bhe(c):new Map,g=["valid-after","valid-before"].filter(x=>f.has(x));if(g.length>0){n.push({line:o,reason:`${g.join(" and ")} is checked against the commit's own date, which its author sets; revoke a key by removing it`});continue}if(f.has("cert-authority")){n.push({line:o,reason:"cert-authority keys are not supported: a certificate's validity is a date the signer controls"});continue}let h=[...f.keys()].filter(x=>x!=="namespaces");if(h.length>0){n.push({line:o,reason:`unknown option ${h.join(", ")}`});continue}let b=l.replace(/^"|"$/g,"").split(",").filter(Boolean),w=b.find(x=>/[*?!]/.test(x));if(w!==void 0||b.length===0){n.push({line:o,reason:`principal ${JSON.stringify(w??l)} is a pattern; name one signer exactly`});continue}for(let x of b)t.push({principal:x,key:`${d} ${p}`,namespaces:f.get("namespaces"),line:o})}return{signers:t,excluded:n}}function Sv(e){return e.map(t=>`${JSON.stringify(t.principal)}${t.namespaces!==void 0?` namespaces=${JSON.stringify(t.namespaces)}`:""} ${t.key}`).join(`
140
+ `)+`
141
+ `}function zhe(e){return typeof e=="string"&&e.length>0&&!e.startsWith("/")&&!e.includes("\\")&&Mhe.normalize(e)===e&&!e.split("/").includes("..")}function Ev(e){if(!Pd(e))return["/: expected an object"];let t=[],n=(i,r,o)=>{r||t.push(`${i}: ${o}`)};return n("/",Lm(e,["schema","signers","roles","adopted","runners","admitted"]),"unknown key"),n("schema",e.schema===1,"expected 1"),n("signers",Sa(e.signers,zhe),"a path inside the repository, with / separators and no .."),n("roles",Sa(e.roles,i=>Pd(i)&&Object.entries(i).every(([r,o])=>/^[a-z][a-z0-9-]*$/.test(r)&&Array.isArray(o)&&o.every(zI))),"role names to lists of principals"),n("adopted",Sa(e.adopted,i=>Array.isArray(i)&&i.every(r=>Pd(r)&&Lm(r,["from","to","note"])&&Sa(r.from,o=>typeof o=="string"&&GK.test(o))&&typeof r.to=="string"&&GK.test(r.to)&&Sa(r.note,o=>typeof o=="string"))),"commit ranges of full commit ids"),n("runners",Sa(e.runners,i=>Array.isArray(i)&&i.every(r=>Pd(r)&&Lm(r,["principal","class","key"])&&zI(r.principal)&&(r.class==="runner"||r.class==="service")&&typeof r.key=="string"&&Ghe.test(r.key))),"runner keys: a principal, a class and an ssh-ed25519 key"),n("admitted",Sa(e.admitted,i=>Array.isArray(i)&&i.every(r=>Pd(r)&&Lm(r,["return","signers","note"])&&typeof r.return=="string"&&/^ret-[0-9a-f]{12}$/.test(r.return)&&Sa(r.note,o=>typeof o=="string")&&Array.isArray(r.signers)&&r.signers.length>0&&r.signers.every(o=>Pd(o)&&Lm(o,["principal","key"])&&zI(o.principal)&&typeof o.key=="string"&&Whe.test(o.key)))),"admitted signers, by return id"),t}var nr,Fr,BK,Pd,GK,Ghe,Whe,Lm,Sa,zI,Od=v(()=>{"use strict";nr=".chant/trust.json",Fr=".chant/allowed_signers",BK=new Set(["ssh-ed25519","ssh-rsa","ecdsa-sha2-nistp256","ecdsa-sha2-nistp384","ecdsa-sha2-nistp521","sk-ssh-ed25519@openssh.com","sk-ecdsa-sha2-nistp256@openssh.com"]);Pd=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),GK=/^[0-9a-f]{40}([0-9a-f]{24})?$/,Ghe=/^ssh-ed25519 [A-Za-z0-9+/]+={0,2}$/,Whe=/^(ssh-ed25519|ssh-rsa|ecdsa-sha2-nistp(256|384|521)|sk-ssh-ed25519@openssh\.com|sk-ecdsa-sha2-nistp256@openssh\.com) [A-Za-z0-9+/]+={0,2}$/;Lm=(e,t)=>Object.keys(e).every(n=>t.includes(n)),Sa=(e,t)=>e===void 0||t(e),zI=e=>typeof e=="string"&&e.length>0});import{posix as UI}from"node:path";function ds(e,t=[]){return{base:e,signersPath:Fr,active:!1,signers:[],excluded:[],roles:{},adopted:[],runners:[],excludedRunners:[],admitted:{},problems:t}}function Av(e,t){let n={schema:1},i=zK(e,nr);if(i!==void 0){let p;try{p=JSON.parse(i)}catch(g){return ds(t,[`${nr} is not JSON: ${g instanceof Error?g.message:String(g)}`])}let f=Hhe.safeParse(p);if(!f.success){let g=f.error.issues.map(h=>`${h.path.join(".")||"/"}: ${h.message}`).join("; ");return ds(t,[`${nr} is invalid: ${g}`])}n=f.data}let r=n.signers??Fr,o=zK(e,r),s=o===void 0?{signers:[],excluded:[]}:us(o),a=new Set(s.signers.map(p=>p.key)),l=new Set(s.signers.map(p=>p.principal)),c=[],u=[],d=n.runners??[];for(let p of d)a.has(p.key)||l.has(p.principal)?u.push({principal:p.principal,reason:`${r} lists this ${a.has(p.key)?"key":"principal"}; runner keys belong to a service or CI identity, never to a signer`}):d.filter(f=>f.key===p.key||f.principal===p.principal).length>1?u.push({principal:p.principal,reason:"another runner entry has the same key or principal; each runner is one principal with one key"}):c.push(p);return{base:t,signersPath:r,active:o!==void 0,signers:s.signers,excluded:s.excluded,roles:n.roles??{},adopted:n.adopted??[],runners:c,excludedRunners:u,admitted:Vhe(n),problems:[]}}function Vhe(e){let t={};for(let n of e.admitted??[])t[n.return]=[...t[n.return]??[],...n.signers.map(i=>({principal:i.principal,key:i.key,line:0}))];return t}function Pv(e,t){return{...e,signers:[...e.signers,...e.admitted[t]??[]],returnedFrom:t}}function zK(e,t){let n=UI.dirname(t),i=e.list(n);if(!(!i||!i.includes(UI.basename(t))))return e.read(t)}var WK,Uhe,Hhe,ps=v(()=>{"use strict";Ln();Od();Od();WK=m.string().regex(/^[0-9a-f]{40}([0-9a-f]{24})?$/,"a full commit id"),Uhe=m.string().min(1).refine(e=>!e.startsWith("/")&&!e.includes("\\")&&UI.normalize(e)===e&&!e.split("/").includes(".."),{message:"a path inside the repository, with / separators and no .."}),Hhe=m.object({schema:m.literal(1),signers:Uhe.optional(),roles:m.record(m.string().regex(/^[a-z][a-z0-9-]*$/),m.array(m.string().min(1))).optional(),adopted:m.array(m.object({from:WK.optional(),to:WK,note:m.string().optional()}).strict()).optional(),runners:m.array(m.object({principal:m.string().min(1),class:m.enum(["runner","service"]),key:m.string().regex(/^ssh-ed25519 [A-Za-z0-9+/]+={0,2}$/,"an ssh-ed25519 public key, with no comment")}).strict()).optional(),admitted:m.array(m.object({return:m.string().regex(/^ret-[0-9a-f]{12}$/,"a return id, ret-<12 hex>"),signers:m.array(m.object({principal:m.string().min(1),key:m.string().regex(/^(ssh-ed25519|ssh-rsa|ecdsa-sha2-nistp(256|384|521)|sk-ssh-ed25519@openssh\.com|sk-ecdsa-sha2-nistp256@openssh\.com) [A-Za-z0-9+/]+={0,2}$/,"an ssh public key, with no comment")}).strict()).min(1),note:m.string().optional()}).strict()).optional()}).strict()});var ZK={};_e(ZK,{splitSignedCommit:()=>Fm,sshCommitAttestor:()=>Jhe,sshKeygen:()=>Ea,sshSignatureIntact:()=>Ov,sshSignatureKey:()=>VI,verifySshSignature:()=>_d});import{execFileSync as VK,spawnSync as qhe}from"node:child_process";import{mkdtempSync as qK,rmSync as KK,writeFileSync as HI}from"node:fs";import{tmpdir as JK}from"node:os";import{join as Mm}from"node:path";function Fm(e,t="gpgsig"){let n=e.indexOf(`
142
+
143
+ `),i=n<0?e.length:n,r=e.subarray(0,i).toString("latin1").split(`
144
+ `),o=[],s=[],a=!1;for(let c of r){if(a&&c.startsWith(" ")){s.push(c.slice(1));continue}if(a=!1,s.length===0&&c.startsWith(`${t} `)){a=!0,s.push(c.slice(t.length+1));continue}o.push(c)}return{payload:Buffer.concat([Buffer.from(o.join(`
145
+ `),"latin1"),e.subarray(i)]),signature:s.length>0?s.join(`
146
+ `)+`
147
+ `:void 0}}function Khe(e){try{return VK("git",["rev-parse","--show-object-format"],{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()}catch{return"sha1"}}function Ea(e,t){let n=qhe("ssh-keygen",e,{input:t,encoding:"buffer",timeout:3e4}),i=n.error?.code==="ENOENT";return{status:n.status,stdout:n.stdout?.toString("utf-8")??"",stderr:n.stderr?.toString("utf-8")??"",missing:i}}function _d(e,t,n,i){if(e.length===0)return{ok:!1,missing:!1,reason:"the policy lists no usable signer"};let r=qK(Mm(JK(),"chant-trust-"));try{let o=Mm(r,"allowed_signers"),s=Mm(r,"signature");HI(o,Sv(e)),HI(s,n);let a=Ea(["-Y","find-principals","-f",o,"-s",s]);if(a.missing)return{ok:!1,missing:!0,reason:"ssh-keygen is not installed here"};let l=a.status===0?a.stdout.split(`
148
+ `).map(c=>c.trim()).filter(Boolean):[];if(l.length===0)return{ok:!1,missing:!1,reason:"signed by a key the policy at base does not list"};for(let c of l){let u=Ea(["-Y","verify","-f",o,"-I",c,"-n",i,"-s",s],t);if(u.status===0){let d=/key (SHA256:[A-Za-z0-9+/=]+)/.exec(u.stdout+u.stderr)?.[1];return{ok:!0,principal:c,...d?{key:d}:{}}}}return{ok:!1,missing:!1,reason:`the signature does not verify in the ${i} namespace for a key the policy lists`}}finally{KK(r,{recursive:!0,force:!0})}}function HK(e,t,n){let{payload:i,signature:r}=Fm(e,t);if(!r)return{level:"unattested",attestor:Cd,reason:"the commit is not signed"};if(!r.startsWith("-----BEGIN SSH SIGNATURE-----")){let s=r.startsWith("-----BEGIN PGP SIGNATURE-----")?"an OpenPGP":"a non-ssh";return{level:"attested-unverifiable-here",attestor:Cd,reason:`the commit carries ${s} signature, which this attestor does not check`}}let o=_d(n,i,r,"git");return o.ok?{level:"attested",attestor:Cd,principal:o.principal,...o.key?{key:o.key}:{},reason:`signed by ${o.principal}`}:o.missing?{level:"attested-unverifiable-here",attestor:Cd,reason:o.reason}:{level:"unattested",attestor:Cd,reason:o.reason}}function VI(e){let t=e.replace(/-----BEGIN SSH SIGNATURE-----/,"").replace(/-----END SSH SIGNATURE-----/,"").replace(/\s+/g,""),n;try{n=Buffer.from(t,"base64")}catch{return}if(n.length<14||n.subarray(0,6).toString("latin1")!=="SSHSIG")return;let i=n.readUInt32BE(10),r=n.subarray(14,14+i);if(r.length!==i||i<4)return;let o=r.readUInt32BE(0),s=r.subarray(4,4+o).toString("latin1");if(/^[a-z0-9@.-]+$/.test(s))return`${s} ${r.toString("base64")}`}function Ov(e,t,n){let i=qK(Mm(JK(),"chant-intact-"));try{let r=Mm(i,"signature");HI(r,t);let o=Ea(["-Y","check-novalidate","-n",n,"-s",r],e);return o.missing?null:o.status!==0?!1:/key (SHA256:[A-Za-z0-9+/=]+)/.exec(o.stdout+o.stderr)?.[1]??""}finally{KK(i,{recursive:!0,force:!0})}}var Cd,UK,Jhe,Bm=v(()=>{"use strict";ps();Cd="ssh-commit";UK=new Map;Jhe={name:Cd,attestCommit(e,t){let n=e.policy.signers,i=`${e.repo}\0${t}\0${Sv(n)}`,r=UK.get(i);if(r)return r;let o=VK("git",["cat-file","commit",t],{cwd:e.repo,maxBuffer:64*1024*1024}),s=HK(o,Khe(e.repo)==="sha256"?"gpgsig-sha256":"gpgsig",n);return UK.set(i,s),s},attestRaw(e,t){let n=/^tree ([0-9a-f]+)$/m.exec(t.subarray(0,200).toString("latin1"))?.[1];return HK(t,n?.length===64?"gpgsig-sha256":"gpgsig",e.policy.signers)}}});var YK={};_e(YK,{PROVENANCE_LEVELS:()=>Zhe,activeAttestors:()=>Gm,attestCommit:()=>_v,attestRawCommit:()=>qI,registerAttestor:()=>Yhe,resetAttestors:()=>Xhe});function Yhe(e){Cv.some(t=>t.name===e.name)||Cv.push(e)}function Xhe(){Cv.length=0}function _v(e,t,n){let i;for(let r of n){let o=r.attestCommit(e,t);if(o.level==="attested")return o;(!i||i.level==="unattested"&&o.level==="attested-unverifiable-here")&&(i=o)}return i??{level:"unattested",attestor:"none",reason:"no attestor is registered"}}function qI(e,t,n){return _v(e,"",n.filter(i=>i.attestRaw).map(i=>({name:i.name,attestCommit:r=>i.attestRaw(r,t)})))}async function Gm(){let{sshCommitAttestor:e}=await Promise.resolve().then(()=>(Bm(),ZK));return[e,...Cv.filter(t=>t.name!==e.name)]}var Zhe,Cv,Id=v(()=>{"use strict";kc();Zhe=["attested","attested-unverifiable-here","adopted",cw],Cv=[]});import{createHash as Qhe,createPrivateKey as tze,createPublicKey as nze,sign as rze,verify as ize}from"node:crypto";function XK(e){let t=Buffer.from(e.trim().split(/\s+/)[1]??"","base64");return`SHA256:${Qhe("sha256").update(t).digest("base64").replace(/=+$/,"")}`}var Iv=v(()=>{"use strict"});import{createHash as eye}from"node:crypto";import{execFileSync as e6}from"node:child_process";import{posix as KI}from"node:path";function nye(e){return KI.join(KI.dirname(e),`${KI.basename(e)}.rotation.json`)}function rye(e){return`sha256:${eye("sha256").update(e.replace(/\r\n?/g,`
149
+ `),"utf8").digest("hex")}`}function oye(e,t){return Buffer.from($r({type:"chant-signer-set",version:e.version,previous:e.previous,signers:t,threshold:e.threshold}),"utf8")}function sye(e,t,n){if(t.signers===void 0)return{code:"signers-removed",reason:"the signers file was removed"};let i=rye(t.signers),r;if(t.rotation!==void 0){let d;try{d=JSON.parse(t.rotation)}catch(f){return{code:"rotation-unparseable",reason:`the rotation file is not JSON: ${f instanceof Error?f.message:String(f)}`}}let p=iye.safeParse(d);if(!p.success)return{code:"rotation-invalid",reason:`the rotation file is invalid: ${p.error.issues.map(f=>`${f.path.join(".")||"/"}: ${f.message}`).join("; ")}`};r=p.data}let o=us(t.signers),s=r?.threshold??1,a=aye(o.signers);if(s>a)return{code:"rotation-threshold-unsatisfiable",reason:`the threshold is ${s}, and the set has ${a} distinct signer${a===1?"":"s"} to meet it`};if(!e)return r&&(r.version!==1||r.previous!==null)?{code:"rotation-first-version",reason:`a first signer set must be version 1 with no previous digest, not version ${r.version}`}:{version:1,commit:n,digest:i,threshold:s,signers:o.signers,excluded:o.excluded,signedBy:[]};if(i===e.digest&&s===e.threshold)return e;if(!r)return{code:"rotation-missing",reason:`the signer set changed from version ${e.version} with no rotation file signed by the set before it`};if(r.version!==e.version+1)return{code:"rotation-version-skew",reason:`the rotation says version ${r.version}; the next version is ${e.version+1}`};if(r.previous!==e.digest)return{code:"rotation-previous-mismatch",reason:`the rotation names previous ${r.previous}, but version ${e.version} is ${e.digest}`};let l=oye(r,i),c=new Set,u=[];for(let d of r.signatures){if(u.includes(d.principal))continue;let p=e.signers.filter(h=>h.principal===d.principal),f=_d(p,l,d.signature,tye);if(!f.ok)continue;let g=f.key??(p.length===1?XK(p[0].key):`principal:${f.principal}`);c.has(g)||(c.add(g),u.push(f.principal))}return c.size<e.threshold?{code:"rotation-threshold-not-met",reason:`version ${r.version} is signed by ${c.size} of the ${e.threshold} signers of version ${e.version} it needs${u.length?` (${u.join(", ")})`:""}`}:{version:r.version,commit:n,digest:i,threshold:s,signers:o.signers,excluded:o.excluded,signedBy:u}}function aye(e){let t=new Map;for(let o of e){let s=t.get(o.principal)??new Set;s.add(o.key),t.set(o.principal,s)}let n=new Map,i=(o,s)=>{for(let a of t.get(o)??[]){if(s.has(a))continue;s.add(a);let l=n.get(a);if(l===void 0||i(l,s))return n.set(a,o),!0}return!1},r=0;for(let o of t.keys())i(o,new Set)&&r++;return r}function JI(e,t){return e6("git",t,{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","pipe"],maxBuffer:256*1024*1024})}function QK(e,t,n){try{return JI(e,["cat-file","blob",`${t}:${n}`])}catch{return}}function t6(e,t,n){let i=[n,nye(n)],r=JI(e,["--literal-pathspecs","log","--first-parent","--reverse","--format=%H",t,"--",...i]).split(`
150
+ `).filter(Boolean),o=[],s;for(let a of r){let l={signers:QK(e,a,i[0]),rotation:QK(e,a,i[1])};if(l.signers===void 0){s&&o.push({version:0,commit:a,digest:"",threshold:0,signers:[],excluded:[],signedBy:[]}),s=void 0;continue}let c=sye(s,l,a);if("code"in c)return{versions:o,broken:{commit:a,code:c.code,reason:c.reason}};c!==s&&o.push(c),s=c}return{versions:o}}var tye,iye,Tv,n6=v(()=>{"use strict";Ln();er();Iv();ps();Bm();tye="chant-signers";iye=m.object({schema:m.literal(1),version:m.number().int().min(1),previous:m.string().regex(/^sha256:[0-9a-f]{64}$/).nullable(),threshold:m.number().int().min(1),signatures:m.array(m.object({principal:m.string().min(1),signature:m.string().min(1)}).strict())}).strict();Tv=class{constructor(t,n,i){this.repo=t;this.base=n;this.history=i;this.index=new Map;this.memo=new Map}isAncestor(t,n){try{return e6("git",["merge-base","--is-ancestor",t,n],{cwd:this.repo,stdio:"ignore"}),!0}catch{return!1}}firstParents(){return this.line||(this.line=JI(this.repo,["rev-list","--first-parent",this.base]).split(`
151
+ `).filter(Boolean),this.line.forEach((t,n)=>this.index.set(t,n))),this.line}versionFor(t){let n=this.memo.get(t);if(n!==void 0)return n;let i=this.lookup(t);return this.memo.set(t,i),i}lookup(t){if(this.history.broken)return null;let n=this.history.versions.at(-1)??null;if(!this.isAncestor(t,this.base))return n;let i=this.firstParents(),r=0,o=i.length-1,s=0;for(;r<=o;){let c=r+o>>1;this.isAncestor(t,i[c])?(s=c,r=c+1):o=c-1}let a=null,l=1/0;for(let c of this.history.versions){let u=c.commit?this.index.get(c.commit):void 0;u===void 0||u<=s||u<l&&(a=c,l=u)}return a}}});import{execFileSync as s6}from"node:child_process";function ZI(e,t){return s6("git",t,{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","pipe"],maxBuffer:256*1024*1024})}function r6(e,t){try{return ZI(e,["rev-parse","--verify","--quiet",`${t}^{commit}`]).trim()||void 0}catch{return}}function Br(e,t){if(t!==void 0){let n=t.startsWith("-")?void 0:r6(e,t);return n?{commit:n,from:"flag"}:{commit:null,from:null,problem:`--base ${t} names no commit in this repository`}}for(let[n,i]of[["refs/remotes/origin/HEAD","origin/HEAD"],["refs/heads/main","main"],["refs/heads/master","master"]]){let r=r6(e,n);if(r)return{commit:r,from:i}}return{commit:null,from:null,problem:"no base revision: pass --base <rev> (there is no origin/HEAD, main or master)"}}function si(e,t){if(!t.commit)return ds(null,t.problem?[t.problem]:[]);let n=Av(Ra(e,t.commit),t.commit);if(!n.active||n.problems.length>0)return n;let i=t6(e,t.commit,n.signersPath);if(i.broken){let o=i.broken.commit?` at ${i.broken.commit.slice(0,8)}`:"";return{...n,problems:[`the signer history of ${n.signersPath} is broken${o}: ${i.broken.reason}`]}}let r=new Tv(e,t.commit,i);return{...n,signersAt:o=>r.versionFor(o)}}function cye(e,t,n){let i=new Map;if(n.length===0)return i;let r=ZI(e,["--literal-pathspecs","log","-c","--name-only","--no-renames","--format=%x00%H",t,"--",...n]),o=new Set(n),s="";for(let a of r.split(`
152
+ `))a.startsWith("\0")?s=a.slice(1).trim():a&&o.has(a)&&!i.has(a)&&i.set(a,s);return i}function lye(e,t){if(t.length===0)return new Set;let n=ZI(e,["--literal-pathspecs","status","--porcelain=v1","-z","--untracked-files=all","--",...t]),i=new Set,r=n.split("\0");for(let o=0;o<r.length;o++){let s=r[o];s.length<4||(i.add(s.slice(3)),(s[0]==="R"||s[0]==="C")&&o++)}return i}function i6(e,t,n){try{return s6("git",["merge-base","--is-ancestor",t,n],{cwd:e,stdio:"ignore"}),!0}catch{return!1}}function o6(e,t,n){return t.adopted.some(i=>i6(e,n,i.to)&&(i.from===void 0||!i6(e,n,i.from)))}function Wm(e,t,n,i){let r=t;if(t.signersAt){let s=t.signersAt(n);if(r={...t,signers:s?.signers??[]},!s||s.version===0){let a="no signer set was in effect where this commit entered the base's history";return o6(e,t,n)?{level:"adopted",commit:n,reason:`in a commit range the policy at base adopts; ${a}`}:{level:"unattested",commit:n,reason:a}}}let o=_v({repo:e,policy:r},n,i);return o.level==="unattested"&&o6(e,t,n)?{level:"adopted",commit:n,attestor:o.attestor,reason:`in a commit range the policy at base adopts; ${o.reason}`}:{level:o.level,commit:n,attestor:o.attestor,...o.principal?{principal:o.principal}:{},...o.key?{key:o.key}:{},reason:o.reason}}function a6(e){let t=new Map,n=o=>{for(let s of e.paths)t.set(s,{level:"unattested",commit:null,reason:o});return t};if(!e.repo)return n("not in a git repository");if(e.policy.problems.length>0)return n(e.policy.problems.join("; "));if(!e.policy.active)return n(`no signers file (${e.policy.signersPath}) at base ${e.policy.base?.slice(0,8)}; attestation is off`);let i=e.at===null?lye(e.repo,e.paths):new Set,r=cye(e.repo,e.at??"HEAD",e.paths.filter(o=>!i.has(o)));for(let o of e.paths){if(i.has(o)){t.set(o,{level:"unattested",commit:null,reason:"the working tree has uncommitted changes to this file"});continue}let s=r.get(o);if(!s){t.set(o,{level:"unattested",commit:null,reason:"no commit holds this file"});continue}let a=Wm(e.repo,e.policy,s,e.attestors);t.set(o,e.revisit?.(o,a)??a)}return t}var Zc=v(()=>{"use strict";mo();Id();ps();n6()});function Dv(e,t){if(typeof e!="string")return!1;let n=e.match(dye);return!!n&&(t===void 0||n[1]===t)}var uye,kze,dye,YI=v(()=>{"use strict";uye={"declaration-missing":"No chant.workspace.json or .jsonc between the directory and the git root.","declaration-ambiguous":"Both chant.workspace.json and chant.workspace.jsonc exist.","declaration-unparseable":"The declaration is not valid JSON, or not valid JSONC for .jsonc.","declaration-invalid":"The declaration does not match its schema, repeats a name, or --member names no entry.","placement-invalid":"A member or group match breaks a placement rule.","reader-too-old":"The declaration's minReader is newer than the chant reading it.","root-chant-required":"The declaration pins a chant version other than the reader's, and that chant is not installed at the workspace root.","not-a-git-repository":"--at, or a ledger read, needs a git repository and there is none.","revision-unknown":"--at names no commit.","live-at-revision":"graph was given --live and --at: a live read is of the account now, not of a revision.","environment-invalid":"An environment name that can't name a ledger directory.","dir-missing":"The member's directory does not exist.","unknown-kind":"No built-in kind or pinned package supplies the member's kind.","kind-probe-failed":"The member's directory is not what its kind reads.","no-matches":"An example group matches no directory holding a chant project.","kind-not-run":"The member's kind is one the per-member commands don't run, such as other.","command-failed":"The member's own command exited with a failure, or the lexicon that reads the member through its kind's graph block isn't installed where the workspace resolves its pin.","output-unreadable":"The member's command printed something that isn't the document asked for.","ir-version-unsupported":"The member's IR has a version this chant can't read.","ledger-unreadable":"Reading the ledger failed, so nothing from it is listed.","ledger-malformed":"Some lines of the ledger aren't release records; the rest are listed.","gates-no-ledger":"The checkout has no chant/lifecycle branch, so there is no gate ledger to read.","gates-no-gate-ledger":"The branch has no gate ledger for the member: no run of it has reached a gate.","gates-ledger-unreadable":"Reading the member's gate ledger failed, so no gate is listed.","stewards-unreadable":"An *.op.ts file could not be imported, so a steward it declares may be missing.","stewards-conflict":"A steward was dropped: its name, or an Op it lists, belongs to another steward.","steward-runs-unreadable":"Reading an Op's run ledger, or a ConvergeOp's converge ledger, failed, so its last run or last tick is null.","record-unparseable":"No front matter, a YAML error or a value outside the JSON subset of YAML, or for a JSON kind a file that is not one object or repeats a member name.","record-schema-invalid":"The record's front matter, or its JSON object, does not match the kind's schema.","record-id-duplicate":"Another record earlier in path order has the same id.","record-supersedes-unknown":"A supersedes link names an id no record has.","record-supersedes-conflict":"A second closed record supersedes a record another one already superseded.","record-remediates-unknown":"A remediates link names an id no record has.","record-remediates-not-closed":"A remediates link names a record that isn't closed; a record still open is amended instead.","record-seal-mismatch":"A closed record's seal is not the whole-file seal of its text now: the record changed after it closed.","session-seal-mismatch":"A closed session's seal is not the whole-file seal of its text now: the session changed after it closed, or was sealed by the rule before #2546.","session-verdict-unknown-record":"A session's verdict names a record that none of the session kind's subject records has.","asset-drift":"A file the record pins by hash has changed: its bytes no longer hash to the pinned sha256.","asset-missing":"A file the record pins by hash does not exist in the tree read.","asset-stale":"A file the record pins is unchanged at the hash a record it supersedes pinned: the decision changed and the artifact did not follow.","record-supersedes-pending":"A supersedes link from a record whose state is weaker than the record it names, so the link has no effect yet.","record-no-evidence":"The record's evidence list is empty: it cites nothing and pins no file. Information for a reviewer, never an error.","review-undigested":"A verdict names no digest of the text it judged. It still counts, and an amendment does not stop it counting.","source-transcript-drift":"The record's source block pins a transcript by hash, the file it names can be read here, and its bytes hash to something else: it is not the transcript the record means.","work-needs-unknown":"A work record's needs list names a work id no record has, so the item stays blocked.","work-implements-unknown":"A work record's implements list names a decision id no decision has.","work-needs-cycle":"A work record needs itself through its needs links, so it can never be ready.","work-implements-undecided":"A work record implements a decision whose state is not approved, such as proposed.","work-done-unpinned":"A work record is done and its evidence list is empty: nothing shows the work was done.","work-closed-without-date":"A work record is done or dropped and has no closing date.","work-done-gap-open":"A work record is done, and the finding it came from still fires on its region. graph --intent raises it, and records does by walking that region.","work-acceptance-unmet":"A work record is done, and one of its acceptance criteria has no passing evidence of the verification it expects. check fails on it (WSP117).","work-acceptance-self-verified":"A passing manual verdict on a work record's criterion names the record's implementer, so it does not count: a manual verdict comes from someone else.","work-contract-unknown":"A work record names a contract that no record of its kind's contract kind has.","work-contract-undecided":"A work record names a contract whose state is not approved, such as a draft.","work-tier-unknown":"A work record names a builder tier that its kind's work.tier.tiers does not list.","answer-points-unreadable":"The points file the answer kind names can't be read, or is not valid.","answer-point-unknown":"The answer's point is not declared in the points file the answer kind names.","answer-point-changed":"The point's declaration changed since the question was asked, so the answer is to an older version of the question.","review-decider":"The verdict is the decider's own, and the quorum counts verdicts besides the decider's.","review-agent":"The reviewer holds the agent role in the trust policy at base.","review-duplicate":"A later verdict by the same principal replaces this one. Names are compared after NFKC, trimming and lower-casing.","review-older-digest":"The verdict names a digest other than the record's text now: the record changed after the verdict.","review-unattested":"An attestation policy is active at base, and the verdict carries no seal that verifies for its reviewer.","seal-missing":"The verdict, or the record, carries no seal.","seal-signer-unlisted":"The reviewer, or the record's author, has no key in the signers file at base, so the seal can't count.","seal-signature-invalid":"The seal is malformed, names a signer other than the reviewer or author, or its signature does not verify over the verdict or record.","seal-unverifiable":"Nothing here can say whose seal it is: there is no signers file at base, ssh-keygen is not installed, or the record came back in a return sealed by a signer no admission lists yet.","record-unattested":"A signers file is active at base, and the record names an author whose seal does not verify: it has none, the author has no key in the file, or the signature fails.","kind-unreadable":"The record kind file is missing or could not be imported.","kind-invalid":"The record kind file exports no recordKind, or its shape is wrong.","schema-unreadable":"The schema file the record kind names is missing or is not JSON.","schema-id-mismatch":"The schema's $id differs from the id the record kind names.","schema-invalid":"The record schema itself does not compile.","location-missing":"The records directory does not exist, in the tree or at the revision.","write-usage-invalid":"The command line lacks a value the write needs, or gives one it does not take.","write-input-invalid":"The fields given with --from or --set can't be read, are not JSON, or are not a JSON object.","record-not-found":"No record of the kind has the id given.","record-id-taken":"The id given for a new record is already used, by a record or a file name.","record-id-unallocatable":"No id was given and none can be allocated: the records share no single prefix and --prefix names none.","record-path-unmatched":"The file name made from the record's id and title does not match the kind's location.","record-closed":"The record is in a closed state, so nothing in it changes; a new record supersedes it instead.","amend-id-immutable":"An amendment changes the record's id, and ids are never renumbered.","amend-supersede-instead":"The record is approved, and the amendment changes a field the approval rule does not let change in place; a new record supersedes it instead.","review-unsupported":"The kind's schema has no reviews field, so its records take no review.","review-note-required":"A dissent was given with no note: a dissent needs a reason.","review-sign-failed":"--sign was given and no seal could be made: the key can't be read or used, git names no ssh signing key, or ssh-keygen is not installed.","record-state-not-initial":"A record written through chant serve mcp gives a state other than the kind's first: a new record opens proposed, and a person moves it on.","source-harvest-not-proposed":"A harvested record (source.via harvest) was written in a state other than the kind's first: a harvest proposes, and a person decides.","ratify-quorum-not-met":"The write puts a record in its kind's ratified state (reviews.ratified), and the record's quorum is not met: too few agreeing verdicts count.","record-sign-failed":"--sign was given and no author seal could be made: the record names no author, the key can't be read or used, git names no ssh signing key, or ssh-keygen is not installed.","record-conflict":"--expect named a digest the record no longer has: another write changed it after the caller read it. The refusal names the digest it has now; re-read the record and write again.","write-lock-timeout":"Another write held the working tree's write lock for longer than the write waits (CHANT_WRITE_LOCK_WAIT_MS); the refusal names the holder. Run the write again.","write-lock-not-held":"CHANT_WRITE_LOCK names a batch's lock token that no longer holds the working tree's write lock: the batch released it, or it expired and another writer took it.","write-scope-member":"The write is to a file, or to a record kind, of a member outside the writer's scope: an agent session writes only the members it is bound to, and writeScope.<class>.members leaves the member out.","write-scope-kind":"The write is to a record kind writeScope.<class>.records does not list, with a verb it does not list for the kind, or deletes a record.","write-scope-protected":"The write is to a file writeScope.<class>.protected lists, or one under a directory it lists, outside the top-level keys or JSON Pointers the entry's except allows (#3146, #3308).","write-scope-class-unknown":"The declaration's writeScope at base names a principal class no pinned package supplies, and the writer is judged human, so it may be in that class; the write is refused until the package is installed at the pinned version or the entry removed (#3080).","agent-unknown":"CHANT_AGENT, or a commit's Chant-Agent trailer, names an agent session the declaration at base does not declare.","principal-unidentified":"chant.workspace.json at base sets identity.attribution to identified, and the write names a person by a bare name: --by, an author field or a decision point's answerer must be a forge identity (github:<login>, gitlab:<login>, <forge>@<host>:<login>), a principal the signers file at base lists, or an agent, runner or service principal (#3163).","session-unknown":"--session names no session of a session kind whose subjects are the record's kind.","session-not-open":"--session names a session in a closed state, which takes no more verdicts.","points-undeclared":"No record kind with an answers block is declared, or given with --kind, so there is no points file to ask.","points-invalid":"The points file an answer kind names can't be read, or does not match decision-points.schema.json and the rules checked in code.","point-unknown":"No points file declares the point asked, or the one an answer names.","point-inputs-invalid":"The inputs given to an ask are not a JSON object of the point's declared inputs.","point-decider-failed":"A model decider that fails closed (unreachable: fail) could not answer, so the ask wrote nothing.","answer-not-candidate":"The people's answer is not one of the question's candidates.","quorum-not-met":"Too few of the people who answered count toward the point's quorum: distinct, not holding the agent role, not the steward that asked, and holding one of its roles when it names any. Nobody named over MCP or ACP counts (#3817).","answer-in-steward-turn":"The answer was given during a steward's turn, or by a process it started: a steward never answers a decision point, and a person answers it through hud or at a shell.","answer-never-over-mcp":"The answer or retraction came over MCP or ACP, or from a process a session on one started, and the question constrains a gate that is never resolved there: a person answers it at a shell or through hud (#3817).","answer-not-answered":"points retract names a question that has no answer to retract: it is escalated or proposed, and people answer it instead (#3351).","answer-field-unsupported":"The answer kind's copy of point-answer.schema.json predates a field the write needs, a note, a relay, a retraction or an ad-hoc question's asked: copy the schema anew to turn it on (#3351, #3402, #3403).","point-candidates-invalid":"points ask names an ad-hoc point without --candidates, a declared point with them, or candidates that are not a question and criteria of the point's question type (#3403).","since-rev-unknown":"--since names no commit, or a session with no opening revision and no commit that added it.","since-session-unknown":"--since has the shape of a session id and names no commit, and no session the kind or the declaration reads has that id.","since-session-open":"--since names a session that is still open, so the comparison runs to the working tree.","intent-region-invalid":"The region's path, or its line range, does not exist in the tree read.","intent-record-unknown":"graph --intent --record names an id that no record of a decision kind read has.","intent-symbol-unsupported":"The region names a symbol, path#symbol, in a file no symbol resolver reads; a line range still works.","intent-symbol-unknown":"The region names a symbol the file does not declare in the tree read.","intent-symbol-ambiguous":"The region names a symbol that matches more than one declaration in the file; its qualified name picks one.","intent-history-shallow":"The repository is a shallow clone, so the region's history stops at the clone's boundary.","intent-plugin-failed":"A kind file's commitJoins, which joins commits to units, contracts and evidence, failed for a commit.","squash-unfollowed":"A squash commit's pull request ref (refs/pull/<n>/head) is not in the clone and could not be fetched from origin, so its original commits are not followed; the read keeps its answer without them.","intent-commit-undecided":"A commit changed the region when no decision constrained it at path granularity.","intent-commit-bare":"A commit names no unit, carries no record through its Chant-Record or Chant-Lease trailer, and has no pull request and no decision covering the region at its time.","intent-pin-drifted":"A decision's pinned artifact no longer hashes to the pin.","intent-pin-missing":"A decision's pinned artifact does not exist in the tree read.","intent-pin-stale":"A current decision pins an artifact at the hash a record it supersedes pinned, and the artifact has not changed since: the decision moved on and the artifact did not.","intent-artifact-unpinned":"An artifact decisions in the graph pinned, which no current decision pins.","intent-decision-superseded-live":"Every decision constraining the region is superseded.","intent-decision-provisional":"The current decisions constraining the region are all in states their kind does not close, such as decided.","intent-decision-contested":"A current decision constraining the region has an open concern: a dissent neither addressed nor withdrawn.","intent-constraint-coarse":"The region is constrained only through its member, not by path.","intent-constraint-lost":"A decision's path constraint names a path that does not exist in the tree read.","intent-evidence-unpinned":"A decision's evidence has no hash: a URL, or a path with no sha256.","intent-trailer-unverified":"A commit carries a trailer a plugin says claims authorship, and the commit is not attested.","intent-region-unconstrained":"No decision constrains the region at any granularity.","intent-decision-unimplemented":"A decided decision constrains the region, no work item that is not dropped implements it, and no commit falls in its window.","intent-work-blocked":"A work item constraining the region has commits in its window while a work item it needs is not done.","intent-work-open-decided-code":"Commits in the region are a decision's own work while the work item implementing that decision is still open.","intent-commit-join-conflict":"A commit joined to an agent run by its Chant-Run trailer or the run's record has the patch-id of a commit another run recorded, so it is not joined to that run by content.","intent-why-no-decision":"No current decision governs the region at any granularity, and none is carried out by the commits or runs that made its current lines.","intent-why-no-run":"None of the region's current lines was made by a commit an agent run is joined to.","intent-why-uncommitted":"Some of the region's lines are not committed yet.","intent-why-run-ambiguous":"Some lines come from a commit several agent runs made, and no run's recorded hunks say which wrote them.","change-uncovered":"A path the diff changes is covered by no current decided record and no open work item, by path or by its member.","change-out-of-scope":"A record in hand for the change, such as the work item it is for or a decision that item implements, lists a path the diff changes in its out_of_scope.","patch-path-invalid":"workspace patch --path names a path that is not relative and inside the workspace.","composites-no-chant-member":"No member of kind chant was read, so nothing declares a composite instance or a component.","composites-none-declared":"The members read declare no composite instance.","composites-no-component":"The members read declare no component, so no composite instance has one.","runtimes-config-unreadable":"The member's chant.config.ts could not be read, so only the built-in local runtime is listed, and no environment from the config.","runtimes-lexicon-unreadable":"A lexicon the member's config lists could not be loaded, so it is not listed as a runtime.","environments-none-declared":"The member's chant.config.ts declares no environments, so only local and the environments in its ledger are listed.","environments-ledger-undeclared":"The member's ledger has releases in an environment its config's environments don't cover, so chant run --env would refuse it and it is not listed.","environments-ledger-unreadable":"The chant/lifecycle branch exists and the member's ledger environments could not be listed.","environments-component-undeclared":"A component declares an environment its member's chant.config.ts environments don't cover, so chant run --env would refuse it and it is not listed (#3153).","diagram-source-missing":"A declared diagram's source file does not exist in the tree read.","diagram-render-missing":"A declared diagram's render file does not exist in the tree read.","diagram-render-drift":"A declared diagram records a sourceHash, and the source's bytes now hash to something else: the render is stale for its source.","box-credential-declared":"A file in a box member's directory carries a literal secret: a credential's shape, or a literal where a credential goes. A variable or secret-manager reference is not one.","box-capability-unbrokered":"A capability in a member's box block names no broker, so the box would hold its credential.","box-fountain-callback-undeclared":"A box member builds a fountain Box, whose persistent sandbox fountain gives a callback token scoped to its owner, and the member's box block does not declare the fountain-callback capability brokered by fountain with scope owner.","box-intent-unknown":"A box block names an intent, and no record of a declared kind named decision has that id.","box-intent-unconstrained":"The decision record a box names as its intent constrains no member or path of this workspace: no member: entry for a declared member and no path: entry at, above or inside one's directory.","box-none":"No member's box block declares services, so the workspace has no box for a host to plant.","box-several":"More than one member's box block declares services, and a planted workspace runs one box.","work-kind-missing":"No work kind to find the item in: --kind names a kind with no work block, or the declaration names no work kind.","work-kind-ambiguous":"More than one declared work kind has a record with the id, so --kind must name one.","work-item-unknown":"No work record has the id, so there is nothing to lease.","work-item-closed":"A claim on a work item in a closed state, such as done or dropped: there is no work left to claim.","work-criterion-unknown":"The work record lists no acceptance criterion with the id the evidence names, or its kind has no acceptance criteria.","lease-held":"Someone holds a live lease on the work item: another worker, or, for a claim, the same one.","lease-not-held":"Nobody holds a live lease on the work item: it expired, was released or was never claimed.","lease-token-mismatch":"The live lease on the work item carries another fencing token than the one given.","lease-race":"Another writer changed the lease between this command's read and its write.","lease-push-rejected":"The remote refused the lease push: another clone claimed the item first, or the remote could not be reached.","run-exists":"runs start or runs record was given a run id the ledger already has.","run-unknown":"runs end names a run the ledger has no start for.","run-ended":"runs end names a run whose end is already recorded.","runs-no-ledger":"The checkout has no chant/lifecycle branch, so there are no agent runs to read.","runs-ledger-malformed":"Some lines of the agent run ledger aren't run events; the rest are read.","run-not-ended":"runs sign or runs statement names a run with no end recorded. A statement is signed over the run's whole record.","run-statement-invalid":"The envelope's payload is not an in-toto Statement v1 with chant's agent-run predicate, or has a field the predicate does not define.","run-statement-signer-mismatch":"The statement names a signer other than the runner whose key signed it.","run-statement-mismatch":"A listed runner key signed the statement, and it does not match the run's record: another run, a record that hashes differently, or another unit, harness, model, provider or principal.","listing-member-unknown":"box listing set names a member the declaration does not declare.","listing-box-missing":"box listing set names a member whose entry declares no box block, so it has no listing.","listing-cover-invalid":"The cover can't be read, is not a PNG, JPEG or WebP picture, is larger than 5 MiB, has a path outside the workspace, or has an extension other than its picture format's.","member-exists":"member add names a member the declaration already has, with an entry other than the one given.","member-unknown":"member remove names a member the declaration does not declare.","factory-member-unknown":"box factory set names a member the declaration does not declare.","factory-box-missing":"box factory set names a member whose entry declares no box block, so it has no factory.","publish-member-unknown":"box publish names a member the declaration does not declare.","publish-none":"box publish names a member whose box block names no publisher, or which declares no box block.","publish-refused":"The box's publisher refused (it exited 2): nothing was published, and its message says why.","publish-failed":"The box's publisher could not be run, failed (a nonzero exit other than 2) or ran out of time; its message says what it had done.","publish-answer-invalid":"The box's publisher exited 0 and printed no JSON object, or one box-publish.schema.json does not allow.","publish-unrecorded":"The commit the publisher named is not in the repository, or lacks the apply record of ws-075: Chant-Applied-By naming --by, Chant-Applied-At, Chant-Applied-Commit and a Chant-Record for the item, or a Chant-Record for each record sent.","wip-no-branch":"HEAD is detached, or names a branch with no commit yet, so there is no branch to keep work in progress for.","wip-none":"wip restore was given no snapshot, and the branch has none under refs/chant/wip/<branch>.","wip-snapshot-unknown":"wip restore names something that is not a work-in-progress snapshot chant took.","wip-branch-other":"wip restore names a snapshot taken on another branch than the one checked out.","wip-race":"Another writer moved refs/chant/wip/<branch> between this command's read and its write.","wip-policy-none":"wip push or wip fetch was run, and no box block declares replicate, so there is no remote.","wip-remote-unknown":"The replicate policy names a git remote the checkout does not have; the host adds it, with its credential, before chant pushes.","ci-green-undeclared":"The declaration has no ci.green block, so chant does not know which check runs make a commit green.","ci-branch-unknown":"The checkout has no ref for the branch ci.green names: neither the remote-tracking branch nor a local one.","box-isolation-collision":"Two boxes on one host resolve to the same port, state path or cookie name, or two ports in one box share an offset.","box-isolation-literal":"A host's stateRoot or a box's state entry is a literal machine path instead of one derived from an environment reference and the box's name.","signers-file-missing":"There is no signers file at the base revision, so there is no signer history to read.","signers-removed":"The signers file was removed. Commits merged before the removal keep the set they were judged by; nothing after it verifies.","rotation-unparseable":"The rotation file beside the signers file is not JSON.","rotation-invalid":"The rotation file does not match its shape: schema 1, a version, the previous set's digest, a threshold and signatures.","rotation-first-version":"The first signer set's rotation file names a version other than 1, or a previous digest.","rotation-missing":"The signer set or its threshold changed and no rotation file signed by the set before it came with the change.","rotation-version-skew":"The rotation names a version other than the one after the set it replaces, as a replayed or skipped rotation does.","rotation-previous-mismatch":"The rotation names a previous digest other than the set it replaces, as a rollback to an older set does.","rotation-threshold-unsatisfiable":"The new threshold is more than the number of distinct signers in the new set, so no later rotation could meet it.","rotation-threshold-not-met":"Fewer distinct signers of the set before signed the rotation, in the chant-signers namespace, than that set's threshold.","trust-policy-unreadable":"The trust policy at base can't be read, or its signer history is broken, so no runner key is trusted.","envelope-unreadable":"The --envelope file can't be read, or is not JSON.","envelope-invalid":"The file is not a DSSE envelope: payloadType, payload in canonical base64, and signatures with keyid and sig.","envelope-untrusted":"No signature in the envelope verifies against a runner key the policy at base lists.","evidence-payload-type":"The envelope's payload type is not application/vnd.in-toto+json.","evidence-statement-invalid":"The payload is not an in-toto Statement v1 with chant's runner-evidence predicate, or has a field the predicate does not define.","evidence-runner-mismatch":"The statement names a runner other than the one whose key signed it.","runner-key-invalid":"The key given to evidence sign or runs sign is not an Ed25519 private key in PEM.","runner-key-is-signer":"The key given to evidence sign or runs sign is a person's key in the signers file. Evidence and run statements are signed by a service or CI identity.","runner-key-unlisted":"The policy at base lists no runner with the key given to evidence sign or runs sign.","lock-invalid":"The lineage lock can't be read.","manual-step-open":"A scope in the lineage lock has an open manual step."},kze=Object.keys(uye),dye=/^plugin:([^:\s]+):([a-z0-9]+(?:-[a-z0-9]+)*)$/});function c6(e){let t=e.commitJoins,n=e.commitJoinsName;if(t===void 0)return n===void 0?void 0:"commitJoinsName: a kind file with no commitJoins has no findings to name";if(n!==void 0&&(typeof n!="string"||!fye.test(n)))return"commitJoinsName: a string with no colon or space, the <name> of plugin:<name>:<code>";let i=n===void 0?{}:{name:n};if(typeof t=="function")return{form:"function",join:t,...i};let r=pye.safeParse(t);return r.success?{form:"data",data:r.data,...i}:r.error.issues.map(o=>`commitJoins${o.path.length?`.${o.path.join(".")}`:""}: ${o.message}`).join("; ")}function jv(e,t){let n=t.toLowerCase(),i=[];for(let[r,o]of Object.entries(e))if(r.toLowerCase()===n)for(let s of o){let a=s.trim();a&&!i.includes(a)&&i.push(a)}return i}function Aa(e,t){return jv(e,t)[0]}function QI(e,t){let n=t.toLowerCase();return Object.keys(e).some(i=>i.toLowerCase()===n)}function mye(e,t,n){if(!e)return{};let i=n.read(e.split("{id}").join(t));if(i===void 0)return{};let r;try{r=JSON.parse(i)}catch{throw new Error(`${e.split("{id}").join(t)} is not JSON`)}if(r===null||typeof r!="object"||Array.isArray(r))return{};let{id:o,...s}=r;return s}function gye(e,t,n){let i={},r=(a,l)=>({...mye(e.records?.[a],l,n),id:l});for(let a of["unit","contract"]){let l=e.trailers[a],c=l?Aa(t.trailers,l):void 0;c&&(i[a]=r(a,c))}let o=e.trailers.evidence?jv(t.trailers,e.trailers.evidence):[];o.length>0&&(i.evidence=o.map(a=>r("evidence",a)));let s=(e.authorship??[]).filter(a=>QI(t.trailers,a));return s.length>0&&(i.authorship=s),i}function Td(e){let t=e?.decisions;return Array.isArray(t)?t.filter(n=>typeof n=="string"&&n!==""):[]}async function Lv(e,t,n,i){if(e.form==="data")return gye(e.data,t,n);let r=await e.join(t,n);if(r==null)return{};if(typeof r!="object")throw new Error("commitJoins returned something that is not an object");let o=(c,u)=>{if(c!=null){if(typeof c!="object"||Array.isArray(c)||typeof c.id!="string"||c.id==="")throw new Error(`commitJoins returned a ${u} with no string id`);return c}},s={},a=o(r.unit,"unit"),l=o(r.contract,"contract");if(a&&(s.unit=a),l&&(s.contract=l),r.evidence!==void 0&&r.evidence!==null){let c=Array.isArray(r.evidence)?r.evidence:[r.evidence];s.evidence=c.map(u=>o(u,"evidence")).filter(Boolean)}if(r.authorship!==void 0){if(!Array.isArray(r.authorship)||!r.authorship.every(c=>typeof c=="string"))throw new Error("commitJoins returned authorship that is not a list of trailer keys");s.authorship=r.authorship}if(r.findings!==void 0&&r.findings!==null){if(!Array.isArray(r.findings))throw new Error("commitJoins returned findings that are not a list");s.findings=r.findings.map(c=>{if(c===null||typeof c!="object"||Array.isArray(c))throw new Error("commitJoins returned a finding that is not an object");let{code:u,message:d,refs:p}=c;if(!Dv(u,i))throw new Error(`commitJoins returned the finding code ${JSON.stringify(u)}, and a plugin's codes are plugin:${i}:<code>, with <code> in lower case words joined by dashes`);if(typeof d!="string"||d==="")throw new Error(`commitJoins returned the finding ${u} with no message`);if(p!==void 0&&(!Array.isArray(p)||!p.every(f=>typeof f=="string")))throw new Error(`commitJoins returned the finding ${u} with refs that are not a list of strings`);return{code:u,message:d,refs:p??[]}})}return s}var Nv,XI,pye,fye,Mv=v(()=>{"use strict";Ln();YI();Nv=m.string().regex(/^[A-Za-z0-9][A-Za-z0-9-]*$/,"a trailer key holds letters, digits and dashes"),XI=m.string().min(1).refine(e=>e.includes("{id}")&&!e.startsWith("/")&&!e.split("/").includes(".."),"a record path is relative to the workspace root and holds {id}"),pye=m.object({trailers:m.object({unit:Nv.optional(),contract:Nv.optional(),evidence:Nv.optional()}).strict(),records:m.object({unit:XI.optional(),contract:XI.optional(),evidence:XI.optional()}).strict().optional(),authorship:m.array(Nv).optional()}).strict(),fye=/^[^:\s]+$/});function eT(e){let t=e.indexOf(":");if(t<=0)return;let n=e.slice(0,t).trim(),i=e.slice(t+1).trim();return kye.test(n)&&xye.test(i)?{kind:n,id:i}:void 0}function u6(e){let t=[];for(let r of jv(e,yye)){let o=eT(r);o&&!t.some(s=>s.kind===o.kind&&s.id===o.id)&&t.push(o)}let n=Aa(e,bye)??null,i=Aa(e,vye)??null;return{agent:Aa(e,zm)??null,lease:Aa(e,hye)??null,run:Aa(e,l6)??null,records:t,applied:n===null?null:{by:n,at:Aa(e,wye)??null,commit:i!==null&&$ye.test(i)?i:null}}}var zm,hye,l6,yye,bye,wye,vye,kye,xye,$ye,Fv=v(()=>{"use strict";Mv();zm="Chant-Agent",hye="Chant-Lease",l6="Chant-Run",yye="Chant-Record",bye="Chant-Applied-By",wye="Chant-Applied-At",vye="Chant-Applied-Commit",kye=/^[a-z][a-z0-9-]*$/,xye=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/,$ye=/^[0-9a-f]{40,64}$/});import{spawn as Rye}from"node:child_process";import{existsSync as Sye,readFileSync as Eye,realpathSync as d6}from"node:fs";import{join as tT,relative as p6,resolve as Aye}from"node:path";function Qt(e,t){let n=Ou(e);if(t!==void 0){if(!n)throw new ve("not-a-git-repository","--at reads git objects, and this directory is not in a git repository");let o=tC(n,t);if(!o)throw new ve("revision-unknown",`--at ${t} names no commit in this repository`);let s=Cu(n,o),a=f6(p6(n,d6(Aye(e)))),l=C0(s,a.startsWith("..")?"":a);if(l===void 0)throw new ve("declaration-missing",`no chant.workspace.json or .jsonc between ${a||"."} and the git root at ${o.slice(0,8)}`);return{tree:l===""?s:Cu(n,o,l),root:l===""?".":l,rootOnDisk:tT(n,...l.split("/")),at:o,top:n}}let i=gr(e);if(!i)throw new ve("declaration-missing",n?"no chant.workspace.json or .jsonc between this directory and the git root; chant workspace init proposes one":"no chant.workspace.json or .jsonc in this directory; chant workspace init proposes one");let r=n?f6(p6(n,d6(i.dir))):i.dir;return{tree:$n(i.dir),root:r===""?".":r,rootOnDisk:i.dir,at:null,top:n}}function Pye(e,t){let n=na(nd,e);if(!n)return;let i;try{i=JSON.parse(Eye(tT(n,"package.json"),"utf-8"))}catch{return}if(i.version!==t)return;let r=typeof i.bin=="string"?i.bin:i.bin?.chant;if(typeof r!="string")return;let o=tT(n,r);return Sye(o)?o:void 0}function Oye(e){let t=td.find(r=>e.tree.stat(r)==="file");if(!t)return;let n;try{n=e.tree.read(t)}catch{return}let i=fa(n,{jsonc:t.endsWith(".jsonc")});if(!(!i.ok||i.value===null||typeof i.value!="object"||Array.isArray(i.value)))return Qw(i.value)?.version}async function Bv(e,t,n=process.argv.slice(2)){if(process.env[m6])return;let i;try{i=Qt(e,t)}catch{return}let r=Oye(i);if(r===void 0||r===Xt())return;let o=Pye(i.rootOnDisk,r);if(o)return new Promise(s=>{let a=Rye(o,n,{stdio:"inherit",env:{...process.env,[m6]:r}});a.on("error",l=>{process.stderr.write(`could not start the root's chant ${r} at ${o}: ${l.message}
153
+ `),s(1)}),a.on("close",l=>s(l??1))})}var f6,m6,ai=v(()=>{"use strict";Ri();_t();ed();ao();Zt();f6=e=>e.split("\\").join("/");m6="CHANT_WORKSPACE_ROOT_CHANT"});var A6={};_e(A6,{AGENT_ENV:()=>nT,AGENT_TRAILER:()=>zm,SCOPE_FINDING_CODES:()=>Iye,WRITE_SCOPE_CODES:()=>Oa,WriteScopeError:()=>fs,checkWriteScope:()=>Nye,classesOf:()=>Em,declaredSessions:()=>sT,judgePath:()=>S6,judgeRecord:()=>oT,onlyKeysChanged:()=>R6,principalClass:()=>v6,protectedEntry:()=>x6,refuseRecordWrite:()=>aT,resolveWriter:()=>rT,roleGrants:()=>Sm,scopeOf:()=>Uv,scopeSource:()=>go,scopedKind:()=>E6,unknownClassVerdict:()=>iT});import{execFileSync as Cye}from"node:child_process";import{posix as g6,relative as h6,sep as y6}from"node:path";import{isDeepStrictEqual as _ye}from"node:util";function v6(e,t,n=wa()){return dq(e,t,n)}function rT(e,t,n,i=wa()){let r=n.principal??null,o=e?.agents??[];if(n.agent!==void 0&&n.agent!==null){let s=o.find(a=>a.name===n.agent);if(!s){let a=o.map(l=>l.name).join(", ");throw new fs("agent-unknown",e===null?`agent session ${JSON.stringify(n.agent)} is not declared: there is no workspace declaration`:`agent session ${JSON.stringify(n.agent)} is not declared: the declaration's agents ${a?`are ${a}`:"list none"}`)}return{principal:r,class:"agent",agent:s}}if(r!==null){let s=an(r),a=o.find(l=>l.principals.some(c=>an(c)===s));if(a)return{principal:r,class:"agent",agent:a}}return{principal:r,class:v6(t,r,i),agent:null}}function iT(e,t,n){if(t.class!=="human")return Pa;let i=eI(e?.writeScope??null,n);if(i.length===0)return Pa;let r=i.map(o=>`writeScope.${o}`).join(", ");return{ok:!1,code:"write-scope-class-unknown",message:`${Yc(t)} may be in ${i.length===1?"a class":"classes"} no pinned package supplies (${r}), so its scope can't be told; install the package that supplies ${i.length===1?"it":"them"} at the pinned version, or remove the entry (known classes: ${n.names().join(", ")})`}}function Uv(e,t){let n=e?.writeScope?.[t.class];return t.class==="agent"?{members:null,records:n?.records??null,protected:n?.protected??[],pointer:n?.pointer??"/agents"}:n??null}function Yc(e){if(e.agent){let n=e.agent.members;return`agent session ${e.agent.name}, bound to ${n.length===1?"member":"members"} ${n.join(", ")},`}let t=e.principal!==null?`${e.principal} (${e.class})`:`a ${e.class} writer`;return e.class==="agent"?`${t}, which no agent session lists,`:t}function k6(e,t,n){return e.class==="agent"?n!==null&&(e.agent?.members.includes(n)??!1):t.members===null||n!==null&&t.members.includes(n)}function oT(e,t,n,i){let r=Uv(e,t);if(r===null)return Pa;if(!(n.declared&&n.member===null?!0:k6(t,r,n.member))){let l=n.member===null?"in no member":`of member ${n.member}`;return{ok:!1,code:"write-scope-member",message:`${Yc(t)} may not write ${n.name} records, which are ${l}: ${t.class==="agent"?"an agent session writes only the members it is bound to":`writeScope.${t.class}.members leaves it out`}`}}if(i==="delete")return{ok:!1,code:"write-scope-kind",message:`${Yc(t)} may not delete a ${n.name} record: a record is never deleted, and a new one supersedes it`};if(r.records===null)return Pa;let a=[n.name,...n.declaredName!==null&&n.declaredName!==n.name?[n.declaredName]:[]].flatMap(l=>r.records[l]??[]);return a.includes(i)?Pa:{ok:!1,code:"write-scope-kind",message:a.length===0?`${Yc(t)} may not write ${n.name} records: writeScope.${t.class}.records does not list the kind`:`${Yc(t)} may ${[...new Set(a)].join(", ")} ${n.name} records, and not ${i} them (writeScope.${t.class}.records)`}}function x6(e,t){if(e.length===0)return null;let n=t.split("/"),i=n.map((r,o)=>n.slice(0,o+1).join("/"));for(let r of e){let o=(0,w6.default)(r.path,{dot:!0});if(i.some(s=>o(s)))return r}return null}function $6(e,t){if(t.length===0||e===null||typeof e!="object")return;let[n,...i]=t,r=e,o=n==="*"?Object.keys(r):Object.prototype.hasOwnProperty.call(r,n)?[n]:[];for(let s of o)i.length>0?$6(r[s],i):Array.isArray(e)?e[Number(s)]=Tye:delete r[s]}function R6(e,t,n){if(e===null||t===null||n.length===0)return!1;let i=s=>{let a=fa(s,{jsonc:!0});if(!a.ok)return null;let l=a.value;if(l===null||typeof l!="object"||Array.isArray(l))return null;let c=structuredClone(l);for(let u of n)u.startsWith("/")?$6(c,u.slice(1).split("/").map(d=>d.replace(/~1/g,"/").replace(/~0/g,"~"))):delete c[u];return c},r=i(e),o=i(t);return r!==null&&o!==null&&_ye(r,o)}function S6(e,t,n,i){let r=Uv(e,t);if(r===null)return Pa;let o=Mr(n,e?.members??[]);if(!k6(t,r,o)){let l=o===null?"is in no member":`is in member ${o}`;return{ok:!1,code:"write-scope-member",message:`${Yc(t)} may not write ${n}, which ${l}: ${t.class==="agent"?"an agent session writes only the members it is bound to":`writeScope.${t.class}.members leaves it out`}`}}let s=x6(r.protected,n);if(s===null||s.except.length>0&&i&&R6(i.before(),i.after(),s.except))return Pa;let a=s.except.length>0?`, outside what its except allows (${s.except.join(", ")})`:"";return{ok:!1,code:"write-scope-protected",message:`${Yc(t)} may not write ${n}${a}: writeScope.${t.class}.protected lists ${s.path}`}}function Wv(e,t){try{let n=Qt(e,t);return{declaration:Lt(n.tree),rootOnDisk:n.rootOnDisk,root:n.root,tree:n.tree}}catch(n){if(n instanceof ve)return null;throw n}}function go(e,t){let n=Un(e),i=n?Br(n,t):null,r=n&&i?si(n,i):ds(null),o=a=>{let{tree:l,...c}=a;return{...c,classes:pq(a.declaration.pins,a.rootOnDisk,{tree:l}).registry}};if(i?.commit){let a=Wv(e,i.commit);if(a)return{...o(a),from:"base",policy:r}}let s=Wv(e);return s?{...o(s),from:"working-tree",policy:r}:{declaration:null,from:null,rootOnDisk:null,root:null,policy:r,classes:wa()}}function E6(e,t,n,i){let r=e.declaration;if(!r||e.rootOnDisk===null)return{name:t,declaredName:null,member:null,declared:!1};let o=b6(h6(e.rootOnDisk,n)),s=[...r.records,...r.members.flatMap(l=>l.records)].find(l=>l.path===o);if(s)return{name:t,declaredName:s.name,member:s.member,declared:!0};let a=b6(h6(e.rootOnDisk,i));return{name:t,declaredName:null,member:a.startsWith("..")?null:Mr(a===""?".":a,r.members),declared:!1}}function sT(e){let t=Un(e),n=t?Br(t):null;if(n?.commit){let r=Wv(e,n.commit);if(r)return{agents:r.declaration.agents,from:"base"}}let i=Wv(e);return i?{agents:i.declaration.agents,from:"working-tree"}:null}function aT(e,t){let n=go(e);if(n.declaration===null&&(t.agent===void 0||t.agent===null))return n;let i=rT(n.declaration,n.policy,{agent:t.agent,principal:t.principal},n.classes),r=iT(n.declaration,i,n.classes);if(!r.ok)throw new fs(r.code,r.message);let o=oT(n.declaration,i,E6(n,t.kindName,t.kindFile,t.recordsDir),t.verb);if(!o.ok)throw new fs(o.code,o.message);return n}function Gv(e,t){return Cye("git",t,{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","pipe"],maxBuffer:512*1024*1024})}function zv(e,t,n){try{return Gv(e,["show",`${t}:${n}`])}catch{return null}}function Dye(e,t,n,i){if(i.format!=="markdown-front-matter")return"amend";let r=zv(e,`${t}^`,n),o=zv(e,t,n);if(r===null||o===null)return"amend";let s=ls(r),a=ls(o);if(!s.ok||!a.ok)return"amend";let c=[...new Set([...Object.keys(s.value),...Object.keys(a.value)])].filter(u=>JSON.stringify(s.value[u])!==JSON.stringify(a.value[u]));if(i.session){let u=a.value[i.session.stateField];return typeof u=="string"&&i.session.closed.includes(u)&&s.value[i.session.stateField]!==u?"close":c.every(d=>i.reviewFields.includes(d)||i.session.fills.includes(d))?"review":"amend"}return c.length>0&&c.every(u=>i.reviewFields.includes(u))?"review":"amend"}async function Nye(e){let{top:t,base:n,head:i,prefix:r,declaration:o}=e,s=e.classes??wa();if(o.writeScope===null&&o.agents.length===0)return null;let a=si(t,{commit:n,from:"flag"}),{activeAttestors:l}=await Promise.resolve().then(()=>(Id(),YK)),c=await l(),u=g=>o.writeScope?.[g]!==void 0||g==="agent"&&o.agents.length>0,d=[...s.names().filter(u),...eI(o.writeScope,s)],p={base:n,restricted:d,agents:o.agents.map(g=>g.name),commits:[],findings:[]},f=Gv(t,["rev-list","--reverse","--no-merges",`${n}..${i}`]).split(`
154
+ `).filter(Boolean);for(let g of f){let[h,b,w]=Gv(t,["log","-1",`--format=%s%x00%ae%x00%(trailers:key=${zm},valueonly,separator=%x01)`,g]).split("\0"),x=(w??"").split("").map(O=>O.trim()).filter(Boolean)[0]??null,k=a.active?Wm(t,a,g,c):null,R=k?.level==="attested"&&k.principal!==void 0,$=R?k.principal:b.trim(),_=Gv(t,["diff-tree","--no-commit-id","-r","--name-status","--no-renames","-z",g]).split("\0").filter(Boolean),T=[];for(let O=0;O+1<_.length;O+=2){let pe=_[O+1];r!==""&&!pe.startsWith(`${r}/`)||T.push({status:_[O],path:pe})}let C;try{C=rT(o,a,{agent:x,principal:$},s)}catch(O){if(!(O instanceof fs))throw O;p.commits.push({commit:g,subject:h,principal:$,attested:R,class:"agent",agent:x,paths:T.length}),p.findings.push({id:`finding:${O.code}:${g}`,code:O.code,commit:g,path:null,principal:$,class:"agent",agent:x,verb:null,message:`${g.slice(0,8)} has ${zm}: ${x}: ${O.message}`});continue}p.commits.push({commit:g,subject:h,principal:$,attested:R,class:C.class,agent:C.agent?.name??null,paths:T.length});let K=iT(o,C,s);if(!K.ok){p.findings.push({id:`finding:${K.code}:${g}`,code:K.code,commit:g,path:null,principal:$,class:C.class,agent:null,verb:null,message:`${g.slice(0,8)}: ${K.message}`});continue}if(Uv(o,C)!==null)for(let O of T){let pe=r===""?O.path:O.path.slice(r.length+1),F=e.kinds.find(B=>g6.dirname(O.path)===B.dir&&B.match.test(g6.basename(O.path))),Q=null,I;F?(Q=O.status==="A"?"new":O.status==="D"?"delete":Dye(t,g,O.path,F),I=oT(o,C,F.scoped,Q)):I=S6(o,C,pe,{before:()=>O.status==="A"?null:zv(t,`${g}^`,O.path),after:()=>O.status==="D"?null:zv(t,g,O.path)}),!I.ok&&p.findings.push({id:`finding:${I.code}:${g}:${pe}`,code:I.code,commit:g,path:pe,principal:$,class:C.class,agent:C.agent?.name??null,verb:Q,message:`${g.slice(0,8)} ${O.status==="D"?"deletes":O.status==="A"?"adds":"changes"} ${pe}: ${I.message}`})}}return p}var w6,nT,Oa,Iye,fs,Pa,Tye,b6,ms=v(()=>{"use strict";w6=Le(_f(),1);_t();tI();ed();uo();mo();mn();ps();Zc();Fv();ai();nT="CHANT_AGENT",Oa=["write-scope-member","write-scope-kind","write-scope-class-unknown","agent-unknown"],Iye=[...Oa,"write-scope-protected"];fs=class extends Error{constructor(n,i){super(i);this.code=n;this.name="WriteScopeError"}};Pa={ok:!0};Tye=Symbol("except");b6=e=>y6==="/"?e:e.split(y6).join("/")});var lT={};_e(lT,{FORGES:()=>O6,IDENTITY_CODES:()=>Xc,IdentityError:()=>gs,forgePrincipal:()=>Lye,gateAdmission:()=>Fye,gateAdmissionFrom:()=>cT,identify:()=>I6,parseForgeIdentity:()=>_6,refuseUnidentified:()=>hs});function _6(e){let t=jye.exec(an(e));if(!t)return null;let n=t[1],i=t[2]??C6[n];return i===null?null:{forge:n,host:i,login:t[3]}}function Lye(e){return e.host===C6[e.forge]?`${e.forge}:${e.login}`:`${e.forge}@${e.host}:${e.login}`}function I6(e,t,n=null){let i=an(e),r=_6(e);return t.active&&t.signers.some(s=>an(s.principal)===i)?{principal:e,form:"signer",forge:r}:r?{principal:e,form:"forge",forge:r}:(n?.agents??[]).some(s=>s.principals.some(a=>an(a)===i))||Em(wa(),t,e).some(s=>Mye.has(s))?{principal:e,form:"role",forge:null}:{principal:e,form:"name",forge:null}}function hs(e,t,n,i={}){if(e.declaration?.identity?.attribution==="identified"&&!(i.agent!==void 0&&i.agent!==null&&e.declaration.agents.some(r=>r.name===i.agent))){for(let r of t)if(I6(r,e.policy,e.declaration).form==="name")throw new gs(`${n} ${JSON.stringify(r)} names no identity the workspace can check: chant.workspace.json at base sets identity.attribution to identified, so a person is named by a forge identity (github:<login>, gitlab:<login>, or <forge>@<host>:<login>) or by a principal ${e.policy.signersPath} lists at base`)}}function cT(e,t){let n=e.declaration?.identity?.gates[t];if(!n)return null;let{policy:i,classes:r}=e,o={gate:t,class:n.class,signers:i,roles:Sm(i),classes:r.all()};return{requirement:n,refuses:s=>Tu(o,s)}}function Fye(e,t,n){return cT(go(e,n),t)}var O6,C6,P6,jye,Mye,Xc,gs,Qc=v(()=>{"use strict";xc();tI();mn();ms();O6=["github","gitlab","forgejo","gitea"],C6={github:"github.com",gitlab:"gitlab.com",forgejo:null,gitea:null},P6="[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?",jye=new RegExp(`^(${O6.join("|")})(?:@(${P6}(?:\\.${P6})+))?:([a-z0-9](?:[a-z0-9._-]{0,98}[a-z0-9_])?)$`);Mye=new Set(["agent","runner","service"]);Xc=["principal-unidentified"],gs=class extends Error{constructor(n){super(n);this.code="principal-unidentified";this.name="IdentityError"}}});function ys(e){return{async read(t){await oi(e);let{resolutions:n,pending:i}=await jr(t,e);return{resolutions:n,pending:i}},async approvalRule(t,n){let{gateAdmission:i}=await Promise.resolve().then(()=>(Qc(),lT));return i(e?.cwd??process.cwd(),t,n?.base)},async appendResolution(t){let{record:n}=await km(t,e);return{record:n,...await ha(e)}},async appendPending(t){let{record:n}=await pd(t,e);return{record:n,...await ha(e)}},async readApplied(t){await oi(e);let{dir:n,file:i}=Gc(t),r=await nn(n,i,e);return r?lv(r):[]},async appendApplied(t){let{dir:n,file:i}=Gc(t.op),r=JSON.stringify(t,pn),o;for(let s=1;s<=5;s++)try{let a=await xr(n,i,e),l=a?await fn(a,e):null;return await An(n,i,l?`${l.replace(/\n$/,"")}
155
+ ${r}
156
+ `:`${r}
157
+ `,`Applied under ${t.gate}`,{...e,expectPriorPathSha:a}),ha(e)}catch(a){if(!(a instanceof Vt))throw a;o=a}throw o}}}function Hv(e){return e.approver?e.approver:{kind:Yr(e.origin)?"agent":"human"}}function el(e,t,n,i,r,o=n){let s=new Date(n).getTime(),a=Math.min(s,new Date(o).getTime()),l=h=>new Date(h.timestamp).getTime(),c=r.quorum?.roles,u=$m(r.context),d=new Map,p,f;for(let h of e){if(h.gate!==t||l(h)<a)continue;if(i!==void 0&&!mt(h.planDigest,i)){l(h)>=s&&(!f||l(h)>=l(f))&&(f=h);continue}let b=h.policyDecision;l(h)>=s&&r.mode==="enforce"&&r.policy&&b?.decision==="allow"&&b.mode==="enforce"&&b.version===r.policy.version&&b.contextDigest===u&&(!p||l(h)>=l(p))&&(p=h);let x=Hv(h);if(x.kind!=="human"||c&&!(x.roles??[]).some(R=>c.includes(R)))continue;let k=d.get(h.resolvedBy);(!k||l(h)>=l(k))&&d.set(h.resolvedBy,h)}return{counted:[...d.values()].sort((h,b)=>l(h)-l(b)),need:r.quorum?.count??1,...p?{permit:p}:{},...f?{mismatched:f}:{}}}function tl(e,t){let n=a=>new Date(a.timestamp).getTime(),i=a=>a.approval?.policy?.version,r=a=>mt(a.planDigest,t.planDigest)&&i(a)===i(t),o=e.filter(a=>a!==t&&a.gate===t.gate&&a.environment===t.environment&&n(a)<=n(t)).sort((a,l)=>n(l)-n(a)),s=t;for(let a of o){if(!r(a)||Wn(a,s.timestamp))break;s=a}return s.timestamp}function Gye(e,t){return JSON.stringify(e??null,pn)===JSON.stringify(t??null,pn)}async function nl(e,t){let n=t.now??new Date().toISOString(),i=await e.read(t.op),r=t.environment,o=r===void 0?i.pending:i.pending.filter(R=>R.environment===r),s=await e.approvalRule?.(t.gate)??null,a=Cn(o,t.gate),l=a?.timestamp??Wye,c=[],u=(r===void 0?i.resolutions:i.resolutions.filter(R=>R.environment===void 0||R.environment===r)).filter(R=>t.spent===void 0||R.gate!==t.gate||!Lr(t.spent,R)).filter(R=>{if(s===null||R.gate!==t.gate)return!0;let $=s.refuses(R);return $===null?!0:(mt(R.planDigest,t.planDigest)&&new Date(R.timestamp).getTime()>=new Date(l).getTime()&&c.push({resolution:R,reason:$}),!1)});c.sort((R,$)=>new Date(R.resolution.timestamp).getTime()-new Date($.resolution.timestamp).getTime());let d,p;if(t.approval){let R=a&&mt(a.planDigest,t.planDigest)&&a.approval?.policy?.version===t.approval.policy?.version?tl(o,a):l,$=el(u,t.gate,l,t.planDigest,t.approval,R);if($.permit)return{satisfied:!0,resolution:$.permit,via:"policy",approvals:$.counted};if($.counted.length>=$.need)return{satisfied:!0,resolution:$.counted[$.counted.length-1],via:"quorum",approvals:$.counted};d=$.mismatched,p={approvers:$.counted.map(_=>_.resolvedBy),need:$.need}}else{let R=Nr(u,t.gate,l,t.planDigest);if(R.resolution)return{satisfied:!0,resolution:R.resolution};d=R.mismatched}let f=d?{...d.planDigest!==void 0?{approved:d.planDigest}:{},planned:t.planDigest,resolvedBy:d.resolvedBy,timestamp:d.timestamp,...r!==void 0?{environment:r}:{}}:void 0,g={...f?{mismatch:f}:{},...p?{quorum:p}:{},...c.length>0?{refused:c}:{}};if(a&&!Wn(a,n)&&mt(a.planDigest,t.planDigest)&&Gye(a.approval,t.approval))return{satisfied:!1,pending:a,recorded:!1,...g};let h=os(),b=ba(),{record:w,pushed:x,pushWarning:k}=await e.appendPending({...t.fields,op:t.op,gate:t.gate,timestamp:n,expiresAt:new Date(new Date(n).getTime()+Li(t.timeout??"48h")).toISOString(),...t.description?{description:t.description}:{},...t.runId?{runId:t.runId}:{},...h?{url:h}:{},...b?{resume:b}:{},...t.planDigest!==void 0?{planDigest:t.planDigest}:{},...r!==void 0?{environment:r}:{},...t.approval?{approval:t.approval}:{},...t.neverOverMcp?{neverOverMcp:!0}:{}});return{satisfied:!1,pending:w,recorded:!0,pushed:x,...k?{pushWarning:k}:{},...g}}function Dd(e,t,n,i,r=!1){return`chant approve ${e} ${t}`+(n===void 0?"":` --env ${n}`)+(i===void 0?"":` --plan ${i}`)+(r?" --sign":"")}var Wye,Fi=v(()=>{"use strict";ji();On();kc();Wc();Wt();Rm();$t();as();gd();Wye=new Date(0).toISOString()});function uT(e,t,n){return(e??Vv).replaceAll("{gate}",t).replaceAll("{k}",String(n))}function dT(e,t,n,i){let r=[...e].sort((c,u)=>{let d=i(c),p=i(u);return d<p?-1:d>p?1:0}),o=Math.floor(r.length/n),s=r.length%n,a=(t-1)*o+Math.min(t-1,s),l=o+(t<=s?1:0);return r.slice(a,a+l)}var Vv,pT=v(()=>{"use strict";Vv="{gate}-wave-{k}"});function T6(e){let t=e.filter(n=>n.provisional!==!0).map(n=>({member:n.member,planDigest:n.planDigest})).sort((n,i)=>zye(n.member,i.member));for(let n=1;n<t.length;n++)if(t[n-1].member===t[n].member)throw new Error(`the change set names member ${t[n].member} twice`);return ud("change-set",t)}var zye,fT=v(()=>{"use strict";On();zye=(e,t)=>e<t?-1:e>t?1:0});function gT(e){let t=e.filter(n=>n.provisional===!0).map(n=>n.member);if(t.length>0)throw new mT([...new Set(t)].sort());return T6(e)}function hT(e,t={}){let n=t.over==="changing"?e.filter(i=>i.empty!==!0):[];return[...n.length>0?n:e,...t.extras??[]]}var mT,yT=v(()=>{"use strict";fT();mT=class extends Error{constructor(n){super(`a wave cannot be gated on a provisional plan: ${n.join(", ")} planned before what it reads applied. Plan it again in its own wave, after its upstream applied`);this.members=n;this.name="ProvisionalWaveMemberError"}}});import{dirname as Uye}from"node:path";import{mkdirSync as Hye,renameSync as Vye,writeFileSync as qye}from"node:fs";function D6(e,t){return nl(e,{op:t.op,gate:t.gate,planDigest:t.digest,description:t.description,...t.timeout?{timeout:t.timeout}:{},...t.now!==void 0?{now:t.now}:{},...t.spent?{spent:t.spent}:{},...t.fields?{fields:t.fields}:{},...t.neverOverMcp?{neverOverMcp:!0}:{}})}function N6(e,t){Hye(Uye(e),{recursive:!0});let n=`${e}.${process.pid}.tmp`;qye(n,JSON.stringify(t,null,2)+`
158
+ `),Vye(n,e)}var j6=v(()=>{"use strict";Fi();pT();yT()});function Nd(e=process.env){let t=e.CI?.trim().toLowerCase();return t&&t!=="false"&&t!=="0"?"ledger":void 0}function qv(e){if(e!==void 0)return typeof e=="string"?{name:e}:e}function rl(e,t=!1){let n=[];t&&n.push("a gate that asks a decision point takes its quorum from the point: give `approval` or `point`, not both");let i=typeof e=="string"?{name:e}:e;if(i===null||typeof i!="object"||Array.isArray(i))return[...n,"`point` is a decision point's name or { name, inputs?, pass?, store? }"];let{name:r,inputs:o,pass:s,store:a,...l}=i;if((typeof r!="string"||!Kye.test(r))&&n.push("`point.name` is a decision point's name: lower case letters, digits and hyphens, starting with a letter"),o!==void 0&&(o===null||typeof o!="object"||Array.isArray(o))&&n.push("`point.inputs` is an object of input name to value"),o&&typeof o=="object"){let u=Object.keys(o).filter(d=>d in Um);u.length>0&&n.push(`\`point.inputs\` gives ${u.join(", ")}, which the gate passes itself`)}s!==void 0&&(!Array.isArray(s)||s.length===0||s.some(u=>typeof u!="string"&&typeof u!="boolean"))&&n.push("`point.pass` is a non-empty list of the answers that pass the gate"),a!==void 0&&a!=="tree"&&a!=="ledger"&&n.push("`point.store` is tree or ledger: where the question is held");let c=Object.keys(l);return c.length>0&&n.push(`\`point\` takes name, inputs, pass and store, not ${c.join(", ")}`),n}function il(e,t,n,i={}){if(n.planDigest!==null&&!t.includes("gate.planDigest"))throw new Error(`gate "${n.name}" binds a plan and asks decision point ${e}, which does not declare the input gate.planDigest: declare it in the points file, so each plan is its own question and an answer for one plan never passes another`);let r={};for(let[o,s]of Object.entries(Um))t.includes(o)&&n[s]!==null&&(r[o]=n[s]);return{...i,...r}}function Hm(e,t,n){return`gate:${e}/${t}${n?`@${n}`:""}`}function Kv(e){if(!e||!e.startsWith("gate:"))return;let t=e.slice(5),n=t.lastIndexOf("@"),i=n>0?t.slice(0,n):t,r=i.indexOf("/");if(!(r<=0||r===i.length-1))return{op:i.slice(0,r),gate:i.slice(r+1),...n>0?{env:t.slice(n+1)}:{}}}var jd,Kye,Um,bs=v(()=>{"use strict";jd=[!0];Kye=/^[a-z][a-z0-9-]*$/;Um={"gate.component":"component","gate.name":"name","gate.env":"env","gate.planDigest":"planDigest"}});function Jye(e){if(e!==void 0)return typeof e=="string"?{name:e}:e}function Jv(e){if(e!==null&&typeof e=="object"&&!Array.isArray(e)&&"timeout"in e){let{timeout:t,...n}=e,i=rl(n);return(typeof t!="string"||!/^(\d+(ms|s|m|h|d))+$/.test(t))&&i.push('`point.timeout` is a duration such as "48h"'),i}return rl(e)}function wT(e,t){let n=e.waves.find(i=>i.name===t);return Jye(n?.point??e.point)}function vT(e,t){return uT(e.gateName,e.gate??e.name,t)}function Yv(e,t){return`.chant/op-waves/${e.name}/wave-${t}.json`}function Km(e){let t=`Op waves "${e.name}"`;if(!M6.test(e.name))throw new Error(`${t}: the name must be lowercase letters, digits, "-" and "_"`);if(!e.op)throw new Error(`${t} names no \`op\`. Name the Op a run runs when it names none.`);if(e.plan!==void 0&&e.planWave!==void 0)throw new Error(`${t} has both \`plan\` and \`planWave\`. A wave is planned one run at a time or all at once; give one.`);if(e.apply!==void 0&&e.applyWave!==void 0)throw new Error(`${t} has both \`apply\` and \`applyWave\`. A wave is applied one run at a time or all at once; give one.`);if(e.planWave!==void 0){if(Vm(t,"planWave",e.planWave),!e.planWave.some(i=>i.includes("{plans}")))throw new Error(`${t}: the \`planWave\` command never names {plans}, the file it writes each run's plan digest to.`)}else{if(!Array.isArray(e.plan)||e.plan.length===0)throw new Error(`${t} has no \`plan\` command. Each wave plans its runs to bind its gate to their plan digests; give \`plan\` or \`planWave\`.`);if(Vm(t,"plan",e.plan),!e.plan.some(i=>i.includes("{plan}")))throw new Error(`${t}: the \`plan\` command never names {plan}, the file it writes the plan digest to.`)}if(e.apply!==void 0&&Vm(t,"apply",e.apply),e.applyWave!==void 0&&(Vm(t,"applyWave",e.applyWave),!e.applyWave.some(i=>i.includes("{runs}"))))throw new Error(`${t}: the \`applyWave\` command never names {runs}, the file listing the approved runs it applies.`);if(Ld(t,e.hooks),e.waves.length===0)throw new Error(`${t} has no waves.`);if(e.resume!==void 0&&(typeof e.resume.schedule!="string"||e.resume.schedule.trim().split(/\s+/).length!==5))throw new Error(`${t}: resume.schedule must be a five-field cron expression, such as "*/10 * * * *".`);if(e.approvals!==void 0){let i=e.approvals;if(i===null||typeof i!="object"||Array.isArray(i))throw new Error(`${t}: \`approvals\` must be { "spend"?: true | false }.`);for(let[r,o]of Object.entries(i)){if(r!=="spend")throw new Error(`${t}: approvals.${r} is not a setting; the one there is approvals.spend.`);if(typeof o!="boolean")throw new Error(`${t}: approvals.spend must be true or false.`)}}if(e.gateName!==void 0){if(typeof e.gateName!="string"||!e.gateName.includes("{k}")||/\s/.test(e.gateName))throw new Error(`${t}: gateName must be a pattern with {k}, the wave's number, and no spaces, such as "${F6}" or "wave-{k}".`);let i=e.gateName.replaceAll("{gate}","").replaceAll("{k}","").match(/\{[^}]*\}/);if(i)throw new Error(`${t}: gateName names ${i[0]}; the pattern fills in {gate} and {k} only.`)}if(e.digest!==void 0){let i=e.digest;if(i===null||typeof i!="object"||Array.isArray(i))throw new Error(`${t}: \`digest\` must be { "over"?: "all" | "changing" }.`);for(let[r,o]of Object.entries(i)){if(r!=="over")throw new Error(`${t}: digest.${r} is not a setting; the one there is digest.over.`);if(!Zye.includes(o))throw new Error(`${t}: digest.over is ${JSON.stringify(o)}; use "all" or "changing".`)}}if(e.override!==void 0){let i=e.override;if(i===null||typeof i!="object"||Array.isArray(i))throw new Error(`${t}: \`override\` must be { "overriders"?: "<file at base>" }.`);for(let[r,o]of Object.entries(i)){if(r!=="overriders")throw new Error(`${t}: override.${r} is not a setting; the one there is override.overriders.`);if(typeof o!="string"||o.trim()==="")throw new Error(`${t}: override.overriders must be a path, such as ".chant/overriders".`)}}if(e.point!==void 0){let i=Jv(e.point);if(i.length>0)throw new Error(`${t}: ${i.join("; ")}.`)}if(e.neverOverMcp!==void 0&&typeof e.neverOverMcp!="boolean")throw new Error(`${t}: neverOverMcp must be true or false.`);if(e.notify!==void 0){let i=ow(e.notify,"notify");if(i)throw new Error(`${t}: ${i}`)}let n=new Set;for(let i of e.waves){if(!M6.test(i.name))throw new Error(`${t}: wave "${i.name}" must be named with lowercase letters, digits, "-" and "_"`);if(n.has(i.name))throw new Error(`${t} names wave "${i.name}" twice.`);if(n.add(i.name),i.gate!==void 0&&!qm.includes(i.gate))throw new Error(`${t}: wave "${i.name}" has gate "${i.gate}"; use ${qm.join(", ")}.`);if(i.approval!==void 0&&!Ca.includes(i.approval))throw new Error(`${t}: wave "${i.name}" has approval "${i.approval}"; use ${Ca.join(", ")}.`);if(Ld(`${t}, wave "${i.name}"`,i.hooks),i.point!==void 0){let s=Jv(i.point);if(s.length>0)throw new Error(`${t}: wave "${i.name}": ${s.join("; ")}.`)}if(i.discover!==void 0&&typeof i.discover!="boolean")throw new Error(`${t}: wave "${i.name}" has discover ${JSON.stringify(i.discover)}; use true or false.`);if(i.rest!==void 0&&typeof i.rest!="boolean")throw new Error(`${t}: wave "${i.name}" has rest ${JSON.stringify(i.rest)}; use true or false.`);if(i.discover){if(e.planWave===void 0)throw new Error(`${t}: wave "${i.name}" discovers its runs, which only \`planWave\` can report. Give planWave.`);if((i.runs??[]).length>0)throw new Error(`${t}: wave "${i.name}" discovers its runs, so it lists none.`)}if(i.rest){if(!i.discover)throw new Error(`${t}: wave "${i.name}" has rest, which follows the waves planWave discovers; set discover too.`);if(i!==e.waves[e.waves.length-1])throw new Error(`${t}: wave "${i.name}" has rest, which only the last wave can have.`);if((i.shares??1)>1)throw new Error(`${t}: wave "${i.name}" has rest and shares; the waves after it run in its one job, so it cannot be split.`)}if(i.discover){let s=i.shares??1;if(!Number.isInteger(s)||s<1)throw new Error(`${t}: wave "${i.name}" has shares ${i.shares}; use a whole number from 1.`);continue}if(!Array.isArray(i.runs)||i.runs.length===0)throw new Error(`${t}: wave "${i.name}" has no runs.`);let r=new Set;for(let s of i.runs){if(!s.target)throw new Error(`${t}: wave "${i.name}" has a run with no target.`);if(r.has(s.target))throw new Error(`${t}: wave "${i.name}" names target "${s.target}" twice.`);r.add(s.target)}let o=i.shares??1;if(!Number.isInteger(o)||o<1)throw new Error(`${t}: wave "${i.name}" has shares ${i.shares}; use a whole number from 1.`);if(o>i.runs.length)throw new Error(`${t}: wave "${i.name}" has ${o} shares for ${i.runs.length} runs, so a share would apply nothing.`)}}function Vm(e,t,n){if(!Array.isArray(n)||n.length===0||!n.every(i=>typeof i=="string")||n[0]==="")throw new Error(`${e}: \`${t}\` must be a command as argv, a non-empty array of strings.`)}function Ld(e,t){if(t!==void 0){if(t===null||typeof t!="object"||Array.isArray(t))throw new Error(`${e}: \`hooks\` must be { "before"?: { "plan"?, "apply"? }, "after"?: { "plan"?, "apply"? } }.`);for(let[n,i]of Object.entries(t)){if(n==="apply"){let r=i?.runBy;if(i===null||typeof i!="object"||Array.isArray(i)||Object.keys(i).some(o=>o!=="runBy"))throw new Error(`${e}: hooks.apply must be { "runBy"?: "chant" | "apply" }.`);if(r!==void 0&&!bT.includes(r))throw new Error(`${e}: hooks.apply.runBy is ${JSON.stringify(r)}; use ${bT.map(o=>`"${o}"`).join(" or ")}.`);continue}if(n!=="before"&&n!=="after")throw new Error(`${e}: hooks.${n} is not a moment; use hooks.before or hooks.after (or hooks.apply.runBy).`);if(i===null||typeof i!="object"||Array.isArray(i))throw new Error(`${e}: hooks.${n} must be { "plan"?: [...], "apply"?: [...] }.`);for(let[r,o]of Object.entries(i)){let s=`hooks.${n}.${r}`;if(r==="gate"&&n==="before")throw new Error(`${e}: ${s} is not a moment; a hook runs after the gate (hooks.after.gate), or before the plan or the apply.`);if(r!=="plan"&&r!=="apply"&&r!=="gate")throw new Error(`${e}: ${s} is not a stage; a hook runs before or after plan or apply, or after the gate.`);if(!Array.isArray(o))throw new Error(`${e}: ${s} must be a list of hooks.`);o.forEach((a,l)=>{let c=`${s}[${l}]${a&&typeof a=="object"&&typeof a.name=="string"?` (${a.name})`:""}`;if(!a||typeof a!="object")throw new Error(`${e}: ${c} must be { "command": [...], "onFailure"?, "perRun"? }.`);if(Vm(e,`${c}.command`,a.command),a.onFailure!==void 0&&!L6.includes(a.onFailure))throw new Error(`${e}: ${c} has onFailure "${a.onFailure}"; use ${L6.join(" or ")}.`);if(a.onFailure==="approve"&&n==="after"&&r==="apply")throw new Error(`${e}: ${c} has onFailure "approve", but after the apply there is nothing left to hold. Use "fail".`);if(a.onFailure==="approve"&&r==="gate")throw new Error(`${e}: ${c} has onFailure "approve", but the gate has already decided when it runs. Use "fail", or hold the wave from an after.plan hook.`);if(a.perRun!==void 0&&typeof a.perRun!="boolean")throw new Error(`${e}: ${c}.perRun must be true or false.`);if(a.perRun){if(n==="before"&&r==="plan"&&a.command.some(u=>u.includes("{plan}")))throw new Error(`${e}: ${c} runs before the plan, so it has no {plan} yet.`)}else{let u=a.command.find(d=>d.includes("{target}")||d.includes("{plan}"));if(u)throw new Error(`${e}: ${c} runs once for the wave, so it has no {target} or {plan} ("${u}"). Set "perRun": true, or read the runs from {runs}.`)}})}}}}function Xv(e,t){let n=e.waves.find(r=>r.name===t),i=(r,o)=>{let[s,a]=o.split("-");return r?.[s]?.[a]??[]};return Object.fromEntries(Zv.map(r=>[r,[...i(e.hooks,r),...i(n?.hooks,r)]]))}function Qv(e,t){return e.waves.find(i=>i.name===t)?.hooks?.apply?.runBy??e.hooks?.apply?.runBy??"chant"}function xT(e,t,n){return dT(e,t,n,i=>i.target)}var qm,Ca,L6,Zv,bT,Zye,F6,kT,M6,Md=v(()=>{"use strict";bs();sw();pT();sw();qm=["always","on-destructive","never"],Ca=["ledger","pr-review","sealed"];L6=["fail","approve"],Zv=["before-plan","after-plan","after-gate","before-apply","after-apply"],bT=["chant","apply"],Zye=["all","changing"],F6=Vv;kT=["chant","run","{op}","--env","{target}"];M6=/^[a-z0-9][a-z0-9_-]*$/});import{readFileSync as Yye}from"node:fs";function z6(e,t){let n=Qye[e==="gitlab"?"gitlab":"github"][t];if(n===void 0)throw new Error(`a commit status state is one of ${Xye.join(", ")}, not ${JSON.stringify(t)}`);return n}function U6(e){if(e instanceof rr&&ebe.has(e.status)){let t=e.detail;try{let n=JSON.parse(e.detail),i=n.message??n.error;typeof i=="string"&&(t=i)}catch{}return{merged:!1,reason:t.slice(0,300)||`the forge refused the merge (${e.status})`}}throw e}function Zm(e,t,n){let i=t.toLowerCase(),r=n.toLowerCase();return i===tbe[e]?`${e}:${r}`:`${e}@${i}:${r}`}function H6(e,t,n){let i=e.replace(/\/+$/,""),r=async(o,s,a)=>{let l=`${i}${s}`,c=await n(l,{method:o,headers:{...t,...a!==void 0?{"Content-Type":"application/json"}:{}},...a!==void 0?{body:JSON.stringify(a)}:{}}),u=await c.text();if(!c.ok)throw new rr(o,l,c.status,u);return u?JSON.parse(u):null};return{call:r,async list(o,s,a){let l=[];for(let c=1;c<=50;c++){let u=o.includes("?")?"&":"?",d=await r("GET",`${o}${u}${s(c)}`);if(!Array.isArray(d)||(l.push(...d),d.length<a))break}return l}}}function q6(e,t,n,i){if(!t)throw new Error(`the ${e} needs a marker to be found again`);if(!V6(n,t,i))throw new Error(`the ${e} body ${i==="anywhere"?"does not carry":"does not start with"} its marker ${JSON.stringify(t)}, so the next run could not find it`)}async function K6(e,t,n,i){if(!n)throw new Error("the comment needs a marker to be found");return(await e.comments(t)).filter($T(n,i)).sort((r,o)=>r.id-o.id)[0]}async function G6(e,t,n,i,r,o){o&&q6("comment",n,i,r.match);let s=await K6(e,t,n,r);if(!s){let c=await e.addComment(t,i);return{action:"created",id:c?.id??0,...c?.url?{url:c.url}:{}}}if(s.body===i)return{action:"unchanged",id:s.id,...s.url?{url:s.url}:{}};let l=(await e.editComment(t,s.id,i))?.url??s.url;return{action:"updated",id:s.id,...l?{url:l}:{}}}async function W6(e,t,n,i,r){n&&r&&q6("issue",t,n.body,i.match);let o=(await e.openIssues(t)).filter($T(t,i)).sort((l,c)=>l.id-c.id)[0],s=l=>l?{number:l.id,...l.url?{url:l.url}:{},...l.created?{created:l.created}:{}}:{};if(n===null)return o?i.closeOnClear?(await e.closeIssue(o.id,i.clearComment),{action:"closed",...s(o)}):{action:"left",...s(o)}:{action:"none"};if(!o)return{action:"opened",...s(await e.openIssue(n.title,n.body))};if(rbe({title:o.title??"",body:o.body},n,i.sameWhen))return{action:"unchanged",...s(o)};let a=await e.editIssue(o.id,n.title,n.body);return{action:"updated",...s(o),...a?.url?{url:a.url}:{}}}function rbe(e,t,n){return typeof n=="function"?n(e,t):e.title!==t.title?!1:typeof n=="string"&&n!==""?e.body.includes(n):e.body===t.body}function J6(e){return{async addComment(t,n){let i=await e.addComment(t,n);return{id:i?.id??0,...i?.url?{url:i.url}:{}}},async findIssue(t,n={}){if(!t)throw new Error("the issue needs a marker to be found");let i=(await e.openIssues(t)).filter($T(t,n)).sort((r,o)=>r.id-o.id)[0];return i?{number:i.id,title:i.title??"",body:i.body,...i.created?{created:i.created}:{},...i.url?{url:i.url}:{}}:void 0},async findComment(t,n,i={}){let r=await K6(e,t,n,i);return r?{id:r.id,body:r.body,...r.url?{url:r.url}:{}}:void 0},upsertComment:(t,n,i,r={})=>G6(e,t,n,i,r,!0),upsertNote:async(t,n,i)=>(await G6(e,t,n,i,{},!1)).url,trackIssue:(t,n,i={})=>W6(e,t,n,i,!0),upsertIssue:async(t,n,i)=>(await W6(e,t,{title:n,body:i},{},!1)).url}}function Z6(e,t){let n=(t.host??"github.com").toLowerCase(),i=H6(t.apiBase,e==="github"?{...t.token?{Authorization:`Bearer ${t.token}`}:{},Accept:"application/vnd.github+json"}:{...t.token?{Authorization:`token ${t.token}`}:{},Accept:"application/json"},t.fetch??globalThis.fetch),r=`/repos/${t.repo}`,o=e==="github"?100:50,s=p=>e==="github"?`per_page=100&page=${p}`:`limit=50&page=${p}`,a=p=>{if(!qe(p))return;let f=ho(p.number)??ho(p.id);if(f===void 0)return;let g=B6(p),h=ut(p.html_url),b=ut(p.created_at);return{id:f,body:ut(p.body)??"",...b?{created:b}:{},...ut(p.title)!==void 0?{title:ut(p.title)}:{},...g?{author:g}:{},...h?{url:h}:{}}},l=p=>p.map(a).filter(f=>f!==void 0),c=p=>{if(!qe(p))return;let f=ho(p.number),g=qe(p.head)?ut(p.head.ref):void 0;if(f===void 0)return;let h=qe(p.base)?ut(p.base.ref):void 0,b=ut(p.html_url);return{number:f,title:ut(p.title)??"",body:ut(p.body)??"",head:g??"",...h?{base:h}:{},...b?{url:b}:{}}},u=(p,f)=>{if(!qe(p)||!qe(p.head)||p.head.ref!==f)return!1;let g=qe(p.head.repo)?ut(p.head.repo.full_name):void 0;return g===void 0||g.toLowerCase()===t.repo.toLowerCase()},d={comments:async p=>l(await i.list(`${r}/issues/${p}/comments`,s,o)),addComment:async(p,f)=>a(await i.call("POST",`${r}/issues/${p}/comments`,{body:f})),editComment:async(p,f,g)=>a(await i.call("PATCH",`${r}/issues/comments/${f}`,{body:g})),openIssues:async()=>l((await i.list(`${r}/issues?state=open`,s,o)).filter(p=>qe(p)&&!qe(p.pull_request))),openIssue:async(p,f)=>a(await i.call("POST",`${r}/issues`,{title:p,body:f})),editIssue:async(p,f,g)=>a(await i.call("PATCH",`${r}/issues/${p}`,{title:f,body:g})),async closeIssue(p,f){f&&await i.call("POST",`${r}/issues/${p}/comments`,{body:f}),await i.call("PATCH",`${r}/issues/${p}`,{state:"closed"})}};return{kind:e,host:n,...t.runUrl?{runUrl:t.runUrl}:{},principalOf:p=>Zm(e,n,p),...J6(d),async setStatus(p,f){await i.call("POST",`${r}/statuses/${p}`,{state:z6(e,f.state),context:f.context,description:f.description.slice(0,ibe),...f.url?{target_url:f.url}:{}})},async approvers(p){let f=await i.list(`${r}/pulls/${p}/reviews`,s,o),g=new Map;for(let h of f){let b=B6(h);if(!b||!qe(h)||typeof h.state!="string")continue;let w=h.dismissed===!0?"DISMISSED":h.state.toUpperCase();w==="COMMENTED"||w==="COMMENT"||w==="PENDING"||g.set(b,w)}return[...g].filter(([,h])=>h==="APPROVED").map(([h])=>h).sort()},async pullRequestFor(p){if(e==="forgejo")try{let w=await i.call("GET",`${r}/commits/${p}/pull`);return qe(w)&&typeof w.number=="number"?w.number:null}catch(w){if(w instanceof rr&&w.status===404)return null;throw w}let f=await i.call("GET",`${r}/commits/${p}/pulls`);if(!Array.isArray(f))return null;let g=f.filter(w=>qe(w)&&w.merged_at),b=g.find(w=>qe(w)&&w.merge_commit_sha===p)??g[0];return b&&typeof b.number=="number"?b.number:null},async openPullRequest(p){let f=p.base??await Y6(i,r,"default_branch"),g=p.draft&&e==="forgejo"?`WIP: ${p.title}`:p.title,h=await i.call("POST",`${r}/pulls`,{title:g,body:p.body,head:p.head,base:f,...p.draft&&e==="github"?{draft:!0}:{}});return c(h)??{number:0,title:g,body:p.body,head:p.head,base:f}},async findPullRequest(p){let f=t.repo.split("/")[0],g=e==="github"?`?state=open&head=${encodeURIComponent(`${f}:${p}`)}`:"?state=open",h;try{h=await i.list(`${r}/pulls${g}`,s,o)}catch(w){if(e!=="forgejo"||!(w instanceof rr)||w.status!==404)throw w;await i.call("GET",r);return}return h.filter(w=>u(w,p)).map(c).filter(w=>w!==void 0).sort((w,x)=>w.number-x.number)[0]},async editPullRequest(p,f){return c(await i.call("PATCH",`${r}/pulls/${p}`,{...f.title!==void 0?{title:f.title}:{},...f.body!==void 0?{body:f.body}:{}}))},async addLabels(p,f){f.length!==0&&await i.call("POST",`${r}/issues/${p}/labels`,{labels:[...f]})},async mergePullRequest(p,f){let g=f.method??"merge",h;try{h=e==="github"?await i.call("PUT",`${r}/pulls/${p}/merge`,{sha:f.sha,merge_method:g,...f.title!==void 0?{commit_title:f.title}:{},...f.message!==void 0?{commit_message:f.message}:{}}):await i.call("POST",`${r}/pulls/${p}/merge`,{Do:g,head_commit_id:f.sha,...f.title!==void 0?{MergeTitleField:f.title}:{},...f.message!==void 0?{MergeMessageField:f.message}:{},...f.deleteBranch?{delete_branch_after_merge:!0}:{}})}catch(x){return U6(x)}if(qe(h)&&h.merged===!1)return{merged:!1,reason:ut(h.message)??"the forge did not merge it"};let b=await i.call("GET",`${r}/pulls/${p}`).catch(()=>{}),w=(qe(h)?ut(h.sha):void 0)??(qe(b)?ut(b.merge_commit_sha):void 0);if(e==="github"&&f.deleteBranch&&qe(b)&&qe(b.head)&&ut(b.head.ref)&&u(b,ut(b.head.ref))){let x=ut(b.head.ref).split("/").map(encodeURIComponent).join("/");await i.call("DELETE",`${r}/git/refs/heads/${x}`).catch(()=>{})}return{merged:!0,...w?{sha:w}:{}}}}}async function Y6(e,t,n){let i=await e.call("GET",t),r=qe(i)?ut(i[n]):void 0;if(!r)throw new Error(`${t} names no default branch to open the pull request against; pass base`);return r}function RT(e){return Z6("github",e)}function ST(e){return Z6("forgejo",e)}function sbe(e){let t=(e.host??"gitlab.com").toLowerCase(),n=H6(e.apiBase,e.token?{[e.tokenHeader??"PRIVATE-TOKEN"]:e.token}:{},e.fetch??globalThis.fetch),i=`/projects/${encodeURIComponent(decodeURIComponent(e.project))}`,r=d=>`per_page=100&page=${d}`,o=d=>qe(d.author)?ut(d.author.username):void 0,s=d=>{if(!qe(d))return;let p=ho(d.id);if(p===void 0)return;let f=o(d);return{id:p,body:ut(d.body)??"",...f?{author:f}:{}}},a=d=>{if(!qe(d))return;let p=ho(d.iid);if(p===void 0)return;let f=o(d),g=ut(d.web_url),h=ut(d.created_at);return{id:p,body:ut(d.description)??"",...h?{created:h}:{},...ut(d.title)!==void 0?{title:ut(d.title)}:{},...f?{author:f}:{},...g?{url:g}:{}}},l=`${i}/merge_requests`,c=d=>{if(!qe(d))return;let p=ho(d.iid);if(p===void 0)return;let f=ut(d.target_branch),g=ut(d.web_url);return{number:p,title:ut(d.title)??"",body:ut(d.description)??"",head:ut(d.source_branch)??"",...f?{base:f}:{},...g?{url:g}:{}}},u={comments:async d=>(await n.list(`${l}/${d}/notes`,r,100)).filter(p=>!(qe(p)&&p.system===!0)).map(s).filter(p=>p!==void 0),addComment:async(d,p)=>s(await n.call("POST",`${l}/${d}/notes`,{body:p})),editComment:async(d,p,f)=>s(await n.call("PUT",`${l}/${d}/notes/${p}`,{body:f})),openIssues:async d=>(await n.list(`${i}/issues?state=opened&search=${encodeURIComponent(d)}&in=description`,r,100)).map(a).filter(p=>p!==void 0),openIssue:async(d,p)=>a(await n.call("POST",`${i}/issues`,{title:d,description:p})),editIssue:async(d,p,f)=>a(await n.call("PUT",`${i}/issues/${d}`,{title:p,description:f})),async closeIssue(d,p){p&&await n.call("POST",`${i}/issues/${d}/notes`,{body:p}),await n.call("PUT",`${i}/issues/${d}`,{state_event:"close"})}};return{kind:"gitlab",host:t,...e.runUrl?{runUrl:e.runUrl}:{},principalOf:d=>Zm("gitlab",t,d),...J6(u),async setStatus(d,p){try{await n.call("POST",`${i}/statuses/${d}`,{state:z6("gitlab",p.state),name:p.context,description:p.description.slice(0,obe),...p.url?{target_url:p.url}:{},...p.pipelineId!==void 0?{pipeline_id:p.pipelineId}:{}})}catch(f){if(f instanceof rr&&f.status===400&&/cannot transition status/i.test(f.message))return;throw f}},async approvers(d){let p=await n.call("GET",`${i}/merge_requests/${d}/approvals`),g=(qe(p)&&Array.isArray(p.approved_by)?p.approved_by:[]).map(h=>qe(h)&&qe(h.user)&&typeof h.user.username=="string"?h.user.username:void 0).filter(h=>h!==void 0);return[...new Set(g)].sort()},async pullRequestFor(d){let p=await n.call("GET",`${i}/repository/commits/${d}/merge_requests`);if(!Array.isArray(p))return null;let f=p.find(g=>qe(g)&&g.state==="merged"&&(g.merge_commit_sha===d||g.squash_commit_sha===d))??p.find(g=>qe(g)&&g.state==="merged");return qe(f)&&typeof f.iid=="number"?f.iid:null},async openPullRequest(d){let p=d.base??await Y6(n,i,"default_branch"),f=d.draft?`Draft: ${d.title}`:d.title,g=await n.call("POST",l,{source_branch:d.head,target_branch:p,title:f,description:d.body});return c(g)??{number:0,title:f,body:d.body,head:d.head,base:p}},async findPullRequest(d){return(await n.list(`${l}?state=opened&source_branch=${encodeURIComponent(d)}`,r,100)).filter(f=>qe(f)&&f.source_branch===d&&(f.source_project_id===void 0||f.source_project_id===f.project_id)).map(c).filter(f=>f!==void 0).sort((f,g)=>f.number-g.number)[0]},async editPullRequest(d,p){return c(await n.call("PUT",`${l}/${d}`,{...p.title!==void 0?{title:p.title}:{},...p.body!==void 0?{description:p.body}:{}}))},async addLabels(d,p){p.length!==0&&await n.call("PUT",`${l}/${d}`,{add_labels:p.join(",")})},async mergePullRequest(d,p){let f=p.method??"merge";if(f==="rebase")throw new Error("GitLab has no one-call rebase merge; use method merge or squash");let g=p.title!==void 0?p.message?`${p.title}
159
+
160
+ ${p.message}`:p.title:p.message,h;try{h=await n.call("PUT",`${l}/${d}/merge`,{sha:p.sha,...f==="squash"?{squash:!0,...g!==void 0?{squash_commit_message:g}:{}}:{},...g!==void 0?{merge_commit_message:g}:{},...p.deleteBranch?{should_remove_source_branch:!0}:{}})}catch(w){return U6(w)}let b=qe(h)?ut(h.merge_commit_sha)??ut(h.squash_commit_sha):void 0;return qe(h)&&h.state!==void 0&&h.state!=="merged"?{merged:!1,reason:`the merge request is ${String(h.state)}`}:{merged:!0,...b?{sha:b}:{}}}}}function Ym(e=process.env){if(tk(e.GITLAB_CI))return"gitlab";if(tk(e.FORGEJO_ACTIONS)||tk(e.GITEA_ACTIONS))return"forgejo";if(tk(e.GITHUB_ACTIONS))return/\/api\/v1\/?$/.test(e.GITHUB_API_URL??"")?"forgejo":"github"}function abe(e,t){let n={};if(qe(e)){let i=qe(e.pull_request)?e.pull_request:void 0,r=qe(e.issue)?e.issue:void 0,o=ho(i?.number)??(r&&qe(r.pull_request)?ho(r.number):void 0)??(i?ho(e.number):void 0);o!==void 0&&o>0&&(n.pr=o);let s=i&&qe(i.head)?ut(i.head.sha):void 0;s&&(n.sha=s)}if(n.pr===void 0){let i=/^refs\/pull\/(\d+)\/(?:merge|head)$/.exec(t??"");i&&(n.pr=Number(i[1]))}return n}function X6(e=process.env,t={}){let n=t.kind??Ym(e);if(!n)throw new Jm(void 0,[]);let i=(...$)=>$.map(_=>e[_]?.trim()).find(_=>_!==void 0&&_!==""),r=t.tokenEnv?[t.tokenEnv]:ET[n],o=r.find($=>e[$]?.trim()),s=o?e[o].trim():void 0,a=[],l=`a token (${r.join(", ")})`;if(n==="gitlab"){let $=i("CI_SERVER_URL")?.replace(/\/+$/,""),_=i("CI_API_V4_URL")?.replace(/\/+$/,"")??($?`${$}/api/v4`:void 0),T=i("CI_MERGE_REQUEST_PROJECT_ID","CI_PROJECT_ID","CI_MERGE_REQUEST_PROJECT_PATH","CI_PROJECT_PATH"),C=ho(i("CI_MERGE_REQUEST_IID"));if(_||a.push("CI_API_V4_URL"),T||a.push("CI_PROJECT_ID"),t.requirePr&&!C&&a.push("CI_MERGE_REQUEST_IID (a merge request pipeline)"),s||a.push(l),a.length>0)throw new Jm(n,a);let K=i("CI_MERGE_REQUEST_SOURCE_BRANCH_SHA","CI_COMMIT_SHA"),O=i("CI_PIPELINE_URL");return{kind:n,apiBase:_,repo:T,host:i("CI_SERVER_HOST")?.toLowerCase()??ek($)??ek(_)??"gitlab.com",token:s,tokenSource:o,tokenHeader:o==="CI_JOB_TOKEN"?"JOB-TOKEN":"PRIVATE-TOKEN",...C?{pr:C}:{},...K?{sha:K}:{},...O?{runUrl:O}:{}}}let c=n==="forgejo",u=$=>c?i(`FORGEJO_${$}`,`GITHUB_${$}`):i(`GITHUB_${$}`),d=u("REPOSITORY"),p=u("SERVER_URL")?.replace(/\/+$/,""),f=u("API_URL")?.replace(/\/+$/,"")??(c?p?`${p}/api/v1`:void 0:"https://api.github.com"),g,h=u("EVENT_PATH");if(h)try{g=JSON.parse((t.readFile??($=>Yye($,"utf8")))(h))}catch{g=void 0}let{pr:b,sha:w}=abe(g,u("REF"));if(d||a.push(c?"FORGEJO_REPOSITORY or GITHUB_REPOSITORY":"GITHUB_REPOSITORY"),f||a.push("GITHUB_SERVER_URL or GITHUB_API_URL"),t.requirePr&&!b&&a.push("a pull request (a pull_request event, or refs/pull/<n>/ in GITHUB_REF)"),s||a.push(l),a.length>0)throw new Jm(n,a);let x=w??u("SHA"),k=u("RUN_ID"),R=p&&k?`${p}/${d}/actions/runs/${k}`:void 0;return{kind:n,apiBase:f,repo:d,host:ek(p)??(c?ek(f):"github.com"),token:s,tokenSource:o,...b?{pr:b}:{},...x?{sha:x}:{},...R?{runUrl:R}:{}}}function Q6(e,t){let n=t?{fetch:t}:{},i=e.runUrl?{runUrl:e.runUrl}:{};if(e.kind==="gitlab")return sbe({apiBase:e.apiBase,project:e.repo,token:e.token,host:e.host,...e.tokenHeader?{tokenHeader:e.tokenHeader}:{},...i,...n});let r={apiBase:e.apiBase,repo:e.repo,token:e.token,host:e.host,...i,...n};return e.kind==="forgejo"?ST(r):RT(r)}var Xye,Qye,ebe,rr,tbe,qe,B6,ut,ho,V6,nbe,$T,ibe,obe,Jm,ek,tk,ET,Xm=v(()=>{"use strict";Xye=["pending","running","success","failed","failure","canceled","error"],Qye={github:{pending:"pending",running:"pending",success:"success",failed:"failure",failure:"failure",canceled:"error",error:"error"},gitlab:{pending:"pending",running:"running",success:"success",failed:"failed",failure:"failed",canceled:"canceled",error:"failed"}};ebe=new Set([405,406,409,422]);rr=class extends Error{constructor(n,i,r,o){super(`${n} ${i} answered ${r}${o?`: ${o.slice(0,300)}`:""}`);this.method=n;this.url=i;this.status=r;this.detail=o;this.name="ForgeApiError"}},tbe={github:"github.com",gitlab:"gitlab.com",forgejo:null};qe=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),B6=e=>qe(e)&&qe(e.user)&&typeof e.user.login=="string"?e.user.login:void 0,ut=e=>typeof e=="string"?e:void 0,ho=e=>typeof e=="number"?e:typeof e=="string"&&/^\d+$/.test(e)?Number(e):void 0,V6=(e,t,n)=>n==="anywhere"?e.includes(t):e.startsWith(t),nbe=(e,t)=>{if(e===void 0||e==="")return!0;let n=(typeof e=="string"?[e]:e).map(i=>i.toLowerCase());return t!==void 0&&n.includes(t.toLowerCase())},$T=(e,t)=>n=>V6(n.body,e,t.match)&&nbe(t.author,n.author);ibe=140,obe=255;Jm=class extends Error{constructor(n,i){super(n?`--forge ${n} needs ${i.join(", ")} in the environment`:"the forge is not known: this is not a GitHub Actions, GitLab CI or Forgejo Actions job, so name the forge");this.kind=n;this.missing=i;this.name="ForgeEnvironmentError"}},ek=e=>{if(e)try{return new URL(e).host.toLowerCase()}catch{return}},tk=e=>e==="true"||e==="1";ET={github:["CHANT_GITHUB_TOKEN","GH_TOKEN","GITHUB_TOKEN"],forgejo:["CHANT_FORGEJO_TOKEN","FORGEJO_TOKEN","GH_TOKEN","GITHUB_TOKEN"],gitlab:["CHANT_GITLAB_TOKEN","GITLAB_TOKEN","CI_JOB_TOKEN"]}});var n4={};_e(n4,{HEAD_PLANS_DIR:()=>Qm,headPlansPath:()=>eg,listWavePlanSpecs:()=>ube,parseHeadPlans:()=>AT,readAllHeadPlans:()=>e4,readHeadPlanDigests:()=>lbe,readHeadPlans:()=>cbe,waveDigests:()=>t4});function eg(e,t){return{dir:`${Qm}/${e}`,file:`${t}.json`}}function AT(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}if(t===null||typeof t!="object")return null;let n=t;if(n.version!==1||typeof n.name!="string"||typeof n.head!="string"||typeof n.timestamp!="string"||!Array.isArray(n.waves))return null;let i=[];for(let r of n.waves){if(r===null||typeof r!="object")return null;let{wave:o,name:s,digest:a}=r;if(typeof o!="number"||typeof s!="string"||typeof a!="string")return null;i.push({wave:o,name:s,digest:a})}return{version:1,name:n.name,head:n.head,timestamp:n.timestamp,waves:i}}async function cbe(e,t,n){let{dir:i,file:r}=eg(t,n);return AT(await e.read(i,r))}async function e4(e,t){let n=new Map,{dir:i}=eg(t,"");for(let r of(await e.list(i)).sort()){if(!r.endsWith(".json"))continue;let o=AT(await e.read(i,r));o&&n.set(r.slice(0,-5),o)}return n}function t4(e){return new Map(e.waves.map(t=>[t.wave,t.digest]))}async function lbe(e,t){let n=new Map;for(let[i,r]of await e4(e,t))n.set(i,t4(r));return n}async function ube(e){return(await e.list(Qm)).sort()}var Qm,PT=v(()=>{"use strict";Qm="_wave-plans"});var tg={};_e(tg,{GATE_APPROVAL_SOURCES:()=>Ca,HEAD_PLANS_DIR:()=>Qm,bothRules:()=>mbe,forgejoReviews:()=>c4,githubReviews:()=>a4,gitlabReviews:()=>l4,headPlansPath:()=>eg,pullRequestHeadFromEnv:()=>hbe,reviewSourceFromEnv:()=>gbe,sealedApprovalRule:()=>fbe,trustPolicyAt:()=>pbe});import{readFileSync as dbe}from"node:fs";function pbe(e,t){return Av(Ra(e,t),t)}function fbe(e,t){return{requirement:{gate:e,class:null},refuses(n){return ea(t,n)}}}function mbe(e,t){return e?t?{requirement:e.requirement,refuses:n=>e.refuses(n)??t.refuses(n)}:e:t}function o4(e,t,n){return async i=>{let r=`${i4(e)}${i}`,o=await n(r,{method:"GET",headers:t}),s=await o.text();if(!o.ok)throw new rr("GET",r,o.status,s);return s?JSON.parse(s):null}}function s4(e,t){let n=o4(t.apiBase,e==="github"?{Authorization:`Bearer ${t.token}`,Accept:"application/vnd.github+json"}:{Authorization:`token ${t.token}`,Accept:"application/json"},t.fetch??globalThis.fetch),i=`/repos/${t.repo}`,r=l=>Zm(e,t.host,l),o=e==="github"?"per_page=100":"limit=50";async function s(l){if(e==="forgejo")try{let p=await n(`${i}/commits/${l}/pull`);return hn(p)&&typeof p.number=="number"?p.number:null}catch(p){if(p instanceof rr&&p.status===404)return null;throw p}let c=await n(`${i}/commits/${l}/pulls`);if(!Array.isArray(c))return null;let u=c.filter(p=>hn(p)&&p.merged_at),d=u.find(p=>hn(p)&&p.merge_commit_sha===l)??u[0];return d&&typeof d.number=="number"?d.number:null}async function a(l){let c=await n(`${i}/collaborators/${encodeURIComponent(l)}/permission`);return hn(c)&&["admin","maintain","write","owner"].includes(String(c.role_name??c.permission))}return{kind:e,async mergedReview(l){let c=await s(l);if(c===null)return null;let u=await n(`${i}/pulls/${c}`);if(!hn(u)||!hn(u.user)||!hn(u.head))throw new Error(`pull request #${c} came back without its author or head`);let d=String(u.user.login),p=String(u.head.sha),f=await n(`${i}/pulls/${c}/reviews?${o}`),g=new Map;for(let x of Array.isArray(f)?f:[]){if(!hn(x)||!hn(x.user)||typeof x.state!="string")continue;let k=x.state.toUpperCase();k==="COMMENTED"||k==="COMMENT"||k==="PENDING"||g.set(String(x.user.login),x)}let h=[],b=[],w=!1;for(let[x,k]of g){let R=k.dismissed===!0?"DISMISSED":String(k.state).toUpperCase();if(x.toLowerCase()===d.toLowerCase()){R==="APPROVED"&&b.push(`${r(x)} is the author, whose own review never counts`);continue}let $=e==="forgejo"?k.official===!0:await a(x);if(R==="REQUEST_CHANGES"||R==="CHANGES_REQUESTED"){$&&(w=!0),b.push(`${r(x)} requests changes`);continue}R==="APPROVED"&&($?k.commit_id!==p||k.stale===!0?b.push(`${r(x)} approved ${String(k.commit_id??"another commit").slice(0,12)}, not the head ${p.slice(0,12)}`):h.push(r(x)):b.push(`${r(x)} approved without write access${e==="forgejo"?" (the review is not official)":""}`))}return{pr:c,...typeof u.html_url=="string"?{url:u.html_url}:{},author:r(d),head:p,approvers:w?[]:h.sort(),refused:b}}}}function a4(e){return s4("github",e)}function c4(e){return s4("forgejo",e)}function l4(e){let t=o4(e.apiBase,{"PRIVATE-TOKEN":e.token},e.fetch??globalThis.fetch),n=`/projects/${encodeURIComponent(decodeURIComponent(e.repo))}`,i=r=>Zm("gitlab",e.host,r);return{kind:"gitlab",async mergedReview(r){let o=await t(`${n}/repository/commits/${r}/merge_requests`),s=Array.isArray(o)?o.find(b=>hn(b)&&b.state==="merged"&&(b.merge_commit_sha===r||b.squash_commit_sha===r))??o.find(b=>hn(b)&&b.state==="merged"):void 0;if(!hn(s)||typeof s.iid!="number")return null;let a=s.iid,l=hn(s.author)?String(s.author.username):"",c=String(s.sha),u=await t(`${n}/approvals`),d=hn(u)&&u.reset_approvals_on_push===!0,p=await t(`${n}/merge_requests/${a}/approvals`),f=hn(p)&&Array.isArray(p.approved_by)?p.approved_by:[],g=[],h=[];for(let b of f){let w=hn(b)&&hn(b.user)?b.user:void 0;if(!w||typeof w.username!="string")continue;let x=w.username;if(x.toLowerCase()===l.toLowerCase()){h.push(`${i(x)} is the author, whose own approval never counts`);continue}if(!d){h.push(`${i(x)}'s approval names no commit, and the project keeps approvals after a new push (turn on "Remove all approvals when commits are added")`);continue}let k=await t(`${n}/members/all/${String(w.id)}`).catch(R=>{if(R instanceof rr&&R.status===404)return null;throw R});if(!hn(k)||typeof k.access_level!="number"||k.access_level<30){h.push(`${i(x)} approved without the Developer role`);continue}g.push(i(x))}return{pr:a,...typeof s.web_url=="string"?{url:s.web_url}:{},author:i(l),head:c,approvers:g.sort(),refused:h}}}}function gbe(e=process.env,t){let n=t?{fetch:t}:{};if(e.GITLAB_CI==="true"){let a=e.CHANT_FORGE_TOKEN??e.GITLAB_TOKEN;if(!e.CI_API_V4_URL||!e.CI_PROJECT_ID||!a)throw new Error("a pr-review gate on GitLab needs CI_API_V4_URL, CI_PROJECT_ID and CHANT_FORGE_TOKEN (a token with read_api)");return l4({apiBase:e.CI_API_V4_URL,repo:e.CI_PROJECT_ID,token:a,host:e.CI_SERVER_HOST??r4(e.CI_SERVER_URL,"gitlab.com"),...n})}let i=e.CHANT_FORGE_TOKEN??e.GITHUB_TOKEN??e.GH_TOKEN;if(!e.GITHUB_REPOSITORY||!i)throw new Error("a pr-review gate needs GITHUB_REPOSITORY and a token (GITHUB_TOKEN with pull-requests: read, or CHANT_FORGE_TOKEN)");let r=e.FORGEJO_ACTIONS==="true"||e.GITEA_ACTIONS==="true",o=r4(e.GITHUB_SERVER_URL,"github.com"),s={apiBase:e.GITHUB_API_URL??(r?`${i4(e.GITHUB_SERVER_URL??"")}/api/v1`:"https://api.github.com"),repo:e.GITHUB_REPOSITORY,token:i,host:o,...n};return r?c4(s):a4(s)}function hbe(e=process.env){if(e.GITLAB_CI==="true")return e.CI_MERGE_REQUEST_IID&&(e.CI_MERGE_REQUEST_SOURCE_BRANCH_SHA||e.CI_COMMIT_SHA)||void 0;if(e.GITHUB_EVENT_PATH)try{let n=JSON.parse(dbe(e.GITHUB_EVENT_PATH,"utf-8")).pull_request?.head?.sha;return typeof n=="string"&&n!==""?n:void 0}catch{return}}var hn,i4,r4,ng=v(()=>{"use strict";ta();ps();mo();Xm();Md();PT();hn=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),i4=e=>e.replace(/\/+$/,"");r4=(e,t)=>{try{return e?new URL(e).host.toLowerCase():t}catch{return t}}});var IT={};_e(IT,{OVERRIDERS_PATH:()=>Fd,OVERRIDE_APPLIED:()=>d4,OVERRIDE_LEDGER:()=>wbe,OVERRIDE_OP:()=>In,appliedOverride:()=>kbe,decideOverride:()=>vbe,overrideAuditApplies:()=>xbe,overrideCommand:()=>nk,overrideDigest:()=>OT,overridePending:()=>p4,overrideRefusal:()=>m4,overridersAt:()=>CT,parseAppliedOverrides:()=>_T,parseOverriders:()=>f4,recordedDenials:()=>rk,sortedRules:()=>_a});import{createHash as ybe}from"node:crypto";import{spawnSync as bbe}from"node:child_process";function _a(e){return[...new Set(e.map(t=>t.trim()).filter(Boolean))].sort()}function OT(e,t,n){let i=[In,e,t,..._a(n)].join(`
161
+ `);return`sha256:${ybe("sha256").update(i).digest("hex")}`}function nk(e,t,n=!1){return`chant approve ${In} ${e} ${_a(t).map(i=>`--rule ${i}`).join(" ")} --reason "<why>"${n?" --sign":""}`}function p4(e){let t=_a(e.rules);return{version:1,kind:"pending",op:In,gate:e.subject,timestamp:e.timestamp,expiresAt:e.expiresAt,planDigest:OT(e.subject,e.planDigest,t),plan:e.planDigest,rules:t,description:e.description??`the policy denied this plan (${t.join(", ")})`,...e.runId?{runId:e.runId}:{},...e.url?{url:e.url}:{}}}function rk(e){let t=new Map;for(let n of e){if(n.op!==In||!n.planDigest)continue;let i=t.get(n.gate);(!i||yo(n.timestamp)>=yo(i.timestamp))&&t.set(n.gate,n)}return[...t.values()].map(n=>{let i=n;return{...n,plan:typeof i.plan=="string"?i.plan:"",rules:Array.isArray(i.rules)?_a(i.rules.filter(r=>typeof r=="string")):[]}}).sort((n,i)=>n.gate<i.gate?-1:n.gate>i.gate?1:0)}function f4(e){let t=[];for(let n of e.split(`
162
+ `)){let i=n.replace(/#.*$/,"").trim();i&&!t.includes(i)&&t.push(i)}return t}function CT(e,t,n=Fd){let i=bbe("git",["cat-file","blob",`${t}:${n}`],{cwd:e,encoding:"utf-8"});return i.status!==0?{base:t,path:n,active:!1,principals:[]}:{base:t,path:n,active:!0,principals:f4(i.stdout)}}function _T(e){let t=[];for(let n of e.split(`
163
+ `).map(i=>i.trim()).filter(Boolean))try{let i=JSON.parse(n);i.version===1&&i.kind==="applied"&&typeof i.op=="string"&&typeof i.gate=="string"&&typeof i.planDigest=="string"&&typeof i.approvedAt=="string"&&t.push(i)}catch{continue}return t}function m4(e,t){let n=t;if(n.via!==void 0)return`the override line was written by a job (via ${String(n.via)}), and an override is a person's`;if(t.review!==void 0)return`the override line came from the review of #${t.review.pr}, and an override is a person's own line`;if(t.approver?.kind==="agent")return`the override by ${t.resolvedBy} was recorded by an agent, and an override is a person's`;let i=`${e.overridersPath??Fd} at base`;if(!e.overriders.map(u4).includes(u4(t.resolvedBy)))return`${t.resolvedBy} is not listed in ${i}${e.overriders.length?` (${e.overriders.join(", ")})`:", which lists nobody"}`;if(!t.note?.trim())return`the override by ${t.resolvedBy} gives no reason`;if(e.mode==="sealed"){let r=e.signers??{base:null,signersPath:Fr,active:!1,signers:[],problems:["no signers were read for this sealed override"]};return ea(r,t)}return null}function vbe(e){let t=_a(e.rules),n=OT(e.subject,e.planDigest,t),i=e.ledger.pending.filter(h=>h.op===In),r=Cn(i,e.subject),o=r?yo(r.timestamp):0,s=(e.applied??[]).filter(h=>h.op===In&&h.gate===e.subject),a=h=>h.planDigest===void 0?void 0:s.find(b=>mt(b.planDigest,h.planDigest)&&yo(b.approvedAt)>=yo(h.timestamp)),l=(h,b)=>!b||yo(h.timestamp)>=yo(b.timestamp),c,u,d,p=[];for(let h of e.ledger.resolutions){if(h.op!==In||h.gate!==e.subject||yo(h.timestamp)<o)continue;let b=m4(e,h),w=a(h);if(mt(h.planDigest,n))b!==null?p.push(b):w?p.push(`the override by ${h.resolvedBy} at ${h.timestamp} is spent: a run applied under it at ${w.timestamp}`):l(h,c)&&(c=h);else{if(b!==null)continue;w?l(h,d)&&(d=h):l(h,u)&&(u=h)}}if(c)return{status:"overridden",digest:n,override:{subject:e.subject,by:c.resolvedBy,at:c.timestamp,reason:c.note.trim(),rules:t,planDigest:e.planDigest,digest:n,sealed:e.mode==="sealed",resolution:c}};let f=e.now??new Date().toISOString(),g=r&&yo(r.expiresAt)>yo(f)&&mt(r.planDigest,n)?rk([r])[0]:void 0;return u?{status:"moved",digest:n,by:u.resolvedBy,was:u.planDigest,refusals:p,...g?{standing:g}:{}}:{status:"none",digest:n,refusals:p,...g?{standing:g}:{},...d?{spent:{digest:d.planDigest,by:d.resolvedBy,at:d.timestamp}}:{}}}function kbe(e,t){return{version:1,kind:"applied",op:In,gate:e.subject,planDigest:e.digest,approvedAt:e.at,approvedBy:e.by,timestamp:t.timestamp,...t.runId?{runId:t.runId}:{},...t.commit?{commit:t.commit}:{}}}function xbe(e,t=d4){return e.map((n,i)=>({ref:`${t}:${i+1}`,at:n.timestamp,gate:n.gate,op:n.op,approval:"not-required",overrides:[{gate:n.gate,digest:n.planDigest}],detail:{approvedBy:n.approvedBy,approvedAt:n.approvedAt,...n.runId?{runId:n.runId}:{},...n.commit?{commit:n.commit}:{}}}))}var In,wbe,d4,Fd,yo,u4,rg=v(()=>{"use strict";Ai();Bc();On();ta();Od();In=Xs,wbe=`_gates/${In}.jsonl`,d4=`_gates/${In}/applied.jsonl`,Fd=".chant/overriders";yo=e=>new Date(e).getTime();u4=e=>e.normalize("NFKC").trim().toLowerCase()});var TT={};_e(TT,{CORE_CLASSES:()=>ro,DEFAULT_SIGNERS_PATH:()=>Fr,GATE_APPROVAL_SOURCES:()=>Ca,GATE_SEAL_NAMESPACE:()=>Rn,TRUST_CONFIG_PATH:()=>nr,admitApprover:()=>Tu,appliedGateApplies:()=>oq,appliedGatePath:()=>Gc,baseCommit:()=>Ebe,decideGateApproval:()=>Dbe,gateSealPayload:()=>no,gateSealRefusal:()=>ea,gateSignersAt:()=>Abe,grantedClasses:()=>jf,identityGateAdmissionAt:()=>_be,identityGatesAt:()=>Pbe,isApprovalSpent:()=>Lr,isPendingGateExpired:()=>Wn,latestPendingGate:()=>Cn,latestResolutionForPlan:()=>Nr,latestResolutionSince:()=>dd,parseAllowedSigners:()=>us,parseAppliedGateLines:()=>lv,reviewApproval:()=>Ibe,sshKeyFingerprint:()=>aC,trustConfigProblems:()=>Ev,verifySshSignatureWith:()=>Qs});import{spawnSync as $be}from"node:child_process";import{readFileSync as Rbe}from"node:fs";import{join as Sbe,posix as g4}from"node:path";function ig(e,t){return $be("git",t,{cwd:e,encoding:"utf-8"})}function ik(e,t,n){let i=ig(e,["cat-file","blob",`${t}:${n}`]);return i.status===0?i.stdout:void 0}function Ebe(e){let t=ig(e,["rev-parse","--verify","-q","HEAD^{commit}"]),n=t.stdout.trim();if(t.status!==0||!n)throw new Error(`${e} has no commit checked out, so the gate cannot be decided`);let i=ig(e,["cat-file","commit",n]).stdout.split(`
164
+
165
+ `)[0]??"",r=/^parent ([0-9a-f]{40,64})$/m.exec(i)?.[1];if(!r)return n;let o=()=>ig(e,["cat-file","-e",`${r}^{commit}`]).status===0;if(o()||ig(e,["fetch","-q","--depth=1","origin",r]),!o())throw new Error(`cannot fetch ${r.slice(0,12)}, the commit before this one, so the gate cannot be decided`);return r}function h4(e,t){let n=a=>({signers:{base:t,signersPath:Fr,active:!1,signers:[],problems:a},roles:{}}),i=ik(e,t,nr),r=Fr,o={};if(i!==void 0){let a;try{a=JSON.parse(i)}catch(c){return n([`${nr} is not JSON: ${c instanceof Error?c.message:String(c)}`])}let l=Ev(a);if(l.length>0)return n([`${nr} is invalid: ${l.join("; ")}`]);r=a.signers??Fr,o=a.roles??{}}let s=ik(e,t,r);return{signers:{base:t,signersPath:r,active:s!==void 0,signers:s===void 0?[]:us(s).signers,problems:[]},roles:o}}function Abe(e,t){return h4(e,t).signers}function y4(e,t){for(let n of["chant.workspace.json","chant.workspace.jsonc"]){let i=ik(e,t,n);if(i===void 0)continue;let r=fa(i,{jsonc:n.endsWith(".jsonc")});if(!r.ok)throw new Error(`${n} at base is not valid JSON (${r.message}), so the gate cannot be decided`);return{file:n,value:r.value}}return null}function b4(e){let t=e?.identity?.gates??{};return Object.entries(t).map(([n,i])=>({gate:n,class:typeof i?.class=="string"?i.class:null}))}function Pbe(e,t){let n=y4(e,t);return n===null?[]:b4(n.value)}function Obe(e,t,n,i){let r=[],o=[];return(Array.isArray(n)?n:[]).forEach((s,a)=>{let l=s!==null&&typeof s=="object"?s:{};if(typeof l.path=="string"&&l.path){let d=g4.normalize(l.path),p=f=>ik(e,t,d==="."?f:g4.join(d,f));r.push({pin:a,source:l.path,read:Mf(p,l.path,pC)});return}if(typeof l.package!="string"||!l.package)return;let c=na(l.package,i);if(!c){o.push(`${l.package} is not installed under ${i}`);return}let u;try{u=JSON.parse(Rbe(Sbe(c,"package.json"),"utf-8")).version}catch{u=void 0}if(typeof l.version=="string"&&l.version&&u!==l.version){o.push(`${l.package} is pinned at ${l.version}, and ${String(u??"an unknown version")} is installed under ${i}`);return}r.push({pin:a,source:l.package,read:Mf(Lf(c),l.package,pC)})}),{classes:gw(r).classes,unread:o}}function _be(e,t,n,i={}){let r=y4(e,t),o=r===null?void 0:b4(r.value).find(p=>p.gate===n);if(!o)return null;let{signers:s,roles:a}=h4(e,t),l=r.value.pins,c=i.classes?{classes:i.classes,unread:[]}:Obe(e,t,l,i.packages??e),u=o.class;if(u!==null&&!Cbe.has(u)&&c.unread.length>0){let p=`identity.gates.${n} names the class ${u}, and the pins in ${r.file} at base could not all be read, so no approval can show it is in that class: ${c.unread.join("; ")}`;return{requirement:o,refuses:()=>p}}let d={gate:n,class:u,signers:s,roles:a,classes:[...ro,...c.classes]};return{requirement:o,refuses:p=>Tu(d,p)}}function Ibe(e,t,n){let i={pr:e.pr,head:e.head,...e.url?{url:e.url}:{}};if(e.approvers.length===0){let r=e.refused.length>0?e.refused.join("; "):"nobody approved it";return{approved:!1,review:{...i,reason:`no writer other than its author approved the head of #${e.pr}: ${r}`}}}return t===void 0?{approved:!1,review:{...i,approvers:e.approvers,reason:`no plans are recorded for the head ${e.head.slice(0,12)} of #${e.pr} (its pipeline runs \`chant run wave --record-plans\`)`}}:t!==n?{approved:!1,review:{...i,approvers:e.approvers,reason:`the plan moved after the review: the head planned ${t}, and the merge plans ${n}`}}:{approved:!0,review:{...i,approvers:e.approvers}}}function Dbe(e){let{gate:t,planDigest:n,environment:i}=e,r=e.mode??"ledger",o=i===void 0?e.ledger.pending:e.ledger.pending.filter(k=>k.environment===i),s=(i===void 0?e.ledger.resolutions:e.ledger.resolutions.filter(k=>k.environment===void 0||k.environment===i)).filter(k=>k.gate===t),a=r==="sealed",l={base:null,signersPath:Fr,active:!1,signers:[],problems:["no signers were read for this sealed gate"]},c=k=>e.refuses?.(k)??(a?ea(e.signers??l,k):null),u=Cn(o,t),d=u?.timestamp??Tbe,p=[],f=[],g;for(let k of s){if(e.spend&&Lr(e.ledger.applied??[],k)){new Date(k.timestamp).getTime()>=new Date(d).getTime()&&(!g||new Date(k.timestamp).getTime()>=new Date(g.timestamp).getTime())&&(g=k);continue}let R=c(k);R===null?p.push(k):mt(k.planDigest,n)&&new Date(k.timestamp).getTime()>=new Date(d).getTime()&&f.push({resolution:k,reason:R})}let h=Nr(p,t,d,n);if(h.resolution)return{status:"approved",via:"ledger",resolution:h.resolution};let b=e.spend===!0&&e.review?.approved===!0&&Lr(e.ledger.applied??[],{gate:t,planDigest:n,review:{...e.review.review.head?{head:e.review.review.head}:{}}});if(r==="pr-review"&&e.review?.approved&&!b)return{status:"approved",via:"pr-review",review:e.review.review};let w=e.now??new Date().toISOString(),x=u&&!Wn(u,w)&&mt(u.planDigest,n)?u:void 0;return{status:"waiting",...x?{standing:x}:{},...h.mismatched?{mismatched:h.mismatched}:{},uncounted:f.sort((k,R)=>new Date(k.resolution.timestamp).getTime()-new Date(R.resolution.timestamp).getTime()),...r==="pr-review"&&e.review?{review:b?{...e.review.review,reason:`a wave already applied this digest under the review of ${e.review.review.head?.slice(0,12)??"its head"}, so the review is spent`}:e.review.review}:{},...g?{spent:g}:{}}}var Cbe,Tbe,DT=v(()=>{"use strict";Bc();On();Wc();ta();Od();ed();xc();Du();Md();Bc();ta();Od();xc();Wc();Cbe=new Set(ro.filter(e=>e.role!==null).map(e=>e.name));Tbe=new Date(0).toISOString()});var v4={};_e(v4,{DEFAULT_GATE_POINT_PASS:()=>jd,GATE_POINT_INPUTS:()=>Um,chantGatePointAsker:()=>jbe,chantPointQuestions:()=>Lbe,defaultGatePointStore:()=>Nd,evaluatePointGate:()=>og,gatePointInputs:()=>il,gatePointOf:()=>qv,gatePointProblems:()=>rl,gateSubject:()=>Hm,isGateRunLocator:()=>zc,parseGateSubject:()=>Kv,pointGateResumable:()=>sg,resolveGateRunLocator:()=>ba});import{execFile as Nbe}from"node:child_process";function w4(e){return e.answeredBy.length>0?e.answeredBy.join(", "):e.decider}async function og(e,t,n){let i=n.now??new Date().toISOString(),r={component:n.op,name:n.gate,env:n.env??null,planDigest:n.planDigest??null},o=await t.ask({point:n.point.name,inputs:n.inputs??{},facts:r,subject:Hm(n.op,n.gate,n.env),...n.point.store?{store:n.point.store}:{}}),s={point:o.point,id:o.id,path:o.path};if(o.state==="answered"&&o.answer!==null){let h={...s,answer:o.answer,decider:o.decider,...o.answeredBy.length>0?{answeredBy:o.answeredBy}:{}},b=n.point.pass??jd;if(!b.includes(o.answer))return{satisfied:!1,answer:h,refused:`decision point ${o.point} answered ${JSON.stringify(o.answer)} (${o.id}, by ${w4(o)}), and gate "${n.gate}" passes only on ${b.map(_=>JSON.stringify(_)).join(" or ")}. To ask again, take the answer back: chant workspace points retract ${o.id} --by <name>`};let x=(await e.read(n.op)).resolutions.find(_=>_.gate===n.gate&&_.answer?.id===o.id&&_.environment===void 0&&mt(_.planDigest,n.planDigest));if(x)return{satisfied:!0,resolution:x,answer:h,recorded:!1};if(!e.appendResolution)throw new Error(`gate "${n.gate}" asks decision point ${o.point}, and this gate ledger cannot record the resolution that cites its answer`);let{record:k,pushed:R,pushWarning:$}=await e.appendResolution({op:n.op,gate:n.gate,resolvedBy:w4(o),timestamp:i,note:`answered through decision point ${o.point} (${o.id})`,...n.planDigest!==void 0?{planDigest:n.planDigest}:{},approver:{kind:o.decider==="quorum"||o.answeredBy.length>0?"human":"agent"},answer:h});return{satisfied:!0,resolution:k,answer:h,recorded:!0,pushed:R,...$?{pushWarning:$}:{}}}let a={id:o.id,point:o.point,state:o.state==="proposed"?"proposed":"escalated",path:o.path,subject:o.subject,steward:o.steward},l=await e.read(n.op),c=Cn(l.pending.filter(h=>h.environment===void 0),n.gate);if(c&&!Wn(c,i)&&mt(c.planDigest,n.planDigest)&&c.answer?.id===o.id&&(!n.neverOverMcp||c.neverOverMcp===!0))return{satisfied:!1,waiting:a,pending:c,recorded:!1};let u=os(),d=n.resume===!1?void 0:n.resume??ba(),{record:p,pushed:f,pushWarning:g}=await e.appendPending({...n.fields,op:n.op,gate:n.gate,timestamp:i,expiresAt:new Date(new Date(i).getTime()+Li(n.timeout??"48h")).toISOString(),...n.description?{description:n.description}:{},...n.runId?{runId:n.runId}:{},...u?{url:u}:{},...n.planDigest!==void 0?{planDigest:n.planDigest}:{},...d?{resume:d}:{},answer:{...s,...n.point.pass?{pass:n.point.pass}:{}},...n.neverOverMcp?{neverOverMcp:!0}:{}});return{satisfied:!1,waiting:a,pending:p,recorded:!0,pushed:f,...g?{pushWarning:g}:{}}}function sg(e,t){let n=e.answer;if(!n)return{resumable:!1,why:"not-a-point",message:"the pending fact cites no decision point's question"};if(!t||t.id!==n.id)return{resumable:!1,why:"unknown",message:`question ${n.id} (${n.point}) can't be read here`};if(t.state!=="answered"||t.answer===null)return{resumable:!1,why:"open",message:`question ${n.id} (${n.point}) is ${t.state}, not answered yet`};let i=n.pass??jd;return i.includes(t.answer)?{resumable:!0,answer:{point:n.point,id:n.id,path:n.path,answer:t.answer,...t.answeredBy.length>0?{answeredBy:t.answeredBy}:{}},answeredBy:t.answeredBy.length>0?t.answeredBy.join(", "):"quorum",answeredOn:t.answeredOn}:{resumable:!1,why:"refused",message:`question ${n.id} (${n.point}) was answered ${JSON.stringify(t.answer)}, and the gate passes only on ${i.map(r=>JSON.stringify(r)).join(" or ")}`}}function NT(e,t){let[n,...i]=e.command;return new Promise((r,o)=>{Nbe(n,[...i,...t],{cwd:e.cwd,encoding:"utf-8",maxBuffer:16*1024*1024,env:{...process.env,NO_COLOR:"1"}},(s,a,l)=>{try{r(JSON.parse(a))}catch{o(new Error(`chant ${t.slice(0,3).join(" ")} printed no JSON document${s?`: ${s.message}`:""}${l?`
166
+ ${l.trim()}`:""}`))}})})}function jT(e,t){let n=t.error;return n?new Error(`${e}: ${n.code}: ${n.message}`):void 0}function jbe(e){return{async ask(t){let n=await NT(e,["workspace","points","--json"]),i=jT(`decision point ${t.point}`,n);if(i)throw i;let r=n.points?.find(u=>u.name===t.point);if(!r)throw new Error(`gate "${t.facts.name}" asks decision point ${t.point}, and no points file declares it`);let o=il(t.point,r.inputs.map(u=>u.name),t.facts,t.inputs),s=t.store??Nd(),a=await NT(e,["workspace","points","ask",t.point,"--inputs",JSON.stringify(o),"--subject",t.subject,...s?["--store",s]:[]]),l=jT(`decision point ${t.point}`,a);if(l)throw l;let c=a.question;return{id:c.id,point:c.point,path:c.path,state:c.state,answer:c.state==="answered"?c.answer:null,decider:typeof c.decider?.kind=="string"?c.decider.kind:"quorum",answeredBy:c.answeredBy??[],subject:c.subject,steward:c.askedBy?.steward??null}}}}async function Lbe(e){let t=await NT(e,["workspace","points","--json"]),n=jT("chant workspace points",t);if(n)throw n;let i=t.questions??[];return new Map(i.map(r=>[r.id,{id:r.id,state:r.state,answer:r.answer??null,answeredBy:r.answeredBy??[],answeredOn:r.answeredOn??null}]))}var ok=v(()=>{"use strict";Bc();U0();On();as();bs();gd();bs();gd()});function bo(){if(k4)return k4;let e=process.env[x4];return e&&e.trim()!==""?{steward:e.trim()}:void 0}var x4,k4,ol=v(()=>{"use strict";x4="CHANT_STEWARD"});import{execFileSync as Mbe}from"node:child_process";import{closeSync as Fbe,existsSync as $4,openSync as Bbe,readdirSync as Gbe,readSync as Wbe,statSync as zbe}from"node:fs";import{isAbsolute as Ube,join as ag,relative as Hbe,resolve as Ia,sep as R4}from"node:path";function MT(e,t){let n=Hbe(e,Ia(t));if(!(n===""||n===".."||n.startsWith(`..${R4}`)||Ube(n)))return n.split(R4)}function Kbe(e){if(!e||e.exclude.length===0&&e.include.length===0)return;let t=Ia(e.root),n=r=>{if(r.length===0)return()=>!1;let o=(0,LT.default)(r,{dot:!0});return s=>{let a=MT(t,s);return a!==void 0&&a.some((l,c)=>o(a.slice(0,c+1).join("/")))}},i=e.include.map(r=>LT.default.scan(r).base).filter(r=>r!=="");return{excluded:n(e.exclude),included:n(e.include),includeBelow:r=>{let o=MT(t,r);if(o===void 0)return!1;let s=o.join("/");return i.some(a=>a.startsWith(`${s}/`))}}}function Jbe(e){let t;try{t=Mbe("git",["ls-files","-z","--others","--ignored","--exclude-standard","--directory"],{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:256*1024*1024})}catch{return new Set}let n=new Set,i=Ia(e);for(let r of t.split("\0")){if(r==="")continue;let o=r.endsWith("/")?r.slice(0,-1):r;if(o==="."||o==="")return new Set;n.add(ag(i,o))}return n}function Zbe(e){if($4(ag(e,"chant.config.ts")))return!0;let t=ag(e,"chant.config.json");return $4(t)&&!Qb(t)}function Ybe(e,t){return e==="ops"||wf(t).configPath!==void 0}async function cg(e){let t=gr(e);if(!t)return[];let n=Ia(e),[{readDeclaration:i,resolveGroups:r,rootExclusions:o},{workingTree:s}]=await Promise.all([Promise.resolve().then(()=>(_t(),_0)),Promise.resolve().then(()=>(Zt(),nC))]),a;try{let l=s(t.dir),c=i(l);a=o(c,r(c,l)).map(u=>Ia(t.dir,u.dir))}catch{return[]}return a.filter(l=>MT(n,l)!==void 0)}function S4(e,t){let n;try{n=Bbe(e,"r");let i=Buffer.alloc(t),r=Wbe(n,i,0,t,0);return i.toString("utf8",0,r)}catch{return""}finally{n!==void 0&&Fbe(n)}}function lg(e){let t=[],n=Kbe(e.globs),i=Jbe(e.root),r=Ybe(e.walker,e.root),o=new Set((e.excludeDirs??[]).map(p=>Ia(p))),s=e.walker==="audit"?Vbe:new Set,a=e.limit,l=p=>i.size>0&&i.has(Ia(p)),c=p=>a&&t.length>=a.max?(a.truncated=!0,!1):(t.push(p),!0),u=(p,f)=>{if(f.isDirectory())return"dir";if(f.isFile())return"file";if(e.followSymlinks&&f.isSymbolicLink())try{let g=zbe(ag(p,f.name));return g.isDirectory()?"dir":g.isFile()?"file":void 0}catch{return}},d=(p,f)=>{let g;try{g=Gbe(p,{withFileTypes:!0})}catch{return!0}e.sorted&&g.sort((h,b)=>h.name<b.name?-1:h.name>b.name?1:0);for(let h of g){if(a?.truncated)return!1;let b=ag(p,h.name),w=u(p,h);if(w==="dir"){if(qbe.has(h.name)||o.has(Ia(b)))continue;let x=h.name.startsWith(".")&&!s.has(h.name);if(x&&e.takeSkippedDir?.(h.name,b)){if(!c(b))return!1;continue}if(x||h.name==="dist"||l(b)&&!e.keepIgnored?.(b)||r&&Zbe(b)||f){if(n?.included(b)){if(!d(b,!1))return!1}else if(n?.includeBelow(b)&&!d(b,!0))return!1;continue}if(!d(b,!1))return!1}else if(w==="file"){if((f||l(b)&&!e.keepIgnored?.(b)||(n?.excluded(b)??!1))&&!n?.included(b)||!e.accept(h.name,b))continue;if(!c(b))return!1}}return!0};return d(e.root,!1),t}var LT,Vbe,qbe,sk=v(()=>{"use strict";LT=Le(_f(),1);Ri();Kt();Vbe=new Set([".github",".forgejo"]),qbe=new Set(["node_modules",".git"])});function Qbe(e){return Xbe.test(e.slice(0,E4))}function ck(e){let t=S4(e,E4);return t.slice(0,256).includes(ak)||Qbe(t)}function ewe(e){return e.endsWith(".ts")&&!e.endsWith(".test.ts")&&!e.endsWith(".spec.ts")}async function lk(e,t){let n=t?.globs===null?void 0:t?.globs??await $u(e);return lg({walker:"source",root:e,globs:n,excludeDirs:await cg(e),accept:(i,r)=>ewe(i)&&!ck(r)})}var ak,E4,Xbe,sl=v(()=>{"use strict";Kt();sk();ak="Generated by chant \u2014 do not edit directly",E4=1024,Xbe=/^[ \t]*(?:\/\/|\/\*+|\*)[ \t]*chant-discovery-skip(?![\w-])/m});var ug=v(()=>{"use strict"});function Bd(e){if(typeof e!="string")return`${JSON.stringify(e)} is not a string`;if(!dg.test(e))return`${JSON.stringify(e)} can't key a work lease: use letters, digits, ".", "_" and "-", starting with a letter or digit, at most 100 characters`;if(e.includes(".."))return`${JSON.stringify(e)} can't key a work lease: git refuses ".." in a ref name`;if(e.endsWith("."))return`${JSON.stringify(e)} can't key a work lease: git refuses a ref name ending in "."`;if(e.toLowerCase().endsWith(".lock"))return`${JSON.stringify(e)} can't key a work lease: git refuses a ref name ending in ".lock"`}function FT(e){return Bd(e)===void 0}var dg,BT=v(()=>{"use strict";dg=/^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/});var uk=v(()=>{"use strict";Mi();as();BT();lo()});function pk(e){if(!e||typeof e!="object")return!1;let t=e;return t.kind===O4&&typeof t.name=="string"&&Array.isArray(t.ops)&&!!t.form&&typeof t.form=="object"&&typeof t.form.default=="string"}var O4,al=v(()=>{"use strict";Mi();ug();uk();O4="Chant::Steward"});var zT={};_e(zT,{discoverOps:()=>ws,discoverStewards:()=>WT});import{existsSync as C4}from"node:fs";import{dirname as nwe,join as _4,resolve as I4}from"node:path";async function rwe(e){let n=await ot().spawn(["git","rev-parse","--show-toplevel"],{cwd:e});if(n.exitCode!==0)throw new Error("Not in a git repository");return n.stdout.trim()}async function T4(e){let t=I4(await rwe(e)),n=I4(e??process.cwd());for(;;){if(C4(_4(n,"chant.config.ts"))||C4(_4(n,"chant.config.json")))return n;if(n===t)break;let i=nwe(n);if(i===n)break;n=i}return t}async function D4(e){return lg({walker:"ops",root:e,globs:await $u(e),excludeDirs:await cg(e),accept:(t,n)=>t.endsWith(".op.ts")&&!t.endsWith(".test.ts")&&!t.endsWith(".spec.ts")&&!ck(n)})}function iwe(e){if(!e||typeof e!="object")return;let t=e.props;if(!(!t||typeof t.name!="string"||!Array.isArray(t.phases)))return t}function owe(e){let t=[],n=new Set,i=(r,o)=>{if(n.has(o))return;let s=iwe(o);s&&(n.add(o),t.push({exportName:r,config:s}))};i("default",e.default);for(let r of Object.keys(e))r!=="default"&&i(r,e[r]);return t}async function ws(e){let t=[],n=new Map,i=await T4(e?.cwd),r=await D4(i),o=new Map;for(let s of r)try{Mn();let a=await import(s),l=owe(a);if(l.length===0&&Object.values(a).some(pk))continue;if(l.length===0){t.push(`${s}: exports no Op. Expected \`export default Op({...})\` or a named export such as \`export const deploy = Op({...})\``);continue}for(let{exportName:c,config:u}of l){let d=o.get(u.name);if(d!==void 0){t.push(d===s?`Duplicate Op name "${u.name}" declared twice in ${s}`:`Duplicate Op name "${u.name}" in ${s} and ${d}`);continue}o.set(u.name,s),n.set(u.name,{config:u,filePath:s,exportName:c})}}catch(a){t.push(`${s}: ${a instanceof Error?a.message:String(a)}`)}return{ops:n,errors:t}}async function WT(e){let t=[],n=[],i=new Map,r=new Map,o=await T4(e?.cwd),s=await D4(o);for(let a of s){let l;try{Mn(),l=await import(a)}catch(d){t.push(`${a}: ${d instanceof Error?d.message:String(d)}`);continue}let c=new Set,u=["default",...Object.keys(l).filter(d=>d!=="default")];for(let d of u){let p=l[d];if(!pk(p)||c.has(p))continue;c.add(p);let f=i.get(p.name);if(f){n.push(`Duplicate steward "${p.name}" in ${a} and ${f.filePath}`);continue}let g=p.ops.find(h=>r.has(h.name));if(g){n.push(`${a}: steward "${p.name}" lists op "${g.name}", which steward "${r.get(g.name)}" already runs. Two stewards running one Op are two writers; list it on one of them.`);continue}for(let h of p.ops)r.set(h.name,p.name);i.set(p.name,{declaration:p,filePath:a,exportName:d})}}return{stewards:i,errors:t,conflicts:n}}var Bi=v(()=>{"use strict";to();sk();sl();Kt();al();Si()});import{AsyncLocalStorage as swe}from"node:async_hooks";import{createHash as L4,randomBytes as qT}from"node:crypto";import{existsSync as awe,mkdirSync as cwe,readFileSync as KT,realpathSync as lwe,renameSync as fk,rmSync as JT,statSync as M4,unlinkSync as uwe,writeFileSync as F4}from"node:fs";import{hostname as dwe,tmpdir as pwe}from"node:os";import{dirname as fwe,isAbsolute as mwe,join as Ta,resolve as UT}from"node:path";function G4(e){let t=UT(e);for(;;){let n=Ta(t,".git");try{let r=M4(n);if(r.isDirectory())return n;if(r.isFile()){let o=KT(n,"utf-8").match(/^gitdir:\s*(.+?)\s*$/m);if(o)return mwe(o[1])?o[1]:UT(t,o[1])}}catch{}let i=fwe(t);if(i===t)return null;t=i}}function HT(e){try{return lwe(e)}catch{return UT(e)}}function wwe(e){let t=G4(HT(e));return t?Ta(t,ywe):Ta(pwe(),`chant-write-${L4("sha256").update(HT(e)).digest("hex").slice(0,16)}.lock`)}function W4(e){let t=G4(HT(e));return t?Ta(t,bwe):null}function mk(e){try{return JSON.parse(KT(Ta(e,"owner.json"),"utf-8"))}catch{return null}}function vwe(e){try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}function U4(e,t,n){if(t===null)try{return n-M4(e).mtimeMs>5e3?"it names no holder":null}catch{return null}return Date.parse(t.expiresAt)<n?`it expired at ${t.expiresAt}`:t.pid!==null&&t.host===z4&&!vwe(t.pid)?`its process ${t.pid} has exited`:null}function H4(e){if(!e)return"a writer that has not said who it is";let t=[e.by,e.agent?`agent ${e.agent}`:null].filter(Boolean).join(", ");return`${e.verb}${t?` (${t})`:""}, since ${e.acquiredAt}, until ${e.expiresAt}`}function kwe(e,t){let n=`${e}.broken-${qT(6).toString("hex")}`;try{fk(e,n)}catch{return}let i=mk(n);if(i!==null&&t!==null&&i.token!==t.token)try{fk(n,e);return}catch{}JT(n,{recursive:!0,force:!0})}function V4(e,t,n=!0){try{cwe(e)}catch(r){if(r.code!=="EEXIST")throw r;let o=mk(e);return n&&U4(e,o,Date.now())!==null?(kwe(e,o),V4(e,t,!1)):{ok:!1,holder:o}}let i=Ta(e,`owner.${process.pid}.tmp`);return F4(i,`${JSON.stringify(t,null,2)}
167
+ `),fk(i,Ta(e,"owner.json")),{ok:!0}}function xwe(){let e=process.env[B4],t=e===void 0||e===""?NaN:Number(e);return Number.isFinite(t)&&t>=0?t:gwe}function $we(e,t,n){let i=Date.now();return{token:qT(16).toString("hex"),pid:n,host:z4,verb:e.verb,by:e.by??null,agent:e.agent??null,acquiredAt:new Date(i).toISOString(),expiresAt:new Date(i+t).toISOString()}}function Rwe(e){if(VT.getStore()?.has(e))return!0;let t=process.env[N4];if(t===void 0||t==="")return!1;let n=mk(e);if(n?.token!==t||U4(e,n,Date.now())!==null)throw new Da("write-lock-not-held",`${N4} names a lock token that no longer holds this working tree's write lock (${n?`it is held by ${H4(n)}`:"nobody holds it"}): the batch's lock was released or expired, so take it again with chant workspace lock acquire and re-read what the batch writes`,n);return!0}function Swe(e,t){if(mk(e)?.token!==t)return!1;try{uwe(Ta(e,"owner.json"))}catch{}return JT(e,{recursive:!0,force:!0}),!0}function Ewe(e,t,n){return new Da("write-lock-timeout",`another write holds this working tree's write lock (${e}): ${H4(t)}. Waited ${n}ms; run the write again once it is done, or raise ${B4}`,t)}async function Pwe(e,t){let n=xwe(),i=Date.now();for(;;){let r=V4(e,t);if(r.ok)return;if(Date.now()-i>=n)throw Ewe(e,r.holder,n);await new Promise(o=>setTimeout(o,Awe()))}}async function wo(e,t,n,i){if(n)return i();let r=wwe(e);if(Rwe(r))return i();let o=$we(t,hwe,process.pid);await Pwe(r,o),j4.add(r);try{return await VT.run(new Set([...VT.getStore()??[],r]),i)}finally{j4.delete(r),Swe(r,o.token)}}function cl(e,t){let n=`${e}.chant-${process.pid}-${qT(4).toString("hex")}.tmp`;F4(n,t);try{fk(n,e)}catch(i){throw JT(n,{force:!0}),i}}function q4(e){return L4("sha256").update(e,"utf-8").digest("hex")}function K4(e){try{let t=JSON.parse(KT(e,"utf-8"));if(t&&t.version===1&&t.files&&typeof t.files=="object")return t}catch{}return{version:1,files:{}}}function vs(e,t,n){let i=W4(e);if(!(i===null||t.length===0))try{let r=K4(i),o=new Date().toISOString();for(let a of t)delete r.files[a.path],r.files[a.path]={sha256:q4(a.text),verb:n.verb,by:n.by??null,agent:n.agent??null,at:o};let s=Object.keys(r.files);for(let a of s.slice(0,Math.max(0,s.length-Owe)))delete r.files[a];cl(i,`${JSON.stringify(r)}
168
+ `)}catch{}}function gk(e){let t=W4(e),n=t!==null&&awe(t)?K4(t):null;return(i,r)=>{let o=n?.files[i];return!o||r===null||o.sha256!==q4(r)?null:{verb:o.verb,by:o.by,agent:o.agent,at:o.at}}}var N4,B4,gwe,hwe,tHe,ywe,bwe,Na,Da,z4,VT,j4,Awe,Owe,pg=v(()=>{"use strict";N4="CHANT_WRITE_LOCK",B4="CHANT_WRITE_LOCK_WAIT_MS",gwe=15e3,hwe=2*6e4,tHe=10*6e4,ywe="chant-write.lock",bwe="chant-writes.json",Na=["write-lock-timeout","write-lock-not-held"],Da=class extends Error{constructor(n,i,r){super(i);this.code=n;this.holder=r;this.name="WriteLockError"}};z4=dwe(),VT=new swe,j4=new Set;Awe=()=>20+Math.floor(Math.random()*40);Owe=2e3});import{execFileSync as Cwe}from"node:child_process";function J4(e,t,n){try{return Cwe("git",t,{cwd:e,input:n,stdio:[n===void 0?"ignore":"pipe","pipe","pipe"],maxBuffer:512*1024*1024})}catch{return}}function _we(e,t){let n=new Map;if(t.length===0)return n;let i=J4(e,["cat-file","--batch"],`${t.join(`
169
+ `)}
170
+ `);if(!i)return n;let r=0;for(let o of t){let s=i.indexOf(10,r);if(s<0)break;let a=i.subarray(r,s).toString("utf-8");r=s+1;let l=a.match(/^[0-9a-f]+ (\w+) (\d+)$/);if(!l)continue;let c=Number(l[2]);l[1]==="blob"&&n.set(o,i.subarray(r,r+c).toString("utf-8")),r+=c+1}return n}function Z4(e,t,n,i){let r=new Map(n.map(d=>[d,null])),o=i.stateField;if(!o||n.length===0)return r;let s=J4(e,["log","--no-renames","--format=%x00%H%x1f%aI%x1f%s","--name-only",t,"--",...n])?.toString("utf-8");if(s===void 0)return r;let a=new Set(n),l=new Map,c=new Map;for(let d of s.split("\0")){if(!d)continue;let p=d.indexOf(`
171
+ `),[f,g,h]=(p<0?d:d.slice(0,p)).split("");l.set(f,{date:g,subject:h});for(let b of(p<0?"":d.slice(p+1)).split(`
172
+ `)){if(!a.has(b))continue;let w=c.get(b)??[];w.push(f),c.set(b,w)}}let u=_we(e,[...c].flatMap(([d,p])=>p.map(f=>`${f}:${d}`)));for(let[d,p]of c){let f=null;for(let g of p){let h=u.get(`${g}:${d}`),b=h===void 0?void 0:xv(i.format,h),w=b?.ok?b.value[o]:void 0;if(typeof w!="string"||!Uc(i,w))break;f=g}f&&r.set(d,{sha:f,...l.get(f)})}return r}var Y4=v(()=>{"use strict";mn();vd()});import{dirname as cHe,join as Iwe,relative as lHe,resolve as uHe,sep as dHe}from"node:path";function ja(e,t){return Iwe(t,...e.path.split("/"))}var Gd=v(()=>{"use strict";_t()});import{execFileSync as Twe}from"node:child_process";function Dwe(e,t){return Twe("git",["--no-optional-locks","--literal-pathspecs",...t],{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","pipe"],maxBuffer:256*1024*1024})}function fg(e,t){try{return Dwe(e,t)}catch{return}}function ZT(e,t){let n=fg(e,["symbolic-ref","--quiet","--short","HEAD"])?.trim()||null,i=fg(e,["rev-parse","--verify","--quiet","HEAD^{commit}"])?.trim()||null,r=Br(e,t),o=i&&r.commit&&fg(e,["merge-base",i,r.commit])?.trim()||null;return{branch:n,head:i,base:o,baseFrom:r.from}}function X4(e){return(e??"").split("\0").filter(Boolean)}function Q4(e,t,n,i,r){let o=new Map;if(t===null){for(let f of i)o.set(f,"new");return{states:o,deleted:[]}}let s=n==="."?"":`${n}/`,a=f=>f.startsWith(s)&&!f.slice(s.length).includes("/"),l=n==="."?".":n,c=new Set(X4(fg(e,["ls-tree","-r","-z","--name-only",t,"--",l])).filter(a)),u=new Set(X4(fg(e,["diff","--name-only","-z","--no-renames",t,"--",l])));for(let f of i)o.set(f,c.has(f)?u.has(f)?"modified":"committed":"new");let d=new Set(i),p=[...c].filter(f=>!d.has(f)&&r.test(f.slice(s.length))).sort();return{states:o,deleted:p}}var YT=v(()=>{"use strict";Zc()});var Wd={};_e(Wd,{GATE_SEAL_NAMESPACE:()=>Rn,RECORD_SEAL_NAMESPACE:()=>yk,REVIEW_SEAL_NAMESPACE:()=>nD,SealError:()=>ll,checkGateSeal:()=>Mwe,checkRecordSeal:()=>Lwe,checkVerdictSeal:()=>jwe,gateSealPayload:()=>no,recordSealPayload:()=>iD,resolveSigningKey:()=>Bwe,reviewSealPayload:()=>rD,sealGateApproval:()=>zwe,sealRecord:()=>Wwe,sealVerdict:()=>Gwe});import{execFileSync as Nwe}from"node:child_process";import{mkdtempSync as XT,rmSync as QT,writeFileSync as eD}from"node:fs";import{homedir as eJ,tmpdir as tD}from"node:os";import{join as ul,resolve as tJ}from"node:path";function rD(e,t,n,i,r){return Buffer.from(`${e}
173
+ ${t}
174
+ ${n}
175
+ ${i}
176
+ ${r}`,"utf-8")}function iD(e,t,n,i){return Buffer.from(`${e}
177
+ ${t}
178
+ ${n}
179
+ ${i??""}`,"utf-8")}function jwe(e,t){let n=t.record===null||t.digest===null||typeof t.on!="string";return oD(e,{principal:t.reviewer,what:`the verdict by ${t.reviewer}`,role:"reviewer",namespace:nD,seal:t.seal,payload:n?`a seal covers the record id, the verdict's digest and on, and the verdict by ${t.reviewer} lacks one`:rD(t.record,t.digest,t.verdict,t.reviewer,t.on)})}function Lwe(e,t){let n=t.record??"the record";return t.author===null&&(t.seal===void 0||t.seal===null)?{attested:null,code:"seal-missing",message:`${n} names no ${t.authorField}, so it claims no author to seal`}:oD(e,{principal:t.author??"",what:n,role:t.authorField,namespace:yk,seal:t.seal,payload:t.record===null||t.author===null?`a record's seal covers its id and its ${t.authorField}, and ${n} lacks one`:iD(t.record,t.digest,t.author,t.state)})}function Mwe(e,t){return oD(e,{principal:t.resolvedBy,what:`the approval of gate ${t.gate} by ${t.resolvedBy}`,role:"approver",namespace:Rn,seal:t.seal,payload:no(t)})}function oD(e,t){let n=`${e.signersPath} at base`;if(t.seal===void 0||t.seal===null)return e.active?{attested:!1,code:"seal-missing",message:`${t.what} carries no seal`}:{attested:null,code:"seal-missing",message:`${t.what} carries no seal; there is no signers file at base, so none is needed`};let i=t.seal;if(typeof i!="object"||Array.isArray(i)||typeof i.signer!="string"||typeof i.signature!="string")return{attested:!1,code:"seal-signature-invalid",message:`the seal on ${t.what} is malformed: it needs signer and signature`};if(hk(i.signer)!==hk(t.principal))return{attested:!1,code:"seal-signature-invalid",message:t.role==="reviewer"?`the seal is by ${i.signer}, and the verdict is ${t.principal}'s`:`the seal on ${t.what} is by ${i.signer}, and its ${t.role} is ${t.principal||"empty"}`};if(typeof t.payload=="string")return{attested:!1,code:"seal-signature-invalid",message:t.payload};if(!e.active)return nJ(t.principal,t.payload,i.signature,t.namespace);let r=e.signers.filter(s=>hk(s.principal)===hk(t.principal));if(r.length===0&&e.returnedFrom!==void 0){let s=nJ(t.principal,t.payload,i.signature,t.namespace);return s.attested===!1?s:{attested:null,code:"seal-unverifiable",message:`${t.what} came back in return ${e.returnedFrom}, sealed by ${t.principal}${s.key?` with ${s.key}`:""}, whom neither ${n} nor an admission for that return lists; it counts once an admin admits the signer (chant workspace admit ${e.returnedFrom})`,...s.key?{key:s.key}:{}}}if(r.length===0)return{attested:!1,code:"seal-signer-unlisted",message:`${t.principal} has no key in ${n}, so the seal can't count`};let o=t.namespace===Rn?Fwe(r,t.payload,i.signature):_d(r,t.payload,i.signature,t.namespace);return o.ok?{attested:!0,message:`sealed by ${o.principal}${o.key?` with ${o.key}`:""}, a signer ${n} lists`,...o.key?{key:o.key}:{}}:o.missing?{attested:null,code:"seal-unverifiable",message:`the seal by ${t.principal} can't be checked here: ${o.reason}`}:{attested:!1,code:"seal-signature-invalid",message:`the seal does not verify for ${t.principal} against ${n}: ${o.reason}`}}function Fwe(e,t,n){let i=e.filter(o=>Nf(o.namespaces,Rn)).map(o=>Buffer.from(o.key.split(" ")[1]??"","base64")),r=Qs(n,t,Rn,i);return r.ok?{ok:!0,principal:e[0].principal,key:r.key}:{ok:!1,reason:r.reason}}function nJ(e,t,n,i){if(i===Rn){let o=pU(n),s=o?Qs(n,t,i,[o]):{ok:!1,reason:"it is not an SSHSIG"};return s.ok?{attested:null,code:"seal-unverifiable",message:`the signature is intact (${s.key}), and there is no signers file at base to say whose key it is`,key:s.key}:{attested:!1,code:"seal-signature-invalid",message:`the seal by ${e} does not verify over this approval, even without a signers file`}}let r=XT(ul(tD(),"chant-seal-"));try{let o=ul(r,"signature");eD(o,n);let s=Ea(["-Y","check-novalidate","-n",i,"-s",o],t);if(s.missing)return{attested:null,code:"seal-unverifiable",message:`the seal by ${e} can't be checked here: ssh-keygen is not installed`};if(s.status!==0)return{attested:!1,code:"seal-signature-invalid",message:`the seal by ${e} does not verify over ${i===yk?"this record":i===Rn?"this approval":"this verdict"}, even without a signers file`};let a=iJ.exec(s.stdout+s.stderr)?.[1];return{attested:null,code:"seal-unverifiable",message:`the signature is intact${a?` (${a})`:""}, and there is no signers file at base to say whose key it is`,...a?{key:a}:{}}}finally{QT(r,{recursive:!0,force:!0})}}function Bwe(e,t){let n={cleanup:()=>{}};if(e!==!0)return{file:tJ(t,rJ(e)),...n};let i=c=>{try{return Nwe("git",["config","--get",c],{cwd:t,encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()||void 0}catch{return}},r=i("gpg.format"),o=i("user.signingkey");if(r!=="ssh"||o===void 0)throw new ll(`--sign with no key file uses git's user.signingkey when gpg.format is ssh, and git has ${r==="ssh"?"no user.signingkey":`gpg.format ${r??"unset"}`}; pass --sign <key file>`);let s=o.startsWith("key::")?o.slice(5):o.startsWith("ssh-")||o.startsWith("ecdsa-")||o.startsWith("sk-")?o:void 0;if(s===void 0)return{file:tJ(t,rJ(o)),...n};let a=XT(ul(tD(),"chant-sign-")),l=ul(a,"key.pub");return eD(l,`${s}
180
+ `),{file:l,cleanup:()=>QT(a,{recursive:!0,force:!0})}}function rJ(e){return e==="~"?eJ():e.startsWith("~/")?ul(eJ(),e.slice(2)):e}function Gwe(e,t){return sD(e,rD(t.record,t.digest,t.verdict,t.reviewer,t.on),nD,t.reviewer)}function Wwe(e,t){return sD(e,iD(t.record,t.digest,t.author,t.state),yk,t.author)}function zwe(e,t){return sD(e,no(t),Rn,t.resolvedBy)}function sD(e,t,n,i){let r=Ea(["-q","-Y","sign","-n",n,"-f",e],t);if(r.missing)throw new ll("--sign needs ssh-keygen, and it is not installed here");if(r.status!==0||!r.stdout.startsWith("-----BEGIN SSH SIGNATURE-----"))throw new ll(`ssh-keygen could not sign with ${e}: ${r.stderr.trim()||`exit ${r.status}`}`);let o=XT(ul(tD(),"chant-seal-"));try{let s=ul(o,"signature");eD(s,r.stdout);let a=Ea(["-Y","check-novalidate","-n",n,"-s",s],t),l=iJ.exec(a.stdout+a.stderr)?.[1];if(a.status!==0||!l)throw new ll(`the signature ssh-keygen made with ${e} does not check: ${a.stderr.trim()}`);return{signer:i,key:l,signature:r.stdout}}finally{QT(o,{recursive:!0,force:!0})}}var nD,yk,hk,iJ,ll,zd=v(()=>{"use strict";Bm();ta();ta();nD="chant-review",yk="chant-record";hk=e=>e.normalize("NFKC").trim().toLowerCase(),iJ=/key (SHA256:[A-Za-z0-9+/=]+)/;ll=class extends Error{constructor(t){super(t),this.name="SealError"}}});import{execFileSync as Uwe}from"node:child_process";import{dirname as Hwe,resolve as aD}from"node:path";async function mg(e,t=[]){let n=[...t.map(o=>aD(e,o))];try{n.push(...ci(e).map(o=>o.file))}catch(o){if(!(o instanceof ve))throw o}let i=new Set,r=[];for(let o of n){let s=Tn(o);if(!i.has(s)){i.add(s);try{let a=await gn(o,e);a.kind.session&&r.push(a)}catch(a){if(!(a instanceof Ve))throw a}}}return r}async function sJ(e,t){let n=Tn(aD(t,e));return(await mg(t)).filter(i=>Cm(i.kind.session).some(r=>Tn(aD(Hwe(i.file),r))===n))}function gg(e){let t=Un(Tn(e));if(!t)return null;try{return Jc(t,"HEAD")}catch(n){if(n instanceof Ve)return null;throw n}}function bk(e,t,n){try{return Uwe("git",["log",...n,"--format=%H","--",t],{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","pipe"]}).split(`
181
+ `).filter(Boolean)}catch{return[]}}var oJ,wk=v(()=>{"use strict";_t();mo();mn();vo();oJ=/^[A-Za-z][A-Za-z0-9]*-[0-9]+$/});var aJ={};_e(aJ,{CLOSE_ERROR_CODES:()=>Vwe,RECORDS_CLOSE_SCHEMA_ID:()=>vk,closeRecord:()=>Kwe});function qwe(e){return e.toISOString().replace(/\.\d{3}Z$/,"Z")}async function Kwe(e){try{if(e.expect!==void 0&&!/^[0-9a-f]{64}$/.test(e.expect))throw new he("write-usage-invalid",`--expect takes a record's digest, 64 lowercase hex digits as records --json prints it, not ${JSON.stringify(e.expect)}`);return await wo(e.cwd,Wi("records close",e),e.dryRun,()=>Jwe(e))}catch(t){return $o(vk,t)}}async function Jwe(e){try{let t=await xs(e.kind,e.cwd);dl(t,"close",e.cwd,e);let{kind:n}=t.loaded,i=n.session;if(!i||n.stateField===void 0)throw new he("write-usage-invalid",`the ${n.name} kind has no session block, and records close closes a review session; amend sets the state of other records`);let r=(n.closedStates??[])[0];if(r===void 0)throw new he("write-usage-invalid",`the ${n.name} kind lists no closed state, so a session of it can't close`);let o=await Gi(t,t.source),s=Ud(o,e.id,n.name);if(hg(t,s,e.id,e.expect),s.state!==null&&(n.closedStates??[]).includes(s.state))throw new he("record-closed",`${e.id} is already ${s.state}, and a closed session is sealed and stays as it is`);if(s.data===null)throw new he("record-unparseable",`${s.path} can't be read, so it can't be closed`);let a=s.data,l=gg(t.root),c={...yg(n,a,t.root),[n.stateField]:r,...i.closedOn?{[i.closedOn]:qwe(e.now??new Date)}:{},...i.closedRev?{[i.closedRev]:l}:{}},u={...a,...c};delete u[i.seal];let d=ks(t.source.read(s.path),c,u);if(d===void 0)throw new he("record-unparseable",`${s.path}: its fields can't be rewritten in place without changing the rest of the file`);let p=hv(d,i.seal,n.format);if(p===null)throw new he("record-unparseable",`${s.path} can't be read, so it can't be sealed`);let f=ks(d,{[i.seal]:p},{...u,[i.seal]:p});if(f===void 0||hv(f,i.seal,n.format)!==p)throw new he("record-unparseable",`${s.path}: the ${i.seal} line can't be added without changing the text it seals`);let g=await Ma(t,o,s.path,f);e.dryRun||(cl(xo(t,s.path),f),vs(t.root,[{path:s.path,text:f}],Wi("records close",e)));let h={...u,[i.seal]:p};return{$schema:vk,contract:ko,kind:t.view,path:s.path,id:e.id,changed:Object.keys(h).filter(b=>on(a[b])!==on(h[b])),seal:{field:i.seal,digest:p},closedRev:l,dryRun:!!e.dryRun,warnings:g.warnings,digest:g.digest,...e.dryRun?{text:f}:{}}}catch(t){return $o(vk,t)}}var vk,Vwe,cJ=v(()=>{"use strict";AI();mn();bg();pg();wk();ms();vk="https://intentius.io/chant/schemas/workspace/records-close/v1/records-close.schema.json",Vwe=[...La,"write-usage-invalid","record-not-found","record-closed","record-conflict",...Na,...Oa,...$a]});var _J={};_e(_J,{AMEND_ERROR_CODES:()=>eve,LOAD_ERROR_CODES:()=>La,NEW_ERROR_CODES:()=>Qwe,RECORDS_AMEND_SCHEMA_ID:()=>wg,RECORDS_NEW_SCHEMA_ID:()=>Fa,RECORDS_REVIEW_SCHEMA_ID:()=>vg,RECORDS_WRITE_CONTRACT_VERSION:()=>ko,REVIEW_ERROR_CODES:()=>tve,RecordWriteError:()=>he,VERDICTS:()=>dD,WRITE_USAGE:()=>OJ,abs:()=>xo,allocateId:()=>RJ,amendRecord:()=>AJ,declaredSessionKind:()=>CJ,declaredWriteKind:()=>fD,failure:()=>$o,findRecord:()=>Ud,isContentAddressed:()=>kk,newRecord:()=>EJ,open:()=>xs,openedRevFill:()=>yg,overlay:()=>kg,pick:()=>Ba,readAll:()=>Gi,refuseOutOfScope:()=>dl,refuseStale:()=>hg,removeField:()=>gJ,renderRecord:()=>pl,replaceFields:()=>ks,resolveWriteKind:()=>Vd,reviewRecord:()=>PJ,runRecordsWrite:()=>gve,schemaOrder:()=>Kd,slug:()=>pD,stableJson:()=>on,toYaml:()=>Hd,validateWrite:()=>xk,validatedEntry:()=>Ma,writeWho:()=>Wi});import{createHash as Zwe}from"node:crypto";import{readFileSync as Ywe,statSync as Xwe,writeFileSync as fJ}from"node:fs";import{join as mD,posix as qd,relative as lJ,resolve as mJ}from"node:path";function cD(e){return nve.test(e)&&!rve.has(e)?e:JSON.stringify(e)}function lD(e){return e===null||typeof e!="object"}function uJ(e){return Array.isArray(e)?e.length===0:e!==null&&typeof e=="object"&&Object.keys(e).length===0}function Hd(e,t=0){let n=" ".repeat(t);if(Array.isArray(e))return e.length===0?`${n}[]`:e.map(r=>lD(r)?`${n}- ${uD(r)}`:uJ(r)?`${n}- ${dJ(r)}`:Array.isArray(r)?`${n}-
182
+ ${Hd(r,t+2)}`:`${n}- ${Hd(r,t+2).slice(t+2)}`).join(`
183
+ `);if(lD(e))return`${n}${uD(e)}`;let i=[];for(let[r,o]of Object.entries(e))lD(o)?i.push(`${n}${cD(r)}: ${uD(o)}`):uJ(o)?i.push(`${n}${cD(r)}: ${dJ(o)}`):i.push(`${n}${cD(r)}:
184
+ ${Hd(o,t+2)}`);return i.join(`
185
+ `)}function pl(e,t){return`---
186
+ ${Hd(e)}
187
+ ---
188
+ ${t}`}function ive(e){let t=e.replace(/\r\n?/g,`
189
+ `),n=t.match(/^---\n[\s\S]*?\n---(?:\n|$)/);return n?t.slice(n[0].length):""}function on(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(on).join(",")}]`;let t=e;return`{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${on(t[n])}`).join(",")}}`}function ks(e,t,n){let i=e.replace(/\r\n?/g,`
190
+ `).split(`
191
+ `);if(i[0]!=="---")return;let r=i.indexOf("---",1);if(r<0)return;for(let[a,l]of Object.entries(t)){let c=Hd({[a]:l}).split(`
192
+ `),u=a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),d=new RegExp(`^(?:${u}|"${u}"|'${u}')[ \\t]*:(?:[ \\t]|$)`),p=i.findIndex((g,h)=>h>0&&h<r&&d.test(g));if(p<0){i.splice(r,0,...c),r+=c.length;continue}let f=p;for(;f+1<r&&/^(?:$|[ \t#-])/.test(i[f+1]);)f++;for(;f>p&&i[f]==="";)f--;i.splice(p,f-p+1,...c),r+=c.length-(f-p+1)}let o=i.join(`
193
+ `),s=ls(o);return s.ok&&on(s.value)===on(n)?o:void 0}function gJ(e,t,n){let i=e.replace(/\r\n?/g,`
194
+ `).split(`
195
+ `);if(i[0]!=="---")return;let r=i.indexOf("---",1);if(r<0)return;let o=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=new RegExp(`^(?:${o}|"${o}"|'${o}')[ \\t]*:(?:[ \\t]|$)`),a=i.findIndex((u,d)=>d>0&&d<r&&s.test(u));if(a>=0){let u=a;for(;u+1<r&&/^(?:$|[ \t#-])/.test(i[u+1]);)u++;for(;u>a&&i[u]==="";)u--;i.splice(a,u-a+1)}let l=i.join(`
196
+ `),c=ls(l);return c.ok&&on(c.value)===on(n)?l:void 0}function pD(e){return e.toLowerCase().replace(/`/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,48).replace(/-$/,"")}function kk(e){return e.format==="json"&&e.idFrom==="sha256"}async function xs(e,t,n={}){let i=Tn(t),r=Un(i)??i,o=await gn(e,i);if(!(o.kind.format==="markdown-front-matter"&&o.kind.idField!==void 0||!!n.contentAddressed&&kk(o.kind))){let l=o.kind.format!=="markdown-front-matter"?`format ${o.kind.format}`:`ids from ${o.kind.idFrom}`,c=kk(o.kind)?"a content-addressed record never changes once records new writes it, so amend, review and close never write one":"records new, amend and review write only Markdown front matter records with an idField, and records new a JSON record named for the sha256 of its bytes";throw new he("write-usage-invalid",`the ${o.kind.name} kind has ${l}: ${c}`)}let a=lJ(r,o.dir).split("\\").join("/")||".";return{loaded:o,root:r,workspaceRoot:$k(o.file,r),source:Ad(r),view:{name:o.kind.name,schema:o.kind.schema.id,file:lJ(r,o.file).split("\\").join("/")},dirRel:a}}function dl(e,t,n,i){let r=aT(n,{kindName:e.loaded.kind.name,kindFile:e.loaded.file,recordsDir:e.loaded.dir,verb:t,agent:i.agent,principal:i.by});return i.by!==void 0&&hs(r,[i.by],"--by",{agent:i.agent}),r}function hJ(e,t,n,i,r){let o=[t.reviews?.decider,t.proposedBy?.field].filter(s=>s!==void 0).map(s=>n[s]).filter(s=>typeof s=="string"&&s.trim()!=="");hs(e,o,`${i} author`,{agent:r})}async function Gi(e,t){let n=$n(e.workspaceRoot==="."?e.root:mD(e.root,...e.workspaceRoot.split("/"))),i=await kv(e.loaded,e.root,t);return(await ka(e.loaded,{root:e.root,source:t,assets:n,workspaceRoot:e.workspaceRoot,...i?{subjects:i}:{}})).records}function kg(e,t,n){let i=qd.dirname(t),r=qd.basename(t);return{label:e.label,list(o){let s=e.list(o);return o!==i||!s||s.includes(r)?s:[...s,r]},read(o){return o===t?n:e.read(o)},bytes(o){return o===t?Buffer.from(n,"utf-8"):e.bytes(o)}}}async function xk(e,t,n,i,r=e.source){return(await Ma(e,t,n,i,r)).warnings}async function Ma(e,t,n,i,r=e.source){let o=await Gi(e,kg(r,n,i)),s=o.find(l=>l.path===n);if(!s)throw new he("record-path-unmatched",`${n} is not a file the kind ${e.view.name} reads`);if(s.reasons.length>0)throw new he(s.reasons[0].code,s.reasons.map(l=>`${l.code}: ${l.message}`).join("; "));let a=new Map(t.map(l=>[l.path,new Set(l.reasons.map(c=>`${c.code}\0${c.message}`))]));for(let l of o){if(l.path===n)continue;let c=l.reasons.find(u=>!a.get(l.path)?.has(`${u.code}\0${u.message}`));if(c)throw new he(c.code,`writing ${n} would make ${l.path} invalid: ${c.message}`)}return s}async function yJ(e,t,n){let i=e.loaded.kind.reviews?.ratified;if(i===void 0||t.state!==i)return;let r=Un(e.root),o=si(r??e.root,r?Br(r):{commit:null,from:null}),s=$n(e.workspaceRoot==="."?e.root:mD(e.root,...e.workspaceRoot.split("/"))),a=await xg(e.loaded,s,o),l=a?$v(e.loaded.kind,t,a):null;if(l===null||l.met)return;let c=l.notCounted.length>0?` (not counted: ${l.notCounted.map(u=>`${u.reviewer}, ${u.reason.code}`).join("; ")})`:"";throw new he("ratify-quorum-not-met",`${n} can't be ${i} yet: its quorum needs ${l.need} agreeing verdicts that count, and it has ${l.agreed}${c}. Add verdicts with chant workspace records review ${n} --verdict agree --by <reviewer>, then set ${e.loaded.kind.stateField} to ${i} again`)}function hg(e,t,n,i){if(i===void 0||i===t.digest)return;let r=gk(e.root)(t.path,e.source.read(t.path)),o=r?` It was last written by chant workspace ${r.verb}${r.by?` for ${r.by}`:""}${r.agent?` in agent session ${r.agent}`:""} at ${r.at}.`:"";throw new he("record-conflict",`${n} has changed since the digest given with --expect (${i}): its digest is now ${t.digest}.${o} Read it again with chant workspace records --json, and write again with --expect ${t.digest} if the change still stands`,{id:n,path:t.path,expected:i,digest:t.digest,lastWrite:r})}function bJ(e){if(e!==void 0&&!/^[0-9a-f]{64}$/.test(e))throw new he("write-usage-invalid",`--expect takes a record's digest, 64 lowercase hex digits as records --json prints it, not ${JSON.stringify(e)}`)}function Wi(e,t){return{verb:e,by:t.by??null,agent:t.agent??null}}function Ud(e,t,n){let i=e.filter(r=>r.id===t);if(i.length===0)throw new he("record-not-found",`no ${n} record has id ${t}`);if(i.length>1)throw new he("record-id-duplicate",`id ${t} is used by ${i.map(r=>r.path).join(" and ")}; make the ids unique before writing either`);return i[0]}function wJ(e,t){let n;try{n=JSON.parse(e)}catch(i){throw new he("write-input-invalid",`the fields given with ${t} are not JSON: ${i instanceof Error?i.message:String(i)}`)}if(n===null||typeof n!="object"||Array.isArray(n))throw new he("write-input-invalid",`the fields given with ${t} must be a JSON object`);return n}function vJ(e,t,n){if(e.loaded.kind.reviews&&rn in t)throw new he("write-input-invalid",`the fields given with ${n} set ${rn}, and only --sign writes a record's seal`);let i=e.loaded.kind.seal?.field;if(i!==void 0&&!e.loaded.kind.session&&i in t)throw new he("write-input-invalid",`the fields given with ${n} set ${i}, and chant writes it when the record closes`)}function kJ(e,t,n,i){let{kind:r}=e.loaded;if(!r.seal||r.session||r.stateField===void 0)return{text:t,data:n};let o=n[r.stateField];if(typeof o!="string"||!(r.closedStates??[]).includes(o))return{text:t,data:n};let s=r.seal.field,a=yd(t,s,r.format);if(a===null)throw new he("record-unparseable",`${i} can't be read, so it can't be sealed`);let l={...n,[s]:a},c=ks(t,{[s]:a},l);if(c===void 0||yd(c,s,r.format)!==a)throw new he("record-unparseable",`the ${s} field can't be written into ${i} without changing the text it seals`);return{text:c,data:l}}function xJ(e,t,n,i){for(let r of[e.session?.openedRev,e.session?.closedRev])if(!(r===void 0||!(r in t)||r in n&&on(n[r])===on(t[r])))throw new he("write-input-invalid",`the fields given with ${i} set ${r}, and chant writes it: records new writes the commit a session opened at, and records close the one it closed at`)}function ove(e,t){if(!e.source||!e.states||e.stateField===void 0)return;let n=t[e.source.field];if(n===null||typeof n!="object"||Array.isArray(n)||n.via!=="harvest")return;let i=e.states[0],r=t[e.stateField];if(r!==i)throw new he("source-harvest-not-proposed",`${e.source.field}.via is harvest, and a harvested ${e.name} opens ${i}, not ${JSON.stringify(r??null)}: write it with ${e.stateField} "${i}", and let the person who decides it move it on with chant workspace records amend or review`)}async function $J(e,t,n,i,r,o){let{kind:s}=e.loaded;if(!s.reviews)throw new he("write-usage-invalid",`--sign seals a record's author, named by the kind's reviews.decider field, and the ${s.name} kind declares no reviews`);let a=s.reviews.decider,l=n[a];if(typeof l!="string"||l.trim()==="")throw new he("record-sign-failed",`${i} names no ${a}, so there is no author to seal: set ${a}, then seal it with records amend ${i} --sign`);let c=s.stateField!==void 0&&typeof n[s.stateField]=="string"?n[s.stateField]:null,u=Kc(t,qc(s),s.format),{resolveSigningKey:d,sealRecord:p,SealError:f}=await Promise.resolve().then(()=>(zd(),Wd)),g;try{let b=d(r,o);try{g={...p(b.file,{record:i,digest:u,author:l,state:c})}}finally{b.cleanup()}}catch(b){throw b instanceof f?new he("record-sign-failed",b.message):b}let h=ks(t,{[rn]:g},{...n,[rn]:g});if(h===void 0)throw new he("record-unparseable",`the ${rn} field can't be written into ${i} without changing the rest of the file`);if(Kc(h,qc(s),s.format)!==u)throw new Error(`sealing ${i} moved its digest; the seal block and the digest rule disagree`);return{text:h,seal:g}}function sve(e,t,n){let{kind:i,schema:r}=e.loaded;if(i.session)return`A closed session is sealed and stays as it is: open a new session for what follows, with chant workspace records new ${e.view.file}`;let o=r.properties!==null&&typeof r.properties=="object"?r.properties:{};return i.supersedes&&(r.additionalProperties!==!1||i.supersedes.field in o)?`Write a new record that supersedes it: ${n}`:`Write a new record in its place with chant workspace records new ${e.view.file}; the ${i.name} schema has no field that links it to ${t}`}function yg(e,t,n){let i=e.session?.openedRev;if(i===void 0||t[i]!==null)return{};let r=gg(n);return r===null?{}:{[i]:r}}function Kd(e,t){let n=Array.isArray(t.required)?t.required.filter(s=>typeof s=="string"):[],i=t.properties!==null&&typeof t.properties=="object"?Object.keys(t.properties):[],r=[...new Set([...n,...i])],o=Object.keys(e);return[...r.filter(s=>o.includes(s)),...o.filter(s=>!r.includes(s))]}function Ba(e,t){return Object.fromEntries(t.map(n=>[n,e[n]]))}function xo(e,t){return mD(e.root,...t.split("/"))}function ave(){return new Date().toISOString().slice(0,10)}function $o(e,t){if(t instanceof he||t instanceof Ve||t instanceof fs||t instanceof gs||t instanceof Da){let n=t instanceof he?t.conflict:void 0;return{$schema:e,contract:ko,error:{code:t.code,message:t.message},...n?{conflict:n}:{}}}throw t}function RJ(e,t,n){let i=[];for(let a of e){let c=(a.id??qd.basename(a.path).match(/^([A-Za-z][A-Za-z0-9]*-[0-9]+)/)?.[1]??null)?.match(cve);c&&i.push({prefix:c[1],digits:c[2]})}if(t===void 0){let a=[...new Set(i.map(l=>l.prefix))];if(a.length!==1)throw new he("record-id-unallocatable",a.length===0?`no ${n} record has an id of the form <prefix>-<number> to follow; pass --prefix <prefix>, or give the id in the fields`:`the ${n} records use the prefixes ${a.join(", ")}; pass --prefix with one of them, or give the id in the fields`);t=a[0]}let r=i.filter(a=>a.prefix===t),o=r.reduce((a,l)=>Math.max(a,Number(l.digits)),0),s=Math.max(3,...r.map(a=>a.digits.length));return`${t}-${String(o+1).padStart(s,"0")}`}function SJ(e,t,n,i,r){let{kind:o}=e.loaded,s={...t},a=n.through;if(i&&a?.opensInitial&&o.states&&o.stateField!==void 0){let l=o.states[0],c=s[o.stateField];if(c===void 0)s[o.stateField]=l;else if(c!==l)throw new he("record-state-not-initial",`a new ${o.name} opens ${l}, and the fields give ${o.stateField} ${JSON.stringify(c)}: write it ${l}, and let the person who decides it move it on with a review or an amendment`)}if(n.by!==void 0){if(n.by.trim()==="")throw new he("write-usage-invalid","by needs the name of the person or agent that proposed or decided");let l=i&&!!o.states&&o.stateField!==void 0&&(s[o.stateField]===void 0||s[o.stateField]===o.states[0]);if(o.proposedBy&&l){let c=o.proposedBy.field;if(s[c]!==void 0&&s[c]!==null&&s[c]!==n.by)throw new he("write-input-invalid",`the fields given with ${r} set ${c} to ${JSON.stringify(s[c])}, and by names ${JSON.stringify(n.by)}: give one proposer`);s[c]=n.by}else{if(!o.reviews)throw new he("write-usage-invalid",`by names a record's author, the kind's reviews.decider field, and the ${o.name} kind declares no reviews`);let c=o.reviews.decider;if(s[c]!==void 0&&s[c]!==null&&s[c]!==n.by)throw new he("write-input-invalid",`the fields given with ${r} set ${c} to ${JSON.stringify(s[c])}, and by names ${JSON.stringify(n.by)}: give one author`);s[c]=n.by}}if(!a)return s;if(o.source&&(i||o.source.field in s)){let l=o.source.field,c=s[l];c==null?s[l]={...a.source}:typeof c=="object"&&!Array.isArray(c)&&(s[l]={...c,...a.source})}return s}async function EJ(e){try{return await wo(e.cwd,Wi("records new",e),e.dryRun,()=>lve(e))}catch(t){return $o(Fa,t)}}async function lve(e){try{if(e.prefix!==void 0&&!/^[A-Za-z][A-Za-z0-9]*$/.test(e.prefix))throw new he("write-usage-invalid",`--prefix takes letters and digits, starting with a letter, not ${JSON.stringify(e.prefix)}`);let t=await xs(e.kind,e.cwd,{contentAddressed:!0}),n=dl(t,"new",e.cwd,e),i=SJ(t,wJ(e.fields,"--from"),e,!0,"--from"),{kind:r,schema:o}=t.loaded;if(hJ(n,r,i,"--from",e.agent),vJ(t,i,"--from"),xJ(r,i,{},"--from"),kk(r))return await uve(t,i,e);let s=r.idField,a=await Gi(t,t.source),l=i[s],c;if(l===void 0)c=RJ(a,e.prefix,r.name);else{if(typeof l!="string"||l==="")throw new he("write-input-invalid",`${s} must be a non-empty string when it is given`);let _=a.find(T=>T.id===l||qd.basename(T.path).startsWith(`${l}-`)||qd.basename(T.path)===`${l}.md`);if(_)throw new he("record-id-taken",`id ${l} is already used by ${_.path}; ids are never reused, so leave ${s} out to have the next one allocated`);c=l}ove(r,i);let u=r.session?.openedRev?{[r.session.openedRev]:gg(t.root)}:{},d={...i,...u,[s]:c},p=Ba(d,Kd(d,o)),f=typeof p.title=="string"?p.title:"",g=new RegExp(r.location.match),h=[pD(f)?`${c}-${pD(f)}.md`:null,`${c}.md`].filter(_=>_!==null),b=h.find(_=>g.test(_));if(!b)throw new he("record-path-unmatched",`the kind's location.match ${r.location.match} matches none of ${h.join(", ")}`);let w=t.dirRel==="."?b:`${t.dirRel}/${b}`;if(t.source.list(t.dirRel)?.includes(b))throw new he("record-id-taken",`${w} already exists`);let x=pl(p,f?`
197
+ # ${f}
198
+ `:""),k;e.sign!==void 0&&({text:x,seal:k}=await $J(t,x,p,c,e.sign,e.cwd)),{text:x}=kJ(t,x,k?{...p,[rn]:k}:p,c);let R=await Ma(t,a,w,x);await yJ(t,R,c);let $=R.warnings;return e.dryRun||(fJ(xo(t,w),x,{flag:"wx"}),vs(t.root,[{path:w,text:x}],Wi("records new",e))),{$schema:Fa,contract:ko,kind:t.view,path:w,id:c,...k?{seal:k}:{},dryRun:!!e.dryRun,warnings:$,digest:R.digest,...e.dryRun?{text:x}:{}}}catch(t){return $o(Fa,t)}}async function uve(e,t,n){let{kind:i,schema:r}=e.loaded;if(n.prefix!==void 0)throw new he("write-usage-invalid",`the ${i.name} kind's ids are the sha256 of each record's bytes, so --prefix allocates nothing`);if(n.sign!==void 0)throw new he("write-usage-invalid",`the ${i.name} kind names no author to seal: its records are named for the sha256 of their bytes`);let o=Ba(t,Kd(t,r)),s=`${JSON.stringify(o,null,2)}
199
+ `,a=Zwe("sha256").update(s,"utf-8").digest("hex"),l=`${a}.json`;if(!new RegExp(i.location.match).test(l))throw new he("record-path-unmatched",`the kind's location.match ${i.location.match} does not match ${l}`);let c=e.dirRel==="."?l:`${e.dirRel}/${l}`;if(e.source.list(e.dirRel)?.includes(l))throw new he("record-id-taken",`${c} already exists, with the same bytes: the record is already written`);let u=await Gi(e,e.source),d=await Ma(e,u,c,s);return n.dryRun||(fJ(xo(e,c),s,{flag:"wx"}),vs(e.root,[{path:c,text:s}],Wi("records new",n))),{$schema:Fa,contract:ko,kind:e.view,path:c,id:a,dryRun:!!n.dryRun,warnings:d.warnings,digest:d.digest,...n.dryRun?{text:s}:{}}}async function AJ(e){try{return bJ(e.expect),await wo(e.cwd,Wi("records amend",e),e.dryRun,()=>dve(e))}catch(t){return $o(wg,t)}}async function dve(e){try{let t=await xs(e.kind,e.cwd),n=dl(t,"amend",e.cwd,e),i=SJ(t,wJ(e.fields,"--set"),e,!1,"--set"),{kind:r}=t.loaded;hJ(n,r,i,"--set",e.agent),vJ(t,i,"--set");let o=await Gi(t,t.source),s=Ud(o,e.id,r.name);hg(t,s,e.id,e.expect);let a=s.data;xJ(r,i,a,"--set");let c={...s.state!==null&&(r.closedStates??[]).includes(s.state)?{}:yg(r,a,t.root),...i},u=Object.keys(c).filter(C=>!(C in a)),d=Ba({...a,...c},[...Object.keys(a),...Kd(Ba(c,u),t.loaded.schema)]),p=Object.keys(d).filter(C=>on(a[C])!==on(d[C]));if(p.includes(r.idField))throw new he("amend-id-immutable",`${r.idField} never changes: ids are never renumbered. Write a new record that supersedes ${e.id} instead`);let f=s.state,g=r.supersedes?.key===void 0?JSON.stringify(e.id):`[{"${r.supersedes.key}": "${e.id}"}]`,h=r.supersedes?`chant workspace records new with ${r.supersedes.field}: ${g}`:"chant workspace records new";if((p.length>0||e.sign!==void 0)&&f!==null&&(r.closedStates??[]).includes(f))throw new he("record-closed",`${e.id} is ${f}, a closed state, so nothing in it changes. ${sve(t,e.id,h)}`);let b=C=>typeof C=="string"?r.approval?.[C]??0:0;if(p.length>0&&r.approval&&b(f)>0){let C=[r.stateField,r.pins?.field,r.reviews?.field].filter(pe=>typeof pe=="string"),K=(r.states??[]).filter(pe=>b(pe)>=b(f)),O=p.filter(pe=>!C.includes(pe));if(O.length>0)throw new he("amend-supersede-instead",`${e.id} is ${f}, so ${O.join(", ")} can't change in place: only ${C.join(", ")} may. Write the change as a new record that supersedes it (${h}); it replaces ${e.id} once it is ${K.filter(pe=>b(pe)>0).join(" or ")}`);if(r.stateField!==void 0&&p.includes(r.stateField)&&b(d[r.stateField])<b(f))throw new he("amend-supersede-instead",`${e.id} is ${f}, and ${JSON.stringify(d[r.stateField])} is approved less strongly: a state only moves to ${K.join(", ")}. Write a new record that supersedes it (${h})`)}let w=t.source.read(s.path),x=p.length===0?w:ks(w,Ba(d,p),d)??pl(d,ive(w)),k,R,$=r.reviews!==void 0&&rn in a;if(e.sign!==void 0)({text:x,seal:k}=await $J(t,x,d,e.id,e.sign,e.cwd)),d[rn]=k;else if($&&(Kc(x,qc(r),r.format)!==Kc(w,qc(r),r.format)||r.stateField!==void 0&&on(a[r.stateField])!==on(d[r.stateField]))){let C=a[rn]?.signer;delete d[rn];let K=gJ(x,rn,d);if(K===void 0)throw new he("record-unparseable",`${s.path}: the ${rn} block can't be removed without changing the rest of the file`);x=K,R=`${e.id} was sealed${typeof C=="string"?` by ${C}`:""}, and the amendment moves its digest or its state, so the seal was removed: seal it again with records amend ${e.id} --sign`}if(on(a[rn])!==on(d[rn])&&p.push(rn),p.length>0&&r.seal&&!r.session){let C=kJ(t,x,d,e.id);x=C.text,on(a[r.seal.field])!==on(C.data[r.seal.field])&&p.push(r.seal.field)}let _=s.warnings,T=s.digest;if(p.length>0){let C=await Ma(t,o,s.path,x);r.stateField!==void 0&&p.includes(r.stateField)&&await yJ(t,C,e.id),_=C.warnings,T=C.digest}return!e.dryRun&&p.length>0&&(cl(xo(t,s.path),x),vs(t.root,[{path:s.path,text:x}],Wi("records amend",e))),{$schema:wg,contract:ko,kind:t.view,path:s.path,id:e.id,changed:p,...k?{seal:k}:{},...R?{sealDropped:R}:{},dryRun:!!e.dryRun,warnings:_,digest:T,...e.dryRun?{text:x}:{}}}catch(t){return $o(wg,t)}}async function PJ(e){try{return bJ(e.expect),await wo(e.cwd,Wi("records review",e),e.dryRun,()=>pve(e))}catch(t){return $o(vg,t)}}async function pve(e){try{if(!dD.includes(e.verdict))throw new he("write-usage-invalid",`--verdict takes ${dD.join(", ")}, not ${JSON.stringify(e.verdict)}`);if(e.by.trim()==="")throw new he("write-usage-invalid","--by needs the reviewer's name");if(e.session!==void 0&&e.session==="")throw new he("write-usage-invalid","--session needs a session id");let t=await xs(e.kind,e.cwd);dl(t,"review",e.cwd,e);let{kind:n}=t.loaded;if(!n.reviews)throw new he("review-unsupported",`the ${n.name} kind declares no reviews field, so its records take no review`);let i=n.reviews.field,r=await Gi(t,t.source),o=Ud(r,e.id,n.name);if(hg(t,o,e.id,e.expect),o.state!==null&&(n.closedStates??[]).includes(o.state))throw new he("record-closed",`${e.id} is ${o.state}, a closed state, so it takes no more reviews`);if(e.verdict==="dissent"&&!(e.note??"").trim())throw new he("review-note-required","a dissent needs a reason: pass --note <text> with the concern");let s=e.session!==void 0?await fve(t,e.session,e.cwd):void 0;s&&dl(s.so,"review",e.cwd,e);let a=o.data[i]??[];if(!Array.isArray(a))throw new he("record-schema-invalid",`${o.path}: ${i} is not a list`);let l=t.source.read(o.path),c={reviewer:e.by,verdict:e.verdict,...e.note!==void 0?{note:e.note}:{},on:e.on??ave(),digest:Kc(l,qc(n),n.format),...e.session!==void 0?{session:e.session}:{}};e.sign!==void 0&&(c.seal=await mve(e.sign,e.cwd,{record:e.id,digest:c.digest,verdict:e.verdict,reviewer:e.by,on:c.on}));let u=[...a,c],d=ks(l,{[i]:u},{...o.data,[i]:u});if(d===void 0)throw new he("record-unparseable",`${o.path}: the ${i} block can't be rewritten in place without changing the rest of the file`);let p=await Ma(t,r,o.path,d),f=p.warnings,g;if(s){let{so:h,before:b,target:w}=s,x=h.loaded.kind.session,k=w.data[x.verdicts]??[];if(!Array.isArray(k))throw new he("record-schema-invalid",`${w.path}: ${x.verdicts} is not a list`);let R={record:e.id,principal:e.by,verdict:e.verdict,digest:c.digest},$={...yg(h.loaded.kind,w.data,h.root),[x.verdicts]:[...k,R]},_=ks(h.source.read(w.path),$,{...w.data,...$});if(_===void 0)throw new he("record-unparseable",`${w.path}: the ${x.verdicts} block can't be rewritten in place without changing the rest of the file`);await xk(h,b,w.path,_,kg(t.source,o.path,d)),g={path:w.path,text:_,out:{id:e.session,path:w.path,verdict:R,...e.dryRun?{text:_}:{}}}}return e.dryRun||(cl(xo(t,o.path),d),g&&cl(xo(t,g.path),g.text),vs(t.root,[{path:o.path,text:d},...g?[{path:g.path,text:g.text}]:[]],Wi("records review",e))),{$schema:vg,contract:ko,kind:t.view,path:o.path,id:e.id,review:c,...g?{session:g.out}:{},dryRun:!!e.dryRun,warnings:f,digest:p.digest,...e.dryRun?{text:d}:{}}}catch(t){return $o(vg,t)}}async function fve(e,t,n){let i=await sJ(e.loaded.file,n);for(let r of i){let o=await xs(r.file,n),s=await Gi(o,o.source);if(!s.some(l=>l.id===t))continue;let a=Ud(s,t,o.view.name);if(a.data===null)throw new he("record-unparseable",`session ${t} (${a.path}) can't be read, so the verdict can't be added to it`);if(a.state!==null&&(o.loaded.kind.closedStates??[]).includes(a.state))throw new he("session-not-open",`session ${t} is ${a.state}, so it takes no more verdicts: give the verdict in an open session, or without --session`);return{so:o,before:s,target:a}}throw new he("session-unknown",i.length===0?`no session kind the workspace declaration names has ${e.view.file} as its subjects, so there is no session ${t} to give the verdict in`:`no ${i.map(r=>r.kind.name).join(" or ")} record has id ${t}`)}async function mve(e,t,n){let{resolveSigningKey:i,sealVerdict:r,SealError:o}=await Promise.resolve().then(()=>(zd(),Wd));try{let s=i(e,t);try{return{...r(s.file,n)}}finally{s.cleanup()}}catch(s){throw s instanceof o?new he("review-sign-failed",s.message):s}}function Gr(e,t){return{$schema:e,contract:ko,error:{code:"write-usage-invalid",message:`${t}
200
+ ${OJ}`}}}function fD(e,t,n){let i;try{i=ci(t)}catch(r){if(!(r instanceof ve))throw r;return Gr(e,`${n}; the declaration can't name one: ${r.code}: ${r.describe()}`)}return i.length===0?Gr(e,n):i.length>1?Gr(e,`the declaration names ${i.length} record kinds (${i.map(r=>r.declared.path).join(", ")}), so name the one to write with --kind`):i[0].file}function Vd(e,t){try{if(Xwe(mJ(t,e)).isFile())return e}catch{}let n;try{n=ci(t)}catch{return e}let i=n.filter(r=>(r.declared.name??qd.basename(r.declared.path).replace(/(?:\.kind)?\.[cm]?[jt]s$/,""))===e);return i.length===1?i[0].file:e}function pJ(e,t,n,i){if(n===void 0||n==="")return Gr(e,`${t} <file|-> is required`);try{return Ywe(n==="-"?0:mJ(i,n),"utf-8")}catch(r){return{$schema:e,contract:ko,error:{code:"write-input-invalid",message:`${t} ${n} could not be read: ${r instanceof Error?r.message:String(r)}`}}}}async function CJ(e,t){let n=(await mg(t)).map(i=>i.file);return n.length===1?n[0]:n.length===0?Gr(e,"--kind <session kind file> is required: the declaration names no session kind"):Gr(e,`the declaration names ${n.length} session kinds (${n.join(", ")}), so name the one to close with --kind`)}async function gve(e){let{args:t}=e,n=process.cwd(),i=t.extraPositional,r=process.env[nT]||void 0,o=c=>(console.log(JSON.stringify(c,null,2)),"error"in c?1:0);if(i==="close"){let{closeRecord:c,RECORDS_CLOSE_SCHEMA_ID:u}=await Promise.resolve().then(()=>(cJ(),aJ));if(t.sign!==void 0)return o(Gr(u,"--sign is not taken by close: the seal close writes is the digest of the session text"));let d=t.extraPositional2;if(!d)return o(Gr(u,"close needs the session's id"));let p=t.kind!==void 0?Vd(t.kind,n):await CJ(u,n);return o(typeof p!="string"?p:await c({kind:p,id:d,dryRun:t.dryRun,cwd:n,agent:r,expect:t.expect}))}if(i==="new"){let c=t.extraPositional2??t.kind,u=c!==void 0?Vd(c,n):fD(Fa,n,"new needs the kind file");if(typeof u!="string")return o(u);if(t.expect!==void 0)return o(Gr(Fa,"--expect is not taken by new: a new record has no digest yet, and its id is allocated under the write lock"));let d=pJ(Fa,"--from",t.migrateFrom,n);return o(typeof d!="string"?d:await EJ({kind:u,fields:d,prefix:t.prefix,by:t.by,sign:t.sign,dryRun:t.dryRun,cwd:n,agent:r}))}let s=i==="amend"?wg:vg,a=t.extraPositional2;if(!a)return o(Gr(s,`${i} needs the record's id`));let l=t.kind!==void 0?Vd(t.kind,n):fD(s,n,"--kind <kind file> is required");if(typeof l!="string")return o(l);if(i==="amend"){if(t.by!==void 0)return o(Gr(s,"--by is not taken by amend: set decided_by, or a kind's proposedBy field, with --set"));let c=pJ(s,"--set",t.set,n);return o(typeof c!="string"?c:await AJ({kind:l,id:a,fields:c,sign:t.sign,dryRun:t.dryRun,cwd:n,agent:r,expect:t.expect}))}return t.verdict===void 0?o(Gr(s,"--verdict agree|dissent|abstain is required")):t.by===void 0?o(Gr(s,"--by <principal> is required")):o(await PJ({kind:l,id:a,verdict:t.verdict,by:t.by,note:t.note,session:t.session,sign:t.sign,dryRun:t.dryRun,cwd:n,agent:r,expect:t.expect}))}var ko,Fa,wg,vg,La,Qwe,eve,tve,dD,he,nve,rve,uD,dJ,cve,OJ,bg=v(()=>{"use strict";mo();mn();vo();Zc();_t();wk();Zt();ms();Qc();pg();ko=1,Fa="https://intentius.io/chant/schemas/workspace/records-new/v1/records-new.schema.json",wg="https://intentius.io/chant/schemas/workspace/records-amend/v1/records-amend.schema.json",vg="https://intentius.io/chant/schemas/workspace/records-review/v1/records-review.schema.json",La=["kind-unreadable","kind-invalid","schema-unreadable","schema-id-mismatch","schema-invalid","location-missing"],Qwe=[...La,"write-usage-invalid","write-input-invalid","record-id-taken","record-id-unallocatable","record-path-unmatched","record-sign-failed","source-harvest-not-proposed","record-state-not-initial","ratify-quorum-not-met",...Na,...Oa,...Xc,...$a],eve=[...La,"write-usage-invalid","write-input-invalid","record-not-found","amend-id-immutable","record-closed","amend-supersede-instead","record-sign-failed","ratify-quorum-not-met","record-conflict",...Na,...Oa,...Xc,...$a],tve=[...La,"write-usage-invalid","record-not-found","review-unsupported","record-closed","review-note-required","review-sign-failed","session-unknown","session-not-open","record-conflict",...Na,...Oa,...Xc,...$a],dD=["agree","dissent","abstain"],he=class extends Error{constructor(n,i,r){super(i);this.code=n;this.conflict=r;this.name="RecordWriteError"}},nve=/^[A-Za-z_][A-Za-z0-9_-]*$/,rve=new Set(["true","false","null"]);uD=e=>e===null?"null":JSON.stringify(e),dJ=e=>Array.isArray(e)?"[]":"{}";cve=/^([A-Za-z][A-Za-z0-9]*)-([0-9]+)$/;OJ=["chant workspace records new [<kind file or declared kind>] --from <file|-> [--prefix <prefix>] [--by <name>] [--sign [<key file>]] [--dry-run]","chant workspace records amend <id> [--kind <kind file>] --set <file|-> [--expect <digest>] [--sign [<key file>]] [--dry-run]","chant workspace records review <id> [--kind <kind file>] --verdict agree|dissent|abstain --by <principal> [--note <text>] [--session <id>] [--expect <digest>] [--sign [<key file>]] [--dry-run]","chant workspace records close <session id> [--kind <session kind file>] [--expect <digest>] [--dry-run]"].join(`
201
+ `)});var hD={};_e(hD,{ANSWERS_LEDGER_DIR:()=>TJ,answersLedgerDir:()=>NJ,readLedgerAnswers:()=>$g,refreshLedger:()=>Rk,withLedgerAnswers:()=>Rg,writeLedgerAnswer:()=>gD});import{basename as hve,dirname as IJ}from"node:path";function NJ(e){return`${TJ}/${e.replace(/[^A-Za-z0-9._-]/g,"_")}`}function yve(e,t){return e==="."?t:`${e}/${t}`}async function $g(e){let t=IJ(e.file),n=NJ(e.name),i={cwd:t,dir:n,dirRel:e.dirRel,byPath:new Map};try{let r=(await Lc(n,{cwd:t})).filter(s=>s.endsWith(".md"));if(r.length===0)return i;let o=await ii(n,{cwd:t});for(let s of r){let a=await xr(n,s,{cwd:t}),l=a?await fn(a,{cwd:t}):null;if(a===null||l===null)continue;let c=yve(e.dirRel,s);i.byPath.set(c,{path:c,ledger:`${DJ}:${o}/${s}`,text:l,sha:a})}}catch{}return i}function Rg(e,t){let n=e;for(let i of t.byPath.values())n=kg(n,i.path,i.text);return n}async function Rk(e){await ya({cwd:IJ(e)}).catch(()=>{})}async function gD(e,t,n,i,r){let o=hve(t);await An(e.dir,o,n,i,{cwd:e.cwd,expectPriorPathSha:r});let s=await Mc({cwd:e.cwd}).catch(()=>!1);return{ledger:`${DJ}:${await ii(e.dir,{cwd:e.cwd})}/${o}`,pushed:s}}var TJ,DJ,Sg=v(()=>{"use strict";$t();bg();TJ="_answers",DJ="chant/lifecycle"});import{randomUUID as bve}from"node:crypto";function Sk(e,t=""){return`${yD}${t}${e}`}function wve(e,t=""){return`${bD}${t}${e}`}async function vD(e,t){let{prefix:n}=await ri(t?.cwd??process.cwd());return{ref:Sk(e,n),trackingRef:wve(e,n)}}function jJ(e){return e?`${e.acquiredAt} ${e.expiresAt}`:""}function vve(e,t){return new Date(e.expiresAt).getTime()<=t.getTime()}function kve(e){try{let t=JSON.parse(e);return typeof t.op=="string"&&typeof t.holder=="string"&&typeof t.token=="string"&&typeof t.acquiredAt=="string"&&typeof t.expiresAt=="string"?t:void 0}catch{return}}async function LJ(e,t){let n=await Fc(e,t);return{sha:n,record:n?kve(await fn(n,t)??""):void 0}}async function Ga(e,t){let{ref:n,trackingRef:i}=await vD(e,t);if(await rv(n,i,t).catch(()=>"failed")==="missing"){let u=await Fc(i,t);u&&await ad(i,u,t).catch(()=>{})}let{sha:o,record:s}=await LJ(n,t),{sha:a,record:l}=await LJ(i,t),c=jJ(l)>jJ(s)?l:s;return{sha:o,record:c,remoteSha:a}}async function Eg(e,t,n){let i=Date.now()+(n?.lockWaitMs??0);for(;;)try{return await xve(e,t,n)}catch(r){if(!(r instanceof Nc)||Date.now()>=i)throw r;await new Promise(o=>setTimeout(o,20+Math.floor(Math.random()*60)))}}async function xve(e,t,n){let i=n?.ttlMs??wD,r=n?.now?.()??new Date,o=n?.mode??"acquire",{sha:s,record:a,remoteSha:l}=await Ga(e,n),c=!a||vve(a,r),u=a?.holder===t;if(o==="renew"){if(!a||c||!u)return{acquired:!1,reason:a&&!c?"held":"not-held",...a?{heldBy:a}:{}};if(n?.token!==void 0&&a.token!==n.token)return{acquired:!1,reason:"token-mismatch",heldBy:a}}else if(a&&!c&&(!u||o==="claim"))return{acquired:!1,heldBy:a,reason:"held"};let d=!!a&&u&&!c,p={op:e,holder:t,token:d?a.token:bve(),acquiredAt:d?a.acquiredAt:r.toISOString(),expiresAt:new Date(r.getTime()+i).toISOString()},{ref:f,trackingRef:g}=await vD(e,n),h=await W0(JSON.stringify(p),n);try{await sd(f,h,s,n)}catch(w){if(w instanceof Vt)return{acquired:!1,heldBy:(await Ga(e,n)).record,reason:"race"};throw w}let b=await bm(f,{...n,expect:l}).catch(()=>"rejected");if(b==="pushed")await sd(g,h,l,n).catch(()=>{});else if(b==="rejected"&&n?.requirePush){await(s===null?ad(f,h,n):sd(f,s,h,n)).catch(()=>{});let w=await Ga(e,n),x=w.record&&w.record.token!==p.token?w.record:void 0;return{acquired:!1,reason:"push-rejected",...x?{heldBy:x}:{}}}return{acquired:!0,lease:p}}async function Ek(e,t,n,i){let{sha:r,record:o,remoteSha:s}=await Ga(e,i);if(!o||o.holder!==t||o.token!==n)return!1;let{ref:a,trackingRef:l}=await vD(e,i);if(r)try{await ad(a,r,i)}catch{return!1}let c=await bm(a,{...i,expect:s}).catch(()=>"rejected");return c==="pushed"&&s&&await ad(l,s,i).catch(()=>{}),r!==null||c==="pushed"}var yD,bD,wD,Jd=v(()=>{"use strict";$t();ga();yD="refs/chant/lease/",bD="refs/chant/lease-remote/",wD=5*6e4});var qJ={};_e(qJ,{ATTEMPT_OUTCOMES:()=>BJ,DEFAULT_WORK_LEASE_TTL_MS:()=>Pk,KEPT_REF_PREFIX:()=>$D,LEASES_DIR:()=>Pg,WORK_ITEM_ID_PATTERN:()=>dg,WORK_LEASE_KEY_PREFIX:()=>Ak,WORK_LEASE_OUTCOMES:()=>xD,WORK_LEASE_REFUSALS:()=>Ave,activeWorkLeases:()=>_ve,claimWorkLease:()=>WJ,isWorkItemId:()=>FT,isWorkLeaseOutcome:()=>Ok,keptAttemptPrefix:()=>RD,keptAttemptRef:()=>GJ,leaseHistoryPath:()=>FJ,listKeptAttempts:()=>Eve,listWorkLeases:()=>Ik,outcomeCountsAsAttempt:()=>Sve,parseLeaseHistory:()=>_k,readLeaseHistory:()=>Ove,releaseWorkLease:()=>HJ,renewWorkLease:()=>zJ,workItemIdProblem:()=>Bd,workLeaseKey:()=>Cg,workLeaseRef:()=>kD});import{dirname as $ve}from"node:path";function Cg(e){return`${Ak}${e}`}function kD(e,t=""){return Sk(Cg(e),t)}function FJ(e,t=""){return`${t}${Pg}/${e}.jsonl`}function Ok(e){return typeof e=="string"&&xD.includes(e)}function Sve(e){return Ok(e)?BJ.includes(e):!0}function GJ(e,t,n=[]){return`${RD(e,n)}${t}`}function RD(e,t=[]){return`${$D}${t.length?`${t.join("/")}/`:""}${e}/`}async function Eve(e,t){let n=RD(e,t.members??[]),i=await ot().spawn(["git","for-each-ref","--format=%(refname) %(objectname)",n],{cwd:t.cwd});return i.exitCode!==0?[]:i.stdout.split(`
202
+ `).filter(Boolean).map(r=>{let[o,s]=r.split(" ");return{token:o.slice(n.length),ref:o,commit:s}}).filter(r=>r.token!==""&&!r.token.includes("/")).sort((r,o)=>r.ref<o.ref?-1:r.ref>o.ref?1:0)}function Og(e,t){return{item:e,holder:t.holder,token:t.token,acquiredAt:t.acquiredAt,expiresAt:t.expiresAt}}function Ck(e){let t=Bd(e);if(t)throw new Error(t)}function Ag(e,t,n){let i=n?`${n.holder} until ${n.expiresAt}`:void 0;switch(t){case"lease-held":return`${e} is held by ${i}`;case"lease-not-held":return`${e} is not held${n?` by the caller: ${i}`:""}; claim it again`;case"lease-token-mismatch":return`${e} is held with another token (${n?.token}) by ${i}`;case"lease-race":return`${e} changed while it was being written${i?`: it is held by ${i}`:""}`;case"lease-push-rejected":return`the remote refused the lease on ${e}${i?`: it is held there by ${i}`:", or could not be reached"}`}}async function WJ(e,t,n){Ck(e);let i=await Eg(Cg(e),t,{cwd:n.cwd,ttlMs:n.ttlMs??Pk,now:n.now,mode:"claim",requirePush:!0,lockWaitMs:MJ});return UJ(e,"claim",t,i,n)}async function zJ(e,t,n){Ck(e);let i=await Eg(Cg(e),t,{cwd:n.cwd,ttlMs:n.ttlMs??Pk,now:n.now,mode:"renew",token:n.token,requirePush:!0,lockWaitMs:MJ});return UJ(e,"renew",t,i,n)}async function UJ(e,t,n,i,r){if(!i.acquired||!i.lease){let l=Pve[i.reason??"race"],c=i.heldBy?Og(e,i.heldBy):void 0;return{ok:!1,reason:l,message:Ag(e,l,c),...c?{heldBy:c}:{}}}let o=Og(e,i.lease),s=r.now?.()??new Date,a=await VJ({version:1,event:t,item:e,holder:n,by:n,token:o.token,acquiredAt:o.acquiredAt,expiresAt:o.expiresAt,timestamp:s.toISOString(),...r.note?{note:r.note}:{}},r);return{ok:!0,lease:o,history:a}}async function HJ(e,t,n){if(Ck(e),n.outcome!==void 0&&!Ok(n.outcome))throw new Error(`${JSON.stringify(n.outcome)} is not a work lease outcome: use one of ${xD.join(", ")}`);let i=Cg(e),r=n.now?.()??new Date,{record:o}=await Ga(i,{cwd:n.cwd});if(!o)return{ok:!1,reason:"lease-not-held",message:Ag(e,"lease-not-held",void 0)};let s=Og(e,o);if(new Date(o.expiresAt).getTime()>r.getTime()&&o.holder!==t)return{ok:!1,reason:"lease-held",message:Ag(e,"lease-held",s),heldBy:s};if(n.token!==void 0&&o.token!==n.token)return{ok:!1,reason:"lease-token-mismatch",message:Ag(e,"lease-token-mismatch",s),heldBy:s};if(!await Ek(i,o.holder,o.token,{cwd:n.cwd})){let c=(await Ga(i,{cwd:n.cwd})).record,u=c?Og(e,c):void 0;return{ok:!1,reason:"lease-race",message:Ag(e,"lease-race",u),...u?{heldBy:u}:{}}}let l=await VJ({version:1,event:"release",item:e,holder:o.holder,by:t,token:o.token,acquiredAt:o.acquiredAt,expiresAt:o.expiresAt,timestamp:r.toISOString(),...n.outcome?{outcome:n.outcome}:{},...n.note?{note:n.note}:{}},n);return{ok:!0,lease:s,history:l}}async function VJ(e,t){await ya(t).catch(()=>{});let n=`${e.item}.jsonl`,i=JSON.stringify(e,pn),r,o;for(let l=1;l<=Rve&&r===void 0;l++)try{let c=await xr(Pg,n,t),u=c?await fn(c,t):null,d=`${u?`${u.replace(/\n$/,"")}
203
+ `:""}${i}
204
+ `;r=await An(Pg,n,d,`Work lease ${e.event}: ${e.item} (${e.holder})`,{...t,expectPriorPathSha:c})}catch(c){if(!(c instanceof Vt))throw c;o=c}if(r===void 0)throw o;let s=await Mc(t).catch(()=>!1),{prefix:a}=await ri(t.cwd);return{path:FJ(e.item,a),commit:r,pushed:s}}function _k(e){let t=[],n=0;for(let i of e.split(`
205
+ `).map(r=>r.trim()).filter(Boolean))try{let r=JSON.parse(i);r.version===1&&(r.event==="claim"||r.event==="renew"||r.event==="release")&&[r.item,r.holder,r.by,r.token,r.acquiredAt,r.expiresAt,r.timestamp].every(s=>typeof s=="string")?t.push(r):n++}catch{n++}return{records:t,malformed:n}}async function Ove(e,t){Ck(e);let n=await nn(Pg,`${e}.jsonl`,t);return n?_k(n):{records:[],malformed:0}}function Cve(e){try{let t=JSON.parse(e);return typeof t.holder=="string"&&typeof t.token=="string"&&typeof t.acquiredAt=="string"&&typeof t.expiresAt=="string"?t:void 0}catch{return}}async function Ik(e){let t=ot(),n=(e.now??new Date).getTime(),i=`${yD}${e.memberPrefix}${Ak}`,r=`${bD}${e.memberPrefix}${Ak}`,o=await t.spawn(["git","for-each-ref","--format=%(refname) %(objectname)",i,r],{cwd:e.cwd});if(o.exitCode!==0)return[];let s=new Map;for(let a of o.stdout.split(`
206
+ `).filter(Boolean)){let[l,c]=a.split(" "),u=l.startsWith(i)?l.slice(i.length):l.slice(r.length);if(!dg.test(u))continue;let d=Cve(await fn(c,e)??"");if(!d)continue;let p=s.get(u),f=g=>`${g.acquiredAt} ${g.expiresAt}`;(!p||f(d)>f(p)||f(d)===f(p)&&l.startsWith(i))&&s.set(u,d)}return[...s.entries()].sort(([a],[l])=>a<l?-1:a>l?1:0).map(([a,l])=>({...Og(a,l),state:new Date(l.expiresAt).getTime()>n?"active":"expired",ref:kD(a,e.memberPrefix)}))}async function _ve(e,t=new Date){let n=$ve(e);try{let{prefix:i}=await ri(n),r=await Ik({cwd:n,memberPrefix:i,now:t});return new Map(r.filter(o=>o.state==="active").map(o=>[o.item,{holder:o.holder,token:o.token,acquiredAt:o.acquiredAt,expiresAt:o.expiresAt}]))}catch{return new Map}}var Ak,Pg,Pk,MJ,Rve,xD,BJ,$D,Ave,Pve,fl=v(()=>{"use strict";Wt();to();Jd();$t();ga();BT();Ak="work/",Pg="_leases",Pk=10*6e4,MJ=2e3,Rve=5;xD=["done","not_done","abandoned","gated","waiting","dropped","redraft","ask"],BJ=["not_done","abandoned"];$D="refs/chant/kept/";Ave=["lease-held","lease-not-held","lease-token-mismatch","lease-race","lease-push-rejected"];Pve={held:"lease-held","not-held":"lease-not-held","token-mismatch":"lease-token-mismatch",race:"lease-race","push-rejected":"lease-push-rejected"}});function Nve(e){return Ive.find(t=>t.pattern.test(e))}function KJ(e,t){let n=t?.get(e);if(n)return n.handWritten?{class:"owned"}:{class:"generated",command:n.command};if(Dve.some(r=>e===r||e.startsWith(`${r}/`)))return{class:"ignored"};let i=Nve(e);return i?{class:"generated",command:i.command}:Tve.includes(e)?{class:"seed"}:{class:"owned"}}function jve(e,t){let n=new Map;for(let i of e.members)for(let r of i.generated){let o=i.dir==="."?r.path:`${i.dir}/${r.path}`;kr(o,t)&&n.set(t==="."?o:o.slice(t.length+1),{command:r.generator,handWritten:r.handWritten!==null})}return n}function SD(e,t){let i=e.members.find(o=>o.name===Mr(t,e.members))?.dir??".",r=i==="."?t:t.slice(i.length+1);return KJ(r,jve(e,i)).class==="generated"}var Ive,Tve,Dve,ED=v(()=>{"use strict";Ri();_t();uo();Zt();Ive=[{glob:"skills/*/SKILL.md",pattern:/^skills\/[^/]+\/SKILL\.md$/,command:"chant update"}],Tve=[".mcp.json"],Dve=[".chant/types"]});import{createHash as Lve}from"node:crypto";function ZJ(e){return`sha256:${Lve("sha256").update(e).digest("hex")}`}var Mve,AD,Fve,Bve,JJ,Gve,Wve,zve,Uve,Hve,Vve,kVe,$s,YJ=v(()=>{"use strict";Ln();_t();ED();Mve=1,AD=m.string().regex(/^sha256:[0-9a-f]{64}$/,"expected sha256:<64 hex>"),Fve=["owned","generated","seed"],Bve=m.object({class:m.enum(Fve),sha256:AD,command:m.string().min(1).optional()}).strict(),JJ=m.discriminatedUnion("type",[m.object({type:m.literal("git"),repo:m.string().min(1),url:m.string().min(1),path:m.string().optional()}).strict(),m.object({type:m.literal("dir"),path:m.string().min(1),member:m.string().optional()}).strict(),m.object({type:m.literal("lexicon"),lexicon:m.string().min(1),template:m.string().min(1)}).strict(),m.object({type:m.literal("local"),path:m.string().min(1)}).strict(),m.object({type:m.literal("archive"),url:m.string().url(),subpath:m.string().optional()}).strict()]),Gve=m.object({digest:AD,commit:m.string().regex(/^[0-9a-f]{40,64}$/).optional(),tree:m.string().regex(/^[0-9a-f]{40,64}$/).optional(),package:m.string().optional(),version:m.string().nullable().optional(),chant:m.string().optional()}).strict(),Wve=["changed-locally","deleted-locally","exists-locally","removed-upstream"],zve=m.object({path:m.string().min(1),reason:m.enum(Wve),upstream:AD.nullable()}).strict(),Uve=m.string().regex(/^[0-9a-f]{40,64}$/),Hve=m.object({by:m.enum(["files","lineage"]),commits:m.object({to:Uve}).strict(),match:m.object({files:m.number().int().nonnegative(),identical:m.number().int().nonnegative(),edited:m.number().int().nonnegative(),missing:m.number().int().nonnegative()}).strict(),index:m.enum(["computed","cache"]),previous:m.object({template:m.string().min(1),source:JJ}).strict().optional()}).strict(),Vve=m.object({kind:m.enum(["template","vendor"]),name:m.string().min(1).optional(),template:m.string().min(1),source:JJ,ref:m.string().optional(),address:Gve.nullable(),parameters:m.record(m.string(),m.unknown()),hostBound:m.record(m.string(),m.array(m.string().min(1))).optional(),repinned:m.array(m.object({record:m.string().min(1),paths:m.array(m.string().min(1))}).strict()).optional(),migrations:m.array(m.string()),files:m.record(m.string(),Bve),manualSteps:m.array(zve),adoption:Hve.optional()}).strict(),kVe=m.object({lockVersion:m.literal(Mve),scopes:m.record(m.string(),Vve)}).strict();$s=class extends Error{constructor(){super(...arguments);this.name="LockError"}}});var oZ={};_e(oZ,{RETURNS_DIR:()=>_g,admitReturn:()=>ske,buildOrigin:()=>eke,gitObjectId:()=>Dk,originSigners:()=>nke,parseReturn:()=>rZ,parseTree:()=>CD,readReturns:()=>ike,renderReturn:()=>iZ,returnedProvenance:()=>oke,verifyOrigin:()=>_D,writeReturn:()=>rke});import{execFileSync as qve}from"node:child_process";import{createHash as Kve}from"node:crypto";import{existsSync as Jve,mkdirSync as QJ,readFileSync as Zve,writeFileSync as eZ}from"node:fs";import{dirname as Yve,join as OD}from"node:path";function Dk(e,t,n){return Kve(n).update(`${e} ${t.length}\0`).update(t).digest("hex")}function CD(e,t){let n=[],i=0;for(;i<e.length;){let r=e.indexOf(32,i),o=e.indexOf(0,r);if(r<0||o<0||o+1+t>e.length)throw new Error("malformed tree object");n.push({mode:e.subarray(i,r).toString("latin1"),name:e.subarray(r+1,o).toString("utf-8"),id:e.subarray(o+1,o+1+t).toString("hex")}),i=o+1+t}return n}function PD(e,t){return qve("git",t,{cwd:e,maxBuffer:256*1024*1024,stdio:["ignore","pipe","pipe"]})}function eke(e,t,n){let i;try{i=PD(e,["log","-1","--format=%H","HEAD","--",t]).toString("utf-8").trim()}catch{return}if(!i)return;let r=PD(e,["cat-file","commit",i]),o={commit:i,raw:r.toString("base64"),trees:[]},s=/^tree ([0-9a-f]+)$/m.exec(r.toString("latin1"))?.[1],a=t.split("/");for(let l=0;l<a.length&&s;l++){let c=PD(e,["cat-file","tree",s]);o.trees.push(c.toString("base64")),s=CD(c,s.length/2).find(u=>u.name===a[l])?.id}return _D(o,t,n).ok?o:void 0}function _D(e,t,n){let i=e.commit.length===64?"sha256":"sha1",r=Buffer.from(e.raw,"base64");if(Dk("commit",r,i)!==e.commit)return{ok:!1,reason:`the commit object does not hash to ${e.commit.slice(0,12)}`};let o=/^tree ([0-9a-f]+)$/m.exec(r.toString("latin1"))?.[1],s=t.split("/");if(e.trees.length!==s.length)return{ok:!1,reason:`the proof has ${e.trees.length} tree(s) for a path ${s.length} deep`};for(let a=0;a<s.length;a++){let l=Buffer.from(e.trees[a],"base64");if(!o||Dk("tree",l,i)!==o)return{ok:!1,reason:`the tree for ${s.slice(0,a).join("/")||"the root"} does not hash to its id`};let c;try{c=CD(l,o.length/2)}catch{return{ok:!1,reason:"a tree object in the proof is malformed"}}o=c.find(u=>u.name===s[a])?.id}return!o||Dk("blob",n,i)!==o?{ok:!1,reason:`the commit holds other bytes at ${t}`}:{ok:!0}}function tke(e){return/^committer [^<]*<([^>]+)>/m.exec(e.toString("utf-8"))?.[1]}function nZ(e){return e.commit.length===64?"gpgsig-sha256":"gpgsig"}function nke(e){let t=new Map,n=new Set;for(let i of e){if(n.has(i.commit))continue;n.add(i.commit);let r=Buffer.from(i.raw,"base64"),{payload:o,signature:s}=Fm(r,nZ(i));if(!s)continue;let a=VI(s);if(!a)continue;let l=t.get(a);if(l){l.commits.push(i.commit);continue}let c=Ov(o,s,"git");c!==!1&&t.set(a,{key:a,fingerprint:c??"",principal:tke(r)??"unknown",commits:[i.commit]})}return[...t.values()].sort((i,r)=>i.key.localeCompare(r.key))}function rZ(e,t){let n;try{n=JSON.parse(e)}catch(r){throw new $s(`${t} is not JSON: ${r instanceof Error?r.message:String(r)}`)}let i=tZ.safeParse(n);if(!i.success)throw new $s(`${t} is not a return record: ${i.error.issues.map(r=>`${r.path.join(".")||"/"}: ${r.message}`).join("; ")}`);return i.data}function iZ(e){let t={};for(let n of Object.keys(e.paths).sort())t[n]=e.paths[n];return JSON.stringify(tZ.parse({...e,paths:t,removed:[...e.removed].sort(),hostValues:[...e.hostValues].sort()}),null,2)+`
207
+ `}function rke(e,t){let n=`${_g}/${t.id}.json`;return QJ(OD(e,_g),{recursive:!0}),eZ(OD(e,n),iZ(t)),n}function ike(e){let t=[],n=[];for(let i of(e.list(_g)??[]).filter(r=>r.type==="file"&&r.name.endsWith(".json")).sort((r,o)=>r.name.localeCompare(o.name))){let r=`${_g}/${i.name}`;try{let o=rZ(e.read(r),r);if(`${o.id}.json`!==i.name)throw new $s(`${r} holds return ${o.id}`);t.push(o)}catch(o){if(!(o instanceof $s))throw o;n.push(o.message)}}return{returns:t,problems:n}}function oke(e,t,n,i,r,o){let s=n.paths[i];if(!s||s.sha256!==ZJ(r))return;let a={id:n.id,importedIn:o.commit};if(!s.origin)return;let l=_D(s.origin,i,r);if(!l.ok)return{level:"unattested",commit:o.commit,reason:`returned in ${n.id}, and its origin does not check: ${l.reason}`,returned:{...a,commit:s.origin.commit}};let c=Buffer.from(s.origin.raw,"base64"),u=Pv(e,n.id),d=qI({repo:"",policy:u},c,t),p=`returned in ${n.id} from commit ${s.origin.commit.slice(0,12)}`,f={commit:o.commit,attestor:d.attestor,returned:{...a,commit:s.origin.commit}};if(d.level==="attested"){let g=(e.admitted[n.id]??[]).some(h=>h.principal===d.principal)&&!e.signers.some(h=>h.principal===d.principal);return{...f,level:"attested",...d.principal?{principal:d.principal}:{},...d.key?{key:d.key}:{},reason:`${p}, ${d.reason}${g?`, a signer admitted for ${n.id} at base`:""}`}}if(d.level==="unattested"){let{payload:g,signature:h}=Fm(c,nZ(s.origin)),b=h?.startsWith("-----BEGIN SSH SIGNATURE-----")?Ov(g,h,"git"):!1;if(b)return{...f,level:"attested-unverifiable-here",key:b,reason:`${p}, signed with ${b}, a key neither the signers nor an admission at base lists; it reads as attested once an admin admits the signer (chant workspace admit ${n.id})`}}return{...f,level:d.level,...d.key?{key:d.key}:{},reason:`${p}: ${d.reason}`}}function ske(e,t,n={}){if(t.signers.length===0)throw new $s(`return ${t.id} names no signer: none of its origin commits carries an ssh signature`);let i=OD(e,nr),r={schema:1};if(Jve(i))try{r=JSON.parse(Zve(i,"utf-8"))}catch(l){throw new $s(`${nr} is not valid JSON, so the admission cannot be added to it: ${l instanceof Error?l.message:String(l)}`)}let o=Array.isArray(r.admitted)?r.admitted:[],s=new Set(o.filter(l=>l.return===t.id).flatMap(l=>(l.signers??[]).map(c=>c.key))),a=t.signers.filter(l=>!s.has(l.key)).map(l=>({principal:l.principal,key:l.key}));return a.length>0&&!n.dryRun&&(r.admitted=[...o,{return:t.id,signers:a,...n.note?{note:n.note}:{}}],QJ(Yve(i),{recursive:!0}),eZ(i,JSON.stringify(r,null,2)+`
208
+ `)),{id:t.id,path:nr,added:a,written:a.length>0&&!n.dryRun}}var _g,Xve,Tk,XJ,Qve,tZ,sZ=v(()=>{"use strict";Ln();YJ();Id();ps();Bm();_g=".chant/returns",Xve=m.string().regex(/^sha256:[0-9a-f]{64}$/),Tk=m.string().regex(/^[0-9a-f]{40}([0-9a-f]{24})?$/),XJ=m.string().regex(/^[A-Za-z0-9+/]*={0,2}$/),Qve=m.object({commit:Tk,raw:XJ,trees:m.array(XJ).min(1)}).strict(),tZ=m.object({schema:m.literal(1),id:m.string().regex(/^ret-[0-9a-f]{12}$/),export:m.object({id:m.string().min(1),workspace:m.string().min(1),revision:Tk.nullable()}).strict(),head:Tk.nullable(),paths:m.record(m.string(),m.object({sha256:Xve,origin:Qve.optional()}).strict()),removed:m.array(m.string()),hostValues:m.array(m.string()),signers:m.array(m.object({key:m.string().min(1),fingerprint:m.string(),principal:m.string().min(1),commits:m.array(Tk)}).strict())}).strict()});function Ig(e){return e.normalize("NFKC").toLowerCase().replace(/[^\p{L}\p{N}]/gu,"")}function Tg(e,t){if(e===t)return e===""?void 0:"exact";let n=Ig(e);return n!==""&&n===Ig(t)?"folded":void 0}var ID=v(()=>{"use strict"});function cke(e,t,n){if(n.member===t.name)return`member ${t.name} links to itself; a link joins two members`;let i=e.entries.find(r=>r.name===n.member);if(!i)return`member ${t.name} links to ${n.member}, which is not a member of this workspace`;if(i.type==="group")return`member ${t.name} links to ${n.member}, which is an example group; a group has no links`}function lke(e,t){let n=Ig(e);return[...new Set(t.filter(i=>i.name!==e&&Ig(i.name)===n).map(i=>i.name))].sort(Zd)}function TD(e,t,n){let i=[],r=new Map;for(let s of e.members)for(let a of s.links){let l=a.kind??cZ,c={consumer:s.name,producer:a.member,output:a.output,kind:l,origin:"declared",label:"exact",input:null,resolves:"source",status:"resolved",reason:null,pointer:a.pointer,...a.protocol?{protocol:a.protocol}:{}};i.push(c);let u=cke(e,s,a);if(u){c.status="invalid",c.reason=u;continue}if((r.get(s.name)??r.set(s.name,new Set).get(s.name)).add(`${a.member}\0${a.output}`),!aZ.includes(l)){c.status="invalid",c.reason=`the link kind ${l} is not one chant knows; known link kinds: ${aZ.join(", ")}`;continue}if(l===ake){uke(c,n);continue}if(a.protocol){c.status="invalid",c.reason=`protocol applies to telemetry links; this link has kind ${l}`;continue}let d=t.get(a.member),p=d?.outputs.find(f=>f.name===a.output);if(p){p.node&&(c.to=p.node);continue}if(!d)c.status="unresolved",c.reason=`the outputs of ${a.member} were not read`;else if(d.exposesNone)c.status="missing",c.reason=d.why??`${a.member} exposes no outputs`;else if(!d.complete)c.status="unresolved",c.reason=`${a.output} was not found in ${a.member}, whose outputs could not all be read in source${d.why?` (${d.why})`:""}`;else{let f=lke(a.output,d.outputs),g=d.outputs.map(h=>h.name);c.status="missing",c.reason=`${a.member} has no output ${a.output}`+(f.length?`; did you mean ${f.join(" or ")}? Links match exactly`:"")+(g.length?`; its outputs: ${[...new Set(g)].sort(Zd).join(", ")}`:"; it exposes no outputs")}}let o=[];for(let s of e.members){let a=t.get(s.name);if(!a)continue;let l=r.get(s.name)??new Set;for(let c of a.inputs){let u=[];for(let p of e.members)if(p.name!==s.name)for(let f of t.get(p.name)?.outputs??[]){let g=Tg(c.name,f.name);g&&(u.some(h=>h.producer===p.name&&h.output===f.name)||u.push({producer:p.name,output:f.name,label:g,...f.node?{to:f.node}:{}}))}if(u.length===0||u.some(p=>l.has(`${p.producer}\0${p.output}`)))continue;let d={consumer:s.name,kind:cZ,origin:"inferred:joinKey",resolves:"source"};if(u.length===1){let p=u[0];o.push({...d,status:"resolved",reason:null,producer:p.producer,output:p.output,label:p.label,input:c.name,...c.node?{from:c.node}:{},...p.to?{to:p.to}:{}})}else{u.sort((f,g)=>Zd(f.producer,g.producer)||Zd(f.output,g.output));let p=new Set(u.map(f=>f.producer));o.push({...d,status:"ambiguous",reason:p.size>1?`parameter ${c.name} of ${s.name} matches outputs of ${[...p].join(" and ")}`:`parameter ${c.name} of ${s.name} matches ${u.map(f=>f.output).join(" and ")} of ${u[0].producer}`,input:c.name,...c.node?{from:c.node}:{},candidates:u})}}}return o.sort((s,a)=>Zd(s.consumer,a.consumer)||Zd(s.input??"",a.input??"")),[...i,...o]}function uke(e,t){if(!t){e.status="unresolved",e.reason=`the collector of ${e.producer} is read by chant workspace graph; chant workspace check reads source and runs no member`;return}let n=t.collectors.get(e.producer);if(!n){t.composed.has(e.producer)?(e.status="missing",e.reason=`${e.producer} declares no collector: its build reports no collector pipelines or components`):(e.status="unresolved",e.reason=`the collector of ${e.producer} was not read: ${e.producer} was not composed`);return}let i=n.pipelines.find(l=>l.id===e.output),r=i?void 0:n.exporters.find(l=>l.id===e.output);if(!i&&!r){e.status="missing",e.reason=`${e.producer}'s collector has no pipeline or exporter ${e.output}; pipelines: ${n.pipelines.map(l=>l.id).join(", ")||"none"}; exporters: ${n.exporters.map(l=>l.id).join(", ")||"none"}`;return}if(e.target=i?"pipeline":"exporter",!e.protocol)return;let o=i?i.receivers:[r.id],s=[...new Set(n.components.filter(l=>o.includes(l.id)).flatMap(l=>l.protocols))],a=i?`the receivers of pipeline ${e.output}`:`exporter ${e.output}`;s.length===0?(e.status="unresolved",e.reason=`${a} state no protocols, so ${e.protocol} could not be confirmed`):s.includes(e.protocol)||(e.status="invalid",e.reason=`${a} speak ${s.join(", ")}, and the link sends ${e.protocol}`)}function DD(e,t){let n=t.outputs;if(n.from==="none")return{member:e.name,outputs:[],inputs:[],complete:!0,why:`${e.name} is kind ${e.kind}, which exposes no outputs as link targets`,exposesNone:!0};if(n.from==="declared"){let i=[...new Set([...n.names,...e.outputs??[]])];return{member:e.name,outputs:i.map(r=>({name:r})),inputs:[],complete:!0,why:null,exposesNone:!1}}}function dke(e){let t=new Map;for(let n of e.composed)t.set(n,{member:n,outputs:e.exports.filter(i=>i.member===n).map(i=>({name:i.name,...i.node?{node:i.node}:{}})),inputs:e.imports.filter(i=>i.member===n).map(i=>({name:i.name,node:i.node})),complete:!0,why:null,exposesNone:!1});return t}function lZ(e,t,n){let i=dke(t);for(let o of e.members){let s=n?.get(o.kind);if(i.has(o.name)||!s)continue;let a=DD(o,s);a&&i.set(o.name,a)}let r={collectors:new Map((t.collectors??[]).map(o=>[o.member,o])),composed:new Set(t.composed)};return TD(e,i,r).map(o=>{if(o.status==="ambiguous"||o.origin!=="declared")return o;let{pointer:s,...a}=o;return a})}var aZ,cZ,ake,Zd,Dg=v(()=>{"use strict";ID();aZ=["output","telemetry"],cZ="output",ake="telemetry",Zd=(e,t)=>e<t?-1:e>t?1:0});var Ke=ie((NVe,ND)=>{if(typeof ND=="object")throw new Error("typescript is not part of chant's wave-job runtime (wave-runtime.mjs): this path needs the full @intentius/chant CLI");ND.exports={}});function mke(e){return!/\.(m?ts|tsx)$/.test(e)||e.endsWith(".d.ts")||/\.(test|spec)\.m?tsx?$/.test(e)?!1:!e.startsWith("chant.config.")}function gke(e,t,n){let i=[],r=o=>{for(let s of e.list(o)??[]){let a=ze(o,s.name);if(s.type==="dir"){if(ts(s.name)||pke.has(s.name)||n.has(a))continue;r(a)}else mke(s.name)&&i.push(a)}};return r(t),i.sort()}function hke(e){let t=new Map,n=new Set;for(let i of e.statements){if(!De.isImportDeclaration(i)||!De.isStringLiteral(i.moduleSpecifier))continue;let r=i.moduleSpecifier.text;if(!fke.test(r)||r.includes("/components"))continue;let o=i.importClause?.namedBindings;if(o)if(De.isNamespaceImport(o))n.add(o.name.text);else for(let s of o.elements)t.set(s.name.text,(s.propertyName??s.name).text)}return{names:t,namespaces:n}}function jD(e,t){if(De.isIdentifier(e))return t.names.get(e.text);if(De.isPropertyAccessExpression(e)&&De.isIdentifier(e.expression)&&t.namespaces.has(e.expression.text))return e.name.text}function yke(e){let t=new Map;for(let n of e.statements)if(!(!De.isVariableStatement(n)||(n.declarationList.flags&De.NodeFlags.Const)===0))for(let i of n.declarationList.declarations)De.isIdentifier(i.name)&&i.initializer&&t.set(i.name.text,i.initializer);return t}function LD(e,t,n=new Set){if(De.isStringLiteral(e)||De.isNoSubstitutionTemplateLiteral(e))return e.text;if(De.isParenthesizedExpression(e)||De.isAsExpression(e)||De.isSatisfiesExpression(e))return LD(e.expression,t,n);if(De.isIdentifier(e)&&!n.has(e.text)){let i=t.get(e.text);if(i)return LD(i,t,new Set([...n,e.text]))}}function bke(e){return(De.canHaveModifiers(e)?De.getModifiers(e):void 0)?.some(t=>t.kind===De.SyntaxKind.ExportKeyword)??!1}function wke(e,t,n){let i=De.createSourceFile(e,t,De.ScriptTarget.Latest,!1),r=hke(i);if(r.names.size===0&&r.namespaces.size===0)return;let o=yke(i),s=l=>i.getLineAndCharacterOfPosition(l.getStart(i)).line+1;for(let l of i.statements)if(!(!De.isVariableStatement(l)||!bke(l)))for(let c of l.declarationList.declarations){if(!De.isIdentifier(c.name)||!c.initializer)continue;let u=c.initializer;if(De.isNewExpression(u)&&jD(u.expression,r)==="Parameter")n.inputs.push({name:c.name.text,file:e,line:s(c)});else if(De.isCallExpression(u)&&jD(u.expression,r)==="stackOutput"){let d=u.arguments[0];d&&!De.isStringLiteralLike(d)&&n.outputs.push({name:c.name.text,file:e,line:s(c)})}}let a=l=>{if(De.isCallExpression(l)&&jD(l.expression,r)==="output"&&l.arguments.length>=2){let c=LD(l.arguments[1],o);c!==void 0?n.outputs.push({name:c,file:e,line:s(l)}):n.gaps.push(`${e}:${s(l)}: an output whose name is not a string literal`)}De.forEachChild(l,a)};a(i)}function vke(e,t,n=new Set){let i={outputs:[],inputs:[],gaps:[]};for(let r of gke(e,t,n)){let o;try{o=e.read(r)}catch{i.gaps.push(`${r}: the file could not be read`);continue}wke(r,o,i)}return i}function dZ(e,t,n,i){let r=new Map;for(let o of e.members){let s=i.get(o.kind);if(!s||t.stat(uZ(o.dir))!=="dir")continue;let a=DD(o,s);if(a)r.set(o.name,a);else{let l=new Set;for(let u of e.members)u!==o&&u.dir!=="."&&kr(u.dir,o.dir)&&l.add(u.dir);for(let u of n)for(let d of u.matches)kr(d,o.dir)&&l.add(d);let c=vke(t,uZ(o.dir),l);r.set(o.name,{member:o.name,outputs:c.outputs.map(u=>({name:u.name})),inputs:c.inputs.map(u=>({name:u.name})),complete:c.gaps.length===0,why:c.gaps.length===0?null:c.gaps.length===1?c.gaps[0]:`${c.gaps[0]}, and ${c.gaps.length-1} more`,exposesNone:!1})}}return r}var De,uZ,pke,fke,pZ=v(()=>{"use strict";De=Le(Ke(),1);_t();Dg();Zt();uZ=e=>e==="."?"":e,pke=new Set(["dist","coverage","generated"]),fke=/^@intentius\/chant(-lexicon-[a-z0-9-]+)?(\/.*)?$/});import{execFileSync as kke}from"node:child_process";function Rs(e,t,n={}){try{return kke("git",t,{cwd:e,encoding:"utf-8",input:n.input,timeout:n.timeout,stdio:[n.input===void 0?"ignore":"pipe","pipe","pipe"],maxBuffer:256*1024*1024,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}})}catch{return}}function $ke(e){let t=e.match(/\(#([0-9]+)\)\s*$/);return t?Number(t[1]):null}function Rke(e){if(!e)return null;let t=(e.match(/^[a-z][a-z0-9+.-]*:\/\/(?:[^@/]*@)?([^/:]+)/i)?.[1]??e.match(/^(?:[^@/]*@)?([^/:]+):/)?.[1]??"").toLowerCase();return t==="github.com"||t.endsWith(".github.com")||/(^|[.-])github([.-]|$)/.test(t)?"github":t==="codeberg.org"||/(^|[.-])(forgejo|gitea)([.-]|$)/.test(t)?"forgejo":null}function jg(e,t){return`refs/pull/${t}/head`}function Ske(e,t,n){for(let i of[`${Nk}${n}/head`,jg(t,n),`refs/remotes/${Ng}/pr/${n}`]){let r=fZ(e,i);if(r)return{ref:i,head:r}}}function Eke(e,t,n){let i=o=>`+${jg(t,o)}:${Nk}${o}/head`,r=o=>Rs(e,["fetch","--no-tags","--quiet","--no-write-fetch-head",Ng,...o.map(i)],{timeout:xke})!==void 0;return n.length===0?new Set:r(n)?new Set(n):new Set(n.length===1?[]:n.filter(o=>r([o])))}function Lg(e,t,n){let i=new Map,r=t.map(p=>({sha:p.sha,n:$ke(p.subject)})).filter(p=>p.n!==null);if(r.length===0)return i;let o=new Map;for(let p of(Rs(e,["log","--no-walk=unsorted","--stdin","--format=%H %P"],{input:`${r.map(f=>f.sha).join(`
209
+ `)}
210
+ `})??"").split(`
211
+ `)){let[f,...g]=p.trim().split(/\s+/);f&&o.set(f,g)}let s=r.filter(p=>o.get(p.sha)?.length===1);if(s.length===0)return i;let a=Rs(e,["config","--get",`remote.${Ng}.url`])?.trim()||null,l=Rke(a),c=new Map;for(let p of new Set(s.map(f=>f.n))){let f=Ske(e,l,p);f&&c.set(p,f)}let u=[...new Set(s.map(p=>p.n))].filter(p=>!c.has(p)),d=n.fetchMissing&&a?Eke(e,l,u):new Set;for(let p of d){let f=fZ(e,`${Nk}${p}/head`);f&&c.set(p,{ref:`${Nk}${p}/head`,head:f})}for(let p of s){let f=c.get(p.n),g={sha:p.sha,pullRequest:p.n,forge:l,ref:null,head:null,fetched:!1,followed:!1,commits:[],problem:null};if(!f){let x=n.fetchMissing?a?`${jg(l,p.n)} could not be fetched from ${Ng}: the forge has no such ref, or it can't be reached`:`there is no ${Ng} remote to fetch ${jg(l,p.n)} from`:`${jg(l,p.n)} is not in this clone`;i.set(p.sha,{...g,problem:x});continue}if(Rs(e,["merge-base","--is-ancestor",f.head,p.sha])!==void 0)continue;let h=o.get(p.sha)[0],b=Rs(e,["rev-list","--reverse","--no-merges",f.head,`^${h}`]);if(b===void 0){i.set(p.sha,{...g,ref:f.ref,head:f.head,fetched:d.has(p.n),problem:`the commits of ${f.ref} could not be listed`});continue}let w=b.split(`
212
+ `).map(x=>x.trim()).filter(Boolean);i.set(p.sha,{...g,ref:f.ref,head:f.head,fetched:d.has(p.n),followed:!0,commits:w})}return i}function mZ(e,t,n,i,r){let o=Rs(e,["rev-parse","--verify","--quiet",`${t}:${i}`])?.trim(),s=Rs(e,["rev-parse","--verify","--quiet",`${n}:${i}`])?.trim();if(!o||o!==s)return;let a=Rs(e,["blame","--porcelain",n,"--",i]);if(a===void 0)return;let l=new Map;for(let c of a.split(`
213
+ `)){let u=c.match(/^([0-9a-f]{40,64}) \d+ (\d+)(?: \d+)?$/);u&&r.has(u[1])&&l.set(Number(u[2]),u[1])}return l}var Nk,Ng,xke,fZ,jk=v(()=>{"use strict";Nk="refs/chant/pull/",Ng="origin",xke=6e4;fZ=(e,t)=>Rs(e,["rev-parse","--verify","--quiet",`${t}^{commit}`])?.trim()||void 0});var FD,Cke,MD,gZ,HVe,hZ=v(()=>{"use strict";Ln();er();Iv();FD="https://in-toto.io/Statement/v1",Cke="https://intentius.io/chant/runner-evidence/v1",MD=m.string().regex(/^[0-9a-f]{64}$/),gZ=m.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/),HVe=m.object({_type:m.literal(FD),subject:m.array(m.object({name:m.string().min(1).refine(e=>!e.startsWith("/")&&!e.split("/").includes(".."),"a path inside the repository"),digest:m.object({sha256:MD}).strict()}).strict()),predicateType:m.literal(Cke),predicate:m.object({runner:m.string().min(1),commit:gZ,tree:gZ,check:m.string().min(1),claim:m.object({sha256:MD}).strict().optional(),environment:m.object({sha256:MD}).strict().optional()}).strict()}).strict()});import{createHash as _ke}from"node:crypto";function bZ(e,t){return _ke("sha256").update($r([e,t]),"utf8").digest("hex")}var Ike,Tke,yZ,Dke,Ss,XVe,wZ=v(()=>{"use strict";Ln();er();Iv();hZ();Ike="https://intentius.io/chant/agent-run/v1",Tke=m.string().regex(/^[0-9a-f]{64}$/),yZ=m.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/),Dke=m.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/),Ss=m.string().min(1),XVe=m.object({_type:m.literal(FD),subject:m.array(m.object({name:yZ,digest:m.object({gitCommit:yZ}).strict(),annotations:m.object({patchId:Dke}).strict().optional()}).strict().refine(e=>e.name===e.digest.gitCommit,"a commit subject is named by its own id")),predicateType:m.literal(Ike),predicate:m.object({signer:Ss,run:m.object({id:Ss,record:m.object({sha256:Tke}).strict()}).strict(),unit:m.object({id:Ss,kind:Ss.nullable()}).strict().nullable(),harness:m.object({name:Ss,version:Ss.nullable()}).strict(),model:Ss.nullable(),provider:Ss.nullable(),by:Ss.nullable()}).strict()}).strict()});import{execFileSync as Nke}from"node:child_process";function Mg(e,t,n){try{return Nke("git",t,{cwd:e,encoding:"utf-8",input:n,stdio:[n===void 0?"ignore":"pipe","pipe","pipe"],maxBuffer:512*1024*1024})}catch{return}}function Hke(e,t){return Mg(e,["rev-parse","--verify","--quiet",`${t}^{commit}`])?.trim()||void 0}function Vke(e){let t=new Map;for(let n of(e??"").split(`
214
+ `)){let[i,r]=n.trim().split(/\s+/);i&&r&&!t.has(r)&&t.set(r,i)}return t}function qke(e,t){if(t.length===0)return new Map;let n=Mg(e,["log","--no-walk=unsorted","--stdin","--no-merges","--format=commit %H","--patch","--no-color","--no-ext-diff"],`${t.join(`
215
+ `)}
216
+ `);return n?.trim()?Vke(Mg(e,["patch-id","--stable"],n)):new Map}function Kke(e,t){let n=[],i=0;for(let r of e.split(`
217
+ `).map(o=>o.trim()).filter(Boolean))try{let o=JSON.parse(r),s=o.event==="statement"&&typeof o.envelope=="object"&&o.envelope!==null;o.version===1&&(o.event==="start"||o.event==="end"||s)&&o.run===t&&typeof o.at=="string"?n.push(o):i++}catch{i++}return{lines:n,malformed:i}}async function Jke(e){let{prefix:t}=await ri(e);return`${t}${jke}`}function Zke(e,t,n=`refs/heads/${Lke}`){let i=new Map,r=Hke(e,n)??null;if(!r)return{tip:r,files:i};let o=Mg(e,["ls-tree","-z",`${r}:${t}`]);if(!o)return{tip:r,files:i};let s=[];for(let c of o.split("\0").filter(Boolean)){let u=c.indexOf(" "),[,d,p]=c.slice(0,u).split(" "),g=c.slice(u+1).match(/^(.+)\.jsonl$/);d==="blob"&&g&&$Z.test(g[1])&&s.push({id:g[1],sha:p})}if(s.length===0)return{tip:r,files:i};let a=Mg(e,["cat-file","--batch"],`${s.map(c=>c.sha).join(`
218
+ `)}
219
+ `)??"",l=0;for(let c of s){let u=a.indexOf(`
220
+ `,l);if(u<0)break;let d=Number(a.slice(l,u).split(" ")[2]),p=u+1,f=Buffer.from(a.slice(p)).subarray(0,d).toString("utf-8");i.set(c.id,{path:`${t}/${c.id}.jsonl`,content:f}),l=p+f.length+1}return{tip:r,files:i}}function Yke(e,t,n){let i=n.find(o=>o.event==="start");if(!i)return;let r=n.find(o=>o.event==="end");return{id:e,state:r?"ended":"running",startedAt:i.at,endedAt:r?.at??null,outcome:r?.outcome??null,by:i.by,agent:i.agent,harness:i.harness,model:i.model,provider:i.provider,unit:i.unit,lease:i.lease,records:i.records??[],instruction:i.instruction??null,usage:r?.usage??null,models:r?.models??[],cost:r?.cost??null,transcript:r?.transcript??null,commits:(r?.commits??[]).map(o=>({sha:o.sha,patchId:o.patchId,joinedBy:["record"],hunks:Array.isArray(o.hunks)&&o.hunks.length>0?o.hunks:null})),decisions:[],ledger:t,record:r?{sha256:bZ(i,r)}:null,statements:n.filter(o=>o.event==="statement").map(o=>({at:o.at,envelope:o.envelope}))}}async function Xke(e,t){let n=await Jke(t),{tip:i,files:r}=Zke(e,n),o=new Map,s=0;for(let[a,l]of r){let c=Kke(l.content,a);s+=c.malformed;let u=Yke(a,l.path,c.lines);u?o.set(a,u):s+=c.lines.length}return{tip:i,dir:n,runs:o,malformed:s}}function Qke(e){let t=new Map;for(let n of e)for(let i of n.commits){if(!i.patchId||!i.joinedBy.includes("record"))continue;let r=t.get(i.patchId)??t.set(i.patchId,[]).get(i.patchId);r.some(o=>o.run===n.id&&o.sha===i.sha)||r.push({run:n.id,sha:i.sha})}return t}async function Lk(e,t,n){let i=new Map;try{i=(await Xke(e,t)).runs}catch{}let r=new Map;for(let u of i.values())for(let d of u.commits)(r.get(d.sha)??r.set(d.sha,[]).get(d.sha)).push(u.id);let o=Qke(i.values()),s=o.size>0?qke(e,n.map(u=>u.sha)):new Map,a=new Map,l=[],c=(u,d,p)=>{let f=i.get(u);return{id:u,recorded:f!==void 0,state:f?.state??null,harness:f?.harness.name??null,model:f?.model??null,provider:f?.provider??null,by:f?.by??null,agent:f?.agent??null,unit:f?.unit?.id??null,joinedBy:d,...p?{recordedAs:p}:{}}};for(let u of n){let d=r.get(u.sha)??[],p=[...new Set([...u.run?[u.run]:[],...d])],f=(o.get(s.get(u.sha)??"")??[]).filter(h=>h.sha!==u.sha);if(p.length>0){let h=f.filter(b=>!p.includes(b.run));h.length>0&&l.push({sha:u.sha,joined:p,content:h}),a.set(u.sha,p.map(b=>c(b,[...u.run===b?["trailer"]:[],...d.includes(b)?["record"]:[]])));continue}let g=new Map;for(let h of f)g.has(h.run)||g.set(h.run,h.sha);a.set(u.sha,[...g].map(([h,b])=>c(h,["patch-id"],b)))}return{refs:a,runs:i,conflicts:l}}function Mk(e,t){for(let n of t.values()){if(!n.followed)continue;let i=e.get(n.sha)??e.set(n.sha,[]).get(n.sha);for(let r of n.commits)for(let o of e.get(r)??[]){let s=i.find(u=>u.id===o.id);if(s){s.joinedBy.includes("squash")||s.joinedBy.push("squash"),s.via=[...new Set([...s.via??[],r])];continue}let{recordedAs:a,via:l,...c}=o;i.push({...c,joinedBy:["squash"],via:[r]})}}}var jke,Lke,$Z,RZ,vZ,Mke,Es,sn,SZ,kZ,Fke,Bke,Gke,Wke,xZ,zke,Uke,EZ,AZ,cqe,lqe,uqe,PZ,dqe,BD=v(()=>{"use strict";Ln();$t();ga();Wt();jk();Fv();wZ();jke="_agent-runs",Lke="chant/lifecycle",$Z=/^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/,RZ=/^[0-9a-f]{64}$/,vZ=/^[0-9a-f]{4,64}$/,Mke=/^[A-Z]{3}$/,Es=m.number().int().nonnegative(),sn=m.string().trim().min(1).refine(e=>!/[\r\n]/.test(e),"one line of text"),SZ=m.string().refine(e=>!Number.isNaN(Date.parse(e))&&/^\d{4}-\d{2}-\d{2}T/.test(e),"an ISO 8601 date and time"),kZ=m.object({amount:m.number().nonnegative().finite(),currency:m.string().regex(Mke,"an ISO 4217 code such as USD"),source:sn}).strict(),Fke=m.object({turns:Es.optional(),inputTokens:Es.optional(),outputTokens:Es.optional(),cacheReadTokens:Es.optional(),cacheWriteTokens:Es.optional()}).strict(),Bke=m.object({sha256:m.string().regex(RZ,"64 lower-case hex digits").optional(),path:sn.optional(),ref:sn.optional()}).strict().refine(e=>e.sha256===void 0!=(e.path===void 0),"give sha256, or a path for chant to hash, not both"),Gke=500,Wke=m.object({sha256:m.string().regex(RZ,"64 lower-case hex digits").optional(),path:sn.optional(),ref:sn.optional(),excerpt:m.string().trim().min(1).max(Gke).optional()}).strict().refine(e=>e.sha256===void 0!=(e.path===void 0),"give sha256, or a path for chant to hash, not both"),xZ=m.number().int().positive(),zke=m.object({path:sn,start:xZ,end:xZ}).strict().refine(e=>e.end>=e.start,"end is not before start").refine(e=>!e.path.startsWith("/")&&!e.path.split("/").includes(".."),"a path from the repository root"),Uke=m.union([m.string().regex(vZ,"a commit id"),m.object({sha:m.string().regex(vZ,"a commit id"),hunks:m.array(zke).min(1)}).strict()]),EZ={id:m.string().regex($Z,"letters, digits, '.', '_' and '-', starting with a letter or digit").optional(),startedAt:SZ.optional(),by:sn.optional(),agent:sn.optional(),harness:m.union([sn,m.object({name:sn,version:sn.optional()}).strict()]),model:sn.optional(),provider:sn.optional(),unit:m.union([sn,m.object({id:sn,kind:sn.optional()}).strict()]).optional(),lease:sn.optional(),records:m.array(m.string().refine(e=>eT(e)!==void 0,"<kind>:<id>")).optional(),instruction:Wke.optional()},AZ={endedAt:SZ.optional(),outcome:sn.optional(),usage:Fke.optional(),models:m.array(m.object({model:sn,provider:sn.optional(),inputTokens:Es.optional(),outputTokens:Es.optional(),cacheReadTokens:Es.optional(),cacheWriteTokens:Es.optional(),cost:kZ.optional()}).strict()).optional(),cost:kZ.optional(),transcript:Bke.optional(),commits:m.array(Uke).optional()},cqe=m.object(EZ).strict(),lqe=m.object(AZ).strict(),uqe=m.object({...EZ,...AZ}).strict();PZ=["trailer","record","patch-id","squash"];dqe=1440*60*1e3});function Fk(e){return e.isTag===!0}function Bk(e){return e.isTag!==!0&&e.foldsAsCall===!0}function ml(e){return e.isTag!==!0&&e.foldsEagerly===!0}function Yd(e){if(typeof e!="object"||e===null||!("name"in e)||typeof e.name!="string"||!("serializer"in e)||typeof e.serializer!="object")return!1;let t=e;return typeof t.generate=="function"&&typeof t.validate=="function"&&typeof t.coverage=="function"&&typeof t.package=="function"}var Ro=v(()=>{"use strict"});function gl(e){return txe.has(e)}function Gk(e){return nxe.some(t=>e===t||e.startsWith(t.endsWith("-")?t:`${t}/`))}var exe,txe,nxe,Wk=v(()=>{"use strict";exe=[{name:"phase",module:"components/component.ts, op/builders.ts",note:"Returns a plain `{ phase, steps, parallel? }` / `{ name, steps, parallel? }` object literal built from its arguments. No state, no I/O."},{name:"gate",module:"components/component.ts, op/builders.ts",note:"Returns a plain `{ kind: 'gate', gate, ... }` object literal built from its arguments."},{name:"activity",module:"op/builders.ts",note:"Returns a plain `{ kind: 'activity', fn, args?, profile? }` object literal built from its arguments."},{name:"stackOutput",module:"components/component.ts, stack-output.ts",note:"Component form returns a plain `{ stackOutput: { stack, name } }` literal. Cross-stack form derives a `StackOutput` from a real `AttrRef`/`Intrinsic` and throws on anything else \u2014 so a fold that only has a symbolic reference fails loudly into run-fallback rather than producing a wrong output."},{name:"output",module:"lexicon-output.ts",note:"Constructs a `LexiconOutput` from a real `AttrRef`/`Intrinsic` and a name. Pure, but identity-sensitive: it reads through the ref's `WeakRef` to its parent entity. Only folds when the ref argument revives to a REAL live reference (see fold-import.ts's `requireLiveRefs`); a symbolic `{ __attrRef }` envelope is rejected, not silently wrapped."},{name:"when",module:"op/converge-rule.ts",note:"Returns a plain `{ id, when, then, why, flapThreshold? }` rule record built from its arguments. Throws at construction on a missing `id`/`why` or a non-positive `flapThreshold`, which is the build-time refusal the run path performs too, so a bad rule fails identically either way."},{name:"eq",module:"op/converge-rule.ts",note:"Returns a plain `{ kind: 'field-comparison', field, op: 'eq', value }` literal built from its arguments."},{name:"neq",module:"op/converge-rule.ts",note:"Returns a plain `{ kind: 'field-comparison', field, op: 'neq', value }` literal built from its arguments."},{name:"gt",module:"op/converge-rule.ts",note:"Returns a plain `{ kind: 'field-comparison', field, op: 'gt', value }` literal built from its arguments."},{name:"gte",module:"op/converge-rule.ts",note:"Returns a plain `{ kind: 'field-comparison', field, op: 'gte', value }` literal built from its arguments."},{name:"lt",module:"op/converge-rule.ts",note:"Returns a plain `{ kind: 'field-comparison', field, op: 'lt', value }` literal built from its arguments."},{name:"lte",module:"op/converge-rule.ts",note:"Returns a plain `{ kind: 'field-comparison', field, op: 'lte', value }` literal built from its arguments."},{name:"truthy",module:"op/converge-rule.ts",note:"Returns a plain `{ kind: 'field-truthiness', field, op: 'truthy' }` literal built from its argument."},{name:"falsy",module:"op/converge-rule.ts",note:"Returns a plain `{ kind: 'field-truthiness', field, op: 'falsy' }` literal built from its argument."},{name:"allOf",module:"op/converge-rule.ts",note:"Returns a plain `{ kind: 'all-of', predicates }` literal over its already-folded predicate arguments."},{name:"anyOf",module:"op/converge-rule.ts",note:"Returns a plain `{ kind: 'any-of', predicates }` literal over its already-folded predicate arguments."},{name:"run",module:"op/converge-rule.ts",note:"Returns a plain `{ kind: 'run', op }` action literal. Names an Op for a later tick to dispatch; it runs nothing at fold time, or at any other time."},{name:"report",module:"op/converge-rule.ts",note:"Returns a plain `{ kind: 'report', reason }` action literal built from its argument."}],txe=new Set(exe.map(e=>e.name));nxe=["@intentius/chant","@intentius/chant-lexicon-"]});function OZ(e){return Ie.isIdentifier(e)||Ie.isStringLiteral(e)||Ie.isNumericLiteral(e)}function Fg(e){return Ie.isStringLiteral(e)||Ie.isNumericLiteral(e)}function ir(e,t=60){let n=e.getText().replace(/\s+/g," ").trim();return n.length>t?`${n.slice(0,t-3)}...`:n}function Hk(e){return`computed/dynamic property name not foldable: ${ir(e)}`}function CZ(e){return`dynamic property access \u2014 computed key must be a string or numeric literal: ${ir(e)}`}function Gg(e){return`unsupported binary operator: ${Ie.SyntaxKind[e]}`}function Xd(e){return`function call as a value is not foldable: ${ir(e.expression)}(...)`}function Wg(e){return`unsupported expression: ${Ie.SyntaxKind[e.kind]}`}var Ie,zk,Uk,Bg,Vk,hl=v(()=>{"use strict";Ie=Le(Ke(),1);Wk();Ro();zk=new Set([Ie.SyntaxKind.AmpersandAmpersandToken,Ie.SyntaxKind.BarBarToken,Ie.SyntaxKind.QuestionQuestionToken,Ie.SyntaxKind.PlusToken,Ie.SyntaxKind.MinusToken,Ie.SyntaxKind.AsteriskToken,Ie.SyntaxKind.SlashToken,Ie.SyntaxKind.EqualsEqualsEqualsToken,Ie.SyntaxKind.ExclamationEqualsEqualsToken,Ie.SyntaxKind.GreaterThanToken,Ie.SyntaxKind.LessThanToken,Ie.SyntaxKind.GreaterThanEqualsToken,Ie.SyntaxKind.LessThanEqualsToken]),Uk=new Set([Ie.SyntaxKind.ExclamationToken,Ie.SyntaxKind.MinusToken]);Bg="unsupported object member",Vk="unsupported unary"});import{relative as rxe}from"node:path";function ixe(e){if(typeof e!="object"||e===null)return;let t=e;if("__attrRef"in t){let n=t.__attrRef;return`a resource attribute reference${typeof n?.entity=="string"&&typeof n?.attribute=="string"?` (${n.entity}.${n.attribute})`:""}`}if("__intrinsic"in t&&typeof t.__intrinsic=="string")return`the intrinsic \`${t.__intrinsic}\``;if("__helper"in t&&typeof t.__helper=="string")return`the helper \`${t.__helper}\``;if("__resource"in t&&typeof t.__resource=="string")return`a nested \`new ${t.__resource}\``;if("__compositeStep"in t&&typeof t.__compositeStep=="string")return`the composite step \`${t.__compositeStep}(\u2026).step\``}function WD(e,t=new Set){if(e===null||typeof e!="object")return typeof e=="function";if(t.has(e))return!1;t.add(e);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==Array.prototype&&n!==null)return!0;for(let i of Object.values(e))if(WD(i,t))return!0;return!1}function Zk(e,t,n=new Set){if(n.has(t))return!1;n.add(t);let i=e.get(t);return i===void 0?!1:J.isNewExpression(i)?!0:J.isIdentifier(i)?Zk(e,i.text,n):!1}function oxe(e){let t=e;for(;J.isParenthesizedExpression(t)||J.isAsExpression(t)||J.isSatisfiesExpression(t);)t=t.expression;return J.isArrowFunction(t)||J.isFunctionExpression(t)?t:void 0}function UD(e,t,n,i,r){let o=new Map(t);for(let[l]of[...o])Zk(t,l,new Set)&&o.delete(l);let s=new Map,a=(l,c)=>{s.set(l,new Jk(l,c,n,o,i,r))};for(let l of e.statements){if(J.isFunctionDeclaration(l)){l.name&&l.body&&a(l.name.text,l);continue}if(J.isVariableStatement(l)&&(l.declarationList.flags&J.NodeFlags.Const)!==0)for(let c of l.declarationList.declarations){if(!J.isIdentifier(c.name)||!c.initializer)continue;let u=oxe(c.initializer);u&&a(c.name.text,u)}}return s}function sxe(e,t){let n;try{n=e.getSourceFile()}catch{return}if(!n)return;let i=_Z.get(n);i||(i=new WeakMap,_Z.set(n,i));let r=i.get(t);if(r)return r;let o=new Map,s=UD(n,t,n.fileName,o);for(let[a,l]of s)o.set(a,l);return i.set(t,s),s}function As(e){return e instanceof Jk}function zD(e){if(e.dotDotDotToken||e.initializer||!J.isIdentifier(e.name))return;let t=e.propertyName??e.name;if(J.isIdentifier(t)||J.isStringLiteral(t)||J.isNumericLiteral(t))return t.text}function axe(e){if(e.asteriskToken)return"a generator function is not foldable";if(e.modifiers?.some(n=>n.kind===J.SyntaxKind.AsyncKeyword))return"an async function is not foldable";if(!e.body)return"a function without a body (an overload signature) is not foldable";for(let n of e.parameters){if(n.dotDotDotToken)return"a rest parameter is not foldable";if(!J.isIdentifier(n.name)){if(J.isObjectBindingPattern(n.name)){for(let i of n.name.elements)if(zD(i)===void 0)return"a destructured parameter with a rest, default, or nested element is not foldable";continue}return"an array-destructured parameter is not foldable"}}if(!J.isBlock(e.body))return;let t=e.body.statements;for(let n=0;n<t.length;n+=1){let i=t[n],r=n===t.length-1;if(J.isReturnStatement(i)){if(!r)return"an early `return` is not foldable";continue}if(!J.isVariableStatement(i))return`\`${J.SyntaxKind[i.kind]}\` in a function body is not foldable \u2014 only \`const\` declarations and a final \`return\` are`;if((i.declarationList.flags&J.NodeFlags.Const)===0)return"`let`/`var` in a function body is not foldable";for(let o of i.declarationList.declarations){if(!o.initializer)return"an uninitialized `const` in a function body is not foldable";if(!J.isIdentifier(o.name)){if(J.isObjectBindingPattern(o.name)){for(let s of o.name.elements)if(zD(s)===void 0)return"a destructured `const` with a rest, default, or nested element is not foldable";continue}return"an array-destructured `const` in a function body is not foldable"}}}}function zg(e,t){if(qk!==0)return dt(e,`${t} inside a folded function body is not foldable`,"EVL001",!0)}function IZ(e){let t=rxe(process.cwd(),e);return t.startsWith("..")?e:t}function TZ(e,t,n,i,r){let o=`call to "${e.name}" (${IZ(e.file)})`,s=axe(e.fn);if(s)throw dt(t,`${o} is not foldable: ${s}`);if(qk>=cxe)throw dt(t,`${o} is not foldable: call depth exceeded \u2014 is it recursive?`);let a=[];for(let p of t.arguments){if(J.isSpreadElement(p))throw dt(p,`${o} is not foldable: a spread argument is not foldable`);a.push(Me(p,n,i,r))}let l=new Map(e.consts),c=new Map(e.externals),u=(p,f)=>{l.delete(p),c.set(p,f)},d=(p,f)=>{if(f===null||typeof f!="object")throw dt(p,`destructured source in \`${ir(p)}\` is not an object`);for(let g of p.elements)u(g.name.text,f[zD(g)])};qk+=1;try{let p=lxe(e,a,l,c,i,u,d);return!e.leakedIdentity&&WD(p)&&!a.some(f=>WD(f))&&(e.leakedIdentity=!0),p}catch(p){if(!(p instanceof So))throw p;let f=`${p.line}:${p.column} - `,g=p.message.startsWith(f)?p.message.slice(f.length):p.message,h=g,b=/^unresolved identifier: (\w+)$/.exec(g);throw b&&e.failures?.has(b[1])&&(h=`${g} (${e.failures.get(b[1])})`),dt(t,`${o} is not foldable: ${IZ(e.file)}:${p.line}:${p.column} - ${h}`,p.ruleId,p.refusedAtDepth)}finally{qk-=1}}function lxe(e,t,n,i,r,o,s){e.fn.parameters.forEach((l,c)=>{let u=t[c];u===void 0&&l.initializer&&(u=Me(l.initializer,n,r,i)),J.isIdentifier(l.name)?o(l.name.text,u):s(l.name,u)});let a=e.fn.body;if(!J.isBlock(a))return Me(a,n,r,i);for(let l of a.statements){if(J.isReturnStatement(l))return l.expression?Me(l.expression,n,r,i):void 0;for(let c of l.declarationList.declarations){let u=Me(c.initializer,n,r,i);J.isIdentifier(c.name)?o(c.name.text,u):s(c.name,u)}}}function HD(e){let t=e.getSourceFile(),{line:n,character:i}=t.getLineAndCharacterOfPosition(e.getStart());return{line:n+1,column:i+1}}function dt(e,t,n="EVL001",i=!1){let{line:r,column:o}=HD(e);return new So(t,r,o,n,i)}function Ug(e){let t=new Map;for(let n of e.statements)if(J.isVariableStatement(n)&&(n.declarationList.flags&J.NodeFlags.Const)!==0)for(let i of n.declarationList.declarations)J.isIdentifier(i.name)&&i.initializer&&t.set(i.name.text,i.initializer);return t}function Hg(e){if(OZ(e))return e.text;throw dt(e,Hk(e))}function uxe(e){if(Fg(e))return e.text;throw dt(e,CZ(e),"EVL003")}function DZ(e,t){let n=e.get(t.text);return n!==void 0&&J.isNewExpression(n)}function dxe(e,t,n,i){if(!J.isCallExpression(e)||!J.isIdentifier(e.expression))return!1;let r=e.expression.text;return!(t.has(r)||gl(r)||n.some(o=>o.name===r&&Bk(o))||As(i?.get(r)))}function NZ(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&"__resource"in e}function pxe(e){return typeof e!="object"||e===null||Array.isArray(e)?!1:"__attrRef"in e||"__intrinsic"in e||"__helper"in e||"__resource"in e||"__compositeStep"in e}function jZ(e,t){if(J.isIdentifier(e.expression))return{__attrRef:{entity:e.expression.text,attribute:t}};throw dt(e,`attribute "${t}" read on an inline resource expression is not foldable \u2014 bind the resource to a const first (falls back to run)`)}function GD(e){return e===MZ}function Qd(e){return FZ(e)?MZ:void 0}function FZ(e){let t=e.parent;return t===void 0?!1:J.isNonNullExpression(t)&&J.isOptionalChain(t)?FZ(t):(J.isPropertyAccessExpression(t)||J.isElementAccessExpression(t)||J.isCallExpression(t))&&t.expression===e&&J.isOptionalChain(t)}function LZ(e,t){return`property "${e}" read on ${String(t)} is not foldable \u2014 running this expression throws a TypeError, so the file falls back to run (write \`?.\` if the value is genuinely optional)`}function Kk(e,t,n){return J.isIdentifier(e)?e.text!=="undefined"&&!t.has(e.text)&&!n?.has(e.text):J.isPropertyAccessExpression(e)||J.isElementAccessExpression(e)||J.isNonNullExpression(e)?Kk(e.expression,t,n):!1}function BZ(e,t,n,i){return Kk(e,t,i)?{__symbol:e.getText()}:Me(e,t,n,i)}function fxe(e){let t=e.rawText;if(t===void 0){let n=e.getText(),i=J.isTemplateHead(e)||J.isTemplateMiddle(e)?2:1;t=n.slice(1,n.length-i)}return t.replace(/\r\n?/g,`
221
+ `)}function mxe(e){for(let t=0;t<e.length;t++){if(e[t]!=="\\")continue;let n=e.slice(t+1),i=n[0];if(i==="x"){if(!/^x[0-9a-fA-F]{2}/.test(n))return!0}else if(i==="u"){let r=/^u(?:[0-9a-fA-F]{4}|\{([0-9a-fA-F]+)\})/.exec(n);if(!r||r[1]!==void 0&&parseInt(r[1],16)>1114111)return!0}else{if(i!==void 0&&i>="1"&&i<="9")return!0;if(i==="0"&&n[1]!==void 0&&n[1]>="0"&&n[1]<="9")return!0}t+=1}return!1}function gxe(e,t,n,i){let r=e.tag.getText();if(!n.some(d=>d.name===r&&Fk(d)))throw dt(e,`unregistered tagged template intrinsic: ${ir(e.tag)}\`...\``);let s=e.template,a=J.isNoSubstitutionTemplateLiteral(s)?[s]:[s.head,...s.templateSpans.map(d=>d.literal)],l=a.map(fxe);if(l.some(mxe))throw dt(e,`${ir(e.tag)}\`...\` holds an escape sequence with no cooked value \u2014 not foldable, falls back to run`);let c=a.map(d=>d.text),u=J.isNoSubstitutionTemplateLiteral(s)?[]:s.templateSpans.map(d=>BZ(d.expression,t,n,i));return{__intrinsic:r,strings:c,raw:l,values:u}}function Me(e,t,n=[],i){if(J.isParenthesizedExpression(e)||J.isAsExpression(e)||J.isSatisfiesExpression(e)||J.isNonNullExpression(e))return Me(e.expression,t,n,i);if(J.isArrowFunction(e)||J.isFunctionExpression(e))throw dt(e,"a function used as a value is not foldable");if(J.isStringLiteral(e)||J.isNoSubstitutionTemplateLiteral(e))return e.text;if(J.isNumericLiteral(e))return Number(e.text);if(e.kind===J.SyntaxKind.TrueKeyword)return!0;if(e.kind===J.SyntaxKind.FalseKeyword)return!1;if(e.kind===J.SyntaxKind.NullKeyword)return null;if(!(J.isIdentifier(e)&&e.text==="undefined")){if(J.isTaggedTemplateExpression(e)){let r=zg(e,"a tagged template intrinsic");if(r)throw r;return gxe(e,t,n,i)}if(J.isTemplateExpression(e)){let r=e.head.text;for(let o of e.templateSpans){let s=Me(o.expression,t,n,i),a=ixe(s);if(a)throw dt(o.expression,`${a} interpolated into a plain template literal, which would stringify it as "[object Object]". A symbolic value has no string form until the build resolves it, so a plain template cannot carry one. Use the lexicon's own intrinsic, whose interior handles envelopes \u2014 \`Sub\`\${\u2026}\`\` for CloudFormation \u2014 or move the reference out of the template.`);r+=String(s)+o.literal.text}return r}if(J.isObjectLiteralExpression(e)){let r={};for(let o of e.properties)if(J.isPropertyAssignment(o))r[Hg(o.name)]=Me(o.initializer,t,n,i);else if(J.isShorthandPropertyAssignment(o))r[o.name.text]=Me(o.name,t,n,i);else if(J.isSpreadAssignment(o)){let s=Me(o.expression,t,n,i);if(s===null||typeof s!="object")throw dt(o,"spread source not an object");Object.assign(r,s)}else throw dt(o,Bg);return r}if(J.isArrayLiteralExpression(e)){let r=[];for(let o of e.elements)if(J.isSpreadElement(o)){let s=Me(o.expression,t,n,i);if(!Array.isArray(s))throw dt(o,"spread source not an array");r.push(...s)}else r.push(Me(o,t,n,i));return r}if(J.isIdentifier(e)){if(!t.has(e.text)){if(i?.has(e.text)){let o=i.get(e.text);if(As(o))throw dt(e,`function "${e.text}" used as a value is not foldable`);if(typeof o=="function"&&n.some(s=>s.name===e.text&&ml(s)))throw dt(e,`function "${e.text}" used as a value is not foldable \u2014 call it instead`);return o}throw e.text==="process"?dt(e,'ambient "process" read is not foldable \u2014 declare a build-time parameter instead (chant.config.ts\'s buildParams + `chant build --param name=value`/`--params-file`) and reference it via `import { params } from "@intentius/chant/params"`, rather than reading process.env directly'):dt(e,`unresolved identifier: ${e.text}`)}let r=t.get(e.text);if((J.isTaggedTemplateExpression(r)||J.isCallExpression(r))&&i?.has(e.text))return i.get(e.text);if(J.isNewExpression(r)){if(i?.has(e.text))return i.get(e.text);throw dt(e,`same-file resource \`${e.text}\` used as a value is not foldable \u2014 falls back to run`)}return Me(r,t,n,i)}if(J.isPropertyAccessExpression(e)){if(J.isIdentifier(e.expression)&&DZ(t,e.expression))return{__attrRef:{entity:e.expression.text,attribute:e.name.text}};if(e.name.text==="step"&&dxe(e.expression,t,n,i)){let o=e.expression,s=o.expression.text,a=zg(e,`composite call \`${s}(...).step\``);if(a)throw a;return{__compositeStep:s,args:o.arguments.map(l=>Me(l,t,n,i))}}let r=Me(e.expression,t,n,i);if(GD(r))return Qd(e);if(r==null){if(e.questionDotToken)return Qd(e);throw dt(e,LZ(e.name.text,r))}return NZ(r)?jZ(e,e.name.text):r[e.name.text]}if(J.isElementAccessExpression(e)){let r=uxe(e.argumentExpression);if(J.isIdentifier(e.expression)&&DZ(t,e.expression))return{__attrRef:{entity:e.expression.text,attribute:r}};let o=Me(e.expression,t,n,i);if(GD(o))return Qd(e);if(o==null){if(e.questionDotToken)return Qd(e);throw dt(e,LZ(r,o))}return NZ(o)?jZ(e,r):o[r]}if(J.isPrefixUnaryExpression(e)){if(!Uk.has(e.operator))throw dt(e,Vk);let r=Me(e.operand,t,n,i);return e.operator===J.SyntaxKind.ExclamationToken?!r:-r}if(J.isBinaryExpression(e)){let r=e.operatorToken.kind,o=J.SyntaxKind;if(r===o.AmpersandAmpersandToken){let l=Me(e.left,t,n,i);return l&&Me(e.right,t,n,i)}if(r===o.BarBarToken){let l=Me(e.left,t,n,i);return l||Me(e.right,t,n,i)}if(r===o.QuestionQuestionToken){let l=Me(e.left,t,n,i);return l??Me(e.right,t,n,i)}if(!zk.has(r))throw dt(e,Gg(r));let s=Me(e.left,t,n,i),a=Me(e.right,t,n,i);switch(r){case o.PlusToken:return s+a;case o.MinusToken:return s-a;case o.AsteriskToken:return s*a;case o.SlashToken:return s/a;case o.EqualsEqualsEqualsToken:return s===a;case o.ExclamationEqualsEqualsToken:return s!==a;case o.GreaterThanToken:return s>a;case o.LessThanToken:return s<a;case o.GreaterThanEqualsToken:return s>=a;case o.LessThanEqualsToken:return s<=a;default:throw dt(e,Gg(r))}}if(J.isConditionalExpression(e))return Me(e.condition,t,n,i)?Me(e.whenTrue,t,n,i):Me(e.whenFalse,t,n,i);if(J.isNewExpression(e)){if(!J.isIdentifier(e.expression))throw dt(e,`nested \`new ${ir(e.expression)}(...)\` as a value needs a plain imported constructor \u2014 falls back to run`);let r=zg(e,`\`new ${e.expression.text}(...)\``);if(r)throw r;return Yk(e,t,n,i)}if(J.isCallExpression(e)){if(J.isIdentifier(e.expression)&&gl(e.expression.text)&&!t.has(e.expression.text)){let r=zg(e,`authoring helper call \`${e.expression.text}(...)\``);if(r)throw r;return{__helper:e.expression.text,args:e.arguments.map(o=>Me(o,t,n,i))}}if(J.isIdentifier(e.expression)&&!t.has(e.expression.text)){let r=e.expression.text;if(n.some(o=>o.name===r&&Bk(o))){let o=zg(e,`intrinsic call \`${r}(...)\``);if(o)throw o;return{__intrinsic:r,args:e.arguments.map(s=>BZ(s,t,n,i))}}}if(J.isIdentifier(e.expression)){let r=i?.get(e.expression.text);if(As(r))return TZ(r,e,t,n,i);if(i===void 0){let o=sxe(e,t)?.get(e.expression.text);if(o)return TZ(o,e,t,n,o.externals)}}if(J.isIdentifier(e.expression)&&!t.has(e.expression.text)&&n.some(r=>r.name===e.expression.text&&ml(r))){let r=i?.get(e.expression.text);if(typeof r!="function")throw dt(e,`"${e.expression.text}" did not resolve to a function \u2014 falls back to run`);let o=e.arguments.map(s=>Me(s,t,n,i));return r(...o)}if(J.isPropertyAccessExpression(e.expression)){let r=e.expression.name.text,o=Me(e.expression.expression,t,n,i);if(GD(o))return Qd(e);if(o==null){if(e.expression.questionDotToken)return Qd(e);throw dt(e,`cannot call ".${r}(...)" on ${String(o)}`)}if(pxe(o))throw dt(e,`method call \`.${r}(...)\` on an unresolved value is not foldable \u2014 falls back to run`);let s=o[r];if(typeof s!="function")throw dt(e,`"${r}" is not a callable method on the folded value \u2014 falls back to run`);let a=e.arguments.map(l=>Me(l,t,n,i));return s.apply(o,a)}throw dt(e,Xd(e))}throw dt(e,Wg(e))}}function Yk(e,t,n=[],i){let r=e.expression.getText(),o=e.arguments??[],[s,a]=o,l=p=>Me(p,t,n,i);if(!s)return{__resource:r,props:{}};if(J.isObjectLiteralExpression(s)){let p=l(s);if(o.length===1)return{__resource:r,props:p};if(o.length===2&&J.isObjectLiteralExpression(a))return{__resource:r,props:p,attributes:l(a)}}let c=o.map(l),u=o.findIndex(p=>J.isObjectLiteralExpression(p)),d=u===-1?{}:c[u];return{__resource:r,props:d,args:c}}var J,So,Jk,_Z,qk,cxe,MZ,Xk=v(()=>{"use strict";J=Le(Ke(),1);Ro();hl();Wk();So=class extends Error{constructor(t,n,i,r="EVL001",o=!1){let s=Error.stackTraceLimit;Error.stackTraceLimit=0,super(`${n}:${i} - ${t}`),Error.stackTraceLimit=s,this.name="FoldError",this.line=n,this.column=i,this.ruleId=r,this.refusedAtDepth=o}},Jk=class{constructor(t,n,i,r,o,s){this.name=t;this.fn=n;this.file=i;this.consts=r;this.externals=o;this.failures=s;this.leakedIdentity=!1}};_Z=new WeakMap;qk=0,cxe=32;MZ=Symbol("chant.fold.optional-chain-short-circuit")});var VZ={};_e(VZ,{readConfigFieldsStatically:()=>wxe,readLexiconDeclarationsStatically:()=>VD,staticConfigBaseDir:()=>vxe,unknownPathLexiconsNotice:()=>qD});import{existsSync as hxe,readFileSync as WZ}from"node:fs";import{dirname as yxe,join as bxe}from"node:path";function VD(e){let{configPath:t}=Ef(e);if(t===void 0)return{status:"no-config"};try{let n=UZ(t,["lexicons"]).lexicons;if(n===void 0)return{status:"read",configPath:t,entries:[]};let i=Sf.shape.lexicons.safeParse(n);return i.success?{status:"read",configPath:t,entries:i.data??[]}:{status:"unknown",configPath:t,reason:"`lexicons` is not a list of lexicon entries"}}catch(n){return{status:"unknown",configPath:t,reason:zZ(n)}}}function zZ(e){return e instanceof So?`line ${e.line}: ${e.message}`:e instanceof li?e.message:`the file could not be read (${e instanceof Error?e.message:String(e)})`}function wxe(e,t){let n=["chant.config.ts","chant.config.json"].map(i=>bxe(e,i)).find(i=>hxe(i));if(n===void 0)return{status:"no-config"};try{return{status:"read",configPath:n,fields:UZ(n,t)}}catch(i){return{status:"unknown",configPath:n,reason:zZ(i)}}}function UZ(e,t){let n=e.endsWith(".json")?kxe(e,t):xxe(e,t);return Object.fromEntries(Object.entries(n).filter(([,i])=>i!==void 0))}function vxe(e){return yxe(e.configPath)}function qD(e){if(e.status==="unknown")return`note: could not read the lexicons in ${e.configPath} without running it (${e.reason}). chant does not run it for this command, so any lexicon it declares by path is unknown here and is treated as a package.`}function kxe(e,t){let n=JSON.parse(WZ(e,"utf-8"));if(typeof n!="object"||n===null||Array.isArray(n))throw new li("the config is not a JSON object");return Object.fromEntries(t.map(i=>[i,n[i]]))}function xxe(e,t){let n=We.createSourceFile(e,WZ(e,"utf-8"),We.ScriptTarget.Latest,!0),i=Ug(n),r,o=new Map;for(let l of n.statements)if(We.isExportAssignment(l)){if(l.isExportEquals)throw new li("`export =` is not read");r=l.expression}else{if(We.isExportDeclaration(l))throw new li("an `export { \u2026 }` or `export \u2026 from` declaration is not read");if(We.isVariableStatement(l)&&GZ(l)){if((l.declarationList.flags&We.NodeFlags.Const)===0)throw new li("an exported `let` or `var` is not read");for(let c of l.declarationList.declarations)if(We.isIdentifier(c.name)&&c.initializer)o.set(c.name.text,c.initializer);else throw new li("a destructured export is not read")}else if(GZ(l)&&Sxe(l))throw new li("the default export is not an object")}let s=r??o.get("config");if(s===void 0)return Object.fromEntries(t.map(l=>{let c=o.get(l);return[l,c===void 0?void 0:Me(c,i)]}));let a=HZ(s,i,new Set);return Object.fromEntries(t.map(l=>[l,$xe(a,l,i)]))}function HZ(e,t,n){let i=Rxe(e);if(We.isObjectLiteralExpression(i))return i;if(We.isIdentifier(i)){let r=t.get(i.text);if(r===void 0||n.has(i.text))throw new li(`the exported config \`${i.text}\` is not a top-level const of this file`);return n.add(i.text),HZ(r,t,n)}throw new li("the exported config is not an object literal")}function $xe(e,t,n){let i;for(let r of e.properties){if(We.isSpreadAssignment(r)){let s=Me(r.expression,n);s!==null&&typeof s=="object"&&Object.prototype.hasOwnProperty.call(s,t)&&(i=s[t]);continue}if(!(r.name===void 0||Hg(r.name)!==t))if(We.isPropertyAssignment(r))i=Me(r.initializer,n);else if(We.isShorthandPropertyAssignment(r))i=Me(r.name,n);else throw new li(`\`${t}\` is a method or accessor`)}return i}function Rxe(e){let t=e;for(;We.isParenthesizedExpression(t)||We.isAsExpression(t)||We.isSatisfiesExpression(t)||We.isNonNullExpression(t)||We.isTypeAssertionExpression(t);)t=t.expression;return t}function GZ(e){return(We.canHaveModifiers(e)&&We.getModifiers(e)?.some(t=>t.kind===We.SyntaxKind.ExportKeyword))??!1}function Sxe(e){return(We.canHaveModifiers(e)&&We.getModifiers(e)?.some(t=>t.kind===We.SyntaxKind.DefaultKeyword))??!1}var We,li,Qk=v(()=>{"use strict";We=Le(Ke(),1);Kt();Xk();li=class extends Error{}});var ex=v(()=>{"use strict"});function Exe(e,t){if(e==="")return!0;if(!t.startsWith(e))return!1;if(t.length===e.length)return!0;let n=t[e.length];return n==="."||n==="["}function zi(e,t){if(!Object.isExtensible(e))return;let n=e[KD];if(n){if(n.sourceFile??=t.sourceFile,n.composite??=t.composite,n.compositeInstance??=t.compositeInstance,n.compositeCall??=t.compositeCall,t.paths){n.paths??={};for(let[i,r]of Object.entries(t.paths))n.paths[i]??=r}return}Object.defineProperty(e,KD,{value:{...t,...t.paths?{paths:{...t.paths}}:{}},enumerable:!1,writable:!0,configurable:!0})}function Eo(e){return e[KD]}function Ps(e,t,n){zi(e,{paths:{[t]:n}})}function JD(e,t){if(!e)return;let n;for(let i of Object.keys(e))Exe(i,t)&&(n===void 0||i.length>n.length)&&(n=i);return n===void 0?void 0:e[n]}function qZ(e){return e[Axe]}var KD,Axe,ui=v(()=>{"use strict";KD=Symbol.for("chant.provenance");Axe=Symbol.for("chant.interpolationFields")});function Ui(e){return typeof e=="object"&&e!==null&&ZD in e&&e[ZD]===!0}function JZ(e,t){let n=Symbol(),i=t??"anonymous",r=(o=>{let s=e(o);for(let[l,c]of Object.entries(s))if(!qt(c)&&!Ui(c))throw new Error(`Composite "${i}" member "${l}" is not a Declarable or CompositeInstance`);ZZ(s,i);let a={};return Object.defineProperty(a,ZD,{value:!0,enumerable:!1}),Object.defineProperty(a,"members",{value:s,enumerable:!1}),Object.defineProperty(a,"_definition",{value:r,enumerable:!1}),Object.assign(a,s)});return Object.defineProperty(r,"compositeName",{value:i,writable:!1}),Object.defineProperty(r,"_id",{value:n,writable:!1}),YD.register(r),r}function ZZ(e,t){for(let n of Object.values(e))Ui(n)?ZZ(n.members,t):qt(n)&&Object.isExtensible(n)&&!Object.prototype.hasOwnProperty.call(n,XD)&&Object.defineProperty(n,XD,{value:t,enumerable:!1,configurable:!0})}function YZ(e){let t=e[XD];return typeof t=="string"?t:void 0}function tx(e,t,n=e){let i=new Map,r=t[Pxe],o=t._definition?.compositeName;for(let[s,a]of Object.entries(t.members)){let l=`${e}${s[0].toUpperCase()}${s.slice(1)}`;if(Ui(a)){let c=tx(l,a,n);for(let[u,d]of c)o&&zi(d,{composite:o}),i.set(u,d)}else o&&zi(a,{composite:o}),i.set(l,a)}if(o)for(let s of i.values())Ps(s,"",{kind:"composite",composite:o,instance:n});if(r){for(let s of i.values())if("props"in s){let l=s[KZ];l===void 0&&(l=s.props,Object.defineProperty(s,KZ,{value:l,enumerable:!1,configurable:!0}));let c={};for(let[u,d]of Object.entries(r))d!==void 0&&(c[u]=d);for(let[u,d]of Object.entries(l))d!==void 0&&(Array.isArray(d)&&Array.isArray(c[u])?c[u]=[...c[u],...d]:c[u]=d);if(Object.defineProperty(s,"props",{value:c,enumerable:!1,configurable:!0}),o)for(let u of Object.keys(r))r[u]===void 0||l[u]!==void 0||Ps(s,u,{kind:"composite",composite:o,instance:n})}}return i}var ZD,YD,XD,Pxe,KZ,nx=v(()=>{"use strict";Pn();ui();ZD=Symbol.for("chant.composite");YD=class{static{this.definitions=new Map}static register(t){this.definitions.set(t._id,t)}static getAll(){return Array.from(this.definitions.values())}static clear(){this.definitions.clear()}static get size(){return this.definitions.size}};XD=Symbol.for("chant.composite.memberOf");Pxe=Symbol.for("chant.composite.shared"),KZ=Symbol.for("chant.composite.origProps")});function QZ(e){return typeof e=="object"&&e!==null&&XZ in e&&e[XZ]===!0}var XZ,QD=v(()=>{"use strict";Pn();XZ=Symbol.for("chant.secret-declaration")});var Oxe,eN,e5,tN=v(()=>{"use strict";Oxe=new WeakMap,eN="[secret material]",e5=class e{constructor(){}static mint(t){let n=new e;return Oxe.set(n,t),n}toString(){return eN}toJSON(){return eN}[Symbol.for("nodejs.util.inspect.custom")](){return eN}}});function nN(e){return Object.fromEntries(e.map(t=>[t.name,t.value]))}var Vg=v(()=>{"use strict"});var t5=v(()=>{"use strict"});var yl={};_e(yl,{BuildError:()=>Os,DiscoveryError:()=>Hn,LintError:()=>rN});var Hn,Os,rN,or=v(()=>{"use strict";Hn=class extends Error{constructor(t,n,i){super(n),this.name="DiscoveryError",this.file=t,this.type=i}toJSON(){return{name:this.name,file:this.file,message:this.message,type:this.type}}},Os=class extends Error{constructor(t,n){super(n),this.name="BuildError",this.entityName=t}toJSON(){return{name:this.name,entityName:this.entityName,message:this.message}}},rN=class extends Error{constructor(t,n,i,r,o){super(o),this.name="LintError",this.file=t,this.line=n,this.column=i,this.ruleId=r}toJSON(){return{name:this.name,file:this.file,line:this.line,column:this.column,ruleId:this.ruleId,message:this.message}}}});var n5=v(()=>{"use strict"});var r5=v(()=>{"use strict"});function Cxe(...e){let t=e.join("_").split(/[^A-Za-z0-9]+/).filter(n=>n.length>0);return t.length===0?"Output":t.map((n,i)=>i===0?n:n.charAt(0).toUpperCase()+n.slice(1)).join("")}function Wr(e){return typeof e=="object"&&e!==null&&rx in e&&e[rx]===!0}var rx,i5,iN,ep,bl=v(()=>{"use strict";Xo();Wt();rx=Symbol.for("chant.lexiconOutput");i5=Pi;iN=class iN{constructor(t,n){this[i5]=!0;if(Object.defineProperty(this,rx,{value:!0,enumerable:!1}),dn(t)){let i=t.parent.deref();if(!i)throw new Error("Cannot create LexiconOutput: parent entity has been garbage collected");if(!("lexicon"in i)||typeof i.lexicon!="string")throw new Error("Cannot create LexiconOutput: parent entity has no lexicon field");this.sourceLexicon=i.lexicon,this.sourceEntity="",this.sourceAttribute=t.attribute,this.outputName=n,this._sourceParent=t.parent,this._intrinsic=null,this._literalValue=null}else if(Au(t))this.sourceLexicon="",this.sourceEntity="",this.sourceAttribute=null,this.outputName=n,this._sourceParent=null,this._intrinsic=t,this._literalValue=null;else if(typeof t=="string"||typeof t=="number"||typeof t=="boolean")this.sourceLexicon="",this.sourceEntity="",this.sourceAttribute=null,this.outputName=n,this._sourceParent=null,this._intrinsic=null,this._literalValue=t;else throw new Error(`output(ref, "${n}"): ref must be an AttrRef, an Intrinsic, or an already-resolved string/number/boolean \u2014 got ${t===null?"null":typeof t} instead. If this came from a resource member access (e.g. "resource.SomeField"), that member is neither a generated attribute nor a real value here \u2014 check for a typo or a property that CloudFormation does not expose via Fn::GetAtt.`)}_setSourceEntity(t){this.sourceEntity=t}getOutputValue(){return this._literalValue!==null?this._literalValue:this._intrinsic?this._intrinsic.toJSON():{"Fn::GetAtt":[this.sourceEntity,this.sourceAttribute]}}static auto(t,n){let i=Cxe(n,t.attribute),r=new iN(t,i);return r._setSourceEntity(n),r}toJSON(){return{"chant::output":this.outputName}}},ep=iN});async function ix(e){let t=o5.get(e);if(t)throw t;try{return Mn(),await import(e)}catch(n){let i=n instanceof Error?n.message:"Unknown import error",r=new Hn(e,i,"import");throw o5.set(e,r),r}}var o5,ox=v(()=>{"use strict";or();Si();o5=new Map});function _xe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function sN(e,t){return Object.isExtensible(e)&&!Object.prototype.hasOwnProperty.call(e,oN)&&Object.defineProperty(e,oN,{value:t,enumerable:!1,configurable:!0}),s5(e,t),e}function s5(e,t){for(let n of Object.values(e))qt(n)?zi(n,{composite:t}):wl(n)!==void 0&&s5(n,t)}function wl(e){if(!_xe(e))return;let t=e[oN];return typeof t=="string"?t:void 0}function aN(e,t,n=e){let i=[],r=wl(t);for(let[o,s]of Object.entries(t)){if(o.length===0)continue;let a=`${e}${o[0].toUpperCase()}${o.slice(1)}`;if(wl(s)!==void 0){i.push(...aN(a,s,n));continue}if(!qt(s))continue;zi(s,{composite:r,compositeInstance:n});let l=Eo(s)?.composite??r;Ps(s,"",{kind:"composite",composite:l,instance:n}),i.push([a,s])}return i}var oN,cN=v(()=>{"use strict";Pn();ui();oN=Symbol.for("chant.fold.hostCompositeInstance")});import{basename as Ixe,dirname as lN,relative as Txe,resolve as a5}from"node:path";function Dxe(e,t){return e!=="default"?e:Ixe(t).replace(/\.ts$/,"").replace(/\.op$/,"")}function Nxe(e,t){let n=lN(e);return(t?Txe(a5(t),a5(n)):n).split(/[^A-Za-z0-9]+/).filter(o=>o.length>0).map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join("")}function c5(e,t){let n=YZ(e);return{sourceFile:t,...n?{composite:n}:{},paths:jxe}}function Lxe(e){let t=[];for(let{file:n,exports:i}of e){let r=Object.entries(i).sort(([o],[s])=>o.localeCompare(s));for(let[o,s]of r){let a=Dxe(o,n);if(qt(s))t.push({bareKey:a,value:s,file:n,provenance:c5(s,n)});else if(Array.isArray(s))for(let l=0;l<s.length;l++){let c=s[l];if(qt(c))t.push({bareKey:`${a}_${l}`,value:c,file:n,provenance:c5(c,n)});else if(Ui(c)){let u=`${a}_${l}`;for(let[d,p]of tx(u,c))t.push({bareKey:d,value:p,file:n,provenance:{sourceFile:n,compositeInstance:u}})}}else if(Ui(s))for(let[l,c]of tx(a,s))t.push({bareKey:l,value:c,file:n,provenance:{sourceFile:n,compositeInstance:a}});else if(wl(s)!==void 0)for(let[l,c]of aN(a,s))t.push({bareKey:l,value:c,file:n,provenance:{sourceFile:n,compositeInstance:a}});else Wr(s)&&t.push({bareKey:a,value:s,file:n,provenance:{sourceFile:n}})}}return t}function uN(e,t){let n=Lxe(e),i=new Map;for(let{bareKey:a,value:l,file:c}of n){let u=lN(c),d=i.get(a);d||(d=new Map,i.set(a,d));let p=d.get(u);p||(p=new Set,d.set(u,p)),p.add(l)}let r=new Set;for(let[a,l]of i){let c=[...l.values()].filter(d=>d.size>0).length,u=new Set;for(let d of l.values())for(let p of d)u.add(p);c>1&&u.size>1&&r.add(a)}let o=new Map,s=new Map;for(let{bareKey:a,value:l,file:c,provenance:u}of n){let d=lN(c),p=s.get(a);p||(p=new Map,s.set(a,p));let f=p.get(d);if(f!==void 0&&f!==l)throw new Hn(c,`Duplicate export name "${a}" found`,"resolution");p.set(d,l);let g=r.has(a)?`${Nxe(c,t)}${a}`:a,h=o.get(g);if(h!==void 0){if(h!==l)throw new Hn(c,`Duplicate export name "${a}" found`,"resolution");continue}zi(l,u),o.set(g,l)}return o}var jxe,sx=v(()=>{"use strict";Pn();nx();bl();or();ui();cN();jxe={"":{kind:"authored"}}});function Mxe(e){if(e instanceof Map)return e;let t=new Map;for(let[n,i]of Object.entries(e))t.set(n,new Set(i));return t}function l5(e){let t=Mxe(e),n=0,i=1,r=2,o=new Map,s=new Map,a=[],l=new Set;for(let u of t.keys())o.set(u,n);function c(u){o.set(u,i);let d=t.get(u)??new Set;for(let p of d){let f=o.get(p);if(f===void 0||f===n){if(f===void 0)continue;s.set(p,u),c(p)}else if(f===i){let g=[p],h=u;for(;h!==p;)g.push(h),h=s.get(h);g.push(p),g.reverse();let b=Fxe(g);l.has(b)||(l.add(b),a.push(g.slice(0,-1)))}}o.set(u,r)}for(let u of t.keys())o.get(u)===n&&c(u);return a}function Fxe(e){let t=e.slice(0,-1),n=0;for(let r=1;r<t.length;r++)t[r]<t[n]&&(n=r);return[...t.slice(n),...t.slice(0,n)].join(",")}var dN=v(()=>{"use strict"});function u5(e){let t=l5(e);if(t.length>0){let s=t[0].join(" -> ");throw new Os(t[0][0],`Circular dependency detected: ${s}`)}let n=[],i=new Set,r=new Set;function o(s){if(i.has(s))return;r.add(s);let a=e[s]||[];for(let l of a)i.has(l)||o(l);r.delete(s),i.add(s),n.push(s)}for(let s of Object.keys(e))i.has(s)||o(s);return n}var pN=v(()=>{"use strict";or();dN()});function d5(e){for(let[t,n]of e.entries())n[XO]=t;for(let[t,n]of e.entries()){let i=Yz(n);for(let r of i){let o=n[r];if(dn(o)){let s=o.parent.deref();if(!s)throw new Error(`Cannot resolve AttrRef on "${t}.${r}": parent has been garbage collected`);let a;for(let[l,c]of e.entries())if(c===s){a=l;break}if(!a)throw new Error(`Cannot resolve AttrRef on "${t}.${r}": parent entity not found in entities collection`);o._setLogicalName(a)}}}}var fN=v(()=>{"use strict";Wt()});function ax(e){let t=new Map;for(let i of e.keys())t.set(i,new Set);let n=new Map;for(let[i,r]of e.entries())n.set(r,i);for(let[i,r]of e.entries()){let o=t.get(i);mN(r,e,n,o,new Set,r)}return t}function mN(e,t,n,i,r,o){if(!qt(e)&&!r.has(e)&&r.add(e),Array.isArray(e)){for(let s of e)p5(s,t,n,i,r,o);return}for(let s in e)if(Object.prototype.hasOwnProperty.call(e,s)){let a=e[s];p5(a,t,n,i,r,o)}}function p5(e,t,n,i,r,o){if(e!=null&&typeof e=="object"){if(dn(e)){if(r.has(e))return;r.add(e);let s=e.parent.deref();if(s&&qt(s)&&s!==o){let a=n.get(s);a&&i.add(a)}return}if(qt(e)){if(e===o){if(r.has(e)){let a=n.get(e);a&&i.add(a);return}r.add(e),mN(e,t,n,i,r,o);return}let s=n.get(e);s&&i.add(s);return}r.has(e)||mN(e,t,n,i,r,o)}}var cx=v(()=>{"use strict";Pn();Wt()});import{readFileSync as Bxe,statSync as gN}from"node:fs";import{dirname as np,extname as Gxe,isAbsolute as Wxe,join as tp,resolve as hN}from"node:path";function Ao(e){try{return gN(e,{throwIfNoEntry:!1})?.isFile()??!1}catch{return!1}}function zxe(e){try{return gN(e,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{return!1}}function yN(e){let t=Gxe(e),n=Uxe[t];if(n){let r=e.slice(0,-t.length);for(let o of n)if(Ao(r+o))return r+o}return[e,`${e}.ts`,`${e}.tsx`,`${e}.js`,`${e}.mjs`,tp(e,"index.ts"),tp(e,"index.js")].find(Ao)}function y5(e){let t=e.split("/"),n=e.startsWith("@")?2:1;if(t.length<n||t.slice(0,n).some(o=>o===""))return;let i=t.slice(0,n).join("/"),r=t.slice(n).join("/");return{name:i,subpath:r===""?".":`./${r}`}}function qg(e,t){if(typeof e=="string")return t===void 0?e:e.split("*").join(t);if(Array.isArray(e)){for(let n of e){let i=qg(n,t);if(i!==void 0)return i}return}if(!(typeof e!="object"||e===null))for(let[n,i]of Object.entries(e)){if(!Hxe.has(n))continue;let r=qg(i,t);if(r!==void 0)return r}}function b5(e,t){if(!(typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.keys(e).some(s=>s.startsWith("."))))return t==="."?qg(e,void 0):void 0;let i=e;if(Object.prototype.hasOwnProperty.call(i,t)&&!t.includes("*"))return qg(i[t],void 0);let r,o;for(let s of Object.keys(i)){let a=s.indexOf("*");if(a===-1||s.indexOf("*",a+1)!==-1)continue;let l=s.slice(0,a),c=s.slice(a+1);!t.startsWith(l)||t===l||c!==""&&(!t.endsWith(c)||t.length<s.length)||(r===void 0||l.length>r.indexOf("*")||l.length===r.indexOf("*")&&s.length>r.length)&&(r=s,o=t.slice(l.length,t.length-c.length))}return r===void 0?void 0:qg(i[r],o)}function w5(e){let t=f5.get(e);if(t!==void 0)return t;let n=tp(e,"tsconfig.json"),i;if(Ao(n))i=n;else{let r=np(e);i=r===e?null:w5(r)}return f5.set(e,i),i}function g5(e){try{return gN(e,{throwIfNoEntry:!1})?.mtimeMs??-1}catch{return-1}}function Vxe(e,t){let n=np(t);if(e.startsWith(".")||Wxe(e)){let i=hN(n,e);return Ao(i)?i:!i.endsWith(".json")&&Ao(`${i}.json`)?`${i}.json`:void 0}for(let i=n;;){let r=tp(i,"node_modules",e);if(Ao(r))return r;if(!r.endsWith(".json")&&Ao(`${r}.json`))return`${r}.json`;if(zxe(r)&&Ao(tp(r,"tsconfig.json")))return tp(r,"tsconfig.json");let o=np(i);if(o===i)return;i=o}}function v5(e,t,n){if(n.has(e))return{};n.add(e),t.push(e);let i;try{i=Bxe(e,"utf-8")}catch{return{}}let{config:r}=h5.parseConfigFileTextToJson(e,i);if(typeof r!="object"||r===null)return{};let o=r,s={},a=typeof o.extends=="string"?[o.extends]:Array.isArray(o.extends)?o.extends:[];for(let c of a){if(typeof c!="string")continue;let u=Vxe(c,e);if(u===void 0)continue;let d=v5(u,t,n);d.paths&&(s.paths=d.paths),d.baseUrl!==void 0&&(s.baseUrl=d.baseUrl)}let l=o.compilerOptions;return l&&typeof l.paths=="object"&&l.paths!==null&&!Array.isArray(l.paths)&&(s.paths={value:l.paths,declaredIn:np(e)}),l&&typeof l.baseUrl=="string"&&(s.baseUrl=hN(np(e),l.baseUrl)),s}function qxe(e){if(!e.paths)return;let t=[];for(let[n,i]of Object.entries(e.paths.value)){if(!Array.isArray(i))continue;let r=i.filter(s=>typeof s=="string"),o=n.indexOf("*");o!==-1&&n.indexOf("*",o+1)!==-1||t.push(o===-1?{key:n,prefix:n,suffix:void 0,substitutions:r}:{key:n,prefix:n.slice(0,o),suffix:n.slice(o+1),substitutions:r})}return{base:e.baseUrl??e.paths.declaredIn,patterns:t}}function Kxe(e){let t=m5.get(e);if(t&&t.stamps.every(([r,o])=>g5(r)===o))return t.paths;let n=[],i=qxe(v5(e,n,new Set));return m5.set(e,{stamps:n.map(r=>[r,g5(r)]),paths:i}),i}function k5(e,t){let n=w5(np(t));if(n===null)return;let i=Kxe(n);if(!i)return;let r;for(let s of i.patterns){if(s.suffix===void 0){if(s.key===e){r=s;break}continue}e.length>=s.prefix.length+s.suffix.length&&e.startsWith(s.prefix)&&e.endsWith(s.suffix)&&(r===void 0||s.prefix.length>r.prefix.length)&&(r=s)}if(!r)return;let o=r.suffix===void 0?"":e.slice(r.prefix.length,e.length-r.suffix.length);for(let s of r.substitutions){let a=yN(hN(i.base,s.split("*").join(o)));if(a!==void 0)return{key:r.key,target:a}}return{key:r.key,target:void 0}}var h5,Uxe,Hxe,f5,m5,x5=v(()=>{"use strict";h5=Le(Ke(),1);Uxe={".js":[".ts",".tsx"],".jsx":[".tsx"],".mjs":[".mts"],".cjs":[".cts"]};Hxe=new Set(["import","node","default"]);f5=new Map,m5=new Map});function bN(e){if(e&&(ke.isIdentifier(e)||ke.isStringLiteral(e)||ke.isNumericLiteral(e)))return e.text}function vl(e){let t=e;for(;;){if(ke.isParenthesizedExpression(t)||ke.isAsExpression(t)||ke.isNonNullExpression(t)){t=t.expression;continue}return t}}function Jxe(e,t,n,i){let r=new Set,o=s=>{if(ke.isPropertyAccessExpression(s)){if(ke.isIdentifier(s.expression)&&n.has(s.expression.text)){i.add(s.name.text);return}o(s.expression);return}if(ke.isElementAccessExpression(s)){ke.isIdentifier(s.expression)&&n.has(s.expression.text)?ke.isStringLiteralLike(s.argumentExpression)&&i.add(s.argumentExpression.text):o(s.expression),o(s.argumentExpression);return}if(ke.isIdentifier(s)){if(n.has(s.text))return;let a=t.get(s.text);a&&!r.has(s.text)&&(r.add(s.text),o(a));return}if(ke.isPropertyAssignment(s)){o(s.initializer);return}ke.forEachChild(s,o)};o(e)}function Zxe(e,t,n,i){let r=new Set,o,s=a=>{if(!o){if(ke.isCallExpression(a)){let l=vl(a.expression);if(ke.isPropertyAccessExpression(l)||ke.isElementAccessExpression(l)){o="host-call";return}if(ke.isIdentifier(l)&&!t.has(l.text)&&i.eagerCalls.has(l.text)){o="host-call";return}for(let c of a.arguments)s(c);return}if(ke.isPropertyAccessExpression(a)){s(a.expression);return}if(ke.isIdentifier(a)){if(n.has(a.text))return;let l=t.get(a.text);if(l){if(ke.isNewExpression(vl(l))||r.has(a.text))return;r.add(a.text),s(l);return}i.values.has(a.text)&&(o="host-value");return}if(ke.isPropertyAssignment(a)){s(a.initializer);return}if(ke.isTaggedTemplateExpression(a)){s(a.template);return}ke.forEachChild(a,s)}};return s(e),o}function R5(e,t,n,i){let r={};if(n.size===0&&!i)return r;let o=(a,l)=>{if(r[a]?.kind==="host")return;let c=i?Zxe(l,t,n,i):void 0;if(c){r[a]={kind:"host",reason:c};return}let u=new Set;if(Jxe(l,t,n,u),u.size===0)return;let d=r[a],p=d&&d.kind==="build-param"?new Set([...d.params,...u]):u;r[a]={kind:"build-param",params:[...p].sort()}},s=(a,l)=>{for(let c of a.properties){if(ke.isSpreadAssignment(c)){o(l,c.expression);continue}if(ke.isShorthandPropertyAssignment(c)){let f=c.name.text;o(l?`${l}.${f}`:f,c.name);continue}if(!ke.isPropertyAssignment(c))continue;let u=bN(c.name);if(u===void 0)continue;let d=l?`${l}.${u}`:u,p=vl(c.initializer);if(ke.isObjectLiteralExpression(p)){s(p,d);continue}o(d,c.initializer)}};return s(e,""),r}function $5(e,t){let n=[],i=e;for(;;){if(ke.isPropertyAccessExpression(i)){n.unshift(i.name.text),i=i.expression;continue}if(ke.isElementAccessExpression(i)&&ke.isStringLiteralLike(i.argumentExpression)){n.unshift(i.argumentExpression.text),i=i.expression;continue}break}if(!ke.isIdentifier(i))return;if(t.whole.has(i.text))return n.length===0?void 0:n.join(".");let r=t.destructured.get(i.text);if(r!==void 0)return n.length===0?r:`${r}.${n.join(".")}`}function Yxe(e){let t=vl(e);return ke.isNewExpression(t)||ke.isCallExpression(t)}function S5(e,t,n,i){let r=new Set,o=s=>{if(ke.isPropertyAccessExpression(s)||ke.isElementAccessExpression(s)){let a=$5(s,n);if(a!==void 0){i.add(a);return}o(s.expression),ke.isElementAccessExpression(s)&&o(s.argumentExpression);return}if(ke.isIdentifier(s)){let a=$5(s,n);if(a!==void 0){i.add(a);return}if(n.whole.has(s.text))return;let l=t.get(s.text);l&&!r.has(s.text)&&!Yxe(l)&&(r.add(s.text),o(l));return}if(ke.isPropertyAssignment(s)){o(s.initializer);return}ke.forEachChild(s,o)};o(e)}function lx(e,t){let n=t.getSourceFile(),{line:i,character:r}=n.getLineAndCharacterOfPosition(t.getStart(n));return{file:e,line:i+1,column:r+1}}function Xxe(e,t){let n={parameter:t,...lx(e.file,e.node)},i=e.node.arguments[0];if(!i)return n;let r=vl(i),o;for(let s of t.split(".")){if(!ke.isObjectLiteralExpression(r))return n;o=void 0;for(let a of r.properties)(ke.isShorthandPropertyAssignment(a)&&a.name.text===s||ke.isPropertyAssignment(a)&&bN(a.name)===s)&&(o=a);if(!o)return n;r=ke.isPropertyAssignment(o)?vl(o.initializer):o.name}return o?{parameter:t,...lx(e.file,o),text:o.getText()}:n}function Qxe(e,t){return e?t.map(n=>Xxe(e,n)):void 0}function E5(e,t,n,i,r){let o={},s=c=>{let u=new Set;return S5(c,t,n,u),[...u].sort()},a=(c,u,d)=>{let p=s(u);if(p.length>0){let f=o[c],g=f&&f.kind==="composite-parameter"?[...new Set([...f.parameters,...p])].sort():p;o[c]=P5(i,g,r);return}d||(o[c]??={kind:"composite-literal",composite:i})},l=(c,u)=>{for(let d of c.properties){if(ke.isSpreadAssignment(d)){a(u,d.expression,!0);continue}if(ke.isShorthandPropertyAssignment(d)){let h=d.name.text;a(u?`${u}.${h}`:h,d.name,!1);continue}if(!ke.isPropertyAssignment(d))continue;let p=bN(d.name);if(p===void 0)continue;let f=u?`${u}.${p}`:p,g=vl(d.initializer);if(ke.isObjectLiteralExpression(g)){l(g,f);continue}a(f,d.initializer,!1)}};return l(e,""),o}function A5(e,t,n,i,r,o,s){let a={};if(e.forEach((l,c)=>{let u=new Set;if(S5(l,i,r,u),u.size!==0)for(let d of t[c]??[]){let p=a[d],f=new Set(p?.kind==="composite-parameter"?p.parameters:[]);for(let g of u)f.add(g);a[d]=P5(o,[...f].sort(),s)}}),n!==null&&typeof n=="object"&&!Array.isArray(n))for(let[l,c]of Object.entries(n))c!==void 0&&(a[l]??={kind:"composite-literal",composite:o});return a}function P5(e,t,n){let i=Qxe(n,t);return{kind:"composite-parameter",composite:e,parameters:t,...i?{arguments:i}:{}}}var ke,O5=v(()=>{"use strict";ke=Le(Ke(),1)});function e$e(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function t$e(e){let t=[],n=(i,r)=>{if(i!==void 0){if(e$e(i)){let o=Object.keys(i).sort();if(o.length===0){r&&t.push(r);return}for(let s of o)n(i[s],r?`${r}.${s}`:s);return}r&&t.push(r)}};return n(e,""),t}function n$e(e,t){if(!t)return{kind:"unknown",reason:"no-provenance"};let n=t.compositeInstance,i=t.compositeCall;switch(e?.kind){case"composite-parameter":return{kind:"composite-parameter",composite:e.composite,...n?{instance:n}:{},parameters:[...e.parameters],...i?{call:{...i}}:{},...e.arguments?{arguments:e.arguments.map(r=>({...r}))}:{}};case"composite-literal":return{kind:"composite-literal",composite:e.composite,...n?{instance:n}:{},...i?{call:{...i}}:{}};case"composite":return{kind:"unknown",reason:"composite-not-interpreted"};case"authored":return t.composite?{kind:"unknown",reason:"composite-not-interpreted"}:{kind:"direct"};case"host":return{kind:"unknown",reason:e.reason};case"build-param":return{kind:"direct"};case void 0:return t.composite?{kind:"unknown",reason:"composite-not-interpreted"}:{kind:"direct"}}}function r$e(e,t){if(!wm(e))return;let n=t$e(e.props);if(n.length===0)return;let i={};for(let r of n)i[r]=n$e(JD(t?.paths,r),t);return{...t?.sourceFile?{sourceFile:t.sourceFile}:{},...t?.composite?{composite:t.composite}:{},...t?.compositeInstance?{instance:t.compositeInstance}:{},...t?.compositeCall?{compositeCall:{...t.compositeCall}}:{},fields:i}}function wN(e,t){let n={};for(let i of[...e.keys()].sort()){let r=e.get(i),o=r$e(r,t(r));o&&(n[i]=o)}return n}var ux=v(()=>{"use strict";Pn();ui()});import{readFile as yx}from"node:fs/promises";import{existsSync as EN,readFileSync as j5,realpathSync as i$e}from"node:fs";import{dirname as Oo,basename as fx,join as ip,sep as xN,isAbsolute as Qg,resolve as Kg}from"node:path";import{fileURLToPath as L5}from"node:url";import{createRequire as o$e}from"node:module";function s$e(e){return`@intentius/chant-lexicon-${e}`}function AN(e=[],t,n=[],i=!1,r=[],o=!1,s=[]){let a=new Set(r),l=new Set,c=[];for(let u of n){let d=Ei(u);d===void 0?a.add(s$e(u)):l.add(Yg(d,d));let p=EO(u);p!==void 0&&!s.some(f=>th(Kg(f),p))&&c.push(p)}return{intrinsics:e,cache:new Map,stack:[],importCache:new Map,resolvePathCache:new Map,buildParams:t,lexiconPackages:a,lexiconModules:l,lexiconRoots:c,sandbox:i,executing:o,factoryModules:new Map}}function sr(e,t,n){let i=!e.startsWith(".")&&!Qg(e),r=`${Oo(t)}\0${e}`;if(i){let a=n.get(r);if(a!==void 0)return a;let l=eh(e,t);if(l!==void 0)return n.set(r,l),l;let c=C5.get(e);if(c!==void 0)return c;let u=Yg(e,t);return C5.set(e,u),u}let o=n.get(r);if(o!==void 0)return o;let s=Yg(e,t);return n.set(r,s),s}function Qe(e){let t=Error.stackTraceLimit;Error.stackTraceLimit=0;try{return new Error(e)}finally{Error.stackTraceLimit=t}}function op(e,t){let n=t.get(e);if(n)return n;let i=ix(e);return t.set(e,i),i}function Jg(e){return e.modifiers?.some(t=>t.kind===D.SyntaxKind.ExportKeyword)??!1}function Wa(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function xl(e){if(!(e.dotDotDotToken||e.initializer||!D.isIdentifier(e.name)))return e.propertyName?D.isIdentifier(e.propertyName)?e.propertyName.text:void 0:e.name.text}function a$e(e){let t=[];for(let n of e.statements){if(D.isExportAssignment(n))return{declarators:t,unfoldableReason:"`export default` is not foldable"};if(D.isExportDeclaration(n)){if(n.isTypeOnly)continue;if(n.moduleSpecifier){if(!D.isStringLiteral(n.moduleSpecifier))return{declarators:t,unfoldableReason:"re-export declaration is not foldable"};if(!n.exportClause||!D.isNamedExports(n.exportClause))return{declarators:t,unfoldableReason:"re-export declaration is not foldable"};let r=[];for(let o of n.exportClause.elements){if(o.isTypeOnly)continue;let s=o.propertyName??o.name;if(!D.isIdentifier(s))return{declarators:t,unfoldableReason:"re-export declaration is not foldable"};r.push({imported:s.text,exportedName:o.name.text})}t.push({kind:"re-export",specifier:n.moduleSpecifier.text,specifierNode:n.moduleSpecifier,elements:r});continue}if(!n.exportClause||!D.isNamedExports(n.exportClause))return{declarators:t,unfoldableReason:"export declaration is not foldable"};let i=[];for(let r of n.exportClause.elements){if(r.isTypeOnly)continue;let o=r.propertyName??r.name;if(!D.isIdentifier(o))return{declarators:t,unfoldableReason:"export declaration is not foldable"};i.push({localNameNode:o,exportedName:r.name.text})}t.push({kind:"named-export",elements:i});continue}if(D.isFunctionDeclaration(n)&&Jg(n)){if(n.modifiers?.some(i=>i.kind===D.SyntaxKind.DefaultKeyword)||!n.name)return{declarators:t,unfoldableReason:"`export default` is not foldable"};if(!n.body)continue;t.push({kind:"function",name:n.name.text});continue}if(D.isClassDeclaration(n)&&Jg(n))return{declarators:t,unfoldableReason:`exported class declaration "${n.name?.text??"<anonymous>"}" is not foldable`};if(!(!D.isVariableStatement(n)||!Jg(n))){if((n.declarationList.flags&D.NodeFlags.Const)===0)return{declarators:t,unfoldableReason:"exported `let`/`var` declaration is not foldable"};for(let i of n.declarationList.declarations){if(!i.initializer)return{declarators:t,unfoldableReason:"exported destructured or uninitialized declaration is not foldable"};if(D.isIdentifier(i.name)){D.isNewExpression(i.initializer)?t.push({kind:"resource",name:i.name.text,node:i.initializer}):t.push({kind:"single",name:i.name.text,node:i.initializer});continue}if(D.isObjectBindingPattern(i.name)){let r=[],o=!0;for(let s of i.name.elements){let a=xl(s);if(a===void 0){o=!1;break}r.push({propKey:a,bindingName:s.name.getText()})}if(!o)return{declarators:t,unfoldableReason:"exported destructured or uninitialized declaration is not foldable"};t.push({kind:"destructure",node:i.initializer,elements:r});continue}return{declarators:t,unfoldableReason:"exported destructured or uninitialized declaration is not foldable"}}}}return{declarators:t}}function c$e(e){let t=new Map;for(let n of e.statements)if(D.isVariableStatement(n)&&(n.declarationList.flags&D.NodeFlags.Const)!==0){for(let i of n.declarationList.declarations)if(i.initializer){if(D.isIdentifier(i.name))t.set(i.name.text,{source:i.initializer});else if(D.isObjectBindingPattern(i.name))for(let r of i.name.elements){let o=xl(r);o!==void 0&&t.set(r.name.getText(),{source:i.initializer,propKey:o})}}}return t}function l$e(e,t){return UD(e,t.consts,t.file,t.externals,t.crossFileFailures)}function PN(e){let t=new Map,n=new Map;for(let i of e.statements){if(!D.isImportDeclaration(i)||!D.isStringLiteral(i.moduleSpecifier))continue;let r=i.importClause;if(!r||r.isTypeOnly)continue;let o=i.moduleSpecifier.text,s=i.moduleSpecifier;if(r.name&&t.set(r.name.text,{specifier:o,imported:"default",specifierNode:s}),r.namedBindings)if(D.isNamedImports(r.namedBindings))for(let a of r.namedBindings.elements){if(a.isTypeOnly)continue;let l=a.propertyName?.text??a.name.text;t.set(a.name.text,{specifier:o,imported:l,specifierNode:s})}else D.isNamespaceImport(r.namedBindings)&&n.set(r.namedBindings.name.text,{specifier:o,specifierNode:s})}return{named:t,namespaces:n}}function u$e(e,t){let n=y5(e);if(n===void 0)return;let i=Oo(t);for(;;){let r=ip(i,"node_modules",n.name);if(EN(r)){let s=M5(r,n.subpath);if(s===void 0||!Ao(s))return;try{return i$e(s)}catch{return}}let o=Oo(i);if(o===i)return;i=o}}function M5(e,t){let n=ip(e,"package.json");if(!EN(n))return;let i;try{i=JSON.parse(j5(n,"utf-8"))}catch{return}if(typeof i!="object"||i===null)return;let r=i.exports;if(r!==void 0){let s=b5(r,t);return s===void 0?void 0:Kg(e,s)}if(t!==".")return M5(ip(e,t),".");let o=i.main;return o!==void 0?typeof o=="string"?Kg(e,o):void 0:Kg(e,"index.js")}function eh(e,t){return F5(e,t)?.target}function F5(e,t){if(!(e.startsWith(".")||Qg(e)||Gk(e)))return k5(e,t)}function Yg(e,t){if(e.startsWith(".")||Qg(e)){let r=e.startsWith(".")?Kg(Oo(t),e):e;return yN(r)??r}let n=eh(e,t);if(n!==void 0)return n;let i=u$e(e,t);return i!==void 0?i:o$e(t).resolve(e)}function p$e(){if(dx===void 0)try{dx=Yg("../params",L5(import.meta.url))}catch{dx=null}return dx}function Xg(e,t){return t.has(e)?e:void 0}function B5(e,t,n){if(Xg(e,n)!==void 0)return eh(e,t)===void 0?e:void 0}function G5(e,t,n,i){if(n.size===0||!Cs(e,t))return;let r;try{r=sr(e,t,i)}catch{return}return n.has(r)?r:void 0}function th(e,t){return e.startsWith(t.endsWith(xN)?t:t+xN)}function px(e,t){return t.some(n=>th(e,n))}function W5(e){if(e.startsWith(".")||Qg(e))return;let t=e.split("/");return e.startsWith("@")?t.length>2?`${t[0]}/${t[1]}`:void 0:t.length>1?t[0]:void 0}async function _5(e,t,n){let i;if(B5(e.specifier,t,n.lexiconPackages))try{i=sr(e.specifier,t,n.resolvePathCache)}catch{return}else if(i=G5(e.specifier,t,n.lexiconModules,n.resolvePathCache),i===void 0)return;let r;try{r=await op(i,n.importCache)}catch{return}if(!(e.imported in r))return;let o=r[e.imported];if(!(typeof o=="function"&&!n.intrinsics.some(a=>a.name===e.imported&&ml(a))))return{value:o}}async function f$e(e,t,n){let i;try{i=await op(e,n.importCache)}catch{return}if(!(!(t in i)||typeof i[t]=="function"))return{value:i[t]}}function ON(e,t){let n=t.memo.get(e);if(n)return n;let i=mx(e,t);return t.memo.set(e,i),i}async function mx(e,t){if(D.isParenthesizedExpression(e)||D.isNonNullExpression(e)||D.isAsExpression(e)||D.isSatisfiesExpression(e))return mx(e.expression,t);if(D.isIdentifier(e)){let n=t.locals.get(e.text);if(!n){if(t.externals.has(e.text)){let r=t.externals.get(e.text);if(As(r))throw Qe(`function "${e.text}" used as a value is not foldable`);return{value:r}}return}let i=await ON(n.source,t);if(i===void 0)return;if(n.propKey===void 0)return i;if(!Wa(i.value))throw Qe(`destructured member "${n.propKey}" is not on a composite value`);return{value:i.value[n.propKey]}}if(D.isCallExpression(e))return{value:await m$e(e,t)};if(D.isPropertyAccessExpression(e)){let n=await mx(e.expression,t);if(n===void 0)return;let i=e.name.text;if(!Wa(n.value))throw Qe(`property access ".${i}" on a non-composite value is not foldable`);return{value:n.value[i]}}}async function m$e(e,t){if(!D.isIdentifier(e.expression))throw Qe(Xd(e));let n=e.expression.text,i=t.imports.get(n),r=t.externals.get(n);if(As(r)){let o;try{let s=Me(e,t.consts,t.intrinsics,t.externals);return await di(s,t,!1)}catch(s){if(!(s instanceof Error))throw s;o=s}if(t.executing&&i)try{return await I5(e,n,i,t)}catch(s){throw Qe(`${o.message}; invoking it instead failed: ${s instanceof Error?s.message:String(s)}`)}throw i&&!t.sandbox?Qe(`${o.message} (the default mode does not invoke a declared project function; \`executing\` would run it and fold what it returns)`):o}if(!i)throw Qe(Xd(e));return I5(e,n,i,t)}async function I5(e,t,n,i){let r=await q5(n,i);if(r){let o=await U5(e,t,i),s=await J5(r,o,i,{file:i.file,node:e});return s?s.value:T5(e,t,n,i,o)}return T5(e,t,n,i)}async function z5(e,t,n,i){let r=bx(t,n,e,"composite factory");if(r)throw Qe(r);if(!n.executing&&Cs(t.specifier,n.file)&&!X5(t,n))throw Qe(`"${e}" is imported from "${t.specifier}", which is a project file; the default mode does not invoke project-owned code (\`executing\` would run it and fold what it returns)`);let o;try{o=sr(t.specifier,n.file,n.resolvePathCache)}catch(d){throw Qe(`could not resolve import "${t.specifier}" for "${e}": ${d instanceof Error?d.message:String(d)}`)}let s;try{s=await op(o,n.importCache)}catch(d){throw Qe(`could not import "${t.specifier}" to resolve "${e}": ${d instanceof Error?d.message:String(d)}`)}let a=s[t.imported];if(typeof a!="function")throw Qe(`"${t.imported}" from "${t.specifier}" is not a function`);$N.factoryInvocations+=1;let l=n.packageRoot!==void 0&&th(o,n.packageRoot);Cs(t.specifier,n.file)&&!l&&($N.projectFactoryInvocations+=1);let c=a(...i),u=a.compositeName;return typeof u=="string"&&Wa(c)&&!Ui(c)&&sN(c,u),c}async function T5(e,t,n,i,r){let o=r??await U5(e,t,i);return z5(t,n,i,o)}async function g$e(e,t,n){let i=n.imports.get(e);if(!i)throw Qe(`unresolved identifier: ${e}`);let r=await q5(i,n);if(r){let o=await J5(r,t,n);if(o)return o.value}return z5(e,i,n,t)}async function U5(e,t,n){let i=gl(t),r=[];for(let o of e.arguments){let s=await mx(o,n);if(s!==void 0){r.push(s.value);continue}let a=await h$e(o,n);try{r.push(await di(Me(o,n.consts,n.intrinsics,n.externals),n,i))}finally{for(let l of a)n.externals.delete(l)}}return r}async function h$e(e,t){let n=new Set,i=o=>{if(D.isIdentifier(o)){y$e(o.text,t)&&n.add(o.text);return}if(!(D.isFunctionLike(o)||D.isTypeNode(o))){if(D.isPropertyAccessExpression(o))return i(o.expression);if(D.isPropertyAssignment(o))return D.isComputedPropertyName(o.name)&&i(o.name),i(o.initializer);D.forEachChild(o,i)}};i(e);let r=[];for(let o of n){let s;try{s=await ON(t.locals.get(o).source,t)}catch{continue}s&&(qt(s.value)||Ui(s.value)||wl(s.value)!==void 0)&&(t.externals.set(o,s.value),r.push(o))}return r}function y$e(e,t){if(t.externals.has(e))return!1;let n=t.locals.get(e);if(!n||n.propKey!==void 0||t.consts.get(e)!==n.source)return!1;let i=n.source;if(!D.isCallExpression(i)||!D.isIdentifier(i.expression))return!1;let r=i.expression.text;return t.imports.has(r)&&!gl(r)&&!t.intrinsics.some(o=>o.name===r)&&!As(t.externals.get(r))}function b$e(e,t,n){let i=t===void 0?e:`${t}\0${e}`,r=n.factoryModules.get(i);if(r)return r;let o=w$e(e,t);return n.factoryModules.set(i,o),o}async function w$e(e,t){let n;try{let o=await yx(e,"utf-8");n=D.createSourceFile(e,o,D.ScriptTarget.Latest,!0)}catch{return}let i=PN(n),r=Ug(n);for(let[o]of[...r])Zk(r,o,new Set)&&r.delete(o);return{file:e,sourceFile:n,packageRoot:t,consts:r,imports:i.named,namespaceImports:i.namespaces}}function v$e(e,t){if(e.resolved)return e.resolved;if(t.stack.includes(e.file)||t.stack.length>=RN)return Promise.resolve({externals:new Map,failures:new Map});t.stack.push(e.file);let n=e.packageRoot===void 0?[]:[e.packageRoot];return e.resolved=r9(e.file,e.imports,e.namespaceImports,t,n).finally(()=>{let i=t.stack.lastIndexOf(e.file);i!==-1&&t.stack.splice(i,1)}),e.resolved}function k$e(e,t,n){for(let i of e.sourceFile.statements)if(D.isVariableStatement(i)&&Jg(i)&&(i.declarationList.flags&D.NodeFlags.Const)!==0)for(let r of i.declarationList.declarations){if(!D.isIdentifier(r.name)||r.name.text!==t)continue;let o=r.initializer;if(!o||!D.isCallExpression(o)||!D.isIdentifier(o.expression))return;let s=e.imports.get(o.expression.text);if(!s||s.imported!=="Composite")return;let a=Y5(s,{...n,file:e.file}),l=B5(s.specifier,e.file,n.lexiconPackages)!==void 0||G5(s.specifier,e.file,n.lexiconModules,n.resolvePathCache)!==void 0;if(!a&&!l)return;let[c,u]=o.arguments;return!c||!D.isArrowFunction(c)&&!D.isFunctionExpression(c)||u!==void 0&&!D.isStringLiteral(u)?void 0:{fn:c,compositeName:u?u.text:"anonymous",hostForm:!a}}}function H5(e){return/\.[cm]?tsx?$/.test(e)&&!/\.d\.[cm]?ts$/.test(e)}function $$e(e,t){let n=Oo(e),i=`${t}\0${n}`;if(vN.has(i))return vN.get(i);let r;for(let o=n;fx(o)!=="node_modules";){let s=ip(o,"package.json");if(EN(s))try{if(JSON.parse(j5(s,"utf-8")).name===t){r=o;break}}catch{}let a=Oo(o);if(a===o)break;o=a}return vN.set(i,r),r}function R$e(e,t,n){if(Cs(e,t)){let s;try{s=sr(e,t,n.resolvePathCache)}catch{return}return n.packageRoot===void 0?{modulePath:s}:th(s,n.packageRoot)?{modulePath:s,packageRoot:n.packageRoot}:void 0}let i=Xg(e,n.lexiconPackages)??Xg(W5(e)??"",n.lexiconPackages);if(i===void 0)return;let r;try{r=sr(e,t,n.resolvePathCache)}catch{return}if(!H5(r))return;let o=$$e(r,i);return o===void 0?void 0:{modulePath:r,packageRoot:o}}function S$e(e,t){let n=[];for(let i of e.statements){if(D.isExportDeclaration(i)){if(i.isTypeOnly)continue;let r=i.moduleSpecifier&&D.isStringLiteral(i.moduleSpecifier)?i.moduleSpecifier.text:void 0,o=i.exportClause;if(o===void 0){r!==void 0&&n.push({specifier:r,imported:t,star:!0});continue}if(!D.isNamedExports(o)){if(o.name.text===t)return[];continue}for(let s of o.elements)if(s.name.text===t)return r===void 0||s.isTypeOnly?[]:[{specifier:r,imported:(s.propertyName??s.name).text,star:!1}];continue}if(Jg(i)){if(D.isVariableStatement(i)){for(let r of i.declarationList.declarations)if(D.isIdentifier(r.name)&&r.name.text===t)return[]}else if((D.isFunctionDeclaration(i)||D.isClassDeclaration(i)||D.isEnumDeclaration(i))&&i.name?.text===t)return[]}}return n}async function E$e(e,t){try{let n=await yx(e,"utf-8");return n.includes(t)||/export\s*\*\s*from/.test(n)}catch{return!1}}async function V5(e,t,n,i=new Set,r=0){i.add(e.modulePath);let o=await b$e(e.modulePath,e.packageRoot,n.session);if(!o)return;let s=k$e(o,t,n);if(s)return{scope:o,definition:s};if(!(r>=x$e))for(let{specifier:a,imported:l,star:c}of S$e(o.sourceFile,t)){if(!IN(a))continue;let u;try{u=sr(a,o.file,n.resolvePathCache)}catch{continue}if(i.has(u)||!H5(u)||e.packageRoot!==void 0&&!th(u,e.packageRoot)||c&&!await E$e(u,l))continue;let d=await V5({modulePath:u,packageRoot:e.packageRoot},l,n,i,r+1);if(d)return d}}async function q5(e,t){let n=R$e(e.specifier,t.file,t);if(!n)return;if(t.interpretDepth>=D5)throw new gx(`interpretation depth exceeded ${D5} at "${e.imported}" \u2014 a composite chain this deep is almost certainly recursive. Falling back to run rather than invoking the factory, which would have reported this file as folded while evaluating it a different way.`,0,0);let i=await V5(n,e.imported,t);if(!i)return;let{scope:r,definition:o}=i;if(A$e(o.fn)===void 0)return{scope:r,fn:o.fn,compositeName:o.compositeName,hostForm:o.hostForm}}function A$e(e){if(e.parameters.length>1)return"a composite factory takes a single props parameter";let t=e.parameters[0];if(t){if(t.dotDotDotToken)return"a rest parameter is not interpretable";if(t.initializer)return"a defaulted parameter is not interpretable";if(D.isObjectBindingPattern(t.name)){for(let i of t.name.elements)if(xl(i)===void 0)return"a destructured props parameter with a rest, default, or nested element is not interpretable"}else if(!D.isIdentifier(t.name))return"an array-destructured props parameter is not interpretable"}if(!D.isBlock(e.body))return yn(e.body);let n=e.body.statements;if(n.length===0)return"an empty composite factory body has no members to interpret";for(let i=0;i<n.length;i+=1){let r=n[i],o=i===n.length-1;if(D.isReturnStatement(r)){if(!o)return"an early `return` is not interpretable";if(!r.expression)return"a composite factory must return its members";let s=yn(r.expression);if(s)return s;continue}if(o)return"a composite factory body must end in `return`";if(!D.isVariableStatement(r))return`\`${D.SyntaxKind[r.kind]}\` in a composite factory body is not interpretable`;if((r.declarationList.flags&D.NodeFlags.Const)===0)return"`let`/`var` in a composite factory body is not interpretable";for(let s of r.declarationList.declarations){if(!s.initializer)return"an uninitialized `const` in a composite factory body is not interpretable";if(D.isObjectBindingPattern(s.name)){for(let l of s.name.elements)if(xl(l)===void 0)return"a destructured `const` with a rest, default, or nested element is not interpretable"}else if(!D.isIdentifier(s.name))return"an array-destructured `const` is not interpretable";let a=yn(s.initializer);if(a)return a}}}function yn(e){if(D.isParenthesizedExpression(e)||D.isAsExpression(e)||D.isSatisfiesExpression(e)||D.isNonNullExpression(e)||D.isTypeAssertionExpression(e))return yn(e.expression);if(!(D.isStringLiteral(e)||D.isNoSubstitutionTemplateLiteral(e)||D.isNumericLiteral(e)||D.isIdentifier(e)||e.kind===D.SyntaxKind.TrueKeyword||e.kind===D.SyntaxKind.FalseKeyword||e.kind===D.SyntaxKind.NullKeyword)){if(D.isNewExpression(e)||D.isCallExpression(e)){if(!D.isIdentifier(e.expression))return D.isNewExpression(e)?`\`new ${ir(e.expression)}(...)\` needs a plain imported constructor to interpret`:Xd(e);for(let t of e.arguments??[]){let n=yn(t);if(n)return n}return}if(D.isTaggedTemplateExpression(e)){if(!D.isIdentifier(e.tag))return Wg(e);if(D.isNoSubstitutionTemplateLiteral(e.template))return;for(let t of e.template.templateSpans){let n=yn(t.expression);if(n)return n}return}if(D.isTemplateExpression(e)){for(let t of e.templateSpans){let n=yn(t.expression);if(n)return n}return}if(D.isObjectLiteralExpression(e)){for(let t of e.properties)if(D.isPropertyAssignment(t)){if(!P$e(t.name))return Hk(t.name);let n=yn(t.initializer);if(n)return n}else if(D.isShorthandPropertyAssignment(t)){if(t.objectAssignmentInitializer)return Bg}else if(D.isSpreadAssignment(t)){let n=yn(t.expression);if(n)return n}else return Bg;return}if(D.isArrayLiteralExpression(e)){for(let t of e.elements){let n=yn(D.isSpreadElement(t)?t.expression:t);if(n)return n}return}return D.isPropertyAccessExpression(e)?yn(e.expression):D.isElementAccessExpression(e)?Fg(e.argumentExpression)?yn(e.expression):`dynamic element access [${ir(e.argumentExpression)}] is not interpretable`:D.isPrefixUnaryExpression(e)?Uk.has(e.operator)?yn(e.operand):Vk:D.isBinaryExpression(e)?zk.has(e.operatorToken.kind)?yn(e.left)??yn(e.right):Gg(e.operatorToken.kind):D.isConditionalExpression(e)?yn(e.condition)??yn(e.whenTrue)??yn(e.whenFalse):Wg(e)}}function P$e(e){return D.isIdentifier(e)||D.isStringLiteral(e)||D.isNumericLiteral(e)}function O$e(e,t,n){let i=new Set,r=new Map,o=e.fn.parameters[0];if(o){if(D.isIdentifier(o.name))i.add(o.name.text);else if(D.isObjectBindingPattern(o.name))for(let l of o.name.elements){let c=xl(l);c!==void 0&&D.isIdentifier(l.name)&&r.set(l.name.text,c)}}let s=new Map(t),a=e.fn.body;if(D.isBlock(a)){for(let l of a.statements)if(D.isVariableStatement(l))for(let c of l.declarationList.declarations)D.isIdentifier(c.name)&&c.initializer&&s.set(c.name.text,c.initializer)}return{composite:e.compositeName,scope:{whole:i,destructured:r},consts:s,...n?{call:n}:{}}}function C$e(e,t,n){let i=n.compositeParams;if(!i||typeof e!="object"||e===null)return;let r;for(let s of t.arguments??[])if(D.isObjectLiteralExpression(s)){r=s;break}if(!r)return;K5(e,i);let o=E5(r,i.consts,i.scope,i.composite,i.call);for(let[s,a]of Object.entries(o))Ps(e,s,a)}function K5(e,t){t.call&&zi(e,{compositeCall:lx(t.call.file,t.call.node)})}function _$e(e,t,n){let i=n.compositeParams;if(!i||!qt(e)||!wm(e))return;let r=qZ(e);if(!r)return;let o=D.isTemplateExpression(t.template)?t.template.templateSpans.map(a=>a.expression):[];K5(e,i);let s=A5(o,r,e.props,i.consts,i.scope,i.composite,i.call);for(let[a,l]of Object.entries(s))Ps(e,a,l)}async function J5(e,t,n,i){if(t.length>1)return;let{scope:r,fn:o}=e,s=await v$e(r,n.session),a=new Map(r.consts),l=new Map(s.externals),c={file:r.file,consts:a,locals:new Map,imports:r.imports,namespaceImports:r.namespaceImports,memo:new Map,intrinsics:n.intrinsics,externals:l,crossFileFailures:s.failures,importCache:n.importCache,resolvePathCache:n.resolvePathCache,lexiconPackages:n.lexiconPackages,lexiconModules:n.lexiconModules,lexiconRoots:r.packageRoot===void 0?n.lexiconRoots:[...n.lexiconRoots,r.packageRoot],packageRoot:r.packageRoot,sandbox:n.sandbox,executing:n.executing,session:n.session,interpretDepth:n.interpretDepth+1,compositeParams:O$e(e,r.consts,i)},u=(d,p)=>{a.delete(d),l.set(d,p)};try{let d=o.parameters[0];if(d){let g=t[0];if(D.isIdentifier(d.name))u(d.name.text,g);else if(D.isObjectBindingPattern(d.name)){if(!Wa(g))return;for(let h of d.name.elements){let b=xl(h);if(b===void 0)return;u(h.name.getText(),g[b])}}}let p=await I$e(o,c,u);if(!Wa(p))return;let f=e.hostForm?sN(p,e.compositeName):JZ(()=>p,e.compositeName)();return $N.factoryInterpretations+=1,{value:f}}catch(d){if(d instanceof gx)throw d;return}}async function I$e(e,t,n){if(!D.isBlock(e.body))return cn(e.body,t);for(let i of e.body.statements){if(D.isReturnStatement(i))return cn(i.expression,t);let r=i.declarationList.declarations;for(let o of r){let s=await cn(o.initializer,t);if(D.isIdentifier(o.name)){n(o.name.text,s);continue}if(!Wa(s))throw Qe(`destructured \`const\` source in "${ir(o.name)}" is not an object`);for(let a of o.name.elements)n(a.name.getText(),s[xl(a)])}}throw Qe("composite factory body did not return")}async function cn(e,t){if(D.isParenthesizedExpression(e)||D.isAsExpression(e)||D.isSatisfiesExpression(e)||D.isNonNullExpression(e))return cn(e.expression,t);if(D.isNewExpression(e))return T$e(e,t);if(D.isTaggedTemplateExpression(e)){let n=(await Zg(e,t)).value;return _$e(n,e,t),n}if(D.isObjectLiteralExpression(e)){let n={};for(let i of e.properties)if(D.isPropertyAssignment(i))n[Hg(i.name)]=await cn(i.initializer,t);else if(D.isShorthandPropertyAssignment(i))n[i.name.text]=await cn(i.name,t);else{let r=await cn(i.expression,t);if(r===null||typeof r!="object")throw Qe("spread source not an object");Object.assign(n,r)}return n}if(D.isArrayLiteralExpression(e)){let n=[];for(let i of e.elements)if(D.isSpreadElement(i)){let r=await cn(i.expression,t);if(!Array.isArray(r))throw Qe("spread source not an array");n.push(...r)}else n.push(await cn(i,t));return n}if(D.isConditionalExpression(e))return await cn(e.condition,t)?cn(e.whenTrue,t):cn(e.whenFalse,t);if(D.isBinaryExpression(e)){let n=D.SyntaxKind,i=e.operatorToken.kind;if(i===n.AmpersandAmpersandToken){let r=await cn(e.left,t);return r&&cn(e.right,t)}if(i===n.BarBarToken){let r=await cn(e.left,t);return r||cn(e.right,t)}if(i===n.QuestionQuestionToken){let r=await cn(e.left,t);return r??cn(e.right,t)}}return(await Zg(e,t)).value}async function T$e(e,t){if(!D.isIdentifier(e.expression))throw Qe(`\`new ${ir(e.expression)}(...)\` needs a plain imported constructor`);let n=e.expression.text,i=t.imports.get(n);if(!i)throw Qe(`constructor "${n}" is not a resolvable import`);let r=bx(i,t,n,"constructor");if(r)throw Qe(r);let o=sr(i.specifier,t.file,t.resolvePathCache),a=(await op(o,t.importCache))[i.imported];if(typeof a!="function")throw Qe(`"${i.imported}" from "${i.specifier}" is not a constructor`);let l=[];for(let u of e.arguments??[])l.push(await cn(u,t));let c=new a(...l);return C$e(c,e,t),c}function Po(e,t,n,i){i.set(e,t),(qt(t)||Ui(t))&&n.push([e,t])}async function CN(e,t){let n=t.imports.get(e);if(!n)throw Qe(`"${e}" is not a resolvable import`);let i=bx(n,t,e,"import");if(i)throw Qe(i);let r;try{r=sr(n.specifier,t.file,t.resolvePathCache)}catch(s){throw Qe(`could not resolve import "${n.specifier}" for "${e}": ${s instanceof Error?s.message:String(s)}`)}let o;try{o=await op(r,t.importCache)}catch(s){throw Qe(`could not import "${n.specifier}" to resolve "${e}": ${s instanceof Error?s.message:String(s)}`)}return o[n.imported]}async function N$e(e,t){if(!D$e.test(e))throw Qe(`symbol "${e}" is not a simple dotted import reference`);let[n,...i]=e.split("."),r=await CN(n,t);for(let o of i){if(r==null)throw Qe(`symbol "${e}": "${n}" has no "${o}"`);r=r[o]}return r}function Z5(e){return e===null||typeof e!="object"?!0:dn(e)||qt(e)||Ui(e)||Au(e)}async function di(e,t,n){if(e===null||typeof e!="object"||Z5(e))return e;if(Array.isArray(e)){let r=[];for(let o of e)r.push(await di(o,t,n));return r}if("__symbol"in e)return N$e(e.__symbol,t);if("__intrinsic"in e){let r=e,o=await CN(r.__intrinsic,t);if(typeof o!="function")throw Qe(`intrinsic "${r.__intrinsic}" did not resolve to a function`);let s=[];if("args"in r){for(let l of r.args)s.push(await di(l,t,!0));return o(...s)}for(let l of r.values)s.push(await di(l,t,!0));let a=Object.freeze(Object.defineProperty([...r.strings],"raw",{value:Object.freeze([...r.raw])}));return o(a,...s)}if("__helper"in e)return j$e(e,t);if("__compositeStep"in e){let r=e,o=[];for(let a of r.args)o.push(await di(a,t,!1));let s=await g$e(r.__compositeStep,o,t);if(!Wa(s))throw Qe(`composite call \`${r.__compositeStep}(...)\` did not resolve to an object with a "step" member`);return s.step}if("__attrRef"in e){if(n)throw Qe("a same-file resource reference passed to a folded intrinsic or authoring helper is not foldable yet");return e}if("__resource"in e)return t9(e,t,n);let i={};for(let[r,o]of Object.entries(e))i[r]=await di(o,t,n);return i}async function j$e(e,t){let n=e.__helper,i=t.imports.get(n);if(!i)throw Qe(`authoring helper "${n}(...)" is not a resolvable import`);if(!Y5(i,t))throw Qe(`"${n}" is imported from "${i.specifier}", which is not chant's own \u2014 only chant's registered authoring helpers fold as calls`);let r=await CN(n,t);if(typeof r!="function")throw Qe(`authoring helper "${n}" did not resolve to a function`);let o=[];for(let s of e.args)o.push(await di(s,t,!0));return r(...o)}function Y5(e,t){if(Gk(e.specifier))return!0;if(!Cs(e.specifier,t.file))return!1;let n;try{n=sr(e.specifier,t.file,t.resolvePathCache)}catch{return!1}return _N(n)}function X5(e,t){let n=eh(e.specifier,t.file)!==void 0;if(!n&&Xg(e.specifier,t.lexiconPackages)!==void 0)return!0;let i=W5(e.specifier);if(!n&&i!==void 0&&Xg(i,t.lexiconPackages)!==void 0)return!0;if(!n&&!IN(e.specifier)&&!Gk(e.specifier))return!1;let r;try{r=sr(e.specifier,t.file,t.resolvePathCache)}catch{return!1}return t.lexiconModules.has(r)||px(r,t.lexiconRoots)?!0:_N(r)}function bx(e,t,n,i){if(t.sandbox&&!X5(e,t))return`${i} "${n}" is imported from "${e.specifier}", which is neither chant's own nor an active lexicon \u2014 under --sandbox it is executed in the sandboxed child, not in this process`}function L$e(){if(!kN){let e=Oo(Oo(L5(import.meta.url))),t=fx(e),n=t==="dist"?ip(Oo(e),"src"):t==="src"?ip(Oo(e),"dist"):void 0;kN=n?[e,n]:[e]}return kN}function _N(e){return L$e().some(t=>e===t||e.startsWith(t+xN))}async function N5(e,t,n){let i={};for(let[r,o]of Object.entries(e))i[r]=await di(o,t,n);return i}async function Q5(e,t,n){if(e.args){let r=[];for(let o of e.args)r.push(await di(o,t,n));return r}return[await N5(e.props,t,n),e.attributes?await N5(e.attributes,t,n):void 0]}async function e9(e,t,n,i){let r=n.imports.get(e);if(!r)throw Qe(`constructor "${e}"${i} is not a resolvable import`);let o=bx(r,n,e,"constructor");if(o)throw Qe(o);let s;try{s=sr(r.specifier,n.file,n.resolvePathCache)}catch(c){throw Qe(`could not resolve import "${r.specifier}" for "${e}": ${c instanceof Error?c.message:String(c)}`)}let a;try{a=await op(s,n.importCache)}catch(c){throw Qe(`could not import "${r.specifier}" to resolve "${e}": ${c instanceof Error?c.message:String(c)}`)}let l=a[r.imported];if(typeof l!="function")throw Qe(`"${r.imported}" from "${r.specifier}" is not a constructor`);return new l(...t)}async function t9(e,t,n){let i=await Q5(e,t,n);return e9(e.__resource,i,t,"")}function M$e(e){let t=new Set,n=e.session.buildParams;if(!n)return t;for(let[i,r]of e.externals)r===n&&t.add(i);return t}function n9(e,t,n){if(typeof e!="object"||e===null)return;let i=M$e(n),r={values:n.hostValues??new Set,eagerCalls:new Set(n.intrinsics.filter(s=>ml(s)).map(s=>s.name))},o;for(let s of t.arguments??[])if(D.isObjectLiteralExpression(s)){o=s;break}if(o)for(let[s,a]of Object.entries(R5(o,n.consts,i,r)))Ps(e,s,a)}async function F$e(e){let t=new Map;for(let[n,i]of e.consts){if(D.isTaggedTemplateExpression(i)&&D.isIdentifier(i.tag)&&e.intrinsics.some(r=>r.name===i.tag.text&&Fk(r))){try{let r=await di(Me(i,e.consts,e.intrinsics,e.externals),e,!1);t.set(i,r),Z5(r)&&e.externals.set(n,r)}catch(r){e.prebuildFailures?.set(n,kl(r,e))}continue}if(!(!D.isNewExpression(i)||!D.isIdentifier(i.expression)))try{let r=Yk(i,e.consts,e.intrinsics,e.externals),o=await t9(r,e,!1);n9(o,i,e),t.set(i,o),e.externals.set(n,o)}catch(r){e.prebuildFailures?.set(n,kl(r,e))}}return t}async function B$e(e,t,n){let i;try{i=Yk(t,n.consts,n.intrinsics,n.externals)}catch(o){if(o instanceof So)return{ok:!1,reason:`"${e}" is not foldable: ${kl(o,n)}`};throw o}let r;try{r=await Q5(i,n,!1)}catch(o){return{ok:!1,reason:`"${e}" is not foldable: ${kl(o,n)}`}}try{let o=await e9(i.__resource,r,n,` for "${e}"`);return n9(o,t,n),{ok:!0,entity:o}}catch(o){return{ok:!1,reason:o instanceof Error?o.message:String(o)}}}function kl(e,t){if(!(e instanceof Error))return String(e);let n=G$e.exec(e.message);if(n){let r=t.crossFileFailures.get(n[1]);if(r)return`${e.message} (${r})`}let i=W$e.exec(e.message);if(i){let r=t.prebuildFailures?.get(i[1]);if(r)return`${e.message} (${r})`}return e.message}function z$e(e){return D.isCallExpression(e)?`${ir(e.expression)}(...)`:ir(e)}function rp(e,t){let{line:n,column:i}=HD(e);return new So(t,n,i).message}function hx(e,t){let n=t.stack.indexOf(e);if(n!==-1){let o=[...t.stack.slice(n),e].map(s=>fx(s));return Promise.resolve({ok:!1,reason:`import cycle: ${o.join(" -> ")}`})}let i=t.cache.get(e);if(i)return i;if(t.stack.length>=RN){let o=[...t.stack.slice(-5),e].map(s=>fx(s));return Promise.resolve({ok:!1,reason:`cross-file resolution depth exceeded ${RN} (...-> ${o.join(" -> ")}) \u2014 this is almost certainly a resolution bug (memoization not taking effect), not a genuinely thousand-file-deep import chain`})}t.stack.push(e);let r=U$e(e,t).finally(()=>{let o=t.stack.lastIndexOf(e);o!==-1&&t.stack.splice(o,1)});return t.cache.set(e,r),r}function IN(e){return e.startsWith(".")||Qg(e)}function Cs(e,t){return IN(e)||eh(e,t)!==void 0}async function r9(e,t,n,i,r=[]){let o=r.length===0?i.lexiconRoots:[...i.lexiconRoots,...r],s=new Map,a=new Map,l=new Set,c=new Set;for(let[u,d]of t){if(i.buildParams&&d.imported==="params"){if(d.specifier===d$e){s.set(u,i.buildParams);continue}if(Cs(d.specifier,e))try{if(sr(d.specifier,e,i.resolvePathCache)===p$e()){s.set(u,i.buildParams);continue}}catch{}}if(!Cs(d.specifier,e)){let g=await _5(d,e,i);if(g){s.set(u,g.value),c.add(u);continue}let h=F5(d.specifier,e);h&&a.set(u,rp(d.specifierNode,`tsconfig paths entry "${h.key}" matches "${d.specifier}" but names no file`));continue}let p;try{p=sr(d.specifier,e,i.resolvePathCache)}catch{continue}if(i.lexiconModules.has(p)){let g=await _5(d,e,i);g&&(s.set(u,g.value),c.add(u));continue}if(px(p,r)){let g=await f$e(p,d.imported,i);g&&(s.set(u,g.value),c.add(u));continue}if(px(p,o))continue;let f=await hx(p,i);if(!f.ok){a.set(u,rp(d.specifierNode,f.reason));continue}if(f.exportedValues.has(d.imported)){let g=f.exportedValues.get(d.imported);s.set(u,g),SN(g)&&l.add(p)}else a.set(u,rp(d.specifierNode,`"${d.imported}" is not exported by "${d.specifier}"`))}for(let[u,d]of n){if(!Cs(d.specifier,e))continue;let p;try{p=sr(d.specifier,e,i.resolvePathCache)}catch{continue}if(i.lexiconModules.has(p)||px(p,o))continue;let f=await hx(p,i);if(!f.ok){a.set(u,rp(d.specifierNode,f.reason));continue}s.set(u,Object.fromEntries(f.exportedValues));for(let g of f.exportedValues.values())if(SN(g)){l.add(p);break}}return{externals:s,failures:a,liveSources:l,hostValues:c}}function SN(e){return As(e)?!1:e!==null&&(typeof e=="object"||typeof e=="function")}async function Zg(e,t){let n=await ON(e,t);if(n!==void 0)return n;let i=Me(e,t.consts,t.intrinsics,t.externals);return{value:await di(i,t,!1)}}async function U$e(e,t){if(_N(e))return{ok:!1,reason:"chant's own module is not project source"};try{let n=await yx(e,"utf-8"),i=D.createSourceFile(e,n,D.ScriptTarget.Latest,!0),r=a$e(i);if(r.unfoldableReason)return{ok:!1,reason:r.unfoldableReason};if(r.declarators.length===0)return{ok:!1,reason:"no foldable resource exports"};let o=PN(i),{externals:s,failures:a,liveSources:l,hostValues:c}=await r9(e,o.named,o.namespaces,t),u={file:e,consts:Ug(i),locals:c$e(i),imports:o.named,namespaceImports:o.namespaces,memo:new Map,intrinsics:t.intrinsics,externals:s,hostValues:c,crossFileFailures:a,importCache:t.importCache,resolvePathCache:t.resolvePathCache,lexiconPackages:t.lexiconPackages,lexiconModules:t.lexiconModules,lexiconRoots:t.lexiconRoots,sandbox:t.sandbox,executing:t.executing,session:t,interpretDepth:0,prebuildFailures:new Map},d=await F$e(u),p=l$e(i,u);for(let[h,b]of p)u.externals.has(h)||u.externals.set(h,b);let f=[],g=new Map;for(let h of r.declarators){if(h.kind==="function"){Po(h.name,p.get(h.name),f,g);continue}if(h.kind==="resource"){let x=d.get(h.node);if(x!==void 0){Po(h.name,x,f,g);continue}let k=await B$e(h.name,h.node,u);if(!k.ok)return k;Po(h.name,k.entity,f,g);continue}if(h.kind==="single"){let x=D.isIdentifier(h.node)?u.externals.get(h.node.text):void 0,k=p.get(h.name)??(As(x)?x:void 0);if(k){Po(h.name,k,f,g);continue}if(d.has(h.node)){Po(h.name,d.get(h.node),f,g);continue}let R;try{R=(await Zg(h.node,u)).value}catch($){return{ok:!1,reason:`"${h.name}" is not foldable: ${kl($,u)}`}}Po(h.name,R,f,g);continue}if(h.kind==="destructure"){let x,k=h.elements.map($=>$.bindingName).join(", "),R=z$e(h.node);try{x=(await Zg(h.node,u)).value}catch($){return{ok:!1,reason:`"${k}" (destructured from ${R}) is not foldable: ${kl($,u)}`}}if(!Wa(x))return{ok:!1,reason:`"${k}" (destructured from ${R}) is not foldable: not a composite call or object`};for(let{propKey:$,bindingName:_}of h.elements)Po(_,x[$],f,g);continue}if(h.kind==="named-export"){for(let{localNameNode:x,exportedName:k}of h.elements){let R=p.get(x.text);if(R){Po(k,R,f,g);continue}let $;try{$=(await Zg(x,u)).value}catch(_){return{ok:!1,reason:`exported "${k}" is not foldable: ${kl(_,u)}`}}Po(k,$,f,g)}continue}let b;try{b=sr(h.specifier,e,t.resolvePathCache)}catch(x){return{ok:!1,reason:`could not resolve re-export "${h.specifier}": ${x instanceof Error?x.message:String(x)}`}}let w=await hx(b,t);if(!w.ok)return{ok:!1,reason:`re-export from "${h.specifier}" is not foldable: ${rp(h.specifierNode,w.reason)}`};for(let{imported:x,exportedName:k}of h.elements){if(!w.exportedValues.has(x))return{ok:!1,reason:rp(h.specifierNode,`"${x}" is not exported by "${h.specifier}"`)};let R=w.exportedValues.get(x);SN(R)&&l.add(b),Po(k,R,f,g)}}return{ok:!0,entities:f,exportedValues:g,liveSources:l}}catch(n){return{ok:!1,reason:n instanceof Error?n.message:String(n)}}}async function i9(e,t=[],n){return hx(e,n??AN(t))}async function H$e(e){let t=new Set(e),n=new Map;for(let i of e){let r=new Set,o=s=>{if(!Cs(s,i))return;let a;try{a=Yg(s,i)}catch{return}t.has(a)&&r.add(a)};try{let s=await yx(i,"utf-8"),a=D.createSourceFile(i,s,D.ScriptTarget.Latest,!0),l=PN(a);for(let c of l.named.values())o(c.specifier);for(let c of l.namespaces.values())o(c.specifier);for(let c of a.statements)D.isExportDeclaration(c)&&!c.isTypeOnly&&c.moduleSpecifier&&D.isStringLiteral(c.moduleSpecifier)&&o(c.moduleSpecifier.text)}catch{}n.set(i,r)}return n}async function TN(e,t,n){let i=new Set(e),r=await H$e(e),o=new Map;for(let[c,u]of n??[])if(i.has(c))for(let d of u){if(!i.has(d))continue;let p=r.get(d);p||(p=new Set,r.set(d,p)),p.add(c);let f=o.get(d);f||(f=new Set,o.set(d,f)),f.add(c)}let s=new Set(e.filter(c=>t.get(c)!==!0)),a=new Map,l=[...s];for(;l.length>0;){let c=l.shift();for(let u of r.get(c)??[])if(!s.has(u)){s.add(u);let d=!o.get(c)?.has(u);a.set(u,{from:c,kind:d?"importer":"capture"}),l.push(u)}}return{tainted:s,reachedBy:a}}var D,C5,$N,d$e,dx,D5,gx,x$e,vN,D$e,kN,G$e,W$e,RN,DN=v(()=>{"use strict";D=Le(Ke(),1);Pn();nx();Wt();Xo();Xk();Wk();xn();x5();hl();ox();O5();ui();ux();sx();cN();Ro();C5=new Map;$N={factoryInvocations:0,projectFactoryInvocations:0,factoryInterpretations:0};d$e="@intentius/chant/params";D5=16,gx=class extends So{};x$e=8;vN=new Map;D$e=/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/;G$e=/unresolved identifier: (\S+)$/,W$e=/same-file resource `([^`]+)` used as a value is not foldable/;RN=200});function NN(e){return typeof e=="object"&&e!==null&&o9 in e&&e[o9]===!0}var o9,wx=v(()=>{"use strict";o9=Symbol.for("chant.childProject")});function Co(e,t){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(r=>Co(r,t));let n=e;if("__attrRef"in n){let{entity:r,attribute:o}=n.__attrRef,s=t.get(r);if(!s)throw new Error(`decodeEntitySet: __attrRef refers to unknown entity "${r}"`);let a=new Qo(s,o);return a._setLogicalName(r),a}if("__entityRef"in n){let{entity:r}=n.__entityRef,o=t.get(r);if(!o)throw new Error(`decodeEntitySet: __entityRef refers to unknown entity "${r}"`);return o}if("__property"in n){let{lexicon:r,entityType:o,props:s}=n.__property,a={};return Object.defineProperty(a,Ni,{value:!0,enumerable:!1}),Object.defineProperty(a,"lexicon",{value:r,enumerable:!1,configurable:!0}),Object.defineProperty(a,"entityType",{value:o,enumerable:!1,configurable:!0}),Object.defineProperty(a,"kind",{value:"property",enumerable:!1,configurable:!0}),s!==void 0&&Object.defineProperty(a,"props",{value:Co(s,t),enumerable:!1,configurable:!0}),a}if("__intrinsic"in n){let r=n.__intrinsic,o=Co(r.value,t),s=r.refs.map(l=>Co(l,t)),a={[Pi]:!0,__chantWireRefs:s,toJSON(){return o}};if("yaml"in r){let l=Co(r.yaml,t);a.toYAML=()=>l}return a}let i={};for(let[r,o]of Object.entries(n))i[r]=Co(o,t);return i}function V$e(e){let t={};for(let n of e.markers)Object.defineProperty(t,Symbol.for(n),{value:!0,enumerable:!1,configurable:!0});return Ni in t||Object.defineProperty(t,Ni,{value:!0,enumerable:!1}),Object.defineProperty(t,"lexicon",{value:e.lexicon,enumerable:!1,configurable:!0}),Object.defineProperty(t,"entityType",{value:e.entityType,enumerable:!1,configurable:!0}),e.kind!==void 0&&Object.defineProperty(t,"kind",{value:e.kind,enumerable:!1,configurable:!0}),t}function nh(e){let t=new Map;for(let i of e.entities)i.form==="declarable"&&t.set(i.name,V$e(i));let n=new Map;for(let i of e.entities){if(i.form==="declarable"){let s=t.get(i.name);i.props!==void 0&&Object.defineProperty(s,"props",{value:Co(i.props,t),enumerable:!1,configurable:!0}),i.attributes!==void 0&&Object.defineProperty(s,"attributes",{value:Co(i.attributes,t),enumerable:!1,configurable:!0});for(let[a,l]of Object.entries(i.extra??{}))s[a]=Co(l,t);n.set(i.name,s);continue}let r=Co(i.ref,t),o=new ep(r,i.outputName);t.set(i.name,o),n.set(i.name,o)}return n}var vx=v(()=>{"use strict";Pn();Pu();Xo();Wt();bl();wx()});function q$e(e){return typeof e=="object"&&e!==null&&e.code==="ERR_ACCESS_DENIED"}function s9(e,t,n="import"){if(q$e(t)){let r=typeof t.permission=="string"?t.permission:"an unrecognized sandboxed operation",o=typeof t.resource=="string"?` (${t.resource})`:"",s=e?`"${e}"`:"sandboxed run-fallback code";return new Hn(e,`sandbox denied ${r}${o}: ${s} attempted an operation outside the sandbox's allowlist`,"permission")}let i=t instanceof Error?t.message:String(t);return new Hn(e,i,n)}var a9=v(()=>{"use strict";or()});var l9={};_e(l9,{runFallbackFilesSandboxed:()=>X$e});import{realpathSync as K$e,rmSync as J$e}from"node:fs";import{resolve as c9}from"node:path";function Y$e(e){return typeof e=="object"&&e!==null&&"entitySet"in e&&"errors"in e}async function X$e(e,t){if(e.length===0)return{entities:new Map,errors:[],bundleMs:0,bundleBytes:0,provenanceByName:{}};let n=BW({files:e,buildRoot:t}),{bundlePath:i,bundleDir:r,externalReadPaths:o,durationMs:s,bytes:a}=await Hb(n);try{let l;try{l=K$e(c9(t))}catch{l=c9(t)}let c=await Kb({bundlePath:i,bundleDir:r,projectRealpath:l,externalReadPaths:o,env:{PATH:process.env.PATH??""},timeoutMs:Z$e,label:"sandboxed run",outputPrefix:"[sandbox:run]"},Y$e),u=(c.errors??[]).map(f=>new Hn(f.file,f.message,f.type)),d=c.provenanceByName??{};return c.fatal?{entities:new Map,errors:u,bundleMs:s,bundleBytes:a,provenanceByName:d}:{entities:nh(c.entitySet??{entities:[]}),errors:u,bundleMs:s,bundleBytes:a,provenanceByName:d}}catch(l){return{entities:new Map,errors:[s9("",l,"import")],provenanceByName:{},bundleMs:s,bundleBytes:a}}finally{J$e(r,{recursive:!0,force:!0})}}var Z$e,u9=v(()=>{"use strict";or();vx();bO();a9();kO();xO();Z$e=12e4});import{relative as Q$e}from"node:path";import{existsSync as eRe,readFileSync as tRe}from"node:fs";import{dirname as nRe,join as rRe,parse as iRe}from"node:path";function oRe(e,t){if(Object.keys(t).length!==0)try{let n=sRe(e);if(!n)return;let i=JSON.parse(tRe(n,"utf-8"));if(i.type==="module")return;let r=i.type?`"type": "${i.type}"`:"no `type` field",o=Object.keys(t).sort().join(", ");console.error(`warning: ${n} has ${r}, but chant is ESM \u2014 build parameters (${o}) will read as empty in project source on the run path, so declarations conditioned on them take their default branch. Set "type": "module". (chant #1421)`)}catch{}}function sRe(e){let t=e,{root:n}=iRe(t);for(;;){let i=rRe(t,"package.json");if(eRe(i))return i;if(t===n)return;let r=nRe(t);if(r===t)return;t=r}}async function jN(e,t){let n=[],i=[],r=[],o=nN(t?.buildParams??[]);wO(o),oRe(e,o);let s=await lk(e);i.push(...s);let a=[],l=[],c=new Map;if(t?.sandbox===!0&&t?.executing===!0)throw new Error("discover: `sandbox` and `executing` are mutually exclusive \u2014 the first refuses to import project code and the second exists to invoke it. Pass one.");let u=t?.fold?AN(t.intrinsics,o,t.lexicons,t.sandbox===!0,t.lexiconPackages??[],t.executing===!0,s):void 0;if(t?.fold)for(let h of s)c.set(h,await i9(h,t.intrinsics,u));let d=t?.fold?await TN(s,new Map(s.map(h=>[h,c.get(h)?.ok===!0])),new Map(s.flatMap(h=>{let b=c.get(h);return b?.ok===!0?[[h,b.liveSources]]:[]}))):{tainted:new Set,reachedBy:new Map},p=d.tainted;for(let h of s){if(t?.fold){let b=c.get(h);if(b.ok&&!p.has(h)){a.push({file:h,exports:Object.fromEntries(b.exportedValues)}),r.push({file:h,mode:"fold",resourceCount:b.entities.length});continue}let w=d.reachedBy.get(h),x=b.ok?w?.kind==="capture"?`would fold in isolation, but it captured objects from ${Q$e(process.cwd(),w.from)}, which falls back to run \u2014 folding independently would hold an instance the build never collects`:"would fold in isolation, but a file that imports it (directly or transitively) falls back to run \u2014 folding independently would create a duplicate, non-identical instance":b.reason;r.push({file:h,mode:"run",reason:x,reverseTainted:b.ok})}if(t?.sandbox){l.push(h);continue}try{let b=await ix(h);a.push({file:h,exports:b})}catch(b){if(b instanceof Error&&b.name==="DiscoveryError")n.push(b);else{let{DiscoveryError:w}=await Promise.resolve().then(()=>(or(),yl));n.push(new w(h,b instanceof Error?b.message:String(b),"import"))}}}let f=new Map;try{f=uN(a,e)}catch(h){if(h instanceof Error&&h.name==="DiscoveryError")n.push(h);else{let{DiscoveryError:b}=await Promise.resolve().then(()=>(or(),yl));n.push(new b("",h instanceof Error?h.message:String(h),"resolution"))}return{entities:new Map,dependencies:new Map,sourceFiles:i,errors:n,foldDecisions:r}}if(t?.sandbox&&l.length>0)try{let{runFallbackFilesSandboxed:h}=await Promise.resolve().then(()=>(u9(),l9)),b=await h(l,e);n.push(...b.errors);for(let[k,R]of b.entities){if(f.has(k)){let{DiscoveryError:$}=await Promise.resolve().then(()=>(or(),yl)),_=b.provenanceByName[k]??e;n.push(new $(_,`Duplicate export name "${k}" found`,"resolution"));continue}f.set(k,R)}let w=new Map(s.map((k,R)=>[k,R])),x=[...f.entries()].map(([k,R])=>{let $=Eo(R)?.sourceFile??b.provenanceByName[k],_=$!==void 0?w.get($):void 0;return{name:k,entity:R,index:_??Number.MAX_SAFE_INTEGER}});x.sort((k,R)=>k.index-R.index),f=new Map(x.map(({name:k,entity:R})=>[k,R]))}catch(h){let{DiscoveryError:b}=await Promise.resolve().then(()=>(or(),yl));n.push(new b(e,h instanceof Error?h.message:String(h),"resolution"))}try{d5(f)}catch(h){let{DiscoveryError:b}=await Promise.resolve().then(()=>(or(),yl));n.push(new b("",h instanceof Error?h.message:String(h),"resolution"))}let g=new Map;try{g=ax(f)}catch(h){let{DiscoveryError:b}=await Promise.resolve().then(()=>(or(),yl));n.push(new b("",h instanceof Error?h.message:String(h),"resolution"))}return{entities:f,dependencies:g,sourceFiles:i,errors:n,foldDecisions:r}}var kx=v(()=>{"use strict";sl();ox();sx();fN();cx();DN();ui();Vg();Vb()});var d9=v(()=>{"use strict"});function f9(e){return typeof e=="object"&&e!==null&&p9 in e&&e[p9]===!0}var p9,LN=v(()=>{"use strict";Pn();p9=Symbol.for("chant.scenario")});function m9(e,t,n){let i=function(r,o){Object.defineProperty(this,Ni,{value:!0,enumerable:!1}),Object.defineProperty(this,"lexicon",{value:t,enumerable:!1}),Object.defineProperty(this,"entityType",{value:e,enumerable:!1}),Object.defineProperty(this,"kind",{value:"resource",enumerable:!1}),Object.defineProperty(this,"props",{value:r??{},enumerable:!1,configurable:!0}),Object.defineProperty(this,"attributes",{value:o??{},enumerable:!1,configurable:!0}),Object.defineProperty(this,"Ref",{value:this,enumerable:!1});for(let[s,a]of Object.entries(n))Object.defineProperty(this,s,{value:new Qo(this,a),enumerable:!0,writable:!1})};return Object.defineProperty(i,"name",{value:e.split("::").pop()??e}),i}var MN=v(()=>{"use strict";Pn();Pu()});function h9(e){return e?.entityType===g9}var g9,FN,xx=v(()=>{"use strict";MN();g9="Chant::Op",FN=m9(g9,"chant",{})});var y9=v(()=>{"use strict";vx();kx();vx()});var R9={};_e(R9,{build:()=>rh,buildFromEntitiesJson:()=>pRe,collectLexiconOutputs:()=>v9,computeStackGraph:()=>b9,detectCrossLexiconRefs:()=>k9,isStackMember:()=>$x,mergeBuildRootEntities:()=>x9,partitionByLexicon:()=>w9});import{statSync as cRe}from"node:fs";import{resolve as BN}from"node:path";function $x(e){return!Wr(e)&&!QZ(e)&&!f9(e)&&!h9(e)}function b9(e,t){let n=[],i=new Set,r=(p,f)=>{if(typeof p!="string"||typeof f!="string"||p===f)return;let g=`${p}\0${f}`;i.has(g)||(i.add(g),n.push({from:p,to:f}))},o=(p,f,g)=>{if(!(p==null||typeof p!="object")&&!g.has(p)){if(g.add(p),dn(p)){let h=p.parent.deref(),b=h?h.lexicon:void 0;typeof b=="string"&&b!==f&&r(f,b);return}if(!Wr(p)){if(Array.isArray(p)){for(let h of p)o(h,f,g);return}for(let h of Object.values(p))o(h,f,g)}}};for(let[,p]of e){if(!$x(p))continue;let f=p.lexicon,g=new Set;for(let h of Object.values(p))o(h,f,g);"props"in p&&typeof p.props=="object"&&p.props!==null&&o(p.props,f,g)}let s=t.length?[...t]:[...new Set([...e.values()].filter($x).map(p=>p.lexicon))],a=new Map;for(let p of s)a.set(p,new Set);for(let{from:p,to:f}of n)a.has(p)||a.set(p,new Set),a.has(f)||a.set(f,new Set),a.get(p).add(f);let l=new Set(a.keys()),c=[],u=[];for(;l.size>0;){let p=[...l].filter(f=>[...a.get(f)].every(g=>!l.has(g))).sort();if(p.length===0)break;for(let f of p)l.delete(f),u.push(f);c.push(p)}let d=l.size>0?[[...l].sort()]:[];return n.sort((p,f)=>`${p.from}\0${p.to}`.localeCompare(`${f.from}\0${f.to}`)),{nodes:[...s].sort(),edges:n,order:u,waves:c,cycles:d}}function w9(e){let t=new Map;for(let[n,i]of e){if(!$x(i))continue;let r=i.lexicon;t.has(r)||t.set(r,new Map),t.get(r).set(n,i)}return t}function v9(e){let t=[],n=new Set;function i(r){if(!(r==null||typeof r!="object")&&!n.has(r)){if(n.add(r),Wr(r)){t.push(r);return}if(Array.isArray(r)){for(let o of r)i(o);return}for(let o of Object.values(r))i(o)}}for(let[r,o]of e){if(Wr(o)){let s=o;if(s._literalValue===null){let a=s._sourceParent?.deref(),l=r;if(a){for(let[c,u]of e)if(u===a){l=c;break}}s._setSourceEntity(l)}t.push(s);continue}if("props"in o&&typeof o.props=="object"&&o.props!==null){let s=t.length;i(o.props);for(let a=s;a<t.length;a++)!t[a].sourceEntity&&t[a]._literalValue===null&&t[a]._setSourceEntity(r)}}return t}function k9(e){let t=[],n=new Set,i=new Map;for(let[o,s]of e)i.set(s,o);function r(o,s,a){if(!(o==null||typeof o!="object")&&!a.has(o)){if(a.add(o),dn(o)){let l=o.parent.deref();if(!l)return;let c=l.lexicon;if(typeof c!="string")return;if(c!==s){let u=i.get(l);if(!u)return;let d=`${u}_${o.attribute}`;n.has(d)||(n.add(d),t.push(ep.auto(o,u)))}return}if(!Wr(o)&&!i.has(o)){if(Array.isArray(o)){for(let l of o)r(l,s,a);return}for(let l of Object.values(o))r(l,s,a)}}}for(let[,o]of e){let s=new Set,a=o.lexicon;for(let l of Object.values(o))r(l,a,s);"props"in o&&typeof o.props=="object"&&o.props!==null&&r(o.props,a,s)}return t}function lRe(e,t){let n=new Map;for(let a of e)n.set(a,new Set);for(let a of t)for(let l of e)l!==a.sourceLexicon&&n.get(l)?.add(a.sourceLexicon);let i=[],r=new Set,o=new Set;function s(a){if(!r.has(a)&&!o.has(a)){o.add(a);for(let l of n.get(a)??[])s(l);o.delete(a),r.add(a),i.push(a)}}for(let a of e)s(a);return i}function uRe(e,t,n){let i={};for(let r of t)i[r.outputName]={source:r.sourceLexicon,entity:r.sourceEntity,attribute:r.sourceAttribute??""};return{lexicons:e,outputs:i,deployOrder:lRe(e,t),stackGraph:b9(n,e)}}function dRe(e){try{return cRe(e).isDirectory()?BN(e):void 0}catch{return}}async function x9(e,t,n){let i=[],r=[];for(let o of t)try{let s=await o({entities:e,...n!==void 0?{sourceDir:n}:{}});i.push(...s.warnings??[]);for(let[a,l]of s.entities){if(e.has(a)){r.push(`Build-root entity "${a}" collides with a discovered entity of the same name`);continue}e.set(a,l)}}catch(s){r.push(s instanceof Error?s.message:String(s))}return{warnings:i,errors:r}}async function rh(e,t,n,i){let r=await jN(e,{fold:i?.fold,intrinsics:i?.intrinsics,lexicons:i?.lexicons,lexiconPackages:i?.lexiconPackages,sandbox:i?.sandbox,executing:i?.executing,buildParams:i?.buildParams});return $9(r,e,t,n,i)}async function $9(e,t,n,i,r){let o=[],s=[];s.push(...e.errors);let a={};for(let[$,_]of e.dependencies)a[$]=Array.from(_);try{u5(a)}catch($){$ instanceof Error&&$.name==="BuildError"?s.push($):s.push(new Os("",$ instanceof Error?$.message:String($)))}let l=BN(t),c=i?new Set(i):new Set;c.add(l);for(let[$,_]of e.entities)if(NN(_)){let T=BN(_.projectPath);if(c.has(T)){s.push(new Os(T,`Circular nested stack: ${[...c].join(" \u2192 ")} \u2192 ${T}`));continue}let C=await rh(T,n,c,r);if(_.buildResult=C,C.errors.length>0)for(let K of C.errors)s.push(K)}if(!i&&r?.buildRoots){let $=await x9(e.entities,r.buildRoots,dRe(t));o.push(...$.warnings);for(let _ of $.errors)s.push(new Os("",_))}let u=w9(e.entities),d=new Map;for(let $ of n)d.set($.name,$);let p=v9(e.entities),f=k9(e.entities),g=p.map($=>({parent:$._sourceParent?.deref(),attribute:$.sourceAttribute})),h=[...p,...f.filter($=>{let _=$._sourceParent?.deref();return!g.some(T=>T.parent===_&&T.attribute===$.sourceAttribute)})],b=new Map,w=[];for(let $ of h){if(!$.sourceLexicon){w.push($);continue}b.has($.sourceLexicon)||b.set($.sourceLexicon,[]),b.get($.sourceLexicon).push($)}let x=new Map;for(let[$,_]of u){let T=d.get($),{applyBound:C,receipts:K}=eq(_);if(T){let O=[...b.get($)??[],...w],pe=T.serialize(C,O,{ownership:r?.ownership,config:r?.config,...r?.telemetry?{telemetry:r.telemetry}:{},...K.size>0?{receipts:K}:{}});if(typeof pe!="string"&&pe.warnings)for(let F of pe.warnings)o.push(F);x.set($,pe)}else C.size===0&&K.size>0||o.push(`No serializer found for lexicon "${$}". List the lexicon in chant.config.ts.`)}let k=Array.from(u.keys()),R=uRe(k,h,e.entities);return{outputs:x,entities:e.entities,dependencies:e.dependencies,warnings:o,errors:s,manifest:R,sourceFileCount:e.sourceFiles.length,foldDecisions:e.foldDecisions,lexiconVersions:{...r?.lexiconVersions??{}},buildParams:r?.buildParams??[],foldProvenance:wN(e.entities,Eo)}}async function pRe(e,t,n="<json-entity-set>",i,r){let o=nh(e.entitySet),s=ax(o),a=e.errors.map(c=>new Hn(c.file,c.message,c.type)),l={entities:o,dependencies:s,sourceFiles:e.sourceFiles,errors:a,foldDecisions:e.foldDecisions};return $9(l,n,t,i,r)}var sp=v(()=>{"use strict";ui();ux();or();bl();QD();er();LN();xx();Wt();wx();kx();y9();cx();pN()});var I9={};_e(I9,{GRAPH_IR_VERSION:()=>Rx,buildGraphIr:()=>_9,buildLiveGraphIr:()=>vRe,collectUnobserved:()=>kRe,entityReferences:()=>S9,entityStack:()=>E9,overlayGraphs:()=>xRe,sourceOverlayGraphs:()=>$Re});import{relative as fRe,isAbsolute as mRe}from"node:path";function gRe(e){return typeof e=="object"&&e!==null&&typeof e.to=="string"}function S9(e){let t=e.references;return Array.isArray(t)?t.filter(gRe):[]}function E9(e){let t=e.stack;return typeof t=="string"&&t.length>0?t:void 0}function hRe(e){return!(Wr(e)||e.kind==="property")}function yRe(e,t){if(e){if(t&&mRe(e)){let n=fRe(t,e);return n.startsWith("..")?e:n}return e}}function A9(e){try{let t=e.toJSON?.();if(t&&typeof t=="object"&&typeof t.Ref=="string")return t.Ref}catch{}}function P9(e,t){let n=e.parent.deref();return e.getLogicalName()??(n?t.get(n):void 0)}function O9(e,t,n){let i=t.get(e);return i!==void 0&&n.has(i)?i:void 0}function GN(e,t,n,i){if(e===null)return null;let r=typeof e;if(r==="string"||r==="number"||r==="boolean")return e;if(r!=="object")return;if(dn(e)){let s=P9(e,n);return{$ref:s?`${s}.${e.attribute}`:e.attribute}}if(e[Pi]===!0){let s=A9(e);return s&&i.has(s)?{$ref:s}:{$intrinsic:!0}}if(t.has(e))return;if(t.add(e),qt(e)){let s=O9(e,n,i);if(s)return{$ref:s};let a=C9(e,t,n,i);return t.delete(e),a}if(Array.isArray(e)){let s=e.map(a=>GN(a,t,n,i)).filter(a=>a!==void 0);return t.delete(e),s}let o={};for(let[s,a]of Object.entries(e)){let l=GN(a,t,n,i);l!==void 0&&(o[s]=l)}return t.delete(e),o}function WN(e){let t=[];for(let[i,r]of Object.entries(e))bRe.has(i)||i==="props"||t.push([i,r]);let n=e.props;if(n&&typeof n=="object"&&!Array.isArray(n))for(let[i,r]of Object.entries(n))t.push([i,r]);return t}function C9(e,t,n,i){let r={};for(let[o,s]of WN(e)){let a=GN(s,t,n,i);a!==void 0&&(r[o]=a)}return r}function wRe(e,t,n,i){let r=[];for(let a of S9(e))a.to===t||!n.has(a.to)||r.push({from:t,to:a.to,kind:"ref",...a.viaAttr?{viaAttr:a.viaAttr}:{},...a.toAttr?{toAttr:a.toAttr}:{}});let o=new Set,s=(a,l)=>{if(a===null||typeof a!="object")return;if(dn(a)){let u=P9(a,i);u&&u!==t&&n.has(u)&&r.push({from:t,to:u,kind:"ref",viaAttr:l});return}if(a[Pi]===!0){let u=A9(a);u&&u!==t&&n.has(u)&&r.push({from:t,to:u,kind:"ref",viaAttr:l});return}let c=O9(a,i,n);if(c){c!==t&&r.push({from:t,to:c,kind:"ref",viaAttr:l});return}if(!o.has(a)){if(o.add(a),qt(a)){for(let[,u]of WN(a))s(u,l);return}if(Array.isArray(a)){for(let u of a)s(u,l);return}for(let u of Object.values(a))s(u,l)}};for(let[a,l]of WN(e))s(l,a);return r}function $l(e){return`${e.from}\0${e.to}\0${e.viaAttr??""}`}function _9(e,t){let n=new Map;for(let[g,h]of e)n.set(h,g);let i=new Set;for(let[g,h]of e)hRe(h)&&i.add(g);let r=[],o={},s={},a={};for(let[g,h]of e){if(!i.has(g))continue;let b=Eo(h),w={id:g,kind:h.entityType,lexicon:h.lexicon,attrs:C9(h,new Set,n,i)};b?.composite&&(w.compositeParent=b.composite),b?.compositeInstance&&(w.compositeInstance=b.compositeInstance);let x=yRe(b?.sourceFile,t);x&&(w.sourceLoc={file:x}),r.push(w),(o[h.lexicon]??=[]).push(g),(a[E9(h)??h.lexicon]??=[]).push(g),b?.composite&&(s[b.composite]??=[]).push(g)}let l=new Map;for(let[g,h]of e)if(i.has(g))for(let b of wRe(h,g,i,n))l.set($l(b),b);r.sort((g,h)=>g.id.localeCompare(h.id));let c=[...l.values()].sort((g,h)=>$l(g).localeCompare($l(h)));for(let g of Object.values(o))g.sort();for(let g of Object.values(s))g.sort();for(let g of Object.values(a))g.sort();let u={};Object.keys(o).length&&(u.byLexicon=ih(o)),Object.keys(s).length&&(u.byComposite=ih(s)),Object.keys(a).length&&(u.byStack=ih(a));let d=[];for(let g of e.values()){if(!Wr(g))continue;let h=g;if(!h.outputName)continue;let b=h._sourceParent?.deref(),w=(b?n.get(b):void 0)??(h.sourceEntity||void 0);d.push({name:h.outputName,...w?{node:w}:{},...h.sourceAttribute?{attr:h.sourceAttribute}:{}})}d.sort((g,h)=>g.name.localeCompare(h.name));let p=r.filter(g=>/(^|::)Parameter$/i.test(g.kind)).map(g=>({name:g.id,node:g.id})).sort((g,h)=>g.name.localeCompare(h.name)),f={nodes:r,edges:c,groups:u};return d.length&&(f.exports=d),p.length&&(f.imports=p),f}function ih(e){let t={};for(let n of Object.keys(e).sort())t[n]=e[n];return t}function vRe(e){let t=[],n={},i={};for(let{lexicon:c,resources:u}of e)for(let[d,p]of Object.entries(u)){let f={id:d,kind:p.type,lexicon:c,attrs:p.attributes??{}};p.physicalId&&(f.physicalId=p.physicalId),(p.ownership==="owned"||p.ownership==="foreign")&&(f.ownership=p.ownership),p.ownerChain?.root==="declared"&&(f.runtimeOwner=p.ownerChain.entity),t.push(f),(n[c]??=[]).push(d),(i[c]??=[]).push(d)}t.sort((c,u)=>c.id.localeCompare(u.id));for(let c of Object.values(n))c.sort();for(let c of Object.values(i))c.sort();let r={};Object.keys(n).length&&(r.byLexicon=ih(n)),Object.keys(i).length&&(r.byStack=ih(i));let o=new Set(t.map(c=>c.id)),s=new Set,a=[];for(let c of e)for(let u of c.edges??[]){if(!o.has(u.from)||!o.has(u.to))continue;let d=`${u.from}\0${u.to}\0${u.viaAttr??""}\0${u.toAttr??""}`;s.has(d)||(s.add(d),a.push(u))}a.sort((c,u)=>c.from.localeCompare(u.from)||c.to.localeCompare(u.to)||(c.viaAttr??"").localeCompare(u.viaAttr??""));let l=[];for(let c of e)for(let[u,d]of Object.entries(c.stackExports??{}))for(let[p,f]of Object.entries(d))l.push({name:p,value:f,stack:u});return l.sort((c,u)=>c.name.localeCompare(u.name)||(c.stack??"").localeCompare(u.stack??"")),{nodes:t,edges:a,groups:r,...l.length>0?{exports:l}:{}}}function kRe(e){let t={};for(let n of e)Object.assign(t,n.unobserved??{});return t}function Rl(e,t,n){return{...e,attrs:{...e.attrs,_status:t,...n?{_unobserved:n.reason}:{}}}}function xRe(e,t,n){let i=new Set(t.nodes.map(a=>a.id)),r=new Set(e.nodes.map(a=>a.id)),o=n?.unobserved??{},s=e.nodes.map(a=>Rl(a,i.has(a.id)?"good":a.runtimeOwner?"runtime":"warn"));for(let a of t.nodes){if(r.has(a.id))continue;let l=o[a.id];s.push(l?Rl(a,"neutral",l):Rl(a,"accent"))}return s.sort((a,l)=>a.id.localeCompare(l.id)),{...e,nodes:s}}function $Re(e,t,n){let i=new Map(t.nodes.map(p=>[p.id,p])),r=new Set(e.nodes.map(p=>p.id)),o=new Set(t.nodes.filter(p=>!r.has(p.id)).map(p=>p.id)),s=n?.unobserved??{},a=e.nodes.map(p=>{let f=i.get(p.id);if(!f){let h=s[p.id];return h?Rl(p,"neutral",h):Rl(p,"accent")}let g={...p};return f.physicalId&&(g.physicalId=f.physicalId),f.ownership&&(g.ownership=f.ownership),f.attrs&&Object.keys(f.attrs).length>0&&(g.attrs={...p.attrs,...f.attrs}),Rl(g,"good")});for(let p of t.nodes)o.has(p.id)&&a.push(Rl(p,p.runtimeOwner?"runtime":"warn"));a.sort((p,f)=>p.id.localeCompare(f.id));let l=new Set(e.edges.map($l)),c=[...e.edges];for(let p of t.edges){if(!(o.has(p.from)||o.has(p.to)))continue;let f=$l(p);l.has(f)||(l.add(f),c.push(p))}c.sort((p,f)=>$l(p).localeCompare($l(f)));let u=t.exports??[],d=e.exports;if(u.length>0){let p=new Map(u.map(g=>[g.name,g])),f=(e.exports??[]).map(g=>{let h=p.get(g.name);return h?(p.delete(g.name),{...g,value:h.value,...h.stack?{stack:h.stack}:{}}):g});for(let g of p.values())f.push(g);f.sort((g,h)=>g.name.localeCompare(h.name)),d=f}return{...e,nodes:a,edges:c,...d?{exports:d}:{}}}var Rx,bRe,oh=v(()=>{"use strict";Wt();Pn();bl();ui();Xo();Rx=1;bRe=new Set(["lexicon","entityType","kind","attributes","Ref","references","stack"])});var T9=v(()=>{"use strict"});var D9=v(()=>{"use strict"});var N9=v(()=>{"use strict"});var j9=v(()=>{"use strict"});var L9=v(()=>{"use strict"});import{readFile as RRe}from"node:fs/promises";function F9(e){return e instanceof Error&&e.message===M9}async function B9(e){let t=new Set;for(let n of e){let i;try{i=await RRe(n,"utf-8")}catch{continue}let r=/(?:import|export)\s+[\s\S]*?\s+from\s+['"]@intentius\/chant-lexicon-([a-z][\w-]*)(?:\/[^'"\s]*)?['"]/g;for(let o of i.matchAll(r))t.add(o[1])}if(t.size===0)throw new Error(M9);return Array.from(t)}var M9,zN=v(()=>{"use strict";M9="No lexicon detected in infrastructure files"});var UN,G9=v(()=>{"use strict";UN=Le(Ke(),1)});var W9=v(()=>{"use strict"});var Sx,Ex=v(()=>{"use strict";Sx=Le(Ke(),1)});var sh,HN=v(()=>{"use strict";sh=Le(Ke(),1);Ex()});var za,VN=v(()=>{"use strict";za=Le(Ke(),1)});var qN,KN=v(()=>{"use strict";qN=Le(Ke(),1);Ex()});var U9,JN=v(()=>{"use strict";U9=Le(Ke(),1)});var ah,ZN=v(()=>{"use strict";ah=Le(Ke(),1)});var Sl,YN=v(()=>{"use strict";Sl=Le(Ke(),1)});var Ax,XN=v(()=>{"use strict";Ax=Le(Ke(),1)});var El,QN=v(()=>{"use strict";El=Le(Ke(),1);Ex()});var ap,ej=v(()=>{"use strict";ap=Le(Ke(),1)});var Px,tj=v(()=>{"use strict";Px=Le(Ke(),1)});var ch,nj=v(()=>{"use strict";ch=Le(Ke(),1)});var lh,Ua=v(()=>{"use strict";lh=Le(Ke(),1)});var ij,oj=v(()=>{"use strict";ij=Le(Ke(),1);Ua();hl()});var pi,R4e,sj=v(()=>{"use strict";pi=Le(Ke(),1),R4e=new Set([pi.SyntaxKind.IfStatement,pi.SyntaxKind.ForStatement,pi.SyntaxKind.ForInStatement,pi.SyntaxKind.ForOfStatement,pi.SyntaxKind.WhileStatement,pi.SyntaxKind.DoStatement,pi.SyntaxKind.SwitchStatement,pi.SyntaxKind.TryStatement])});var H9,aj=v(()=>{"use strict";H9=Le(Ke(),1);hl()});var fi,cj=v(()=>{"use strict";fi=Le(Ke(),1);Ua()});var uh,lj=v(()=>{"use strict";uh=Le(Ke(),1)});var zr,uj=v(()=>{"use strict";zr=Le(Ke(),1)});var ar,dj=v(()=>{"use strict";ar=Le(Ke(),1);Ua()});var pj,fj=v(()=>{"use strict";pj=Le(Ke(),1);Ua()});var Ha,mj=v(()=>{"use strict";Ha=Le(Ke(),1)});var dh,gj=v(()=>{"use strict";dh=Le(Ke(),1);Ua()});var _o,hj=v(()=>{"use strict";_o=Le(Ke(),1);Ua()});var Al,yj=v(()=>{"use strict";Al=Le(Ke(),1)});var Pl,Ox=v(()=>{"use strict";Pl=Le(Ke(),1)});var Hi,bj=v(()=>{"use strict";Hi=Le(Ke(),1);Ox()});var PRe,wj=v(()=>{"use strict";PRe=Le(Ke(),1)});var V9=v(()=>{"use strict";HN();VN();KN();JN();ZN();YN();XN();QN();ej();tj();nj();oj();sj();aj();cj();lj();uj();dj();fj();mj();gj();hj();yj();Ox();bj();wj();Ua();HN();VN();KN();JN();ZN();YN();XN();QN();ej();tj();nj();oj();sj();aj();cj();lj();uj();dj();fj();mj();gj();hj();yj();Ox();bj();wj()});function Ol(e,t){let n=[];function i(r){t(r)&&n.push(r),Ft.forEachChild(r,i)}return i(e),n}function q9(e){return Ol(e,t=>Ft.isNewExpression(t))}function nSe(e){return q9(e)}function rSe(e){return Ol(e,t=>Ft.isStringLiteral(t))}function iSe(e){return Ol(e,t=>Ft.isVariableStatement(t)?t.modifiers?.some(n=>n.kind===Ft.SyntaxKind.ExportKeyword)??!1:Ft.isFunctionDeclaration(t)||Ft.isClassDeclaration(t)?t.modifiers?.some(n=>n.kind===Ft.SyntaxKind.ExportKeyword)??!1:!1)}function oSe(e){return Ol(e,t=>!!Ft.isImportDeclaration(t))}function sSe(e){return Ol(e,t=>Ft.isPropertyAssignment(t))}function aSe(e){return Ol(e,t=>!!(Ft.isNewExpression(t)&&t.typeArguments&&t.typeArguments.length>0))}function cSe(e){return Ol(e,t=>!Ft.isVariableStatement(t)||!(t.modifiers?.some(i=>i.kind===Ft.SyntaxKind.ExportKeyword)??!1)?!1:t.declarationList.flags===Ft.NodeFlags.Const||(t.declarationList.flags&Ft.NodeFlags.Const)!==0)}var Ft,tSe,lSe,vj=v(()=>{"use strict";Ft=Le(Ke(),1),tSe=new Map;lSe=[["resource",q9],["any-resource",nSe],["string-literal",rSe],["export-name",iSe],["import-source",oSe],["property",sSe],["resource-type",aSe],["exported-const",cSe]];for(let[e,t]of lSe)tSe.set(e,t)});var kj=v(()=>{"use strict"});var K9=v(()=>{"use strict";vj();kj()});function fSe(e){if(e===null)return!1;let t=e.length,n=0,i=!1;if(!t)return!1;let r=e[n];if((r==="-"||r==="+")&&(r=e[++n]),r==="0"){if(n+1===t)return!0;r=e[++n];let o={b:s=>s===48||s===49,x:uSe,o:dSe}[r];if(o){for(n++;n<t;n++){if(!o(e.charCodeAt(n)))return!1;i=!0}return i&&isFinite(xj(e))}}for(;n<t;n++){if(!pSe(e.charCodeAt(n)))return!1;i=!0}return i?isFinite(xj(e)):!1}function xj(e){let t=e,n=1,i=t[0];if((i==="-"||i==="+")&&(i==="-"&&(n=-1),t=t.slice(1),i=t[0]),t==="0")return 0;if(i==="0"){if(t[1]==="b")return n*parseInt(t.slice(2),2);if(t[1]==="x")return n*parseInt(t.slice(2),16);if(t[1]==="o")return n*parseInt(t.slice(2),8)}return n*parseInt(t,10)}function hSe(e){return e===null||!mSe.test(e)?!1:isFinite(parseFloat(e,10))?!0:gSe.test(e)}function J9(e){switch(e){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return`
222
+ `;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"\x85";case 95:return"\xA0";case 76:return"\u2028";case 80:return"\u2029";default:return""}}var Z9,uSe,dSe,pSe,Y9,mSe,gSe,X9,Q9,e3,t3,ySe,bSe,n3=v(()=>{"use strict";Z9={tag:"tag:yaml.org,2002:null",kind:"scalar",resolve:e=>e===null||e==="~"||e==="null"||e==="Null"||e==="NULL",construct:()=>null},uSe=e=>e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102,dSe=e=>e>=48&&e<=55,pSe=e=>e>=48&&e<=57;Y9={tag:"tag:yaml.org,2002:int",kind:"scalar",resolve:fSe,construct:xj},mSe=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),gSe=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");X9={tag:"tag:yaml.org,2002:float",kind:"scalar",resolve:hSe,construct:e=>{let t=e.toLowerCase(),n=t[0]==="-"?-1:1;return"+-".indexOf(t[0])>=0&&(t=t.slice(1)),t===".inf"?n===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:t===".nan"?NaN:n*parseFloat(t,10)}},Q9={tag:"tag:yaml.org,2002:str",kind:"scalar",construct:e=>e!==null?e:""},e3={tag:"tag:yaml.org,2002:seq",kind:"sequence",construct:e=>e!==null?e:[]},t3={tag:"tag:yaml.org,2002:map",kind:"mapping",construct:e=>e!==null?e:{}};for(let e of[Z9,Y9,X9,Q9,e3,t3])e.resolve??=()=>!0;ySe=new Array(256),bSe=new Array(256);for(let e=0;e<256;e++)ySe[e]=J9(e)?1:0,bSe[e]=J9(e)});var $j=v(()=>{"use strict";n3()});var Rj=v(()=>{"use strict";$j()});var Cx=v(()=>{"use strict";Rj();Rj()});var r3=v(()=>{"use strict";Kt();cp()});function Sj(e,t){for(let[n,i]of Object.entries(t)){let r=e[n];if(!r)throw new Error(`audit lineage names ${n}, which this catalog does not define`);i.length>0&&(r.lineage=i)}}var Ej=v(()=>{"use strict"});var s3,a3=v(()=>{"use strict";s3={AGT002:[{tool:"agent-audit",rule:"auth-bypass/env-secret-in-config",url:"https://raw.githubusercontent.com/piiiico/agent-audit/main/README.md",relation:"equivalent"},{tool:"mcp-audit",rule:"Secrets Detection",url:"https://raw.githubusercontent.com/apisec-inc/mcp-audit/main/README.md",relation:"overlaps"},{tool:"agent-scan",rule:"W008",url:"https://raw.githubusercontent.com/invariantlabs-ai/mcp-scan/main/docs/issue-codes.md",relation:"overlaps"}],COR020:[{tool:"cfn-lint",rule:"E3004",url:"https://github.com/aws-cloudformation/cfn-lint/blob/main/docs/rules.md#E3004",relation:"equivalent"}],EXT001:[{tool:"cfn-lint",url:"https://github.com/aws-cloudformation/cfn-lint/blob/main/docs/cfn-schema-specification.md#extending-the-schemas-with-new-keywords",relation:"equivalent"},{tool:"cfn-lint",rule:"E3014",url:"https://github.com/aws-cloudformation/cfn-lint/blob/main/docs/rules.md#E3014",relation:"equivalent"},{tool:"cfn-lint",rule:"E3021",url:"https://github.com/aws-cloudformation/cfn-lint/blob/main/docs/rules.md#E3021",relation:"equivalent"}],NGX001:[{tool:"gixy-ng",rule:"weak_ssl_tls",url:"https://gixy.getpagespeed.com/plugins/weak_ssl_tls/",relation:"overlaps"}],NGX002:[{tool:"gixy-ng",rule:"weak_ssl_tls",url:"https://gixy.getpagespeed.com/plugins/weak_ssl_tls/",relation:"overlaps"}],NGX004:[{tool:"gixy",rule:"alias_traversal",url:"https://github.com/yandex/gixy",relation:"equivalent"},{tool:"gixy-ng",rule:"alias_traversal",url:"https://gixy.getpagespeed.com/plugins/aliastraversal/",relation:"equivalent"}],NGX005:[{tool:"gixy-ng",rule:"status_page_exposed",url:"https://gixy.getpagespeed.com/checks/status-page-exposed/",relation:"overlaps"}],NGX006:[{tool:"gixy-ng",rule:"version_disclosure",url:"https://gixy.getpagespeed.com/plugins/version_disclosure/",relation:"equivalent"}],SEC001:[{tool:"gitleaks",rule:"aws-access-token",url:"https://github.com/gitleaks/gitleaks/blob/master/config/gitleaks.toml",relation:"equivalent"},{tool:"trufflehog",rule:"aws",url:"https://github.com/trufflesecurity/trufflehog/blob/main/pkg/detectors/aws/access_keys/accesskey.go",relation:"overlaps"},{tool:"detect-secrets",rule:"AWSKeyDetector",url:"https://github.com/Yelp/detect-secrets/blob/master/detect_secrets/plugins/aws.py",relation:"equivalent"}],SEC002:[{tool:"gitleaks",rule:"generic-api-key",url:"https://github.com/gitleaks/gitleaks/blob/master/config/gitleaks.toml",relation:"overlaps"},{tool:"trufflehog",rule:"aws",url:"https://github.com/trufflesecurity/trufflehog/blob/main/pkg/detectors/aws/access_keys/accesskey.go",relation:"overlaps"},{tool:"detect-secrets",rule:"AWSKeyDetector",url:"https://github.com/Yelp/detect-secrets/blob/master/detect_secrets/plugins/aws.py",relation:"overlaps"}],SEC003:[{tool:"gitleaks",rule:"github-pat",url:"https://github.com/gitleaks/gitleaks/blob/master/config/gitleaks.toml",relation:"overlaps"},{tool:"trufflehog",rule:"github",url:"https://github.com/trufflesecurity/trufflehog/blob/main/pkg/detectors/github/v2/github.go",relation:"equivalent"},{tool:"detect-secrets",rule:"GitHubTokenDetector",url:"https://github.com/Yelp/detect-secrets/blob/master/detect_secrets/plugins/github_token.py",relation:"overlaps"}],SEC004:[{tool:"gitleaks",rule:"slack-bot-token",url:"https://github.com/gitleaks/gitleaks/blob/master/config/gitleaks.toml",relation:"overlaps"},{tool:"trufflehog",rule:"slack",url:"https://github.com/trufflesecurity/trufflehog/blob/main/pkg/detectors/slack/slack.go",relation:"overlaps"},{tool:"detect-secrets",rule:"SlackDetector",url:"https://github.com/Yelp/detect-secrets/blob/master/detect_secrets/plugins/slack.py",relation:"overlaps"}],SEC005:[{tool:"gitleaks",rule:"gcp-api-key",url:"https://github.com/gitleaks/gitleaks/blob/master/config/gitleaks.toml",relation:"equivalent"},{tool:"trufflehog",rule:"googlegemini",url:"https://github.com/trufflesecurity/trufflehog/blob/main/pkg/detectors/googlegemini/googlegemini.go",relation:"overlaps"}],SEC006:[{tool:"gitleaks",rule:"stripe-access-token",url:"https://github.com/gitleaks/gitleaks/blob/master/config/gitleaks.toml",relation:"overlaps"},{tool:"trufflehog",rule:"stripe",url:"https://github.com/trufflesecurity/trufflehog/blob/main/pkg/detectors/stripe/stripe.go",relation:"overlaps"},{tool:"detect-secrets",rule:"StripeDetector",url:"https://github.com/Yelp/detect-secrets/blob/master/detect_secrets/plugins/stripe.py",relation:"overlaps"}],SEC007:[{tool:"gitleaks",rule:"private-key",url:"https://github.com/gitleaks/gitleaks/blob/master/config/gitleaks.toml",relation:"equivalent"},{tool:"trufflehog",rule:"privatekey",url:"https://github.com/trufflesecurity/trufflehog/blob/main/pkg/detectors/privatekey/privatekey.go",relation:"equivalent"},{tool:"detect-secrets",rule:"PrivateKeyDetector",url:"https://github.com/Yelp/detect-secrets/blob/master/detect_secrets/plugins/private_key.py",relation:"equivalent"}],SEC008:[{tool:"gitleaks",rule:"curl-auth-header",url:"https://github.com/gitleaks/gitleaks/blob/master/config/gitleaks.toml",relation:"overlaps"}],SEC009:[{tool:"detect-secrets",rule:"BasicAuthDetector",url:"https://github.com/Yelp/detect-secrets/blob/master/detect_secrets/plugins/basic_auth.py",relation:"equivalent"},{tool:"trufflehog",rule:"uri",url:"https://github.com/trufflesecurity/trufflehog/blob/main/pkg/detectors/uri/uri.go",relation:"overlaps"},{tool:"gitleaks",rule:"curl-auth-user",url:"https://github.com/gitleaks/gitleaks/blob/master/config/gitleaks.toml",relation:"overlaps"}],SEC010:[{tool:"detect-secrets",rule:"Base64HighEntropyString",url:"https://github.com/Yelp/detect-secrets/blob/master/detect_secrets/plugins/high_entropy_strings.py",relation:"overlaps"},{tool:"detect-secrets",rule:"HexHighEntropyString",url:"https://github.com/Yelp/detect-secrets/blob/master/detect_secrets/plugins/high_entropy_strings.py",relation:"overlaps"},{tool:"gitleaks",rule:"generic-api-key",url:"https://github.com/gitleaks/gitleaks/blob/master/config/gitleaks.toml",relation:"overlaps"}],TF023:[{tool:"hashicorp-style-guide",rule:".gitignore: do not commit terraform.tfstate, terraform.tfstate.* backups, or the .terraform directory",url:"https://developer.hashicorp.com/terraform/language/style#gitignore",relation:"equivalent"}]}});function It(e,t,n,i,r,o,s){let a=o&&o.length>0?"security":u3[e]??"best-practice";return{id:e,tier:t,fixKind:n,category:a,title:i,remediation:r,authority:o,...s?.length?{lineage:s}:{},yamlBased:!0}}function Va(e,t,n,i,r){let o=r&&r.length>0?"security":u3[e]??"best-practice";return{id:e,tier:t,fixKind:Ot,category:o,title:n,remediation:i,authority:r,yamlBased:!1}}var c3,Io,kSe,xSe,$Se,RSe,SSe,l3,ESe,ASe,PSe,OSe,CSe,_Se,Rt,lp,Ot,u3,ISe,d3=v(()=>{"use strict";Ej();a3();Ej();c3={name:"OSSF Scorecard \u2014 Pinned-Dependencies",url:"https://github.com/ossf/scorecard/blob/main/docs/checks.md#pinned-dependencies"},Io={name:"GitHub \u2014 About secret scanning",url:"https://docs.github.com/en/code-security/secret-scanning/introduction/about-secret-scanning"},kSe={name:"Cloudflare Workers \u2014 workers.dev",url:"https://developers.cloudflare.com/workers/configuration/routing/workers-dev/"},xSe={name:"Cloudflare Workers \u2014 Secrets",url:"https://developers.cloudflare.com/workers/configuration/secrets/"},$Se={name:"Cloudflare Workers \u2014 Routes",url:"https://developers.cloudflare.com/workers/configuration/routing/routes/"},RSe={name:"Cloudflare Workers \u2014 Wrangler environments",url:"https://developers.cloudflare.com/workers/wrangler/configuration/#environments"},SSe={name:"Cloudflare Workers \u2014 Static assets",url:"https://developers.cloudflare.com/workers/static-assets/"},l3={name:"Mozilla \u2014 Server Side TLS",url:"https://wiki.mozilla.org/Security/Server_Side_TLS"},ESe={name:"CWE-548 \u2014 Exposure of Information Through Directory Listing",url:"https://cwe.mitre.org/data/definitions/548.html"},ASe={name:"Gixy \u2014 alias traversal",url:"https://github.com/yandex/gixy/blob/master/docs/en/plugins/aliastraversal.md"},PSe={name:"nginx \u2014 ngx_http_stub_status_module",url:"https://nginx.org/en/docs/http/ngx_http_stub_status_module.html"},OSe={name:"CWE-798 \u2014 Use of Hard-coded Credentials",url:"https://cwe.mitre.org/data/definitions/798.html"},CSe={name:"HashiCorp Terraform style guide \u2014 .gitignore",url:"https://developer.hashicorp.com/terraform/language/style#gitignore"},_Se={name:"CWE-319 \u2014 Cleartext Transmission of Sensitive Information",url:"https://cwe.mitre.org/data/definitions/319.html"};Rt="merge-worthy",lp="report-only",Ot="guidance";u3={COR020:"correctness",EXT001:"correctness",SEC001:"security",SEC002:"security",SEC003:"security",SEC004:"security",SEC005:"security",SEC006:"security",SEC007:"security",SEC008:"security",SEC009:"security",SEC010:"security",WRG001:"security",WRG002:"security",WRG003:"best-practice",WRG004:"security",WRG005:"security",WRG006:"security",NGX001:"security",NGX002:"security",NGX003:"security",NGX004:"security",NGX005:"security",NGX006:"best-practice",NGX007:"best-practice",TF023:"security",AGT001:"security",AGT002:"security",AGT003:"security",AGT004:"security",AGT005:"security",AGT006:"best-practice",AGT007:"correctness",AGT008:"best-practice"},ISe={COR020:It("COR020",Rt,Ot,"Circular resource dependency","Break the dependency cycle between resources."),EXT001:It("EXT001",Rt,Ot,"Extension constraint violation","Fix the cross-property constraint flagged by the cfn-lint extension schema."),SEC001:It("SEC001",Rt,Ot,"AWS access key ID found","Remove the key from source, rotate it in IAM, and load it from a secret store or environment variable instead.",[Io]),SEC002:It("SEC002",Rt,Ot,"AWS secret access key found","Remove the key from source, rotate it in IAM, and load it from a secret store or environment variable instead.",[Io]),SEC003:It("SEC003",Rt,Ot,"GitHub token found","Remove the token from source and revoke it at github.com/settings/tokens; use a GitHub Actions secret instead.",[Io]),SEC004:It("SEC004",Rt,Ot,"Slack token found","Remove the token from source and revoke it in the Slack app's OAuth settings.",[Io]),SEC005:It("SEC005",Rt,Ot,"Google API key found","Remove the key from source and regenerate it in the Google Cloud Console credentials page.",[Io]),SEC006:It("SEC006",Rt,Ot,"Stripe live secret key found","Remove the key from source and roll it in the Stripe dashboard immediately \u2014 this is a live-mode key.",[Io]),SEC007:It("SEC007",Rt,Ot,"Private key block found","Remove the private key from source, rotate the keypair, and load the key from a secret store instead.",[Io]),SEC008:It("SEC008",Rt,Ot,"Bearer/authorization token found","Remove the token from source; if it's long-lived, revoke and reissue it via the issuing service.",[Io]),SEC009:It("SEC009",Rt,Ot,"Credentials embedded in a connection string","Move the username/password out of the URI into a secret store, and rotate the credential.",[Io]),SEC010:It("SEC010",Rt,Ot,"High-entropy string \u2014 possible secret","Confirm whether this is a live credential; if so, remove it from source and rotate it. If it's a false positive, suppress with a `chant-audit-ignore` comment or an allowlist entry.",[Io]),WRG001:It("WRG001",Rt,Ot,"Production environment exposed on *.workers.dev","Remove workers_dev (or set it to false) for this environment and rely on its custom domain/route instead of the shared public subdomain.",[kSe]),WRG002:It("WRG002",Rt,Ot,"Credential-shaped key stored in [vars]","Move the value out of [vars] and into `wrangler secret put <name>` so it isn't committed to source or visible in `wrangler dev`/the dashboard.",[xSe]),WRG003:It("WRG003",lp,Ot,"Observability explicitly disabled","Set observability.enabled = true (or remove the override) so Workers Logs are recorded for this deployment."),WRG004:It("WRG004",Rt,Ot,"Unscoped wildcard route",'Scope the route pattern to the intended zone (e.g. "example.com/*") instead of a bare "*" or "*/*" that matches every zone on the account.',[$Se]),WRG005:It("WRG005",Rt,Ot,"Non-production environment shares a data store with production","Give the non-production environment its own KV namespace/R2 bucket/D1 database id instead of reusing production's.",[RSe]),WRG006:It("WRG006",Rt,Ot,"Static assets served from the project root","Point [site].bucket / [assets].directory at a dedicated public output folder, not the project root, so non-public files (config, source maps, .git) aren't served.",[SSe]),NGX001:It("NGX001",Rt,Ot,"Deprecated TLS protocol enabled","Remove SSLv2/SSLv3/TLSv1/TLSv1.1 from ssl_protocols and serve TLSv1.2 and TLSv1.3 only.",[l3]),NGX002:It("NGX002",Rt,Ot,"Weak cipher suite enabled","Remove the RC4/DES/MD5/NULL/EXPORT-class entries from ssl_ciphers and use a modern cipher list (e.g. Mozilla's intermediate configuration).",[l3]),NGX003:It("NGX003",Rt,Ot,"Directory listing enabled","Remove `autoindex on` (or scope it to a directory that is genuinely meant to be enumerated) so file listings aren't served to anyone who asks.",[ESe]),NGX004:It("NGX004",Rt,Ot,"alias path traversal",'End the location prefix with "/" so it matches the trailing slash of the alias target \u2014 without it, a request for "<prefix>../" escapes the aliased directory.',[ASe]),NGX005:It("NGX005",Rt,Ot,"Status endpoint with no access restriction","Restrict the stub_status location with allow/deny (or auth_basic/auth_request) so connection metrics aren't public reconnaissance.",[PSe]),NGX006:It("NGX006",lp,Ot,"Server version disclosure","Add `server_tokens off;` in the http block so nginx stops advertising its exact version in the Server header and error pages."),NGX007:It("NGX007",lp,Ot,"Access logging disabled at server scope","Re-enable access_log at http/server scope (silencing a single noisy location is fine) so requests are recorded for incident investigation."),TF023:It("TF023",Rt,Ot,"Terraform state committed to the repository","Delete the state file (or `.terraform/`) from version control, add it to .gitignore, move the state to a remote backend, and rotate every credential the file held.",[CSe]),AGT001:Va("AGT001",Rt,"MCP server runs an unpinned package","Pin the package spec to an exact version (`server@1.2.3`), so a new upstream release can't execute on this machine unreviewed.",[c3]),AGT002:Va("AGT002",Rt,"Literal credential in agent config","Replace the value with an environment reference (`${TOKEN}`) and keep the secret in a secret store \u2014 agent config files sync, back up, and get shared.",[OSe]),AGT003:Va("AGT003",Rt,"MCP server reached over cleartext HTTP","Use an https:// endpoint. Tool arguments and results \u2014 including data the agent read locally \u2014 otherwise cross the network in the clear.",[_Se]),AGT004:Va("AGT004",Rt,"Remote skill or plugin is unpinned","Pin the source to a tag or commit sha, so the instructions the agent follows can't change upstream without a local edit.",[c3]),AGT005:Va("AGT005",Rt,"Tool permission granted without constraint","Scope the grant to the specific commands you run (`Bash(git status:*)`), and re-enable the confirmation prompt for dangerous operations."),AGT006:Va("AGT006",lp,"User-scope config applies to every project","Move project-specific instructions, MCP servers, and skills to that project's own config so they don't follow you into unrelated repos."),AGT007:Va("AGT007",lp,"MCP server declared in multiple files","Delete the shadowed declarations. The harness silently picks one, so the file you read may not be the one that decides what runs."),AGT008:Va("AGT008",lp,"Instruction file exceeds the attention budget","Move situational guidance into skills that load on demand, so the always-on instructions stay short enough to be followed reliably.")};Sj(ISe,s3)});var f3,p3=v(()=>{f3={rules:{COR001:"error",COR002:"error",COR003:"warning",COR004:"warning",COR005:"warning",COR006:"error",COR007:"warning",COR008:"error",COR009:"warning",COR010:"warning",COR011:"error",COR012:"warning",COR013:"info",COR014:"warning",COR015:"warning",COMP001:"error",COMP002:"error",COMP003:"error",COMP004:"error",COMP005:"error",COMP006:"error",COMP007:"warning"}}});import{join as OZe,dirname as CZe,resolve as m3}from"path";var jZe,g3,h3,LZe,MZe,y3=v(()=>{"use strict";Ln();RO();to();d3();p3();Ri();jZe={"@intentius/chant/lint/presets/strict":m3(HO(import.meta.url),"presets/strict.json"),"@intentius/chant/lint/presets/relaxed":m3(HO(import.meta.url),"presets/relaxed.json")},g3=m.enum(["off","error","warning","info"]),h3=m.union([g3,m.tuple([g3,m.record(m.string(),m.unknown())])]),LZe=m.object({rules:m.record(m.string(),h3).optional(),extends:m.array(m.string()).optional(),overrides:m.array(m.object({files:m.array(m.string()),rules:m.record(m.string(),h3)})).optional(),plugins:m.array(m.string()).optional(),policies:m.array(m.string()).optional(),presets:m.record(m.string(),m.string()).optional()}),MZe={rules:{...f3.rules},extends:[]}});var b3=v(()=>{"use strict";Si()});var Aj=v(()=>{"use strict";Kt();Vg();cp();r3();Kn();sp();Cx();y3();b3()});function k3(e){switch(e){case"template":return{basis:"deterministic-synthesis",verifyBy:"re-synth"};case"image":case"asset":return{basis:"best-effort"};case"sbom":return}}var Pj=v(()=>{"use strict"});function x3(e){let t=e.map(n=>({kind:n.kind,path:n.path,digest:n.digest})).sort((n,i)=>n.path<i.path?-1:n.path>i.path?1:0);return Dr($r(t))}function _x(e,t){let n=(t?.now??(()=>new Date))().toISOString();return{version:1,component:e,createdAt:n,contents:[],manifestDigest:x3([])}}function Ix(e,t){let n=t.reproducibility??(t.kind==="image"||t.kind==="template"||t.kind==="asset"||t.kind==="sbom"?k3(t.kind):void 0),i={mediaType:DSe[t.kind],...t,...n?{reproducibility:n}:{}},r=[...e.contents.filter(o=>o.path!==i.path),i];return{...e,contents:r,manifestDigest:x3(r)}}function Oj(e){return e.startsWith("archive:")?e.slice(8):e}var DSe,up=v(()=>{"use strict";Pj();ss();er();DSe={image:"application/vnd.oci.image.layout.v1.tar",template:"application/json",asset:"application/octet-stream",sbom:"application/spdx+json"}});import{exec as NSe}from"node:child_process";import{createConnection as jSe}from"node:net";import{promisify as LSe}from"node:util";import{isAbsolute as MSe,join as FSe}from"node:path";function qa(e){return BSe(e,{maxBuffer:64*1024*1024})}function Sr(e){return`'${e.replace(/'/g,"'\\''")}'`}function zSe(e,t=5e3){let[n,i]=e.split(":"),r=Number(i??7687);return new Promise(o=>{let s=jSe({host:n,port:r,timeout:t}),a=l=>{s.destroy(),o(l)};s.once("connect",()=>a(!0)),s.once("timeout",()=>a(!1)),s.once("error",()=>a(!1))})}function USe(){return{docker:GSe,neo4j:WSe}}function Tx(){return Cj||(Cj=USe()),Cj}function Dx(e){return new Promise(t=>setTimeout(t,e))}var BSe,GSe,WSe,Cj,Nx=v(()=>{"use strict";BSe=LSe(NSe);GSe={async build(e){let t=["docker build",`-t ${Sr(e.tag)}`];if(e.dockerfile){let i=MSe(e.dockerfile)?e.dockerfile:FSe(e.context,e.dockerfile);t.push(`-f ${Sr(i)}`)}e.target&&t.push(`--target ${Sr(e.target)}`);for(let[i,r]of Object.entries(e.buildArgs??{}))t.push(`--build-arg ${Sr(`${i}=${r}`)}`);t.push(Sr(e.context)),await qa(t.join(" "));let{stdout:n}=await qa(`docker image inspect ${Sr(e.tag)} --format '{{.Id}}'`);return{digest:n.trim()}},async save(e){await qa(`docker save ${Sr(e.image)} -o ${Sr(e.outFile)}`)},async load(e){let{stdout:t}=await qa(`docker load -i ${Sr(e.inFile)}`);return{digest:t.match(/[Ll]oaded image(?: ID)?:\s*(\S+)/)?.[1]??t.trim()}},async tag(e){await qa(`docker tag ${Sr(e.source)} ${Sr(e.target)}`)},async push(e){await qa(`docker push ${Sr(e.image)}`);let{stdout:t}=await qa(`docker image inspect ${Sr(e.image)} --format '{{index .RepoDigests 0}}'`);return{digest:t.trim()}},async remoteDigest(e){let{stdout:t}=await qa(`docker manifest inspect -v ${Sr(e)}`);return t.trim()}},WSe={async probe(e){let t=e.cluster.split(",").map(i=>i.trim()).filter(Boolean);return{healthyCount:(await Promise.all(t.map(i=>zSe(i)))).filter(Boolean).length,total:t.length}}}});import{exec as HSe}from"node:child_process";import{promisify as VSe}from"node:util";function Se(e){return`'${e.replace(/'/g,"'\\''")}'`}function KSe(){return qSe}function en(){return _j||(_j=KSe()),_j}async function ln(e,t,n){if(!await e.available(t))throw new ph(t,n)}var $3,qSe,_j,ph,Vi=v(()=>{"use strict";$3=VSe(HSe);qSe={async run(e,t){return $3(e,{cwd:t?.cwd,maxBuffer:t?.maxBuffer??64*1024*1024})},async available(e){try{return await $3(`command -v ${Se(e)}`),!0}catch{return!1}}};ph=class extends Error{constructor(n,i){super(`"${n}" is not installed or not on PATH \u2014 required to ${i}. Install it and retry.`);this.tool=n;this.purpose=i;this.name="ToolNotAvailableError"}}});import{readFileSync as R3}from"node:fs";import{createHash as S3}from"node:crypto";function JSe(e=Tx()){return{kind:"docker-build",async run(t,n){let i=`chant-build/${n.into.replace(/[^a-zA-Z0-9_.-]/g,"-")}:latest`,{digest:r}=await e.docker.build({context:n.context,dockerfile:n.dockerfile,buildArgs:n.buildArgs,target:n.target,tag:i});await e.docker.save({image:i,outFile:n.into});let o=n.manifest??_x(t.component),s=n.sourceRef?{sourceRef:n.sourceRef,artifactDigest:r}:void 0,a=Ix(o,{kind:"image",path:n.into,digest:r,...s?{provenance:s}:{}});return{archivePath:n.into,digest:r,manifest:a}}}}function YSe(e=en()){return{kind:"zip-package",async run(t,n){let i=(n.exclude??[]).map(o=>`-x ${Se(o)}`).join(" ");await e.run(`rm -f ${Se(n.into)} && zip -r -X ${Se(n.into)} ${Se(n.source)}${i?` ${i}`:""}`);let r=`sha256:${S3("sha256").update(R3(n.into)).digest("hex")}`;return{archivePath:n.into,digest:r}}}}function QSe(e=en()){return{kind:"jvm-build",async run(t,n){if(n.tool==="gradle"){let r=(n.goals??["build"]).join(" ");await e.run(`./gradlew -q ${r}`,{cwd:n.path}),await e.run(`cp "$(ls ${Se(n.path)}/build/libs/*.jar | head -1)" ${Se(n.into)}`)}else{let r=(n.goals??["package"]).join(" ");await e.run(`mvn -q -B -f ${Se(`${n.path}/pom.xml`)} ${r}`),await e.run(`cp "$(ls ${Se(`${n.path}/target`)}/*.jar | grep -Ev '(-sources|-javadoc)\\.jar$' | head -1)" ${Se(n.into)}`)}let i=`sha256:${S3("sha256").update(R3(n.into)).digest("hex")}`;return{archivePath:n.into,digest:i}}}}var ZSe,XSe,eEe,E3=v(()=>{"use strict";Nx();Vi();up();ZSe=JSe();XSe=YSe();eEe=QSe()});function tEe(e){return`${Oj(e)}.sbom.json`}async function nEe(e,t,n){switch(t.artifactType){case"image":return e.forImage({imagePath:n,digest:t.digest??"",format:t.format});case"jar":return e.forJar({jarPath:n,digest:t.digest??"",format:t.format});case"zip":return e.forZip({zipPath:n,digest:t.digest??"",format:t.format});case"dir":return e.forDir({path:n,format:t.format})}}function rEe(e=AW()){return{kind:"generate-sbom",async run(t,n){let i=Oj(n.path),r=n.format??Kr,o=await nEe(e,{...n,format:r},i),s=n.into??tEe(n.path),a=Dr(o.bytes),l=n.manifest??_x(t.component),c=Ix(l,{kind:"sbom",path:s,digest:a,mediaType:o.mediaType,subjectDigest:n.digest,packageCount:o.packageCount,generator:o.generator});return{sbom:o,archivePath:s,digest:a,manifest:c}}}}var iEe,A3=v(()=>{"use strict";up();Yo();iEe=rEe()});import{basename as C3,dirname as P3,join as fh}from"node:path";import{existsSync as O3}from"node:fs";function Cl(e,t){try{let n=JSON.parse(t);if(e==="cyclonedx"&&Array.isArray(n.components))return n.components.length;if(e==="spdx"&&Array.isArray(n.packages))return n.packages.length}catch{}}function Lx(e,t,n){let i=e??"/tmp/chant-sbom",r=C3(t).replace(/[^a-zA-Z0-9_.-]/g,"_");return fh(i,`${r}.${Date.now()}.${n}.json`)}function sEe(e={}){let t=e.runner??en();async function n(i,r){await ln(t,"syft",`scan ${i} for a software bill of materials`);let o=Lx(e.workDir,i,r);await t.run(`syft ${Se(i)} -o ${oEe[r]}=${Se(o)}`);let{stdout:s}=await t.run(`cat ${Se(o)}`);return{bytes:s,generator:"syft"}}return{async forImage(i){let r=i.format??Kr,o=P3(i.imagePath);if(O3(fh(o,"Dockerfile"))&&await t.available("docker")){let c=Lx(e.workDir,i.imagePath,r);await t.run(`docker buildx build --sbom=true --output type=local,dest=${Se(c)} ${Se(o)}`);let{stdout:u}=await t.run(`cat ${Se(fh(c,"sbom.spdx.json"))}`);return{format:r,mediaType:Qi[r],bytes:u,packageCount:Cl(r,u),generator:"buildkit"}}let{bytes:a,generator:l}=await n(i.imagePath,r);return{format:r,mediaType:Qi[r],bytes:a,packageCount:Cl(r,a),generator:l}},async forJar(i){let r=i.format??Kr,o=P3(i.jarPath);if(O3(fh(o,"pom.xml"))&&await t.available("mvn")){await ln(t,"mvn",`run cyclonedx-maven against ${o}`);let c=Lx(e.workDir,i.jarPath,"cyclonedx");await t.run(`mvn -f ${Se(fh(o,"pom.xml"))} org.cyclonedx:cyclonedx-maven-plugin:makeAggregateBom -DoutputFormat=json -DoutputName=${Se(C3(c,".json"))}`,{cwd:o});let{stdout:u}=await t.run(`cat ${Se(c)}`);return{format:"cyclonedx",mediaType:Qi.cyclonedx,bytes:u,packageCount:Cl("cyclonedx",u),generator:"cyclonedx-maven"}}let{bytes:a,generator:l}=await n(i.jarPath,r);return{format:r,mediaType:Qi[r],bytes:a,packageCount:Cl(r,a),generator:l}},async forZip(i){let r=i.format??Kr,{bytes:o,generator:s}=await n(i.zipPath,r);return{format:r,mediaType:Qi[r],bytes:o,packageCount:Cl(r,o),generator:s}},async forDir(i){let r=i.format??Kr;if(await t.available("syft")){let{bytes:a,generator:l}=await n(i.path,r);return{format:r,mediaType:Qi[r],bytes:a,packageCount:Cl(r,a),generator:l}}await ln(t,"cdxgen",`scan ${i.path} for a software bill of materials (syft is also unavailable)`);let o=Lx(e.workDir,i.path,jx);await t.run(`cdxgen -o ${Se(o)} ${Se(i.path)}`);let{stdout:s}=await t.run(`cat ${Se(o)}`);return{format:jx,mediaType:Qi[jx],bytes:s,packageCount:Cl(jx,s),generator:"cdxgen"}}}}var oEe,jx,T5e,_3=v(()=>{"use strict";Yo();Vi();oEe={spdx:"spdx-json",cyclonedx:"cyclonedx-json"},jx="cyclonedx";T5e=sEe()});var I3=v(()=>{"use strict";up();Wb();Yo()});function cEe(e){return/@sha256:[0-9a-f]{64}$/i.test(e)}function T3(e,t){if(!cEe(e))throw new Mx(e,t)}function D3(e,t){if(t.key){e.push("--key",Se(t.key.key));return}let n=t.keyless;n?.identityToken&&e.push("--identity-token",Se(n.identityToken)),n?.oidcIssuer&&e.push("--oidc-issuer",Se(n.oidcIssuer)),n?.oidcClientId&&e.push("--oidc-client-id",Se(n.oidcClientId)),n?.fulcioUrl&&e.push("--fulcio-url",Se(n.fulcioUrl)),n?.rekorUrl&&e.push("--rekor-url",Se(n.rekorUrl))}function lEe(e){let t=["cosign","sign","--yes"];D3(t,{keyless:e.keyless,key:e.key});for(let[n,i]of Object.entries(e.annotations??{}))t.push("-a",Se(`${n}=${i}`));return t.push(Se(e.imageRef)),t.join(" ")}function uEe(e=en()){return{kind:"sign",async run(t,n){return T3(n.imageRef,"sign"),await ln(e,"cosign",`sign ${n.imageRef}`),await e.run(lEe(n)),{imageRef:n.imageRef,signed:!0,method:n.key?"key":"keyless"}}}}function N3(e){let t=/sha256:([0-9a-f]{64})$/i.exec(e);if(!t)throw new Mx(e,"attest");return t[1]}function j3(e){let t=N3(e.imageRef);return{_type:"https://in-toto.io/Statement/v1",predicateType:"https://slsa.dev/provenance/v1",subject:[{name:e.imageRef,digest:{sha256:t}}],predicate:{buildDefinition:{buildType:e.buildType??pEe,externalParameters:{...e.externalParameters,sourceRef:e.provenance.sourceRef},internalParameters:{...e.internalParameters,artifactDigest:e.provenance.artifactDigest},resolvedDependencies:[{uri:e.provenance.sourceRef,digest:{sha256:t}}]},runDetails:{builder:{id:e.builderId},metadata:{...e.invocationId?{invocationId:e.invocationId}:{},finishedOn:e.finishedOn??new Date().toISOString()}}}}}function fEe(e,t){let n=["cosign","attest","--yes","--type","slsaprovenance1","--predicate",Se(t)];return D3(n,{keyless:e.keyless,key:e.key}),n.push(Se(e.imageRef)),n.join(" ")}function mEe(e=en()){return{kind:"attest-provenance",async run(t,n){T3(n.imageRef,"attest"),await ln(e,"cosign",`attest SLSA provenance for ${n.imageRef}`);let i=j3(n),r=`/tmp/chant-provenance-attest/${N3(n.imageRef)}-${Date.now()}.json`;return await e.run(`mkdir -p ${Se("/tmp/chant-provenance-attest")}`),await e.run(`printf '%s' ${Se(JSON.stringify(i))} > ${Se(r)}`),await e.run(fEe(n,r)),{imageRef:n.imageRef,statement:i,attested:!0,method:n.key?"key":"keyless"}}}}var Mx,dEe,pEe,gEe,Ij=v(()=>{"use strict";Vi();Mx=class extends Error{constructor(n,i){super(`${i} "${n}": expected a digest reference ("repo@sha256:...", e.g. from a prior publish step's "@Publish.uri") \u2014 signing a mutable tag would not pin which bytes were signed. Pass the digest-qualified reference instead.`);this.ref=n;this.verb=i;this.name="SignTargetNotDigestError"}};dEe=uEe(),pEe="https://chant.dev/build-archive/v1";gEe=mEe()});function L3(e,t){if(t.key){e.push("--key",Se(t.key));return}e.push("--certificate-oidc-issuer",Se(t.expectedIssuer)),e.push(t.identityIsRegexp?"--certificate-identity-regexp":"--certificate-identity",Se(t.expectedIdentity))}function hEe(e){let t=["cosign","verify"];return L3(t,e.policy),t.push(Se(e.imageRef)),t.join(" ")}function yEe(e){let t=["cosign","verify-attestation","--type","slsaprovenance1"];return L3(t,e.policy),t.push(Se(e.imageRef)),t.join(" ")}function bEe(e=en()){return{kind:"verify",async run(t,n){await ln(e,"cosign",`verify ${n.imageRef} against the configured identity policy`);let i=[];try{await e.run(hEe(n))}catch(r){throw new Fx(n.imageRef,"signature",r instanceof Error?r.message:String(r))}if(i.push("signature"),n.requireProvenance!==!1){try{await e.run(yEe(n))}catch(r){throw new Fx(n.imageRef,"provenance",r instanceof Error?r.message:String(r))}i.push("provenance")}return{verified:!0,checked:i}}}}var Fx,wEe,M3=v(()=>{"use strict";Vi();Fx=class extends Error{constructor(n,i,r){super(`verify "${n}": ${i} verification failed \u2014 ${r}`);this.imageRef=n;this.check=i;this.reason=r;this.name="VerificationFailedError"}};wEe=bEe()});function vEe(){let e=t=>async()=>{throw new Tj(t)};return{create:e("create"),checkpoint:e("checkpoint"),exec:e("exec"),restore:e("restore"),destroy:e("destroy"),writeFile:e("writeFile"),readFile:e("readFile")}}function kEe(e=vEe()){let t=new WeakMap;return{kind:"run-agent",rollbackPolicy:"native",async run(n,i){let r=!!i.workspace.spriteName,o=i.workspace.spriteName??SEe(n);r||await e.create({name:o,image:i.workspace.image});let s=i.workspace.checkpointComment??"pre-run",{checkpointId:a}=await e.checkpoint({id:o,comment:s});t.set(i,{spriteId:o,checkpointId:a}),await e.writeFile({id:o,path:mh,content:i.task.prompt,mkdir:!0});let l=new Date().toISOString(),c=await e.exec({id:o,cmd:REe(i.agent)}),u={status:c.exitCode===0?"completed":"failed",exitCode:c.exitCode,startedAt:l,endedAt:new Date().toISOString()},d=await AEe(e,o);!r&&u.status==="completed"&&await e.destroy({id:o});let p=$Ee({agent:i.agent,prompt:i.task.prompt,images:i.task.images,turn:u,stdout:c.stdout,stderr:c.stderr,artifacts:d}),g={sourceRef:i.sourceRef?`${i.sourceRef}@${p}`:p,artifactDigest:d.files[0]?.digest??xEe},h=`${n.component}/run-agent@${p}`;return{spriteId:o,checkpointId:a,turn:u,artifacts:d,provenance:g,attestationRef:h}},async rollback(n,i,r){let o=t.get(i),s=r?.spriteId??o?.spriteId??i.workspace.spriteName;if(!s)return;let a=r?.checkpointId??o?.checkpointId;if(a){await e.restore({id:s,checkpoint:a});return}let l=i.workspace.checkpointComment??"pre-run";await e.restore({id:s,comment:l})}}}function $Ee(e){let t={agent:e.agent,promptDigest:Ka(e.prompt),images:(e.images??[]).map(n=>({mediaType:n.media_type,digest:Ka(n.data)})),status:e.turn.status,exitCode:e.turn.exitCode,stdoutDigest:Ka(e.stdout),stderrDigest:Ka(e.stderr),artifacts:[...e.artifacts.files].sort((n,i)=>n.path<i.path?-1:n.path>i.path?1:0).map(n=>({path:n.path,digest:n.digest})),diffDigest:Ka(e.artifacts.diff??"")};return Ka(JSON.stringify(t))}function REe(e){switch(e){case"claude":return`claude -p "$(cat ${mh})" --output-format json`;case"codex":return`codex exec "$(cat ${mh})"`;case"gemini":return`gemini -p "$(cat ${mh})"`;case"opencode":return`opencode run "$(cat ${mh})"`;default:return e}}function SEe(e){let t=Math.random().toString(36).slice(2,10);return`run-agent-${e.component}-${t}`.replace(/[^a-zA-Z0-9._-]/g,"-")}function EEe(e){return e instanceof Error&&/^sprite .+ read .+: not found$/.test(e.message)}async function AEe(e,t){try{let{content:n}=await e.readFile({id:t,path:F3});return{files:[{path:F3,digest:Ka(n)}]}}catch(n){if(EEe(n))return{files:[]};throw n}}var Tj,mh,F3,Ka,xEe,H5e,B3=v(()=>{"use strict";ss();Ij();Tj=class extends Error{constructor(n){super(`SpriteActivities.${n}: not wired to a real sprite backend yet \u2014 sprite lifecycle wiring is #1942 (epic #1564 phase 2). Inject a real or fake ("sprites-fake"/"sprites-emulator") implementation to exercise "run-agent" end to end.`);this.method=n;this.name="SpriteActivitiesNotWiredError"}};mh="/work/prompt",F3="/work/output",Ka=Dr,xEe=Ka("");H5e=kEe()});function Gx(e,t){return t?`${e}#${t}`:e}function PEe(e){let t=["wrangler","deploy","--config",Se(e.config)];return e.env&&t.push("--env",Se(e.env)),t.join(" ")}function OEe(e,t){let n=["wrangler","versions","list","--config",Se(e),"--json"];return t&&n.push("--env",Se(t)),n.join(" ")}function Dj(e,t,n,i){let r=["wrangler","versions","deploy",Se(`${t}@${n}`),"--config",Se(e),"--yes"];return i&&r.push("--env",Se(i)),r.join(" ")}function _Ee(e){let t=CEe.exec(e);if(!t)throw new Nj(e);return t[1]}async function G3(e,t,n){try{let{stdout:i}=await e.run(OEe(t,n));return JSON.parse(i).find(o=>o.percentage===100)?.id}catch{return}}function IEe(e=en()){let t=new Map;return{kind:"wrangler-deploy",async run(n,i){await ln(e,Bx,`deploy the Worker in ${i.config}`);let r=Gx(i.config,i.env);t.has(r)||t.set(r,await G3(e,i.config,i.env));let{stdout:o}=await e.run(PEe(i));return{versionId:_Ee(o)}},async rollback(n,i){let r=Gx(i.config,i.env),o=t.get(r);o&&(await ln(e,Bx,`roll back the Worker in ${i.config}`),await e.run(Dj(i.config,o,100,i.env)))}}}function DEe(e=en()){let t=new Map;return{kind:"wrangler-versions-promote",async run(n,i){await ln(e,Bx,`promote version ${i.versionId} in ${i.config}`);let r=i.percentage??100,o=Gx(i.config,i.env);return t.has(o)||t.set(o,await G3(e,i.config,i.env)),await e.run(Dj(i.config,i.versionId,r,i.env)),{versionId:i.versionId,percentage:r}},async rollback(n,i){let r=Gx(i.config,i.env),o=t.get(r);o&&(await ln(e,Bx,`roll back version promotion in ${i.config}`),await e.run(Dj(i.config,o,100,i.env)))}}}var Bx,Nj,CEe,TEe,NEe,W3=v(()=>{"use strict";Vi();Bx="wrangler";Nj=class extends Error{constructor(n){super(`wrangler-deploy: could not find a Version ID in wrangler's output. Got:
223
+ ${n}`);this.stdout=n;this.name="WranglerVersionIdNotFoundError"}},CEe=/Version(?: ID)?:\s*([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})/;TEe=IEe();NEe=DEe()});function MEe(e,t="r2"){let n=LEe.exec(e);if(!n)throw new jj(e);let[,i,r]=n;return`${t}:${i}${r?`/${r}`:""}`}function FEe(e){let t=MEe(e.to,e.remote);return`rclone ${e.delete?"sync":"copy"} ${Se(e.from)} ${Se(t)} -v`}function zEe(e){let t=(e.match(BEe)??[]).length+(e.match(GEe)??[]).length,n=(e.match(WEe)??[]).length;return{uploaded:t,deleted:n}}function UEe(e=en()){return{kind:"r2-sync",rollbackPolicy:"needs-opt-out",async run(t,n){await ln(e,jEe,`sync ${n.from} to ${n.to}`);let{stdout:i}=await e.run(FEe(n));return zEe(i)}}}var jEe,LEe,jj,BEe,GEe,WEe,HEe,z3=v(()=>{"use strict";Vi();jEe="rclone",LEe=/^r2:\/\/([^/]+)(?:\/(.*))?$/,jj=class extends Error{constructor(n){super(`r2-sync: destination "${n}" is not an "r2://bucket[/prefix]" URI \u2014 mirror s3-sync's "s3://bucket/prefix" shape.`);this.to=n;this.name="R2SyncInvalidDestinationError"}};BEe=/: Copied \(new\)/g,GEe=/: Copied \(replaced existing\)/g,WEe=/: Deleted$/gm;HEe=UEe()});import{readFileSync as X5e,writeFileSync as VEe}from"node:fs";import{tmpdir as qEe}from"node:os";import{join as KEe}from"node:path";import{createHash as JEe}from"node:crypto";function U3(e){let t=(e??"").toLowerCase();return t==="critical"||t==="high"||t==="medium"||t==="low"||t==="negligible"?t:"unknown"}function ZEe(e){return(JSON.parse(e).matches??[]).map(n=>{let i=n.vulnerability?.fix?.versions??[],r=n.vulnerability?.epss?.[0],o=n.vulnerability?.knownExploited?.[0];return{cveId:n.vulnerability?.id??"UNKNOWN",severity:U3(n.vulnerability?.severity),package:n.artifact?.name??"unknown",installedVersion:n.artifact?.version??"",fixedVersion:i[0],fixable:n.vulnerability?.fix?.state==="fixed"||i.length>0,epss:r?.epss,epssPercentile:r?.percentile,inKev:o?!0:void 0,kevDateAdded:o?.dateAdded,kevDueDate:o?.dueDate,kevRansomware:o?.knownRansomwareCampaignUse?.toLowerCase()==="known"?!0:void 0}})}function YEe(e){let t=JSON.parse(e),n=[];for(let i of t.Results??[])for(let r of i.Vulnerabilities??[])n.push({cveId:r.VulnerabilityID??"UNKNOWN",severity:U3(r.Severity),package:r.PkgName??"unknown",installedVersion:r.InstalledVersion??"",fixedVersion:r.FixedVersion||void 0,fixable:!!r.FixedVersion});return n}function XEe(e="grype",t=en()){return{async scan(n){await ln(t,e,"scan the SBOM for known vulnerabilities");let i=JEe("sha256").update(n.sbom.bytes).digest("hex").slice(0,16),r=n.sbom.format==="cyclonedx"?"cdx.json":"spdx.json",o=KEe(qEe(),`chant-scan-${i}.${r}`);if(VEe(o,n.sbom.bytes),e==="trivy"){let{stdout:a}=await t.run(`trivy sbom --quiet --format json ${Se(o)}`);return YEe(a)}let{stdout:s}=await t.run(`grype sbom:${Se(o)} -o json`);return ZEe(s)}}}function QEe(e=en()){return{async scan(t){let n=await e.available("grype")?"grype":await e.available("trivy")?"trivy":void 0;if(!n)throw new ph("grype or trivy","scan the SBOM for known vulnerabilities");return XEe(n,e).scan(t)}}}function Mj(){return Lj||(Lj=QEe()),Lj}function eAe(e=Mj()){return{kind:"scan-vulnerabilities",async run(t,n){return{findings:await e.scan({sbom:n.sbom,digest:n.digest}),digest:n.digest}}}}var Wx,Lj,tAe,Fj=v(()=>{"use strict";Vi();Wx={critical:5,high:4,medium:3,low:2,negligible:1,unknown:0};tAe=eAe()});function nAe(e){return e==="not_affected"||e==="fixed"}function rAe(e){switch((e??"").toLowerCase()){case"not_affected":return"not_affected";case"affected":return"affected";case"fixed":return"fixed";case"under_investigation":return"under_investigation";default:return}}function iAe(e){let t=JSON.parse(e),n=[];for(let i of t.statements??[]){let r=typeof i.vulnerability=="string"?i.vulnerability:i.vulnerability?.name??i.vulnerability?.["@id"],o=rAe(i.status);!r||!o||n.push({cveId:r,status:o,justification:i.justification??i.impact_statement})}return n}function oAe(e){switch((e??"").toLowerCase()){case"not_affected":case"false_positive":return"not_affected";case"resolved":case"resolved_with_pedigree":return"fixed";case"exploitable":return"affected";case"in_triage":return"under_investigation";default:return}}function sAe(e){let t=JSON.parse(e),n=[];for(let i of t.vulnerabilities??[]){let r=oAe(i.analysis?.state);!i.id||!r||n.push({cveId:i.id,status:r,justification:i.analysis?.justification??i.analysis?.detail})}return n}function H3(e){let t;try{t=JSON.parse(e)}catch{return[]}return Array.isArray(t.statements)?iAe(e):Array.isArray(t.vulnerabilities)?sAe(e):[]}function V3(e,t){let n=new Map;for(let o of t){let s=n.get(o.cveId);s?s.push(o):n.set(o.cveId,[o])}let i=[],r=[];for(let o of e){let s=n.get(o.cveId)??[],l=s.some(c=>c.status==="affected"||c.status==="under_investigation")?void 0:s.find(c=>nAe(c.status));l?r.push({finding:o,status:l.status,justification:l.justification}):i.push(o)}return{gating:i,suppressed:r}}var Bj=v(()=>{"use strict"});function aAe(e){let t=JSON.parse(e.bytes);return e.format==="cyclonedx"||Array.isArray(t.components)?(t.components??[]).map(n=>{let i=n.licenses?.[0],r=i?.expression??i?.license?.id??i?.license?.name??"NOASSERTION";return{package:n.name??"unknown",license:r}}):(t.packages??[]).map(n=>({package:n.name??"unknown",license:n.licenseConcluded&&n.licenseConcluded!=="NOASSERTION"?n.licenseConcluded:n.licenseDeclared??"NOASSERTION"}))}function q3(e,t){let n=t.toLowerCase();return e.some(i=>i.toLowerCase()===n)}function cAe(e){return e.replace(/[()]/g," ").split(/\s+(?:OR|AND)\s+/i).map(t=>t.split(/\s+WITH\s+/i)[0].trim()).filter(Boolean)}function K3(e,t){let n=[];for(let{package:i,license:r}of aAe(e)){if(!r||r==="NOASSERTION")continue;let o=cAe(r);if(t.deny&&o.some(s=>q3(t.deny,s))){n.push({package:i,license:r,reason:"denied"});continue}t.allow&&t.allow.length>0&&o.some(s=>!q3(t.allow,s))&&n.push({package:i,license:r,reason:"not-allowed"})}return n}var Gj=v(()=>{"use strict"});function uAe(e){let t=e.finding;switch(e.reason){case"kev":{let n=t.kevDateAdded?`in CISA KEV since ${t.kevDateAdded}`:"in CISA KEV";return t.kevRansomware?`${n}, known ransomware use`:n}case"epss-threshold":return`EPSS ${t.epss} at/above the fail threshold`;case"unknown-severity":return"severity unreported by the scanner (failOnUnknownSeverity)";case"severity-threshold":return`severity at/above the fail threshold${t.fixable?", fixable":""}`}}function dAe(e){let t=[];for(let n of e??[])t.push(...H3(n));return t}function pAe(e=Mj()){return{kind:"vuln-gate",async run(t,n){let i={...lAe,...n.policy},r=n.findings??await e.scan({sbom:n.sbom,digest:n.digest}),{gating:o,suppressed:s}=V3(r,dAe(n.vex)),a=Wx[i.failSeverity],l=Wx[i.warnSeverity],c=[],u=[];for(let f of o){let g=Wx[f.severity],h=i.failEpssAtOrAbove!==void 0&&f.epss!==void 0&&f.epss>=i.failEpssAtOrAbove,b=i.warnEpssAtOrAbove!==void 0&&f.epss!==void 0&&f.epss>=i.warnEpssAtOrAbove,w=i.failOnKev&&f.inKev===!0,x=!i.exploitabilityFixableOnly||f.fixable;w&&x?c.push({finding:f,reason:"kev"}):h&&x?c.push({finding:f,reason:"epss-threshold"}):g>=a&&(!i.fixableOnly||f.fixable)?c.push({finding:f,reason:"severity-threshold"}):f.severity==="unknown"?i.failOnUnknownSeverity?c.push({finding:f,reason:"unknown-severity"}):u.push(f):(g>=l||w||h||b)&&u.push(f)}let d=i.license?K3(n.sbom,i.license):[],p=i.failOnLicense?d:[];if(c.length>0||p.length>0)throw new Wj(c,p);return{passed:!0,warnings:u,suppressed:s,licenseFindings:d}}}}var lAe,Wj,fAe,J3=v(()=>{"use strict";Fj();Bj();Gj();lAe={failSeverity:"critical",fixableOnly:!0,warnSeverity:"high",failOnLicense:!1,failOnUnknownSeverity:!1,failOnKev:!1,exploitabilityFixableOnly:!0},Wj=class extends Error{constructor(n,i){let r=i.map(s=>`${s.license} in ${s.package}`).join(", "),o=[];if(n.length){let s=n.map(a=>` ${a.finding.cveId} (${a.finding.severity}, ${a.finding.package}) \u2014 ${uAe(a)}`);o.push(`${n.length} vulnerability finding(s):
224
+ ${s.join(`
225
+ `)}`)}i.length&&o.push(`${i.length} license violation(s): ${r}`);super(`vuln-gate blocked the deploy \u2014 ${o.join(`
226
+ `)}
227
+ Fix the dependency, or record a VEX statement if it is not exploitable.`);this.blocking=n;this.blockingLicenses=i;this.name="VulnGateFailedError"}};fAe=pAe()});function mAe(e=Tx()){return{kind:"wait-cluster-healthy",async run(t,n){let i=n.cluster??t.vars?.clusterEndpoints??t.component,r=n.intervalMs??5e3,o=Date.now()+(n.timeoutMs??5*6e4);for(;;){let{healthyCount:s,total:a}=await e.neo4j.probe({cluster:i}),l=n.quorum?Math.floor(a/2)+1:n.size??a;if(s>=l)return{healthyCount:s};if(Date.now()>o)throw new Error(`wait-cluster-healthy "${i}" timed out: ${s}/${a} healthy, needed ${l}`);await Dx(r)}}}}function hAe(e=Y3){return{kind:"wait-endpoint",async run(t,n){let i=n.expectStatus??[200],r=n.intervalMs??5e3,o=n.timeoutMs??5*6e4,s=Date.now()+o;for(;;){try{let a=await e(n.url);if(i.includes(a.status))return{status:a.status}}catch{}if(Date.now()>=s)throw new Error(`wait-endpoint: ${n.url} did not return ${i.join("/")} within ${o}ms`);await Dx(r)}}}}function Z3(e){if(!e.host)return e.path;let t=/^https?:\/\//.test(e.host)?e.host:`http://${e.host}`;return new URL(e.path,t).toString()}function bAe(e=Y3){return{kind:"health-gate",async run(t,n){let i=n.consecutiveSuccesses??1,r=n.intervalMs??5e3,o=Date.now()+5*6e4,s=0;for(;;){let a=!1;try{a=(await e(Z3(n))).ok}catch{a=!1}if(s=a?s+1:0,s>=i)return{healthy:!0};if(Date.now()>=o)throw new Error(`health-gate: ${Z3(n)} did not reach ${i} consecutive healthy check(s) within 300000ms`);await Dx(r)}}}}var Y3,gAe,yAe,wAe,X3=v(()=>{"use strict";Nx();Y3=e=>fetch(e);gAe=mAe();yAe=hAe();wAe=bAe()});function kAe(e){return e?[["service.version",e.version],["vcs.ref.head.revision",e.revision]].filter(n=>n[1]!==void 0&&n[1]!=="").map(([n,i])=>`,${n}=${encodeURIComponent(i)}`).join(""):""}function Q3(e){let t=kAe(e);return t===""?{}:{[vAe]:t}}var vAe,e8=v(()=>{"use strict";Ri();vAe="CHANT_RELEASE_ATTRIBUTES"});function xAe(e=en()){return{kind:"shell",async run(t,n){let i={...Q3(t.release),...n.env??{}},r=Object.keys(i).length>0?`env ${Object.entries(i).map(([s,a])=>`${s}=${Se(a)}`).join(" ")} `:"",{stdout:o}=await e.run(`${r}${n.cmd}`,{cwd:n.cwd});return{stdout:o,exitCode:0}}}}var $Ae,t8=v(()=>{"use strict";Vi();e8();$Ae=xAe()});var zj=v(()=>{"use strict"});var n8=v(()=>{"use strict";zj();tN()});var r8=v(()=>{"use strict";up();E3();Wb();Yo();A3();mO();_3();I3();Pj();Ij();M3();B3();W3();z3();Fj();Bj();Gj();J3();X3();t8();n8();Nx();Vi()});var Uj=v(()=>{"use strict"});var i8,Hj=v(()=>{"use strict";r8();Uj();i8={build:["docker-build","zip-package","jvm-build"],sbom:["generate-sbom"],supplyChainSecurity:["sign","attest-provenance","verify"],supplyChainPolicy:["scan-vulnerabilities","vuln-gate"],waitVerify:["wait-cluster-healthy","wait-endpoint","health-gate"],secrets:["ensure-secret"],escapeHatch:["shell"],cloudflare:["wrangler-deploy","wrangler-versions-promote","r2-sync"]}});var o8=v(()=>{"use strict"});var i3e,s8=v(()=>{"use strict";Hj();o8();i3e=new Set(Object.values(i8).flat())});var a8=v(()=>{"use strict";Si()});import{createRequire as RAe}from"module";function SAe(){if(!c8&&(c8=!0,!Mn()))try{let e=RAe(import.meta.url),{register:t}=e("tsx/cjs/api");t()}catch{}}var c8,l8=v(()=>{"use strict";Si();c8=!1;import.meta.url.endsWith(".js")||SAe()});var u8=v(()=>{"use strict"});var d8=v(()=>{"use strict"});var EAe,d3e,mi=v(()=>{"use strict";EAe={"read-failed":!0,"no-credentials":!0,"no-binding":!0,"unsupported-kind":!0,filtered:!0},d3e=Object.keys(EAe)});function Kj(e,t=process.env){let n=e;for(let[i,r]of Object.entries(t))!r||r.length<AAe||zx.test(i)&&n.includes(r)&&(n=n.split(r).join(Ur));for(let i of Vj)n=n.replace(i,Ur);for(let{re:i}of qj)n=n.replace(i,Ur);return n}var Ur,zx,AAe,Vj,qj,Ux=v(()=>{"use strict";Ur="[redacted]",zx=/(SECRET|TOKEN|PASSWORD|PASSWD|CREDENTIAL|PRIVATE_KEY|APIKEY|API_KEY|ACCESS_KEY|SESSION_KEY|AUTH)/i,AAe=8,Vj=[/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g,/\beyJ[A-Za-z0-9_-]{4,}\.[A-Za-z0-9_-]{4,}\.[A-Za-z0-9_-]*/g,/\b(?:Bearer|Basic)\s+[A-Za-z0-9\-._~+/]{16,}={0,2}/g],qj=[{name:"a GitHub token",re:/\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{6,}\b/g},{name:"a GitHub fine-grained token",re:/\bgithub_pat_[A-Za-z0-9_]{6,}\b/g},{name:"a GitLab personal access token",re:/\bglpat-[A-Za-z0-9_-]{3,}\b/g},{name:"an OpenAI-style secret key",re:/\bsk-(?:live-|proj-|test-)?[A-Za-z0-9]{6,}\b/g},{name:"a Stripe key",re:/\b[rs]k_(?:live|test)_[A-Za-z0-9]{6,}\b/g},{name:"a Slack token",re:/\bxox[abposr]-[A-Za-z0-9-]{6,}\b/g},{name:"an AWS access key id",re:/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g},{name:"a Google API key",re:/\bAIza[0-9A-Za-z_-]{20,}\b/g},{name:"a Google OAuth token",re:/\bya29\.[0-9A-Za-z_-]{10,}/g},{name:"an npm token",re:/\bnpm_[A-Za-z0-9]{10,}\b/g}]});var Jj=v(()=>{"use strict"});var dp=v(()=>{"use strict";ex()});function Xj(e){return typeof e=="string"&&CAe.includes(e)}function Qj(e,t){return{rate:"per-hour",perHour:e,currency:t}}function eL(e){return typeof e=="string"&&IAe.includes(e)}function Hx(e){return typeof e=="string"&&g8.includes(e)}function Za(e){return typeof e=="object"&&e!==null&&"refusal"in e}function h8(e){if(typeof e!="object"||e===null)return!1;let t=e;return t.behaviour!=="v1"?!1:typeof t.refusal=="object"&&t.refusal!==null?!0:typeof t.entities=="object"&&t.entities!==null&&typeof t.meta=="object"&&t.meta!==null}function p8(e){return DAe.includes(e.trim().toLowerCase().replace(/\.$/,""))}function tL(e,t){let n=a=>{throw new Error(`predictBehaviour produced an invalid block for "${e}": ${a}. behold's own validator (behold/src/behaviour.ts) drops a block failing this, so it would render nothing rather than render wrong \u2014 which is worse to debug, because everything here looked legal.`)};To(t.at?.traffic)||n("at.traffic is missing \u2014 name the traffic level you priced");let i=t.cost?.perHour;(typeof i!="number"||!Number.isFinite(i))&&n("cost.perHour is not a finite number"),i<0&&n("cost.perHour is negative"),To(t.cost?.currency)||n("cost.currency is missing");let r=t.headroom;(!r||typeof r!="object")&&n("headroom is missing");let o=r;o.cpu!==void 0&&!Zj(o.cpu)&&n("headroom.cpu is not a fraction 0..1"),o.latency!==void 0&&!Zj(o.latency)&&n("headroom.latency is not a fraction 0..1"),o.cpu===void 0&&o.latency===void 0&&n("headroom carries neither cpu nor latency \u2014 an axis you did not model is absent, and a block with no axis at all says nothing"),Zj(t.errorRate)||n("errorRate is not a fraction 0..1"),To(t.resilience?.failure)||n("resilience.failure is missing \u2014 a verdict with no named failure says nothing"),p8(t.resilience.failure)&&n(`resilience.failure ${JSON.stringify(t.resilience.failure)} names no failure. behold takes any non-empty string here, so this passes its validator and renders a confident verdict about nothing. Name the event: "one zone lost", "primary database failover"`),eL(t.resilience?.verdict)||n(`resilience.verdict ${JSON.stringify(t.resilience?.verdict)} is not survives/degrades/fails`),t.rightSize!==void 0&&!To(t.rightSize.suggestion)&&n("rightSize is present without a suggestion");let s=t.provenance;(!s||typeof s!="object")&&n("provenance is missing"),To(s?.engine)||n("provenance.engine is missing"),To(s?.version)||n("provenance.version is missing"),To(s?.tolerance)||n("provenance.tolerance is missing \u2014 a figure without a stated tolerance is not a prediction"),p8(s.tolerance)&&n(`provenance.tolerance ${JSON.stringify(s.tolerance)} states no tolerance. An engine with nothing to say about its own error bars has no business publishing a figure; say the number, however wide`),Xj(s?.basis)||n(`provenance.basis ${JSON.stringify(s?.basis)} is not modeled/validated`)}function y8(e,t,n,i){if(!To(t?.engine))throw new Error("predictBehaviour: meta.engine is missing");if(!To(t?.version))throw new Error("predictBehaviour: meta.version is missing");if(!To(e?.traffic))throw new Error("predictBehaviour: meta.at.traffic is missing");if(t.total&&(!Number.isFinite(t.total.perHour)||t.total.perHour<0))throw new Error("predictBehaviour: meta.total.perHour is not a non-negative finite number");oL(e.edgeCoverage);let r={engine:t.engine,version:t.version,at:{traffic:e.traffic},...t.total?{total:t.total}:{},edgeCoverage:iPe(e.edgeCoverage)},o=e.entityNames,s=new Set(o),a=new Set(Object.keys(i??{}));for(let c of Object.keys(n)){if(a.has(c))throw new Error(`predictBehaviour reported "${c}" as both priced and unpriced. An entity has one verdict.`);if(!s.has(c))throw new Error(`predictBehaviour returned a figure for "${c}", which was not in entityNames. An engine answering about entities nobody asked about is answering about the wrong estate.`);if(tL(c,n[c]),n[c].at.traffic!==r.at.traffic)throw new Error(`predictBehaviour priced "${c}" at ${JSON.stringify(n[c].at.traffic)} in a run whose meta.at.traffic is ${JSON.stringify(r.at.traffic)}. One run, one level.`)}for(let c of a){if(!s.has(c))throw new Error(`predictBehaviour reported "${c}" unpredicted, and it was not in entityNames.`);if(!Hx(i[c]?.reason))throw new Error(`predictBehaviour gave "${c}" the reason ${JSON.stringify(i[c]?.reason)}, which is not one of ${g8.join(", ")}.`)}let l=o.filter(c=>!Object.prototype.hasOwnProperty.call(n,c)&&!a.has(c));if(l.length>0)throw new Error(`predictBehaviour gave no verdict at all for ${l.map(c=>`"${c}"`).join(", ")}. Every entity asked about lands in \`entities\` or in \`unpredicted\` \u2014 there is no third position, because a prediction has no equivalent of "the provider says it is not there". An entity you could not price is \`unsupported-kind\`, not an omission.`);return{behaviour:"v1",meta:r,entities:n,...i&&Object.keys(i).length>0?{unpredicted:i}:{}}}function _l(e){return{behaviour:"v1",refusal:e}}function NAe(e,t){return e.engine!==t.engine||e.version!==t.version||e.tolerance!==t.tolerance?"mixed-engine":e.basis===t.basis?"comparable":"mixed-basis"}function w8(e,t){let n=new Set;return NAe(e.provenance,t.provenance)==="mixed-engine"&&n.add("mixed-engine"),e.at.traffic!==t.at.traffic&&n.add("mixed-level"),e.cost.currency!==t.cost.currency&&n.add("mixed-currency"),e.provenance.basis!==t.provenance.basis&&n.add("mixed-basis"),e.resilience.failure!==t.resilience.failure&&n.add("mixed-failure"),n}function nL(e){return[`CHANT_BEHAVIOUR_ENGINE_${e.toUpperCase().replace(/[^A-Z0-9]+/g,"_")}`,"CHANT_BEHAVIOUR_ENGINE","BEHAVIOUR_ENGINE"]}function v8(e,t){for(let n of nL(e)){let i=t[n]?.trim();if(i)return{value:i,source:n}}}function jAe(e){let[t,n,i]=nL(e);return`predictBehaviour has the ${e} estate to predict and no engine to predict it with. Set a ${n} environment variable to the engine's address \u2014 a URL, a socket path, or a command on PATH \u2014 or ${i} where nothing else in the environment is chant's. ${t} is read first, for an estate whose lexicons are priced by different engines. The address is not a credential: the engine is never handed one and never writes.`}function rL(e){return[`CHANT_BEHAVIOUR_TOKEN_${e.toUpperCase().replace(/[^A-Z0-9]+/g,"_")}`,"CHANT_BEHAVIOUR_TOKEN","BEHAVIOUR_TOKEN"]}function k8(e,t){for(let n of rL(e)){let i=t[n]?.trim();if(i)return{value:i,source:n}}}function LAe(e,t){let[n,i,r]=rL(e);return`predictBehaviour has the ${e} behaviour engine at ${Ja(t.value)}, named by ${t.source}, and no token to authenticate to it with, so nothing was sent. Set a ${i} environment variable to the bearer token the engine issued \u2014 or ${r} where nothing else in the environment is chant's. ${n} is read first, for an estate whose lexicons are priced by different engines on different accounts. The token goes in a header the engine reads and nowhere else; it is never in the request body and never in a message.`}function x8(e,t){let[,n]=rL(e);return _l({cause:"no-engine",reason:LAe(e,t),remedy:`Set ${n} to the bearer token the engine at ${Ja(t.value)} issued.`})}function $8(e,t,n,i){return _l({cause:"no-engine",reason:`The ${e} behaviour engine at ${Ja(t.value)}, named by ${t.source}, answered and rejected the token ${n.source} holds (${Vx(i)}). The address is reachable and the account is not the problem; the token is not one this engine accepts. No overlay is drawn and no figure is guessed locally.`,remedy:`Set ${n.source} to a bearer token the engine at ${Ja(t.value)} accepts.`,source:n.source})}function MAe(e,t,n){return`predictBehaviour reached for the ${e} behaviour engine at ${Ja(t.value)}, named by ${t.source}, and it did not answer: ${Vx(n)}. No overlay is drawn and no figure is guessed locally. Check the engine is up and that ${t.source} names the address this environment can reach.`}function R8(e){let[,t]=nL(e);return _l({cause:"no-engine",reason:jAe(e),remedy:`Set ${t} to the engine's address.`})}function gh(e,t,n){return _l({cause:"engine-unreachable",reason:MAe(e,t,n),remedy:`Check the engine at ${Ja(t.value)} is reachable, or repoint ${t.source}.`,source:t.source})}function FAe(e,t,n){return`The ${e} behaviour engine at ${Ja(t.value)}, named by ${t.source}, answered and refused: the account behind it is out of credit (${Vx(n)}). The address is reachable and nothing here is a networking problem. Add credit to the account this engine bills, or point ${t.source} at an engine on an account that has some. No overlay is drawn and no figure is guessed locally.`}function BAe(e,t,n){return`The ${e} behaviour engine at ${Ja(t.value)}, named by ${t.source}, answered and refused: a rate or volume limit is spent (${Vx(n)}). The account has credit and the address is reachable, so this usually clears when the engine's window rolls over. Wait for it, raise the limit on the account, or point ${t.source} at an engine with its own budget. No overlay is drawn and no figure is guessed locally.`}function GAe(e,t,n){return _l({cause:"engine-out-of-credit",reason:FAe(e,t,n),remedy:`Add credit to the account behind ${t.source}, or repoint it at a funded engine.`,source:t.source})}function WAe(e,t,n){return _l({cause:"engine-over-quota",reason:BAe(e,t,n),remedy:`Wait for the engine's window to roll over, or raise the limit on the account behind ${t.source}.`,source:t.source})}function Ya(e,t,n,i){switch(n){case"engine-out-of-credit":return GAe(e,t,i);case"engine-over-quota":return WAe(e,t,i);case"engine-unreachable":return gh(e,t,i)}}function S8(e=process.env){return{PATH:e.PATH??""}}function iL(e,t={}){let n=t.color??(!process.env.NO_COLOR&&process.stdout.isTTY!==!1),i=`behaviour: refused (${e.cause}) \u2014 ${e.reason}
228
+ ${e.remedy}`;return n?`${zAe}${i}${UAe}`:i}function ZAe(e){if(/^[a-z][a-z0-9+.-]*:\/\//i.test(e))try{if(new URL(e).password!=="")return!0}catch{}return/^[^\s:@/]+:[^\s:@/]+@[A-Za-z0-9._-]+(?::\d+)?(?:[/?#]|$)/.test(e.trim())}function YAe(e){let t=e.toLowerCase().replace(/[^a-z0-9]/g,"");return KAe.includes(t)||qAe.some(n=>t.endsWith(n))?!1:HAe.includes(t)?!0:zx.test(e)||JAe.test(t)}function XAe(e){return/^\{\{[^}]+\}\}$/.test(e.trim())||/^\$\{[^}]+\}$/.test(e.trim())||/^!(?:Ref|GetAtt|Sub|ImportValue)\b/.test(e.trim())||/^arn:[a-z0-9-]*:secretsmanager:/i.test(e.trim())||/^projects\/[^/]+\/secrets\/[^/]+/.test(e.trim())}function QAe(e){for(let t of Vj)if(t.lastIndex=0,t.test(e))return"a literal credential shape (PEM key, JWT or Authorization value)";for(let{name:t,re:n}of qj)if(n.lastIndex=0,n.test(e))return t;if(ZAe(e))return"a password in a URL's userinfo"}function ePe(e){if(!/^[a-z][a-z0-9+.-]*:\/\//i.test(e))return e;try{let t=new URL(e),n=t.username!==""||t.password!=="",i=t.search!=="",r=t.hash!=="";t.username="",t.password="",t.search="",t.hash="";let o=t.toString();return n&&(o=o.replace("://",`://${Ur}@`)),i&&(o+=`?${Ur}`),r&&(o+=`#${Ur}`),o}catch{return e}}function tPe(e){return e.replace(/(--?[A-Za-z0-9-]*(?:secret|token|password|passwd|key|credential|auth|pat)[A-Za-z0-9-]*)([=\s])(\S+)/gi,(t,n,i)=>`${n}${i}${Ur}`).replace(/(^|\s)(-[pPkK])(\s+)(\S+)/g,(t,n,i,r)=>`${n}${i}${r}${Ur}`)}function Ja(e,t=process.env){return Kj(tPe(ePe(e)),t)}function Vx(e,t=process.env){let n=e.replace(/\b[a-z][a-z0-9+.-]*:\/\/\S+/gi,r=>{try{return new URL(r).host||Ur}catch{return Ur}}),i=Kj(n,t).replace(/\s+/g," ").trim();return i.length>f8?`${i.slice(0,f8)}\u2026`:i}function rPe(e){return typeof e=="string"&&E8.includes(e)}function iPe(e){let t={verdict:e.verdict,...e.dangling?{dangling:Object.freeze(e.dangling.map(n=>Object.freeze({...n})))}:{},...e.unresolvedKinds?{unresolvedKinds:Object.freeze([...e.unresolvedKinds])}:{},...e.containmentEdges?{containmentEdges:Object.freeze(e.containmentEdges.map(n=>Object.freeze({...n})))}:{}};return Object.freeze(t)}function oL(e){if(!rPe(e?.verdict))throw new Error(`predictBehaviour: edgeCoverage.verdict ${JSON.stringify(e?.verdict)} is not ${E8.join("/")}.`);if(e.verdict==="partial"&&(e.dangling?.length??0)===0&&(e.unresolvedKinds?.length??0)===0)throw new Error('predictBehaviour: edgeCoverage is "partial" and names nothing missing. Populate `dangling` or `unresolvedKinds`, or say "unknown" \u2014 a partial that lists no gap is an unknown with a more confident word on it.')}function A8(e){let t=[],n=new WeakSet,i=(o,s,a)=>{if(a>m8){t.push({path:s,rule:"walk-depth",what:`a structure deeper than ${m8} levels, which the credential walk did not read`});return}if(typeof o=="string"){let l=QAe(o);l&&t.push({path:s,rule:"value-shape",what:l});return}if(!(o===null||typeof o!="object")&&!n.has(o)){if(n.add(o),Array.isArray(o)){o.forEach((l,c)=>i(l,`${s}[${c}]`,a+1));return}if(o instanceof Map){for(let[l,c]of o){let u=typeof l=="string"?l:String(l),d=`${s}.get(${u})`;typeof l=="string"&&r(l,d,c),i(c,d,a+1)}return}if(o instanceof Set){let l=0;for(let c of o)i(c,`${s}.item[${l++}]`,a+1);return}for(let[l,c]of Object.entries(o)){let u=`${s}.${l}`;r(l,u,c),i(c,u,a+1)}}};function r(o,s,a){typeof a=="string"&&(a.length<VAe||XAe(a)||YAe(o)&&t.push({path:s,rule:"key-name",what:`a credential-shaped field name ("${o}")`}))}return i(e,"options",0),t}function oPe(e){let t=A8(e).filter(i=>i.rule==="value-shape");if(t.length===0)return;let[n]=t;throw new Error(`predictBehaviour was passed ${n.what} at ${n.path}. The behaviour engine is never handed a credential: it is given the resource graph and a traffic level, and nothing it receives can reach the account. Remove it \u2014 a lexicon that needs authenticated access to its own engine resolves that on its own transport, not through this contract.`)}function P8(e,t){oPe(t);let n=A8(t);if(n.length===0)return;let[i]=n,r=n.length>1?` (and ${n.length-1} more)`:"";return _l({cause:"credential-in-request",reason:`The ${e} behaviour request carries ${i.what} at ${i.path}${r}, so it was not sent. The engine is a third party and this contract hands it the resource graph and a traffic level only. No overlay is drawn and no figure is guessed locally.`,remedy:"Remove the value from the declaration, or hold it in a secret reference the build does not expand. If the field is a false positive, it still leaves the process in this request."})}var OAe,CAe,_Ae,IAe,TAe,g8,DAe,Zj,To,Yj,b8,zAe,UAe,HAe,VAe,qAe,KAe,JAe,f8,nPe,E8,m8,Xa=v(()=>{"use strict";Ux();OAe={modeled:!0,validated:!0},CAe=Object.keys(OAe);_Ae={survives:!0,degrades:!0,fails:!0},IAe=Object.keys(_Ae);TAe={"read-failed":!0,"no-binding":!0,"unsupported-kind":!0,filtered:!0,"no-engine":!0,"engine-unreachable":!0,"engine-out-of-credit":!0,"engine-over-quota":!0,"credential-in-request":!0},g8=Object.keys(TAe);DAe=["n/a","na","none","unknown","-","?","tbd","null"];Zj=e=>typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1,To=e=>typeof e=="string"&&e.trim()!=="";Yj={"mixed-engine":0,"mixed-level":1,"mixed-currency":2,"mixed-basis":3,"mixed-failure":4},b8=Object.keys(Yj).sort((e,t)=>Yj[e]-Yj[t]);zAe="\x1B[31m",UAe="\x1B[0m";HAe=["pat","cookie"],VAe=8,qAe=["ref","refs","name","names","id","ids","arn","arns","count","validity","mode","modes","policy","policies","scope","scopes","network","networks","type","types","enabled","required","version","uri","url","urls","config","configs","settings","options"],KAe=["imagepullsecrets","clienttoken","automountserviceaccounttoken","author","authors","authority","secretsmanager"],JAe=new RegExp(zx.source.replace(/_/g,""),"i");f8=200,nPe={complete:!0,partial:!0,unknown:!0},E8=Object.keys(nPe);m8=32});function C8(e){return/^https?:\/\//i.test(e.trim())}function sL(e,t){return e.value.length<4||!t.includes(e.value)?t:t.split(e.value).join(Ur)}function aPe(e,t,n,i,r,o){if(i>=200&&i<300)return;let s=r.trim().length>0?`: ${r.trim()}`:"";if(i===401||i===403)return $8(e,t,n,`HTTP ${i}${s}`);if(i===402)return Ya(e,t,"engine-out-of-credit",`the account ${n.source} authenticates answered HTTP 402${s}`);if(i===429){let a=o&&o.trim().length>0?`, retry after ${o.trim()}`:"";return Ya(e,t,"engine-over-quota",`the account ${n.source} authenticates answered HTTP 429${a}${s}`)}return Ya(e,t,"engine-unreachable",`HTTP ${i}${s||" with no body"}`)}function cPe(e){let t=e.split(`
229
+ `).find(n=>n.trim().length>0)?.trim()??"";return t.length>O8?`${t.slice(0,O8)}\u2026`:t}function _8(e,t,n,i={}){let r=k8(e,n),o=i.fetch??globalThis.fetch,s=i.timeoutMs??sPe;if(!r){let a=x8(e,t);return{async send(){return{ok:!1,refusal:a}}}}return{async send(a){let l;try{l=await o(t.value.trim(),{method:"POST",headers:{"content-type":"application/json",accept:"application/json",authorization:`Bearer ${r.value}`},body:a,redirect:"error",signal:AbortSignal.timeout(s)})}catch(d){return{ok:!1,refusal:Ya(e,t,"engine-unreachable",sL(r,lPe(d,s)))}}let c=await l.text().catch(()=>""),u=aPe(e,t,r,l.status,sL(r,cPe(c)),l.headers.get("retry-after")??void 0);return u?{ok:!1,refusal:u}:{ok:!0,body:sL(r,c)}}}}function lPe(e,t){if(e instanceof Error){if(e.name==="TimeoutError"||e.name==="AbortError")return`no answer within ${t} ms`;let n=e.cause,i=typeof n?.code=="string"?n.code:void 0;return i?`${i}: ${e.message}`:e.message}return String(e)}var sPe,O8,aL=v(()=>{"use strict";Xa();Ux();sPe=3e4,O8=300});function I8(e,t,n){if(t.startsWith(dPe))return{status:"declared-unmapped",reason:"one of chant's own build-time entities rather than something an account holds \u2014 a declared output, or a default that rides onto the resources beside it. It is never created and never billed"};let i=e.find(a=>a.prefixes.some(l=>t.startsWith(l)));if(!i)return{status:"unknown-type"};if(i.nothingPriced)return{status:"provider-not-modelled",substrate:i.nothingPriced};let r=i.resolveType?i.resolveType(t,n):t;if(r===void 0)return{status:"unknown-type"};if(i.mapped&&Object.prototype.hasOwnProperty.call(i.mapped,r)){let a=i.mapped[r];return{status:"mapped",mapping:{...a,provider:a.provider??i.provider}}}if(i.unmapped&&Object.prototype.hasOwnProperty.call(i.unmapped,r))return{status:"declared-unmapped",reason:i.unmapped[r]};let o=i.notModelledWhen?.(r);if(o!==void 0)return{status:"provider-not-modelled",substrate:o};let s=i.unmappedWhen?.(r);return s!==void 0?{status:"declared-unmapped",reason:s}:{status:"unknown-type"}}function cL(e,t){return e.find(n=>n.prefixes.some(i=>t.startsWith(i)))}function T8(e,t,n){let i=cL(e,t);if(!i?.resolveType)return t;let r=i.resolveType(t,n);return r===void 0||r===t?t:`${r} (${t})`}function D8(e,t,n){if(t.status==="declared-unmapped")return`${e} is declared unmapped by the ${n?.provider??"declaring"} coverage rows: ${t.reason}.`;if(t.status==="provider-not-modelled")return`${e} belongs to ${t.substrate}, which nothing here models. A substrate is added by the lexicon that owns its types contributing rows for them, not by adding a row elsewhere. This is a stated boundary rather than a gap \u2014 nothing needs filing.`;let i=n?`the lexicon that owns ${n.prefixes.join(", ")}`:"the lexicon that owns this entity type";return`${e} has no row in any contributed coverage table. It is a type from a substrate that is modelled, and is neither mapped to an engine kind nor declared unmapped, so nothing has an opinion about it rather than a stated one. Add a row in ${i}.`}var uPe,R3e,dPe,pp,lL=v(()=>{"use strict";uPe={compute:!0,serverless:!0,"control-plane":!0,database:!0,cache:!0,queue:!0,"object-store":!0,"block-store":!0,"load-balancer":!0,cdn:!0},R3e=Object.keys(uPe),dPe="chant:";pp=(e,t)=>e<t?-1:e>t?1:0});function M8(e,t){if(!h8(e))throw new Error('behaviour result is neither a report nor a refusal: expected `behaviour: "v1"` with either `refusal` or both `meta` and `entities`.');if(Za(e)){let a=e.refusal;if(!Hx(a.cause))throw new Error(`behaviour refusal carries the cause ${JSON.stringify(a.cause)}, which is not a legal reason.`);if(typeof a.reason!="string"||a.reason.trim()==="")throw new Error("behaviour refusal states no reason \u2014 the sentence a consumer prints is missing.");if(typeof a.remedy!="string"||a.remedy.trim()==="")throw new Error("behaviour refusal states no remedy \u2014 a refusal exists to be acted on.");return e}let n=e;if(oL(n.meta.edgeCoverage),typeof n.meta.at?.traffic!="string"||n.meta.at.traffic.trim()==="")throw new Error("behaviour report states no traffic level in meta.at \u2014 a figure without its question is a bill in waiting.");let i=new Set(t),r=n.unpredicted??{},o=new Set(Object.keys(r));for(let a of Object.keys(n.entities)){if(o.has(a))throw new Error(`behaviour report names "${a}" as both predicted and unpredicted.`);if(!i.has(a))throw new Error(`behaviour report carries a figure for "${a}", which was not asked about.`);if(tL(a,n.entities[a]),n.entities[a].at.traffic!==n.meta.at.traffic)throw new Error(`behaviour report priced "${a}" at ${JSON.stringify(n.entities[a].at.traffic)} in a run whose meta.at.traffic is ${JSON.stringify(n.meta.at.traffic)}.`)}for(let a of o){if(!i.has(a))throw new Error(`behaviour report names "${a}" unpredicted, and it was not asked about.`);if(!Hx(r[a]?.reason))throw new Error(`behaviour report gives "${a}" the reason ${JSON.stringify(r[a]?.reason)}, which is not a legal one.`)}let s=t.filter(a=>!Object.prototype.hasOwnProperty.call(n.entities,a)&&!o.has(a));if(s.length>0)throw new Error(`behaviour report gives no verdict at all for ${s.map(a=>`"${a}"`).join(", ")}. Every entity asked about lands in \`entities\` or in \`unpredicted\`; there is no third position.`);return n}function N8(e,t){return e<t?-1:e>t?1:0}function qx(e,t){return e!==void 0&&Object.prototype.hasOwnProperty.call(e,t)}function F8(e,t){let n=Za(e.result),i=Za(t.result);if(n||i)return{kind:"no-prediction",base:{label:e.label,...e.ref?{ref:e.ref}:{},...n?{refusal:e.result.refusal}:{}},head:{label:t.label,...t.ref?{ref:t.ref}:{},...i?{refusal:t.result.refusal}:{}}};let r=e.result,o=t.result,s=new Set([...Object.keys(r.entities),...Object.keys(r.unpredicted??{}),...Object.keys(o.entities),...Object.keys(o.unpredicted??{})]),a=[],l=new Map;for(let c of[...s].sort(N8)){let u=qx(r.entities,c)?r.entities[c]:void 0,d=qx(o.entities,c)?o.entities[c]:void 0,p=qx(r.unpredicted,c)?r.unpredicted[c]:void 0,f=qx(o.unpredicted,c)?o.unpredicted[c]:void 0,g=p?.type??f?.type,h={name:c,...g?{type:g}:{},kind:"comparable",...u?{base:u}:{},...d?{head:d}:{},...p?{baseDeclined:p}:{},...f?{headDeclined:f}:{}};if(p||f)h.kind="declined";else if(u&&d){let b=w8(u,d);if(b.size>0)h.kind="marked",h.mismatches=b8.filter(w=>b.has(w));else{h.kind="comparable",h.deltaPerHour=d.cost.perHour-u.cost.perHour,h.currency=d.cost.currency;let w=l.get(h.currency)??{currency:h.currency,perHour:0,pairs:0};w.perHour+=h.deltaPerHour,w.pairs+=1,l.set(h.currency,w)}}else u?h.kind="only-base":h.kind="only-head";a.push(h)}return{kind:"delta",base:{label:e.label,...e.ref?{ref:e.ref}:{},meta:r.meta},head:{label:t.label,...t.ref?{ref:t.ref}:{},meta:o.meta},rows:a,sums:[...l.values()].sort((c,u)=>N8(c.currency,u.currency)),resilienceComparable:r.meta.edgeCoverage.verdict==="complete"&&o.meta.edgeCoverage.verdict==="complete"}}function hh(e){let t=e.toFixed(4);return t.includes(".")?t.replace(/0+$/,"").replace(/\.$/,""):t}function B8(e){return`${hh(e.perHour)} ${e.currency}/hour`}function G8(e,t){return`${e>0?"+":""}${hh(e)} ${t}/hour`}function Kx(e){return`${e.engine} ${e.version} \xB7 ${e.tolerance} \xB7 ${e.basis}`}function pPe(e){let t=[];return e.unresolvedKinds&&e.unresolvedKinds.length>0&&t.push(`unresolved kinds: ${e.unresolvedKinds.join(", ")}`),e.dangling&&e.dangling.length>0&&t.push(`${e.dangling.length} dangling reference(s)`),e.containmentEdges&&e.containmentEdges.length>0&&t.push(`${e.containmentEdges.length} containment edge(s)`),t.length>0?`${e.verdict} (${t.join("; ")})`:e.verdict}function j8(e,t,n){let i=t===void 0?"\u2014":hh(t),r=n===void 0?"\u2014":hh(n);return`${e} ${i} \u2192 ${r}`}function fPe(e,t){let n=e?.headroom??{},i=t?.headroom??{};return[j8("cpu",n.cpu,i.cpu),j8("latency",n.latency,i.latency)].join(" \xB7 ")}function Jx(e){return e?`${e.resilience.verdict} (${e.resilience.failure})`:"\u2014"}function mPe(e,t){let{base:n,head:i}=e;if(!n||!i)return n?`base ${Jx(n)}`:i?`head ${Jx(i)}`:"\u2014";if(t&&n.resilience.failure===i.resilience.failure){let r=n.resilience.verdict===i.resilience.verdict?"=":"\u2192";return`${n.resilience.verdict} ${r} ${i.resilience.verdict} (${n.resilience.failure})`}return`base ${Jx(n)}; head ${Jx(i)}`}function gPe(e){let{base:t,head:n}=e;if(t&&n){let i=Kx(t.provenance),r=Kx(n.provenance);return i===r?i:`base: ${i}; head: ${r}`}return t?Kx(t.provenance):n?Kx(n.provenance):"\u2014"}function gi(e){return e.replace(/\|/g,"\\|").replace(/\r?\n/g," ")}function L8(e,t){return t?`declined: ${t.reason}`:e?B8(e.cost):"\u2014"}function hPe(e){switch(e.kind){case"comparable":return G8(e.deltaPerHour,e.currency);case"marked":return`marked: ${(e.mismatches??[]).join(", ")}`;case"declined":return"no delta (declined)";case"only-base":return"removed";case"only-head":return"added"}}function W8(e,t){let n=[];if(e.kind==="no-prediction"){n.push(`## Predicted behaviour for \`${t.env}\` \u2014 no prediction (Op \`${t.op}\`)`,""),n.push("No delta is shown and no figure is guessed locally. A prediction refused on one side is not a prediction of zero on that side, so there is nothing to difference the other side against.","");for(let c of[e.base,e.head]){if(!c.refusal)continue;let u=c.ref?`${c.label} (${c.ref})`:c.label;n.push(`**${u}**`,"","```",iL(c.refusal,{color:!1}),"```","")}return n.join(`
230
+ `).trimEnd()+`
231
+ `}let i=e.head.meta.at.traffic;n.push(`## Predicted behaviour for \`${t.env}\` at \`${i}\` (Op \`${t.op}\`)`,""),n.push("A prediction, not a measurement. Every figure below is one engine's modeled rate for one hypothetical hour at the stated traffic level, shown with that engine's name, version, stated tolerance and basis (`modeled` from list prices, or `validated`). Nothing here is an amount owed for an hour that happened.",""),n.push("| Side | Predicted from | Engine | Traffic level | Edge coverage | Engine's own estate total |"),n.push("|---|---|---|---|---|---|");for(let c of[e.base,e.head]){let u=c.meta.total?B8(c.meta.total):"not stated";n.push(`| ${c.label} | ${gi(c.ref??"\u2014")} | ${gi(`${c.meta.engine} ${c.meta.version}`)} | ${gi(c.meta.at.traffic)} | ${gi(pPe(c.meta.edgeCoverage))} | ${u} |`)}n.push(""),e.base.meta.at.traffic!==e.head.meta.at.traffic&&n.push(`The two sides were predicted at different traffic levels (\`${e.base.meta.at.traffic}\` and \`${e.head.meta.at.traffic}\`), so every pair below is marked \`mixed-level\` and none is differenced.`,""),e.resilienceComparable||n.push(`Resilience verdicts are shown per side and **not compared**: edge coverage is \`${e.base.meta.edgeCoverage.verdict}\` on ${e.base.label} and \`${e.head.meta.edgeCoverage.verdict}\` on ${e.head.label}, so the two verdicts were computed over graphs of different completeness, and a difference between them is not a difference in the estate.`,""),n.push(`| Entity | Type | ${e.base.label} | ${e.head.label} | Delta per hour | Headroom (${e.base.label} \u2192 ${e.head.label}) | Resilience | Provenance |`),n.push("|---|---|---|---|---|---|---|---|");for(let c of e.rows)n.push(`| ${gi(c.name)} | ${gi(c.type??"")} | ${gi(L8(c.base,c.baseDeclined))} | ${gi(L8(c.head,c.headDeclined))} | ${gi(hPe(c))} | ${gi(fPe(c.base,c.head))} | ${gi(mPe(c,e.resilienceComparable))} | ${gi(gPe(c))} |`);n.push("");let r=e.rows.filter(c=>c.kind==="marked").length,o=e.rows.filter(c=>c.kind==="declined").length,s=e.rows.filter(c=>c.kind==="only-base"||c.kind==="only-head").length;if(e.sums.length>0){for(let c of e.sums)n.push(`Sum of the comparable deltas: **${G8(c.perHour,c.currency)}** over ${c.pairs} pair(s). This is chant's own arithmetic over the comparable rows above and not an engine figure; it excludes ${r} marked pair(s), ${o} declined entit${o===1?"y":"ies"} and ${s} entit`+(s===1?"y":"ies")+" present on one side only.");n.push("")}else n.push("No pair is comparable, so no delta is summed.","");let a=e.rows.filter(c=>c.kind==="declined");if(a.length>0){n.push("### Declined entities",""),n.push("An entity the engine could not price is reported, not priced at nothing. It carries no delta on either side; the reason is the lexicon's own.","");for(let c of a)for(let[u,d]of[[e.base.label,c.baseDeclined],[e.head.label,c.headDeclined]])d&&n.push(`- \`${c.name}\` on ${u}: \`${d.reason}\`${d.detail?` \u2014 ${d.detail}`:""}`);n.push("")}let l=e.rows.filter(c=>c.head?.rightSize);if(l.length>0){n.push(`### Right-size hints on ${e.head.label}`,"");for(let c of l){let u=c.head.rightSize;n.push(`- \`${c.name}\`: ${u.suggestion}${u.reason?` \u2014 ${u.reason}`:""}`)}n.push("")}return n.join(`
232
+ `).trimEnd()+`
233
+ `}var Zx=v(()=>{"use strict";Xa()});var Yx=v(()=>{"use strict";dp()});var z8=v(()=>{"use strict"});var uL=v(()=>{"use strict";to()});var U8=v(()=>{"use strict"});var vPe,kPe,N3e,xPe,$Pe,j3e,H8=v(()=>{"use strict";Ln();vPe=m.object({name:m.string().min(1,"intrinsic name must not be empty"),description:m.string().optional(),outputKey:m.string().optional(),isTag:m.boolean(),foldsAsCall:m.boolean().optional(),foldsEagerly:m.boolean().optional()}),kPe=/^\d+\.\d+\.\d+(-[a-zA-Z0-9.]+)?(\+[a-zA-Z0-9.]+)?$/,N3e=m.object({name:m.string().min(1,"manifest name must not be empty"),version:m.string().regex(kPe,"version must be valid semver (X.Y.Z)"),chantVersion:m.string().optional(),namespace:m.string().optional(),intrinsics:m.array(vPe).optional(),pseudoParameters:m.record(m.string(),m.string()).optional()}),xPe=m.object({name:m.string(),type:m.enum(["if_then","dependent_excluded","required_or","required_xor"]),condition:m.unknown().optional(),requirement:m.unknown().optional()}),$Pe=m.object({pattern:m.string().optional(),minLength:m.number().optional(),maxLength:m.number().optional(),minimum:m.number().optional(),maximum:m.number().optional(),format:m.string().optional(),const:m.unknown().optional(),default:m.unknown().optional(),enum:m.array(m.string()).optional()}),j3e=m.object({resourceType:m.string(),kind:m.enum(["resource","property"]),lexicon:m.string(),attrs:m.record(m.string(),m.string()).optional(),constraints:m.array(xPe).optional(),propertyConstraints:m.record(m.string(),$Pe).optional(),createOnly:m.array(m.string()).optional(),writeOnly:m.array(m.string()).optional(),primaryIdentifier:m.array(m.string()).optional(),deprecatedProperties:m.array(m.string()).optional(),conditionalCreateOnly:m.array(m.string()).optional(),replacementStrategy:m.enum(["delete_then_create","create_then_delete"]).optional(),tagging:m.object({taggable:m.boolean(),tagOnCreate:m.boolean(),tagUpdatable:m.boolean()}).optional(),runtimeDeprecations:m.record(m.string(),m.string()).optional()})});var V8=v(()=>{"use strict"});var q8=v(()=>{"use strict"});var K8=v(()=>{"use strict"});var J8=v(()=>{"use strict"});var U3e,H3e,dL=v(()=>{"use strict";J8();U3e=1440*60*1e3,H3e=10080*60*1e3});var Z8=v(()=>{"use strict"});var fp=v(()=>{"use strict"});var pL=v(()=>{"use strict";fp()});var Y8=v(()=>{"use strict";oh();bl();ui();$j()});var Do,X8=v(()=>{"use strict";Do=Le(Ke(),1);Y8()});var Q8=v(()=>{"use strict";uL();pL();X8()});var eY=v(()=>{"use strict";to()});var fL=v(()=>{"use strict"});var yh=v(()=>{"use strict"});var mL=v(()=>{"use strict";fL();yh()});var Xx=v(()=>{"use strict";fp()});var oY=v(()=>{"use strict";Xx()});var sY=v(()=>{"use strict";fp();Ro()});var aY=v(()=>{"use strict";fp();Xx();pL();oY();sY();fp();Xx()});var Qx=v(()=>{"use strict";mL();yh()});var lY=v(()=>{"use strict";yh();Qx()});var uY=v(()=>{"use strict";Qx();dL();Ro();xn();Si()});var dY=v(()=>{"use strict"});var pY=v(()=>{"use strict";Pn();Xo();Wt()});var fY=v(()=>{"use strict"});var mY=v(()=>{"use strict"});var gY=v(()=>{"use strict"});var hY=v(()=>{"use strict"});var gL=v(()=>{"use strict";er();ss();Wt()});var hL=v(()=>{"use strict";$t();Wt();er()});var yL=v(()=>{"use strict";dp();Yx();ex();ui();hL()});var bL=v(()=>{"use strict";dp();Yx();mi();yL()});var bh=v(()=>{"use strict"});import{exec as CPe,execFile as _Pe}from"node:child_process";import{promisify as yY}from"node:util";var KYe,JYe,wL=v(()=>{"use strict";bh();KYe=yY(CPe),JYe=yY(_Pe)});var vL=v(()=>{"use strict";Kt();wL()});var bY=v(()=>{"use strict"});var wY=v(()=>{"use strict";sp();mi();vL();bY();Pn()});var vY=v(()=>{"use strict";bL();gL();wY();$t();Wt();mi();dp();Pn()});var xL=v(()=>{"use strict"});var $L=v(()=>{"use strict"});var n$=v(()=>{"use strict";xL();mi();$L()});var RL=v(()=>{"use strict";mi()});var kY=v(()=>{"use strict";Pu();er()});import{execFile as LPe}from"node:child_process";import{promisify as MPe}from"node:util";var UXe,xY=v(()=>{"use strict";sp();Cx();UXe=MPe(LPe)});var vh=v(()=>{"use strict"});var SL=v(()=>{"use strict";vh()});var kh=v(()=>{"use strict";Wt();vh();$t();SL();SL()});var $Y=v(()=>{"use strict";up()});var RY=v(()=>{"use strict";Wt();vh();$t()});var SY=v(()=>{"use strict";Vi()});var EY=v(()=>{"use strict";kh();vh();mi()});var EL=v(()=>{"use strict";mi()});var AY=v(()=>{"use strict";mi()});var xh=v(()=>{"use strict";n$();mi()});var r$=v(()=>{"use strict";Wt();$t()});var Il=v(()=>{"use strict";Wt();$t()});var PY=v(()=>{"use strict";n$();RL();mi();Xa();Zx()});var OY=v(()=>{"use strict";hY();$t();gL();vY();xL();yL();bL();hL();n$();$L();RL();kY();xY();kh();$Y();RY();SY();EY();EL();AY();xh();r$();Il();LN();PY();On()});var i$=v(()=>{"use strict";er()});var hi=v(()=>{"use strict";xx();uk();lo();er();i$();Rm();bs();Mi();ug()});var _Y=v(()=>{"use strict"});var mp=v(()=>{"use strict";to();fl();ga();Jd();as();Mi();lo();lo();uk()});var IY=v(()=>{"use strict";hi();i$()});var TY=v(()=>{"use strict";hi()});import{exec as JPe}from"node:child_process";import{promisify as ZPe}from"node:util";var KQe,AL=v(()=>{"use strict";Jj();xn();KQe=ZPe(JPe)});var NY=v(()=>{"use strict";hi();Mi();Ai();AL()});var o$=v(()=>{"use strict"});var jY=v(()=>{"use strict";hi();Mi();o$();xh()});var LY=v(()=>{"use strict";hi()});var MY=v(()=>{"use strict";hi()});var FY=v(()=>{"use strict";hi()});var BY=v(()=>{"use strict";hi()});var GY=v(()=>{"use strict";IY();TY();NY();jY();LY();MY();FY();BY()});var WY=v(()=>{"use strict";Bi();xn();Ro();Md()});import{exec as lOe}from"node:child_process";import{promisify as uOe}from"node:util";var jet,zY=v(()=>{"use strict";jet=uOe(lOe)});var UY=v(()=>{"use strict";bh()});import{exec as dOe}from"node:child_process";import{promisify as pOe}from"node:util";var zet,HY=v(()=>{"use strict";UY();zet=pOe(dOe)});var fOe,VY,qY,s$,a$=v(()=>{"use strict";fOe=Symbol.for("chant.op.GateWait"),s$=class extends(qY=Error,VY=fOe,qY){constructor(n){super(`stopped at gate ${n.op} / ${n.gate}: approve it with \`chant approve ${n.op} ${n.gate}\` and run again`);this.pending=n;this[VY]=!0;this.name="GateWait"}}});import{AsyncLocalStorage as mOe}from"node:async_hooks";import{execFile as gOe}from"node:child_process";import{promisify as hOe}from"node:util";var Zet,Yet,hp=v(()=>{"use strict";ga();Zet=hOe(gOe),Yet=new mOe});import{exec as bOe}from"node:child_process";import{promisify as wOe}from"node:util";var itt,ott,KY=v(()=>{"use strict";a$();hp();itt=wOe(bOe),ott=64*1024*1024});var JY=v(()=>{"use strict";bh()});var PL=v(()=>{"use strict"});var OL=v(()=>{"use strict";Wt();PL()});var ZY=v(()=>{"use strict";PL();OL()});import{exec as xOe}from"node:child_process";import{promisify as $Oe}from"node:util";var xtt,YY=v(()=>{"use strict";On();xtt=$Oe(xOe)});import{exec as ROe}from"node:child_process";import{promisify as SOe}from"node:util";var Itt,XY=v(()=>{"use strict";fT();Yh();Itt=SOe(ROe)});import{exec as EOe}from"node:child_process";import{promisify as AOe}from"node:util";var jtt,QY=v(()=>{"use strict";jtt=AOe(EOe)});var eX=v(()=>{"use strict";Kt();bu();vL();EL()});import{execFile as POe}from"node:child_process";import{promisify as OOe}from"node:util";function Rh(e){let t=e?.trim();if(!t)return;let n=/^[^@/\s]+@([^:/\s]+):(?!\/)/.exec(t);if(n)return n[1].toLowerCase();try{let i=new URL(t);return(i.protocol==="ssh:"?i.hostname:i.host).toLowerCase()||void 0}catch{return}}function _Oe(e){return Rh(e.FORGEJO_SERVER_URL)??Rh(e.GITHUB_SERVER_URL)}function IOe(e,t){if(e.GH_HOST?.trim()||!t||t==="github.com")return e;let n={...e,GH_HOST:t},i=e.GH_TOKEN?.trim()||e.GITHUB_TOKEN?.trim();return i&&!e.GH_ENTERPRISE_TOKEN?.trim()&&!e.GITHUB_ENTERPRISE_TOKEN?.trim()&&(n.GH_ENTERPRISE_TOKEN=i),n}async function c$(e=process.env,t){if(e.GH_HOST?.trim())return e;let n=_Oe(e);if(!n)try{let{stdout:i}=await COe("git",["remote","get-url","origin"],t?{cwd:t}:{});n=Rh(i)}catch{n=void 0}return IOe(e,n)}var COe,Sh=v(()=>{"use strict";COe=OOe(POe)});import{execFile as TOe}from"node:child_process";import{promisify as DOe}from"node:util";function jOe(e){let t=e?.trim();if(!t)return;let n=/^[^@/\s]+@[^:/\s]+:(?!\/)(.+)$/.exec(t),i;if(n)i=n[1];else try{i=new URL(t).pathname}catch{return}let r=i.replace(/^\/+/,"").replace(/\/+$/,"").replace(/\.git$/,"");return r.includes("/")?r:void 0}async function l$(e=process.env,t={}){let n=Ym(e);if(n!=="forgejo"&&n!=="gitlab")return;let i=X6(e,{kind:n});if(t.cwd){let r=await(t.remoteUrl??LOe)(t.cwd,t.remote??"origin"),o=jOe(r);o&&Rh(r)===i.host&&(i.repo=o)}return Q6(i,t.fetch)}var NOe,LOe,u$=v(()=>{"use strict";Xm();Sh();NOe=DOe(TOe);LOe=async(e,t)=>{try{return(await NOe("git",["remote","get-url",t],{cwd:e})).stdout.trim()}catch{return}}});import{exec as MOe}from"node:child_process";import{readFile as FOe}from"node:fs/promises";import{promisify as BOe}from"node:util";function GOe(e){return`chant/reconcile-${e.replace(/[^a-zA-Z0-9._-]+/g,"-")}`}function WOe(e,t){let n=[`Reconcile from live environment \`${e}\`.`,"","This PR regenerates chant TypeScript from live state to close the gap between the cloud and source. It was triggered by the following change-set entries:","","| Entry | Action | Type |","|---|---|---|"];for(let i of t)n.push(`| ${i.name} | ${i.action} | ${i.type??""} |`);return t.length===0&&n.push("| _(none)_ | | |"),n.push(""),n.push("Review the diff before merging \u2014 live import may surface values that need redaction."),n.join(`
234
+ `)}function yi(e){return`'${e.replace(/'/g,"'\\''")}'`}function tX(e){return`<!-- chant-reconcile:${yp(e)} -->`}function zOe(e,t){return`<!-- chant-reconcile-issue:${yp(e)}/${yp(t)} -->`}function yp(e){return e.replace(/[^a-zA-Z0-9._-]+/g,"-")}function UOe(e){return`reconcilePr was given the marker ${JSON.stringify(e)}, which it cannot use. The marker goes into the \`--jq\` filter that finds this Op's own comment or issue, as \`startswith("<marker>")\`, so a double quote, a backslash or a control character in it either breaks that filter or changes what it matches. Markers this activity builds itself are slugified to letters, digits, dot, underscore and hyphen and cannot contain any of the three. Keep a supplied marker to printable text without \`"\` or \`\\\`, or drop \`marker\` and pass \`op\` instead.`}function d$(e){let t=e?.trim();if(t){if(/["\\]|[\u0000-\u001f\u007f]/.test(t))throw new Error(UOe(t));return t}}function HOe(e){return`reconcilePr mode "issue" edits the one OPEN issue carrying this Op's hidden marker in place, so the marker has to name the Op. This step supplies env "${e}" and no identity, and an env alone is not unique: two Ops over one env \u2014 a stock terraform drift watch and a live one over the same root, or a terraform root and a chant environment that happen to share a name \u2014 resolve to the same marker, and each run then rewrites the other's issue title and body. Pass \`op\` with the Op's own name (every composite in tree does), or pass an explicit \`marker\` you keep unique yourself.`}function VOe(){return'reconcilePr mode "comment" posts the finding on the pull request or merge request that triggered the run, and this run has none. On GitHub Actions it needs GITHUB_REPOSITORY plus a pull request number, read from the event payload at GITHUB_EVENT_PATH (`.number` / `.pull_request.number`) or from GITHUB_REF (`refs/pull/<n>/merge`), which a pull_request event sets and nothing else does. On GitLab CI it needs CI_MERGE_REQUEST_IID plus the project (CI_MERGE_REQUEST_PROJECT_ID or CI_PROJECT_ID) and the API base (CI_API_V4_URL, or CI_SERVER_URL to derive it), which a merge_request_event pipeline sets and nothing else does. Trigger this Op from a pull_request or merge_request pipeline, or give it findingMode "issue" or "report".'}function qOe(e){if(typeof e!="object"||e===null)return;let t=e;if(typeof t.number=="number")return t.number;if(typeof t.pull_request?.number=="number")return t.pull_request.number}function nX(e,t){let n=e.GITHUB_REPOSITORY;if(!n)return;let i=/^refs\/pull\/(\d+)\//.exec(e.GITHUB_REF??"")?.[1],r=qOe(t)??(i?Number(i):void 0);if(!(r===void 0||!Number.isInteger(r)||r<=0))return{repo:n,number:r}}async function rX(e=process.env){let t,n=e.GITHUB_EVENT_PATH;if(n)try{t=JSON.parse(await FOe(n,"utf8"))}catch{t=void 0}let i=nX(e,t);if(!i)throw new Error(VOe());return i}function iX(e){return e.GITHUB_API_URL?.trim().replace(/\/+$/,"")||"https://api.github.com"}function oX(e){return Ym(e)==="forgejo"||/\/api\/v1$/.test(iX(e))?"forgejo":"github"}function sX(e){for(let t of ET[oX(e)]){let n=e[t]?.trim();if(n)return{value:n,source:t}}}function KOe(e,t){return`reconcilePr mode "comment" has pull request ${e}#${t} to post its finding on and no token to post it with. GH_TOKEN or GITHUB_TOKEN, set from github.token, already covers this on a GitHub Actions or Forgejo Actions run \u2014 set CHANT_GITHUB_TOKEN (GitHub) or CHANT_FORGEJO_TOKEN (Forgejo) to post against a different instance than the one the job runs on. It is read first where the two must differ.`}function JOe(e){return`reconcilePr mode "issue" has repository ${e} to open or edit its finding in and no token to do it with. GH_TOKEN or GITHUB_TOKEN, set from github.token, already covers this on a GitHub Actions or Forgejo Actions run \u2014 set CHANT_GITHUB_TOKEN (GitHub) or CHANT_FORGEJO_TOKEN (Forgejo) to post against a different instance than the one the job runs on. It is read first where the two must differ.`}function aX(e,t,n,i){let r=iX(e),o=oX(e)==="forgejo",s=(c,u)=>globalThis.fetch(c,{...u,...i?{signal:i}:{}}),a={apiBase:r,repo:t,token:n.value,fetch:s};if(!o)return RT(a);let l;try{l=new URL(r).host}catch{l=r}return ST({...a,host:l})}async function cX(e,t){try{return await t()}catch(n){throw n instanceof rr?new Error(`${n.message} (token from ${e.source}).`):n}}async function ZOe(e,t,n,i){let r=sX(process.env);if(!r)throw new Error(KOe(e.repo,e.number));let o=aX(process.env,e.repo,r,i);return cX(r,()=>o.upsertNote(e.number,t,`${t}
235
+
236
+ ${n}`))}function lX(e){let t=e.CI_MERGE_REQUEST_IID?.trim();if(!t)return;let n=Number(t);if(!Number.isInteger(n)||n<=0)return;let i=e.CI_SERVER_URL?.trim().replace(/\/+$/,""),r=e.CI_API_V4_URL?.trim().replace(/\/+$/,"")||(i?`${i}/api/v4`:"");if(!r)return;let o=e.CI_MERGE_REQUEST_PROJECT_ID?.trim()||e.CI_PROJECT_ID?.trim()||e.CI_MERGE_REQUEST_PROJECT_PATH?.trim()||e.CI_PROJECT_PATH?.trim()||"";if(!o)return;let s=e.CI_MERGE_REQUEST_PROJECT_PATH?.trim()||e.CI_PROJECT_PATH?.trim(),a=e.CI_MERGE_REQUEST_PROJECT_URL?.trim()||e.CI_PROJECT_URL?.trim();return{api:r,project:o,iid:n,...s?{path:s}:{},...a?{webUrl:a}:{}}}function YOe(e){let t=e.CI_PROJECT_ID?.trim();if(!t)return;let n=e.CI_SERVER_URL?.trim().replace(/\/+$/,""),i=e.CI_API_V4_URL?.trim().replace(/\/+$/,"")||(n?`${n}/api/v4`:"");if(!i)return;let r=e.CI_PROJECT_PATH?.trim(),o=e.CI_PROJECT_URL?.trim();return{api:i,project:t,...r?{path:r}:{},...o?{webUrl:o}:{}}}function CL(e){for(let n of["CHANT_GITLAB_TOKEN","GITLAB_TOKEN"]){let i=e[n]?.trim();if(i)return{header:"PRIVATE-TOKEN",value:i,source:n}}let t=e.CI_JOB_TOKEN?.trim();if(t)return{header:"JOB-TOKEN",value:t,source:"CI_JOB_TOKEN"}}function XOe(e){return`reconcilePr mode "comment" has merge request !${e} to post its finding on and no token to post it with. Set a GITLAB_TOKEN CI/CD variable (masked, scope: api) on the project \u2014 a project access token is enough \u2014 or, on an instance whose job-token allowlist covers the notes API, make CI_JOB_TOKEN available to the job. CHANT_GITLAB_TOKEN is read first where the two must differ.`}function QOe(e){return`reconcilePr mode "issue" wants to open or update an issue on GitLab project ${e} and has no token to do it with. Set a GITLAB_TOKEN CI/CD variable (masked, scope: api) on the project \u2014 a project access token is enough \u2014 or, on an instance whose job-token allowlist covers the issues API, make CI_JOB_TOKEN available to the job. CHANT_GITLAB_TOKEN is read first where the two must differ.`}function uX(e){return`${e.api}/projects/${encodeURIComponent(e.project)}/merge_requests/${e.iid}/notes`}async function bp(e,t,n,i){let r=await fetch(e,{...n,...i?{signal:i}:{},headers:{[t.header]:t.value,"content-type":"application/json"}});if(!r.ok){let o=(await r.text().catch(()=>"")).slice(0,500);throw new Error(`GitLab API ${n.method??"GET"} ${e} answered ${r.status}${o?`: ${o}`:""} (token from ${t.source}, sent as ${t.header}).`)}return r}async function eCe(e,t,n,i){let r=uX(e),o=50;for(let s=1;s<=o;s++){let a=await bp(`${r}?per_page=100&page=${s}`,t,{method:"GET"},i),c=(await a.json()).find(d=>!d.system&&(d.body??"").startsWith(n));if(c)return c.id;if(!a.headers.get("x-next-page")?.trim())return}}async function tCe(e,t,n,i,r){let o=uX(e),s=await eCe(e,t,n,r),a=JSON.stringify({body:`${n}
237
+
238
+ ${i}`}),c=await(s?await bp(`${o}/${s}`,t,{method:"PUT",body:a},r):await bp(o,t,{method:"POST",body:a},r)).json();return e.webUrl?`${e.webUrl}/-/merge_requests/${e.iid}#note_${c.id}`:`${o}/${c.id}`}function dX(e){return`${e.api}/projects/${encodeURIComponent(e.project)}/issues`}async function nCe(e,t,n,i){let r=dX(e),o=50;for(let s=1;s<=o;s++){let a=await bp(`${r}?per_page=100&page=${s}&search=${encodeURIComponent(n)}&in=description`,t,{method:"GET"},i),c=(await a.json()).find(d=>(d.description??"").startsWith(n));if(c)return c.iid;if(!a.headers.get("x-next-page")?.trim())return}}async function rCe(e,t,n,i,r,o){let s=dX(e),a=await nCe(e,t,n,o),l=JSON.stringify({title:i,description:`${n}
239
+
240
+ ${r}`}),u=await(a?await bp(`${s}/${a}`,t,{method:"PUT",body:l},o):await bp(s,t,{method:"POST",body:l},o)).json();return e.webUrl?`${e.webUrl}/-/issues/${u.iid}`:`${s}/${u.iid}`}function iCe(e){return(JSON.parse(e).entries??[]).filter(n=>n.action!=="noop").map(n=>({name:n.name,action:n.action,type:n.type}))}async function oCe(e,t,n){let i=t?" --owned":"",{stdout:r}=await Qa(`chant lifecycle plan ${yi(e)}${i} --json`,{signal:n});return iCe(r)}function sCe(e,t){if(e==="issue"){let n=d$(t.marker),i=t.op?.trim();if(!n&&!i)throw new Error(HOe(t.env));return n??zOe(i,t.env)}if(e==="comment")return d$(t.marker)??tX(t.env)}async function _L(e,t){let n=e.mode??"pull-request",i=e.owned??!1,r=sCe(n,e),o=e.entries??(e.body!==void 0?[]:await oCe(e.env,i,t)),s=e.body??WOe(e.env,o),a=e.title??`Reconcile ${e.env}: ${o.length} change(s) from live`;if(n==="report")return{mode:n,summary:s,entries:o};if(n==="issue"){let f=r,g=YOe(process.env);if(g){let w=CL(process.env);if(!w)throw new Error(QOe(g.project));let x=await rCe(g,w,f,a,s,t);return{mode:n,summary:s,entries:o,issueUrl:x}}let h=process.env.GITHUB_REPOSITORY;if(h){let w=sX(process.env);if(!w)throw new Error(JOe(h));let x=aX(process.env,h,w,t),k=await cX(w,()=>x.upsertIssue(f,a,`${f}
241
+
242
+ ${s}`));return{mode:n,summary:s,entries:o,issueUrl:k}}let{stdout:b}=await Qa(`gh issue create --title ${yi(a)} --body ${yi(`${f}
243
+
244
+ ${s}`)}`,{signal:t});return{mode:n,summary:s,entries:o,issueUrl:b.trim()}}if(n==="comment"){let f=r,g=lX(process.env);if(g){let w=CL(process.env);if(!w)throw new Error(XOe(g.iid));let x=await tCe(g,w,f,s,t);return{mode:n,summary:s,entries:o,commentUrl:x,mergeRequest:`${g.path??g.project}!${g.iid}`}}let h=await rX(),b=await ZOe(h,f,s,t);return{mode:n,summary:s,entries:o,commentUrl:b,pullRequest:`${h.repo}#${h.number}`}}let l=e.branch??GOe(e.env),c=e.output??"./infra",u=i?" --owned":"";await Qa(`git checkout -b ${yi(l)}`,{signal:t}),await Qa(`chant import --from ${yi(e.env)}${u} --output ${yi(c)} --force`,{signal:t}),await Qa(`git add ${yi(c)}`,{signal:t}),await Qa(`git commit -m ${yi(a)}`,{signal:t}),await Qa(`git push -u origin ${yi(l)}`,{signal:t});let d=await l$(process.env,{fetch:(f,g)=>globalThis.fetch(f,{...g,...t?{signal:t}:{}})});if(d){let f=await d.openPullRequest({head:l,title:a,body:s});return{mode:n,branch:l,summary:s,entries:o,prUrl:f.url??""}}let{stdout:p}=await Qa(`gh pr create --title ${yi(a)} --body ${yi(s)} --head ${yi(l)}`,{signal:t,env:await c$(process.env)});return{mode:n,branch:l,summary:s,entries:o,prUrl:p.trim()}}var Qa,p$=v(()=>{"use strict";Xm();Sh();u$();Qa=BOe(MOe)});var f$=v(()=>{"use strict"});var fX=v(()=>{"use strict";f$();Aj()});var mX=v(()=>{"use strict";f$()});var gX=v(()=>{"use strict"});var hX=v(()=>{"use strict"});var yX=v(()=>{"use strict"});var IL=v(()=>{"use strict"});import{exec as fCe}from"node:child_process";import{promisify as mCe}from"node:util";var Tnt,bX=v(()=>{"use strict";o$();IL();Bi();xh();r$();ji();$t();Tnt=mCe(fCe)});var wX=v(()=>{"use strict"});import{exec as gCe}from"node:child_process";import{promisify as hCe}from"node:util";var Hnt,vX=v(()=>{"use strict";wX();Sh();u$();p$();Hnt=hCe(gCe)});function kX(e,t){let n=e;for(let i of t.split(".")){if(typeof n!="object"||n===null)return;n=n[i]}return n}function bCe(e,t,n){if(!t)return;let i=kX(e,t);return n==="number"?typeof i=="number"&&Number.isFinite(i)?String(i):void 0:xX(i)?i:void 0}function xX(e){return typeof e=="string"&&e.length>0&&!e.includes("${")}function $X(e,t){let n=[],i=[];for(let o of[...e.entityNames].sort(pp)){let s=e.entities.get(o);if(!s){i.push({name:o,entityType:"(undeclared)",status:"unknown-type",detail:`${o} was named in entityNames and is not in the entities map, so this lexicon has nothing to translate. It is reported rather than dropped: an entity that vanished between the build and the request is a defect in the caller, and a silent omission hides it behind an estate that looks smaller.`});continue}let a=I8(t,s.entityType,s.props),l=cL(t,s.entityType),c=l?.resolveType?.(s.entityType,s.props),u=c&&c!==s.entityType?c:void 0;if(a.status!=="mapped"){i.push({name:o,entityType:s.entityType,...u?{resourceType:u}:{},status:a.status,detail:D8(T8(t,s.entityType,s.props),a,l)});continue}let{mapping:d}=a,p=d.regionProp?kX(s.props,d.regionProp):void 0,f=xX(p)?p:e.region,g=bCe(s.props,d.sizeProp,d.sizeType);n.push({name:o,entityType:s.entityType,...u?{resourceType:u}:{},kind:d.kind,provider:d.provider,...f?{region:f}:{},...g?{size:g}:{}})}let r=e.edges.map(o=>({from:o.from,to:o.to,...o.viaAttr?{via:o.viaAttr}:{},...o.toAttr?{toAttr:o.toAttr}:{}})).sort((o,s)=>pp(o.from,s.from)||pp(o.to,s.to)||pp(o.via??"",s.via??"")||pp(o.toAttr??"",s.toAttr??""));return{request:yCe,traffic:e.traffic,...e.region?{region:e.region}:{},nodes:n,edges:r,coverage:e.edgeCoverage,withheld:i}}function RX(e){return`${JSON.stringify(TL(e),null,2)}
245
+ `}function TL(e){if(Array.isArray(e))return e.map(TL);if(typeof e=="object"&&e!==null){let t={};for(let n of Object.keys(e).sort()){let i=e[n];i!==void 0&&(t[n]=TL(i))}return t}return e}var yCe,DL=v(()=>{"use strict";lL();yCe="behaviour/v1"});import{execFile as wCe}from"node:child_process";function SX(e,t){return{async predict(n){let i=await e.send(RX(n));if(!i.ok)return{ok:!1,refusal:i.refusal};let r=SCe(i.body);if(!r.ok){let o=EX(i.body);return o?{ok:!1,refusal:Ya(Is,t,o,`the engine answered ${AX(i.body)}`)}:{ok:!1,refusal:gh(Is,t,r.detail)}}return{ok:!0,answer:r.answer}}}}function xCe(e){let[t,...n]=e.value.trim().split(/\s+/);return{async send(i){let r=await new Promise(o=>{wCe(t,n,{timeout:vCe,maxBuffer:kCe,env:S8()},(a,l,c)=>{o({stdout:String(l),stderr:String(c),...a?{error:a}:{}})}).stdin?.end(i)});return r.error?{ok:!1,refusal:Ya(Is,e,EX(r.stderr)??"engine-unreachable",AX(r.stderr)||r.error.message)}:{ok:!0,body:r.stdout}}}}function $Ce(e){return SX(xCe(e),e)}function EX(e){let t=e.toLowerCase();if(/\b(out of credit|insufficient (funds|balance)|no balance|payment required)\b/.test(t))return"engine-out-of-credit";if(/\b(over quota|quota exceeded|rate limit|too many requests|throttl)/.test(t))return"engine-over-quota"}function AX(e){return e.split(`
246
+ `).find(t=>t.trim().length>0)?.trim()??""}function RCe(e,t){let n=c=>`figures.${e}.${c}`;if(typeof t!="object"||t===null||Array.isArray(t))return[`${n("")} is ${Array.isArray(t)?"an array":typeof t}, not an object`];let i=t,r=[],o=(c,u)=>{(typeof u!="number"||!Number.isFinite(u)||u<0||u>1)&&r.push(`${n(c)} is not a number in 0..1`)};(typeof i.perHour!="number"||!Number.isFinite(i.perHour)||i.perHour<0)&&r.push(`${n("perHour")} is not a non-negative finite number`),(typeof i.currency!="string"||i.currency.trim().length===0)&&r.push(`${n("currency")} is empty`),o("errorRate",i.errorRate);let s=i.headroom;if(typeof s!="object"||s===null||Array.isArray(s))r.push(`${n("headroom")} is missing`);else{let c=s;c.cpu===void 0&&c.latency===void 0&&r.push(`${n("headroom")} carries neither cpu nor latency`);for(let u of["cpu","latency"])c[u]!==void 0&&o(`headroom.${u}`,c[u])}let a=i.resilience;if(typeof a!="object"||a===null||Array.isArray(a))r.push(`${n("resilience")} is missing`);else{let c=a;(typeof c.failure!="string"||c.failure.trim().length===0)&&r.push(`${n("resilience.failure")} names no failure`),eL(c.verdict)||r.push(`${n("resilience.verdict")} is not survives/degrades/fails`),c.note!==void 0&&typeof c.note!="string"&&r.push(`${n("resilience.note")} is not a string`)}let l=i.rightSize;return l!==void 0&&(typeof l!="object"||l===null||Array.isArray(l)?r.push(`${n("rightSize")} is not an object`):typeof l.suggestion!="string"&&r.push(`${n("rightSize.suggestion")} is missing`)),r}function _s(e){return{ok:!1,detail:e}}function SCe(e){let t;try{t=JSON.parse(e)}catch{return _s(`the engine wrote ${e.length} byte(s) that are not JSON`)}if(typeof t!="object"||t===null||Array.isArray(t))return _s("the engine's answer is not an object");let n=t,i=["engine","version","tolerance"].filter(o=>typeof n[o]!="string"||n[o].trim().length===0);if(i.length>0)return _s(`the engine's answer states no ${i.join(", ")}. Every figure carries provenance, so an answer that cannot say who produced it is not a usable answer`);if(!Xj(n.basis))return _s(`the engine's answer states a basis of ${JSON.stringify(n.basis)}, which is not modeled or validated`);if(typeof n.figures!="object"||n.figures===null||Array.isArray(n.figures))return _s("the engine's answer carries no figures map");if(n.total!==void 0){let o=n.total;if(typeof o!="object"||o===null||typeof o.perHour!="number"||!Number.isFinite(o.perHour)||o.perHour<0||typeof o.currency!="string"||o.currency.trim().length===0)return _s("the engine's answer states a total that is not a non-negative rate in a named currency")}if(n.declined!==void 0){let o=n.declined;if(typeof o!="object"||o===null||Array.isArray(o))return _s("the engine's answer carries a declined list that is not a map");for(let[s,a]of Object.entries(o))if(typeof a!="string")return _s(`the engine declined ${s} with a reason that is not a string`)}let r=[];for(let[o,s]of Object.entries(n.figures))if(r.push(...RCe(o,s)),r.length>=5)break;return r.length>0?_s(`the engine's answer is malformed: ${r.slice(0,5).join("; ")}`+(r.length>=5?" (and possibly more)":"")):{ok:!0,answer:n}}function ECe(e={}){return(t,n)=>{let i=t.value.trim();if(i.length!==0){if(C8(i))return SX(_8(Is,t,n,e),t);if(!/^[a-z][a-z0-9+.-]*:\/\//i.test(i))return $Ce(t)}}}var Is,vCe,kCe,PX,OX=v(()=>{"use strict";Xa();aL();DL();Is="chant";vCe=3e4,kCe=8*1024*1024;PX=ECe()});function _X(e={}){let t=e.env??process.env,n=e.kinds??[],i=e.connect??PX;return async function(o){let s=P8(Is,o);if(s)return s;let a=v8(Is,t);if(!a)return R8(Is);let l=i(a,t);if(!l)return gh(Is,a,"no transport speaks that address \u2014 a http(s) URL is dialled with a bearer token, and a bare address is run as a command on PATH; any other scheme has no transport yet");let c=$X(o,n),u=await l.predict(c);if(!u.ok)return u.refusal;let{answer:d}=u,p=Object.create(null),f=Object.create(null);for(let g of c.withheld)f[g.name]={...g.entityType==="(undeclared)"?{}:{type:g.entityType},reason:"unsupported-kind",detail:g.detail};for(let g of c.nodes){let h=CX(d.declined,g.name)?d.declined[g.name]:void 0;if(h!==void 0){f[g.name]={type:g.entityType,reason:"read-failed",detail:`${d.engine} was sent ${g.name} as a ${g.kind} and declined it: ${h}`};continue}let b=CX(d.figures,g.name)?d.figures[g.name]:void 0;if(b===void 0){f[g.name]={type:g.entityType,reason:"read-failed",detail:`${d.engine} was sent ${g.name} and its answer names it in neither its figures nor its declined list. An engine that loses a node is reported, not rendered as an estate one node smaller.`};continue}p[g.name]=ACe(o.traffic,b,d)}return y8(o,{engine:d.engine,version:d.version,...d.total?{total:Qj(d.total.perHour,d.total.currency)}:{}},p,f)}}function CX(e,t){return e!==void 0&&Object.prototype.hasOwnProperty.call(e,t)}function ACe(e,t,n){let i=t.headroom?.cpu,r=t.headroom?.latency,o=i!==void 0?{cpu:i,...r!==void 0?{latency:r}:{}}:{latency:r};if(i===void 0&&r===void 0)throw new Error("predictBehaviour: the engine's figure for this entity carries neither a cpu nor a latency headroom axis, and parseEngineAnswer should have refused it.");return{at:{traffic:e},cost:Qj(t.perHour,t.currency),headroom:o,errorRate:t.errorRate,resilience:{failure:t.resilience.failure,verdict:t.resilience.verdict,...t.resilience.note?{note:t.resilience.note}:{}},...t.rightSize?{rightSize:t.rightSize}:{},provenance:{engine:n.engine,version:n.version,tolerance:n.tolerance,basis:n.basis}}}var IX=v(()=>{"use strict";Xa();DL();OX()});import{exec as PCe}from"node:child_process";import{mkdtemp as OCe,rm as TX}from"node:fs/promises";import{join as DX,resolve as NX}from"node:path";import{promisify as CCe}from"node:util";function m$(e){return`'${e.replace(/'/g,"'\\''")}'`}function jX(){return{verdict:"unknown"}}async function _Ce(e,t){let{loadChantConfigUpward:n}=await Promise.resolve().then(()=>(Kt(),tw)),{loadPlugins:i,resolveProjectLexicons:r}=await Promise.resolve().then(()=>(cp(),g$)),{build:o}=await Promise.resolve().then(()=>(sp(),R9)),{buildGraphIr:s}=await Promise.resolve().then(()=>(oh(),I9)),{config:a}=await n(e),l=await r(e),c=await i(l),u=c.map(k=>k.behaviourKinds).filter(k=>k!==void 0),d=NX(e,a.sourceDir??"."),p=await o(d,c.map(k=>k.serializer));if(p.errors.length>0){let k=p.errors.map(R=>typeof R=="string"?R:R.message??String(R));throw new Error(`predictBehaviour: the project under ${e} did not build: ${k.join("; ")}`)}let f=new Map;for(let[k,R]of p.entities){let $=R;typeof $.entityType=="string"&&f.set(k,{entityType:$.entityType,props:$.props!=null?$.props:{}})}let g=s(p.entities,d).edges,h=[...p.outputs.values()][0],b=h===void 0?"":typeof h=="string"?h:h.primary,w={environment:t.environment,buildOutput:b,entityNames:[...f.keys()],entities:f,...t.stack?{stack:t.stack}:{},...t.region?{region:t.region}:{},...t.owned!==void 0?{owned:t.owned}:{},traffic:t.traffic,edges:g,edgeCoverage:jX(),from:"declared"},x=await _X({kinds:u})(w);return M8(x,w.entityNames)}function LX(e,t){return`<!-- chant-behaviour:${yp(e)}/${yp(t)} -->`}function MX(){return"behaviourFinding predicts the pull request's declared estate against its base branch's, and this run names no base branch. On GitHub Actions and Forgejo Actions a pull_request event sets GITHUB_BASE_REF; on GitLab CI a merge_request_event pipeline sets CI_MERGE_REQUEST_TARGET_BRANCH_NAME. Trigger the Op from one of those, or pass `base` with the branch name."}function FX(e,t){let n=t?.trim();if(n)return n;for(let i of["GITHUB_BASE_REF","CI_MERGE_REQUEST_TARGET_BRANCH_NAME"]){let r=e[i]?.trim();if(r)return r}}function BX(e,t){for(let n of["GITHUB_HEAD_REF","CI_MERGE_REQUEST_SOURCE_BRANCH_NAME"]){let i=e[n]?.trim();if(i)return i}return t?.trim()||"head"}async function ICe(e,t){let{stdout:n}=await wp("git rev-parse --show-toplevel",{signal:t}),{stdout:i}=await wp("git rev-parse --show-prefix",{signal:t}),r=n.trim(),o=i.trim(),s="FETCH_HEAD";try{await wp(`git fetch --depth=1 origin ${m$(e)}`,{signal:t})}catch{s=e}let a=await OCe(DX(r,".chant-behaviour-base-"));try{await wp(`git worktree add --detach ${m$(a)} ${m$(s)}`,{signal:t})}catch(l){throw await TX(a,{recursive:!0,force:!0}),new Error(`behaviourFinding could not check out base branch ${JSON.stringify(e)}: ${l.message}`)}return{projectPath:o?DX(a,o):a,async cleanup(){try{await wp(`git worktree remove --force ${m$(a)}`)}catch{await TX(a,{recursive:!0,force:!0})}}}}async function TCe(){try{let{stdout:e}=await wp("git rev-parse --short HEAD");return e.trim()}catch{return}}function DCe(e={}){let t=e.predict??_Ce,n=e.checkout??ICe,i=e.post??_L,r=e.env??process.env,o=e.shortSha??TCe;return async function(a,l){let c=a.mode??"comment";if(typeof a.op!="string"||a.op.trim()==="")throw new Error("behaviourFinding needs `op`, the name of the Op this step belongs to: it keys the comment's marker together with `environment`, and an env alone is not unique across Ops (#2319).");let u=FX(r,a.base);if(!u)throw new Error(MX());let d=BX(r,await o()),p={environment:a.environment,traffic:a.traffic,...a.stack?{stack:a.stack}:{},...a.region?{region:a.region}:{},...a.owned!==void 0?{owned:a.owned}:{}},f=await t(NX("."),p),g=await n(u,l),h;try{h=await t(g.projectPath,p)}finally{await g.cleanup()}let b=F8({label:"base",ref:u,result:h},{label:"head",ref:d,result:f}),w=W8(b,{env:a.environment,op:a.op}),x=Za(h)||Za(f),k={mode:c,base:u,head:d,finding:b,refused:x,summary:w};if(c==="report")return k;let R=await i({env:a.environment,op:a.op,mode:"comment",marker:d$(LX(a.op,a.environment)),body:w,title:a.title??`Predicted behaviour for ${a.environment} at ${a.traffic}`},l);return{...k,...R.commentUrl?{commentUrl:R.commentUrl}:{},...R.pullRequest?{pullRequest:R.pullRequest}:{},...R.mergeRequest?{mergeRequest:R.mergeRequest}:{}}}}var wp,NCe,GX=v(()=>{"use strict";Xa();Zx();IX();p$();wp=CCe(PCe);NCe=DCe()});import{execFile as jCe}from"node:child_process";import{promisify as LCe}from"node:util";var brt,WX=v(()=>{"use strict";Sh();u$();brt=LCe(jCe)});var zX=v(()=>{"use strict"});var LL={};_e(LL,{DEFAULT_TIMEOUT_MS:()=>NL,DecideConfigError:()=>ec,SYSTEMONE_PATH:()=>HX,backendAsk:()=>FCe,brokeredCapability:()=>jL,checkKey:()=>MCe,postQuestion:()=>KX,questionName:()=>VX,resolveKey:()=>qX});function jL(e,t){let n;try{n=Lt(Qt(t).tree).members}catch(s){throw new ec(`the key names the brokered capability ${e.capability}, and the workspace declaration can't be read: ${s instanceof Error?s.message:String(s)}`)}let i=n.filter(s=>(e.member===void 0||s.name===e.member)&&s.box?.capabilities.some(a=>a.name===e.capability));if(i.length===0){let s=e.member!==void 0?`member ${e.member}'s box does not declare the capability ${e.capability}`:`no member's box declares the capability ${e.capability}`;throw new ec(`${s} (box.capabilities in chant.workspace.json, #2726)`)}if(i.length>1)throw new ec(`the capability ${e.capability} is declared by ${i.map(s=>s.name).join(" and ")}: name the member in the key`);let r=i[0],o=r.box.capabilities.find(s=>s.name===e.capability);if(o.broker===null)throw new ec(`member ${r.name}'s capability ${e.capability} names no broker (WSP122), so nothing holds its key`);return{member:r.name,broker:o.broker,scope:o.scope}}function MCe(e,t,n){if(e!==void 0){if(typeof e=="string")throw new ec(`${t} is a literal string; a key is { env: "<VARIABLE>" } or a brokered capability, never the key itself (SYS001)`);e!==null&&typeof e=="object"&&"capability"in e&&jL(e,n)}}function qX(e,t,n=process.env){if(e===void 0)return;if("capability"in e){let r=jL(e,t);if(e.env===void 0)return;let o=n[e.env];if(!o)throw new Error(`the broker ${r.broker} has not set ${e.env} for the capability ${e.capability}`);return o}let i=n[e.env];if(!i)throw new Error(`the environment variable ${e.env} is not set`);return i}function UX(e){let t=e.replace(/\s+/g," ").trim();return t.length>300?`${t.slice(0,300)}...`:t}async function KX(e,t,n,i){let r=qX(e.key,i.cwd,i.env),o=VX(n.point),s={model:n.model,state:n.state,questions:{[o]:{type:n.question.type,instructions:n.question.instructions,criteria:n.question.criteria}}},a=`${e.url.replace(/\/+$/,"")}${HX}`,l=AbortSignal.timeout(e.timeoutMs??NL),c=i.signal?AbortSignal.any([i.signal,l]):l,u;try{u=await(i.transport??fetch)(a,{method:"POST",headers:{"content-type":"application/json",accept:"application/json",...r?{authorization:`Bearer ${r}`}:{}},body:JSON.stringify(s),signal:c})}catch(h){let b=l.aborted?`no answer within ${e.timeoutMs??NL} ms`:h instanceof Error?h.message:String(h);throw new Error(`${t} at ${a}: ${b}`)}let d=await u.text();if(!u.ok)throw new Error(`${t} at ${a} answered ${u.status}${d?`: ${UX(d)}`:""}`);let p;try{p=JSON.parse(d)}catch{throw new Error(`${t} at ${a} answered with something that is not JSON: ${UX(d)}`)}let f=p;if(f===null||typeof f!="object")throw new Error(`${t} answered with no JSON object`);if(typeof f.model!="string"||f.model==="")throw new Error(`${t}'s response names no model`);let g=f.answers?.[o];if(g===null||typeof g!="object")throw new Error(`${t}'s response has no answer to ${o}`);return{model:f.model,answer:g,response:f}}function FCe(e){return async t=>{let n=e.backends[t.backend];if(!n)throw new Error(`no backend named ${t.backend} is configured (decide.backends)`);let{model:i,answer:r,response:o}=await KX(n,t.backend,t,e);return e.onResponse?.(t.backend,o),{model:i,answer:r}}}var HX,NL,VX,ec,ML=v(()=>{"use strict";_t();ai();HX="/v1/systemone",NL=3e4,VX=e=>e,ec=class extends Error{constructor(t){super(t),this.name="DecideConfigError"}}});function FL(e,t,n){return async(i,r,o)=>{let s=`${BCe(e)}${r}`,a=await n(s,{method:i,headers:{...t,...o!==void 0?{"Content-Type":"application/json"}:{}},...o!==void 0?{body:JSON.stringify(o)}:{}}),l=await a.text();if(!a.ok)throw new rr(i,s,a.status,l);if(!l)return null;try{return JSON.parse(l)}catch{return l}}}async function BL(e,t){let n=t.fetch??globalThis.fetch,i=e.url?{url:e.url}:{},r=g=>({status:"skipped",forge:e.forge,reason:g,...i}),o=g=>({status:"would-resume",forge:e.forge,how:`would ${g}`,...i});if(e.forge==="github"){let g=FL(e.api,{Authorization:`Bearer ${t.token}`,Accept:"application/vnd.github+json"},n),h=`/repos/${e.repo}/actions/runs/${e.run}`,b=await g("GET",h);if(!Ts(b))throw new Error(`GET ${h} returned no run`);if(b.status!=="completed")return r(`run ${e.run} is ${String(b.status)}, not finished`);let w=typeof b.run_attempt=="number"?b.run_attempt:void 0;return e.attempt!==void 0&&w!==void 0&&w>e.attempt?r(`run ${e.run} was already re-run (attempt ${w}; attempt ${e.attempt} waited)`):b.conclusion==="success"?r(`run ${e.run} succeeded`):t.dryRun?o(`re-run the failed jobs of run ${e.run}`):(await g("POST",`${h}/rerun-failed-jobs`,{}),{status:"resumed",forge:"github",how:`re-ran the failed jobs of run ${e.run}`,...i})}if(e.forge==="gitlab"){let g=FL(e.api,{"PRIVATE-TOKEN":t.token},n),h=`/projects/${encodeURIComponent(decodeURIComponent(e.repo))}`,b=await g("GET",`${h}/jobs/${e.job}`);if(!Ts(b))throw new Error(`GET ${h}/jobs/${e.job} returned no job`);let w=String(b.status);if(w==="success")return r(`job ${e.job} succeeded`);if(!["failed","canceled","skipped"].includes(w))return r(`job ${e.job} is ${w}, not finished`);let x=e.jobName??(typeof b.name=="string"?b.name:void 0);if(x){let $=await g("GET",`${h}/pipelines/${e.run}/jobs?per_page=100`),_=Array.isArray($)?$.find(T=>Ts(T)&&T.name===x):void 0;if(Ts(_)&&String(_.id)!==String(e.job))return r(`job ${e.job} (${x}) was already retried as job ${String(_.id)}`)}if(t.dryRun)return o(`retry job ${e.job}`);let k=await g("POST",`${h}/jobs/${e.job}/retry`),R=Ts(k)&&k.id!==void 0?` as job ${String(k.id)}`:"";return{status:"resumed",forge:"gitlab",how:`retried job ${e.job}${R}`,...i}}let s=FL(e.api,{Authorization:`token ${t.token}`,Accept:"application/json"},n),a=`/repos/${e.repo}`,l=await s("GET",`${a}/actions/runs/${e.run}`);if(!Ts(l))throw new Error(`GET ${a}/actions/runs/${e.run} returned no run`);let c=String(l.status);if(c==="success")return r(`run ${e.run} succeeded`);if(["waiting","running","blocked","unknown"].includes(c))return r(`run ${e.run} is ${c}, not finished`);let u=await s("GET",`${a}/actions/runs?workflow_id=${encodeURIComponent(e.workflow)}&limit=50`),d=Ts(u)&&Array.isArray(u.workflow_runs)?u.workflow_runs:Array.isArray(u)?u:[],p=t.since?Math.floor(new Date(t.since).getTime()/1e3)*1e3:void 0,f=d.find(g=>Ts(g)&&Number(g.id)>Number(e.run)&&(g.prettyref===void 0||g.prettyref===e.ref)&&(p===void 0||typeof g.created=="string"&&new Date(g.created).getTime()>=p));return Ts(f)?r(`run ${String(f.id)} of ${e.workflow} started after the approval`):t.dryRun?o(`dispatch ${e.workflow} on ${e.ref}`):(await s("POST",`${a}/actions/workflows/${encodeURIComponent(e.workflow)}/dispatches`,{ref:e.ref}),{status:"resumed",forge:"forgejo",how:`dispatched ${e.workflow} on ${e.ref}`,...i})}function GL(e,t=process.env){return t.CHANT_FORGE_TOKEN?t.CHANT_FORGE_TOKEN:e==="gitlab"?t.GITLAB_TOKEN:t.GITHUB_TOKEN??t.GH_TOKEN}var BCe,Ts,JX=v(()=>{"use strict";Xm();gd();BCe=e=>e.replace(/\/+$/,""),Ts=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)});function WL(e,t,n=[t]){let i=t.environment,r=e.filter(o=>i===void 0||o.environment===i);if(t.approval){let o=el(r,t.gate,t.timestamp,t.planDigest,t.approval,tl(n,t));return o.permit?o.permit:o.counted.length>=o.need?o.counted[o.counted.length-1]:void 0}return Nr(r,t.gate,t.timestamp,t.planDigest).resolution}var ZX=v(()=>{"use strict";ji();Fi();JX()});function e7(e,t){let n=new Map;for(let i of e){if(t!==void 0&&i.gate!==t)continue;let r=`${i.gate}\0${i.environment??""}`,o=n.get(r);(!o||Lo(i.timestamp)>=Lo(o.timestamp))&&n.set(r,i)}return[...n.values()]}function YX(e,t,n,i){if(n===void 0)return;let r={gate:t,planDigest:n,timestamp:i.timestamp,...i.review?{review:{pr:i.review.pr,head:i.review.head}}:{}};if(Lr(e,r))return e.find(o=>Lr([o],r))}function h$(e){let t=e.applied??[],n=e.finished??[],i=e.answering??GCe,r=[],o=e7(e.pending,e.gate).filter(s=>!Wn(s,e.now));for(let s of o){let a={source:"pending",op:s.op||e.op,gate:s.gate,...s.environment!==void 0?{environment:s.environment}:{},...s.planDigest!==void 0?{planDigest:s.planDigest}:{},...zc(s.resume)?{run:s.resume}:{},pending:s};if(s.answer){let u=sg(s,e.questions?.get(s.answer.id));if(!u.resumable){r.push({...a,resumable:!1,reason:"not-approved",message:u.message});continue}let p=e.resolutions.filter(f=>f.gate===s.gate&&f.answer?.id===s.answer.id&&mt(f.planDigest,s.planDigest)).map(f=>({r:f,by:YX(t,s.gate,s.planDigest,f)})).find(f=>f.by);if(p?.by){r.push({...a,resumable:!1,reason:"spent",approvedBy:u.answeredBy,approvedAt:p.r.timestamp,message:QX(p.by),spent:XX(p.by)});continue}r.push({...a,resumable:!0,reason:"answered",approvedBy:u.answeredBy,...u.answeredOn?{approvedAt:u.answeredOn}:{},message:`question ${s.answer.id} has an answer the gate passes on`});continue}let l=i(e.resolutions,s,e.pending);if(!l){r.push({...a,resumable:!1,reason:"not-approved",message:s.approval&&!e.answering?"its gate has an approval block, which needs chant's tally (pass answering)":"no approval answers it yet"});continue}let c=YX(t,s.gate,s.planDigest,l);if(c){r.push({...a,resumable:!1,reason:"spent",approvedBy:l.resolvedBy,approvedAt:l.timestamp,message:QX(c),spent:XX(c)});continue}r.push({...a,resumable:!0,reason:"approved",approvedBy:l.resolvedBy,approvedAt:l.timestamp,message:`approved by ${l.resolvedBy} at ${l.timestamp}`})}for(let s of WCe(t,n,e.pending,e.gate))r.push({source:"stopped",op:s.op||e.op,gate:s.gate,planDigest:s.planDigest,resumable:!0,reason:"stopped",approvedBy:s.approvedBy,approvedAt:s.approvedAt,run:s.resume,stopped:{appliedAt:s.timestamp,approvedAt:s.approvedAt,kind:s.kind,...s.wave?{wave:s.wave}:{}},message:`the apply of ${s.planDigest} under the approval by ${s.approvedBy||"?"} began at ${s.timestamp} and never recorded how it ended; it resumes once run ${s.resume.run} is gone`});return r}function WCe(e,t,n,i){let r=new Map;for(let s of e){if(i!==void 0&&s.gate!==i)continue;let a=r.get(s.gate);(!a||Lo(s.timestamp)>=Lo(a.timestamp))&&r.set(s.gate,s)}let o=[];for(let[s,a]of r){let l=e.filter(u=>u.gate===s&&mt(u.planDigest,a.planDigest)&&Lo(u.approvedAt)===Lo(a.approvedAt)&&zc(u.resume)),c=l.reduce((u,d)=>!u||Lo(d.timestamp)>=Lo(u.timestamp)?d:u,void 0);c&&(l.some(u=>iq(t,u))||n.some(u=>u.gate===s&&Lo(u.timestamp)>Lo(c.timestamp))||o.push(c))}return o}var Lo,GCe,XX,QX,zL=v(()=>{"use strict";Bc();Wc();On();ok();gd();Lo=e=>new Date(e).getTime();GCe=(e,t)=>{if(t.approval)return;let n=e.filter(i=>t.environment===void 0||i.environment===t.environment);return Nr(n,t.gate,t.timestamp,t.planDigest).resolution};XX=e=>({appliedAt:e.timestamp,approvedAt:e.approvedAt,...e.wave?{wave:e.wave}:{}}),QX=e=>`the approval that answers it is spent: ${e.wave?`wave ${e.wave.number} (${e.wave.name})`:"a wave"} applied under it at ${e.timestamp}`});var qL={};_e(qL,{readAppliedGateFile:()=>n7,resumeAfterAnswer:()=>HCe,resumeAfterApproval:()=>UCe,resumeCandidate:()=>UL,resumeOpGates:()=>y$,resumeStanding:()=>zCe,resumeWaitingGates:()=>r7,runResumeCommand:()=>VL,workspaceQuestions:()=>t7});async function t7(e){let{workspacePoints:t}=await Promise.resolve().then(()=>(Eh(),w$)),n=await t({cwd:e}).catch(()=>{});return!n||!("questions"in n)?new Map:new Map(n.questions.map(i=>[i.id,{id:i.id,state:i.state,answer:i.answer,answeredBy:i.answeredBy,answeredOn:i.answeredOn}]))}async function zCe(e,t,n={},i=[e]){let[r]=h$({op:e.op,pending:[e],resolutions:t,applied:n.applied??[],now:e.timestamp,...n.questions?{questions:n.questions}:{},answering:(o,s)=>WL(o,s,i)});return UL(r,n)}async function UL(e,t={}){let n={op:e.op,gate:e.gate,...e.environment!==void 0?{environment:e.environment}:{},source:e.source,status:"not-approved",reason:e.reason,resumable:e.resumable,message:e.message,...e.planDigest!==void 0?{planDigest:e.planDigest}:{},...e.approvedBy!==void 0?{approvedBy:e.approvedBy}:{},...e.approvedAt!==void 0?{approvedAt:e.approvedAt}:{},...e.run?.url?{url:e.run.url}:{},...e.run?{run:e.run}:{},...e.spent?{spent:e.spent}:{},...e.stopped?{stopped:{...e.stopped}}:{}};if(e.reason==="spent")return{...n,status:"spent"};if(!e.resumable)return n;if(!e.run)return{...n,status:"no-job",message:"its pending fact names no CI job (it was recorded outside CI); run it again by hand"};let i=e.source==="stopped",r=GL(e.run.forge,t.env??process.env);if(t.dryRun&&!i)return{...n,status:"would-resume",message:`would resume ${e.run.forge} run ${e.run.run}; ${e.message}`};if(!r){let o=`${e.run.forge==="gitlab"?"GITLAB_TOKEN":"GITHUB_TOKEN"}`;return{...n,...i?{resumable:!1}:{},status:"no-token",message:i?`${e.message}; whether run ${e.run.run} is gone needs a token to read ${e.run.forge} with: set CHANT_FORGE_TOKEN (or ${o})`:`no token to call ${e.run.forge} with: set CHANT_FORGE_TOKEN (or ${o})`}}try{let o=i?e.stopped.appliedAt:e.approvedAt,s=await BL(e.run,{token:r,...o?{since:o}:{},...t.fetch?{fetch:t.fetch}:{},...t.dryRun?{dryRun:!0}:{}}),a=s.status==="skipped"?s.reason:s.how;if(!i)return{...n,status:s.status,message:a};let l=s.status!=="skipped";return{...n,status:s.status,resumable:l,message:l?`the apply that began at ${e.stopped.appliedAt} stopped and its run is gone: ${a}`:`the apply that began at ${e.stopped.appliedAt} is left alone: ${a}`,stopped:{...e.stopped,runGone:l}}}catch(o){return{...n,status:"failed",message:o instanceof Error?o.message:String(o)}}}async function n7(e){let{dir:t,file:n}=Gc(e),i=await nn(t,n);return i?rq(i):{applied:[],finished:[]}}async function y$(e,t,n={}){let i=await jr(e),r=n.applied?{applied:n.applied,finished:n.finished??[]}:await n7(e),o=n.now??new Date().toISOString(),s=n.questions??(i.pending.some(c=>c.answer)?await t7(process.cwd()):void 0),a=h$({op:e,pending:i.pending,resolutions:i.resolutions,applied:r.applied,finished:r.finished,now:o,...t!==void 0?{gate:t}:{},...s?{questions:s}:{},answering:WL}),l=[];for(let c of a)l.push(await UL(c,n));return l}function HL(e){let t=`${e.op} / ${e.gate}${e.environment!==void 0?` (${e.environment})`:""}`,n=e.approvedBy?`, approved by ${e.approvedBy}`:"",i=e.url?` ${e.url}`:"";e.status==="resumed"?console.error(Ip(`${t}${n}: ${e.message}${i}`)):e.status==="would-resume"?console.error(ur(`${t}${n}: ${e.message}${i}`)):e.status==="failed"||e.status==="no-token"?console.error(fe({message:`${t}${n}: not resumed: ${e.message}`,hint:"GitHub needs actions: write; GitLab a token with the api scope and the Developer role; Forgejo a token with write:repository."})):console.error(ur(`${t}${n}: not resumed: ${e.message}${i}`))}async function UCe(e,t,n,i){if(!i)return console.error(Hr({message:"Not resuming: the approval did not reach the remote, so the resumed job would not see it.",hint:"Push chant/lifecycle, then run `chant run resume --op "+e+"`."})),1;let r=(await y$(e,t)).filter(o=>n===void 0||o.environment===n);if(r.length===0)return console.error(ur(`No pending fact for ${e} / ${t} is waiting, so there is nothing to resume.`)),0;for(let o of r)HL(o);return r.some(o=>o.status==="failed"||o.status==="no-token")?1:0}async function HCe(e,t=process.cwd()){let n=Kv(e.subject);if(!n)return console.error(ur(`Question ${e.id} names no gate in its subject, so there is nothing to resume.`)),0;if(e.ledger===null)return console.error(Hr({message:`Not resuming: the answer to ${e.id} is in the working tree, and the resumed job would not see it.`,hint:`Commit and push it, then run \`chant run resume --op ${n.op}\`.`})),1;if((await od({cwd:t})).status!=="pushed")return console.error(Hr({message:"Not resuming: the answer did not reach the remote, so the resumed job would not see it.",hint:`Push chant/lifecycle, then run \`chant run resume --op ${n.op}\`.`})),1;let i=(await y$(n.op,n.gate)).filter(r=>r.environment===void 0);if(i.length===0)return console.error(ur(`No pending fact for ${n.op} / ${n.gate} is waiting, so there is nothing to resume.`)),0;for(let r of i)HL(r);return i.some(r=>r.status==="failed"||r.status==="no-token")?1:0}async function r7(e={}){let{op:t,gate:n,...i}=e,r=t?[t]:(await Lc(av)).filter(s=>s.endsWith(".jsonl")).map(s=>s.slice(0,-6)),o=[];for(let s of r)o.push(...await y$(s,n,i));return o}async function VL(e){try{await oi()}catch(i){return console.error(fe({message:`Cannot read the gate ledgers: ${i instanceof Error?i.message:String(i)}`})),1}let t=e.args.dryRun===!0,n=await r7({...e.args.op?{op:e.args.op}:{},...e.args.gate?{gate:e.args.gate}:{},dryRun:t});if(e.args.json)console.log(JSON.stringify({dryRun:t,reports:n},null,2));else{for(let o of n.filter(s=>s.status!=="not-approved"))HL(o);let i=n.filter(o=>o.status==="not-approved").length,r=t?`${n.filter(o=>o.resumable).length} would resume`:`${n.filter(o=>o.status==="resumed").length} resumed`;console.error(ur(`${r}, ${i} still waiting for an approval or a passing answer.`))}return n.some(i=>i.status==="failed"||!t&&i.status==="no-token")?1:0}var b$=v(()=>{"use strict";ji();Wc();$t();bs();ZX();zL();Kn()});var w$={};_e(w$,{POINTS_CONTRACT_VERSION:()=>s7,POINTS_ERROR_CODES:()=>JCe,POINTS_OUTPUT_SCHEMA_ID:()=>a7,POINTS_SOURCE_REASON_CODES:()=>ZCe,formatPoints:()=>c7,readQuestionStates:()=>YCe,responseAsk:()=>l7,runWorkspacePoints:()=>ZL,workspacePoints:()=>JL});import{readFileSync as VCe}from"node:fs";import{relative as qCe,resolve as o7,sep as KCe}from"node:path";async function JL(e){let t={$schema:a7,contract:s7,chant:Xt()},n,i;try{n=Qt(e.cwd,e.at),i=Lt(n.tree)}catch(c){if(!(c instanceof ve))throw c;return{...t,error:{code:c.code,message:c.message,location:c.location??null}}}let r=e.kind!==void 0?[{shown:e.kind,file:o7(e.cwd,e.kind),given:!0}]:Ti(i).map(c=>({shown:c.path,file:ja(c,n.rootOnDisk),given:!1})),o=[],s=[],a=[];for(let c of r)try{let u=await gn(c.file);if(!u.kind.answers){c.given&&o.push({kind:c.shown,points:null,reason:{code:"kind-invalid",message:`the ${u.kind.name} kind has no answers block, so it holds no answers to decision points`}});continue}let d,p=await Ds({kind:c.file,cwd:e.cwd,at:e.at,overlay:async(w,{loaded:x,root:k})=>(d=await $g({file:x.file,name:x.kind.name,dirRel:qCe(k,x.dir).split(KCe).join("/")||"."}),Rg(w,d))}),f=p.at!==null&&p.top?Ra(p.top,p.at):Ad(p.root),g=Sd(p.loaded,p.root),h=Ed(f,g),b="points"in h?h.points:{};o.push({kind:c.shown,points:g,reason:"error"in h?{code:"points-invalid",message:h.error}:null});for(let[w,x]of Object.entries(b))s.push({name:w,title:x.title,kind:c.shown,file:g,version:xa(x),questionType:x.question.type,instructions:x.question.instructions,candidates:x.adhoc?[]:fo(x.question),criteria:x.question.criteria??(x.question.type==="score"?[]:{}),adhoc:!!x.adhoc,inputs:Object.entries(x.inputs).map(([k,R])=>({name:k,output:Vc(k),description:R})),deciders:x.deciders,quorum:Rd(x)});for(let w of p.result.records){let x=vp(w,typeof w.data?.point=="string"?b[w.data.point]:void 0,d?.byPath.get(w.path)?.ledger??null);x&&(!e.open||x.open)&&a.push(x)}}catch(u){if(!(u instanceof Ve))throw u;o.push({kind:c.shown,points:null,reason:{code:u.code,message:u.message}})}let l=c=>a.filter(u=>u.state===c).length;return{...t,at:n.at,workspace:{name:i.name,root:n.root},open:!!e.open,sources:o,points:s,questions:a,summary:{points:s.length,questions:a.length,open:a.filter(c=>c.open).length,escalated:l("escalated"),proposed:l("proposed"),answered:l("answered")}}}async function YCe(e){try{let t=await JL({cwd:e});return!("questions"in t)||t.sources.some(n=>n.reason!==null)?null:new Map(t.questions.map(n=>[n.id,n.state]))}catch{return null}}function c7(e){let t=[];for(let i of e.sources)i.reason&&t.push(`${i.kind}: ${i.reason.code}: ${i.reason.message}`);for(let i of e.points)t.push(`${i.name} ${i.questionType}${i.adhoc?", ad hoc":""} ${i.title} (${i.deciders.map(r=>r.kind).join(", ")})`);e.points.length===0&&t.push("no decision points are declared"),t.push("");for(let i of e.questions){let r=i.model&&i.state!=="answered"?` model ${JSON.stringify(i.model.answer)} at ${i.model.confidence??"?"}${i.model.observed?"":`, below ${i.model.threshold??"?"}`}`:"";t.push(`${i.id} ${i.state} ${i.title}${r}`)}let n=e.summary.questions;return t.push(e.open?`${n} open ${n===1?"question":"questions"}`:`${n} ${n===1?"question":"questions"}, ${e.summary.open} open`),t.join(`
247
+ `)}function l7(e){return async t=>{let n=e;if(n===null||typeof n!="object")throw new Error("the response is not a JSON object");if(typeof n.model!="string"||n.model==="")throw new Error("the response names no model");let i=n.answers?.[t.point];if(i===null||typeof i!="object")throw new Error(`the response has no answer for ${t.point}`);return{model:n.model,answer:i}}}function tc(e,t){return{$schema:Fo,contract:Mo,verb:e,error:{code:"write-usage-invalid",message:t}}}function KL(e,t,n,i){let r;try{r=XCe(n)?n:VCe(n==="-"?0:o7(i,n),"utf-8")}catch(o){return{$schema:Fo,contract:Mo,verb:e,error:{code:"write-input-invalid",message:`${t} ${n} could not be read: ${o instanceof Error?o.message:String(o)}`}}}try{return{value:JSON.parse(r)}}catch(o){return{$schema:Fo,contract:Mo,verb:e,error:{code:"write-input-invalid",message:`${t} ${n} is not JSON: ${o instanceof Error?o.message:String(o)}`}}}}async function ZL(e){let{args:t}=e,n=process.cwd(),i=s=>(console.log(JSON.stringify(s,null,2)),"error"in s?1:0),r=t.extraPositional;if(r==="ask"){let s=t.extraPositional2;if(!s)return i(tc("ask","ask needs the point's name"));if(t.inputs===void 0)return i(tc("ask","--inputs <file|-|json> is required"));if(t.inputs==="-"&&t.candidates==="-")return i(tc("ask","--inputs and --candidates can't both read standard input: give one as a file or as JSON"));let a=KL("ask","--inputs",t.inputs,n);if(!("value"in a))return i(a);let l;if(t.candidates!==void 0){let u=KL("ask","--candidates",t.candidates,n);if(!("value"in u))return i(u);l=u.value}let c;if(t.response!==void 0){let u=KL("ask","--response",t.response,n);if(!("value"in u))return i(u);c=l7(u.value)}return i(await YL({cwd:n,point:s,inputs:a.value,candidates:l,subject:t.subject,kind:t.kind,ask:c,...t.store?{store:t.store}:{},dryRun:t.dryRun}))}if(r==="answer"){let s=t.extraPositional2;if(!s)return i(tc("answer","answer needs the question's id"));if(t.answer===void 0)return i(tc("answer","--answer <value> is required"));if(!t.bys||t.bys.length===0)return i(tc("answer","--by <name> is required, once for each person who answered"));let a=await XL({cwd:n,id:s,answer:t.answer,by:t.bys,note:t.note,relayedBy:t.relayedBy,kind:t.kind,dryRun:t.dryRun}),l=i(a);if(l!==0||t.dryRun||!(t.resumeRun||t.resume!==void 0)||!("question"in a))return l;let{resumeAfterAnswer:c}=await Promise.resolve().then(()=>(b$(),qL));return c(a.question,n)}if(r==="retract"){let s=t.extraPositional2;return s?!t.bys||t.bys.length===0?i(tc("retract","--by <name> is required, once for each person who takes the answer back")):i(await QL({cwd:n,id:s,by:t.bys,note:t.note,kind:t.kind,dryRun:t.dryRun})):i(tc("retract","retract needs the question's id"))}if(r!==void 0)return console.error(fe({message:`chant workspace points takes no argument but ask, answer or retract (got ${r})`,hint:i7})),1;let o=await JL({cwd:n,at:t.at,open:t.open,kind:t.kind});return t.json?console.log(JSON.stringify(o,null,2)):"error"in o?console.error(fe({message:`${o.error.code}: ${o.error.message}`,hint:i7})):console.log(c7(o)),"error"in o?1:0}var s7,a7,JCe,ZCe,i7,XCe,Eh=v(()=>{"use strict";Kn();_t();Gd();v$();Dm();mo();Sg();mn();vo();ai();s7=1,a7="https://intentius.io/chant/schemas/workspace/points/v1/points.schema.json",JCe=["declaration-missing","declaration-ambiguous","declaration-unparseable","declaration-invalid","placement-invalid","reader-too-old","root-chant-required","not-a-git-repository","revision-unknown"],ZCe=["kind-unreadable","kind-invalid","schema-unreadable","schema-id-mismatch","schema-invalid","location-missing","points-invalid"];i7=["chant workspace points [--open] [--kind <kind file>] [--at <rev>] [--json]","chant workspace points ask <point> --inputs <file|-|json> [--candidates <file|-|json>] [--response <file>] [--subject <id>] [--kind <kind file>] [--dry-run]","chant workspace points answer <id> --answer <value> --by <name> [--by <name>...] [--note <text>] [--relayed-by <principal>] [--kind <kind file>] [--resume] [--dry-run]","chant workspace points retract <id> --by <name> [--by <name>...] [--note <text>] [--kind <kind file>] [--dry-run]"].join(`
248
+ `);XCe=e=>/^\s*[[{]/.test(e)});var u7,eM=v(()=>{"use strict";sl();_t();Zt();u7=".chant/generated.json"});function d7(e){return e===".gitlab-ci.yml"?!0:/^(\.github\/workflows|\.forgejo\/workflows|\.gitea\/workflows|\.gitlab\/ci)\/[^/]+$/.test(e)}var p7=v(()=>{"use strict";Dg();eM()});function e_e(e,t){let n;try{n=hd.load(t)}catch{return null}if(!n||typeof n!="object"||Array.isArray(n))return null;let i=n;if(e.startsWith(".gitlab/ci/")||e===".gitlab-ci.yml")return Object.entries(i).filter(([o,s])=>!o.startsWith(".")&&!QCe.has(o)&&s&&typeof s=="object"&&!Array.isArray(s)).map(([o])=>o);let r=i.jobs;return!r||typeof r!="object"||Array.isArray(r)?null:Object.entries(r).map(([o,s])=>{let a=s&&typeof s=="object"?s.name:void 0;return typeof a=="string"&&a!==""?a:o})}function f7(e,t,n){let i=a=>ze(n,a),r=new Map,o=ze(e.dir,u7);if(t.stat(o)==="file")try{let a=JSON.parse(t.read(o));for(let l of Array.isArray(a.files)?a.files:[])typeof l.path=="string"&&r.set(l.path,{path:l.path,command:typeof l.command=="string"?l.command:"",env:typeof l.env=="string"?l.env:null,jobs:null})}catch{}for(let a of e.generated){if(a.handWritten)continue;let l=i(ze(e.dir,a.path));r.set(l,{path:l,command:a.generator,env:r.get(l)?.env??null,jobs:null})}let s=n==="."?"":`${n}/`;for(let a of r.values()){if(!d7(a.path)||!a.path.startsWith(s))continue;let l=a.path.slice(s.length);if(t.stat(l)==="file")try{a.jobs=e_e(a.path,t.read(l))}catch{a.jobs=null}}return[...r.values()].sort((a,l)=>a.path<l.path?-1:a.path>l.path?1:0)}var QCe,m7=v(()=>{"use strict";SI();p7();eM();Zt();QCe=new Set(["stages","variables","default","include","workflow","image","services","cache","before_script","after_script","pages"])});import{isAbsolute as t_e,resolve as hit}from"node:path";function k$(e,t,n){if(t.stat(e.dir==="."?"":e.dir)!=="dir")return{code:"dir-missing",message:`${e.dir} is not a directory${t.label}`};let i=n.get(e.kind);return i?fV(i,t,e.dir==="."?"":e.dir)?null:{code:"kind-probe-failed",message:`${e.dir} is not ${i.description}`}:{code:"unknown-kind",message:`no built-in kind or pinned package supplies kind ${e.kind}; known kinds: ${n.names().join(", ")}`}}function h7(e){return i_e(e).doc}function i_e(e){let t=Xt(),n={$schema:r_e,contract:n_e,chant:t};try{let i=Qt(e.cwd,e.at),{tree:r,rootOnDisk:o,at:s}=i,a=Lt(r,"",{rootChant:!0}),l=e.kinds??pa(a.pins,o).registry,c=ma(a,r),u=t_e(i.root)?".":i.root,d=s!==null?{agents:a.agents,from:"at"}:sT(e.cwd)??{agents:a.agents,from:"working-tree"},p=a.members.map(b=>{let w=k$(b,r,l);return{name:b.name,dir:b.dir,kind:b.kind,roles:b.roles,upstream:b.upstream,because:b.because,readable:w===null,reason:w,records:g7(b.records),generated:f7(b,r,u),agents:d.agents.filter(x=>x.members.includes(b.name)).map(x=>x.name),...hm(a,b.pointer)}}),f=c.map(b=>({name:b.group.name,kind:"examples",glob:b.group.globs,matches:b.matches,skipped:b.skipped,reason:b.matches.length===0?{code:"no-matches",message:`no directory ${b.group.globs.join(" or ")} matches${r.label} holds a chant project`}:null})),g=O0(a).map(b=>({name:b.name,title:b.title,source:b.source,render:b.render,renderer:b.renderer,member:b.member}));return{doc:{...n,at:s,workspace:{name:a.name,root:i.root,file:a.file,schema:a.schema,minReader:a.minReader,pins:a.pins,records:g7(a.records),agentsFrom:d.from,...hm(a,"")},members:p,groups:f,diagrams:g,ci:a.ci?{green:a.ci.green?{branch:a.ci.green.branch,window:a.ci.green.window,phases:a.ci.green.phases.map(b=>({name:b.name,runs:b.runs,skipped:b.skipped})),require:a.ci.green.require}:null}:null,summary:{members:p.length,unreadable:p.filter(b=>!b.readable).length,groups:f.length,matches:f.reduce((b,w)=>b+w.matches.length,0)}},declaration:a,tree:r,rootOnDisk:o}}catch(i){if(!(i instanceof ve))throw i;return{doc:{...n,error:{code:i.code,message:i.message,location:i.location??null}}}}}var n_e,r_e,g7,tM=v(()=>{"use strict";Kn();_t();m7();ao();ai();ms();n_e=1,r_e="https://intentius.io/chant/schemas/workspace/ls/v1/ls.schema.json";g7=e=>e.map(t=>({name:t.name,path:t.path,kind:null,reason:null,acceptance:null}))});function y7(e,t){let n=e;for(let i of t.split(".")){if(n===null||typeof n!="object"||!Object.prototype.hasOwnProperty.call(n,i))return;n=n[i]}return n}function b7(e,t,n="acceptance"){let i=e??{},r=Array.isArray(i[n])?i[n]:[],o=nM(y7(i,"source.ask.said"))||nM(y7(i,"source.intent.answer")),s=t.split(`
249
+ `).filter(u=>!o_e.test(u)),a=r.map(u=>typeof u=="string"?u:nM(u?.text)),l=[o,...s,...a].join(`
250
+ `),c=new Set([...l.matchAll(/`([^`\s]+)`/g)].map(u=>u[1]).filter(u=>s_e.test(u)));return{criteria:r.length,files:c.size,words:l.split(/\s+/).filter(Boolean).length}}function a_e(e,t){return t?["criteria","files","words"].every(n=>t[n]===void 0||e[n]<=t[n]):!1}function w7(e,t=rM){let n={criteria:e.criteria,files:e.files,words:e.words};for(let[i,r]of Object.entries(t))n[`fits_${i}`]=a_e(e,r);return n}var rM,o_e,s_e,nM,v7=v(()=>{"use strict";rM=Object.freeze({small:{criteria:10,files:5,words:150},medium:{criteria:20,files:10,words:300}}),o_e=/^\s*#/,s_e=/^[\w@.-]+(\/[\w@.*-]+)+\/?$|^[\w@-][\w@.-]*\.[a-z]{1,5}$/i,nM=e=>typeof e=="string"?e:""});var k7={};_e(k7,{InputReadError:()=>nc,READABLE_OUTPUTS:()=>iM,fieldOf:()=>x$,readInputs:()=>m_e});import{readFileSync as c_e}from"node:fs";import{join as l_e}from"node:path";function x$(e,t){let n=e;for(let i of t.split(".")){if(n===null||typeof n!="object"||!Object.prototype.hasOwnProperty.call(n,i))return;n=n[i]}return n}async function u_e(e,t,n){let i=ci(t),r=await $$(i,{cwd:t}),o=[];for(let[s,a]of r.kinds.entries()){if("error"in a){o.push(`${a.declared.path}: ${a.error.code}`);continue}let l=a.records.find(c=>c.id===e);if(l){let c=l;return n==="work-item"?{...c,...await d_e(i[s].file,l.path,l.data,t)}:c}}throw new nc(`no declared record kind holds a record with id ${e} (read for ${n})${o.length?`; not read: ${o.join(", ")}`:""}`)}async function d_e(e,t,n,i){let o=(await gn(e,i)).kind.work;if(!o)return{};let s=Qt(i),a="";try{a=BI(c_e(l_e(s.top??s.rootOnDisk,...t.split("/")),"utf-8"))}catch{}let l=b7(n,a,o.acceptance?.field??"acceptance");return w7(l,o.tier?.limits??rM)}function p_e(e,t){let n=h7({cwd:t});if("error"in n)throw new nc(`the workspace can't be listed: ${n.error.code}: ${n.error.message}`);let i=n.members.find(r=>r.name===e);if(!i)throw new nc(`the workspace has no member named ${e}`);return i}function f_e(e,t,n){let i=e.length>t.length?e.slice(t.length+1):"";if(i==="")return n;if(t==="member")return x$(n,i);let r=x$(n.data,i);return r!==void 0?r:x$(n,i)}async function m_e(e,t,n){let i=new Set(e.map(Vc));for(let a of Object.keys(t)){if(!iM.includes(a))throw new nc(`${a} is not read by id here; pass its values in inputs, as the read contract printed them (read takes ${iM.join(", ")})`);if(!i.has(a))throw new nc(`the point reads no ${a} input (its inputs are ${e.join(", ")})`)}let r=new Map;for(let[a,l]of Object.entries(t))r.set(a,a==="member"?p_e(l,n):await u_e(l,n,a));let o={},s=[];for(let a of e){let l=Vc(a),c=r.get(l);if(c===void 0)continue;let u=f_e(a,l,c);u===void 0?s.push(a):o[a]=u}return{inputs:o,missing:s}}var iM,nc,x7=v(()=>{"use strict";vo();tM();Dm();mn();ai();v7();iM=["record","decision","work-item","member"],nc=class extends Error{constructor(t){super(t),this.name="InputReadError"}}});var E7={};_e(E7,{DecideError:()=>bi,decide:()=>S7,runDecide:()=>R7});async function g_e(e,t){let{checkKey:n,DecideConfigError:i}=await Promise.resolve().then(()=>(ML(),LL)),r=e.backends;if(r===void 0){let{config:s}=await Ys(t);r=s.decide?.backends??{}}if(r===null||typeof r!="object"||Array.isArray(r))throw new i("backends must be an object of backend name to { url, key? }");let o={};for(let[s,a]of Object.entries(r)){n(a?.key,`backend ${s}'s key`,t);let l=ku.safeParse(a);if(!l.success)throw new i(`backend ${s} is not { url, key?, timeoutMs? }: ${l.error.issues.map(c=>`${c.path.join(".")||"(backend)"} ${c.message}`).join("; ")}`);o[s]=l.data}return o}async function h_e(e,t){let{workspacePoints:n}=await Promise.resolve().then(()=>(Eh(),w$)),i=await n({cwd:t,...e.kind!==void 0?{kind:e.kind}:{}});if("error"in i)throw new bi(i.error.code,i.error.message);let r=i.points.find(o=>o.name===e.point);if(!r){let o=i.sources.find(s=>s.reason);throw new bi("point-unknown",`no points file declares ${JSON.stringify(e.point)}${o?` (${o.kind}: ${o.reason.message})`:i.points.length?` (the points are ${i.points.map(s=>s.name).join(", ")})`:""}`)}return r}function $7(e,t){let n=typeof e.decider.kind=="string"?e.decider.kind:"quorum",i=n==="model";return{id:e.id,path:e.path,state:e.state,open:e.open,answer:e.answer,decider:n,model:i?e.model?.model??null:null,backend:i?e.model?.backend??null:null,confidence:i?e.confidence:null,threshold:i?e.threshold:null,reason:i?e.reason:null,answeredBy:e.answeredBy,escalations:e.escalations,missing:t}}async function R7(e,t={},n){if(typeof e?.point!="string"||e.point==="")throw new bi("write-usage-invalid","decide needs the point's name");let i=e.cwd??process.cwd(),{backendAsk:r,brokeredCapability:o,checkKey:s,DecideConfigError:a}=await Promise.resolve().then(()=>(ML(),LL)),l=k=>{try{return k()}catch(R){throw R instanceof a?new bi("backend-invalid",R.message):R}},c;try{c=await g_e(e,i)}catch(k){throw k instanceof a?new bi("backend-invalid",k.message):k}let u=await h_e(e,i),d;for(let k of u.deciders){if(k.kind!=="model")continue;let R=c[k.backend];if(!R)throw new bi("backend-invalid",`${e.point}'s model decider names the backend ${k.backend}, and none is configured (decide.backends${Object.keys(c).length?`: ${Object.keys(c).join(", ")}`:" is empty"})`);if(l(()=>s(R.key,`backend ${k.backend}'s key`,i)),d===void 0&&R.key&&"capability"in R.key){let $=R.key;d={capability:$.capability,broker:l(()=>o($,i)).broker}}}let p={inputs:{},missing:[]};if(e.read&&Object.keys(e.read).length>0)try{let{readInputs:k}=await Promise.resolve().then(()=>(x7(),k7));p=await k(u.inputs.map(R=>R.name),e.read,i)}catch(k){throw new bi("point-inputs-invalid",k instanceof Error?k.message:String(k))}let f={...p.inputs,...e.inputs??{}},g=p.missing.filter(k=>!(k in f)),h=r({backends:c,cwd:i,...t.transport?{transport:t.transport}:{},...t.env?{env:t.env}:{},...n?{signal:n}:{},...t.onResponse?{onResponse:t.onResponse}:{}}),b=bo(),w=async k=>{let R=c[k.backend]?.key;if(b&&R&&!("capability"in R))throw new Error(`in the steward ${b.steward}'s turn a model call goes through the broker, and backend ${k.backend}'s key is the environment variable ${R.env}, a credential the steward would hold`);return h(k)},x={cwd:i,point:e.point,inputs:f,...e.subject!==void 0?{subject:e.subject}:{},...e.kind!==void 0?{kind:e.kind}:{},...e.store!==void 0?{store:e.store}:{},...t.on?{on:t.on}:{}};if(e.dryRun){let{askPoint:k}=await Promise.resolve().then(()=>(v$(),sM)),R=await k({...x,ask:await R$(w,{...d||{},turn:b??null,cwd:i}),...b?{steward:{name:b.steward,...b.run?{run:b.run}:{}}}:{client:{name:"chant decide"}},dryRun:!0});if("error"in R)throw new bi(R.error.code,`${R.error.code}: ${R.error.message}`);return $7(R.question,g)}try{let{question:k}=await aM({...x,ask:w,...d?{capability:d.capability,broker:d.broker}:{},turn:b??null});return $7(k,g)}catch(k){if(kp(k))throw k;let R=k instanceof Error?/^decision point [^:]+: ([a-z0-9-]+): /.exec(k.message):null;throw R?new bi(R[1],k instanceof Error?k.message:String(k)):k}}async function S7(e,t){return R7(e,{},t)}var bi,oM=v(()=>{"use strict";Kt();Ah();ol();Yb();bi=class extends Error{constructor(n,i){super(i);this.code=n;this.name="DecideError"}}});var A7=v(()=>{"use strict";hp()});var P7=v(()=>{"use strict";zY();HY();KY();JY();OL();ZY();YY();XY();QY();eX();p$();AL();fX();mX();gX();hX();yX();bX();vX();GX();WX();zX();oM();A7()});var S$=v(()=>{"use strict";P7();fd();xn()});var cst,lst,ust,dst,pst,fst,mst,gst,hst,yst,bst,cM,wst,vst,kst,xst,$st,b_e,Rst,Sst,Est,E$,w_e,Ast,Pst,Ost,Cst,_st,Ist,O7=v(()=>{"use strict";Ln();xm();Yb();cst=Pt("lifecycleSnapshot",m.strictObject({env:m.string()})),lst=Pt("lifecycleDiff",m.strictObject({env:m.string(),live:m.boolean().optional()}),m.object({output:m.string(),exitCode:m.number(),drifted:m.boolean()})),ust=Pt("shellCmd",m.strictObject({cmd:m.string(),env:m.record(m.string(),m.string()).optional(),cwd:m.string().optional(),okExit:m.array(m.number()).optional(),gatedExit:m.number().optional(),gate:m.strictObject({op:m.string(),gate:m.string()}).optional(),json:m.boolean().optional()}),m.object({stdout:m.string(),stderr:m.string(),exitCode:m.number(),json:m.unknown().optional()})),dst=Pt("httpCheck",m.strictObject({url:m.string(),method:m.string().optional(),status:m.number().optional(),contains:m.string().optional(),retries:m.number().optional(),intervalMs:m.number().optional()}),m.object({status:m.number()}),{entities:["url"]}),pst=Pt("chantTeardown",m.strictObject({path:m.string()})),fst=Pt("predictBehaviour",m.strictObject({environment:m.string(),traffic:m.string(),stack:m.string().optional(),region:m.string().optional(),owned:m.boolean().optional()}),m.object({behaviour:m.literal("v1"),refusal:m.unknown().optional()})),mst=Pt("behaviourFinding",m.strictObject({environment:m.string(),traffic:m.string(),op:m.string(),mode:m.enum(["comment","report"]).optional(),base:m.string().optional(),title:m.string().optional(),stack:m.string().optional(),region:m.string().optional(),owned:m.boolean().optional()}),m.object({mode:m.enum(["comment","report"]),base:m.string(),head:m.string(),refused:m.boolean(),summary:m.string(),commentUrl:m.string().optional(),pullRequest:m.string().optional(),mergeRequest:m.string().optional()})),gst=Pt("proposeWorkspaceUpgrade",m.strictObject({scope:m.string().optional(),to:m.string().optional(),mode:m.enum(["report","branch","pull-request"]).optional(),branch:m.string().optional(),base:m.string().optional(),remote:m.string().optional(),allowCode:m.boolean().optional(),source:m.string().optional(),cwd:m.string().optional()}),m.object({scope:m.string(),mode:m.enum(["report","branch","pull-request"]),changed:m.boolean(),proposed:m.boolean(),checksOk:m.boolean(),from:m.string().nullable(),to:m.string().nullable(),digest:m.string(),manualSteps:m.number(),governance:m.boolean(),branch:m.string().optional(),commit:m.string().optional(),pushed:m.boolean().optional(),prUrl:m.string().optional(),summary:m.string()})),hst=Pt("changeCoverage",m.strictObject({cwd:m.string().optional(),range:m.string().optional(),work:m.string().optional(),severity:m.enum(["off","warn","fail"]).optional()}),m.object({ok:m.boolean(),range:m.object({spec:m.string(),base:m.string(),head:m.string()}),work:m.string().nullable(),severity:m.enum(["off","warn","fail"]),findings:m.array(m.object({code:m.enum(["change-uncovered","change-out-of-scope"]),path:m.string(),message:m.string(),severity:m.enum(["warn","fail"]),records:m.array(m.string()),triage:m.object({finding:m.enum(["change-uncovered","change-out-of-scope"]),region:m.string()})})),summary:m.object({paths:m.number(),covered:m.number(),uncovered:m.number(),outOfScope:m.number(),ignored:m.number(),records:m.number()})})),yst=Pt("workEvidence",m.strictObject({lease:m.unknown(),criterion:m.string(),result:m.enum(["pass","fail"]),title:m.string(),url:m.string().optional(),path:m.string().optional(),kind:m.string().optional(),cwd:m.string().optional()}),m.object({item:m.string(),path:m.string(),evidence:m.record(m.string(),m.unknown()),acceptance:m.object({met:m.number(),total:m.number(),criteria:m.array(m.object({id:m.string(),verification:m.string(),met:m.boolean()}))})})),bst=Pt("sourceArchive",m.strictObject({path:m.string(),ref:m.string().optional(),out:m.string().optional(),cwd:m.string().optional()}),m.object({digest:m.string(),archive:m.string(),commit:m.string(),dir:m.string(),files:m.number(),bytes:m.number()})),cM=m.object({member:m.object({member:m.string(),planDigest:m.string().nullable()}).passthrough(),entries:m.array(m.unknown())}),wst=Pt("composeChangeSet",m.strictObject({parts:m.array(cM)}),m.object({document:m.record(m.string(),m.unknown()),digest:m.string(),summary:m.record(m.string(),m.unknown())})),vst=Pt("lifecyclePlanChangeSet",m.strictObject({member:m.string(),env:m.string(),cwd:m.string().optional(),owned:m.boolean().optional()}),m.object({part:cM})),kst=Pt("readChangeSetPart",m.strictObject({member:m.string(),planner:m.enum(["chant","warden","sql"]),file:m.string(),lexicon:m.string().optional()}),m.object({part:cM})),xst=Pt("releasePlan",m.strictObject({component:m.string(),env:m.string(),gitSha:m.string(),content:m.record(m.string(),m.unknown()),dir:m.string().optional(),cwd:m.string().optional()}),m.object({digest:m.string(),file:m.string(),gitSha:m.string()})),$st=Pt("releaseRecord",m.strictObject({plan:m.string(),digest:m.string().optional(),approval:m.strictObject({op:m.string(),gate:m.string()}).optional(),actor:m.string().optional(),runId:m.string().optional(),cwd:m.string().optional()}),m.object({recorded:m.boolean(),digest:m.string(),env:m.string(),component:m.string(),approver:m.string().nullable()})),b_e=m.object({kind:m.enum(["table","model"]),reason:m.string()}).loose(),Rst=Pt("decide",m.strictObject({point:m.string().min(1),inputs:m.record(m.string(),m.unknown()).optional(),read:m.record(m.string(),m.string()).optional(),subject:m.string().optional(),kind:m.string().optional(),cwd:m.string().optional(),backends:m.record(m.string(),ku).optional(),dryRun:m.boolean().optional(),store:m.enum(["tree","ledger"]).optional()}),m.strictObject({id:m.string(),path:m.string(),state:m.enum(["escalated","proposed","answered"]),open:m.boolean(),answer:m.union([m.string(),m.boolean(),m.null()]),decider:m.string(),model:m.string().nullable(),backend:m.string().nullable(),confidence:m.number().nullable(),threshold:m.number().nullable(),answeredBy:m.array(m.string()),escalations:m.array(b_e),missing:m.array(m.string())}),{entities:["point"]}),Sst=Pt("releaseRollbackPlan",m.strictObject({component:m.string(),env:m.string(),to:m.string().optional(),path:m.string().optional(),dir:m.string().optional(),cwd:m.string().optional()}),m.object({digest:m.string(),file:m.string(),to:m.string(),from:m.string(),gitSha:m.string(),archive:m.string(),archiveDigest:m.string(),dir:m.string()})),Est=Pt("releaseRollbackRecord",m.strictObject({plan:m.string(),digest:m.string().optional(),approval:m.strictObject({op:m.string(),gate:m.string()}).optional(),actor:m.string().optional(),runId:m.string().optional(),cwd:m.string().optional()}),m.object({recorded:m.boolean(),digest:m.string(),env:m.string(),component:m.string(),approver:m.string().nullable()})),E$=m.unknown(),w_e=m.record(m.string(),ku).optional(),Ast=Pt("factoryPick",m.strictObject({cwd:m.string().optional(),kind:m.string().optional()}),m.strictObject({candidates:m.array(m.string()),held:m.array(m.object({item:m.string(),hold:m.string(),message:m.string()})),keys:m.array(m.string())})),Pst=Pt("factoryReady",m.strictObject({cwd:m.string().optional(),kind:m.string().optional(),also:m.string().optional()}),m.array(m.string())),Ost=Pt("factoryAsk",m.strictObject({lease:E$,cwd:m.string().optional(),kind:m.string().optional(),backends:w_e}),m.strictObject({item:m.string(),ask:m.boolean(),tier:m.string(),understand:m.string().nullable(),outcome:m.enum(["dropped","redraft","ask"]).nullable()})),Cst=Pt("factoryBuild",m.strictObject({lease:E$,ask:m.unknown(),builder:m.string().min(1),context:m.string().optional(),cwd:m.string().optional()}),m.strictObject({ran:m.boolean(),finished:m.boolean(),exitCode:m.number().nullable(),reverted:m.array(m.string()),note:m.string(),report:m.record(m.string(),m.unknown()).nullable()})),_st=Pt("factoryCheck",m.strictObject({lease:E$,build:m.unknown(),check:m.string().optional(),cwd:m.string().optional()}),m.strictObject({ran:m.boolean(),ok:m.boolean(),command:m.string().nullable(),evidence:m.array(m.string()),log:m.string().nullable(),report:m.record(m.string(),m.unknown()).nullable()})),Ist=Pt("factoryRecord",m.strictObject({lease:E$,ask:m.unknown(),build:m.unknown(),check:m.unknown(),after:m.string().optional(),cwd:m.string().optional()}),m.strictObject({outcome:m.enum(["done","not_done","dropped","redraft","ask"]),reason:m.string().nullable(),commit:m.string().nullable(),implementsProposed:m.array(m.object({decision:m.string(),paths:m.array(m.string())}))}))});var C7=v(()=>{"use strict";O7();xm();xn()});import{AsyncLocalStorage as x_e}from"node:async_hooks";var Lst,lM=v(()=>{"use strict";Lst=new x_e});var lat,Ph=v(()=>{"use strict";lo();S$();Mi();as();fd();Fi();Ai();bs();A$();dv();lM();Ah();a$();ol();Il();mp();lo();hp();Il();as();lat=5*6e4});var pM=v(()=>{"use strict"});var I7=v(()=>{"use strict";or();pM();Vg();Vb();sl();Kt();sk();Si()});var T7=v(()=>{"use strict"});var D7=v(()=>{"use strict"});var N7=v(()=>{"use strict";On()});var j7=v(()=>{"use strict";$t();kh()});var L7=v(()=>{"use strict";T7();D7();Fi();Ai();N7();j7()});var M7=v(()=>{"use strict";zj();xn();Uj();Hj()});var F7=v(()=>{"use strict";Kt()});var B7=v(()=>{"use strict";yT();xn();I7();pM();L7();Ai();Ro();$t();M7();F7();Kt()});var fM=v(()=>{"use strict"});var W7=v(()=>{"use strict";xn();Kt();S$();Ph();B7();Bi();Il();fM()});var z7=v(()=>{"use strict";fd();Ai()});var U7=v(()=>{"use strict";Fi();tv()});var hM=v(()=>{"use strict";Ph();as();Jd();al()});var yM=v(()=>{"use strict"});var K7=v(()=>{"use strict";Bi();Ph();Jd();Il();ji();ol();al();hM();mp();$t();ug();yM()});var Z7=v(()=>{"use strict";hi();Mi();mp()});var Y7=v(()=>{"use strict";hi();xx();bh();wL();_Y();lo();mp();ug();GY();xh();i$();Bi();WY();Md();SM();JO();S$();C7();fd();f$();Ph();lM();Fi();Fi();zL();Rm();dv();On();Ai();bs();A$();W7();fM();z7();U7();xm();Mi();o$();K7();hM();al();Bi();Ah();a$();ol();hp();yM();IL();hi();Z7()});var tQ=v(()=>{"use strict";Pn();ex();nx();ui();QD();tN();er();Vg();Xo();t5();or();Pu();Wt();n5();r5();bl();sl();ox();sx();dN();pN();fN();cx();kx();d9();sp();bu();oh();T9();D9();N9();j9();L9();zN();Xk();hl();hl();DN();G9();W9();V9();K9();vj();kj();Cx();Aj();s8();a8();l8();u8();d8();Ro();mi();Ux();Jj();dp();Xa();aL();lL();Zx();Yx();ux();z8();uL();U8();H8();Kt();V8();q8();K8();dL();Z8();Q8();eY();fL();mL();aY();yh();Qx();lY();uY();MN();to();dY();pY();wx();fY();mY();gY();OY();Y7()});function nQ(e){let t=[],n=[],i=new Map;for(let l of e){let c=l.lintRules?.()??[];for(let u of c){let d=i.get(u.id)??[];d.push(l.name),i.set(u.id,d)}}for(let[l,c]of i)c.length>1&&t.push({type:"rule-id",key:l,plugins:c});let r=new Map;for(let l of e){let c=l.skills?.()??[];for(let u of c){let d=r.get(u.name)??[];d.push(l.name),r.set(u.name,d)}}for(let[l,c]of r)c.length>1&&n.push({type:"skill-name",key:l,plugins:c});let o=new Map;for(let l of e){let c=l.mcpTools?.()??[];for(let u of c){let d=o.get(u.name)??[];d.push(l.name),o.set(u.name,d)}}for(let[l,c]of o)c.length>1&&n.push({type:"mcp-tool",key:l,plugins:c});let s=new Map;for(let l of e){let c=l.mcpResources?.()??[];for(let u of c){let d=s.get(u.uri)??[];d.push(l.name),s.set(u.uri,d)}}for(let[l,c]of s)c.length>1&&n.push({type:"mcp-resource",key:l,plugins:c});let a=new Map;for(let l of e){let c=l.commands?.();if(!c)continue;let u=a.get(c.name)??[];u.push(l.name),a.set(c.name,u)}for(let[l,c]of a)(c.length>1||Q$.has(l))&&t.push({type:"command-group-name",key:l,plugins:c});return{conflicts:t,warnings:n}}function rQ(e){let t=` ${e.type} "${e.key}" from: ${e.plugins.join(", ")}`;return e.type==="command-group-name"&&Q$.has(e.key)?`${t} \u2014 "${e.key}" is a reserved chant command name, so no lexicon can register a command group with it. Rename the group.`:t}var iQ=v(()=>{"use strict";eR()});import{createHash as X_e}from"node:crypto";import{existsSync as oQ,mkdirSync as egt,readFileSync as Q_e,readdirSync as tgt,rmdirSync as ngt,rmSync as rgt,writeFileSync as igt}from"node:fs";import{dirname as sgt,isAbsolute as e0e,join as sQ,relative as t0e,resolve as aQ,sep as cQ}from"node:path";function i0e(e,t){let n=t.codegen,i=typeof n?.outDir=="string"&&n.outDir.length>0?n.outDir:n0e;return aQ(e,i)}function lQ(e,t,n){return{projectRoot:t,config:n,outDir:sQ(i0e(t,n),e)}}function o0e(e){return`sha256:${X_e("sha256").update($r(e)).digest("hex")}`}function s0e(e){let t=sQ(e,r0e);if(oQ(t))try{let n=JSON.parse(Q_e(t,"utf8"));return typeof n.inputs!="string"||!Array.isArray(n.files)?void 0:{inputs:n.inputs,files:n.files.filter(i=>typeof i=="string")}}catch{return}}async function a0e(e,t,n){let i=e.projectCodegen?.();if(!i)return{status:"none"};let r=lQ(e.name,t,n),o=l0e(t,r.outDir),s=s0e(r.outDir),a=await i.inputs(r);if(a===void 0)return s?{status:"orphan",message:`${o} holds generated ${e.name} code, but chant.config declares no ${e.name} sources for it. Run \`chant generate\` to remove it.`}:{status:"none"};if(!s)return{status:"missing",message:`chant.config declares ${e.name} sources to generate, but ${o} has no generated code. Run \`chant generate\` and commit the result.`};let l=s.files.filter(c=>!oQ(c0e(r.outDir,c)));return l.length>0?{status:"missing",message:`generated ${e.name} file(s) missing from ${o}: ${l.join(", ")}. Run \`chant generate\` and commit the result.`}:s.inputs!==o0e(a)?{status:"drift",message:`generated ${e.name} code in ${o} is out of date: its declared sources changed since it was generated. Run \`chant generate\` and commit the result.`}:{status:"current"}}async function uQ(e,t,n){let i=await a0e(e,t,n);if("message"in i)throw new Error(i.message);i.status!=="none"&&await e.projectCodegen?.().load?.(lQ(e.name,t,n))}function c0e(e,t){let n=aQ(e,t);if(e0e(t)||n!==e&&!n.startsWith(e+cQ))throw new Error(`generated file path "${t}" is outside ${e}`);return n}function l0e(e,t){let n=t0e(e,t);return n===""?".":n.split(cQ).join("/")}var n0e,r0e,lgt,dQ=v(()=>{"use strict";er();sl();n0e="src/generated",r0e="chant-codegen.json",lgt=`// ${ak}. Run \`chant generate\` to update.`});var g$={};_e(g$,{collectBuildRootContributors:()=>o3,collectChangeSubscribers:()=>b0e,listInstalledLexicons:()=>y0e,loadPlugin:()=>mQ,loadPlugins:()=>w3,recordProjectLexicons:()=>h0e,resolveLexiconVersions:()=>i3,resolveProjectLexicons:()=>v3,unknownPathLexiconsNotice:()=>qD});import{createRequire as u0e}from"node:module";import{dirname as Ch,join as fQ,resolve as d0e}from"node:path";import{fileURLToPath as p0e}from"node:url";import{existsSync as f0e,readdirSync as m0e,readFileSync as g0e}from"node:fs";function h0e(e){let t=VD(e);return t.status==="read"&&Zs(t.entries,Ch(t.configPath)),t}async function mQ(e){let t=Ei(e);if(t!==void 0){let o=await bc(e);for(let s of Object.values(o))if(Yd(s)){if(s.name!==e)throw new Error(`lexicon "${e}" is declared with module ${t}, but the plugin it exports is named "${s.name}"`);return s}throw new Error(`Module ${t} (lexicon "${e}") does not export a LexiconPlugin`)}let n=`@intentius/chant-lexicon-${e}`,i=await Zr(n);for(let o of Object.values(i))if(Yd(o))return o;let r=i.serializer??i.default?.serializer??i[`${e}Serializer`];if(r&&typeof r=="object"&&"name"in r&&"serialize"in r){let o=s=>async()=>{throw new Error(`${r.name}: ${s} is not supported (raw serializer fallback)`)};return{name:r.name,serializer:r,generate:o("generate"),validate:o("validate"),coverage:o("coverage"),package:o("package")}}throw new Error(`Package ${n} does not export a LexiconPlugin or Serializer`)}function y0e(e=process.cwd()){let t=new Set,n=[Ch(p0e(import.meta.url)),d0e(e)];for(let i of n){let r=i;for(;;){let o=fQ(r,"node_modules","@intentius"),s=[];try{s=m0e(o,{withFileTypes:!0})}catch{}for(let l of s){if(!l.name.startsWith(pQ)||!l.isDirectory()&&!l.isSymbolicLink())continue;let c=l.name.slice(pQ.length);c!==""&&t.add(c)}let a=Ch(r);if(a===r)break;r=a}}return[...t].sort()}function i3(e){let t=u0e(import.meta.url),n={};for(let i of e){if(Ei(i)!==void 0)continue;let r=`@intentius/chant-lexicon-${i}`;try{let o;try{o=t.resolve(r)}catch(a){if(o=Zb(r),o===void 0)throw a}let s=Ch(o);for(let a=0;a<10;a++){let l=fQ(s,"package.json");if(f0e(l)){let u=JSON.parse(g0e(l,"utf-8"));if(u.name===r&&u.version){n[i]=u.version;break}}let c=Ch(s);if(c===s)break;s=c}}catch{}}return n}function o3(e,t,n){let i=(e??[]).filter(o=>typeof o.projectCodegen=="function").map(o=>async()=>(await uQ(o,n,t),{entities:new Map})),r=(e??[]).filter(o=>typeof o.buildRoots=="function").map(o=>s=>o.buildRoots({projectRoot:n,config:t,entities:s?.entities,...s?.sourceDir!==void 0?{sourceDir:s.sourceDir}:{}}));return[...i,...r]}function b0e(e,t){return(e??[]).filter(n=>typeof n.subscribeChanges=="function").filter(n=>(t.entities.get(n.name)?.size??0)>0).map(n=>({lexicon:n.name,subscribe:i=>n.subscribeChanges({environment:t.environment,...t.cwd?{cwd:t.cwd}:{},entities:t.entities.get(n.name),onChange:i.onChange,onError:i.onError,signal:i.signal})}))}async function w3(e){let t=[];for(let i of e){let r=await mQ(i);r.init&&await r.init(),t.push(r)}let n=nQ(t);for(let i of n.warnings)console.warn(`[chant] warning: ${i.type} "${i.key}" is provided by multiple lexicons: ${i.plugins.join(", ")}`);if(n.conflicts.length>0){let i=n.conflicts.map(rQ).join(`
251
+ `);throw new Error(`Cross-lexicon conflicts detected:
252
+ ${i}`)}return t}async function v3(e,t={}){let n=t.lexicon,{config:i}=await Xb(e),r;if(i.lexicons&&i.lexicons.length>0)r=Jr(i.lexicons);else{let o=await lk(e);try{r=await B9(o)}catch(s){if(n&&F9(s))return[n];throw s}}return n&&!r.includes(n)?[...r,n]:r}var pQ,cp=v(()=>{"use strict";xn();Qk();Qk();Ro();Kt();tQ();zN();iQ();dQ();pQ="chant-lexicon-"});import{join as w0e}from"node:path";function v0e(e,t,n){let i=t;if(!(i!==null&&typeof i=="object"&&typeof i.language=="string"&&Array.isArray(i.extensions)&&i.extensions.length>0&&i.extensions.every(s=>typeof s=="string"&&/^\.[^./\\]+$/.test(s))&&typeof i.declarations=="function")){n.push(`lexicon "${e}" returned a symbol resolver that is not { language, extensions: [".ext", ...], declarations(path, text) }`);return}let o=i.declarations.bind(i);return{language:`${i.language} (lexicon ${e})`,extensions:[...i.extensions],declarations(s,a){let l=o(s,a);return Array.isArray(l)?l.filter(c=>c!==null&&typeof c=="object"&&typeof c.qualified=="string"&&c.qualified!==""&&typeof c.kind=="string"&&Number.isInteger(c.lines?.start)&&Number.isInteger(c.lines?.end)&&c.lines.start>=1&&c.lines.end>=c.lines.start):[]}}}async function k0e(e){let{readLexiconDeclarationsStatically:t}=await Promise.resolve().then(()=>(Qk(),VZ)),n=t(e);if(n.status==="no-config")return[];if(n.status==="read"){let{registerLexiconDeclarations:o}=await Promise.resolve().then(()=>(xn(),QW)),{dirname:s}=await import("node:path");return o(n.entries,s(n.configPath)),Jr(n.entries)}let{loadChantConfig:i}=await Promise.resolve().then(()=>(Kt(),tw)),{config:r}=await i(e);return Jr(r.lexicons??[])}async function gQ(e,t){let n=[],i;try{i=await k0e(e)}catch(s){return{resolvers:[],problems:[`its chant.config could not be read: ${EM(s)}`]}}let r=t??(await Promise.resolve().then(()=>(cp(),g$))).loadPlugin,o=[];for(let s of i){let a;try{a=await r(s)}catch(c){n.push(`lexicon "${s}" could not be loaded: ${EM(c)}`);continue}if(typeof a.symbolResolvers!="function")continue;let l;try{l=a.symbolResolvers()}catch(c){n.push(`lexicon "${s}" symbolResolvers() threw: ${EM(c)}`);continue}if(!Array.isArray(l)){n.push(`lexicon "${s}" symbolResolvers() did not return a list`);continue}for(let c of l){let u=v0e(s,c,n);u&&o.push(u)}}return{resolvers:o,problems:n}}var EM,hQ,yQ=v(()=>{"use strict";xn();EM=e=>(e instanceof Error?e.message:String(e)).split(`
253
+ `)[0];hQ=(e,t)=>t==="."?e:w0e(e,...t.split("/"))});function x0e(e){return/\.tsx$/.test(e)?be.ScriptKind.TSX:/\.jsx$/.test(e)?be.ScriptKind.JSX:/\.[cm]?js$/.test(e)?be.ScriptKind.JS:be.ScriptKind.TS}function O$(e){if(e&&(be.isIdentifier(e)||be.isPrivateIdentifier(e)||be.isStringLiteral(e)||be.isNumericLiteral(e)))return e.text}function AM(e,t=[]){let n=e.toLowerCase();return[...bQ,...t].find(i=>i.extensions.some(r=>n.endsWith(r.toLowerCase())))}function PM(e,t,n,i=[]){let r=AM(e,i);if(!r){let u=[...new Set([...bQ,...i].flatMap(d=>d.extensions))].join(", ");return{ok:!1,reason:"unsupported",message:`${e} has no symbol resolver: symbols resolve in ${u} files. Give a line range, ${e}:<start>-<end>, instead`,candidates:[]}}let o=r.declarations(e,t),s=o.filter(u=>u.qualified===n);if(s.length>0){let u=Math.min(...s.map(p=>p.lines.start)),d=Math.max(...s.map(p=>p.lines.end));return{ok:!0,declaration:{qualified:n,kind:s[0].kind,lines:{start:u,end:d}}}}let a=[...new Set(o.filter(u=>u.qualified.endsWith(`.${n}`)).map(u=>u.qualified))];if(a.length===1)return PM(e,t,a[0],i);if(a.length>1)return{ok:!1,reason:"ambiguous",message:`${n} names ${a.length} declarations in ${e}: ${a.join(", ")}. Give the qualified name`,candidates:a};let l=[...new Set(o.filter(u=>!u.qualified.includes(".")).map(u=>u.qualified))],c=l.slice(0,20);return{ok:!1,reason:"unknown",message:`${e} declares no ${n}${l.length>0?`; its top-level declarations are ${c.join(", ")}${l.length>c.length?`, and ${l.length-c.length} more`:""}`:", and no top-level declaration a resolver reads"}`,candidates:c}}var be,$0e,bQ,wQ=v(()=>{"use strict";be=Le(Ke(),1);$0e={language:"TypeScript and JavaScript",extensions:[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"],declarations(e,t){let n=be.createSourceFile(e,t,be.ScriptTarget.Latest,!0,x0e(e)),i=[],r=c=>n.getLineAndCharacterOfPosition(c).line+1,o=(c,u,d)=>{i.push({qualified:c,kind:u,lines:{start:r(d.getStart(n,!0)),end:r(d.getEnd())}})},s=(c,u)=>{for(let d of u){let p=O$(d.name);if(p===void 0){be.isConstructorDeclaration(d)&&o(`${c}.constructor`,"method",d);continue}let f=`${c}.${p}`;be.isMethodDeclaration(d)||be.isMethodSignature(d)||be.isGetAccessorDeclaration(d)||be.isSetAccessorDeclaration(d)?o(f,"method",d):be.isPropertyDeclaration(d)||be.isPropertySignature(d)?(o(f,"property",d),be.isPropertyDeclaration(d)&&d.initializer&&a(f,d.initializer)):be.isEnumMember(d)?o(f,"member",d):be.isPropertyAssignment(d)?(o(f,"property",d),a(f,d.initializer)):be.isShorthandPropertyAssignment(d)&&o(f,"property",d)}},a=(c,u)=>{let d=u;for(;be.isParenthesizedExpression(d)||be.isAsExpression(d)||be.isSatisfiesExpression(d);)d=d.expression;be.isClassExpression(d)?s(c,d.members):be.isObjectLiteralExpression(d)&&s(c,d.properties)},l=(c,u)=>{let d=p=>c?`${c}.${p}`:p;for(let p of u)if(be.isFunctionDeclaration(p)&&p.name)o(d(p.name.text),"function",p);else if(be.isClassDeclaration(p)&&p.name)o(d(p.name.text),"class",p),s(d(p.name.text),p.members);else if(be.isInterfaceDeclaration(p))o(d(p.name.text),"interface",p),s(d(p.name.text),p.members);else if(be.isTypeAliasDeclaration(p))o(d(p.name.text),"type",p);else if(be.isEnumDeclaration(p))o(d(p.name.text),"enum",p),s(d(p.name.text),p.members);else if(be.isModuleDeclaration(p)){let f=O$(p.name);if(f===void 0)continue;o(d(f),"namespace",p);let g=p.body,h=d(f);for(;g&&be.isModuleDeclaration(g);)h=`${h}.${O$(g.name)}`,g=g.body;g&&be.isModuleBlock(g)&&l(h,g.statements)}else if(be.isVariableStatement(p)){let f=p.declarationList.declarations.length===1;for(let g of p.declarationList.declarations){let h=O$(g.name);h!==void 0&&(o(d(h),"variable",f?p:g),g.initializer&&a(d(h),g.initializer))}}else be.isExportAssignment(p)&&!p.isExportEquals&&(o(d("default"),"variable",p),a(d("default"),p.expression))};return l("",n.statements),i}},bQ=[$0e]});import{execFileSync as R0e}from"node:child_process";function OM(e,t){try{return R0e("git",t,{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","pipe"],maxBuffer:256*1024*1024})}catch{return}}function S0e(e,t){let n=new Map,i=[...new Set(t.filter(o=>o!==""))];if(i.length===0||OM(e,["rev-parse","--verify","--quiet",_h])===void 0)return n;let r=OM(e,["grep","-l","-F",...i.flatMap(o=>["-e",o]),_h,"--",":(glob)**/_leases/*.jsonl"]);for(let o of(r??"").split(`
254
+ `)){let s=o.startsWith(`${_h}:`)?o.slice(_h.length+1):"",a=s.match(/(?:^|\/)_leases\/([^/]+)\.jsonl$/);if(!a)continue;let l=OM(e,["show",`${_h}:${s}`]);for(let c of _k(l??"").records)i.includes(c.token)&&c.item===a[1]&&!n.has(c.token)&&n.set(c.token,c.item)}return n}function C$(e,t){let n=t.map(o=>({sha:o.sha,trailers:u6(o.trailers)})),i=S0e(e,n.map(o=>o.trailers.lease).filter(o=>o!==null)),r=new Map;for(let{sha:o,trailers:s}of n)r.set(o,{trailers:s,joins:{agent:s.agent,lease:s.lease===null?null:{token:s.lease,item:i.get(s.lease)??null},run:s.run,records:s.records.map(a=>({kind:a.kind,id:a.id,node:null})),applied:s.applied}});return r}var _h,CM=v(()=>{"use strict";fl();Fv();_h="refs/heads/chant/lifecycle"});import{createHash as E0e}from"node:crypto";function _M(e){let t=e.members.filter(n=>(n.box?.services.length??0)>0);return t.length===1?{plantable:!0,box:t[0].name,reason:null}:t.length===0?{plantable:!1,box:null,reason:{code:"box-none",message:"no member's box block declares services, so there is no box to plant"}}:{plantable:!1,box:null,reason:{code:"box-several",message:`members ${t.map(n=>n.name).join(", ")} each declare box services, and a planted workspace runs one box`}}}function vQ(e,t=[]){return e===null?null:{builds:[...e.builds],check:e.check===null?null:{...e.check},checks:e.checks,builders:e.builders,tiers:e.tiers.map(n=>({...n,kinds:n.kinds===null?null:[...n.kinds]})),builderFor:A0e(e,t),publish:e.publish===null?null:{...e.publish}}}function A0e(e,t){let n=[...new Set(e.tiers.map(r=>r.tier))],i={};for(let r of e.builds){let o=t.find(a=>a.name===r)?.kind,s={};for(let a of n){let l=e.tiers.find(c=>c.tier===a&&o!==void 0&&c.kinds?.includes(o))??e.tiers.find(c=>c.tier===a&&c.kinds===null);l&&(s[a]={agent:l.agent,session:l.session})}i[r]=s}return i}function kQ(e,t){if(e===null)return null;let n=null;if(e.cover!==null){let i=t(e.cover);n={path:e.cover,sha256:i===null?null:E0e("sha256").update(i).digest("hex")}}return{published:e.published,title:e.title,line:e.line,cover:n}}function xQ(e){return t=>{try{return e.stat(t)!=="file"?null:e.bytes?e.bytes(t):new TextEncoder().encode(e.read(t))}catch{return null}}}function $Q(e,t,n=[]){return e===null||e.factory===null&&e.listing===null?null:{factory:vQ(e.factory,n),listing:kQ(e.listing,xQ(t))}}var IM=v(()=>{"use strict"});function xp(e){let t;try{t=JSON.parse(e)}catch{return{reason:{code:"output-unreadable",message:"chant graph --format ir printed something that is not JSON"}}}if(t===null||typeof t!="object"||!Array.isArray(t.nodes)||!Array.isArray(t.edges))return{reason:{code:"output-unreadable",message:"chant graph --format ir printed JSON with no nodes and edges"}};let n=t,i=n.version;if(i===void 0)n.version=1;else if(typeof i!="number"||i>Rx)return{reason:{code:"ir-version-unsupported",message:`the member's chant printed IR version ${String(i)}, and this chant reads up to version ${Rx}`}};return n.groups??={},{ir:n,irVersion:i===void 0?null:i}}function C0e(e,t){if(typeof t!="object"||t===null||!Array.isArray(t.pipelines))return null;let n=t;return{member:e,pipelines:TM(n.pipelines).map(i=>({id:String(i.id),signal:String(i.signal),receivers:Ns(i.receivers),processors:Ns(i.processors),exporters:Ns(i.exporters)})),components:TM(n.components).map(i=>({id:String(i.id),kind:String(i.kind),type:String(i.type),endpoints:Ns(i.endpoints),protocols:Ns(i.protocols),pipelines:Ns(i.pipelines)})),exporters:TM(n.exporters).map(i=>({id:String(i.id),type:String(i.type),endpoints:Ns(i.endpoints),pipelines:Ns(i.pipelines),signals:Ns(i.signals)}))}}function DM(e,t){if(Array.isArray(e))return e.map(i=>DM(i,t));if(e===null||typeof e!="object")return e;let n={};for(let[i,r]of Object.entries(e))n[i]=i==="$ref"&&typeof r=="string"?qi(t,r):DM(r,t);return n}function RQ(e,t,n){(e[t]??=[]).push(...n)}function SQ(e){let t={};for(let n of Object.keys(e).sort())t[n]=[...e[n]].sort();return t}function EQ(e,t,n){let i=[],r=[],o=[],s=[],a={},l={byLexicon:{},byComposite:{}},c={byStack:{},byContainer:{},byWave:{}},u={},d=[];for(let{member:h,ir:b}of t){if(!b)continue;let w=h.name,x=[];for(let k of b.nodes){let R={...k,id:qi(w,k.id),member:w,attrs:DM(k.attrs??{},w)};k.compositeInstance&&(R.compositeInstance=qi(w,k.compositeInstance)),k.runtimeOwner&&(R.runtimeOwner=qi(w,k.runtimeOwner)),i.push(R),x.push(R.id)}a[w]=x.sort();for(let k of b.edges)r.push({...k,from:qi(w,k.from),to:qi(w,k.to),member:w});for(let k of["byLexicon","byComposite"])for(let[R,$]of Object.entries(b.groups[k]??{}))RQ(l[k],R,$.map(_=>qi(w,_)));for(let k of["byStack","byContainer","byWave"])for(let[R,$]of Object.entries(b.groups[k]??{}))RQ(c[k],qi(w,R),$.map(_=>qi(w,_)));for(let k of b.exports??[])o.push({...k,...k.node?{node:qi(w,k.node)}:{},member:w});for(let k of b.imports??[])s.push({...k,node:qi(w,k.node),member:w});for(let[k,R]of Object.entries(b.derivedAttrs??{}))for(let $ of R)(u[k]??=new Set).add($);if(b.meta){let{[O0e]:k,...R}=b.meta,$=C0e(w,k);$&&d.push($),$?Object.keys(R).length>0&&(h.meta=R):h.meta=b.meta}b.pipeline&&(h.pipeline=b.pipeline)}i.sort((h,b)=>h.id.localeCompare(b.id));let p=h=>`${h.from}\0${h.to}\0${h.viaAttr??""}`;r.sort((h,b)=>p(h).localeCompare(p(b)));let f={byMember:a};for(let h of["byLexicon","byComposite"])Object.keys(l[h]).length&&(f[h]=SQ(l[h]));for(let h of["byStack","byContainer","byWave"])Object.keys(c[h]).length&&(f[h]=SQ(c[h]));let g={version:P0e,workspace:e,members:t.map(h=>h.member),nodes:i,edges:r,groups:f,exports:o,imports:s,links:n?lZ(n.declaration,{composed:t.filter(h=>h.ir).map(h=>h.member.name),collectors:d,exports:o,imports:s},n.kinds):[],collectors:d,records:[]};return Object.keys(u).length&&(g.derivedAttrs=Object.fromEntries(Object.keys(u).sort().map(h=>[h,[...u[h]].sort()]))),g}var P0e,O0e,qi,Ns,TM,_$=v(()=>{"use strict";Dg();oh();P0e=1,O0e="collector";qi=(e,t)=>`${e}/${t}`,Ns=e=>Array.isArray(e)?e.filter(t=>typeof t=="string"):[],TM=e=>Array.isArray(e)?e.filter(t=>typeof t=="object"&&t!==null):[]});var AQ=v(()=>{"use strict"});var NM,PQ,OQ=v(()=>{"use strict";bu();_t();NM="@@chant-member-run@@ ",PQ=1});import{spawn as _0e}from"node:child_process";import{existsSync as I0e,mkdirSync as TQ,realpathSync as T0e,writeFileSync as D0e}from"node:fs";import{dirname as Th,join as Ih,resolve as Dh}from"node:path";import{fileURLToPath as N0e}from"node:url";function CQ(){return Dh(Th(N0e(import.meta.url)),"..","..","bin","chant")}function DQ(e){try{return T0e(e)}catch{return e}}function I$(){let e=process.argv[1]??"";return{command:/[\\/]cli[\\/]main\.(ts|js|mjs)$/.test(e)?[process.execPath,...process.execArgv,e]:[CQ()],identity:DQ(CQ()),source:"reader"}}function j0e(e,t,n=I$()){for(let i=e;;i=Th(i)){let r=Ih(i,"node_modules",".bin","chant");if(I0e(r)){let o=DQ(r),s=i===t?"root":"member";return o===n.identity?{...n,source:s}:{command:[r],identity:o,source:s}}if(i===t||Th(i)===i)break}return n}function T$(e,t,n={}){let i=n.tree??$n(t),r=Lt(i),o=ma(r,i),s=n.kinds??pV(),a=n.only?.length?new Set(n.only):void 0;if(a){let g=new Set(r.entries.map(b=>b.name)),h=[...a].filter(b=>!g.has(b));if(h.length>0)throw new ve("declaration-invalid",`--member names ${h.join(", ")}, which the declaration does not declare; it declares ${[...g].join(", ")}`)}let l=[],c=[],u=[],d=e==="build"||e==="lint";for(let g of r.entries){if(a&&!a.has(g.name))continue;if(g.type==="group"){let w=o.find(x=>x.group===g);if(!d){c.push({name:g.name,dir:null,kind:g.kind,reason:{code:"kind-not-run",message:`example groups are built and linted only; chant workspace ${e} leaves them out`}});continue}for(let x of w.matches)l.push({id:`${g.name}:${x}`,member:g.name,kind:g.kind,group:!0,dir:x,abs:Ih(t,x),exclude:[]});continue}let h=e==="graph"&&g.kind!=="chant"?s.get(g.kind):void 0;if(h?.graph&&h.packageDir){let w=k$(g,i,s);if(w){u.push({name:g.name,dir:g.dir,kind:g.kind,reason:w});continue}l.push({id:g.name,member:g.name,kind:g.kind,group:!1,dir:g.dir,abs:g.dir==="."?t:Ih(t,g.dir),exclude:[],reader:{...h.graph,packageDir:h.packageDir}});continue}if(g.kind!=="chant"){let w=g.kind==="workspace"?"a nested workspace runs its own chant workspace commands":g.kind==="design"?"a design member is data: chant reads its files for record pins and builds nothing":`chant workspace ${e} runs members of kind chant, and this one is kind ${g.kind}`;c.push({name:g.name,dir:g.dir,kind:g.kind,reason:{code:"kind-not-run",message:w}});continue}let b=k$(g,i,s);if(b){u.push({name:g.name,dir:g.dir,kind:g.kind,reason:b});continue}l.push({id:g.name,member:g.name,kind:g.kind,group:!1,dir:g.dir,abs:g.dir==="."?t:Ih(t,g.dir),exclude:g.dir==="."?ev(r,o).map(w=>w.dir):[]})}let p=n.reader??I$(),f=new Map;for(let g of l){let h=j0e(g.abs,t,p),b=f.get(h.identity)??{toolchain:h,units:[]};b.units.push(g),f.set(h.identity,b)}return{verb:e,workspace:{name:r.name,root:t,file:r.file},groups:[...f.values()],unreadable:u,skipped:c}}function _Q(e,t){return e==="graph"?"ir":e==="audit"?"json":e==="lint"?t.format==="sarif"||t.format==="json"?t.format:"stylish":t.format==="yaml"?"yaml":"json"}function jM(e,t,n){let i=e==="build"&&!n.format?[e,"."]:[e,".","--format",_Q(e,n)],r=()=>{for(let o of n.param??[])i.push("--param",o);n.paramsFile&&i.push("--params-file",Dh(n.paramsFile))};return e==="build"?(n.env&&i.push("--env",n.env),r(),n.lexicon&&i.push("--lexicon",n.lexicon),n.output&&i.push("--output",L0e(n.output,t,_Q(e,n)))):e==="lint"?(r(),n.fix&&i.push("--fix")):e==="audit"?(n.tier&&i.push("--tier",n.tier),n.failOn&&i.push("--fail-on",n.failOn),n.maxFiles!==void 0&&i.push("--max-files",String(n.maxFiles))):(n.env&&(!t.reader||n.live)&&i.push("--env",n.env),n.live&&i.push("--live"),n.overlay&&i.push("--overlay"),n.traffic&&i.push("--traffic",n.traffic)),i}function L0e(e,t,n){let i=n==="yaml"?"yaml":"json";return`${Dh(e,t.group?Ih(t.member,t.dir):t.member)}.${i}`}function IQ(e,t,n,i){let[r,...o]=e;return new Promise(s=>{let a=_0e(r,[...o,...t],{cwd:n,stdio:["pipe","pipe","pipe"],env:process.env}),l=[],c=[];a.stdout.on("data",u=>l.push(u)),a.stderr.on("data",u=>c.push(u)),a.on("error",u=>s({exitCode:127,stdout:"",stderr:`could not start ${r}: ${u.message}
255
+ `})),a.on("close",u=>s({exitCode:u??1,stdout:Buffer.concat(l).toString("utf8"),stderr:Buffer.concat(c).toString("utf8")})),a.stdin.on("error",()=>{}),a.stdin.end(i??"")})}function M0e(e){let t,n=new Map,i=[];for(let r of e.split(`
256
+ `)){if(!r.startsWith(NM)){r.trim()&&i.push(r);continue}let o;try{o=JSON.parse(r.slice(NM.length))}catch{continue}o.type==="header"&&!t?t=o:o.type==="result"&&t&&n.set(o.id,o)}return t?{chant:t.chant,results:n,stray:i.join(`
257
+ `)}:void 0}async function F0e(e,t,n,i,r){let{toolchain:o,units:s}=t,a=new Map(s.map(f=>[f.id,r?r(f):jM(e,f,i)]));for(let f of s){let g=a.get(f.id),h=g.indexOf("--output");h>=0&&TQ(Th(g[h+1]),{recursive:!0})}let l={protocol:PQ,units:s.map(f=>({id:f.id,dir:f.abs,argv:a.get(f.id),...f.exclude.length?{exclude:f.exclude}:{}}))},c=await IQ(o.command,["workspace","member-run"],n,JSON.stringify(l)),u=new Date().toISOString(),d=M0e(c.stdout);if(d)return d.stray&&process.stderr.write(`${d.stray}
258
+ `),s.map(f=>{let g=d.results.get(f.id),h={unit:f,toolchain:o,chant:d.chant,mode:"member-run",id:f.id,member:f.member,dir:f.dir,exclude:f.exclude};return g?{...h,exitCode:g.exitCode,stdout:g.stdout,stderr:g.stderr,finishedAt:g.finishedAt??u}:{...h,exitCode:c.exitCode||1,stdout:"",stderr:`the member-run process for ${o.identity} ended before running this member
259
+ ${c.stderr}`}});let p=[];for(let f of s){let g=await IQ(o.command,a.get(f.id),f.abs);p.push({unit:f,toolchain:o,chant:null,mode:"per-member",id:f.id,member:f.member,dir:f.dir,exclude:f.exclude,...g,finishedAt:new Date().toISOString()})}return p}async function LM(e,t,n){let i=await Promise.all(e.groups.map(s=>F0e(e.verb,s,e.workspace.root,t,n))),r=new Map(i.flat().map(s=>[s.id,s]));return e.groups.flatMap(s=>s.units).map(s=>r.get(s.id))}function NQ(e){let t=[`chant workspace ${e.verb} in ${e.workspace.name} (${e.workspace.root})`];for(let n of e.groups){t.push("",`${n.toolchain.identity} (${n.toolchain.source}, ${n.units.length} project${n.units.length===1?"":"s"}, one process)`);for(let i of n.units)t.push(` ${i.id}${i.group?"":` ${i.dir}`}`)}for(let n of e.unreadable)t.push("",`unreadable ${n.name}: ${n.reason.code}: ${n.reason.message}`);if(e.skipped.length){t.push("","skipped:");for(let n of e.skipped)t.push(` ${n.name} ${n.reason.code}: ${n.reason.message}`)}return t.join(`
260
+ `)}function jQ(e){return{verb:e.verb,workspace:e.workspace,toolchains:e.groups.map(t=>({...t.toolchain,units:t.units.map(n=>({id:n.id,member:n.member,dir:n.dir,group:n.group}))})),unreadable:e.unreadable,skipped:e.skipped}}function Nh(e,t){let n=JSON.stringify(e,null,2);t?(TQ(Th(Dh(t)),{recursive:!0}),D0e(Dh(t),`${n}
261
+ `)):console.log(n)}function jh(e,t,n,i,r,o){return{name:e,dir:t,kind:n,status:i,reason:r,chant:o,irVersion:null,live:!1}}var Lh=v(()=>{"use strict";Kn();Ri();AQ();_t();ao();tM();OQ();Zt()});import{createHash as B0e,randomBytes as G0e}from"node:crypto";import{existsSync as W0e,mkdirSync as z0e,readdirSync as LQ,readFileSync as MM,realpathSync as U0e,renameSync as H0e,rmSync as V0e,statSync as FM,utimesSync as q0e,writeFileSync as K0e}from"node:fs";import{homedir as J0e}from"node:os";import{dirname as D$,join as cr,relative as Z0e,resolve as BM,sep as MQ}from"node:path";function iIe(e){return!e.some(t=>eIe.some(n=>t===n||t.startsWith(`${n}=`)))}function Mh(e){return B0e("sha256").update(e).digest("hex")}function oIe(e,t){let n=new Set(t.map(s=>BM(e,s))),i=[],r=0,o=s=>{for(let a of LQ(s,{withFileTypes:!0})){let l=cr(s,a.name);if(a.isDirectory()){if(nIe.has(a.name)||a.name.startsWith(".")||n.has(l))continue;o(l)}else if(a.isFile()){let c=FM(l);i.push(`${Z0e(e,l).split(MQ).join("/")}\0${c.mtimeMs}\0${c.size}`),c.mtimeMs>r&&(r=c.mtimeMs)}}};return o(e),i.sort(),{lines:i,newest:r}}function sIe(e){let t=[];for(let n=BM(e);;n=D$(n)){for(let i of rIe){let r=cr(n,i);try{let o=FM(r);o.isFile()&&t.push(`${r}\0${o.mtimeMs}\0${o.size}`)}catch{}}if(D$(n)===n)break}return t}function WM(e,t=[],n){try{let i=sIe(e);if(n)return{value:`sha256:${Mh(["at",n.commit,n.dir,...i].join(`
262
+ `))}`,newest:0};let{lines:r,newest:o}=oIe(e,t);return{value:`sha256:${Mh(["files",...r,"install",...i].join(`
263
+ `))}`,newest:o}}catch{return}}function aIe(e){let t=D$(D$(e.identity)),n="";try{n=String(JSON.parse(MM(cr(t,"package.json"),"utf-8")).version??"")}catch{}let i=e.identity.split(MQ).includes("node_modules"),r="";return!i&&W0e(cr(t,"src"))&&(r=WM(cr(t,"src"))?.value??`unstamped:${Date.now()}`),`${e.identity}\0${n}\0${r}`}function cIe(e){let t="";try{t=String(JSON.parse(MM(cr(e.packageDir,"package.json"),"utf-8")).version??"")}catch{}return JSON.stringify([e.lexicon,e.config,e.packageDir,t])}function lIe(e=process.env){let t=Object.keys(e).filter(n=>!tIe.some(i=>typeof i=="string"?i===n:i.test(n))).sort();return Mh(t.map(n=>`${n}=${e[n]??""}`).join("\0"))}function uIe(e){return Mh(JSON.stringify([GM,e.member,e.dir,e.stamp,e.toolchain,e.argv,e.env]))}function dIe(e,t=process.env){let n=t[FQ]||cr(t.XDG_CACHE_HOME||cr(J0e(),".cache"),"chant"),i=BM(e);try{i=U0e(i)}catch{}return cr(n,"workspace-graph",Mh(i).slice(0,16))}function BQ(e,t=process.env){let n=dIe(e,t),i=r=>cr(n,`${r}.json`);return{dir:n,get(r){try{let o=JSON.parse(MM(i(r),"utf-8"));if(o.format!==GM||o.key!==r||typeof o.stdout!="string")return;let s=new Date;return q0e(i(r),s,s),o}catch{return}},put(r){try{z0e(n,{recursive:!0});let o=cr(n,`.${r.key}.${process.pid}.${G0e(4).toString("hex")}.tmp`);K0e(o,JSON.stringify(r)),H0e(o,i(r.key)),pIe(n)}catch{}}}}function pIe(e){let t=LQ(e).filter(i=>i.endsWith(".json")&&!i.startsWith(".")).map(i=>{try{let r=FM(cr(e,i));return{path:cr(e,i),mtime:r.mtimeMs,size:r.size}}catch{return}}).filter(i=>i!==void 0).sort((i,r)=>r.mtime-i.mtime),n=0;t.forEach((i,r)=>{n+=i.size,(r>=Y0e||n>X0e)&&V0e(i.path,{force:!0})})}function GQ(e,t,n,i,r=o=>jM("graph",o,t)){let o=Date.now(),s=lIe(),a=[],l=new Map,c=new Map;for(let u of e.groups){let d=aIe(u.toolchain);for(let p of u.units){if(p.group)continue;let f=r(p);if(!iIe(f))continue;let g=p.reader?cIe(p.reader):"",h=p.dir==="."?e.workspace.root:cr(e.workspace.root,...p.dir.split("/")),b=i?{commit:i,dir:p.dir}:void 0,w=WM(h,p.exclude,b);if(!w)continue;l.set(p.id,w.value);let x=uIe({member:p.member,dir:p.dir,stamp:w.value,toolchain:`${d}\0${g}`,argv:f,env:s}),k=n.get(x);k?a.push({unit:p,toolchain:u.toolchain,chant:k.chant,mode:"member-run",id:p.id,member:p.member,dir:p.dir,exclude:p.exclude,exitCode:0,stdout:k.stdout,stderr:""}):c.set(p.id,{key:x,stamp:w,abs:h,exclude:p.exclude,...b?{at:b}:{},member:p.member})}}return{hits:a,stamps:l,pending:c,started:o}}function N$(e,t){if(t.size===0)return e;let n=e.groups.map(i=>({...i,units:i.units.filter(r=>!t.has(r.id))})).filter(i=>i.units.length>0);return{...e,groups:n}}function WQ(e,t,n){for(let i of t){let r=e.pending.get(i.id);if(!r||i.exitCode!==0||"reason"in xp(i.stdout)||!r.at&&r.stamp.newest>e.started-Q0e)continue;let o=WM(r.abs,r.exclude,r.at);!o||o.value!==r.stamp.value||n.put({format:GM,key:r.key,member:r.member,stamp:r.stamp.value,chant:i.chant,stdout:i.stdout})}}var GM,FQ,Y0e,X0e,Q0e,eIe,tIe,nIe,rIe,zQ=v(()=>{"use strict";_$();Lh();GM=1,FQ="CHANT_CACHE_DIR",Y0e=512,X0e=128*1024*1024,Q0e=2e3,eIe=["--live","--overlay","--traffic"],tIe=["_","PWD","OLDPWD","SHLVL","COLUMNS","LINES","WINDOWID",/^TERM/,/^ITERM_/,/^TMUX/,/^SSH_/,/^VSCODE_/,/^npm_/,/^VITEST/,/^__/,FQ],nIe=new Set(["node_modules","dist",".git"]),rIe=[cr("node_modules",".package-lock.json"),"package-lock.json","npm-shrinkwrap.json","yarn.lock","pnpm-lock.yaml","bun.lock","bun.lockb"]});import{mkdirSync as fIe,mkdtempSync as mIe,realpathSync as gIe,rmSync as hIe,symlinkSync as yIe,writeFileSync as bIe}from"node:fs";import{tmpdir as wIe}from"node:os";import{join as Fh}from"node:path";function vIe(e,t){let n=e;for(let i=0;i<t.split("/").length;i++)n=Fh(n,"..");return n}function zM(e){try{return gIe(e)}catch{return e}}function kIe(e,t){let n=e.reader,i=Jw(n.lexicon),r=na(i,t);return r?zM(r)!==zM(n.packageDir)?{message:`kind ${e.kind} comes from ${n.packageDir}, and the ${i} found from ${t} is ${zM(r)}; install the pinned package where the workspace resolves it`}:{modules:vIe(r,i)}:{message:`kind ${e.kind} is read by the ${n.lexicon} lexicon, and ${i} is not installed in a node_modules at or above ${t}; install it there to read this member`}}function UQ(e,t){let n=[],i,r=()=>{i&&hIe(i,{recursive:!0,force:!0}),i=void 0};try{for(let o of e.groups)o.units=o.units.filter(s=>{if(!s.reader)return!0;let a=kIe(s,t);if("message"in a)return n.push({name:s.member,dir:s.dir,kind:s.kind,reason:{code:"command-failed",message:a.message}}),!1;i??=mIe(Fh(wIe(),"chant-ws-reader-"));let l=Fh(i,s.id);fIe(l,{recursive:!0});let c=gV(s.reader.config,{member:s.member,dir:s.abs,workspace:t});return bIe(Fh(l,"chant.config.json"),`${JSON.stringify({lexicons:[s.reader.lexicon],[s.reader.lexicon]:c},null,2)}
264
+ `),yIe(a.modules,Fh(l,"node_modules"),"dir"),s.abs=l,!0});e.groups=e.groups.filter(o=>o.units.length>0)}catch(o){throw r(),o}return e.unreadable.push(...n),{failed:n,cleanup:r}}var HQ=v(()=>{"use strict";ao()});var KQ={};_e(KQ,{foldNested:()=>SIe,nestedArgv:()=>VQ,readNested:()=>RIe,readNestedDocument:()=>qQ});import{spawn as xIe}from"node:child_process";function VQ(e,t,n){return["workspace","graph",e,...n?["--at",n]:[],...t.env?["--env",t.env]:[],...t.live?["--live"]:[],...t.overlay?["--overlay"]:[],...t.traffic!==void 0?["--traffic",String(t.traffic)]:[],...t.noCache?["--no-cache"]:[]]}function $Ie(e,t,n){let[i,...r]=e;return new Promise(o=>{let s=xIe(i,[...r,...t],{cwd:n,stdio:["ignore","pipe","pipe"],env:process.env}),a=[],l=[];s.stdout.on("data",c=>a.push(c)),s.stderr.on("data",c=>l.push(c)),s.on("error",c=>o({exitCode:127,stdout:"",stderr:`could not start ${i}: ${c.message}
265
+ `})),s.on("close",c=>o({exitCode:c??1,stdout:Buffer.concat(a).toString("utf8"),stderr:Buffer.concat(l).toString("utf8")}))})}function qQ(e,t,n,i,r){let o;try{o=JSON.parse(e)}catch{let l=n.trim().split(`
266
+ `).slice(-5).join(`
267
+ `);return{ok:!1,chant:null,code:t===0?"output-unreadable":"command-failed",message:`the nested chant workspace graph exited ${t} and printed no document${l?`: ${l}`:""}`}}let s=o,a=typeof s.chant=="string"?s.chant:null;if(s.$schema!==i||typeof s.contract!="number")return{ok:!1,chant:a,code:"output-unreadable",message:"the nested chant workspace graph printed something that is not a workspace graph document"};if(s.contract>r)return{ok:!1,chant:a,code:"ir-version-unsupported",message:`the nested workspace's chant printed graph contract ${s.contract}, and this chant reads up to ${r}`};if(s.error&&typeof s.error=="object"){let l=s.error;return{ok:!1,chant:a,code:"command-failed",message:`the nested workspace could not be read: ${String(l.code)}: ${String(l.message)}`}}return!Array.isArray(s.nodes)||!Array.isArray(s.edges)||!Array.isArray(s.members)?{ok:!1,chant:a,code:"output-unreadable",message:"the nested workspace graph has no nodes, edges and members"}:{ok:!0,chant:a,doc:s}}async function RIe(e,t,n,i,r,o=void 0){let s=await $Ie((o??I$()).command,VQ(e,t,n),e);return{...qQ(s.stdout,s.exitCode,s.stderr,i,r),stderr:s.stderr}}function UM(e,t){if(Array.isArray(e))return e.map(i=>UM(i,t));if(e===null||typeof e!="object")return e;let n={};for(let[i,r]of Object.entries(e))n[i]=i==="$ref"&&typeof r=="string"?wi(t,r):UM(r,t);return n}function SIe(e,t,n){let i=t.name,r=new Map(n.members.map(c=>[c.name,c.dir])),o=[];for(let c of n.nodes){let u={...c,id:wi(i,c.id),member:i,nested:c.member,attrs:UM(c.attrs??{},i)};c.compositeInstance&&(u.compositeInstance=wi(i,c.compositeInstance)),c.runtimeOwner&&(u.runtimeOwner=wi(i,c.runtimeOwner)),c.compositeParent&&(u.compositeParent=c.compositeParent);let d=r.get(c.member);c.sourceLoc&&d&&d!=="."&&(u.sourceLoc={...c.sourceLoc,file:`${d}/${c.sourceLoc.file}`}),e.nodes.push(u),o.push(u.id)}for(let c of n.edges)e.edges.push({...c,from:wi(i,c.from),to:wi(i,c.to),member:i});for(let c of n.exports??[])e.exports.push({...c,...c.node?{node:wi(i,c.node)}:{},member:i});for(let c of n.imports??[])e.imports.push({...c,node:wi(i,c.node),member:i});e.groups.byMember[i]=o.sort();let s=e.groups,a=n.groups;for(let c of["byLexicon","byComposite"])for(let[u,d]of Object.entries(a[c]??{})){let p=s[c]??={};p[u]=[...p[u]??[],...d.map(f=>wi(i,f))].sort()}for(let c of["byStack","byContainer","byWave"])for(let[u,d]of Object.entries(a[c]??{})){let p=s[c]??={};p[wi(i,u)]=d.map(f=>wi(i,f)).sort()}for(let c of n.collectors??[])e.collectors.push({...c,member:wi(i,c.member)});for(let[c,u]of Object.entries(n.derivedAttrs??{})){let d=new Set([...e.derivedAttrs?.[c]??[],...u]);e.derivedAttrs={...e.derivedAttrs??{},[c]:[...d].sort()}}e.nodes.sort((c,u)=>c.id.localeCompare(u.id));let l=c=>`${c.from}\0${c.to}\0${c.viaAttr??""}`;e.edges.sort((c,u)=>l(c).localeCompare(l(u))),t.status="composed",t.reason=null,t.nested={name:n.workspace.name,contract:n.contract,members:n.members,links:n.links??[]}}var wi,JQ=v(()=>{"use strict";Lh();wi=(e,t)=>`${e}/${t}`});import{join as EIe}from"node:path";async function AIe(e,t){let n=[],i,r;try{let{loadChantConfig:a}=await Promise.resolve().then(()=>(Kt(),tw)),{config:l}=await a(e);i=Jr(l.lexicons??[]),r=l.environments??[]}catch(a){return{lexicons:[],default:Bo,reasons:[{code:"runtimes-config-unreadable",message:`chant.config.ts: ${ZQ(a)}`}],environments:null}}let o=t??(await Promise.resolve().then(()=>(cp(),g$))).loadPlugin,s=[];for(let a of i)try{(await o(a)).opRuntime?.runComponents&&s.push(a)}catch(l){n.push({code:"runtimes-lexicon-unreadable",message:`lexicon "${a}": ${ZQ(l)}`})}return{lexicons:s,default:Bo,reasons:n,environments:r}}function XQ(e,t){let n=t?.default??Bo,i=(r,o)=>({name:r,lexicon:o,default:r===n,command:`chant run --components ${e}${r===Bo?"":` --on ${r}`}`});return[i(Bo,null),...(t?.lexicons??[]).filter(r=>r!==Bo).map(r=>i(r,r))]}async function QQ(e,t,n){let i=new Map;for(let r of t)r.kind==="chant"&&i.set(r.name,await AIe(r.dir==="."?e:EIe(e,...r.dir.split("/")),n));return i}var Bo,YQ,ZQ,HM=v(()=>{"use strict";xn();Bo="local",YQ=["runtimes-config-unreadable","runtimes-lexicon-unreadable"],ZQ=e=>(e instanceof Error?e.message:String(e)).split(`
268
+ `)[0]});var eee=v(()=>{"use strict";Wt();$t()});var Pht,Oht,tee=v(()=>{"use strict";fl();_t();Qc();Zt();ai();ms();Pht=[...co],Oht=[...co,"write-usage-invalid","wip-no-branch","wip-none","wip-snapshot-unknown","wip-branch-other","wip-race","wip-policy-none","wip-remote-unknown",...Xc]});var nee=v(()=>{"use strict";_t();ed()});var ree=v(()=>{"use strict";Gd();uo();Zt()});var VM=v(()=>{"use strict";On();ji();Fi()});import{execFile as PIe}from"node:child_process";import{promisify as OIe}from"node:util";var Kht,iee=v(()=>{"use strict";Yh();Bi();al();Kht=OIe(PIe)});var oee=v(()=>{"use strict";al();Il();r$();Jd();$t();ga();fl();mp();iee();hp();VM()});var $p,qM,see,aee=v(()=>{"use strict";Kn();ji();$t();kh();eee();fl();YT();tee();Ri();nee();ree();ao();IM();_t();Qc();ms();VM();oee();Zt();ai();$p="chant/lifecycle",qM="_members",see=/^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/});import{execFileSync as CIe}from"node:child_process";function KM(e,t,n){return CIe("git",t,{cwd:e,encoding:"utf-8",input:n,stdio:[n===void 0?"ignore":"pipe","pipe","pipe"]})}function cee(e,t){try{return KM(e,["rev-parse","--verify","--quiet",t]),!0}catch{return!1}}function dee(e,t){let n=[],i=e?.environments??null;if(e&&i===null){let u=e.reasons.find(d=>d.code==="runtimes-config-unreadable");n.push({code:"runtimes-config-unreadable",message:u?.message??"chant.config.ts could not be read"})}else i&&i.length===0&&n.push({code:"environments-none-declared",message:"chant.config.ts declares no environments, so only local and the environments in the ledger are listed"});t?.reason&&n.push(t.reason);let r=(i??[]).map(wc).filter(u=>!$f(u)),o=t?.envs??[],s=u=>!i||i.length===0||Rf(i,u),a=o.filter(u=>u!==Rp&&!s(u));a.length>0&&n.push({code:"environments-ledger-undeclared",message:`the ledger has releases in ${a.join(", ")}, which chant.config.ts's environments don't cover, so chant run --env refuses ${a.length===1?"it":"them"}`});let l=[],c=(u,d)=>{l.some(p=>p.name===u)||l.push({name:u,default:u===Rp,source:d})};c(Rp,r.includes(Rp)?"config":o.includes(Rp)?"ledger":"builtin");for(let u of r)c(u,"config");for(let u of o)s(u)&&c(u,"ledger");return{environments:l,reasons:n,declared:i}}function pee(e,t,n=Bo,i=[],r=[],o=[]){let s=[...t?.environments??[{name:Rp,default:!0,source:"builtin"}]],a=t?.declared,l=u=>!a||a.length===0||Rf(a,u),c=new Map;for(let u of i)c.set(u.name,{runtime:u.runtime??null,url:u.url??null,domain:u.domain??null,lifecycle:u.lifecycle??null}),!s.some(d=>d.name===u.name)&&(l(u.name)?s.push({name:u.name,default:!1,source:"component"}):o.push({code:"environments-component-undeclared",message:`component ${e} declares environment ${u.name}, which chant.config.ts's environments don't cover, so chant run --env refuses it`}));return s.map(u=>{let d=c.get(u.name)??null,p=d?.runtime&&(d.runtime===Bo||r.includes(d.runtime))?d.runtime:n;return{...u,site:d,command:`chant run --components ${e}${p===Bo?"":` --on ${p}`}${u.default?"":` --env ${u.name}`}`}})}var Rp,lee,uee,fee=v(()=>{"use strict";Kt();HM();aee();Rp="local",lee=["runtimes-config-unreadable","environments-none-declared","environments-ledger-undeclared","environments-ledger-unreadable","environments-component-undeclared"];uee=(e,t)=>{if(!cee(t,`refs/heads/${$p}`))return{envs:[],reason:null};let i=e.dir!=="."&&cee(t,`refs/heads/${$p}:${qM}/${e.name}`)?`${qM}/${e.name}/`:"";try{let r=KM(t,["ls-tree","--full-tree",`refs/heads/${$p}:${i}`]).split(`
269
+ `).map(s=>s.match(/^\d+ tree [0-9a-f]+\t(.+)$/)?.[1]).filter(s=>!!s&&see.test(s));if(r.length===0)return{envs:[],reason:null};let o=KM(t,["cat-file","--batch-check"],r.map(s=>`refs/heads/${$p}:${i}${s}/releases.jsonl
270
+ `).join("")).split(`
271
+ `).filter(Boolean);return{envs:r.filter((s,a)=>o[a]!==void 0&&!o[a].endsWith(" missing")).sort(),reason:null}}catch(r){let o=(r instanceof Error?r.message:String(r)).split(`
272
+ `)[0];return{envs:[],reason:{code:"environments-ledger-unreadable",message:`${$p}:${i||"."}: ${o}`}}}}});var wee={};_e(wee,{COMPOSITES_CONTRACT_VERSION:()=>gee,COMPOSITES_ENVIRONMENT_REASON_CODES:()=>DIe,COMPOSITES_ERROR_CODES:()=>_Ie,COMPOSITES_OUTPUT_SCHEMA_ID:()=>mee,COMPOSITES_REASON_CODES:()=>IIe,COMPOSITES_RUNTIME_REASON_CODES:()=>TIe,compositeInstances:()=>hee,joinComponents:()=>yee,runWorkspaceComposites:()=>MIe,workspaceComposites:()=>bee});function NIe(e,t,n,i,r){if(n.exitCode!==0){let a=n.stderr.trim().split(`
273
+ `).slice(-5).join(`
274
+ `);return{reason:{code:"command-failed",message:`chant graph --components exited ${n.exitCode}${a?`: ${a}`:""}`}}}let o=xp(n.stdout);if("reason"in o)return{reason:{...o.reason,message:`chant graph --components: ${o.reason.message}`}};let s=[];for(let a of o.ir.nodes){if(a.kind!=="Component")continue;let l=a.attrs??{},c=Array.isArray(l.composites)?l.composites.filter(d=>typeof d=="string"):null,u=a.sourceLoc?.file;s.push({id:`${e}/${a.id}`,name:a.id,member:e,archetype:typeof l.archetype=="string"?l.archetype:null,composites:c&&c.length>0?c:null,file:u?t==="."?u:`${t}/${u}`:null,runtimes:XQ(a.id,i),environments:pee(a.id,r,i?.default,jIe(l.environments),i?.lexicons??[],r?.reasons??[])})}return{components:s}}function jIe(e){if(!Array.isArray(e))return[];let t=n=>typeof n=="string"&&n.length>0?n:void 0;return e.filter(n=>n!==null&&typeof n=="object"&&typeof n.name=="string").map(n=>({name:n.name,runtime:t(n.runtime),url:t(n.url),domain:t(n.domain),lifecycle:t(n.lifecycle)}))}function hee(e){let t=new Map;for(let n of e.nodes){if(!n.compositeInstance)continue;let i=t.get(n.compositeInstance)??{member:n.member,kinds:new Set,lexicons:new Set,nodes:[]};n.compositeParent&&i.kinds.add(n.compositeParent),i.lexicons.add(n.lexicon),i.nodes.push(n.id),t.set(n.compositeInstance,i)}return[...t.entries()].sort(([n],[i])=>n.localeCompare(i)).map(([n,i])=>({id:n,member:i.member,instance:n.slice(i.member.length+1),kinds:[...i.kinds].sort(),lexicons:[...i.lexicons].sort(),nodes:i.nodes.sort(),components:[]}))}function yee(e,t,n){let i=new Set;for(let o of n)"consumer"in o&&"producer"in o&&o.status==="resolved"&&i.add(`${o.consumer}\0${o.producer}`);let r=(o,s)=>o.member===s.member?"member":i.has(`${o.member}\0${s.member}`)?"link":"unlinked";return e.map(o=>{let s=[];for(let a of t){if(a.composites){let c=o.kinds.find(u=>a.composites.includes(u));c&&s.push({component:a.id,by:"composites",against:"kind",value:c,label:"exact",via:r(a,o)});continue}let l;for(let c of o.kinds){let u=Tg(a.name,c);u&&(!l||u==="exact"&&l.label!=="exact")&&(l={by:"name",against:"kind",value:c,label:u})}if(!l){let c=Tg(a.name,o.instance);c&&(l={by:"name",against:"instance",value:o.instance,label:c})}l&&s.push({component:a.id,...l,via:r(a,o)})}return s.sort((a,l)=>a.component.localeCompare(l.component)),{...o,components:s}})}function LIe(e,t,n,i){let r=e.reason??t,o=e.status==="composed"?t?"failed":"read":e.status;return{name:e.name,dir:e.dir,kind:e.kind,status:o,reason:r,chant:e.chant,runtimeReasons:n?.reasons??[],environmentReasons:i?.reasons??[]}}async function bee(e){let t={$schema:mee,contract:gee,chant:Xt()},n=new Map,{loadPlugin:i,readLedgerEnvironments:r=uee,...o}=e,{doc:s,failed:a,components:l}=await j$({...o,...o.args?{args:{...o.args,live:!1,overlay:!1,traffic:void 0}}:{},components:!0,inTree:async(w,x)=>{n=await QQ(w,x,i)}});if("error"in s)return{doc:{...t,error:{...s.error,code:s.error.code}},failed:!0};let c=new Map((l??[]).map(w=>[w.unit.member,w])),u=[],d=[],p=!1;for(let w of s.members){let x=w.status==="composed"?c.get(w.name):void 0,k=n.get(w.name),R=k?dee(k,r(w,e.cwd)):void 0,$=null;if(x){let _=NIe(w.name,w.dir,x,k,R);"reason"in _?($=_.reason,p=!0):d.push(..._.components)}u.push(LIe(w,$,k,R))}d.sort((w,x)=>w.id.localeCompare(x.id));let f=yee(hee(s),d,s.links),g=u.filter(w=>w.status==="read"),h=[];if(!u.some(w=>w.kind==="chant"&&w.status!=="skipped"))h.push({code:"composites-no-chant-member",message:"no member of kind chant was read, so nothing declares a composite or a component"});else if(g.length>0){let w=g.map(x=>x.name).join(", ");f.length===0&&h.push({code:"composites-none-declared",message:`the members read (${w}) declare no composite instance`}),d.length===0&&h.push({code:"composites-no-component",message:`the members read (${w}) declare no component in a *.component.ts file`})}let b=f.filter(w=>w.components.length>0).length;return{doc:{...t,at:s.at,workspace:s.workspace,members:u,composites:f,components:d,reasons:h,summary:{composites:f.length,withComponent:b,withoutComponent:f.length-b,components:d.length}},failed:a||p}}async function MIe(e,t){let{args:n}=e,{doc:i,failed:r}=await bee({cwd:t,at:n.at,members:n.members,args:n,onStderr:o=>process.stderr.write(o)});if(Nh(i,n.output),"error"in i){let o=i.error.location;console.error(fe({message:`${i.error.code}: ${o?`${o.file}:${o.line}:${o.column}: `:""}${i.error.message}`}))}return r?1:0}var mee,gee,_Ie,IIe,TIe,DIe,vee=v(()=>{"use strict";Kn();ID();_$();JM();Lh();_t();fee();HM();mee="https://intentius.io/chant/schemas/workspace/composites/v1/composites.schema.json",gee=1,_Ie=co,IIe=["composites-no-chant-member","composites-none-declared","composites-no-component"],TIe=YQ,DIe=lee});async function kee(e){let t={$schema:BIe,contract:FIe,chant:Xt()};try{return await WIe(e,t)}catch(n){if(n instanceof tn||n instanceof ve||n instanceof Ve)return{doc:{...t,error:{code:n.code,message:n.message}},failed:!0};throw n}}async function WIe(e,t){let n=Qt(e.cwd,e.at),i=n.top;if(!i)throw new tn("not-a-git-repository","the intent walk reads git history, and this directory is not in a git repository");let r=Lt(n.tree,"",{rootChant:!0}),o=e.kinds??Ti(r).map(W=>ja(W,n.rootOnDisk)),s=await F$({cwd:e.cwd,region:"",at:e.at,kinds:o},i),a=n.root==="."?"":n.root,l=W=>W.records.workspaceRoot==="."?"":W.records.workspaceRoot,c=W=>a===""?W:W.startsWith(`${a}/`)?W.slice(a.length+1):W===a?".":W,u=e.record.indexOf("/"),[d,p]=u>0?[e.record.slice(0,u),e.record.slice(u+1)]:[null,e.record],f=s.filter(W=>W.records&&!W.records.loaded.kind.work),g=f.filter(W=>d===null||W.records.loaded.kind.name===d).flatMap(W=>W.records.views.filter(de=>de.id===p).map(de=>({kind:W,view:de})))[0];if(!g){let W=f.map(de=>de.records.loaded.kind.name);throw new tn("intent-record-unknown",`no record of ${W.length>0?`the decision kinds read (${W.join(", ")})`:"a decision kind: none was read"} has the id ${e.record}`)}let h=g.kind.records.loaded.kind,b=g.view,w=n.at??(Dn(i,["rev-parse","--verify","--quiet","HEAD^{commit}"])?.trim()||null),x=Dn(i,["rev-parse","--is-shallow-repository"])?.trim()==="true",k=[];x&&k.push({code:"intent-history-shallow",message:"this is a shallow clone, so the history stops at its boundary and the oldest commit listed may stand for many"});let R=[],$=[],_=[],T=new Map,C=h.constrains?.field?b.data?.[h.constrains.field]:void 0;for(let W of Array.isArray(C)?C:[])if(typeof W=="string")if(W.startsWith("path:")){let de=W.slice(5);if(!_n(de)){R.push({entry:W,granularity:"path",path:null,exists:null,walked:!1});continue}let Oe=ze(l(g.kind),de),pt=n.tree.stat(c(Oe));if(R.push({entry:W,granularity:"path",path:c(Oe),exists:pt!==void 0,walked:w!==null}),$.push({entry:W,full:Oe}),!w)continue;for(let et of L$(i,w,Oe,pt==="file"?"file":"dir",null))(T.get(et.sha)??T.set(et.sha,[]).get(et.sha)).push(W)}else if(W.startsWith("member:")){let de=W.slice(7),Oe=r.members.find(Tt=>Tt.name===de);if(R.push({entry:W,granularity:"member",path:Oe?Oe.dir:null,exists:!!Oe,walked:!!Oe&&w!==null}),!Oe||(_.push({entry:W,name:de}),!w))continue;let pt=ze(a,Oe.dir),et=r.members.filter(Tt=>Tt.name!==Oe.name&&Tt.dir!==Oe.dir&&(Oe.dir==="."||Tt.dir.startsWith(`${Oe.dir}/`))).map(Tt=>`:(exclude)${ze(a,Tt.dir)}`),Ut=Dn(i,["log","--format=%H",w,"--",pt===""?".":pt,...et]);for(let Tt of(Ut??"").split(`
275
+ `).map(wt=>wt.trim()).filter(Boolean))(T.get(Tt)??T.set(Tt,[]).get(Tt)).push(W)}else R.push({entry:W,granularity:/^[^/\s]+\/[^/\s]+#[0-9]+$/.test(W)?"issue":"contract",path:null,exists:null,walked:!1});let K=new Map;for(let W of f)for(let de of W.records.views)de.id!==null&&K.set(`${W.records.loaded.kind.name}/${de.id}`,{kind:W,view:de});let O=(W,de)=>{let Oe=w?Ep(i,w,de):null,pt=de.supersededBy?K.get(`${W.records.loaded.kind.name}/${de.supersededBy}`):void 0,et=w&&pt?Ep(i,w,pt.view):null;return{from:Oe,until:et,fromSet:Oe&&w?Go(i,Oe,w):new Set,untilSet:et&&w?Go(i,et,w):null}},pe=(W,de)=>W.fromSet.has(de)&&!W.untilSet?.has(de),F=O(g.kind,b),Q=[...T.keys()].filter(W=>pe(F,W)),I=Sp(i,Q),B=e.followSquash?Lg(i,[...I.values()],{fetchMissing:!0}):new Map;for(let W of B.values())W.problem&&k.push({code:"squash-unfollowed",message:`${W.sha.slice(0,8)} squashes pull request #${W.pullRequest}, and ${W.problem}, so its original commits are not followed`});let Z=Sp(i,[...new Set([...B.values()].flatMap(W=>W.commits))]),xe=W=>(B.get(W)?.commits??[]).map(de=>Z.get(de)).filter(de=>de!==void 0),we=(Q.length>0?Dn(i,["rev-list","--no-walk=sorted","--stdin"],`${Q.join(`
276
+ `)}
277
+ `):"")?.split(`
278
+ `).map(W=>W.trim()).filter(Boolean)??Q;Q.sort((W,de)=>we.indexOf(W)-we.indexOf(de));let Ct=W=>$.some(de=>cs(de.full,W))||_.some(de=>Mr(c(W),r.members)===de.name),at=new Map;if(Q.length>0){let W=Dn(i,["log","--no-walk=unsorted","--stdin","--format=%x00%H","--name-only","--no-renames","--diff-merges=first-parent"],`${Q.join(`
279
+ `)}
280
+ `)??"";for(let de of W.split("\0")){if(!de)continue;let[Oe,...pt]=de.split(`
281
+ `).map(et=>et.trim());at.set(Oe,[...new Set(pt.filter(et=>et!==""&&Ct(et)))].map(c))}}let $e=(W,de)=>{let Oe=W.records.loaded.kind.constrains?.field,pt=Oe?de.data?.[Oe]:void 0;return(Array.isArray(pt)?pt:[]).filter(et=>typeof et=="string"&&et.startsWith("path:")&&_n(et.slice(5))).map(et=>ze(l(W),et.slice(5)))},Te=[...new Set([...at.values()].flat())].map(W=>ze(a,W)),nt=[];for(let[,W]of K){if(W.view===b)continue;let de=$e(W.kind,W.view);de.some(Oe=>Te.some(pt=>cs(Oe,pt)))&&nt.push({ref:{recordKind:W.kind.records.loaded.kind.name,record:W.view.id,state:W.view.state},paths:de,window:O(W.kind,W.view)})}let St=[];for(let W of s.filter(de=>de.records?.loaded.kind.work)){let de=W.records.loaded.kind;for(let Oe of W.records.views){if(Oe.id===null||Oe.state!==null&&Oe.state!==de.work.done&&(de.closedStates??[]).includes(Oe.state))continue;let et=Rr(Oe.data,de.work.implements).includes(b.id),Ut=$e(W,Oe);if(!et&&!Ut.some(Ar=>Te.some(Pr=>cs(Ar,Pr))))continue;let Tt=w?Bh(i,w,Oe.path):null,wt=w&&de.stateField?M$(i,w,Oe.path,de.stateField,de.closedStates??[]):null,qn=wt&&w?Go(i,wt,w):null;wt&&qn.delete(wt),St.push({ref:{recordKind:de.name,record:Oe.id,state:Oe.state},paths:Ut,implementsRecord:et,window:{fromSet:Tt&&w?Go(i,Tt,w):new Set,untilSet:qn}})}}let Ee=W=>_n(W)&&n.tree.stat(W)==="file"?n.tree.read(W):void 0,zt=W=>{let de=W==="."?"":W.replace(/\/+$/,"");if(!(de!==""&&(!_n(de)||n.tree.stat(de)!=="dir")))return n.tree.list(de)?.map(Oe=>`${ze(de,Oe.name)}${Oe.type==="dir"?"/":""}`).sort()},Vn=new Set,ne=R.filter(W=>W.granularity==="contract").map(W=>W.entry),Re=[],X=C$(i,[...I.values(),...Z.values()]),Ce=new Map(s.filter(W=>W.records).map(W=>[W.records.loaded.kind.name,W])),tt=s.filter(W=>W.records?.loaded.kind.work),gt=await Lk(i,n.rootOnDisk,[...new Set([...Q,...Z.keys()])].map(W=>({sha:W,run:X.get(W)?.joins.run??null})));Mk(gt.refs,B);let Je=(W,de)=>{let Oe=W.records.views.find(pt=>pt.id===de);return Oe?Rr(Oe.data,W.records.loaded.kind.work.implements).includes(b.id):void 0};for(let W of Q){let de=I.get(W);if(!de)continue;let Oe=null,pt=!1,et=X.get(W).joins,Ut=xe(W);for(let y of[et,...Ut.map(N=>X.get(N.sha).joins)]){for(let q of y.records){let Y=Ce.get(q.kind);!Y||!Y.records.views.some(z=>z.id===q.id)||(q.node=`record:${q.kind}/${q.id}`,(Y.records.loaded.kind.work?Je(Y,q.id):q.kind===h.name&&q.id===b.id)&&(pt=!0))}let N=y.lease?.item;if(N){let q=tt.filter(Y=>Y.records.views.some(z=>z.id===N));q.length===1&&Je(q[0],N)&&(pt=!0)}}let Tt=[de,...Ut];for(let y of s)if(y.joins)for(let N of Tt){let q;try{q=await Lv(y.joins,N,{read:Ee,list:zt,at:n.at},y.name)}catch(z){let E=`${y.display}: commitJoins failed for ${N.sha.slice(0,8)}: ${z instanceof Error?z.message:String(z)}`;Vn.has(E)||k.push({code:"intent-plugin-failed",message:E}),Vn.add(E);continue}if(!q.unit)continue;Oe??=q.unit.id,[...Td(q.unit),...Td(q.contract)].some(z=>z===b.id||z===`${h.name}/${b.id}`)&&(pt=!0),q.contract&&ne.includes(q.contract.id)&&(pt=!0)}let wt=B.get(W),qn=(at.get(W)??[]).map(y=>ze(a,y)),Ar=y=>y.some(N=>qn.some(q=>cs(N,q))),Pr=St.filter(y=>pe(y.window,W)&&(y.implementsRecord||Ar(y.paths))).map(y=>y.ref),vi=nt.filter(y=>pe(y.window,W)&&Ar(y.paths)).map(y=>y.ref),Ho=de.subject.match(/\(#([0-9]+)\)\s*$/);Re.push({sha:W,subject:de.subject,author:de.author,date:de.date,trailers:de.trailers,pullRequest:Ho?Number(Ho[1]):null,unit:Oe,joins:et,runs:gt.refs.get(W)??[],...wt?{squash:{pullRequest:wt.pullRequest,forge:wt.forge,ref:wt.ref,head:wt.head,fetched:wt.fetched,followed:wt.followed,commits:Ut.map(y=>({sha:y.sha,subject:y.subject,author:y.author,date:y.date,trailers:y.trailers,joins:X.get(y.sha).joins}))}}:{},entries:T.get(W),files:at.get(W)??[],bucket:pt?"own":Pr.length>0?"worked":vi.length>0?"within-other":"unexplained",workedBy:Pr,alsoWithin:vi})}let Bt=W=>Re.filter(de=>de.bucket===W).length;return{doc:{...t,at:n.at,workspace:{name:r.name,root:n.root},record:{id:`record:${h.name}/${b.id}`,recordKind:h.name,record:b.id,path:b.path,title:GIe(b.data?.title),state:b.state,supersededBy:b.supersededBy,decidedIn:b.decidedIn??null,constrains:R},history:{rev:w,shallow:x},window:{from:F.from,until:F.until},kinds:s.map(W=>({file:W.display,name:W.name,records:W.records?.loaded.kind.name??null,joins:W.joins?.form??null})),commits:Re,counts:{commits:Re.length,own:Bt("own"),worked:Bt("worked"),withinOther:Bt("within-other"),unexplained:Bt("unexplained"),outsideWindow:T.size-Q.length},reasons:k},failed:k.some(W=>W.code==="intent-plugin-failed")}}var FIe,BIe,GIe,xee=v(()=>{"use strict";_t();Gd();Mv();B$();uo();mn();BD();jk();CM();Zt();ai();vd();FIe=1,BIe="https://intentius.io/chant/schemas/workspace/intent-record/v1/intent-record.schema.json",GIe=e=>typeof e=="string"?e:null});var Cee={};_e(Cee,{IN_WINDOW_QUESTION:()=>Eee,formatIntent:()=>Pee,formatIntentRecord:()=>Oee,runWorkspaceIntent:()=>ZIe,whyLines:()=>Aee});import{resolve as Ree}from"node:path";function Gh(e,t,n){return e.edges.filter(i=>i.from===t&&i.kind===n)}function rc(e,t){return e.nodes.filter(n=>n.kind===t)}function zIe(e,t){let n=e.edges.filter(r=>r.kind==="within"&&r.to===t.id),i=[];for(let r of n){let o=e.nodes.find(d=>d.kind==="commit"&&d.id===r.from);if(!o)continue;let s=Gh(e,o.id,"produced-by").map(d=>e.nodes.find(p=>p.id===d.to)).map(d=>d&&"ref"in d?d.ref:void 0).filter(Boolean),a=(o.joins?.records??[]).filter(d=>d.node!==null).map(d=>`${d.kind}:${d.id}`),l=o.joins?.lease?.item;l&&!a.some(d=>d.endsWith(`:${l}`))&&a.push(`lease on ${l}`);let c=s.length>0?`unit ${s.join(", ")}`:a.length>0?`carries ${a.join(", ")}`:"no unit",u=r.state==="decided"?"decided ":"within ";i.push(` ${u} ${Nn(o.sha)} ${o.subject}; ${c}${r.state==="decided"?`, ${t.record}'s own work`:`, in ${t.record}'s window and not its work`}`)}return n.some(r=>r.state==="decided-by-window")&&i.push(` ask ${Eee}`),i}function UIe(e){let t=e.constrains.length>0?e.constrains.map(s=>`${s.entry} (${s.granularity})`).join(", "):"through supersession only",n=e.decided_by?`, decided by ${e.decided_by}${e.decided_on?` on ${e.decided_on}`:""}`:"",i=e.decidedIn?` in ${Nn(e.decidedIn.sha)}`:"",r=`${e.reviews.agree} agree, ${e.reviews.dissent} dissent, ${e.reviews.abstain} abstain`,o=e.supersededBy?`, superseded by ${e.supersededBy}`:"";return`decision ${e.record} ${e.state??"stateless"}${o}: ${e.title??e.path}; constrains ${t}${n}${i}; ${r}; ${e.provenance.level}${e.valid?"":`; invalid: ${e.reasons.map(s=>s.code).join(", ")}`}`}function HIe(e,t){let n=t.constrains.length>0?t.constrains.map(l=>`${l.entry} (${l.granularity})`).join(", "):"through a link only",i=t.implements.length>0?`; implements ${t.implements.map(l=>`${l.id} (${l.state??"unknown"})`).join(", ")}`:"",r=t.ready?"; ready":t.blockedBy.length>0?`; blocked by ${t.blockedBy.map(l=>`${l.id} (${l.state??"unknown"})`).join(", ")}`:"",o=t.owner?`, owned by ${t.owner}`:"",s=t.source?`; from ${t.source.finding} on ${t.source.region}`:"",a=[`work ${t.record} ${t.state??"stateless"}${o}: ${t.title??t.path}; constrains ${n}${i}${r}${s}`];for(let l of e.edges.filter(c=>c.kind==="within"&&c.to===t.id)){let c=e.nodes.find(u=>u.kind==="commit"&&u.id===l.from);c&&a.push(` worked ${Nn(c.sha)} ${c.subject}; in ${t.record}'s window`)}for(let l of t.warnings)a.push(` warning ${l.code}: ${l.message}`);return a}function VIe(e,t){let n=e.edges.filter(i=>i.kind==="pins"&&i.to===t.id).map(i=>`${i.from.slice(i.from.indexOf("/")+1)} at ${Nn(i.pinnedSha256)} (${i.pinState})`);return`artifact ${t.path} ${t.pinState}; pinned by ${n.join(", ")}; now ${Nn(t.currentSha256)}`}function qIe(e){if(!e)return[];let t=[];e.agent&&t.push(` agent ${e.agent}`),e.lease&&t.push(` lease ${e.lease.token}${e.lease.item?` on ${e.lease.item}`:", no lease history names it"}`);for(let n of e.records)t.push(` record ${n.kind}:${n.id}${n.node?"":", in no kind read"}`);return e.applied&&t.push(` applied by ${e.applied.by}${e.applied.at?` at ${e.applied.at}`:""}${e.applied.commit?`, ${Nn(e.applied.commit)}`:""}`),t}function KIe(e,t){let n=t.lines&&t.lines.length>0?`, lines ${t.lines.map(r=>r.start===r.end?`${r.start}`:`${r.start}-${r.end}`).join(", ")}`:"",i=[`commit ${Nn(t.sha)} ${t.date.slice(0,10)} ${t.author.name}: ${t.subject}${n}; ${t.signature.level}`];for(let r of Gh(e,t.id,"produced-by")){let o=e.nodes.find(s=>s.id===r.to);i.push(` unit ${o&&"ref"in o?o.ref:r.to}`);for(let s of Gh(e,r.to,"serves"))i.push(` contract ${s.to.slice(9)}`);for(let s of Gh(e,r.to,"cites-evidence"))i.push(` evidence ${s.to.slice(9)}`)}if(i.push(...qIe(t.joins)),t.squash){let r=t.squash;i.push(` squash #${r.pullRequest}${r.followed?`: ${r.commits.length} original ${r.commits.length===1?"commit":"commits"} from ${r.ref}${r.fetched?", fetched":""}`:", not followed"}`);for(let o of r.commits){let s=[...o.joins.records.map(a=>`${a.kind}:${a.id}`),...o.joins.lease?[`lease ${o.joins.lease.token}`]:[],...o.joins.run?[`run ${o.joins.run}`]:[]];i.push(` original ${Nn(o.sha)} ${o.subject}; ${o.signature.level}${s.length>0?`; ${s.join(", ")}`:""}`)}}for(let r of Gh(e,t.id,"made-by")){let o=e.nodes.find(l=>l.kind==="run"&&l.id===r.to);if(!o)continue;let s=o.recorded?`${[o.harness?.name,o.model].filter(Boolean).join("/")||"no model recorded"}${o.by?` for ${o.by}`:""}${o.cost?`, ${o.cost.amount} ${o.cost.currency}`:", unpriced"}`:"not in the run ledger",a=r.kind!=="made-by"?"":r.joinedBy.includes("patch-id")?`; joined by content${r.recordedAs?`, as ${Nn(r.recordedAs)}`:""}`:r.joinedBy.length===1&&r.joinedBy[0]==="squash"?`; through the squash, by ${(r.via??[]).map(Nn).join(", ")}`:"";i.push(` run ${o.run}: ${s}${a}`)}return i}function Aee(e,t){let n=[],i=o=>{let s=e.nodes.find(a=>a.id===o);return s&&(s.kind==="decision"||s.kind==="work")?s.record:o},r=o=>{let s=e.nodes.find(l=>l.kind==="run"&&l.id===o);if(!s)return o;let a=[s.harness?.name,s.model].filter(Boolean).join("/");return`${s.run}${a?` (${a})`:s.recorded?"":" (not in the run ledger)"}${s.unit?` on ${s.unit}`:""}`};n.push(`why ${t.explained?"explained":"unexplained"}${t.lines?`, lines ${G$(t.lines)}`:""}`);for(let o of t.decisions)n.push(` decision ${i(o.decision)} ${o.relevance}${o.lines>0?`, ${o.lines} ${o.lines===1?"line":"lines"}`:""}${o.current?"":", superseded"}${o.closed?", closed":""}`);for(let o of t.blame){let s=o.runs.length>0?`; ${o.runs.map(r).join(", ")}${o.narrowedBy?" (by its hunks)":""}${o.joinedBy?.includes("patch-id")?" (joined by content)":""}${o.via&&o.via.length>0?` (squashed from ${o.via.map(Nn).join(", ")})`:""}`:o.sha?"; no run":"";n.push(` lines ${G$(o)} ${o.sha?Nn(o.sha):"uncommitted"}${s}`)}for(let o of t.gaps)n.push(` gap ${o.code}: ${o.message}${o.lines?` (lines ${o.lines.map(G$).join(", ")})`:""}`);return n}function Pee(e){let t=[],n=e.nodes.find(s=>s.id===e.region);if(n?.kind==="region"){let s=n.lines?`:${n.lines.start}${n.lines.end===n.lines.start?"":`-${n.lines.end}`}`:"",a=e.at?`at ${Nn(e.at)}`:"in the working tree",l=n.symbol?`#${n.symbol.name} (${n.symbol.kind} ${n.symbol.qualified}, lines ${n.lines?G$(n.lines):"none"})`:s;t.push(`region ${n.path}${l} (${n.type}, member ${n.member??"none"}${n.generated?", generated":""}) ${a}${n.node?`, from node ${n.node}`:""}`)}let i=rc(e,"file");i.length>0&&t.push(`files ${i.length} under the region, ${i.filter(s=>s.generated).length} generated`);for(let s of rc(e,"decision"))t.push(UIe(s),...zIe(e,s));for(let s of rc(e,"work"))t.push(...HIe(e,s));for(let s of rc(e,"artifact"))t.push(VIe(e,s));for(let s of rc(e,"commit"))t.push(...KIe(e,s));for(let s of rc(e,"link")){let a=s.row;t.push(`link ${a.consumer} reads ${"producer"in a?`${a.producer} ${a.output}`:a.input} (${a.status})`)}for(let s of rc(e,"finding")){let a=s.addressedBy&&s.addressedBy.length>0?`; addressed by ${s.addressedBy.map(l=>`${l.id} (${l.state??"unknown"})`).join(", ")}`:"";t.push(`finding ${s.code}: ${s.message}${a}`)}for(let s of e.reasons)t.push(`reason ${s.code}: ${s.message}`);e.why&&t.push(...Aee(e,e.why));let r=e.kinds.length===0?"; no --kind, so no decisions were read":"",o=rc(e,"work").length;return t.push(`${e.summary.commits} commits, ${e.summary.decisions} decisions, ${o>0?`${o} work ${o===1?"item":"items"}, `:""}${e.summary.artifacts} artifacts, ${e.summary.findings} findings${r}`),t.join(`
282
+ `)}function Oee(e){let t=e.record,n=[`record ${t.record} ${t.state??"stateless"}${t.supersededBy?`, superseded by ${t.supersededBy}`:""}: ${t.title??t.path}`];n.push(`window ${e.window.from?`from ${Nn(e.window.from)}`:"no history"}${e.window.until?` until ${Nn(e.window.until)}`:""}${t.decidedIn?`; decided in ${Nn(t.decidedIn.sha)} ${t.decidedIn.date.slice(0,10)}: ${t.decidedIn.subject}`:"; not decided in the history read"}`);for(let r of t.constrains)n.push(`entry ${r.entry}${r.walked?"":r.exists===!1?" (not in the tree read)":" (not walked)"}`);for(let r of e.commits){let o=r.bucket==="own"?r.unit!==null?`unit ${r.unit}`:`carries ${[...(r.joins?.records??[]).filter(l=>l.node!==null).map(l=>`${l.kind}:${l.id}`),...r.joins?.lease?.item?[`lease on ${r.joins.lease.item}`]:[]].join(", ")}`:r.bucket==="worked"?`worked by ${r.workedBy.map(l=>l.record).join(", ")}`:r.bucket==="within-other"?`within ${r.alsoWithin.map(l=>l.record).join(", ")}`:"nothing else accounts for it",s=(r.runs??[]).map(l=>`run ${l.id}${l.model?` (${l.model})`:""}${l.joinedBy?.includes("squash")&&!l.joinedBy.some(c=>c!=="squash")?" through the squash":""}`).join(", "),a=r.squash?`; squash of #${r.squash.pullRequest}${r.squash.followed?`, ${r.squash.commits.length} original ${r.squash.commits.length===1?"commit":"commits"}`:", not followed"}`:"";n.push(`${r.bucket.padEnd(12)} ${Nn(r.sha)} ${r.date.slice(0,10)} ${r.subject}; ${o}${s?`; ${s}`:""}${a}; ${r.files.join(", ")||r.entries.join(", ")}`)}for(let r of e.reasons)n.push(`reason ${r.code}: ${r.message}`);let i=e.counts;return n.push(`${i.commits} commits in the window: ${i.own} own, ${i.worked} worked, ${i.withinOther} within another record's window, ${i.unexplained} unexplained; ${i.outsideWindow} outside it`),n.join(`
283
+ `)}async function JIe(e,t,n){let{args:i}=e,{doc:r,failed:o}=await kee({cwd:t,record:i.record,at:i.at,kinds:n?.map(s=>Ree(s)),followSquash:i.followSquash});return i.json&&console.log(JSON.stringify(r,null,2)),"error"in r?(console.error(fe({message:`${r.error.code}: ${r.error.message}`,hint:See})),1):(i.json||console.log(Oee(r)),o?1:0)}async function ZIe(e,t){let{args:n}=e;if(n.record!==void 0)return n.intent?(console.error(fe({message:"--record walks a record, so --intent takes no region with it",hint:See})),1):JIe(e,t,n.kinds??(n.kind!==void 0?[n.kind]:void 0));if(!n.intent)return console.error(fe({message:"--intent needs a region: a path, path:line, path:start-end or path#symbol",hint:$ee})),1;let i=n.kinds??(n.kind!==void 0?[n.kind]:void 0),{doc:r,failed:o}=await ZM({cwd:t,region:n.intent,at:n.at,kinds:i?.map(s=>Ree(s)),followSquash:n.followSquash});return n.json&&console.log(JSON.stringify(r,null,2)),"error"in r?(console.error(fe({message:`${r.error.code}: ${r.error.message}`,hint:$ee})),1):(n.json||console.log(Pee(r)),o?1:0)}var $ee,See,Nn,Eee,G$,_ee=v(()=>{"use strict";Kn();xee();B$();$ee="chant workspace graph --intent <path[:start-end]|path#symbol> [--at <rev>] [--kind <kind file>...] [--follow-squash] [--json]",See="chant workspace graph --intent --record <id> [--at <rev>] [--kind <kind file>...] [--follow-squash] [--json]";Nn=e=>e?e.slice(0,8):"none",Eee="is this drift, a superseding decision nobody wrote down, or the decision being wrong?";G$=e=>e.start===e.end?`${e.start}`:`${e.start}-${e.end}`});var Fee={};_e(Fee,{GRAPH_CONTRACT_VERSION:()=>W$,GRAPH_ERROR_CODES:()=>eTe,GRAPH_OUTPUT_SCHEMA_ID:()=>z$,componentGraphArgv:()=>jee,exportRevision:()=>Lee,planGraph:()=>Mee,runWorkspaceGraph:()=>rTe,workspaceGraph:()=>j$});import{execFileSync as Iee}from"node:child_process";import{existsSync as Tl,mkdirSync as YIe,mkdtempSync as XIe,rmSync as Nee,symlinkSync as Tee}from"node:fs";import{tmpdir as QIe}from"node:os";import{dirname as Wh,join as Wo,resolve as Dee}from"node:path";function jee(e){return["graph",".","--components","--format","ir",...e.env?["--env",e.env]:[]]}function Lee(e,t){let{top:n,at:i,root:r,rootOnDisk:o}=e;if(!n||!i)throw new Error("exportRevision needs a revision");let s=XIe(Wo(QIe(),"chant-ws-at-")),a=Wo(s,"root"),l=Wo(s,"tree.tar");Iee("git",["archive","--format=tar","-o",l,r==="."?i:`${i}:${r}`],{cwd:n,stdio:["ignore","ignore","pipe"]}),YIe(a,{recursive:!0}),Iee("tar",["-xf",l,"-C",a],{stdio:["ignore","ignore","pipe"]}),Nee(l,{force:!0});let c=new Set([""]);for(let u of t){if(u===".")continue;let d=u.split("/");for(let p=1;p<=d.length;p++)c.add(d.slice(0,p).join("/"))}for(let u of c){let d=Wo(o,...u.split("/"),"node_modules"),p=Wo(a,...u.split("/"),"node_modules");Tl(d)&&Tl(Wh(p))&&!Tl(p)&&Tee(d,p,"dir")}if(!Tl(Wo(a,"node_modules")))for(let u=Wh(o);;u=Wh(u)){if(Tl(Wo(u,"node_modules"))){Tee(Wo(u,"node_modules"),Wo(a,"node_modules"),"dir");break}if(Wh(u)===u)break}return a}function tTe(e,t,n,i,r=!1){let o=(c,u)=>(r&&(c.live=!0,u.finishedAt&&(c.readAt=u.finishedAt)),c),s=new Map(t.map(c=>[c.id,c])),a=[],l=e.unreadable.length>0;for(let c of i){if(n?.length&&!n.includes(c.name))continue;let u=s.get(c.name),d=e.skipped.find(g=>g.name===c.name)??e.unreadable.find(g=>g.name===c.name);if(!u){let g=e.unreadable.some(h=>h.name===c.name)?"failed":"skipped";a.push({member:jh(c.name,c.dir,c.kind,g,d?.reason??null,null)});continue}if(u.exitCode!==0){l=!0;let g=u.stderr.trim().split(`
284
+ `).slice(-5).join(`
285
+ `);a.push({member:o(jh(c.name,c.dir,c.kind,"failed",{code:"command-failed",message:`chant graph exited ${u.exitCode}${g?`: ${g}`:""}`},u.chant),u)});continue}let p=xp(u.stdout);if("reason"in p){l=!0,a.push({member:o(jh(c.name,c.dir,c.kind,"failed",p.reason,u.chant),u)});continue}let f=o(jh(c.name,c.dir,c.kind,"composed",null,u.chant),u);f.irVersion=p.irVersion,a.push({member:f,ir:p.ir})}return{inputs:a,failed:l}}function Mee(e){let t=Qt(e.cwd,e.at),n=Lt(t.tree,"",{rootChant:!0}),i=pa(n.pins,t.rootOnDisk).registry;return T$("graph",t.rootOnDisk,{only:e.members,reader:e.reader,tree:t.tree,kinds:i})}async function j$(e){let t={$schema:z$,contract:W$,chant:Xt()},n,i;if(e.args?.live&&e.at!==void 0)return{doc:{...t,error:{code:"live-at-revision",message:YM,location:null}},failed:!0};try{let r=Qt(e.cwd,e.at),o=Lt(r.tree,"",{rootChant:!0}),s=pa(o.pins,r.rootOnDisk).registry,a=T$("graph",r.rootOnDisk,{only:e.members,reader:e.reader,tree:r.tree,kinds:s}),l=e.args??{},c=e.noCache||e.components?void 0:BQ(r.rootOnDisk),u=c?GQ(a,l,c,r.at):void 0,d=new Set(u?.hits.map($=>$.id));r.at!==null&&N$(a,d).groups.length>0&&(n=Lee(r,N$(a,d).groups.flatMap($=>$.units.map(_=>_.dir))),a=T$("graph",n,{only:e.members,reader:e.reader,tree:$n(n),kinds:s}));let p=N$(a,d);i=UQ(p,n??r.rootOnDisk);let[f,g]=await Promise.all([LM(p,l),e.components?LM(a,l,()=>jee(l)):Promise.resolve(void 0)]);c&&u&&WQ(u,f,c);let h=[...u?.hits??[],...f];e.inTree&&await e.inTree(n??r.rootOnDisk,o.members.filter($=>!e.members?.length||e.members.includes($.name)));for(let $ of g??[])$.stderr.trim()&&e.onStderr&&e.onStderr($.stderr.endsWith(`
286
+ `)?$.stderr:`${$.stderr}
287
+ `);for(let $ of h)$.stderr.trim()&&e.onStderr&&e.onStderr($.stderr.endsWith(`
288
+ `)?$.stderr:`${$.stderr}
289
+ `);let{inputs:b,failed:w}=tTe(a,h,e.members,o.members,!!l.live);for(let{member:$}of b)$.status==="composed"&&($.cached=d.has($.name),$.stamp=u?.stamps.get($.name)??null);let x=EQ({name:o.name,root:r.root},b,{declaration:o,kinds:s});for(let $ of x.members)$.box=$Q(o.members.find(_=>_.name===$.name)?.box??null,r.tree,o.members);let k=await nTe(x,o.members,e,r.rootOnDisk,r.at),R=!1;if(e.kind!==void 0){let{readRecordsFor:$}=await Promise.resolve().then(()=>(vo(),Bee));try{let _=await $({kind:e.kind,cwd:e.cwd,at:e.at}),T=_.loaded.kind.name;x.records=_.result.records.map(C=>({kind:T,id:C.id,path:C.path,state:C.state,valid:C.valid,supersededBy:C.supersededBy,remediatedBy:C.remediatedBy})),x.links.push(...nK(T,_.result.records,_.loaded.kind.constrains?.field,r.tree,o.members))}catch(_){if(!(_ instanceof Ve))throw _;R=!0,e.onStderr?.(`${fe({message:`--kind ${e.kind}: ${_.code}: ${_.message}`,hint:ic})}
290
+ `)}}return{doc:{...t,at:r.at,plantable:_M(o),...x},failed:w||R||k,...g?{components:g}:{}}}catch(r){if(!(r instanceof ve))throw r;return{doc:{...t,error:{code:r.code,message:r.message,location:r.location??null}},failed:!0}}finally{i?.cleanup(),n&&Nee(Wh(n),{recursive:!0,force:!0})}}async function nTe(e,t,n,i,r){let o=t.filter(u=>u.kind==="workspace"&&(!n.members?.length||n.members.includes(u.name)));if(o.length===0)return!1;let{foldNested:s,readNested:a}=await Promise.resolve().then(()=>(JQ(),KQ)),l=await Promise.all(o.map(async u=>{let d=Wo(i,...u.dir.split("/"));return Tl(d)?{m:u,read:await a(d,n.args??{},r,z$,W$,n.reader)}:{m:u,read:null}})),c=!1;for(let{m:u,read:d}of l){let p=e.members.find(f=>f.name===u.name);if(p){if(!d){c=!0,p.status="failed",p.reason={code:"dir-missing",message:`the nested workspace's directory ${u.dir} does not exist`};continue}d.stderr.trim()&&n.onStderr&&n.onStderr(d.stderr.endsWith(`
291
+ `)?d.stderr:`${d.stderr}
292
+ `),p.chant=d.chant,d.ok?s(e,p,d.doc):(c=!0,p.status="failed",p.reason={code:d.code,message:d.message})}}return c}async function rTe(e){let{args:t}=e,n=Dee(t.extraPositional??".");if(!Tl(n))return console.error(fe({message:`${n} does not exist`,hint:ic})),1;let i=await Bv(n,t.at);if(i!==void 0)return i;if(t.composites){if(t.intent!==void 0||t.kind!==void 0)return console.error(fe({message:"--composites takes neither --intent nor --kind",hint:ic})),1;if(!t.dryRun)return(await Promise.resolve().then(()=>(vee(),wee))).runWorkspaceComposites(e,n)}if(!t.composites&&t.intent===void 0){if((t.overlay||t.traffic!==void 0)&&!t.live)return console.error(fe({message:"--overlay and --traffic act on a live read; add --live --env <env>",hint:ic})),1;if(t.live&&t.at!==void 0)return Nh({$schema:z$,contract:W$,chant:Xt(),error:{code:"live-at-revision",message:YM,location:null}},t.output),console.error(fe({message:`live-at-revision: ${YM}`,hint:ic})),1;if(t.live&&!t.env)return console.error(fe({message:"--live needs an environment, as each member's chant graph --live does: --live --env <env>",hint:ic})),1}if(t.intent!==void 0)return(await Promise.resolve().then(()=>(_ee(),Cee))).runWorkspaceIntent(e,n);if(t.dryRun){let s;try{s=Mee({cwd:n,at:t.at,members:t.members})}catch(a){if(!(a instanceof ve))throw a;return console.error(fe({message:`${a.code}: ${a.describe()}`,hint:ic})),1}return console.log(t.json?JSON.stringify(jQ(s),null,2):NQ(s)),0}let{doc:r,failed:o}=await j$({cwd:n,at:t.at,members:t.members,args:t,...t.noCache?{noCache:!0}:{},...t.kind!==void 0?{kind:Dee(t.kind)}:{},onStderr:s=>process.stderr.write(s)});if(Nh(r,t.output),"error"in r){let s=r.error.location;console.error(fe({message:`${r.error.code}: ${s?`${s.file}:${s.line}:${s.column}: `:""}${r.error.message}`,hint:ic}))}return o?1:0}var W$,z$,eTe,YM,ic,JM=v(()=>{"use strict";Kn();IM();_$();zQ();_t();Lh();ao();HQ();uo();mn();Zt();ai();W$=1,z$="https://intentius.io/chant/schemas/workspace/graph/v1/graph.schema.json",eTe=[...co,"live-at-revision"],YM="--live reads the account as it stands now, and --at reads the source at a revision; chant workspace graph takes one of them",ic="chant workspace graph [dir] [--at <rev>] [--member <name>] [--kind <kind file>] [-o <file>] [--env <env>] [--live [--overlay] [--traffic <level>]] [--no-cache] [--dry-run] | chant workspace graph --composites [--at <rev>] [--member <name>] [-o <file>] | chant workspace graph --intent <path[:start-end]|path#symbol> [--at <rev>] [--kind <kind file>...] [--follow-squash] [--json]"});var Zee={};_e(Zee,{INTENT_CONTRACT_VERSION:()=>Hee,INTENT_ERROR_CODES:()=>lTe,INTENT_FINDING_CODES:()=>XM,INTENT_OUTPUT_SCHEMA_ID:()=>Vee,INTENT_REASON_CODES:()=>cTe,INTENT_WHY_CODES:()=>uTe,IntentError:()=>tn,addingCommit:()=>Bh,blameLines:()=>Kee,closingCommit:()=>M$,commitDetails:()=>Sp,descendants:()=>Go,intentGraph:()=>ZM,loadKinds:()=>F$,parseRegion:()=>e1,regionHistory:()=>L$,tryGit:()=>Dn,windowOpening:()=>Ep});import{execFileSync as iTe}from"node:child_process";import{realpathSync as oTe}from"node:fs";import{basename as sTe,dirname as aTe,relative as Uee,resolve as QM,sep as Gee}from"node:path";function qee(e,t,n){return iTe("git",t,{cwd:e,encoding:"utf-8",input:n,stdio:[n===void 0?"ignore":"pipe","pipe","pipe"],maxBuffer:512*1024*1024})}function Dn(e,t,n){try{return qee(e,t,n)}catch{return}}function dTe(e){let t=[];for(let n of e.matchAll(/^@@+ [^@]*\+(\d+)(?:,(\d+))? @@/gm)){let i=Number(n[1]),r=n[2]===void 0?1:Number(n[2]);r>0&&t.push({start:i,end:i+r-1})}return t}function L$(e,t,n,i,r){if(r){let a=Dn(e,["log",`-L${r.start},${r.end}:${n}`,"--format=%x00%H","--no-color",t]);return a===void 0?[]:a.split("\0").filter(Boolean).map(l=>{let c=l.indexOf(`
293
+ `);return{sha:(c<0?l:l.slice(0,c)).trim(),lines:dTe(c<0?"":l.slice(c+1))}})}let s=Dn(e,i==="file"?["log","--follow","--format=%H",t,"--",n]:["log","--format=%H",t,"--",n===""?".":n]);return s===void 0?[]:s.split(`
294
+ `).map(a=>a.trim()).filter(Boolean).map(a=>({sha:a,lines:null}))}function Kee(e,t,n,i){let r=Dn(e,["blame","--line-porcelain",...i?[`-L${i.start},${i.end}`]:[],...t?[t]:[],"--",n]);if(r===void 0)return;let o=[],s;for(let a of r.split(`
295
+ `)){if(a.startsWith(" ")){s&&o.push({line:s.line,sha:pTe.test(s.sha)?null:s.sha,origPath:s.origPath,origLine:s.origLine}),s=void 0;continue}let l=a.match(/^([0-9a-f]{40,64}) (\d+) (\d+)(?: \d+)?$/);if(l){s={sha:l[1],origLine:Number(l[2]),line:Number(l[3]),origPath:n};continue}s&&a.startsWith("filename ")&&(s.origPath=a.slice(9))}return o}function Sp(e,t){let n=new Map;if(t.length===0)return n;let i=qee(e,["log","--no-walk=unsorted","--stdin","--format=%x00%H%x1f%an%x1f%ae%x1f%aI%x1f%(trailers:only,unfold,separator=%x1e)%x1f%B"],`${t.join(`
296
+ `)}
297
+ `);for(let r of i.split("\0")){if(!r)continue;let[o,s,a,l,c,...u]=r.split(""),d=u.join("").replace(/\n+$/,""),p=d.indexOf(`
298
+ `),f={};for(let g of(c??"").split("")){let h=g.indexOf(":");if(h<=0)continue;let b=g.slice(0,h).trim();(f[b]??=[]).push(g.slice(h+1).trim())}n.set(o.trim(),{sha:o.trim(),subject:p<0?d:d.slice(0,p),body:p<0?"":d.slice(p+1).replace(/^\n+/,""),author:{name:s,email:a},date:l,trailers:f})}return n}function Bh(e,t,n){return Dn(e,["log","--diff-filter=A","-1","--format=%H",t,"--",n])?.trim()||null}function M$(e,t,n,i,r){let o=Dn(e,["log","--format=%H",t,"--",n]),s=null;for(let a of(o??"").split(`
299
+ `).map(l=>l.trim()).filter(Boolean)){let l=Dn(e,["show",`${a}:${n}`]),c=l===void 0?void 0:ls(l),u=c?.ok?c.value[i]:void 0;if(typeof u!="string"||!r.includes(u))break;s=a}return s}function Ep(e,t,n){return n.decidedIn?.sha??Bh(e,t,n.path)}function Go(e,t,n){let i=new Set([t]),r=Dn(e,["rev-list","--ancestry-path",`${t}..${n}`]);for(let o of(r??"").split(`
300
+ `))o.trim()&&i.add(o.trim());return i}function fTe(e){let n=Dn(e,["config","--get","remote.origin.url"])?.trim()?.match(/[:/]([^/:]+)\/([^/]+?)(?:\.git)?\/?$/);return n?`${n[1]}/${n[2]}`.toLowerCase():null}function zh(e){try{return oTe(e)}catch{return e}}function e1(e){let t=e.match(/^(.+?):(\d+)(?:-(\d+))?$/);if(!t)return{path:e,lines:null};let n=Number(t[2]),i=t[3]===void 0?n:Number(t[3]);return n<1||i<n?{error:`${e}: a line range is start-end with 1 <= start <= end`}:{path:t[1],lines:{start:n,end:i}}}function mTe(e,t,n){return n!==void 0?`region:${e}#${n}`:`region:${e}${t?`:${t.start}${t.end===t.start?"":`-${t.end}`}`:""}`}function gTe(e,t){let n=[],i=r=>{for(let o of(e.list(r)??[]).sort((s,a)=>s.name.localeCompare(a.name))){let s=ze(r,o.name);o.type==="dir"?ts(o.name)||i(s):n.push(s)}};return i(t==="."?"":t),n}function Dl(e){return typeof e=="string"?e:null}function Wee(e){let t=e?.source;if(t===null||typeof t!="object"||Array.isArray(t))return null;let n=t;return typeof n.finding!="string"||typeof n.region!="string"?null:{finding:n.finding,region:n.region,...typeof n.decision=="string"?{decision:n.decision}:{},...typeof n.artifact=="string"?{artifact:n.artifact}:{}}}function hTe(e){let t={agree:0,dissent:0,abstain:0,openConcerns:0},n=e?.reviews;if(!Array.isArray(n))return t;for(let i of n){if(i===null||typeof i!="object")continue;let r=i;r.verdict==="agree"?t.agree++:r.verdict==="abstain"?t.abstain++:r.verdict==="dissent"&&(t.dissent++,r.addressed_by==null&&r.withdrawn_on==null&&t.openConcerns++)}return t}async function wTe(e,t,n,i){let{workspaceGraph:r}=await Promise.resolve().then(()=>(JM(),Fee)),{doc:o}=await r({cwd:e,at:t,members:[n]});if("error"in o)return null;let s=o.nodes.find(a=>a.id===i);return s?s.sourceLoc?{file:s.sourceLoc.file,line:s.sourceLoc.line??null}:{file:".",line:null}:null}async function F$(e,t){let n=[];for(let i of e.kinds??[]){let r=QM(e.cwd,i),o=Jee(Uee(t,zh(r))),s;try{s=await FI(r)}catch(c){throw new tn("kind-unreadable",`kind file ${i} could not be loaded: ${c instanceof Error?c.message:String(c)}`)}let a=c6(s);if(typeof a=="string")throw new tn("kind-invalid",`kind file ${i} has a commitJoins export that can't be read: ${a}`);let l={file:r,display:o,name:a?.name??sTe(r).replace(/(?:\.kind)?\.[cm]?[jt]s$/,""),...a?{joins:a}:{}};if(s.recordKind!==void 0){let c=await Uh({kind:r,at:e.at,cwd:e.cwd,workGaps:!1});if("error"in c)throw new tn(c.error.code,c.error.message);try{l.records={loaded:await gn(r),views:c.records,workspaceRoot:c.workspaceRoot},l.name=a?.name??l.records.loaded.kind.name}catch(u){throw u instanceof Ve?new tn(u.code,u.message):u}}else if(!a)throw new tn("kind-invalid",`kind file ${i} exports neither recordKind nor commitJoins`);n.push(l)}return n}async function vTe(e,t,n){let i=e1(e.region);if("error"in i)throw new tn("intent-region-invalid",i.error);let r=c=>{let u=Jee(Uee(zh(t.rootOnDisk),QM(zh(e.cwd),c))),d=u===""?".":u;return d==="."||_n(d)&&!d.startsWith("../")&&t.tree.stat(d)!==void 0?d:void 0},o=r(i.path);if(o!==void 0)return{path:o,lines:i.lines,node:null,symbol:null};let s=i.lines?-1:e.region.lastIndexOf("#");if(s>0){let c=e.region.slice(s+1),u=r(e.region.slice(0,s));if(u!==void 0&&c!==""){if(u==="."||t.tree.stat(u)!=="file")throw new tn("intent-region-invalid",`${u} is a directory, and a symbol needs a file`);let d=[],p="";if(!AM(u)){let g=Mr(u,n.members),h=g?n.members.find(b=>b.name===g):void 0;if(h&&h.kind==="chant"){let b=await gQ(hQ(t.rootOnDisk,h.dir),e.loadLexicon);d=b.resolvers,b.problems.length>0&&(p=`; member ${h.name}: ${b.problems.join("; ")}`)}}let f=PM(u,t.tree.read(u),c,d);if(!f.ok)throw new tn(f.reason==="unsupported"?"intent-symbol-unsupported":f.reason==="ambiguous"?"intent-symbol-ambiguous":"intent-symbol-unknown",`${f.message}${f.reason==="unsupported"?p:""}${t.tree.label}`);return{path:u,lines:f.declaration.lines,node:null,symbol:{name:c,qualified:f.declaration.qualified,kind:f.declaration.kind}}}}let a=e.region.indexOf("/"),l=a>0?n.members.find(c=>c.name===e.region.slice(0,a)):void 0;if(l&&!i.lines){let c=await(e.resolveNode??wTe)(e.cwd,e.at,l.name,e.region);if(c){let u=ze(l.dir,c.file);return{path:u===""?".":u,lines:c.line?{start:c.line,end:c.line}:null,node:e.region,symbol:null}}}throw new tn("intent-region-invalid",`${e.region} is not a path in the workspace${t.tree.label}, a path#symbol, or a graph node id`)}async function ZM(e){let t={$schema:Vee,contract:Hee,chant:Xt()};try{return await kTe(e,t)}catch(n){if(n instanceof tn||n instanceof ve||n instanceof Ve)return{doc:{...t,error:{code:n.code,message:n.message}},failed:!0};throw n}}async function kTe(e,t){let n=Qt(e.cwd,e.at),i=n.top;if(!i)throw new tn("not-a-git-repository","the intent graph reads git history, and this directory is not in a git repository");let r=Lt(n.tree,"",{rootChant:!0}),o=await vTe(e,n,r),s=o.path==="."?"dir":n.tree.stat(o.path);if(!s)throw new tn("intent-region-invalid",`${o.path} does not exist${n.tree.label}`);if(o.lines){if(s!=="file")throw new tn("intent-region-invalid",`${o.path} is a directory, and a line range needs a file`);let S=n.tree.read(o.path).replace(/\n$/,"").split(`
301
+ `).length;if(o.lines.end>S)throw new tn("intent-region-invalid",`${o.path} has ${S} lines${n.tree.label}, so ${o.lines.start}-${o.lines.end} is not in it`)}let a=e.kinds??Ti(r).map(S=>ja(S,n.rootOnDisk)),l=await F$({...e,kinds:a},i),c=new Map,u=[],d=[],p=[],f=S=>(c.has(S.id)||c.set(S.id,S),c.get(S.id)),g=(S,A,P)=>{p.push({id:`finding:${S}:${p.filter(j=>j.code===S).length+1}`,kind:"finding",code:S,message:A,concerns:P})},h=o.path==="."?r.members.find(S=>S.dir===".")?.name??null:Mr(o.path,r.members),b=mTe(o.path,o.lines,o.symbol?.name);f({id:b,kind:"region",path:o.path,lines:o.lines,member:h,at:n.at,type:s,generated:s==="file"?SD(r,o.path):null,node:o.node,symbol:o.symbol});let w=s==="dir"?gTe(n.tree,o.path):[];for(let S of w)f({id:`file:${S}`,kind:"file",path:S,member:Mr(S,r.members),generated:SD(r,S)});let x=S=>{let A=r.members.find(P=>P.name===S);return f({id:`member:${S}`,kind:"member",name:S,dir:A?.dir??"",memberKind:A?.kind??""})};h&&x(h);let k=n.at??(Dn(i,["rev-parse","--verify","--quiet","HEAD^{commit}"])?.trim()||null),R=Dn(i,["rev-parse","--is-shallow-repository"])?.trim()==="true";R&&d.push({code:"intent-history-shallow",message:"this is a shallow clone, so the history stops at its boundary and the oldest commit listed may stand for many"});let $=n.root==="."?"":n.root,_=ze($,o.path),T=k?L$(i,k,_,s,o.lines):[],C=s==="file"?o.lines??{start:1,end:Math.max(1,n.tree.read(o.path).replace(/\n$/,"").split(`
302
+ `).length)}:null,K=C===null?[]:(k?Kee(i,n.at,_,o.lines):void 0)??(n.at===null?Array.from({length:C.end-C.start+1},(S,A)=>({line:C.start+A,sha:null,origPath:_,origLine:C.start+A})):[]);for(let S of new Set(K.map(A=>A.sha).filter(A=>A!==null)))T.some(A=>A.sha===S)||T.push({sha:S,lines:null});let O=Sp(i,T.map(S=>S.sha)),pe=e.followSquash?Lg(i,[...O.values()],{fetchMissing:!0}):new Map;for(let S of pe.values())S.problem&&d.push({code:"squash-unfollowed",message:`${S.sha.slice(0,8)} squashes pull request #${S.pullRequest}, and ${S.problem}, so its original commits are not followed`});let F=Sp(i,[...new Set([...pe.values()].flatMap(S=>S.commits))]),Q=S=>(pe.get(S)?.commits??[]).map(A=>F.get(A)).filter(A=>A!==void 0),I=si(i,Br(i)),B=I.active?await Gm():[],Z=S=>{if(!(!_n(S)||n.tree.stat(S)!=="file"))return n.tree.read(S)},xe=S=>{let A=S==="."?"":S.replace(/\/+$/,"");return A!==""&&(!_n(A)||n.tree.stat(A)!=="dir")?void 0:n.tree.list(A)?.map(j=>`${ze(A,j.name)}${j.type==="dir"?"/":""}`).sort()},we=new Map,Ct=C$(i,[...O.values(),...F.values()]),at=[],$e=S=>{if(!I.active)return{level:"unattested",reason:I.problems.length?I.problems.join("; "):`no signers file (${I.signersPath}) at base; attestation is off`};let A=Wm(i,I,S,B);return{level:A.level,reason:A.reason,...A.principal?{principal:A.principal}:{}}},Te=new Set;for(let S of T){let A=O.get(S.sha);if(!A)continue;let P=$e(A.sha),j=A.subject.match(/\(#([0-9]+)\)\s*$/),U=`commit:${A.sha}`,L=pe.get(A.sha),re=L?{pullRequest:L.pullRequest,forge:L.forge,ref:L.ref,head:L.head,fetched:L.fetched,followed:L.followed,commits:Q(A.sha).map(it=>({sha:it.sha,subject:it.subject,author:it.author,date:it.date,trailers:it.trailers,signature:$e(it.sha),joins:Ct.get(it.sha).joins}))}:void 0;f({id:U,kind:"commit",sha:A.sha,subject:A.subject,author:A.author,date:A.date,trailers:A.trailers,pullRequest:j?Number(j[1]):null,signature:P,lines:S.lines,state:null,joins:Ct.get(A.sha).joins,...re?{squash:re}:{}}),u.push({kind:"touched-by",from:b,to:U,lines:S.lines});let me={contracts:[],authorship:[],decisions:[],carries:[]};we.set(A.sha,me);let Be=it=>{u.some(lr=>lr.kind===it.kind&&lr.from===it.from&&lr.to===it.to)||u.push(it)},Gt=[A,...Q(A.sha)];for(let it of l)if(it.joins)for(let lr of Gt){let _p=lr!==A,wn;try{wn=await Lv(it.joins,lr,{read:Z,list:xe,at:n.at},it.name)}catch(Or){let Ki=`${it.display}: commitJoins failed for ${lr.sha.slice(0,8)}: ${Or instanceof Error?Or.message:String(Or)}`;Te.has(Ki)||d.push({code:"intent-plugin-failed",message:Ki}),Te.add(Ki);continue}let Ll=(Or,Ki)=>{let{id:Ls,...ae}=Ki;return f({id:`${Or}:${Ls}`,kind:Or,ref:Ls,plugin:it.display,data:ae}).id},ki=wn.unit?Ll("unit",wn.unit):void 0,sc=wn.contract?Ll("contract",wn.contract):void 0;ki&&(_p?me.unit??=ki:me.unit=ki,Be({kind:"produced-by",from:U,to:ki}),sc&&Be({kind:"serves",from:ki,to:sc})),sc&&me.contracts.push(wn.contract.id),ki&&me.decisions.push(...Td(wn.unit),...Td(wn.contract));for(let Or of wn.findings??[])at.push({commit:U,plugin:it.display,finding:Or});let ac=wn.evidence===void 0?[]:Array.isArray(wn.evidence)?wn.evidence:[wn.evidence];for(let Or of ac)Be({kind:"cites-evidence",from:ki??sc??U,to:Ll("evidence",Or)});_p||me.authorship.push(...wn.authorship??[])}}let nt=await Lk(i,n.rootOnDisk,[...new Set([...T.map(S=>S.sha),...F.keys()])].map(S=>({sha:S,run:Ct.get(S)?.joins.run??null})));Mk(nt.refs,pe);for(let S of T)if(c.has(`commit:${S.sha}`))for(let A of nt.refs.get(S.sha)??[]){let P=nt.runs.get(A.id),j=f({id:`run:${A.id}`,kind:"run",run:A.id,recorded:P!==void 0,state:P?.state??null,harness:P?.harness??null,model:P?.model??null,provider:P?.provider??null,by:P?.by??null,agent:P?.agent??null,unit:P?.unit?.id??null,startedAt:P?.startedAt??null,endedAt:P?.endedAt??null,outcome:P?.outcome??null,usage:P?.usage??null,cost:P?.cost??null,transcript:P?.transcript??null,instruction:P?.instruction??null,lease:P?.lease??null});u.push({kind:"made-by",from:`commit:${S.sha}`,to:j.id,joinedBy:A.joinedBy,...A.recordedAs?{recordedAs:A.recordedAs}:{},...A.via?{via:A.via}:{}})}for(let S of nt.conflicts){if(!c.has(`commit:${S.sha}`))continue;let A=S.content.map(P=>`${P.run} (${P.sha.slice(0,8)})`).join(", ");g("intent-commit-join-conflict",`${S.sha.slice(0,8)} joins ${S.joined.join(", ")} by its trailer or the run's record, and has the patch-id of a commit ${A} recorded; it is not joined to ${S.content.length===1?"that run":"those runs"}`,[`commit:${S.sha}`,...S.joined.map(P=>`run:${P}`)])}let St=o.path==="."?$:_,Ee=fTe(i),zt=new Set;for(let S of O.values())for(let A of S.subject.matchAll(/#([0-9]+)/g))zt.add(A[1]);let Vn=new Set([...we.values()].flatMap(S=>S.contracts)),ne=[],Re=new Map,X=(S,A)=>`record:${S.records.loaded.kind.name}/${A}`,Ce=(S,A)=>{let P=S.records.loaded.kind,j=GI(P,A.data);return f({id:X(S,A.id),kind:"decision",recordKind:P.name,record:A.id,path:A.path,title:Dl(A.data?.title),state:A.state,closed:A.state!==null&&(P.closedStates??[]).includes(A.state),valid:A.valid,reasons:A.reasons,provenance:{level:A.provenance.level,commit:A.provenance.commit,reason:A.provenance.reason},decided_by:Dl(A.data?.decided_by),decided_on:Dl(A.data?.decided_on),decidedIn:A.decidedIn??null,reviews:hTe(A.data),supersededBy:A.supersededBy,supersedes:j,constrains:[]})},tt=S=>w.filter(A=>cs(S,ze($,A))),gt=(S,A)=>{let P=S.records.loaded.kind.constrains?.field,j=S.records.workspaceRoot==="."?"":S.records.workspaceRoot,U=P?A.data?.[P]:void 0,L=[];if(!Array.isArray(U))return L;for(let re of U)if(typeof re=="string")if(re.startsWith("path:")){let me=re.slice(5);if(!_n(me))continue;let Be=ze(j,me);if(St!==""&&cs(Be,St))L.push({entry:re,granularity:"path",to:b});else if(s==="dir"&&Be!==St&&(St===""||Be.startsWith(`${St}/`)))for(let Gt of tt(Be))L.push({entry:re,granularity:"path",to:`file:${Gt}`})}else if(re.startsWith("member:"))h!==null&&re.slice(7)===h&&L.push({entry:re,granularity:"member",to:b});else{let me=re.match(bTe);me&&Ee!==null&&me[1].toLowerCase()===Ee&&zt.has(me[2])?L.push({entry:re,granularity:"issue",to:b}):Vn.has(re)&&L.push({entry:re,granularity:"contract",to:`contract:${re}`})}return L};for(let S of l)if(!(!S.records||S.records.loaded.kind.work))for(let A of S.records.views){if(A.id===null)continue;Re.set(`${S.records.loaded.kind.name}/${A.id}`,{view:A,kind:S});let P=gt(S,A);if(P.length===0)continue;let j=Ce(S,A);for(let U of P)u.push({kind:"constrains",from:j.id,to:U.to,granularity:U.granularity,entry:U.entry}),(U.to===b||U.granularity==="contract")&&j.constrains.push({entry:U.entry,granularity:U.granularity});j.constrains.length>0&&ne.push({view:A,kind:S,node:j})}let Je=[...c.values()].filter(S=>S.kind==="decision");for(;Je.length>0;){let S=Je.shift(),A=[];S.supersededBy&&A.push(`${S.recordKind}/${S.supersededBy}`);for(let[P,{view:j}]of Re)P.startsWith(`${S.recordKind}/`)&&j.supersededBy===S.record&&A.push(P);for(let P of A){let j=Re.get(P);if(!j)continue;let U=X(j.kind,j.view.id);c.has(U)||Je.push(Ce(j.kind,j.view))}}let Bt=[...c.values()].filter(S=>S.kind==="decision");for(let S of Bt)if(S.supersededBy){let A=`record:${S.recordKind}/${S.supersededBy}`;c.has(A)&&u.push({kind:"supersedes",from:A,to:S.id})}let W=new Map;for(let S of Bt){let A=Re.get(`${S.recordKind}/${S.record}`),P=A.kind.records.loaded.kind;for(let U of A.view.assets){let L=W.get(U.path)??[];L.push({decision:S,state:U.state,sha256:U.sha256,actual:U.actual}),W.set(U.path,L)}let j=P.pins?A.view.data?.[P.pins.field]:void 0;if(Array.isArray(j))for(let U of j){if(U===null||typeof U!="object"||Array.isArray(U))continue;let L=U,re=typeof L.sha256=="string"&&yTe.test(L.sha256);if(_n(L.path)){if(re)continue;let Be=W.get(L.path)??[];Be.push({decision:S,state:"unpinned",sha256:null,actual:null}),W.set(L.path,Be),g("intent-evidence-unpinned",`${S.record} names ${L.path} as evidence with no sha256, so a later edit can't be told from what was decided on`,[S.id,`artifact:${L.path}`]);continue}if(typeof L.url!="string")continue;let me=f({id:`evidence:${L.url}`,kind:"evidence",ref:L.url,plugin:null,data:{title:Dl(L.title),url:L.url,path:null,as_of:Dl(L.as_of),sha256:re?L.sha256:null}});u.push({kind:"cites-evidence",from:S.id,to:me.id}),re||g("intent-evidence-unpinned",`${S.record} cites ${L.url} with no hash, so what the page said when it was decided can't be checked`,[S.id,me.id])}}for(let[S,A]of W){let P=`artifact:${S}`,U=[...A.filter(L=>L.decision.supersededBy===null&&L.state!=="unpinned")].sort((L,re)=>zee.indexOf(L.state)-zee.indexOf(re.state))[0];f({id:P,kind:"artifact",path:S,anchor:null,pinnedSha256:U?.sha256??null,currentSha256:A.find(L=>L.state!=="unpinned")?.actual??null,pinState:U?.state??"unpinned"});for(let L of A)if(u.push({kind:"pins",from:L.decision.id,to:P,pinnedSha256:L.sha256,pinState:L.state}),L.state==="drifted"&&g("intent-pin-drifted",`${S} changed after ${L.decision.record} pinned it: sha256 ${L.sha256?.slice(0,12)} is pinned, the file hashes to ${L.actual?.slice(0,12)}`,[L.decision.id,P]),L.state==="missing"&&g("intent-pin-missing",`${L.decision.record} pins ${S}, which does not exist${n.tree.label}`,[L.decision.id,P]),L.state==="stale"&&L.decision.supersededBy===null&&L.decision.constrains.length>0){let re=A.find(me=>me.decision.supersededBy===L.decision.record&&me.decision.recordKind===L.decision.recordKind&&me.sha256===L.sha256);g("intent-pin-stale",`${S} is pinned by ${L.decision.record} at sha256 ${L.sha256?.slice(0,12)}, the hash ${re?re.decision.record:"the record it supersedes"} pinned, and it has not changed since: the decision moved on and the artifact did not`,[L.decision.id,P,...re?[re.decision.id]:[]])}!U&&A.some(L=>L.state!=="unpinned")&&g("intent-artifact-unpinned",`${S} was pinned by ${[...new Set(A.map(L=>L.decision.record))].join(", ")}, and no current decision pins it`,[P,...new Set(A.map(L=>L.decision.id))])}for(let S of Bt){let A=Re.get(`${S.recordKind}/${S.record}`),P=A.kind.records.loaded.kind.constrains?.field,j=P?A.view.data?.[P]:void 0;if(!Array.isArray(j))continue;let U=A.kind.records.workspaceRoot==="."?"":A.kind.records.workspaceRoot;for(let L of j){if(typeof L!="string"||!L.startsWith("path:"))continue;let re=L.slice(5);if(!_n(re))continue;let me=ze(U,re),Be=$===""?me:me.startsWith(`${$}/`)?me.slice($.length+1):void 0;Be!==void 0&&n.tree.stat(Be)===void 0&&g("intent-constraint-lost",`${S.record} constrains ${re}, which does not exist${n.tree.label}`,[S.id])}}let de=new Map;if(k)for(let S of ne){let A=Ep(i,k,S.view),P=S.view.supersededBy?Re.get(`${S.node.recordKind}/${S.view.supersededBy}`):void 0,j=P?Ep(i,k,P.view):null;de.set(S.node.id,{from:A?Go(i,A,k):new Set,until:j?Go(i,j,k):null})}let Oe=l.filter(S=>S.records?.loaded.kind.work),pt=Oe.length>0,et=[],Ut=new Map;for(let S of Oe)for(let A of S.records.views){if(A.id===null)continue;let P={view:A,kind:S};et.push(P);let j=`${S.records.loaded.kind.name}/${A.id}`;Ut.has(j)||Ut.set(j,P)}let Tt=S=>S.kind.records.loaded.kind.work,wt=S=>{if(S.node)return S.node;let A=S.kind.records.loaded.kind,P=S.view;return S.node=f({id:`record:${A.name}/${P.id}`,kind:"work",recordKind:A.name,record:P.id,path:P.path,title:Dl(P.data?.title),state:P.state,closed:P.state!==null&&(A.closedStates??[]).includes(P.state),valid:P.valid,reasons:P.reasons,provenance:{level:P.provenance.level,commit:P.provenance.commit,reason:P.provenance.reason},owner:Dl(P.data?.owner),ready:P.ready??!1,blockedBy:P.blockedBy??[],implements:P.implements??[],needs:Rr(P.data,A.work.needs),source:Wee(P.data),supersededBy:P.supersededBy,constrains:[],warnings:P.warnings.filter(j=>CI.includes(j.code))}),S.node},qn=S=>{let A=zh(QM(aTe(S.records.loaded.file),S.records.loaded.kind.work.decisions));return l.find(P=>P.records&&!P.records.loaded.kind.work&&zh(P.records.loaded.file)===A)},Ar=S=>{let A=qn(S.kind);return A?Rr(S.view.data,Tt(S).implements).map(P=>Re.get(`${A.records.loaded.kind.name}/${P}`)).filter(P=>P!==void 0).map(P=>X(P.kind,P.view.id)):[]},Pr=S=>et.filter(A=>{let P=A.kind.records.loaded.kind;return!(A.view.state!==null&&A.view.state!==P.work.done&&(P.closedStates??[]).includes(A.view.state))&&Ar(A).includes(S.id)}),vi=[];for(let S of et){let A=gt(S.kind,S.view);if(A.length===0)continue;let P=wt(S);for(let j of A)u.push({kind:"constrains",from:P.id,to:j.to,granularity:j.granularity,entry:j.entry}),(j.to===b||j.granularity==="contract")&&P.constrains.push({entry:j.entry,granularity:j.granularity});P.constrains.length>0&&vi.push(S)}let Ho=new Map;if(k)for(let S of vi){let A=S.kind.records.loaded.kind,P=Bh(i,k,S.view.path),j=A.stateField?M$(i,k,S.view.path,A.stateField,A.closedStates??[]):null,U=j?Go(i,j,k):null;j&&U.delete(j),Ho.set(S.node.id,{from:P?Go(i,P,k):new Set,until:U})}let y=(S,A)=>{let P=Ho.get(S.node.id);return!!P&&P.from.has(A)&&!P.until?.has(A)},N=new Map(l.filter(S=>S.records).map(S=>[S.records.loaded.kind.name,S])),q=S=>{let A=[],P=j=>{A.some(U=>U.node===j.node)||A.push(j)};if(S.unit){let U=(S.unit.kind?Oe.filter(L=>L.records.loaded.kind.name===S.unit.kind):Oe).map(L=>Ut.get(`${L.records.loaded.kind.name}/${S.unit.id}`)).filter(L=>L!==void 0);U.length===1&&P({node:wt(U[0]).id,work:U[0]})}for(let j of S.records){let U=N.get(j.kind);if(!U)continue;if(U.records.loaded.kind.work){let re=Ut.get(`${j.kind}/${j.id}`);re&&P({node:wt(re).id,work:re});continue}let L=Re.get(`${j.kind}/${j.id}`);L&&P({node:Ce(L.kind,L.view).id,decision:`${j.kind}/${j.id}`})}return A};for(let S of T){let A=c.get(`commit:${S.sha}`),P=we.get(S.sha);if(!A||!P)continue;let j=L=>{P.carries.includes(L)||(P.carries.push(L),u.push({kind:"carries",from:A.id,to:L}))},U=L=>{let re=wt(L);return j(re.id),P.decisions.push(...Ar(L).map(me=>me.slice(7))),re.id};for(let L of[A.joins,...(A.squash?.commits??[]).map(re=>re.joins)]){for(let me of L.records){let Be=N.get(me.kind);if(!Be)continue;if(Be.records.loaded.kind.work){let it=Ut.get(`${me.kind}/${me.id}`);it&&(me.node=U(it));continue}let Gt=Re.get(`${me.kind}/${me.id}`);Gt&&(me.node=Ce(Gt.kind,Gt.view).id,j(me.node),P.decisions.push(`${me.kind}/${me.id}`))}let re=L.lease?.item;if(re){let me=Oe.map(Be=>Ut.get(`${Be.records.loaded.kind.name}/${re}`)).filter(Be=>Be!==void 0);me.length===1&&U(me[0])}}for(let L of nt.refs.get(S.sha)??[]){let re=nt.runs.get(L.id);if(re)for(let me of q(re))me.work?U(me.work):me.decision&&(j(me.node),P.decisions.push(me.decision))}}for(let S of[...c.values()]){if(S.kind!=="run")continue;let A=nt.runs.get(S.run);if(A)for(let P of q(A))u.push({kind:"worked-on",from:S.id,to:P.node})}for(let S of et.filter(A=>A.node)){for(let A of Ar(S)){let P=Re.get(A.slice(7));u.push({kind:"implements",from:S.node.id,to:Ce(P.kind,P.view).id})}for(let A of Rr(S.view.data,Tt(S).needs)){let P=Ut.get(`${S.kind.records.loaded.kind.name}/${A}`);P&&u.push({kind:"needs",from:S.node.id,to:wt(P).id})}}let Y=(S,A)=>ne.filter(P=>{if(!P.node.constrains.some(U=>A.includes(U.granularity)))return!1;let j=de.get(P.node.id);return!!j&&j.from.has(S)&&!j.until?.has(S)}),z=l.some(S=>S.records),E=(S,A)=>(!!S.unit||S.carries.length>0)&&(S.decisions.some(P=>P===A.record||P===`${A.recordKind}/${A.record}`)||A.constrains.some(P=>P.granularity==="contract"&&S.contracts.includes(P.entry)));for(let S of T){let A=c.get(`commit:${S.sha}`);if(!A)continue;let P=we.get(S.sha);if(z){let U=Y(S.sha,["path"]);for(let L of U)u.push({kind:"within",from:A.id,to:L.node.id,state:E(P,L.node)?"decided":"decided-by-window"});A.state=U.length===0?"undecided":U.some(L=>E(P,L.node))?"decided":"decided-by-window"}for(let U of vi)U.node.constrains.some(L=>L.granularity==="path")&&y(U,S.sha)&&u.push({kind:"within",from:A.id,to:U.node.id,state:"worked"});z&&A.state==="undecided"&&g("intent-commit-undecided",`${S.sha.slice(0,8)} changed the region when no decision constrained ${o.path} by path`,[A.id,b]),z&&!P.unit&&P.carries.length===0&&A.pullRequest===null&&Y(S.sha,["path","member","contract","issue"]).length===0&&g("intent-commit-bare",`${S.sha.slice(0,8)} names no unit, no record, no pull request and no decision`,[A.id]);let j=[...new Set(P.authorship)].filter(U=>QI(A.trailers,U));j.length>0&&A.signature.level!=="attested"&&g("intent-trailer-unverified",`${S.sha.slice(0,8)} carries ${j.join(", ")}, and the commit is ${A.signature.level}, so nothing vouches for the trailer`,[A.id])}if(z){let S=ne.filter(P=>P.node.supersededBy===null);ne.length===0?g("intent-region-unconstrained",`no decision constrains ${o.path}`,[b]):S.length===0?g("intent-decision-superseded-live",`every decision constraining ${o.path} is superseded: ${ne.map(P=>`${P.node.record} by ${P.node.supersededBy}`).join(", ")}`,[b,...ne.map(P=>P.node.id)]):S.every(P=>!P.node.closed)&&g("intent-decision-provisional",`the decisions constraining ${o.path} are ${[...new Set(S.map(P=>P.node.state??"stateless"))].join(" or ")}, and none is in a closed state`,[b,...S.map(P=>P.node.id)]);for(let P of S){let j=P.view.quorum?.openConcerns??[];if(j.length===0)continue;let U=[...new Set(j.map(L=>L.principal))];p.push({id:`finding:intent-decision-contested:${p.filter(L=>L.code==="intent-decision-contested").length+1}`,kind:"finding",code:"intent-decision-contested",message:`${P.node.record} constrains ${o.path} and has ${j.length} open ${j.length===1?"concern":"concerns"}, from ${j.map(L=>L.reviewer).join(", ")}: a dissent neither addressed nor withdrawn`,concerns:[P.node.id,b],openConcerns:{count:j.length,principals:U}})}let A=new Set(ne.flatMap(P=>P.node.constrains.map(j=>j.granularity)));ne.length>0&&!A.has("path")&&A.has("member")&&g("intent-constraint-coarse",`${o.path} is constrained only through its member, ${h}`,[b,...ne.map(P=>P.node.id)])}if(pt){for(let S of ne){if(S.node.supersededBy!==null||!Uc(S.kind.records.loaded.kind,S.node.state)||Pr(S.node).length>0)continue;let A=de.get(S.node.id);A&&T.some(P=>A.from.has(P.sha)&&!A.until?.has(P.sha))||g("intent-decision-unimplemented",`${S.node.record} is ${S.node.state} and constrains ${o.path}, and no work item that is not dropped implements it, and no commit changed the region in its window`,[S.node.id,b])}for(let S of vi){let A=S.node;if(A.blockedBy.length===0)continue;let P=T.filter(L=>y(S,L.sha));if(P.length===0)continue;let j=A.blockedBy.map(L=>`${L.id} (${L.state??"unknown"})`).join(", "),U=A.blockedBy.map(L=>Ut.get(`${A.recordKind}/${L.id}`)).filter(L=>L!==void 0).map(L=>wt(L).id);g("intent-work-blocked",`${A.record} has ${P.length} ${P.length===1?"commit":"commits"} in its window while it waits on ${j}`,[A.id,...P.map(L=>`commit:${L.sha}`),...U])}for(let S of[...c.values()].filter(A=>A.kind==="decision")){let A=u.filter(j=>j.kind==="within"&&j.to===S.id&&j.state==="decided").map(j=>j.from);if(A.length===0)continue;let P=Pr(S);P.length===0||P.some(j=>j.view.state===Tt(j).done)||g("intent-work-open-decided-code",`${A.length} ${A.length===1?"commit":"commits"} in ${o.path} ${A.length===1?"is":"are"} ${S.record}'s own work, and ${P.map(j=>`${j.view.id} is ${j.view.state??"stateless"}`).join(", ")}: the code says done and the queue says not`,[S.id,...A,...P.map(j=>wt(j).id)])}}if(h){let S=[];try{let A=ma(r,n.tree),P=pa(r.pins,n.rootOnDisk).registry;S=TD(r,dZ(r,n.tree,A,P)).filter(j=>j.origin==="declared")}catch(A){if(!(A instanceof ve))throw A}S.forEach((A,P)=>{let j="producer"in A?A.producer:null;if(A.consumer!==h&&j!==h)return;let{pointer:U,...L}=A;f({id:`link:${P+1}`,kind:"link",row:L}),x(A.consumer),j&&r.members.some(re=>re.name===j)&&(x(j),u.push({kind:"links",from:`member:${A.consumer}`,to:`member:${j}`}))})}p.sort((S,A)=>XM.indexOf(S.code)-XM.indexOf(A.code));let G=S=>{if(c.has(S))return S;for(let A of["commit","unit","contract","evidence","artifact","file","member"])if(c.has(`${A}:${S}`))return`${A}:${S}`;for(let A of c.values())if(A.kind==="decision"&&(S===A.record||S===`${A.recordKind}/${A.record}`)||A.kind==="commit"&&/^[0-9a-f]{7,}$/.test(S)&&A.sha.startsWith(S))return A.id};for(let{commit:S,plugin:A,finding:P}of at){let j=P.code,U=P.refs??[],L=[...new Set([S,...U.map(G).filter(re=>re!==void 0)])];p.push({id:`finding:${j}:${p.filter(re=>re.code===j).length+1}`,kind:"finding",code:j,message:P.message,concerns:L,plugin:A,refs:U})}if(pt){let S=new Set(["intent-pin-drifted","intent-pin-missing","intent-pin-stale"]),A=(P,j)=>{let U=Wee(P.view.data);if(U===null||U.finding!==j)return!1;let L=e1(U.region);if("error"in L)return!1;let re=P.kind.records.workspaceRoot==="."?"":P.kind.records.workspaceRoot,me=ze(re,L.path),Be=(Gt,it)=>Gt===it||Gt===""||it.startsWith(`${Gt}/`);return!Be(me,St)&&!Be(St,me)?!1:me===St&&L.lines&&o.lines?L.lines.start<=o.lines.end&&o.lines.start<=L.lines.end:!0};for(let P of p){let j=[];for(let U of et){let L=A(U,P.code),re=(S.has(P.code)||Dv(P.code))&&Ar(U).some(me=>P.concerns.includes(me));if((L||re)&&j.push(U),L&&U.view.state===Tt(U).done){let me=wt(U);me.warnings.some(Be=>Be.code==="work-done-gap-open")||me.warnings.push({code:"work-done-gap-open",message:`${me.record} is ${U.view.state}, and ${P.code}, the gap it came from, still fires on ${o.path}`})}}P.addressed=j.length>0,P.addressedBy=j.map(U=>({id:U.view.id,state:U.view.state}));for(let U of j)u.push({kind:"addressed-by",from:P.id,to:wt(U).id})}}let H=[...c.values()].filter(S=>S.kind==="work");if(H.length>0){let S=new Map(H.map(A=>[`${A.recordKind}:${A.record}`,A]));for(let A of l){let P=A.records?.loaded.kind;if(P?.session)for(let j of A.records.views){if(j.id===null||!j.data)continue;let U=new Map,L=(me,Be)=>{if(Array.isArray(me))for(let Gt of me){let it=typeof Gt=="string"?S.get(Gt):void 0;if(!it)continue;let lr=U.get(it)??[];Be!==null&&!lr.includes(Be)&&lr.push(Be),U.set(it,lr)}};L(j.data.follow_ups,null),(Array.isArray(j.data.comments)?j.data.comments:[]).forEach((me,Be)=>L(me?.follow_ups,Be+1));for(let[me,Be]of U)(me.reviews??=[]).push({id:`record:${P.name}/${j.id}`,recordKind:P.name,record:j.id,path:j.path,state:j.state,comments:Be.sort((Gt,it)=>Gt-it)})}}}for(let S of p)c.set(S.id,S);let ee=oe(),te=[...c.values()];return{doc:{...t,at:n.at,workspace:{name:r.name,root:n.root},region:b,history:{rev:k,follows:o.lines?"line-range":s==="file"?"file":"directory",shallow:R},kinds:l.map(S=>({file:S.display,name:S.name,records:S.records?.loaded.kind.name??null,joins:S.joins?.form??null})),nodes:te,edges:u,reasons:d,summary:{commits:te.filter(S=>S.kind==="commit").length,decisions:te.filter(S=>S.kind==="decision").length,artifacts:te.filter(S=>S.kind==="artifact").length,findings:p.length},why:ee},failed:d.some(S=>S.code==="intent-plugin-failed")};function oe(){let S=(ae,ye)=>nt.runs.get(ae)?.commits.find(ct=>ct.sha===ye)?.hunks??null,A=(ae,ye)=>(nt.refs.get(ye)??[]).find(ct=>ct.id===ae)?.joinedBy??[],P=(ae,ye)=>{let ct=new Set(ae.flatMap(ft=>ye.flatMap(Cr=>A(ft,Cr))));return PZ.filter(ft=>ct.has(ft))},j=new Map,U=(ae,ye,ct)=>{let ft=pe.get(ae);if(!ft?.followed||!ft.head)return{squash:!1,origin:void 0};let Cr=`${ae}\0${ye}`;return j.has(Cr)||j.set(Cr,mZ(i,ae,ft.head,ye,new Set(ft.commits))),{squash:!0,origin:j.get(Cr)?.get(ct)}},L=K.map(ae=>{if(ae.sha===null)return{line:ae.line,sha:null,runs:[],narrowedBy:null,via:void 0};let ye=ae.sha,{squash:ct,origin:ft}=U(ye,ae.origPath,ae.origLine),Cr=ct?ft?[ft]:[]:void 0,cc=(nt.refs.get(ye)??[]).filter(Dt=>!ft||Dt.joinedBy.some(Vo=>Vo!=="squash")||(Dt.via??[]).includes(ft)).map(Dt=>Dt.id),vn=cc.filter(Dt=>S(Dt,ye)!==null);if(vn.length===0)return{line:ae.line,sha:ye,runs:cc,narrowedBy:null,via:Cr};let Zh=vn.filter(Dt=>S(Dt,ye).some(Vo=>Vo.path===ae.origPath&&Vo.start<=ae.origLine&&ae.origLine<=Vo.end));return{line:ae.line,sha:ye,runs:Zh.length>0?Zh:cc.filter(Dt=>!vn.includes(Dt)),narrowedBy:"hunks",via:Cr}}),re=[];for(let ae of L){let ye=re[re.length-1],ct=ae.via;if(ye&&ye.end===ae.line-1&&ye.sha===ae.sha&&ye.narrowedBy===ae.narrowedBy&&ye.runs.join("\0")===ae.runs.map(ft=>`run:${ft}`).join("\0")&&ye.via?.join("\0")===ct?.join("\0")){ye.end=ae.line;continue}re.push({start:ae.line,end:ae.line,commit:ae.sha?`commit:${ae.sha}`:null,sha:ae.sha,runs:ae.runs.map(ft=>`run:${ft}`),narrowedBy:ae.narrowedBy,joinedBy:ae.sha?P(ae.runs,[ae.sha]):[],...ct?{via:ct}:{}})}let me=ae=>{let ye=[];for(let ct of ae){let ft=ye[ye.length-1];ft&&ft.end===ct-1?ft.end=ct:ye.push({start:ct,end:ct})}return ye},Be=[...c.values()].filter(ae=>ae.kind==="decision"),Gt=ae=>L.filter(ye=>ye.sha!==null&&E(we.get(ye.sha)??{contracts:[],authorship:[],decisions:[],carries:[]},ae)).length,it=["carried","path","contract","issue","member","related"],lr=Be.map(ae=>{let ye=Gt(ae),ct=ye>0||C===null&&T.some(vn=>E(we.get(vn.sha)??{contracts:[],authorship:[],decisions:[],carries:[]},ae)),ft=new Set(ae.constrains.map(vn=>vn.granularity)),Cr=ct?"carried":["path","contract","issue","member"].find(vn=>ft.has(vn))??"related",cc=Math.max(0,...ae.constrains.filter(vn=>vn.granularity==="path").map(vn=>vn.entry.length));return{d:ae,entry:{decision:ae.id,relevance:Cr,current:ae.supersededBy===null,closed:ae.closed,lines:ye},specificity:cc}});lr.sort((ae,ye)=>Number(ye.entry.current)-Number(ae.entry.current)||it.indexOf(ae.entry.relevance)-it.indexOf(ye.entry.relevance)||ye.entry.lines-ae.entry.lines||Number(ye.entry.closed)-Number(ae.entry.closed)||ye.specificity-ae.specificity||(ye.d.decidedIn?.date??"").localeCompare(ae.d.decidedIn?.date??"")||ae.d.id.localeCompare(ye.d.id));let _p=lr.map(ae=>ae.entry),wn=[...c.values()].filter(ae=>ae.kind==="run"),Ll=(ae,ye,ct)=>{let ft=nt.runs.get(ae.run),Cr=u.filter(Dt=>Dt.kind==="worked-on"&&Dt.from===ae.id).map(Dt=>c.get(Dt.to)),cc=ft?.unit?Cr.find(Dt=>Dt?.kind==="work"&&Dt.record===ft.unit.id):void 0,vn=new Set;for(let Dt of Cr)if(Dt?.kind==="decision"&&vn.add(Dt.id),Dt?.kind==="work")for(let Vo of u)Vo.kind==="implements"&&Vo.from===Dt.id&&vn.add(Vo.to);let Zh=ct.map(Dt=>Dt.slice(7));return{run:ae.id,lines:ye,commits:ct,unit:ft?.unit?{id:ft.unit.id,kind:ft.unit.kind,node:cc?.id??null}:null,decisions:[...vn],joinedBy:P([ae.run],Zh)}},ki;if(C!==null){let ae=new Map;for(let ye of L)for(let ct of ye.runs){let ft=ae.get(ct)??ae.set(ct,{lines:0,commits:new Set}).get(ct);ft.lines++,ft.commits.add(`commit:${ye.sha}`)}ki=[...ae].map(([ye,ct])=>({n:c.get(`run:${ye}`),t:ct})).filter(ye=>ye.n!==void 0).sort((ye,ct)=>ct.t.lines-ye.t.lines||(ct.n.startedAt??"").localeCompare(ye.n.startedAt??"")||ye.n.run.localeCompare(ct.n.run)).map(ye=>Ll(ye.n,ye.t.lines,[...ye.t.commits]))}else ki=wn.sort((ae,ye)=>(ye.startedAt??"").localeCompare(ae.startedAt??"")||ae.run.localeCompare(ye.run)).map(ae=>Ll(ae,0,u.filter(ye=>ye.kind==="made-by"&&ye.to===ae.id).map(ye=>ye.from)));let sc=_p.some(ae=>ae.current&&ae.relevance!=="related"),ac=[];sc||ac.push({code:"intent-why-no-decision",message:z?`no current decision governs ${o.path}, and none is carried out by what made its lines`:`no record kind was read, so no decision can account for ${o.path}`});let Or=L.filter(ae=>ae.sha!==null);(C!==null?Or.length>0&&Or.every(ae=>ae.runs.length===0):T.length>0&&wn.length===0)&&ac.push({code:"intent-why-no-run",message:`no agent run is joined to the commits that made ${C!==null?"the current lines of ":""}${o.path}`});let Ki=L.filter(ae=>ae.sha===null).map(ae=>ae.line);Ki.length>0&&ac.push({code:"intent-why-uncommitted",message:`${Ki.length} ${Ki.length===1?"line is":"lines are"} not committed yet`,lines:me(Ki)});let Ls=L.filter(ae=>ae.runs.length>1).map(ae=>ae.line);return Ls.length>0&&ac.push({code:"intent-why-run-ambiguous",message:`${Ls.length} ${Ls.length===1?"line comes":"lines come"} from a commit several runs made, and no run's recorded hunks say which wrote ${Ls.length===1?"it":"them"}`,lines:me(Ls)}),{lines:C,blame:re,decisions:_p,runs:ki,explained:sc,gaps:ac}}}var Hee,Vee,XM,cTe,lTe,uTe,tn,pTe,Jee,yTe,bTe,zee,B$=v(()=>{"use strict";_t();Gd();ED();Mv();ao();Dg();pZ();uo();mn();vo();YI();BD();jk();yQ();wQ();CM();Zt();Id();Zc();ai();vd();Hee=1,Vee="https://intentius.io/chant/schemas/workspace/intent/v1/intent.schema.json",XM=["intent-commit-undecided","intent-commit-bare","intent-pin-drifted","intent-pin-missing","intent-pin-stale","intent-artifact-unpinned","intent-decision-superseded-live","intent-decision-provisional","intent-decision-contested","intent-constraint-coarse","intent-constraint-lost","intent-evidence-unpinned","intent-trailer-unverified","intent-region-unconstrained","intent-decision-unimplemented","intent-work-blocked","intent-work-open-decided-code","intent-commit-join-conflict"],cTe=["intent-history-shallow","intent-plugin-failed","squash-unfollowed"],lTe=[...co,"kind-unreadable","kind-invalid","schema-unreadable","schema-id-mismatch","schema-invalid","location-missing","intent-region-invalid","intent-record-unknown","intent-symbol-unsupported","intent-symbol-unknown","intent-symbol-ambiguous"],uTe=["intent-why-no-decision","intent-why-no-run","intent-why-uncommitted","intent-why-run-ambiguous"],tn=class extends Error{constructor(n,i){super(i);this.code=n;this.name="IntentError"}};pTe=/^0+$/;Jee=e=>Gee==="/"?e:e.split(Gee).join("/");yTe=/^[0-9a-f]{64}$/,bTe=/^([A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+)#([0-9]+)$/,zee=["missing","drifted","stale","pinned"]});var r1={};_e(r1,{RECORDS_SINCE_ERROR_CODES:()=>RTe,RECORDS_SINCE_OUTPUT_SCHEMA_ID:()=>t1,RECORDS_SINCE_REASON_CODES:()=>STe,SINCE_CHANGE_KINDS:()=>n1,compareRecords:()=>Qee,formatSince:()=>_Te,queryRecordsSince:()=>ATe});import{realpathSync as xTe}from"node:fs";import{relative as $Te}from"node:path";async function ATe(e){let t=(n,i)=>({$schema:t1,contract:js,error:{code:n,message:i}});try{let n=await OTe(e),i=CTe(e.cwd,n?n.since:e.since,n?.session.id),r=n?n.at??void 0:e.at,o=await Ds({kind:e.kind,at:r,cwd:e.cwd}),s;try{s=(await Ds({kind:e.kind,at:i,cwd:e.cwd})).result.records}catch(c){if(!(c instanceof Ve)||c.code!=="location-missing")throw c;s=[]}let a=Qee(o.loaded.kind,s,o.result.records),l=Object.fromEntries(n1.map(c=>[c,a.filter(u=>u.change===c).length]));return{$schema:t1,contract:js,kind:PTe(o.loaded,o.root),since:i,at:o.at,...n?{session:n.session}:{},changes:a,summary:l}}catch(n){if(n instanceof Ap||n instanceof Ve)return t(n.code,n.message);throw n}}function PTe(e,t){return{name:e.kind.name,schema:e.kind.schema.id,file:$Te(t,e.file).split("\\").join("/")}}async function OTe(e){let t=Un(Tn(e.cwd));if(!t||!oJ.test(e.since))return null;let n=await mg(e.cwd,[e.kind]);for(let i of n){let r;try{r=(await Ds({kind:i.file,cwd:e.cwd})).result.records}catch(p){if(p instanceof Ve)continue;throw p}let o=r.find(p=>p.id===e.since);if(!o)continue;let s=i.kind.session,a=p=>p!==void 0&&typeof o.data?.[p]=="string"?o.data[p]:null,l=o.state!==null&&(i.kind.closedStates??[]).includes(o.state),c={id:o.id,path:o.path,state:o.state,sinceFrom:"opened-rev",atFrom:"working-tree",reasons:[]},u=a(s.openedRev);if(u===null&&(u=bk(t,o.path,["--diff-filter=A"])[0]??null,c.sinceFrom="history",u===null))throw new Ap("since-rev-unknown",`session ${o.id} (${o.path}) names no commit it opened at${s.openedRev?` in ${s.openedRev}`:""}, and no commit added its file`);let d=null;if(e.at!==void 0)d=e.at,c.atFrom="at";else if(l){let p=a(s.closedRev);p!==null&&/^[0-9a-f]{40,64}$/.test(p)?(d=bk(t,o.path,[`${p}..HEAD`]).slice(-1)[0]??null,c.atFrom=d===null?"working-tree":"close-commit"):(d=bk(t,o.path,["-1"])[0]??null,c.atFrom=d===null?"working-tree":"history")}else c.reasons.push({code:"since-session-open",message:`session ${o.id} is ${o.state??"not closed"}, so it has no closing revision, and the comparison runs to the working tree`});return{since:u,at:d,session:c}}try{return Jc(t,e.since),null}catch(i){if(!(i instanceof Ve))throw i}if(n.length===0)return null;throw new Ap("since-session-unknown",`--since ${e.since} names no commit, and no ${[...new Set(n.map(i=>i.kind.name))].join(" or ")} record has that id`)}function CTe(e,t,n){let i=e;try{i=xTe(e)}catch{}let r=Un(i);if(!r)throw new Ve("not-a-git-repository","--since reads git objects, and this directory is not in a git repository");try{return Jc(r,t)}catch(o){throw o instanceof Ve&&o.code==="revision-unknown"?new Ap("since-rev-unknown",n?`session ${n} names ${t}, which is no commit in this repository`:`--since ${t} names no commit in this repository`):o}}function Yee(e){let t=new Map;for(let n of e)n.id!==null&&!t.has(n.id)&&t.set(n.id,n);return t}function Xee(e,t){let n=e.session?e.session.verdicts:e.reviews?.field??ETe,i=t.data?.[n];if(!Array.isArray(i))return[];let r=s=>typeof s=="string"?s:void 0,o=[];return i.forEach((s,a)=>{if(s===null||typeof s!="object"||Array.isArray(s))return;let l=s,c=r(e.session?l.principal:l.reviewer)??null,u=r(l.verdict)??null,d=r(l.record),p=r(l.session);o.push({key:JSON.stringify([c,u,r(l.on)??null,p??null,d??null]),index:a,principal:c,verdict:u,...d!==void 0?{record:d}:{},...p!==void 0?{session:p}:{}})}),o}function Qee(e,t,n){let i=Yee(t),r=Yee(n),o=[...new Set([...i.keys(),...r.keys()])].sort(),s={new:[],removed:[],state:[],verdict:[],supersession:[],pin:[]};for(let a of o){let l=i.get(a),c=r.get(a);if(!l&&c&&s.new.push({change:"new",id:a,path:c.path,state:c.state}),l&&!c&&s.removed.push({change:"removed",id:a,path:l.path,state:l.state}),!c)continue;l&&l.state!==c.state&&s.state.push({change:"state",id:a,from:l.state,to:c.state});let u=new Map;for(let d of l?Xee(e,l):[])u.set(d.key,(u.get(d.key)??0)+1);for(let d of Xee(e,c)){let p=u.get(d.key)??0;if(p>0){u.set(d.key,p-1);continue}s.verdict.push({change:"verdict",id:a,principal:d.principal,verdict:d.verdict,index:d.index,...d.record!==void 0?{record:d.record}:{},...d.session!==void 0?{session:d.session}:{}})}if(c.supersededBy!==null&&(!l||l.supersededBy!==c.supersededBy)&&s.supersession.push({change:"supersession",id:c.supersededBy,supersedes:a}),l&&e.pins){let d=new Map(Om(l.data,e.pins.field).map(f=>[f.path,f.sha256])),p=new Map(Om(c.data,e.pins.field).map(f=>[f.path,f.sha256]));for(let f of[...new Set([...d.keys(),...p.keys()])].sort()){let g=d.get(f)??null,h=p.get(f)??null;g!==h&&s.pin.push({change:"pin",id:a,path:f,from:g,to:h})}}}return s.supersession.sort((a,l)=>a.id<l.id?-1:a.id>l.id?1:0),n1.flatMap(a=>s[a])}function _Te(e){let t=e.changes.map(i=>{switch(i.change){case"new":return`${i.id} new, ${i.state??"no state"} (${i.path})`;case"removed":return`${i.id} removed, was ${i.state??"no state"} (${i.path})`;case"state":return`${i.id} state ${i.from??"none"} to ${i.to??"none"}`;case"verdict":return`${i.id} verdict ${i.verdict??"-"} by ${i.principal??"-"}${i.record?` on ${i.record}`:""}${i.session?` in ${i.session}`:""}`;case"supersession":return`${i.id} supersedes ${i.supersedes}`;case"pin":return`${i.id} pin ${i.path} ${i.from?i.from.slice(0,12):"none"} to ${i.to?i.to.slice(0,12):"none"}`}}),n=e.summary;if(e.session){let i=e.session;t.unshift(`session ${i.id} (${i.state??"no state"}): opened at ${e.since.slice(0,8)} (${i.sinceFrom}), compared to ${e.at?`${e.at.slice(0,8)} (${i.atFrom})`:"the working tree"}`)}return t.push(`${e.changes.length} changes since ${e.since.slice(0,8)}${e.at?` to ${e.at.slice(0,8)}`:" to the working tree"}: ${n.new} new, ${n.removed} removed, ${n.state} state, ${n.verdict} verdicts, ${n.supersession} supersessions, ${n.pin} pins`),t.join(`
303
+ `)}var t1,RTe,STe,n1,ETe,Ap,i1=v(()=>{"use strict";uo();mo();mn();vo();wk();t1="https://intentius.io/chant/schemas/workspace/records-since/v1/records-since.schema.json",RTe=[...DK,"since-rev-unknown","since-session-unknown"],STe=["since-session-open"],n1=["new","removed","state","verdict","supersession","pin"],ETe="reviews",Ap=class extends Error{constructor(n,i){super(i);this.code=n}}});var Bee={};_e(Bee,{AGENT_ROLE:()=>U$,EXIT_BELOW_REQUIRED:()=>a1,RECORDS_CONTRACT_VERSION:()=>js,RECORDS_OUTPUT_SCHEMA_ID:()=>qh,belowRequired:()=>c1,declaredKindFiles:()=>ci,pinFile:()=>tte,pinRoot:()=>$k,queryDeclaredRecords:()=>$$,queryRecords:()=>Uh,quorumOptionsFor:()=>xg,readRecordsFor:()=>Ds,realpathOr:()=>Tn,runWorkspaceRecords:()=>GTe,runWorkspaceUnknown:()=>HTe,specOf:()=>ete});import{execFileSync as ITe}from"node:child_process";import{readFileSync as TTe,realpathSync as DTe}from"node:fs";import{dirname as Vh,join as o1,relative as Pp,resolve as s1,sep as Hh}from"node:path";function NTe(e){try{return TTe(e,"utf-8")}catch{return null}}function ete(e){let t={kinds:[],records:[]};for(let n of e)if(!("error"in n||!n.kind.spec)){t.kinds.push(n.declared);for(let i of n.records)t.records.push({kind:n.kind.name,id:i.id,path:i.path,state:i.state,valid:i.valid,digest:i.digest,assets:i.assets})}return t}function ci(e,t){let n;try{n=Qt(e,t)}catch(i){if(i instanceof ve&&i.code==="declaration-missing")return[];throw i}return Ti(Lt(n.tree)).map(i=>({declared:i,file:ja(i,n.rootOnDisk)}))}async function $$(e,t){let n=[];for(let i of e){let r=await Uh({...t,kind:i.file});n.push({...r,declared:{member:i.declared.member,path:i.declared.path,name:i.declared.name}})}return{$schema:qh,contract:js,kinds:n,...t.current&&!t.uncommitted?{spec:ete(n)}:{}}}function jTe(e){try{let t=Lt(e).quorum;if(t!==null)return{need:t,needFrom:"declaration"}}catch{}return{need:LK,needFrom:"default"}}async function xg(e,t,n){if(!e.kind.reviews)return;let{checkVerdictSeal:i}=await Promise.resolve().then(()=>(zd(),Wd));return{...jTe(t),agents:new Set((n.roles[U$]??[]).map(an)),attestation:n.active,verifySeal:r=>i(n,r)}}function $k(e,t){let n=gr(Vh(e));if(!n)return".";let i=Pp(t,Tn(n.dir)).split(Hh).join("/");return i===""||i.startsWith("..")?".":i}function LTe(e,t,n){let i=r=>{try{return ITe("git",r,{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","pipe"]}).split(`
304
+ `).filter(Boolean).map(Number)}catch{return[]}};return{fileChanged:r=>i(["log","-1","--format=%ct",t,"--",n==="."?r:`${n}/${r}`])[0]??null,recorded:r=>i(["log","--diff-filter=A","--format=%ct",t,"--",r])[0]??null}}async function Ds(e){let t=Tn(e.cwd),n=Un(t),i=n??t,r=await gn(e.kind,t),o=$k(r.file,i),s=null,a=Ad(i),l=$n(o==="."?i:o1(i,...o.split("/")));if(e.at!==void 0){if(!n)throw new Ve("not-a-git-repository","--at reads git objects, and this directory is not in a git repository");s=Jc(n,e.at),a=Ra(n,s),l=Cu(n,s,o==="."?"":o)}s===null&&e.overlay&&(a=await e.overlay(a,{loaded:r,root:i}));let c=n?LTe(n,s??"HEAD",o):void 0,u=await kv(r,i,a),d=await ka(r,{root:i,source:a,current:!!e.current,assets:l,workspaceRoot:o,...c?{history:c}:{},...u?{subjects:u}:{}});return{loaded:r,root:i,top:n,at:s,workspaceRoot:o,tree:l,result:d}}async function Uh(e){if(e.uncommitted&&e.at!==void 0)throw new Error("--uncommitted reads the working tree and takes no --at");try{let t,{loaded:n,root:i,top:r,at:o,workspaceRoot:s,tree:a,result:l}=await Ds({...e,overlay:async(k,{loaded:R,root:$})=>{if(!R.kind.answers)return k;let{readLedgerAnswers:_,refreshLedger:T,withLedgerAnswers:C}=await Promise.resolve().then(()=>(Sg(),hD));e.fetchLedger&&await T(R.file);let K=await _({file:R.file,name:R.kind.name,dirRel:Pp($,R.dir).split(Hh).join("/")||"."});return t=new Map([...K.byPath.values()].map(O=>[O.path,O.ledger])),C(k,K)}}),c=r?Br(r,e.base):{commit:null,from:null},u=r?si(r,c):si(i,c),d=u.active?await Gm():[],p=a6({repo:r,policy:u,at:o,paths:l.records.map(k=>k.path),attestors:d,...u.active?{revisit:await MTe(a,s,u,d)}:{}}),f=n.kind.reviews?await Promise.resolve().then(()=>(zd(),Wd)):void 0,g=await xg(n,a,u),h=[];for(let k of l.records){let R=p.get(k.path),$=R.returned?Pv(u,R.returned.id):u,_=R.returned?await xg(n,a,$):g;h.push({...k,provenance:R,..._?{quorum:$v(n.kind,k,_)}:{},...f?FTe(n.kind,k,$,f.checkRecordSeal):{}})}if(t)for(let k of h)k.ledger=t.get(k.path)??null;if(n.kind.approval&&!n.kind.work&&r){let k=Z4(r,o??"HEAD",h.map(R=>R.path),n.kind);for(let R of h)R.decidedIn=k.get(R.path)??null}if(n.kind.work&&e.workGaps!==!1&&r&&await BTe(n,h,{root:i,workspaceRoot:s,at:e.at}),n.kind.work&&o===null&&r){let{activeWorkLeases:k}=await Promise.resolve().then(()=>(fl(),qJ)),R=await k(n.file);for(let $ of h)$.id!==null&&($.lease=R.get($.id)??null)}if(n.kind.work?.answers){let[{workAnswers:k},{readLedgerAnswers:R,withLedgerAnswers:$}]=await Promise.all([Promise.resolve().then(()=>(vd(),_I)),Promise.resolve().then(()=>(Sg(),hD))]),_=await Ds({kind:s1(Vh(n.file),n.kind.work.answers),cwd:e.cwd,...e.at!==void 0?{at:e.at}:{},overlay:async(T,{loaded:C,root:K})=>$(T,await R({file:C.file,name:C.kind.name,dirRel:Pp(K,C.dir).split(Hh).join("/")||"."}))}).catch(T=>{if(!(T instanceof Ve))throw T});if(_){let T=k(_.result.records,h.flatMap(C=>C.id!==null?[C.id]:[]));for(let C of h)C.id!==null&&(C.answers=T.get(C.id)??[])}}let b,w=h,x=l.summary;if(o===null&&r){let{head:k,...R}=ZT(r,e.base),$=Pp(i,n.dir).split(Hh).join("/")||".",_=h.filter(O=>!O.ledger),{states:T,deleted:C}=Q4(r,k,$,h.map(O=>O.path),new RegExp(n.kind.location.match));for(let O of _)O.worktree=T.get(O.path)??"new";let K=gk(r);for(let O of _)O.lastWrite=K(O.path,NTe(o1(r,...O.path.split("/"))));b={branch:R.branch,head:k,base:R.base,baseFrom:R.baseFrom,deleted:C},e.uncommitted&&(w=_.filter(O=>O.worktree!=="committed"),x={...x,total:w.length,valid:w.filter(O=>O.valid).length,invalid:w.filter(O=>!O.valid).length})}else if(e.uncommitted&&!r)throw new Ve("not-a-git-repository","--uncommitted compares the working tree with HEAD, and this directory is not in a git repository");return{$schema:qh,contract:js,kind:{name:n.kind.name,schema:n.kind.schema.id,file:Pp(i,n.file).split("\\").join("/"),format:n.kind.format,spec:n.kind.spec===!0},at:o,workspaceRoot:s,current:!!e.current,uncommitted:!!e.uncommitted,...b?{checkout:b}:{},trust:{base:c.commit,baseFrom:c.from,active:u.active,signersPath:u.signersPath,problems:u.problems},records:w,summary:x,...l.decisions?{decisions:l.decisions}:{}}}catch(t){if(!(t instanceof Ve))throw t;return{$schema:qh,contract:js,error:{code:t.code,message:t.message}}}}async function MTe(e,t,n,i){let{readReturns:r,returnedProvenance:o}=await Promise.resolve().then(()=>(sZ(),oZ)),{returns:s}=r(e);if(s.length===0)return;let a=t==="."?"":`${t}/`;return(l,c)=>{if(!l.startsWith(a))return;let u=l.slice(a.length),d=s.filter(f=>f.paths[u]!==void 0);if(d.length===0||e.stat(u)!=="file")return;let p=Buffer.from(e.bytes?e.bytes(u):e.read(u));for(let f of d){let g=o(n,i,f,u,p,c);if(g)return g}}}function FTe(e,t,n,i){if(t.data===null)return{};let r=e.reviews.decider,o=typeof t.data[r]=="string"&&t.data[r].trim()!==""?t.data[r]:null,{attested:s,...a}=i(n,{record:t.id,digest:t.digest,author:o,authorField:r,state:t.state,seal:t.data[rn]});return n.active&&o!==null&&s!==!0&&t.warnings.push({code:"record-unattested",message:`an attestation policy is active at base, and ${a.message}`}),{attested:s,attestation:a}}async function BTe(e,t,n){let i=e.kind.work,r=new Map;for(let u of t){if(u.id===null||u.state!==i.done)continue;let d=u.data?.source;if(d===null||typeof d!="object"||Array.isArray(d))continue;let{finding:p,region:f}=d;typeof p!="string"||typeof f!="string"||r.set(f,[...r.get(f)??[],u])}if(r.size===0)return;let o=n.workspaceRoot==="."?n.root:o1(n.root,...n.workspaceRoot.split("/")),s;try{s=ci(o,n.at).map(u=>u.file)}catch(u){if(u instanceof ve)return;throw u}let a=[],l=new Set;for(let u of[...s,s1(Vh(e.file),i.decisions),e.file]){let d=Tn(u);l.has(d)||(l.add(d),a.push(u))}let{intentGraph:c}=await Promise.resolve().then(()=>(B$(),Zee));for(let[u,d]of r){let{doc:p}=await c({cwd:o,region:u,at:n.at,kinds:a});if(!("error"in p))for(let f of d){let g=p.nodes.find(b=>b.kind==="work"&&b.id===`record:${e.kind.name}/${f.id}`),h=g?.kind==="work"?g.warnings.find(b=>b.code==="work-done-gap-open"):void 0;h&&!f.warnings.some(b=>b.code===h.code)&&f.warnings.push(h)}}}function tte(e,t){let n=Tn(s1(t,e)),i=Un(Vh(n)),r=gr(Vh(n)),o=Tn(r?r.dir:i||t),s=Pp(o,n).split(Hh).join("/");if(s.startsWith("..")||!_n(s))return{error:`${e} is not a file path inside the workspace at ${o}`};let a=EI($n(o),s);return a===void 0?{error:`${e} is not a file`}:{path:s,sha256:a}}async function GTe(e){let{args:t}=e;if(t.extraPositional==="new"||t.extraPositional==="amend"||t.extraPositional==="review"||t.extraPositional==="close")return(await Promise.resolve().then(()=>(bg(),_J))).runRecordsWrite(e);if(t.extraPositional==="pin"){if(!t.extraPositional2)return console.error(fe({message:"pin needs the path of a file",hint:Er})),1;let r=tte(t.extraPositional2,process.cwd());return"error"in r?(console.error(fe({message:r.error,hint:Er})),1):(console.log(JSON.stringify(r,null,2)),0)}if(t.extraPositional)return console.error(fe({message:`chant workspace records takes no argument but pin, new, amend, review or close (got ${t.extraPositional})`,hint:Er})),1;let n=UTe(t);if(n)return console.error(fe({message:n,hint:Er})),1;if(!t.kind)return WTe(t);if(t.require!==void 0&&t.require!=="attested")return console.error(fe({message:`--require takes one level, attested, not ${JSON.stringify(t.require)}`,hint:Er})),1;if(t.since!==void 0){if(t.current||t.require!==void 0||t.base!==void 0)return console.error(fe({message:"--since compares two revisions and takes no --current, --require or --base",hint:Er})),1;let{formatSince:r,queryRecordsSince:o}=await Promise.resolve().then(()=>(i1(),r1)),s=await o({kind:t.kind,since:t.since,at:t.at,cwd:process.cwd()});return t.json?console.log(JSON.stringify(s,null,2)):"error"in s?console.error(fe({message:`${s.error.code}: ${s.error.message}`,hint:Er})):console.log(r(s)),"error"in s?1:0}let i=await Uh({kind:t.kind,current:t.current,uncommitted:t.uncommitted,at:t.at,base:t.base,cwd:process.cwd(),fetchLedger:!0});if(t.json?console.log(JSON.stringify(i,null,2)):"error"in i?console.error(fe({message:`${i.error.code}: ${i.error.message}`,hint:Er})):console.log(nte(i.records,i.summary,i.at,i.checkout)),"error"in i)return 1;if(t.require){let r=c1(i.records,t.require);if(r.length>0)return console.error(fe({message:`${r.length} of ${i.records.length} records are not ${t.require}: ${r.slice(0,5).map(o=>`${o.path} (${o.provenance.level})`).join(", ")}${r.length>5?", ...":""}`,hint:i.trust.active?"run with --json to see each record's reason":`there is no signers file (${i.trust.signersPath}) at base`})),a1}return 0}async function WTe(e){if(e.require!==void 0&&e.require!=="attested")return console.error(fe({message:`--require takes one level, attested, not ${JSON.stringify(e.require)}`,hint:Er})),1;let t;try{t=ci(process.cwd(),e.at)}catch(i){if(!(i instanceof ve))throw i;let r=`${i.describe()}; without --kind, the declaration names the record kinds`;return e.json&&(i.code==="not-a-git-repository"||i.code==="revision-unknown")?console.log(JSON.stringify({$schema:qh,contract:js,error:{code:i.code,message:r}},null,2)):console.error(fe({message:`${i.code}: ${r}`,hint:Er})),1}if(t.length===0)return console.error(fe({message:"--kind <kind file> is required",hint:Er})),1;if(e.since!==void 0)return zTe(t,e);let n=await $$(t,{current:e.current,uncommitted:e.uncommitted,at:e.at,base:e.base,cwd:process.cwd(),fetchLedger:!0});e.json&&console.log(JSON.stringify(n,null,2));for(let i of e.json?[]:n.kinds){if("error"in i){console.error(fe({message:`${i.declared.path}: ${i.error.code}: ${i.error.message}`,hint:Er}));continue}console.log(`${i.declared.name??i.kind.name} (${i.declared.path})`),console.log(nte(i.records,i.summary,i.at,i.checkout))}if(n.kinds.some(i=>"error"in i))return 1;if(e.require){let i=n.kinds.filter(s=>!("error"in s)),r=i.flatMap(s=>s.records),o=c1(r,e.require);if(o.length>0){let s=i.find(a=>!a.trust.active);return console.error(fe({message:`${o.length} of ${r.length} records are not ${e.require}: ${o.slice(0,5).map(a=>`${a.path} (${a.provenance.level})`).join(", ")}${o.length>5?", ...":""}`,hint:s?`there is no signers file (${s.trust.signersPath}) at base`:"run with --json to see each record's reason"})),a1}}return 0}async function zTe(e,t){if(t.current||t.require!==void 0||t.base!==void 0)return console.error(fe({message:"--since compares two revisions and takes no --current, --require or --base",hint:Er})),1;let{formatSince:n,queryRecordsSince:i,RECORDS_SINCE_OUTPUT_SCHEMA_ID:r}=await Promise.resolve().then(()=>(i1(),r1)),o=[];for(let s of e){let a=await i({kind:s.file,since:t.since,at:t.at,cwd:process.cwd()});o.push({...a,declared:{member:s.declared.member,path:s.declared.path,name:s.declared.name}})}t.json&&console.log(JSON.stringify({$schema:r,contract:js,kinds:o},null,2));for(let s of t.json?[]:o){if("error"in s){console.error(fe({message:`${s.declared.path}: ${s.error.code}: ${s.error.message}`,hint:Er}));continue}console.log(`${s.declared.name??s.kind.name} (${s.declared.path})`),console.log(n(s))}return o.some(s=>"error"in s)?1:0}function Tn(e){try{return DTe(e)}catch{return e}}function c1(e,t){return e.filter(n=>n.provenance.level!==t)}function UTe(e){if(e.uncommitted){if(e.at!==void 0)return"--uncommitted reads the working tree against HEAD, and takes no --at";if(e.since!==void 0)return"--uncommitted takes no --since: --since compares two revisions"}}function nte(e,t,n,i){let r=[],o=Math.max(2,...e.map(a=>(a.id??"-").length)),s=Math.max(5,...e.map(a=>(a.state??"-").length));for(let a of e){let l=typeof a.data?.title=="string"?a.data.title:a.path,c=a.valid?"":" INVALID",u=a.supersededBy?` superseded by ${a.supersededBy}`:"",d=a.remediatedBy.length>0?` remediated by ${a.remediatedBy.join(", ")}`:"",p=a.provenance.level==="attested"?` attested by ${a.provenance.principal}`:"",f=a.attested===!0?` sealed by ${(a.data?.[rn]).signer}`:"",g=a.worktree==="new"||a.worktree==="modified"?` (${a.worktree}, uncommitted)`:"",h=a.ledger?` (held on ${a.ledger})`:"";if(r.push(`${(a.id??"-").padEnd(o)} ${(a.state??"-").padEnd(s)} ${l}${u}${d}${p}${f}${g}${h}${c}`),a.ready!==void 0){let w=(a.blockedBy??[]).map($=>`${$.id} (${$.state??"unknown"})`).join(", "),x=(a.implements??[]).map($=>`${$.id} (${$.state??"unknown"})`).join(", "),k=a.lease?`held by ${a.lease.holder} until ${a.lease.expiresAt}`:"",R=[a.ready?"ready":w?`blocked by ${w}`:"",x?`implements ${x}`:"",k].filter(Boolean).join("; ");R&&r.push(`${" ".repeat(o+2)}${R}`)}for(let w of a.reasons)r.push(`${" ".repeat(o+2)}${w.code}: ${w.message} (${a.path})`);for(let w of a.warnings)r.push(`${" ".repeat(o+2)}warning ${w.code}: ${w.message} (${a.path})`);let b=a.quorum;if(b&&b.counted.length+b.notCounted.length>0){let w=b.metWithObjections?"met with objections":b.met?"met":"not met",x=b.openConcerns.length>0?`, ${b.openConcerns.length} open ${b.openConcerns.length===1?"concern":"concerns"}`:"";r.push(`${" ".repeat(o+2)}quorum ${b.agreed} of ${b.need} agreed, ${w}; ${b.notCounted.length} not counted${x}`)}}for(let a of i?.deleted??[])r.push(`${"-".padEnd(o)} ${"-".padEnd(s)} ${a} (deleted, uncommitted)`);if(r.push(`${t.total} records${n?` at ${n.slice(0,8)}`:""}: ${t.valid} valid, ${t.invalid} invalid, ${t.superseded} superseded`),i){let a=i.branch??"a detached HEAD",l=i.head?` at ${i.head.slice(0,8)}`:" with no commits",c=i.base?`, forked from ${i.base.slice(0,8)} of ${i.baseFrom}`:"";r.push(`working tree on ${a}${l}${c}`)}return r.join(`
305
+ `)}async function HTe(e){let t=e.args.path&&e.args.path!=="."?e.args.path:"";return console.error(fe({message:t?`Unknown workspace subcommand: ${t}`:"chant workspace needs a subcommand",hint:'Workspace subcommands: adopt-lineage, audit, build, check, evidence, graph, hash-index, init, lineage, lint, ls, pin, records, signers, status, upgrade, verify, versions, work. Run "chant --help" for their options.'})),1}var js,qh,Er,a1,U$,vo=v(()=>{"use strict";Kn();Ri();uo();Y4();mo();_t();Gd();ai();mn();YT();pg();Zt();Id();Zc();ps();js=1,qh="https://intentius.io/chant/schemas/workspace/records/v1/records.schema.json",Er="chant workspace records [--kind <kind file>] [--current] [--uncommitted | --at <rev>] [--base <rev>] [--require attested] [--json] | chant workspace records [--kind <kind file>] --since <rev|session id> [--at <rev>] [--json] | chant workspace records pin <path> | chant workspace records new|amend|review|close (#2670, #2693)",a1=2,U$="agent"});var sM={};_e(sM,{POINTS_WRITE_CONTRACT_VERSION:()=>Mo,POINTS_WRITE_ERROR_CODES:()=>qTe,POINTS_WRITE_SCHEMA_ID:()=>Fo,PointsWriteError:()=>bt,STEWARD_HARNESS:()=>u1,answerFields:()=>Kh,answerKindFiles:()=>d1,answerPoint:()=>XL,askPoint:()=>YL,askedByOf:()=>H$,questionView:()=>vp,reasonFields:()=>V$,retractAnswer:()=>QL,tallyQuorum:()=>ote});import{writeFileSync as VTe}from"node:fs";function KTe(e){if(!Array.isArray(e.retractions))return[];let t=i=>typeof i=="string"?i:null,n=i=>Array.isArray(i)?i.filter(r=>typeof r=="string"):[];return e.retractions.filter(i=>i!==null&&typeof i=="object"&&!Array.isArray(i)).map(i=>({answer:typeof i.answer=="string"||typeof i.answer=="boolean"?i.answer:null,decider:i.decider!==null&&typeof i.decider=="object"&&!Array.isArray(i.decider)?i.decider:{},answeredBy:n(i.answered_by),answeredOn:t(i.answered_on),answerNote:t(i.answer_note),answerRelayedBy:t(i.answer_relayed_by),by:n(i.by),on:t(i.on),note:t(i.note)}))}function H$(e){let t=e.source;if(t===null||typeof t!="object"||Array.isArray(t))return null;let n=t;if(n.harness!==u1)return null;let i=n.client,r=i&&typeof i.name=="string"?i.name:null;if(r===null)return null;let o=n.session,s=typeof o=="string"?o:o&&typeof o=="object"&&typeof o.id=="string"?o.id:null;return{steward:r,run:s}}function vp(e,t,n=null){let i=e.data;if(i===null||e.id===null)return null;let r=p=>typeof p=="string"?p:null,o=p=>typeof p=="number"?p:null,s=["escalated","proposed","answered"].find(p=>p===e.state)??"escalated",a=i.decider!==null&&typeof i.decider=="object"&&!Array.isArray(i.decider)?i.decider:{},l=Array.isArray(i.escalations)?i.escalations:[],c=typeof i.answer=="string"||typeof i.answer=="boolean"?i.answer:null,u=null;if(a.kind==="model")u={answer:c,confidence:o(i.confidence),threshold:o(i.threshold),model:r(a.model),backend:r(a.backend),observed:!0,reason:r(i.reason)};else{let p=[...l].reverse().find(f=>f.kind==="model"&&f.answer!==void 0&&f.answer!==null);p&&(u={answer:p.answer??null,confidence:p.confidence??null,threshold:p.threshold??null,model:p.model??null,backend:p.backend??null,observed:!1,reason:typeof p.model_reason=="string"?p.model_reason:null})}let d=Array.isArray(i.constrains)?i.constrains.filter(p=>typeof p=="string"):[];return{id:e.id,path:e.path,point:r(i.point)??"",title:r(i.title)??"",subject:d[0]??null,state:s,open:s!=="answered",questionType:r(i.question_type)??"",candidates:Array.isArray(i.candidates)?i.candidates:[],inputs:i.inputs!==null&&typeof i.inputs=="object"&&!Array.isArray(i.inputs)?i.inputs:{},inputsHash:r(i.inputs_hash)??"",pointVersion:r(i.point_version)??"",current:t?xa(t)===i.point_version:null,answer:c,decider:a,probabilities:i.probabilities!==null&&typeof i.probabilities=="object"?i.probabilities:null,confidence:o(i.confidence),threshold:o(i.threshold),reason:a.kind==="model"?r(i.reason):null,model:u,escalations:l,answeredBy:Array.isArray(i.answered_by)?i.answered_by.filter(p=>typeof p=="string"):[],askedOn:r(i.asked_on),answeredOn:r(i.answered_on),note:r(i.note),relayedBy:r(i.relayed_by),retractions:KTe(i),asked:Tm(i)??null,askedBy:H$(i),ledger:n,valid:e.valid,warnings:e.warnings}}function Op(e,t){if(t instanceof bt||t instanceof he||t instanceof Ve||t instanceof gs||t instanceof Da)return{$schema:Fo,contract:Mo,verb:e,error:{code:t.code,message:t.message}};if(t instanceof ve)return{$schema:Fo,contract:Mo,verb:e,error:{code:"points-undeclared",message:`the declaration can't be read: ${t.code}: ${t.message}`}};throw t}async function d1(e,t){if(t!==void 0)return[Vd(t,e)];let n=[];for(let i of ci(e))try{(await gn(i.file)).kind.answers&&n.push(i.file)}catch(r){if(!(r instanceof Ve))throw r}return n}async function rte(e,t){let n=await xs(e,t);if(!n.loaded.kind.answers)throw new bt("points-undeclared",`the ${n.loaded.kind.name} kind has no answers block, so it holds no answers to decision points`);let i=Sd(n.loaded,n.root),r=Ed(n.source,i);if("error"in r)throw new bt("points-invalid",r.error);return{o:n,points:r.points,pointsFile:i}}function f1(e,t,n,i,r){let o=n==="escalated"?"open for people":n==="proposed"?`${oc(i,e.question.type)}, proposed`:oc(i,e.question.type);return`${r?r.question:e.title}${t?` (${t})`:""}: ${o}`}function m1(e,t,n){let i=$d(e,n),r=s=>i.type==="score"?"":i.criteria?.[String(s)]??"",o=fo(i).map(s=>`- ${oc(s,i.type)}${r(s)?`: ${r(s)}`:""}`);return["",`# ${t}`,"",i.instructions.trim(),"",...o,""].join(`
306
+ `)}async function JTe(e,t,n){if(e.length===0)throw new bt("points-undeclared","no record kind with an answers block is declared: name one with --kind, or declare one in chant.workspace.json");let i=[];for(let r of e){let o=await rte(r,n),s=xd(o.points,t);if(s)return{...o,point:s};i.push(...Object.keys(o.points))}throw new bt("point-unknown",`no points file declares ${JSON.stringify(t)}${i.length?` (the points are ${i.join(", ")})`:""}`)}function ZTe(e,t,n,i){if(!t.adhoc){if(n!==void 0)throw new bt("point-candidates-invalid",`${e} declares its candidates, so the ask gives none: --candidates is for an ad-hoc point`);return}if(n===void 0)throw new bt("point-candidates-invalid",`${e} is an ad-hoc point, so each ask gives the question and its candidates: --candidates <file|-|json>`);let r=jI(t,n);if("problems"in r)throw new bt("point-candidates-invalid",`the candidates for ${e}, a ${t.question.type} question: ${r.problems.join("; ")}`);if(!Kh(i.schema).asked)throw new bt("answer-field-unsupported",`the ${i.kind.name} kind's schema has no asked field, so an ad-hoc question's text and candidates can't be kept: copy point-answer.schema.json from @intentius/chant anew`);return r.asked}function YTe(e,t,n){if(n===null||typeof n!="object"||Array.isArray(n))throw new bt("point-inputs-invalid",`the inputs to ${e} must be a JSON object`);let i=Object.keys(t.inputs),r=Object.keys(n).filter(o=>!i.includes(o));if(r.length>0)throw new bt("point-inputs-invalid",`${e} reads ${i.join(", ")}, and the inputs also give ${r.join(", ")}`);return n}async function g1(e,t,n,i,r,o,s){let a=await xk(e,t,n,i,s.source),l=s.ledger.byPath.get(n);if(s.onLedger){if(o)return{warnings:a,ledger:l?.ledger??null};try{let{ledger:c}=await gD(s.ledger,n,i,s.message,l?.sha??null);return{warnings:a,ledger:c}}catch(c){throw c instanceof Vt?new bt("record-id-taken",`${n} was written on chant/lifecycle by another ask or answer at the same time: ask again to read it`):c}}if(!o)try{VTe(xo(e,n),i,r?{flag:"wx"}:void 0),vs(e.root,[{path:n,text:i}],s.who)}catch(c){throw c.code==="EEXIST"?new bt("record-id-taken",`${n} was written by another ask at the same time: ask again to read it`):c}return{warnings:a,ledger:null}}async function ite(e){let t=await $g({file:e.loaded.file,name:e.loaded.kind.name,dirRel:e.dirRel}),n=Rg(e.source,t);return{ledger:t,source:n,before:await Gi(e,n)}}function h1(e,t){let n=Object.fromEntries(Object.entries(t).filter(([,i])=>i!==void 0));return Ba(n,Kd(n,{properties:e.loaded.schema.properties}))}function V$(e){let t=(i,r)=>i!==null&&typeof i=="object"&&Object.prototype.hasOwnProperty.call(i,r),n=e.definitions??e.$defs;return{top:t(e.properties,"reason"),escalation:t(n?.escalation?.properties,"model_reason")}}function XTe(e,t){return t.escalation?e:e.map(({model_reason:n,...i})=>i)}function QTe(e,t){let n=e.escalations.length>0?XTe(e.escalations,t):void 0;if(e.status==="proposed"){let i=t.top?e.reason:void 0;return{state:"proposed",answer:e.answer,decider:e.decider,probabilities:e.probabilities,confidence:e.confidence,threshold:e.threshold,reason:i,escalations:n}}return e.status==="answered"?{state:"answered",answer:e.answer,decider:e.decider,escalations:n}:{state:"escalated",decider:e.decider,escalations:n}}async function YL(e){try{return await wo(e.cwd,{verb:"points ask",by:e.steward?.name??null},e.dryRun,()=>eDe(e))}catch(t){return Op("ask",t)}}async function eDe(e){try{let t=e.steward?void 0:bo(),n=e.steward??(t?{name:t.steward,...t.run?{run:t.run}:{}}:void 0),i=e.store!==void 0?e.store==="ledger":n!==void 0,r=await d1(e.cwd,e.kind),{o,point:s}=await JTe(r,e.point,e.cwd),a=YTe(e.point,s,e.inputs),l=ZTe(e.point,s,e.candidates,o.loaded),c=xa(s),u=NI(e.point,c,a,l),d=LI(e.point,u);i&&!e.dryRun&&await Rk(o.loaded.file);let{ledger:p,source:f,before:g}=await ite(o),h=g.find(xe=>xe.id===d),b=xe=>p.byPath.get(xe.path)?.ledger??null,w=(xe,we)=>({$schema:Fo,contract:Mo,verb:"ask",kind:o.view,id:d,path:xe.path,reused:we.reused,written:we.written,dryRun:!!e.dryRun,question:vp(xe,s,we.ledger!==void 0?we.ledger:b(xe)),...we.text!==void 0?{text:we.text}:{}});if(h&&h.data!==null&&(h.state==="answered"||h.state==="proposed"))return w(h,{reused:!0,written:!1});if(h&&h.data!==null&&Array.isArray(h.data.retractions)&&h.data.retractions.length>0)return w(h,{reused:!0,written:!1});let x;try{x=await MI(e.point,{...s,question:$d(s,l)},a,e.ask)}catch(xe){throw xe instanceof kd?new bt("point-decider-failed",xe.message):xe}if(h&&h.data!==null&&x.status==="escalated")return w(h,{reused:!0,written:!1});let k=e.on??p1(),R=x.status,$=x.status==="escalated"?void 0:x.answer,_=f1(s,e.subject,R,$,l),T=x.status==="proposed"?x.decider.model:void 0,C=n?{name:n.name}:e.client,K={via:e.via??"cli",...n?{harness:u1}:{},...C?{client:C}:{},...T?{model:T}:{},...n?.run?{session:{id:n.run}}:{}},O=h1(o,{id:d,title:_,point:e.point,point_version:c,question_type:s.question.type,candidates:fo($d(s,l)),asked:l,inputs:a,inputs_hash:u,constrains:e.subject!==void 0?[e.subject]:h?.data?.constrains,...QTe(x,V$(o.loaded.schema)),asked_on:k,answered_on:R==="answered"?k:void 0,source:K}),pe=h?h.path:o.dirRel==="."?`${d}.md`:`${o.dirRel}/${d}.md`,F=pl(O,m1(s,_,l)),Q=i||p.byPath.has(pe),I=`Decision point ${e.point}: ${R}${e.subject?` (${e.subject})`:""}${n?`, asked by ${n.name}`:""}`,B=await g1(o,g,pe,F,!h,!!e.dryRun,{source:f,ledger:p,onLedger:Q,message:I,who:{verb:"points ask",by:n?.name??null}}),Z={...h??tDe(pe),id:d,path:pe,state:R,data:O,valid:!0,reasons:[],warnings:B.warnings};return w(Z,{reused:!1,written:!e.dryRun,ledger:B.ledger,...e.dryRun?{text:F}:{}})}catch(t){return Op("ask",t)}}function tDe(e){return{id:null,path:e,state:null,valid:!0,reasons:[],supersededBy:null,remediatedBy:[],data:null,assets:[],warnings:[],digest:""}}function Kh(e){let t=e.properties,n=i=>t!=null&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,i);return{note:n("note"),retractions:n("retractions"),relayedBy:n("relayed_by"),asked:n("asked")}}function nDe(e){if(!Un(e))return ds(null);try{return si(e,Br(e))}catch{return ds(null)}}function ote(e,t,n,i){let r=u=>new Set((n.roles[u]??[]).map(an)),o=r(U$),s=i!==void 0?an(i):void 0,a=[],l=new Set,c=[];for(let u of e){let d=an(u);if(!(d===""||l.has(d))){if(l.add(d),s!==void 0&&d===s){c.push({name:u,why:"is the steward that asked"});continue}if(o.has(d)){c.push({name:u,why:"holds the agent role"});continue}if(t.roles&&!t.roles.some(p=>r(p).has(d))){c.push({name:u,why:`holds none of the roles ${t.roles.join(", ")}`});continue}a.push(u)}}return{counted:a,left:c,met:a.length>=t.count}}function ste(e,t){let n=bo();if(n)throw new bt("answer-in-steward-turn",`this is the steward ${n.steward}'s turn, and a steward never ${t} a decision point: a person ${t==="answers"?"answers":"retracts the answer to"} ${e} through hud or \`chant workspace points ${t==="answers"?"answer":"retract"}\` at a shell`)}async function ate(e,t,n){let i=await d1(e,t);if(i.length===0)throw new bt("points-undeclared","no record kind with an answers block is declared: name one with --kind, or declare one in chant.workspace.json");for(let r of i){let o=await rte(r,e);await Rk(o.o.loaded.file);let s=await ite(o.o),a=s.before.find(l=>l.id===n);if(a&&a.data!==null)return{opened:o,before:s.before,read:s,target:a}}throw new bt("record-not-found",`no answer record has id ${n}`)}function lte(e,t,n,i,r,o,s){let a=Yr(s),l=a?{counted:[],left:t.map(c=>({name:c,why:`was named over ${cte(s)}, where an answer is an agent's`})),met:!1}:ote(t,n,nDe(i),r);if(!l.met){let c=l.counted.length,u=l.left.length?`; not counted: ${l.left.map(p=>`${p.name}, who ${p.why}`).join("; ")}`:"",d=a?`: a person ${o==="answer"?"answers":"retracts it"} at a shell with \`chant workspace points ${o}\`, or through hud`:"";throw new bt("quorum-not-met",`${e} needs ${n.count} ${n.count===1?"person":"people"}${n.roles?` holding ${n.roles.join(" or ")}`:""} to ${o==="answer"?"answer":"retract an answer"}, and ${c} ${c===1?"counts":"count"}${c?` (${l.counted.join(", ")})`:""}${u}${d}`)}return l}function rDe(e){let t=[];for(let n of Array.isArray(e.constrains)?e.constrains:[]){if(typeof n!="string"||!n.startsWith("gate:"))continue;let i=n.slice(5),r=i.lastIndexOf("@"),o=r>0?i.slice(0,r):i,s=o.indexOf("/");s>0&&s<o.length-1&&t.push({op:o.slice(0,s),gate:o.slice(s+1)})}return t}async function ute(e,t,n,i,r){if(!Yr(i))return;let o=rDe(t);if(o.length===0)return;let{isNeverOverMcpGateOp:s}=await Promise.resolve().then(()=>(Ai(),Jz)),{readGateLedger:a}=await Promise.resolve().then(()=>(ji(),nq)),l;for(let{op:c,gate:u}of o){let d=s(c);if(!d){let{pending:p}=await a(c,{cwd:n}).catch(()=>({pending:[]}));d=p.some(f=>f.gate===u&&f.neverOverMcp===!0)}if(!d){if(l===void 0){let{discoverOps:p}=await Promise.resolve().then(()=>(Bi(),zT));l=await p({cwd:n}).then(f=>f.ops).catch(()=>new Map)}d=!!l.get(c)?.config.neverOverMcp}if(d)throw new bt("answer-never-over-mcp",`${e} constrains gate "${u}" on "${c}", which is never resolved over ${cte(i)}, so its question is not ${r==="answers"?"answered":"retracted"} there either: a person ${r==="answers"?"answers":"retracts the answer to"} it at a shell with \`chant workspace points ${r==="answers"?"answer":"retract"} ${e}\`, or through hud`)}}async function XL(e){try{return await wo(e.cwd,{verb:"points answer",by:(e.by??[]).join(", ")||null},e.dryRun,()=>iDe(e))}catch(t){return Op("answer",t)}}async function iDe(e){try{ste(e.id,"answers"),hs(go(e.cwd),e.by,"--by");let t=l1(e.relayedBy);t!==void 0&&hs(go(e.cwd),[t],"--relayed-by");let n=await ate(e.cwd,e.kind,e.id),{opened:i,before:r,target:o}=n,s=n.read.ledger,{o:a}=i,l=o.data;if(o.state==="answered")throw new bt("record-closed",`${e.id} is answered, and an answer never changes in place: retract it with \`points retract ${e.id}\` and answer again, ask again with other inputs, or change the point, which asks the question anew`);let c=l1(e.note);if(c!==void 0&&!Kh(a.loaded.schema).note)throw new bt("answer-field-unsupported",`the ${a.loaded.kind.name} kind's schema has no note field, so ${e.id} can't keep the note: copy point-answer.schema.json from @intentius/chant anew`);if(t!==void 0&&!Kh(a.loaded.schema).relayedBy)throw new bt("answer-field-unsupported",`the ${a.loaded.kind.name} kind's schema has no relayed_by field, so ${e.id} can't record who relayed the answer: copy point-answer.schema.json from @intentius/chant anew`);let u=String(l.point),d=xd(i.points,u);if(!d)throw new bt("point-unknown",`${e.id} answers ${u}, which ${i.pointsFile} no longer declares`);let p=Tm(l),f=p?fo($d(d,p)):Array.isArray(l.candidates)?l.candidates:fo(d.question),g=String(l.question_type),h=g==="noul"&&typeof e.answer=="string"?{true:!0,yes:!0,false:!1,no:!1}[e.answer.toLowerCase()]:e.answer;if(h===void 0||!f.includes(h))throw new bt("answer-not-candidate",`${e.id} takes one of ${f.map(B=>JSON.stringify(B)).join(", ")}, not ${JSON.stringify(e.answer)}`);let b=e.origin??es();await ute(e.id,l,a.root,b,"answers");let w=Rd(d),x=lte(u,e.by,w,a.root,H$(l)?.steward,"answer",b),k=e.on??p1(),R=l.decider,$=o.state==="proposed"&&R.kind==="model"&&l.answer===h,_=Array.isArray(l.escalations)?[...l.escalations]:[],T;$?T={...l,state:"answered",answered_by:x.counted,answered_on:k,note:c,relayed_by:t}:(o.state==="proposed"&&R.kind==="model"&&_.push({kind:"model",backend:String(R.backend),model:String(R.model),answer:l.answer,...l.probabilities?{probabilities:l.probabilities}:{},...typeof l.confidence=="number"?{confidence:l.confidence}:{},...typeof l.threshold=="number"?{threshold:l.threshold}:{},reason:`proposed ${oc(l.answer,g)}, and people answered ${oc(h,g)}`,...typeof l.reason=="string"&&V$(a.loaded.schema).escalation?{model_reason:l.reason}:{}}),T={...Object.fromEntries(Object.entries(l).filter(([Z])=>Z!=="probabilities"&&Z!=="confidence"&&Z!=="threshold"&&Z!=="reason")),state:"answered",answer:h,decider:{kind:"quorum",count:w.count,...w.roles?{roles:w.roles}:{},by:x.counted},escalations:_.length>0?_:void 0,answered_by:x.counted,answered_on:k,note:c,relayed_by:t});let C=Array.isArray(l.constrains)&&typeof l.constrains[0]=="string"?l.constrains[0]:void 0;T.title=f1(d,C,"answered",h,p);let K=h1(a,T),O=pl(K,m1(d,String(T.title),p)),pe=s.byPath.has(o.path),F=`Decision point ${u}: answered ${oc(h,g)} by ${x.counted.join(", ")}${t?`, relayed by ${t}`:""}`,Q=await g1(a,r,o.path,O,!1,!!e.dryRun,{source:n.read.source,ledger:s,onLedger:pe,message:F,who:{verb:"points answer",by:x.counted.join(", ")}}),I={...o,state:"answered",data:K,valid:!0,reasons:[],warnings:Q.warnings};return{$schema:Fo,contract:Mo,verb:"answer",kind:a.view,id:e.id,path:o.path,reused:!1,written:!e.dryRun,dryRun:!!e.dryRun,question:vp(I,d,pe?Q.ledger??s.byPath.get(o.path)?.ledger??null:null),...e.dryRun?{text:O}:{}}}catch(t){return Op("answer",t)}}async function QL(e){try{return await wo(e.cwd,{verb:"points retract",by:(e.by??[]).join(", ")||null},e.dryRun,()=>oDe(e))}catch(t){return Op("retract",t)}}async function oDe(e){try{ste(e.id,"retracts"),hs(go(e.cwd),e.by,"--by");let t=await ate(e.cwd,e.kind,e.id),{opened:n,before:i,target:r}=t,o=t.read.ledger,{o:s}=n,a=r.data;if(r.state!=="answered")throw new bt("answer-not-answered",`${e.id} is ${r.state??"not answered"}, so there is no answer to retract: answer it with \`points answer ${e.id}\``);if(!Kh(s.loaded.schema).retractions)throw new bt("answer-field-unsupported",`the ${s.loaded.kind.name} kind's schema has no retractions field, so ${e.id} can't keep the answer it would retract: copy point-answer.schema.json from @intentius/chant anew`);let l=String(a.point),c=xd(n.points,l);if(!c)throw new bt("point-unknown",`${e.id} answers ${l}, which ${n.pointsFile} no longer declares, so no quorum can take the answer back: ask the point as it is declared now`);let u=e.origin??es();await ute(e.id,a,s.root,u,"retracts");let d=Rd(c),p=lte(l,e.by,d,s.root,H$(a)?.steward,"retract",u),f=e.on??p1(),g=String(a.question_type),h=a.decider!==null&&typeof a.decider=="object"&&!Array.isArray(a.decider)?a.decider:{kind:"quorum"},b=a.answer,w=l1(e.note),x={answer:b,decider:h,answered_by:Array.isArray(a.answered_by)&&a.answered_by.length>0?a.answered_by:void 0,answered_on:typeof a.answered_on=="string"?a.answered_on:void 0,answer_note:typeof a.note=="string"?a.note:void 0,answer_relayed_by:typeof a.relayed_by=="string"?a.relayed_by:void 0,by:p.counted,on:f,note:w},k=Array.isArray(a.escalations)?[...a.escalations]:[];h.kind==="model"&&k.push({kind:"model",backend:String(h.backend),model:String(h.model),answer:b,...a.probabilities?{probabilities:a.probabilities}:{},...typeof a.confidence=="number"?{confidence:a.confidence}:{},...typeof a.threshold=="number"?{threshold:a.threshold}:{},reason:`proposed ${oc(b,g)}, which people confirmed and then retracted`,...typeof a.reason=="string"&&V$(s.loaded.schema).escalation?{model_reason:a.reason}:{}});let R=new Set(["answer","answered_by","answered_on","note","relayed_by","probabilities","confidence","threshold","reason"]),$=Object.fromEntries(Object.entries(a).filter(([Z])=>!R.has(Z))),_=Array.isArray(a.retractions)?a.retractions:[],T=Array.isArray(a.constrains)&&typeof a.constrains[0]=="string"?a.constrains[0]:void 0,C=Tm(a),K=f1(c,T,"escalated",void 0,C),O=h1(s,{...$,title:K,state:"escalated",decider:{kind:"quorum",count:d.count,...d.roles?{roles:d.roles}:{}},escalations:k.length>0?k:void 0,retractions:[..._,Object.fromEntries(Object.entries(x).filter(([,Z])=>Z!==void 0))]}),pe=pl(O,m1(c,K,C)),F=o.byPath.has(r.path),Q=`Decision point ${l}: ${oc(b,g)} retracted by ${p.counted.join(", ")}`,I=await g1(s,i,r.path,pe,!1,!!e.dryRun,{source:t.read.source,ledger:o,onLedger:F,message:Q,who:{verb:"points retract",by:p.counted.join(", ")}}),B={...r,state:"escalated",data:O,valid:!0,reasons:[],warnings:I.warnings};return{$schema:Fo,contract:Mo,verb:"retract",kind:s.view,id:e.id,path:r.path,reused:!1,written:!e.dryRun,dryRun:!!e.dryRun,question:vp(B,c,F?I.ledger??o.byPath.get(r.path)?.ledger??null:null),...e.dryRun?{text:pe}:{}}}catch(t){return Op("retract",t)}}var Mo,Fo,qTe,bt,u1,p1,oc,l1,cte,v$=v(()=>{"use strict";pg();mo();mn();vo();bg();Dm();_t();Zc();ps();vo();ol();Qc();ms();$t();Sg();kc();Mo=1,Fo="https://intentius.io/chant/schemas/workspace/points-write/v1/points-write.schema.json",qTe=[...La,"write-usage-invalid","write-input-invalid","points-undeclared","points-invalid","point-unknown","point-inputs-invalid","point-decider-failed","answer-not-candidate","quorum-not-met","record-not-found","record-closed","record-id-taken","answer-in-steward-turn","answer-never-over-mcp","principal-unidentified","answer-not-answered","answer-field-unsupported","point-candidates-invalid",...Na,...$a],bt=class extends Error{constructor(n,i){super(i);this.code=n;this.name="PointsWriteError"}};u1="chant-steward";p1=()=>new Date().toISOString().slice(0,10),oc=(e,t)=>t==="noul"?e?"yes":"no":String(e);l1=e=>{let t=e?.trim();return t||void 0};cte=e=>e==="acp"?"ACP":"MCP"});function kp(e){return!!e&&typeof e=="object"&&e[fte]===!0&&"question"in e}async function sDe(e,t){if(e.capabilities!==void 0)return{capabilities:e.capabilities,vault:e.vault??null};let{discoverStewards:n}=await Promise.resolve().then(()=>(Bi(),zT)),i=(await n({cwd:t})).stewards.get(e.steward)?.declaration;return{capabilities:i?.capabilities??[],vault:i?.vault??null}}async function R$(e,t){let n=t.capability??X7,i={capability:n,broker:t.broker??null},r=t.turn===void 0?bo():t.turn;if(!r)return a=>e(a,i);let{capabilities:o,vault:s}=await sDe(r,t.cwd);if(!o.includes(n)){let a=s!==null?`the steward ${r.steward} holds the vault ${s} and names no brokered capabilities, and a steward's model call goes through the broker`:`the steward ${r.steward} does not name the brokered capability ${n}`+(o.length?` (it names ${o.join(", ")})`:"")+", and a steward holds no credential of its own";return async()=>{throw new Error(a)}}return a=>e(a,i)}async function aM(e){let t=e.turn===void 0?bo():e.turn,n=e.ask?await R$(e.ask,{capability:e.capability,broker:e.broker,turn:t,cwd:e.cwd}):void 0,{askPoint:i}=await Promise.resolve().then(()=>(v$(),sM)),r=await i({cwd:e.cwd,point:e.point,inputs:e.inputs,...e.subject!==void 0?{subject:e.subject}:{},...e.kind!==void 0?{kind:e.kind}:{},...n?{ask:n}:{},...e.on!==void 0?{on:e.on}:{},...e.store!==void 0?{store:e.store}:{},...t?{steward:{name:t.steward,...t.run?{run:t.run}:{}}}:{}});if("error"in r)throw new Error(`decision point ${e.point}: ${r.error.code}: ${r.error.message}`);let o=r.question;if(o.state==="answered"&&o.answer!==null)return{answer:o.answer,question:o};throw new P$({id:o.id,point:o.point,state:o.state==="proposed"?"proposed":"escalated",path:o.path,subject:o.subject,steward:o.askedBy?.steward??null})}var X7,fte,dte,pte,P$,Ah=v(()=>{"use strict";ol();X7="inference",fte=Symbol.for("chant.op.PointWait"),P$=class extends(pte=Error,dte=fte,pte){constructor(n){super(`waiting on decision point ${n.point} (${n.id}, ${n.state}): a person answers it through hud or \`chant workspace points answer ${n.id}\``);this.question=n;this[dte]=!0;this.name="PointWait"}}});var mte={};_e(mte,{evaluatePointGate:()=>og,pointGateResumable:()=>sg,workspaceGatePointAsker:()=>dM});function dM(e){return{async ask(t){let{workspacePoints:n}=await Promise.resolve().then(()=>(Eh(),w$)),i=await n({cwd:e});if("error"in i)throw new Error(`decision point ${t.point}: ${i.error.code}: ${i.error.message}`);let r=i.points.find(l=>l.name===t.point);if(!r){let l=i.sources.find(c=>c.reason);throw new Error(`gate "${t.facts.name}" asks decision point ${t.point}, and no points file declares it${l?` (${l.kind}: ${l.reason.message})`:""}`)}let o=il(t.point,r.inputs.map(l=>l.name),t.facts,t.inputs),{runDecide:s}=await Promise.resolve().then(()=>(oM(),E7)),a=r.deciders.some(l=>l.kind==="model");try{let l=t.store??Nd(),c=await s({point:t.point,inputs:o,subject:t.subject,cwd:e,...l?{store:l}:{},...a?{}:{backends:{}}});return{id:c.id,point:t.point,path:c.path,state:c.state,answer:c.answer,decider:c.decider,answeredBy:c.answeredBy,subject:t.subject,steward:null}}catch(l){if(!kp(l))throw l;let c=l.question;return{id:c.id,point:c.point,path:c.path,state:c.state,answer:null,decider:"quorum",answeredBy:[],subject:c.subject,steward:c.steward}}}}}var A$=v(()=>{"use strict";bs();Ah();ok()});import{execFileSync as q$,spawnSync as aDe}from"node:child_process";import{existsSync as vte,mkdirSync as Z$,readFileSync as jl,rmSync as Jh,writeFileSync as w1}from"node:fs";import{dirname as v1,isAbsolute as tvt,join as bn,posix as cDe}from"node:path";function Oh(e,t){let n;try{n=JSON.parse(e)}catch(o){throw new Error(`${t}: ${o instanceof Error?o.message:String(o)}`)}let i=n?.waves,r=Array.isArray(i)?n:i;if(!r||typeof r!="object"||!Array.isArray(r.waves))throw new Error(`${t} must hold an Op waves spec: { "name", "op", "plan", "waves": [...] }, or { "waves": <that>, "options": {...} }`);return r}function Q7(e,t,n,i,r=uDe){let{sha:o,text:s}=r(n,e.replace(/^\.\//,"").split("\\").join(cDe.sep),i),a={policy:"always",approval:"ledger",source:"absent-at-base",base:o,hooks:gte(),spend:!1,applyHooksRunBy:"chant",neverOverMcp:!1};if(s===null)return a;let l;try{l=Oh(s,`${e} at ${n}`)}catch{return a}let c=l.approvals?.spend===!0,u=l.neverOverMcp===!0,d=dDe(l,t,`${e} at ${o.slice(0,12)}`),p=l.waves.find(b=>b.name===t);if(!p)return{...a,spend:c,neverOverMcp:u,...d};let f=p.gate??"always",g=p.approval===void 0?"ledger":Ca.includes(p.approval)?p.approval:"sealed",h={policy:qm.includes(f)?f:"always",approval:g,source:"base",base:o,hooks:gte(),spend:c,applyHooksRunBy:"chant",neverOverMcp:u,...d};try{Ld(`${e} at ${o.slice(0,12)}`,l.hooks),Ld(`${e} at ${o.slice(0,12)}, wave "${t}"`,p.hooks),h.hooks=Xv(l,t),h.applyHooksRunBy=Qv(l,t)}catch(b){h.hooksRefused=`the hooks at base cannot be run (${b instanceof Error?b.message:String(b)})`}return h}function dDe(e,t,n){let i=e.waves.find(o=>o.name===t)?.point??e.point;if(i===void 0)return{};let r=Jv(i);return r.length>0?{pointRefused:`the decision point at base cannot be asked (${n}: ${r.join("; ")})`}:{point:wT(e,t)}}function Cp(e,t){let n=[["{op}",t.op],["{target}",t.target],["{wave}",t.wave],["{plans}",t.plans],["{plan}",t.plan],["{runs}",t.runs]];return e.map(i=>n.reduce((r,[o,s])=>s===void 0?r:r.replaceAll(o,s),i))}function Y$(e,t,n){return`.chant/op-waves/${e.name}/wave-${t}/${n.replace(/[^A-Za-z0-9._-]/g,"_")}.plan.json`}function wM(e,t){return`.chant/op-waves/${e.name}/wave-${t}/runs.json`}function vM(e,t){return`.chant/op-waves/${e.name}/wave-${t}/plans.json`}function pDe(e,t,n){let i=n.op??e.spec.op,r=Y$(e.spec,e.wave,n.target);Z$(v1(bn(e.cwd,r)),{recursive:!0});let o=e.exec(Cp(e.spec.plan,{op:i,target:n.target,wave:t,plan:r}),e.cwd);if(o!==0)throw new Error(`planning ${n.target} exited ${o}`);let s;try{s=JSON.parse(jl(bn(e.cwd,r),"utf-8"))}catch(a){throw new Error(`planning ${n.target} wrote no readable plan file at ${r}: ${a instanceof Error?a.message:String(a)}`)}if(typeof s.planDigest!="string"||s.planDigest==="")throw new Error(`the plan file for ${n.target} (${r}) has no planDigest`);return xte(n.target,i,s)}function xte(e,t,n){let i=n.denied;if(i!==void 0){let r=i;if(!r||typeof r!="object"||!Array.isArray(r.rules)||r.rules.length===0||!r.rules.every(o=>typeof o=="string"&&o.trim()!=="")||r.reason!==void 0&&typeof r.reason!="string")throw new Error(`the plan of ${e} has denied ${JSON.stringify(i)}; a denial is { "rules": ["<rule id>", ...], "reason"?: "<text>" }`)}return{member:e,planDigest:n.planDigest,op:t,...n.destructive===!0?{destructive:!0}:{},...n.empty===!0?{empty:!0}:{},...n.denied?{denied:{rules:n.denied.rules,...n.denied.reason?{reason:n.denied.reason}:{}}}:{}}}function K$(e,t,n,i,r=wM(e.spec,e.k),o=!1){let s={wave:e.wave.name,number:e.k,...i?{digest:i}:{},...o?{discover:!0}:{},runs:t.map(a=>{let l=n?.get(a.target);return{target:a.target,op:a.op??e.spec.op,...l?{planDigest:l.planDigest,...l.destructive?{destructive:!0}:{},...l.empty?{empty:!0}:{}}:{}}})};return Z$(v1(bn(e.cwd,r)),{recursive:!0}),w1(bn(e.cwd,r),JSON.stringify(s,null,2)+`
307
+ `),r}function b1(e,t,n=!1){let{spec:i,k:r,wave:o,cwd:s,exec:a}=e;if(!i.planWave)return{members:t.map(T=>pDe({spec:i,wave:r,cwd:s,exec:a},o.name,T))};let l=K$(e,t,void 0,void 0,void 0,n),c=vM(i,r);Jh(bn(s,c),{force:!0});let u=a(Cp(i.planWave,{op:i.op,wave:o.name,runs:l,plans:c}),s);if(u!==0)throw new Error(`planning wave ${r} (${o.name}) exited ${u}`);let d;try{d=JSON.parse(jl(bn(s,c),"utf-8"))}catch(T){throw new Error(`planning wave ${r} (${o.name}) wrote no readable plans file at ${c}: ${T instanceof Error?T.message:String(T)}`)}let p=Array.isArray(d)?d:d?.runs;if(!Array.isArray(p))throw new Error(`the plans file of wave ${r} (${c}) must hold { "runs": [{ "target", "planDigest" }] }`);let f=new Set(t.map(T=>T.target)),g=new Map,h=[];for(let T of p){let C=T?.target;if(n&&typeof C=="string"&&C!==""&&!g.has(C)){if(T.op!==void 0&&(typeof T.op!="string"||T.op===""))throw new Error(`the plans file of wave ${r} (${c}) gives ${C} an op that is not a name`);h.push({target:C,...T.op&&T.op!==i.op?{op:T.op}:{}}),f.add(C)}if(typeof C!="string"||!f.has(C))throw new Error(`the plans file of wave ${r} (${c}) plans ${JSON.stringify(C)}, which is not a run it was asked to plan`);if(g.has(C))throw new Error(`the plans file of wave ${r} (${c}) plans ${C} twice`);if(typeof T.planDigest!="string"||T.planDigest==="")throw new Error(`the plans file of wave ${r} (${c}) has no planDigest for ${C}`);g.set(C,T)}let b=t.filter(T=>!g.has(T.target)).map(T=>T.target);if(b.length>0)throw new Error(`the plans file of wave ${r} (${c}) has no plan for ${b.join(", ")}`);n&&(t=h);let w=Array.isArray(d)?void 0:fDe(d.members,new Set(t.map(T=>T.target)),`the plans file of wave ${r} (${c})`),x=Array.isArray(d)?void 0:d.waves;if(x!==void 0&&(!Number.isInteger(x)||x<0))throw new Error(`the plans file of wave ${r} (${c}): \`waves\` must be the number of waves found, a whole number`);let k=Array.isArray(d)?void 0:$te(d.pending,`the plans file of wave ${r} (${c})`),R=t.map(T=>{let C=xte(T.target,T.op??i.op,g.get(T.target)),K=bn(s,Y$(i,r,T.target));return w1(K,JSON.stringify({planDigest:C.planDigest,...C.destructive?{destructive:!0}:{},...C.empty?{empty:!0}:{},...C.denied?{denied:C.denied}:{}})+`
308
+ `),C}),$=Array.isArray(d)?void 0:d.overriders,_=Array.isArray(d)?void 0:d.overridersSource;if(_!==void 0&&(typeof _!="string"||_.trim()===""))throw new Error(`the plans file of wave ${r} (${c}): \`overridersSource\` must be a label for where the overriders come from, such as "policy.override in terragucci.yml"`);if($!==void 0&&(!Array.isArray($)||!$.every(T=>typeof T=="string")))throw new Error(`the plans file of wave ${r} (${c}): \`overriders\` must be a list of principals`);return{members:R,...k?{pending:k}:{},...$?{overriders:$}:{},...$&&_?{overridersSource:_}:{},...w?{extras:w}:{},...x!==void 0?{waves:x}:{}}}function fDe(e,t,n){if(e===void 0)return;if(!Array.isArray(e))throw new Error(`${n}: \`members\` must be a list of { "member", "planDigest" }`);let i=new Set,r=[];for(let o of e){if(!o||typeof o.member!="string"||o.member===""||typeof o.planDigest!="string"||o.planDigest==="")throw new Error(`${n}: each of \`members\` needs a member and a planDigest`);if(t.has(o.member))throw new Error(`${n}: member ${o.member} is also a run's target; a digest member that is no run needs a name of its own`);if(i.has(o.member))throw new Error(`${n}: names member ${o.member} twice`);i.add(o.member),r.push({member:o.member,planDigest:o.planDigest})}return r.length>0?r:void 0}function $te(e,t){if(e===void 0)return;if(e===null||typeof e!="object"||Array.isArray(e))throw new Error(`${t}: \`pending\` must be an object of fields for the pending fact`);let n=Object.keys(e).filter(i=>lDe.includes(i));if(n.length>0)throw new Error(`${t}: \`pending\` sets ${n.join(", ")}, which chant writes itself`);if("description"in e&&typeof e.description!="string")throw new Error(`${t}: pending.description must be a string`);return Object.keys(e).length>0?e:void 0}function kM(e,t,n=[]){return gT(hT(t,{...e.digest?.over?{over:e.digest.over}:{},extras:n}))}function Rte(e,t,n){if(vte(e))try{let i=JSON.parse(jl(e,"utf-8"));if(typeof i.gate!="string"||i.gate===""||typeof i.digest!="string"||i.digest==="")throw new Error("it names no gate and digest");if(i.op!==void 0&&(typeof i.op!="string"||i.op===""))throw new Error("its op is not a name");return{gate:i.gate,digest:i.digest,...i.op?{op:i.op}:{},...typeof i.description=="string"?{description:i.description}:{},...i.pending?{pending:$te(i.pending,`the hold ${n} wrote`)??{}}:{}}}catch(i){t(`${n} wrote a hold file that cannot be read (${i instanceof Error?i.message:String(i)}), so it holds the wave on its set digest`);return}}function mDe(e,t,n,i,r,o={}){let s={holds:[],outcomes:[],otherGates:[]};if(!n||n.length===0)return s;let{name:a,op:l,waveName:c,k:u,cwd:d,exec:p,log:f}=e,g=`.chant/op-waves/${a}/wave-${u}/hold.json`,h={CHANT_OP_WAVES:a,CHANT_WAVE:c,CHANT_WAVE_NUMBER:String(u),CHANT_HOOK:t,CHANT_RUNS:r,CHANT_HOLD:g,...o};for(let b of n){let w=b.name??(b.command.join(" ").length>60?`${b.command.join(" ").slice(0,57)}...`:b.command.join(" ")),x=b.perRun?i.map(k=>({target:k.target,argv:Cp(b.command,{op:k.op,wave:c,target:k.target,runs:r,...k.plan?{plan:k.plan}:{}}),env:{...h,CHANT_TARGET:k.target,...k.plan?{CHANT_PLAN:k.plan}:{}}})):[{target:void 0,argv:Cp(b.command,{op:l,wave:c,runs:r}),env:h}];for(let k of x){let R=`${t} hook ${w}${k.target?` (${k.target})`:""}`,$;Jh(bn(d,g),{force:!0});try{$=p(k.argv,d,k.env)}catch(T){f(`${R} did not run: ${T instanceof Error?T.message:String(T)}`),$=127}let _={moment:t,name:w,...k.target?{target:k.target}:{},exit:$};if($===0){s.outcomes.push({..._,outcome:"passed"});continue}if(b.onFailure==="approve"){s.outcomes.push({..._,outcome:"held"});let T=Rte(bn(d,g),f,R);if(T){s.otherGates.push({label:R,name:w,moment:t,...k.target?{target:k.target}:{},argv:k.argv,env:k.env,request:T}),f(`${R} exited ${$} and holds wave ${u} (${c}) on gate ${T.op??a} / ${T.gate}, digest ${T.digest}`);continue}s.holds.push(R),f(`${R} exited ${$}, so wave ${u} (${c}) waits for an approval of its set digest`);continue}return s.outcomes.push({..._,outcome:"failed"}),s.failed=`${R} exited ${$}`,f(s.failed),s}}return s}async function Nl(e,t,n,i,r,o,s={}){if(!n||n.length===0)return{holds:[]};let a=K$(e,i,r,o),l=mDe(gDe(e),t,n,Ste(e.spec,e.k,i,r),a,s);e.result.hooks.push(...l.outcomes);let c={holds:l.holds,...l.failed?{failed:l.failed}:{}};if(l.failed)return c;for(let u of l.otherGates){let d=u,p=[];for(;;){let f=await hDe(e,d);if(f.status==="waiting"){p.length>0&&(f.after=p),c.waitingOn??=f;break}let g={op:f.op,gate:f.gate,digest:f.digest,approvedBy:f.approvedBy,approvedAt:f.approvedAt};p.push(g);let h={...d.env,CHANT_HOLD_APPROVED:JSON.stringify(g),CHANT_HOLDS_APPROVED:JSON.stringify(p)},b=bn(e.cwd,d.env.CHANT_HOLD);Jh(b,{force:!0});let w;try{w=e.exec(d.argv,e.cwd,h)}catch($){e.log(`${d.label} did not run: ${$ instanceof Error?$.message:String($)}`),w=127}let x=d.target?{target:d.target}:{};if(w===0){e.result.hooks.push({moment:t,name:d.name,...x,exit:w,outcome:"passed"}),e.log(`${d.label}: ${f.approvedBy} approved ${f.op} / ${f.gate} at ${f.digest}, and the hook ran again and passed`);break}let k=Rte(b,e.log,d.label),R=k?p.some($=>$.op===(k.op??e.spec.name)&&$.gate===k.gate&&$.digest===k.digest)?`${d.label} exited ${w} after ${f.approvedBy} approved ${f.gate}, and holds the wave again on ${k.op??e.spec.name} / ${k.gate} at ${k.digest}, which is already approved`:p.length>=hte?`${d.label} held the wave on ${p.length} gates in turn and asks for one more; a hook call holds on at most ${hte}`:void 0:`${d.label} exited ${w} after ${f.approvedBy} approved ${f.gate}`;if(R)return e.result.hooks.push({moment:t,name:d.name,...x,exit:w,outcome:"failed"}),c.failed=R,e.log(c.failed),c;e.result.hooks.push({moment:t,name:d.name,...x,exit:w,outcome:"held"}),e.log(`${d.label}: ${f.approvedBy} approved ${f.op} / ${f.gate}; the hook ran again, exited ${w} and holds wave ${e.k} (${e.wave.name}) on gate ${k.op??e.spec.name} / ${k.gate}, digest ${k.digest}`),d={...d,request:k}}}return c}async function Ete(e,t,n,i,r){let o=e.gates??ys({cwd:t}),s=c=>o.approvalRule?.(c,{base:r})??Promise.resolve(null);if(i!=="sealed")return{ledger:o,port:o.approvalRule?{...o,approvalRule:s}:o};let a=await Promise.resolve().then(()=>(ng(),tg)),l=a.sealedApprovalRule(n,(e.trust??(c=>a.trustPolicyAt(t,c)))(r));return{ledger:o,port:{...o,async approvalRule(c){let u=await s(c);return c===n?a.bothRules(u,l):u}}}}function Ate(e,t,n){if(!n.satisfied)for(let{resolution:i,reason:r}of n.refused??[])e(`${t}: the approval by ${i.resolvedBy} at ${i.timestamp} does not count: ${r}`)}async function hDe(e,t){let{spec:n,k:i,wave:r,log:o}=e,s=e.gateRule,a=t.request.op??n.name,l=s.approval==="sealed"?"sealed":"ledger",{port:c}=await Ete(e.options,e.cwd,t.request.gate,l,s.base),u=s.neverOverMcp,d=e.options.now??new Date().toISOString(),p=await nl(c,{op:a,gate:t.request.gate,planDigest:t.request.digest,description:t.request.description??`wave ${i} (${r.name}) of ${n.name} is held on it by ${t.label}`,now:d,fields:{...t.request.pending,approvalMode:s.approval,wave:{number:i,name:r.name,op:n.name},heldBy:{hook:t.name,moment:t.moment,...t.target?{target:t.target}:{}}},...u?{neverOverMcp:!0}:{}}),f={op:a,gate:t.request.gate,digest:t.request.digest,hook:t.label};if(Ate(o,`${a} / ${t.request.gate}`,p),p.satisfied)return{...f,status:"approved",approvedBy:p.resolution.resolvedBy,approvedAt:p.resolution.timestamp};let g=Dd(a,t.request.gate,void 0,t.request.digest,l==="sealed");return o(`wave ${i} (${r.name}) waits on ${a} / ${t.request.gate}, which ${t.label} holds it on: nobody approved ${t.request.digest}. Approve: ${g}`),{...f,status:"waiting",approve:g,waitingSince:p.pending.timestamp,recorded:p.recorded,...p.mismatch?{mismatch:p.mismatch}:{}}}function eQ(e,t){return e==="never"||t.every(n=>n.empty===!0)?!1:e==="on-destructive"?t.some(n=>n.destructive===!0):!0}function yDe(e,t){let{hooks:n,base:i}=t,r=Xv(e.spec,e.wave.name);(JSON.stringify(r)!==JSON.stringify(n)||Qv(e.spec,e.wave.name)!==t.applyHooksRunBy)&&e.log(`wave ${e.k} (${e.wave.name}): its hooks are read at ${i.slice(0,12)}, and this change's differ; the ones at base run`)}async function xM(e){let{spec:t}=e;Km(t);let n=e.log??(s=>console.error(s)),i=t.waves[t.waves.length-1],r=[],o=[];for(let s=e.wave;;s++){let a,l;for(let d=0;a=await bDe(e,s,l,d),!!a.replan;d++){if(d+1>=$M){n(`wave ${s}: its apply asked to plan again ${$M} times, so the wave stops here`),a.exitCode=1;break}n(`wave ${s}: the apply applied nothing and asks to plan again${a.replan.reason?` (${a.replan.reason})`:""}; planning again`),l=a.decision}r.push(...a.applied);let c=a.decision?.discovered?.waves,u=s>=t.waves.length&&i.rest===!0&&e.share===void 0&&!e.decide&&a.exitCode===0&&c!==void 0&&s<c;if((o.length>0||u)&&o.push({wave:s,exitCode:a.exitCode,...a.decision?{digest:a.decision.digest}:{}}),!u)return{...a,applied:r,...o.length>0?{rest:o}:{}};n(`wave ${s} applied; the plan found ${c} waves, so this job goes on to wave ${s+1}`)}}async function bDe(e,t,n,i){let{spec:r}=e,o=e.cwd??process.cwd(),s=e.exec??kte,a=e.log??($e=>console.error($e)),l=r.waves[r.waves.length-1],c=r.waves[t-1]??(l.rest?l:void 0);if(!c)throw new Error(`Op waves "${r.name}" has ${r.waves.length} waves; there is no wave ${t}.`);let u=c.shares??1;if(e.share!==void 0&&(e.share<1||e.share>u))throw new Error(`wave ${t} (${c.name}) has ${u} share${u===1?"":"s"}; there is no share ${e.share}.`);let d=bn(o,Yv(r,t)),p={exitCode:0,applied:[],failed:[],moved:[],hooks:[]},f={spec:r,k:t,wave:c,cwd:o,exec:s,log:a,result:p,options:e,gateRule:{approval:"ledger",base:"HEAD",neverOverMcp:r.neverOverMcp===!0}};if(i>0&&a(`wave ${t} (${c.name}): plan ${i+1}`),e.share!==void 0){let $e;try{$e=JSON.parse(jl(d,"utf-8"))}catch{throw new Error(`share ${e.share} of wave ${t} (${c.name}) found no decision at ${Yv(r,t)}. Run the deciding job first.`)}if(p.decision=$e,f.gateRule={approval:$e.approval,base:$e.base,neverOverMcp:$e.neverOverMcp===!0},$e.status==="waiting"||$e.status==="refused")return a(`wave ${t} (${c.name}) is ${$e.status==="refused"?"refused by its policy":`waiting on ${$e.heldOn?.gate??$e.gate}`}; nothing applied. ${$e.approve??""}`.trim()),{...p,exitCode:$e.status==="refused"?x1($e):3};c.discover&&(c={...c,runs:$e.members.map(Re=>({target:Re.member,...Re.op!==r.op?{op:Re.op}:{}}))},f.wave=c);let Te=xT(c.runs,e.share,u),nt=await Nl(f,"before-plan",$e.hooks?.["before-plan"],Te);if(nt.failed)return zo(f,`a hook before the plan failed, so nothing in share ${e.share} of wave ${t} was planned or applied`);if(nt.waitingOn)return yte(f,$e,nt.waitingOn);let{members:St}=b1(f,Te),Ee=new Map(St.map(Re=>[Re.member,Re])),zt=await Nl(f,"after-plan",$e.hooks?.["after-plan"],Te,Ee);if(zt.failed)return zo(f,`a hook after the plan failed, so nothing in share ${e.share} of wave ${t} was applied`);if(zt.waitingOn)return yte(f,$e,zt.waitingOn);let Vn=new Map($e.members.map(Re=>[Re.member,Re.planDigest])),ne=[];for(let Re of Te){let X=Ee.get(Re.target);if(Vn.get(Re.target)!==X.planDigest){a(`${Re.target}: its plan moved since wave ${t} was decided, so it was not applied. decided: ${Vn.get(Re.target)??"(not in the decision)"}; planned now: ${X.planDigest}`),p.moved.push(Re.target);continue}ne.push(Re)}return await wte(e,f,$e,ne,Ee,[...nt.holds,...zt.holds]),p.exitCode===0&&p.moved.length>0&&(p.exitCode=4),p}let g=Q7(e.specFile,c.name,e.base??r.base??"HEAD^1",o,e.show),{policy:h,approval:b,source:w,base:x}=g,k=g.neverOverMcp||r.neverOverMcp===!0;if(f.gateRule={approval:b,base:x,neverOverMcp:k},yDe(f,g),g.pointRefused)return zo(f,`wave ${t} (${c.name}): ${g.pointRefused}, so nothing in it was planned or applied`);let R=wT(r,c.name);JSON.stringify(R)!==JSON.stringify(g.point)&&a(`wave ${t} (${c.name}): its gate's decision point is read at ${x.slice(0,12)} (${g.point?.name??"none"}), and this change's differs (${R?.name??"none"}); the one at base holds`);let $=[];g.hooksRefused&&($.push(g.hooksRefused),a(`wave ${t} (${c.name}): ${g.hooksRefused}, so none run and the wave waits for an approval`));let _=vT(r,t),T=Object.fromEntries(Object.entries(g.hooks).filter(([,$e])=>$e.length>0)),C={wave:t,name:c.name,op:r.name,gate:_,policy:h,approval:b,policySource:w,base:x,digest:"",members:[],status:"not-required",...Object.keys(T).length>0?{hooks:T}:{},...g.spend?{spend:"base"}:r.approvals?.spend===!0?{spend:"change"}:{},...g.applyHooksRunBy==="apply"?{applyHooksRunBy:"apply"}:{},...r.digest?.over==="changing"?{digestOver:"changing"}:{},...k?{neverOverMcp:!0}:{},...g.point?{point:{...g.point}}:{}},K=await Nl(f,"before-plan",g.hooks["before-plan"],c.runs);if(K.failed)return zo(f,`a hook before the plan failed, so nothing in wave ${t} was planned or applied`);if(K.waitingOn)return y1(f,C,d,K.waitingOn);let{members:O,pending:pe,overriders:F,overridersSource:Q,extras:I,waves:B}=b1(f,c.runs,c.discover===!0);c.discover&&(c={...c,runs:O.map($e=>({target:$e.member,...$e.op!==r.op?{op:$e.op}:{}}))},f.wave=c,C.discovered={...B!==void 0?{waves:B}:{}},a(`wave ${t} (${c.name}): the plan found ${O.length} run${O.length===1?"":"s"}${B!==void 0?` of ${B} waves`:""}${O.length?`: ${O.map($e=>$e.member).join(", ")}`:""}`));let Z=new Map(O.map($e=>[$e.member,$e])),xe=kM(r,O,I);C.digest=xe,C.members=O,I&&(C.extras=I),pe&&(C.pending=pe);let we=await Nl(f,"after-plan",g.hooks["after-plan"],c.runs,Z,xe);if(we.failed)return zo(f,`a hook after the plan failed, so nothing in wave ${t} was applied`);if($.push(...K.holds,...we.holds),$.length>0&&(C.heldBy=$),we.waitingOn)return y1(f,C,d,we.waitingOn);let Ct=n!==void 0&&(n.status==="approved"||n.status==="not-required")&&n.digest===xe;if(Ct){let $e=new Map(n.members.map(Te=>[Te.member,Te.override]));for(let Te of O)Te.denied&&$e.get(Te.member)&&(Te.override=$e.get(Te.member));n.overridesSpentAt&&(C.overridesSpentAt=n.overridesSpentAt)}if(O.some($e=>$e.denied&&!$e.override)&&await vDe(f,C,F,Q),Ct&&n.status==="approved"&&C.status!=="refused"){for(let $e of["via","approvedBy","approvedAt","review","spentAt"])n[$e]!==void 0&&(C[$e]=n[$e]);C.status="approved",a(`wave ${t} (${c.name}): planned again to the same digest, so the approval by ${n.approvedBy} still holds`)}else C.status!=="refused"&&(eQ(h,O)||$.length>0)&&await Ote(e,f,C);let at=await y1(f,C,d);return at.exitCode!==0?at:(a(`wave ${t} (${c.name}): gate ${h} (read at ${x.slice(0,12)}${w==="absent-at-base"?", where the wave is absent":""}), digest ${xe}: ${C.status}${C.approvedBy?` by ${C.approvedBy}`:""}`+(C.via==="pr-review"?` (review of #${C.review?.pr})`:"")+($.length>0?`; held by ${$.join(", ")}`:"")),e.decide?!await $1(e,f,C)||!await Pte(f,C)?f.result:((C.spentAt||C.overridesSpentAt)&&Uo(d,C,p),p):(await wte(e,f,C,c.runs,Z,[],d),p))}async function y1(e,t,n,i){let{k:r,wave:o,log:s,result:a}=e;i&&k1(t,i),Z$(v1(n),{recursive:!0}),Uo(n,t,a),a.decision=t,t.approval==="pr-review"&&t.status==="waiting"&&t.review?.reason&&s(`The pull request's review does not approve wave ${r}: ${t.review.reason}`);let l=await J$(e,t,n);return t.status==="waiting"?(s(`Nothing in wave ${r} or after it ran. ${t.heldOn?`It waits on ${t.heldOn.op} / ${t.heldOn.gate}.`:"Read the plans, then"} approve: ${t.approve} (with --resume, the approval also starts this job again)`),{...a,exitCode:3}):t.status==="refused"&&t.refused?.reason==="point"?(s(`Nothing in wave ${r} (${o.name}) or after it ran: ${t.refused.message}`),{...a,exitCode:8}):t.status==="refused"?(s(`Nothing in wave ${r} (${o.name}) or after it ran: the policy denied ${t.refused?.runs.join(", ")}, and no override counts for ${t.refused?.runs.length===1?"it":"them"}.`),{...a,exitCode:7}):l.failed?zo(e,`wave ${r} (${o.name}): ${l.failed}, so nothing in it was applied`):a}function k1(e,t){e.heldOn=t,e.status="waiting",e.approve=t.approve,t.waitingSince&&(e.waitingSince=t.waitingSince),t.recorded!==void 0&&(e.recorded=t.recorded)}async function yte(e,t,n){return k1(t,n),e.log(`share ${e.options.share} of wave ${e.k} (${e.wave.name}) waits on ${n.op} / ${n.gate}; nothing in it applied. Approve: ${n.approve}`),{...e.result,decision:t,exitCode:3}}async function J$(e,t,n){let i=t.hooks?.["after-gate"];if(!i?.length)return{holds:[]};let r=t.heldOn,o={CHANT_GATE_STATUS:t.status,CHANT_GATE_OP:r?.op??t.op,CHANT_GATE:r?.gate??t.gate,CHANT_GATE_DIGEST:r?.digest??t.digest,CHANT_DECISION:wDe(e.cwd,n),...t.approve?{CHANT_GATE_APPROVE:t.approve}:{},...t.waitingSince?{CHANT_GATE_WAITING_SINCE:t.waitingSince}:{},...t.recorded!==void 0?{CHANT_GATE_RECORDED:String(t.recorded)}:{}},s=new Map(t.members.map(l=>[l.member,l])),a=await Nl(e,"after-gate",i,e.wave.runs,s.size>0?s:void 0,t.digest||void 0,o);return Uo(n,t,e.result),a.failed&&t.status!=="approved"&&t.status!=="not-required"&&e.log(`${a.failed}; the wave is ${t.status} whatever the hook came to`),a}function wDe(e,t){return t.startsWith(e+"/")?t.slice(e.length+1):t}async function vDe(e,t,n,i){let{spec:r,k:o,wave:s,cwd:a,log:l,options:c}=e,u=await Promise.resolve().then(()=>(rg(),IT)),d=c.gates??ys({cwd:a}),p=r.override?.overriders??u.OVERRIDERS_PATH,f=n??u.overridersAt(a,t.base,p).principals,g=t.approval==="sealed",h=g?(c.signers??(await Promise.resolve().then(()=>(DT(),TT))).gateSignersAt.bind(null,a))(t.base):void 0,b=await d.read(u.OVERRIDE_OP),w=await d.readApplied?.(u.OVERRIDE_OP)??[],x=c.now??new Date().toISOString(),k=[],R=!1;for(let $ of t.members){if(!$.denied||$.override)continue;let _=u.decideOverride({ledger:b,applied:w,subject:$.member,planDigest:$.planDigest,rules:$.denied.rules,overriders:f,overridersPath:n?i??"the overriders the plans file names":p,mode:g?"sealed":"ledger",...h?{signers:h}:{},now:x});if(_.status==="overridden"){let T=_.override;$.override={by:T.by,at:T.at,digest:T.digest,reason:T.reason},l(`${$.member}: the policy denial (${T.rules.join(", ")}) is overridden by ${T.by} at ${T.at}${T.sealed?", sealed":""}: ${T.reason}`);continue}k.push($.member);for(let T of _.refusals)l(`${$.member}: an override does not count: ${T}`);if(_.status==="moved"&&(R=!0,l(`${$.member}: ${_.by} overrode an earlier plan or other rules (${_.was??"no digest"}); this plan and its rules give ${_.digest}, so that override counts for nothing`)),!_.standing){let{version:T,kind:C,...K}=u.overridePending({subject:$.member,planDigest:$.planDigest,rules:$.denied.rules,timestamp:x,expiresAt:new Date(new Date(x).getTime()+1728e5).toISOString(),description:$.denied.reason??`wave ${o} (${s.name}) of ${r.name}: ${$.member}: plan ${$.planDigest} denied by ${u.sortedRules($.denied.rules).join(", ")}`});try{await d.appendPending({...K,members:[{member:$.member,planDigest:$.planDigest}],wave:{number:o,name:s.name,op:r.name}})}catch(O){l(`${$.member}: the denial was not recorded for an override: ${O instanceof Error?O.message:String(O)}`)}}l(`${$.member}: ${f.length?`${f.join(", ")} may`:"nobody listed may"} override it with: ${u.overrideCommand($.member,$.denied.rules,g)}`)}k.length>0&&(t.status="refused",t.refused={reason:R?"override-moved":"policy",runs:k.sort(),...n&&i?{overridersSource:i}:{}})}async function Pte(e,t){let n=t.members.filter(d=>d.override);if(n.length===0||t.overridesSpentAt)return!0;let{k:i,wave:r,cwd:o,log:s,options:a}=e,l=await Promise.resolve().then(()=>(rg(),IT)),c=a.gates??ys({cwd:o}),u=a.now??new Date().toISOString();try{if(!c.appendApplied)throw new Error("this gate ledger cannot record an applied override");for(let d of n){let p=l.appliedOverride({subject:d.member,digest:d.override.digest,at:d.override.at,by:d.override.by},{timestamp:u});await c.appendApplied(p)}}catch(d){return zo(e,`wave ${i} (${r.name}) could not record the overrides it applies under, so nothing applied: ${d instanceof Error?d.message:String(d)}`),!1}return t.overridesSpentAt=u,s(`wave ${i} (${r.name}) applies ${n.map(d=>d.member).join(", ")} under their overrides, which are now spent`),!0}function x1(e){return e.refused?.reason==="point"?8:7}function zo(e,t){return e.log(t),e.result.exitCode=1,e.result}async function Ote(e,t,n){if(n.point)return kDe(e,t,n,n.point);let{spec:i,k:r,wave:o,cwd:s}=t,{gate:a,digest:l,approval:c,base:u,policy:d,members:p}=n,{ledger:f,port:g}=await Ete(e,s,a,c,u),h=e.now??new Date().toISOString(),b=n.spend==="base"?(await f.readApplied?.(i.name)??[]).filter(R=>R.gate===a):void 0,w=n.heldBy?.length?`, held by ${n.heldBy.join(", ")}`:"",x=await D6(g,{op:i.name,gate:a,digest:l,description:(typeof n.pending?.description=="string"?n.pending.description:void 0)??`wave ${r} (${o.name}): ${p.length} run${p.length===1?"":"s"}, gate ${d}, approval ${c}${w}`,now:h,...b?{spent:b}:{},fields:{...n.pending,approvalMode:c},...n.neverOverMcp?{neverOverMcp:!0}:{}});if(x.satisfied){n.status="approved",n.via="ledger",n.approvedBy=x.resolution.resolvedBy,n.approvedAt=x.resolution.timestamp;return}Ate(t.log,`wave ${r} (${o.name})`,x),n.pendingFact=x.pending,n.recorded=x.recorded,n.waitingSince=x.pending.timestamp,x.mismatch&&(n.mismatch=x.mismatch);let k=b?.filter(R=>Lr([R],{gate:a,planDigest:l,timestamp:R.approvedAt})).pop();if(k&&t.log(`wave ${r} (${o.name}): the approval of ${l} by ${k.approvedBy} at ${k.approvedAt} is spent: a wave applied under it at ${k.timestamp}. Applying it again needs a new approval`),c==="pr-review"){let R=await $De(e,{op:i.name,gate:a,k:r,digest:l,cwd:s,now:h,port:f,...b?{spent:b}:{}});if(n.review=R.review,R.approved){for(let $ of["pendingFact","recorded","waitingSince","mismatch"])delete n[$];n.status="approved",n.via="pr-review",n.approvedBy=R.review.approvers.join(", "),n.approvedAt=h;return}n.status="waiting",n.approve=Dd(i.name,a,void 0,l);return}n.status="waiting",n.approve=Dd(i.name,a,void 0,l,c==="sealed")}async function kDe(e,t,n,i){let{spec:r,k:o,wave:s,cwd:a,log:l}=t,{gate:c,digest:u,policy:d,members:p}=n;n.approval!=="ledger"&&l(`wave ${o} (${s.name}): its gate asks decision point ${i.name}, so its approval mode (${n.approval}) does not apply`);let{evaluatePointGate:f}=await Promise.resolve().then(()=>(ok(),v4)),g=e.points??(await Promise.resolve().then(()=>(A$(),mte))).workspaceGatePointAsker(a),h=n.heldBy?.length?`, held by ${n.heldBy.join(", ")}`:"",b=await f(e.gates??ys({cwd:a}),g,{op:r.name,gate:c,point:{name:i.name,...i.pass?{pass:i.pass}:{},...i.store?{store:i.store}:{}},...i.inputs?{inputs:i.inputs}:{},description:(typeof n.pending?.description=="string"?n.pending.description:void 0)??`wave ${o} (${s.name}): ${p.length} run${p.length===1?"":"s"}, gate ${d}, decision point ${i.name}${h}`,...i.timeout?{timeout:i.timeout}:{},planDigest:u,...e.now?{now:e.now}:{},fields:{...n.pending,approvalMode:n.approval},...n.neverOverMcp?{neverOverMcp:!0}:{}});if(b.satisfied){n.status="approved",n.via="point",n.approvedBy=b.resolution.resolvedBy,n.approvedAt=b.resolution.timestamp,i.answer=b.answer;return}if("refused"in b){n.status="refused",n.refused={reason:"point",runs:p.map(w=>w.member),message:b.refused},i.answer=b.answer;return}n.status="waiting",n.pendingFact=b.pending,n.recorded=b.recorded,n.waitingSince=b.pending.timestamp,i.question=b.waiting,n.approve=`chant workspace points answer ${b.waiting.id} --answer <answer> --by <your name>`,l(`wave ${o} (${s.name}) asks decision point ${i.name} about ${u}: question ${b.waiting.id} is ${b.waiting.state}`)}function Uo(e,t,n){n.hooks.length>0&&(t.outcomes=[...n.hooks]),N6(e,t)}async function Cte(e,t,n,i,r){let{k:o,wave:s,log:a,result:l}=t;return i.length===0||n.status==="approved"?!0:(n.heldBy=[...n.heldBy??[],...i],await Ote(e,t,n),r&&Uo(r,n,l),n.status==="refused"?(r&&await J$(t,n,r),a(`wave ${o} (${s.name}) is held by ${i.join(", ")}; nothing applied: ${n.refused?.message??"refused"}`),l.exitCode=x1(n),!1):n.status==="waiting"?(r&&await J$(t,n,r),a(`wave ${o} (${s.name}) is held by ${i.join(", ")}, and nobody approved ${n.digest}; nothing applied. Approve: ${n.approve}`),l.exitCode=3,!1):(a(`wave ${o} (${s.name}) is held by ${i.join(", ")}, and ${n.approvedBy} approved its digest`),!0))}function xDe(e,t,n){if(vte(e))try{let i=JSON.parse(jl(e,"utf-8"));if(!bM.includes(i.outcome))throw new Error(`outcome ${JSON.stringify(i.outcome)} is none of ${bM.join(", ")}`);if(i.reason!==void 0&&typeof i.reason!="string")throw new Error("its reason is not text");let r=i.holder&&typeof i.holder=="object"&&typeof i.holder.run=="string"?{run:i.holder.run,...typeof i.holder.url=="string"?{url:i.holder.url}:{}}:void 0;return{outcome:i.outcome,...i.reason?{reason:i.reason}:{},...r?{holder:r}:{}}}catch(i){n(`${t}: the apply wrote an outcome that cannot be read (${i instanceof Error?i.message:String(i)}), so its exit code decides`);return}}async function bte(e,t,n,i,r,o,s,a){let{spec:l,k:c,wave:u,cwd:d,exec:p,log:f,result:g}=t,h=n.applyHooksRunBy==="apply",b=`.chant/op-waves/${l.name}/wave-${c}`,w=`${b}/${s.key}.json`,x=`${b}/${s.key}-result.json`,k=`${b}/${s.key}-outcome.json`,R={};if(h)for(let $ of["before-apply","after-apply"])n.hooks?.[$]?.length&&(R[$]=n.hooks[$]);for(let $=0;$<2;$++){let _=n.status==="approved",T={version:1,opWaves:l.name,op:l.op,wave:u.name,number:c,base:n.base,digest:n.digest,approved:_,...n.heldBy?.length?{heldBy:n.heldBy}:{},runBy:h?"apply":"chant",runs:Ste(l,c,i,r),runsFile:s.runsPath,hooks:R,outcomes:[...g.hooks],...h?{result:x}:{}};Z$(bn(d,b),{recursive:!0}),w1(bn(d,w),JSON.stringify(T,null,2)+`
309
+ `),Jh(bn(d,x),{force:!0}),Jh(bn(d,k),{force:!0});let C;try{C=p(o,d,{CHANT_HOOKS:w,CHANT_APPLY_OUTCOME:k,...h?{CHANT_HOOKS_RESULT:x}:{}})}catch(Z){f(`${s.label}: the apply did not run: ${Z instanceof Error?Z.message:String(Z)}`),C=127}let K=xDe(bn(d,k),s.label,f);if(K){if(h)try{let Z=JSON.parse(jl(bn(d,x),"utf-8"));Array.isArray(Z?.outcomes)&&g.hooks.push(...Z.outcomes)}catch{}return f(`${s.label}: the apply applied nothing: ${K.outcome}${K.reason?` (${K.reason})`:""}${K.holder?`, held by run ${K.holder.run}`:""}`),{outcome:"applied-nothing",said:K}}if(!h)return{outcome:C===0?"applied":"failed"};let O=null;try{O=JSON.parse(jl(bn(d,x),"utf-8"))}catch{O=null}let pe=Array.isArray(O?.outcomes)?O.outcomes:[],F=Array.isArray(O?.moments)?O.moments:[];g.hooks.push(...pe);let Q=pe.filter(Z=>Z.moment==="before-apply"&&Z.outcome==="held").map(Z=>`${Z.moment} hook ${Z.name}${Z.target?` (${Z.target})`:""}`);if(Q.length>0&&!_){if(C===0)return f(`${s.label}: the apply exited 0 although ${Q.join(", ")} held it and no approval stood; an apply applies nothing on a hold`),{outcome:"failed"};if($>0||!await Cte(e,t,n,Q,a))return{outcome:"waiting"};if(!await $1(e,t,n))return{outcome:"failed"};a&&n.spentAt&&Uo(a,n,g);continue}let I=pe.find(Z=>Z.moment==="after-apply"&&Z.outcome==="failed");if(I)return{outcome:"applied",problem:`${s.label} applied, and then the after-apply hook ${I.name} failed`};if(C!==0)return{outcome:"failed"};let B=["before-apply","after-apply"].filter(Z=>R[Z]&&!F.includes(Z));return B.length>0?{outcome:"applied",problem:`${s.label}: the apply exited 0 without running its ${B.join(" and ")} hooks (runOpWaveApplyHooks with CHANT_HOOKS), which the spec at base hands it`}:{outcome:"applied"}}return{outcome:"failed"}}async function wte(e,t,n,i,r,o,s){let{spec:a,k:l,wave:c,log:u,result:d}=t;if(i.length===0)return;let p=n.applyHooksRunBy==="apply",f=[...o];if(!p){let w=await Nl(t,"before-apply",n.hooks?.["before-apply"],i,r,n.digest);if(w.failed){zo(t,`a hook before the apply failed, so nothing in wave ${l} was applied`);return}if(w.waitingOn){k1(n,w.waitingOn),s&&(Uo(s,n,d),await J$(t,n,s)),d.decision=n,d.exitCode=3;return}f.push(...w.holds)}if(!await Cte(e,t,n,f,s)||!await $1(e,t,n)||!await Pte(t,n))return;s&&(n.spentAt||n.overridesSpentAt)&&Uo(s,n,d);let g=[],h=!1,b;if(a.applyWave){let w=K$(t,i,r,n.digest),x=Cp(a.applyWave,{op:a.op,wave:c.name,runs:w,plans:vM(a,l)}),k=await bte(e,t,n,i,r,x,{label:`wave ${l} (${c.name})`,key:"hooks",runsPath:w},s);k.outcome==="applied-nothing"?b=k.said:k.outcome==="applied"?(d.applied.push(...i.map(R=>R.target)),k.problem&&g.push(k.problem)):k.outcome==="waiting"?h=!0:(u(`wave ${l} (${c.name}): apply failed, so none of ${i.map(R=>R.target).join(", ")} counts as applied`),d.failed.push(...i.map(R=>R.target)))}else for(let w of i){let x=w.target.replace(/[^A-Za-z0-9._-]/g,"_"),k=p?K$(t,[w],r,n.digest,`.chant/op-waves/${a.name}/wave-${l}/${x}.runs.json`):wM(a,l),R=Cp(a.apply??kT,{op:w.op??a.op,target:w.target,wave:c.name,plan:Y$(a,l,w.target)}),$=await bte(e,t,n,[w],r,R,{label:w.target,key:`${x}.hooks`,runsPath:k},s);if($.outcome==="applied-nothing"){b=$.said;break}if($.outcome==="waiting"){h=!0;break}$.outcome==="applied"?(d.applied.push(w.target),$.problem&&g.push($.problem)):(u(`${w.target}: apply failed`),d.failed.push(w.target))}if(s&&p&&Uo(s,n,d),b){if(b.outcome==="replan"){d.replan={...b.reason?{reason:b.reason}:{}};return}d.outcome=b,d.exitCode=b.outcome==="stood-down"?6:5,s&&Uo(s,n,d);return}if(h){d.exitCode=n.status==="refused"?x1(n):3;return}if(d.failed.length>0){d.exitCode=1;return}if(g.length>0){for(let w of g)u(w);d.exitCode=1;return}p||(await Nl(t,"after-apply",n.hooks?.["after-apply"],i,r,n.digest)).failed&&zo(t,`wave ${l} (${c.name}) applied, and then a hook after the apply failed`),s&&d.hooks.length>0&&Uo(s,n,d)}async function $1(e,t,n){if(!n.spend||n.status!=="approved"||n.spentAt||!n.approvedAt)return!0;let{spec:i,k:r,wave:o,cwd:s,log:a}=t,l=e.gates??ys({cwd:s}),c=e.now??new Date().toISOString(),u={version:1,kind:"applied",op:i.name,gate:n.gate,planDigest:n.digest,approvedAt:n.approvedAt,approvedBy:n.approvedBy??"",timestamp:c,wave:{number:r,name:o.name},...n.via==="pr-review"&&n.review?{review:{...n.review.pr!==void 0?{pr:n.review.pr}:{},...n.review.head?{head:n.review.head}:{}}}:{}};try{if(!l.appendApplied)throw new Error("this gate ledger cannot record an applied approval");let d=await l.appendApplied(u);!d.pushed&&d.pushWarning&&a(`wave ${r} (${o.name}): ${d.pushWarning}`)}catch(d){return zo(t,`wave ${r} (${o.name}) could not record that it applies under the approval by ${u.approvedBy}, so nothing applied: ${d instanceof Error?d.message:String(d)}`),!1}return n.spentAt=c,a(`wave ${r} (${o.name}) applies under the approval by ${u.approvedBy} at ${u.approvedAt}, which is now spent`),!0}async function $De(e,t){let n=await Promise.resolve().then(()=>(ng(),tg)),i=e.head??q$("git",["rev-parse","HEAD"],{cwd:t.cwd,encoding:"utf-8"}).trim(),r;try{r=await(e.reviews??n.reviewSourceFromEnv()).mergedReview(i)}catch(c){return{approved:!1,review:{reason:`the forge's review could not be read: ${c instanceof Error?c.message:String(c)}`}}}if(!r)return{approved:!1,review:{reason:`no merged pull request produced ${i.slice(0,12)}`}};let o=r.approvers.length===0?null:await(e.headPlans??((c,u)=>RDe(c,u,t.cwd)))(e.spec.name,r.head),{reviewApproval:s}=await Promise.resolve().then(()=>(DT(),TT)),a=s(r,o?.waves.find(c=>c.wave===t.k)?.digest,t.digest);if(!a.approved)return a;if(t.spent&&Lr(t.spent,{gate:t.gate,planDigest:t.digest,review:{head:r.head}}))return{approved:!1,review:{...a.review,reason:`a wave already applied ${t.digest} under the review of #${r.pr} at ${r.head.slice(0,12)}, so the review is spent`}};let l=`approved by the review of #${r.pr} at ${r.head.slice(0,12)}: ${r.approvers.join(", ")}`;return await t.port.appendResolution?.({op:t.op,gate:t.gate,resolvedBy:r.approvers[0],timestamp:t.now,planDigest:t.digest,approver:{kind:"human"},note:l,...r.url?{url:r.url}:{},review:{pr:r.pr,head:r.head,approvers:r.approvers}}),a}async function RDe(e,t,n){let{gitLedgerReadPort:i,requireLifecycleLedger:r}=await Promise.resolve().then(()=>($t(),z0)),{readHeadPlans:o}=await Promise.resolve().then(()=>(PT(),n4));return await r({cwd:n}),o(i({cwd:n}),e,t)}async function RM(e){let{spec:t}=e;Km(t);let n=e.cwd??process.cwd(),i=e.exec??kte,r=await Promise.resolve().then(()=>(ng(),tg)),o=e.head??r.pullRequestHeadFromEnv()??q$("git",["rev-parse","HEAD"],{cwd:n,encoding:"utf-8"}).trim(),s={version:1,name:t.name,head:o,timestamp:e.now??new Date().toISOString(),waves:[]},a=t.waves[t.waves.length-1];for(let l=1;;l++){let c=t.waves[l-1]??a,{members:u,extras:d,waves:p}=b1({spec:t,k:l,wave:c,cwd:n,exec:i},c.runs,c.discover===!0);if(s.waves.push({wave:l,name:c.name,digest:kM(t,u,d)}),l>=t.waves.length&&!(a.rest&&p!==void 0&&l<p))break}return await(e.write??(l=>SDe(l,n)))(s),s}async function SDe(e,t){let{pushLifecycle:n,requireLifecycleLedger:i,writeBlobToPath:r}=await Promise.resolve().then(()=>($t(),z0)),{headPlansPath:o}=await Promise.resolve().then(()=>(ng(),tg));await i({cwd:t});let{dir:s,file:a}=o(e.name,e.head);if(await r(s,a,JSON.stringify(e,null,2)+`
310
+ `,`Op waves plans of ${e.name} at ${e.head.slice(0,12)}`,{cwd:t}),!await n({cwd:t}))throw new Error("the plans were recorded locally only: chant/lifecycle has no remote to push to")}var lDe,bM,kte,uDe,gte,gDe,Ste,hte,$M,SM=v(()=>{"use strict";j6();Fi();Wc();Md();lDe=["version","kind","op","gate","timestamp","expiresAt","planDigest","runId","url","resume","environment","origin","neverOverMcp","approval","approvalMode","answer","wave","heldBy"],bM=["stood-down","held","replan"],kte=(e,t,n)=>{let i=aDe(e[0],e.slice(1),{cwd:t,stdio:"inherit",...n?{env:{...process.env,...n}}:{}});if(i.error)throw i.error;return i.status??1},uDe=(e,t,n)=>{let i;try{i=q$("git",["rev-parse","--verify",`${e}^{commit}`],{cwd:n,encoding:"utf-8",stdio:["ignore","pipe","pipe"]}).trim()}catch{throw new Error(`the gate policy is read at ${e}, which this checkout does not have. Check out the full history (fetch-depth: 0 on GitHub and Forgejo, GIT_DEPTH: "0" on GitLab), or set the spec's base.`)}try{let r=q$("git",["show",`${i}:./${t}`],{cwd:n,encoding:"utf-8",stdio:["ignore","pipe","pipe"]});return{sha:i,text:r}}catch{return{sha:i,text:null}}};gte=()=>Object.fromEntries(Zv.map(e=>[e,[]]));gDe=e=>({name:e.spec.name,op:e.spec.op,waveName:e.wave.name,k:e.k,cwd:e.cwd,exec:e.exec,log:e.log}),Ste=(e,t,n,i)=>n.map(r=>({target:r.target,op:r.op??e.op,...i?.has(r.target)?{plan:Y$(e,t,r.target)}:{}}));hte=10;$M=10});var Dte=v(()=>{"use strict";On()});var R1,Nte=v(()=>{"use strict";Dte();R1=/^pr-\d+(?:-[a-z0-9][a-z0-9-]*)?$/});async function jte(e){let{resolutions:t,pending:n}=await jr(In,e),i=await nn(ADe,PDe,e);return{resolutions:t,pending:n,applied:i?_T(i):[]}}var ADe,PDe,Lte=v(()=>{"use strict";Wt();ji();$t();rg();ADe=`_gates/${In}`,PDe="applied.jsonl"});var Fte={};_e(Fte,{runOverrideApprove:()=>ODe});async function ODe(e){let t=e.args.extraPositional,n=nk(t,e.args.rules?.length?e.args.rules:["<id>"]);if(e.args.reason!==void 0&&e.args.note!==void 0&&e.args.reason.trim()!==e.args.note.trim())return console.error(fe({message:"Give the override's reason once: --reason <text> (--note is the same field)",hint:n})),1;let i=(e.args.reason??e.args.note)?.trim(),r=_a(e.args.rules??[]);if(r.length===0)return console.error(fe({message:"An override names each rule it overrides with --rule <id>",hint:n})),1;if(!i)return console.error(fe({message:"An override needs --reason <text>: why this plan goes out although the policy denies it",hint:n})),1;if(e.args.agent||Yr(es()))return console.error(fe({message:"An override is a person's: it is never recorded by an agent or over MCP or ACP",hint:`${n}, at a shell.`})),1;try{await oi()}catch(d){return console.error(fe({message:`Cannot record the override: ${d instanceof Error?d.message:String(d)}`})),1}let o=await jte(),s=rk(o.pending),a=s.find(d=>d.gate===t);if(!a)return console.error(fe({message:`No denial of ${t} is recorded on ${In}`+(s.length?`; denied: ${s.map(d=>d.gate).join(", ")}`:""),hint:"A run records one when its policy denies the plan. An override answers that denial, for that plan."})),1;if(a.rules.join(`
311
+ `)!==r.join(`
312
+ `))return console.error(fe({message:`${t} was denied by ${a.rules.join(", ")||"no rule it named"}; an override names exactly those rules, and --rule gave ${r.join(", ")}`,hint:nk(t,a.rules)})),1;if(e.args.plan!==void 0&&!mt(e.args.plan,a.plan)&&!mt(e.args.plan,a.planDigest))return console.error(fe({message:`--plan ${e.args.plan} is not the plan denied for ${t}: the newest denial is of ${a.plan||a.planDigest}`,hint:"Run the plan again, or override the denial that stands."})),1;let l=await S1(In,t,{actor:e.args.approver??e.args.actor,note:i,url:e.args.url,plan:a.planDigest,allowSameOrigin:e.args.allowSameOrigin,...e.args.roles?{roles:e.args.roles}:{},...e.args.sign!==void 0?{sign:e.args.sign}:{},...e.args.relayedBy!==void 0?{relayedBy:e.args.relayedBy}:{}});if(!l.ok)return 1;if(console.error(ur(`This overrides the denial of ${t} by ${r.join(", ")} for the plan ${a.plan||a.planDigest}. The next run that plans it applies it once; a plan that moves, or rules that change, need their own override.`)),process.env.CHANT_OVERRIDERS_FROM?.trim())return 0;let u=CT(process.cwd(),"HEAD");return u.active?u.principals.map(Mte).includes(Mte(l.record.resolvedBy))||console.error(Hr({message:`${l.record.resolvedBy} is not in ${Fd} here (${u.principals.join(", ")||"nobody"}), so a run that reads it at base does not count this override`})):console.error(Hr({message:`This checkout has no ${Fd}: unless the run reads its overriders from elsewhere at base, no override counts (a tool that does sets CHANT_OVERRIDERS_FROM to say so)`})),0}var Mte,Bte=v(()=>{"use strict";kc();$t();Lte();On();rg();Kn();E1();Mte=e=>e.normalize("NFKC").trim().toLowerCase()});async function Wte(e){let{pushed:t,pushWarning:n}=await ha();return t?{pushed:t,suffix:""}:N0(n)?{pushed:t,suffix:` (${rd})`}:(console.error(Hr({message:`The push to the remote did not land: ${n??"no reason given"}`,hint:e})),{pushed:t,suffix:" (local only \u2014 the push did not land)"})}async function zte(e){let t=e.args.path,n=e.args.extraPositional;if(!t||t==="."||!n)return console.error(fe({message:"Usage: chant approve <op> <gate>"})),1;if(e.args.expire){try{await oi()}catch(a){return console.error(fe({message:`Cannot expire the gate: ${a instanceof Error?a.message:String(a)}`})),1}let r=new Date().toISOString(),o=Cn((await jr(t)).pending,n);if(!o||Wn(o,r))return console.error(Hr({message:`Gate "${n}" on "${t}" has no standing pending fact \u2014 nothing to expire`})),0;await pd({op:t,gate:n,timestamp:r,expiresAt:r,...o.description?{description:o.description}:{}});let s=await Wte(`The expiry is recorded locally on ${Gte}. Until it reaches the remote, a run in another checkout still sees the old pending fact.`);return console.error(Ip(`Gate "${n}" on "${t}" expired at ${r} \u2014 not approved`+s.suffix)),console.error(ur(t===Su?"The next `chant components fan-out` decides this gate from scratch and records a fresh pending fact.":R1.test(t)?"The next `chant components pr-apply` decides this gate from scratch and records a fresh pending fact.":t===Eu?`The next \`chant workspace upgrade ${n}\` decides this gate from scratch and records a fresh pending fact.`:`The next \`chant run ${t}\` decides this gate from scratch and records a fresh pending fact.`)),0}if(t===Xs){let{runOverrideApprove:r}=await Promise.resolve().then(()=>(Bte(),Fte));return r(e)}if(e.args.rules!==void 0||e.args.reason!==void 0)return console.error(fe({message:`--rule and --reason override a denied plan: chant approve ${Xs} <subject> --rule <id> --reason <text>`,hint:`To approve gate "${n}" on "${t}", put any prose in --note.`})),1;let i=await S1(t,n,{actor:e.args.approver??e.args.actor,note:e.args.note,url:e.args.url,plan:e.args.plan,...e.args.env!==void 0?{environment:e.args.env}:{},allowSameOrigin:e.args.allowSameOrigin,...e.args.roles?{roles:e.args.roles}:{},...e.args.agent?{agent:!0}:{},...e.args.sign!==void 0?{sign:e.args.sign}:{},...e.args.relayedBy!==void 0?{relayedBy:e.args.relayedBy}:{}});if(!i.ok)return 1;if(e.args.resumeRun||e.args.resume!==void 0){let{resumeAfterApproval:r}=await Promise.resolve().then(()=>(b$(),qL));return r(t,n,i.record.environment,i.pushed)}return console.error(ur("This records the resolution as a fact; it does not itself re-run anything. "+(t===Su?`Repeat the \`chant components fan-out\` command and it walks through gate "${n}".`:R1.test(t)?`The pull request's apply (\`chant components pr-apply\`) walks through gate "${n}" when it plans this same digest.`:t===Eu?`Repeat \`chant workspace upgrade ${n}\` with the same target, and it applies the patch this approval names.`:`Run \`chant run ${t}\` and it walks through gate "${n}".`))),0}async function S1(e,t,n){let{ops:i}=await ws();!i.has(e)&&e!==Su&&e!==Eu&&e!==Xs&&console.error(Hr({message:`Op "${e}" was not found among discovered *.op.ts declarations \u2014 recording the resolution anyway`}));try{await oi()}catch(F){return console.error(fe({message:`Cannot record the approval: ${F instanceof Error?F.message:String(F)}`,hint:"The pending fact this answers lives on that branch; appending without it would drop it."})),{ok:!1}}let r=n.url??os();if(r&&!ov(r))return console.error(fe({message:`--url must be an absolute http/https URL (got "${r}")`,hint:"Pass the PR/MR link, or omit --url and put prose in --note."})),{ok:!1};let o=await jr(e),s=F=>F.some(I=>I.gate===t&&I.environment!==void 0)&&n.environment!==void 0?F.filter(I=>I.environment===n.environment):F,a=Cn(s(o.pending),t),l=a?.environment,c;if(n.plan!==void 0){if(!J0(n.plan))return console.error(fe({message:`--plan must be a plan digest ("jcs1-sha256:" or "sha256:", then 64 hex characters), got "${n.plan}"`,hint:"Copy it from the gated run's `plan :` line, or from the pending-gate summary. It is not a plan file path."})),{ok:!1};c=n.plan}else{if(!a)return console.error(fe({message:n.environment!==void 0&&o.pending.some(F=>F.gate===t&&F.environment!==void 0)?`Gate "${t}" on "${e}" has no pending fact in environment "${n.environment}", so there is no plan to approve`:`Gate "${t}" on "${e}" has no pending fact, so there is no plan to approve`,hint:`Run \`chant run ${e}\` first \u2014 it plans, stops at the gate, and records the plan this approval would be for. To approve a plan you already have the digest for, pass \`--plan <digest>\`.`})),{ok:!1};c=a.planDigest}let u=n.origin??es(),d=await jr(e),p=Cn(s(d.pending),t);if(Yr(u)&&(p?.neverOverMcp||i.get(e)?.config.neverOverMcp))return console.error(fe({message:`Gate "${t}" on "${e}" is never resolved over ${u==="acp"?"ACP":"MCP"}`,hint:`Approvals belong to people: \`chant approve ${e} ${t}\` at a shell.`})),{ok:!1};if(p?.answer)return console.error(fe({message:`Gate "${t}" on "${e}" asks decision point ${p.answer.point}, so its answer passes the gate, not an approval`,hint:`Answer the question: \`chant workspace points answer ${p.answer.id} --answer <value> --by <name>\`, then run \`chant run ${e}\` again.`})),{ok:!1};let f=Xz(p?.origin,u);if(f&&!n.allowSameOrigin)return console.error(fe({message:`Gate "${t}" on "${e}" cannot be resolved from here: ${f}`,hint:`Approve it from a channel the run did not come from \u2014 \`chant approve ${e} ${t}\` at a shell is the usual one. If resolving from the same channel genuinely is the intent, pass --allow-same-origin, which records that it was deliberate.`})),{ok:!1};let g=n.relayedBy?.trim();if(n.relayedBy!==void 0&&(!g||/[\r\n]/.test(g)))return console.error(fe({message:`--relayed-by needs one principal on one line (got ${JSON.stringify(n.relayedBy)})`,hint:"Name who relayed the approval, such as --relayed-by github:<login> or a principal the signers file lists."})),{ok:!1};let h=n.actor??(Yr(u)?cw:process.env.GITHUB_ACTOR??process.env.GITLAB_USER_LOGIN??process.env.USER??"unknown"),b={kind:n.agent||Yr(u)?"agent":"human",...n.roles&&n.roles.length>0?{roles:[...new Set(n.roles)]}:{}},w=n.cwd??process.cwd(),x=await Promise.resolve().then(()=>(Qc(),lT)),{scopeSource:k}=await Promise.resolve().then(()=>(ms(),A6)),R=k(w);try{x.refuseUnidentified(R,[h],n.actor!==void 0?"--actor":"the approver"),g&&x.refuseUnidentified(R,[g],"--relayed-by")}catch(F){if(!(F instanceof x.IdentityError))throw F;return console.error(fe({message:`Gate "${t}" on "${e}" was not approved: ${F.message}`,hint:"Pass --actor <forge identity or signer>, as the surface that signed the person in maps them, for example --actor github:<login>."})),{ok:!1}}let $=x.gateAdmissionFrom(R,t);if($&&n.sign===void 0)return console.error(fe({message:`Gate "${t}" needs a signed approval: chant.workspace.json at base names it in identity.gates`+($.requirement.class!==null?`, from the class ${$.requirement.class}`:"")+", and this approval is not signed",hint:`chant approve ${e} ${t} --actor <principal> --sign [<key file>], with a key ${R.policy.signersPath} at base lists for that principal.`})),{ok:!1};let _=new Date().toISOString(),T;if(n.sign!==void 0){let{resolveSigningKey:F,sealGateApproval:Q,SealError:I}=await Promise.resolve().then(()=>(zd(),Wd));try{let B=F(n.sign,w);try{T=Q(B.file,{op:e,gate:t,...l!==void 0?{environment:l}:{},...c!==void 0?{planDigest:c}:{},resolvedBy:h,...g?{relayedBy:g}:{},timestamp:_})}finally{B.cleanup()}}catch(B){if(!(B instanceof I))throw B;return console.error(fe({message:`Gate "${t}" on "${e}" was not approved: ${B.message}`})),{ok:!1}}}if($){let F=$.refuses({op:e,gate:t,...l!==void 0?{environment:l}:{},...c!==void 0?{planDigest:c}:{},resolvedBy:h,...g?{relayedBy:g}:{},timestamp:_,seal:T});if(F!==null)return console.error(fe({message:`Gate "${t}" on "${e}" was not approved: ${F}`,hint:`identity.gates.${t} in chant.workspace.json at base counts only an approval signed by a key ${R.policy.signersPath} lists for the approver`+($.requirement.class!==null?`, who holds the role of the class ${$.requirement.class}`:"")+"."})),{ok:!1}}let C=p?.approval,K;if(C?.policy)try{let Q=await(n.evaluator??await Y0(C.policy.lexicon)).evaluateGatePolicy(C.policy,X0({op:e,gate:t,resolvedBy:h,approver:b,...c!==void 0?{planDigest:c}:{},...C.context?{context:C.context}:{}}));K={policy:C.policy.name,version:C.policy.version,mode:C.mode,contextDigest:$m(C.context),decision:Q.decision,determining:Q.determining,errors:Q.errors}}catch(F){return console.error(fe({message:`Gate "${t}" on "${e}" declares policy "${C.policy.name}", which could not be evaluated: ${F instanceof Error?F.message:String(F)}`,hint:`Install the ${C.policy.lexicon} lexicon in this project, or approve from a checkout that has it.`})),{ok:!1}}let{record:O}=await km({op:e,gate:t,resolvedBy:h,...g?{relayedBy:g}:{},timestamp:_,...T?{seal:T}:{},approver:b,...K?{policyDecision:K}:{},...n.note?{note:n.note}:{},...r?{url:r}:{},...c!==void 0?{planDigest:c}:{},...l!==void 0?{environment:l}:{},origin:u,...f&&n.allowSameOrigin?{sameOriginOverride:!0}:{}}),pe=await Wte(`The resolution is recorded locally on ${Gte}. Until it reaches the remote, a run in another checkout will not see it.`);if(console.error(Ip(`Gate "${t}" on "${e}" resolved by ${O.resolvedBy}`+(O.relayedBy?`, relayed by ${O.relayedBy},`:"")+` at ${O.timestamp}`+(O.url?` (${O.url})`:"")+(O.seal?`, signed with ${O.seal.key}`:"")+pe.suffix)),O.planDigest&&console.error(ur(`This approves the plan ${O.planDigest}`+(O.environment!==void 0?` in environment "${O.environment}"`:"")+", and only that plan. A run whose fresh plan differs refuses rather than applying it.")),C)for(let F of CDe(C,O,d.resolutions,p,d.pending))console.error(ur(F));return{ok:!0,record:O,pushed:pe.pushed}}function CDe(e,t,n,i,r=i?[i]:[]){let o=[],s=t.policyDecision;if(s){let p=s.determining.length>0?` (${s.determining.join(", ")})`:"",f=e.mode==="enforce"?s.decision==="allow"?"In enforce mode this permit passes the gate on its own.":"In enforce mode only a permit passes the gate on its own, so this approval counts only toward the quorum.":"The gate is in log-only mode, so the decision is recorded and does not change the outcome.";o.push(`Policy "${s.policy}" ${s.version}: ${s.decision}${p}. ${f}`);for(let g of s.errors)o.push(`Policy evaluation error: ${g}`)}let a=i?.timestamp??new Date(0).toISOString(),l=i&&mt(i.planDigest,t.planDigest)?tl(r,i):a,c=el([...n,t],t.gate,a,t.planDigest,e,l),u=e.quorum?.roles?` with role ${e.quorum.roles.join(" or ")}`:"",d=c.counted.map(p=>p.resolvedBy).join(", ")||"none yet";return o.push(`Quorum: ${c.counted.length} of ${c.need} human approval(s)${u} for this plan (${d}).`),c.counted.includes(t)||o.push(Hv(t).kind==="agent"?"An agent's approval does not count toward the quorum.":`This approval does not count toward the quorum: the approver claims none of its roles (${e.quorum?.roles?.join(", ")}).`),o}var Gte,E1=v(()=>{"use strict";Bi();kc();ji();On();Rm();Fi();Ai();Nte();$t();tv();Kn();Gte="chant/lifecycle"});eR();var Zte=new Set(["--help","--open","--version","--agents","--agent","--all-projects","--force","--fix","--watch","--verbose","--live","--overlay","--explain","--owned","--verbatim","--apply-rewrites","--write","--strict","--validate","--use-composites","--composites","--stacks","--components","--up","--down","--include-dependents","--local","--json","--progress-json","--update-snapshot","--update-baseline","--run-examples","--check","--bump","--no-release-record","--fold","--no-fold","--no-cache","--sandbox","--yes","--confirm-prod","--once","--expire","--check-live","--check-snapshot","--fail-on-drift","--durable-requests","--skip-mcp","--current","--uncommitted","--allow-code","--root-only","--generated","--decide","--record-plans"]);function P1(e){e=e.slice();let t={command:"",path:".",extraPositional:void 0,extraPositional2:void 0,output:void 0,format:"",force:void 0,fix:!1,lexicon:void 0,template:void 0,watch:!1,verbose:!1,help:!1,param:void 0,paramsFile:void 0,report:void 0,local:void 0,profile:void 0,json:void 0,live:!1,migrateFrom:void 0,migrateTo:void 0,emit:void 0,strict:!1,validate:!1,useComposites:!1,reportFile:void 0,skill:void 0,skipMcp:void 0,src:void 0,env:void 0};e=A1(e,Zte);let n=0;for(;n<e.length;){let i=e[n];if(i==="--help"||i==="-h")t.help=!0;else if(i==="--version"||i==="-V")t.version=!0;else if(i==="--output"||i==="-o")t.output=e[++n];else if(i==="--format"||i==="-f")t.format=e[++n];else if(i==="--lexicon"||i==="-d")t.lexicon=e[++n];else if(i==="--template"||i==="-t")t.template=e[++n];else if(i==="--force")t.force=!0;else if(i==="--fix")t.fix=!0;else if(i==="--watch"||i==="-w")t.watch=!0;else if(i==="--verbose"||i==="-v")t.verbose=!0;else if(i==="--profile"||i==="-p")t.profile=e[++n];else if(i==="--report"){let r=e[n+1];r&&!r.startsWith("-")?(t.reportFile=r,n++):t.report=!0}else if(i==="--live")t.live=!0;else if(i==="--overlay")t.overlay=!0;else if(i==="--between"){if(t.betweenA=e[++n],t.betweenB=e[++n],!t.betweenA||!t.betweenB)throw new Error("--between needs two snapshot refs: --between <refA> <refB>")}else if(i==="--traffic"){let r=e[++n];if(!r)throw new Error('--traffic needs a level, passed to the engine verbatim: --traffic "100 rps, p50"');t.traffic=r}else if(i==="--overlay-anchor"){let r=e[++n];if(r!=="source"&&r!=="live")throw new Error(`--overlay-anchor must be 'source' or 'live', got '${r}'`);t.overlayAnchor=r}else if(i==="--from")t.migrateFrom=e[++n];else if(i==="--kustomize")t.kustomize=e[++n];else if(i==="--parser-option"){let r=e[++n];if(!r||r.startsWith("-"))throw new Error("--parser-option needs key or key=value: --parser-option acceptLossyV1");(t.parserOption??=[]).push(r)}else if(i==="--type")t.selectType=e[++n];else if(i==="--name")t.selectName=e[++n];else if(i==="--owned")t.owned=!0;else if(i==="--namespace"){if(t.namespace=e[++n],!t.namespace||t.namespace.startsWith("-"))throw new Error("--namespace needs a namespace: --namespace <ns>")}else if(i==="--verbatim")t.verbatim=!0;else if(i==="--state")t.statePath=e[++n];else if(i==="--select")t.selectAddress=e[++n];else if(i==="--live-name")t.liveName=e[++n];else if(i==="--apply-rewrites")t.applyRewrites=!0;else if(i==="--stack")t.carveStack=e[++n];else if(i==="--write")t.write=!0;else if(i==="--write-source")t.writeSource=!0;else if(i==="--to")t.migrateTo=e[++n];else if(i==="--emit")t.emit=e[++n];else if(i==="--dry-run")t.dryRun=!0;else if(i==="--yes")t.yes=!0;else if(i==="--confirm-prod")t.confirmProd=!0;else if(i==="--strict")t.strict=!0;else if(i==="--validate")t.validate=!0;else if(i==="--use-composites")t.useComposites=!0;else if(i==="--skill")t.skill=e[++n];else if(i==="--skip-mcp")t.skipMcp=!0;else if(i==="--src")t.src=e[++n];else if(i==="--env")t.env=e[++n];else if(i==="--port"){let r=e[++n];if(!r||r.startsWith("-"))throw new Error("--port needs a port: --port <container-port>=<host-port>");(t.port??=[]).push(r)}else if(i==="--promote-to"){if(t.promoteTo=e[++n],!t.promoteTo||t.promoteTo.startsWith("-"))throw new Error("--promote-to needs an environment: --promote-to <env>")}else if(i==="--tier")t.tier=e[++n];else if(i==="--agents")t.agents=!0;else if(i==="--scope")t.scope=e[++n];else if(i==="--all-projects")t.allProjects=!0;else if(i==="--runtime")t.runtime=e[++n];else if(i==="--fail-on")t.failOn=e[++n];else if(i==="--max-files")t.maxFiles=Number(e[++n]);else if(i==="--theme")t.theme=e[++n];else if(i==="--stacks")t.stacks=!0;else if(i==="--components")t.components=!0;else if(i==="--generate")t.generate=e[++n];else if(i==="--spec")t.opsSpec=e[++n];else if(i==="--dump-outputs")t.dumpOutputs=e[++n];else if(i==="--digest-file")t.digestFile=e[++n];else if(i==="--seed-outputs")(t.seedOutputs??=[]).push(e[++n]);else if(i==="--detail")t.detail=Number(e[++n]);else if(i==="--lens")t.lens=e[++n];else if(i==="--explain")t.explain=!0;else if(i==="--show")t.show=e[++n];else if(i==="--up")t.up=!0;else if(i==="--down")t.down=!0;else if(i==="--node-sizes")t.nodeSizes=e[++n];else if(i==="--layout-engine")t.layoutEngine=e[++n];else if(i==="--base")t.base=e[++n];else if(i==="--head")t.head=e[++n];else if(i==="--include-dependents")t.includeDependents=!0;else if(i==="--from-affected")t.fromAffected=e[++n];else if(i==="--gate")t.gate=e[++n];else if(i==="--wave-gate"){if(t.waveGate=e[++n],!t.waveGate||t.waveGate.startsWith("-"))throw new Error("--wave-gate needs a gate name: --wave-gate <name>")}else if(i==="--wave"){let r=e[++n],o=Number(r);if(!Number.isInteger(o)||o<1)throw new Error(`--wave needs a wave number from 1: got "${r??""}"`);t.wave=o}else if(i==="--decide")t.decide=!0;else if(i==="--record-plans")t.recordPlans=!0;else if(i==="--share"){let r=e[++n],o=Number(r);if(!Number.isInteger(o)||o<1)throw new Error(`--share needs a share number from 1: got "${r??""}"`);t.share=o}else if(i==="--canary"){let r=e[++n];if(!r||r.startsWith("-"))throw new Error("--canary needs a component name: --canary <name>[,<name>...]");(t.canary??=[]).push(...r.split(",").map(o=>o.trim()).filter(Boolean))}else if(i==="--pr"){let r=e[++n],o=Number(r);if(!Number.isInteger(o)||o<1)throw new Error(`--pr needs a pull or merge request number: got "${r??""}"`);t.pr=o}else if(i==="--forge"){if(t.forge=e[++n],!t.forge||t.forge.startsWith("-"))throw new Error("--forge needs a forge: --forge github|gitlab|forgejo")}else if(i==="--require-review")t.requireReview=!0;else if(i==="--pr-loop")t.prLoop=!0;else if(i==="--resume"){let r=e[n+1];r===void 0||r.startsWith("-")?t.resumeRun=!0:t.resume=e[++n]}else if(i==="--local")t.local=!0;else if(i==="--json")t.json=!0;else if(i==="--progress-json")t.progressJson=!0;else if(i==="--gated-exit")t.gatedExit=Number(e[++n]);else if(i==="--durable-requests")t.durableRequests=!0;else if(i==="--update-snapshot")t.updateSnapshot=!0;else if(i==="--update-baseline")t.updateBaseline=!0;else if(i==="--deep")t.deep=!0;else if(i==="--at")t.at=e[++n];else if(i==="--kind"){if(t.kind=e[++n],!t.kind||t.kind.startsWith("-"))throw new Error("--kind needs a kind file: --kind <path>");(t.kinds??=[]).push(t.kind)}else if(i==="--composites")t.composites=!0;else if(i==="--intent"){let r=e[n+1];if(r!==void 0&&!r.startsWith("-"))t.intent=e[++n];else if(e.includes("--record"))t.intent="";else throw new Error("--intent needs a region: --intent <path[:start-end]|path#symbol>, or --intent --record <id>")}else if(i==="--follow-squash")t.followSquash=!0;else if(i==="--record"){if(t.record=e[++n],!t.record||t.record.startsWith("-"))throw new Error("--record needs a record id: --record <id>")}else if(i==="--path"){let r=e[++n];if(!r||r.startsWith("-"))throw new Error("--path needs a path: --path <path>");(t.paths??=[]).push(r)}else if(i==="--worktree")t.worktree=!0;else if(i==="--max-bytes"){let r=Number(e[++n]);if(!Number.isInteger(r)||r<1)throw new Error("--max-bytes needs a whole number of bytes above 0");t.maxBytes=r}else if(i==="--changes"){if(t.changes=e[++n],!t.changes||t.changes.startsWith("-"))throw new Error("--changes needs a range: --changes <base>..<head>")}else if(i==="--severity"){if(t.severity=e[++n],!t.severity||t.severity.startsWith("-"))throw new Error("--severity needs off, warn or fail")}else if(i==="--current")t.current=!0;else if(i==="--uncommitted")t.uncommitted=!0;else if(i==="--set"){if(t.set=e[++n],!t.set||t.set.startsWith("-")&&t.set!=="-")throw new Error("--set needs a JSON file, or - for standard input: --set <file|->")}else if(i==="--cover"){if(t.cover=e[++n],!t.cover||t.cover.startsWith("-"))throw new Error("--cover needs a PNG, JPEG or WebP file: --cover <image>")}else if(i==="--cover-path"){if(t.coverPath=e[++n],!t.coverPath||t.coverPath.startsWith("-"))throw new Error("--cover-path needs a path from the workspace root: --cover-path <path>")}else if(i==="--records")t.records=!0;else if(i==="--expect"){if(t.expect=e[++n],!t.expect||t.expect.startsWith("-"))throw new Error("--expect needs the record's digest, as records --json prints it: --expect <digest>")}else if(i==="--label"){if(t.label=e[++n],!t.label||t.label.startsWith("-"))throw new Error("--label needs the snapshot's name, such as a turn id: --label <text>")}else if(i==="--branch"){if(t.branch=e[++n],!t.branch||t.branch.startsWith("-"))throw new Error("--branch needs a branch name: --branch <branch>")}else if(i==="--workflow"){let r=e[++n];if(!r||r.startsWith("-"))throw new Error("--workflow needs a workflow's name: --workflow <name>");t.ciWorkflows=[...t.ciWorkflows??[],r]}else if(i==="--chant"){if(t.ciChant=e[++n],!t.ciChant||t.ciChant.startsWith("-"))throw new Error('--chant needs the command that runs chant, such as "npx tsx packages/core/src/cli/main.ts": --chant <command>')}else if(i==="--install"){if(t.ciInstall=e[++n],!t.ciInstall||t.ciInstall.startsWith("-"))throw new Error('--install needs the install command, such as "npm install": --install <command>')}else if(i==="--token-secret"){if(t.ciTokenSecret=e[++n],!t.ciTokenSecret||t.ciTokenSecret.startsWith("-"))throw new Error("--token-secret needs a repository secret's name, such as CI_GREEN_TOKEN: --token-secret <NAME>")}else if(i==="--app-id-var"){if(t.ciAppIdVar=e[++n],!t.ciAppIdVar||t.ciAppIdVar.startsWith("-"))throw new Error("--app-id-var needs the Actions variable holding the App's id: --app-id-var <VAR>")}else if(i==="--app-key-secret"){if(t.ciAppKeySecret=e[++n],!t.ciAppKeySecret||t.ciAppKeySecret.startsWith("-"))throw new Error("--app-key-secret needs the secret holding the App's private key: --app-key-secret <NAME>")}else if(i==="--verdict"){if(t.verdict=e[++n],!t.verdict||t.verdict.startsWith("-"))throw new Error("--verdict needs agree, dissent or abstain")}else if(i==="--by"){if(t.by=e[++n],!t.by||t.by.startsWith("-"))throw new Error("--by needs the reviewer: --by <principal>");(t.bys??=[]).push(t.by)}else if(i==="--open")t.open=!0;else if(i==="--inputs"){if(t.inputs=e[++n],!t.inputs||t.inputs.startsWith("-")&&t.inputs!=="-")throw new Error("--inputs needs a JSON file, - for standard input, or the JSON itself: --inputs <file|-|json>")}else if(i==="--candidates"){if(t.candidates=e[++n],!t.candidates||t.candidates.startsWith("-")&&t.candidates!=="-")throw new Error("--candidates needs a JSON file, - for standard input, or the JSON itself: --candidates <file|-|json>")}else if(i==="--response"){if(t.response=e[++n],!t.response||t.response.startsWith("-"))throw new Error("--response needs a JSON file: --response <file>")}else if(i==="--subject"){if(t.subject=e[++n],!t.subject||t.subject.startsWith("-"))throw new Error("--subject needs what the question is about, such as a work item id: --subject <id>")}else if(i==="--store"){let r=e[++n];if(r!=="tree"&&r!=="ledger")throw new Error("--store is tree (the answer kind's directory in the working tree) or ledger (chant/lifecycle): --store <tree|ledger>");t.store=r}else if(i==="--answer"){if(t.answer=e[++n],t.answer===void 0||t.answer==="")throw new Error("--answer needs one of the question's candidates: --answer <value>")}else if(i==="--sign"){let r=e[n+1];t.sign=r!==void 0&&!r.startsWith("-")?e[++n]:!0}else if(i==="--session"){if(t.session=e[++n],!t.session||t.session.startsWith("-"))throw new Error("--session needs a session id: --session <id>")}else if(i==="--prefix"){if(t.prefix=e[++n],!t.prefix||t.prefix.startsWith("-"))throw new Error("--prefix needs an id prefix: --prefix <prefix>")}else if(i==="--key"||i==="--check-id"||i==="--claim"||i==="--environment"||i==="--envelope"||i==="--threshold"){let r=e[++n];if(r===void 0||r.startsWith("-"))throw new Error(`${i} needs a value`);let o={"--key":"key","--check-id":"checkId","--claim":"claim","--environment":"environment","--envelope":"envelope","--threshold":"threshold"}[i];t[o]=r}else if(i==="--require"){if(t.require=e[++n],!t.require||t.require.startsWith("-"))throw new Error("--require needs a provenance level: --require attested")}else if(i==="--ambient")t.ambient=!0;else if(i==="--check-live")t.checkLive=!0;else if(i==="--check-snapshot")t.checkSnapshot=!0;else if(i==="--fail-on-drift")t.failOnDrift=!0;else if(i==="--run-examples")t.runExamples=!0;else if(i==="--pinned-digest")t.pinnedDigest=e[++n];else if(i==="--check")t.check=!0;else if(i==="--bump")t.bump=!0;else if(i==="--component")t.component=e[++n];else if(i==="--digest")t.digest=e[++n],t.digest!==void 0&&(t.digests??=[]).push(t.digest);else if(i==="--release-plan")t.releasePlanFile=e[++n];else if(i==="--git-sha")t.gitSha=e[++n];else if(i==="--run-id")t.runId=e[++n];else if(i==="--actor")t.actor=e[++n];else if(i==="--approver")t.approver=e[++n];else if(i==="--relayed-by"){if(t.relayedBy=e[++n],!t.relayedBy||t.relayedBy.startsWith("-"))throw new Error("--relayed-by needs the principal that relayed it: --relayed-by <principal>")}else if(i==="--on"){if(t.on=e[++n],!t.on||t.on.startsWith("-"))throw new Error("--on needs a runtime name: --on <lexicon>")}else if(i==="--compare-to")t.compareTo=e[++n];else if(i==="--no-release-record")t.noReleaseRecord=!0;else if(i==="--fold")t.fold=!0;else if(i==="--no-cache")t.noCache=!0;else if(i==="--no-fold")t.fold=!1;else if(i==="--sandbox")t.sandbox=!0;else if(i==="--fold-rank"){let r=e[n+1];r&&!r.startsWith("-")?(t.foldRankCollapsedFile=r,n++):t.foldRank=!0}else if(i==="--param")(t.param??=[]).push(e[++n]);else if(i==="--lexicon-output")(t.lexiconOutput??=[]).push(e[++n]);else if(i==="--params-file")t.paramsFile=e[++n];else if(i==="--projection")t.projection=e[++n];else if(i==="--interval")t.interval=e[++n];else if(i==="--lease-ttl")t.leaseTtl=e[++n];else if(i==="--steward"){let r=e[n+1];r!==void 0&&!r.startsWith("-")?(t.steward=r,n++):t.steward=""}else if(i==="--once")t.once=!0;else if(i==="--work"){let r=e[++n];if(!r||r.startsWith("-"))throw new Error("--work needs a work item id: --work <id>");t.work=r}else if(i==="--holder"||i==="--ttl"||i==="--token"||i==="--outcome"){let r=e[++n];if(!r||r.startsWith("-"))throw new Error(`${i} needs a value: ${i} <${i.slice(2)}>`);t[i.slice(2)]=r}else if(i==="--signer"){let r=e[++n];if(!r||r.startsWith("-"))throw new Error("--signer needs a principal: --signer <principal>");t.signer=r}else if(i==="--unit"||i==="--decision"){let r=e[++n];if(!r||r.startsWith("-"))throw new Error(`${i} needs an id: ${i} <id>`);t[i.slice(2)]=r}else if(i==="--note")t.note=e[++n];else if(i==="--reason"){if(t.reason=e[++n],t.reason===void 0||t.reason.startsWith("-"))throw new Error("--reason needs the text of the reason: --reason <text>")}else if(i==="--rule"){let r=e[++n];if(!r||r.startsWith("-"))throw new Error("--rule needs a rule id: --rule <id>");(t.rules??=[]).push(r)}else if(i==="--expire")t.expire=!0;else if(i==="--role"){let r=e[++n]??"";t.roles=[...t.roles??[],...r.split(",").map(o=>o.trim()).filter(Boolean)]}else if(i==="--agent")t.agent=!0;else if(i==="--allow-code")t.allowCode=!0;else if(i==="--source"){if(t.source=e[++n],!t.source||t.source.startsWith("-"))throw new Error("--source needs a template: --source <repo>[#<member>]")}else if(i==="--tags"){if(t.tags=e[++n],!t.tags||t.tags.startsWith("-"))throw new Error("--tags needs a tag glob: --tags 'v*'")}else if(i==="--index"){if(t.index=e[++n],!t.index||t.index.startsWith("-"))throw new Error("--index needs a hash index file: --index <file>")}else if(i==="--remove")t.remove=!0;else if(i==="--available")t.available=!0;else if(i==="--root-only")t.rootOnly=!0;else if(i==="--generated")t.generated=!0;else if(i==="--member"){let r=e[++n];if(!r||r.startsWith("-"))throw new Error("--member needs a member or group name: --member <name>");t.members=[...t.members??[],...r.split(",").map(o=>o.trim()).filter(Boolean)]}else if(i==="--allow-same-origin")t.allowSameOrigin=!0;else if(i==="--plan")t.plan=e[++n];else if(i==="--url")t.url=e[++n];else if(i==="--op")t.op=e[++n];else if(i==="--since")t.since=e[++n];else if(i==="--limit")t.limit=Number(e[++n]);else{if(i.startsWith("--"))throw new Error(`Unknown flag: ${i}
313
+ Run "chant --help" to see supported flags.`);i.startsWith("-")||(t.command&&(t.positionals??=[]).push(i),t.command?t.path==="."?t.path=i:t.extraPositional?t.extraPositional2=i:t.extraPositional=i:t.command=i)}n++}if(t.promoteTo&&!(t.command==="build"&&t.components&&t.generate))throw new Error("--promote-to needs build --components --generate <lexicon>: it adds a promote job to the generated CI pipeline, and only generate mode emits one.");return t}var Yte={lc:"lifecycle"};function O1(e,t){let n=Yte[e.command]??e.command,i=`${n} ${e.path}`,r=t.find(s=>s.name===i);if(r)return{def:r,compound:!0};let o=t.find(s=>s.name===n);return o?{def:o,compound:!1}:null}Kn();function C1(e){return new Promise(t=>{let n=()=>{if(e.writableLength===0||e.writableEnded||e.destroyed){r(),t();return}e.once("drain",n)},i=()=>{r(),t()},r=()=>{e.off("drain",n),e.off("error",i),e.off("close",i)};e.once("error",i),e.once("close",i),n()})}async function tR(e){await C1(process.stdout),await C1(process.stderr),process.exit(e)}Yh();import{realpathSync as _1}from"node:fs";import{fileURLToPath as Qte}from"node:url";function I1(e,t){if(!e)return!1;try{return _1(e)===_1(Qte(t))}catch{return!1}}bu();to();JO();SM();Kn();import{readFileSync as _te}from"node:fs";import{relative as EDe,resolve as Ite}from"node:path";async function Tte(e){let{args:t}=e,n=t.opsSpec;if(n&&t.recordPlans)try{let o=Oh(_te(Ite(n),"utf-8"),`--spec ${n}`),s=await RM({spec:o});if(t.json)console.log(JSON.stringify(s,null,2));else for(let a of s.waves)console.error(`wave ${a.wave} (${a.name}) at ${s.head.slice(0,12)}: ${a.digest}`);return 0}catch(o){return console.error(fe({message:o instanceof Error?o.message:String(o)})),1}if(!n||t.wave===void 0)return console.error(fe({message:"`chant run wave` needs --spec <file> and --wave <k>",hint:"Run it as a generated Op waves pipeline does: chant run wave --spec <file> --wave <k> [--decide | --share <i>]"})),1;if(t.decide&&t.share!==void 0)return console.error(fe({message:"--decide and --share are two different jobs; pass one"})),1;let i,r=t.share!==void 0?{share:t.share}:{};try{let o=Ite(n);i=Oh(_te(o,"utf-8"),`--spec ${n}`);let s=await xM({spec:i,specFile:EDe(process.cwd(),o),wave:t.wave,...t.decide?{decide:!0}:{},...t.share!==void 0?{share:t.share}:{},...t.base?{base:t.base}:{}});return t.json&&console.log(JSON.stringify(s,null,2)),await aw(i,t.wave,{result:s},r),s.exitCode}catch(o){let s=o instanceof Error?o.message:String(o);return console.error(fe({message:s})),i&&await aw(i,t.wave,{error:s},r),1}}b$();E1();Eh();var _De=[{name:"run wave",handler:Tte},{name:"run resume",handler:VL},{name:"approve",handler:zte},{name:"workspace points",handler:ZL}],IDe=`
314
+ chant runtime ${Tp} - the wave-job commands of chant, in one file
315
+
316
+ Usage: node wave-runtime.mjs <command> [options]
317
+
318
+ Commands:
319
+ run wave --spec <file> --wave <k> Plan, gate and apply wave k of an Op waves spec
320
+ (--decide, --share <i>, --record-plans, --base <ref>, --json)
321
+ run resume Start the CI jobs that wait at gates whose approval arrived
322
+ (--gate <op>/<gate>, --dry-run, --json)
323
+ approve <op> <gate> Record a gate's resolution on the lifecycle ledger
324
+ (--actor, --plan, --note, --url, --sign, --expire, --resume, ...)
325
+ workspace points <verb> Ask, answer and list decision points
326
+
327
+ Flags, output, exit codes and ledger formats are the full chant CLI's;
328
+ see "chant --help" in @intentius/chant for every flag. This runtime does
329
+ not evaluate chant.config.ts, so --env is not checked against the
330
+ declared environments.
331
+ `;async function TDe(e){let t;try{t=P1(e)}catch(i){return console.error(fe({message:i instanceof Error?i.message:String(i)})),1}let n=O1(t,_De);if(t.version&&(!t.command||n))return console.log(Tp),0;if(t.help||!t.command)return console.log(IDe),t.help?0:1;if(!n){let i=t.path&&t.path!=="."?`${t.command} ${t.path}`:t.command;return console.error(fe({message:`"${i}" is not part of chant's wave-job runtime`,hint:"It runs run wave, run resume, approve and workspace points. Every other command needs the full @intentius/chant CLI."})),1}return t.env&&(process.env[yu]=t.env),UO(),n.def.handler({args:t,plugins:[],serializers:[]})}I1(process.argv[1],import.meta.url)&&TDe(process.argv.slice(2)).then(tR,async e=>{(process.argv.includes("--verbose")||process.argv.includes("-v"))&&e instanceof Error&&e.stack?console.error(e.stack):console.error(fe({message:e instanceof Error?e.message:String(e)})),await tR(1)});export{_De as RUNTIME_COMMANDS,TDe as runRuntime};