@intentius/chant 0.124.57 → 0.124.58

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 (121) hide show
  1. package/dist/ci-product-words.d.ts +47 -2
  2. package/dist/ci-product-words.d.ts.map +1 -1
  3. package/dist/ci-product-words.js +59 -1
  4. package/dist/ci-product.d.ts +26 -2
  5. package/dist/ci-product.d.ts.map +1 -1
  6. package/dist/ci-product.js +26 -2
  7. package/dist/cli/commands/init.d.ts +2 -0
  8. package/dist/cli/commands/init.d.ts.map +1 -1
  9. package/dist/cli/commands/init.js +1 -1
  10. package/dist/cli/handlers/build.d.ts.map +1 -1
  11. package/dist/cli/handlers/build.js +5 -1
  12. package/dist/cli/handlers/init.d.ts.map +1 -1
  13. package/dist/cli/handlers/init.js +16 -0
  14. package/dist/cli/handlers/serve.d.ts.map +1 -1
  15. package/dist/cli/handlers/serve.js +9 -0
  16. package/dist/cli/main.d.ts.map +1 -1
  17. package/dist/cli/main.js +6 -2
  18. package/dist/cli/mcp/product-tools.d.ts +40 -7
  19. package/dist/cli/mcp/product-tools.d.ts.map +1 -1
  20. package/dist/cli/mcp/product-tools.js +59 -15
  21. package/dist/cli/mcp/read-only.d.ts +2 -1
  22. package/dist/cli/mcp/read-only.d.ts.map +1 -1
  23. package/dist/cli/mcp/read-only.js +2 -1
  24. package/dist/cli/mcp/server.d.ts +11 -0
  25. package/dist/cli/mcp/server.d.ts.map +1 -1
  26. package/dist/cli/mcp/server.js +15 -3
  27. package/dist/cli/mcp-config.d.ts +4 -1
  28. package/dist/cli/mcp-config.d.ts.map +1 -1
  29. package/dist/cli/mcp-config.js +6 -2
  30. package/dist/cli/parse-args.d.ts.map +1 -1
  31. package/dist/cli/parse-args.js +9 -0
  32. package/dist/cli/registry.d.ts +8 -0
  33. package/dist/cli/registry.d.ts.map +1 -1
  34. package/dist/components/pr-pipeline.d.ts +56 -0
  35. package/dist/components/pr-pipeline.d.ts.map +1 -1
  36. package/dist/components/pr-pipeline.js +55 -2
  37. package/dist/components/product-pipeline.d.ts +18 -1
  38. package/dist/components/product-pipeline.d.ts.map +1 -1
  39. package/dist/components/product-pipeline.js +8 -2
  40. package/dist/e2e-harness/driver.d.ts.map +1 -1
  41. package/dist/e2e-harness/driver.js +97 -0
  42. package/dist/e2e-harness/forgejo.d.ts +5 -1
  43. package/dist/e2e-harness/forgejo.d.ts.map +1 -1
  44. package/dist/e2e-harness/forgejo.js +35 -0
  45. package/dist/e2e-harness/index.d.ts +7 -0
  46. package/dist/e2e-harness/index.d.ts.map +1 -1
  47. package/dist/e2e-harness/index.js +11 -1
  48. package/dist/e2e-harness/ports.d.ts +31 -0
  49. package/dist/e2e-harness/ports.d.ts.map +1 -1
  50. package/dist/e2e-harness/scenario.d.ts.map +1 -1
  51. package/dist/e2e-harness/scenario.js +9 -5
  52. package/dist/e2e-harness/schemas/e2e-scenario.schema.json +43 -3
  53. package/dist/e2e-harness/schemas/index.d.ts +22 -1
  54. package/dist/e2e-harness/schemas/index.d.ts.map +1 -1
  55. package/dist/e2e-harness/schemas/index.js +1 -1
  56. package/dist/e2e-harness/steps.d.ts.map +1 -1
  57. package/dist/e2e-harness/steps.js +4 -0
  58. package/dist/mcp/types.d.ts +9 -0
  59. package/dist/mcp/types.d.ts.map +1 -1
  60. package/dist/release-floors.d.ts +1 -1
  61. package/dist/release-floors.js +1 -1
  62. package/dist/template-request/index.d.ts +9 -0
  63. package/dist/template-request/index.d.ts.map +1 -0
  64. package/dist/template-request/index.js +8 -0
  65. package/dist/template-request/request-body.d.ts +21 -0
  66. package/dist/template-request/request-body.d.ts.map +1 -0
  67. package/dist/template-request/request-body.js +86 -0
  68. package/dist/template-request/template-request.d.ts +100 -0
  69. package/dist/template-request/template-request.d.ts.map +1 -0
  70. package/dist/template-request/template-request.js +150 -0
  71. package/dist/template-request/template-request.schema.json +100 -0
  72. package/dist/template-request/template-spec.d.ts +83 -0
  73. package/dist/template-request/template-spec.d.ts.map +1 -0
  74. package/dist/template-request/template-spec.js +146 -0
  75. package/dist/template-request/template.schema.json +114 -0
  76. package/dist/template-request/validate.d.ts +4 -0
  77. package/dist/template-request/validate.d.ts.map +1 -0
  78. package/dist/template-request/validate.js +21 -0
  79. package/dist/wave-runtime.mjs +4 -4
  80. package/package.json +8 -1
  81. package/src/ci-product-words.test.ts +23 -0
  82. package/src/ci-product-words.ts +68 -3
  83. package/src/ci-product.ts +32 -1
  84. package/src/cli/commands/init.ts +3 -1
  85. package/src/cli/handlers/build.ts +5 -1
  86. package/src/cli/handlers/init.ts +18 -0
  87. package/src/cli/handlers/serve.ts +9 -0
  88. package/src/cli/main.ts +6 -2
  89. package/src/cli/mcp/product-tools.test.ts +57 -1
  90. package/src/cli/mcp/product-tools.ts +67 -15
  91. package/src/cli/mcp/read-only.ts +2 -1
  92. package/src/cli/mcp/server.ts +20 -5
  93. package/src/cli/mcp-config.test.ts +52 -2
  94. package/src/cli/mcp-config.ts +6 -3
  95. package/src/cli/parse-args.ts +7 -0
  96. package/src/cli/registry.ts +8 -0
  97. package/src/components/pr-pipeline.ts +87 -2
  98. package/src/components/product-actions.test.ts +76 -0
  99. package/src/components/product-pipeline.ts +21 -2
  100. package/src/e2e-harness/driver.test.ts +163 -0
  101. package/src/e2e-harness/driver.ts +86 -1
  102. package/src/e2e-harness/forgejo.ts +42 -1
  103. package/src/e2e-harness/index.ts +12 -1
  104. package/src/e2e-harness/ports.ts +33 -0
  105. package/src/e2e-harness/scenario.ts +8 -6
  106. package/src/e2e-harness/schemas/README.md +11 -2
  107. package/src/e2e-harness/schemas/e2e-scenario.schema.json +43 -3
  108. package/src/e2e-harness/schemas/index.ts +5 -1
  109. package/src/e2e-harness/schemas.test.ts +44 -1
  110. package/src/e2e-harness/steps.ts +4 -0
  111. package/src/mcp/types.ts +9 -0
  112. package/src/release-floors.ts +1 -1
  113. package/src/template-request/__fixtures__/request-body.md +41 -0
  114. package/src/template-request/index.ts +8 -0
  115. package/src/template-request/request-body.ts +91 -0
  116. package/src/template-request/template-request.schema.json +100 -0
  117. package/src/template-request/template-request.test.ts +316 -0
  118. package/src/template-request/template-request.ts +235 -0
  119. package/src/template-request/template-spec.ts +176 -0
  120. package/src/template-request/template.schema.json +114 -0
  121. package/src/template-request/validate.ts +28 -0
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
- // @intentius/chant 0.124.57 wave-job runtime (#3896): run wave, run resume, approve, workspace points.
2
+ // @intentius/chant 0.124.58 wave-job runtime (#3896): run wave, run resume, approve, workspace points.
3
3
  import { createRequire as __chantCreateRequire } from "node:module";
4
4
  const require = __chantCreateRequire(import.meta.url);
5
5
  var oRe=Object.create;var i0=Object.defineProperty;var iRe=Object.getOwnPropertyDescriptor;var sRe=Object.getOwnPropertyNames;var aRe=Object.getPrototypeOf,cRe=Object.prototype.hasOwnProperty;var x=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(r){throw n=[r],r}};var he=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(n){throw t=0,n}},xe=(e,t)=>{for(var n in t)i0(e,n,{get:t[n],enumerable:!0})},lRe=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of sRe(t))!cRe.call(e,o)&&o!==n&&i0(e,o,{get:()=>t[o],enumerable:!(r=iRe(t,o))||r.enumerable});return e};var tt=(e,t,n)=>(n=e!=null?oRe(aRe(e)):{},lRe(t||!e||!e.__esModule?i0(n,"default",{value:e,enumerable:!0}):n,e));function a0(e,t=new Set){let n=[];for(let r of e)if(r.startsWith("--")&&r.includes("=")){let o=r.indexOf("="),i=r.slice(0,o),s=r.slice(o+1);if(t.has(i))throw new Error(`${r} \u2014 ${i} is a boolean flag and does not take a value. Pass ${i} on its own.`);n.push(i,s)}else n.push(r);return n}var s0,c0=x(()=>{"use strict";s0=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 dRe(){return!process.env.NO_COLOR&&process.stdout.isTTY!==!1}function yc(e,t){return dRe()?`${t}${e}${da.reset}`:e}function $e(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(yc(n,da.cyan)),t.push(" - ")}return t.push(yc("error",da.red)),t.push(": "),t.push(e.message),e.hint&&(t.push(`
6
6
  `),t.push(yc(e.hint,da.gray))),t.join("")}function cr(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(yc(n,da.cyan)),t.push(" - ")}return t.push(yc("warning",da.yellow)),t.push(": "),t.push(e.message),e.hint&&(t.push(`
7
- `),t.push(yc(e.hint,da.gray))),t.join("")}function Qg(e){return yc(e,da.green)}function Kn(e){return yc(e,da.gray)}var da,Jn=x(()=>{"use strict";da={red:"\x1B[31m",yellow:"\x1B[33m",green:"\x1B[32m",cyan:"\x1B[36m",gray:"\x1B[90m",reset:"\x1B[0m",bold:"\x1B[1m"}});var mR,u0=x(()=>{"use strict";mR="0.124.57"});function z(e,t,n){function r(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:s,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);let l=s.prototype,u=Object.keys(l);for(let d=0;d<u.length;d++){let p=u[d];p in a||(a[p]=l[p].bind(a))}}let o=n?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function s(a){var c;let l=n?.Parent?new i:this;r(l,a),(c=l._zod).deferred??(c.deferred=[]);for(let u of l._zod.deferred)u();return l}return Object.defineProperty(s,"init",{value:r}),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 Rn(e){return e&&Object.assign(Xg,e),Xg}var d0,gR,Li,wc,Xg,up=x(()=>{d0=Object.freeze({status:"aborted"});gR=Symbol("zod_brand"),Li=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},wc=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}},Xg={}});var Re={};xe(Re,{BIGINT_FORMAT_RANGES:()=>k0,Class:()=>f0,NUMBER_FORMAT_RANGES:()=>v0,aborted:()=>Rc,allowsEval:()=>h0,assert:()=>yRe,assertEqual:()=>fRe,assertIs:()=>gRe,assertNever:()=>hRe,assertNotEqual:()=>mRe,assignProp:()=>vc,base64ToUint8Array:()=>n6,base64urlToUint8Array:()=>DRe,cached:()=>pp,captureStackTrace:()=>yR,cleanEnum:()=>TRe,cleanRegex:()=>nh,clone:()=>jr,cloneDef:()=>bRe,createTransparentProxy:()=>SRe,defineLazy:()=>mt,esc:()=>hR,escapeRegex:()=>Jo,extend:()=>PRe,finalizeIssue:()=>oo,floatSafeRemainder:()=>m0,getElementAtPath:()=>vRe,getEnumValues:()=>th,getLengthableOrigin:()=>ih,getParsedType:()=>$Re,getSizableOrigin:()=>oh,hexToUint8Array:()=>NRe,isObject:()=>fu,isPlainObject:()=>kc,issue:()=>fp,joinValues:()=>ne,jsonStringifyReplacer:()=>dp,merge:()=>ARe,mergeDefs:()=>pa,normalizeParams:()=>Se,nullish:()=>bc,numKeys:()=>xRe,objectClone:()=>wRe,omit:()=>ORe,optionalKeys:()=>b0,parsedType:()=>ke,partial:()=>_Re,pick:()=>ERe,prefixIssues:()=>Po,primitiveTypes:()=>w0,promiseAllObject:()=>kRe,propertyKeyTypes:()=>rh,randomString:()=>RRe,required:()=>IRe,safeExtend:()=>CRe,shallowClone:()=>y0,slugify:()=>g0,stringifyPrimitive:()=>we,uint8ArrayToBase64:()=>r6,uint8ArrayToBase64url:()=>jRe,uint8ArrayToHex:()=>LRe,unwrapMessage:()=>eh});function fRe(e){return e}function mRe(e){return e}function gRe(e){}function hRe(e){throw new Error("Unexpected value in exhaustive check")}function yRe(e){}function th(e){let t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function ne(e,t="|"){return e.map(n=>we(n)).join(t)}function dp(e,t){return typeof t=="bigint"?t.toString():t}function pp(e){return{get value(){{let n=e();return Object.defineProperty(this,"value",{value:n}),n}throw new Error("cached value already set")}}}function bc(e){return e==null}function nh(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function m0(e,t){let n=(e.toString().split(".")[1]||"").length,r=t.toString(),o=(r.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(r)){let c=r.match(/\d?e-(\d?)/);c?.[1]&&(o=Number.parseInt(c[1]))}let i=n>o?n:o,s=Number.parseInt(e.toFixed(i).replace(".","")),a=Number.parseInt(t.toFixed(i).replace(".",""));return s%a/10**i}function mt(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==t6)return r===void 0&&(r=t6,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function wRe(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function vc(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function pa(...e){let t={};for(let n of e){let r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function bRe(e){return pa(e._zod.def)}function vRe(e,t){return t?t.reduce((n,r)=>n?.[r],e):e}function kRe(e){let t=Object.keys(e),n=t.map(r=>e[r]);return Promise.all(n).then(r=>{let o={};for(let i=0;i<t.length;i++)o[t[i]]=r[i];return o})}function RRe(e=10){let t="abcdefghijklmnopqrstuvwxyz",n="";for(let r=0;r<e;r++)n+=t[Math.floor(Math.random()*t.length)];return n}function hR(e){return JSON.stringify(e)}function g0(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function fu(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function kc(e){if(fu(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let n=t.prototype;return!(fu(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function y0(e){return kc(e)?{...e}:Array.isArray(e)?[...e]:e}function xRe(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function Jo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function jr(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function Se(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 SRe(e){let t;return new Proxy({},{get(n,r,o){return t??(t=e()),Reflect.get(t,r,o)},set(n,r,o,i){return t??(t=e()),Reflect.set(t,r,o,i)},has(n,r){return t??(t=e()),Reflect.has(t,r)},deleteProperty(n,r){return t??(t=e()),Reflect.deleteProperty(t,r)},ownKeys(n){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,r){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,r)},defineProperty(n,r,o){return t??(t=e()),Reflect.defineProperty(t,r,o)}})}function we(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function b0(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function ERe(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let i=pa(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 vc(this,"shape",s),s},checks:[]});return jr(e,i)}function ORe(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let i=pa(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 vc(this,"shape",s),s},checks:[]});return jr(e,i)}function PRe(e,t){if(!kc(t))throw new Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let i=e._zod.def.shape;for(let s in t)if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let o=pa(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return vc(this,"shape",i),i}});return jr(e,o)}function CRe(e,t){if(!kc(t))throw new Error("Invalid input to safeExtend: expected a plain object");let n=pa(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t};return vc(this,"shape",r),r}});return jr(e,n)}function ARe(e,t){let n=pa(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return vc(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return jr(e,n)}function _Re(e,t,n){let o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let s=pa(t._zod.def,{get shape(){let a=t._zod.def.shape,c={...a};if(n)for(let l in n){if(!(l in a))throw new Error(`Unrecognized key: "${l}"`);n[l]&&(c[l]=e?new e({type:"optional",innerType:a[l]}):a[l])}else for(let l in a)c[l]=e?new e({type:"optional",innerType:a[l]}):a[l];return vc(this,"shape",c),c},checks:[]});return jr(t,s)}function IRe(e,t,n){let r=pa(t._zod.def,{get shape(){let o=t._zod.def.shape,i={...o};if(n)for(let s in n){if(!(s in i))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(i[s]=new e({type:"nonoptional",innerType:o[s]}))}else for(let s in o)i[s]=new e({type:"nonoptional",innerType:o[s]});return vc(this,"shape",i),i}});return jr(t,r)}function Rc(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 Po(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function eh(e){return typeof e=="string"?e:e?.message}function oo(e,t,n){let r={...e,path:e.path??[]};if(!e.message){let o=eh(e.inst?._zod.def?.error?.(e))??eh(t?.error?.(e))??eh(n.customError?.(e))??eh(n.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function oh(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function ih(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ke(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 fp(...e){let[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function TRe(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function n6(e){let t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}function r6(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function DRe(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return n6(t+n)}function jRe(e){return r6(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function NRe(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 r=0;r<t.length;r+=2)n[r/2]=Number.parseInt(t.slice(r,r+2),16);return n}function LRe(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var t6,yR,h0,$Re,rh,w0,v0,k0,f0,He=x(()=>{t6=Symbol("evaluating");yR="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};h0=pp(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});$Re=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}`)}},rh=new Set(["string","number","symbol"]),w0=new Set(["string","number","bigint","boolean","symbol","undefined"]);v0={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]},k0={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};f0=class{constructor(...t){}}});function ah(e,t=n=>n.message){let n={},r=[];for(let o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function ch(e,t=n=>n.message){let n={_errors:[]},r=o=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(s=>r({issues:s}));else if(i.code==="invalid_key")r({issues:i.issues});else if(i.code==="invalid_element")r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let s=n,a=0;for(;a<i.path.length;){let c=i.path[a];a===i.path.length-1?(s[c]=s[c]||{_errors:[]},s[c]._errors.push(t(i))):s[c]=s[c]||{_errors:[]},s=s[c],a++}}};return r(e),n}function R0(e,t=n=>n.message){let n={errors:[]},r=(o,i=[])=>{var s,a;for(let c of o.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(l=>r({issues:l},c.path));else if(c.code==="invalid_key")r({issues:c.issues},c.path);else if(c.code==="invalid_element")r({issues:c.issues},c.path);else{let l=[...i,...c.path];if(l.length===0){n.errors.push(t(c));continue}let u=n,d=0;for(;d<l.length;){let p=l[d],f=d===l.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(c)),d++}}};return r(e),n}function i6(e){let t=[],n=e.map(r=>typeof r=="object"?r.key:r);for(let r of n)typeof r=="number"?t.push(`[${r}]`):typeof r=="symbol"?t.push(`[${JSON.stringify(String(r))}]`):/[^\w$]/.test(r)?t.push(`[${JSON.stringify(r)}]`):(t.length&&t.push("."),t.push(r));return t.join("")}function x0(e){let t=[],n=[...e.issues].sort((r,o)=>(r.path??[]).length-(o.path??[]).length);for(let r of n)t.push(`\u2716 ${r.message}`),r.path?.length&&t.push(` \u2192 at ${i6(r.path)}`);return t.join(`
7
+ `),t.push(yc(e.hint,da.gray))),t.join("")}function Qg(e){return yc(e,da.green)}function Kn(e){return yc(e,da.gray)}var da,Jn=x(()=>{"use strict";da={red:"\x1B[31m",yellow:"\x1B[33m",green:"\x1B[32m",cyan:"\x1B[36m",gray:"\x1B[90m",reset:"\x1B[0m",bold:"\x1B[1m"}});var mR,u0=x(()=>{"use strict";mR="0.124.58"});function z(e,t,n){function r(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:s,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);let l=s.prototype,u=Object.keys(l);for(let d=0;d<u.length;d++){let p=u[d];p in a||(a[p]=l[p].bind(a))}}let o=n?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function s(a){var c;let l=n?.Parent?new i:this;r(l,a),(c=l._zod).deferred??(c.deferred=[]);for(let u of l._zod.deferred)u();return l}return Object.defineProperty(s,"init",{value:r}),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 Rn(e){return e&&Object.assign(Xg,e),Xg}var d0,gR,Li,wc,Xg,up=x(()=>{d0=Object.freeze({status:"aborted"});gR=Symbol("zod_brand"),Li=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},wc=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}},Xg={}});var Re={};xe(Re,{BIGINT_FORMAT_RANGES:()=>k0,Class:()=>f0,NUMBER_FORMAT_RANGES:()=>v0,aborted:()=>Rc,allowsEval:()=>h0,assert:()=>yRe,assertEqual:()=>fRe,assertIs:()=>gRe,assertNever:()=>hRe,assertNotEqual:()=>mRe,assignProp:()=>vc,base64ToUint8Array:()=>n6,base64urlToUint8Array:()=>DRe,cached:()=>pp,captureStackTrace:()=>yR,cleanEnum:()=>TRe,cleanRegex:()=>nh,clone:()=>jr,cloneDef:()=>bRe,createTransparentProxy:()=>SRe,defineLazy:()=>mt,esc:()=>hR,escapeRegex:()=>Jo,extend:()=>PRe,finalizeIssue:()=>oo,floatSafeRemainder:()=>m0,getElementAtPath:()=>vRe,getEnumValues:()=>th,getLengthableOrigin:()=>ih,getParsedType:()=>$Re,getSizableOrigin:()=>oh,hexToUint8Array:()=>NRe,isObject:()=>fu,isPlainObject:()=>kc,issue:()=>fp,joinValues:()=>ne,jsonStringifyReplacer:()=>dp,merge:()=>ARe,mergeDefs:()=>pa,normalizeParams:()=>Se,nullish:()=>bc,numKeys:()=>xRe,objectClone:()=>wRe,omit:()=>ORe,optionalKeys:()=>b0,parsedType:()=>ke,partial:()=>_Re,pick:()=>ERe,prefixIssues:()=>Po,primitiveTypes:()=>w0,promiseAllObject:()=>kRe,propertyKeyTypes:()=>rh,randomString:()=>RRe,required:()=>IRe,safeExtend:()=>CRe,shallowClone:()=>y0,slugify:()=>g0,stringifyPrimitive:()=>we,uint8ArrayToBase64:()=>r6,uint8ArrayToBase64url:()=>jRe,uint8ArrayToHex:()=>LRe,unwrapMessage:()=>eh});function fRe(e){return e}function mRe(e){return e}function gRe(e){}function hRe(e){throw new Error("Unexpected value in exhaustive check")}function yRe(e){}function th(e){let t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function ne(e,t="|"){return e.map(n=>we(n)).join(t)}function dp(e,t){return typeof t=="bigint"?t.toString():t}function pp(e){return{get value(){{let n=e();return Object.defineProperty(this,"value",{value:n}),n}throw new Error("cached value already set")}}}function bc(e){return e==null}function nh(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function m0(e,t){let n=(e.toString().split(".")[1]||"").length,r=t.toString(),o=(r.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(r)){let c=r.match(/\d?e-(\d?)/);c?.[1]&&(o=Number.parseInt(c[1]))}let i=n>o?n:o,s=Number.parseInt(e.toFixed(i).replace(".","")),a=Number.parseInt(t.toFixed(i).replace(".",""));return s%a/10**i}function mt(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==t6)return r===void 0&&(r=t6,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function wRe(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function vc(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function pa(...e){let t={};for(let n of e){let r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function bRe(e){return pa(e._zod.def)}function vRe(e,t){return t?t.reduce((n,r)=>n?.[r],e):e}function kRe(e){let t=Object.keys(e),n=t.map(r=>e[r]);return Promise.all(n).then(r=>{let o={};for(let i=0;i<t.length;i++)o[t[i]]=r[i];return o})}function RRe(e=10){let t="abcdefghijklmnopqrstuvwxyz",n="";for(let r=0;r<e;r++)n+=t[Math.floor(Math.random()*t.length)];return n}function hR(e){return JSON.stringify(e)}function g0(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function fu(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function kc(e){if(fu(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let n=t.prototype;return!(fu(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function y0(e){return kc(e)?{...e}:Array.isArray(e)?[...e]:e}function xRe(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function Jo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function jr(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function Se(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 SRe(e){let t;return new Proxy({},{get(n,r,o){return t??(t=e()),Reflect.get(t,r,o)},set(n,r,o,i){return t??(t=e()),Reflect.set(t,r,o,i)},has(n,r){return t??(t=e()),Reflect.has(t,r)},deleteProperty(n,r){return t??(t=e()),Reflect.deleteProperty(t,r)},ownKeys(n){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,r){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,r)},defineProperty(n,r,o){return t??(t=e()),Reflect.defineProperty(t,r,o)}})}function we(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function b0(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function ERe(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let i=pa(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 vc(this,"shape",s),s},checks:[]});return jr(e,i)}function ORe(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let i=pa(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 vc(this,"shape",s),s},checks:[]});return jr(e,i)}function PRe(e,t){if(!kc(t))throw new Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let i=e._zod.def.shape;for(let s in t)if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let o=pa(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return vc(this,"shape",i),i}});return jr(e,o)}function CRe(e,t){if(!kc(t))throw new Error("Invalid input to safeExtend: expected a plain object");let n=pa(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t};return vc(this,"shape",r),r}});return jr(e,n)}function ARe(e,t){let n=pa(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return vc(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return jr(e,n)}function _Re(e,t,n){let o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let s=pa(t._zod.def,{get shape(){let a=t._zod.def.shape,c={...a};if(n)for(let l in n){if(!(l in a))throw new Error(`Unrecognized key: "${l}"`);n[l]&&(c[l]=e?new e({type:"optional",innerType:a[l]}):a[l])}else for(let l in a)c[l]=e?new e({type:"optional",innerType:a[l]}):a[l];return vc(this,"shape",c),c},checks:[]});return jr(t,s)}function IRe(e,t,n){let r=pa(t._zod.def,{get shape(){let o=t._zod.def.shape,i={...o};if(n)for(let s in n){if(!(s in i))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(i[s]=new e({type:"nonoptional",innerType:o[s]}))}else for(let s in o)i[s]=new e({type:"nonoptional",innerType:o[s]});return vc(this,"shape",i),i}});return jr(t,r)}function Rc(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 Po(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function eh(e){return typeof e=="string"?e:e?.message}function oo(e,t,n){let r={...e,path:e.path??[]};if(!e.message){let o=eh(e.inst?._zod.def?.error?.(e))??eh(t?.error?.(e))??eh(n.customError?.(e))??eh(n.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function oh(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function ih(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ke(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 fp(...e){let[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function TRe(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function n6(e){let t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}function r6(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function DRe(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return n6(t+n)}function jRe(e){return r6(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function NRe(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 r=0;r<t.length;r+=2)n[r/2]=Number.parseInt(t.slice(r,r+2),16);return n}function LRe(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var t6,yR,h0,$Re,rh,w0,v0,k0,f0,He=x(()=>{t6=Symbol("evaluating");yR="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};h0=pp(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});$Re=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}`)}},rh=new Set(["string","number","symbol"]),w0=new Set(["string","number","bigint","boolean","symbol","undefined"]);v0={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]},k0={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};f0=class{constructor(...t){}}});function ah(e,t=n=>n.message){let n={},r=[];for(let o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function ch(e,t=n=>n.message){let n={_errors:[]},r=o=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(s=>r({issues:s}));else if(i.code==="invalid_key")r({issues:i.issues});else if(i.code==="invalid_element")r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let s=n,a=0;for(;a<i.path.length;){let c=i.path[a];a===i.path.length-1?(s[c]=s[c]||{_errors:[]},s[c]._errors.push(t(i))):s[c]=s[c]||{_errors:[]},s=s[c],a++}}};return r(e),n}function R0(e,t=n=>n.message){let n={errors:[]},r=(o,i=[])=>{var s,a;for(let c of o.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(l=>r({issues:l},c.path));else if(c.code==="invalid_key")r({issues:c.issues},c.path);else if(c.code==="invalid_element")r({issues:c.issues},c.path);else{let l=[...i,...c.path];if(l.length===0){n.errors.push(t(c));continue}let u=n,d=0;for(;d<l.length;){let p=l[d],f=d===l.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(c)),d++}}};return r(e),n}function i6(e){let t=[],n=e.map(r=>typeof r=="object"?r.key:r);for(let r of n)typeof r=="number"?t.push(`[${r}]`):typeof r=="symbol"?t.push(`[${JSON.stringify(String(r))}]`):/[^\w$]/.test(r)?t.push(`[${JSON.stringify(r)}]`):(t.length&&t.push("."),t.push(r));return t.join("")}function x0(e){let t=[],n=[...e.issues].sort((r,o)=>(r.path??[]).length-(o.path??[]).length);for(let r of n)t.push(`\u2716 ${r.message}`),r.path?.length&&t.push(` \u2192 at ${i6(r.path)}`);return t.join(`
8
8
  `)}var o6,sh,io,$0=x(()=>{up();He();o6=(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,dp,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},sh=z("$ZodError",o6),io=z("$ZodError",o6,{Parent:Error})});var mp,wR,gp,bR,hp,S0,yp,E0,vR,FRe,kR,GRe,RR,WRe,xR,BRe,$R,URe,SR,zRe,ER,HRe,OR,qRe,O0=x(()=>{up();$0();He();mp=e=>(t,n,r,o)=>{let i=r?Object.assign(r,{async:!1}):{async:!1},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new Li;if(s.issues.length){let a=new(o?.Err??e)(s.issues.map(c=>oo(c,i,Rn())));throw yR(a,o?.callee),a}return s.value},wR=mp(io),gp=e=>async(t,n,r,o)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){let a=new(o?.Err??e)(s.issues.map(c=>oo(c,i,Rn())));throw yR(a,o?.callee),a}return s.value},bR=gp(io),hp=e=>(t,n,r)=>{let o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new Li;return i.issues.length?{success:!1,error:new(e??sh)(i.issues.map(s=>oo(s,o,Rn())))}:{success:!0,data:i.value}},S0=hp(io),yp=e=>async(t,n,r)=>{let o=r?Object.assign(r,{async:!0}):{async:!0},i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>oo(s,o,Rn())))}:{success:!0,data:i.value}},E0=yp(io),vR=e=>(t,n,r)=>{let o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return mp(e)(t,n,o)},FRe=vR(io),kR=e=>(t,n,r)=>mp(e)(t,n,r),GRe=kR(io),RR=e=>async(t,n,r)=>{let o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return gp(e)(t,n,o)},WRe=RR(io),xR=e=>async(t,n,r)=>gp(e)(t,n,r),BRe=xR(io),$R=e=>(t,n,r)=>{let o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return hp(e)(t,n,o)},URe=$R(io),SR=e=>(t,n,r)=>hp(e)(t,n,r),zRe=SR(io),ER=e=>async(t,n,r)=>{let o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return yp(e)(t,n,o)},HRe=ER(io),OR=e=>async(t,n,r)=>yp(e)(t,n,r),qRe=OR(io)});var Zo={};xe(Zo,{base64:()=>U0,base64url:()=>PR,bigint:()=>J0,boolean:()=>Y0,browserEmail:()=>exe,cidrv4:()=>W0,cidrv6:()=>B0,cuid:()=>P0,cuid2:()=>C0,date:()=>H0,datetime:()=>V0,domain:()=>rxe,duration:()=>D0,e164:()=>z0,email:()=>N0,emoji:()=>L0,extendedDuration:()=>VRe,guid:()=>j0,hex:()=>oxe,hostname:()=>nxe,html5Email:()=>YRe,idnEmail:()=>XRe,integer:()=>Z0,ipv4:()=>M0,ipv6:()=>F0,ksuid:()=>I0,lowercase:()=>eI,mac:()=>G0,md5_base64:()=>sxe,md5_base64url:()=>axe,md5_hex:()=>ixe,nanoid:()=>T0,null:()=>Q0,number:()=>CR,rfc5322Email:()=>QRe,sha1_base64:()=>lxe,sha1_base64url:()=>uxe,sha1_hex:()=>cxe,sha256_base64:()=>pxe,sha256_base64url:()=>fxe,sha256_hex:()=>dxe,sha384_base64:()=>gxe,sha384_base64url:()=>hxe,sha384_hex:()=>mxe,sha512_base64:()=>wxe,sha512_base64url:()=>bxe,sha512_hex:()=>yxe,string:()=>K0,time:()=>q0,ulid:()=>A0,undefined:()=>X0,unicodeEmail:()=>s6,uppercase:()=>tI,uuid:()=>mu,uuid4:()=>KRe,uuid6:()=>JRe,uuid7:()=>ZRe,xid:()=>_0});function L0(){return new RegExp(txe,"u")}function c6(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 q0(e){return new RegExp(`^${c6(e)}$`)}function V0(e){let t=c6({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${t}(?:${n.join("|")})`;return new RegExp(`^${a6}T(?:${r})$`)}function lh(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function uh(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var P0,C0,A0,_0,I0,T0,D0,VRe,j0,mu,KRe,JRe,ZRe,N0,YRe,QRe,s6,XRe,exe,txe,M0,F0,G0,W0,B0,U0,PR,nxe,rxe,z0,a6,H0,K0,J0,Z0,CR,Y0,Q0,X0,eI,tI,oxe,ixe,sxe,axe,cxe,lxe,uxe,dxe,pxe,fxe,mxe,gxe,hxe,yxe,wxe,bxe,AR=x(()=>{He();P0=/^[cC][^\s-]{8,}$/,C0=/^[0-9a-z]+$/,A0=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,_0=/^[0-9a-vA-V]{20}$/,I0=/^[A-Za-z0-9]{27}$/,T0=/^[a-zA-Z0-9_-]{21}$/,D0=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,VRe=/^[-+]?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)?)??$/,j0=/^([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})$/,mu=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)$/,KRe=mu(4),JRe=mu(6),ZRe=mu(7),N0=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,YRe=/^[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])?)*$/,QRe=/^(([^<>()\[\]\\.,;:\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,}))$/,s6=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,XRe=s6,exe=/^[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])?)*$/,txe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";M0=/^(?:(?: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])$/,F0=/^(([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}|:))$/,G0=e=>{let t=Jo(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},W0=/^((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])$/,B0=/^(([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])$/,U0=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,PR=/^[A-Za-z0-9_-]*$/,nxe=/^(?=.{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])?)*\.?$/,rxe=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,z0=/^\+[1-9]\d{6,14}$/,a6="(?:(?:\\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])))",H0=new RegExp(`^${a6}$`);K0=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},J0=/^-?\d+n?$/,Z0=/^-?\d+$/,CR=/^-?\d+(?:\.\d+)?$/,Y0=/^(?:true|false)$/i,Q0=/^null$/i,X0=/^undefined$/i,eI=/^[^A-Z]*$/,tI=/^[^a-z]*$/,oxe=/^[0-9a-fA-F]*$/;ixe=/^[0-9a-fA-F]{32}$/,sxe=lh(22,"=="),axe=uh(22),cxe=/^[0-9a-fA-F]{40}$/,lxe=lh(27,"="),uxe=uh(27),dxe=/^[0-9a-fA-F]{64}$/,pxe=lh(43,"="),fxe=uh(43),mxe=/^[0-9a-fA-F]{96}$/,gxe=lh(64,""),hxe=uh(64),yxe=/^[0-9a-fA-F]{128}$/,wxe=lh(86,"=="),bxe=uh(86)});function l6(e,t,n){e.issues.length&&t.issues.push(...Po(n,e.issues))}var Yt,u6,_R,IR,nI,rI,oI,iI,sI,aI,cI,lI,uI,wp,dI,pI,fI,mI,gI,hI,yI,wI,bI,TR=x(()=>{up();AR();He();Yt=z("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),u6={number:"number",bigint:"bigint",object:"date"},_R=z("$ZodCheckLessThan",(e,t)=>{Yt.init(e,t);let n=u6[typeof t.value];e._zod.onattach.push(r=>{let o=r._zod.bag,i=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),IR=z("$ZodCheckGreaterThan",(e,t)=>{Yt.init(e,t);let n=u6[typeof t.value];e._zod.onattach.push(r=>{let o=r._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),nI=z("$ZodCheckMultipleOf",(e,t)=>{Yt.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.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):m0(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})}}),rI=z("$ZodCheckNumberFormat",(e,t)=>{Yt.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),r=n?"int":"number",[o,i]=v0[t.format];e._zod.onattach.push(s=>{let a=s._zod.bag;a.format=t.format,a.minimum=o,a.maximum=i,n&&(a.pattern=Z0)}),e._zod.check=s=>{let a=s.value;if(n){if(!Number.isInteger(a)){s.issues.push({expected:r,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:r,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:r,inclusive:!0,continue:!t.abort});return}}a<o&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>i&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),oI=z("$ZodCheckBigIntFormat",(e,t)=>{Yt.init(e,t);let[n,r]=k0[t.format];e._zod.onattach.push(o=>{let i=o._zod.bag;i.format=t.format,i.minimum=n,i.maximum=r}),e._zod.check=o=>{let i=o.value;i<n&&o.issues.push({origin:"bigint",input:i,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),i>r&&o.issues.push({origin:"bigint",input:i,code:"too_big",maximum:r,inclusive:!0,inst:e,continue:!t.abort})}}),iI=z("$ZodCheckMaxSize",(e,t)=>{var n;Yt.init(e,t),(n=e._zod.def).when??(n.when=r=>{let o=r.value;return!bc(o)&&o.size!==void 0}),e._zod.onattach.push(r=>{let o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{let o=r.value;o.size<=t.maximum||r.issues.push({origin:oh(o),code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),sI=z("$ZodCheckMinSize",(e,t)=>{var n;Yt.init(e,t),(n=e._zod.def).when??(n.when=r=>{let o=r.value;return!bc(o)&&o.size!==void 0}),e._zod.onattach.push(r=>{let o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{let o=r.value;o.size>=t.minimum||r.issues.push({origin:oh(o),code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),aI=z("$ZodCheckSizeEquals",(e,t)=>{var n;Yt.init(e,t),(n=e._zod.def).when??(n.when=r=>{let o=r.value;return!bc(o)&&o.size!==void 0}),e._zod.onattach.push(r=>{let o=r._zod.bag;o.minimum=t.size,o.maximum=t.size,o.size=t.size}),e._zod.check=r=>{let o=r.value,i=o.size;if(i===t.size)return;let s=i>t.size;r.issues.push({origin:oh(o),...s?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),cI=z("$ZodCheckMaxLength",(e,t)=>{var n;Yt.init(e,t),(n=e._zod.def).when??(n.when=r=>{let o=r.value;return!bc(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{let o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{let o=r.value;if(o.length<=t.maximum)return;let s=ih(o);r.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),lI=z("$ZodCheckMinLength",(e,t)=>{var n;Yt.init(e,t),(n=e._zod.def).when??(n.when=r=>{let o=r.value;return!bc(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{let o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{let o=r.value;if(o.length>=t.minimum)return;let s=ih(o);r.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),uI=z("$ZodCheckLengthEquals",(e,t)=>{var n;Yt.init(e,t),(n=e._zod.def).when??(n.when=r=>{let o=r.value;return!bc(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{let o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{let o=r.value,i=o.length;if(i===t.length)return;let s=ih(o),a=i>t.length;r.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),wp=z("$ZodCheckStringFormat",(e,t)=>{var n,r;Yt.init(e,t),e._zod.onattach.push(o=>{let i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),dI=z("$ZodCheckRegex",(e,t)=>{wp.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})}}),pI=z("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=eI),wp.init(e,t)}),fI=z("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=tI),wp.init(e,t)}),mI=z("$ZodCheckIncludes",(e,t)=>{Yt.init(e,t);let n=Jo(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{let i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),gI=z("$ZodCheckStartsWith",(e,t)=>{Yt.init(e,t);let n=new RegExp(`^${Jo(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{let o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),hI=z("$ZodCheckEndsWith",(e,t)=>{Yt.init(e,t);let n=new RegExp(`.*${Jo(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{let o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}});yI=z("$ZodCheckProperty",(e,t)=>{Yt.init(e,t),e._zod.check=n=>{let r=t.schema._zod.run({value:n.value[t.property],issues:[]},{});if(r instanceof Promise)return r.then(o=>l6(o,n,t.property));l6(r,n,t.property)}}),wI=z("$ZodCheckMimeType",(e,t)=>{Yt.init(e,t);let n=new Set(t.mime);e._zod.onattach.push(r=>{r._zod.bag.mime=t.mime}),e._zod.check=r=>{n.has(r.value.type)||r.issues.push({code:"invalid_value",values:t.mime,input:r.value.type,inst:e,continue:!t.abort})}}),bI=z("$ZodCheckOverwrite",(e,t)=>{Yt.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}})});var dh,vI=x(()=>{dh=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 r=t.split(`
9
9
  `).filter(s=>s),o=Math.min(...r.map(s=>s.length-s.trimStart().length)),i=r.map(s=>s.slice(o)).map(s=>" ".repeat(this.indent*2)+s);for(let s of i)this.content.push(s)}compile(){let t=Function,n=this?.args,o=[...(this?.content??[""]).map(i=>` ${i}`)];return new t(...n,o.join(`
10
10
  `))}}});var kI,RI=x(()=>{kI={major:4,minor:3,patch:6}});function zI(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}function x6(e){if(!PR.test(e))return!1;let t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return zI(n)}function $6(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let o=JSON.parse(atob(r));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}function p6(e,t,n){e.issues.length&&t.issues.push(...Po(n,e.issues)),t.value[n]=e.value}function MR(e,t,n,r,o){if(e.issues.length){if(o&&!(n in r))return;t.issues.push(...Po(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function S6(e){let t=Object.keys(e.shape);for(let r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);let n=b0(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function E6(e,t,n,r,o,i){let s=[],a=o.keySet,c=o.catchall._zod,l=c.def.type,u=c.optout==="optional";for(let d in t){if(a.has(d))continue;if(l==="never"){s.push(d);continue}let p=c.run({value:t[d],issues:[]},r);p instanceof Promise?e.push(p.then(f=>MR(f,n,d,t,u))):MR(p,n,d,t,u)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}function f6(e,t,n,r){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let o=e.filter(i=>!Rc(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(s=>oo(s,r,Rn())))}),t)}function m6(e,t,n,r){let o=e.filter(i=>i.issues.length===0);return o.length===1?(t.value=o[0].value,t):(o.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(s=>oo(s,r,Rn())))}):t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:[],inclusive:!1}),t)}function xI(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(kc(e)&&kc(t)){let n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};for(let i of r){let s=xI(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let o=e[r],i=t[r],s=xI(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function g6(e,t,n){let r=new Map,o;for(let a of t.issues)if(a.code==="unrecognized_keys"){o??(o=a);for(let c of a.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else e.issues.push(a);for(let a of n.issues)if(a.code==="unrecognized_keys")for(let c of a.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else e.issues.push(a);let i=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(i.length&&o&&e.issues.push({...o,keys:i}),Rc(e))return e;let s=xI(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 DR(e,t,n){e.issues.length&&t.issues.push(...Po(n,e.issues)),t.value[n]=e.value}function h6(e,t,n,r,o,i,s){e.issues.length&&(rh.has(typeof r)?n.issues.push(...Po(r,e.issues)):n.issues.push({code:"invalid_key",origin:"map",input:o,inst:i,issues:e.issues.map(a=>oo(a,s,Rn()))})),t.issues.length&&(rh.has(typeof r)?n.issues.push(...Po(r,t.issues)):n.issues.push({origin:"map",code:"invalid_element",input:o,inst:i,key:r,issues:t.issues.map(a=>oo(a,s,Rn()))})),n.value.set(e.value,t.value)}function y6(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}function w6(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}function b6(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}function v6(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 jR(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}function NR(e,t,n){if(e.issues.length)return e.aborted=!0,e;if((n.direction||"forward")==="forward"){let o=t.transform(e.value,e);return o instanceof Promise?o.then(i=>LR(e,i,t.out,n)):LR(e,o,t.out,n)}else{let o=t.reverseTransform(e.value,e);return o instanceof Promise?o.then(i=>LR(e,i,t.in,n)):LR(e,o,t.in,n)}}function LR(e,t,n,r){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},r)}function k6(e){return e.value=Object.freeze(e.value),e}function R6(e,t,n,r){if(!e){let o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(fp(o))}}var nt,gu,Ht,$I,SI,EI,OI,PI,CI,AI,_I,II,TI,DI,jI,NI,LI,MI,FI,GI,WI,BI,UI,HI,qI,VI,KI,JI,FR,ZI,ph,GR,YI,QI,XI,eT,tT,nT,rT,oT,iT,sT,O6,aT,fh,cT,lT,uT,WR,dT,pT,fT,mT,gT,hT,yT,BR,wT,bT,vT,kT,RT,xT,$T,ST,ET,mh,OT,PT,CT,AT,_T,IT,TT=x(()=>{TR();up();vI();O0();AR();He();RI();He();nt=z("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=kI;let r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(let o of r)for(let i of o._zod.onattach)i(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let o=(s,a,c)=>{let l=Rc(s),u;for(let d of a){if(d._zod.def.when){if(!d._zod.def.when(s))continue}else if(l)continue;let p=s.issues.length,f=d._zod.check(s);if(f instanceof Promise&&c?.async===!1)throw new Li;if(u||f instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await f,s.issues.length!==p&&(l||(l=Rc(s,p)))});else{if(s.issues.length===p)continue;l||(l=Rc(s,p))}}return u?u.then(()=>s):s},i=(s,a,c)=>{if(Rc(s))return s.aborted=!0,s;let l=o(a,r,c);if(l instanceof Promise){if(c.async===!1)throw new Li;return l.then(u=>e._zod.parse(u,c))}return e._zod.parse(l,c)};e._zod.run=(s,a)=>{if(a.skipChecks)return e._zod.parse(s,a);if(a.direction==="backward"){let l=e._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});return l instanceof Promise?l.then(u=>i(u,s,a)):i(l,s,a)}let c=e._zod.parse(s,a);if(c instanceof Promise){if(a.async===!1)throw new Li;return c.then(l=>o(l,r,a))}return o(c,r,a)}}mt(e,"~standard",()=>({validate:o=>{try{let i=S0(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return E0(e,o).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),gu=z("$ZodString",(e,t)=>{nt.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??K0(e._zod.bag),e._zod.parse=(n,r)=>{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}}),Ht=z("$ZodStringFormat",(e,t)=>{wp.init(e,t),gu.init(e,t)}),$I=z("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=j0),Ht.init(e,t)}),SI=z("$ZodUUID",(e,t)=>{if(t.version){let r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=mu(r))}else t.pattern??(t.pattern=mu());Ht.init(e,t)}),EI=z("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=N0),Ht.init(e,t)}),OI=z("$ZodURL",(e,t)=>{Ht.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),o=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.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(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.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=o.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),PI=z("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=L0()),Ht.init(e,t)}),CI=z("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=T0),Ht.init(e,t)}),AI=z("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=P0),Ht.init(e,t)}),_I=z("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=C0),Ht.init(e,t)}),II=z("$ZodULID",(e,t)=>{t.pattern??(t.pattern=A0),Ht.init(e,t)}),TI=z("$ZodXID",(e,t)=>{t.pattern??(t.pattern=_0),Ht.init(e,t)}),DI=z("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=I0),Ht.init(e,t)}),jI=z("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=V0(t)),Ht.init(e,t)}),NI=z("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=H0),Ht.init(e,t)}),LI=z("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=q0(t)),Ht.init(e,t)}),MI=z("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=D0),Ht.init(e,t)}),FI=z("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=M0),Ht.init(e,t),e._zod.bag.format="ipv4"}),GI=z("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=F0),Ht.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})}}}),WI=z("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=G0(t.delimiter)),Ht.init(e,t),e._zod.bag.format="mac"}),BI=z("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=W0),Ht.init(e,t)}),UI=z("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=B0),Ht.init(e,t),e._zod.check=n=>{let r=n.value.split("/");try{if(r.length!==2)throw new Error;let[o,i]=r;if(!i)throw new Error;let s=Number(i);if(`${s}`!==i)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${o}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});HI=z("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=U0),Ht.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{zI(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});qI=z("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=PR),Ht.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{x6(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),VI=z("$ZodE164",(e,t)=>{t.pattern??(t.pattern=z0),Ht.init(e,t)});KI=z("$ZodJWT",(e,t)=>{Ht.init(e,t),e._zod.check=n=>{$6(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),JI=z("$ZodCustomStringFormat",(e,t)=>{Ht.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})}}),FR=z("$ZodNumber",(e,t)=>{nt.init(e,t),e._zod.pattern=e._zod.bag.pattern??CR,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;let i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),n}}),ZI=z("$ZodNumberFormat",(e,t)=>{rI.init(e,t),FR.init(e,t)}),ph=z("$ZodBoolean",(e,t)=>{nt.init(e,t),e._zod.pattern=Y0,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),GR=z("$ZodBigInt",(e,t)=>{nt.init(e,t),e._zod.pattern=J0,e._zod.parse=(n,r)=>{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}}),YI=z("$ZodBigIntFormat",(e,t)=>{oI.init(e,t),GR.init(e,t)}),QI=z("$ZodSymbol",(e,t)=>{nt.init(e,t),e._zod.parse=(n,r)=>{let o=n.value;return typeof o=="symbol"||n.issues.push({expected:"symbol",code:"invalid_type",input:o,inst:e}),n}}),XI=z("$ZodUndefined",(e,t)=>{nt.init(e,t),e._zod.pattern=X0,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(n,r)=>{let o=n.value;return typeof o>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:o,inst:e}),n}}),eT=z("$ZodNull",(e,t)=>{nt.init(e,t),e._zod.pattern=Q0,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{let o=n.value;return o===null||n.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),n}}),tT=z("$ZodAny",(e,t)=>{nt.init(e,t),e._zod.parse=n=>n}),nT=z("$ZodUnknown",(e,t)=>{nt.init(e,t),e._zod.parse=n=>n}),rT=z("$ZodNever",(e,t)=>{nt.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)}),oT=z("$ZodVoid",(e,t)=>{nt.init(e,t),e._zod.parse=(n,r)=>{let o=n.value;return typeof o>"u"||n.issues.push({expected:"void",code:"invalid_type",input:o,inst:e}),n}}),iT=z("$ZodDate",(e,t)=>{nt.init(e,t),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=new Date(n.value)}catch{}let o=n.value,i=o instanceof Date;return i&&!Number.isNaN(o.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:o,...i?{received:"Invalid Date"}:{},inst:e}),n}});sT=z("$ZodArray",(e,t)=>{nt.init(e,t),e._zod.parse=(n,r)=>{let o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);let i=[];for(let s=0;s<o.length;s++){let a=o[s],c=t.element._zod.run({value:a,issues:[]},r);c instanceof Promise?i.push(c.then(l=>p6(l,n,s))):p6(c,n,s)}return i.length?Promise.all(i).then(()=>n):n}});O6=z("$ZodObject",(e,t)=>{if(nt.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let a=t.shape;Object.defineProperty(t,"shape",{get:()=>{let c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}let r=pp(()=>S6(t));mt(e._zod,"propValues",()=>{let a=t.shape,c={};for(let l in a){let u=a[l]._zod;if(u.values){c[l]??(c[l]=new Set);for(let d of u.values)c[l].add(d)}}return c});let o=fu,i=t.catchall,s;e._zod.parse=(a,c)=>{s??(s=r.value);let l=a.value;if(!o(l))return a.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),a;a.value={};let u=[],d=s.shape;for(let p of s.keys){let f=d[p],m=f._zod.optout==="optional",g=f._zod.run({value:l[p],issues:[]},c);g instanceof Promise?u.push(g.then(h=>MR(h,a,p,l,m))):MR(g,a,p,l,m)}return i?E6(u,l,a,c,r.value,e):u.length?Promise.all(u).then(()=>a):a}}),aT=z("$ZodObjectJIT",(e,t)=>{O6.init(e,t);let n=e._zod.parse,r=pp(()=>S6(t)),o=p=>{let f=new dh(["shape","payload","ctx"]),m=r.value,g=R=>{let k=hR(R);return`shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`};f.write("const input = payload.value;");let h=Object.create(null),y=0;for(let R of m.keys)h[R]=`key_${y++}`;f.write("const newResult = {};");for(let R of m.keys){let k=h[R],$=hR(R),C=p[R]?._zod?.optout==="optional";f.write(`const ${k} = ${g(R)};`),C?f.write(`
@@ -101,7 +101,7 @@ ${e.timestamp}`,"utf-8")}function XOe(e,t,n){let r=`the approval of gate ${n.gat
101
101
  `+P.slice(le+1):je+=P.slice(me),je.slice(1)}function Cn(P){let H="",te=0;for(let pe=0;pe<P.length;te>=65536?pe+=2:pe++){te=Ce(P,pe);let me=O[te];!me&&ue(te)?(H+=P[pe],te>=65536&&(H+=P[pe+1])):H+=me||Q(te)}return H}function ir(P,H,te){let pe="",me=P.tag;for(let ye=0,le=te.length;ye<le;ye+=1){let Oe=te[ye];P.replacer&&(Oe=P.replacer.call(te,String(ye),Oe)),(B(P,H,Oe,!1,!1)||typeof Oe>"u"&&B(P,H,null,!1,!1))&&(pe!==""&&(pe+=","+(P.condenseFlow?"":" ")),pe+=P.dump)}P.tag=me,P.dump="["+pe+"]"}function Dr(P,H,te,pe){let me="",ye=P.tag;for(let le=0,Oe=te.length;le<Oe;le+=1){let je=te[le];P.replacer&&(je=P.replacer.call(te,String(le),je)),(B(P,H+1,je,!0,!0,!1,!0)||typeof je>"u"&&B(P,H+1,null,!0,!0,!1,!0))&&((!pe||me!=="")&&(me+=ee(P,H)),P.dump&&a===P.dump.charCodeAt(0)?me+="-":me+="- ",me+=P.dump)}P.tag=ye,P.dump=me||"[]"}function vr(P,H,te){let pe="",me=P.tag,ye=Object.keys(te);for(let le=0,Oe=ye.length;le<Oe;le+=1){let je="";pe!==""&&(je+=", "),P.condenseFlow&&(je+='"');let Ve=ye[le],Je=te[Ve];P.replacer&&(Je=P.replacer.call(te,Ve,Je)),B(P,H,Ve,!1,!1)&&(P.dump.length>1024&&(je+="? "),je+=P.dump+(P.condenseFlow?'"':"")+":"+(P.condenseFlow?"":" "),B(P,H,Je,!1,!1)&&(je+=P.dump,pe+=je))}P.tag=me,P.dump="{"+pe+"}"}function gc(P,H,te,pe){let me="",ye=P.tag,le=Object.keys(te);if(P.sortKeys===!0)le.sort();else if(typeof P.sortKeys=="function")le.sort(P.sortKeys);else if(P.sortKeys)throw new t("sortKeys must be a boolean or a function");for(let Oe=0,je=le.length;Oe<je;Oe+=1){let Ve="";(!pe||me!=="")&&(Ve+=ee(P,H));let Je=le[Oe],Xe=te[Je];if(P.replacer&&(Xe=P.replacer.call(te,Je,Xe)),!B(P,H+1,Je,!0,!0,!0))continue;let ut=P.tag!==null&&P.tag!=="?"||P.dump&&P.dump.length>1024;ut&&(P.dump&&a===P.dump.charCodeAt(0)?Ve+="?":Ve+="? "),Ve+=P.dump,ut&&(Ve+=ee(P,H)),B(P,H+1,Xe,!0,ut)&&(P.dump&&a===P.dump.charCodeAt(0)?Ve+=":":Ve+=": ",Ve+=P.dump,me+=Ve)}P.tag=ye,P.dump=me||"{}"}function v(P,H,te){let pe=te?P.explicitTypes:P.implicitTypes;for(let me=0,ye=pe.length;me<ye;me+=1){let le=pe[me];if((le.instanceOf||le.predicate)&&(!le.instanceOf||typeof H=="object"&&H instanceof le.instanceOf)&&(!le.predicate||le.predicate(H))){if(te?le.multi&&le.representName?P.tag=le.representName(H):P.tag=le.tag:P.tag="?",le.represent){let Oe=P.styleMap[le.tag]||le.defaultStyle,je;if(r.call(le.represent)==="[object Function]")je=le.represent(H,Oe);else if(o.call(le.represent,Oe))je=le.represent[Oe](H,Oe);else throw new t("!<"+le.tag+'> tag resolver accepts not "'+Oe+'" style');P.dump=je}return!0}}return!1}function B(P,H,te,pe,me,ye,le){P.tag=null,P.dump=te,v(P,te,!1)||v(P,te,!0);let Oe=r.call(P.dump),je=pe;pe&&(pe=P.flowLevel<0||P.flowLevel>H);let Ve=Oe==="[object Object]"||Oe==="[object Array]",Je,Xe;if(Ve&&(Je=P.duplicates.indexOf(te),Xe=Je!==-1),(P.tag!==null&&P.tag!=="?"||Xe||P.indent!==2&&H>0)&&(me=!1),Xe&&P.usedDuplicates[Je])P.dump="*ref_"+Je;else{if(Ve&&Xe&&!P.usedDuplicates[Je]&&(P.usedDuplicates[Je]=!0),Oe==="[object Object]")pe&&Object.keys(P.dump).length!==0?(gc(P,H,P.dump,me),Xe&&(P.dump="&ref_"+Je+P.dump)):(vr(P,H,P.dump),Xe&&(P.dump="&ref_"+Je+" "+P.dump));else if(Oe==="[object Array]")pe&&P.dump.length!==0?(P.noArrayIndent&&!le&&H>0?Dr(P,H-1,P.dump,me):Dr(P,H,P.dump,me),Xe&&(P.dump="&ref_"+Je+P.dump)):(ir(P,H,P.dump),Xe&&(P.dump="&ref_"+Je+" "+P.dump));else if(Oe==="[object String]")P.tag!=="?"&&Tt(P,P.dump,H,ye,je);else{if(Oe==="[object Undefined]")return!1;if(P.skipInvalid)return!1;throw new t("unacceptable kind of an object to dump "+Oe)}if(P.tag!==null&&P.tag!=="?"){let ut=encodeURI(P.tag[0]==="!"?P.tag.slice(1):P.tag).replace(/!/g,"%21");P.tag[0]==="!"?ut="!"+ut:ut.slice(0,18)==="tag:yaml.org,2002:"?ut="!!"+ut.slice(18):ut="!<"+ut+">",P.dump=ut+" "+P.dump}}return!0}function X(P,H){let te=[],pe=[];ce(P,te,pe);let me=pe.length;for(let ye=0;ye<me;ye+=1)H.duplicates.push(te[pe[ye]]);H.usedDuplicates=new Array(me)}function ce(P,H,te){if(P!==null&&typeof P=="object"){let pe=H.indexOf(P);if(pe!==-1)te.indexOf(pe)===-1&&te.push(pe);else if(H.push(P),Array.isArray(P))for(let me=0,ye=P.length;me<ye;me+=1)ce(P[me],H,te);else{let me=Object.keys(P);for(let ye=0,le=me.length;ye<le;ye+=1)ce(P[me[ye]],H,te)}}}function Y(P,H){H=H||{};let te=new de(H);te.noRefs||X(P,te);let pe=P;return te.replacer&&(pe=te.replacer.call({"":pe},"",pe)),B(te,0,pe,!0,!0)?te.dump+`
102
102
  `:""}return cF.dump=Y,cF}function ZTe(){if(EX)return Sr;EX=1;let e=KTe(),t=JTe();function n(r,o){return function(){throw new Error("Function yaml."+r+" is removed in js-yaml 4. Use yaml."+o+" instead, which is now safe by default.")}}return Sr.Type=Br(),Sr.Schema=OX(),Sr.FAILSAFE_SCHEMA=_X(),Sr.JSON_SCHEMA=NX(),Sr.CORE_SCHEMA=LX(),Sr.DEFAULT_SCHEMA=lF(),Sr.load=e.load,Sr.loadAll=e.loadAll,Sr.dump=t.dump,Sr.YAMLException=Vy(),Sr.types={binary:GX(),float:jX(),map:AX(),null:IX(),pairs:BX(),set:UX(),timestamp:MX(),bool:TX(),int:DX(),merge:FX(),omap:WX(),seq:CX(),str:PX()},Sr.safeLoad=n("safeLoad","load"),Sr.safeLoadAll=n("safeLoadAll","loadAll"),Sr.safeDump=n("safeDump","dump"),Sr}var Sr,$S,qc,nX,W1,rX,B1,oX,U1,iX,z1,sX,H1,aX,q1,cX,V1,lX,K1,uX,J1,dX,Z1,pX,Y1,fX,Q1,mX,X1,gX,eF,hX,tF,yX,nF,wX,rF,bX,oF,vX,iF,kX,sF,RX,aF,xX,$X,cF,SX,EX,YTe,Sa,mlt,glt,hlt,ylt,wlt,blt,vlt,klt,Rlt,xlt,$lt,Slt,Elt,Olt,SS=x(()=>{Sr={},$S={},qc={};cF={};YTe=ZTe(),Sa=qTe(YTe),{Type:mlt,Schema:glt,FAILSAFE_SCHEMA:hlt,JSON_SCHEMA:ylt,CORE_SCHEMA:wlt,DEFAULT_SCHEMA:blt,load:vlt,loadAll:klt,dump:Rlt,YAMLException:xlt,types:$lt,safeLoad:Slt,safeLoadAll:Elt,safeDump:Olt}=Sa});import{existsSync as QTe,readFileSync as OS}from"node:fs";import{isAbsolute as dF,join as pF,relative as fF,resolve as mF}from"node:path";function HX(e=[]){let t=new Map;for(let n of[...zX,...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 qX(){return HX()}function VX(e,t,n){if("directory"in e.probe)return!0;if("chantProject"in e.probe)return yF(t,n);if("repo"in e.probe)return!0;let{anyFile:r,anyBlock:o,anyJsonKey:i,anyLine:s,anyDocument:a}=e.probe;if(r&&Ky(t,n,r).length>0)return!0;if(i)for(let c of Ky(t,n,i.in))try{let l=JSON.parse(t.read(c));if(i.pointers.some(u=>KX(l,u)!==void 0))return!0}catch{}if(s){let c=s.starts.map(l=>l.toLowerCase());for(let l of Ky(t,n,s.in))try{if(t.read(l).split(/\r?\n/).some(u=>c.some(d=>u.trimStart().toLowerCase().startsWith(d))))return!0}catch{}}if(a)for(let c of Ky(t,n,a.in))try{if(tDe(t.read(c)).some(l=>a.match.some(u=>nDe(l,u))))return!0}catch{}if(o){let c=new RegExp(`^\\s*(?:${o.blocks.map(hF).join("|")})\\s*\\{`,"m");for(let l of Ky(t,n,o.in))try{if(c.test(t.read(l)))return!0}catch{}}return!1}function Ky(e,t,n){let r=[],o=n.filter(i=>i.includes("*"));for(let i of n)!i.includes("*")&&e.stat(Fe(t,i))==="file"&&r.push(Fe(t,i));if(o.length>0){let i=o.map(s=>new RegExp(`^${s.split("*").map(a=>hF(a).replace(/\\\[0-9\\\]/g,"[0-9]")).join("[^/]*")}$`));for(let s of e.list(t)??[])s.type==="file"&&i.some(a=>a.test(s.name))&&r.push(Fe(t,s.name))}return r.sort()}function tDe(e){try{return Sa.loadAll(e)}catch{try{return Sa.loadAll(e.replace(/(^|[\s:\-[,{])!(?:[A-Za-z][\w]*:?)+/gm,"$1"))}catch{return[]}}}function nDe(e,t){let n=Object.entries(t);return n.length>0&&n.every(([r,o])=>{let i=KX(e,r);return i===void 0?!1:o.some(s=>new RegExp(`^${s.split("*").map(hF).join(".*")}$`).test(String(i)))})}function KX(e,t){let n=e;for(let r of t.split("/").slice(1)){let o=r.replace(/~1/g,"/").replace(/~0/g,"~");if(n===null||typeof n!="object"||!Object.prototype.hasOwnProperty.call(n,o))return;n=n[o]}return n}function hF(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function yF(e,t){let n=Fe(t,"package.json");if(e.stat(n)==="file")try{let o=JSON.parse(e.read(n));for(let i of["dependencies","devDependencies","peerDependencies"]){let s=o[i];if(s&&typeof s=="object"&&Object.keys(s).some(iDe))return!0}}catch{}let r=(o,i)=>{let s=e.list(o)??[];return s.some(a=>a.type==="file"&&rDe.includes(a.name))?!0:i===oDe?!1:s.some(a=>a.type==="dir"&&!jo(a.name)&&r(Fe(o,a.name),i+1))};return r(t,0)}function iDe(e){return e==="@intentius/chant"||e.startsWith("@intentius/chant-lexicon-")}function sDe(){if(ES)return ES;let e=$a();return ES=new e({allErrors:!0,strict:!0}).compile(RL),ES}function aDe(e,t){let n;try{n=JSON.parse(e)}catch(a){return{kinds:[],problems:[`${t}: the kinds file is not JSON (${a.message})`]}}let r=sDe();if(!r(n)){let a=(r.errors??[]).map(c=>`${t}: ${c.instancePath||"the kinds file"} ${c.message??"is invalid"}`);return{kinds:[],problems:[...new Set(a)]}}let o=[],i=[],s=new Set;for(let a of n.kinds){if(eDe.includes(a.name)){o.push(`${t}: kind ${a.name} is built in and can't be supplied by a package`);continue}if(s.has(a.name)){o.push(`${t}: kind ${a.name} is listed twice`);continue}s.add(a.name),i.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]}}:{},...a.probe.anyLine?{anyLine:{in:[...a.probe.anyLine.in],starts:[...a.probe.anyLine.starts]}}:{},...a.probe.anyDocument?{anyDocument:{in:[...a.probe.anyDocument.in],match:a.probe.anyDocument.match.map(c=>structuredClone(c))}}:{}},precedence:a.precedence,shape:"member",outputs:{from:"declared",names:[...a.outputs??[]]},source:t,...a.graph?{graph:{...a.graph.lexicon?{lexicon:a.graph.lexicon}:{},...a.graph.reader?{reader:a.graph.reader}:{},config:structuredClone(a.graph.config??{})}}:{},...a.fields?{fields:structuredClone(a.fields)}:{},...a.reader&&uF.includes(a.reader)?{reader:a.reader}:{},...a.memberFile?{memberFile:{path:a.memberFile.path,schema:a.memberFile.schema}}:{}}),a.reader&&!uF.includes(a.reader)&&o.push(`${t}: kind ${a.name} names link reader ${a.reader}, which this chant does not have (it has ${uF.join(", ")}); the kind is kept, and its members' links are only those their entries state`);for(let c of dDe(a.fields??{}))o.push(`${t}: kind ${a.name} ${c}`)}return{kinds:i,problems:o}}function cDe(e,t=gF){return _L(e,t)}function lDe(e,t){let n=pF(e,"package.json"),r;try{r=JSON.parse(OS(n,"utf-8"))}catch{return{kinds:[],problems:[`${t??e}: no readable package.json in ${e}`],file:void 0}}let o=t??(typeof r.name=="string"?r.name:e),i=cDe(r);if(i===void 0)return{kinds:[],problems:[],file:void 0};if(typeof i!="string")return{kinds:[],problems:[`${o}: ${i.problem}`],file:void 0};let s=mF(e,i),a=fF(e,s);if(a.startsWith("..")||dF(a))return{kinds:[],problems:[`${o}: exports["${gF}"] points outside the package`],file:void 0};let c;try{c=OS(s,"utf-8")}catch{return{kinds:[],problems:[`${o}: exports["${gF}"] names ${i}, which does not exist`],file:s}}let l=aDe(c,o),u=typeof r.name=="string"?r.name:void 0;for(let d of l.kinds){if(d.packageDir=e,d.memberFile){let p=uDe(d.memberFile,e);p&&l.problems.push(`${o}: kind ${d.name} ${p}; members of the kind fail WSP012 until it is fixed`)}if(d.graph?.reader){let p=mF(e,...d.graph.reader.split("/")),f=fF(e,p);f.startsWith("..")||dF(f)?(l.problems.push(`${o}: kind ${d.name} names graph reader ${d.graph.reader}, which is outside the package; the kind is kept, and workspace graph lists its members with kind-not-run`),delete d.graph):QTe(p)?d.graph.readerFile=p:(l.problems.push(`${o}: kind ${d.name} names graph reader ${d.graph.reader}, which does not exist in the package; the kind is kept, and workspace graph lists its members with kind-not-run`),delete d.graph)}else d.graph?.lexicon&&u!==PS(d.graph.lexicon)&&(l.problems.push(`${o}: kind ${d.name} reads its members with lexicon ${d.graph.lexicon}, which is ${PS(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{...l,file:s}}function uDe(e,t){let n=mF(t,...e.schema.split("/"));e.schemaFile=n;let r=fF(t,n);if(r.startsWith("..")||dF(r))return`names member-file schema ${e.schema}, which is outside the package`;let o;try{o=JSON.parse(OS(n,"utf-8"))}catch(i){return i.code==="ENOENT"?`names member-file schema ${e.schema}, which does not exist`:`names member-file schema ${e.schema}, which is not JSON (${i.message})`}if(o===null||typeof o!="object"||Array.isArray(o))return`names member-file schema ${e.schema}, which is not a JSON Schema object`;try{let i=$a();e.validate=new i({allErrors:!0,strict:!1}).compile(o)}catch(i){return`names member-file schema ${e.schema}, which does not compile as a draft 2020-12 schema (${i.message})`}}function PS(e){return`@intentius/chant-lexicon-${e}`}function wF(e,t){let n=o=>o.replace(/\{(member|dir|workspace)\}/g,(i,s)=>t[s]),r=o=>typeof o=="string"?n(o):Array.isArray(o)?o.map(r):o!==null&&typeof o=="object"?Object.fromEntries(Object.entries(o).map(([i,s])=>[n(i),r(s)])):o;return r(e)}function bF(e,t){if(e.package){let n=Lc(e.package,t);if(!n)return{problem:`pinned package ${e.package} is not installed; install it to read the kinds it supplies`};let r;try{r=JSON.parse(OS(pF(n,"package.json"),"utf-8")).version}catch{r=void 0}return e.version&&r!==e.version?{problem:`${e.package} is pinned at ${e.version}, and ${String(r??"an unknown version")} is installed`}:{dir:n,source:e.package}}if(e.path){let n=pF(t,...e.path.split("/"));if(e.integrity){let r=t8(n,e.integrity,e.path);if(!r.ok)return{problem:r.message}}return{dir:n,source:e.path}}return null}function Vc(e,t){let n=[],r=[],o=new Map,i=new Set;return e.forEach((s,a)=>{let c=bF(s,t);if(c===null)return;if("problem"in c){n.push({pin:a,message:c.problem});return}let{dir:l,source:u}=c,d=lDe(l,u);for(let p of d.problems)n.push({pin:a,message:p});for(let p of d.kinds){let f=o.get(p.name);if(f){i.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}o.set(p.name,u),r.push(p)}}),{registry:HX(r.filter(s=>!i.has(s.name))),problems:n}}function JX(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 r;try{r=new RegExp(e.pattern,"u")}catch{return}if(!r.test(t))return`is ${JSON.stringify(t)}, which does not match ${e.pattern}`}}function dDe(e){let t=[],n=(r,o)=>{if(o.pattern!==void 0)try{new RegExp(o.pattern,"u")}catch{t.push(`declares field ${r} with pattern ${o.pattern}, which is not a regular expression`);return}if(o.default===void 0)return;let i=JX(o,o.default);i&&t.push(`declares field ${r} whose default ${i}`)};for(let[r,o]of Object.entries(e))if(o.type==="object")for(let[i,s]of Object.entries(o.properties))n(`${r}.${i}`,s);else n(r,o);return t}function vF(e,t){if(e===void 0)return{fields:null,problems:[]};let n=e.fields,r=[];if(n===void 0)return t!==null&&r.push({path:"",message:`kind ${e.name} declares no fields, and the entry sets ${Object.keys(t).join(", ")||"an empty fields block"}`}),{fields:null,problems:r};let o=t??{};for(let a of Object.keys(o))a in n||r.push({path:a,message:`kind ${e.name} declares no field ${a}; its fields are ${Object.keys(n).join(", ")}`});let i=(a,c,l)=>{if(l!==void 0){let u=JX(c,l);if(!u)return l;r.push({path:a,message:`field ${a.replace("/",".")} ${u}`})}return c.default??null},s={};for(let[a,c]of Object.entries(n)){if(c.type!=="object"){s[a]=i(a,c,o[a]);continue}let l=o[a],u={};l!==void 0&&(l!==null&&typeof l=="object"&&!Array.isArray(l)?u=l:r.push({path:a,message:`field ${a} is ${JSON.stringify(l)}, and the field is an object`}));for(let d of Object.keys(u))d in c.properties||r.push({path:`${a}/${d}`,message:`kind ${e.name} declares no field ${a}.${d}; ${a} has ${Object.keys(c.properties).join(", ")}`});s[a]=Object.fromEntries(Object.entries(c.properties).map(([d,p])=>[d,i(`${a}/${d}`,p,u[d])]))}return{fields:s,problems:r}}var Llt,gF,uF,CS,Ea,XTe,zX,eDe,rDe,oDe,ES,ai=x(()=>{"use strict";ZZ();zt();n8();rf();Hy();SS();Llt=RL.$id,gF="./workspace-kinds",uF=["dbt-project","goose-dir","golang-migrate-dir","clickhouse-migrations-dir","flyway-dir"],CS="examples",Ea="repo",XTe="design",zX=[{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:Ea,description:"another repository's workspace, named by URL and pinned revision; chant reads it through that repository's own chant workspace graph and never writes there",probe:{repo:!0},precedence:0,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:XTe,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:CS,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"}],eDe=zX.map(e=>e.name);rDe=["chant.config.ts","chant.config.json"],oDe=4});function Gu(e){return String(e).replace(/~/g,"~0").replace(/\//g,"~1")}function Kc(e,t){let n=[0];for(let h=0;h<e.length;h++)e.charCodeAt(h)===10&&n.push(h+1);let r=h=>{let y=0,b=n.length-1;for(;y<b;){let R=y+b+1>>1;n[R]<=h?y=R:b=R-1}return{line:y+1,column:h-n[y]+1}},o=new Map,i=new Map,s=new Map,a=e.charCodeAt(0)===65279?1:0,c=(h,y=a)=>{throw new AS(h,y)},l=h=>h>=e.length?"the end of the file":`${JSON.stringify(e[h])}`;function u(){for(;;){let h=e[a];if(h===" "||h===" "||h===`
103
103
  `||h==="\r")a++;else if(h==="/"&&(e[a+1]==="/"||e[a+1]==="*"))if(t.jsonc||c("comments are only allowed in chant.workspace.jsonc"),e[a+1]==="/")for(;a<e.length&&e[a]!==`
104
- `;)a++;else{let y=e.indexOf("*/",a+2);y<0&&c("unterminated /* comment"),a=y+2}else return}}function d(){let h=a;for(a++;;){a>=e.length&&c("unterminated string",h);let y=e.charCodeAt(a);if(y===34)break;y<32&&c("control character in a string; escape it",a),a+=y===92?2:1}a++;try{return JSON.parse(e.slice(h,a))}catch{return c("invalid escape in a string",h)}}function p(h){u(),o.set(h,a);let y=f(h);return i.set(h,a),y}function f(h){let y=e[a];if(y==="{")return m(h);if(y==="[")return g(h);if(y==='"')return d();for(let[R,k]of[["true",!0],["false",!1],["null",null]])if(e.startsWith(R,a))return a+=R.length,k;let b=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/.exec(e.slice(a,a+64));return b?(a+=b[0].length,Number(b[0])):c(`expected a value, found ${l(a)}`)}function m(h){let y={},b=new Set;if(a++,u(),e[a]==="}")return a++,y;for(;;){u(),e[a]!=='"'&&c(`expected a quoted key, found ${l(a)}`);let R=a,k=d();b.has(k)&&c(`duplicate key ${JSON.stringify(k)}`,R),b.add(k);let $=`${h}/${Gu(k)}`;if(s.set($,R),u(),e[a]!==":"&&c(`expected ":" after key ${JSON.stringify(k)}, found ${l(a)}`),a++,Object.defineProperty(y,k,{value:p($),enumerable:!0,writable:!0,configurable:!0}),u(),e[a]===","){if(a++,u(),e[a]==="}")return t.jsonc||c("trailing comma; only chant.workspace.jsonc allows one"),a++,y;continue}if(e[a]==="}")return a++,y;c(`expected "," or "}", found ${l(a)}`)}}function g(h){let y=[];if(a++,u(),e[a]==="]")return a++,y;for(;;){if(y.push(p(`${h}/${y.length}`)),u(),e[a]===","){if(a++,u(),e[a]==="]")return t.jsonc||c("trailing comma; only chant.workspace.jsonc allows one"),a++,y;continue}if(e[a]==="]")return a++,y;c(`expected "," or "]", found ${l(a)}`)}}try{u(),a>=e.length&&c("the file is empty");let h=p("");return u(),a<e.length&&c(`unexpected ${l(a)} after the value`),{ok:!0,value:h,locate(y,b){if(b&&s.has(y))return r(s.get(y));for(let R=y;;R=R.slice(0,R.lastIndexOf("/"))){let k=o.get(R);if(k!==void 0)return r(k);if(R==="")return r(0)}},span(y){let b=o.get(y),R=i.get(y);if(!(b===void 0||R===void 0))return{key:s.get(y)??null,start:b,end:R}}}}catch(h){if(!(h instanceof AS))throw h;return{ok:!1,message:h.message,location:r(h.offset)}}}var AS,xf=x(()=>{"use strict";AS=class extends Error{constructor(n,r){super(n);this.offset=r}}});function ZX(){return"0.124.57"}var YX=x(()=>{"use strict"});function $f(e=process.env){let t=e.CI?.trim().toLowerCase();return t&&t!=="false"&&t!=="0"?"ledger":void 0}function _S(e){if(e!==void 0)return typeof e=="string"?{name:e}:e}function Wu(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 r=typeof e=="string"?{name:e}:e;if(r===null||typeof r!="object"||Array.isArray(r))return[...n,"`point` is a decision point's name or { name, inputs?, pass?, store? }"];let{name:o,inputs:i,pass:s,store:a,...c}=r;if((typeof o!="string"||!pDe.test(o))&&n.push("`point.name` is a decision point's name: lower case letters, digits and hyphens, starting with a letter"),i!==void 0&&(i===null||typeof i!="object"||Array.isArray(i))&&n.push("`point.inputs` is an object of input name to value"),i&&typeof i=="object"){let u=Object.keys(i).filter(d=>d in Jy);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 l=Object.keys(c);return l.length>0&&n.push(`\`point\` takes name, inputs, pass and store, not ${l.join(", ")}`),n}function Bu(e,t,n,r={}){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 o={};for(let[i,s]of Object.entries(Jy))t.includes(i)&&n[s]!==null&&(o[i]=n[s]);return{...r,...o}}function Zy(e,t,n){return`gate:${e}/${t}${n?`@${n}`:""}`}function IS(e){if(!e||!e.startsWith("gate:"))return;let t=e.slice(5),n=t.lastIndexOf("@"),r=n>0?t.slice(0,n):t,o=r.indexOf("/");if(!(o<=0||o===r.length-1))return{op:r.slice(0,o),gate:r.slice(o+1),...n>0?{env:t.slice(n+1)}:{}}}var Sf,pDe,Jy,Oa=x(()=>{"use strict";Sf=[!0];pDe=/^[a-z][a-z0-9-]*$/;Jy={"gate.component":"component","gate.name":"name","gate.env":"env","gate.planDigest":"planDigest"}});function ci(e){return e===void 0?[]:Array.isArray(e)?[...e]:[e]}function kF(e,t){let n=e.replace(/\\/g,"/").replace(/\/+$/,""),r="";for(let o=0;o<n.length;o++){let i=n[o];i==="*"&&n[o+1]==="*"?n[o+2]==="/"?(r+="(?:.*/)?",o+=2):(r+=".*",o+=1):i==="*"?r+="[^/]*":i==="?"?r+="[^/]":r+=i.replace(/[.+^${}()|[\]\\]/g,"\\$&")}return new RegExp(`^${r}$`).test(t.replace(/\\/g,"/").replace(/\/+$/,""))}function Ef(e,t){return e.filter(n=>n.targets===void 0||n.targets.some(r=>t.some(o=>kF(r,o))))}function Qy(e){return e.reduce((t,n)=>Math.max(t,n.count),1)}function li(e,t,n){let r=Array.isArray(e)?e:[e],o=[];return Array.isArray(e)&&e.length===0&&o.push(`\`${t}\` must name at least one rule`),r.forEach((i,s)=>{let a=Array.isArray(e)?`${t}[${s}]`:t;if(typeof i!="object"||i===null||Array.isArray(i)){o.push(`\`${a}\` must be an object`);return}let c=i;(typeof c.count!="number"||!Number.isInteger(c.count)||c.count<1)&&o.push(`\`${a}.count\` must be an integer of at least 1`),c.roles!==void 0&&(!Array.isArray(c.roles)||c.roles.length===0||c.roles.some(u=>typeof u!="string"||u===""))&&o.push(`\`${a}.roles\` must be a non-empty list of role names`),c.targets!==void 0&&(!Array.isArray(c.targets)||c.targets.length===0||c.targets.some(u=>typeof u!="string"||u===""))&&o.push(`\`${a}.targets\` must be a non-empty list of globs`),c.notAuthor!==void 0&&typeof c.notAuthor!="boolean"&&o.push(`\`${a}.notAuthor\` must be true or false`),c.notAuthor===!0&&!n.notAuthor&&o.push(`\`${a}.notAuthor\` is not read here: an Op gate has no author to judge by. An Op waves spec's \`approvals.quorum\` reads it from the merged pull request`);let l=new Set(["targets","count","roles","notAuthor"]);for(let u of Object.keys(c))l.has(u)||o.push(`\`${a}.${u}\` is not a quorum field; use targets, count, roles or notAuthor`)}),o}function DS(e,t){return Object.entries(t).filter(([,n])=>n.some(r=>No(r,e))).map(([n])=>n).sort()}function Xy(e,t){let n=new Set,r=[];for(let s of[...t].sort((a,c)=>Date.parse(a.at)-Date.parse(c.at)))n.has(TS(s.who))||s.judged.excluded!==void 0||e.roles?.length&&!(s.judged.proven&&s.judged.roles.some(a=>e.roles.includes(a)))||(n.add(TS(s.who)),r.push(s));let o=!e.notAuthor||r.some(s=>s.judged.proven&&s.judged.author===!1),i=e.notAuthor===!0&&!o&&r.some(s=>s.judged.proven&&s.judged.author===void 0);return{...e.targets?{targets:[...e.targets]}:{},count:e.count,...e.roles?.length?{roles:[...e.roles]}:{},...e.notAuthor?{notAuthor:!0}:{},approvers:r.map(s=>s.who),met:r.length>=e.count&&o,...i?{authorUnknown:!0}:{}}}function Jc(e){let t=e.targets?e.targets.join(", "):"every target",n=`${e.approvers.length} of ${e.count} approval${e.count===1?"":"s"}${e.approvers.length?` (${e.approvers.join(", ")})`:""}`;if(e.met)return`${t}: ${n}, met`;let r=e.count-e.approvers.length,o=[];r>0&&o.push(`${r} more${e.roles?.length?` from ${e.roles.join(" or ")}`:""}`),e.notAuthor&&o.push(r>0?"one of them not the author":"an approver who is not the author");let i=e.authorUnknown?" (the change's author is not known, so no approver can show they are someone else)":"";return`${t}: ${n}, needs ${o.join(", ")}${i}`}function ew(e){return e.filter(t=>!t.met).map(Jc).join("; ")}function jS(e){let t=[];for(let n of e.replace(/\r\n/g,`
104
+ `;)a++;else{let y=e.indexOf("*/",a+2);y<0&&c("unterminated /* comment"),a=y+2}else return}}function d(){let h=a;for(a++;;){a>=e.length&&c("unterminated string",h);let y=e.charCodeAt(a);if(y===34)break;y<32&&c("control character in a string; escape it",a),a+=y===92?2:1}a++;try{return JSON.parse(e.slice(h,a))}catch{return c("invalid escape in a string",h)}}function p(h){u(),o.set(h,a);let y=f(h);return i.set(h,a),y}function f(h){let y=e[a];if(y==="{")return m(h);if(y==="[")return g(h);if(y==='"')return d();for(let[R,k]of[["true",!0],["false",!1],["null",null]])if(e.startsWith(R,a))return a+=R.length,k;let b=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/.exec(e.slice(a,a+64));return b?(a+=b[0].length,Number(b[0])):c(`expected a value, found ${l(a)}`)}function m(h){let y={},b=new Set;if(a++,u(),e[a]==="}")return a++,y;for(;;){u(),e[a]!=='"'&&c(`expected a quoted key, found ${l(a)}`);let R=a,k=d();b.has(k)&&c(`duplicate key ${JSON.stringify(k)}`,R),b.add(k);let $=`${h}/${Gu(k)}`;if(s.set($,R),u(),e[a]!==":"&&c(`expected ":" after key ${JSON.stringify(k)}, found ${l(a)}`),a++,Object.defineProperty(y,k,{value:p($),enumerable:!0,writable:!0,configurable:!0}),u(),e[a]===","){if(a++,u(),e[a]==="}")return t.jsonc||c("trailing comma; only chant.workspace.jsonc allows one"),a++,y;continue}if(e[a]==="}")return a++,y;c(`expected "," or "}", found ${l(a)}`)}}function g(h){let y=[];if(a++,u(),e[a]==="]")return a++,y;for(;;){if(y.push(p(`${h}/${y.length}`)),u(),e[a]===","){if(a++,u(),e[a]==="]")return t.jsonc||c("trailing comma; only chant.workspace.jsonc allows one"),a++,y;continue}if(e[a]==="]")return a++,y;c(`expected "," or "]", found ${l(a)}`)}}try{u(),a>=e.length&&c("the file is empty");let h=p("");return u(),a<e.length&&c(`unexpected ${l(a)} after the value`),{ok:!0,value:h,locate(y,b){if(b&&s.has(y))return r(s.get(y));for(let R=y;;R=R.slice(0,R.lastIndexOf("/"))){let k=o.get(R);if(k!==void 0)return r(k);if(R==="")return r(0)}},span(y){let b=o.get(y),R=i.get(y);if(!(b===void 0||R===void 0))return{key:s.get(y)??null,start:b,end:R}}}}catch(h){if(!(h instanceof AS))throw h;return{ok:!1,message:h.message,location:r(h.offset)}}}var AS,xf=x(()=>{"use strict";AS=class extends Error{constructor(n,r){super(n);this.offset=r}}});function ZX(){return"0.124.58"}var YX=x(()=>{"use strict"});function $f(e=process.env){let t=e.CI?.trim().toLowerCase();return t&&t!=="false"&&t!=="0"?"ledger":void 0}function _S(e){if(e!==void 0)return typeof e=="string"?{name:e}:e}function Wu(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 r=typeof e=="string"?{name:e}:e;if(r===null||typeof r!="object"||Array.isArray(r))return[...n,"`point` is a decision point's name or { name, inputs?, pass?, store? }"];let{name:o,inputs:i,pass:s,store:a,...c}=r;if((typeof o!="string"||!pDe.test(o))&&n.push("`point.name` is a decision point's name: lower case letters, digits and hyphens, starting with a letter"),i!==void 0&&(i===null||typeof i!="object"||Array.isArray(i))&&n.push("`point.inputs` is an object of input name to value"),i&&typeof i=="object"){let u=Object.keys(i).filter(d=>d in Jy);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 l=Object.keys(c);return l.length>0&&n.push(`\`point\` takes name, inputs, pass and store, not ${l.join(", ")}`),n}function Bu(e,t,n,r={}){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 o={};for(let[i,s]of Object.entries(Jy))t.includes(i)&&n[s]!==null&&(o[i]=n[s]);return{...r,...o}}function Zy(e,t,n){return`gate:${e}/${t}${n?`@${n}`:""}`}function IS(e){if(!e||!e.startsWith("gate:"))return;let t=e.slice(5),n=t.lastIndexOf("@"),r=n>0?t.slice(0,n):t,o=r.indexOf("/");if(!(o<=0||o===r.length-1))return{op:r.slice(0,o),gate:r.slice(o+1),...n>0?{env:t.slice(n+1)}:{}}}var Sf,pDe,Jy,Oa=x(()=>{"use strict";Sf=[!0];pDe=/^[a-z][a-z0-9-]*$/;Jy={"gate.component":"component","gate.name":"name","gate.env":"env","gate.planDigest":"planDigest"}});function ci(e){return e===void 0?[]:Array.isArray(e)?[...e]:[e]}function kF(e,t){let n=e.replace(/\\/g,"/").replace(/\/+$/,""),r="";for(let o=0;o<n.length;o++){let i=n[o];i==="*"&&n[o+1]==="*"?n[o+2]==="/"?(r+="(?:.*/)?",o+=2):(r+=".*",o+=1):i==="*"?r+="[^/]*":i==="?"?r+="[^/]":r+=i.replace(/[.+^${}()|[\]\\]/g,"\\$&")}return new RegExp(`^${r}$`).test(t.replace(/\\/g,"/").replace(/\/+$/,""))}function Ef(e,t){return e.filter(n=>n.targets===void 0||n.targets.some(r=>t.some(o=>kF(r,o))))}function Qy(e){return e.reduce((t,n)=>Math.max(t,n.count),1)}function li(e,t,n){let r=Array.isArray(e)?e:[e],o=[];return Array.isArray(e)&&e.length===0&&o.push(`\`${t}\` must name at least one rule`),r.forEach((i,s)=>{let a=Array.isArray(e)?`${t}[${s}]`:t;if(typeof i!="object"||i===null||Array.isArray(i)){o.push(`\`${a}\` must be an object`);return}let c=i;(typeof c.count!="number"||!Number.isInteger(c.count)||c.count<1)&&o.push(`\`${a}.count\` must be an integer of at least 1`),c.roles!==void 0&&(!Array.isArray(c.roles)||c.roles.length===0||c.roles.some(u=>typeof u!="string"||u===""))&&o.push(`\`${a}.roles\` must be a non-empty list of role names`),c.targets!==void 0&&(!Array.isArray(c.targets)||c.targets.length===0||c.targets.some(u=>typeof u!="string"||u===""))&&o.push(`\`${a}.targets\` must be a non-empty list of globs`),c.notAuthor!==void 0&&typeof c.notAuthor!="boolean"&&o.push(`\`${a}.notAuthor\` must be true or false`),c.notAuthor===!0&&!n.notAuthor&&o.push(`\`${a}.notAuthor\` is not read here: an Op gate has no author to judge by. An Op waves spec's \`approvals.quorum\` reads it from the merged pull request`);let l=new Set(["targets","count","roles","notAuthor"]);for(let u of Object.keys(c))l.has(u)||o.push(`\`${a}.${u}\` is not a quorum field; use targets, count, roles or notAuthor`)}),o}function DS(e,t){return Object.entries(t).filter(([,n])=>n.some(r=>No(r,e))).map(([n])=>n).sort()}function Xy(e,t){let n=new Set,r=[];for(let s of[...t].sort((a,c)=>Date.parse(a.at)-Date.parse(c.at)))n.has(TS(s.who))||s.judged.excluded!==void 0||e.roles?.length&&!(s.judged.proven&&s.judged.roles.some(a=>e.roles.includes(a)))||(n.add(TS(s.who)),r.push(s));let o=!e.notAuthor||r.some(s=>s.judged.proven&&s.judged.author===!1),i=e.notAuthor===!0&&!o&&r.some(s=>s.judged.proven&&s.judged.author===void 0);return{...e.targets?{targets:[...e.targets]}:{},count:e.count,...e.roles?.length?{roles:[...e.roles]}:{},...e.notAuthor?{notAuthor:!0}:{},approvers:r.map(s=>s.who),met:r.length>=e.count&&o,...i?{authorUnknown:!0}:{}}}function Jc(e){let t=e.targets?e.targets.join(", "):"every target",n=`${e.approvers.length} of ${e.count} approval${e.count===1?"":"s"}${e.approvers.length?` (${e.approvers.join(", ")})`:""}`;if(e.met)return`${t}: ${n}, met`;let r=e.count-e.approvers.length,o=[];r>0&&o.push(`${r} more${e.roles?.length?` from ${e.roles.join(" or ")}`:""}`),e.notAuthor&&o.push(r>0?"one of them not the author":"an approver who is not the author");let i=e.authorUnknown?" (the change's author is not known, so no approver can show they are someone else)":"";return`${t}: ${n}, needs ${o.join(", ")}${i}`}function ew(e){return e.filter(t=>!t.met).map(Jc).join("; ")}function jS(e){let t=[];for(let n of e.replace(/\r\n/g,`
105
105
  `).split(`
106
106
  `)){let r=/^requested-by:\s*(\S+)\s*$/i.exec(n.trim());r&&fDe.test(r[1])&&!t.some(o=>No(o,r[1]))&&t.push(r[1])}return t}function Yy(e){let t=/^(?:github|gitlab|forgejo|gitea|codeberg)(?:@[^:\s]+)?:(.+)$/i.exec(e.trim());return t?[e,t[1]]:[e]}function NS(e,t){let n=Yy(t);return e.find(r=>Yy(r.who).some(o=>n.some(i=>No(o,i))))?.why}function tw(e){let t=[],n=(r,o)=>{r.trim()&&!t.some(i=>No(i.who,r))&&t.push({who:r,why:o})};e.author&&n(e.author,`${e.author} opened the change`);for(let r of e.commits??[])for(let o of jS(r.message))n(e.principal?e.principal(o):o,`${o} asked for ${r.sha.slice(0,7)}`);for(let r of e.agents??[])n(r,`${r} is an account an agent acts as`);return t}function LS(e){let t=e;return t.via!=="pr-review"||typeof t.head!="string"||t.head===""||!Array.isArray(t.reviewers)||t.reviewers.length===0||t.reviewers.some(n=>typeof n!="string"||n==="")?null:{...typeof t.pr=="number"?{pr:t.pr}:{},head:t.head,reviewers:[...t.reviewers]}}function nw(e,t=n=>n){let n=[],r=[];for(let o of e){let i=LS(o);if(!i){n.push(o);continue}let s=i.reviewers.map(t);r.push({head:i.head,approvers:s});let{seal:a,...c}=o,l=Object.fromEntries(Object.entries(c).filter(([u])=>!["via","reviewers","head","pr","excluded"].includes(u)));for(let u of s)n.push({...l,resolvedBy:u,approver:{kind:"human"},review:{pr:i.pr??0,head:i.head,approvers:s}})}return{records:n,reviews:r}}function ui(e){let t=(n,r)=>n.some(o=>No(o,r));return n=>{let r=n.seal!==void 0&&n.seal!==null&&Rs(e.signers,n)===null,o=e.review!==void 0&&n.review?.head===e.review.head&&t(e.review.approvers,n.resolvedBy),i=n.review!==void 0&&(e.recorded??[]).some(l=>l.head===n.review.head&&t(l.approvers,n.resolvedBy)),s=r||o||i,c=e.authors!==void 0&&e.authors.some(l=>No(l,n.resolvedBy))?`${n.resolvedBy} wrote the change`:NS(e.involved??[],n.resolvedBy);return{proven:s,roles:s?DS(n.resolvedBy,e.roles):[],...c!==void 0?{author:!0}:e.authors!==void 0?{author:!1}:{},...c!==void 0&&e.excludeInvolved?{excluded:`${c}, so ${n.resolvedBy}'s approval does not count`}:{}}}}var Pa,TS,No,Ca,fDe,Lo=x(()=>{"use strict";ba();Pa=()=>({proven:!1,roles:[]});TS=e=>e.normalize("NFKC").trim().toLowerCase(),No=(e,t)=>TS(e)===TS(t);Ca=e=>(e.roles?.length??0)>0||e.notAuthor===!0,fDe=/^[A-Za-z0-9][A-Za-z0-9._-]*(\[bot\])?$/});function RF(e,t,n){return(e??MS).replaceAll("{gate}",t).replaceAll("{k}",String(n))}function xF(e,t,n,r){let o=[...e].sort((l,u)=>{let d=r(l),p=r(u);return d<p?-1:d>p?1:0}),i=Math.floor(o.length/n),s=o.length%n,a=(t-1)*i+Math.min(t-1,s),c=i+(t<=s?1:0);return o.slice(a,a+c)}var MS,$F=x(()=>{"use strict";MS="{gate}-wave-{k}"});var n7={};xe(n7,{WAVE_OUTCOME_VERSION:()=>FS,blockedMembers:()=>GS,blockedWords:()=>WS,earlierWaveOutcomes:()=>OF,onlyWaiting:()=>vDe,passesThrough:()=>Of,readWaveOutcomeFile:()=>PF,runSummary:()=>kDe,settleEarlierWaves:()=>bDe,waveOutcomeFileName:()=>Pf,writeWaveOutcomeFile:()=>EF});import{existsSync as mDe,readdirSync as gDe,readFileSync as QX,statSync as hDe,writeFileSync as yDe}from"node:fs";import{basename as wDe,join as XX}from"node:path";function Of(e){return e!==void 0&&SF.has(e.status)}function GS(e,t,n,r,o){if(o!==void 0)return new Map(e.map(s=>[s,`wave-${o}`]));let i=new Map;for(let s of e){let a=[...t.get(s)??[]].filter(c=>n.has(c)).sort().map(c=>{let l=r.get(c);if(!Of(l))return l?.status==="blocked"&&l.by?l.by:c}).find(c=>c!==void 0);a!==void 0&&i.set(s,a)}return i}function bDe(e,t,n,r){let o=new Map(r),i=[],s=new Set;for(let a=1;a<t&&a<=e.length;a++){let c=e[a-1],l=c.filter(d=>!o.has(d)),u=GS(l,n,s,o);for(let d of l){let p=u.get(d);p!==void 0?o.set(d,{status:"blocked",by:p}):i.push(d)}for(let d of c)s.add(d)}return{outcomes:o,unsettled:i}}function vDe(e){let t=!1;for(let n of e.values())if(!SF.has(n.status)&&(t=!0,n.status!=="waiting"&&!(n.status==="blocked"&&n.by!==void 0&&e.get(n.by)?.status==="waiting")))return!1;return t}function WS(e){let t=new Map;for(let[n,r]of[...e].sort(e7))t.set(r,[...t.get(r)??[],n]);return[...t].map(([n,r])=>`${r.join(", ")} (blocked by ${n})`).join("; ")}function kDe(e){let t=new Map;for(let r of e)t.set(r.status,(t.get(r.status)??0)+1);if(![...t.keys()].some(r=>!SF.has(r)))return;let n=[`${t.get("applied")??0} applied`,`${t.get("failed")??0} failed`,`${t.get("blocked")??0} blocked`];for(let r of["waiting","refused","decided","not-applied"])t.get(r)&&n.push(`${t.get(r)} ${r==="decided"?"not reported by their share":r}`);return t.get("unchanged")&&n.push(`${t.get("unchanged")} unchanged`),n.join(", ")}function Pf(e,t={}){let n=t.group!==void 0?`-group-${t.group.replace(/[^A-Za-z0-9._-]/g,"_")}`:"",r=t.share!==void 0?`-share-${t.share}`:"";return`outcome-wave-${e}${n}${r}.json`}function EF(e,t,n,r,o=new Date().toISOString(),i=!1){let s=XX(e,Pf(t,n)),a={version:FS,wave:t,at:o,members:Object.fromEntries(Object.entries(r).sort(e7)),...i?{holds_all:!0}:{}};return yDe(s,JSON.stringify(a,null,2)+`
107
107
  `),s}function t7(e){let t=[],n=(r,o)=>{let i;try{i=gDe(r)}catch{return}for(let s of i){let a=XX(r,s),c=!1;try{c=hDe(a).isDirectory()}catch{continue}c?o<4&&n(a,o+1):/^outcome-wave-\d+.*\.json$/.test(s)&&t.push(a)}};for(let r of e)mDe(r)&&n(r,0);return t.sort()}function OF(e,t){let n=new Map,r=new Map;for(let i of t7(e)){let s;try{s=JSON.parse(QX(i,"utf-8"))}catch{continue}let a=s?.members??s?.roots;if(s?.version!==FS||!Number.isInteger(s.wave)||s.wave>=t||typeof s.at!="string"||typeof a!="object"||a===null)continue;for(let[l,u]of Object.entries(a)){let d=n.get(l);d&&(d.at>s.at||d.at===s.at&&u.status==="decided"&&d.status!=="decided")||n.set(l,{...u,wave:s.wave,at:s.at})}let c=r.get(s.wave);(!c||c.at<=s.at)&&r.set(s.wave,{at:s.at,holdsAll:s.holds_all===!0})}let o=[...r].filter(([,i])=>i.holdsAll).map(([i])=>i).sort((i,s)=>i-s);return{members:n,...o.length?{holdsAll:o[0]}:{}}}function PF(e,t){let n;for(let r of t7(e)){if(wDe(r)!==t)continue;let o;try{o=JSON.parse(QX(r,"utf-8"))}catch{continue}o?.version!==FS||typeof o.at!="string"||typeof o.members!="object"||o.members===null||(!n||n.at<=o.at)&&(n=o)}return n}var FS,SF,e7,rw=x(()=>{"use strict";FS=1,SF=new Set(["applied","unchanged"]);e7=([e],[t])=>e<t?-1:e>t?1:0});function zS(e){let t=e.step;if(t===void 0)return[];if(t===null||typeof t!="object"||Array.isArray(t))return['`step` must be { "kind": "<capability>", ...input }'];let n=[],r=t.kind;(typeof r!="string"||r.trim()==="")&&n.push('`step.kind` must name a capability, such as "terraform-apply"');for(let o of["plan","apply","planWave","applyWave"])e[o]!==void 0&&n.push(`\`step\` and \`${o}\` are both set; a wave plans and applies through its capability or through commands, so give one`);e.hooks?.apply?.runBy==="apply"&&n.push('`hooks.apply.runBy: "apply"` hands the apply-stage hooks to an apply command, and a `step` has none; leave runBy as chant');for(let o of e.waves){o.discover&&n.push(`wave "${o.name}" discovers its runs, which only \`planWave\` can report; a \`step\` plans the runs the spec lists`),o.hooks?.apply?.runBy==="apply"&&n.push(`wave "${o.name}" hands its apply-stage hooks to an apply command, and a \`step\` has none`);for(let i of o.runs??[]){let s=i.input;s!==void 0&&(s===null||typeof s!="object"||Array.isArray(s))&&n.push(`wave "${o.name}" run "${i.target}": \`input\` must be an object laid over the step's input`),s&&typeof s=="object"&&"kind"in s&&n.push(`wave "${o.name}" run "${i.target}": \`input\` cannot change the step's kind`)}}return n}function r7(e){let t=[];for(let[n,r]of[["parallelism",e.parallelism],...e.waves.map(o=>[`wave "${o.name}" parallelism`,o.parallelism])])r!==void 0&&(typeof r!="number"||!Number.isInteger(r)||r<1?t.push(`${n} is ${JSON.stringify(r)}; give a whole number of 1 or more, the most that run at once`):r>1&&e.step===void 0&&t.push(`${n} is ${r}, and runs apply at once only through \`step\`; drop it or give step`));return t}function Cf(e){if(e===void 0)return[];if(e===null||typeof e!="object"||Array.isArray(e))return['`holds` must be { "policy"?: true, "cost"?: {...} }'];let t=[];for(let[n,r]of Object.entries(e))n==="policy"?typeof r!="boolean"&&t.push("`holds.policy` must be true or false"):n==="cost"?t.push(...RDe(r)):t.push(`\`holds.${n}\` is not a setting; the ones there are holds.policy and holds.cost`);return t}function RDe(e){if(e===null||typeof e!="object"||Array.isArray(e))return['`holds.cost` must be { "command": [...], "approveAbove": <number>, "format"?, "currency"? }'];let t=e,n=[];(!Array.isArray(t.command)||t.command.length===0||!t.command.every(r=>typeof r=="string"&&r!==""))&&n.push("`holds.cost.command` must be argv, a non-empty list of strings"),(typeof t.approveAbove!="number"||!Number.isFinite(t.approveAbove)||t.approveAbove<0)&&n.push("`holds.cost.approveAbove` must be a monthly amount of 0 or more"),t.format!==void 0&&!BS.includes(t.format)&&n.push(`\`holds.cost.format\` must be ${BS.join(" or ")}`),t.currency!==void 0&&(typeof t.currency!="string"||!/^[A-Z]{3}$/.test(t.currency))&&n.push('`holds.cost.currency` must be a three-letter currency code, such as "USD"');for(let r of Object.keys(t))["command","approveAbove","format","currency"].includes(r)||n.push(`\`holds.cost.${r}\` is not a setting`);return n}function HS(e,t){let n=e?.policy===!0||t?.policy===!0,r=e!==void 0?e.cost:t?.cost;if(!(!n&&!r))return{...n?{policy:!0}:{},...r?{cost:r}:{}}}var BS,US,qS=x(()=>{"use strict";BS=["infracost","chant"],US="(monthly cost)"});function CF(e){let t=[],n=(r,o,i)=>{if(r!==void 0&&!(r===!1&&i)){if(r===null||typeof r!="object"||Array.isArray(r)){t.push(`${o} must be { "env"?: "<env>", "component"?: "<name>" }${i?" or false":""}`);return}for(let[s,a]of Object.entries(r))s!=="env"&&s!=="component"?t.push(`${o} has an unknown key "${s}"; it takes env and component`):(typeof a!="string"||a.trim()==="")&&t.push(`${o}.${s} must be a non-empty string`)}};n(e.release,"`release`",!0);for(let r of e.waves)for(let o of r.runs??[])n(o.release,`wave "${r.name}" run "${o.target}": \`release\``,!1);return t}function o7(e,t){return e.replaceAll("{target}",t.target).replaceAll("{op}",t.op).replaceAll("{wave}",t.wave)}function AF(e,t,n){if(!e.step||e.release===!1)return null;let r={target:n.target,op:n.op??e.op,wave:t.name},o=e.release??{},i=n.release?.env??o.env,s=n.release?.component??o.component;return{env:i!==void 0?o7(i,r):e.labels?.Env??t.name,component:s!==void 0?o7(s,r):n.target}}function _F(e,t,n,r){let o=new Map;for(let a of t){let c=o.get(a.releaseDigest);(c===void 0||a.timestamp>c)&&o.set(a.releaseDigest,a.timestamp)}let s=e.filter(a=>a.commit===n.commit).map(a=>({r:a,digest:r(a,n.env,n.component)})).filter(a=>a.digest!==null).sort((a,c)=>(o.get(c.r.releaseDigest)??"").localeCompare(o.get(a.r.releaseDigest)??"")||a.r.releaseDigest.localeCompare(c.r.releaseDigest))[0];return s?{releaseDigest:s.r.releaseDigest,templatesDigest:s.digest}:null}var ow=x(()=>{"use strict"});function cw(e){let n=e.replace(/^https?:\/\//,"").replace(/\.git$/,"").replace(/\/+$/,"").split("/");if(n.length<3||n.some(i=>i===""))throw new sw(`project key "${e}" must be <host>/<owner>/<name>, such as github.com/acme/infra`);let[r,...o]=n;return{key:e,host:r,path:o.join("/"),owner:o.slice(0,-1).join("/"),name:o[o.length-1]}}function c7(e){let t=e.toLowerCase().replace(/:\d+$/,"");if(t==="github.com"||t.startsWith("github."))return"github";if(t==="gitlab.com"||t.startsWith("gitlab.")||t.includes(".gitlab."))return"gitlab";if(t==="codeberg.org"||t.startsWith("forgejo.")||t.startsWith("gitea.")||t.includes("forgejo"))return"forgejo"}function SDe(e,t){let n=t.toLowerCase();return e==="github"?n==="github.com"?"https://api.github.com":`https://${t}/api/v3`:e==="gitlab"?`https://${t}/api/v4`:`https://${t}/api/v1`}function jF(e,t="control"){if(typeof e!="object"||e===null||Array.isArray(e))return[`${t} must be a mapping with repo and op`];let n=e,r=[],o;if(typeof n.repo!="string")r.push(`${t}.repo must name the control repo, such as github.com/acme/control`);else try{o=cw(n.repo).host}catch(i){r.push(`${t}.repo: ${i.message}`)}return typeof n.op=="string"&&iw.test(n.op)||r.push(`${t}.op must name the Op the control repo runs on this repo's dependents, such as deploy`),n.forge!==void 0&&!s7.includes(n.forge)&&r.push(`${t}.forge must be one of ${s7.join(", ")}`),o!==void 0&&n.forge===void 0&&!c7(o)&&r.push(`${t}.forge is needed: ${n.repo}'s host does not say which forge it is`),n.member!==void 0&&!(typeof n.member=="string"&&iw.test(n.member))&&r.push(`${t}.member must be this repo's name in the control repo's workspace`),n.tokenSecret!==void 0&&!(typeof n.tokenSecret=="string"&&i7.test(n.tokenSecret))&&r.push(`${t}.tokenSecret must name the secret holding the dispatch token, such as ${IF}`),n.readTokenSecret!==void 0&&!(typeof n.readTokenSecret=="string"&&i7.test(n.readTokenSecret))?r.push(`${t}.readTokenSecret must name the secret holding a read-only token for the control repo, such as ${a7}`):typeof n.readTokenSecret=="string"&&n.readTokenSecret===(n.tokenSecret??IF)&&r.push(`${t}.readTokenSecret must not be the dispatch token's secret (${n.readTokenSecret}): the plan job runs the change's code`),n.ref!==void 0&&!(typeof n.ref=="string"&&xDe.test(n.ref))&&r.push(`${t}.ref must be a branch name`),n.apiBase!==void 0&&!(typeof n.apiBase=="string"&&/^https?:\/\/[^\s'"]+$/.test(n.apiBase))&&r.push(`${t}.apiBase must be an http(s) URL`),r}function l7(e,t){let n=jF(e);if(n.length>0)throw new sw(n.join("; "),n);let r=cw(e.repo),o=e.forge??c7(r.host),i=e.member??t;if(!iw.test(i))throw new sw(`control.member: "${i}" is not a name the control repo's workspace can hold; set control.member`);return{repo:e.repo,host:r.host,path:r.path,forge:o,apiBase:(e.apiBase??SDe(o,r.host)).replace(/\/+$/,""),op:e.op,member:i,ref:e.ref??$De,tokenSecret:e.tokenSecret??IF,readTokenSecret:e.readTokenSecret??a7}}var iw,xDe,i7,IF,a7,TF,aw,DF,$De,sw,s7,u7,lw=x(()=>{"use strict";ti();iw=/^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/,xDe=/^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/,i7=/^[A-Za-z_][A-Za-z0-9_]{0,127}$/,IF="CHANT_CONTROL_TOKEN",a7="CHANT_CONTROL_READ_TOKEN",TF="CHANT_CONTROL_OUTCOME",aw=["applied","partial","unchanged","waiting","failed"],DF=["applied","partial"],$De="main",sw=class extends Error{constructor(n,r=[n]){super(n);this.problems=r;this.name="ControlConfigError"}};s7=["github","gitlab","forgejo"];u7="control-dispatch"});var b7={};xe(b7,{CHECK_HOOK_MOMENT:()=>EDe,CI_CHECK_HOOK_FLOOR:()=>ODe,GATE_APPROVAL_SOURCES:()=>Aa,OP_LEDGER_NAME:()=>Df,OP_WAVES_APPROVAL_STATUS_VAR:()=>NDe,OP_WAVES_CONTROL_FLOOR:()=>PDe,OP_WAVES_CONTROL_JOB:()=>CDe,OP_WAVES_DIGEST_OVER:()=>m7,OP_WAVE_APPLY_HOOKS_RUNNERS:()=>VS,OP_WAVE_DEFAULT_APPLY:()=>ZS,OP_WAVE_DEFAULT_GATE_NAME:()=>MF,OP_WAVE_GATE_POLICIES:()=>If,OP_WAVE_HOOK_FAILURES:()=>Tf,OP_WAVE_HOOK_MOMENTS:()=>dw,OP_WAVE_JOB_TIMEOUT_MINUTES:()=>f7,PR_LOOP_HOOK_MOMENTS:()=>h7,assertCheckHooks:()=>y7,assertOpWaveCloud:()=>FF,assertOpWaveHooks:()=>_a,assertOpWavesSpec:()=>Uu,assertPrLoopHooks:()=>tE,notifyVariables:()=>wZ,opWaveApplyHooksRunBy:()=>mw,opWaveBinArgv:()=>jf,opWaveGateName:()=>pw,opWaveGroupOf:()=>UDe,opWaveGroupRuns:()=>XS,opWaveGroupsProblem:()=>eE,opWaveHookRuns:()=>Lf,opWaveHooksAt:()=>fw,opWaveJobTimeout:()=>TDe,opWaveJobs:()=>w7,opWaveOf:()=>zDe,opWaveOutcomeDir:()=>YS,opWaveOutcomePath:()=>Af,opWavePointAt:()=>KS,opWavePointOf:()=>d7,opWavePointProblems:()=>uw,opWaveRecordPath:()=>Nf,opWaveRunMatches:()=>QS,opWaveShare:()=>gw,opWavesApprovalStatusCommand:()=>MDe,opWavesControlProblems:()=>p7,opWavesControlTarget:()=>ADe,opWavesInvolvedProblems:()=>JS,opWavesLastJobs:()=>IDe,opWavesOutcomeCommand:()=>_De,opWavesPostsApprovalStatus:()=>LDe,opWavesRecordPlansCommand:()=>jDe,opWavesResumeCommand:()=>DDe});function d7(e){if(e!==void 0)return typeof e=="string"?{name:e}:e}function uw(e){if(e!==null&&typeof e=="object"&&!Array.isArray(e)&&"timeout"in e){let{timeout:t,...n}=e,r=Wu(n);return(typeof t!="string"||!/^(\d+(ms|s|m|h|d))+$/.test(t))&&r.push('`point.timeout` is a duration such as "48h"'),r}return Wu(e)}function KS(e,t){let n=e.waves.find(r=>r.name===t);return d7(n?.point??e.point)}function p7(e){let t=jF(e,"control");if(t.length>0)return t;let n=e,r=[];typeof n.member=="string"&&iw.test(n.member)||r.push("control.member must name this repo in the control repo's workspace: an Op waves spec has no repository name to default it to");for(let o of["sentCheck","markSent"])n[o]!==void 0&&!(typeof n[o]=="string"&&n[o]!==""&&!n[o].includes(`
@@ -488,7 +488,7 @@ ${o}${o.endsWith(`
488
488
  `);let S=await i(`
489
489
  Approve this plan for ${h}, ${m}? Type ${h} to approve: `);if(S===null||S.trim()!==h)return o(`Not approved: the answer was not ${h}.
490
490
  `),{status:"refused",code:Ue.declined};if(n.plan===void 0){let C;try{C=Yke((await l(e)).pending,t,n.environment,u)}catch{return{status:"confirmed",plan:m,target:h}}if(C?.planDigest===void 0||!p(C.planDigest,m))return o(`Not approved: the plan moved while you were asked (now ${C?.planDigest??"no pending plan"}); run chant approve ${e} ${t} again.
491
- `),{status:"refused",code:Ue.moved}}return{status:"confirmed",plan:m,target:h}}var tRe=x(()=>{"use strict";Wi()});async function nRe(e){let{pushed:t,pushWarning:n}=await bE();return t?{pushed:t,suffix:""}:qu(n)?{pushed:t,suffix:` (${Hu})`}:(console.error(cr({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 rRe(e){let t=e.args.path,n=e.args.extraPositional;if(!t||t==="."||!n)return console.error($e({message:"Usage: chant approve <op> <gate>"})),1;if(e.args.expire){try{await Hr()}catch(l){return console.error($e({message:`Cannot expire the gate: ${l instanceof Error?l.message:String(l)}`})),1}let s=new Date().toISOString(),a=_n((await gr(t)).pending,n);if(!a||Un(a,s))return console.error(cr({message:`Gate "${n}" on "${t}" has no standing pending fact \u2014 nothing to expire`})),0;await Xf({op:t,gate:n,timestamp:s,expiresAt:s,...a.description?{description:a.description}:{},...a.runId?{runId:a.runId}:{},...a.gitSha?{gitSha:a.gitSha}:{}});let c=await nRe(`The expiry is recorded locally on ${pR}. Until it reaches the remote, a run in another checkout still sees the old pending fact.`);return console.error(Qg(`Gate "${n}" on "${t}" expired at ${s} \u2014 not approved`+c.suffix)),console.error(Kn(t===Kf?"The next `chant components fan-out` decides this gate from scratch and records a fresh pending fact.":NP.test(t)?"The next `chant components pr-apply` decides this gate from scratch and records a fresh pending fact.":t===Aw?`The next \`chant workspace promote ${n}\` decides this gate from scratch and records a fresh pending fact.`:t===Jf?`The next \`chant workspace upgrade ${n}\` decides this gate from scratch and records a fresh pending fact.`:t===Zf?"The next `chant workspace exit` decides this gate from scratch and records a fresh pending fact.":t===yi?"The next `chant components promote --release` 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===el){let{runOverrideApprove:s}=await Promise.resolve().then(()=>(qke(),Hke));return s(e)}if(e.args.rules!==void 0||e.args.reason!==void 0)return console.error($e({message:`--rule and --reason override a denied plan: chant approve ${el} <subject> --rule <id> --reason <text>`,hint:`To approve gate "${n}" on "${t}", put any prose in --note.`})),1;let r=e.args.plan,o=await Promise.resolve().then(()=>(tRe(),eRe));if(await o.interactiveApproval(e.args)){let s=await o.confirmApproval(t,n,{...r!==void 0?{plan:r}:{},...e.args.env!==void 0?{environment:e.args.env}:{}});if(s.status==="refused")return s.code;s.status==="confirmed"&&(r=s.plan)}let i=await V4(t,n,{actor:e.args.approver??e.args.actor,note:e.args.note,url:e.args.url,plan:r,...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:s}=await Promise.resolve().then(()=>(N_(),h4));return s(t,n,i.record.environment,i.pushed)}return console.error(Kn("This records the resolution as a fact; it does not itself re-run anything. "+(t===Kf?`Repeat the \`chant components fan-out\` command and it walks through gate "${n}".`:NP.test(t)?`The pull request's apply (\`chant components pr-apply\`) walks through gate "${n}" when it plans this same digest.`:t===Aw?`Repeat \`chant workspace promote ${n}\`, and it applies the patch this approval names.`:t===Jf?`Repeat \`chant workspace upgrade ${n}\` with the same target, and it applies the patch this approval names.`:t===Zf?"Repeat `chant workspace exit` with the same members, and it applies the patch this approval names.":t===yi?`Repeat the same \`chant components promote --release\`, and it walks through gate "${n}" when it plans this same change set for this release.`:`Run \`chant run ${t}\` and it walks through gate "${n}".`))),0}async function Att(e,t,n,r){let{readRelease:o,readCuts:i,labelsByDigest:s}=await Promise.resolve().then(()=>(Fa(),Pm)),{readRevokedCommits:a,revocationOf:c,revokedRefusal:l}=await Promise.resolve().then(()=>(u_(),iK)),u=await o(n,{cwd:r}).catch(()=>null);if(!u)return console.error($e({message:`Gate "${t}" on "${e}" binds release ${n}, which can't be read from ${pR}, so whether it is revoked is unknown [release-unreadable]`,hint:`Fetch the ledger branch (git fetch origin ${pR}:${pR}) and approve again from the member's directory.`})),!0;let d;try{d=await a(r)}catch(m){return console.error($e({message:`Gate "${t}" on "${e}" binds release ${n}, and the ci tags can't be judged: ${m instanceof Error?m.message:String(m)} [declaration-invalid]`,hint:"Fix ci.green in chant.workspace.json at base; chant workspace check names the problem."})),!0}let p=c(u,d);if(!p)return!1;let f=s((await i({cwd:r}).catch(()=>({cuts:[]}))).cuts).get(n)??null;return console.error($e(l({releaseDigest:n,label:f},p,`Clear the pending gate with \`chant approve ${e} ${t} --expire\`, then promote a release cut from a green commit: \`chant ci last-green\` names the newest, and \`chant release list\` marks the revoked releases.`))),!0}async function V4(e,t,n){if(Ur())return console.error($e({message:`Cannot record the approval of "${t}": ${fi} is set, so nothing is written to chant/lifecycle`,hint:`Unset ${fi} to approve the gate.`})),{ok:!1};let{ops:r}=await _l(),o=bge([...r.values()].map(j=>j.config),e,t);!o&&!r.has(e)&&e!==Kf&&e!==Jf&&e!==Zf&&e!==Aw&&e!==el&&e!==yi&&console.error(cr({message:`Op "${e}" was not found among discovered *.op.ts declarations \u2014 recording the resolution anyway`}));try{await Hr()}catch(j){return console.error($e({message:`Cannot record the approval: ${j instanceof Error?j.message:String(j)}`,hint:"The pending fact this answers lives on that branch; appending without it would drop it."})),{ok:!1}}if(o){let j=_n((await gr(o.op)).pending,o.gate);if(j&&!Un(j,new Date().toISOString()))return console.error($e({message:`Gate "${t}" on "${e}" is now gate "${o.gate}" on "${o.op}", which lists it as an alias, and "${o.gate}" has a standing pending fact`,hint:`Approve that gate instead: chant approve ${o.op} ${o.gate}`})),{ok:!1};console.error(Kn(`Gate "${t}" on "${e}" is an alias of gate "${o.gate}" on "${o.op}": the next run of ${o.op} counts this approval there while the pending fact it answers stands and the plan is the same.`))}let i=n.url??nl();if(i&&!SE(i))return console.error($e({message:`--url must be an absolute http/https URL (got "${i}")`,hint:"Pass the PR/MR link, or omit --url and put prose in --note."})),{ok:!1};let s=await gr(e),a=j=>j.some(de=>de.gate===t&&de.environment!==void 0)&&n.environment!==void 0?j.filter(de=>de.environment===n.environment):j,c=_n(a(s.pending),t),l=c?.environment,u;if(n.plan!==void 0){if(!T$(n.plan))return console.error($e({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};u=n.plan}else{if(!c)return console.error($e({message:n.environment!==void 0&&s.pending.some(j=>j.gate===t&&j.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};u=c.planDigest}let d=c?.checkpointDigest!==void 0&&ot(u,c.planDigest)?c.checkpointDigest:void 0,p=c?.releaseDigest!==void 0&&ot(u,c.planDigest)?c.releaseDigest:void 0,f=c?.changeSet!==void 0&&ot(u,c.planDigest)?c.changeSet:void 0;if(c?.releaseDigest!==void 0&&await Att(e,t,c.releaseDigest,n.cwd??process.cwd()))return{ok:!1};let m=n.origin??Cs(),g=await gr(e),h=_n(a(g.pending),t);if(wo(m)&&(h?.neverOverMcp||r.get(e)?.config.neverOverMcp))return console.error($e({message:`Gate "${t}" on "${e}" is never resolved over ${m==="acp"?"ACP":"MCP"}`,hint:`Approvals belong to people: \`chant approve ${e} ${t}\` at a shell.`})),{ok:!1};if(h?.answer)return console.error($e({message:`Gate "${t}" on "${e}" asks decision point ${h.answer.point}, so its answer passes the gate, not an approval`,hint:`Answer the question: \`chant workspace points answer ${h.answer.id} --answer <value> --by <name>\`, then run \`chant run ${e}\` again.`})),{ok:!1};let y=dG(h?.origin,m);if(y&&!n.allowSameOrigin)return console.error($e({message:`Gate "${t}" on "${e}" cannot be resolved from here: ${y}`,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 b=n.relayedBy?.trim();if(n.relayedBy!==void 0&&(!b||/[\r\n]/.test(b)))return console.error($e({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 R=n.actor??(wo(m)?Iw:process.env.GITHUB_ACTOR??process.env.GITLAB_USER_LOGIN??process.env.USER??"unknown"),k={kind:n.agent||wo(m)?"agent":"human",...n.roles&&n.roles.length>0?{roles:[...new Set(n.roles)]}:{}},$=n.cwd??process.cwd(),S=await Promise.resolve().then(()=>(dd(),rW)),{scopeSource:C}=await Promise.resolve().then(()=>(ko(),nb)),A=C($);try{S.refuseUnidentified(A,[R],n.actor!==void 0?"--actor":"the approver"),b&&S.refuseUnidentified(A,[b],"--relayed-by")}catch(j){if(!(j instanceof S.IdentityError))throw j;return console.error($e({message:`Gate "${t}" on "${e}" was not approved: ${j.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 I=S.gateAdmissionFrom(A,t);if(I&&n.sign===void 0)return console.error($e({message:`Gate "${t}" needs a signed approval: chant.workspace.json at base names it in identity.gates`+(I.requirement.class!==null?`, from the class ${I.requirement.class}`:"")+", and this approval is not signed",hint:`chant approve ${e} ${t} --actor <principal> --sign [<key file>], with a key ${A.policy.signersPath} at base lists for that principal.`})),{ok:!1};let E=new Date().toISOString(),D;if(n.sign!==void 0){let{resolveSigningKey:j,sealGateApproval:U,gateSealVersion:de,SealError:se}=await Promise.resolve().then(()=>(eg(),Xm));try{let ee=j(n.sign,$);try{let V={op:e,gate:t,...l!==void 0?{environment:l}:{},...u!==void 0?{planDigest:u}:{},resolvedBy:R,...b?{relayedBy:b}:{},timestamp:E,...d!==void 0?{checkpointDigest:d}:{}};D={...U(ee.file,V),...de(V)===2?{version:2}:{}}}finally{ee.cleanup()}}catch(ee){if(!(ee instanceof se))throw ee;return console.error($e({message:`Gate "${t}" on "${e}" was not approved: ${ee.message}`})),{ok:!1}}}if(I){let j=I.refuses({op:e,gate:t,...l!==void 0?{environment:l}:{},...u!==void 0?{planDigest:u}:{},resolvedBy:R,...b?{relayedBy:b}:{},timestamp:E,...d!==void 0?{checkpointDigest:d}:{},seal:D});if(j!==null)return console.error($e({message:`Gate "${t}" on "${e}" was not approved: ${j}`,hint:`identity.gates.${t} in chant.workspace.json at base counts only an approval signed by a key ${A.policy.signersPath} lists for the approver`+(I.requirement.class!==null?`, who holds the role of the class ${I.requirement.class}`:"")+"."})),{ok:!1}}let G=h?.approval,M=ui({signers:A.policy,roles:A.policy.roles}),O=M({version:1,op:e,gate:t,...l!==void 0?{environment:l}:{},...u!==void 0?{planDigest:u}:{},resolvedBy:R,...b?{relayedBy:b}:{},timestamp:E,...d!==void 0?{checkpointDigest:d}:{},...D?{seal:D}:{}}).roles,_;if(G?.policy)try{let U=await(n.evaluator??await GF(G.policy.lexicon)).evaluateGatePolicy(G.policy,WF({op:e,gate:t,resolvedBy:R,approver:k,roles:O,...u!==void 0?{planDigest:u}:{},...G.context?{context:G.context}:{}}));_={policy:G.policy.name,version:G.policy.version,mode:G.mode,contextDigest:vw(G.context),decision:U.decision,determining:U.determining,errors:U.errors}}catch(j){return console.error($e({message:`Gate "${t}" on "${e}" declares policy "${G.policy.name}", which could not be evaluated: ${j instanceof Error?j.message:String(j)}`,hint:`Install the ${G.policy.lexicon} lexicon in this project, or approve from a checkout that has it.`})),{ok:!1}}let{record:L}=await Dw({op:e,gate:t,resolvedBy:R,...b?{relayedBy:b}:{},timestamp:E,...D?{seal:D}:{},approver:k,..._?{policyDecision:_}:{},...n.note?{note:n.note}:{},...i?{url:i}:{},...u!==void 0?{planDigest:u}:{},...d!==void 0?{checkpointDigest:d}:{},...l!==void 0?{environment:l}:{},...p!==void 0?{releaseDigest:p}:{},...f!==void 0?{changeSet:f}:{},...c?.gitSha?{gitSha:c.gitSha}:{},...c?.runId?{runId:c.runId}:{},origin:m,...y&&n.allowSameOrigin?{sameOriginOverride:!0}:{}}),q=await nRe(`The resolution is recorded locally on ${pR}. Until it reaches the remote, a run in another checkout will not see it.`);console.error(Qg(`Gate "${t}" on "${e}" resolved by ${L.resolvedBy}`+(L.relayedBy?`, relayed by ${L.relayedBy},`:"")+` at ${L.timestamp}`+(L.url?` (${L.url})`:"")+(L.seal?`, signed with ${L.seal.key}`:"")+q.suffix)),L.planDigest&&console.error(Kn(`This approves the plan ${L.planDigest}`+(L.environment!==void 0?` in environment "${L.environment}"`:"")+(L.releaseDigest!==void 0?` for release ${L.releaseDigest}`:"")+", and only that plan. A run whose fresh plan differs refuses rather than applying it.")),L.checkpointDigest&&console.error(Kn(`The next run resumes at this gate from run ${c?.runId??"(unknown)"}'s checkpoint ${L.checkpointDigest}, after it plans again. A moved plan or another commit starts it at the first phase.`));let Q=(k.roles??[]).filter(j=>!O.includes(j));if(Q.length>0&&console.error(Kn(`--role ${Q.join(", ")} is recorded on the approval and trusted by nothing: a gate's quorum and policy read ${L.resolvedBy}'s roles from .chant/trust.json at base, and only for an approval sealed by a signer listed at base (chant approve --sign).`)),G)for(let j of _tt(G,L,g.resolutions,h,g.pending,M))console.error(Kn(j));return{ok:!0,record:L,pushed:q.pushed}}function _tt(e,t,n,r,o=r?[r]:[],i=Pa){let s=[],a=t.policyDecision;if(a){let p=a.determining.length>0?` (${a.determining.join(", ")})`:"",f=e.mode==="enforce"?a.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.";s.push(`Policy "${a.policy}" ${a.version}: ${a.decision}${p}. ${f}`);for(let m of a.errors)s.push(`Policy evaluation error: ${m}`)}let c=r?.timestamp??new Date(0).toISOString(),l=r&&ot(r.planDigest,t.planDigest)?hl(o,r):c,u=gl([...n,t],t.gate,c,t.planDigest,e,l,i),d=u.counted.map(p=>p.resolvedBy).join(", ")||"none yet";if(Array.isArray(e.quorum))for(let p of u.rules??[])s.push(`Quorum: ${Jc(p)}.`);else{let p=ci(e.quorum)[0],f=p?.roles?` with role ${p.roles.join(" or ")}`:"";s.push(`Quorum: ${u.counted.length} of ${u.need} human approval(s)${f} for this plan (${d}).`)}if(!u.counted.includes(t)){let p=ci(e.quorum).flatMap(f=>f.roles??[]);s.push(xm(t).kind==="agent"?"An agent's approval does not count toward the quorum.":i(t).proven?`This approval does not count toward the quorum: .chant/trust.json at base gives ${t.resolvedBy} none of its roles (${[...new Set(p)].join(", ")}).`:"This approval does not count toward the quorum: its roles are read from .chant/trust.json at base, and only for an approval sealed by a signer listed at base (chant approve --sign).")}return s}var pR,K4=x(()=>{"use strict";Us();_A();tl();Pr();Wt();Mf();Jr();Lo();qr();LP();lt();Wf();Ps();Jn();pR="chant/lifecycle"});c0();var J4=new Set(["--help","--open","--version","--agents","--agent","--all-projects","--all","--force","--fix","--watch","--verbose","--live","--overlay","--explain","--owned","--verbatim","--skip-undeclarable","--apply-rewrites","--write","--strict","--validate","--use-composites","--composites","--stacks","--components","--pr-build","--pr-env","--up","--down","--include-dependents","--cross-root","--local","--json","--progress-json","--events-json","--follow","--update-snapshot","--update-baseline","--run-examples","--check","--bump","--no-release-record","--no-record","--fold","--no-fold","--no-cache","--sandbox","--yes","--confirm-prod","--once","--rerun-failed","--setup-key","--trust","--unsigned","--in-place","--require-runner-start","--require-clouds","--no-push","--list","--no-require-review","--expire","--check-live","--stream","--check-snapshot","--fail-on-drift","--durable-requests","--skip-mcp","--read-only","--mcp-read-only","--current","--uncommitted","--allow-code","--allow-skip","--allow-unsigned","--require-provenance","--root-only","--generated","--decide","--record-plans","--approval-status","--waves-outcome","--loopback","--artifacts","--push"]);function Z4(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,readOnly:void 0,mcpReadOnly:void 0,src:void 0,env:void 0},n=e.indexOf("--");e=n<0?a0(e,J4):[...a0(e.slice(0,n),J4),...e.slice(n)];let r=!1,o=s=>{t.command&&(t.positionals??=[]).push(s),t.command?t.path==="."?t.path=s:t.extraPositional?t.extraPositional2=s:t.extraPositional=s:t.command=s},i=0;for(;i<e.length;){let s=e[i];if(r)o(s);else if(s==="--")r=!0;else if(s==="--help"||s==="-h")t.help=!0;else if(s==="--version"||s==="-V")t.version=!0;else if(s==="--output"||s==="-o")t.output=e[++i];else if(s==="--format"||s==="-f")t.format=e[++i];else if(s==="--lexicon"||s==="-d")t.lexicon=e[++i];else if(s==="--template"||s==="-t")t.template=e[++i];else if(s==="--force")t.force=!0;else if(s==="--fix")t.fix=!0;else if(s==="--watch"||s==="-w")t.watch=!0;else if(s==="--verbose"||s==="-v")t.verbose=!0;else if(s==="--profile"||s==="-p")t.profile=e[++i];else if(s==="--report"){let a=e[i+1];a&&!a.startsWith("-")?(t.reportFile=a,i++):t.report=!0}else if(s==="--live")t.live=!0;else if(s==="--overlay")t.overlay=!0;else if(s==="--between"){if(t.betweenA=e[++i],t.betweenB=e[++i],!t.betweenA||!t.betweenB)throw new Error("--between needs two snapshot refs: --between <refA> <refB>")}else if(s==="--traffic"){let a=e[++i];if(!a)throw new Error('--traffic needs a level, passed to the engine verbatim: --traffic "100 rps, p50"');t.traffic=a}else if(s==="--overlay-anchor"){let a=e[++i];if(a!=="source"&&a!=="live")throw new Error(`--overlay-anchor must be 'source' or 'live', got '${a}'`);t.overlayAnchor=a}else if(s==="--scan"){let a=e[++i];if(a===void 0||a==="--"||a.startsWith("--"))throw new Error("--scan needs a directory: --scan <dir>");(t.scanDirs??=[]).push(a)}else if(s==="--from")t.migrateFrom=e[++i];else if(s==="--kustomize")t.kustomize=e[++i];else if(s==="--parser-option"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--parser-option needs key or key=value: --parser-option acceptLossyV1");(t.parserOption??=[]).push(a)}else if(s==="--tag"){let a=e[++i];if(!a||a.startsWith("-")||!a.includes("="))throw new Error("--tag needs key=value: --tag team=payments");(t.selectTags??=[]).push(a)}else if(s==="--type")t.selectType=e[++i];else if(s==="--name")t.selectName=e[++i];else if(s==="--owned")t.owned=!0;else if(s==="--namespace"){if(t.namespace=e[++i],!t.namespace||t.namespace.startsWith("-"))throw new Error("--namespace needs a namespace: --namespace <ns>")}else if(s==="--verbatim")t.verbatim=!0;else if(s==="--skip-undeclarable")t.skipUndeclarable=!0;else if(s==="--state")t.statePath=e[++i],t.statePath!==void 0&&(t.statePaths??=[]).push(t.statePath);else if(s==="--state-dir"){if(t.stateDir=e[++i],!t.stateDir||t.stateDir.startsWith("-"))throw new Error("--state-dir needs a directory: --state-dir <dir>")}else if(s==="--wave-size"){let a=e[++i],c=Number(a);if(!Number.isInteger(c)||c<1)throw new Error(`--wave-size needs a whole number from 1: got "${a??""}"`);t.waveSize=c}else if(s==="--all")t.all=!0;else if(s==="--select")t.selectAddress=e[++i];else if(s==="--live-name")t.liveName=e[++i];else if(s==="--apply-rewrites")t.applyRewrites=!0;else if(s==="--stack")t.carveStack=e[++i];else if(s==="--write")t.write=!0;else if(s==="--write-source")t.writeSource=!0;else if(s==="--to")t.migrateTo=e[++i];else if(s==="--emit")t.emit=e[++i];else if(s==="--dry-run")t.dryRun=!0;else if(s==="--drill")t.drill=!0;else if(s==="--yes")t.yes=!0;else if(s==="--push")t.push=!0;else if(s==="--confirm-prod")t.confirmProd=!0;else if(s==="--strict")t.strict=!0;else if(s==="--validate")t.validate=!0;else if(s==="--use-composites")t.useComposites=!0;else if(s==="--skill")t.skill=e[++i];else if(s==="--skip-mcp")t.skipMcp=!0;else if(s==="--read-only")t.readOnly=!0;else if(s==="--mcp-read-only")t.mcpReadOnly=!0;else if(s==="--src")t.src=e[++i];else if(s==="--env")t.env=e[++i];else if(s==="--port"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--port needs a port: --port <container-port>=<host-port>");(t.port??=[]).push(a)}else if(s==="--image"){if(t.image=e[++i],!t.image||t.image.startsWith("-"))throw new Error("--image needs an image reference: --image <name>:<tag>")}else if(s==="--network"){if(t.network=e[++i],!t.network||t.network.startsWith("-"))throw new Error("--network needs a Docker network name: --network <name>")}else if(s==="--setting"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--setting needs a value: --setting <KEY>=<VALUE>");(t.setting??=[]).push(a)}else if(s==="--loopback")t.loopback=!0;else if(s==="--promote-to"){if(t.promoteTo=e[++i],!t.promoteTo||t.promoteTo.startsWith("-"))throw new Error("--promote-to needs an environment: --promote-to <env>")}else if(s==="--tier")t.tier=e[++i];else if(s==="--agents")t.agents=!0;else if(s==="--scope")t.scope=e[++i];else if(s==="--all-projects")t.allProjects=!0;else if(s==="--runtime")t.runtime=e[++i];else if(s==="--fail-on")t.failOn=e[++i];else if(s==="--max-files")t.maxFiles=Number(e[++i]);else if(s==="--theme")t.theme=e[++i];else if(s==="--stacks")t.stacks=!0;else if(s==="--components")t.components=!0;else if(s==="--generate")t.generate=e[++i];else if(s==="--spec")t.opsSpec=e[++i];else if(s==="--dump-outputs")t.dumpOutputs=e[++i];else if(s==="--digest-file")t.digestFile=e[++i];else if(s==="--seed-outputs")(t.seedOutputs??=[]).push(e[++i]);else if(s==="--keep")t.keepLocks=!0;else if(s==="--runs"||s==="--plans"||s==="--wave-outputs"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error(`${s} needs a file`);t[{"--runs":"runsFile","--plans":"plansFile","--wave-outputs":"waveOutputs"}[s]]=a}else if(s==="--detail")t.detail=Number(e[++i]);else if(s==="--lens")t.lens=e[++i];else if(s==="--explain")t.explain=!0;else if(s==="--show")t.show=e[++i];else if(s==="--count-by"){if(t.countBy=e[++i],!t.countBy||t.countBy.startsWith("-"))throw new Error("--count-by needs a grouping: --count-by kind, --count-by module or --count-by attr:<name>")}else if(s==="--up")t.up=!0;else if(s==="--down")t.down=!0;else if(s==="--node-sizes")t.nodeSizes=e[++i];else if(s==="--layout-engine")t.layoutEngine=e[++i];else if(s==="--base")t.base=e[++i];else if(s==="--head")t.head=e[++i];else if(s==="--include-dependents")t.includeDependents=!0;else if(s==="--cross-root")t.crossRoot=!0;else if(s==="--dependents-of"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--dependents-of needs a member name: --dependents-of <member>");t.dependentsOf=a}else if(s==="--pin"){let a=e[++i];if(!a||a.startsWith("-")||!a.includes("="))throw new Error("--pin needs a member and a release: --pin <member>=<label|digest>");(t.pins??=[]).push(a)}else if(s==="--from-affected")t.fromAffected=e[++i];else if(s==="--gate")t.gate=e[++i];else if(s==="--wave-gate"){if(t.waveGate=e[++i],!t.waveGate||t.waveGate.startsWith("-"))throw new Error("--wave-gate needs a gate name: --wave-gate <name>")}else if(s==="--wave"){let a=e[++i],c=Number(a);if(!Number.isInteger(c)||c<1)throw new Error(`--wave needs a wave number from 1: got "${a??""}"`);t.wave=c}else if(s==="--decide")t.decide=!0;else if(s==="--record-plans")t.recordPlans=!0;else if(s==="--approval-status")t.approvalStatus=!0;else if(s==="--waves-outcome")t.wavesOutcome=!0;else if(s==="--group"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--group needs a job group's name: --group <name>");t.group=a}else if(s==="--share"){let a=e[++i],c=Number(a);if(!Number.isInteger(c)||c<1)throw new Error(`--share needs a share number from 1: got "${a??""}"`);t.share=c}else if(s==="--target"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--target needs an address: --target <component>:<address>, or on pr-plan --target <address>");(t.targets??=[]).push(a)}else if(s==="--refresh")t.refresh=!0;else if(s==="--target-dependents")t.targetDependents=!0;else if(s==="--comment-targets")t.commentTargets=!0;else if(s==="--parallelism"){let a=e[++i],c=Number(a);if(!Number.isInteger(c)||c<1)throw new Error(`--parallelism needs a whole number of 1 or more: got "${a??""}"`);t.parallelism=c}else if(s==="--canary"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--canary needs a component name: --canary <name>[,<name>...]");(t.canary??=[]).push(...a.split(",").map(c=>c.trim()).filter(Boolean))}else if(s==="--pr"){let a=e[++i],c=Number(a);if(!Number.isInteger(c)||c<1)throw new Error(`--pr needs a pull or merge request number: got "${a??""}"`);t.pr=c,(t.prs??=[]).push(c)}else if(s==="--channel"){if(t.channel=e[++i],!t.channel||!/^[A-Za-z][A-Za-z0-9._-]*$/.test(t.channel))throw new Error(`--channel needs a channel name, such as next or hotfix: got "${t.channel??""}"`)}else if(s==="--forge"){if(t.forge=e[++i],!t.forge||t.forge.startsWith("-"))throw new Error("--forge needs a forge: --forge github|gitlab|forgejo")}else if(s==="--require-clouds")t.requireClouds=!0;else if(s==="--require-review")t.requireReview=!0;else if(s==="--list")t.list=!0;else if(s==="--stage"){if(t.lockStage=e[++i],!t.lockStage||t.lockStage.startsWith("-"))throw new Error("--stage needs plan, apply or lock: --stage <stage>")}else if(s==="--alive"){if(t.aliveRun=e[++i],!t.aliveRun||t.aliveRun.startsWith("-"))throw new Error("--alive needs a run id: --alive <run>")}else if(s==="--from-report"){if(t.fromReport=e[++i],!t.fromReport||t.fromReport.startsWith("-"))throw new Error("--from-report needs a report file: --from-report <pr-plan.json>")}else if(s==="--report-url"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--report-url needs a URL: --report-url s3://<bucket>/<prefix>, gs://<bucket>/<prefix>, az://<account>/<container>/<prefix> or file://<directory>");t.reportUrl=a}else if(s==="--result"){if(t.planResult=e[++i],!t.planResult||t.planResult.startsWith("-"))throw new Error("--result needs the plan job's result: --result success|failure|cancelled")}else if(s==="--no-status")t.noStatus=!0;else if(s==="--status-url"){if(t.statusUrl=e[++i],!t.statusUrl||t.statusUrl.startsWith("-"))throw new Error("--status-url needs a URL template: --status-url https://host/reports/{key}")}else if(s==="--allow-unsigned")t.allowUnsigned=!0;else if(s==="--require-provenance")t.requireProvenance=!0;else if(s==="--pr-loop")t.prLoop=!0;else if(s==="--green")t.green=!0;else if(s==="--before-merge")t.beforeMerge=!0;else if(s==="--requires"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error("--requires needs a list of checks: --requires approved,mergeable,undiverged,checks");t.requires=a.split(",").map(c=>c.trim()).filter(Boolean)}else if(s==="--respond"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error("--respond needs a list of responses: --respond wave-refused=diff,apply-failed=off,description=check");t.respond=[...t.respond??[],a]}else if(s==="--decide-backend"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error("--decide-backend needs the name of a decide.backends entry");t.decideBackend=a}else if(s==="--decide-model"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error("--decide-model needs a model id");t.decideModel=a}else if(s==="--merge"||s==="--merge-token-env"||s==="--merge-method"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error(`${s} needs a value: --merge manual|auto, --merge-token-env <VAR>, --merge-method merge|squash|rebase`);s==="--merge"?t.merge=a:s==="--merge-token-env"?t.mergeTokenEnv=a:t.mergeMethod=a}else if(s==="--apply-before-merge")t.applyBeforeMerge=!0;else if(s==="--apply-on-merge")t.applyOnMerge=!0;else if(s==="--preview-comment")t.previewComment=!0;else if(s==="--pr-env")t.prEnv=!0;else if(s==="--pr-runner"){let a=e[++i]??"",c=/^(plan|apply|default)=(.+)$/.exec(a);if(!c)throw new Error(`--pr-runner needs <stage>=<label>[,<label>...], the stage plan, apply or default: got "${a}"`);let l=c[2].split(",").map(u=>u.trim()).filter(Boolean);if(l.length===0)throw new Error(`--pr-runner ${c[1]} names no label`);(t.prRunners??={})[c[1]]=l}else if(s==="--pr-variable"||s==="--pr-secret"){let a=e[++i]??"",c=a.indexOf("=");if(c<1)throw new Error(`${s} needs <NAME>=<${s==="--pr-secret"?"secret":"value"}>: got "${a}"`);let l=s==="--pr-secret"?t.prSecrets??={}:t.prVariables??={};l[a.slice(0,c)]=a.slice(c+1)}else if(s==="--pr-build")t.prBuild=!0;else if(s==="--build-command"){let a=e[++i];if(a===void 0||a==="")throw new Error("--build-command needs a shell line: --build-command '<line>'");t.ciBuildCommand=a}else if(s==="--land")t.ciLand=!0;else if(s==="--pr-build-command"){let a=e[++i];if(a===void 0||a==="")throw new Error("--pr-build-command needs a shell line: --pr-build-command '<line>'");t.prBuildCommand=a}else if(s==="--before-script"){let a=e[++i];if(a===void 0||a==="")throw new Error("--before-script needs a shell line: --before-script '<line>'");(t.beforeScript??=[]).push(a)}else if(s==="--resume"){let a=e[i+1];a===void 0||a.startsWith("-")?t.resumeRun=!0:t.resume=e[++i]}else if(s==="--local")t.local=!0;else if(s==="--json")t.json=!0;else if(s==="--progress-json")t.progressJson=!0;else if(s==="--events-json")t.eventsJson=!0;else if(s==="--follow")t.follow=!0;else if(s==="--gated-exit")t.gatedExit=Number(e[++i]);else if(s==="--durable-requests")t.durableRequests=!0;else if(s==="--update-snapshot")t.updateSnapshot=!0;else if(s==="--update-baseline")t.updateBaseline=!0;else if(s==="--deep")t.deep=!0;else if(s==="--at")t.at=e[++i];else if(s==="--capability-view")t.capabilityView=!0;else if(s==="--capabilities")t.capabilities=!0;else if(s==="--snapshot"){if(t.snapshot=e[++i],!t.snapshot||t.snapshot.startsWith("-"))throw new Error("--snapshot needs a snapshot ref: --snapshot latest")}else if(s==="--kind"){if(t.kind=e[++i],!t.kind||t.kind.startsWith("-"))throw new Error("--kind needs a kind file: --kind <path>");(t.kinds??=[]).push(t.kind)}else if(s==="--composites")t.composites=!0;else if(s==="--intent"){let a=e[i+1];if(a!==void 0&&!a.startsWith("-"))t.intent=e[++i];else if(e.includes("--record"))t.intent="";else throw new Error("--intent needs a region: --intent <path[:start-end]|path#symbol|member/node|sha>, or --intent --record <id>")}else if(s==="--follow-squash")t.followSquash=!0;else if(s==="--record"){if(t.record=e[++i],!t.record||t.record.startsWith("-"))throw new Error("--record needs a record id: --record <id>")}else if(s==="--path"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--path needs a path: --path <path>");(t.paths??=[]).push(a)}else if(s==="--worktree")t.worktree=!0;else if(s==="--max-bytes"){let a=Number(e[++i]);if(!Number.isInteger(a)||a<1)throw new Error("--max-bytes needs a whole number of bytes above 0");t.maxBytes=a}else if(s==="--changes"){if(t.changes=e[++i],!t.changes||t.changes.startsWith("-"))throw new Error("--changes needs a range: --changes <base>..<head>")}else if(s==="--severity"){if(t.severity=e[++i],!t.severity||t.severity.startsWith("-"))throw new Error("--severity needs off, warn or fail")}else if(s==="--current")t.current=!0;else if(s==="--uncommitted")t.uncommitted=!0;else if(s==="--set"){if(t.set=e[++i],!t.set||t.set.startsWith("-")&&t.set!=="-")throw new Error("--set needs a JSON file, or - for standard input: --set <file|->")}else if(s==="--cover"){if(t.cover=e[++i],!t.cover||t.cover.startsWith("-"))throw new Error("--cover needs a PNG, JPEG or WebP file: --cover <image>")}else if(s==="--cover-path"){if(t.coverPath=e[++i],!t.coverPath||t.coverPath.startsWith("-"))throw new Error("--cover-path needs a path from the workspace root: --cover-path <path>")}else if(s==="--records")t.records=!0;else if(s==="--expect"){if(t.expect=e[++i],!t.expect||t.expect.startsWith("-"))throw new Error("--expect needs the record's digest, as records --json prints it: --expect <digest>")}else if(s==="--label"){if(t.label=e[++i],!t.label||t.label.startsWith("-"))throw new Error("--label needs the snapshot's name, such as a turn id: --label <text>")}else if(s==="--branch"){if(t.branch=e[++i],!t.branch||t.branch.startsWith("-"))throw new Error("--branch needs a branch name: --branch <branch>")}else if(s==="--security"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--security needs a group: --security verified-releases|supply-chain|who-ran-it|review-rules|isolated-runners");t.securityGroups=[...t.securityGroups??[],a]}else if(s==="--workflow"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--workflow needs a workflow's name: --workflow <name>");t.ciWorkflows=[...t.ciWorkflows??[],a]}else if(s==="--chant"){if(t.ciChant=e[++i],!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(s==="--commit"){if(t.commit=e[++i],!t.commit||t.commit.startsWith("-"))throw new Error("--commit needs the commit the job runs at: --commit <sha>")}else if(s==="--pass-env"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--pass-env needs a variable's name, such as AWS_PROFILE: --pass-env <NAME>");(t.passEnv??=[]).push(a)}else if(s==="--secrets"){if(t.ciSecrets=e[++i],!t.ciSecrets||t.ciSecrets.startsWith("-"))throw new Error("--secrets needs the host's secrets file, a dotenv or JSON file only its owner can read: --secrets <file>")}else if(s==="--repo"){if(t.ciRepo=e[++i],!t.ciRepo||!/^[^/\s-][^/\s]*\/[^/\s]+$/.test(t.ciRepo))throw new Error("--repo needs the repository as owner/name: --repo <owner/repo>")}else if(s==="--run-index-limit"){let a=Number(e[++i]);if(!Number.isInteger(a)||a<1)throw new Error("--run-index-limit needs a whole number of runs, 1 or more: --run-index-limit <n>");t.runIndexLimit=a}else if(s==="--max-jobs"){let a=Number(e[++i]);if(!Number.isInteger(a)||a<1)throw new Error("--max-jobs needs a whole number of jobs, 1 or more: --max-jobs <n>");t.maxJobs=a}else if(s==="--author"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--author needs a forge login: --author <login>");(t.ciAuthors??=[]).push(a)}else if(s==="--rerun-failed")t.rerunFailed=!0;else if(s==="--install"){if(t.ciInstall=e[++i],!t.ciInstall||t.ciInstall.startsWith("-"))throw new Error('--install needs the install command, such as "npm install": --install <command>')}else if(s==="--token-secret"){if(t.ciTokenSecret=e[++i],!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(s==="--app-id-var"){if(t.ciAppIdVar=e[++i],!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(s==="--app-key-secret"){if(t.ciAppKeySecret=e[++i],!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(s==="--runner-key-secret"){if(t.ciRunnerKeySecret=e[++i],!t.ciRunnerKeySecret||t.ciRunnerKeySecret.startsWith("-"))throw new Error("--runner-key-secret needs the repository secret holding the runner key, such as CHANT_RUNNER_KEY: --runner-key-secret <NAME>")}else if(s==="--verdict"){if(t.verdict=e[++i],!t.verdict||t.verdict.startsWith("-"))throw new Error("--verdict needs agree, dissent or abstain")}else if(s==="--class"){if(t.runnerClass=e[++i],!t.runnerClass||t.runnerClass.startsWith("-"))throw new Error("--class needs runner or service: --class <class>")}else if(s==="--by"){if(t.by=e[++i],!t.by||t.by.startsWith("-"))throw new Error("--by needs the reviewer: --by <principal>");(t.bys??=[]).push(t.by)}else if(s==="--stale-notes")t.staleNotes=!0;else if(s==="--stale")t.stale=!0;else if(s==="--tip"){let a=e[++i];if(!a||!/^[0-9a-f]{40}$/.test(a))throw new Error(`--tip needs the target branch's full commit sha: got "${a??""}"`);t.tip=a}else if(s==="--open")t.open=!0;else if(s==="--inputs"){if(t.inputs=e[++i],!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(s==="--candidates"){if(t.candidates=e[++i],!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(s==="--response"){if(t.response=e[++i],!t.response||t.response.startsWith("-"))throw new Error("--response needs a JSON file: --response <file>")}else if(s==="--subject"){if(t.subject=e[++i],!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(s==="--store"){let a=e[++i];if(a!=="tree"&&a!=="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=a}else if(s==="--answer"){if(t.answer=e[++i],t.answer===void 0||t.answer==="")throw new Error("--answer needs one of the question's candidates: --answer <value>")}else if(s==="--sign"){let a=e[i+1];t.sign=a!==void 0&&!a.startsWith("-")?e[++i]:!0}else if(s==="--session"){if(t.session=e[++i],!t.session||t.session.startsWith("-"))throw new Error("--session needs a session id: --session <id>")}else if(s==="--prefix"){if(t.prefix=e[++i],!t.prefix||t.prefix.startsWith("-"))throw new Error("--prefix needs an id prefix: --prefix <prefix>")}else if(s==="--key"||s==="--check-id"||s==="--claim"||s==="--environment"||s==="--envelope"||s==="--threshold"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error(`${s} needs a value`);let c={"--key":"key","--check-id":"checkId","--claim":"claim","--environment":"environment","--envelope":"envelope","--threshold":"threshold"}[s];t[c]=a}else if(s==="--require"){if(t.require=e[++i],!t.require||t.require.startsWith("-"))throw new Error("--require needs a provenance level: --require attested")}else if(s==="--ambient")t.ambient=!0;else if(s==="--check-live")t.checkLive=!0;else if(s==="--check-snapshot")t.checkSnapshot=!0;else if(s==="--fail-on-drift")t.failOnDrift=!0;else if(s==="--run-examples")t.runExamples=!0;else if(s==="--pinned-digest")t.pinnedDigest=e[++i];else if(s==="--check")t.check=!0;else if(s==="--bump")t.bump=!0;else if(s==="--component")t.component=e[++i];else if(s==="--digest")t.digest=e[++i],t.digest!==void 0&&(t.digests??=[]).push(t.digest);else if(s==="--release-plan")t.releasePlanFile=e[++i];else if(s==="--release"){if(t.release=e[++i],!t.release||t.release.startsWith("-"))throw new Error("--release needs a release's label or digest: --release <label|digest>")}else if(s==="--build"){if(t.buildCommand=e[++i],!t.buildCommand)throw new Error("--build needs a shell command: --build '<command>'")}else if(s==="--artifacts")t.artifacts=!0;else if(s==="--git-sha")t.gitSha=e[++i];else if(s==="--run-id")t.runId=e[++i];else if(s==="--actor")t.actor=e[++i];else if(s==="--approver")t.approver=e[++i];else if(s==="--relayed-by"){if(t.relayedBy=e[++i],!t.relayedBy||t.relayedBy.startsWith("-"))throw new Error("--relayed-by needs the principal that relayed it: --relayed-by <principal>")}else if(s==="--on"){if(t.on=e[++i],!t.on||t.on.startsWith("-"))throw new Error("--on needs a runtime name: --on <lexicon>")}else if(s==="--compare-to")t.compareTo=e[++i];else if(s==="--no-release-record")t.noReleaseRecord=!0;else if(s==="--no-record")t.noRecord=!0;else if(s==="--fold")t.fold=!0;else if(s==="--no-cache")t.noCache=!0;else if(s==="--no-fold")t.fold=!1;else if(s==="--sandbox")t.sandbox=!0;else if(s==="--fold-rank"){let a=e[i+1];a&&!a.startsWith("-")?(t.foldRankCollapsedFile=a,i++):t.foldRank=!0}else if(s==="--param")(t.param??=[]).push(e[++i]);else if(s==="--lexicon-output")(t.lexiconOutput??=[]).push(e[++i]);else if(s==="--params-file")t.paramsFile=e[++i];else if(s==="--projection")t.projection=e[++i];else if(s==="--interval")t.interval=e[++i];else if(s==="--lease-ttl")t.leaseTtl=e[++i];else if(s==="--steward"){let a=e[i+1];a!==void 0&&!a.startsWith("-")?(t.steward=a,i++):t.steward=""}else if(s==="--once")t.once=!0;else if(s==="--setup-key")t.setupKey=!0;else if(s==="--trust")t.trustKey=!0;else if(s==="--in-place")t.ciInPlace=!0;else if(s==="--require-runner-start")t.requireRunnerStart=!0;else if(s==="--job"){if(t.ciJob=e[++i],!t.ciJob||t.ciJob.startsWith("-"))throw new Error("--job needs the job as JSON or @<file>: --job @job.json")}else if(s==="--no-push")t.noPush=!0;else if(s==="--no-require-review")t.requireReview=!1;else if(s==="--unsigned")t.unsigned=!0;else if(s==="--principal"){if(t.ciPrincipal=e[++i],!t.ciPrincipal||t.ciPrincipal.startsWith("-"))throw new Error("--principal needs the runner's principal: --principal <name>")}else if(s==="--work"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--work needs a work item id: --work <id>");t.work=a,(t.works??=[]).push(a)}else if(s==="--holder"||s==="--ttl"||s==="--token"||s==="--outcome"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error(`${s} needs a value: ${s} <${s.slice(2)}>`);t[s.slice(2)]=a}else if(s==="--input"||s==="--org"||s==="--endpoint"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error(`${s} needs a value: ${s} <${s==="--input"?"file":s.slice(2)}>`);t[s.slice(2)]=a}else if(s==="--signer"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--signer needs a principal: --signer <principal>");t.signer=a}else if(s==="--unit"||s==="--decision"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error(`${s} needs an id: ${s} <id>`);t[s.slice(2)]=a}else if(s==="--note")t.note=e[++i];else if(s==="--reason"){if(t.reason=e[++i],t.reason===void 0||t.reason.startsWith("-"))throw new Error("--reason needs the text of the reason: --reason <text>")}else if(s==="--rule"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--rule needs a rule id: --rule <id>");(t.rules??=[]).push(a)}else if(s==="--expire")t.expire=!0;else if(s==="--role"){let a=e[++i]??"";t.roles=[...t.roles??[],...a.split(",").map(c=>c.trim()).filter(Boolean)]}else if(s==="--agent")t.agent=!0;else if(s==="--allow-code")t.allowCode=!0;else if(s==="--allow-skip")t.allowSkip=!0;else if(s==="--source"){if(t.source=e[++i],!t.source||t.source.startsWith("-"))throw new Error("--source needs a template: --source <repo>[#<member>] for workspace upgrade, or a source for ci tick and ci list: --source checks|runs")}else if(s==="--tags"){if(t.tags=e[++i],!t.tags||t.tags.startsWith("-"))throw new Error("--tags needs a tag glob: --tags 'v*'")}else if(s==="--index"){if(t.index=e[++i],!t.index||t.index.startsWith("-"))throw new Error("--index needs a value: --index <file> for workspace adopt-lineage, --index <scope key>[@<version>] for search and lifecycle diff")}else if(s==="--adopt"){if(t.adopt=e[++i],!t.adopt||t.adopt.startsWith("-"))throw new Error("--adopt needs an adoption file: --adopt <file>")}else if(s==="--adopt-out"){if(t.adoptOut=e[++i],!t.adoptOut||t.adoptOut.startsWith("-"))throw new Error("--adopt-out needs a file: --adopt-out <file>")}else if(s==="--remove")t.remove=!0;else if(s==="--available")t.available=!0;else if(s==="--root-only")t.rootOnly=!0;else if(s==="--forge-repos"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--forge-repos needs a file: --forge-repos <repos.json>");t.forgeRepos=a}else if(s==="--generated")t.generated=!0;else if(s==="--member"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--member needs a member or group name: --member <name>");t.members=[...t.members??[],...a.split(",").map(c=>c.trim()).filter(Boolean)]}else if(s==="--allow-same-origin")t.allowSameOrigin=!0;else if(s==="--plan")t.plan=e[++i];else if(s==="--url")t.url=e[++i];else if(s==="--op")t.op=e[++i];else if(s==="--where"){let a=e[++i];if(a===void 0||a.startsWith("--"))throw new Error("--where needs a clause: --where <field><op><value>");t.where=[...t.where??[],a]}else if(s==="--read"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--read needs a read: --read <state|plan|refresh|live-read|ownership>");t.driftRead=a}else if(s==="--stream")t.stream=!0;else if(s==="--resource"){let a=e[++i];if(!a||a.startsWith("--"))throw new Error("--resource needs an address: --resource <addr>");t.resource=a}else if(s==="--since")t.since=e[++i];else if(s==="--audit-log"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--audit-log needs the log: --audit-log aws[:<region>]");t.auditLog=a}else if(s==="--limit")t.limit=Number(e[++i]);else{if(s.startsWith("--"))throw new Error(`Unknown flag: ${s}
491
+ `),{status:"refused",code:Ue.moved}}return{status:"confirmed",plan:m,target:h}}var tRe=x(()=>{"use strict";Wi()});async function nRe(e){let{pushed:t,pushWarning:n}=await bE();return t?{pushed:t,suffix:""}:qu(n)?{pushed:t,suffix:` (${Hu})`}:(console.error(cr({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 rRe(e){let t=e.args.path,n=e.args.extraPositional;if(!t||t==="."||!n)return console.error($e({message:"Usage: chant approve <op> <gate>"})),1;if(e.args.expire){try{await Hr()}catch(l){return console.error($e({message:`Cannot expire the gate: ${l instanceof Error?l.message:String(l)}`})),1}let s=new Date().toISOString(),a=_n((await gr(t)).pending,n);if(!a||Un(a,s))return console.error(cr({message:`Gate "${n}" on "${t}" has no standing pending fact \u2014 nothing to expire`})),0;await Xf({op:t,gate:n,timestamp:s,expiresAt:s,...a.description?{description:a.description}:{},...a.runId?{runId:a.runId}:{},...a.gitSha?{gitSha:a.gitSha}:{}});let c=await nRe(`The expiry is recorded locally on ${pR}. Until it reaches the remote, a run in another checkout still sees the old pending fact.`);return console.error(Qg(`Gate "${n}" on "${t}" expired at ${s} \u2014 not approved`+c.suffix)),console.error(Kn(t===Kf?"The next `chant components fan-out` decides this gate from scratch and records a fresh pending fact.":NP.test(t)?"The next `chant components pr-apply` decides this gate from scratch and records a fresh pending fact.":t===Aw?`The next \`chant workspace promote ${n}\` decides this gate from scratch and records a fresh pending fact.`:t===Jf?`The next \`chant workspace upgrade ${n}\` decides this gate from scratch and records a fresh pending fact.`:t===Zf?"The next `chant workspace exit` decides this gate from scratch and records a fresh pending fact.":t===yi?"The next `chant components promote --release` 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===el){let{runOverrideApprove:s}=await Promise.resolve().then(()=>(qke(),Hke));return s(e)}if(e.args.rules!==void 0||e.args.reason!==void 0)return console.error($e({message:`--rule and --reason override a denied plan: chant approve ${el} <subject> --rule <id> --reason <text>`,hint:`To approve gate "${n}" on "${t}", put any prose in --note.`})),1;let r=e.args.plan,o=await Promise.resolve().then(()=>(tRe(),eRe));if(await o.interactiveApproval(e.args)){let s=await o.confirmApproval(t,n,{...r!==void 0?{plan:r}:{},...e.args.env!==void 0?{environment:e.args.env}:{}});if(s.status==="refused")return s.code;s.status==="confirmed"&&(r=s.plan)}let i=await V4(t,n,{actor:e.args.approver??e.args.actor,note:e.args.note,url:e.args.url,plan:r,...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:s}=await Promise.resolve().then(()=>(N_(),h4));return s(t,n,i.record.environment,i.pushed)}return console.error(Kn("This records the resolution as a fact; it does not itself re-run anything. "+(t===Kf?`Repeat the \`chant components fan-out\` command and it walks through gate "${n}".`:NP.test(t)?`The pull request's apply (\`chant components pr-apply\`) walks through gate "${n}" when it plans this same digest.`:t===Aw?`Repeat \`chant workspace promote ${n}\`, and it applies the patch this approval names.`:t===Jf?`Repeat \`chant workspace upgrade ${n}\` with the same target, and it applies the patch this approval names.`:t===Zf?"Repeat `chant workspace exit` with the same members, and it applies the patch this approval names.":t===yi?`Repeat the same \`chant components promote --release\`, and it walks through gate "${n}" when it plans this same change set for this release.`:`Run \`chant run ${t}\` and it walks through gate "${n}".`))),0}async function Att(e,t,n,r){let{readRelease:o,readCuts:i,labelsByDigest:s}=await Promise.resolve().then(()=>(Fa(),Pm)),{readRevokedCommits:a,revocationOf:c,revokedRefusal:l}=await Promise.resolve().then(()=>(u_(),iK)),u=await o(n,{cwd:r}).catch(()=>null);if(!u)return console.error($e({message:`Gate "${t}" on "${e}" binds release ${n}, which can't be read from ${pR}, so whether it is revoked is unknown [release-unreadable]`,hint:`Fetch the ledger branch (git fetch origin ${pR}:${pR}) and approve again from the member's directory.`})),!0;let d;try{d=await a(r)}catch(m){return console.error($e({message:`Gate "${t}" on "${e}" binds release ${n}, and the ci tags can't be judged: ${m instanceof Error?m.message:String(m)} [declaration-invalid]`,hint:"Fix ci.green in chant.workspace.json at base; chant workspace check names the problem."})),!0}let p=c(u,d);if(!p)return!1;let f=s((await i({cwd:r}).catch(()=>({cuts:[]}))).cuts).get(n)??null;return console.error($e(l({releaseDigest:n,label:f},p,`Clear the pending gate with \`chant approve ${e} ${t} --expire\`, then promote a release cut from a green commit: \`chant ci last-green\` names the newest, and \`chant release list\` marks the revoked releases.`))),!0}async function V4(e,t,n){if(Ur())return console.error($e({message:`Cannot record the approval of "${t}": ${fi} is set, so nothing is written to chant/lifecycle`,hint:`Unset ${fi} to approve the gate.`})),{ok:!1};let{ops:r}=await _l(),o=bge([...r.values()].map(j=>j.config),e,t);!o&&!r.has(e)&&e!==Kf&&e!==Jf&&e!==Zf&&e!==Aw&&e!==el&&e!==yi&&console.error(cr({message:`Op "${e}" was not found among discovered *.op.ts declarations \u2014 recording the resolution anyway`}));try{await Hr()}catch(j){return console.error($e({message:`Cannot record the approval: ${j instanceof Error?j.message:String(j)}`,hint:"The pending fact this answers lives on that branch; appending without it would drop it."})),{ok:!1}}if(o){let j=_n((await gr(o.op)).pending,o.gate);if(j&&!Un(j,new Date().toISOString()))return console.error($e({message:`Gate "${t}" on "${e}" is now gate "${o.gate}" on "${o.op}", which lists it as an alias, and "${o.gate}" has a standing pending fact`,hint:`Approve that gate instead: chant approve ${o.op} ${o.gate}`})),{ok:!1};console.error(Kn(`Gate "${t}" on "${e}" is an alias of gate "${o.gate}" on "${o.op}": the next run of ${o.op} counts this approval there while the pending fact it answers stands and the plan is the same.`))}let i=n.url??nl();if(i&&!SE(i))return console.error($e({message:`--url must be an absolute http/https URL (got "${i}")`,hint:"Pass the PR/MR link, or omit --url and put prose in --note."})),{ok:!1};let s=await gr(e),a=j=>j.some(de=>de.gate===t&&de.environment!==void 0)&&n.environment!==void 0?j.filter(de=>de.environment===n.environment):j,c=_n(a(s.pending),t),l=c?.environment,u;if(n.plan!==void 0){if(!T$(n.plan))return console.error($e({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};u=n.plan}else{if(!c)return console.error($e({message:n.environment!==void 0&&s.pending.some(j=>j.gate===t&&j.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};u=c.planDigest}let d=c?.checkpointDigest!==void 0&&ot(u,c.planDigest)?c.checkpointDigest:void 0,p=c?.releaseDigest!==void 0&&ot(u,c.planDigest)?c.releaseDigest:void 0,f=c?.changeSet!==void 0&&ot(u,c.planDigest)?c.changeSet:void 0;if(c?.releaseDigest!==void 0&&await Att(e,t,c.releaseDigest,n.cwd??process.cwd()))return{ok:!1};let m=n.origin??Cs(),g=await gr(e),h=_n(a(g.pending),t);if(wo(m)&&(h?.neverOverMcp||r.get(e)?.config.neverOverMcp))return console.error($e({message:`Gate "${t}" on "${e}" is never resolved over ${m==="acp"?"ACP":"MCP"}`,hint:`Approvals belong to people: \`chant approve ${e} ${t}\` at a shell.`})),{ok:!1};if(h?.answer)return console.error($e({message:`Gate "${t}" on "${e}" asks decision point ${h.answer.point}, so its answer passes the gate, not an approval`,hint:`Answer the question: \`chant workspace points answer ${h.answer.id} --answer <value> --by <name>\`, then run \`chant run ${e}\` again.`})),{ok:!1};let y=dG(h?.origin,m);if(y&&!n.allowSameOrigin)return console.error($e({message:`Gate "${t}" on "${e}" cannot be resolved from here: ${y}`,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 b=n.relayedBy?.trim();if(n.relayedBy!==void 0&&(!b||/[\r\n]/.test(b)))return console.error($e({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 R=n.actor??(wo(m)?Iw:process.env.GITHUB_ACTOR??process.env.GITLAB_USER_LOGIN??process.env.USER??"unknown"),k={kind:n.agent||wo(m)?"agent":"human",...n.roles&&n.roles.length>0?{roles:[...new Set(n.roles)]}:{}},$=n.cwd??process.cwd(),S=await Promise.resolve().then(()=>(dd(),rW)),{scopeSource:C}=await Promise.resolve().then(()=>(ko(),nb)),A=C($);try{S.refuseUnidentified(A,[R],n.actor!==void 0?"--actor":"the approver"),b&&S.refuseUnidentified(A,[b],"--relayed-by")}catch(j){if(!(j instanceof S.IdentityError))throw j;return console.error($e({message:`Gate "${t}" on "${e}" was not approved: ${j.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 I=S.gateAdmissionFrom(A,t);if(I&&n.sign===void 0)return console.error($e({message:`Gate "${t}" needs a signed approval: chant.workspace.json at base names it in identity.gates`+(I.requirement.class!==null?`, from the class ${I.requirement.class}`:"")+", and this approval is not signed",hint:`chant approve ${e} ${t} --actor <principal> --sign [<key file>], with a key ${A.policy.signersPath} at base lists for that principal.`})),{ok:!1};let E=new Date().toISOString(),D;if(n.sign!==void 0){let{resolveSigningKey:j,sealGateApproval:U,gateSealVersion:de,SealError:se}=await Promise.resolve().then(()=>(eg(),Xm));try{let ee=j(n.sign,$);try{let V={op:e,gate:t,...l!==void 0?{environment:l}:{},...u!==void 0?{planDigest:u}:{},resolvedBy:R,...b?{relayedBy:b}:{},timestamp:E,...d!==void 0?{checkpointDigest:d}:{}};D={...U(ee.file,V),...de(V)===2?{version:2}:{}}}finally{ee.cleanup()}}catch(ee){if(!(ee instanceof se))throw ee;return console.error($e({message:`Gate "${t}" on "${e}" was not approved: ${ee.message}`})),{ok:!1}}}if(I){let j=I.refuses({op:e,gate:t,...l!==void 0?{environment:l}:{},...u!==void 0?{planDigest:u}:{},resolvedBy:R,...b?{relayedBy:b}:{},timestamp:E,...d!==void 0?{checkpointDigest:d}:{},seal:D});if(j!==null)return console.error($e({message:`Gate "${t}" on "${e}" was not approved: ${j}`,hint:`identity.gates.${t} in chant.workspace.json at base counts only an approval signed by a key ${A.policy.signersPath} lists for the approver`+(I.requirement.class!==null?`, who holds the role of the class ${I.requirement.class}`:"")+"."})),{ok:!1}}let G=h?.approval,M=ui({signers:A.policy,roles:A.policy.roles}),O=M({version:1,op:e,gate:t,...l!==void 0?{environment:l}:{},...u!==void 0?{planDigest:u}:{},resolvedBy:R,...b?{relayedBy:b}:{},timestamp:E,...d!==void 0?{checkpointDigest:d}:{},...D?{seal:D}:{}}).roles,_;if(G?.policy)try{let U=await(n.evaluator??await GF(G.policy.lexicon)).evaluateGatePolicy(G.policy,WF({op:e,gate:t,resolvedBy:R,approver:k,roles:O,...u!==void 0?{planDigest:u}:{},...G.context?{context:G.context}:{}}));_={policy:G.policy.name,version:G.policy.version,mode:G.mode,contextDigest:vw(G.context),decision:U.decision,determining:U.determining,errors:U.errors}}catch(j){return console.error($e({message:`Gate "${t}" on "${e}" declares policy "${G.policy.name}", which could not be evaluated: ${j instanceof Error?j.message:String(j)}`,hint:`Install the ${G.policy.lexicon} lexicon in this project, or approve from a checkout that has it.`})),{ok:!1}}let{record:L}=await Dw({op:e,gate:t,resolvedBy:R,...b?{relayedBy:b}:{},timestamp:E,...D?{seal:D}:{},approver:k,..._?{policyDecision:_}:{},...n.note?{note:n.note}:{},...i?{url:i}:{},...u!==void 0?{planDigest:u}:{},...d!==void 0?{checkpointDigest:d}:{},...l!==void 0?{environment:l}:{},...p!==void 0?{releaseDigest:p}:{},...f!==void 0?{changeSet:f}:{},...c?.gitSha?{gitSha:c.gitSha}:{},...c?.runId?{runId:c.runId}:{},origin:m,...y&&n.allowSameOrigin?{sameOriginOverride:!0}:{}}),q=await nRe(`The resolution is recorded locally on ${pR}. Until it reaches the remote, a run in another checkout will not see it.`);console.error(Qg(`Gate "${t}" on "${e}" resolved by ${L.resolvedBy}`+(L.relayedBy?`, relayed by ${L.relayedBy},`:"")+` at ${L.timestamp}`+(L.url?` (${L.url})`:"")+(L.seal?`, signed with ${L.seal.key}`:"")+q.suffix)),L.planDigest&&console.error(Kn(`This approves the plan ${L.planDigest}`+(L.environment!==void 0?` in environment "${L.environment}"`:"")+(L.releaseDigest!==void 0?` for release ${L.releaseDigest}`:"")+", and only that plan. A run whose fresh plan differs refuses rather than applying it.")),L.checkpointDigest&&console.error(Kn(`The next run resumes at this gate from run ${c?.runId??"(unknown)"}'s checkpoint ${L.checkpointDigest}, after it plans again. A moved plan or another commit starts it at the first phase.`));let Q=(k.roles??[]).filter(j=>!O.includes(j));if(Q.length>0&&console.error(Kn(`--role ${Q.join(", ")} is recorded on the approval and trusted by nothing: a gate's quorum and policy read ${L.resolvedBy}'s roles from .chant/trust.json at base, and only for an approval sealed by a signer listed at base (chant approve --sign).`)),G)for(let j of _tt(G,L,g.resolutions,h,g.pending,M))console.error(Kn(j));return{ok:!0,record:L,pushed:q.pushed}}function _tt(e,t,n,r,o=r?[r]:[],i=Pa){let s=[],a=t.policyDecision;if(a){let p=a.determining.length>0?` (${a.determining.join(", ")})`:"",f=e.mode==="enforce"?a.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.";s.push(`Policy "${a.policy}" ${a.version}: ${a.decision}${p}. ${f}`);for(let m of a.errors)s.push(`Policy evaluation error: ${m}`)}let c=r?.timestamp??new Date(0).toISOString(),l=r&&ot(r.planDigest,t.planDigest)?hl(o,r):c,u=gl([...n,t],t.gate,c,t.planDigest,e,l,i),d=u.counted.map(p=>p.resolvedBy).join(", ")||"none yet";if(Array.isArray(e.quorum))for(let p of u.rules??[])s.push(`Quorum: ${Jc(p)}.`);else{let p=ci(e.quorum)[0],f=p?.roles?` with role ${p.roles.join(" or ")}`:"";s.push(`Quorum: ${u.counted.length} of ${u.need} human approval(s)${f} for this plan (${d}).`)}if(!u.counted.includes(t)){let p=ci(e.quorum).flatMap(f=>f.roles??[]);s.push(xm(t).kind==="agent"?"An agent's approval does not count toward the quorum.":i(t).proven?`This approval does not count toward the quorum: .chant/trust.json at base gives ${t.resolvedBy} none of its roles (${[...new Set(p)].join(", ")}).`:"This approval does not count toward the quorum: its roles are read from .chant/trust.json at base, and only for an approval sealed by a signer listed at base (chant approve --sign).")}return s}var pR,K4=x(()=>{"use strict";Us();_A();tl();Pr();Wt();Mf();Jr();Lo();qr();LP();lt();Wf();Ps();Jn();pR="chant/lifecycle"});c0();var J4=new Set(["--help","--open","--version","--agents","--agent","--all-projects","--all","--force","--fix","--watch","--verbose","--live","--overlay","--explain","--owned","--verbatim","--skip-undeclarable","--apply-rewrites","--write","--strict","--validate","--use-composites","--composites","--stacks","--components","--pr-build","--pr-env","--up","--down","--include-dependents","--cross-root","--local","--json","--progress-json","--events-json","--follow","--update-snapshot","--update-baseline","--run-examples","--check","--bump","--no-release-record","--no-record","--fold","--no-fold","--no-cache","--sandbox","--yes","--confirm-prod","--once","--rerun-failed","--setup-key","--trust","--unsigned","--in-place","--require-runner-start","--require-clouds","--no-push","--list","--no-require-review","--expire","--check-live","--stream","--check-snapshot","--fail-on-drift","--durable-requests","--skip-mcp","--read-only","--mcp-read-only","--propose","--current","--uncommitted","--allow-code","--allow-skip","--allow-unsigned","--require-provenance","--root-only","--generated","--decide","--record-plans","--approval-status","--waves-outcome","--loopback","--artifacts","--push"]);function Z4(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,readOnly:void 0,mcpReadOnly:void 0,propose:void 0,src:void 0,env:void 0},n=e.indexOf("--");e=n<0?a0(e,J4):[...a0(e.slice(0,n),J4),...e.slice(n)];let r=!1,o=s=>{t.command&&(t.positionals??=[]).push(s),t.command?t.path==="."?t.path=s:t.extraPositional?t.extraPositional2=s:t.extraPositional=s:t.command=s},i=0;for(;i<e.length;){let s=e[i];if(r)o(s);else if(s==="--")r=!0;else if(s==="--help"||s==="-h")t.help=!0;else if(s==="--version"||s==="-V")t.version=!0;else if(s==="--output"||s==="-o")t.output=e[++i];else if(s==="--format"||s==="-f")t.format=e[++i];else if(s==="--lexicon"||s==="-d")t.lexicon=e[++i];else if(s==="--template"||s==="-t")t.template=e[++i];else if(s==="--force")t.force=!0;else if(s==="--fix")t.fix=!0;else if(s==="--watch"||s==="-w")t.watch=!0;else if(s==="--verbose"||s==="-v")t.verbose=!0;else if(s==="--profile"||s==="-p")t.profile=e[++i];else if(s==="--report"){let a=e[i+1];a&&!a.startsWith("-")?(t.reportFile=a,i++):t.report=!0}else if(s==="--live")t.live=!0;else if(s==="--overlay")t.overlay=!0;else if(s==="--between"){if(t.betweenA=e[++i],t.betweenB=e[++i],!t.betweenA||!t.betweenB)throw new Error("--between needs two snapshot refs: --between <refA> <refB>")}else if(s==="--traffic"){let a=e[++i];if(!a)throw new Error('--traffic needs a level, passed to the engine verbatim: --traffic "100 rps, p50"');t.traffic=a}else if(s==="--overlay-anchor"){let a=e[++i];if(a!=="source"&&a!=="live")throw new Error(`--overlay-anchor must be 'source' or 'live', got '${a}'`);t.overlayAnchor=a}else if(s==="--scan"){let a=e[++i];if(a===void 0||a==="--"||a.startsWith("--"))throw new Error("--scan needs a directory: --scan <dir>");(t.scanDirs??=[]).push(a)}else if(s==="--from")t.migrateFrom=e[++i];else if(s==="--kustomize")t.kustomize=e[++i];else if(s==="--parser-option"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--parser-option needs key or key=value: --parser-option acceptLossyV1");(t.parserOption??=[]).push(a)}else if(s==="--tag"){let a=e[++i];if(!a||a.startsWith("-")||!a.includes("="))throw new Error("--tag needs key=value: --tag team=payments");(t.selectTags??=[]).push(a)}else if(s==="--type")t.selectType=e[++i];else if(s==="--name")t.selectName=e[++i];else if(s==="--owned")t.owned=!0;else if(s==="--namespace"){if(t.namespace=e[++i],!t.namespace||t.namespace.startsWith("-"))throw new Error("--namespace needs a namespace: --namespace <ns>")}else if(s==="--verbatim")t.verbatim=!0;else if(s==="--skip-undeclarable")t.skipUndeclarable=!0;else if(s==="--state")t.statePath=e[++i],t.statePath!==void 0&&(t.statePaths??=[]).push(t.statePath);else if(s==="--state-dir"){if(t.stateDir=e[++i],!t.stateDir||t.stateDir.startsWith("-"))throw new Error("--state-dir needs a directory: --state-dir <dir>")}else if(s==="--wave-size"){let a=e[++i],c=Number(a);if(!Number.isInteger(c)||c<1)throw new Error(`--wave-size needs a whole number from 1: got "${a??""}"`);t.waveSize=c}else if(s==="--all")t.all=!0;else if(s==="--select")t.selectAddress=e[++i];else if(s==="--live-name")t.liveName=e[++i];else if(s==="--apply-rewrites")t.applyRewrites=!0;else if(s==="--stack")t.carveStack=e[++i];else if(s==="--write")t.write=!0;else if(s==="--write-source")t.writeSource=!0;else if(s==="--to")t.migrateTo=e[++i];else if(s==="--emit")t.emit=e[++i];else if(s==="--dry-run")t.dryRun=!0;else if(s==="--drill")t.drill=!0;else if(s==="--yes")t.yes=!0;else if(s==="--push")t.push=!0;else if(s==="--confirm-prod")t.confirmProd=!0;else if(s==="--strict")t.strict=!0;else if(s==="--validate")t.validate=!0;else if(s==="--use-composites")t.useComposites=!0;else if(s==="--skill")t.skill=e[++i];else if(s==="--skip-mcp")t.skipMcp=!0;else if(s==="--read-only")t.readOnly=!0;else if(s==="--mcp-read-only")t.mcpReadOnly=!0;else if(s==="--propose")t.propose=!0;else if(s==="--src")t.src=e[++i];else if(s==="--env")t.env=e[++i];else if(s==="--port"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--port needs a port: --port <container-port>=<host-port>");(t.port??=[]).push(a)}else if(s==="--image"){if(t.image=e[++i],!t.image||t.image.startsWith("-"))throw new Error("--image needs an image reference: --image <name>:<tag>")}else if(s==="--network"){if(t.network=e[++i],!t.network||t.network.startsWith("-"))throw new Error("--network needs a Docker network name: --network <name>")}else if(s==="--setting"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--setting needs a value: --setting <KEY>=<VALUE>");(t.setting??=[]).push(a)}else if(s==="--loopback")t.loopback=!0;else if(s==="--promote-to"){if(t.promoteTo=e[++i],!t.promoteTo||t.promoteTo.startsWith("-"))throw new Error("--promote-to needs an environment: --promote-to <env>")}else if(s==="--tier")t.tier=e[++i];else if(s==="--agents")t.agents=!0;else if(s==="--scope")t.scope=e[++i];else if(s==="--all-projects")t.allProjects=!0;else if(s==="--runtime")t.runtime=e[++i];else if(s==="--fail-on")t.failOn=e[++i];else if(s==="--max-files")t.maxFiles=Number(e[++i]);else if(s==="--theme")t.theme=e[++i];else if(s==="--stacks")t.stacks=!0;else if(s==="--components")t.components=!0;else if(s==="--generate")t.generate=e[++i];else if(s==="--spec")t.opsSpec=e[++i];else if(s==="--dump-outputs")t.dumpOutputs=e[++i];else if(s==="--digest-file")t.digestFile=e[++i];else if(s==="--seed-outputs")(t.seedOutputs??=[]).push(e[++i]);else if(s==="--keep")t.keepLocks=!0;else if(s==="--runs"||s==="--plans"||s==="--wave-outputs"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error(`${s} needs a file`);t[{"--runs":"runsFile","--plans":"plansFile","--wave-outputs":"waveOutputs"}[s]]=a}else if(s==="--detail")t.detail=Number(e[++i]);else if(s==="--lens")t.lens=e[++i];else if(s==="--explain")t.explain=!0;else if(s==="--show")t.show=e[++i];else if(s==="--count-by"){if(t.countBy=e[++i],!t.countBy||t.countBy.startsWith("-"))throw new Error("--count-by needs a grouping: --count-by kind, --count-by module or --count-by attr:<name>")}else if(s==="--up")t.up=!0;else if(s==="--down")t.down=!0;else if(s==="--node-sizes")t.nodeSizes=e[++i];else if(s==="--layout-engine")t.layoutEngine=e[++i];else if(s==="--base")t.base=e[++i];else if(s==="--head")t.head=e[++i];else if(s==="--include-dependents")t.includeDependents=!0;else if(s==="--cross-root")t.crossRoot=!0;else if(s==="--dependents-of"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--dependents-of needs a member name: --dependents-of <member>");t.dependentsOf=a}else if(s==="--pin"){let a=e[++i];if(!a||a.startsWith("-")||!a.includes("="))throw new Error("--pin needs a member and a release: --pin <member>=<label|digest>");(t.pins??=[]).push(a)}else if(s==="--from-affected")t.fromAffected=e[++i];else if(s==="--gate")t.gate=e[++i];else if(s==="--wave-gate"){if(t.waveGate=e[++i],!t.waveGate||t.waveGate.startsWith("-"))throw new Error("--wave-gate needs a gate name: --wave-gate <name>")}else if(s==="--wave"){let a=e[++i],c=Number(a);if(!Number.isInteger(c)||c<1)throw new Error(`--wave needs a wave number from 1: got "${a??""}"`);t.wave=c}else if(s==="--decide")t.decide=!0;else if(s==="--record-plans")t.recordPlans=!0;else if(s==="--approval-status")t.approvalStatus=!0;else if(s==="--waves-outcome")t.wavesOutcome=!0;else if(s==="--group"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--group needs a job group's name: --group <name>");t.group=a}else if(s==="--share"){let a=e[++i],c=Number(a);if(!Number.isInteger(c)||c<1)throw new Error(`--share needs a share number from 1: got "${a??""}"`);t.share=c}else if(s==="--target"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--target needs an address: --target <component>:<address>, or on pr-plan --target <address>");(t.targets??=[]).push(a)}else if(s==="--refresh")t.refresh=!0;else if(s==="--target-dependents")t.targetDependents=!0;else if(s==="--comment-targets")t.commentTargets=!0;else if(s==="--parallelism"){let a=e[++i],c=Number(a);if(!Number.isInteger(c)||c<1)throw new Error(`--parallelism needs a whole number of 1 or more: got "${a??""}"`);t.parallelism=c}else if(s==="--canary"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--canary needs a component name: --canary <name>[,<name>...]");(t.canary??=[]).push(...a.split(",").map(c=>c.trim()).filter(Boolean))}else if(s==="--pr"){let a=e[++i],c=Number(a);if(!Number.isInteger(c)||c<1)throw new Error(`--pr needs a pull or merge request number: got "${a??""}"`);t.pr=c,(t.prs??=[]).push(c)}else if(s==="--channel"){if(t.channel=e[++i],!t.channel||!/^[A-Za-z][A-Za-z0-9._-]*$/.test(t.channel))throw new Error(`--channel needs a channel name, such as next or hotfix: got "${t.channel??""}"`)}else if(s==="--forge"){if(t.forge=e[++i],!t.forge||t.forge.startsWith("-"))throw new Error("--forge needs a forge: --forge github|gitlab|forgejo")}else if(s==="--require-clouds")t.requireClouds=!0;else if(s==="--require-review")t.requireReview=!0;else if(s==="--list")t.list=!0;else if(s==="--stage"){if(t.lockStage=e[++i],!t.lockStage||t.lockStage.startsWith("-"))throw new Error("--stage needs plan, apply or lock: --stage <stage>")}else if(s==="--alive"){if(t.aliveRun=e[++i],!t.aliveRun||t.aliveRun.startsWith("-"))throw new Error("--alive needs a run id: --alive <run>")}else if(s==="--from-report"){if(t.fromReport=e[++i],!t.fromReport||t.fromReport.startsWith("-"))throw new Error("--from-report needs a report file: --from-report <pr-plan.json>")}else if(s==="--report-url"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--report-url needs a URL: --report-url s3://<bucket>/<prefix>, gs://<bucket>/<prefix>, az://<account>/<container>/<prefix> or file://<directory>");t.reportUrl=a}else if(s==="--result"){if(t.planResult=e[++i],!t.planResult||t.planResult.startsWith("-"))throw new Error("--result needs the plan job's result: --result success|failure|cancelled")}else if(s==="--no-status")t.noStatus=!0;else if(s==="--status-url"){if(t.statusUrl=e[++i],!t.statusUrl||t.statusUrl.startsWith("-"))throw new Error("--status-url needs a URL template: --status-url https://host/reports/{key}")}else if(s==="--allow-unsigned")t.allowUnsigned=!0;else if(s==="--require-provenance")t.requireProvenance=!0;else if(s==="--pr-loop")t.prLoop=!0;else if(s==="--green")t.green=!0;else if(s==="--before-merge")t.beforeMerge=!0;else if(s==="--requires"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error("--requires needs a list of checks: --requires approved,mergeable,undiverged,checks");t.requires=a.split(",").map(c=>c.trim()).filter(Boolean)}else if(s==="--respond"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error("--respond needs a list of responses: --respond wave-refused=diff,apply-failed=off,description=check");t.respond=[...t.respond??[],a]}else if(s==="--decide-backend"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error("--decide-backend needs the name of a decide.backends entry");t.decideBackend=a}else if(s==="--decide-model"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error("--decide-model needs a model id");t.decideModel=a}else if(s==="--merge"||s==="--merge-token-env"||s==="--merge-method"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error(`${s} needs a value: --merge manual|auto, --merge-token-env <VAR>, --merge-method merge|squash|rebase`);s==="--merge"?t.merge=a:s==="--merge-token-env"?t.mergeTokenEnv=a:t.mergeMethod=a}else if(s==="--apply-before-merge")t.applyBeforeMerge=!0;else if(s==="--apply-on-merge")t.applyOnMerge=!0;else if(s==="--action-job")t.actionJob=!0;else if(s==="--preview-comment")t.previewComment=!0;else if(s==="--pr-env")t.prEnv=!0;else if(s==="--pr-runner"){let a=e[++i]??"",c=/^(plan|apply|default)=(.+)$/.exec(a);if(!c)throw new Error(`--pr-runner needs <stage>=<label>[,<label>...], the stage plan, apply or default: got "${a}"`);let l=c[2].split(",").map(u=>u.trim()).filter(Boolean);if(l.length===0)throw new Error(`--pr-runner ${c[1]} names no label`);(t.prRunners??={})[c[1]]=l}else if(s==="--pr-variable"||s==="--pr-secret"){let a=e[++i]??"",c=a.indexOf("=");if(c<1)throw new Error(`${s} needs <NAME>=<${s==="--pr-secret"?"secret":"value"}>: got "${a}"`);let l=s==="--pr-secret"?t.prSecrets??={}:t.prVariables??={};l[a.slice(0,c)]=a.slice(c+1)}else if(s==="--pr-build")t.prBuild=!0;else if(s==="--build-command"){let a=e[++i];if(a===void 0||a==="")throw new Error("--build-command needs a shell line: --build-command '<line>'");t.ciBuildCommand=a}else if(s==="--land")t.ciLand=!0;else if(s==="--pr-build-command"){let a=e[++i];if(a===void 0||a==="")throw new Error("--pr-build-command needs a shell line: --pr-build-command '<line>'");t.prBuildCommand=a}else if(s==="--before-script"){let a=e[++i];if(a===void 0||a==="")throw new Error("--before-script needs a shell line: --before-script '<line>'");(t.beforeScript??=[]).push(a)}else if(s==="--resume"){let a=e[i+1];a===void 0||a.startsWith("-")?t.resumeRun=!0:t.resume=e[++i]}else if(s==="--local")t.local=!0;else if(s==="--json")t.json=!0;else if(s==="--progress-json")t.progressJson=!0;else if(s==="--events-json")t.eventsJson=!0;else if(s==="--follow")t.follow=!0;else if(s==="--gated-exit")t.gatedExit=Number(e[++i]);else if(s==="--durable-requests")t.durableRequests=!0;else if(s==="--update-snapshot")t.updateSnapshot=!0;else if(s==="--update-baseline")t.updateBaseline=!0;else if(s==="--deep")t.deep=!0;else if(s==="--at")t.at=e[++i];else if(s==="--capability-view")t.capabilityView=!0;else if(s==="--capabilities")t.capabilities=!0;else if(s==="--snapshot"){if(t.snapshot=e[++i],!t.snapshot||t.snapshot.startsWith("-"))throw new Error("--snapshot needs a snapshot ref: --snapshot latest")}else if(s==="--kind"){if(t.kind=e[++i],!t.kind||t.kind.startsWith("-"))throw new Error("--kind needs a kind file: --kind <path>");(t.kinds??=[]).push(t.kind)}else if(s==="--composites")t.composites=!0;else if(s==="--intent"){let a=e[i+1];if(a!==void 0&&!a.startsWith("-"))t.intent=e[++i];else if(e.includes("--record"))t.intent="";else throw new Error("--intent needs a region: --intent <path[:start-end]|path#symbol|member/node|sha>, or --intent --record <id>")}else if(s==="--follow-squash")t.followSquash=!0;else if(s==="--record"){if(t.record=e[++i],!t.record||t.record.startsWith("-"))throw new Error("--record needs a record id: --record <id>")}else if(s==="--path"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--path needs a path: --path <path>");(t.paths??=[]).push(a)}else if(s==="--worktree")t.worktree=!0;else if(s==="--max-bytes"){let a=Number(e[++i]);if(!Number.isInteger(a)||a<1)throw new Error("--max-bytes needs a whole number of bytes above 0");t.maxBytes=a}else if(s==="--changes"){if(t.changes=e[++i],!t.changes||t.changes.startsWith("-"))throw new Error("--changes needs a range: --changes <base>..<head>")}else if(s==="--severity"){if(t.severity=e[++i],!t.severity||t.severity.startsWith("-"))throw new Error("--severity needs off, warn or fail")}else if(s==="--current")t.current=!0;else if(s==="--uncommitted")t.uncommitted=!0;else if(s==="--set"){if(t.set=e[++i],!t.set||t.set.startsWith("-")&&t.set!=="-")throw new Error("--set needs a JSON file, or - for standard input: --set <file|->")}else if(s==="--cover"){if(t.cover=e[++i],!t.cover||t.cover.startsWith("-"))throw new Error("--cover needs a PNG, JPEG or WebP file: --cover <image>")}else if(s==="--cover-path"){if(t.coverPath=e[++i],!t.coverPath||t.coverPath.startsWith("-"))throw new Error("--cover-path needs a path from the workspace root: --cover-path <path>")}else if(s==="--records")t.records=!0;else if(s==="--expect"){if(t.expect=e[++i],!t.expect||t.expect.startsWith("-"))throw new Error("--expect needs the record's digest, as records --json prints it: --expect <digest>")}else if(s==="--label"){if(t.label=e[++i],!t.label||t.label.startsWith("-"))throw new Error("--label needs the snapshot's name, such as a turn id: --label <text>")}else if(s==="--branch"){if(t.branch=e[++i],!t.branch||t.branch.startsWith("-"))throw new Error("--branch needs a branch name: --branch <branch>")}else if(s==="--security"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--security needs a group: --security verified-releases|supply-chain|who-ran-it|review-rules|isolated-runners");t.securityGroups=[...t.securityGroups??[],a]}else if(s==="--workflow"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--workflow needs a workflow's name: --workflow <name>");t.ciWorkflows=[...t.ciWorkflows??[],a]}else if(s==="--chant"){if(t.ciChant=e[++i],!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(s==="--commit"){if(t.commit=e[++i],!t.commit||t.commit.startsWith("-"))throw new Error("--commit needs the commit the job runs at: --commit <sha>")}else if(s==="--pass-env"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--pass-env needs a variable's name, such as AWS_PROFILE: --pass-env <NAME>");(t.passEnv??=[]).push(a)}else if(s==="--secrets"){if(t.ciSecrets=e[++i],!t.ciSecrets||t.ciSecrets.startsWith("-"))throw new Error("--secrets needs the host's secrets file, a dotenv or JSON file only its owner can read: --secrets <file>")}else if(s==="--repo"){if(t.ciRepo=e[++i],!t.ciRepo||!/^[^/\s-][^/\s]*\/[^/\s]+$/.test(t.ciRepo))throw new Error("--repo needs the repository as owner/name: --repo <owner/repo>")}else if(s==="--run-index-limit"){let a=Number(e[++i]);if(!Number.isInteger(a)||a<1)throw new Error("--run-index-limit needs a whole number of runs, 1 or more: --run-index-limit <n>");t.runIndexLimit=a}else if(s==="--max-jobs"){let a=Number(e[++i]);if(!Number.isInteger(a)||a<1)throw new Error("--max-jobs needs a whole number of jobs, 1 or more: --max-jobs <n>");t.maxJobs=a}else if(s==="--author"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--author needs a forge login: --author <login>");(t.ciAuthors??=[]).push(a)}else if(s==="--rerun-failed")t.rerunFailed=!0;else if(s==="--install"){if(t.ciInstall=e[++i],!t.ciInstall||t.ciInstall.startsWith("-"))throw new Error('--install needs the install command, such as "npm install": --install <command>')}else if(s==="--token-secret"){if(t.ciTokenSecret=e[++i],!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(s==="--app-id-var"){if(t.ciAppIdVar=e[++i],!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(s==="--app-key-secret"){if(t.ciAppKeySecret=e[++i],!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(s==="--runner-key-secret"){if(t.ciRunnerKeySecret=e[++i],!t.ciRunnerKeySecret||t.ciRunnerKeySecret.startsWith("-"))throw new Error("--runner-key-secret needs the repository secret holding the runner key, such as CHANT_RUNNER_KEY: --runner-key-secret <NAME>")}else if(s==="--verdict"){if(t.verdict=e[++i],!t.verdict||t.verdict.startsWith("-"))throw new Error("--verdict needs agree, dissent or abstain")}else if(s==="--class"){if(t.runnerClass=e[++i],!t.runnerClass||t.runnerClass.startsWith("-"))throw new Error("--class needs runner or service: --class <class>")}else if(s==="--by"){if(t.by=e[++i],!t.by||t.by.startsWith("-"))throw new Error("--by needs the reviewer: --by <principal>");(t.bys??=[]).push(t.by)}else if(s==="--stale-notes")t.staleNotes=!0;else if(s==="--stale")t.stale=!0;else if(s==="--tip"){let a=e[++i];if(!a||!/^[0-9a-f]{40}$/.test(a))throw new Error(`--tip needs the target branch's full commit sha: got "${a??""}"`);t.tip=a}else if(s==="--open")t.open=!0;else if(s==="--inputs"){if(t.inputs=e[++i],!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(s==="--candidates"){if(t.candidates=e[++i],!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(s==="--response"){if(t.response=e[++i],!t.response||t.response.startsWith("-"))throw new Error("--response needs a JSON file: --response <file>")}else if(s==="--subject"){if(t.subject=e[++i],!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(s==="--store"){let a=e[++i];if(a!=="tree"&&a!=="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=a}else if(s==="--answer"){if(t.answer=e[++i],t.answer===void 0||t.answer==="")throw new Error("--answer needs one of the question's candidates: --answer <value>")}else if(s==="--sign"){let a=e[i+1];t.sign=a!==void 0&&!a.startsWith("-")?e[++i]:!0}else if(s==="--session"){if(t.session=e[++i],!t.session||t.session.startsWith("-"))throw new Error("--session needs a session id: --session <id>")}else if(s==="--prefix"){if(t.prefix=e[++i],!t.prefix||t.prefix.startsWith("-"))throw new Error("--prefix needs an id prefix: --prefix <prefix>")}else if(s==="--key"||s==="--check-id"||s==="--claim"||s==="--environment"||s==="--envelope"||s==="--threshold"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error(`${s} needs a value`);let c={"--key":"key","--check-id":"checkId","--claim":"claim","--environment":"environment","--envelope":"envelope","--threshold":"threshold"}[s];t[c]=a}else if(s==="--require"){if(t.require=e[++i],!t.require||t.require.startsWith("-"))throw new Error("--require needs a provenance level: --require attested")}else if(s==="--ambient")t.ambient=!0;else if(s==="--check-live")t.checkLive=!0;else if(s==="--check-snapshot")t.checkSnapshot=!0;else if(s==="--fail-on-drift")t.failOnDrift=!0;else if(s==="--run-examples")t.runExamples=!0;else if(s==="--pinned-digest")t.pinnedDigest=e[++i];else if(s==="--check")t.check=!0;else if(s==="--bump")t.bump=!0;else if(s==="--component")t.component=e[++i];else if(s==="--digest")t.digest=e[++i],t.digest!==void 0&&(t.digests??=[]).push(t.digest);else if(s==="--release-plan")t.releasePlanFile=e[++i];else if(s==="--release"){if(t.release=e[++i],!t.release||t.release.startsWith("-"))throw new Error("--release needs a release's label or digest: --release <label|digest>")}else if(s==="--build"){if(t.buildCommand=e[++i],!t.buildCommand)throw new Error("--build needs a shell command: --build '<command>'")}else if(s==="--artifacts")t.artifacts=!0;else if(s==="--git-sha")t.gitSha=e[++i];else if(s==="--run-id")t.runId=e[++i];else if(s==="--actor")t.actor=e[++i];else if(s==="--approver")t.approver=e[++i];else if(s==="--relayed-by"){if(t.relayedBy=e[++i],!t.relayedBy||t.relayedBy.startsWith("-"))throw new Error("--relayed-by needs the principal that relayed it: --relayed-by <principal>")}else if(s==="--on"){if(t.on=e[++i],!t.on||t.on.startsWith("-"))throw new Error("--on needs a runtime name: --on <lexicon>")}else if(s==="--compare-to")t.compareTo=e[++i];else if(s==="--no-release-record")t.noReleaseRecord=!0;else if(s==="--no-record")t.noRecord=!0;else if(s==="--fold")t.fold=!0;else if(s==="--no-cache")t.noCache=!0;else if(s==="--no-fold")t.fold=!1;else if(s==="--sandbox")t.sandbox=!0;else if(s==="--fold-rank"){let a=e[i+1];a&&!a.startsWith("-")?(t.foldRankCollapsedFile=a,i++):t.foldRank=!0}else if(s==="--param")(t.param??=[]).push(e[++i]);else if(s==="--lexicon-output")(t.lexiconOutput??=[]).push(e[++i]);else if(s==="--params-file")t.paramsFile=e[++i];else if(s==="--projection")t.projection=e[++i];else if(s==="--interval")t.interval=e[++i];else if(s==="--lease-ttl")t.leaseTtl=e[++i];else if(s==="--steward"){let a=e[i+1];a!==void 0&&!a.startsWith("-")?(t.steward=a,i++):t.steward=""}else if(s==="--once")t.once=!0;else if(s==="--setup-key")t.setupKey=!0;else if(s==="--trust")t.trustKey=!0;else if(s==="--in-place")t.ciInPlace=!0;else if(s==="--require-runner-start")t.requireRunnerStart=!0;else if(s==="--job"){if(t.ciJob=e[++i],!t.ciJob||t.ciJob.startsWith("-"))throw new Error("--job needs the job as JSON or @<file>: --job @job.json")}else if(s==="--no-push")t.noPush=!0;else if(s==="--no-require-review")t.requireReview=!1;else if(s==="--unsigned")t.unsigned=!0;else if(s==="--principal"){if(t.ciPrincipal=e[++i],!t.ciPrincipal||t.ciPrincipal.startsWith("-"))throw new Error("--principal needs the runner's principal: --principal <name>")}else if(s==="--work"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--work needs a work item id: --work <id>");t.work=a,(t.works??=[]).push(a)}else if(s==="--holder"||s==="--ttl"||s==="--token"||s==="--outcome"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error(`${s} needs a value: ${s} <${s.slice(2)}>`);t[s.slice(2)]=a}else if(s==="--input"||s==="--org"||s==="--endpoint"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error(`${s} needs a value: ${s} <${s==="--input"?"file":s.slice(2)}>`);t[s.slice(2)]=a}else if(s==="--signer"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--signer needs a principal: --signer <principal>");t.signer=a}else if(s==="--unit"||s==="--decision"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error(`${s} needs an id: ${s} <id>`);t[s.slice(2)]=a}else if(s==="--note")t.note=e[++i];else if(s==="--reason"){if(t.reason=e[++i],t.reason===void 0||t.reason.startsWith("-"))throw new Error("--reason needs the text of the reason: --reason <text>")}else if(s==="--rule"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--rule needs a rule id: --rule <id>");(t.rules??=[]).push(a)}else if(s==="--expire")t.expire=!0;else if(s==="--role"){let a=e[++i]??"";t.roles=[...t.roles??[],...a.split(",").map(c=>c.trim()).filter(Boolean)]}else if(s==="--agent")t.agent=!0;else if(s==="--allow-code")t.allowCode=!0;else if(s==="--allow-skip")t.allowSkip=!0;else if(s==="--source"){if(t.source=e[++i],!t.source||t.source.startsWith("-"))throw new Error("--source needs a template: --source <repo>[#<member>] for workspace upgrade, or a source for ci tick and ci list: --source checks|runs")}else if(s==="--tags"){if(t.tags=e[++i],!t.tags||t.tags.startsWith("-"))throw new Error("--tags needs a tag glob: --tags 'v*'")}else if(s==="--index"){if(t.index=e[++i],!t.index||t.index.startsWith("-"))throw new Error("--index needs a value: --index <file> for workspace adopt-lineage, --index <scope key>[@<version>] for search and lifecycle diff")}else if(s==="--adopt"){if(t.adopt=e[++i],!t.adopt||t.adopt.startsWith("-"))throw new Error("--adopt needs an adoption file: --adopt <file>")}else if(s==="--adopt-out"){if(t.adoptOut=e[++i],!t.adoptOut||t.adoptOut.startsWith("-"))throw new Error("--adopt-out needs a file: --adopt-out <file>")}else if(s==="--remove")t.remove=!0;else if(s==="--available")t.available=!0;else if(s==="--root-only")t.rootOnly=!0;else if(s==="--forge-repos"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--forge-repos needs a file: --forge-repos <repos.json>");t.forgeRepos=a}else if(s==="--generated")t.generated=!0;else if(s==="--member"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--member needs a member or group name: --member <name>");t.members=[...t.members??[],...a.split(",").map(c=>c.trim()).filter(Boolean)]}else if(s==="--allow-same-origin")t.allowSameOrigin=!0;else if(s==="--plan")t.plan=e[++i];else if(s==="--url")t.url=e[++i];else if(s==="--op")t.op=e[++i];else if(s==="--where"){let a=e[++i];if(a===void 0||a.startsWith("--"))throw new Error("--where needs a clause: --where <field><op><value>");t.where=[...t.where??[],a]}else if(s==="--read"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--read needs a read: --read <state|plan|refresh|live-read|ownership>");t.driftRead=a}else if(s==="--stream")t.stream=!0;else if(s==="--resource"){let a=e[++i];if(!a||a.startsWith("--"))throw new Error("--resource needs an address: --resource <addr>");t.resource=a}else if(s==="--since")t.since=e[++i];else if(s==="--audit-log"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--audit-log needs the log: --audit-log aws[:<region>]");t.auditLog=a}else if(s==="--limit")t.limit=Number(e[++i]);else{if(s.startsWith("--"))throw new Error(`Unknown flag: ${s}
492
492
  Run "chant --help" to see supported flags.`);if(/^-[A-Za-z]/.test(s))throw new Error(`Unknown flag: ${s}
493
493
  Run "chant --help" to see supported flags.`);o(s)}i++}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 uRe={lc:"lifecycle",sync:"update"};function Y4(e,t){let n=uRe[e.command]??e.command,r=`${n} ${e.path}`,o=t.find(s=>s.name===r);if(o)return{def:o,compound:!0};let i=t.find(s=>s.name===n);return i?{def:i,compound:!1}:null}Jn();function Q4(e){return new Promise(t=>{let n=()=>{if(e.writableLength===0||e.writableEnded||e.destroyed){o(),t();return}e.once("drain",n)},r=()=>{o(),t()},o=()=>{e.off("drain",n),e.off("error",r),e.off("close",r)};e.once("error",r),e.once("close",r),n()})}async function l0(e){await Q4(process.stdout),await Q4(process.stderr),process.exit(e)}u0();import{realpathSync as X4}from"node:fs";import{fileURLToPath as pRe}from"node:url";function e6(e,t){if(!e)return!1;try{return X4(e)===X4(pRe(t))}catch{return!1}}Wh();Io();iW();VA();fO();Jn();Ps();import{readFileSync as o0}from"node:fs";import{relative as Gke,resolve as Zg}from"node:path";async function Wke(e){let t=e.args.noRecord===!0;if(!t&&!Ur())return Mke(e);let n=t?"--no-record":`${fi}=${process.env[fi]}`,r=process.env[fi];t&&(process.env[fi]="1"),hE(),console.error(cr({message:ZF(n)}));try{return await Mke(e)}finally{console.error(cr({message:QF(n)})),hE(),t&&(r===void 0?delete process.env[fi]:process.env[fi]=r)}}async function Mke(e){let{args:t}=e,n=t.opsSpec;if(n&&t.recordPlans)try{let i=na(o0(Zg(n),"utf-8"),`--spec ${n}`),s=await qA({spec:i});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(i){return console.error($e({message:i instanceof Error?i.message:String(i)})),1}if(n&&t.approvalStatus)return btt(e,n);if(n&&t.wavesOutcome)try{let i=na(o0(Zg(n),"utf-8"),`--spec ${n}`),{opWaveOutcomeDir:s}=await Promise.resolve().then(()=>(Os(),b7)),{earlierWaveOutcomes:a}=await Promise.resolve().then(()=>(rw(),n7)),{applyOutcomeOf:c}=await Promise.resolve().then(()=>(dke(),uke)),l=c(a([Zg(s(i))],Number.MAX_SAFE_INTEGER).members);if(t.json)console.log(JSON.stringify(l,null,2));else{console.log(l.outcome);let u=Object.entries(l.counts).map(([d,p])=>`${p} ${d}`).join(", ");console.error(`${i.name}: ${l.outcome}${u?` (${u})`:", no wave wrote an outcome"}`)}return 0}catch(i){return console.error($e({message:i instanceof Error?i.message:String(i)})),1}if(!n||t.wave===void 0)return console.error($e({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> | --group <name> [--share <i>]]"})),1;if(t.decide&&(t.share!==void 0||t.group!==void 0))return console.error($e({message:`--decide and --${t.share!==void 0?"share":"group"} are two different jobs; pass one`})),1;let r,o={...t.share!==void 0?{share:t.share}:{},...t.group!==void 0?{group:t.group}:{}};if(t.eventsJson&&t.json)return console.error($e({message:"--events-json and --json both print to stdout",hint:"Pass one. --events-json prints the job's run events; --json prints its result."})),1;try{let i=Zg(n);r=na(o0(i,"utf-8"),`--spec ${n}`);let s=t.eventsJson?await(await Promise.resolve().then(()=>(mke(),fke))).openCliRunEvents(t,{kind:"op",name:r.name,cwd:process.cwd()}):void 0,a=Hne(),c=await zA({...s?{events:s.emit}:{},...a?.afterPlan?{afterPlan:a.afterPlan}:{},...a?.capabilities?{capabilities:a.capabilities}:{},...a?.hookExec?{hookExec:a.hookExec}:{},spec:r,specFile:Gke(process.cwd(),i),wave:t.wave,...t.decide?{decide:!0}:{},...t.share!==void 0?{share:t.share}:{},...t.group!==void 0?{group:t.group}:{},...t.base?{base:t.base}:{}});return t.json&&console.log(JSON.stringify(c,null,2)),await sO(r,t.wave,{result:c},o),await Fke(r,t.wave,{result:c}),c.exitCode}catch(i){let s=i instanceof Error?i.message:String(i);return console.error($e({message:s})),r&&(await sO(r,t.wave,{error:s},o),await Fke(r,t.wave,{error:s})),1}}async function Fke(e,t,n){try{let{respondOpWave:r,triageOfOpWave:o}=await Promise.resolve().then(()=>(_ke(),Ake)),{resolveResponses:i}=await Promise.resolve().then(()=>(H4(),xke)),s=i(e.respond);if(s["wave-refused"]==="off"&&s["apply-failed"]==="off"||n.result&&n.result.exitCode===0&&!o(e,t,n))return;let{detectForge:a,forgeFromEnv:c}=await Promise.resolve().then(()=>($d(),bU)),l=a();if(!l)return;let u;try{u=c(l)}catch{return}let d=process.env.GITHUB_SHA??process.env.CI_COMMIT_SHA;await r(e,t,n,{forge:u,...d?{head:d}:{}})}catch(r){console.error(cr({message:`the wave's responses were not posted: ${r instanceof Error?r.message:String(r)}`}))}}async function btt(e,t){let{args:n}=e,r=d=>(console.error($e({message:d})),1),{FORGE_KINDS:o,forgeFromEnv:i}=await Promise.resolve().then(()=>($d(),bU));if(!n.forge||!o.includes(n.forge))return r(`--approval-status posts on a forge: --forge ${o.join("|")}`);let s,a;try{s=na(o0(Zg(t),"utf-8"),`--spec ${t}`),a=i(n.forge)}catch(d){return r(d instanceof Error?d.message:String(d))}let{postApprovalStatus:c,postOpenApprovalStatuses:l}=await Promise.resolve().then(()=>(Lke(),Nke)),u=Gke(process.cwd(),Zg(t));try{if(n.open){let p=n.branch??process.env.CI_COMMIT_BRANCH;if(!p)return r("--approval-status --open posts for the pull requests into a branch: run it in a branch pipeline, or pass --branch <branch>");let f=await l({spec:s,specFile:u,forge:a,branch:p});for(let m of f.warnings)console.error(cr({message:m}));for(let m of f.posted)console.error(`!${m.pr}: ${m.status.state}: ${m.status.description}`);return f.warnings.length>0&&f.posted.length===0?1:0}if(n.pr===void 0||!n.head||!n.base)return r("--approval-status needs the pull request, its head and its base: --pr <n> --head <sha> --base <sha>, or --open");let d=await c({spec:s,specFile:u,forge:a,pr:n.pr,head:n.head,base:n.base});return console.error(`#${n.pr}: ${d.state}: ${d.description}`),0}catch(d){return r(`the approval status was not posted: ${d instanceof Error?d.message:String(d)}`)}}N_();K4();sR();var Itt=[{name:"run wave",handler:Wke},{name:"run resume",handler:g4},{name:"approve",handler:rRe},{name:"workspace points",handler:b4}],Ttt=`
494
494
  chant runtime ${mR} - the wave-job commands of chant, in one file