@oss-autopilot/core 3.30.0 → 3.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -323,7 +323,8 @@ export const commands = [
323
323
  .command('search [count]')
324
324
  .description('Search for new issues to work on')
325
325
  .option('--json', 'Output as JSON')
326
- .option('--strategy <strategies>', "Comma-separated discovery phases to run (merged,orgs,starred,broad,maintained,all). Omit to run scout's default staged pipeline.")
326
+ .option('--strategy <strategies>', 'Comma-separated discovery phases to rotate through (merged,orgs,starred,broad,maintained,all). Omit for all. Each search runs one of them in turn unless --full is set.')
327
+ .option('--full', 'Run every enabled strategy in this search instead of one per search in rotation. More API calls, can take a few minutes.')
327
328
  .action(async (count, options) => {
328
329
  const { SearchOutputSchema } = await import('./formatters/json.js');
329
330
  await executeAction(options, async () => {
@@ -344,7 +345,7 @@ export const commands = [
344
345
  if (!options.json) {
345
346
  console.log(`\nSearching for issues (max ${maxResults})...\n`);
346
347
  }
347
- return runSearch({ maxResults, strategies });
348
+ return runSearch({ maxResults, strategies, full: options.full });
348
349
  }, (data) => {
349
350
  if (data.hiddenOwnPRCount > 0) {
350
351
  console.log(`Hidden: ${data.hiddenOwnPRCount} candidate(s) were issues you already have open PRs for.`);
@@ -55,7 +55,7 @@ ${c}`:c:"",p=Function,d=`return (input) => {
55
55
  ${c}
56
56
  }`,m;try{m=new p(...i,d)(...a)}catch(f){throw new ye(`this schema (generated code failed to evaluate: ${f.message})`)}return t?.debug&&(m.code=l),m}function Q(e,t){for(let[n,s]of e.constants)if(s===t)return n;let r=`c${e.constantCounter++}`;return e.constants.set(r,t),r}function re(e){return`v${e.varCounter++}`}function pD(e,t){let r=e._zod.run({value:t,issues:[]},{});if(r&&typeof r.then=="function")return Vt;let n=r;return n.issues.length===0?n.value:Vt}function wt(e,t,r,n,s=!0){let o=e.content.length,i=t.constants.size,a=t.constantCounter,c=t.varCounter;try{return Ue(e,t,r,n,s)}catch(l){if(!(l instanceof ye)||!l.islandable)throw l;if(e.content.length=o,t.constants.size>i){let p=Array.from(t.constants.keys()).slice(i);for(let d of p)t.constants.delete(d)}return t.constantCounter=a,t.varCounter=c,dD(e,t,r,n)}}function dD(e,t,r,n){let s=Q(t,r),o=Q(t,pD),i=re(t);return e.write(`const ${i} = ${o}(${s}, ${n});`),e.write(`if (${i} === INVALID) return INVALID;`),i}function fD(e,t,r,n){let s=r._zod.def.checks;if(!s||s.length===0)return n;let o=n;for(let i of s){let a=i._zod.def;if(a.when&&!mD.has(a.check))throw new ye('check with a custom "when" condition');switch(a.check){case"greater_than":gD(e,t,a,o);break;case"less_than":hD(e,t,a,o);break;case"multiple_of":yD(e,t,a,o);break;case"number_format":mv(e,a,o);break;case"min_length":{let c=us(a.minimum,"min_length"),l=ah(e,t,o,`${o}.length >= ${c} && ${o}.length < ${a.minimum*2}`);e.write(`if (${l} < ${c}) return INVALID;`);break}case"max_length":{let c=us(a.maximum,"max_length"),l=ah(e,t,o,`${o}.length > ${c}`);e.write(`if (${l} > ${c}) return INVALID;`);break}case"length_equals":{let c=us(a.length,"length_equals"),l=ah(e,t,o,`${o}.length >= ${c} && ${o}.length <= ${a.length*2}`);e.write(`if (${l} !== ${c}) return INVALID;`);break}case"min_size":e.write(`if (${o}.size < ${us(a.minimum,"min_size")}) return INVALID;`);break;case"max_size":e.write(`if (${o}.size > ${us(a.maximum,"max_size")}) return INVALID;`);break;case"size_equals":e.write(`if (${o}.size !== ${us(a.size,"size_equals")}) return INVALID;`);break;case"string_format":o=fv(e,t,a,o);break;case"custom":o=SD(e,t,i,o);break;case"bigint_format":bD(e,a,o);break;case"mime_type":wD(e,t,a,o);break;case"property":_D(e,t,a,o);break;case"overwrite":{let c=re(t);RD(e,t,i,o,c),o=c;break}default:throw new ye(`check type ${a.check}`)}}return o}function ah(e,t,r,n){let s=Q(t,os),o=re(t);return e.write(`const ${o} = typeof ${r} === "string" && ${n} ? ${s}(${r}) : ${r}.length;`),o}function us(e,t){if(typeof e!="number"||!Number.isFinite(e))throw new ye(`${t} bound of type ${typeof e}`);return`${e}`}function dv(e,t){if(typeof t=="bigint")return`${t}n`;if(typeof t=="number"){if(Number.isNaN(t))throw new ye("comparison check with NaN bound");return`${t}`}if(t instanceof Date){if(Number.isNaN(t.getTime()))throw new ye("comparison check with Invalid Date bound");return Q(e,t)}throw new ye(`comparison check bound of type ${typeof t}`)}function gD(e,t,r,n){let s=r.inclusive?"<":"<=";e.write(`if (${n} ${s} ${dv(t,r.value)}) return INVALID;`)}function hD(e,t,r,n){let s=r.inclusive?">":">=";e.write(`if (${n} ${s} ${dv(t,r.value)}) return INVALID;`)}function yD(e,t,r,n){if(typeof r.value=="bigint"){if(r.value===BigInt(0))throw new ye("multiple_of check with a zero divisor");e.write(`if (${n} % ${r.value}n !== 0n) return INVALID;`)}else{let s=Q(t,na);e.write(`if (${s}(${n}, ${us(r.value,"multiple_of")}) !== 0) return INVALID;`)}}function mv(e,t,r){let n=t.format;switch(n){case"safeint":e.write(`if (!Number.isSafeInteger(${r})) return INVALID;`);break;case"int32":e.write(`if (!Number.isInteger(${r}) || ${r} < -2147483648 || ${r} > 2147483647) return INVALID;`);break;case"uint32":e.write(`if (!Number.isInteger(${r}) || ${r} < 0 || ${r} > 4294967295) return INVALID;`);break;case"float32":e.write(`if (!Number.isFinite(${r}) || ${r} < -3.4028234663852886e38 || ${r} > 3.4028234663852886e38) return INVALID;`);break;case"float64":e.write(`if (!Number.isFinite(${r})) return INVALID;`);break;default:throw new ye(`number format ${n}`)}}function bD(e,t,r){let n=t.format;if(n)switch(n){case"int64":e.write(`if (${r} < -9223372036854775808n || ${r} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${r} < 0n || ${r} > 18446744073709551615n) return INVALID;`);break;default:throw new ye(`bigint format ${n}`)}}function wD(e,t,r,n){let s=r.mime;if(s&&s.length>0){let o=Q(t,new Set(s));e.write(`if (!${o}.has(${n}.type)) return INVALID;`)}}function _D(e,t,r,n){let s=`${n}[${JSON.stringify(r.property)}]`;Ue(e,t,r.schema,s)}function RD(e,t,r,n,s){let o=r._zod.def.tx;if(!o)throw new ye("overwrite check without a transform function");if(ds(o))throw new pr("z.compile: async overwrite transforms are not supported");let i=Q(t,o);e.write(`const ${s} = ${i}(${n});`)}function ch(){throw new Ot}function ph(e){this.issues.push(e)}function SD(e,t,r,n){let s=r._zod.def;if(s.fn){if(ds(s.fn))throw new pr("z.compile: async .refine() predicates are not supported");let o=Q(t,s.fn),i=Q(t,ch),a=re(t);return e.write(`const ${a} = ${o}(${n});`),e.write(`if (${a} instanceof Promise) ${i}();`),e.write(`if (!${a}) return INVALID;`),n}if(r._zod.check){if(ds(r._zod.check))throw new pr("z.compile: async .superRefine() / check functions are not supported");let o=r._zod.check,a=Q(t,l=>{let p={value:l,issues:[],addIssue:ph};return o(p)instanceof Promise&&ch(),p.issues.length===0?p.value:Vt}),c=re(t);return e.write(`const ${c} = ${a}(${n});`),e.write(`if (${c} === INVALID) return INVALID;`),c}throw new ye("custom check without a predicate or check function")}function fv(e,t,r,n){let s=r.format;if(s==="base64"){let c=Q(t,ga);return e.write(`if (!${c}(${n})) return INVALID;`),n}if(s==="base64url"){let c=Q(t,ju);return e.write(`if (!${c}(${n})) return INVALID;`),n}if(s==="jwt"){let c=Q(t,Hu),l=Q(t,r.alg??null);return e.write(`if (!${c}(${n}, ${l})) return INVALID;`),n}if(s==="ipv6"){let c=Q(t,fa);return e.write(`if (!${c}(${n})) return INVALID;`),n}if(s==="cidrv6"){let c=Q(t,Uu);return e.write(`if (!${c}(${n})) return INVALID;`),n}if(s==="credit_card"){let c=Q(t,zu);return e.write(`if (!${c}(${n})) return INVALID;`),n}let o=r;if(s==="url"||s==="httpurl"||o.normalize||o.hostname!==void 0||o.protocol!==void 0){let c=Q(t,Fu),l=Q(t,r),p=re(t),d=re(t);if(e.write(`const ${p} = ${n}.trim();`),e.write(`const ${d} = ${c}(${p}, ${l});`),e.write(`if (typeof ${d} === "number") return INVALID;`),o.hostname!==void 0){let g=Q(t,Gu);e.write(`if (!${g}(${d}, ${l}.hostname)) return INVALID;`)}if(o.protocol!==void 0){let g=Q(t,Nu);e.write(`if (!${g}(${d}, ${l}.protocol)) return INVALID;`)}let m=re(t),f=o.normalize?`${d}.href`:`${Q(t,Mu)}(${p})`;return e.write(`const ${m} = ${f};`),m}let i=r.fn;if(i){if(ds(i))throw new ye(`async string format ${s}`);let c=Q(t,i);return e.write(`if (!${c}(${n})) return INVALID;`),n}if(vD.has(s)&&r.pattern){let c=Q(t,r.pattern);return e.write(`${c}.lastIndex = 0;`),e.write(`if (!${c}.test(${n})) return INVALID;`),n}let a=r.format;switch(a){case"regex":throw new ye("regex format without a pattern");case"lowercase":e.write(`if (${n} !== ${n}.toLowerCase()) return INVALID;`);break;case"uppercase":e.write(`if (${n} !== ${n}.toUpperCase()) return INVALID;`);break;case"includes":e.write(`if (!${n}.includes(${Tt(r.includes)})) return INVALID;`);break;case"starts_with":{let c=r.prefix;e.write(`if (${n}.slice(0, ${c.length}) !== ${Tt(c)}) return INVALID;`);break}case"ends_with":{let c=r.suffix;e.write(`if (${n}.slice(-${c.length}) !== ${Tt(c)}) return INVALID;`);break}default:throw new ye(`string format ${a}`)}return n}function Ue(e,t,r,n,s=!0){let o=r._zod.def,i=o.type;if(o.coerce)throw new ye(`coercion (z.coerce.${i}())`);let a=s||!!o.checks?.length,c;switch(i){case"string":c=kD(e,t,r,n);break;case"number":c=ED(e,r,n);break;case"boolean":c=PD(e,n);break;case"bigint":c=CD(e,r,n);break;case"symbol":c=TD(e,n);break;case"undefined":c=$D(e,n);break;case"null":c=AD(e,n);break;case"any":case"unknown":c=n;break;case"never":e.write("return INVALID;"),c=n;break;case"void":c=OD(e,n);break;case"nan":c=xD(e,n);break;case"date":c=ID(e,n);break;case"object":c=DD(e,t,r,n,a);break;case"optional":c=LD(e,t,r,n,a);break;case"nullable":c=GD(e,t,r,n,a);break;case"array":c=ND(e,t,r,n,a);break;case"literal":c=UD(e,t,r,n);break;case"enum":c=jD(e,t,r,n);break;case"readonly":{let l=lv(e,t,r,n),p=re(t);e.write(`const ${p} = Object.freeze(${l});`),c=p;break}case"success":lv(e,t,r,n),c="true";break;case"default":case"prefault":c=zD(e,t,r,n);break;case"nonoptional":c=HD(e,t,r,n);break;case"tuple":c=VD(e,t,r,n);break;case"union":c=BD(e,t,r,n);break;case"intersection":c=ZD(e,t,r,n);break;case"record":c=JD(e,t,r,n);break;case"map":c=YD(e,t,r,n);break;case"set":c=QD(e,t,r,n);break;case"file":c=XD(e,n);break;case"template_literal":c=eL(e,t,r,n);break;case"lazy":c=tL(e,t,r,n);break;case"pipe":c=rL(e,t,r,n);break;case"custom":c=nL(e,t,r,n);break;case"transform":c=iL(e,t,r,n);break;case"catch":c=oL(e,t,r,n);break;default:throw new ye(`schema type ${i}`)}return c===null?null:fD(e,t,r,c)}function kD(e,t,r,n){e.write(`if (typeof ${n} !== "string") return INVALID;`);let s=r._zod.def;return s.format===void 0?n:fv(e,t,s,n)}function ED(e,t,r){e.write(`if (typeof ${r} !== "number" || !Number.isFinite(${r})) return INVALID;`);let n=t._zod.def;return n.check==="number_format"&&n.format&&mv(e,{format:n.format},r),r}function PD(e,t){return e.write(`if (typeof ${t} !== "boolean") return INVALID;`),t}function CD(e,t,r){e.write(`if (typeof ${r} !== "bigint") return INVALID;`);let n=t._zod.def;if(n.format)switch(n.format){case"int64":e.write(`if (${r} < -9223372036854775808n || ${r} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${r} < 0n || ${r} > 18446744073709551615n) return INVALID;`);break}return r}function TD(e,t){return e.write(`if (typeof ${t} !== "symbol") return INVALID;`),t}function $D(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function AD(e,t){return e.write(`if (${t} !== null) return INVALID;`),t}function OD(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function xD(e,t){return e.write(`if (typeof ${t} !== "number" || !Number.isNaN(${t})) return INVALID;`),t}function ID(e,t){return e.write(`if (!(${t} instanceof Date) || Number.isNaN(${t}.getTime())) return INVALID;`),t}function DD(e,t,r,n,s=!0){let o=r._zod.def;e.write(`if (typeof ${n} !== "object" || ${n} === null || Array.isArray(${n})) return INVALID;`);let i=o.shape,a=Object.keys(i),c=Object.getOwnPropertySymbols(i),l=c.length?[...a,...c]:a,p=R=>typeof R=="symbol"?Q(t,R):Tt(R),d=R=>typeof R=="symbol"?`[${p(R)}]`:Tt(R),m=i;if(a.includes("__proto__"))throw new ye('object shape key "__proto__"');let f=new Map;for(let R of l){let y=m[R],S=p(R),E=re(t);if(e.write(`const ${E} = ${n}[${S}];`),y._zod.optin!==void 0){let D=re(t);e.write(`let ${D} = (() => {`),e.indented(P=>{let k=wt(P,t,y,E);P.write(`return ${k};`)}),e.write("})();"),y._zod.optout==="optional"?(e.write(`if (${D} === INVALID) {`),e.indented(P=>{P.write(`if (${S} in ${n}) return INVALID;`),P.write(`${D} = undefined;`)}),e.write("}")):e.write(`if (${D} === INVALID) return INVALID;`),f.set(R,D)}else{MD(y)&&e.write(`if (!(${S} in ${n})) return INVALID;`);let D=wt(e,t,y,E,s);D!==null&&f.set(R,D)}}let g=o.catchall,h="none";if(g){let R=g._zod.def.type;if(R==="never"){let y=a.map(S=>`k !== ${Tt(S)}`).join(" && ")||"true";e.write(`for (const k in ${n}) {`),e.indented(S=>{S.write(`if (${y}) return INVALID;`)}),e.write("}")}else(R==="unknown"||R==="any")&&!g._zod.def.checks?.length?h="passthrough":h="schema"}let w=re(t),v=l.some(R=>ps(m[R])||uh(m[R]));if(!s){if(h==="schema"){let R=a.length>0?Q(t,new Set(a)):null;e.write(`for (const k in ${n}) {`),e.indented(y=>{y.write('if (k === "__proto__") continue;'),R&&y.write(`if (${R}.has(k)) continue;`);let S=re(t);y.write(`const ${S} = ${n}[k];`),wt(y,t,g,S,!1)}),e.write("}")}return null}if(v){e.write(`const ${w} = {};`);for(let R of l){let y=p(R),S=f.get(R);uh(m[R])?e.write(`if (${y} in ${n}) ${w}[${y}] = ${S};`):ps(m[R])?e.write(`if (${S} !== undefined || ${y} in ${n}) ${w}[${y}] = ${S};`):e.write(`${w}[${y}] = ${S};`)}}else{let R=l.map(y=>`${d(y)}: ${f.get(y)}`).join(", ");e.write(`const ${w} = { ${R} };`)}if(h!=="none"){let R=a.length>0?Q(t,new Set(a)):null;e.write(`for (const k in ${n}) {`),e.indented(y=>{if(y.write('if (k === "__proto__") continue;'),R&&y.write(`if (${R}.has(k)) continue;`),h==="passthrough")y.write(`${w}[k] = ${n}[k];`);else{let S=re(t);y.write(`const ${S} = ${n}[k];`);let E=wt(y,t,g,S);y.write(`${w}[k] = ${E};`)}}),e.write("}")}return w}function LD(e,t,r,n,s=!0){let o=r._zod.def;if(FD(r))return Ue(e,t,o.innerType,n,s);if(o.innerType._zod.optin==="defaulted"){let a=re(t),c=re(t);return e.write(`let ${a};`),e.write(`if (${n} === undefined) {`),e.indented(l=>{l.write(`const ${c} = (() => {`),l.indented(p=>{let d=Ue(p,t,o.innerType,n);p.write(`return ${d};`)}),l.write("})();"),l.write(`if (${c} !== INVALID) ${a} = ${c};`)}),e.write("} else {"),e.indented(l=>{let p=Ue(l,t,o.innerType,n);l.write(`${a} = ${p};`)}),e.write("}"),a}let i=s?re(t):null;return i&&e.write(`let ${i};`),e.write(`if (${n} !== undefined) {`),e.indented(a=>{let c=Ue(a,t,o.innerType,n,s);i&&c!==null&&a.write(`${i} = ${c};`)}),e.write("}"),i}function FD(e){return e._zod.traits?.has("$ZodExactOptional")===!0}function MD(e){return e._zod.optin===void 0&&ls(e)}function ls(e){if(e._zod.def.coerce)return!0;let t=e._zod.def;switch(t.type){case"any":case"unknown":case"undefined":case"void":case"default":case"prefault":case"transform":case"custom":case"lazy":return!0;case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"never":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":return!1;case"nonoptional":return t.innerType?ls(t.innerType):!1;case"literal":return!!t.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":case"nullable":case"readonly":case"success":return t.innerType?ls(t.innerType):!0;case"catch":return!0;case"union":return t.options?t.options.some(ls):!0;case"intersection":return!t.left||!t.right?!0:ls(t.left)&&ls(t.right);case"pipe":return t.in?ls(t.in):!0;default:return!0}}function uh(e){return e._zod.optin==="optional"&&e._zod.optout==="optional"}function ps(e){let t=e._zod.def;switch(t.type){case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":case"never":case"success":return!1;case"literal":return!!t.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":return!0;case"nullable":case"readonly":case"nonoptional":return t.innerType?ps(t.innerType):!0;case"union":return t.options?t.options.some(ps):!0;case"intersection":return!t.left||!t.right||ps(t.left)||ps(t.right);case"pipe":return t.out?ps(t.out):!0;default:return!0}}function GD(e,t,r,n,s=!0){let o=r._zod.def,i=s?re(t):null;return i&&e.write(`let ${i} = null;`),e.write(`if (${n} !== null) {`),e.indented(a=>{let c=Ue(a,t,o.innerType,n,s);i&&c!==null&&a.write(`${i} = ${c};`)}),e.write("}"),i}function ND(e,t,r,n,s=!0){let o=r._zod.def;e.write(`if (!Array.isArray(${n})) return INVALID;`);let i=s?re(t):null,a=re(t),c=re(t);return i&&e.write(`const ${i} = new Array(${n}.length);`),e.write(`for (let ${a} = 0; ${a} < ${n}.length; ${a}++) {`),e.indented(l=>{l.write(`const ${c} = ${n}[${a}];`);let p=wt(l,t,o.element,c,s);i&&p!==null&&l.write(`${i}[${a}] = ${p};`)}),e.write("}"),i}function UD(e,t,r,n){let o=r._zod.def.values;if(o.length!==1){let a=Q(t,new Set(o));return e.write(`if (!${a}.has(${n})) return INVALID;`),n}let i=o[0];if(typeof i=="number"&&Number.isNaN(i)){let a=Q(t,new Set(o));return e.write(`if (!${a}.has(${n})) return INVALID;`),n}if(typeof i=="string")e.write(`if (${n} !== ${Tt(i)}) return INVALID;`);else if(typeof i=="number"||typeof i=="boolean")e.write(`if (${n} !== ${i}) return INVALID;`);else if(i===null)e.write(`if (${n} !== null) return INVALID;`);else if(i===void 0)e.write(`if (${n} !== undefined) return INVALID;`);else if(typeof i=="bigint")e.write(`if (${n} !== ${i}n) return INVALID;`);else throw new ye(`literal type ${typeof i}`);return n}function jD(e,t,r,n){let s=r._zod.values;if(!s)throw new ye("enum schema without enumerated values");let o=Q(t,s);return e.write(`if (!${o}.has(${n})) return INVALID;`),n}function lv(e,t,r,n){let s=r._zod.def;return Ue(e,t,s.innerType,n)}function zD(e,t,r,n){let s=r._zod.def,i=Object.getOwnPropertyDescriptor(r._zod.def,"defaultValue")?()=>r._zod.def.defaultValue:void 0;if(r._zod.def.type==="prefault"){if(!i)return Ue(e,t,s.innerType,n);let c=Q(t,i),l=re(t);return e.write(`let ${l} = ${n};`),e.write(`if (${n} === undefined) ${l} = ${c}();`),Ue(e,t,s.innerType,l)}let a=re(t);if(i){let c=Q(t,i),l=Q(t,sa);e.write(`let ${a};`),e.write(`if (${n} === undefined) {`),e.indented(p=>{p.write(`${a} = ${l}(${c}());`)}),e.write("} else {"),e.indented(p=>{let d=Ue(p,t,s.innerType,n);p.write(`${a} = ${d} === undefined ? ${l}(${c}()) : ${d};`)}),e.write("}")}else e.write(`let ${a};`),e.write(`if (${n} !== undefined) {`),e.indented(c=>{let l=Ue(c,t,s.innerType,n);c.write(`${a} = ${l};`)}),e.write("}");return a}function HD(e,t,r,n){let s=r._zod.def,o=Ue(e,t,s.innerType,n),i=re(t);return e.write(`const ${i} = ${o};`),e.write(`if (${i} === undefined) return INVALID;`),i}function VD(e,t,r,n){let s=r._zod.def,o=s.items,i=s.rest;e.write(`if (!Array.isArray(${n})) return INVALID;`);let a=pv(o,"optin"),c=pv(o,"optout");i?e.write(`if (${n}.length < ${a}) return INVALID;`):e.write(`if (${n}.length < ${a} || ${n}.length > ${o.length}) return INVALID;`);let l=re(t);e.write(`const ${l} = [];`);for(let p=0;p<o.length;p++){let d=o[p];if(p>=c)e.write(`if (${l}.length === ${p}) {`),e.indented(m=>{m.write(`if (${p} < ${n}.length) {`),m.indented(f=>{let g=re(t);f.write(`const ${g} = ${n}[${p}];`);let h=wt(f,t,d,g);f.write(`${l}[${p}] = ${h};`)}),m.write("} else {"),m.indented(f=>{if(uh(d)){f.write(`${l}.length = ${p};`);return}let g=re(t),h=re(t);f.write(`const ${g} = undefined;`),f.write(`const ${h} = (() => {`),f.indented(w=>{let v=wt(w,t,d,g);w.write(`return ${v};`)}),f.write("})();"),f.write(`if (${h} === INVALID || ${h} === undefined) ${l}.length = ${p};`),f.write(`else ${l}[${p}] = ${h};`)}),m.write("}")}),e.write("}");else{let m=re(t);e.write(`const ${m} = ${n}[${p}];`);let f=wt(e,t,d,m);e.write(`${l}[${p}] = ${f};`)}}if(i){let p=re(t),d=re(t);e.write(`for (let ${p} = ${o.length}; ${p} < ${n}.length; ${p}++) {`),e.indented(m=>{m.write(`const ${d} = ${n}[${p}];`);let f=wt(m,t,i,d);m.write(`${l}[${p}] = ${f};`)}),e.write("}")}return l}function pv(e,t){for(let r=e.length-1;r>=0;r--)if(!(t==="optin"?e[r]._zod.optin!==void 0:e[r]._zod.optout==="optional"))return r+1;return 0}function BD(e,t,r,n){let s=r._zod.def,o=s.options;if(s.discriminator)return WD(e,t,s,n);if(s.inclusive===!1)throw new ye("exclusive unions (z.xor)");if(o.length===0)return e.write("return INVALID;"),n;if(o.length===1)return Ue(e,t,o[0],n);if(o.every(c=>c._zod.def.type==="literal"&&!c._zod.def.checks?.length)){let c=new Set(o.flatMap(p=>p._zod.def.values)),l=Q(t,c);return e.write(`if (!${l}.has(${n})) return INVALID;`),n}let a=re(t);e.write(`let ${a};`);for(let c=0;c<o.length;c++){let l=o[c];c===0?e.write(`${a} = (() => {`):e.write(`if (${a} === INVALID) ${a} = (() => {`),e.indented(p=>{let d=Ue(p,t,l,n);p.write(`return ${d};`)}),e.write("})();")}return e.write(`if (${a} === INVALID) return INVALID;`),a}function WD(e,t,r,n){if(r.unionFallback)throw new ye("discriminated union with unionFallback");if(r.options.length===0)return e.write("return INVALID;"),n;let s=re(t),o=re(t);e.write(`const ${s} = ${n}?.[${Tt(r.discriminator)}];`),e.write(`let ${o};`);let i=!0,a=new Set;for(let c of r.options){let l=c._zod.propValues?.[r.discriminator];if(!l||l.size===0)throw new ye("discriminated union option without static discriminator values");for(let m of l){if(a.has(m))throw new ye(`duplicate discriminator value ${String(m)}`);a.add(m)}let p=Array.from(l,m=>qD(t,s,m)),d=i?"if":"else if";e.write(`${d} (${p.join(" || ")}) {`),e.indented(m=>{let f=Ue(m,t,c,n);m.write(`${o} = ${f};`)}),e.write("}"),i=!1}return e.write("else { return INVALID; }"),o}function qD(e,t,r){if(typeof r=="string")return`${t} === ${Tt(r)}`;if(typeof r=="number")return Number.isNaN(r)?`Number.isNaN(${t})`:`${t} === ${r}`;if(typeof r=="boolean")return`${t} === ${r}`;if(r===null)return`${t} === null`;if(r===void 0)return`${t} === undefined`;if(typeof r=="bigint")return`${t} === ${r}n`;if(typeof r=="symbol"){let n=Q(e,r);return`${t} === ${n}`}throw new ye(`literal discriminator value ${String(r)}`)}function ZD(e,t,r,n){let s=r._zod.def,o=wt(e,t,s.left,n),i=wt(e,t,s.right,n),a=Q(t,vo),c=re(t);return e.write(`const ${c} = ${a}(${o}, ${i});`),e.write(`if (!${c}.valid) return INVALID;`),`${c}.data`}function JD(e,t,r,n){let s=r._zod.def,o=Q(t,rr);e.write(`if (!${o}(${n})) return INVALID;`);let i=re(t),a=re(t),c=re(t);e.write(`const ${i} = {};`);let l=s,p=l.partial?void 0:s.keyType._zod.values;if(p){let g=[];for(let w of p){if(!(typeof w=="string"||typeof w=="number"||typeof w=="symbol"))throw new ye(`record key value ${String(w)}`);let v=typeof w=="number"?w.toString():w;if(v==="__proto__")throw new ye('record key "__proto__"');g.push(v);let R=Q(t,w),y=Ue(e,t,s.keyType,R),S=re(t);e.write(`const ${S} = ${n}[${KD(t,v)}];`);let E=wt(e,t,s.valueType,S);e.write(`${i}[${y}] = ${E};`)}let h=Q(t,new Set(g));return e.write(`for (const ${a} in ${n}) {`),e.indented(w=>{w.write(`if (${h}.has(${a})) continue;`),l.mode==="loose"?w.write(`if (${a} !== "__proto__") ${i}[${a}] = ${n}[${a}];`):w.write("return INVALID;")}),e.write("}"),i}let d=s.keyType._zod.def;if(!(d.type==="string"&&d.format===void 0&&!d.coerce&&(d.checks?.length??0)===0)){let g=s.mode==="loose",h=Q(t,rl(s.keyType)),w=Q(t,vn),v=Q(t,Object.prototype.propertyIsEnumerable),R=re(t);return e.write(`for (const ${a} of Reflect.ownKeys(${n})) {`),e.indented(y=>{y.write(`if (${a} === "__proto__") continue;`),y.write(`if (!${v}.call(${n}, ${a})) continue;`),y.write(`let ${R} = ${h}(${a});`),y.write(`if (${R} === INVALID && typeof ${a} === "string" && ${w}.test(${a})) ${R} = ${h}(Number(${a}));`),g?y.write(`if (${R} === INVALID) { ${i}[${a}] = ${n}[${a}]; continue; }`):y.write(`if (${R} === INVALID) return INVALID;`),y.write(`if (${R} === "__proto__") continue;`);let S=re(t);y.write(`const ${S} = ${n}[${a}];`);let E=wt(y,t,s.valueType,S);y.write(`${i}[${R}] = ${E};`)}),e.write("}"),i}let f=Q(t,Object.prototype.propertyIsEnumerable);return e.write(`for (const ${a} of Reflect.ownKeys(${n})) {`),e.indented(g=>{g.write(`if (${a} === "__proto__") continue;`),g.write(`if (!${f}.call(${n}, ${a})) continue;`),g.write(`if (typeof ${a} !== "string") return INVALID;`),g.write(`const ${c} = ${n}[${a}];`);let h=wt(g,t,s.valueType,c);g.write(`${i}[${a}] = ${h};`)}),e.write("}"),i}function KD(e,t){return typeof t=="string"?Tt(t):Q(e,t)}function YD(e,t,r,n){let s=r._zod.def;e.write(`if (!(${n} instanceof Map)) return INVALID;`);let o=re(t),i=re(t),a=re(t);return e.write(`const ${o} = new Map();`),e.write(`for (const [${i}, ${a}] of ${n}) {`),e.indented(c=>{let l=Ue(c,t,s.keyType,i),p=Ue(c,t,s.valueType,a);c.write(`${o}.set(${l}, ${p});`)}),e.write("}"),o}function QD(e,t,r,n){let s=r._zod.def;e.write(`if (!(${n} instanceof Set)) return INVALID;`);let o=re(t),i=re(t);return e.write(`const ${o} = new Set();`),e.write(`for (const ${i} of ${n}) {`),e.indented(a=>{let c=Ue(a,t,s.valueType,i);a.write(`${o}.add(${c});`)}),e.write("}"),o}function XD(e,t){return e.write(`if (!(${t} instanceof File)) return INVALID;`),t}function eL(e,t,r,n){e.write(`if (typeof ${n} !== "string") return INVALID;`);let s=r._zod.pattern;if(s){let o=Q(t,s);e.write(`${o}.lastIndex = 0;`),e.write(`if (!${o}.test(${n})) return INVALID;`)}return n}function tL(e,t,r,n){let s=r._zod.def,o=Q(t,s.getter),i=Q(t,{parser:null});e.write(`if (!${i}.parser) {`),e.indented(c=>{c.write(`const inner = ${o}();`),c.write(`${i}.parser = function(input) {`),c.indented(l=>{l.write("const result = inner._zod.run({ value: input, issues: [] }, {});"),l.write("return result.issues.length === 0 ? result.value : INVALID;")}),c.write("};")}),e.write("}");let a=re(t);return e.write(`const ${a} = ${i}.parser(${n});`),e.write(`if (${a} === INVALID) return INVALID;`),a}function rL(e,t,r,n){let s=r._zod.def,o=Ue(e,t,s.in,n);if(s.transform){if(ds(s.transform))throw new pr("z.compile: async transforms in pipes are not supported");let i=s.transform,c=Q(t,p=>{let d={value:p,issues:[],addIssue:ph},m=i(p,d);return m instanceof Promise?Vt:d.issues.length===0?m:Vt}),l=re(t);return e.write(`const ${l} = ${c}(${o});`),e.write(`if (${l} === INVALID) return INVALID;`),Ue(e,t,s.out,l)}else return Ue(e,t,s.out,o)}function ds(e){return typeof e=="function"&&(e.constructor.name==="AsyncFunction"||e[Symbol.toStringTag]==="AsyncFunction")}function nL(e,t,r,n){let s=r._zod.def;if(s.fn){if(ds(s.fn))throw new pr("z.compile: async custom predicates are not supported");let o=Q(t,s.fn),i=Q(t,ch),a=re(t);e.write(`const ${a} = ${o}(${n});`),e.write(`if (${a} instanceof Promise) ${i}();`),e.write(`if (!${a}) return INVALID;`)}else throw new ye("custom schema without a predicate function");return n}function sL(e,t,r){let n=e._zod.run({value:r,issues:[]},{});if(n&&typeof n.then=="function")return Vt;let s=n;return s.issues.length===0?s.value:t()}function oL(e,t,r,n){let s=r._zod.def;if(!s.catchValue[pu])throw new ye("catch with a callback (only a constant catch value compiles)",!1);let o=re(t);e.write(`let ${o} = (() => {`),e.indented(l=>{let p=wt(l,t,s.innerType,n);l.write(`return ${p};`)}),e.write("})();");let i=Q(t,s.innerType),a=Q(t,s.catchValue),c=Q(t,sL);return e.write(`if (${o} === INVALID) {`),e.indented(l=>{l.write(`${o} = ${c}(${i}, ${a}, ${n});`),l.write(`if (${o} === INVALID) return INVALID;`)}),e.write("}"),o}function iL(e,t,r,n){let s=r._zod.def;if(s.transform){if(ds(s.transform))throw new pr("z.compile: async transforms are not supported");let o=s.transform,a=Q(t,l=>{let p={value:l,issues:[],addIssue:ph},d=o(l,p);return d instanceof Promise?Vt:p.issues.length===0?d:Vt}),c=re(t);return e.write(`const ${c} = ${a}(${n});`),e.write(`if (${c} === INVALID) return INVALID;`),c}return n}var Vt,uv,pr,ye,mD,vD,gv=C(()=>{Rn();Au();rh();Ro();_a();Je();Vt=Symbol.for("zod.compile.invalid"),uv=Symbol.for("zod.compile.fallback"),pr=class extends Error{constructor(t="z.compile does not support async refinements, transforms, or checks"){super(t),this.name="ZodCompileAsyncError"}},ye=class extends Error{constructor(t,r=!0){super(`z.compile does not support ${t}; this schema must use the runtime parser`),this.name="ZodCompileUnsupportedError",this.islandable=r}};mD=new Set(["max_size","min_size","size_equals","max_length","min_length","length_equals"]);vD=new Set(["cidrv4","cuid","cuid2","date","datetime","duration","e164","email","emoji","ends_with","guid","includes","ipv4","ksuid","lowercase","mac","nanoid","regex","starts_with","time","ulid","uppercase","uuid","xid"])});function dh(e,t){return new e({type:"string",...N(t)})}function mh(e,t){return new e({type:"string",coerce:!0,...N(t)})}function nl(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...N(t)})}function sl(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...N(t)})}function ol(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...N(t)})}function il(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...N(t)})}function al(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...N(t)})}function cl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...N(t)})}function ka(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...N(t)})}function ul(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...N(t)})}function ll(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...N(t)})}function pl(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...N(t)})}function dl(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...N(t)})}function ml(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...N(t)})}function fl(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...N(t)})}function gl(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...N(t)})}function hl(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...N(t)})}function yl(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...N(t)})}function fh(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...N(t)})}function bl(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...N(t)})}function wl(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...N(t)})}function _l(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...N(t)})}function Rl(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...N(t)})}function Sl(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...N(t)})}function gh(e,t){return new e({type:"string",format:"credit_card",check:"string_format",abort:!1,...N(t)})}function vl(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...N(t)})}function Ea(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...N(t)})}function Pa(e,t){return new e({type:"string",format:"date",check:"string_format",...N(t)})}function Ca(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...N(t)})}function Ta(e,t){return new e({type:"string",format:"duration",check:"string_format",...N(t)})}function yh(e,t){return new e({type:"number",checks:[],...N(t)})}function bh(e,t){return new e({type:"number",coerce:!0,checks:[],...N(t)})}function wh(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...N(t)})}function _h(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...N(t)})}function Rh(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...N(t)})}function Sh(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...N(t)})}function vh(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...N(t)})}function kh(e,t){return new e({type:"boolean",...N(t)})}function Eh(e,t){return new e({type:"boolean",coerce:!0,...N(t)})}function Ph(e,t){return new e({type:"bigint",...N(t)})}function Ch(e,t){return new e({type:"bigint",coerce:!0,...N(t)})}function Th(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...N(t)})}function $h(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...N(t)})}function Ah(e,t){return new e({type:"symbol",...N(t)})}function Oh(e,t){return new e({type:"undefined",...N(t)})}function xh(e,t){return new e({type:"null",...N(t)})}function Ih(e){return new e({type:"any"})}function Dh(e){return new e({type:"unknown"})}function Lh(e,t){return new e({type:"never",...N(t)})}function Fh(e,t){return new e({type:"void",...N(t)})}function Mh(e,t){return new e({type:"date",...N(t)})}function Gh(e,t){return new e({type:"date",coerce:!0,...N(t)})}function Nh(e,t){return new e({type:"nan",...N(t)})}function kr(e,t){return new Pu({check:"less_than",...N(t),value:e,inclusive:!1})}function Bt(e,t){return new Pu({check:"less_than",...N(t),value:e,inclusive:!0})}function Er(e,t){return new Cu({check:"greater_than",...N(t),value:e,inclusive:!1})}function Wt(e,t){return new Cu({check:"greater_than",...N(t),value:e,inclusive:!0})}function kl(e){return Er(0,e)}function El(e){return kr(0,e)}function Pl(e){return Bt(0,e)}function Cl(e){return Wt(0,e)}function kn(e,t){return new Rf({check:"multiple_of",...N(t),value:e})}function En(e,t){return new kf({check:"max_size",...N(t),maximum:e})}function Pr(e,t){return new Ef({check:"min_size",...N(t),minimum:e})}function ms(e,t){return new Pf({check:"size_equals",...N(t),size:e})}function fs(e,t){return new Cf({check:"max_length",...N(t),maximum:e})}function Jr(e,t){return new Tf({check:"min_length",...N(t),minimum:e})}function gs(e,t){return new $f({check:"length_equals",...N(t),length:e})}function ko(e,t){return new Af({check:"string_format",format:"regex",...N(t),pattern:e})}function Eo(e){return new Of({check:"string_format",format:"lowercase",...N(e)})}function Po(e){return new xf({check:"string_format",format:"uppercase",...N(e)})}function Co(e,t){return new If({check:"string_format",format:"includes",...N(t),includes:e})}function To(e,t){return new Df({check:"string_format",format:"starts_with",...N(t),prefix:e})}function $o(e,t){return new Lf({check:"string_format",format:"ends_with",...N(t),suffix:e})}function Tl(e,t,r){return new Tu({check:"property",property:e,schema:t,...N(r)})}function $l(e){return Object.entries(e).map(([t,r])=>new Tu({check:"property",property:t,schema:r}))}function Ao(e,t){return new Ff({check:"mime_type",mime:e,...N(t)})}function dr(e){return new Mf({check:"overwrite",tx:e})}function Oo(e){return dr(t=>t.normalize(e))}function xo(){return dr(e=>e.trim())}function Io(){return dr(e=>e.toLowerCase())}function Do(){return dr(e=>e.toUpperCase())}function Lo(){return dr(e=>ym(e))}function Uh(e,t,r){return new e({type:"array",element:t,...N(r)})}function aL(e,t,r){return new e({type:"union",options:t,...N(r)})}function cL(e,t,r){return new e({type:"union",options:t,inclusive:!1,...N(r)})}function uL(e,t,r,n){return new e({type:"union",options:r,discriminator:t,...N(n)})}function lL(e,t,r){return new e({type:"intersection",left:t,right:r})}function pL(e,t,r,n){let s=r instanceof oe,o=s?n:r,i=s?r:null;return new e({type:"tuple",items:t,rest:i,...N(o)})}function dL(e,t,r,n){return new e({type:"record",keyType:t,valueType:r,...N(n)})}function mL(e,t,r,n){return new e({type:"map",keyType:t,valueType:r,...N(n)})}function fL(e,t,r){return new e({type:"set",valueType:t,...N(r)})}function gL(e,t,r){let n=Array.isArray(t)?Object.fromEntries(t.map(s=>[s,s])):t;return new e({type:"enum",entries:n,...N(r)})}function hL(e,t,r){return new e({type:"enum",entries:t,...N(r)})}function yL(e,t,r){return new e({type:"literal",values:Array.isArray(t)?t:[t],...N(r)})}function jh(e,t){return new e({type:"file",...N(t)})}function bL(e,t){return new e({type:"transform",transform:t})}function wL(e,t){return new e({type:"optional",innerType:t})}function _L(e,t){return new e({type:"nullable",innerType:t})}function RL(e,t,r){return new e({type:"default",innerType:t,get defaultValue(){return typeof r=="function"?r():sa(r)}})}function SL(e,t,r){return new e({type:"nonoptional",innerType:t,...N(r)})}function vL(e,t){return new e({type:"success",innerType:t})}function kL(e,t,r){return new e({type:"catch",innerType:t,catchValue:typeof r=="function"?r:Cm(r)})}function EL(e,t,r){return new e({type:"pipe",in:t,out:r})}function PL(e,t){return new e({type:"readonly",innerType:t})}function CL(e,t,r){return new e({type:"template_literal",parts:t,...N(r)})}function TL(e,t){return new e({type:"lazy",getter:t})}function $L(e,t){return new e({type:"promise",innerType:t})}function zh(e,t,r){let n=N(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function Hh(e,t,r){return new e({type:"custom",check:"custom",fn:t,...N(r)})}function Vh(e,t){let r=hv(n=>(n.addIssue=s=>{if(typeof s=="string")n.issues.push(ho(s,n.value,r._zod.def));else{let o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),"input"in o||(o.input=n.value),o.inst??(o.inst=r),o.continue??(o.continue=!r._zod.def.abort),n.issues.push(ho(o))}},e(n.value,n)),t);return r}function hv(e,t){let r=new xe({check:"custom",...N(t)});return r._zod.check=e,r}function Bh(e){let t=new xe({check:"describe"});return t._zod.onattach=[r=>{let n=ct.get(r)??{};ct.add(r,{...n,description:e})}],t._zod.check=()=>{},t}function Wh(e){let t=new xe({check:"meta"});return t._zod.onattach=[r=>{let n=ct.get(r)??{};ct.add(r,{...n,...e})}],t._zod.check=()=>{},t}function qh(e,t){let r=N(t),n=r.truthy??["true","1","yes","on","y","enabled"],s=r.falsy??["false","0","no","off","n","disabled"];r.case!=="sensitive"&&(n=n.map(f=>typeof f=="string"?f.toLowerCase():f),s=s.map(f=>typeof f=="string"?f.toLowerCase():f));let o=new Set(n),i=new Set(s),a=e.Codec??ba,c=e.Boolean??ha,l=e.String??cs,p=new l({type:"string",error:r.error}),d=new c({type:"boolean",error:r.error}),m=new a({type:"pipe",in:p,out:d,transform:((f,g)=>{let h=f;return r.case!=="sensitive"&&(h=h.toLowerCase()),o.has(h)?!0:i.has(h)?!1:(g.issues.push({code:"invalid_value",expected:"stringbool",values:[...o,...i],input:g.value,inst:m,continue:!1}),{})}),reverseTransform:((f,g)=>f===!0?n[0]||"true":s[0]||"false"),error:r.error});return m._zod.bag.truthy=n,m._zod.bag.falsy=s,m._zod.bag.case=r.case??"insensitive",m}function Fo(e,t,r,n={}){let s=N(n),o={check:"string_format",type:"string",format:t,fn:typeof r=="function"?r:a=>r.test(a),...s};return r instanceof RegExp&&(o.pattern=r),new e(o)}var hh,yv=C(()=>{$u();va();_a();Je();hh={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6}});function $a(e,...t){for(let r of t)for(let n of Reflect.ownKeys(r))Object.prototype.propertyIsEnumerable.call(r,n)&&je(e,n,r[n]);return e}function Pn(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??ct,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function Ke(e,t,r,n,s){let o=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:n.path,message:s}):t.unrepresentable;if(o==="any")return!1;if(o===void 0||o==="throw")throw new Error(s);return Object.assign(r,o),!0}function Ce(e,t,r={path:[],schemaPath:[]}){var n;let s=e._zod.def,o=t.seen.get(e);if(o)return o.count++,r.schemaPath.includes(e)&&(o.cycle=r.path),o.schema;let i={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,i),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{let p={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,p);else{let m=i.schema,f=t.processors[s.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${s.type}`);f(e,t,m,p)}let d=e._zod.parent;d&&(i.ref||(i.ref=d),Ce(d,t,p),t.seen.get(d).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&$a(i.schema,c),t.io==="input"&&_t(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&"_prefault"in i.schema&&((n=i.schema).default??(n.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function bv(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Cn(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let n=new Map;for(let i of e.seen.entries()){let a=e.metadataRegistry.get(i[0])?.id;if(a){let c=n.get(a);if(c&&c!==i[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(a,i[0])}}let s=i=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(i[0])?.id,m=e.external.uri??(g=>g);if(d)return{ref:m(d)};let f=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=f,{defId:f,ref:`${m("__shared")}#/${a}/${bv(f)}`}}let c="#",l=`${c}/${a}/`;if(i[1]===r&&!i[1].schema.id)return{ref:c};let p=i[1].schema.id??`__schema${e.counter++}`;return{defId:p,ref:l+bv(p)}},o=i=>{if(i[1].schema.$ref)return;let a=i[1],{ref:c,defId:l}=s(i);a.def={...a.schema},l&&(a.defId=l);let p=a.schema;for(let d in p)delete p[d];p.$ref=c};if(e.cycles==="throw")for(let i of e.seen.entries()){let a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
57
57
 
58
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let a=i[1];if(t===i[0]){o(i);continue}if(e.external){let l=e.external.registry.get(i[0])?.id;if(t!==i[0]&&l){o(i);continue}}if(e.metadataRegistry.get(i[0])?.id){o(i);continue}if(a.cycle){o(i);continue}if(a.count>1&&e.reused==="ref"){o(i);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function Rv(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let n of t){if(!n||typeof n!="object")return;Rv(n);let s=Object.keys(n);if(s.length!==1||s[0]!=="type")return;let o=n.type;for(let i of Array.isArray(o)?o:[o]){if(typeof i!="string")return;r.includes(i)||r.push(i)}}delete e.anyOf,e.type=r.length===1?r[0]:r}function _v(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function Zh(e){let t=[];for(let o of e){if(typeof o!="object"||o.type!=="object")return null;for(let i in o)if(!Sv.has(i))return null;t.push(o)}let r={},n=new Set;for(let o of t){for(let i in o.properties){if(Object.prototype.hasOwnProperty.call(r,i))continue;let a=[];for(let l of t){let p=l.properties?.[i]??_v(l);p!=null&&(a.some(d=>JSON.stringify(d)===JSON.stringify(p))||a.push(p))}let c=a.length===1?a[0]:Zh(a)??{allOf:a};je(r,i,c)}for(let i of o.required??[])n.add(i)}let s={type:"object",properties:r};if(n.size&&(s.required=[...n]),t.every(o=>o.additionalProperties===!1))s.additionalProperties=!1;else{let o=[];for(let i of t){let a=_v(i);a&&!o.some(c=>JSON.stringify(c)===JSON.stringify(a))&&o.push(a)}o.length===1?s.additionalProperties=o[0]:o.length>1&&(s.additionalProperties={allOf:o})}return s}function AL(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let s of Sv)if(s in e)return;let r=t.filter(s=>wv.some(o=>Array.isArray(s[o]))),n=null;if(!r.length)n=Zh(t);else{let s=r[0],o=wv.find(c=>Array.isArray(s[c]));if(Object.keys(s).length!==1)return;let i=t.filter(c=>c!==s),a=s[o].map(c=>Zh([...i,c]));if(a.some(c=>!c))return;n={[o]:a}}n&&(delete e.allOf,$a(e,n))}function Tn(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=a=>{let c=e.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,p={...l},d=c.ref;if(c.ref=null,d){n(d);let f=e.seen.get(d),g=f.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(l.allOf=l.allOf??[],l.allOf.push(g)):$a(l,g),$a(l,p),a._zod.parent===d)for(let w in l)w==="$ref"||w==="allOf"||w in p||delete l[w];if(g.$ref&&f.def)for(let w in l)w==="$ref"||w==="allOf"||w in f.def&&JSON.stringify(l[w])===JSON.stringify(f.def[w])&&delete l[w]}let m=a._zod.parent;if(m&&m!==d){n(m);let f=e.seen.get(m);if(f?.schema.$ref&&(l.$ref=f.schema.$ref,f.def))for(let g in l)g==="$ref"||g==="allOf"||g in f.def&&JSON.stringify(l[g])===JSON.stringify(f.def[g])&&delete l[g]}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())n(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())Rv(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let l of[c.schema,c.def]){let p=l?.allOf;if(!Array.isArray(p))continue;let d=a.get(p);d?d.push(l):a.set(p,[l])}for(let c of e.intersections)for(let l of a.get(c)??[])AL(l)}}let s={};if(e.target==="draft-2020-12"?s.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?s.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?s.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");s.$id=e.external.uri(a)}$a(s,r.defId?r.schema:r.def??r.schema);let o=e.metadataRegistry.get(t)?.id;o!==void 0&&s.id===o&&delete s.id;let i=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,je(i,c.defId,c.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?s.$defs=i:s.definitions=i);try{let a=JSON.parse(JSON.stringify(s));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Mo(t,"input",e.processors),output:Mo(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function _t(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return _t(n.element,r);if(n.type==="set")return _t(n.valueType,r);if(n.type==="lazy")return _t(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault"||n.type==="catch")return _t(n.innerType,r);if(n.type==="intersection")return _t(n.left,r)||_t(n.right,r);if(n.type==="record"||n.type==="map")return _t(n.keyType,r)||_t(n.valueType,r);if(n.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:_t(n.in,r)||_t(n.out,r);if(n.type==="object"){for(let s in n.shape)if(_t(n.shape[s],r))return!0;return!1}if(n.type==="union"){for(let s of n.options)if(_t(s,r))return!0;return!1}if(n.type==="tuple"){for(let s of n.items)if(_t(s,r))return!0;return!!(n.rest&&_t(n.rest,r))}return!1}var Sv,wv,Jh,Mo,Aa=C(()=>{va();Je();Sv=new Set(["type","properties","required","additionalProperties"]),wv=["oneOf","anyOf"];Jh=(e,t={})=>r=>{let n=Pn({...r,processors:t});return Ce(e,n),Cn(n,e),Tn(n,e)},Mo=(e,t,r={})=>n=>{let{libraryOptions:s,target:o}=n??{},i=Pn({...s??{},target:o,io:t,processors:r});return Ce(e,i),Cn(i,e),Tn(i,e)}});function Oa(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?Oa(t.out):t.type==="catch"?Oa(t.innerType):e._zod.optin}function Kh(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let g=e.get(t)?.def;if(!g)return t;let h=Kh(e,g,r);return h===g?t:h}for(let g of["anyOf","oneOf"]){let h=t[g];if(!Array.isArray(h))continue;let w=h.map(v=>Kh(e,v,r));w.some((v,R)=>v!==h[R])&&(t={...t,[g]:w})}let n=Array.isArray(t.type)?t.type:[t.type],s=!n.includes("string")&&n.some(g=>g==="number"||g==="integer"),o=t.enum??(t.const!==void 0?[t.const]:void 0);if(!s&&!o?.some(g=>typeof g=="number"))return t;let{minimum:i,maximum:a,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:p,format:d,id:m,...f}=t;return f.enum?f.enum=f.enum.map(g=>typeof g=="number"?String(g):g):typeof f.const=="number"&&(f.const=String(f.const)),s&&(f.type="string",o||(f.pattern=(n.includes("number")?vn:pa).source)),f}function xL(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let r=new Map;for(let n of Yh.get(e)??[]){let s=e.seen.get(n),o=(s?.def??s?.schema)?.propertyNames;if(!o||o===!0||r.has(o))continue;let i=Kh(t,o,new Set);i!==o&&r.set(o,i)}if(r.size)for(let n of e.seen.values())for(let s of[n.schema,n.def]){let o=s&&r.get(s.propertyNames);o&&(s.propertyNames=o)}}function vv(e,t,r,n,s){let o=!1,i=JSON.stringify(e,(a,c)=>typeof c!="bigint"?c:(o=!0,null));return o?(Ke(t,r,n,s,"BigInt defaults cannot be represented in JSON Schema"),Ty):JSON.parse(i)}function Il(e,t){if("_idmap"in e){let n=e,s=Pn({...t,processors:Al}),o={};for(let c of n._idmap.entries()){let[l,p]=c;Ce(p,s)}let i={},a={registry:n,uri:t?.uri,defs:o};s.external=a;for(let c of n._idmap.entries()){let[l,p]=c;Cn(s,p),je(i,l,Tn(s,p))}if(Object.keys(o).length>0){let c=s.target==="draft-2020-12"?"$defs":"definitions";i.__shared={[c]:o}}return{schemas:i}}let r=Pn({...t,processors:Al});return Ce(e,r),Cn(r,e),Tn(r,e)}var OL,Qh,Xh,ey,ty,ry,ny,sy,oy,iy,ay,cy,uy,ly,py,dy,my,fy,gy,hy,yy,by,wy,_y,Ry,Sy,Ol,vy,ky,Yh,Ey,Py,Cy,Ty,$y,Ay,Oy,xy,Iy,Dy,xl,Ly,Al,xa=C(()=>{Ro();Aa();Je();OL={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Qh=(e,t,r,n)=>{let s=r;s.type="string";let{minimum:o,maximum:i,format:a,patterns:c,contentEncoding:l,laxFormat:p}=e._zod.bag;if(typeof o=="number"&&(s.minLength=o),typeof i=="number"&&(s.maxLength=i),a&&(s.format=OL[a]??a,s.format===""&&delete s.format,(a==="time"||p)&&delete s.format),l&&(s.contentEncoding=l),c&&c.size>0){let d=[...c];d.length===1?s.pattern=d[0].source:d.length>1&&(s.allOf=[...d.map(m=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},Xh=(e,t,r,n)=>{let s=r,{minimum:o,maximum:i,format:a,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:p}=e._zod.bag;typeof a=="string"&&a.includes("int")?s.type="integer":s.type="number";let d=typeof p=="number"&&p>=(o??Number.NEGATIVE_INFINITY),m=typeof l=="number"&&l<=(i??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";d?f?(s.minimum=p,s.exclusiveMinimum=!0):s.exclusiveMinimum=p:typeof o=="number"&&(s.minimum=o),m?f?(s.maximum=l,s.exclusiveMaximum=!0):s.exclusiveMaximum=l:typeof i=="number"&&(s.maximum=i),typeof c=="number"&&(Number.isFinite(c)&&c!==0?s.multipleOf=Math.abs(c):Ke(e,t,s,n,`A multipleOf divisor of ${c} cannot be represented in JSON Schema`))},ey=(e,t,r,n)=>{r.type="boolean"},ty=(e,t,r,n)=>{Ke(e,t,r,n,"BigInt cannot be represented in JSON Schema")},ry=(e,t,r,n)=>{Ke(e,t,r,n,"Symbols cannot be represented in JSON Schema")},ny=(e,t,r,n)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},sy=(e,t,r,n)=>{Ke(e,t,r,n,"Undefined cannot be represented in JSON Schema")},oy=(e,t,r,n)=>{Ke(e,t,r,n,"Void cannot be represented in JSON Schema")},iy=(e,t,r,n)=>{r.not={}},ay=(e,t,r,n)=>{},cy=(e,t,r,n)=>{},uy=(e,t,r,n)=>{Ke(e,t,r,n,"Date cannot be represented in JSON Schema")},ly=(e,t,r,n)=>{let s=e._zod.def,o=ta(s.entries);if(o.length===0){r.not={};return}o.every(i=>typeof i=="number")&&(r.type="number"),o.every(i=>typeof i=="string")&&(r.type="string"),r.enum=o},py=(e,t,r,n)=>{let s=e._zod.def;if(s.values.length===0){r.not={};return}let o=[];for(let i of s.values)if(i===void 0){if(Ke(e,t,r,n,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i=="bigint"){if(Ke(e,t,r,n,"BigInt literals cannot be represented in JSON Schema"))return;o.push(Number(i))}else o.push(i);if(o.length!==0)if(o.length===1){let i=o[0];r.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[i]:r.const=i}else o.every(i=>typeof i=="number")&&(r.type="number"),o.every(i=>typeof i=="string")&&(r.type="string"),o.every(i=>typeof i=="boolean")&&(r.type="boolean"),o.every(i=>i===null)&&(r.type="null"),r.enum=o},dy=(e,t,r,n)=>{Ke(e,t,r,n,"NaN cannot be represented in JSON Schema")},my=(e,t,r,n)=>{let s=r,o=e._zod.pattern;if(!o)throw new Error("Pattern not found in template literal");s.type="string",s.pattern=o.source},fy=(e,t,r,n)=>{let s=r,o={type:"string",format:"binary",contentEncoding:"binary"},{minimum:i,maximum:a,mime:c}=e._zod.bag;i!==void 0&&(o.minLength=i),a!==void 0&&(o.maxLength=a),c?c.length===1?(o.contentMediaType=c[0],Object.assign(s,o)):(Object.assign(s,o),s.anyOf=c.map(l=>({contentMediaType:l}))):Object.assign(s,o)},gy=(e,t,r,n)=>{r.type="boolean"},hy=(e,t,r,n)=>{Ke(e,t,r,n,"Custom types cannot be represented in JSON Schema")},yy=(e,t,r,n)=>{Ke(e,t,r,n,"Function types cannot be represented in JSON Schema")},by=(e,t,r,n)=>{Ke(e,t,r,n,"Transforms cannot be represented in JSON Schema")},wy=(e,t,r,n)=>{Ke(e,t,r,n,"Map cannot be represented in JSON Schema")},_y=(e,t,r,n)=>{Ke(e,t,r,n,"Set cannot be represented in JSON Schema")},Ry=(e,t,r,n)=>{let s=r,o=e._zod.def,{minimum:i,maximum:a}=e._zod.bag;typeof i=="number"&&(s.minItems=i),typeof a=="number"&&(s.maxItems=a),s.type="array",s.items=Ce(o.element,t,{...n,path:[...n.path,"items"]})};Sy=(e,t,r,n)=>{let s=r,o=e._zod.def,i=o.shape;if(Object.getOwnPropertySymbols(i).length&&Ke(e,t,s,n,"Symbol keys cannot be represented in JSON Schema"))return;s.type="object",s.properties={};for(let p in i)je(s.properties,p,Ce(i[p],t,{...n,path:[...n.path,"properties",p]}));let c=new Set(Object.keys(i)),l=new Set([...c].filter(p=>{let d=o.shape[p];return t.io==="input"?Oa(d)===void 0:d._zod.optout===void 0}));l.size>0&&(s.required=Array.from(l)),o.catchall?._zod.def.type==="never"?s.additionalProperties=!1:o.catchall?o.catchall&&(s.additionalProperties=Ce(o.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(s.additionalProperties=!1)},Ol=(e,t,r,n)=>{let s=e._zod.def,o=s.inclusive===!1,i=s.options.map((a,c)=>Ce(a,t,{...n,path:[...n.path,o?"oneOf":"anyOf",c]}));o?r.oneOf=i:r.anyOf=i},vy=(e,t,r,n)=>{let s=e._zod.def,o=Ce(s.left,t,{...n,path:[...n.path,"allOf",0]}),i=Ce(s.right,t,{...n,path:[...n.path,"allOf",1]}),a=l=>"allOf"in l&&Object.keys(l).length===1,c=[...a(o)?o.allOf:[o],...a(i)?i.allOf:[i]];r.allOf=c,t.intersections.push(c)},ky=(e,t,r,n)=>{let s=r,o=e._zod.def;s.type="array";let i=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=o.items.map((h,w)=>Ce(h,t,{...n,path:[...n.path,i,w]})),l=o.rest?Ce(o.rest,t,{...n,path:[...n.path,a,...t.target==="openapi-3.0"?[o.items.length]:[]]}):null,p=o.items.length;for(;p>0;){let h=o.items[p-1];if(!(t.io==="input"?Oa(h)!==void 0:h._zod.optout==="optional"))break;p--}let d=o.items.length,m=!o.rest;t.target==="draft-2020-12"?(s.prefixItems=c,m?s.items=!1:l&&(s.items=l),p>0&&(s.minItems=p),m&&(s.maxItems=d)):t.target==="openapi-3.0"?(s.items={anyOf:c},l&&s.items.anyOf.push(l),p>0&&(s.minItems=p),m&&(s.maxItems=d)):(s.items=c,m?s.additionalItems=!1:l&&(s.additionalItems=l),p>0&&(s.minItems=p),m&&(s.maxItems=d));let{minimum:f,maximum:g}=e._zod.bag;typeof f=="number"&&(s.minItems=f),typeof g=="number"&&(s.maxItems=g)};Yh=new WeakMap;Ey=(e,t,r,n)=>{let s=r,o=e._zod.def;s.type="object";let i=o.keyType,c=i._zod.bag?.patterns;if(o.mode==="loose"&&c&&c.size>0){let d=Ce(o.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});s.patternProperties={};for(let m of c)je(s.patternProperties,m.source,d)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){s.propertyNames=Ce(o.keyType,t,{...n,path:[...n.path,"propertyNames"]});let d=Yh.get(t);d||(d=[],Yh.set(t,d),t.deferred.push(()=>xL(t))),d.push(e)}s.additionalProperties=Ce(o.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let l=i._zod.values,p=t.io==="input"&&Oa(o.valueType)!==void 0;if(l&&!o.partial&&!p){let d=[...l].filter(m=>typeof m=="string"||typeof m=="number");d.length>0&&(s.required=d.map(String))}},Py=(e,t,r,n)=>{let s=e._zod.def,o=Ce(s.innerType,t,n),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=s.innerType,r.nullable=!0):r.anyOf=[o,{type:"null"}]},Cy=(e,t,r,n)=>{let s=e._zod.def;Ce(s.innerType,t,n);let o=t.seen.get(e);o.ref=s.innerType},Ty=Symbol();$y=(e,t,r,n)=>{let s=e._zod.def;Ce(s.innerType,t,n);let o=t.seen.get(e);o.ref=s.innerType;let i=vv(s.defaultValue,e,t,r,n);i!==Ty&&(r.default=i)},Ay=(e,t,r,n)=>{let s=e._zod.def;Ce(s.innerType,t,n);let o=t.seen.get(e);if(o.ref=s.innerType,t.io!=="input")return;let i=vv(s.defaultValue,e,t,r,n);i!==Ty&&(r._prefault=i)},Oy=(e,t,r,n)=>{let s=e._zod.def;Ce(s.innerType,t,n);let o=t.seen.get(e);o.ref=s.innerType;let i;try{i=s.catchValue(void 0)}catch{Ke(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=i},xy=(e,t,r,n)=>{let s=e._zod.def,o=s.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?o?s.out:s.in:s.out;Ce(i,t,n);let a=t.seen.get(e);a.ref=i},Iy=(e,t,r,n)=>{let s=e._zod.def;Ce(s.innerType,t,n);let o=t.seen.get(e);o.ref=s.innerType,r.readOnly=!0},Dy=(e,t,r,n)=>{let s=e._zod.def;Ce(s.innerType,t,n);let o=t.seen.get(e);o.ref=s.innerType},xl=(e,t,r,n)=>{let s=e._zod.def;Ce(s.innerType,t,n);let o=t.seen.get(e);o.ref=s.innerType},Ly=(e,t,r,n)=>{let s=e._zod.innerType;Ce(s,t,n);let o=t.seen.get(e);o.ref=s},Al={string:Qh,number:Xh,boolean:ey,bigint:ty,symbol:ry,null:ny,undefined:sy,void:oy,never:iy,any:ay,unknown:cy,date:uy,enum:ly,literal:py,nan:dy,template_literal:my,file:fy,success:gy,custom:hy,function:yy,transform:by,map:wy,set:_y,array:Ry,object:Sy,union:Ol,intersection:vy,tuple:ky,record:Ey,nullable:Py,nonoptional:Cy,default:$y,prefault:Ay,catch:Oy,pipe:xy,readonly:Iy,promise:Dy,optional:xl,lazy:Ly}});var Dl,kv=C(()=>{xa();Aa();Dl=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let r=t?.target??"draft-2020-12";r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),this.ctx=Pn({processors:Al,target:r,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,r={path:[],schemaPath:[]}){return Ce(t,this.ctx,r)}emit(t,r){r&&(r.cycles&&(this.ctx.cycles=r.cycles),r.reused&&(this.ctx.reused=r.reused),r.external&&(this.ctx.external=r.external)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,Cn(this.ctx,t);let n=Tn(this.ctx,t),{"~standard":s,...o}=n;return o}}});var Ev={};var Pv=C(()=>{});var Kr={};ne(Kr,{$ZodAny:()=>_g,$ZodArray:()=>Eg,$ZodAsyncError:()=>Ot,$ZodBase64:()=>ug,$ZodBase64URL:()=>lg,$ZodBigInt:()=>Bu,$ZodBigIntFormat:()=>hg,$ZodBoolean:()=>ha,$ZodCIDRv4:()=>ag,$ZodCIDRv6:()=>cg,$ZodCUID:()=>Jf,$ZodCUID2:()=>Kf,$ZodCatch:()=>Vg,$ZodCheck:()=>xe,$ZodCheckBigIntFormat:()=>vf,$ZodCheckEndsWith:()=>Lf,$ZodCheckGreaterThan:()=>Cu,$ZodCheckIncludes:()=>If,$ZodCheckLengthEquals:()=>$f,$ZodCheckLessThan:()=>Pu,$ZodCheckLowerCase:()=>Of,$ZodCheckMaxLength:()=>Cf,$ZodCheckMaxSize:()=>kf,$ZodCheckMimeType:()=>Ff,$ZodCheckMinLength:()=>Tf,$ZodCheckMinSize:()=>Ef,$ZodCheckMultipleOf:()=>Rf,$ZodCheckNumberFormat:()=>Sf,$ZodCheckOverwrite:()=>Mf,$ZodCheckProperty:()=>Tu,$ZodCheckRegex:()=>Af,$ZodCheckSizeEquals:()=>Pf,$ZodCheckStartsWith:()=>Df,$ZodCheckStringFormat:()=>So,$ZodCheckUpperCase:()=>xf,$ZodCodec:()=>ba,$ZodCreditCard:()=>dg,$ZodCustom:()=>Yg,$ZodCustomStringFormat:()=>fg,$ZodCyclicError:()=>Yu,$ZodDate:()=>kg,$ZodDefault:()=>Ug,$ZodDiscriminatedUnion:()=>$g,$ZodE164:()=>pg,$ZodEmail:()=>Hf,$ZodEmoji:()=>qf,$ZodEncodeError:()=>Sn,$ZodEnum:()=>Dg,$ZodError:()=>ca,$ZodExactOptional:()=>Gg,$ZodFile:()=>Fg,$ZodFunction:()=>Jg,$ZodGUID:()=>jf,$ZodIPv4:()=>sg,$ZodIPv6:()=>og,$ZodISODate:()=>tg,$ZodISODateTime:()=>eg,$ZodISODuration:()=>ng,$ZodISOTime:()=>rg,$ZodIntersection:()=>Ag,$ZodJWT:()=>mg,$ZodKSUID:()=>Xf,$ZodLazy:()=>wa,$ZodLiteral:()=>Lg,$ZodMAC:()=>ig,$ZodMap:()=>xg,$ZodNaN:()=>Bg,$ZodNanoID:()=>Zf,$ZodNever:()=>Sg,$ZodNonOptional:()=>zg,$ZodNull:()=>wg,$ZodNullable:()=>Ng,$ZodNumber:()=>Vu,$ZodNumberFormat:()=>gg,$ZodObject:()=>sv,$ZodObjectJIT:()=>Pg,$ZodOptional:()=>qu,$ZodPipe:()=>Zu,$ZodPrefault:()=>jg,$ZodPreprocess:()=>Wg,$ZodPromise:()=>Kg,$ZodReadonly:()=>qg,$ZodRealError:()=>xt,$ZodRecord:()=>Og,$ZodRegistry:()=>el,$ZodSet:()=>Ig,$ZodString:()=>cs,$ZodStringFormat:()=>$e,$ZodSuccess:()=>Hg,$ZodSymbol:()=>yg,$ZodTemplateLiteral:()=>Zg,$ZodTransform:()=>Mg,$ZodTuple:()=>Wu,$ZodType:()=>oe,$ZodULID:()=>Yf,$ZodURL:()=>Wf,$ZodUUID:()=>zf,$ZodUndefined:()=>bg,$ZodUnion:()=>ya,$ZodUnknown:()=>Rg,$ZodVoid:()=>vg,$ZodXID:()=>Qf,$ZodXor:()=>Cg,$brand:()=>Am,$constructor:()=>T,$input:()=>ih,$output:()=>oh,Doc:()=>as,INVALID:()=>Vt,JSONSchema:()=>Ev,JSONSchemaGenerator:()=>Dl,NEVER:()=>$m,TimePrecision:()=>hh,URL_BAD_FORMAT:()=>Vf,URL_UNPARSEABLE:()=>Bf,ZodCompileAsyncError:()=>pr,ZodCompileUnsupportedError:()=>ye,_any:()=>Ih,_array:()=>Uh,_base64:()=>_l,_base64url:()=>Rl,_bigint:()=>Ph,_boolean:()=>kh,_catch:()=>kL,_check:()=>hv,_cidrv4:()=>bl,_cidrv6:()=>wl,_coercedBigint:()=>Ch,_coercedBoolean:()=>Eh,_coercedDate:()=>Gh,_coercedNumber:()=>bh,_coercedString:()=>mh,_creditCard:()=>gh,_cuid:()=>pl,_cuid2:()=>dl,_custom:()=>zh,_date:()=>Mh,_decode:()=>hu,_decodeAsync:()=>bu,_default:()=>RL,_discriminatedUnion:()=>uL,_e164:()=>Sl,_email:()=>nl,_emoji:()=>ul,_encode:()=>gu,_encodeAsync:()=>yu,_endsWith:()=>$o,_enum:()=>gL,_file:()=>jh,_float32:()=>_h,_float64:()=>Rh,_gt:()=>Er,_gte:()=>Wt,_guid:()=>sl,_includes:()=>Co,_int:()=>wh,_int32:()=>Sh,_int64:()=>Th,_intersection:()=>lL,_ipv4:()=>hl,_ipv6:()=>yl,_isoDate:()=>Pa,_isoDateTime:()=>Ea,_isoDuration:()=>Ta,_isoTime:()=>Ca,_jwt:()=>vl,_ksuid:()=>gl,_lazy:()=>TL,_length:()=>gs,_literal:()=>yL,_lowercase:()=>Eo,_lt:()=>kr,_lte:()=>Bt,_mac:()=>fh,_map:()=>mL,_max:()=>Bt,_maxLength:()=>fs,_maxSize:()=>En,_mime:()=>Ao,_min:()=>Wt,_minLength:()=>Jr,_minSize:()=>Pr,_multipleOf:()=>kn,_nan:()=>Nh,_nanoid:()=>ll,_nativeEnum:()=>hL,_negative:()=>El,_never:()=>Lh,_nonnegative:()=>Cl,_nonoptional:()=>SL,_nonpositive:()=>Pl,_normalize:()=>Oo,_null:()=>xh,_nullable:()=>_L,_number:()=>yh,_optional:()=>wL,_overwrite:()=>dr,_parse:()=>yo,_parseAsync:()=>bo,_pipe:()=>EL,_positive:()=>kl,_promise:()=>$L,_properties:()=>$l,_property:()=>Tl,_readonly:()=>PL,_record:()=>dL,_refine:()=>Hh,_regex:()=>ko,_safeDecode:()=>_u,_safeDecodeAsync:()=>Su,_safeEncode:()=>wu,_safeEncodeAsync:()=>Ru,_safeParse:()=>wo,_safeParseAsync:()=>_o,_set:()=>fL,_size:()=>ms,_slugify:()=>Lo,_startsWith:()=>To,_string:()=>dh,_stringFormat:()=>Fo,_stringbool:()=>qh,_success:()=>vL,_superRefine:()=>Vh,_symbol:()=>Ah,_templateLiteral:()=>CL,_toLowerCase:()=>Io,_toUpperCase:()=>Do,_transform:()=>bL,_trim:()=>xo,_tuple:()=>pL,_uint32:()=>vh,_uint64:()=>$h,_ulid:()=>ml,_undefined:()=>Oh,_union:()=>aL,_unknown:()=>Dh,_uppercase:()=>Po,_url:()=>ka,_uuid:()=>ol,_uuidv4:()=>il,_uuidv6:()=>al,_uuidv7:()=>cl,_void:()=>Fh,_xid:()=>fl,_xor:()=>cL,clone:()=>Pe,compile:()=>lh,compileFn:()=>rl,config:()=>ze,createStandardJSONSchemaMethod:()=>Mo,createToJSONSchemaMethod:()=>Jh,decode:()=>w0,decodeAsync:()=>R0,describe:()=>Bh,encode:()=>b0,encodeAsync:()=>_0,extractDefs:()=>Cn,finalize:()=>Tn,flattenError:()=>ua,formatError:()=>la,getDiscriminatedOption:()=>Tg,globalConfig:()=>ot,globalRegistry:()=>ct,handleUnrepresentable:()=>Ke,initializeContext:()=>Pn,isBackEdge:()=>Qu,isRecursiveSchema:()=>th,isValidBase64:()=>ga,isValidBase64URL:()=>ju,isValidCIDRv6:()=>Uu,isValidCreditCard:()=>zu,isValidIPv6:()=>fa,isValidJWT:()=>Hu,locales:()=>Sa,memoizer:()=>Ra,mergeValues:()=>vo,meta:()=>Wh,parse:()=>mu,parseAsync:()=>fu,parseURLObject:()=>Fu,prettifyError:()=>Lm,process:()=>Ce,regexes:()=>bt,registry:()=>tl,safeDecode:()=>v0,safeDecodeAsync:()=>E0,safeEncode:()=>S0,safeEncodeAsync:()=>k0,safeParse:()=>Mm,safeParseAsync:()=>Gm,standardProps:()=>Lu,stripTabAndNewline:()=>Mu,toDotPath:()=>LS,toJSONSchema:()=>Il,toZod:()=>ea,treeifyError:()=>Dm,urlHostnameOk:()=>Gu,urlProtocolOk:()=>Nu,util:()=>Y,validate:()=>Nm,validateAsync:()=>Um,version:()=>Gf});var qt=C(()=>{Rn();jm();Fm();_a();rh();$u();Nf();Je();Je();Ro();sh();va();Au();gv();yv();Aa();xa();kv();Pv()});var Ll={};ne(Ll,{endsWith:()=>$o,gt:()=>Er,gte:()=>Wt,includes:()=>Co,length:()=>gs,lowercase:()=>Eo,lt:()=>kr,lte:()=>Bt,maxLength:()=>fs,maxSize:()=>En,mime:()=>Ao,minLength:()=>Jr,minSize:()=>Pr,multipleOf:()=>kn,negative:()=>El,nonnegative:()=>Cl,nonpositive:()=>Pl,normalize:()=>Oo,overwrite:()=>dr,positive:()=>kl,properties:()=>$l,property:()=>Tl,regex:()=>ko,size:()=>ms,slugify:()=>Lo,startsWith:()=>To,toLowerCase:()=>Io,toUpperCase:()=>Do,trim:()=>xo,uppercase:()=>Po});var Fl=C(()=>{qt()});function Ml(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let n=r(this);return Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0})}})}var Cv,Tv,DL,It,Fy=C(()=>{qt();qt();Je();Cv=new WeakSet([Object.prototype,Error.prototype]);Tv=(e,t)=>{ca.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);Cv.has(r)||(Cv.add(r),Ml(r,"format",n=>s=>la(n,s)),Ml(r,"flatten",n=>s=>ua(n,s)),Ml(r,"addIssue",n=>s=>{n.issues.push(s),n.message=JSON.stringify(n.issues,fo,2)}),Ml(r,"addIssues",n=>s=>{n.issues.push(...s),n.message=JSON.stringify(n.issues,fo,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},DL=T("ZodError",Tv),It=T("ZodError",Tv,void 0,{Parent:Error})});var My,Gy,Ny,Uy,jy,zy,Hy,Vy,By,Wy,qy,Zy,Jy=C(()=>{qt();Fy();qt();My=yo(It),Gy=bo(It),Ny=wo(It),Uy=_o(It),jy=gu(It),zy=hu(It),Hy=yu(It),Vy=bu(It),By=wu(It),Wy=_u(It),qy=Ru(It),Zy=Su(It)});var Wo={};ne(Wo,{ZodAny:()=>sb,ZodArray:()=>cb,ZodBase64:()=>ep,ZodBase64URL:()=>tp,ZodBigInt:()=>Vo,ZodBigIntFormat:()=>sp,ZodBoolean:()=>Ho,ZodCIDRv4:()=>Ql,ZodCIDRv6:()=>Xl,ZodCUID:()=>Bl,ZodCUID2:()=>Wl,ZodCatch:()=>$b,ZodCodec:()=>za,ZodCreditCard:()=>Yy,ZodCustom:()=>Ha,ZodCustomStringFormat:()=>jo,ZodDate:()=>Fa,ZodDefault:()=>vb,ZodDiscriminatedUnion:()=>lb,ZodE164:()=>rp,ZodEmail:()=>jl,ZodEmoji:()=>Hl,ZodEnum:()=>No,ZodExactOptional:()=>cp,ZodFile:()=>wb,ZodFunction:()=>Nb,ZodGUID:()=>zl,ZodIPv4:()=>Kl,ZodIPv6:()=>Yl,ZodISODate:()=>An,ZodISODateTime:()=>$n,ZodISODuration:()=>xn,ZodISOTime:()=>On,ZodIntersection:()=>pb,ZodJWT:()=>np,ZodKSUID:()=>Jl,ZodLazy:()=>Fb,ZodLiteral:()=>bb,ZodMAC:()=>Ky,ZodMap:()=>hb,ZodNaN:()=>Ob,ZodNanoID:()=>Vl,ZodNever:()=>ib,ZodNonOptional:()=>up,ZodNull:()=>rb,ZodNullable:()=>Sb,ZodNumber:()=>zo,ZodNumberFormat:()=>ws,ZodObject:()=>Ga,ZodOptional:()=>Ua,ZodPipe:()=>ja,ZodPrefault:()=>Eb,ZodPreprocess:()=>xb,ZodPromise:()=>Gb,ZodReadonly:()=>Ib,ZodRecord:()=>Go,ZodSet:()=>yb,ZodString:()=>Uo,ZodStringFormat:()=>Oe,ZodSuccess:()=>Tb,ZodSymbol:()=>eb,ZodTemplateLiteral:()=>Lb,ZodTransform:()=>_b,ZodTuple:()=>mb,ZodType:()=>le,ZodULID:()=>ql,ZodURL:()=>La,ZodUUID:()=>Cr,ZodUndefined:()=>tb,ZodUnion:()=>Na,ZodUnknown:()=>ob,ZodVoid:()=>ab,ZodXID:()=>Zl,ZodXor:()=>ub,_ZodString:()=>Ul,_default:()=>kb,_function:()=>Fk,any:()=>mk,array:()=>Ma,base64:()=>Jv,base64url:()=>Kv,bigint:()=>ck,boolean:()=>Xy,catch:()=>Ab,check:()=>Mk,cidrv4:()=>qv,cidrv6:()=>Zv,codec:()=>xk,creditCard:()=>Qv,cuid:()=>Nv,cuid2:()=>Uv,custom:()=>Gk,date:()=>gk,describe:()=>Nk,discriminatedUnion:()=>Rk,e164:()=>Yv,email:()=>$v,emoji:()=>Mv,enum:()=>ip,exactOptional:()=>Rb,file:()=>Tk,float32:()=>sk,float64:()=>ok,function:()=>Fk,guid:()=>Av,hash:()=>nk,hex:()=>rk,hostname:()=>tk,httpUrl:()=>Fv,instanceof:()=>jk,int:()=>Gl,int32:()=>ik,int64:()=>uk,intersection:()=>db,invertCodec:()=>Ik,ipv4:()=>Vv,ipv6:()=>Wv,json:()=>Hk,jwt:()=>Xv,keyof:()=>hk,ksuid:()=>Hv,lazy:()=>Mb,literal:()=>Ck,looseObject:()=>wk,looseRecord:()=>vk,mac:()=>Bv,map:()=>kk,meta:()=>Uk,nan:()=>Ok,nanoid:()=>Gv,nativeEnum:()=>Pk,never:()=>op,nonoptional:()=>Cb,null:()=>nb,nullable:()=>Da,nullish:()=>$k,number:()=>Qy,object:()=>yk,optional:()=>ys,partialRecord:()=>Sk,pipe:()=>Nl,prefault:()=>Pb,preprocess:()=>Vk,promise:()=>Lk,readonly:()=>Db,record:()=>gb,refine:()=>Ub,set:()=>Ek,strictObject:()=>bk,string:()=>Ia,stringFormat:()=>ek,stringbool:()=>zk,success:()=>Ak,superRefine:()=>jb,symbol:()=>pk,templateLiteral:()=>Dk,transform:()=>ap,tuple:()=>fb,uint32:()=>ak,uint64:()=>lk,ulid:()=>jv,undefined:()=>dk,union:()=>Bo,unknown:()=>hs,url:()=>Lv,uuid:()=>Ov,uuidv4:()=>xv,uuidv6:()=>Iv,uuidv7:()=>Dv,void:()=>fk,xid:()=>zv,xor:()=>_k});function FL(){ot.localeError||ze(Xu())}function bs(){ot.memoizer||ze({memoizer:Ra()})}function Ia(e){return dh(Uo,e)}function $v(e){return nl(jl,e)}function Av(e){return sl(zl,e)}function Ov(e){return ol(Cr,e)}function xv(e){return il(Cr,e)}function Iv(e){return al(Cr,e)}function Dv(e){return cl(Cr,e)}function Lv(e){return ka(La,e)}function Fv(e){return ka(La,{protocol:bt.httpProtocol,hostname:bt.domain,...Y.normalizeParams(e)})}function Mv(e){return ul(Hl,e)}function Gv(e){return ll(Vl,e)}function Nv(e){return pl(Bl,e)}function Uv(e){return dl(Wl,e)}function jv(e){return ml(ql,e)}function zv(e){return fl(Zl,e)}function Hv(e){return gl(Jl,e)}function Vv(e){return hl(Kl,e)}function Bv(e){return fh(Ky,e)}function Wv(e){return yl(Yl,e)}function qv(e){return bl(Ql,e)}function Zv(e){return wl(Xl,e)}function Jv(e){return _l(ep,e)}function Kv(e){return Rl(tp,e)}function Yv(e){return Sl(rp,e)}function Qv(e){return gh(Yy,e)}function Xv(e){return vl(np,e)}function ek(e,t,r={}){return Fo(jo,e,t,r)}function tk(e){return Fo(jo,"hostname",bt.hostname,e)}function rk(e){return Fo(jo,"hex",bt.hex,e)}function nk(e,t){let r=t?.enc??"hex",n=`${e}_${r}`,s=bt[n];if(!s)throw new Error(`Unrecognized hash format: ${n}`);return Fo(jo,n,s,t)}function Qy(e){return yh(zo,e)}function Gl(e){return wh(ws,e)}function sk(e){return _h(ws,e)}function ok(e){return Rh(ws,e)}function ik(e){return Sh(ws,e)}function ak(e){return vh(ws,e)}function Xy(e){return kh(Ho,e)}function ck(e){return Ph(Vo,e)}function uk(e){return Th(sp,e)}function lk(e){return $h(sp,e)}function pk(e){return Ah(eb,e)}function dk(e){return Oh(tb,e)}function nb(e){return xh(rb,e)}function mk(){return Ih(sb)}function hs(){return Dh(ob)}function op(e){return Lh(ib,e)}function fk(e){return Fh(ab,e)}function gk(e){return Mh(Fa,e)}function Ma(e,t){return Uh(cb,e,t)}function hk(e){let t=e._zod.def.shape;return ip(Object.keys(t))}function yk(e,t){let r={type:"object",shape:e??{},...Y.normalizeParams(t)};return new Ga(r)}function bk(e,t){return new Ga({type:"object",shape:e,catchall:op(),...Y.normalizeParams(t)})}function wk(e,t){return new Ga({type:"object",shape:e,catchall:hs(),...Y.normalizeParams(t)})}function Bo(e,t){return new Na({type:"union",options:e,...Y.normalizeParams(t)})}function _k(e,t){return new ub({type:"union",options:e,inclusive:!1,...Y.normalizeParams(t)})}function Rk(e,t,r){return new lb({type:"union",options:t,discriminator:e,...Y.normalizeParams(r)})}function db(e,t){return new pb({type:"intersection",left:e,right:t})}function fb(e,t,r){let n=t instanceof oe,s=n?r:t,o=n?t:null;return new mb({type:"tuple",items:e,rest:o,...Y.normalizeParams(s)})}function gb(e,t,r){return!t||!t._zod?new Go({type:"record",keyType:Ia(),valueType:e,...Y.normalizeParams(t)}):new Go({type:"record",keyType:e,valueType:t,...Y.normalizeParams(r)})}function Sk(e,t,r){return new Go({type:"record",keyType:e,valueType:t,...Y.normalizeParams(r),partial:!0})}function vk(e,t,r){return new Go({type:"record",keyType:e,valueType:t,mode:"loose",...Y.normalizeParams(r)})}function kk(e,t,r){return new hb({type:"map",keyType:e,valueType:t,...Y.normalizeParams(r)})}function Ek(e,t){return new yb({type:"set",valueType:e,...Y.normalizeParams(t)})}function ip(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new No({type:"enum",entries:r,...Y.normalizeParams(t)})}function Pk(e,t){return new No({type:"enum",entries:e,...Y.normalizeParams(t)})}function Ck(e,t){return new bb({type:"literal",values:Array.isArray(e)?e:[e],...Y.normalizeParams(t)})}function Tk(e){return jh(wb,e)}function ap(e){return new _b({type:"transform",transform:e})}function ys(e){return new Ua({type:"optional",innerType:e})}function Rb(e){return new cp({type:"optional",innerType:e})}function Da(e){return new Sb({type:"nullable",innerType:e})}function $k(e){return ys(Da(e))}function kb(e,t){return new vb({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Y.shallowClone(t)}})}function Pb(e,t){return new Eb({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Y.shallowClone(t)}})}function Cb(e,t){return new up({type:"nonoptional",innerType:e,...Y.normalizeParams(t)})}function Ak(e){return new Tb({type:"success",innerType:e})}function Ab(e,t){return new $b({type:"catch",innerType:e,catchValue:typeof t=="function"?t:Y.constantCatch(t)})}function Ok(e){return Nh(Ob,e)}function Nl(e,t){return new ja({type:"pipe",in:e,out:t})}function xk(e,t,r){return new za({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}function Ik(e){let t=e._zod.def;return new za({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}function Db(e){return new Ib({type:"readonly",innerType:e})}function Dk(e,t){return new Lb({type:"template_literal",parts:e,...Y.normalizeParams(t)})}function Mb(e){return new Fb({type:"lazy",getter:e})}function Lk(e){return new Gb({type:"promise",innerType:e})}function Fk(e){return new Nb({type:"function",input:Array.isArray(e?.input)?fb(e?.input):e?.input??Ma(hs()),output:e?.output??hs()})}function Mk(e){let t=new xe({check:"custom"});return t._zod.check=e,t}function Gk(e,t){return zh(Ha,e??(()=>!0),t)}function Ub(e,t={}){return Hh(Ha,e,t)}function jb(e,t){return Vh(e,t)}function jk(e,t={}){let r=new Ha({type:"custom",check:"custom",fn:n=>n instanceof e,abort:!0,...Y.normalizeParams(t)});return r._zod.bag.Class=e,r._zod.check=n=>{n.value instanceof e||n.issues.push({code:"invalid_type",expected:e.name,input:n.value,inst:r,path:[...r._zod.def.path??[]]})},r}function Hk(e){let t=Mb(()=>Bo([Ia(e),Qy(),Xy(),nb(),Ma(t),gb(Ia(),t)]));return t}function Vk(e,t){return new xb({type:"pipe",in:ap(e),out:t})}var le,Ul,Uo,Oe,$n,An,On,xn,jl,zl,Cr,La,Hl,Vl,Bl,Wl,ql,Zl,Jl,Kl,Ky,Yl,Ql,Xl,ep,tp,rp,Yy,np,jo,zo,ws,Ho,Vo,sp,eb,tb,rb,sb,ob,ib,ab,Fa,cb,Ga,Na,ub,lb,pb,mb,Go,hb,yb,No,bb,wb,_b,Ua,cp,Sb,vb,Eb,up,Tb,$b,Ob,ja,za,xb,Ib,Lb,Fb,Gb,Nb,Ha,Nk,Uk,zk,In=C(()=>{qt();qt();xa();Aa();nh();Fl();Jy();le=T("ZodType",(e,t)=>(FL(),oe.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Y.mergeDefs(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Pe(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Ub(e,t))},superRefine(e,t){return this.check(jb(e,t))},overwrite(e){return this.check(dr(e))},optional(){return ys(this)},exactOptional(){return Rb(this)},nullable(){return Da(this)},nullish(){return ys(Da(this))},nonoptional(e){return Cb(this,e)},array(){return Ma(this)},or(e){return Bo([this,e])},and(e){return db(this,e)},transform(e){return Nl(this,ap(e))},default(e){return kb(this,e)},prefault(e){return Pb(this,e)},catch(e){return Ab(this,e)},pipe(e){return Nl(this,e)},readonly(){return Db(this)},describe(e){let t=this.clone();return ct.add(t,{description:e}),t},meta(...e){if(e.length===0)return ct.get(this);let t=this.clone();return ct.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return Y.hide(this,"~standard",{...Lu(this),jsonSchema:{input:Mo(this,"input"),output:Mo(this,"output")}})},set"~standard"(e){Y.own(this,"~standard",e)},parse:function e(t,r){return My(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await Gy(this,t,r,{callee:e})},safeParse(e,t){return Ny(this,e,t)},async safeParseAsync(e,t){return Uy(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Y.own(this,"spa",e)},encode:function e(t,r){return jy(this,t,r,{callee:e})},decode:function e(t,r){return zy(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await Hy(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await Vy(this,t,r,{callee:e})},safeEncode(e,t){return By(this,e,t)},safeDecode(e,t){return Wy(this,e,t)},async safeEncodeAsync(e,t){return qy(this,e,t)},async safeDecodeAsync(e,t){return Zy(this,e,t)},toJSONSchema(e){return Jh(this,{})(e)},get description(){return ct.get(this)?.description},get _def(){return this._zod.def}}),Ul=T("_ZodString",(e,t)=>{cs.init(e,t),le.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Qh(e,n,s,o);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null},{regex(...e){return this.check(ko(...e))},includes(...e){return this.check(Co(...e))},startsWith(...e){return this.check(To(...e))},endsWith(...e){return this.check($o(...e))},min(...e){return this.check(Jr(...e))},max(...e){return this.check(fs(...e))},length(...e){return this.check(gs(...e))},nonempty(...e){return this.check(Jr(1,...e))},lowercase(e){return this.check(Eo(e))},uppercase(e){return this.check(Po(e))},trim(){return this.check(xo())},normalize(...e){return this.check(Oo(...e))},toLowerCase(){return this.check(Io())},toUpperCase(){return this.check(Do())},slugify(){return this.check(Lo())}}),Uo=T("ZodString",(e,t)=>{cs.init(e,t),Ul.init(e,t)},{email(e){return this.check(nl(jl,e))},url(e){return this.check(ka(La,e))},jwt(e){return this.check(vl(np,e))},emoji(e){return this.check(ul(Hl,e))},guid(e){return this.check(sl(zl,e))},uuid(e){return this.check(ol(Cr,e))},uuidv4(e){return this.check(il(Cr,e))},uuidv6(e){return this.check(al(Cr,e))},uuidv7(e){return this.check(cl(Cr,e))},nanoid(e){return this.check(ll(Vl,e))},cuid(e){return this.check(pl(Bl,e))},cuid2(e){return this.check(dl(Wl,e))},ulid(e){return this.check(ml(ql,e))},base64(e){return this.check(_l(ep,e))},base64url(e){return this.check(Rl(tp,e))},xid(e){return this.check(fl(Zl,e))},ksuid(e){return this.check(gl(Jl,e))},ipv4(e){return this.check(hl(Kl,e))},ipv6(e){return this.check(yl(Yl,e))},cidrv4(e){return this.check(bl(Ql,e))},cidrv6(e){return this.check(wl(Xl,e))},e164(e){return this.check(Sl(rp,e))},datetime(e){return this.check(Ea($n,e))},date(e){return this.check(Pa(An,e))},time(e){return this.check(Ca(On,e))},duration(e){return this.check(Ta(xn,e))}});Oe=T("ZodStringFormat",(e,t)=>{$e.init(e,t),Ul.init(e,t)}),$n=T("ZodISODateTime",(e,t)=>{eg.init(e,t),Oe.init(e,t)}),An=T("ZodISODate",(e,t)=>{tg.init(e,t),Oe.init(e,t)}),On=T("ZodISOTime",(e,t)=>{rg.init(e,t),Oe.init(e,t)}),xn=T("ZodISODuration",(e,t)=>{ng.init(e,t),Oe.init(e,t)}),jl=T("ZodEmail",(e,t)=>{Hf.init(e,t),Oe.init(e,t)});zl=T("ZodGUID",(e,t)=>{jf.init(e,t),Oe.init(e,t)});Cr=T("ZodUUID",(e,t)=>{zf.init(e,t),Oe.init(e,t)});La=T("ZodURL",(e,t)=>{Wf.init(e,t),Oe.init(e,t)});Hl=T("ZodEmoji",(e,t)=>{qf.init(e,t),Oe.init(e,t)});Vl=T("ZodNanoID",(e,t)=>{Zf.init(e,t),Oe.init(e,t)});Bl=T("ZodCUID",(e,t)=>{Jf.init(e,t),Oe.init(e,t)});Wl=T("ZodCUID2",(e,t)=>{Kf.init(e,t),Oe.init(e,t)});ql=T("ZodULID",(e,t)=>{Yf.init(e,t),Oe.init(e,t)});Zl=T("ZodXID",(e,t)=>{Qf.init(e,t),Oe.init(e,t)});Jl=T("ZodKSUID",(e,t)=>{Xf.init(e,t),Oe.init(e,t)});Kl=T("ZodIPv4",(e,t)=>{sg.init(e,t),Oe.init(e,t)});Ky=T("ZodMAC",(e,t)=>{ig.init(e,t),Oe.init(e,t)});Yl=T("ZodIPv6",(e,t)=>{og.init(e,t),Oe.init(e,t)});Ql=T("ZodCIDRv4",(e,t)=>{ag.init(e,t),Oe.init(e,t)});Xl=T("ZodCIDRv6",(e,t)=>{cg.init(e,t),Oe.init(e,t)});ep=T("ZodBase64",(e,t)=>{ug.init(e,t),Oe.init(e,t)});tp=T("ZodBase64URL",(e,t)=>{lg.init(e,t),Oe.init(e,t)});rp=T("ZodE164",(e,t)=>{pg.init(e,t),Oe.init(e,t)});Yy=T("ZodCreditCard",(e,t)=>{dg.init(e,t),Oe.init(e,t)});np=T("ZodJWT",(e,t)=>{mg.init(e,t),Oe.init(e,t)});jo=T("ZodCustomStringFormat",(e,t)=>{fg.init(e,t),Oe.init(e,t)});zo=T("ZodNumber",(e,t)=>{Vu.init(e,t),le.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Xh(e,n,s,o);let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null},{gt(e,t){return this.check(Er(e,t))},gte(e,t){return this.check(Wt(e,t))},min(e,t){return this.check(Wt(e,t))},lt(e,t){return this.check(kr(e,t))},lte(e,t){return this.check(Bt(e,t))},max(e,t){return this.check(Bt(e,t))},int(e){return this.check(Gl(e))},safe(e){return this.check(Gl(e))},positive(e){return this.check(Er(0,e))},nonnegative(e){return this.check(Wt(0,e))},negative(e){return this.check(kr(0,e))},nonpositive(e){return this.check(Bt(0,e))},multipleOf(e,t){return this.check(kn(e,t))},step(e,t){return this.check(kn(e,t))},finite(){return this}});ws=T("ZodNumberFormat",(e,t)=>{gg.init(e,t),zo.init(e,t)});Ho=T("ZodBoolean",(e,t)=>{ha.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>ey(e,r,n,s)});Vo=T("ZodBigInt",(e,t)=>{Bu.init(e,t),le.init(e,t),e._zod.processJSONSchema=(n,s,o)=>ty(e,n,s,o);let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null},{gte(e,t){return this.check(Wt(e,t))},min(e,t){return this.check(Wt(e,t))},gt(e,t){return this.check(Er(e,t))},lt(e,t){return this.check(kr(e,t))},lte(e,t){return this.check(Bt(e,t))},max(e,t){return this.check(Bt(e,t))},positive(e){return this.check(Er(BigInt(0),e))},negative(e){return this.check(kr(BigInt(0),e))},nonpositive(e){return this.check(Bt(BigInt(0),e))},nonnegative(e){return this.check(Wt(BigInt(0),e))},multipleOf(e,t){return this.check(kn(e,t))}});sp=T("ZodBigIntFormat",(e,t)=>{hg.init(e,t),Vo.init(e,t)});eb=T("ZodSymbol",(e,t)=>{yg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>ry(e,r,n,s)});tb=T("ZodUndefined",(e,t)=>{bg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>sy(e,r,n,s)});rb=T("ZodNull",(e,t)=>{wg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>ny(e,r,n,s)});sb=T("ZodAny",(e,t)=>{_g.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>ay(e,r,n,s)});ob=T("ZodUnknown",(e,t)=>{Rg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>cy(e,r,n,s)});ib=T("ZodNever",(e,t)=>{Sg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>iy(e,r,n,s)});ab=T("ZodVoid",(e,t)=>{vg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>oy(e,r,n,s)});Fa=T("ZodDate",(e,t)=>{kg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(n,s,o)=>uy(e,n,s,o),e.min=(n,s)=>e.check(Wt(n,s)),e.max=(n,s)=>e.check(Bt(n,s));let r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null});cb=T("ZodArray",(e,t)=>{bs(),Eg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>Ry(e,r,n,s),e.element=t.element},{min(e,t){return this.check(Jr(e,t))},nonempty(e){return this.check(Jr(1,e))},max(e,t){return this.check(fs(e,t))},length(e,t){return this.check(gs(e,t))},unwrap(){return this.element}});Ga=T("ZodObject",(e,t)=>{bs(),Pg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>Sy(e,r,n,s),Y.installLazyProp(e,"shape",r=>r._zod.def.shape,!1)},{keyof(){return ip(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:hs()})},loose(){return this.clone({...this._zod.def,catchall:hs()})},strict(){return this.clone({...this._zod.def,catchall:op()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return Y.extend(this,e)},safeExtend(e){return Y.safeExtend(this,e)},merge(e){return Y.merge(this,e)},pick(e){return Y.pick(this,e)},omit(e){return Y.omit(this,e)},partial(...e){return Y.partial(Ua,this,e[0])},exactPartial(...e){return Y.partial(cp,this,e[0],"exactPartial")},required(...e){return Y.required(up,this,e[0])}});Na=T("ZodUnion",(e,t)=>{ya.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>Ol(e,r,n,s),e.options=t.options});ub=T("ZodXor",(e,t)=>{Na.init(e,t),Cg.init(e,t),e._zod.processJSONSchema=(r,n,s)=>Ol(e,r,n,s),e.options=t.options});lb=T("ZodDiscriminatedUnion",(e,t)=>{Na.init(e,t),$g.init(e,t)});pb=T("ZodIntersection",(e,t)=>{Ag.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>vy(e,r,n,s)});mb=T("ZodTuple",(e,t)=>{bs(),Wu.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>ky(e,r,n,s)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map(t=>new Ua({type:"optional",innerType:t}))})}});Go=T("ZodRecord",(e,t)=>{bs(),Og.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>Ey(e,r,n,s),e.keyType=t.keyType,e.valueType=t.valueType});hb=T("ZodMap",(e,t)=>{bs(),xg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>wy(e,r,n,s),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(Pr(...r)),e.nonempty=r=>e.check(Pr(1,r)),e.max=(...r)=>e.check(En(...r)),e.size=(...r)=>e.check(ms(...r))});yb=T("ZodSet",(e,t)=>{bs(),Ig.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>_y(e,r,n,s),e.min=(...r)=>e.check(Pr(...r)),e.nonempty=r=>e.check(Pr(1,r)),e.max=(...r)=>e.check(En(...r)),e.size=(...r)=>e.check(ms(...r))});No=T("ZodEnum",(e,t)=>{Dg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(n,s,o)=>ly(e,n,s,o),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(n,s)=>{let o={};for(let i of n)if(r.has(i))o[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new No({...t,checks:[],...Y.normalizeParams(s),entries:o})},e.exclude=(n,s)=>{let o={...t.entries};for(let i of n)if(r.has(i))delete o[i];else throw new Error(`Key ${i} not found in enum`);return new No({...t,checks:[],...Y.normalizeParams(s),entries:o})}});bb=T("ZodLiteral",(e,t)=>{Lg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>py(e,r,n,s),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});wb=T("ZodFile",(e,t)=>{Fg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>fy(e,r,n,s),e.min=(r,n)=>e.check(Pr(r,n)),e.max=(r,n)=>e.check(En(r,n)),e.mime=(r,n)=>e.check(Ao(Array.isArray(r)?r:[r],n))});_b=T("ZodTransform",(e,t)=>{bs(),Mg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>by(e,r,n,s),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Sn(e.constructor.name);r.addIssue=o=>{if(typeof o=="string")r.issues.push(Y.issue(o,r.value,t));else{let i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=r.value),i.inst??(i.inst=e),r.issues.push(Y.issue(i))}};let s=t.transform(r.value,r);return s instanceof Promise?s.then(o=>(r.value=o,r)):(r.value=s,r)}});Ua=T("ZodOptional",(e,t)=>{qu.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>xl(e,r,n,s),e.unwrap=()=>e._zod.def.innerType});cp=T("ZodExactOptional",(e,t)=>{Gg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>xl(e,r,n,s),e.unwrap=()=>e._zod.def.innerType});Sb=T("ZodNullable",(e,t)=>{Ng.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>Py(e,r,n,s),e.unwrap=()=>e._zod.def.innerType});vb=T("ZodDefault",(e,t)=>{Ug.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>$y(e,r,n,s),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});Eb=T("ZodPrefault",(e,t)=>{jg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>Ay(e,r,n,s),e.unwrap=()=>e._zod.def.innerType});up=T("ZodNonOptional",(e,t)=>{zg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>Cy(e,r,n,s),e.unwrap=()=>e._zod.def.innerType});Tb=T("ZodSuccess",(e,t)=>{Hg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>gy(e,r,n,s),e.unwrap=()=>e._zod.def.innerType});$b=T("ZodCatch",(e,t)=>{Vg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>Oy(e,r,n,s),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});Ob=T("ZodNaN",(e,t)=>{Bg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>dy(e,r,n,s)});ja=T("ZodPipe",(e,t)=>{Zu.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>xy(e,r,n,s),e.in=t.in,e.out=t.out});za=T("ZodCodec",(e,t)=>{ja.init(e,t),ba.init(e,t)});xb=T("ZodPreprocess",(e,t)=>{ja.init(e,t),Wg.init(e,t)}),Ib=T("ZodReadonly",(e,t)=>{qg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>Iy(e,r,n,s),e.unwrap=()=>e._zod.def.innerType});Lb=T("ZodTemplateLiteral",(e,t)=>{Zg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>my(e,r,n,s)});Fb=T("ZodLazy",(e,t)=>{wa.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>Ly(e,r,n,s),e.unwrap=()=>e._zod.def.getter()});Gb=T("ZodPromise",(e,t)=>{Kg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>Dy(e,r,n,s),e.unwrap=()=>e._zod.def.innerType});Nb=T("ZodFunction",(e,t)=>{Jg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>yy(e,r,n,s)});Ha=T("ZodCustom",(e,t)=>{Yg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>hy(e,r,n,s)});Nk=Bh,Uk=Wh;zk=(...e)=>qh({Codec:za,Boolean:Ho,String:Uo},...e)});function GL(e){ze({customError:e})}function NL(){return ze().customError}var ML,zb,Bk=C(()=>{qt();ML={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};zb||(zb={})});var Va={};ne(Va,{ZodISODate:()=>An,ZodISODateTime:()=>$n,ZodISODuration:()=>xn,ZodISOTime:()=>On,date:()=>jL,datetime:()=>UL,duration:()=>HL,time:()=>zL});function UL(e){return Ea($n,e)}function jL(e){return Pa(An,e)}function zL(e){return Ca(On,e)}function HL(e){return Ta(xn,e)}var lp=C(()=>{qt();In();In()});function BL(e,t){let r=e.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function Wk(e,t){return e.map((r,n)=>n<t?r:r.optional())}function WL(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function qL(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let r=e.slice(1).split("/").filter(Boolean);if(r.length===0)return t.rootSchema;let n=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===n){let s=r[1]===void 0?void 0:WL(r[1]);if(!s||!t.defs[s])throw new Error(`Reference not found: ${e}`);return t.defs[s]}throw new Error(`Reference not found: ${e}`)}function ZL(e,t){return V.transform(n=>n).check(n=>{let s=n.value;if(!(typeof s!="object"||s===null||Array.isArray(s)))for(let o of Object.getOwnPropertyNames(s)){let i=t.safeParse(o);i.success||n.issues.push({code:"invalid_key",origin:"record",issues:i.error.issues,input:o,path:[o],continue:!0})}}).pipe(e)}function qk(e,t){if(e!==!1)return e===void 0||e===!0?V.any():Dt(e,t)}function Zk(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return V.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let s=e.$ref;if(t.refs.has(s))return t.refs.get(s);if(t.processing.has(s))return V.lazy(()=>{if(!t.refs.has(s))throw new Error(`Circular reference not resolved: ${s}`);return t.refs.get(s)});t.processing.add(s);let o=qL(s,t),i=Dt(o,t);return t.refs.set(s,i),t.processing.delete(s),i}if(e.enum!==void 0){let s=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&s.length===1&&s[0]===null)return V.null();if(s.length===0)return V.never();if(s.length===1)return V.literal(s[0]);if(s.every(i=>typeof i=="string"))return V.enum(s);let o=s.map(i=>V.literal(i));return o.length<2?o[0]:V.union([o[0],o[1],...o.slice(2)])}if(e.const!==void 0)return V.literal(e.const);let r=e.type;if(Array.isArray(r)){let s=r.map(o=>{let i={...e,type:o};return Zk(i,t)});return s.length===0?V.never():s.length===1?s[0]:V.union(s)}if(!r)return V.any();let n;switch(r){case"string":{let s=V.string();if(e.format){let o=e.format;o==="email"?s=s.check(V.email()):o==="uri"||o==="uri-reference"?s=s.check(V.url()):o==="uuid"||o==="guid"?s=s.check(V.uuid()):o==="date-time"?s=s.check(V.iso.datetime({offset:!0})):o==="date"?s=s.check(V.iso.date()):o==="time"?s=s.check(V.regex(JL)):o==="duration"?s=s.check(V.iso.duration()):o==="hostname"?s=s.check(V.hostname()):o==="ipv4"?s=s.check(V.ipv4()):o==="ipv6"?s=s.check(V.ipv6()):o==="mac"?s=s.check(V.mac()):o==="cidr"?s=s.check(V.cidrv4()):o==="cidr-v6"?s=s.check(V.cidrv6()):o==="base64"?s=s.check(V.base64()):o==="base64url"?s=s.check(V.base64url()):o==="e164"?s=s.check(V.e164()):o==="credit_card"?s=s.check(V.creditCard()):o==="jwt"?s=s.check(V.jwt()):o==="emoji"?s=s.check(V.emoji()):o==="nanoid"?s=s.check(V.nanoid()):o==="cuid"?s=s.check(V.cuid()):o==="cuid2"?s=s.check(V.cuid2()):o==="ulid"?s=s.check(V.ulid()):o==="xid"?s=s.check(V.xid()):o==="ksuid"&&(s=s.check(V.ksuid()))}typeof e.minLength=="number"&&(s=s.min(e.minLength)),typeof e.maxLength=="number"&&(s=s.max(e.maxLength)),e.pattern&&(s=s.regex(new RegExp(e.pattern))),n=s;break}case"number":case"integer":{let s=r==="integer"?V.number().int():V.number();typeof e.minimum=="number"&&e.exclusiveMinimum!==!0&&(s=s.min(e.minimum)),typeof e.maximum=="number"&&e.exclusiveMaximum!==!0&&(s=s.max(e.maximum)),typeof e.exclusiveMinimum=="number"?s=s.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(s=s.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?s=s.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(s=s.lt(e.maximum)),typeof e.multipleOf=="number"&&(s=s.multipleOf(e.multipleOf)),n=s;break}case"boolean":{n=V.boolean();break}case"null":{n=V.null();break}case"object":{let s={},o=e.properties||{},i=new Set(e.required||[]),a=typeof e.additionalProperties=="object"?Dt(e.additionalProperties,t):void 0;for(let[c,l]of Object.entries(o)){let p=Dt(l,t);je(s,c,i.has(c)?p:p.optional())}if(e.patternProperties){let c=e.patternProperties,l=Object.keys(c),p=[];for(let m of l){let f=Dt(c[m],t),g=V.string().regex(new RegExp(m));p.push(V.looseRecord(g,f))}let d=[];if(Object.keys(s).length>0&&d.push(V.object(s).passthrough()),d.push(...p),d.length===0)n=V.object({}).passthrough();else if(d.length===1)n=d[0];else{let m=V.intersection(d[0],d[1]);for(let f=2;f<d.length;f++)m=V.intersection(m,d[f]);n=m}if(e.additionalProperties===!1){let m=Object.keys(s),f=l.map(h=>new RegExp(h)),g=n;n=n.check(h=>{if(!rr(h.value))return;let w=[];for(let v of Object.keys(h.value))m.includes(v)||f.some(R=>R.test(v))||w.push(v);w.length&&h.issues.push({code:"unrecognized_keys",keys:w,input:h.value,inst:g})})}}else{let c=V.object(s);e.additionalProperties===!1?n=c.strict():a?n=c.catchall(a):n=c.passthrough()}if(e.propertyNames!==void 0&&e.propertyNames!==!0){let c=typeof e.propertyNames=="object"&&e.propertyNames.type===void 0?{type:"string",...e.propertyNames}:e.propertyNames;n=ZL(n,Dt(c,t))}break}case"array":{let s=e.prefixItems,o=e.items;if(s&&Array.isArray(s)){let i=typeof e.minItems=="number"?e.minItems:0,a=s.map(d=>Dt(d,t)),c=Wk(a,i),l=Array.isArray(o)?void 0:qk(o,t),p=V.tuple(c);n=l?p.rest(l):p,typeof e.minItems=="number"&&(n=n.check(V.minLength(e.minItems))),typeof e.maxItems=="number"&&(n=n.check(V.maxLength(e.maxItems)))}else if(Array.isArray(o)){let i=typeof e.minItems=="number"?e.minItems:0,a=o.map(d=>Dt(d,t)),c=Wk(a,i),l=qk(e.additionalItems,t),p=V.tuple(c);n=l?p.rest(l):p,typeof e.minItems=="number"&&(n=n.check(V.minLength(e.minItems))),typeof e.maxItems=="number"&&(n=n.check(V.maxLength(e.maxItems)))}else if(o!==void 0){let i=Dt(o,t),a=V.array(i);typeof e.minItems=="number"&&(a=a.min(e.minItems)),typeof e.maxItems=="number"&&(a=a.max(e.maxItems)),n=a}else n=V.array(V.any());break}default:throw new Error(`Unsupported type: ${r}`)}return n}function Dt(e,t){if(typeof e=="boolean")return e?V.any():V.never();let r=Zk(e,t),n=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let a=e.anyOf.map(l=>Dt(l,t)),c=V.union(a);r=n?V.intersection(r,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let a=e.oneOf.map(l=>Dt(l,t)),c=V.xor(a);r=n?V.intersection(r,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=n?r:V.any();else{let a=n?r:Dt(e.allOf[0],t),c=n?0:1;for(let l=c;l<e.allOf.length;l++)a=V.intersection(a,Dt(e.allOf[l],t));r=a}e.nullable===!0&&t.version==="openapi-3.0"&&(r=V.nullable(r)),e.readOnly===!0&&(r=V.readonly(r)),e.default!==void 0&&(r=r.default(e.default));let s={},o=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let a of o)a in e&&(s[a]=e[a]);let i=["contentEncoding","contentMediaType","contentSchema"];for(let a of i)a in e&&(s[a]=e[a]);e.propertyNames!==void 0&&e.type==="object"&&e.$ref===void 0&&(s.propertyNames=e.propertyNames);for(let a of Object.keys(e))VL.has(a)||je(s,a,e[a]);return Object.keys(s).length>0&&t.registry.add(r,s),e.description&&(r=r.describe(e.description)),r}function Jk(e,t){if(typeof e=="boolean")return e?V.any():V.never();let r;try{r=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let n=BL(r,t?.defaultTarget),s=r.$defs||r.definitions||{},o={version:n,defs:s,refs:new Map,processing:new Set,rootSchema:r,registry:t?.registry??ct};return Dt(r,o)}var V,VL,JL,Kk=C(()=>{va();Je();Fl();lp();In();V={...Wo,...Ll,iso:Va},VL=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);JL=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/});function Ba(e,t){let r=typeof t=="function"?t:(i,a)=>{let c=t[i._zod.def.type];return c?c(i,a):i},n=new Map;function s(i){let a=n.get(i);if(a===Yk)return new wa({type:"lazy",getter:()=>n.get(i)});if(a!==void 0)return a;n.set(i,Yk);let c=o(i),l=r(c,c!==i);return n.set(i,l),l}function o(i){let a=i._zod.def,c=a.type;switch(c){case"object":{let l=a.shape,p=Object.keys(l),d=!1,m={};for(let g of p){let h=s(l[g]);h!==l[g]&&(d=!0),m[g]=h}let f=a.catchall;return a.catchall&&(f=s(a.catchall),f!==a.catchall&&(d=!0)),d?Pe(i,{...a,shape:m,catchall:f}):i}case"array":{let l=s(a.element);return l===a.element?i:Pe(i,{...a,element:l})}case"tuple":{let l=a.items,p=!1,d=[];for(let f of l){let g=s(f);g!==f&&(p=!0),d.push(g)}let m=a.rest;return a.rest&&(m=s(a.rest),m!==a.rest&&(p=!0)),p?Pe(i,{...a,items:d,rest:m}):i}case"record":case"map":{let l=s(a.keyType),p=s(a.valueType);return l===a.keyType&&p===a.valueType?i:Pe(i,{...a,keyType:l,valueType:p})}case"set":{let l=s(a.valueType);return l===a.valueType?i:Pe(i,{...a,valueType:l})}case"union":{let l=a.options,p=!1,d=[];for(let m of l){let f=s(m);f!==m&&(p=!0),d.push(f)}return p?Pe(i,{...a,options:d}):i}case"intersection":{let l=s(a.left),p=s(a.right);return l===a.left&&p===a.right?i:Pe(i,{...a,left:l,right:p})}case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":{let l=s(a.innerType);return l===a.innerType?i:Pe(i,{...a,innerType:l})}case"pipe":{let l=s(a.in),p=s(a.out);return l===a.in&&p===a.out?i:Pe(i,{...a,in:l,out:p})}case"function":{let l=s(a.input),p=s(a.output);return l===a.input&&p===a.output?i:Pe(i,{...a,input:l,output:p})}case"lazy":{let l=a.getter,{_cachedInner:p,...d}=a;return Pe(i,{...d,getter:()=>s(l())})}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":return i;default:return i}}return s(e)}var Yk,Hb=C(()=>{_a();Je();Yk=Symbol("z.visit/resolving")});function Qk(e){return Ba(e,{object:t=>t.partial(),union:t=>{let r=t._zod.def;return r.discriminator===void 0?t:Bo(r.options)}})}var Xk=C(()=>{Hb();In()});function KL(e,t){if(!t?.length)return e;let r=e._zod.def;return Pe(e,lr(r,{checks:[...r.checks??[],...t]}),{parent:!0})}function eE(e){return KL(e.out,e.checks)}function YL(e){return e.in._zod.traits.has("$ZodTransform")?eE(e):e.in}function tE(e){return Ba(e,{pipe:t=>YL(t._zod.def),default:(t,r)=>r?ys(t._zod.def.innerType):t,catch:(t,r)=>r?t._zod.def.innerType:t})}function rE(e){return Ba(e,{pipe:t=>eE(t._zod.def),prefault:(t,r)=>r?t._zod.def.innerType:t})}var nE=C(()=>{Je();Hb();In()});var Vb={};ne(Vb,{bigint:()=>tF,boolean:()=>eF,date:()=>rF,number:()=>XL,string:()=>QL});function QL(e){return mh(Uo,e)}function XL(e){return bh(zo,e)}function eF(e){return Eh(Ho,e)}function tF(e){return Ch(Vo,e)}function rF(e){return Gh(Fa,e)}var sE=C(()=>{qt();In()});var u={};ne(u,{$brand:()=>Am,$input:()=>ih,$output:()=>oh,NEVER:()=>$m,TimePrecision:()=>hh,ZodAny:()=>sb,ZodArray:()=>cb,ZodBase64:()=>ep,ZodBase64URL:()=>tp,ZodBigInt:()=>Vo,ZodBigIntFormat:()=>sp,ZodBoolean:()=>Ho,ZodCIDRv4:()=>Ql,ZodCIDRv6:()=>Xl,ZodCUID:()=>Bl,ZodCUID2:()=>Wl,ZodCatch:()=>$b,ZodCodec:()=>za,ZodCompileAsyncError:()=>pr,ZodCompileUnsupportedError:()=>ye,ZodCreditCard:()=>Yy,ZodCustom:()=>Ha,ZodCustomStringFormat:()=>jo,ZodDate:()=>Fa,ZodDefault:()=>vb,ZodDiscriminatedUnion:()=>lb,ZodE164:()=>rp,ZodEmail:()=>jl,ZodEmoji:()=>Hl,ZodEnum:()=>No,ZodError:()=>DL,ZodExactOptional:()=>cp,ZodFile:()=>wb,ZodFirstPartyTypeKind:()=>zb,ZodFunction:()=>Nb,ZodGUID:()=>zl,ZodIPv4:()=>Kl,ZodIPv6:()=>Yl,ZodISODate:()=>An,ZodISODateTime:()=>$n,ZodISODuration:()=>xn,ZodISOTime:()=>On,ZodIntersection:()=>pb,ZodIssueCode:()=>ML,ZodJWT:()=>np,ZodKSUID:()=>Jl,ZodLazy:()=>Fb,ZodLiteral:()=>bb,ZodMAC:()=>Ky,ZodMap:()=>hb,ZodNaN:()=>Ob,ZodNanoID:()=>Vl,ZodNever:()=>ib,ZodNonOptional:()=>up,ZodNull:()=>rb,ZodNullable:()=>Sb,ZodNumber:()=>zo,ZodNumberFormat:()=>ws,ZodObject:()=>Ga,ZodOptional:()=>Ua,ZodPipe:()=>ja,ZodPrefault:()=>Eb,ZodPreprocess:()=>xb,ZodPromise:()=>Gb,ZodReadonly:()=>Ib,ZodRealError:()=>It,ZodRecord:()=>Go,ZodSet:()=>yb,ZodString:()=>Uo,ZodStringFormat:()=>Oe,ZodSuccess:()=>Tb,ZodSymbol:()=>eb,ZodTemplateLiteral:()=>Lb,ZodTransform:()=>_b,ZodTuple:()=>mb,ZodType:()=>le,ZodULID:()=>ql,ZodURL:()=>La,ZodUUID:()=>Cr,ZodUndefined:()=>tb,ZodUnion:()=>Na,ZodUnknown:()=>ob,ZodVoid:()=>ab,ZodXID:()=>Zl,ZodXor:()=>ub,_ZodString:()=>Ul,_default:()=>kb,_function:()=>Fk,any:()=>mk,array:()=>Ma,base64:()=>Jv,base64url:()=>Kv,bigint:()=>ck,boolean:()=>Xy,catch:()=>Ab,check:()=>Mk,cidrv4:()=>qv,cidrv6:()=>Zv,clone:()=>Pe,codec:()=>xk,coerce:()=>Vb,compile:()=>lh,config:()=>ze,core:()=>Kr,creditCard:()=>Qv,cuid:()=>Nv,cuid2:()=>Uv,custom:()=>Gk,date:()=>gk,decode:()=>zy,decodeAsync:()=>Vy,deepPartial:()=>Qk,describe:()=>Nk,discriminatedUnion:()=>Rk,e164:()=>Yv,email:()=>$v,emoji:()=>Mv,encode:()=>jy,encodeAsync:()=>Hy,endsWith:()=>$o,enum:()=>ip,exactOptional:()=>Rb,file:()=>Tk,flattenError:()=>ua,float32:()=>sk,float64:()=>ok,formatError:()=>la,fromJSONSchema:()=>Jk,function:()=>Fk,getDiscriminatedOption:()=>Tg,getErrorMap:()=>NL,globalRegistry:()=>ct,gt:()=>Er,gte:()=>Wt,guid:()=>Av,hash:()=>nk,hex:()=>rk,hostname:()=>tk,httpUrl:()=>Fv,includes:()=>Co,input:()=>tE,instanceof:()=>jk,int:()=>Gl,int32:()=>ik,int64:()=>uk,intersection:()=>db,invertCodec:()=>Ik,ipv4:()=>Vv,ipv6:()=>Wv,iso:()=>Va,json:()=>Hk,jwt:()=>Xv,keyof:()=>hk,ksuid:()=>Hv,lazy:()=>Mb,length:()=>gs,literal:()=>Ck,locales:()=>Sa,looseObject:()=>wk,looseRecord:()=>vk,lowercase:()=>Eo,lt:()=>kr,lte:()=>Bt,mac:()=>Bv,map:()=>kk,maxLength:()=>fs,maxSize:()=>En,memoizer:()=>Ra,meta:()=>Uk,mime:()=>Ao,minLength:()=>Jr,minSize:()=>Pr,multipleOf:()=>kn,nan:()=>Ok,nanoid:()=>Gv,nativeEnum:()=>Pk,negative:()=>El,never:()=>op,nonnegative:()=>Cl,nonoptional:()=>Cb,nonpositive:()=>Pl,normalize:()=>Oo,null:()=>nb,nullable:()=>Da,nullish:()=>$k,number:()=>Qy,object:()=>yk,optional:()=>ys,output:()=>rE,overwrite:()=>dr,parse:()=>My,parseAsync:()=>Gy,partialRecord:()=>Sk,pipe:()=>Nl,positive:()=>kl,prefault:()=>Pb,preprocess:()=>Vk,prettifyError:()=>Lm,promise:()=>Lk,properties:()=>$l,property:()=>Tl,readonly:()=>Db,record:()=>gb,refine:()=>Ub,regex:()=>ko,regexes:()=>bt,registry:()=>tl,safeDecode:()=>Wy,safeDecodeAsync:()=>Zy,safeEncode:()=>By,safeEncodeAsync:()=>qy,safeParse:()=>Ny,safeParseAsync:()=>Uy,set:()=>Ek,setErrorMap:()=>GL,size:()=>ms,slugify:()=>Lo,startsWith:()=>To,strictObject:()=>bk,string:()=>Ia,stringFormat:()=>ek,stringbool:()=>zk,success:()=>Ak,superRefine:()=>jb,symbol:()=>pk,templateLiteral:()=>Dk,toJSONSchema:()=>Il,toLowerCase:()=>Io,toUpperCase:()=>Do,toZod:()=>ea,transform:()=>ap,treeifyError:()=>Dm,trim:()=>xo,tuple:()=>fb,uint32:()=>ak,uint64:()=>lk,ulid:()=>jv,undefined:()=>dk,union:()=>Bo,unknown:()=>hs,uppercase:()=>Po,url:()=>Lv,util:()=>Y,uuid:()=>Ov,uuidv4:()=>xv,uuidv6:()=>Iv,uuidv7:()=>Dv,validate:()=>Nm,validateAsync:()=>Um,void:()=>fk,xid:()=>zv,xor:()=>_k});var Bb=C(()=>{qt();In();Fl();Fy();Jy();Bk();qt();xa();Kk();Xk();nE();sh();lp();lp();sE()});var Wa=C(()=>{Bb();Bb()});var nF,qb,Zb,Jb,Kb,sF,oF,iF,aF,cF,uF,lF,pF,dF,mF,oE,fF,pp,gF,hF,yF,bF,wF,Wb,_F,RF,SF,vF,Yb,Qb,Lt,Dn=C(()=>{"use strict";Wa();nF=u.enum(["candidate","claimed","in_progress","pr_submitted"]),qb=u.enum(["needs_addressing","waiting_on_maintainer"]),Zb=u.enum(["nonprofit","devtools","infrastructure","web-frameworks","data-ml","education"]),Jb=u.enum(["beginner","intermediate","advanced"]),Kb=u.enum(["inline","sourcetree","vscode","custom"]),sF=u.object({hasActiveMaintainers:u.boolean(),isResponsive:u.boolean(),hasHostileComments:u.boolean()}),oF=u.object({repo:u.string(),score:u.number(),mergedPRCount:u.number(),closedWithoutMergeCount:u.number(),avgResponseDays:u.number().nullable(),lastMergedAt:u.string().optional(),lastEvaluatedAt:u.string(),signals:sF,stargazersCount:u.number().optional(),language:u.string().nullable().optional()}),iF=u.object({url:u.string(),title:u.string(),mergedAt:u.string(),openedAt:u.string().optional(),firstMaintainerResponseAt:u.string().optional(),commentsFetchedAt:u.string().datetime().optional(),learningsExtractedAt:u.string().datetime().optional()}),aF=u.object({url:u.string(),title:u.string(),closedAt:u.string(),openedAt:u.string().optional(),firstMaintainerResponseAt:u.string().optional(),commentsFetchedAt:u.string().datetime().optional(),learningsExtractedAt:u.string().datetime().optional()}),cF=u.object({url:u.string(),repo:u.string(),analyzedAt:u.string()}),uF=u.object({tier:u.enum(["light_check_in","direct_check_in","final_check_in"]),timestamp:u.string().datetime(),draftPath:u.string().optional()}),lF=u.object({workflowName:u.enum(["draft-first","work-through-issues","pre-commit-review"]),currentStep:u.string(),branchName:u.string().optional(),issueContext:u.object({title:u.string(),url:u.string()}).optional(),completedSteps:u.array(u.string()).default([]),stepData:u.record(u.string(),u.unknown()).default({}),lastUpdatedAt:u.string().datetime()}),pF=u.object({branchNamingConvention:u.string().optional(),commitMessageFormat:u.string().optional(),prTitleFormat:u.string().optional(),requiredChecks:u.array(u.string()).optional(),testFramework:u.string().optional(),testCoverageRequired:u.boolean().optional(),testFileNaming:u.string().optional(),linter:u.string().optional(),formatter:u.string().optional(),styleGuideUrl:u.string().optional(),issueClaimProcess:u.string().optional(),reviewProcess:u.string().optional(),claRequired:u.boolean().optional(),rawContent:u.string().optional()}),dF=u.object({passedAllChecks:u.boolean(),checks:u.object({noExistingPR:u.boolean(),notClaimed:u.boolean(),projectActive:u.boolean(),clearRequirements:u.boolean(),contributionGuidelinesFound:u.boolean()}),contributionGuidelines:pF.optional(),notes:u.array(u.string())}),mF=u.object({id:u.number(),url:u.string(),repo:u.string(),number:u.number(),title:u.string(),status:nF,labels:u.array(u.string()),createdAt:u.string(),updatedAt:u.string(),vetted:u.boolean(),vettingResult:dF.optional()}),oE=u.object({number:u.number(),url:u.string(),title:u.string(),repo:u.string(),daysSinceActivity:u.number(),status:qb}),fF=u.object({status:qb,setAt:u.string(),lastActivityAt:u.string()}),pp=u.object({setupComplete:u.boolean().default(!1),setupCompletedAt:u.string().optional(),persistence:u.enum(["local","gist"]).default("local"),maxActivePRs:u.number().default(10),dormantThresholdDays:u.number().default(30),approachingDormantDays:u.number().default(25),maxIssueAgeDays:u.number().default(90),skipBroadWhenSufficientResults:u.number().min(0).default(8),languages:u.array(u.string()).default(["typescript","javascript"]),labels:u.array(u.string()).default(["good first issue","help wanted"]),scope:u.array(Jb).optional(),excludeRepos:u.array(u.string()).default([]),excludeOrgs:u.array(u.string()).optional(),untrackedOrgs:u.array(u.string()).default([]),avoidRepos:u.array(u.string()).default([]),boostIssueTypes:u.array(u.string()).default([]),trustedProjects:u.array(u.string()).default([]),githubUsername:u.string().default(""),minRepoScoreThreshold:u.number().default(4),starredRepos:u.array(u.string()).default([]),starredReposLastFetched:u.string().optional(),squashByDefault:u.union([u.boolean(),u.literal("ask")]).default(!0),localRepoScanPaths:u.array(u.string()).optional(),minStars:u.number().default(50),includeDocIssues:u.boolean().default(!0),aiPolicyBlocklist:u.array(u.string()).default(["matplotlib/matplotlib"]),shelvedPRUrls:u.array(u.string()).default([]),dismissedIssues:u.record(u.string(),u.string()).default({}),statusOverrides:u.record(u.string(),fF).optional(),issueListPath:u.string().optional(),skippedIssuesPath:u.string().optional(),projectCategories:u.array(Zb).default([]),preferredOrgs:u.array(u.string()).default([]),diffTool:Kb.default("inline"),diffToolCustomCommand:u.string().optional(),autoExtractLearnings:u.boolean().default(!0),autoFormatBeforePush:u.boolean().default(!1),trustOwnRepoWrites:u.boolean().default(!1),healthCheckFreshnessMinutes:u.number().int().positive().default(30),reviewMaxPasses:u.number().int().positive().optional(),slmTriageModel:u.string().default(""),slmTriageHost:u.string().default("")}),gF=u.object({repos:u.record(u.string(),u.object({path:u.string(),exists:u.boolean(),currentBranch:u.string().nullable()})),scanPaths:u.array(u.string()),cachedAt:u.string()}),hF=u.object({url:u.string(),repo:u.string(),number:u.number(),title:u.string(),closedAt:u.string(),closedBy:u.string().optional(),openedAt:u.string().optional()}),yF=u.object({url:u.string(),repo:u.string(),number:u.number(),title:u.string(),mergedAt:u.string(),openedAt:u.string().optional()}),bF=u.object({totalActivePRs:u.number(),totalNeedingAttention:u.number(),totalMergedAllTime:u.number(),mergeRate:u.number()}),wF=u.object({url:u.string(),repo:u.string(),number:u.number(),status:qb}).passthrough(),Wb=u.array(wF),_F=u.object({generatedAt:u.string(),openPRs:Wb,needsAddressingPRs:Wb,waitingOnMaintainerPRs:Wb,recentlyClosedPRs:u.array(hF),recentlyMergedPRs:u.array(yF),shelvedPRs:u.array(oE),autoUnshelvedPRs:u.array(oE),summary:bF}),RF=u.object({url:u.string(),lastSeenAt:u.string()}),SF=u.object({url:u.string(),branch:u.string(),worktree:u.string().optional(),note:u.string().optional(),recordedAt:u.string(),pushedRef:u.string().optional(),pushedAt:u.string().optional(),compareUrl:u.string().optional(),pushProblem:u.string().optional()}),vF=u.object({url:u.string(),attemptedAt:u.string(),outcome:u.enum(["prepared","blocked"]),note:u.string().optional()}),Yb=u.object({runAt:u.string(),reportPath:u.string(),prepareCount:u.number().int().nonnegative(),judgmentCount:u.number().int().nonnegative(),prepared:u.array(SF).default([]),implementUrl:u.string().optional(),implementAttempts:u.array(vF).optional()}),Qb=u.object({languageOffset:u.number().int().nonnegative().default(0),phase0Offset:u.number().int().nonnegative().default(0),starredOffset:u.number().int().nonnegative().default(0),maintainedOffset:u.number().int().nonnegative().default(0),strategyOffset:u.number().int().nonnegative().default(0),lastRotatedAt:u.string().optional()}),Lt=u.object({version:u.literal(4),gistId:u.string().optional(),repoScores:u.record(u.string(),oF).default({}),config:pp.default(()=>pp.parse({})),lastRunAt:u.string().default(()=>new Date().toISOString()),lastDigestAt:u.string().optional(),lastStrategyAt:u.string().optional(),lastDigest:_F.optional(),monthlyMergedCounts:u.record(u.string(),u.number()).optional(),monthlyClosedCounts:u.record(u.string(),u.number()).optional(),monthlyOpenedCounts:u.record(u.string(),u.number()).optional(),localRepoCache:gF.optional(),mergedPRs:u.array(iF).optional(),closedPRs:u.array(aF).optional(),analyzedIssueConversations:u.array(cF).optional(),activeIssues:u.array(mF).default([]),prFollowUpHistory:u.record(u.string(),u.array(uF)).optional(),workflowState:lF.optional(),searchSeen:u.array(RF).default([]),lastOvernight:Yb.optional(),searchRotation:Qb.optional()})});function sr(){let e=Ft.join(Xb.homedir(),".oss-autopilot");return Rt.existsSync(e)||Rt.mkdirSync(e,{recursive:!0,mode:448}),e}function St(){return Ft.join(sr(),"state.json")}function iE(){return Ft.join(process.cwd(),"data","state.json")}function aE(){return Ft.join(process.cwd(),"data","backups")}function _s(){let e=Ft.join(sr(),"backups");return Rt.existsSync(e)||Rt.mkdirSync(e,{recursive:!0,mode:448}),e}function dp(){let e=Ft.join(sr(),"cache");return Rt.existsSync(e)||Rt.mkdirSync(e,{recursive:!0,mode:448}),e}function qo(){let e=Ft.join(sr(),"reports");return Rt.existsSync(e)||Rt.mkdirSync(e,{recursive:!0,mode:448}),e}function Rs(){return Ft.join(sr(),"gist-id")}function Ln(){return Ft.join(sr(),"state-cache.json")}function mp(){let e=Ft.join(Xb.homedir(),".oss-autopilot","state.json");return Rt.existsSync(e)}function Tr(){return"3.30.0"}var Rt,Ft,Xb,Yr=C(()=>{"use strict";Rt=H(require("node:fs"),1),Ft=H(require("node:path"),1),Xb=H(require("node:os"),1)});function gp(){fp=!0}function cE(){return fp}function I(e,t,...r){if(!fp)return;let n=new Date().toISOString();console.error(`[${n}] [DEBUG] [${e}] ${t}`,...r)}function uE(e,t,...r){let n=new Date().toISOString();console.error(`[${n}] [INFO] [${e}] ${t}`,...r)}function _(e,t,...r){let n=new Date().toISOString();console.error(`[${n}] [WARN] [${e}] ${t}`,...r)}async function hp(e,t,r){if(!fp)return r();let n=performance.now();try{let s=await r(),o=(performance.now()-n).toFixed(0);return I(e,`${t} completed in ${o}ms`),s}catch(s){let o=(performance.now()-n).toFixed(0);throw I(e,`${t} failed after ${o}ms`),s}}var fp,de=C(()=>{"use strict";fp=!1});function Za(e){if(process.env[yp]!==void 0)throw new Ge(`Refusing to ${e} during an unattended run (${yp} is set). Run it yourself in an interactive session.`)}function A(e){return e instanceof Error?e.message:String(e)}function Ye(e){if(e&&typeof e=="object"&&"status"in e){let t=e.status;return typeof t=="number"&&Number.isFinite(t)?t:void 0}}function Mt(e){let t=Ye(e);return t===429?!0:t===403?A(e).toLowerCase().includes("rate limit"):!1}function lE(e){if(Ye(e)!==422)return!1;let t=e?.response?.data,r=t&&typeof t=="object"?t.errors:void 0;return Array.isArray(r)?r.some(n=>{if(!n||typeof n!="object")return!1;let s=n;return s.resource!=="Search"||s.code!=="invalid"?!1:typeof s.message=="string"?ew.test(s.message):ew.test(A(e))}):ew.test(A(e))}function Le(e){let t=Ye(e);if(t===401||t===429)return!0;if(t===403){let r=A(e).toLowerCase();return r.includes("rate limit")||r.includes("abuse detection")}return!1}function pE(e){if(!e||typeof e!="object")return!1;let t=Ye(e);if(typeof t=="number"&&t>=500&&t<600)return!0;let r=e.code;if(typeof r=="string"&&(r==="ECONNRESET"||r==="ETIMEDOUT"||r==="ENETUNREACH"||r==="ENOTFOUND"||r==="ECONNREFUSED"||r==="EAI_AGAIN"))return!0;let n=e.name;return typeof n=="string"&&(n==="AbortError"||n==="TimeoutError")}function dE(e){return t=>{if(Le(t))throw t;return _(e.module,`Failed to ${e.label}: ${A(t)}`),e.fallback}}function bp(e){if(e instanceof Ge)return"CONFIGURATION";if(e instanceof W)return"VALIDATION";if(e instanceof mr||e instanceof $r)return"CONCURRENCY";let t=Ye(e);if(t===401)return"AUTH_REQUIRED";if(t===403){let n=A(e).toLowerCase();return n.includes("rate limit")||n.includes("abuse detection")?"RATE_LIMITED":"AUTH_REQUIRED"}if(t===404)return"NOT_FOUND";if(t===429)return"RATE_LIMITED";let r=A(e).toLowerCase();return r.includes("enotfound")||r.includes("econnrefused")||r.includes("econnreset")||r.includes("etimedout")||r.includes("fetch failed")?"NETWORK":r.includes("state")&&(r.includes("corrupt")||r.includes("invalid"))?"STATE_CORRUPTED":"UNKNOWN"}var or,Ge,yp,W,Zo,qa,mr,$r,ew,ie=C(()=>{"use strict";de();or=class extends Error{constructor(r,n){super(r);this.code=n;this.name="OssAutopilotError"}code},Ge=class extends or{constructor(t){super(t,"CONFIGURATION_ERROR"),this.name="ConfigurationError"}},yp="OSS_AUTOPILOT_UNATTENDED";W=class extends or{constructor(t){super(t,"VALIDATION_ERROR"),this.name="ValidationError"}},Zo=class extends Ge{constructor(t){super(t??'Your GitHub token does not have Gist permissions. Run `gh auth refresh -s gist` to add the required scope, or create a token with the "gist" scope.'),this.name="GistPermissionError"}},qa=class extends Ge{constructor(r,n,s){let o=s instanceof Error?s.message:String(s),i=n?`
58
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let a=i[1];if(t===i[0]){o(i);continue}if(e.external){let l=e.external.registry.get(i[0])?.id;if(t!==i[0]&&l){o(i);continue}}if(e.metadataRegistry.get(i[0])?.id){o(i);continue}if(a.cycle){o(i);continue}if(a.count>1&&e.reused==="ref"){o(i);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function Rv(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let n of t){if(!n||typeof n!="object")return;Rv(n);let s=Object.keys(n);if(s.length!==1||s[0]!=="type")return;let o=n.type;for(let i of Array.isArray(o)?o:[o]){if(typeof i!="string")return;r.includes(i)||r.push(i)}}delete e.anyOf,e.type=r.length===1?r[0]:r}function _v(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function Zh(e){let t=[];for(let o of e){if(typeof o!="object"||o.type!=="object")return null;for(let i in o)if(!Sv.has(i))return null;t.push(o)}let r={},n=new Set;for(let o of t){for(let i in o.properties){if(Object.prototype.hasOwnProperty.call(r,i))continue;let a=[];for(let l of t){let p=l.properties?.[i]??_v(l);p!=null&&(a.some(d=>JSON.stringify(d)===JSON.stringify(p))||a.push(p))}let c=a.length===1?a[0]:Zh(a)??{allOf:a};je(r,i,c)}for(let i of o.required??[])n.add(i)}let s={type:"object",properties:r};if(n.size&&(s.required=[...n]),t.every(o=>o.additionalProperties===!1))s.additionalProperties=!1;else{let o=[];for(let i of t){let a=_v(i);a&&!o.some(c=>JSON.stringify(c)===JSON.stringify(a))&&o.push(a)}o.length===1?s.additionalProperties=o[0]:o.length>1&&(s.additionalProperties={allOf:o})}return s}function AL(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let s of Sv)if(s in e)return;let r=t.filter(s=>wv.some(o=>Array.isArray(s[o]))),n=null;if(!r.length)n=Zh(t);else{let s=r[0],o=wv.find(c=>Array.isArray(s[c]));if(Object.keys(s).length!==1)return;let i=t.filter(c=>c!==s),a=s[o].map(c=>Zh([...i,c]));if(a.some(c=>!c))return;n={[o]:a}}n&&(delete e.allOf,$a(e,n))}function Tn(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=a=>{let c=e.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,p={...l},d=c.ref;if(c.ref=null,d){n(d);let f=e.seen.get(d),g=f.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(l.allOf=l.allOf??[],l.allOf.push(g)):$a(l,g),$a(l,p),a._zod.parent===d)for(let w in l)w==="$ref"||w==="allOf"||w in p||delete l[w];if(g.$ref&&f.def)for(let w in l)w==="$ref"||w==="allOf"||w in f.def&&JSON.stringify(l[w])===JSON.stringify(f.def[w])&&delete l[w]}let m=a._zod.parent;if(m&&m!==d){n(m);let f=e.seen.get(m);if(f?.schema.$ref&&(l.$ref=f.schema.$ref,f.def))for(let g in l)g==="$ref"||g==="allOf"||g in f.def&&JSON.stringify(l[g])===JSON.stringify(f.def[g])&&delete l[g]}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())n(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())Rv(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let l of[c.schema,c.def]){let p=l?.allOf;if(!Array.isArray(p))continue;let d=a.get(p);d?d.push(l):a.set(p,[l])}for(let c of e.intersections)for(let l of a.get(c)??[])AL(l)}}let s={};if(e.target==="draft-2020-12"?s.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?s.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?s.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");s.$id=e.external.uri(a)}$a(s,r.defId?r.schema:r.def??r.schema);let o=e.metadataRegistry.get(t)?.id;o!==void 0&&s.id===o&&delete s.id;let i=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,je(i,c.defId,c.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?s.$defs=i:s.definitions=i);try{let a=JSON.parse(JSON.stringify(s));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Mo(t,"input",e.processors),output:Mo(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function _t(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return _t(n.element,r);if(n.type==="set")return _t(n.valueType,r);if(n.type==="lazy")return _t(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault"||n.type==="catch")return _t(n.innerType,r);if(n.type==="intersection")return _t(n.left,r)||_t(n.right,r);if(n.type==="record"||n.type==="map")return _t(n.keyType,r)||_t(n.valueType,r);if(n.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:_t(n.in,r)||_t(n.out,r);if(n.type==="object"){for(let s in n.shape)if(_t(n.shape[s],r))return!0;return!1}if(n.type==="union"){for(let s of n.options)if(_t(s,r))return!0;return!1}if(n.type==="tuple"){for(let s of n.items)if(_t(s,r))return!0;return!!(n.rest&&_t(n.rest,r))}return!1}var Sv,wv,Jh,Mo,Aa=C(()=>{va();Je();Sv=new Set(["type","properties","required","additionalProperties"]),wv=["oneOf","anyOf"];Jh=(e,t={})=>r=>{let n=Pn({...r,processors:t});return Ce(e,n),Cn(n,e),Tn(n,e)},Mo=(e,t,r={})=>n=>{let{libraryOptions:s,target:o}=n??{},i=Pn({...s??{},target:o,io:t,processors:r});return Ce(e,i),Cn(i,e),Tn(i,e)}});function Oa(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?Oa(t.out):t.type==="catch"?Oa(t.innerType):e._zod.optin}function Kh(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let g=e.get(t)?.def;if(!g)return t;let h=Kh(e,g,r);return h===g?t:h}for(let g of["anyOf","oneOf"]){let h=t[g];if(!Array.isArray(h))continue;let w=h.map(v=>Kh(e,v,r));w.some((v,R)=>v!==h[R])&&(t={...t,[g]:w})}let n=Array.isArray(t.type)?t.type:[t.type],s=!n.includes("string")&&n.some(g=>g==="number"||g==="integer"),o=t.enum??(t.const!==void 0?[t.const]:void 0);if(!s&&!o?.some(g=>typeof g=="number"))return t;let{minimum:i,maximum:a,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:p,format:d,id:m,...f}=t;return f.enum?f.enum=f.enum.map(g=>typeof g=="number"?String(g):g):typeof f.const=="number"&&(f.const=String(f.const)),s&&(f.type="string",o||(f.pattern=(n.includes("number")?vn:pa).source)),f}function xL(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let r=new Map;for(let n of Yh.get(e)??[]){let s=e.seen.get(n),o=(s?.def??s?.schema)?.propertyNames;if(!o||o===!0||r.has(o))continue;let i=Kh(t,o,new Set);i!==o&&r.set(o,i)}if(r.size)for(let n of e.seen.values())for(let s of[n.schema,n.def]){let o=s&&r.get(s.propertyNames);o&&(s.propertyNames=o)}}function vv(e,t,r,n,s){let o=!1,i=JSON.stringify(e,(a,c)=>typeof c!="bigint"?c:(o=!0,null));return o?(Ke(t,r,n,s,"BigInt defaults cannot be represented in JSON Schema"),Ty):JSON.parse(i)}function Il(e,t){if("_idmap"in e){let n=e,s=Pn({...t,processors:Al}),o={};for(let c of n._idmap.entries()){let[l,p]=c;Ce(p,s)}let i={},a={registry:n,uri:t?.uri,defs:o};s.external=a;for(let c of n._idmap.entries()){let[l,p]=c;Cn(s,p),je(i,l,Tn(s,p))}if(Object.keys(o).length>0){let c=s.target==="draft-2020-12"?"$defs":"definitions";i.__shared={[c]:o}}return{schemas:i}}let r=Pn({...t,processors:Al});return Ce(e,r),Cn(r,e),Tn(r,e)}var OL,Qh,Xh,ey,ty,ry,ny,sy,oy,iy,ay,cy,uy,ly,py,dy,my,fy,gy,hy,yy,by,wy,_y,Ry,Sy,Ol,vy,ky,Yh,Ey,Py,Cy,Ty,$y,Ay,Oy,xy,Iy,Dy,xl,Ly,Al,xa=C(()=>{Ro();Aa();Je();OL={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Qh=(e,t,r,n)=>{let s=r;s.type="string";let{minimum:o,maximum:i,format:a,patterns:c,contentEncoding:l,laxFormat:p}=e._zod.bag;if(typeof o=="number"&&(s.minLength=o),typeof i=="number"&&(s.maxLength=i),a&&(s.format=OL[a]??a,s.format===""&&delete s.format,(a==="time"||p)&&delete s.format),l&&(s.contentEncoding=l),c&&c.size>0){let d=[...c];d.length===1?s.pattern=d[0].source:d.length>1&&(s.allOf=[...d.map(m=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},Xh=(e,t,r,n)=>{let s=r,{minimum:o,maximum:i,format:a,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:p}=e._zod.bag;typeof a=="string"&&a.includes("int")?s.type="integer":s.type="number";let d=typeof p=="number"&&p>=(o??Number.NEGATIVE_INFINITY),m=typeof l=="number"&&l<=(i??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";d?f?(s.minimum=p,s.exclusiveMinimum=!0):s.exclusiveMinimum=p:typeof o=="number"&&(s.minimum=o),m?f?(s.maximum=l,s.exclusiveMaximum=!0):s.exclusiveMaximum=l:typeof i=="number"&&(s.maximum=i),typeof c=="number"&&(Number.isFinite(c)&&c!==0?s.multipleOf=Math.abs(c):Ke(e,t,s,n,`A multipleOf divisor of ${c} cannot be represented in JSON Schema`))},ey=(e,t,r,n)=>{r.type="boolean"},ty=(e,t,r,n)=>{Ke(e,t,r,n,"BigInt cannot be represented in JSON Schema")},ry=(e,t,r,n)=>{Ke(e,t,r,n,"Symbols cannot be represented in JSON Schema")},ny=(e,t,r,n)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},sy=(e,t,r,n)=>{Ke(e,t,r,n,"Undefined cannot be represented in JSON Schema")},oy=(e,t,r,n)=>{Ke(e,t,r,n,"Void cannot be represented in JSON Schema")},iy=(e,t,r,n)=>{r.not={}},ay=(e,t,r,n)=>{},cy=(e,t,r,n)=>{},uy=(e,t,r,n)=>{Ke(e,t,r,n,"Date cannot be represented in JSON Schema")},ly=(e,t,r,n)=>{let s=e._zod.def,o=ta(s.entries);if(o.length===0){r.not={};return}o.every(i=>typeof i=="number")&&(r.type="number"),o.every(i=>typeof i=="string")&&(r.type="string"),r.enum=o},py=(e,t,r,n)=>{let s=e._zod.def;if(s.values.length===0){r.not={};return}let o=[];for(let i of s.values)if(i===void 0){if(Ke(e,t,r,n,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i=="bigint"){if(Ke(e,t,r,n,"BigInt literals cannot be represented in JSON Schema"))return;o.push(Number(i))}else o.push(i);if(o.length!==0)if(o.length===1){let i=o[0];r.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[i]:r.const=i}else o.every(i=>typeof i=="number")&&(r.type="number"),o.every(i=>typeof i=="string")&&(r.type="string"),o.every(i=>typeof i=="boolean")&&(r.type="boolean"),o.every(i=>i===null)&&(r.type="null"),r.enum=o},dy=(e,t,r,n)=>{Ke(e,t,r,n,"NaN cannot be represented in JSON Schema")},my=(e,t,r,n)=>{let s=r,o=e._zod.pattern;if(!o)throw new Error("Pattern not found in template literal");s.type="string",s.pattern=o.source},fy=(e,t,r,n)=>{let s=r,o={type:"string",format:"binary",contentEncoding:"binary"},{minimum:i,maximum:a,mime:c}=e._zod.bag;i!==void 0&&(o.minLength=i),a!==void 0&&(o.maxLength=a),c?c.length===1?(o.contentMediaType=c[0],Object.assign(s,o)):(Object.assign(s,o),s.anyOf=c.map(l=>({contentMediaType:l}))):Object.assign(s,o)},gy=(e,t,r,n)=>{r.type="boolean"},hy=(e,t,r,n)=>{Ke(e,t,r,n,"Custom types cannot be represented in JSON Schema")},yy=(e,t,r,n)=>{Ke(e,t,r,n,"Function types cannot be represented in JSON Schema")},by=(e,t,r,n)=>{Ke(e,t,r,n,"Transforms cannot be represented in JSON Schema")},wy=(e,t,r,n)=>{Ke(e,t,r,n,"Map cannot be represented in JSON Schema")},_y=(e,t,r,n)=>{Ke(e,t,r,n,"Set cannot be represented in JSON Schema")},Ry=(e,t,r,n)=>{let s=r,o=e._zod.def,{minimum:i,maximum:a}=e._zod.bag;typeof i=="number"&&(s.minItems=i),typeof a=="number"&&(s.maxItems=a),s.type="array",s.items=Ce(o.element,t,{...n,path:[...n.path,"items"]})};Sy=(e,t,r,n)=>{let s=r,o=e._zod.def,i=o.shape;if(Object.getOwnPropertySymbols(i).length&&Ke(e,t,s,n,"Symbol keys cannot be represented in JSON Schema"))return;s.type="object",s.properties={};for(let p in i)je(s.properties,p,Ce(i[p],t,{...n,path:[...n.path,"properties",p]}));let c=new Set(Object.keys(i)),l=new Set([...c].filter(p=>{let d=o.shape[p];return t.io==="input"?Oa(d)===void 0:d._zod.optout===void 0}));l.size>0&&(s.required=Array.from(l)),o.catchall?._zod.def.type==="never"?s.additionalProperties=!1:o.catchall?o.catchall&&(s.additionalProperties=Ce(o.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(s.additionalProperties=!1)},Ol=(e,t,r,n)=>{let s=e._zod.def,o=s.inclusive===!1,i=s.options.map((a,c)=>Ce(a,t,{...n,path:[...n.path,o?"oneOf":"anyOf",c]}));o?r.oneOf=i:r.anyOf=i},vy=(e,t,r,n)=>{let s=e._zod.def,o=Ce(s.left,t,{...n,path:[...n.path,"allOf",0]}),i=Ce(s.right,t,{...n,path:[...n.path,"allOf",1]}),a=l=>"allOf"in l&&Object.keys(l).length===1,c=[...a(o)?o.allOf:[o],...a(i)?i.allOf:[i]];r.allOf=c,t.intersections.push(c)},ky=(e,t,r,n)=>{let s=r,o=e._zod.def;s.type="array";let i=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=o.items.map((h,w)=>Ce(h,t,{...n,path:[...n.path,i,w]})),l=o.rest?Ce(o.rest,t,{...n,path:[...n.path,a,...t.target==="openapi-3.0"?[o.items.length]:[]]}):null,p=o.items.length;for(;p>0;){let h=o.items[p-1];if(!(t.io==="input"?Oa(h)!==void 0:h._zod.optout==="optional"))break;p--}let d=o.items.length,m=!o.rest;t.target==="draft-2020-12"?(s.prefixItems=c,m?s.items=!1:l&&(s.items=l),p>0&&(s.minItems=p),m&&(s.maxItems=d)):t.target==="openapi-3.0"?(s.items={anyOf:c},l&&s.items.anyOf.push(l),p>0&&(s.minItems=p),m&&(s.maxItems=d)):(s.items=c,m?s.additionalItems=!1:l&&(s.additionalItems=l),p>0&&(s.minItems=p),m&&(s.maxItems=d));let{minimum:f,maximum:g}=e._zod.bag;typeof f=="number"&&(s.minItems=f),typeof g=="number"&&(s.maxItems=g)};Yh=new WeakMap;Ey=(e,t,r,n)=>{let s=r,o=e._zod.def;s.type="object";let i=o.keyType,c=i._zod.bag?.patterns;if(o.mode==="loose"&&c&&c.size>0){let d=Ce(o.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});s.patternProperties={};for(let m of c)je(s.patternProperties,m.source,d)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){s.propertyNames=Ce(o.keyType,t,{...n,path:[...n.path,"propertyNames"]});let d=Yh.get(t);d||(d=[],Yh.set(t,d),t.deferred.push(()=>xL(t))),d.push(e)}s.additionalProperties=Ce(o.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let l=i._zod.values,p=t.io==="input"&&Oa(o.valueType)!==void 0;if(l&&!o.partial&&!p){let d=[...l].filter(m=>typeof m=="string"||typeof m=="number");d.length>0&&(s.required=d.map(String))}},Py=(e,t,r,n)=>{let s=e._zod.def,o=Ce(s.innerType,t,n),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=s.innerType,r.nullable=!0):r.anyOf=[o,{type:"null"}]},Cy=(e,t,r,n)=>{let s=e._zod.def;Ce(s.innerType,t,n);let o=t.seen.get(e);o.ref=s.innerType},Ty=Symbol();$y=(e,t,r,n)=>{let s=e._zod.def;Ce(s.innerType,t,n);let o=t.seen.get(e);o.ref=s.innerType;let i=vv(s.defaultValue,e,t,r,n);i!==Ty&&(r.default=i)},Ay=(e,t,r,n)=>{let s=e._zod.def;Ce(s.innerType,t,n);let o=t.seen.get(e);if(o.ref=s.innerType,t.io!=="input")return;let i=vv(s.defaultValue,e,t,r,n);i!==Ty&&(r._prefault=i)},Oy=(e,t,r,n)=>{let s=e._zod.def;Ce(s.innerType,t,n);let o=t.seen.get(e);o.ref=s.innerType;let i;try{i=s.catchValue(void 0)}catch{Ke(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=i},xy=(e,t,r,n)=>{let s=e._zod.def,o=s.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?o?s.out:s.in:s.out;Ce(i,t,n);let a=t.seen.get(e);a.ref=i},Iy=(e,t,r,n)=>{let s=e._zod.def;Ce(s.innerType,t,n);let o=t.seen.get(e);o.ref=s.innerType,r.readOnly=!0},Dy=(e,t,r,n)=>{let s=e._zod.def;Ce(s.innerType,t,n);let o=t.seen.get(e);o.ref=s.innerType},xl=(e,t,r,n)=>{let s=e._zod.def;Ce(s.innerType,t,n);let o=t.seen.get(e);o.ref=s.innerType},Ly=(e,t,r,n)=>{let s=e._zod.innerType;Ce(s,t,n);let o=t.seen.get(e);o.ref=s},Al={string:Qh,number:Xh,boolean:ey,bigint:ty,symbol:ry,null:ny,undefined:sy,void:oy,never:iy,any:ay,unknown:cy,date:uy,enum:ly,literal:py,nan:dy,template_literal:my,file:fy,success:gy,custom:hy,function:yy,transform:by,map:wy,set:_y,array:Ry,object:Sy,union:Ol,intersection:vy,tuple:ky,record:Ey,nullable:Py,nonoptional:Cy,default:$y,prefault:Ay,catch:Oy,pipe:xy,readonly:Iy,promise:Dy,optional:xl,lazy:Ly}});var Dl,kv=C(()=>{xa();Aa();Dl=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let r=t?.target??"draft-2020-12";r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),this.ctx=Pn({processors:Al,target:r,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,r={path:[],schemaPath:[]}){return Ce(t,this.ctx,r)}emit(t,r){r&&(r.cycles&&(this.ctx.cycles=r.cycles),r.reused&&(this.ctx.reused=r.reused),r.external&&(this.ctx.external=r.external)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,Cn(this.ctx,t);let n=Tn(this.ctx,t),{"~standard":s,...o}=n;return o}}});var Ev={};var Pv=C(()=>{});var Kr={};ne(Kr,{$ZodAny:()=>_g,$ZodArray:()=>Eg,$ZodAsyncError:()=>Ot,$ZodBase64:()=>ug,$ZodBase64URL:()=>lg,$ZodBigInt:()=>Bu,$ZodBigIntFormat:()=>hg,$ZodBoolean:()=>ha,$ZodCIDRv4:()=>ag,$ZodCIDRv6:()=>cg,$ZodCUID:()=>Jf,$ZodCUID2:()=>Kf,$ZodCatch:()=>Vg,$ZodCheck:()=>xe,$ZodCheckBigIntFormat:()=>vf,$ZodCheckEndsWith:()=>Lf,$ZodCheckGreaterThan:()=>Cu,$ZodCheckIncludes:()=>If,$ZodCheckLengthEquals:()=>$f,$ZodCheckLessThan:()=>Pu,$ZodCheckLowerCase:()=>Of,$ZodCheckMaxLength:()=>Cf,$ZodCheckMaxSize:()=>kf,$ZodCheckMimeType:()=>Ff,$ZodCheckMinLength:()=>Tf,$ZodCheckMinSize:()=>Ef,$ZodCheckMultipleOf:()=>Rf,$ZodCheckNumberFormat:()=>Sf,$ZodCheckOverwrite:()=>Mf,$ZodCheckProperty:()=>Tu,$ZodCheckRegex:()=>Af,$ZodCheckSizeEquals:()=>Pf,$ZodCheckStartsWith:()=>Df,$ZodCheckStringFormat:()=>So,$ZodCheckUpperCase:()=>xf,$ZodCodec:()=>ba,$ZodCreditCard:()=>dg,$ZodCustom:()=>Yg,$ZodCustomStringFormat:()=>fg,$ZodCyclicError:()=>Yu,$ZodDate:()=>kg,$ZodDefault:()=>Ug,$ZodDiscriminatedUnion:()=>$g,$ZodE164:()=>pg,$ZodEmail:()=>Hf,$ZodEmoji:()=>qf,$ZodEncodeError:()=>Sn,$ZodEnum:()=>Dg,$ZodError:()=>ca,$ZodExactOptional:()=>Gg,$ZodFile:()=>Fg,$ZodFunction:()=>Jg,$ZodGUID:()=>jf,$ZodIPv4:()=>sg,$ZodIPv6:()=>og,$ZodISODate:()=>tg,$ZodISODateTime:()=>eg,$ZodISODuration:()=>ng,$ZodISOTime:()=>rg,$ZodIntersection:()=>Ag,$ZodJWT:()=>mg,$ZodKSUID:()=>Xf,$ZodLazy:()=>wa,$ZodLiteral:()=>Lg,$ZodMAC:()=>ig,$ZodMap:()=>xg,$ZodNaN:()=>Bg,$ZodNanoID:()=>Zf,$ZodNever:()=>Sg,$ZodNonOptional:()=>zg,$ZodNull:()=>wg,$ZodNullable:()=>Ng,$ZodNumber:()=>Vu,$ZodNumberFormat:()=>gg,$ZodObject:()=>sv,$ZodObjectJIT:()=>Pg,$ZodOptional:()=>qu,$ZodPipe:()=>Zu,$ZodPrefault:()=>jg,$ZodPreprocess:()=>Wg,$ZodPromise:()=>Kg,$ZodReadonly:()=>qg,$ZodRealError:()=>xt,$ZodRecord:()=>Og,$ZodRegistry:()=>el,$ZodSet:()=>Ig,$ZodString:()=>cs,$ZodStringFormat:()=>$e,$ZodSuccess:()=>Hg,$ZodSymbol:()=>yg,$ZodTemplateLiteral:()=>Zg,$ZodTransform:()=>Mg,$ZodTuple:()=>Wu,$ZodType:()=>oe,$ZodULID:()=>Yf,$ZodURL:()=>Wf,$ZodUUID:()=>zf,$ZodUndefined:()=>bg,$ZodUnion:()=>ya,$ZodUnknown:()=>Rg,$ZodVoid:()=>vg,$ZodXID:()=>Qf,$ZodXor:()=>Cg,$brand:()=>Am,$constructor:()=>T,$input:()=>ih,$output:()=>oh,Doc:()=>as,INVALID:()=>Vt,JSONSchema:()=>Ev,JSONSchemaGenerator:()=>Dl,NEVER:()=>$m,TimePrecision:()=>hh,URL_BAD_FORMAT:()=>Vf,URL_UNPARSEABLE:()=>Bf,ZodCompileAsyncError:()=>pr,ZodCompileUnsupportedError:()=>ye,_any:()=>Ih,_array:()=>Uh,_base64:()=>_l,_base64url:()=>Rl,_bigint:()=>Ph,_boolean:()=>kh,_catch:()=>kL,_check:()=>hv,_cidrv4:()=>bl,_cidrv6:()=>wl,_coercedBigint:()=>Ch,_coercedBoolean:()=>Eh,_coercedDate:()=>Gh,_coercedNumber:()=>bh,_coercedString:()=>mh,_creditCard:()=>gh,_cuid:()=>pl,_cuid2:()=>dl,_custom:()=>zh,_date:()=>Mh,_decode:()=>hu,_decodeAsync:()=>bu,_default:()=>RL,_discriminatedUnion:()=>uL,_e164:()=>Sl,_email:()=>nl,_emoji:()=>ul,_encode:()=>gu,_encodeAsync:()=>yu,_endsWith:()=>$o,_enum:()=>gL,_file:()=>jh,_float32:()=>_h,_float64:()=>Rh,_gt:()=>Er,_gte:()=>Wt,_guid:()=>sl,_includes:()=>Co,_int:()=>wh,_int32:()=>Sh,_int64:()=>Th,_intersection:()=>lL,_ipv4:()=>hl,_ipv6:()=>yl,_isoDate:()=>Pa,_isoDateTime:()=>Ea,_isoDuration:()=>Ta,_isoTime:()=>Ca,_jwt:()=>vl,_ksuid:()=>gl,_lazy:()=>TL,_length:()=>gs,_literal:()=>yL,_lowercase:()=>Eo,_lt:()=>kr,_lte:()=>Bt,_mac:()=>fh,_map:()=>mL,_max:()=>Bt,_maxLength:()=>fs,_maxSize:()=>En,_mime:()=>Ao,_min:()=>Wt,_minLength:()=>Jr,_minSize:()=>Pr,_multipleOf:()=>kn,_nan:()=>Nh,_nanoid:()=>ll,_nativeEnum:()=>hL,_negative:()=>El,_never:()=>Lh,_nonnegative:()=>Cl,_nonoptional:()=>SL,_nonpositive:()=>Pl,_normalize:()=>Oo,_null:()=>xh,_nullable:()=>_L,_number:()=>yh,_optional:()=>wL,_overwrite:()=>dr,_parse:()=>yo,_parseAsync:()=>bo,_pipe:()=>EL,_positive:()=>kl,_promise:()=>$L,_properties:()=>$l,_property:()=>Tl,_readonly:()=>PL,_record:()=>dL,_refine:()=>Hh,_regex:()=>ko,_safeDecode:()=>_u,_safeDecodeAsync:()=>Su,_safeEncode:()=>wu,_safeEncodeAsync:()=>Ru,_safeParse:()=>wo,_safeParseAsync:()=>_o,_set:()=>fL,_size:()=>ms,_slugify:()=>Lo,_startsWith:()=>To,_string:()=>dh,_stringFormat:()=>Fo,_stringbool:()=>qh,_success:()=>vL,_superRefine:()=>Vh,_symbol:()=>Ah,_templateLiteral:()=>CL,_toLowerCase:()=>Io,_toUpperCase:()=>Do,_transform:()=>bL,_trim:()=>xo,_tuple:()=>pL,_uint32:()=>vh,_uint64:()=>$h,_ulid:()=>ml,_undefined:()=>Oh,_union:()=>aL,_unknown:()=>Dh,_uppercase:()=>Po,_url:()=>ka,_uuid:()=>ol,_uuidv4:()=>il,_uuidv6:()=>al,_uuidv7:()=>cl,_void:()=>Fh,_xid:()=>fl,_xor:()=>cL,clone:()=>Pe,compile:()=>lh,compileFn:()=>rl,config:()=>ze,createStandardJSONSchemaMethod:()=>Mo,createToJSONSchemaMethod:()=>Jh,decode:()=>w0,decodeAsync:()=>R0,describe:()=>Bh,encode:()=>b0,encodeAsync:()=>_0,extractDefs:()=>Cn,finalize:()=>Tn,flattenError:()=>ua,formatError:()=>la,getDiscriminatedOption:()=>Tg,globalConfig:()=>ot,globalRegistry:()=>ct,handleUnrepresentable:()=>Ke,initializeContext:()=>Pn,isBackEdge:()=>Qu,isRecursiveSchema:()=>th,isValidBase64:()=>ga,isValidBase64URL:()=>ju,isValidCIDRv6:()=>Uu,isValidCreditCard:()=>zu,isValidIPv6:()=>fa,isValidJWT:()=>Hu,locales:()=>Sa,memoizer:()=>Ra,mergeValues:()=>vo,meta:()=>Wh,parse:()=>mu,parseAsync:()=>fu,parseURLObject:()=>Fu,prettifyError:()=>Lm,process:()=>Ce,regexes:()=>bt,registry:()=>tl,safeDecode:()=>v0,safeDecodeAsync:()=>E0,safeEncode:()=>S0,safeEncodeAsync:()=>k0,safeParse:()=>Mm,safeParseAsync:()=>Gm,standardProps:()=>Lu,stripTabAndNewline:()=>Mu,toDotPath:()=>LS,toJSONSchema:()=>Il,toZod:()=>ea,treeifyError:()=>Dm,urlHostnameOk:()=>Gu,urlProtocolOk:()=>Nu,util:()=>Y,validate:()=>Nm,validateAsync:()=>Um,version:()=>Gf});var qt=C(()=>{Rn();jm();Fm();_a();rh();$u();Nf();Je();Je();Ro();sh();va();Au();gv();yv();Aa();xa();kv();Pv()});var Ll={};ne(Ll,{endsWith:()=>$o,gt:()=>Er,gte:()=>Wt,includes:()=>Co,length:()=>gs,lowercase:()=>Eo,lt:()=>kr,lte:()=>Bt,maxLength:()=>fs,maxSize:()=>En,mime:()=>Ao,minLength:()=>Jr,minSize:()=>Pr,multipleOf:()=>kn,negative:()=>El,nonnegative:()=>Cl,nonpositive:()=>Pl,normalize:()=>Oo,overwrite:()=>dr,positive:()=>kl,properties:()=>$l,property:()=>Tl,regex:()=>ko,size:()=>ms,slugify:()=>Lo,startsWith:()=>To,toLowerCase:()=>Io,toUpperCase:()=>Do,trim:()=>xo,uppercase:()=>Po});var Fl=C(()=>{qt()});function Ml(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let n=r(this);return Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0})}})}var Cv,Tv,DL,It,Fy=C(()=>{qt();qt();Je();Cv=new WeakSet([Object.prototype,Error.prototype]);Tv=(e,t)=>{ca.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);Cv.has(r)||(Cv.add(r),Ml(r,"format",n=>s=>la(n,s)),Ml(r,"flatten",n=>s=>ua(n,s)),Ml(r,"addIssue",n=>s=>{n.issues.push(s),n.message=JSON.stringify(n.issues,fo,2)}),Ml(r,"addIssues",n=>s=>{n.issues.push(...s),n.message=JSON.stringify(n.issues,fo,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},DL=T("ZodError",Tv),It=T("ZodError",Tv,void 0,{Parent:Error})});var My,Gy,Ny,Uy,jy,zy,Hy,Vy,By,Wy,qy,Zy,Jy=C(()=>{qt();Fy();qt();My=yo(It),Gy=bo(It),Ny=wo(It),Uy=_o(It),jy=gu(It),zy=hu(It),Hy=yu(It),Vy=bu(It),By=wu(It),Wy=_u(It),qy=Ru(It),Zy=Su(It)});var Wo={};ne(Wo,{ZodAny:()=>sb,ZodArray:()=>cb,ZodBase64:()=>ep,ZodBase64URL:()=>tp,ZodBigInt:()=>Vo,ZodBigIntFormat:()=>sp,ZodBoolean:()=>Ho,ZodCIDRv4:()=>Ql,ZodCIDRv6:()=>Xl,ZodCUID:()=>Bl,ZodCUID2:()=>Wl,ZodCatch:()=>$b,ZodCodec:()=>za,ZodCreditCard:()=>Yy,ZodCustom:()=>Ha,ZodCustomStringFormat:()=>jo,ZodDate:()=>Fa,ZodDefault:()=>vb,ZodDiscriminatedUnion:()=>lb,ZodE164:()=>rp,ZodEmail:()=>jl,ZodEmoji:()=>Hl,ZodEnum:()=>No,ZodExactOptional:()=>cp,ZodFile:()=>wb,ZodFunction:()=>Nb,ZodGUID:()=>zl,ZodIPv4:()=>Kl,ZodIPv6:()=>Yl,ZodISODate:()=>An,ZodISODateTime:()=>$n,ZodISODuration:()=>xn,ZodISOTime:()=>On,ZodIntersection:()=>pb,ZodJWT:()=>np,ZodKSUID:()=>Jl,ZodLazy:()=>Fb,ZodLiteral:()=>bb,ZodMAC:()=>Ky,ZodMap:()=>hb,ZodNaN:()=>Ob,ZodNanoID:()=>Vl,ZodNever:()=>ib,ZodNonOptional:()=>up,ZodNull:()=>rb,ZodNullable:()=>Sb,ZodNumber:()=>zo,ZodNumberFormat:()=>ws,ZodObject:()=>Ga,ZodOptional:()=>Ua,ZodPipe:()=>ja,ZodPrefault:()=>Eb,ZodPreprocess:()=>xb,ZodPromise:()=>Gb,ZodReadonly:()=>Ib,ZodRecord:()=>Go,ZodSet:()=>yb,ZodString:()=>Uo,ZodStringFormat:()=>Oe,ZodSuccess:()=>Tb,ZodSymbol:()=>eb,ZodTemplateLiteral:()=>Lb,ZodTransform:()=>_b,ZodTuple:()=>mb,ZodType:()=>le,ZodULID:()=>ql,ZodURL:()=>La,ZodUUID:()=>Cr,ZodUndefined:()=>tb,ZodUnion:()=>Na,ZodUnknown:()=>ob,ZodVoid:()=>ab,ZodXID:()=>Zl,ZodXor:()=>ub,_ZodString:()=>Ul,_default:()=>kb,_function:()=>Fk,any:()=>mk,array:()=>Ma,base64:()=>Jv,base64url:()=>Kv,bigint:()=>ck,boolean:()=>Xy,catch:()=>Ab,check:()=>Mk,cidrv4:()=>qv,cidrv6:()=>Zv,codec:()=>xk,creditCard:()=>Qv,cuid:()=>Nv,cuid2:()=>Uv,custom:()=>Gk,date:()=>gk,describe:()=>Nk,discriminatedUnion:()=>Rk,e164:()=>Yv,email:()=>$v,emoji:()=>Mv,enum:()=>ip,exactOptional:()=>Rb,file:()=>Tk,float32:()=>sk,float64:()=>ok,function:()=>Fk,guid:()=>Av,hash:()=>nk,hex:()=>rk,hostname:()=>tk,httpUrl:()=>Fv,instanceof:()=>jk,int:()=>Gl,int32:()=>ik,int64:()=>uk,intersection:()=>db,invertCodec:()=>Ik,ipv4:()=>Vv,ipv6:()=>Wv,json:()=>Hk,jwt:()=>Xv,keyof:()=>hk,ksuid:()=>Hv,lazy:()=>Mb,literal:()=>Ck,looseObject:()=>wk,looseRecord:()=>vk,mac:()=>Bv,map:()=>kk,meta:()=>Uk,nan:()=>Ok,nanoid:()=>Gv,nativeEnum:()=>Pk,never:()=>op,nonoptional:()=>Cb,null:()=>nb,nullable:()=>Da,nullish:()=>$k,number:()=>Qy,object:()=>yk,optional:()=>ys,partialRecord:()=>Sk,pipe:()=>Nl,prefault:()=>Pb,preprocess:()=>Vk,promise:()=>Lk,readonly:()=>Db,record:()=>gb,refine:()=>Ub,set:()=>Ek,strictObject:()=>bk,string:()=>Ia,stringFormat:()=>ek,stringbool:()=>zk,success:()=>Ak,superRefine:()=>jb,symbol:()=>pk,templateLiteral:()=>Dk,transform:()=>ap,tuple:()=>fb,uint32:()=>ak,uint64:()=>lk,ulid:()=>jv,undefined:()=>dk,union:()=>Bo,unknown:()=>hs,url:()=>Lv,uuid:()=>Ov,uuidv4:()=>xv,uuidv6:()=>Iv,uuidv7:()=>Dv,void:()=>fk,xid:()=>zv,xor:()=>_k});function FL(){ot.localeError||ze(Xu())}function bs(){ot.memoizer||ze({memoizer:Ra()})}function Ia(e){return dh(Uo,e)}function $v(e){return nl(jl,e)}function Av(e){return sl(zl,e)}function Ov(e){return ol(Cr,e)}function xv(e){return il(Cr,e)}function Iv(e){return al(Cr,e)}function Dv(e){return cl(Cr,e)}function Lv(e){return ka(La,e)}function Fv(e){return ka(La,{protocol:bt.httpProtocol,hostname:bt.domain,...Y.normalizeParams(e)})}function Mv(e){return ul(Hl,e)}function Gv(e){return ll(Vl,e)}function Nv(e){return pl(Bl,e)}function Uv(e){return dl(Wl,e)}function jv(e){return ml(ql,e)}function zv(e){return fl(Zl,e)}function Hv(e){return gl(Jl,e)}function Vv(e){return hl(Kl,e)}function Bv(e){return fh(Ky,e)}function Wv(e){return yl(Yl,e)}function qv(e){return bl(Ql,e)}function Zv(e){return wl(Xl,e)}function Jv(e){return _l(ep,e)}function Kv(e){return Rl(tp,e)}function Yv(e){return Sl(rp,e)}function Qv(e){return gh(Yy,e)}function Xv(e){return vl(np,e)}function ek(e,t,r={}){return Fo(jo,e,t,r)}function tk(e){return Fo(jo,"hostname",bt.hostname,e)}function rk(e){return Fo(jo,"hex",bt.hex,e)}function nk(e,t){let r=t?.enc??"hex",n=`${e}_${r}`,s=bt[n];if(!s)throw new Error(`Unrecognized hash format: ${n}`);return Fo(jo,n,s,t)}function Qy(e){return yh(zo,e)}function Gl(e){return wh(ws,e)}function sk(e){return _h(ws,e)}function ok(e){return Rh(ws,e)}function ik(e){return Sh(ws,e)}function ak(e){return vh(ws,e)}function Xy(e){return kh(Ho,e)}function ck(e){return Ph(Vo,e)}function uk(e){return Th(sp,e)}function lk(e){return $h(sp,e)}function pk(e){return Ah(eb,e)}function dk(e){return Oh(tb,e)}function nb(e){return xh(rb,e)}function mk(){return Ih(sb)}function hs(){return Dh(ob)}function op(e){return Lh(ib,e)}function fk(e){return Fh(ab,e)}function gk(e){return Mh(Fa,e)}function Ma(e,t){return Uh(cb,e,t)}function hk(e){let t=e._zod.def.shape;return ip(Object.keys(t))}function yk(e,t){let r={type:"object",shape:e??{},...Y.normalizeParams(t)};return new Ga(r)}function bk(e,t){return new Ga({type:"object",shape:e,catchall:op(),...Y.normalizeParams(t)})}function wk(e,t){return new Ga({type:"object",shape:e,catchall:hs(),...Y.normalizeParams(t)})}function Bo(e,t){return new Na({type:"union",options:e,...Y.normalizeParams(t)})}function _k(e,t){return new ub({type:"union",options:e,inclusive:!1,...Y.normalizeParams(t)})}function Rk(e,t,r){return new lb({type:"union",options:t,discriminator:e,...Y.normalizeParams(r)})}function db(e,t){return new pb({type:"intersection",left:e,right:t})}function fb(e,t,r){let n=t instanceof oe,s=n?r:t,o=n?t:null;return new mb({type:"tuple",items:e,rest:o,...Y.normalizeParams(s)})}function gb(e,t,r){return!t||!t._zod?new Go({type:"record",keyType:Ia(),valueType:e,...Y.normalizeParams(t)}):new Go({type:"record",keyType:e,valueType:t,...Y.normalizeParams(r)})}function Sk(e,t,r){return new Go({type:"record",keyType:e,valueType:t,...Y.normalizeParams(r),partial:!0})}function vk(e,t,r){return new Go({type:"record",keyType:e,valueType:t,mode:"loose",...Y.normalizeParams(r)})}function kk(e,t,r){return new hb({type:"map",keyType:e,valueType:t,...Y.normalizeParams(r)})}function Ek(e,t){return new yb({type:"set",valueType:e,...Y.normalizeParams(t)})}function ip(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new No({type:"enum",entries:r,...Y.normalizeParams(t)})}function Pk(e,t){return new No({type:"enum",entries:e,...Y.normalizeParams(t)})}function Ck(e,t){return new bb({type:"literal",values:Array.isArray(e)?e:[e],...Y.normalizeParams(t)})}function Tk(e){return jh(wb,e)}function ap(e){return new _b({type:"transform",transform:e})}function ys(e){return new Ua({type:"optional",innerType:e})}function Rb(e){return new cp({type:"optional",innerType:e})}function Da(e){return new Sb({type:"nullable",innerType:e})}function $k(e){return ys(Da(e))}function kb(e,t){return new vb({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Y.shallowClone(t)}})}function Pb(e,t){return new Eb({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Y.shallowClone(t)}})}function Cb(e,t){return new up({type:"nonoptional",innerType:e,...Y.normalizeParams(t)})}function Ak(e){return new Tb({type:"success",innerType:e})}function Ab(e,t){return new $b({type:"catch",innerType:e,catchValue:typeof t=="function"?t:Y.constantCatch(t)})}function Ok(e){return Nh(Ob,e)}function Nl(e,t){return new ja({type:"pipe",in:e,out:t})}function xk(e,t,r){return new za({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}function Ik(e){let t=e._zod.def;return new za({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}function Db(e){return new Ib({type:"readonly",innerType:e})}function Dk(e,t){return new Lb({type:"template_literal",parts:e,...Y.normalizeParams(t)})}function Mb(e){return new Fb({type:"lazy",getter:e})}function Lk(e){return new Gb({type:"promise",innerType:e})}function Fk(e){return new Nb({type:"function",input:Array.isArray(e?.input)?fb(e?.input):e?.input??Ma(hs()),output:e?.output??hs()})}function Mk(e){let t=new xe({check:"custom"});return t._zod.check=e,t}function Gk(e,t){return zh(Ha,e??(()=>!0),t)}function Ub(e,t={}){return Hh(Ha,e,t)}function jb(e,t){return Vh(e,t)}function jk(e,t={}){let r=new Ha({type:"custom",check:"custom",fn:n=>n instanceof e,abort:!0,...Y.normalizeParams(t)});return r._zod.bag.Class=e,r._zod.check=n=>{n.value instanceof e||n.issues.push({code:"invalid_type",expected:e.name,input:n.value,inst:r,path:[...r._zod.def.path??[]]})},r}function Hk(e){let t=Mb(()=>Bo([Ia(e),Qy(),Xy(),nb(),Ma(t),gb(Ia(),t)]));return t}function Vk(e,t){return new xb({type:"pipe",in:ap(e),out:t})}var le,Ul,Uo,Oe,$n,An,On,xn,jl,zl,Cr,La,Hl,Vl,Bl,Wl,ql,Zl,Jl,Kl,Ky,Yl,Ql,Xl,ep,tp,rp,Yy,np,jo,zo,ws,Ho,Vo,sp,eb,tb,rb,sb,ob,ib,ab,Fa,cb,Ga,Na,ub,lb,pb,mb,Go,hb,yb,No,bb,wb,_b,Ua,cp,Sb,vb,Eb,up,Tb,$b,Ob,ja,za,xb,Ib,Lb,Fb,Gb,Nb,Ha,Nk,Uk,zk,In=C(()=>{qt();qt();xa();Aa();nh();Fl();Jy();le=T("ZodType",(e,t)=>(FL(),oe.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Y.mergeDefs(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Pe(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Ub(e,t))},superRefine(e,t){return this.check(jb(e,t))},overwrite(e){return this.check(dr(e))},optional(){return ys(this)},exactOptional(){return Rb(this)},nullable(){return Da(this)},nullish(){return ys(Da(this))},nonoptional(e){return Cb(this,e)},array(){return Ma(this)},or(e){return Bo([this,e])},and(e){return db(this,e)},transform(e){return Nl(this,ap(e))},default(e){return kb(this,e)},prefault(e){return Pb(this,e)},catch(e){return Ab(this,e)},pipe(e){return Nl(this,e)},readonly(){return Db(this)},describe(e){let t=this.clone();return ct.add(t,{description:e}),t},meta(...e){if(e.length===0)return ct.get(this);let t=this.clone();return ct.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return Y.hide(this,"~standard",{...Lu(this),jsonSchema:{input:Mo(this,"input"),output:Mo(this,"output")}})},set"~standard"(e){Y.own(this,"~standard",e)},parse:function e(t,r){return My(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await Gy(this,t,r,{callee:e})},safeParse(e,t){return Ny(this,e,t)},async safeParseAsync(e,t){return Uy(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Y.own(this,"spa",e)},encode:function e(t,r){return jy(this,t,r,{callee:e})},decode:function e(t,r){return zy(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await Hy(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await Vy(this,t,r,{callee:e})},safeEncode(e,t){return By(this,e,t)},safeDecode(e,t){return Wy(this,e,t)},async safeEncodeAsync(e,t){return qy(this,e,t)},async safeDecodeAsync(e,t){return Zy(this,e,t)},toJSONSchema(e){return Jh(this,{})(e)},get description(){return ct.get(this)?.description},get _def(){return this._zod.def}}),Ul=T("_ZodString",(e,t)=>{cs.init(e,t),le.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Qh(e,n,s,o);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null},{regex(...e){return this.check(ko(...e))},includes(...e){return this.check(Co(...e))},startsWith(...e){return this.check(To(...e))},endsWith(...e){return this.check($o(...e))},min(...e){return this.check(Jr(...e))},max(...e){return this.check(fs(...e))},length(...e){return this.check(gs(...e))},nonempty(...e){return this.check(Jr(1,...e))},lowercase(e){return this.check(Eo(e))},uppercase(e){return this.check(Po(e))},trim(){return this.check(xo())},normalize(...e){return this.check(Oo(...e))},toLowerCase(){return this.check(Io())},toUpperCase(){return this.check(Do())},slugify(){return this.check(Lo())}}),Uo=T("ZodString",(e,t)=>{cs.init(e,t),Ul.init(e,t)},{email(e){return this.check(nl(jl,e))},url(e){return this.check(ka(La,e))},jwt(e){return this.check(vl(np,e))},emoji(e){return this.check(ul(Hl,e))},guid(e){return this.check(sl(zl,e))},uuid(e){return this.check(ol(Cr,e))},uuidv4(e){return this.check(il(Cr,e))},uuidv6(e){return this.check(al(Cr,e))},uuidv7(e){return this.check(cl(Cr,e))},nanoid(e){return this.check(ll(Vl,e))},cuid(e){return this.check(pl(Bl,e))},cuid2(e){return this.check(dl(Wl,e))},ulid(e){return this.check(ml(ql,e))},base64(e){return this.check(_l(ep,e))},base64url(e){return this.check(Rl(tp,e))},xid(e){return this.check(fl(Zl,e))},ksuid(e){return this.check(gl(Jl,e))},ipv4(e){return this.check(hl(Kl,e))},ipv6(e){return this.check(yl(Yl,e))},cidrv4(e){return this.check(bl(Ql,e))},cidrv6(e){return this.check(wl(Xl,e))},e164(e){return this.check(Sl(rp,e))},datetime(e){return this.check(Ea($n,e))},date(e){return this.check(Pa(An,e))},time(e){return this.check(Ca(On,e))},duration(e){return this.check(Ta(xn,e))}});Oe=T("ZodStringFormat",(e,t)=>{$e.init(e,t),Ul.init(e,t)}),$n=T("ZodISODateTime",(e,t)=>{eg.init(e,t),Oe.init(e,t)}),An=T("ZodISODate",(e,t)=>{tg.init(e,t),Oe.init(e,t)}),On=T("ZodISOTime",(e,t)=>{rg.init(e,t),Oe.init(e,t)}),xn=T("ZodISODuration",(e,t)=>{ng.init(e,t),Oe.init(e,t)}),jl=T("ZodEmail",(e,t)=>{Hf.init(e,t),Oe.init(e,t)});zl=T("ZodGUID",(e,t)=>{jf.init(e,t),Oe.init(e,t)});Cr=T("ZodUUID",(e,t)=>{zf.init(e,t),Oe.init(e,t)});La=T("ZodURL",(e,t)=>{Wf.init(e,t),Oe.init(e,t)});Hl=T("ZodEmoji",(e,t)=>{qf.init(e,t),Oe.init(e,t)});Vl=T("ZodNanoID",(e,t)=>{Zf.init(e,t),Oe.init(e,t)});Bl=T("ZodCUID",(e,t)=>{Jf.init(e,t),Oe.init(e,t)});Wl=T("ZodCUID2",(e,t)=>{Kf.init(e,t),Oe.init(e,t)});ql=T("ZodULID",(e,t)=>{Yf.init(e,t),Oe.init(e,t)});Zl=T("ZodXID",(e,t)=>{Qf.init(e,t),Oe.init(e,t)});Jl=T("ZodKSUID",(e,t)=>{Xf.init(e,t),Oe.init(e,t)});Kl=T("ZodIPv4",(e,t)=>{sg.init(e,t),Oe.init(e,t)});Ky=T("ZodMAC",(e,t)=>{ig.init(e,t),Oe.init(e,t)});Yl=T("ZodIPv6",(e,t)=>{og.init(e,t),Oe.init(e,t)});Ql=T("ZodCIDRv4",(e,t)=>{ag.init(e,t),Oe.init(e,t)});Xl=T("ZodCIDRv6",(e,t)=>{cg.init(e,t),Oe.init(e,t)});ep=T("ZodBase64",(e,t)=>{ug.init(e,t),Oe.init(e,t)});tp=T("ZodBase64URL",(e,t)=>{lg.init(e,t),Oe.init(e,t)});rp=T("ZodE164",(e,t)=>{pg.init(e,t),Oe.init(e,t)});Yy=T("ZodCreditCard",(e,t)=>{dg.init(e,t),Oe.init(e,t)});np=T("ZodJWT",(e,t)=>{mg.init(e,t),Oe.init(e,t)});jo=T("ZodCustomStringFormat",(e,t)=>{fg.init(e,t),Oe.init(e,t)});zo=T("ZodNumber",(e,t)=>{Vu.init(e,t),le.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Xh(e,n,s,o);let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null},{gt(e,t){return this.check(Er(e,t))},gte(e,t){return this.check(Wt(e,t))},min(e,t){return this.check(Wt(e,t))},lt(e,t){return this.check(kr(e,t))},lte(e,t){return this.check(Bt(e,t))},max(e,t){return this.check(Bt(e,t))},int(e){return this.check(Gl(e))},safe(e){return this.check(Gl(e))},positive(e){return this.check(Er(0,e))},nonnegative(e){return this.check(Wt(0,e))},negative(e){return this.check(kr(0,e))},nonpositive(e){return this.check(Bt(0,e))},multipleOf(e,t){return this.check(kn(e,t))},step(e,t){return this.check(kn(e,t))},finite(){return this}});ws=T("ZodNumberFormat",(e,t)=>{gg.init(e,t),zo.init(e,t)});Ho=T("ZodBoolean",(e,t)=>{ha.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>ey(e,r,n,s)});Vo=T("ZodBigInt",(e,t)=>{Bu.init(e,t),le.init(e,t),e._zod.processJSONSchema=(n,s,o)=>ty(e,n,s,o);let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null},{gte(e,t){return this.check(Wt(e,t))},min(e,t){return this.check(Wt(e,t))},gt(e,t){return this.check(Er(e,t))},lt(e,t){return this.check(kr(e,t))},lte(e,t){return this.check(Bt(e,t))},max(e,t){return this.check(Bt(e,t))},positive(e){return this.check(Er(BigInt(0),e))},negative(e){return this.check(kr(BigInt(0),e))},nonpositive(e){return this.check(Bt(BigInt(0),e))},nonnegative(e){return this.check(Wt(BigInt(0),e))},multipleOf(e,t){return this.check(kn(e,t))}});sp=T("ZodBigIntFormat",(e,t)=>{hg.init(e,t),Vo.init(e,t)});eb=T("ZodSymbol",(e,t)=>{yg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>ry(e,r,n,s)});tb=T("ZodUndefined",(e,t)=>{bg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>sy(e,r,n,s)});rb=T("ZodNull",(e,t)=>{wg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>ny(e,r,n,s)});sb=T("ZodAny",(e,t)=>{_g.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>ay(e,r,n,s)});ob=T("ZodUnknown",(e,t)=>{Rg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>cy(e,r,n,s)});ib=T("ZodNever",(e,t)=>{Sg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>iy(e,r,n,s)});ab=T("ZodVoid",(e,t)=>{vg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>oy(e,r,n,s)});Fa=T("ZodDate",(e,t)=>{kg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(n,s,o)=>uy(e,n,s,o),e.min=(n,s)=>e.check(Wt(n,s)),e.max=(n,s)=>e.check(Bt(n,s));let r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null});cb=T("ZodArray",(e,t)=>{bs(),Eg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>Ry(e,r,n,s),e.element=t.element},{min(e,t){return this.check(Jr(e,t))},nonempty(e){return this.check(Jr(1,e))},max(e,t){return this.check(fs(e,t))},length(e,t){return this.check(gs(e,t))},unwrap(){return this.element}});Ga=T("ZodObject",(e,t)=>{bs(),Pg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>Sy(e,r,n,s),Y.installLazyProp(e,"shape",r=>r._zod.def.shape,!1)},{keyof(){return ip(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:hs()})},loose(){return this.clone({...this._zod.def,catchall:hs()})},strict(){return this.clone({...this._zod.def,catchall:op()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return Y.extend(this,e)},safeExtend(e){return Y.safeExtend(this,e)},merge(e){return Y.merge(this,e)},pick(e){return Y.pick(this,e)},omit(e){return Y.omit(this,e)},partial(...e){return Y.partial(Ua,this,e[0])},exactPartial(...e){return Y.partial(cp,this,e[0],"exactPartial")},required(...e){return Y.required(up,this,e[0])}});Na=T("ZodUnion",(e,t)=>{ya.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>Ol(e,r,n,s),e.options=t.options});ub=T("ZodXor",(e,t)=>{Na.init(e,t),Cg.init(e,t),e._zod.processJSONSchema=(r,n,s)=>Ol(e,r,n,s),e.options=t.options});lb=T("ZodDiscriminatedUnion",(e,t)=>{Na.init(e,t),$g.init(e,t)});pb=T("ZodIntersection",(e,t)=>{Ag.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>vy(e,r,n,s)});mb=T("ZodTuple",(e,t)=>{bs(),Wu.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>ky(e,r,n,s)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map(t=>new Ua({type:"optional",innerType:t}))})}});Go=T("ZodRecord",(e,t)=>{bs(),Og.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>Ey(e,r,n,s),e.keyType=t.keyType,e.valueType=t.valueType});hb=T("ZodMap",(e,t)=>{bs(),xg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>wy(e,r,n,s),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(Pr(...r)),e.nonempty=r=>e.check(Pr(1,r)),e.max=(...r)=>e.check(En(...r)),e.size=(...r)=>e.check(ms(...r))});yb=T("ZodSet",(e,t)=>{bs(),Ig.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>_y(e,r,n,s),e.min=(...r)=>e.check(Pr(...r)),e.nonempty=r=>e.check(Pr(1,r)),e.max=(...r)=>e.check(En(...r)),e.size=(...r)=>e.check(ms(...r))});No=T("ZodEnum",(e,t)=>{Dg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(n,s,o)=>ly(e,n,s,o),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(n,s)=>{let o={};for(let i of n)if(r.has(i))o[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new No({...t,checks:[],...Y.normalizeParams(s),entries:o})},e.exclude=(n,s)=>{let o={...t.entries};for(let i of n)if(r.has(i))delete o[i];else throw new Error(`Key ${i} not found in enum`);return new No({...t,checks:[],...Y.normalizeParams(s),entries:o})}});bb=T("ZodLiteral",(e,t)=>{Lg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>py(e,r,n,s),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});wb=T("ZodFile",(e,t)=>{Fg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>fy(e,r,n,s),e.min=(r,n)=>e.check(Pr(r,n)),e.max=(r,n)=>e.check(En(r,n)),e.mime=(r,n)=>e.check(Ao(Array.isArray(r)?r:[r],n))});_b=T("ZodTransform",(e,t)=>{bs(),Mg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>by(e,r,n,s),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Sn(e.constructor.name);r.addIssue=o=>{if(typeof o=="string")r.issues.push(Y.issue(o,r.value,t));else{let i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=r.value),i.inst??(i.inst=e),r.issues.push(Y.issue(i))}};let s=t.transform(r.value,r);return s instanceof Promise?s.then(o=>(r.value=o,r)):(r.value=s,r)}});Ua=T("ZodOptional",(e,t)=>{qu.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>xl(e,r,n,s),e.unwrap=()=>e._zod.def.innerType});cp=T("ZodExactOptional",(e,t)=>{Gg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>xl(e,r,n,s),e.unwrap=()=>e._zod.def.innerType});Sb=T("ZodNullable",(e,t)=>{Ng.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>Py(e,r,n,s),e.unwrap=()=>e._zod.def.innerType});vb=T("ZodDefault",(e,t)=>{Ug.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>$y(e,r,n,s),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});Eb=T("ZodPrefault",(e,t)=>{jg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>Ay(e,r,n,s),e.unwrap=()=>e._zod.def.innerType});up=T("ZodNonOptional",(e,t)=>{zg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>Cy(e,r,n,s),e.unwrap=()=>e._zod.def.innerType});Tb=T("ZodSuccess",(e,t)=>{Hg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>gy(e,r,n,s),e.unwrap=()=>e._zod.def.innerType});$b=T("ZodCatch",(e,t)=>{Vg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>Oy(e,r,n,s),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});Ob=T("ZodNaN",(e,t)=>{Bg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>dy(e,r,n,s)});ja=T("ZodPipe",(e,t)=>{Zu.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>xy(e,r,n,s),e.in=t.in,e.out=t.out});za=T("ZodCodec",(e,t)=>{ja.init(e,t),ba.init(e,t)});xb=T("ZodPreprocess",(e,t)=>{ja.init(e,t),Wg.init(e,t)}),Ib=T("ZodReadonly",(e,t)=>{qg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>Iy(e,r,n,s),e.unwrap=()=>e._zod.def.innerType});Lb=T("ZodTemplateLiteral",(e,t)=>{Zg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>my(e,r,n,s)});Fb=T("ZodLazy",(e,t)=>{wa.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>Ly(e,r,n,s),e.unwrap=()=>e._zod.def.getter()});Gb=T("ZodPromise",(e,t)=>{Kg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>Dy(e,r,n,s),e.unwrap=()=>e._zod.def.innerType});Nb=T("ZodFunction",(e,t)=>{Jg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>yy(e,r,n,s)});Ha=T("ZodCustom",(e,t)=>{Yg.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,s)=>hy(e,r,n,s)});Nk=Bh,Uk=Wh;zk=(...e)=>qh({Codec:za,Boolean:Ho,String:Uo},...e)});function GL(e){ze({customError:e})}function NL(){return ze().customError}var ML,zb,Bk=C(()=>{qt();ML={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};zb||(zb={})});var Va={};ne(Va,{ZodISODate:()=>An,ZodISODateTime:()=>$n,ZodISODuration:()=>xn,ZodISOTime:()=>On,date:()=>jL,datetime:()=>UL,duration:()=>HL,time:()=>zL});function UL(e){return Ea($n,e)}function jL(e){return Pa(An,e)}function zL(e){return Ca(On,e)}function HL(e){return Ta(xn,e)}var lp=C(()=>{qt();In();In()});function BL(e,t){let r=e.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function Wk(e,t){return e.map((r,n)=>n<t?r:r.optional())}function WL(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function qL(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let r=e.slice(1).split("/").filter(Boolean);if(r.length===0)return t.rootSchema;let n=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===n){let s=r[1]===void 0?void 0:WL(r[1]);if(!s||!t.defs[s])throw new Error(`Reference not found: ${e}`);return t.defs[s]}throw new Error(`Reference not found: ${e}`)}function ZL(e,t){return V.transform(n=>n).check(n=>{let s=n.value;if(!(typeof s!="object"||s===null||Array.isArray(s)))for(let o of Object.getOwnPropertyNames(s)){let i=t.safeParse(o);i.success||n.issues.push({code:"invalid_key",origin:"record",issues:i.error.issues,input:o,path:[o],continue:!0})}}).pipe(e)}function qk(e,t){if(e!==!1)return e===void 0||e===!0?V.any():Dt(e,t)}function Zk(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return V.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let s=e.$ref;if(t.refs.has(s))return t.refs.get(s);if(t.processing.has(s))return V.lazy(()=>{if(!t.refs.has(s))throw new Error(`Circular reference not resolved: ${s}`);return t.refs.get(s)});t.processing.add(s);let o=qL(s,t),i=Dt(o,t);return t.refs.set(s,i),t.processing.delete(s),i}if(e.enum!==void 0){let s=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&s.length===1&&s[0]===null)return V.null();if(s.length===0)return V.never();if(s.length===1)return V.literal(s[0]);if(s.every(i=>typeof i=="string"))return V.enum(s);let o=s.map(i=>V.literal(i));return o.length<2?o[0]:V.union([o[0],o[1],...o.slice(2)])}if(e.const!==void 0)return V.literal(e.const);let r=e.type;if(Array.isArray(r)){let s=r.map(o=>{let i={...e,type:o};return Zk(i,t)});return s.length===0?V.never():s.length===1?s[0]:V.union(s)}if(!r)return V.any();let n;switch(r){case"string":{let s=V.string();if(e.format){let o=e.format;o==="email"?s=s.check(V.email()):o==="uri"||o==="uri-reference"?s=s.check(V.url()):o==="uuid"||o==="guid"?s=s.check(V.uuid()):o==="date-time"?s=s.check(V.iso.datetime({offset:!0})):o==="date"?s=s.check(V.iso.date()):o==="time"?s=s.check(V.regex(JL)):o==="duration"?s=s.check(V.iso.duration()):o==="hostname"?s=s.check(V.hostname()):o==="ipv4"?s=s.check(V.ipv4()):o==="ipv6"?s=s.check(V.ipv6()):o==="mac"?s=s.check(V.mac()):o==="cidr"?s=s.check(V.cidrv4()):o==="cidr-v6"?s=s.check(V.cidrv6()):o==="base64"?s=s.check(V.base64()):o==="base64url"?s=s.check(V.base64url()):o==="e164"?s=s.check(V.e164()):o==="credit_card"?s=s.check(V.creditCard()):o==="jwt"?s=s.check(V.jwt()):o==="emoji"?s=s.check(V.emoji()):o==="nanoid"?s=s.check(V.nanoid()):o==="cuid"?s=s.check(V.cuid()):o==="cuid2"?s=s.check(V.cuid2()):o==="ulid"?s=s.check(V.ulid()):o==="xid"?s=s.check(V.xid()):o==="ksuid"&&(s=s.check(V.ksuid()))}typeof e.minLength=="number"&&(s=s.min(e.minLength)),typeof e.maxLength=="number"&&(s=s.max(e.maxLength)),e.pattern&&(s=s.regex(new RegExp(e.pattern))),n=s;break}case"number":case"integer":{let s=r==="integer"?V.number().int():V.number();typeof e.minimum=="number"&&e.exclusiveMinimum!==!0&&(s=s.min(e.minimum)),typeof e.maximum=="number"&&e.exclusiveMaximum!==!0&&(s=s.max(e.maximum)),typeof e.exclusiveMinimum=="number"?s=s.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(s=s.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?s=s.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(s=s.lt(e.maximum)),typeof e.multipleOf=="number"&&(s=s.multipleOf(e.multipleOf)),n=s;break}case"boolean":{n=V.boolean();break}case"null":{n=V.null();break}case"object":{let s={},o=e.properties||{},i=new Set(e.required||[]),a=typeof e.additionalProperties=="object"?Dt(e.additionalProperties,t):void 0;for(let[c,l]of Object.entries(o)){let p=Dt(l,t);je(s,c,i.has(c)?p:p.optional())}if(e.patternProperties){let c=e.patternProperties,l=Object.keys(c),p=[];for(let m of l){let f=Dt(c[m],t),g=V.string().regex(new RegExp(m));p.push(V.looseRecord(g,f))}let d=[];if(Object.keys(s).length>0&&d.push(V.object(s).passthrough()),d.push(...p),d.length===0)n=V.object({}).passthrough();else if(d.length===1)n=d[0];else{let m=V.intersection(d[0],d[1]);for(let f=2;f<d.length;f++)m=V.intersection(m,d[f]);n=m}if(e.additionalProperties===!1){let m=Object.keys(s),f=l.map(h=>new RegExp(h)),g=n;n=n.check(h=>{if(!rr(h.value))return;let w=[];for(let v of Object.keys(h.value))m.includes(v)||f.some(R=>R.test(v))||w.push(v);w.length&&h.issues.push({code:"unrecognized_keys",keys:w,input:h.value,inst:g})})}}else{let c=V.object(s);e.additionalProperties===!1?n=c.strict():a?n=c.catchall(a):n=c.passthrough()}if(e.propertyNames!==void 0&&e.propertyNames!==!0){let c=typeof e.propertyNames=="object"&&e.propertyNames.type===void 0?{type:"string",...e.propertyNames}:e.propertyNames;n=ZL(n,Dt(c,t))}break}case"array":{let s=e.prefixItems,o=e.items;if(s&&Array.isArray(s)){let i=typeof e.minItems=="number"?e.minItems:0,a=s.map(d=>Dt(d,t)),c=Wk(a,i),l=Array.isArray(o)?void 0:qk(o,t),p=V.tuple(c);n=l?p.rest(l):p,typeof e.minItems=="number"&&(n=n.check(V.minLength(e.minItems))),typeof e.maxItems=="number"&&(n=n.check(V.maxLength(e.maxItems)))}else if(Array.isArray(o)){let i=typeof e.minItems=="number"?e.minItems:0,a=o.map(d=>Dt(d,t)),c=Wk(a,i),l=qk(e.additionalItems,t),p=V.tuple(c);n=l?p.rest(l):p,typeof e.minItems=="number"&&(n=n.check(V.minLength(e.minItems))),typeof e.maxItems=="number"&&(n=n.check(V.maxLength(e.maxItems)))}else if(o!==void 0){let i=Dt(o,t),a=V.array(i);typeof e.minItems=="number"&&(a=a.min(e.minItems)),typeof e.maxItems=="number"&&(a=a.max(e.maxItems)),n=a}else n=V.array(V.any());break}default:throw new Error(`Unsupported type: ${r}`)}return n}function Dt(e,t){if(typeof e=="boolean")return e?V.any():V.never();let r=Zk(e,t),n=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let a=e.anyOf.map(l=>Dt(l,t)),c=V.union(a);r=n?V.intersection(r,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let a=e.oneOf.map(l=>Dt(l,t)),c=V.xor(a);r=n?V.intersection(r,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=n?r:V.any();else{let a=n?r:Dt(e.allOf[0],t),c=n?0:1;for(let l=c;l<e.allOf.length;l++)a=V.intersection(a,Dt(e.allOf[l],t));r=a}e.nullable===!0&&t.version==="openapi-3.0"&&(r=V.nullable(r)),e.readOnly===!0&&(r=V.readonly(r)),e.default!==void 0&&(r=r.default(e.default));let s={},o=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let a of o)a in e&&(s[a]=e[a]);let i=["contentEncoding","contentMediaType","contentSchema"];for(let a of i)a in e&&(s[a]=e[a]);e.propertyNames!==void 0&&e.type==="object"&&e.$ref===void 0&&(s.propertyNames=e.propertyNames);for(let a of Object.keys(e))VL.has(a)||je(s,a,e[a]);return Object.keys(s).length>0&&t.registry.add(r,s),e.description&&(r=r.describe(e.description)),r}function Jk(e,t){if(typeof e=="boolean")return e?V.any():V.never();let r;try{r=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let n=BL(r,t?.defaultTarget),s=r.$defs||r.definitions||{},o={version:n,defs:s,refs:new Map,processing:new Set,rootSchema:r,registry:t?.registry??ct};return Dt(r,o)}var V,VL,JL,Kk=C(()=>{va();Je();Fl();lp();In();V={...Wo,...Ll,iso:Va},VL=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);JL=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/});function Ba(e,t){let r=typeof t=="function"?t:(i,a)=>{let c=t[i._zod.def.type];return c?c(i,a):i},n=new Map;function s(i){let a=n.get(i);if(a===Yk)return new wa({type:"lazy",getter:()=>n.get(i)});if(a!==void 0)return a;n.set(i,Yk);let c=o(i),l=r(c,c!==i);return n.set(i,l),l}function o(i){let a=i._zod.def,c=a.type;switch(c){case"object":{let l=a.shape,p=Object.keys(l),d=!1,m={};for(let g of p){let h=s(l[g]);h!==l[g]&&(d=!0),m[g]=h}let f=a.catchall;return a.catchall&&(f=s(a.catchall),f!==a.catchall&&(d=!0)),d?Pe(i,{...a,shape:m,catchall:f}):i}case"array":{let l=s(a.element);return l===a.element?i:Pe(i,{...a,element:l})}case"tuple":{let l=a.items,p=!1,d=[];for(let f of l){let g=s(f);g!==f&&(p=!0),d.push(g)}let m=a.rest;return a.rest&&(m=s(a.rest),m!==a.rest&&(p=!0)),p?Pe(i,{...a,items:d,rest:m}):i}case"record":case"map":{let l=s(a.keyType),p=s(a.valueType);return l===a.keyType&&p===a.valueType?i:Pe(i,{...a,keyType:l,valueType:p})}case"set":{let l=s(a.valueType);return l===a.valueType?i:Pe(i,{...a,valueType:l})}case"union":{let l=a.options,p=!1,d=[];for(let m of l){let f=s(m);f!==m&&(p=!0),d.push(f)}return p?Pe(i,{...a,options:d}):i}case"intersection":{let l=s(a.left),p=s(a.right);return l===a.left&&p===a.right?i:Pe(i,{...a,left:l,right:p})}case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":{let l=s(a.innerType);return l===a.innerType?i:Pe(i,{...a,innerType:l})}case"pipe":{let l=s(a.in),p=s(a.out);return l===a.in&&p===a.out?i:Pe(i,{...a,in:l,out:p})}case"function":{let l=s(a.input),p=s(a.output);return l===a.input&&p===a.output?i:Pe(i,{...a,input:l,output:p})}case"lazy":{let l=a.getter,{_cachedInner:p,...d}=a;return Pe(i,{...d,getter:()=>s(l())})}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":return i;default:return i}}return s(e)}var Yk,Hb=C(()=>{_a();Je();Yk=Symbol("z.visit/resolving")});function Qk(e){return Ba(e,{object:t=>t.partial(),union:t=>{let r=t._zod.def;return r.discriminator===void 0?t:Bo(r.options)}})}var Xk=C(()=>{Hb();In()});function KL(e,t){if(!t?.length)return e;let r=e._zod.def;return Pe(e,lr(r,{checks:[...r.checks??[],...t]}),{parent:!0})}function eE(e){return KL(e.out,e.checks)}function YL(e){return e.in._zod.traits.has("$ZodTransform")?eE(e):e.in}function tE(e){return Ba(e,{pipe:t=>YL(t._zod.def),default:(t,r)=>r?ys(t._zod.def.innerType):t,catch:(t,r)=>r?t._zod.def.innerType:t})}function rE(e){return Ba(e,{pipe:t=>eE(t._zod.def),prefault:(t,r)=>r?t._zod.def.innerType:t})}var nE=C(()=>{Je();Hb();In()});var Vb={};ne(Vb,{bigint:()=>tF,boolean:()=>eF,date:()=>rF,number:()=>XL,string:()=>QL});function QL(e){return mh(Uo,e)}function XL(e){return bh(zo,e)}function eF(e){return Eh(Ho,e)}function tF(e){return Ch(Vo,e)}function rF(e){return Gh(Fa,e)}var sE=C(()=>{qt();In()});var u={};ne(u,{$brand:()=>Am,$input:()=>ih,$output:()=>oh,NEVER:()=>$m,TimePrecision:()=>hh,ZodAny:()=>sb,ZodArray:()=>cb,ZodBase64:()=>ep,ZodBase64URL:()=>tp,ZodBigInt:()=>Vo,ZodBigIntFormat:()=>sp,ZodBoolean:()=>Ho,ZodCIDRv4:()=>Ql,ZodCIDRv6:()=>Xl,ZodCUID:()=>Bl,ZodCUID2:()=>Wl,ZodCatch:()=>$b,ZodCodec:()=>za,ZodCompileAsyncError:()=>pr,ZodCompileUnsupportedError:()=>ye,ZodCreditCard:()=>Yy,ZodCustom:()=>Ha,ZodCustomStringFormat:()=>jo,ZodDate:()=>Fa,ZodDefault:()=>vb,ZodDiscriminatedUnion:()=>lb,ZodE164:()=>rp,ZodEmail:()=>jl,ZodEmoji:()=>Hl,ZodEnum:()=>No,ZodError:()=>DL,ZodExactOptional:()=>cp,ZodFile:()=>wb,ZodFirstPartyTypeKind:()=>zb,ZodFunction:()=>Nb,ZodGUID:()=>zl,ZodIPv4:()=>Kl,ZodIPv6:()=>Yl,ZodISODate:()=>An,ZodISODateTime:()=>$n,ZodISODuration:()=>xn,ZodISOTime:()=>On,ZodIntersection:()=>pb,ZodIssueCode:()=>ML,ZodJWT:()=>np,ZodKSUID:()=>Jl,ZodLazy:()=>Fb,ZodLiteral:()=>bb,ZodMAC:()=>Ky,ZodMap:()=>hb,ZodNaN:()=>Ob,ZodNanoID:()=>Vl,ZodNever:()=>ib,ZodNonOptional:()=>up,ZodNull:()=>rb,ZodNullable:()=>Sb,ZodNumber:()=>zo,ZodNumberFormat:()=>ws,ZodObject:()=>Ga,ZodOptional:()=>Ua,ZodPipe:()=>ja,ZodPrefault:()=>Eb,ZodPreprocess:()=>xb,ZodPromise:()=>Gb,ZodReadonly:()=>Ib,ZodRealError:()=>It,ZodRecord:()=>Go,ZodSet:()=>yb,ZodString:()=>Uo,ZodStringFormat:()=>Oe,ZodSuccess:()=>Tb,ZodSymbol:()=>eb,ZodTemplateLiteral:()=>Lb,ZodTransform:()=>_b,ZodTuple:()=>mb,ZodType:()=>le,ZodULID:()=>ql,ZodURL:()=>La,ZodUUID:()=>Cr,ZodUndefined:()=>tb,ZodUnion:()=>Na,ZodUnknown:()=>ob,ZodVoid:()=>ab,ZodXID:()=>Zl,ZodXor:()=>ub,_ZodString:()=>Ul,_default:()=>kb,_function:()=>Fk,any:()=>mk,array:()=>Ma,base64:()=>Jv,base64url:()=>Kv,bigint:()=>ck,boolean:()=>Xy,catch:()=>Ab,check:()=>Mk,cidrv4:()=>qv,cidrv6:()=>Zv,clone:()=>Pe,codec:()=>xk,coerce:()=>Vb,compile:()=>lh,config:()=>ze,core:()=>Kr,creditCard:()=>Qv,cuid:()=>Nv,cuid2:()=>Uv,custom:()=>Gk,date:()=>gk,decode:()=>zy,decodeAsync:()=>Vy,deepPartial:()=>Qk,describe:()=>Nk,discriminatedUnion:()=>Rk,e164:()=>Yv,email:()=>$v,emoji:()=>Mv,encode:()=>jy,encodeAsync:()=>Hy,endsWith:()=>$o,enum:()=>ip,exactOptional:()=>Rb,file:()=>Tk,flattenError:()=>ua,float32:()=>sk,float64:()=>ok,formatError:()=>la,fromJSONSchema:()=>Jk,function:()=>Fk,getDiscriminatedOption:()=>Tg,getErrorMap:()=>NL,globalRegistry:()=>ct,gt:()=>Er,gte:()=>Wt,guid:()=>Av,hash:()=>nk,hex:()=>rk,hostname:()=>tk,httpUrl:()=>Fv,includes:()=>Co,input:()=>tE,instanceof:()=>jk,int:()=>Gl,int32:()=>ik,int64:()=>uk,intersection:()=>db,invertCodec:()=>Ik,ipv4:()=>Vv,ipv6:()=>Wv,iso:()=>Va,json:()=>Hk,jwt:()=>Xv,keyof:()=>hk,ksuid:()=>Hv,lazy:()=>Mb,length:()=>gs,literal:()=>Ck,locales:()=>Sa,looseObject:()=>wk,looseRecord:()=>vk,lowercase:()=>Eo,lt:()=>kr,lte:()=>Bt,mac:()=>Bv,map:()=>kk,maxLength:()=>fs,maxSize:()=>En,memoizer:()=>Ra,meta:()=>Uk,mime:()=>Ao,minLength:()=>Jr,minSize:()=>Pr,multipleOf:()=>kn,nan:()=>Ok,nanoid:()=>Gv,nativeEnum:()=>Pk,negative:()=>El,never:()=>op,nonnegative:()=>Cl,nonoptional:()=>Cb,nonpositive:()=>Pl,normalize:()=>Oo,null:()=>nb,nullable:()=>Da,nullish:()=>$k,number:()=>Qy,object:()=>yk,optional:()=>ys,output:()=>rE,overwrite:()=>dr,parse:()=>My,parseAsync:()=>Gy,partialRecord:()=>Sk,pipe:()=>Nl,positive:()=>kl,prefault:()=>Pb,preprocess:()=>Vk,prettifyError:()=>Lm,promise:()=>Lk,properties:()=>$l,property:()=>Tl,readonly:()=>Db,record:()=>gb,refine:()=>Ub,regex:()=>ko,regexes:()=>bt,registry:()=>tl,safeDecode:()=>Wy,safeDecodeAsync:()=>Zy,safeEncode:()=>By,safeEncodeAsync:()=>qy,safeParse:()=>Ny,safeParseAsync:()=>Uy,set:()=>Ek,setErrorMap:()=>GL,size:()=>ms,slugify:()=>Lo,startsWith:()=>To,strictObject:()=>bk,string:()=>Ia,stringFormat:()=>ek,stringbool:()=>zk,success:()=>Ak,superRefine:()=>jb,symbol:()=>pk,templateLiteral:()=>Dk,toJSONSchema:()=>Il,toLowerCase:()=>Io,toUpperCase:()=>Do,toZod:()=>ea,transform:()=>ap,treeifyError:()=>Dm,trim:()=>xo,tuple:()=>fb,uint32:()=>ak,uint64:()=>lk,ulid:()=>jv,undefined:()=>dk,union:()=>Bo,unknown:()=>hs,uppercase:()=>Po,url:()=>Lv,util:()=>Y,uuid:()=>Ov,uuidv4:()=>xv,uuidv6:()=>Iv,uuidv7:()=>Dv,validate:()=>Nm,validateAsync:()=>Um,void:()=>fk,xid:()=>zv,xor:()=>_k});var Bb=C(()=>{qt();In();Fl();Fy();Jy();Bk();qt();xa();Kk();Xk();nE();sh();lp();lp();sE()});var Wa=C(()=>{Bb();Bb()});var nF,qb,Zb,Jb,Kb,sF,oF,iF,aF,cF,uF,lF,pF,dF,mF,oE,fF,pp,gF,hF,yF,bF,wF,Wb,_F,RF,SF,vF,Yb,Qb,Lt,Dn=C(()=>{"use strict";Wa();nF=u.enum(["candidate","claimed","in_progress","pr_submitted"]),qb=u.enum(["needs_addressing","waiting_on_maintainer"]),Zb=u.enum(["nonprofit","devtools","infrastructure","web-frameworks","data-ml","education"]),Jb=u.enum(["beginner","intermediate","advanced"]),Kb=u.enum(["inline","sourcetree","vscode","custom"]),sF=u.object({hasActiveMaintainers:u.boolean(),isResponsive:u.boolean(),hasHostileComments:u.boolean()}),oF=u.object({repo:u.string(),score:u.number(),mergedPRCount:u.number(),closedWithoutMergeCount:u.number(),avgResponseDays:u.number().nullable(),lastMergedAt:u.string().optional(),lastEvaluatedAt:u.string(),signals:sF,stargazersCount:u.number().optional(),language:u.string().nullable().optional()}),iF=u.object({url:u.string(),title:u.string(),mergedAt:u.string(),openedAt:u.string().optional(),firstMaintainerResponseAt:u.string().optional(),commentsFetchedAt:u.string().datetime().optional(),learningsExtractedAt:u.string().datetime().optional()}),aF=u.object({url:u.string(),title:u.string(),closedAt:u.string(),openedAt:u.string().optional(),firstMaintainerResponseAt:u.string().optional(),commentsFetchedAt:u.string().datetime().optional(),learningsExtractedAt:u.string().datetime().optional()}),cF=u.object({url:u.string(),repo:u.string(),analyzedAt:u.string()}),uF=u.object({tier:u.enum(["light_check_in","direct_check_in","final_check_in"]),timestamp:u.string().datetime(),draftPath:u.string().optional()}),lF=u.object({workflowName:u.enum(["draft-first","work-through-issues","pre-commit-review"]),currentStep:u.string(),branchName:u.string().optional(),issueContext:u.object({title:u.string(),url:u.string()}).optional(),completedSteps:u.array(u.string()).default([]),stepData:u.record(u.string(),u.unknown()).default({}),lastUpdatedAt:u.string().datetime()}),pF=u.object({branchNamingConvention:u.string().optional(),commitMessageFormat:u.string().optional(),prTitleFormat:u.string().optional(),requiredChecks:u.array(u.string()).optional(),testFramework:u.string().optional(),testCoverageRequired:u.boolean().optional(),testFileNaming:u.string().optional(),linter:u.string().optional(),formatter:u.string().optional(),styleGuideUrl:u.string().optional(),issueClaimProcess:u.string().optional(),reviewProcess:u.string().optional(),claRequired:u.boolean().optional(),rawContent:u.string().optional()}),dF=u.object({passedAllChecks:u.boolean(),checks:u.object({noExistingPR:u.boolean(),notClaimed:u.boolean(),projectActive:u.boolean(),clearRequirements:u.boolean(),contributionGuidelinesFound:u.boolean()}),contributionGuidelines:pF.optional(),notes:u.array(u.string())}),mF=u.object({id:u.number(),url:u.string(),repo:u.string(),number:u.number(),title:u.string(),status:nF,labels:u.array(u.string()),createdAt:u.string(),updatedAt:u.string(),vetted:u.boolean(),vettingResult:dF.optional()}),oE=u.object({number:u.number(),url:u.string(),title:u.string(),repo:u.string(),daysSinceActivity:u.number(),status:qb}),fF=u.object({status:qb,setAt:u.string(),lastActivityAt:u.string()}),pp=u.object({setupComplete:u.boolean().default(!1),setupCompletedAt:u.string().optional(),persistence:u.enum(["local","gist"]).default("local"),maxActivePRs:u.number().default(10),dormantThresholdDays:u.number().default(30),approachingDormantDays:u.number().default(25),maxIssueAgeDays:u.number().default(90),skipBroadWhenSufficientResults:u.number().min(0).default(8),languages:u.array(u.string()).default(["typescript","javascript"]),labels:u.array(u.string()).default(["good first issue","help wanted"]),scope:u.array(Jb).optional(),excludeRepos:u.array(u.string()).default([]),excludeOrgs:u.array(u.string()).optional(),untrackedOrgs:u.array(u.string()).default([]),avoidRepos:u.array(u.string()).default([]),boostIssueTypes:u.array(u.string()).default([]),trustedProjects:u.array(u.string()).default([]),githubUsername:u.string().default(""),minRepoScoreThreshold:u.number().default(4),starredRepos:u.array(u.string()).default([]),starredReposLastFetched:u.string().optional(),squashByDefault:u.union([u.boolean(),u.literal("ask")]).default(!0),localRepoScanPaths:u.array(u.string()).optional(),minStars:u.number().default(50),includeDocIssues:u.boolean().default(!0),aiPolicyBlocklist:u.array(u.string()).default(["matplotlib/matplotlib"]),shelvedPRUrls:u.array(u.string()).default([]),dismissedIssues:u.record(u.string(),u.string()).default({}),statusOverrides:u.record(u.string(),fF).optional(),issueListPath:u.string().optional(),skippedIssuesPath:u.string().optional(),projectCategories:u.array(Zb).default([]),preferredOrgs:u.array(u.string()).default([]),diffTool:Kb.default("inline"),diffToolCustomCommand:u.string().optional(),autoExtractLearnings:u.boolean().default(!0),autoFormatBeforePush:u.boolean().default(!1),trustOwnRepoWrites:u.boolean().default(!1),healthCheckFreshnessMinutes:u.number().int().positive().default(30),reviewMaxPasses:u.number().int().positive().optional(),slmTriageModel:u.string().default(""),slmTriageHost:u.string().default("")}),gF=u.object({repos:u.record(u.string(),u.object({path:u.string(),exists:u.boolean(),currentBranch:u.string().nullable()})),scanPaths:u.array(u.string()),cachedAt:u.string()}),hF=u.object({url:u.string(),repo:u.string(),number:u.number(),title:u.string(),closedAt:u.string(),closedBy:u.string().optional(),openedAt:u.string().optional()}),yF=u.object({url:u.string(),repo:u.string(),number:u.number(),title:u.string(),mergedAt:u.string(),openedAt:u.string().optional()}),bF=u.object({totalActivePRs:u.number(),totalNeedingAttention:u.number(),totalMergedAllTime:u.number(),mergeRate:u.number()}),wF=u.object({url:u.string(),repo:u.string(),number:u.number(),status:qb}).passthrough(),Wb=u.array(wF),_F=u.object({generatedAt:u.string(),openPRs:Wb,needsAddressingPRs:Wb,waitingOnMaintainerPRs:Wb,recentlyClosedPRs:u.array(hF),recentlyMergedPRs:u.array(yF),shelvedPRs:u.array(oE),autoUnshelvedPRs:u.array(oE),summary:bF}),RF=u.object({url:u.string(),lastSeenAt:u.string()}),SF=u.object({url:u.string(),branch:u.string(),worktree:u.string().optional(),note:u.string().optional(),recordedAt:u.string(),pushedRef:u.string().optional(),pushedAt:u.string().optional(),compareUrl:u.string().optional(),pushProblem:u.string().optional()}),vF=u.object({url:u.string(),attemptedAt:u.string(),outcome:u.enum(["prepared","blocked"]),note:u.string().optional()}),Yb=u.object({runAt:u.string(),reportPath:u.string(),prepareCount:u.number().int().nonnegative(),judgmentCount:u.number().int().nonnegative(),prepared:u.array(SF).default([]),implementUrl:u.string().optional(),implementAttempts:u.array(vF).optional()}),Qb=u.object({languageOffset:u.number().int().nonnegative().default(0),phase0Offset:u.number().int().nonnegative().default(0),starredOffset:u.number().int().nonnegative().default(0),maintainedOffset:u.number().int().nonnegative().default(0),strategyOffset:u.number().int().nonnegative().default(0),lastRotatedAt:u.string().optional()}),Lt=u.object({version:u.literal(4),gistId:u.string().optional(),repoScores:u.record(u.string(),oF).default({}),config:pp.default(()=>pp.parse({})),lastRunAt:u.string().default(()=>new Date().toISOString()),lastDigestAt:u.string().optional(),lastStrategyAt:u.string().optional(),lastDigest:_F.optional(),monthlyMergedCounts:u.record(u.string(),u.number()).optional(),monthlyClosedCounts:u.record(u.string(),u.number()).optional(),monthlyOpenedCounts:u.record(u.string(),u.number()).optional(),localRepoCache:gF.optional(),mergedPRs:u.array(iF).optional(),closedPRs:u.array(aF).optional(),analyzedIssueConversations:u.array(cF).optional(),activeIssues:u.array(mF).default([]),prFollowUpHistory:u.record(u.string(),u.array(uF)).optional(),workflowState:lF.optional(),searchSeen:u.array(RF).default([]),lastOvernight:Yb.optional(),searchRotation:Qb.optional()})});function sr(){let e=Ft.join(Xb.homedir(),".oss-autopilot");return Rt.existsSync(e)||Rt.mkdirSync(e,{recursive:!0,mode:448}),e}function St(){return Ft.join(sr(),"state.json")}function iE(){return Ft.join(process.cwd(),"data","state.json")}function aE(){return Ft.join(process.cwd(),"data","backups")}function _s(){let e=Ft.join(sr(),"backups");return Rt.existsSync(e)||Rt.mkdirSync(e,{recursive:!0,mode:448}),e}function dp(){let e=Ft.join(sr(),"cache");return Rt.existsSync(e)||Rt.mkdirSync(e,{recursive:!0,mode:448}),e}function qo(){let e=Ft.join(sr(),"reports");return Rt.existsSync(e)||Rt.mkdirSync(e,{recursive:!0,mode:448}),e}function Rs(){return Ft.join(sr(),"gist-id")}function Ln(){return Ft.join(sr(),"state-cache.json")}function mp(){let e=Ft.join(Xb.homedir(),".oss-autopilot","state.json");return Rt.existsSync(e)}function Tr(){return"3.31.0"}var Rt,Ft,Xb,Yr=C(()=>{"use strict";Rt=H(require("node:fs"),1),Ft=H(require("node:path"),1),Xb=H(require("node:os"),1)});function gp(){fp=!0}function cE(){return fp}function I(e,t,...r){if(!fp)return;let n=new Date().toISOString();console.error(`[${n}] [DEBUG] [${e}] ${t}`,...r)}function uE(e,t,...r){let n=new Date().toISOString();console.error(`[${n}] [INFO] [${e}] ${t}`,...r)}function _(e,t,...r){let n=new Date().toISOString();console.error(`[${n}] [WARN] [${e}] ${t}`,...r)}async function hp(e,t,r){if(!fp)return r();let n=performance.now();try{let s=await r(),o=(performance.now()-n).toFixed(0);return I(e,`${t} completed in ${o}ms`),s}catch(s){let o=(performance.now()-n).toFixed(0);throw I(e,`${t} failed after ${o}ms`),s}}var fp,de=C(()=>{"use strict";fp=!1});function Za(e){if(process.env[yp]!==void 0)throw new Ge(`Refusing to ${e} during an unattended run (${yp} is set). Run it yourself in an interactive session.`)}function A(e){return e instanceof Error?e.message:String(e)}function Ye(e){if(e&&typeof e=="object"&&"status"in e){let t=e.status;return typeof t=="number"&&Number.isFinite(t)?t:void 0}}function Mt(e){let t=Ye(e);return t===429?!0:t===403?A(e).toLowerCase().includes("rate limit"):!1}function lE(e){if(Ye(e)!==422)return!1;let t=e?.response?.data,r=t&&typeof t=="object"?t.errors:void 0;return Array.isArray(r)?r.some(n=>{if(!n||typeof n!="object")return!1;let s=n;return s.resource!=="Search"||s.code!=="invalid"?!1:typeof s.message=="string"?ew.test(s.message):ew.test(A(e))}):ew.test(A(e))}function Le(e){let t=Ye(e);if(t===401||t===429)return!0;if(t===403){let r=A(e).toLowerCase();return r.includes("rate limit")||r.includes("abuse detection")}return!1}function pE(e){if(!e||typeof e!="object")return!1;let t=Ye(e);if(typeof t=="number"&&t>=500&&t<600)return!0;let r=e.code;if(typeof r=="string"&&(r==="ECONNRESET"||r==="ETIMEDOUT"||r==="ENETUNREACH"||r==="ENOTFOUND"||r==="ECONNREFUSED"||r==="EAI_AGAIN"))return!0;let n=e.name;return typeof n=="string"&&(n==="AbortError"||n==="TimeoutError")}function dE(e){return t=>{if(Le(t))throw t;return _(e.module,`Failed to ${e.label}: ${A(t)}`),e.fallback}}function bp(e){if(e instanceof Ge)return"CONFIGURATION";if(e instanceof W)return"VALIDATION";if(e instanceof mr||e instanceof $r)return"CONCURRENCY";let t=Ye(e);if(t===401)return"AUTH_REQUIRED";if(t===403){let n=A(e).toLowerCase();return n.includes("rate limit")||n.includes("abuse detection")?"RATE_LIMITED":"AUTH_REQUIRED"}if(t===404)return"NOT_FOUND";if(t===429)return"RATE_LIMITED";let r=A(e).toLowerCase();return r.includes("enotfound")||r.includes("econnrefused")||r.includes("econnreset")||r.includes("etimedout")||r.includes("fetch failed")?"NETWORK":r.includes("state")&&(r.includes("corrupt")||r.includes("invalid"))?"STATE_CORRUPTED":"UNKNOWN"}var or,Ge,yp,W,Zo,qa,mr,$r,ew,ie=C(()=>{"use strict";de();or=class extends Error{constructor(r,n){super(r);this.code=n;this.name="OssAutopilotError"}code},Ge=class extends or{constructor(t){super(t,"CONFIGURATION_ERROR"),this.name="ConfigurationError"}},yp="OSS_AUTOPILOT_UNATTENDED";W=class extends or{constructor(t){super(t,"VALIDATION_ERROR"),this.name="ValidationError"}},Zo=class extends Ge{constructor(t){super(t??'Your GitHub token does not have Gist permissions. Run `gh auth refresh -s gist` to add the required scope, or create a token with the "gist" scope.'),this.name="GistPermissionError"}},qa=class extends Ge{constructor(r,n,s){let o=s instanceof Error?s.message:String(s),i=n?`
59
59
  Corrupt content preserved at: ${n}
60
60
  Inspect or restore manually, then re-run. Falling back to a fresh state would overwrite your Gist.`:`
61
61
  Could not preserve the rejected content; do not push without inspecting the Gist manually.`;super(`Gist ${r} state.json is corrupt or fails schema validation: ${o}${i}`);this.gistId=r;this.rejectedPath=n;this.cause=s;this.name="GistCorruptError"}gistId;rejectedPath;cause},mr=class extends or{constructor(r,n){super("Another oss-autopilot process wrote state.json concurrently. Re-run the command to retry \u2014 the last write wins and no data was lost from the other process.","CONCURRENCY_ERROR");this.expectedMtimeMs=r;this.actualMtimeMs=n;this.name="ConcurrencyError"}expectedMtimeMs;actualMtimeMs},$r=class extends or{constructor(r,n){super("Another machine pushed to the state Gist while this push was in flight, and the merge attempt also collided. Re-run `oss-autopilot state --sync` to retry \u2014 your local mutations are still in memory.","CONCURRENCY_ERROR");this.expectedEtag=r;this.remoteEtag=n;this.name="GistConcurrencyError"}expectedEtag;remoteEtag};ew=/users.*do not exist|cannot be searched/i});function EF(e){try{let t=JSON.parse(te.readFileSync(e,"utf8"));return Date.now()-t.timestamp>kF}catch(t){return I(X,"Lock file unreadable or invalid JSON, treating as stale",t),!0}}function gE(e){let t=JSON.stringify({pid:process.pid,timestamp:Date.now()});try{te.writeFileSync(e,t,{flag:"wx"});return}catch(r){I(X,"Lock file already exists, checking staleness",r)}if(!EF(e))throw new Error("State file is locked by another process");try{te.unlinkSync(e)}catch(r){I(X,"Stale lock already removed by another process",r)}try{te.writeFileSync(e,t,{flag:"wx"})}catch(r){throw I(X,"Lock re-acquire failed (race condition)",r),new Error("State file is locked by another process",{cause:r})}}function hE(e){try{JSON.parse(te.readFileSync(e,"utf8")).pid===process.pid&&te.unlinkSync(e)}catch(t){I(X,"Lock file already removed or unreadable during release",t)}}function ir(e,t,r){let n=e+".tmp";te.writeFileSync(n,t,{mode:r??384}),te.renameSync(n,e),r!==void 0&&te.chmodSync(e,r)}function Jo(e){I(X,"Migrating state from v1 to v2 (fresh GitHub fetching)...");let t=e.mergedPRs||[],r=e.closedPRs||[],n={...e.repoScores||{}};for(let o of[...t,...r])n[o.repo]||(n[o.repo]={repo:o.repo,score:5,mergedPRCount:0,closedWithoutMergeCount:0,avgResponseDays:null,lastEvaluatedAt:new Date().toISOString(),signals:{hasActiveMaintainers:!0,isResponsive:!1,hasHostileComments:!1}});let s={version:2,activeIssues:e.activeIssues||[],repoScores:n,config:e.config,lastRunAt:new Date().toISOString()};return I(X,`Migration complete. Preserved ${Object.keys(n).length} repo scores.`),s}function Ko(e){I(X,"Migrating state from v2 to v3 (drop dead fields, add learnings tracking)..."),delete e.events,delete e.dailyActivityCounts;let t=e.config;return t&&(delete t.showHealthCheck,delete t.scoreThreshold),e.version=3,I(X,"v2 to v3 migration complete."),e}function Yo(e){return I(X,"Migrating state from v3 to v4 (add commentsFetchedAt to stored PR records)..."),e.version=4,I(X,"v3 to v4 migration complete (no data transformation required)."),e}function Xr(){return Lt.parse({version:4})}function PF(){let e=St(),t=iE(),r=aE();if(te.existsSync(e)||!te.existsSync(t))return!1;I(X,"Migrating state from ./data/ to ~/.oss-autopilot/...");try{if(sr(),te.copyFileSync(t,e),I(X,`Migrated state file to ${e}`),te.existsSync(r)){let s=_s(),o=te.readdirSync(r).filter(i=>i.startsWith("state-")&&i.endsWith(".json"));for(let i of o){let a=Qr.join(r,i),c=Qr.join(s,i);te.copyFileSync(a,c)}I(X,`Migrated ${o.length} backup files`)}if(te.unlinkSync(t),I(X,"Removed legacy state file"),te.existsSync(r)){let s=te.readdirSync(r);for(let o of s)te.unlinkSync(Qr.join(r,o));te.rmdirSync(r)}let n=Qr.dirname(t);return te.existsSync(n)&&te.readdirSync(n).length===0&&(te.rmdirSync(n),I(X,"Removed empty legacy data directory")),I(X,"Migration complete!"),!0}catch(n){if(_(X,`Failed to migrate state: ${A(n)}`),te.existsSync(e)&&te.existsSync(t))try{te.unlinkSync(e),I(X,"Cleaned up partial migration - removed incomplete new state file")}catch(s){_(X,"Could not clean up partial migration file"),I(X,"Partial migration cleanup failed",s)}return _(X,"To resolve this issue:"),_(X," 1. Ensure you have write permissions to ~/.oss-autopilot/"),_(X," 2. Check available disk space"),_(X," 3. Manually copy ./data/state.json to ~/.oss-autopilot/state.json"),_(X," 4. Or delete ./data/state.json to start fresh"),!1}}function mE(){let e=_s();if(!te.existsSync(e))return null;let t=te.readdirSync(e).filter(r=>r.startsWith("state-")&&r.endsWith(".json")).sort().reverse();for(let r of t){let n=Qr.join(e,r);try{let s=te.readFileSync(n,"utf8"),o=JSON.parse(s);if(typeof o=="object"&&o!==null){let c=o;c.version===1&&(o=Jo(c)),o.version===2&&(o=Ko(o)),o.version===3&&(o=Yo(o))}let i=Lt.safeParse(o);if(i.success){let c=i.data;I(X,`Successfully restored state from backup: ${r}`);let l=Object.keys(c.repoScores).length;I(X,`Restored state v${c.version}: ${l} repo scores`);let p=St();return ir(p,JSON.stringify(c,null,2),384),I(X,"Restored backup written to main state file"),c}let a=i.error.issues.map(c=>`${c.path.join(".")}: ${c.message}`).join("; ");_(X,`Backup ${r} failed schema validation: ${a}`),I(X,`Backup ${r} full validation errors:`,i.error.issues)}catch(s){let o=s instanceof Error?s.message:String(s);_(X,`Backup ${r} is corrupted (${o}), trying next...`),I(X,`Backup ${r} parse failed`,s)}}return null}function fE(e){try{let t=e+".rejected-"+Date.now();return te.copyFileSync(e,t),_(X,`Previous state preserved at: ${t}`),t}catch(t){return _(X,`Could not preserve rejected state file: ${A(t)}`),null}}function wp(){PF();let e=St();try{if(te.existsSync(e)){let t=Ss(e),r=te.readFileSync(e,"utf8"),n=JSON.parse(r),s=!1;if(typeof n=="object"&&n!==null){let c=n;c.version===1&&(n=Jo(c),s=!0),n.version===2&&(n=Ko(n),s=!0),n.version===3&&(n=Yo(n),s=!0)}let o=Lt.safeParse(n);if(!o.success){let c=o.error.issues.map(m=>`${m.path.join(".")}: ${m.message}`).join("; ");_(X,`Invalid state file structure: ${c}`),_(X,"Attempting to restore from backup..."),I(X,"Full validation errors:",o.error.issues);let l=fE(e),p=`Invalid state file structure: ${c}`,d=mE();if(d){let m=Ss(e);return{state:d,mtimeMs:m,recovery:{source:"backup",rejectedPath:l,reason:p}}}return _(X,"No valid backup found, starting fresh"),{state:Xr(),mtimeMs:0,recovery:{source:"fresh",rejectedPath:l,reason:p}}}s&&(ir(e,JSON.stringify(o.data,null,2),384),t=Ss(e),I(X,"Migrated and validated state saved"));let i=o.data;try{let c=!1;if(i.config.dismissedIssues){let l=/\/pull\/\d+$/;for(let p of Object.keys(i.config.dismissedIssues))l.test(p)&&(delete i.config.dismissedIssues[p],c=!0)}c&&(ir(e,JSON.stringify(i,null,2),384),t=Ss(e),_(X,"Cleaned up dismissed PR URLs from persisted state"))}catch(c){_(X,`Failed to clean up removed features from state: ${A(c)}`)}let a=Object.keys(i.repoScores).length;return I(X,`Loaded state v${i.version}: ${a} repo scores tracked`),{state:i,mtimeMs:t}}}catch(t){let r=t?.code;if(r==="EACCES"||r==="EPERM")throw new Error(`Permission denied reading state file (${r}): ${A(t)}. This is an environment problem, not state corruption. Check the ownership and permissions of ~/.oss-autopilot/state.json (e.g. run \`ls -l ~/.oss-autopilot/state.json\` and fix with chown/chmod), then retry.`,{cause:t});_(X,"Error loading state:",t),_(X,"Attempting to restore from backup...");let n=te.existsSync(e)?fE(e):null,s=`Error loading state: ${A(t)}`,o=mE();if(o){let i=Ss(e);return{state:o,mtimeMs:i,recovery:{source:"backup",rejectedPath:n,reason:s}}}return _(X,"No valid backup found, starting fresh"),{state:Xr(),mtimeMs:0,recovery:{source:"fresh",rejectedPath:n,reason:s}}}return I(X,"No existing state found, initializing..."),{state:Xr(),mtimeMs:0}}function Ss(e){try{return te.statSync(e).mtimeMs}catch(t){return I(X,`Could not read state file mtime (reload detection will always trigger): ${A(t)}`),0}}function CF(){let e=_s();try{let t=te.readdirSync(e).filter(r=>r.startsWith("state-")).sort().reverse();for(let r of t.slice(10))try{te.unlinkSync(Qr.join(e,r))}catch(n){_(X,`Could not delete old backup ${r}:`,A(n))}}catch(t){_(X,"Could not clean up backups:",A(t))}}function yE(e,t=null){let r=St(),n=r+".lock",s=_s();gE(n);try{if(t!==null&&t>0&&te.existsSync(r)){let i=Ss(r);if(i!==t)throw new mr(t,i)}try{if(te.existsSync(r)){let i=new Date().toISOString().replace(/[.:]/g,"-"),a=Math.random().toString(36).slice(2,8).padEnd(6,"0"),c=Qr.join(s,`state-${i}-${a}.json`);te.copyFileSync(r,c),te.chmodSync(c,384),CF()}}catch(i){_(X,`Could not create backup before save: ${A(i)}`)}ir(r,JSON.stringify(e,null,2),384);let o=Ss(r);return I(X,"State saved successfully"),o}finally{hE(n)}}function bE(e){try{let t=St();if(te.statSync(t).mtimeMs===e)return null;let n=wp();if(n.recovery)try{n.mtimeMs=te.statSync(t).mtimeMs}catch(s){I(X,"Could not re-read mtime after reload (will retry next cycle)",s)}return n}catch(t){return _(X,`Failed to reload state from disk: ${A(t)}`),null}}var te,Qr,X,kF,Ja=C(()=>{"use strict";te=H(require("node:fs"),1),Qr=H(require("node:path"),1);Dn();Yr();ie();de();X="state",kF=3e4});function Ar(e,t){return e===void 0||e<t}var tw,TF,_p,vs,ks,$F,Fn=C(()=>{"use strict";Dn();tw=pp.parse({}),TF=Lt.parse({version:4}),_p=Zb.options,vs=Jb.options,ks=Kb.options,$F={beginner:["good first issue","help wanted","easy","up-for-grabs","first-timers-only","beginner"],intermediate:["enhancement","feature","feature-request","contributions welcome"],advanced:["proposal","RFC","accepted","design"]}});function rw(e,t){return AF.test(e)&&OF.test(t)}function me(e){if(!e.startsWith("https://github.com/"))return null;let t=e.match(/github\.com\/([^/]+)\/([^/]+)\/pull\/(\d+)/);if(t){let n=t[1],s=t[2];return rw(n,s)?{owner:n,repo:s,number:parseInt(t[3],10),type:"pull"}:null}let r=e.match(/github\.com\/([^/]+)\/([^/]+)\/issues\/(\d+)/);if(r){let n=r[1],s=r[2];return rw(n,s)?{owner:n,repo:s,number:parseInt(r[3],10),type:"issues"}:null}return null}function Qo(e){if(!e.startsWith("https://github.com/"))return null;let t=e.match(/github\.com\/([^/]+)\/([^/]+)/);if(!t)return null;let r=t[1],n=t[2];return rw(r,n)?{owner:r,repo:n}:null}function Xo(e){let[t,r]=e.split("/");if(!t||!r)throw new Error(`Invalid repo format: expected "owner/repo", got "${e}"`);return{owner:t,repo:r}}function Or(e,t){return e.toLowerCase()===t.toLowerCase()}function Rp(e,t=[]){let r=e.toLowerCase();return t.some(n=>n.toLowerCase()===r)}var AF,OF,Zt=C(()=>{"use strict";AF=/^[\w-]+$/,OF=/^[\w.-]+$/});function zF(e){return{repo:e,score:SE,mergedPRCount:0,closedWithoutMergeCount:0,avgResponseDays:null,lastEvaluatedAt:new Date().toISOString(),signals:{hasActiveMaintainers:!0,isResponsive:!1,hasHostileComments:!1}}}function HF(e){let t=SE;if(e.mergedPRCount>0){let r=Math.min(Math.round(Math.log2(e.mergedPRCount+1)*xF),IF);t+=r}if(t-=Math.min(e.closedWithoutMergeCount,DF),e.lastMergedAt){let r=new Date(e.lastMergedAt);isNaN(r.getTime())?_(Ka,`Invalid lastMergedAt date for ${e.repo}: "${e.lastMergedAt}". Skipping recency bonus.`):Math.floor((Date.now()-r.getTime())/864e5)<=LF&&(t+=FF)}return e.signals.isResponsive&&(t+=MF),e.signals.hasHostileComments&&(t-=GF),Math.max(NF,Math.min(UF,t))}function vE(e,t){return e.repoScores[t]}function wE(e){return JSON.stringify([e.mergedPRCount,e.closedWithoutMergeCount,e.avgResponseDays??null,e.lastMergedAt??null,e.signals.hasActiveMaintainers,e.signals.isResponsive,e.signals.hasHostileComments])}function ei(e,t,r){let n=!e.repoScores[t];n&&(e.repoScores[t]=zF(t));let s=e.repoScores[t],o=wE(s);r.mergedPRCount!==void 0&&(s.mergedPRCount=r.mergedPRCount),r.closedWithoutMergeCount!==void 0&&(s.closedWithoutMergeCount=r.closedWithoutMergeCount),r.avgResponseDays!==void 0&&(s.avgResponseDays=r.avgResponseDays),r.lastMergedAt!==void 0&&(s.lastMergedAt=r.lastMergedAt),r.stargazersCount!==void 0&&(s.stargazersCount=r.stargazersCount),r.language!==void 0&&(s.language=r.language),r.signals&&(s.signals={...s.signals,...r.signals}),s.score=HF(s),(n||wE(s)!==o)&&(s.lastEvaluatedAt=new Date().toISOString()),I(Ka,`Updated repo score for ${t}: ${s.score}/10`)}function kE(e,t){let r=(e.repoScores[t]?.mergedPRCount??0)+1;ei(e,t,{mergedPRCount:r,lastMergedAt:new Date().toISOString()})}function EE(e,t){let r=(e.repoScores[t]?.closedWithoutMergeCount??0)+1;ei(e,t,{closedWithoutMergeCount:r})}function PE(e,t){ei(e,t,{signals:{hasHostileComments:!0}})}function CE(e){return Object.values(e.repoScores).filter(t=>t.mergedPRCount>0).sort((t,r)=>r.mergedPRCount-t.mergedPRCount).map(t=>t.repo)}function TE(e){return Object.values(e.repoScores).filter(t=>t.mergedPRCount===0&&t.closedWithoutMergeCount===0).sort((t,r)=>r.score-t.score).map(t=>t.repo)}function $E(e,t){let r=t??e.config.minRepoScoreThreshold;return Object.values(e.repoScores).filter(n=>n.score>=r).sort((n,s)=>s.score-n.score).map(n=>n.repo)}function AE(e,t){let r=t??e.config.minRepoScoreThreshold,n=Date.now();return Object.values(e.repoScores).filter(s=>{if(s.score>r)return!1;let o=n-new Date(s.lastEvaluatedAt).getTime();return Number.isFinite(o)?o<=jF:(_(Ka,`Invalid lastEvaluatedAt for repo ${s.repo}: "${s.lastEvaluatedAt}", treating as stale`),!1)}).sort((s,o)=>s.score-o.score).map(s=>s.repo)}function _E(e){let t=new Map;for(let r of e){let n=me(r.url);if(!n){_(Ka,`Skipping PR with unparseable URL during reconciliation: "${r.url}"`);continue}let s=`${n.owner}/${n.repo}`;t.set(s,(t.get(s)??0)+1)}return t}function OE(e,t,r){let n=RE(e,_E(t),"mergedPRCount"),s=RE(e,_E(r),"closedWithoutMergeCount");return n||s}function RE(e,t,r){let n=!1;for(let[s,o]of t){let i=e.repoScores[s]?.[r]??0;o>i&&(I(Ka,`Reconciling ${s} ${r}: ${i} \u2192 ${o}`),ei(e,s,{[r]:o}),n=!0)}return n}function xE(e){let t=0,r=0,n=0;for(let i of Object.values(e.repoScores))Ar(i.stargazersCount,e.config.minStars??50)||(n++,t+=i.mergedPRCount,r+=i.closedWithoutMergeCount);let s=t+r,o=s>0?t/s*100:0;return{mergedPRs:t,closedPRs:r,activeIssues:0,trustedProjects:e.config.trustedProjects.length,mergeRate:o.toFixed(1)+"%",totalTracked:n,needsResponse:0}}var Ka,SE,xF,IF,DF,LF,FF,MF,GF,NF,UF,jF,IE=C(()=>{"use strict";Fn();de();Zt();Ka="scoring",SE=5,xF=2,IF=5,DF=3,LF=90,FF=1,MF=1,GF=2,NF=1,UF=10,jF=720*60*60*1e3});function DE(e){return e?e.etag??e.ETag??null:null}function nw(e,t){try{let r=`${Ln()}.rejected-${Date.now()}`;return xr.writeFileSync(r,e,{encoding:"utf8",mode:384}),r}catch(r){return _(Se,`Could not preserve rejected Gist content for ${t}: ${r instanceof Error?r.message:String(r)}`),null}}var xr,Se,sw,en,ti,ow=C(()=>{"use strict";xr=H(require("node:fs"),1);Dn();Ja();Yr();de();ie();Se="gist-store";sw="oss-autopilot-state",en="state.json",ti=class e{gistId=null;cachedFiles=new Map;dirtyFiles=new Set;baselineFiles=new Map;lastFetchedEtag=null;octokit;lastRefreshAt=0;static REFRESH_THROTTLE_MS=3e4;lastRefreshError=null;constructor(t){this.octokit=t}async bootstrap(){try{await this.checkGistScope();let t=this.readLocalGistId();if(t){I(Se,`Found local Gist ID: ${t}`);try{this.gistId=t;let o=await this.fetchAndCache(t);return{gistId:t,state:o,created:!1}}catch(o){if(o instanceof Ge||Mt(o))throw o;_(Se,`Failed to fetch Gist ${t}, will search/create`,o)}}let r=await this.searchForGist();if(r){I(Se,`Found Gist via search: ${r}`),this.gistId=r,this.writeLocalGistId(r);let o=await this.fetchAndCache(r);return{gistId:r,state:o,created:!1}}I(Se,"No existing Gist found, creating new one");let{id:n,state:s}=await this.createGist();return this.writeLocalGistId(n),{gistId:n,state:s,created:!0}}catch(t){if(t instanceof Ge||Mt(t))throw t;this.gistId=null,this.lastFetchedEtag=null,_(Se,"All Gist API paths failed, entering degraded mode",t);let r=Ln(),n=null;try{if(xr.existsSync(r)){n=xr.readFileSync(r,"utf8");let s=JSON.parse(n);if(typeof s=="object"&&s!==null){let i=s;i.version===1&&(s=Jo(i)),s.version===2&&(s=Ko(s)),s.version===3&&(s=Yo(s))}let o=Lt.parse(s);return I(Se,"Loaded state from local cache in degraded mode"),{gistId:"",state:o,created:!1,degraded:!0}}}catch(s){if(n){let o=nw(n,"local-cache");_(Se,`Local state cache failed to parse in degraded mode: ${s instanceof Error?s.message:String(s)}. Corrupt cache preserved at: ${o??"(could not preserve)"}`)}else _(Se,`Failed to read local cache in degraded mode: ${s instanceof Error?s.message:String(s)}`)}return I(Se,"No local cache found, returning fresh state in degraded mode"),{gistId:"",state:Xr(),created:!1,degraded:!0}}}async bootstrapWithMigration(t){try{await this.checkGistScope();let r=this.readLocalGistId();if(r){I(Se,`bootstrapWithMigration: found local Gist ID: ${r}`);try{this.gistId=r;let i=await this.fetchAndCache(r);return{gistId:r,state:i,created:!1,migrated:!1}}catch(i){if(i instanceof Ge||Mt(i))throw i;_(Se,`bootstrapWithMigration: failed to fetch Gist ${r}, will search/create`,i)}}let n=await this.searchForGist();if(n){I(Se,`bootstrapWithMigration: found Gist via search: ${n}`),this.gistId=n,this.writeLocalGistId(n);let i=await this.fetchAndCache(n);return{gistId:n,state:i,created:!1,migrated:!1}}I(Se,"bootstrapWithMigration: no existing Gist found, creating one seeded with local state");let{id:s,state:o}=await this.createGistFromState(t);return this.writeLocalGistId(s),{gistId:s,state:o,created:!0,migrated:!0}}catch(r){if(r instanceof Ge||Mt(r))throw r;this.gistId=null,this.lastFetchedEtag=null,_(Se,"bootstrapWithMigration: all Gist API paths failed, entering degraded mode",r);let n=Ln(),s=null;try{if(xr.existsSync(n)){s=xr.readFileSync(n,"utf8");let o=JSON.parse(s);if(typeof o=="object"&&o!==null){let a=o;a.version===1&&(o=Jo(a)),o.version===2&&(o=Ko(o)),o.version===3&&(o=Yo(o))}let i=Lt.parse(o);return I(Se,"bootstrapWithMigration: loaded state from local cache in degraded mode"),{gistId:"",state:i,created:!1,degraded:!0,migrated:!1}}}catch(o){if(s){let i=nw(s,"local-cache");_(Se,`bootstrapWithMigration: local cache failed to parse: ${o instanceof Error?o.message:String(o)}. Corrupt cache preserved at: ${i??"(could not preserve)"}`)}else _(Se,`bootstrapWithMigration: failed to read local cache: ${o instanceof Error?o.message:String(o)}`)}return I(Se,"bootstrapWithMigration: no local cache found, returning existing state in degraded mode"),{gistId:"",state:t,created:!1,degraded:!0,migrated:!1}}}getGistId(){return this.gistId}markDirty(t){this.dirtyFiles.add(t)}getDocument(t){return this.cachedFiles.get(t)??null}setDocument(t,r){this.cachedFiles.set(t,r),this.markDirty(t)}listDocuments(t){let r=[];for(let n of this.cachedFiles.keys())n.startsWith(t)&&r.push(n);return r}setState(t){this.cachedFiles.set(en,t),this.markDirty(en)}async push(){if(this.dirtyFiles.size===0)return!0;if(this.gistId===null)throw new Error("GistStateStore: cannot push before bootstrap \u2014 gistId is null");let t=()=>{let o={};for(let i of this.dirtyFiles){let a=this.cachedFiles.get(i);a!==void 0&&(o[i]={content:a})}return o},r=async()=>{try{let o={gist_id:this.gistId,files:t()},i=await this.octokit.gists.update(o),a=DE(i.headers);return a&&(this.lastFetchedEtag=a),{ok:!0}}catch(o){return{ok:!1,status:o.status,err:o}}};if(this.dirtyFiles.has(en)){let o={};for(let m of this.dirtyFiles){let f=this.cachedFiles.get(m);f!==void 0&&(o[m]=f)}let i=new Map(this.cachedFiles),a=new Map(this.baselineFiles),c=this.lastFetchedEtag,l=a.get(en),p=()=>{for(let[m,f]of Object.entries(o))this.cachedFiles.set(m,f)};try{await this.fetchAndCache(this.gistId)}catch(m){_(Se,`Pre-write re-read failed: ${m}`),this.cachedFiles.clear();for(let[f,g]of i)this.cachedFiles.set(f,g);throw this.baselineFiles=a,this.lastFetchedEtag=c,p(),m instanceof qa||Mt(m)?m:new $r(c,null)}let d=this.cachedFiles.get(en);if(l!==d)throw _(Se,"state.json changed remotely since our last fetch; surfacing GistConcurrencyError instead of clobbering (#1235, #1510)"),p(),new $r(c,this.lastFetchedEtag);p()}let n=await r();if(!n.ok&&(I(Se,`push failed on first attempt, retrying: ${n.err}`),n=await r(),!n.ok))return _(Se,`push failed after retry, giving up: ${n.err}`),!1;if(this.dirtyFiles.clear(),this.baselineFiles=new Map(this.cachedFiles),this.cachedFiles.get(en))try{let o=this.parseStateFromCache();this.writeLocalStateCache(o)}catch(o){I(Se,`push succeeded but local cache write failed: ${o}`)}return!0}async refreshFromGist(){if(!this.gistId)return{status:"no-gist"};let t=Date.now(),r=t-this.lastRefreshAt;if(r<e.REFRESH_THROTTLE_MS)return{status:"throttled",sinceLastMs:r};this.lastRefreshAt=t;try{return await this.fetchAndCache(this.gistId),this.lastRefreshError=null,{status:"refreshed"}}catch(n){let s=n instanceof Error?n:new Error(String(n));return _(Se,`refreshFromGist failed: ${s.message}`),this.lastRefreshError=s,{status:"error",error:s}}}async checkGistScope(){try{await this.octokit.gists.list({per_page:1,page:1})}catch(t){if(Mt(t))throw t;let r=t.status;throw r===401||r===403?new Zo:t}}async fetchAndCache(t){let r=await this.octokit.gists.get({gist_id:t});this.gistId=t,this.lastFetchedEtag=DE(r.headers),this.cachedFiles.clear();for(let[s,o]of Object.entries(r.data.files))o&&o.content!=null&&this.cachedFiles.set(s,o.content);this.baselineFiles=new Map(this.cachedFiles);let n=this.parseStateFromCache();return this.writeLocalStateCache(n),n}parseStateFromCache(){let t=this.cachedFiles.get(en);if(!t)return I(Se,"No state.json found in Gist, using fresh state"),Xr();try{let r=JSON.parse(t);if(typeof r=="object"&&r!==null){let n=r;n.version===1&&(r=Jo(n)),r.version===2&&(r=Ko(r)),r.version===3&&(r=Yo(r))}return Lt.parse(r)}catch(r){let n=nw(t,this.gistId??"unknown");throw _(Se,`Gist state.json failed to parse \u2014 refusing to overwrite with fresh state. Corrupt content preserved at: ${n??"(could not preserve)"}`),new qa(this.gistId??"unknown",n,r)}}async searchForGist(){try{for(let r=1;r<=10;r++){let{data:n}=await this.octokit.gists.list({per_page:100,page:r});if(n.length===0)break;let s=n.find(o=>o.description===sw);if(s)return s.id}}catch(t){if(Mt(t))throw t;_(Se,"Failed to search Gists by description",t)}return null}async createGist(){let t=Xr(),r=JSON.stringify(t,null,2),{data:n}=await this.octokit.gists.create({description:sw,public:!1,files:{[en]:{content:r}}});this.gistId=n.id,this.cachedFiles.clear();for(let[s,o]of Object.entries(n.files))o&&o.content!=null&&this.cachedFiles.set(s,o.content);return this.baselineFiles=new Map(this.cachedFiles),this.writeLocalStateCache(t),{id:n.id,state:t}}async createGistFromState(t){let r=JSON.stringify(t,null,2),{data:n}=await this.octokit.gists.create({description:sw,public:!1,files:{[en]:{content:r}}});this.gistId=n.id,this.cachedFiles.clear();for(let[s,o]of Object.entries(n.files))o&&o.content!=null&&this.cachedFiles.set(s,o.content);return this.baselineFiles=new Map(this.cachedFiles),this.writeLocalStateCache(t),{id:n.id,state:t}}readLocalGistId(){try{let t=Rs();if(xr.existsSync(t))return xr.readFileSync(t,"utf8").trim()||null}catch(t){I(Se,"Could not read local Gist ID file",t)}return null}writeLocalGistId(t){try{let r=Rs();ir(r,t,384),I(Se,`Wrote Gist ID to ${r}`)}catch(r){_(Se,`Failed to write local Gist ID file: ${r}`)}}writeLocalStateCache(t){try{let r=Ln();ir(r,JSON.stringify(t,null,2),384),I(Se,`Wrote state cache to ${r}`)}catch(r){_(Se,`Failed to write local state cache: ${r}`)}}}});function Qa(e){if(!e.includes("/"))throw new or(`Invalid repo identifier "${e}". Expected "owner/repo" format.`,"INVALID_REPO_ID");let[t,r]=e.split("/");return`${ri}${t}--${r}${iw}`}function aw(e){if(!e.startsWith(ri)||!e.endsWith(iw))return null;let t=e.slice(ri.length,e.length-iw.length),r=t.indexOf("--");if(r===-1)return null;let n=t.slice(0,r),s=t.slice(r+2);return!n||!s?null:`${n}/${s}`}function LE(e,t){if(!e)return null;let r=e.getDocument(Qa(t));return r===null||r===""?null:r}function FE(e,t,r){if(!e)throw new Mn;let n=Buffer.byteLength(r,"utf8");if(n>Sp)throw new Ya(n);e.setDocument(Qa(t),r)}function ME(e,t){if(!e)throw new Mn;e.setDocument(Qa(t),"")}function GE(e){if(!e)return[];let t=e.listDocuments(ri),r=[];for(let n of t){let s=aw(n);if(!s)continue;let o=e.getDocument(n);o===null||o===""||r.push(s)}return r.sort()}var ri,Sp,iw,Mn,Ya,cw=C(()=>{"use strict";ie();ri="guidelines--",Sp=8192,iw=".md";Mn=class extends or{constructor(t){super(t??"Per-repo guidelines require Gist persistence. Run `oss-autopilot setup` to enable Gist sync, then retry.","GUIDELINES_NOT_AVAILABLE"),this.name="GuidelinesNotAvailableError"}},Ya=class extends or{constructor(t,r=Sp){super(`Guidelines content is ${t} bytes, exceeding the ${r}-byte cap. Trim or split across categories.`,"GUIDELINES_TOO_LARGE"),this.name="GuidelinesTooLargeError"}}});function ni(e,t={}){return`Gist persistence is configured but ${typeof e=="string"?WF[e]:e.reason}; writes are LOCAL-ONLY and may be overwritten by the next successful Gist sync.${t.retryHint?` ${t.retryHint}`:""}`}var WF,uw=C(()=>{"use strict";WF={"no-token":"no GitHub token was available","state-unreadable":"the state file could not be read","init-fallback":"initialization hit a transient network failure","configured-but-local":"this process is running local-only (Gist init has not succeeded)","bootstrap-degraded":"the Gist bootstrap fell back to the local cache (reads may be stale and pushes are failing)"}});function Gn(){return typeof navigator=="object"&&"userAgent"in navigator?navigator.userAgent:typeof process=="object"&&process.version!==void 0?`Node.js/${process.version.substr(1)} (${process.platform}; ${process.arch})`:"<environment undetectable>"}var Xa=C(()=>{});function vp(e,t,r,n){if(typeof r!="function")throw new Error("method for before hook must be a function");return n||(n={}),Array.isArray(t)?t.reverse().reduce((s,o)=>vp.bind(null,e,o,s,n),r)():Promise.resolve().then(()=>e.registry[t]?e.registry[t].reduce((s,o)=>o.hook.bind(null,s,n),r)():r(n))}var NE=C(()=>{});function UE(e,t,r,n){let s=n;e.registry[r]||(e.registry[r]=[]),t==="before"&&(n=(o,i)=>Promise.resolve().then(s.bind(null,i)).then(o.bind(null,i))),t==="after"&&(n=(o,i)=>{let a;return Promise.resolve().then(o.bind(null,i)).then(c=>(a=c,s(a,i))).then(()=>a)}),t==="error"&&(n=(o,i)=>Promise.resolve().then(o.bind(null,i)).catch(a=>s(a,i))),e.registry[r].push({hook:n,orig:s})}var jE=C(()=>{});function zE(e,t,r){if(!e.registry[t])return;let n=e.registry[t].map(s=>s.orig).indexOf(r);n!==-1&&e.registry[t].splice(n,1)}var HE=C(()=>{});function WE(e,t,r){let n=BE(zE,null).apply(null,r?[t,r]:[t]);e.api={remove:n},e.remove=n,["before","error","after","wrap"].forEach(s=>{let o=r?[t,s,r]:[t,s];e[s]=e.api[s]=BE(UE,null).apply(null,o)})}function qF(){let e=Symbol("Singular"),t={registry:{}},r=vp.bind(null,t,e);return WE(r,t,e),r}function ZF(){let e={registry:{}},t=vp.bind(null,e);return WE(t,e),t}var VE,BE,qE,ZE=C(()=>{NE();jE();HE();VE=Function.bind,BE=VE.bind(VE);qE={Singular:qF,Collection:ZF}});function QF(e){return e?Object.keys(e).reduce((t,r)=>(t[r.toLowerCase()]=e[r],t),{}):{}}function XF(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let r=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&Function.prototype.call(r)===Function.prototype.call(e)}function YE(e,t){let r=Object.assign({},e);return Object.keys(t).forEach(n=>{XF(t[n])?n in e?r[n]=YE(e[n],t[n]):Object.assign(r,{[n]:t[n]}):Object.assign(r,{[n]:t[n]})}),r}function JE(e){for(let t in e)e[t]===void 0&&delete e[t];return e}function pw(e,t,r){if(typeof t=="string"){let[s,o]=t.split(" ");r=Object.assign(o?{method:s,url:o}:{url:s},r)}else r=Object.assign({},t);r.headers=QF(r.headers),JE(r),JE(r.headers);let n=YE(e||{},r);return r.url==="/graphql"&&(e&&e.mediaType.previews?.length&&(n.mediaType.previews=e.mediaType.previews.filter(s=>!n.mediaType.previews.includes(s)).concat(n.mediaType.previews)),n.mediaType.previews=(n.mediaType.previews||[]).map(s=>s.replace(/-preview/,""))),n}function eM(e,t){let r=/\?/.test(e)?"&":"?",n=Object.keys(t);return n.length===0?e:e+r+n.map(s=>s==="q"?"q="+t.q.split("+").map(encodeURIComponent).join("+"):`${s}=${encodeURIComponent(t[s])}`).join("&")}function rM(e){return e.replace(/(?:^\W+)|(?:(?<!\W)\W+$)/g,"").split(/,/)}function nM(e){let t=e.match(tM);return t?t.map(rM).reduce((r,n)=>r.concat(n),[]):[]}function KE(e,t){let r={__proto__:null};for(let n of Object.keys(e))t.indexOf(n)===-1&&(r[n]=e[n]);return r}function QE(e){return e.split(/(%[0-9A-Fa-f]{2})/g).map(function(t){return/%[0-9A-Fa-f]/.test(t)||(t=encodeURI(t).replace(/%5B/g,"[").replace(/%5D/g,"]")),t}).join("")}function oi(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()})}function ec(e,t,r){return t=e==="+"||e==="#"?QE(t):oi(t),r?oi(r)+"="+t:t}function si(e){return e!=null}function lw(e){return e===";"||e==="&"||e==="?"}function sM(e,t,r,n){var s=e[r],o=[];if(si(s)&&s!=="")if(typeof s=="string"||typeof s=="number"||typeof s=="bigint"||typeof s=="boolean")s=s.toString(),n&&n!=="*"&&(s=s.substring(0,parseInt(n,10))),o.push(ec(t,s,lw(t)?r:""));else if(n==="*")Array.isArray(s)?s.filter(si).forEach(function(i){o.push(ec(t,i,lw(t)?r:""))}):Object.keys(s).forEach(function(i){si(s[i])&&o.push(ec(t,s[i],i))});else{let i=[];Array.isArray(s)?s.filter(si).forEach(function(a){i.push(ec(t,a))}):Object.keys(s).forEach(function(a){si(s[a])&&(i.push(oi(a)),i.push(ec(t,s[a].toString())))}),lw(t)?o.push(oi(r)+"="+i.join(",")):i.length!==0&&o.push(i.join(","))}else t===";"?si(s)&&o.push(oi(r)):s===""&&(t==="&"||t==="?")?o.push(oi(r)+"="):s===""&&o.push("");return o}function oM(e){return{expand:iM.bind(null,e)}}function iM(e,t){var r=["+","#",".","/",";","?","&"];return e=e.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g,function(n,s,o){if(s){let a="",c=[];if(r.indexOf(s.charAt(0))!==-1&&(a=s.charAt(0),s=s.substr(1)),s.split(/,/g).forEach(function(l){var p=/([^:\*]*)(?::(\d+)|(\*))?/.exec(l);c.push(sM(t,a,p[1],p[2]||p[3]))}),a&&a!=="+"){var i=",";return a==="?"?i="&":a!=="#"&&(i=a),(c.length!==0?a:"")+c.join(i)}else return c.join(",")}else return QE(o)}),e==="/"?e:e.replace(/\/$/,"")}function XE(e){let t=e.method.toUpperCase(),r=(e.url||"/").replace(/:([a-z]\w+)/g,"{$1}"),n=Object.assign({},e.headers),s,o=KE(e,["method","baseUrl","url","headers","request","mediaType"]),i=nM(r);r=oM(r).expand(o),/^http/.test(r)||(r=e.baseUrl+r);let a=Object.keys(e).filter(p=>i.includes(p)).concat("baseUrl"),c=KE(o,a);if(!/application\/octet-stream/i.test(n.accept)&&(e.mediaType.format&&(n.accept=n.accept.split(/,/).map(p=>p.replace(/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/,`application/vnd$1$2.${e.mediaType.format}`)).join(",")),r.endsWith("/graphql")&&e.mediaType.previews?.length)){let p=n.accept.match(/(?<![\w-])[\w-]+(?=-preview)/g)||[];n.accept=p.concat(e.mediaType.previews).map(d=>{let m=e.mediaType.format?`.${e.mediaType.format}`:"+json";return`application/vnd.github.${d}-preview${m}`}).join(",")}return["GET","HEAD"].includes(t)?r=eM(r,c):"data"in c?s=c.data:Object.keys(c).length&&(s=c),!n["content-type"]&&typeof s<"u"&&(n["content-type"]="application/json; charset=utf-8"),["PATCH","PUT"].includes(t)&&typeof s>"u"&&(s=""),Object.assign({method:t,url:r,headers:n},typeof s<"u"?{body:s}:null,e.request?{request:e.request}:null)}function aM(e,t,r){return XE(pw(e,t,r))}function eP(e,t){let r=pw(e,t),n=aM.bind(null,r);return Object.assign(n,{DEFAULTS:r,defaults:eP.bind(null,r),merge:pw.bind(null,r),parse:XE})}var JF,KF,YF,tM,tP,rP=C(()=>{Xa();JF="0.0.0-development",KF=`octokit-endpoint.js/${JF} ${Gn()}`,YF={method:"GET",baseUrl:"https://api.github.com",headers:{accept:"application/vnd.github.v3+json","user-agent":KF},mediaType:{format:""}};tM=/\{[^{}}]+\}/g;tP=eP(null,YF)});var iP=RS((qq,tc)=>{"use strict";var Pp=function(){};Pp.prototype=Object.create(null);var kp=/; *([!#$%&'*+.^\w`|~-]+)=("(?:[\v\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\v\u0020-\u00ff])*"|[!#$%&'*+.^\w`|~-]+) */gu,Ep=/\\([\v\u0020-\u00ff])/gu,nP=/^[!#$%&'*+.^\w|~-]+\/[!#$%&'*+.^\w|~-]+$/u,Es={type:"",parameters:new Pp};Object.freeze(Es.parameters);Object.freeze(Es);function sP(e){if(typeof e!="string")throw new TypeError("argument header is required and must be a string");let t=e.indexOf(";"),r=t!==-1?e.slice(0,t).trim():e.trim();if(nP.test(r)===!1)throw new TypeError("invalid media type");let n={type:r.toLowerCase(),parameters:new Pp};if(t===-1)return n;let s,o,i;for(kp.lastIndex=t;o=kp.exec(e);){if(o.index!==t)throw new TypeError("invalid parameter format");t+=o[0].length,s=o[1].toLowerCase(),i=o[2],i[0]==='"'&&(i=i.slice(1,i.length-1),Ep.test(i)&&(i=i.replace(Ep,"$1"))),n.parameters[s]=i}if(t!==e.length)throw new TypeError("invalid parameter format");return n}function oP(e){if(typeof e!="string")return Es;let t=e.indexOf(";"),r=t!==-1?e.slice(0,t).trim():e.trim();if(nP.test(r)===!1)return Es;let n={type:r.toLowerCase(),parameters:new Pp};if(t===-1)return n;let s,o,i;for(kp.lastIndex=t;o=kp.exec(e);){if(o.index!==t)return Es;t+=o[0].length,s=o[1].toLowerCase(),i=o[2],i[0]==='"'&&(i=i.slice(1,i.length-1),Ep.test(i)&&(i=i.replace(Ep,"$1"))),n.parameters[s]=i}return t!==e.length?Es:n}tc.exports.default={parse:sP,safeParse:oP};tc.exports.parse=sP;tc.exports.safeParse=oP;tc.exports.defaultContentType=Es});var cM,uP,dw,aP,uM,lM,pM,lP,dM,mM,fM,pP,cP,gM,hM,dP,mP=C(()=>{cM=/^-?\d+$/,uP=/^-?\d+n+$/,dw=JSON.stringify,aP=JSON.parse,uM=/^-?\d+n$/,lM=/([\[:])?"(-?\d+)n"($|([\\n]|\s)*(\s|[\\n])*[,\}\]])/g,pM=/([\[:])?("-?\d+n+)n("$|"([\\n]|\s)*(\s|[\\n])*[,\}\]])/g,lP=(e,t,r)=>"rawJSON"in JSON?dw(e,(i,a)=>typeof a=="bigint"?JSON.rawJSON(a.toString()):typeof t=="function"?t(i,a):(Array.isArray(t)&&t.includes(i),a),r):e?dw(e,(i,a)=>typeof a=="string"&&!!a.match(uP)||typeof a=="bigint"?a.toString()+"n":typeof t=="function"?t(i,a):(Array.isArray(t)&&t.includes(i),a),r).replace(lM,"$1$2$3").replace(pM,"$1$2$3"):dw(e,t,r),dM=()=>JSON.parse("1",(e,t,r)=>!!r&&r.source==="1"),mM=(e,t,r,n)=>typeof t=="string"&&t.match(uM)?BigInt(t.slice(0,-1)):typeof t=="string"&&t.match(uP)?t.slice(0,-1):typeof n!="function"?t:n(e,t,r),fM=(e,t)=>JSON.parse(e,(r,n,s)=>{let o=typeof n=="number"&&(n>Number.MAX_SAFE_INTEGER||n<Number.MIN_SAFE_INTEGER),i=s&&cM.test(s.source);return o&&i?BigInt(s.source):typeof t!="function"?n:t(r,n,s)}),pP=Number.MAX_SAFE_INTEGER.toString(),cP=pP.length,gM=/"(?:\\.|[^"])*"|-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?/g,hM=/^"-?\d+n+"$/,dP=(e,t)=>{if(!e)return aP(e,t);if(dM())return fM(e,t);let r=e.replace(gM,(n,s,o,i)=>{let a=n[0]==='"';if(a&&!!n.match(hM))return n.substring(0,n.length-1)+'n"';let l=o||i,p=s&&(s.length<cP||s.length===cP&&s<=pP);return a||l||p?n:'"'+n+'n"'});return aP(r,(n,s,o)=>mM(n,s,o,t))}});var tn,mw=C(()=>{tn=class extends Error{name;status;request;response;constructor(t,r,n){super(t,{cause:n.cause}),this.name="HttpError",this.status=Number.parseInt(r),Number.isNaN(this.status)&&(this.status=0);"response"in n&&(this.response=n.response);let s=Object.assign({},n.request);n.request.headers.authorization&&(s.headers=Object.assign({},n.request.headers,{authorization:n.request.headers.authorization.replace(/(?<! ) .*$/," [REDACTED]")})),s.url=s.url.replace(/\bclient_secret=\w+/g,"client_secret=[REDACTED]").replace(/\baccess_token=\w+/g,"access_token=[REDACTED]"),this.request=s}}});function wM(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let r=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&Function.prototype.call(r)===Function.prototype.call(e)}async function gP(e){let t=e.request?.fetch||globalThis.fetch;if(!t)throw new Error("fetch is not set. Please pass a fetch implementation as new Octokit({ request: { fetch }}). Learn more at https://github.com/octokit/octokit.js/#fetch-missing");let r=e.request?.log||console,n=e.request?.parseSuccessResponseBody!==!1,s=wM(e.body)||Array.isArray(e.body)?lP(e.body):e.body,o=Object.fromEntries(Object.entries(e.headers).map(([d,m])=>[d,String(m)])),i;try{i=await t(e.url,{method:e.method,body:s,redirect:e.request?.redirect,headers:o,signal:e.request?.signal,...e.body&&{duplex:"half"}})}catch(d){let m="Unknown Error";if(d instanceof Error){if(d.name==="AbortError")throw d.status=500,d;m=d.message,d.name==="TypeError"&&"cause"in d&&(d.cause instanceof Error?m=d.cause.message:typeof d.cause=="string"&&(m=d.cause))}let f=new tn(m,500,{request:e});throw f.cause=d,f}let a=i.status,c=i.url,l={};for(let[d,m]of i.headers)l[d]=m;let p={url:c,status:a,headers:l,data:""};if("deprecation"in l){let d=l.link&&l.link.match(/<([^<>]+)>; rel="deprecation"/),m=d&&d.pop();r.warn(`[@octokit/request] "${e.method} ${e.url}" is deprecated. It is scheduled to be removed on ${l.sunset}${m?`. See ${m}`:""}`)}if(a===204||a===205)return p;if(e.method==="HEAD"){if(a<400)return p;throw new tn(i.statusText,a,{response:p,request:e})}if(a===304)throw p.data=await fw(i),new tn("Not modified",a,{response:p,request:e});if(a>=400)throw p.data=await fw(i),new tn(RM(p.data),a,{response:p,request:e});return p.data=n?await fw(i):i.body,p}async function fw(e){let t=e.headers.get("content-type");if(!t)return e.text().catch(fP);let r=(0,hP.safeParse)(t);if(_M(r)){let n="";try{return n=await e.text(),dP(n)}catch{return n}}else return r.type.startsWith("text/")||r.parameters.charset?.toLowerCase()==="utf-8"?e.text().catch(fP):e.arrayBuffer().catch(()=>new ArrayBuffer(0))}function _M(e){return e.type==="application/json"||e.type==="application/scim+json"}function RM(e){if(typeof e=="string")return e;if(e instanceof ArrayBuffer)return"Unknown error";if("message"in e){let t="documentation_url"in e?` - ${e.documentation_url}`:"";return Array.isArray(e.errors)?`${e.message}: ${e.errors.map(r=>JSON.stringify(r)).join(", ")}${t}`:`${e.message}${t}`}return`Unknown error: ${JSON.stringify(e)}`}function gw(e,t){let r=e.defaults(t);return Object.assign(function(s,o){let i=r.merge(s,o);if(!i.request||!i.request.hook)return gP(r.parse(i));let a=(c,l)=>gP(r.parse(r.merge(c,l)));return Object.assign(a,{endpoint:r,defaults:gw.bind(null,r)}),i.request.hook(a,i)},{endpoint:r,defaults:gw.bind(null,r)})}var hP,yM,bM,fP,rc,hw=C(()=>{rP();Xa();hP=H(iP(),1);mP();mw();yM="10.0.8",bM={headers:{"user-agent":`octokit-request.js/${yM} ${Gn()}`}};fP=()=>"";rc=gw(tP,bM);});function vM(e){return`Request failed due to following response errors:
@@ -252,7 +252,7 @@ ${o.join(`
252
252
  `)){if(/^\s*(```|~~~)/.test(p)){c=!c;continue}if(c||/^\s*#+\s/.test(p))continue;let d=p.replace(a,"").replace(/`[^`]*`/g,"");for(let m of d.matchAll(/(?:^|[^&\w])#(\d+)\b/g)){let f=Number.parseInt(m[1],10);f>0&&n.add(f)}}let l=/https?:\/\/github\.com\/([\w.-]+\/[\w.-]+)\/issues\/(\d+)/gi;for(let p of e.matchAll(l))if(p[1].toLowerCase()===s){let d=Number.parseInt(p[2],10);d>0&&n.add(d)}return n}async function Ud(e,t,r){let n=`${t}/${r}`.toLowerCase(),s=Vc.get(n);if(s&&Date.now()-s.fetchedAt<oO)return s.refs;let o=MR.get(n);if(o)return o;let i=h1(e,t,r,n);MR.set(n,i);try{return await i}finally{MR.delete(n)}}async function h1(e,t,r,n){for(let o of g1){let{text:i}=await Gi(e,t,r,o);if(!i)continue;let a=GR(i,t,r);return Vc.set(n,{refs:a,fetchedAt:Date.now()}),sO(),a}let s=new Set;return Vc.set(n,{refs:s,fetchedAt:Date.now()}),sO(),s}var oO,g1,Vc,MR,NR=C(()=>{Dd();oO=3600*1e3,g1=["ROADMAP.md","docs/ROADMAP.md",".github/ROADMAP.md","Roadmap.md","roadmap.md"],Vc=new Map;MR=new Map});function zR(e,t=jR){return Object.values(e).filter(r=>r.mergedPRCount>=t).sort((r,n)=>n.mergedPRCount-r.mergedPRCount).map(r=>r.repo)}function HR(e){if(e.hasMilestone||e.isOnRoadmap)return"bigger-bet";for(let t of e.labels)if(w1.has(t.toLowerCase()))return"bigger-bet";return"quick-win"}function jd(e,t,r=b1){let n=e.filter(g=>g.horizon==="quick-win").sort((g,h)=>h.viabilityScore-g.viabilityScore),s=e.filter(g=>g.horizon==="bigger-bet").sort((g,h)=>h.viabilityScore-g.viabilityScore),o=Math.max(0,Math.min(1,r)),i=Math.round(t*o),a=t-i,c=Math.min(n.length,i),l=Math.min(s.length,a),p=c,d=l,m=i-c,f=a-l;return m>0&&(d=Math.min(s.length,d+m)),f>0&&(p=Math.min(n.length,p+f)),{quickWins:n.slice(0,p),biggerBets:s.slice(0,d)}}function S1(e){if(!e.labels.some(o=>_1.has(o.toLowerCase())))return!1;let r=new Date(e.createdAt);return Number.isNaN(r.getTime())?!1:((e.now??new Date).getTime()-r.getTime())/(1e3*60*60*24)>=(e.minAgeDays??R1)}function lO(e){let t=new Set([...e.excludeRepos??[],...e.aiPolicyBlocklist??[]].map(n=>n.toLowerCase())),r=new Set((e.excludeOrgs??[]).map(n=>n.toLowerCase()));return n=>{let s=n.toLowerCase();if(t.has(s))return!1;let o=s.split("/")[0];return!(o&&r.has(o))}}function pO(e){return Array.isArray(e.labels)?e.labels.map(t=>typeof t=="string"?t:t?.name).filter(t=>typeof t=="string"):[]}function dO(e){let t=pO(e).map(r=>r.toLowerCase());return t.length===0||t.some(r=>uO.has(r))?!1:t.some(r=>zd.includes(r))}async function mO(e,t,r){let n=pO(e),s=!!e.milestone,o=e.reactions?.total_count??0,i=e.comments??0,a=e.created_at?S1({labels:n,createdAt:e.created_at}):!1,c=r!==void 0,l=c&&typeof e.number=="number"&&r.has(e.number),p;try{p=await t.vetIssue(e.html_url,{featureSignals:{reactions:o,comments:i,hasMilestone:s,wontfixNoContributor:a,...c?{onRoadmap:l}:{}}})}catch(m){return Me(m),z(UR,`vet failed for ${e.html_url}: ${Z(m)}`),null}let d=HR({hasMilestone:s,labels:n,...c?{isOnRoadmap:l}:{}});return{...p,horizon:d}}async function Hd(e){let t=lO(e),r=zR(e.repoScores,e.anchorThreshold).filter(t);if(r.length===0)return{quickWins:[],biggerBets:[],anchorRepos:[],message:VR};let n=[];for(let a=0;a<r.length;a++){a>0&&await Qt(y1);let[c,l]=r[a].split("/"),p,d;try{let[f,g]=await Promise.all([e.octokit.issues.listForRepo({owner:c,repo:l,state:"open",sort:"updated",direction:"desc",per_page:20}),Ud(e.octokit,c,l)]);p=f,d=g}catch(f){Me(f),z(UR,`failed to list issues for ${r[a]}: ${Z(f)}`);continue}let m=p.data.filter(f=>!f.pull_request&&!f.assignee&&dO(f));for(let f of m){let g=await mO(f,e.vetter,d);g&&n.push(g)}}let s=n.filter(a=>a.viabilityScore>=cO),o=jd(s,e.count,e.splitRatio),i=o.quickWins.length+o.biggerBets.length;return{...o,anchorRepos:r,message:i===0?BR:null}}function aO(e){let t=["is:issue","is:open","no:assignee"],r=`label:${zd.map(n=>JSON.stringify(n)).join(",")}`;t.push(r);for(let n of uO)t.push(`-label:"${n}"`);e.language&&t.push(`language:${e.language}`);for(let n of e.excludeRepos??[])t.push(`-repo:${n}`);for(let n of e.excludeOrgs??[])t.push(`-user:${n}`);return t.join(" ")}function k1(e){let t={excludeRepos:e.excludeRepos,excludeOrgs:e.excludeOrgs},r=(e.languages??[]).filter(n=>n&&n.toLowerCase()!=="any");return r.length===0?[aO(t)]:r.map(n=>aO({...t,language:n}))}async function fO(e){let t=k1({languages:e.languages,excludeRepos:e.excludeRepos,excludeOrgs:e.excludeOrgs}),r=e.maxToVet??v1,n;try{let c=[],l=new Set;for(let d of t){let m=await AR(e.octokit,{q:d,sort:"interactions",order:"desc",per_page:r});for(let f of m.items)l.has(f.html_url)||(l.add(f.html_url),c.push(f))}let p=lO(e);n=c.filter(d=>!d.pull_request&&!d.assignee&&dO(d)).filter(d=>{let m=We(d.html_url);return m===null||p(m)}).slice(0,r)}catch(c){return Me(c),z(UR,`broad feature search failed: ${Z(c)}`),{quickWins:[],biggerBets:[],anchorRepos:[],message:iO}}let s=[];for(let c of n){let l=await mO(c,e.vetter);l&&s.push(l)}let o=s.filter(c=>c.viabilityScore>=cO),i=jd(o,e.count,e.splitRatio),a=i.quickWins.length+i.biggerBets.length;return{...i,anchorRepos:[],message:a===0?iO:null}}var UR,y1,cO,jR,b1,w1,zd,uO,_1,R1,VR,BR,iO,v1,WR=C(()=>{st();rt();Pt();NR();DR();UR="feature-discovery",y1=2e3,cO=40,jR=3,b1=.6;w1=new Set(["roadmap","accepted-rfc","proposal"]);zd=["enhancement","feature","feature-request","proposal","roadmap","accepted-rfc"],uO=new Set(["good first issue","bug","documentation"]),_1=new Set(["help wanted","contributions welcome","up-for-grabs","bounty","pinned","unmaintained"]),R1=60;VR="No anchor repos yet (need 3+ merged PRs in a repo). Try `scout search` to build relationships first.",BR="No open feature opportunities in your anchor repos right now. Check back next week, or try `scout search` for fix-mode work.";iO="No open feature opportunities matched your filters. Try widening your language preferences in `scout config`.",v1=30});function C1(e){if(nt(e))return"rate_limit";let t=Ae(e);if(t!==void 0&&t>=500&&t<600)return"server";if(e&&typeof e=="object"&&"code"in e){let r=e.code;if(r==="ECONNREFUSED"||r==="ENOTFOUND"||r==="ETIMEDOUT"||r==="ECONNRESET"||r==="EAI_AGAIN")return"network"}return e instanceof Error&&e.message.toLowerCase().includes("fetch failed")?"network":"unknown"}function yO(){return JR.join(Li(),E1)}function bO(){return JR.join(Li(),P1)}function $1(e,t){let r=Date.now()-T1,n=new Map;for(let s of[...e,...t]){let o=n.get(s.url);(!o||s.removedAt>o.removedAt)&&n.set(s.url,s)}return[...n.values()].filter(s=>{let o=new Date(s.removedAt).getTime();return Number.isFinite(o)&&o>=r})}function wO(e,t,r,n){if(t.length===0)return e;let s=new Map(t.map(o=>[o.url,o.removedAt]));return e.filter(o=>{let i=s.get(r(o));return i===void 0?!0:n(o)>i})}function Bc(e,t){let r=$1(e.tombstones??[],t.tombstones??[]),n=wO(I1(e.savedResults??[],t.savedResults??[]),r,w=>w.issueUrl,w=>w.lastSeenAt),s=wO(D1(e.skippedIssues??[],t.skippedIssues??[]),r,w=>w.url,w=>w.skippedAt),o=new Set(s.map(w=>w.url)),i=n.filter(w=>!o.has(w.issueUrl)),a=e.preferencesUpdatedAt,c=t.preferencesUpdatedAt,p=a!==void 0&&(c===void 0||a>c)?e.preferences:t.preferences,d=Vd(a,c),m=ZR(e.mergedPRs,t.mergedPRs),f=ZR(e.closedPRs,t.closedPRs),g=new Set([...m.map(w=>w.url),...f.map(w=>w.url)]),h=ZR(e.openPRs??[],t.openPRs??[]).filter(w=>!g.has(w.url));return{...e,...t,version:1,stateRevision:Math.max(e.stateRevision,t.stateRevision),preferences:p,preferencesUpdatedAt:d,tombstones:r,repoScores:O1(e.repoScores,t.repoScores),starredRepos:x1(e,t),starredReposLastFetched:Vd(e.starredReposLastFetched,t.starredReposLastFetched),mergedPRs:m,closedPRs:f,openPRs:h,savedResults:i,skippedIssues:s,lastSearchAt:Vd(e.lastSearchAt,t.lastSearchAt),lastRunAt:Vd(e.lastRunAt,t.lastRunAt)??new Date().toISOString(),gistId:t.gistId??e.gistId,searchRotation:A1(e.searchRotation,t.searchRotation)}}function A1(e,t){let r=e??{languageOffset:0},n=t??{languageOffset:0},s=r.lastRotatedAt,o=n.lastRotatedAt;return s&&o?s>=o?r:n:s?r:o||n.languageOffset>=r.languageOffset?n:r}function O1(e,t){let r=Object.assign(Object.create(null),e);for(let[n,s]of Object.entries(t)){let o=r[n];if(!o)r[n]=s;else{let i=o.mergedPRCount+o.closedWithoutMergeCount,a=s.mergedPRCount+s.closedWithoutMergeCount;r[n]=a>=i?s:o}}return r}function x1(e,t){let r=e.starredReposLastFetched,n=t.starredReposLastFetched;return!r&&!n?t.starredRepos.length>=e.starredRepos.length?t.starredRepos:e.starredRepos:r?n&&n>=r?t.starredRepos:e.starredRepos:t.starredRepos}function ZR(e,t){let r=new Map;for(let n of e)r.set(n.url,n);for(let n of t)r.set(n.url,n);return[...r.values()]}function I1(e,t){let r=new Map;for(let n of e)r.set(n.issueUrl,n);for(let n of t){let s=r.get(n.issueUrl);(!s||n.lastSeenAt>s.lastSeenAt)&&r.set(n.issueUrl,n)}return[...r.values()]}function D1(e,t){let r=new Map;for(let n of e)r.set(n.url,n);for(let n of t){let s=r.get(n.url);(!s||n.skippedAt>s.skippedAt)&&r.set(n.url,n)}return[...r.values()]}function Vd(e,t){return e?t?e>=t?e:t:e:t}var zi,JR,qe,gO,qR,E1,P1,hO,Bd,T1,_O=C(()=>{zi=H(require("fs"),1),JR=H(require("path"),1);Ys();Pt();rt();st();qe="gist-state",gO="oss-scout-state",qR="state.json",E1="gist-id",P1="state-cache.json",hO=10;Bd=class{octokit;gistId=null;constructor(t){this.octokit=t}async bootstrap(){try{return await this.bootstrapFromApi()}catch(t){if(Ae(t)===401)throw t;return z(qe,`API bootstrap failed: ${Z(t)}`),this.bootstrapFromCache(C1(t))}}async push(t){if(!this.gistId)return z(qe,"No gist ID \u2014 cannot push"),this.writeCache(t),!1;let r=t;try{let s=await this.fetchGistState(this.gistId);if(s.kind==="ok")r=Bc(t,s.state);else if(s.kind==="invalid")return this.writeCache(t),z(qe,"Remote gist content failed validation \u2014 not overwriting it. Changes saved locally; gist sync skipped."),!1}catch(s){Me(s),z(qe,`Could not fetch gist before push, writing local snapshot: ${Z(s)}`)}this.writeCache(r);let n=JSON.stringify(r,null,2);if(n.length>9e5)return z(qe,`State too large for gist (${Math.round(n.length/1024)}KB). Consider clearing old results with 'oss-scout results clear'.`),!1;try{return await this.octokit.gists.update({gist_id:this.gistId,files:{[qR]:{content:n}}}),ee(qe,"State pushed to gist"),!0}catch(s){return Me(s),z(qe,`Failed to push: ${Z(s)}`),!1}}getGistId(){return this.gistId}async bootstrapFromApi(){let t=this.readCachedGistId();if(t){ee(qe,`Trying cached gist ID: ${t}`);try{let o=await this.fetchGistState(t);if(o.kind==="ok"){this.gistId=t;let i=this.mergeCacheInto(o.state);return this.writeCache(i),{gistId:t,state:i,created:!1}}}catch(o){if(Ae(o)!==404)throw o;ee(qe,`Cached gist gone (404): ${Z(o)}`)}ee(qe,"Cached gist ID invalid, searching...")}let r=await this.searchForGist();if(r.id){ee(qe,`Found gist via search: ${r.id}`),this.saveGistId(r.id),this.gistId=r.id;let o=await this.fetchGistState(r.id);if(o.kind==="ok"){let i=this.mergeCacheInto(o.state);return this.writeCache(i),{gistId:r.id,state:i,created:!1}}return z(qe,`Found existing gist ${r.id} but content failed validation. Using local cache to avoid data loss.`),this.bootstrapFromCache("unknown")}r.exhaustive||z(qe,`Scanned the first ${hO*100} gists without finding an oss-scout state gist, but the account has more. Creating a new state gist; if one already exists, copy its id into the gist-id file in the oss-scout data directory to avoid a duplicate.`),ee(qe,"No existing gist found, creating new one");let n=pn.parse({version:1}),s=await this.createGist(n);return this.saveGistId(s),this.gistId=s,this.writeCache(n),{gistId:s,state:n,created:!0}}bootstrapFromCache(t){let r=this.readCache();if(r){ee(qe,"Bootstrapped from local cache (degraded mode)");let s=this.readCachedGistId();return s&&(this.gistId=s),{gistId:s??"",state:r,created:!1,degraded:!0,degradedReason:t}}return ee(qe,"No cache available, using fresh state (degraded mode)"),{gistId:"",state:pn.parse({version:1}),created:!1,degraded:!0,degradedReason:t}}async fetchGistState(t){let{data:r}=await this.octokit.gists.get({gist_id:t}),n=r.files?.[qR];if(!n?.content)return{kind:"missing"};try{let s=JSON.parse(n.content);return{kind:"ok",state:jc(s)}}catch(s){return z(qe,`Gist content failed validation: ${Z(s)}`),{kind:"invalid"}}}async searchForGist(){for(let t=1;t<=hO;t++){let{data:r}=await this.octokit.gists.list({per_page:100,page:t});if(r.length===0)return{id:null,exhaustive:!0};let n=r.find(s=>s.description===gO);if(n)return{id:n.id,exhaustive:!0};if(r.length<100)return{id:null,exhaustive:!0}}return{id:null,exhaustive:!1}}async createGist(t){let{data:r}=await this.octokit.gists.create({description:gO,public:!1,files:{[qR]:{content:JSON.stringify(t,null,2)}}});return r.id}readCachedGistId(){try{return zi.readFileSync(yO(),"utf-8").trim()||null}catch(t){return t?.code!=="ENOENT"&&z(qe,`Failed to read cached gist ID: ${Z(t)}`),null}}saveGistId(t){zi.writeFileSync(yO(),t+`
253
253
  `,{mode:384})}mergeCacheInto(t){let r=this.readCache();return r?Bc(r,t):t}readCache(){try{let t=zi.readFileSync(bO(),"utf-8");return jc(JSON.parse(t))}catch(t){return t?.code!=="ENOENT"&&z(qe,`Failed to read state cache: ${Z(t)}`),null}}writeCache(t){try{zi.writeFileSync(bO(),JSON.stringify(t,null,2)+`
254
254
  `,{mode:384})}catch(r){z(qe,`Failed to write cache: ${Z(r)}`)}}},T1=2160*60*60*1e3});function SO(){return RO.join(Li(),"state.json")}function qd(){let e=SO();try{let t=wr.readFileSync(e,"utf-8");return jc(JSON.parse(t))}catch(t){if(t?.code==="ENOENT")return pn.parse({version:1});z(Wd,`Failed to load state from ${e}: ${Z(t)}. Using defaults.`);try{let n=`${e}.corrupt.${Date.now()}`;wr.copyFileSync(e,n),z(Wd,`Corrupt state backed up to ${n}`)}catch(n){z(Wd,`Failed to back up corrupt state: ${Z(n)}`)}return pn.parse({version:1})}}function vO(e){let t=SO(),r=`${t}.tmp.${process.pid}.${L1++}`,n=JSON.stringify(e,null,2)+`
255
- `;wr.writeFileSync(r,n,{mode:384});try{wr.renameSync(r,t)}catch(s){try{wr.unlinkSync(r)}catch{}throw s}ee(Wd,"State saved")}var wr,RO,Wd,L1,kO=C(()=>{wr=H(require("fs"),1),RO=H(require("path"),1);Ys();Pt();rt();st();Wd="local-state";L1=0});function F1(e){let t="Changes will only be saved locally.";switch(e){case"rate_limit":return`Gist sync unavailable \u2014 GitHub API rate limit exceeded. ${t} Try again after the rate limit resets.`;case"network":return`Gist sync unavailable \u2014 could not reach GitHub. ${t} Check your network connection.`;case"server":return`Gist sync unavailable \u2014 GitHub returned a server error. ${t} Try again later.`;case"unknown":case void 0:return`Gist sync unavailable \u2014 running in offline mode. ${t}`}}function M1(e){return{gists:{async get(t){let{data:r}=await e.gists.get(t);if(!r.id)throw new Error("Gist get returned no id");let n=r.files?Object.fromEntries(Object.entries(r.files).map(([s,o])=>[s,o?{content:o.content}:void 0])):null;return{data:{id:r.id,files:n}}},async create(t){let{data:r}=await e.gists.create(t);if(!r.id)throw new Error("Gist create returned no id");return{data:{id:r.id}}},async update(t){let{data:r}=await e.gists.update(t);if(!r.id)throw new Error("Gist update returned no id");return{data:{id:r.id}}},async list(t){let{data:r}=await e.gists.list(t);return{data:r.filter(n=>n.id).map(n=>({id:n.id,description:n.description??null}))}}}}}async function Zd(e){e.logLevel!==void 0&&vd(e.logLevel);let t,r=null,n=!1;if(e.persistence==="provided")t=e.initialState;else if(e.persistence==="gist"){r=new Bd(M1(ln(e.githubToken)));let s=await r.bootstrap();s.degraded&&z("scout",F1(s.degradedReason));let o=qd();t=Bc(o,s.state),e.gistId?t.gistId=e.gistId:s.gistId&&(t.gistId=s.gistId)}else t=qd(),n=!0;return new Wc(e.githubToken,t,r,{persistLocal:n})}var Wc,EO=C(()=>{FR();Fd();WR();Ys();_O();Td();kO();rt();Pt();st();dn();Wc=class{githubToken;gistStore;state;dirty=!1;persistLocal;constructor(t,r,n=null,s={}){this.githubToken=t,this.gistStore=n,this.state=r,this.persistLocal=s.persistLocal??!1}evictStaleCacheEntries(){mt().evictStale()}async search(t){this.evictStaleCacheEntries(),this.cullExpiredSkips();let r=new Set((this.state.skippedIssues??[]).map(v=>v.url));if(t?.excludeRecentlySurfaced??!0){let v=t?.recentlySurfacedTtlDays??7,R=Date.now()-v*24*60*60*1e3;for(let y of this.state.savedResults??[]){let S=Date.parse(y.lastSeenAt);!Number.isNaN(S)&&S>=R&&r.add(y.issueUrl)}}let n=new Qs(this.githubToken,this.state.preferences,this),s=this.state.preferences,o=s.preferLanguages??[],i=s.preferRepos??[],a=t?.preferLanguages??(o.length>0?o:void 0),c=t?.preferRepos??(i.length>0?i:void 0),l=s.avoidRepos??[],p=s.boostIssueTypes??[],d=t?.avoidRepos??(l.length>0?l:void 0),m=t?.boostIssueTypes??(p.length>0?p:void 0),f=t?.diversityRatio??s.diversityRatio??0,g=this.state.searchRotation??{languageOffset:0},h,w;try{({candidates:h,strategiesUsed:w}=await n.searchIssues({maxResults:t?.maxResults,strategies:t?.strategies,skippedUrls:r,preferLanguages:a,preferRepos:c,avoidRepos:d,boostIssueTypes:m,diversityRatio:f,interPhaseDelayMs:t?.interPhaseDelayMs,broadPhaseDelayMs:t?.broadPhaseDelayMs,languageRotationOffset:g.languageOffset,repoRotationOffsets:{merged:g.phase0Offset??0,starred:g.starredOffset??0,maintained:g.maintainedOffset??0},strategyRotationOffset:g.strategyOffset??0}))}catch(v){throw v instanceof Be&&this.advanceRotation(g,v.strategiesUsed??[]),v}this.advanceRotation(g,w);for(let v of h)this.updateRepoSignalsFromHealth(v.projectHealth);return this.state.lastSearchAt=new Date().toISOString(),this.dirty=!0,{candidates:h,excludedRepos:this.state.preferences.excludeRepos,aiPolicyBlocklist:this.state.preferences.aiPolicyBlocklist,rateLimitWarning:n.rateLimitWarning??void 0,strategiesUsed:w}}advanceRotation(t,r){let n=s=>r.includes(s)?1:0;r.length!==0&&(this.state.searchRotation={...t,languageOffset:t.languageOffset+n("broad"),phase0Offset:(t.phase0Offset??0)+n("merged"),starredOffset:(t.starredOffset??0)+n("starred"),maintainedOffset:(t.maintainedOffset??0)+n("maintained"),strategyOffset:Ks.indexOf(r[0])+1,lastRotatedAt:new Date().toISOString()},this.dirty=!0)}updateRepoSignalsFromHealth(t){t.checkFailed||this.updateRepoScore(t.repo,{signals:{hasActiveMaintainers:t.isActive}})}async vetIssue(t){return new Qs(this.githubToken,this.state.preferences,this).vetIssue(t)}async features(t){this.evictStaleCacheEntries();let r=t?.count??10,n=ln(this.githubToken),s=new Yn(n,this),o=t?.broad?await fO({octokit:n,vetter:s,count:r,languages:this.state.preferences.languages,excludeRepos:this.state.preferences.excludeRepos,excludeOrgs:this.state.preferences.excludeOrgs,aiPolicyBlocklist:this.state.preferences.aiPolicyBlocklist,splitRatio:t?.splitRatio??this.state.preferences.featuresSplitRatio}):await Hd({octokit:n,vetter:s,repoScores:this.state.repoScores??{},count:r,excludeRepos:this.state.preferences.excludeRepos,excludeOrgs:this.state.preferences.excludeOrgs,aiPolicyBlocklist:this.state.preferences.aiPolicyBlocklist,anchorThreshold:t?.anchorThreshold??this.state.preferences.featuresAnchorThreshold,splitRatio:t?.splitRatio??this.state.preferences.featuresSplitRatio});return this.saveResults([...o.quickWins,...o.biggerBets]),this.state.lastSearchAt=new Date().toISOString(),this.dirty=!0,o}async vetList(t){this.evictStaleCacheEntries();let r=this.getSavedResults(),n=t?.concurrency??5,s=[],o=new Map,i=null;for(let m of r){if(i)break;let f=this.vetIssue(m.issueUrl).then(g=>{s.push({issueUrl:m.issueUrl,repo:m.repo,number:m.number,title:m.title,status:this.classifyVetResult(g),ok:!0,recommendation:g.recommendation,viabilityScore:g.viabilityScore})}).catch(g=>{if(Ae(g)===401||nt(g)){i??=g;return}let h=Ae(g),w=h===404||h===410;s.push({issueUrl:m.issueUrl,repo:m.repo,number:m.number,title:m.title,status:w?"closed":"error",ok:!1,errorMessage:Z(g)})}).finally(()=>{o.delete(m.issueUrl)});o.set(m.issueUrl,f),o.size>=n&&await Promise.race(o.values())}if(await Promise.allSettled(o.values()),i)throw s.length>0&&z("scout",`vetList aborted mid-batch after ${s.length} result(s) \u2014 discarding partial results due to auth/rate-limit failure`),i;let a={total:s.length,stillAvailable:s.filter(m=>m.status==="still_available").length,claimed:s.filter(m=>m.status==="claimed").length,closed:s.filter(m=>m.status==="closed").length,hasPR:s.filter(m=>m.status==="has_pr").length,errors:s.filter(m=>m.status==="error").length},c=new Map((this.state.savedResults??[]).map(m=>[m.issueUrl,m.lastStatus])),l=s.filter(m=>m.status!=="error").filter(m=>{let f=c.get(m.issueUrl);return f!==void 0&&f!==m.status}).map(m=>({issueUrl:m.issueUrl,repo:m.repo,number:m.number,from:c.get(m.issueUrl),to:m.status})),p=new Map(s.map(m=>[m.issueUrl,m.status]));for(let m of this.state.savedResults??[]){let f=p.get(m.issueUrl);f!==void 0&&f!=="error"&&(m.lastStatus=f)}s.length>0&&(this.dirty=!0);let d;if(t?.prune){let m=new Set(s.filter(g=>g.status!=="still_available").map(g=>g.issueUrl)),f=(this.state.savedResults??[]).length;this.state.savedResults=(this.state.savedResults??[]).filter(g=>!m.has(g.issueUrl)),d=f-(this.state.savedResults?.length??0),d>0&&this.addTombstones([...m]),this.dirty=!0}return{results:s,summary:a,prunedCount:d,transitions:l}}classifyVetResult(t){if(t.issueState==="closed")return"closed";let r=t.vettingResult.checks;return r.noExistingPR?r.notClaimed?"still_available":"claimed":"has_pr"}getReposWithMergedPRs(){let t=new Map;for(let r of this.state.mergedPRs??[]){let n=We(r.url);n&&t.set(n,(t.get(n)??0)+1)}return[...t.entries()].sort((r,n)=>n[1]-r[1]).map(([r])=>r)}getReposWithOpenPRs(){let t=new Map;for(let r of this.state.openPRs??[]){let n=We(r.url);n&&t.set(n,(t.get(n)??0)+1)}return[...t.entries()].sort((r,n)=>n[1]-r[1]).map(([r])=>r)}getStarredRepos(){return this.state.starredRepos}getProjectCategories(){return this.state.preferences.projectCategories}getGitHubUsername(){return this.state.preferences.githubUsername}getRepoScore(t){let r=this.state.repoScores[t];return r?r.score:null}getClosedWithoutMergeCount(t){let r=this.state.repoScores[t];return r?r.closedWithoutMergeCount:(this.state.closedPRs??[]).filter(n=>We(n.url)===t).length}getSLMTriageConfig(){let t=this.state.preferences.slmTriageModel??"";return t?{model:t,host:this.state.preferences.slmTriageHost??""}:null}getPreferences(){return this.state.preferences}getRepoScoreRecord(t){return this.state.repoScores[t]}recordMergedPR(t){let r=this.state.mergedPRs??[];r.some(n=>n.url===t.url)||(this.state.mergedPRs=[...r,{url:t.url,title:t.title,mergedAt:t.mergedAt}],this.updateRepoScoreFromPRs(t.repo),this.dirty=!0)}recordClosedPR(t){let r=this.state.closedPRs??[];r.some(n=>n.url===t.url)||(this.state.closedPRs=[...r,{url:t.url,title:t.title,closedAt:t.closedAt}],this.updateRepoScoreFromPRs(t.repo),this.dirty=!0)}recordOpenPR(t){let r=this.state.openPRs??[];r.some(n=>n.url===t.url)||(this.state.openPRs=[...r,{url:t.url,title:t.title,openedAt:t.openedAt}],this.dirty=!0)}async syncOpenPRs(){let t=ln(this.githubToken),r=this.state.openPRs??[],n={checked:r.length,merged:0,closed:0,stillOpen:0,errors:0},s=[];for(let o of r){let i=Ws(o.url);if(!i||i.type!=="pull"){s.push(o),n.errors++;continue}let a=`${i.owner}/${i.repo}`;try{let{data:c}=await t.pulls.get({owner:i.owner,repo:i.repo,pull_number:i.number});c.merged?(this.recordMergedPR({url:o.url,title:o.title,mergedAt:c.merged_at??new Date().toISOString(),repo:a}),n.merged++):c.state==="closed"?(this.recordClosedPR({url:o.url,title:o.title,closedAt:c.closed_at??new Date().toISOString(),repo:a}),n.closed++):(s.push(o),n.stillOpen++)}catch(c){Me(c),z("scout",`sync: could not check ${o.url}: ${Z(c)}`),s.push(o),n.errors++}}return this.state.openPRs=s,this.dirty=!0,await this.checkpoint(),n}updateRepoScore(t,r){let s=this.state.repoScores[t]??{repo:t,score:5,mergedPRCount:0,closedWithoutMergeCount:0,avgResponseDays:null,lastEvaluatedAt:new Date().toISOString(),signals:{hasActiveMaintainers:!1,isResponsive:!1,hasHostileComments:!1}},o={...s,...r,repo:t,lastEvaluatedAt:new Date().toISOString(),signals:{...s.signals,...r.signals??{}}};o.score=this.calculateScore(o),this.state.repoScores[t]=o,this.dirty=!0}updatePreferences(t){this.state.preferences={...this.state.preferences,...t},this.state.preferencesUpdatedAt=new Date().toISOString(),this.dirty=!0}setStarredRepos(t){this.state.starredRepos=t,this.state.starredReposLastFetched=new Date().toISOString(),this.dirty=!0}saveResults(t){let r=new Date().toISOString(),n=new Map((this.state.savedResults??[]).map(s=>[s.issueUrl,s]));for(let s of t){if(s.recommendation==="skip"){n.delete(s.issue.url);let i=new Set(["Issue is closed","Linked PR already merged"]),a=s.reasonsToSkip.some(c=>i.has(c));this.skipIssue(s.issue.url,{repo:s.issue.repo,number:s.issue.number,title:s.issue.title,reason:s.reasonsToSkip.join("; ")||"vetter: skip",permanent:a});continue}let o=n.get(s.issue.url);n.set(s.issue.url,{issueUrl:s.issue.url,repo:s.issue.repo,number:s.issue.number,title:s.issue.title,labels:s.issue.labels,recommendation:s.recommendation,viabilityScore:s.viabilityScore,searchPriority:s.searchPriority,firstSeenAt:o?.firstSeenAt??r,lastSeenAt:r,lastScore:s.viabilityScore,horizon:"horizon"in s?s.horizon:void 0})}this.state.savedResults=[...n.values()],this.dirty=!0}getSavedResults(){return this.state.savedResults??[]}clearResults(){this.addTombstones((this.state.savedResults??[]).map(t=>t.issueUrl)),this.state.savedResults=[],this.dirty=!0}addTombstones(t){if(t.length===0)return;let r=new Date().toISOString(),n=this.state.tombstones??[],s=new Map(n.map(o=>[o.url,o]));for(let o of t)s.set(o,{url:o,removedAt:r});this.state.tombstones=[...s.values()]}skipIssue(t,r){let n=this.state.skippedIssues??[],s=n.find(i=>i.url===t);if(s){r?.permanent===!0&&s.permanent!==!0&&(s.permanent=!0,this.dirty=!0);return}let o=r?.permanent??!0;this.state.skippedIssues=[...n,{url:t,repo:r?.repo??"",number:r?.number??0,title:r?.title??"",skippedAt:new Date().toISOString(),permanent:o,...r?.reason?{reason:r.reason}:{}}],this.state.savedResults&&(this.state.savedResults=this.state.savedResults.filter(i=>i.issueUrl!==t)),this.dirty=!0}getSkippedIssues(){return this.state.skippedIssues??[]}unskipIssue(t){let r=(this.state.skippedIssues??[]).length;this.state.skippedIssues=(this.state.skippedIssues??[]).filter(n=>n.url!==t),this.state.skippedIssues.length<r&&this.addTombstones([t]),this.dirty=!0}clearSkippedIssues(){this.addTombstones((this.state.skippedIssues??[]).map(t=>t.url)),this.state.skippedIssues=[],this.dirty=!0}cullExpiredSkips(t=90){let r=new Date;r.setDate(r.getDate()-t);let n=(this.state.skippedIssues??[]).length;this.state.skippedIssues=(this.state.skippedIssues??[]).filter(o=>{if(o.permanent!==!1)return!0;let i=new Date(o.skippedAt);return isNaN(i.getTime())?!0:i>=r});let s=n-this.state.skippedIssues.length;return s>0&&(this.dirty=!0),s}isDirty(){return this.dirty}async checkpoint(){if(!this.dirty)return!0;if(this.state.lastRunAt=new Date().toISOString(),this.gistStore&&!await this.gistStore.push(this.state))return!1;if(this.persistLocal)try{this.state=Bc(this.state,qd()),vO(this.state)}catch{return!1}return this.dirty=!1,!0}getState(){return this.state}updateRepoScoreFromPRs(t){let r=(this.state.mergedPRs??[]).filter(s=>We(s.url)===t).length,n=(this.state.closedPRs??[]).filter(s=>We(s.url)===t).length;this.updateRepoScore(t,{mergedPRCount:r,closedWithoutMergeCount:n,lastMergedAt:r>0?(this.state.mergedPRs??[]).filter(s=>We(s.url)===t).sort((s,o)=>o.mergedAt.localeCompare(s.mergedAt))[0]?.mergedAt:void 0})}calculateScore(t){let r=5;return r+=Math.min(t.mergedPRCount,3),r-=Math.min(t.closedWithoutMergeCount,3),t.signals.hasActiveMaintainers&&(r+=1),t.signals.hasHostileComments&&(r-=2),Math.max(1,Math.min(10,r))}}});function PO(){let e=Zc.filter(r=>!(r in qc));if(e.length>0)throw new Error(`FIELD_CONFIGS is missing entries for preference keys: ${e.join(", ")}`);let t=Object.keys(qc).filter(r=>!Zc.includes(r));if(t.length>0)throw new Error(`FIELD_CONFIGS has entries for unknown preference keys: ${t.join(", ")}`)}function G1(e){let t=e.toLowerCase();if(t==="true"||t==="yes")return!0;if(t==="false"||t==="no")return!1;throw new Be(`Invalid boolean value: "${e}". Use true/false or yes/no.`)}function N1(e,t){let r=parseInt(e,10);if(isNaN(r))throw new Be(`Invalid number for "${t}": "${e}"`);return r}function U1(e,t){let r=Number.parseFloat(e);if(isNaN(r))throw new Be(`Invalid number for "${t}": "${e}"`);return r}function KR(e){return e.split(",").map(t=>t.trim()).filter(t=>t.length>0)}function Jd(e,t){if(t.startsWith("+")){let r=KR(t.slice(1)),n=[...e];for(let s of r)n.includes(s)||n.push(s);return n}if(t.startsWith("-")){let r=new Set(KR(t.slice(1)));return e.filter(n=>!r.has(n))}return KR(t)}function CO(e,t,r){let n=qc[t];if(!n)throw new Be(`Unknown config key: "${t}". Valid keys: ${YR.join(", ")}`);let s={...e};switch(n.type){case"string":t==="slmTriageHost"&&zA(r),s[t]=r;break;case"boolean":s[t]=G1(r);break;case"number":s[t]=N1(r,t);break;case"float":s[t]=U1(r,t);break;case"array":{let o=s[t]??[];s[t]=Jd(o,r);break}case"enum":{let o=n.validValues;if(!o.includes(r))throw new Be(`Invalid value for "${t}": "${r}". Valid: ${o.join(", ")}`);s[t]=r;break}case"enum-array":{let o=s[t]??[],i=Jd(o,r),a=n.validValues,c=i.filter(l=>!a.includes(l));if(c.length>0)throw new Be(`Invalid value(s) for "${t}": ${c.join(", ")}. Valid: ${a.join(", ")}`);t==="scope"?s[t]=i.length>0?i:void 0:s[t]=i;break}}return Zs.parse(s)}var qc,Zc,YR,TO=C(()=>{Ys();st();TR();qc={githubUsername:{type:"string"},languages:{type:"array"},labels:{type:"array"},scope:{type:"enum-array",validValues:Uc.options},excludeRepos:{type:"array"},excludeOrgs:{type:"array"},preferredOrgs:{type:"array"},aiPolicyBlocklist:{type:"array"},projectCategories:{type:"enum-array",validValues:Nc.options},minStars:{type:"number"},maxIssueAgeDays:{type:"number"},includeDocIssues:{type:"boolean"},minRepoScoreThreshold:{type:"number"},interPhaseDelayMs:{type:"number"},persistence:{type:"enum",validValues:fR.options},defaultStrategy:{type:"enum-array",validValues:Js.options},broadPhaseDelayMs:{type:"number"},skipBroadWhenSufficientResults:{type:"number"},preferLanguages:{type:"array"},preferRepos:{type:"array"},diversityRatio:{type:"float"},avoidRepos:{type:"array"},boostIssueTypes:{type:"array"},slmTriageModel:{type:"string"},slmTriageHost:{type:"string"},featuresAnchorThreshold:{type:"number"},featuresSplitRatio:{type:"float"}},Zc=Object.keys(Zs.shape),YR=[...Zc].sort()});async function $O(e,t,r=Ct()){let n=e.getPreferences().githubUsername;if(!n)throw new Ii("GitHub username not configured. Run `oss-scout setup` first.");let s=await Cd(t);if(ee(zr,`Rate limit: ${s.remaining}/${s.limit}, resets at ${s.resetAt}`),s.remaining<15)return ee(zr,"Insufficient rate limit, skipping bootstrap"),{starredRepoCount:0,mergedPRCount:0,closedPRCount:0,openPRCount:0,reposScoredCount:0,skippedDueToRateLimit:!0,errors:[]};let o=ln(t),i=[],a=[],c=0,l=new Set;try{let f=0;for await(let g of o.paginate.iterator(o.activity.listReposStarredByAuthenticatedUser,{per_page:Xs,headers:{accept:"application/vnd.github.v3+json"}})){for(let h of g.data){let w=h;a.push(w.full_name)}if(f++,f>=j1)break}ee(zr,`Fetched ${a.length} starred repos`),e.setStarredRepos(a),c=a.length}catch(f){Me(f),z(zr,`Failed to fetch starred repos: ${Z(f)}`),i.push("starred repos fetch failed")}let p=0;try{for(let f=1;f<=QR;f++){await r.waitForBudget();let g;try{g=(await o.search.issuesAndPullRequests({q:`is:pr is:merged author:${n}`,per_page:Xs,page:f})).data}finally{r.recordCall()}for(let h of g.items){let w=We(h.html_url);w&&(e.recordMergedPR({url:h.html_url,title:h.title,mergedAt:h.closed_at??new Date().toISOString(),repo:w}),l.add(w),p++)}if(g.items.length<Xs)break}ee(zr,`Imported ${p} merged PRs`)}catch(f){Me(f),z(zr,`Failed to fetch merged PRs: ${Z(f)}`),i.push("merged PR fetch failed")}let d=0;try{for(let f=1;f<=QR;f++){await r.waitForBudget();let g;try{g=(await o.search.issuesAndPullRequests({q:`is:pr is:closed is:unmerged author:${n}`,per_page:Xs,page:f})).data}finally{r.recordCall()}for(let h of g.items){let w=We(h.html_url);w&&(e.recordClosedPR({url:h.html_url,title:h.title,closedAt:h.closed_at??new Date().toISOString(),repo:w}),l.add(w),d++)}if(g.items.length<Xs)break}ee(zr,`Imported ${d} closed PRs`)}catch(f){Me(f),z(zr,`Failed to fetch closed PRs: ${Z(f)}`),i.push("closed PR fetch failed")}let m=0;try{for(let f=1;f<=QR;f++){await r.waitForBudget();let g;try{g=(await o.search.issuesAndPullRequests({q:`is:pr is:open author:${n}`,per_page:Xs,page:f})).data}finally{r.recordCall()}for(let h of g.items){let w=We(h.html_url);w&&(e.recordOpenPR({url:h.html_url,title:h.title,openedAt:h.created_at??new Date().toISOString(),repo:w}),m++)}if(g.items.length<Xs)break}ee(zr,`Imported ${m} open PRs`)}catch(f){Me(f),z(zr,`Failed to fetch open PRs: ${Z(f)}`),i.push("open PR fetch failed")}return{starredRepoCount:c,mergedPRCount:p,closedPRCount:d,openPRCount:m,reposScoredCount:l.size,skippedDueToRateLimit:!1,errors:i}}var zr,j1,QR,Xs,AO=C(()=>{Td();rt();st();Pt();qs();zr="bootstrap",j1=5,QR=3,Xs=100});function xO(e,t=new Date,r=30){if(!e||e.state!=="open"||!e.updatedAt)return!1;let n=new Date(e.updatedAt);return Number.isNaN(n.getTime())?!1:(t.getTime()-n.getTime())/(1e3*60*60*24)>=r}var OO,IO=C(()=>{OO=30});function FO(e,t,r){if(!t.test(e))throw new Be(`Invalid ${r} URL: ${e}. Expected format: https://github.com/owner/repo/issues/123`)}function MO(e){if(e.length>DO)throw new Be(`URL exceeds maximum length of ${DO} characters`);return e}var LO,DO,GO=C(()=>{st();LO=/^https:\/\/github\.com\/[^/]+\/[^/]+\/issues\/\d+$/,DO=2048});var NO={};ne(NO,{ANCHOR_THRESHOLD:()=>jR,ANTI_LLM_KEYWORDS:()=>vR,FEATURE_LABELS:()=>zd,FIELD_CONFIGS:()=>qc,HorizonSchema:()=>mR,ISSUE_URL_PATTERN:()=>LO,IssueDiscovery:()=>Qs,IssueScopeSchema:()=>Uc,IssueVetter:()=>Yn,NO_ANCHORS_MESSAGE:()=>VR,NO_RESULTS_MESSAGE:()=>BR,OssScout:()=>Wc,PREFERENCE_KEYS:()=>Zc,ProjectCategorySchema:()=>Nc,RepoScoreSchema:()=>pR,SORTED_PREFERENCE_KEYS:()=>YR,STALLED_PR_THRESHOLD_DAYS:()=>OO,ScoutPreferencesSchema:()=>Zs,ScoutStateSchema:()=>pn,SearchStrategySchema:()=>Js,SkippedIssueSchema:()=>dR,applyPreferenceField:()=>CO,assertFieldConfigsCover:()=>PO,bootstrapScout:()=>$O,classifyHorizon:()=>HR,createScout:()=>Zd,discoverFeatures:()=>Hd,enableDebug:()=>nA,fetchRoadmapIssueRefs:()=>Ud,getGitHubToken:()=>sR,getLogLevel:()=>rA,isLinkedPRStalled:()=>xO,parseRoadmapIssueRefs:()=>GR,requireGitHubToken:()=>pA,resolveAnchorRepos:()=>zR,scanForAntiLLMPolicy:()=>kR,setLogLevel:()=>vd,splitByHorizon:()=>jd,updateArray:()=>Jd,validateGitHubUrl:()=>FO,validateUrl:()=>MO});var Kd=C(()=>{EO();Ys();TO();Pt();FR();Fd();ER();AO();rt();WR();IO();NR();GO()});function V1(e){let t=[],r=e.split(/\r?\n/);for(let n=0;n<r.length;n++){let s=n+1,o=r[n].trim();if(o===""||o.startsWith("#"))continue;let i=o.match(/^(\S+)\s+(\S+)(?:\s+#.*)?$/);if(!i){_("skip-file-parser",`Line ${s}: malformed (expected "<date> <url>"): ${o}`);continue}let[,a,c]=i;if(!z1.test(a)){_("skip-file-parser",`Line ${s}: invalid date format (expected YYYY-MM-DD): ${o}`);continue}let l=Date.parse(`${a}T00:00:00.000Z`);if(Number.isNaN(l)){_("skip-file-parser",`Line ${s}: unparseable date: ${o}`);continue}let p=new Date(l).toISOString().slice(0,10);if(p!==a){_("skip-file-parser",`Line ${s}: invalid calendar date ${a} (would be normalized to ${p}): ${o}`);continue}let d=c.match(H1);if(!d){_("skip-file-parser",`Line ${s}: non-GitHub-issue URL: ${o}`);continue}let[,m,f]=d,g=Number.parseInt(f,10);t.push({url:c,repo:m,number:g,title:"",skippedAt:new Date(l).toISOString(),permanent:!0})}return t}function XR(e){if(!e)return{issues:[]};let t=UO.resolve(e);if(!Yd.existsSync(t))return _("skip-file-parser",`Configured skipped-issues file not found at ${t} (cwd ${process.cwd()}); proceeding with an EMPTY skip list \u2014 previously skipped issues may resurface. Use an absolute skippedIssuesPath, or run from the directory that contains "${e}".`),{issues:[],notFound:!0,resolvedPath:t};let r;try{r=Yd.readFileSync(t,"utf8")}catch(n){return _("skip-file-parser",`Failed to read skipped-issues file at ${t}: ${A(n)}`),{issues:[],readError:A(n),resolvedPath:t}}return{issues:V1(r),resolvedPath:t}}function jO(e){return XR(e).issues}var Yd,UO,z1,H1,eS=C(()=>{"use strict";Yd=H(require("node:fs"),1),UO=H(require("node:path"),1);de();ie();z1=/^\d{4}-\d{2}-\d{2}$/,H1=/^https:\/\/github\.com\/([^/]+\/[^/]+)\/(?:issues|pull)\/(\d+)(?:[#/?].*)?$/});function eo(e){if(!e)return null;let t={author:{login:e.author},state:e.merged?"merged":e.state};return e.updatedAt!==void 0&&(t.updatedAt=e.updatedAt),t}function Qn(e){if(!e)return;let t=eo(e);if(!t)return;let r={number:e.number,state:t.state,url:e.url,isStalled:Bp(t)};return e.updatedAt!==void 0&&(r.updatedAt=e.updatedAt),r}function B1(e){let t=M().getState(),{config:r}=t,n=XR(r.skippedIssuesPath);(n.readError!==void 0||n.notFound)&&e&&(e.skipListUnavailable=!0);let s=[...n.issues],o=new Set(s.map(a=>a.url));for(let[a,c]of Object.entries(r.dismissedIssues??{})){if(o.has(a))continue;let l=me(a);s.push({url:a,repo:l?`${l.owner}/${l.repo}`:"",number:l?.number??0,title:"",skippedAt:c,reason:"dismissed",permanent:!0})}let i=Wn(t);return{version:1,stateRevision:1,preferences:{githubUsername:r.githubUsername,languages:r.languages,labels:r.labels,scope:r.scope,excludeRepos:r.excludeRepos,excludeOrgs:r.excludeOrgs??[],preferredOrgs:r.preferredOrgs??[],aiPolicyBlocklist:r.aiPolicyBlocklist,projectCategories:r.projectCategories??[],minStars:r.minStars,maxIssueAgeDays:r.maxIssueAgeDays,includeDocIssues:r.includeDocIssues,minRepoScoreThreshold:r.minRepoScoreThreshold,interPhaseDelayMs:0,broadPhaseDelayMs:0,skipBroadWhenSufficientResults:r.skipBroadWhenSufficientResults,persistence:r.persistence,slmTriageModel:r.slmTriageModel,slmTriageHost:r.slmTriageHost,featuresAnchorThreshold:3,featuresSplitRatio:.6,preferLanguages:i?.recommendations.languages??[],preferRepos:i?.recommendations.repos??[],diversityRatio:Jc,avoidRepos:r.avoidRepos??[],boostIssueTypes:r.boostIssueTypes??[]},repoScores:t.repoScores,tombstones:[],starredRepos:r.starredRepos,starredReposLastFetched:r.starredReposLastFetched,mergedPRs:(t.mergedPRs??[]).map(a=>({url:a.url,title:a.title,mergedAt:a.mergedAt})),closedPRs:(t.closedPRs??[]).map(a=>({url:a.url,title:a.title,closedAt:a.closedAt})),openPRs:(t.lastDigest?.openPRs??[]).map(a=>({url:a.url,title:a.title,openedAt:a.createdAt})),savedResults:(t.searchSeen??[]).map(a=>({issueUrl:a.url,repo:"",number:0,title:"",labels:[],recommendation:"skip",viabilityScore:0,searchPriority:"normal",firstSeenAt:a.lastSeenAt,lastSeenAt:a.lastSeenAt,lastScore:0})),skippedIssues:s,lastRunAt:t.lastRunAt,searchRotation:t.searchRotation??Qb.parse({})}}async function Xn(e){let t=Ee();return Zd({githubToken:t,persistence:"provided",initialState:B1(e)})}var Jc,Hi=C(()=>{"use strict";Kd();ue();Dn();Tc();eS();Jc=.2});function es(e,t){return e==="approve"&&t.score<4?"needs_review":e}function W1(e){return e.reduce((t,r)=>r.score<t.score?r:t)}function q1(e){let t=to.indexOf(e);return t===-1?to[to.length-1]:to[Math.min(t+1,to.length-1)]}function fn(e,t,r){return typeof e!="number"||!Number.isFinite(e)||e<t||e>r?null:e}function Z1(e){return e<3?{score:10,detail:`~${Math.round(e)}-day avg response`}:e<14?{score:7,detail:`${Math.round(e)}-day avg response`}:e<=60?{score:4,detail:`${Math.round(e)}-day avg response`}:{score:1,detail:"unresponsive maintainers"}}function J1(e){let t=Math.round(e*100);return e>.7?{score:10,detail:`merges ${t}% of PRs`}:e>=.4?{score:7,detail:`merges ${t}% of PRs`}:e>=.1?{score:4,detail:`merges ${t}% of PRs`}:{score:1,detail:`merges ${t}% of PRs`}}function K1(e){return e<7?{score:10,detail:"commits in last week"}:e<30?{score:7,detail:"commits in last month"}:e<90?{score:4,detail:"commits in last 90 days"}:{score:1,detail:`no commits in ${e}+ days`}}function Y1(e){let{projectHealth:t,repoScore:r}=e,n=!t.checkFailed,s=fn(r?.avgResponseDays,0,Number.MAX_SAFE_INTEGER)??(n?fn(t.avgIssueResponseDays,.001,Number.MAX_SAFE_INTEGER):null),o=n?fn(t.daysSinceLastCommit,0,Number.MAX_SAFE_INTEGER):null,i=n?fn(t.recentMergeRate,0,1):null;if(i===null&&r){let a=fn(r.mergedPRCount,0,Number.MAX_SAFE_INTEGER),c=fn(r.closedWithoutMergeCount,0,Number.MAX_SAFE_INTEGER);if(a!==null&&c!==null){let l=a+c;i=l===0?null:a/l}}return{avgResponseDays:s,mergeRate:i,daysSinceLastCommit:o}}function ts(e){let t=e.getRepoScore(e.repo),r=e.projectHealth,n=r.checkFailed?{avgIssueResponseDays:null,daysSinceLastCommit:null,checkFailed:!0}:{avgIssueResponseDays:r.avgIssueResponseDays,daysSinceLastCommit:r.daysSinceLastCommit,recentMergeRate:r.recentMergeRate??null,checkFailed:!1};return tS(Y1({projectHealth:n,repoScore:t?{mergedPRCount:t.mergedPRCount,closedWithoutMergeCount:t.closedWithoutMergeCount,avgResponseDays:t.avgResponseDays}:null}))}function tS(e){let t=[],r=[],n=fn(e.avgResponseDays,0,Number.MAX_SAFE_INTEGER);n===null?r.push("maintainer responsiveness"):t.push(Z1(n));let s=fn(e.mergeRate,0,1);s===null?r.push("merge rate"):t.push(J1(s));let o=fn(e.daysSinceLastCommit,0,Number.MAX_SAFE_INTEGER);if(o===null?r.push("activity"):t.push(K1(o)),t.length===0)return{score:to[to.length-1],reason:`unknown ${r.join(", ")}`};let i=W1(t),a=r.length>0?q1(i.score):i.score,c=[i.detail];return r.length>0&&c.push(`unknown ${r.join(", ")}`),{score:a,reason:c.join(", ")}}var to,Kc=C(()=>{"use strict";to=[10,7,4,1]});async function eH(e){let t=[],r=0;for await(let n of e.paginate.iterator(e.activity.listReposStarredByAuthenticatedUser,{per_page:Q1,headers:{accept:"application/vnd.github.v3+json"}})){for(let s of n.data)s.full_name&&t.push(s.full_name);if(r+=1,r>=X1)break}return t}async function zO(e){if(!e.isStarredReposStale())return e.getStarredRepos().length;let t=Ee(),r;try{r=await eH(we(t))}catch(n){return _(rS,`Failed to refresh starred repos; continuing with cached list (${e.getStarredRepos().length}): ${n instanceof Error?n.message:String(n)}`),e.getStarredRepos().length}return r.length===0?(I(rS,"Starred-repo fetch returned 0; keeping existing cache"),e.getStarredRepos().length):(e.setStarredRepos(r),I(rS,`Refreshed starred repos from GitHub: ${r.length} cached`),r.length)}var rS,Q1,X1,HO=C(()=>{"use strict";Cs();zp();de();rS="starred-repos",Q1=100,X1=5});var qO={};ne(qO,{DEFAULT_SEARCH_RESULTS:()=>rH,MAX_SEARCH_RESULTS:()=>tH,SEARCH_DIVERSITY_RATIO:()=>Jc,SEARCH_SEEN_RETENTION_DAYS:()=>BO,parseSearchStrategies:()=>nH,recordSearchSeen:()=>WO,runSearch:()=>oH});function nH(e){if(e===void 0)return;let t=e.split(",").map(n=>n.trim()).filter(Boolean);if(t.length===0)return;let r=[];for(let n of t){let s=Js.safeParse(n);if(!s.success)throw new Error(`Unknown search strategy "${n}". Valid strategies: merged, orgs, starred, broad, maintained, all`);r.push(s.data)}return r}function sH(e){return typeof e!="number"||!Number.isFinite(e)||e<0||e>100?(_(Vi,`Ignoring out-of-contract viabilityScore from scout: ${JSON.stringify(e)}`),0):e}function VO(e){let t=process.env[e];if(t===void 0||t==="")return;let r=Number(t);if(!Number.isInteger(r)||r<0){_(Vi,`Ignoring invalid ${e}="${t}" (expected a non-negative integer); using scout's default delay`);return}return r}function WO(e,t){let r=Date.now(),n=new Date(r).toISOString(),s=r-BO*24*60*60*1e3,o=new Map(e.getSearchSeen().map(a=>[a.url,a]));for(let a of t)o.set(a,{url:a,lastSeenAt:n});let i=[...o.values()].filter(a=>{let c=Date.parse(a.lastSeenAt);return Number.isNaN(c)?!1:c>=s});e.setSearchSeen(i)}async function oH(e){let t={},r=M();await zO(r);let n=await Xn(t),s=Wn(r.getState()),o=s?.recommendations.languages??void 0,i=s?.recommendations.repos??void 0;(o?.length||i?.length)&&I(Vi,`Applying strategy bias to search: preferLanguages=${JSON.stringify(o??[])}, preferRepos=${JSON.stringify(i??[])}`);let a=VO("OSS_AUTOPILOT_SCOUT_INTER_PHASE_DELAY_MS"),c=VO("OSS_AUTOPILOT_SCOUT_BROAD_PHASE_DELAY_MS"),l=await n.search({maxResults:e.maxResults,...e.strategies?{strategies:e.strategies}:{},preferLanguages:o,preferRepos:i,diversityRatio:Jc,...a!==void 0?{interPhaseDelayMs:a}:{},...c!==void 0?{broadPhaseDelayMs:c}:{}});WO(r,l.candidates.map(h=>h.issue.url)),r.setSearchRotation(n.getState().searchRotation);let p=await Re(r,Vi),d=r.getState().config?.githubUsername??"";d===""&&_(Vi,"githubUsername not configured \u2014 the own-PR filter (#1354) cannot run; hiddenOwnPRCount will be 0");let m=l.candidates.filter(h=>Vn({linkedPR:eo(h.vettingResult?.linkedPR),userLogin:d})!=="user_open"),f=l.candidates.length-m.length;f>0&&I(Vi,`Hid ${f} candidate(s) with the user's own open PR (#1354)`);let g={candidates:m.map(h=>{let w=r.getRepoScore(h.issue.repo),v=ts({repo:h.issue.repo,projectHealth:h.projectHealth??{repo:h.issue.repo,checkFailed:!0,failureReason:"health not supplied by the caller"},getRepoScore:y=>{let S=r.getRepoScore(y);return S?{mergedPRCount:S.mergedPRCount,closedWithoutMergeCount:S.closedWithoutMergeCount,avgResponseDays:S.avgResponseDays??null}:void 0}}),R=Qn(h.vettingResult?.linkedPR);return{issue:{repo:h.issue.repo,repoUrl:`https://github.com/${h.issue.repo}`,number:h.issue.number,title:h.issue.title,url:h.issue.url,labels:h.issue.labels},recommendation:es(h.recommendation,v),reasonsToApprove:h.reasonsToApprove,reasonsToSkip:h.reasonsToSkip,searchPriority:h.searchPriority,viabilityScore:sH(h.viabilityScore),grade:v,repoScore:w?{score:w.score,mergedPRCount:w.mergedPRCount,closedWithoutMergeCount:w.closedWithoutMergeCount,isResponsive:w.signals?.isResponsive??!1,lastMergedAt:w.lastMergedAt}:void 0,...R?{linkedPR:R}:{},...h.personalization?.kind==="boosted"?{boostScore:h.personalization.score}:{},...h.personalization?.kind==="boosted"&&h.personalization.reasons.length>0?{boostReasons:h.personalization.reasons}:{},...h.personalization?.kind==="diversity"?{diversitySlot:!0}:{}}}),excludedRepos:l.excludedRepos,aiPolicyBlocklist:l.aiPolicyBlocklist,hiddenOwnPRCount:f};return p&&(g.gistSyncWarning=p),l.rateLimitWarning&&(g.rateLimitWarning=l.rateLimitWarning),t.skipListUnavailable&&(g.skipListUnavailable=!0),g}var Vi,tH,rH,BO,ZO=C(()=>{"use strict";Hi();Kd();ue();Kc();Tc();HO();de();Hi();Vi="search",tH=100,rH=15;BO=30});var KO={};ne(KO,{MAX_FEATURES_RESULTS:()=>aH,runFeatures:()=>uH});function cH(e){return typeof e!="number"||!Number.isFinite(e)||e<0||e>100?(_(iH,`Ignoring out-of-contract viabilityScore from scout: ${JSON.stringify(e)}`),0):e}function JO(e,t){let r=t.getRepoScore(e.issue.repo),n=ts({repo:e.issue.repo,projectHealth:e.projectHealth??{repo:e.issue.repo,checkFailed:!0,failureReason:"health not supplied by the caller"},getRepoScore:o=>{let i=t.getRepoScore(o);return i?{mergedPRCount:i.mergedPRCount,closedWithoutMergeCount:i.closedWithoutMergeCount,avgResponseDays:i.avgResponseDays??null}:void 0}}),s=Qn(e.vettingResult?.linkedPR);return{issue:{repo:e.issue.repo,repoUrl:`https://github.com/${e.issue.repo}`,number:e.issue.number,title:e.issue.title,url:e.issue.url,labels:e.issue.labels},recommendation:es(e.recommendation,n),reasonsToApprove:e.reasonsToApprove,reasonsToSkip:e.reasonsToSkip,searchPriority:e.searchPriority,viabilityScore:cH(e.viabilityScore),grade:n,repoScore:r?{score:r.score,mergedPRCount:r.mergedPRCount,closedWithoutMergeCount:r.closedWithoutMergeCount,isResponsive:r.signals?.isResponsive??!1,lastMergedAt:r.lastMergedAt}:void 0,...s?{linkedPR:s}:{},horizon:e.horizon}}async function uH(e){let r=await(await Xn()).features({count:e.maxResults,anchorThreshold:e.anchorThreshold,splitRatio:e.splitRatio}),n=M();return{quickWins:r.quickWins.map(o=>JO(o,n)),biggerBets:r.biggerBets.map(o=>JO(o,n)),anchorRepos:r.anchorRepos,message:r.message}}var iH,aH,YO=C(()=>{"use strict";Hi();ue();Kc();de();iH="features",aH=100});var QO={};ne(QO,{runVet:()=>lH});async function lH(e){Xe(e.issueUrl),Qe(e.issueUrl,yr,"issue");let r=await(await Xn()).vetIssue(e.issueUrl),n=ts({repo:r.issue.repo,projectHealth:r.projectHealth,getRepoScore:a=>M().getRepoScore(a)}),s=M().getState().config.githubUsername,o=Vn({linkedPR:eo(r.vettingResult.linkedPR),userLogin:s}),i=Qn(r.vettingResult.linkedPR);return{issue:{repo:r.issue.repo,number:r.issue.number,title:r.issue.title,url:r.issue.url,labels:r.issue.labels},recommendation:es(r.recommendation,n),reasonsToApprove:r.reasonsToApprove,reasonsToSkip:r.reasonsToSkip,projectHealth:r.projectHealth,vettingResult:r.vettingResult,antiLLMPolicy:r.antiLLMPolicy,linkedPRClassification:o,...i?{linkedPR:i}:{},slmTriage:r.slmTriage??null,grade:n}}var XO=C(()=>{"use strict";Hi();Kt();Kc();ue()});var ex={};ne(ex,{runVerifyIssue:()=>pH});async function pH(e){Xe(e.issueUrl),Qe(e.issueUrl,yr,"issue");let t=me(e.issueUrl);if(!t||t.type!=="issues")throw new W(`Not a parseable GitHub issue URL: ${e.issueUrl}`);let r=we(Ee());return bc(r,{owner:t.owner,repo:t.repo,number:t.number})}var tx=C(()=>{"use strict";ue();ie();Kt()});var ix={};ne(ix,{classifyListStatus:()=>sx,extractSkipReason:()=>nx,listStatusFromVerdict:()=>ox,runVetList:()=>yH});function mH(e,t){switch(e){case"issue_closed":return"closed";case"claimed":return"claimed";case"has_linked_pr":return t.linkedPR?.state==="open"&&t.linkedPR.isStalled?"has_stalled_pr":"has_pr";case"score_too_low":case"anti_llm_policy":case"other":return null}}function nx(e){if(typeof e!="object"||e===null)return;let t=e.skipReason;if(typeof t=="string")return dH.has(t)?t:void 0}function sx(e,t){if(t){let r=mH(t,e);if(r)return r}else{let r=e.reasonsToSkip.map(n=>n.toLowerCase());if(r.some(n=>n.includes("closed")))return"closed";if(r.some(n=>n.includes("claimed")||n.includes("assigned")))return"claimed";if(r.some(n=>n.includes("existing pr")||n.includes("linked pr")||n.includes("pull request")))return e.linkedPR?.state==="open"&&e.linkedPR.isStalled?"has_stalled_pr":"has_pr"}return e.recommendation==="approve"||e.recommendation==="needs_review","still_available"}function ox(e){switch(e){case"closed":return"closed";case"own-open-pr":return"own_open_pr";case"taken":return"claimed";case"at-risk":return"at_risk";case"available":return"still_available"}}function gH(e){return{verdict:e.verdict,verdictReason:e.verdictReason,state:e.state,stateReason:e.stateReason,assignees:e.assignees,linkedPRs:e.linkedPRs}}function hH(e){return{issue:{repo:`${e.owner}/${e.repo}`,number:e.number,title:e.title,url:e.url,labels:[]},recommendation:"skip",reasonsToApprove:[],reasonsToSkip:[e.verdictReason],projectHealth:{},vettingResult:{},grade:rx}}function nS(e){return e instanceof Error?e.message:String(e)}async function yH(e={}){let t=e.concurrency??5,r=e.issueListPath;if(!r){let y=Bs();if(!y)throw new Error("No issue list found. Provide a path with --path or configure issueListPath in settings.");r=y.path}let n=await I_({filePath:r}),s=[...n.available,...n.blocked];if(s.length===0)return{results:[],summary:{total:0,stillAvailable:0,claimed:0,closed:0,hasPR:0,hasStalledPR:0,atRisk:0,ownOpenPr:0,errors:0}};let o=we(Ee()),i=[];s.forEach((y,S)=>{let E=me(y.url);E&&E.type==="issues"&&i.push({index:S,params:{owner:E.owner,repo:E.repo,number:E.number}})});let a=await Wp(o,i.map(y=>y.params),{concurrency:t}),c=new Map;i.forEach((y,S)=>c.set(y.index,a[S]));let l=await Xn();async function p(y){let S=await l.vetIssue(y.url),E=ts({repo:S.issue.repo,projectHealth:S.projectHealth,getRepoScore:G=>M().getRepoScore(G)}),D=M().getState().config.githubUsername,P=Vn({linkedPR:eo(S.vettingResult.linkedPR),userLogin:D}),k=Qn(S.vettingResult.linkedPR);return{vetResult:{issue:{repo:S.issue.repo,number:S.issue.number,title:S.issue.title,url:S.issue.url,labels:S.issue.labels},recommendation:es(S.recommendation,E),reasonsToApprove:S.reasonsToApprove,reasonsToSkip:S.reasonsToSkip,projectHealth:S.projectHealth,vettingResult:S.vettingResult,antiLLMPolicy:S.antiLLMPolicy,linkedPRClassification:P,...k?{linkedPR:k}:{},slmTriage:S.slmTriage??null,grade:E},skipReason:nx(S)}}function d(y,S){let E=nS(S);return{issue:{repo:y.repo,number:y.number,title:y.title,url:y.url,labels:[]},recommendation:"skip",reasonsToApprove:[],reasonsToSkip:[`Error: ${E}`],projectHealth:{},vettingResult:{},grade:rx,listStatus:"error",errorMessage:E}}async function m(y,S){if(!S||S.verification===void 0){let k=S?.error;if(k instanceof W)return{...d(y,k),verifyError:nS(k)};let $={verifyError:k===void 0?`not verified: ${y.url} is not a verifiable issue URL`:nS(k)};try{let{vetResult:G,skipReason:U}=await p(y);return{...G,listStatus:sx(G,U),...$}}catch(G){return{...d(y,G),...$}}}let E=S.verification,D=gH(E),P=ox(E.verdict);if(fH.has(E.verdict))return{...hH(E),listStatus:P,verification:D};try{let{vetResult:k}=await p(y);return{...k,listStatus:P,verification:D}}catch(k){return{...d(y,k),verification:D}}}let f=new Array(s.length),g=0;async function h(){for(;g<s.length;){let y=g++;f[y]=await m(s[y],c.get(y))}}let w=Array.from({length:Math.min(t,s.length)},()=>h());await Promise.all(w);let v={total:f.length,stillAvailable:f.filter(y=>y.listStatus==="still_available").length,claimed:f.filter(y=>y.listStatus==="claimed").length,closed:f.filter(y=>y.listStatus==="closed").length,hasPR:f.filter(y=>y.listStatus==="has_pr").length,hasStalledPR:f.filter(y=>y.listStatus==="has_stalled_pr").length,atRisk:f.filter(y=>y.listStatus==="at_risk").length,ownOpenPr:f.filter(y=>y.listStatus==="own_open_pr").length,errors:f.filter(y=>y.listStatus==="error").length},R;if(e.prune&&r)try{let y=Qd.readFileSync(r,"utf8"),{pruned:S,removedCount:E}=x_(y);S!==y&&Qd.writeFileSync(r,S,"utf8"),R={removedCount:E}}catch(y){let S=y instanceof Error?y.message:String(y);console.error(`Warning: Failed to prune ${r}: ${S}`),R={removedCount:0,error:S}}return{results:f,summary:v,pruneResult:R}}var Qd,rx,dH,fH,ax=C(()=>{"use strict";Qd=H(require("node:fs"),1);Hi();Ti();Lc();Kc();ie();ue();rx=tS({avgResponseDays:null,mergeRate:null,daysSinceLastCommit:null}),dH=new Set(["issue_closed","has_linked_pr","claimed","score_too_low","anti_llm_policy","other"]);fH=new Set(["closed","taken","own-open-pr"])});var cx={};ne(cx,{runSkipAdd:()=>RH});function _H(e){return e.toISOString().slice(0,10)}function RH(e){let t=e.skipFilePath??M().getState().config.skippedIssuesPath;if(!t)throw new Error("No skipped-issues path configured. Set one via `oss-autopilot setup --set skippedIssuesPath=<path>` or pass --path.");if(!bH.test(e.issueUrl))throw new Error(`Invalid GitHub issue or PR URL: ${e.issueUrl}`);if(jO(t).some(s=>s.url===e.issueUrl))return{added:!1,alreadyPresent:!0,url:e.issueUrl,path:t};Bi.existsSync(t)||Bi.writeFileSync(t,wH);let n=_H(e.now??new Date);return Bi.appendFileSync(t,`${n} ${e.issueUrl}
255
+ `;wr.writeFileSync(r,n,{mode:384});try{wr.renameSync(r,t)}catch(s){try{wr.unlinkSync(r)}catch{}throw s}ee(Wd,"State saved")}var wr,RO,Wd,L1,kO=C(()=>{wr=H(require("fs"),1),RO=H(require("path"),1);Ys();Pt();rt();st();Wd="local-state";L1=0});function F1(e){let t="Changes will only be saved locally.";switch(e){case"rate_limit":return`Gist sync unavailable \u2014 GitHub API rate limit exceeded. ${t} Try again after the rate limit resets.`;case"network":return`Gist sync unavailable \u2014 could not reach GitHub. ${t} Check your network connection.`;case"server":return`Gist sync unavailable \u2014 GitHub returned a server error. ${t} Try again later.`;case"unknown":case void 0:return`Gist sync unavailable \u2014 running in offline mode. ${t}`}}function M1(e){return{gists:{async get(t){let{data:r}=await e.gists.get(t);if(!r.id)throw new Error("Gist get returned no id");let n=r.files?Object.fromEntries(Object.entries(r.files).map(([s,o])=>[s,o?{content:o.content}:void 0])):null;return{data:{id:r.id,files:n}}},async create(t){let{data:r}=await e.gists.create(t);if(!r.id)throw new Error("Gist create returned no id");return{data:{id:r.id}}},async update(t){let{data:r}=await e.gists.update(t);if(!r.id)throw new Error("Gist update returned no id");return{data:{id:r.id}}},async list(t){let{data:r}=await e.gists.list(t);return{data:r.filter(n=>n.id).map(n=>({id:n.id,description:n.description??null}))}}}}}async function Zd(e){e.logLevel!==void 0&&vd(e.logLevel);let t,r=null,n=!1;if(e.persistence==="provided")t=e.initialState;else if(e.persistence==="gist"){r=new Bd(M1(ln(e.githubToken)));let s=await r.bootstrap();s.degraded&&z("scout",F1(s.degradedReason));let o=qd();t=Bc(o,s.state),e.gistId?t.gistId=e.gistId:s.gistId&&(t.gistId=s.gistId)}else t=qd(),n=!0;return new Wc(e.githubToken,t,r,{persistLocal:n})}var Wc,EO=C(()=>{FR();Fd();WR();Ys();_O();Td();kO();rt();Pt();st();dn();Wc=class{githubToken;gistStore;state;dirty=!1;persistLocal;constructor(t,r,n=null,s={}){this.githubToken=t,this.gistStore=n,this.state=r,this.persistLocal=s.persistLocal??!1}evictStaleCacheEntries(){mt().evictStale()}async search(t){this.evictStaleCacheEntries(),this.cullExpiredSkips();let r=new Set((this.state.skippedIssues??[]).map(v=>v.url));if(t?.excludeRecentlySurfaced??!0){let v=t?.recentlySurfacedTtlDays??7,R=Date.now()-v*24*60*60*1e3;for(let y of this.state.savedResults??[]){let S=Date.parse(y.lastSeenAt);!Number.isNaN(S)&&S>=R&&r.add(y.issueUrl)}}let n=new Qs(this.githubToken,this.state.preferences,this),s=this.state.preferences,o=s.preferLanguages??[],i=s.preferRepos??[],a=t?.preferLanguages??(o.length>0?o:void 0),c=t?.preferRepos??(i.length>0?i:void 0),l=s.avoidRepos??[],p=s.boostIssueTypes??[],d=t?.avoidRepos??(l.length>0?l:void 0),m=t?.boostIssueTypes??(p.length>0?p:void 0),f=t?.diversityRatio??s.diversityRatio??0,g=this.state.searchRotation??{languageOffset:0},h,w;try{({candidates:h,strategiesUsed:w}=await n.searchIssues({maxResults:t?.maxResults,strategies:t?.strategies,skippedUrls:r,preferLanguages:a,preferRepos:c,avoidRepos:d,boostIssueTypes:m,diversityRatio:f,interPhaseDelayMs:t?.interPhaseDelayMs,broadPhaseDelayMs:t?.broadPhaseDelayMs,languageRotationOffset:g.languageOffset,repoRotationOffsets:{merged:g.phase0Offset??0,starred:g.starredOffset??0,maintained:g.maintainedOffset??0},strategyRotationOffset:t?.full?void 0:g.strategyOffset??0}))}catch(v){throw v instanceof Be&&this.advanceRotation(g,v.strategiesUsed??[],t?.full),v}this.advanceRotation(g,w,t?.full);for(let v of h)this.updateRepoSignalsFromHealth(v.projectHealth);return this.state.lastSearchAt=new Date().toISOString(),this.dirty=!0,{candidates:h,excludedRepos:this.state.preferences.excludeRepos,aiPolicyBlocklist:this.state.preferences.aiPolicyBlocklist,rateLimitWarning:n.rateLimitWarning??void 0,strategiesUsed:w}}advanceRotation(t,r,n=!1){let s=o=>r.includes(o)?1:0;r.length!==0&&(this.state.searchRotation={...t,languageOffset:t.languageOffset+s("broad"),phase0Offset:(t.phase0Offset??0)+s("merged"),starredOffset:(t.starredOffset??0)+s("starred"),maintainedOffset:(t.maintainedOffset??0)+s("maintained"),strategyOffset:n?t.strategyOffset:Ks.indexOf(r[0])+1,lastRotatedAt:new Date().toISOString()},this.dirty=!0)}updateRepoSignalsFromHealth(t){t.checkFailed||this.updateRepoScore(t.repo,{signals:{hasActiveMaintainers:t.isActive}})}async vetIssue(t){return new Qs(this.githubToken,this.state.preferences,this).vetIssue(t)}async features(t){this.evictStaleCacheEntries();let r=t?.count??10,n=ln(this.githubToken),s=new Yn(n,this),o=t?.broad?await fO({octokit:n,vetter:s,count:r,languages:this.state.preferences.languages,excludeRepos:this.state.preferences.excludeRepos,excludeOrgs:this.state.preferences.excludeOrgs,aiPolicyBlocklist:this.state.preferences.aiPolicyBlocklist,splitRatio:t?.splitRatio??this.state.preferences.featuresSplitRatio}):await Hd({octokit:n,vetter:s,repoScores:this.state.repoScores??{},count:r,excludeRepos:this.state.preferences.excludeRepos,excludeOrgs:this.state.preferences.excludeOrgs,aiPolicyBlocklist:this.state.preferences.aiPolicyBlocklist,anchorThreshold:t?.anchorThreshold??this.state.preferences.featuresAnchorThreshold,splitRatio:t?.splitRatio??this.state.preferences.featuresSplitRatio});return this.saveResults([...o.quickWins,...o.biggerBets]),this.state.lastSearchAt=new Date().toISOString(),this.dirty=!0,o}async vetList(t){this.evictStaleCacheEntries();let r=this.getSavedResults(),n=t?.concurrency??5,s=[],o=new Map,i=null;for(let m of r){if(i)break;let f=this.vetIssue(m.issueUrl).then(g=>{s.push({issueUrl:m.issueUrl,repo:m.repo,number:m.number,title:m.title,status:this.classifyVetResult(g),ok:!0,recommendation:g.recommendation,viabilityScore:g.viabilityScore})}).catch(g=>{if(Ae(g)===401||nt(g)){i??=g;return}let h=Ae(g),w=h===404||h===410;s.push({issueUrl:m.issueUrl,repo:m.repo,number:m.number,title:m.title,status:w?"closed":"error",ok:!1,errorMessage:Z(g)})}).finally(()=>{o.delete(m.issueUrl)});o.set(m.issueUrl,f),o.size>=n&&await Promise.race(o.values())}if(await Promise.allSettled(o.values()),i)throw s.length>0&&z("scout",`vetList aborted mid-batch after ${s.length} result(s) \u2014 discarding partial results due to auth/rate-limit failure`),i;let a={total:s.length,stillAvailable:s.filter(m=>m.status==="still_available").length,claimed:s.filter(m=>m.status==="claimed").length,closed:s.filter(m=>m.status==="closed").length,hasPR:s.filter(m=>m.status==="has_pr").length,errors:s.filter(m=>m.status==="error").length},c=new Map((this.state.savedResults??[]).map(m=>[m.issueUrl,m.lastStatus])),l=s.filter(m=>m.status!=="error").filter(m=>{let f=c.get(m.issueUrl);return f!==void 0&&f!==m.status}).map(m=>({issueUrl:m.issueUrl,repo:m.repo,number:m.number,from:c.get(m.issueUrl),to:m.status})),p=new Map(s.map(m=>[m.issueUrl,m.status]));for(let m of this.state.savedResults??[]){let f=p.get(m.issueUrl);f!==void 0&&f!=="error"&&(m.lastStatus=f)}s.length>0&&(this.dirty=!0);let d;if(t?.prune){let m=new Set(s.filter(g=>g.status!=="still_available").map(g=>g.issueUrl)),f=(this.state.savedResults??[]).length;this.state.savedResults=(this.state.savedResults??[]).filter(g=>!m.has(g.issueUrl)),d=f-(this.state.savedResults?.length??0),d>0&&this.addTombstones([...m]),this.dirty=!0}return{results:s,summary:a,prunedCount:d,transitions:l}}classifyVetResult(t){if(t.issueState==="closed")return"closed";let r=t.vettingResult.checks;return r.noExistingPR?r.notClaimed?"still_available":"claimed":"has_pr"}getReposWithMergedPRs(){let t=new Map;for(let r of this.state.mergedPRs??[]){let n=We(r.url);n&&t.set(n,(t.get(n)??0)+1)}return[...t.entries()].sort((r,n)=>n[1]-r[1]).map(([r])=>r)}getReposWithOpenPRs(){let t=new Map;for(let r of this.state.openPRs??[]){let n=We(r.url);n&&t.set(n,(t.get(n)??0)+1)}return[...t.entries()].sort((r,n)=>n[1]-r[1]).map(([r])=>r)}getStarredRepos(){return this.state.starredRepos}getProjectCategories(){return this.state.preferences.projectCategories}getGitHubUsername(){return this.state.preferences.githubUsername}getRepoScore(t){let r=this.state.repoScores[t];return r?r.score:null}getClosedWithoutMergeCount(t){let r=this.state.repoScores[t];return r?r.closedWithoutMergeCount:(this.state.closedPRs??[]).filter(n=>We(n.url)===t).length}getSLMTriageConfig(){let t=this.state.preferences.slmTriageModel??"";return t?{model:t,host:this.state.preferences.slmTriageHost??""}:null}getPreferences(){return this.state.preferences}getRepoScoreRecord(t){return this.state.repoScores[t]}recordMergedPR(t){let r=this.state.mergedPRs??[];r.some(n=>n.url===t.url)||(this.state.mergedPRs=[...r,{url:t.url,title:t.title,mergedAt:t.mergedAt}],this.updateRepoScoreFromPRs(t.repo),this.dirty=!0)}recordClosedPR(t){let r=this.state.closedPRs??[];r.some(n=>n.url===t.url)||(this.state.closedPRs=[...r,{url:t.url,title:t.title,closedAt:t.closedAt}],this.updateRepoScoreFromPRs(t.repo),this.dirty=!0)}recordOpenPR(t){let r=this.state.openPRs??[];r.some(n=>n.url===t.url)||(this.state.openPRs=[...r,{url:t.url,title:t.title,openedAt:t.openedAt}],this.dirty=!0)}async syncOpenPRs(){let t=ln(this.githubToken),r=this.state.openPRs??[],n={checked:r.length,merged:0,closed:0,stillOpen:0,errors:0},s=[];for(let o of r){let i=Ws(o.url);if(!i||i.type!=="pull"){s.push(o),n.errors++;continue}let a=`${i.owner}/${i.repo}`;try{let{data:c}=await t.pulls.get({owner:i.owner,repo:i.repo,pull_number:i.number});c.merged?(this.recordMergedPR({url:o.url,title:o.title,mergedAt:c.merged_at??new Date().toISOString(),repo:a}),n.merged++):c.state==="closed"?(this.recordClosedPR({url:o.url,title:o.title,closedAt:c.closed_at??new Date().toISOString(),repo:a}),n.closed++):(s.push(o),n.stillOpen++)}catch(c){Me(c),z("scout",`sync: could not check ${o.url}: ${Z(c)}`),s.push(o),n.errors++}}return this.state.openPRs=s,this.dirty=!0,await this.checkpoint(),n}updateRepoScore(t,r){let s=this.state.repoScores[t]??{repo:t,score:5,mergedPRCount:0,closedWithoutMergeCount:0,avgResponseDays:null,lastEvaluatedAt:new Date().toISOString(),signals:{hasActiveMaintainers:!1,isResponsive:!1,hasHostileComments:!1}},o={...s,...r,repo:t,lastEvaluatedAt:new Date().toISOString(),signals:{...s.signals,...r.signals??{}}};o.score=this.calculateScore(o),this.state.repoScores[t]=o,this.dirty=!0}updatePreferences(t){this.state.preferences={...this.state.preferences,...t},this.state.preferencesUpdatedAt=new Date().toISOString(),this.dirty=!0}setStarredRepos(t){this.state.starredRepos=t,this.state.starredReposLastFetched=new Date().toISOString(),this.dirty=!0}saveResults(t){let r=new Date().toISOString(),n=new Map((this.state.savedResults??[]).map(s=>[s.issueUrl,s]));for(let s of t){if(s.recommendation==="skip"){n.delete(s.issue.url);let i=new Set(["Issue is closed","Linked PR already merged"]),a=s.reasonsToSkip.some(c=>i.has(c));this.skipIssue(s.issue.url,{repo:s.issue.repo,number:s.issue.number,title:s.issue.title,reason:s.reasonsToSkip.join("; ")||"vetter: skip",permanent:a});continue}let o=n.get(s.issue.url);n.set(s.issue.url,{issueUrl:s.issue.url,repo:s.issue.repo,number:s.issue.number,title:s.issue.title,labels:s.issue.labels,recommendation:s.recommendation,viabilityScore:s.viabilityScore,searchPriority:s.searchPriority,firstSeenAt:o?.firstSeenAt??r,lastSeenAt:r,lastScore:s.viabilityScore,horizon:"horizon"in s?s.horizon:void 0})}this.state.savedResults=[...n.values()],this.dirty=!0}getSavedResults(){return this.state.savedResults??[]}clearResults(){this.addTombstones((this.state.savedResults??[]).map(t=>t.issueUrl)),this.state.savedResults=[],this.dirty=!0}addTombstones(t){if(t.length===0)return;let r=new Date().toISOString(),n=this.state.tombstones??[],s=new Map(n.map(o=>[o.url,o]));for(let o of t)s.set(o,{url:o,removedAt:r});this.state.tombstones=[...s.values()]}skipIssue(t,r){let n=this.state.skippedIssues??[],s=n.find(i=>i.url===t);if(s){r?.permanent===!0&&s.permanent!==!0&&(s.permanent=!0,s.skippedAt=new Date().toISOString(),this.dirty=!0);return}let o=r?.permanent??!0;this.state.skippedIssues=[...n,{url:t,repo:r?.repo??"",number:r?.number??0,title:r?.title??"",skippedAt:new Date().toISOString(),permanent:o,...r?.reason?{reason:r.reason}:{}}],this.state.savedResults&&(this.state.savedResults=this.state.savedResults.filter(i=>i.issueUrl!==t)),this.dirty=!0}getSkippedIssues(){return this.state.skippedIssues??[]}unskipIssue(t){let r=(this.state.skippedIssues??[]).length;this.state.skippedIssues=(this.state.skippedIssues??[]).filter(n=>n.url!==t),this.state.skippedIssues.length<r&&this.addTombstones([t]),this.dirty=!0}clearSkippedIssues(){this.addTombstones((this.state.skippedIssues??[]).map(t=>t.url)),this.state.skippedIssues=[],this.dirty=!0}cullExpiredSkips(t=90){let r=new Date;r.setDate(r.getDate()-t);let n=[];return this.state.skippedIssues=(this.state.skippedIssues??[]).filter(s=>{if(s.permanent!==!1)return!0;let o=new Date(s.skippedAt);return isNaN(o.getTime())||o>=r?!0:(n.push(s.url),!1)}),n.length>0&&(this.addTombstones(n),this.dirty=!0),n.length}isDirty(){return this.dirty}async checkpoint(){if(!this.dirty)return!0;if(this.state.lastRunAt=new Date().toISOString(),this.gistStore&&!await this.gistStore.push(this.state))return!1;if(this.persistLocal)try{this.state=Bc(this.state,qd()),vO(this.state)}catch{return!1}return this.dirty=!1,!0}getState(){return this.state}updateRepoScoreFromPRs(t){let r=(this.state.mergedPRs??[]).filter(s=>We(s.url)===t).length,n=(this.state.closedPRs??[]).filter(s=>We(s.url)===t).length;this.updateRepoScore(t,{mergedPRCount:r,closedWithoutMergeCount:n,lastMergedAt:r>0?(this.state.mergedPRs??[]).filter(s=>We(s.url)===t).sort((s,o)=>o.mergedAt.localeCompare(s.mergedAt))[0]?.mergedAt:void 0})}calculateScore(t){let r=5;return r+=Math.min(t.mergedPRCount,3),r-=Math.min(t.closedWithoutMergeCount,3),t.signals.hasActiveMaintainers&&(r+=1),t.signals.hasHostileComments&&(r-=2),Math.max(1,Math.min(10,r))}}});function PO(){let e=Zc.filter(r=>!(r in qc));if(e.length>0)throw new Error(`FIELD_CONFIGS is missing entries for preference keys: ${e.join(", ")}`);let t=Object.keys(qc).filter(r=>!Zc.includes(r));if(t.length>0)throw new Error(`FIELD_CONFIGS has entries for unknown preference keys: ${t.join(", ")}`)}function G1(e){let t=e.toLowerCase();if(t==="true"||t==="yes")return!0;if(t==="false"||t==="no")return!1;throw new Be(`Invalid boolean value: "${e}". Use true/false or yes/no.`)}function N1(e,t){let r=parseInt(e,10);if(isNaN(r))throw new Be(`Invalid number for "${t}": "${e}"`);return r}function U1(e,t){let r=Number.parseFloat(e);if(isNaN(r))throw new Be(`Invalid number for "${t}": "${e}"`);return r}function KR(e){return e.split(",").map(t=>t.trim()).filter(t=>t.length>0)}function Jd(e,t){if(t.startsWith("+")){let r=KR(t.slice(1)),n=[...e];for(let s of r)n.includes(s)||n.push(s);return n}if(t.startsWith("-")){let r=new Set(KR(t.slice(1)));return e.filter(n=>!r.has(n))}return KR(t)}function CO(e,t,r){let n=qc[t];if(!n)throw new Be(`Unknown config key: "${t}". Valid keys: ${YR.join(", ")}`);let s={...e};switch(n.type){case"string":t==="slmTriageHost"&&zA(r),s[t]=r;break;case"boolean":s[t]=G1(r);break;case"number":s[t]=N1(r,t);break;case"float":s[t]=U1(r,t);break;case"array":{let o=s[t]??[];s[t]=Jd(o,r);break}case"enum":{let o=n.validValues;if(!o.includes(r))throw new Be(`Invalid value for "${t}": "${r}". Valid: ${o.join(", ")}`);s[t]=r;break}case"enum-array":{let o=s[t]??[],i=Jd(o,r),a=n.validValues,c=i.filter(l=>!a.includes(l));if(c.length>0)throw new Be(`Invalid value(s) for "${t}": ${c.join(", ")}. Valid: ${a.join(", ")}`);t==="scope"?s[t]=i.length>0?i:void 0:s[t]=i;break}}return Zs.parse(s)}var qc,Zc,YR,TO=C(()=>{Ys();st();TR();qc={githubUsername:{type:"string"},languages:{type:"array"},labels:{type:"array"},scope:{type:"enum-array",validValues:Uc.options},excludeRepos:{type:"array"},excludeOrgs:{type:"array"},preferredOrgs:{type:"array"},aiPolicyBlocklist:{type:"array"},projectCategories:{type:"enum-array",validValues:Nc.options},minStars:{type:"number"},maxIssueAgeDays:{type:"number"},includeDocIssues:{type:"boolean"},minRepoScoreThreshold:{type:"number"},interPhaseDelayMs:{type:"number"},persistence:{type:"enum",validValues:fR.options},defaultStrategy:{type:"enum-array",validValues:Js.options},broadPhaseDelayMs:{type:"number"},skipBroadWhenSufficientResults:{type:"number"},preferLanguages:{type:"array"},preferRepos:{type:"array"},diversityRatio:{type:"float"},avoidRepos:{type:"array"},boostIssueTypes:{type:"array"},slmTriageModel:{type:"string"},slmTriageHost:{type:"string"},featuresAnchorThreshold:{type:"number"},featuresSplitRatio:{type:"float"}},Zc=Object.keys(Zs.shape),YR=[...Zc].sort()});async function $O(e,t,r=Ct()){let n=e.getPreferences().githubUsername;if(!n)throw new Ii("GitHub username not configured. Run `oss-scout setup` first.");let s=await Cd(t);if(ee(zr,`Rate limit: ${s.remaining}/${s.limit}, resets at ${s.resetAt}`),s.remaining<15)return ee(zr,"Insufficient rate limit, skipping bootstrap"),{starredRepoCount:0,mergedPRCount:0,closedPRCount:0,openPRCount:0,reposScoredCount:0,skippedDueToRateLimit:!0,errors:[]};let o=ln(t),i=[],a=[],c=0,l=new Set;try{let f=0;for await(let g of o.paginate.iterator(o.activity.listReposStarredByAuthenticatedUser,{per_page:Xs,headers:{accept:"application/vnd.github.v3+json"}})){for(let h of g.data){let w=h;a.push(w.full_name)}if(f++,f>=j1)break}ee(zr,`Fetched ${a.length} starred repos`),e.setStarredRepos(a),c=a.length}catch(f){Me(f),z(zr,`Failed to fetch starred repos: ${Z(f)}`),i.push("starred repos fetch failed")}let p=0;try{for(let f=1;f<=QR;f++){await r.waitForBudget();let g;try{g=(await o.search.issuesAndPullRequests({q:`is:pr is:merged author:${n}`,per_page:Xs,page:f})).data}finally{r.recordCall()}for(let h of g.items){let w=We(h.html_url);w&&(e.recordMergedPR({url:h.html_url,title:h.title,mergedAt:h.closed_at??new Date().toISOString(),repo:w}),l.add(w),p++)}if(g.items.length<Xs)break}ee(zr,`Imported ${p} merged PRs`)}catch(f){Me(f),z(zr,`Failed to fetch merged PRs: ${Z(f)}`),i.push("merged PR fetch failed")}let d=0;try{for(let f=1;f<=QR;f++){await r.waitForBudget();let g;try{g=(await o.search.issuesAndPullRequests({q:`is:pr is:closed is:unmerged author:${n}`,per_page:Xs,page:f})).data}finally{r.recordCall()}for(let h of g.items){let w=We(h.html_url);w&&(e.recordClosedPR({url:h.html_url,title:h.title,closedAt:h.closed_at??new Date().toISOString(),repo:w}),l.add(w),d++)}if(g.items.length<Xs)break}ee(zr,`Imported ${d} closed PRs`)}catch(f){Me(f),z(zr,`Failed to fetch closed PRs: ${Z(f)}`),i.push("closed PR fetch failed")}let m=0;try{for(let f=1;f<=QR;f++){await r.waitForBudget();let g;try{g=(await o.search.issuesAndPullRequests({q:`is:pr is:open author:${n}`,per_page:Xs,page:f})).data}finally{r.recordCall()}for(let h of g.items){let w=We(h.html_url);w&&(e.recordOpenPR({url:h.html_url,title:h.title,openedAt:h.created_at??new Date().toISOString(),repo:w}),m++)}if(g.items.length<Xs)break}ee(zr,`Imported ${m} open PRs`)}catch(f){Me(f),z(zr,`Failed to fetch open PRs: ${Z(f)}`),i.push("open PR fetch failed")}return{starredRepoCount:c,mergedPRCount:p,closedPRCount:d,openPRCount:m,reposScoredCount:l.size,skippedDueToRateLimit:!1,errors:i}}var zr,j1,QR,Xs,AO=C(()=>{Td();rt();st();Pt();qs();zr="bootstrap",j1=5,QR=3,Xs=100});function xO(e,t=new Date,r=30){if(!e||e.state!=="open"||!e.updatedAt)return!1;let n=new Date(e.updatedAt);return Number.isNaN(n.getTime())?!1:(t.getTime()-n.getTime())/(1e3*60*60*24)>=r}var OO,IO=C(()=>{OO=30});function FO(e,t,r){if(!t.test(e))throw new Be(`Invalid ${r} URL: ${e}. Expected format: https://github.com/owner/repo/issues/123`)}function MO(e){if(e.length>DO)throw new Be(`URL exceeds maximum length of ${DO} characters`);return e}var LO,DO,GO=C(()=>{st();LO=/^https:\/\/github\.com\/[^/]+\/[^/]+\/issues\/\d+$/,DO=2048});var NO={};ne(NO,{ANCHOR_THRESHOLD:()=>jR,ANTI_LLM_KEYWORDS:()=>vR,FEATURE_LABELS:()=>zd,FIELD_CONFIGS:()=>qc,HorizonSchema:()=>mR,ISSUE_URL_PATTERN:()=>LO,IssueDiscovery:()=>Qs,IssueScopeSchema:()=>Uc,IssueVetter:()=>Yn,NO_ANCHORS_MESSAGE:()=>VR,NO_RESULTS_MESSAGE:()=>BR,OssScout:()=>Wc,PREFERENCE_KEYS:()=>Zc,ProjectCategorySchema:()=>Nc,RepoScoreSchema:()=>pR,SORTED_PREFERENCE_KEYS:()=>YR,STALLED_PR_THRESHOLD_DAYS:()=>OO,ScoutPreferencesSchema:()=>Zs,ScoutStateSchema:()=>pn,SearchStrategySchema:()=>Js,SkippedIssueSchema:()=>dR,applyPreferenceField:()=>CO,assertFieldConfigsCover:()=>PO,bootstrapScout:()=>$O,classifyHorizon:()=>HR,createScout:()=>Zd,discoverFeatures:()=>Hd,enableDebug:()=>nA,fetchRoadmapIssueRefs:()=>Ud,getGitHubToken:()=>sR,getLogLevel:()=>rA,isLinkedPRStalled:()=>xO,parseRoadmapIssueRefs:()=>GR,requireGitHubToken:()=>pA,resolveAnchorRepos:()=>zR,scanForAntiLLMPolicy:()=>kR,setLogLevel:()=>vd,splitByHorizon:()=>jd,updateArray:()=>Jd,validateGitHubUrl:()=>FO,validateUrl:()=>MO});var Kd=C(()=>{EO();Ys();TO();Pt();FR();Fd();ER();AO();rt();WR();IO();NR();GO()});function V1(e){let t=[],r=e.split(/\r?\n/);for(let n=0;n<r.length;n++){let s=n+1,o=r[n].trim();if(o===""||o.startsWith("#"))continue;let i=o.match(/^(\S+)\s+(\S+)(?:\s+#.*)?$/);if(!i){_("skip-file-parser",`Line ${s}: malformed (expected "<date> <url>"): ${o}`);continue}let[,a,c]=i;if(!z1.test(a)){_("skip-file-parser",`Line ${s}: invalid date format (expected YYYY-MM-DD): ${o}`);continue}let l=Date.parse(`${a}T00:00:00.000Z`);if(Number.isNaN(l)){_("skip-file-parser",`Line ${s}: unparseable date: ${o}`);continue}let p=new Date(l).toISOString().slice(0,10);if(p!==a){_("skip-file-parser",`Line ${s}: invalid calendar date ${a} (would be normalized to ${p}): ${o}`);continue}let d=c.match(H1);if(!d){_("skip-file-parser",`Line ${s}: non-GitHub-issue URL: ${o}`);continue}let[,m,f]=d,g=Number.parseInt(f,10);t.push({url:c,repo:m,number:g,title:"",skippedAt:new Date(l).toISOString(),permanent:!0})}return t}function XR(e){if(!e)return{issues:[]};let t=UO.resolve(e);if(!Yd.existsSync(t))return _("skip-file-parser",`Configured skipped-issues file not found at ${t} (cwd ${process.cwd()}); proceeding with an EMPTY skip list \u2014 previously skipped issues may resurface. Use an absolute skippedIssuesPath, or run from the directory that contains "${e}".`),{issues:[],notFound:!0,resolvedPath:t};let r;try{r=Yd.readFileSync(t,"utf8")}catch(n){return _("skip-file-parser",`Failed to read skipped-issues file at ${t}: ${A(n)}`),{issues:[],readError:A(n),resolvedPath:t}}return{issues:V1(r),resolvedPath:t}}function jO(e){return XR(e).issues}var Yd,UO,z1,H1,eS=C(()=>{"use strict";Yd=H(require("node:fs"),1),UO=H(require("node:path"),1);de();ie();z1=/^\d{4}-\d{2}-\d{2}$/,H1=/^https:\/\/github\.com\/([^/]+\/[^/]+)\/(?:issues|pull)\/(\d+)(?:[#/?].*)?$/});function eo(e){if(!e)return null;let t={author:{login:e.author},state:e.merged?"merged":e.state};return e.updatedAt!==void 0&&(t.updatedAt=e.updatedAt),t}function Qn(e){if(!e)return;let t=eo(e);if(!t)return;let r={number:e.number,state:t.state,url:e.url,isStalled:Bp(t)};return e.updatedAt!==void 0&&(r.updatedAt=e.updatedAt),r}function B1(e){let t=M().getState(),{config:r}=t,n=XR(r.skippedIssuesPath);(n.readError!==void 0||n.notFound)&&e&&(e.skipListUnavailable=!0);let s=[...n.issues],o=new Set(s.map(a=>a.url));for(let[a,c]of Object.entries(r.dismissedIssues??{})){if(o.has(a))continue;let l=me(a);s.push({url:a,repo:l?`${l.owner}/${l.repo}`:"",number:l?.number??0,title:"",skippedAt:c,reason:"dismissed",permanent:!0})}let i=Wn(t);return{version:1,stateRevision:1,preferences:{githubUsername:r.githubUsername,languages:r.languages,labels:r.labels,scope:r.scope,excludeRepos:r.excludeRepos,excludeOrgs:r.excludeOrgs??[],preferredOrgs:r.preferredOrgs??[],aiPolicyBlocklist:r.aiPolicyBlocklist,projectCategories:r.projectCategories??[],minStars:r.minStars,maxIssueAgeDays:r.maxIssueAgeDays,includeDocIssues:r.includeDocIssues,minRepoScoreThreshold:r.minRepoScoreThreshold,interPhaseDelayMs:0,broadPhaseDelayMs:0,skipBroadWhenSufficientResults:r.skipBroadWhenSufficientResults,persistence:r.persistence,slmTriageModel:r.slmTriageModel,slmTriageHost:r.slmTriageHost,featuresAnchorThreshold:3,featuresSplitRatio:.6,preferLanguages:i?.recommendations.languages??[],preferRepos:i?.recommendations.repos??[],diversityRatio:Jc,avoidRepos:r.avoidRepos??[],boostIssueTypes:r.boostIssueTypes??[]},repoScores:t.repoScores,tombstones:[],starredRepos:r.starredRepos,starredReposLastFetched:r.starredReposLastFetched,mergedPRs:(t.mergedPRs??[]).map(a=>({url:a.url,title:a.title,mergedAt:a.mergedAt})),closedPRs:(t.closedPRs??[]).map(a=>({url:a.url,title:a.title,closedAt:a.closedAt})),openPRs:(t.lastDigest?.openPRs??[]).map(a=>({url:a.url,title:a.title,openedAt:a.createdAt})),savedResults:(t.searchSeen??[]).map(a=>({issueUrl:a.url,repo:"",number:0,title:"",labels:[],recommendation:"skip",viabilityScore:0,searchPriority:"normal",firstSeenAt:a.lastSeenAt,lastSeenAt:a.lastSeenAt,lastScore:0})),skippedIssues:s,lastRunAt:t.lastRunAt,searchRotation:t.searchRotation??Qb.parse({})}}async function Xn(e){let t=Ee();return Zd({githubToken:t,persistence:"provided",initialState:B1(e)})}var Jc,Hi=C(()=>{"use strict";Kd();ue();Dn();Tc();eS();Jc=.2});function es(e,t){return e==="approve"&&t.score<4?"needs_review":e}function W1(e){return e.reduce((t,r)=>r.score<t.score?r:t)}function q1(e){let t=to.indexOf(e);return t===-1?to[to.length-1]:to[Math.min(t+1,to.length-1)]}function fn(e,t,r){return typeof e!="number"||!Number.isFinite(e)||e<t||e>r?null:e}function Z1(e){return e<3?{score:10,detail:`~${Math.round(e)}-day avg response`}:e<14?{score:7,detail:`${Math.round(e)}-day avg response`}:e<=60?{score:4,detail:`${Math.round(e)}-day avg response`}:{score:1,detail:"unresponsive maintainers"}}function J1(e){let t=Math.round(e*100);return e>.7?{score:10,detail:`merges ${t}% of PRs`}:e>=.4?{score:7,detail:`merges ${t}% of PRs`}:e>=.1?{score:4,detail:`merges ${t}% of PRs`}:{score:1,detail:`merges ${t}% of PRs`}}function K1(e){return e<7?{score:10,detail:"commits in last week"}:e<30?{score:7,detail:"commits in last month"}:e<90?{score:4,detail:"commits in last 90 days"}:{score:1,detail:`no commits in ${e}+ days`}}function Y1(e){let{projectHealth:t,repoScore:r}=e,n=!t.checkFailed,s=fn(r?.avgResponseDays,0,Number.MAX_SAFE_INTEGER)??(n?fn(t.avgIssueResponseDays,.001,Number.MAX_SAFE_INTEGER):null),o=n?fn(t.daysSinceLastCommit,0,Number.MAX_SAFE_INTEGER):null,i=n?fn(t.recentMergeRate,0,1):null;if(i===null&&r){let a=fn(r.mergedPRCount,0,Number.MAX_SAFE_INTEGER),c=fn(r.closedWithoutMergeCount,0,Number.MAX_SAFE_INTEGER);if(a!==null&&c!==null){let l=a+c;i=l===0?null:a/l}}return{avgResponseDays:s,mergeRate:i,daysSinceLastCommit:o}}function ts(e){let t=e.getRepoScore(e.repo),r=e.projectHealth,n=r.checkFailed?{avgIssueResponseDays:null,daysSinceLastCommit:null,checkFailed:!0}:{avgIssueResponseDays:r.avgIssueResponseDays,daysSinceLastCommit:r.daysSinceLastCommit,recentMergeRate:r.recentMergeRate??null,checkFailed:!1};return tS(Y1({projectHealth:n,repoScore:t?{mergedPRCount:t.mergedPRCount,closedWithoutMergeCount:t.closedWithoutMergeCount,avgResponseDays:t.avgResponseDays}:null}))}function tS(e){let t=[],r=[],n=fn(e.avgResponseDays,0,Number.MAX_SAFE_INTEGER);n===null?r.push("maintainer responsiveness"):t.push(Z1(n));let s=fn(e.mergeRate,0,1);s===null?r.push("merge rate"):t.push(J1(s));let o=fn(e.daysSinceLastCommit,0,Number.MAX_SAFE_INTEGER);if(o===null?r.push("activity"):t.push(K1(o)),t.length===0)return{score:to[to.length-1],reason:`unknown ${r.join(", ")}`};let i=W1(t),a=r.length>0?q1(i.score):i.score,c=[i.detail];return r.length>0&&c.push(`unknown ${r.join(", ")}`),{score:a,reason:c.join(", ")}}var to,Kc=C(()=>{"use strict";to=[10,7,4,1]});async function eH(e){let t=[],r=0;for await(let n of e.paginate.iterator(e.activity.listReposStarredByAuthenticatedUser,{per_page:Q1,headers:{accept:"application/vnd.github.v3+json"}})){for(let s of n.data)s.full_name&&t.push(s.full_name);if(r+=1,r>=X1)break}return t}async function zO(e){if(!e.isStarredReposStale())return e.getStarredRepos().length;let t=Ee(),r;try{r=await eH(we(t))}catch(n){return _(rS,`Failed to refresh starred repos; continuing with cached list (${e.getStarredRepos().length}): ${n instanceof Error?n.message:String(n)}`),e.getStarredRepos().length}return r.length===0?(I(rS,"Starred-repo fetch returned 0; keeping existing cache"),e.getStarredRepos().length):(e.setStarredRepos(r),I(rS,`Refreshed starred repos from GitHub: ${r.length} cached`),r.length)}var rS,Q1,X1,HO=C(()=>{"use strict";Cs();zp();de();rS="starred-repos",Q1=100,X1=5});var qO={};ne(qO,{DEFAULT_SEARCH_RESULTS:()=>rH,MAX_SEARCH_RESULTS:()=>tH,SEARCH_DIVERSITY_RATIO:()=>Jc,SEARCH_SEEN_RETENTION_DAYS:()=>BO,parseSearchStrategies:()=>nH,recordSearchSeen:()=>WO,runSearch:()=>oH});function nH(e){if(e===void 0)return;let t=e.split(",").map(n=>n.trim()).filter(Boolean);if(t.length===0)return;let r=[];for(let n of t){let s=Js.safeParse(n);if(!s.success)throw new Error(`Unknown search strategy "${n}". Valid strategies: merged, orgs, starred, broad, maintained, all`);r.push(s.data)}return r}function sH(e){return typeof e!="number"||!Number.isFinite(e)||e<0||e>100?(_(Vi,`Ignoring out-of-contract viabilityScore from scout: ${JSON.stringify(e)}`),0):e}function VO(e){let t=process.env[e];if(t===void 0||t==="")return;let r=Number(t);if(!Number.isInteger(r)||r<0){_(Vi,`Ignoring invalid ${e}="${t}" (expected a non-negative integer); using scout's default delay`);return}return r}function WO(e,t){let r=Date.now(),n=new Date(r).toISOString(),s=r-BO*24*60*60*1e3,o=new Map(e.getSearchSeen().map(a=>[a.url,a]));for(let a of t)o.set(a,{url:a,lastSeenAt:n});let i=[...o.values()].filter(a=>{let c=Date.parse(a.lastSeenAt);return Number.isNaN(c)?!1:c>=s});e.setSearchSeen(i)}async function oH(e){let t={},r=M();await zO(r);let n=await Xn(t),s=Wn(r.getState()),o=s?.recommendations.languages??void 0,i=s?.recommendations.repos??void 0;(o?.length||i?.length)&&I(Vi,`Applying strategy bias to search: preferLanguages=${JSON.stringify(o??[])}, preferRepos=${JSON.stringify(i??[])}`);let a=VO("OSS_AUTOPILOT_SCOUT_INTER_PHASE_DELAY_MS"),c=VO("OSS_AUTOPILOT_SCOUT_BROAD_PHASE_DELAY_MS"),l=await n.search({maxResults:e.maxResults,...e.strategies?{strategies:e.strategies}:{},...e.full?{full:!0}:{},preferLanguages:o,preferRepos:i,diversityRatio:Jc,...a!==void 0?{interPhaseDelayMs:a}:{},...c!==void 0?{broadPhaseDelayMs:c}:{}});WO(r,l.candidates.map(h=>h.issue.url)),r.setSearchRotation(n.getState().searchRotation);let p=await Re(r,Vi),d=r.getState().config?.githubUsername??"";d===""&&_(Vi,"githubUsername not configured \u2014 the own-PR filter (#1354) cannot run; hiddenOwnPRCount will be 0");let m=l.candidates.filter(h=>Vn({linkedPR:eo(h.vettingResult?.linkedPR),userLogin:d})!=="user_open"),f=l.candidates.length-m.length;f>0&&I(Vi,`Hid ${f} candidate(s) with the user's own open PR (#1354)`);let g={candidates:m.map(h=>{let w=r.getRepoScore(h.issue.repo),v=ts({repo:h.issue.repo,projectHealth:h.projectHealth??{repo:h.issue.repo,checkFailed:!0,failureReason:"health not supplied by the caller"},getRepoScore:y=>{let S=r.getRepoScore(y);return S?{mergedPRCount:S.mergedPRCount,closedWithoutMergeCount:S.closedWithoutMergeCount,avgResponseDays:S.avgResponseDays??null}:void 0}}),R=Qn(h.vettingResult?.linkedPR);return{issue:{repo:h.issue.repo,repoUrl:`https://github.com/${h.issue.repo}`,number:h.issue.number,title:h.issue.title,url:h.issue.url,labels:h.issue.labels},recommendation:es(h.recommendation,v),reasonsToApprove:h.reasonsToApprove,reasonsToSkip:h.reasonsToSkip,searchPriority:h.searchPriority,viabilityScore:sH(h.viabilityScore),grade:v,repoScore:w?{score:w.score,mergedPRCount:w.mergedPRCount,closedWithoutMergeCount:w.closedWithoutMergeCount,isResponsive:w.signals?.isResponsive??!1,lastMergedAt:w.lastMergedAt}:void 0,...R?{linkedPR:R}:{},...h.personalization?.kind==="boosted"?{boostScore:h.personalization.score}:{},...h.personalization?.kind==="boosted"&&h.personalization.reasons.length>0?{boostReasons:h.personalization.reasons}:{},...h.personalization?.kind==="diversity"?{diversitySlot:!0}:{}}}),excludedRepos:l.excludedRepos,aiPolicyBlocklist:l.aiPolicyBlocklist,hiddenOwnPRCount:f};return p&&(g.gistSyncWarning=p),l.rateLimitWarning&&(g.rateLimitWarning=l.rateLimitWarning),t.skipListUnavailable&&(g.skipListUnavailable=!0),g}var Vi,tH,rH,BO,ZO=C(()=>{"use strict";Hi();Kd();ue();Kc();Tc();HO();de();Hi();Vi="search",tH=100,rH=15;BO=30});var KO={};ne(KO,{MAX_FEATURES_RESULTS:()=>aH,runFeatures:()=>uH});function cH(e){return typeof e!="number"||!Number.isFinite(e)||e<0||e>100?(_(iH,`Ignoring out-of-contract viabilityScore from scout: ${JSON.stringify(e)}`),0):e}function JO(e,t){let r=t.getRepoScore(e.issue.repo),n=ts({repo:e.issue.repo,projectHealth:e.projectHealth??{repo:e.issue.repo,checkFailed:!0,failureReason:"health not supplied by the caller"},getRepoScore:o=>{let i=t.getRepoScore(o);return i?{mergedPRCount:i.mergedPRCount,closedWithoutMergeCount:i.closedWithoutMergeCount,avgResponseDays:i.avgResponseDays??null}:void 0}}),s=Qn(e.vettingResult?.linkedPR);return{issue:{repo:e.issue.repo,repoUrl:`https://github.com/${e.issue.repo}`,number:e.issue.number,title:e.issue.title,url:e.issue.url,labels:e.issue.labels},recommendation:es(e.recommendation,n),reasonsToApprove:e.reasonsToApprove,reasonsToSkip:e.reasonsToSkip,searchPriority:e.searchPriority,viabilityScore:cH(e.viabilityScore),grade:n,repoScore:r?{score:r.score,mergedPRCount:r.mergedPRCount,closedWithoutMergeCount:r.closedWithoutMergeCount,isResponsive:r.signals?.isResponsive??!1,lastMergedAt:r.lastMergedAt}:void 0,...s?{linkedPR:s}:{},horizon:e.horizon}}async function uH(e){let r=await(await Xn()).features({count:e.maxResults,anchorThreshold:e.anchorThreshold,splitRatio:e.splitRatio}),n=M();return{quickWins:r.quickWins.map(o=>JO(o,n)),biggerBets:r.biggerBets.map(o=>JO(o,n)),anchorRepos:r.anchorRepos,message:r.message}}var iH,aH,YO=C(()=>{"use strict";Hi();ue();Kc();de();iH="features",aH=100});var QO={};ne(QO,{runVet:()=>lH});async function lH(e){Xe(e.issueUrl),Qe(e.issueUrl,yr,"issue");let r=await(await Xn()).vetIssue(e.issueUrl),n=ts({repo:r.issue.repo,projectHealth:r.projectHealth,getRepoScore:a=>M().getRepoScore(a)}),s=M().getState().config.githubUsername,o=Vn({linkedPR:eo(r.vettingResult.linkedPR),userLogin:s}),i=Qn(r.vettingResult.linkedPR);return{issue:{repo:r.issue.repo,number:r.issue.number,title:r.issue.title,url:r.issue.url,labels:r.issue.labels},recommendation:es(r.recommendation,n),reasonsToApprove:r.reasonsToApprove,reasonsToSkip:r.reasonsToSkip,projectHealth:r.projectHealth,vettingResult:r.vettingResult,antiLLMPolicy:r.antiLLMPolicy,linkedPRClassification:o,...i?{linkedPR:i}:{},slmTriage:r.slmTriage??null,grade:n}}var XO=C(()=>{"use strict";Hi();Kt();Kc();ue()});var ex={};ne(ex,{runVerifyIssue:()=>pH});async function pH(e){Xe(e.issueUrl),Qe(e.issueUrl,yr,"issue");let t=me(e.issueUrl);if(!t||t.type!=="issues")throw new W(`Not a parseable GitHub issue URL: ${e.issueUrl}`);let r=we(Ee());return bc(r,{owner:t.owner,repo:t.repo,number:t.number})}var tx=C(()=>{"use strict";ue();ie();Kt()});var ix={};ne(ix,{classifyListStatus:()=>sx,extractSkipReason:()=>nx,listStatusFromVerdict:()=>ox,runVetList:()=>yH});function mH(e,t){switch(e){case"issue_closed":return"closed";case"claimed":return"claimed";case"has_linked_pr":return t.linkedPR?.state==="open"&&t.linkedPR.isStalled?"has_stalled_pr":"has_pr";case"score_too_low":case"anti_llm_policy":case"other":return null}}function nx(e){if(typeof e!="object"||e===null)return;let t=e.skipReason;if(typeof t=="string")return dH.has(t)?t:void 0}function sx(e,t){if(t){let r=mH(t,e);if(r)return r}else{let r=e.reasonsToSkip.map(n=>n.toLowerCase());if(r.some(n=>n.includes("closed")))return"closed";if(r.some(n=>n.includes("claimed")||n.includes("assigned")))return"claimed";if(r.some(n=>n.includes("existing pr")||n.includes("linked pr")||n.includes("pull request")))return e.linkedPR?.state==="open"&&e.linkedPR.isStalled?"has_stalled_pr":"has_pr"}return e.recommendation==="approve"||e.recommendation==="needs_review","still_available"}function ox(e){switch(e){case"closed":return"closed";case"own-open-pr":return"own_open_pr";case"taken":return"claimed";case"at-risk":return"at_risk";case"available":return"still_available"}}function gH(e){return{verdict:e.verdict,verdictReason:e.verdictReason,state:e.state,stateReason:e.stateReason,assignees:e.assignees,linkedPRs:e.linkedPRs}}function hH(e){return{issue:{repo:`${e.owner}/${e.repo}`,number:e.number,title:e.title,url:e.url,labels:[]},recommendation:"skip",reasonsToApprove:[],reasonsToSkip:[e.verdictReason],projectHealth:{},vettingResult:{},grade:rx}}function nS(e){return e instanceof Error?e.message:String(e)}async function yH(e={}){let t=e.concurrency??5,r=e.issueListPath;if(!r){let y=Bs();if(!y)throw new Error("No issue list found. Provide a path with --path or configure issueListPath in settings.");r=y.path}let n=await I_({filePath:r}),s=[...n.available,...n.blocked];if(s.length===0)return{results:[],summary:{total:0,stillAvailable:0,claimed:0,closed:0,hasPR:0,hasStalledPR:0,atRisk:0,ownOpenPr:0,errors:0}};let o=we(Ee()),i=[];s.forEach((y,S)=>{let E=me(y.url);E&&E.type==="issues"&&i.push({index:S,params:{owner:E.owner,repo:E.repo,number:E.number}})});let a=await Wp(o,i.map(y=>y.params),{concurrency:t}),c=new Map;i.forEach((y,S)=>c.set(y.index,a[S]));let l=await Xn();async function p(y){let S=await l.vetIssue(y.url),E=ts({repo:S.issue.repo,projectHealth:S.projectHealth,getRepoScore:G=>M().getRepoScore(G)}),D=M().getState().config.githubUsername,P=Vn({linkedPR:eo(S.vettingResult.linkedPR),userLogin:D}),k=Qn(S.vettingResult.linkedPR);return{vetResult:{issue:{repo:S.issue.repo,number:S.issue.number,title:S.issue.title,url:S.issue.url,labels:S.issue.labels},recommendation:es(S.recommendation,E),reasonsToApprove:S.reasonsToApprove,reasonsToSkip:S.reasonsToSkip,projectHealth:S.projectHealth,vettingResult:S.vettingResult,antiLLMPolicy:S.antiLLMPolicy,linkedPRClassification:P,...k?{linkedPR:k}:{},slmTriage:S.slmTriage??null,grade:E},skipReason:nx(S)}}function d(y,S){let E=nS(S);return{issue:{repo:y.repo,number:y.number,title:y.title,url:y.url,labels:[]},recommendation:"skip",reasonsToApprove:[],reasonsToSkip:[`Error: ${E}`],projectHealth:{},vettingResult:{},grade:rx,listStatus:"error",errorMessage:E}}async function m(y,S){if(!S||S.verification===void 0){let k=S?.error;if(k instanceof W)return{...d(y,k),verifyError:nS(k)};let $={verifyError:k===void 0?`not verified: ${y.url} is not a verifiable issue URL`:nS(k)};try{let{vetResult:G,skipReason:U}=await p(y);return{...G,listStatus:sx(G,U),...$}}catch(G){return{...d(y,G),...$}}}let E=S.verification,D=gH(E),P=ox(E.verdict);if(fH.has(E.verdict))return{...hH(E),listStatus:P,verification:D};try{let{vetResult:k}=await p(y);return{...k,listStatus:P,verification:D}}catch(k){return{...d(y,k),verification:D}}}let f=new Array(s.length),g=0;async function h(){for(;g<s.length;){let y=g++;f[y]=await m(s[y],c.get(y))}}let w=Array.from({length:Math.min(t,s.length)},()=>h());await Promise.all(w);let v={total:f.length,stillAvailable:f.filter(y=>y.listStatus==="still_available").length,claimed:f.filter(y=>y.listStatus==="claimed").length,closed:f.filter(y=>y.listStatus==="closed").length,hasPR:f.filter(y=>y.listStatus==="has_pr").length,hasStalledPR:f.filter(y=>y.listStatus==="has_stalled_pr").length,atRisk:f.filter(y=>y.listStatus==="at_risk").length,ownOpenPr:f.filter(y=>y.listStatus==="own_open_pr").length,errors:f.filter(y=>y.listStatus==="error").length},R;if(e.prune&&r)try{let y=Qd.readFileSync(r,"utf8"),{pruned:S,removedCount:E}=x_(y);S!==y&&Qd.writeFileSync(r,S,"utf8"),R={removedCount:E}}catch(y){let S=y instanceof Error?y.message:String(y);console.error(`Warning: Failed to prune ${r}: ${S}`),R={removedCount:0,error:S}}return{results:f,summary:v,pruneResult:R}}var Qd,rx,dH,fH,ax=C(()=>{"use strict";Qd=H(require("node:fs"),1);Hi();Ti();Lc();Kc();ie();ue();rx=tS({avgResponseDays:null,mergeRate:null,daysSinceLastCommit:null}),dH=new Set(["issue_closed","has_linked_pr","claimed","score_too_low","anti_llm_policy","other"]);fH=new Set(["closed","taken","own-open-pr"])});var cx={};ne(cx,{runSkipAdd:()=>RH});function _H(e){return e.toISOString().slice(0,10)}function RH(e){let t=e.skipFilePath??M().getState().config.skippedIssuesPath;if(!t)throw new Error("No skipped-issues path configured. Set one via `oss-autopilot setup --set skippedIssuesPath=<path>` or pass --path.");if(!bH.test(e.issueUrl))throw new Error(`Invalid GitHub issue or PR URL: ${e.issueUrl}`);if(jO(t).some(s=>s.url===e.issueUrl))return{added:!1,alreadyPresent:!0,url:e.issueUrl,path:t};Bi.existsSync(t)||Bi.writeFileSync(t,wH);let n=_H(e.now??new Date);return Bi.appendFileSync(t,`${n} ${e.issueUrl}
256
256
  `),{added:!0,alreadyPresent:!1,url:e.issueUrl,path:t,date:n}}var Bi,bH,wH,ux=C(()=>{"use strict";Bi=H(require("node:fs"),1);eS();ue();bH=/^https:\/\/github\.com\/([^/]+\/[^/]+)\/(?:issues|pull)\/(\d+)(?:[#/?].*)?$/,wH=`# Skipped Issues \u2014 permanent
257
257
  # Format: YYYY-MM-DD URL
258
258
 
@@ -305,9 +305,9 @@ Capacity: ${o.openPRCount} open, ${o.dormantPRCount} dormant across ${o.dormantR
305
305
  Trajectory: ${i.trajectoryDirection}`);let l=i.prTypeDistribution,p=[];for(let[d,m]of Object.entries(l))typeof m=="number"&&m>0&&p.push([d,m]);p.length>0&&console.log(`PR types (recent): ${p.map(([d,m])=>`${d}=${m}`).join(", ")}`),a.avoidPatterns.length>0&&console.log(`
306
306
  Watch for: ${a.avoidPatterns.join("; ")}`),console.log(`
307
307
  Run with --json for structured output`)},r)})}},{name:"state",register(e){e.command("state").description("Manage state persistence (local/gist). Gist mode uses ETag-based optimistic concurrency: a concurrent push from another machine surfaces as a CONCURRENCY error rather than silently overwriting (#1115).").option("--show","Display current persistence mode and Gist ID").option("--sync","Force push state to Gist (no-op if not in Gist mode)").option("--unlink","Switch from Gist back to local persistence").option("--validate","When used with --show, also report stored PR entries with unparseable URLs").option("--json","Output as JSON").action(async t=>{t.unlink?await ae(t,async()=>(await Promise.resolve().then(()=>(Rd(),_d))).runStateUnlink(),r=>{console.log(`State written to ${r.localStatePath}`),console.log("Persistence switched to local mode."),r.previousGistId&&console.log(`Previous Gist (${r.previousGistId}) was NOT deleted.`),console.log("Restart any running processes (e.g. dashboard server) to pick up the change.")}):t.sync?await ae(t,async()=>(await Promise.resolve().then(()=>(Rd(),_d))).runStateSync(),r=>{r.pushed?console.log(`State pushed to Gist ${r.gistId}`):console.log("Not in Gist mode. Nothing to sync.")}):await ae(t,async()=>(await Promise.resolve().then(()=>(Rd(),_d))).runStateShow({validate:!!t.validate}),r=>{if(console.log(`
308
- Persistence: ${r.persistence}`),r.gistId&&console.log(`Gist ID: ${r.gistId}`),r.gistDegraded&&console.log("Status: DEGRADED (using local cache)"),console.log(`Last run: ${r.lastRunAt??"Never"}`),r.invalidEntries)if(r.invalidEntries.length===0)console.log("Validation: no invalid PR URLs in stored state.");else{console.log(`Validation: ${r.invalidEntries.length} stored PR(s) with invalid URLs:`);for(let n of r.invalidEntries)console.log(` [${n.kind}] ${n.url} ${n.title}`)}console.log("")})})}},{name:"search",register(e){e.command("search [count]").description("Search for new issues to work on").option("--json","Output as JSON").option("--strategy <strategies>","Comma-separated discovery phases to run (merged,orgs,starred,broad,maintained,all). Omit to run scout's default staged pipeline.").action(async(t,r)=>{let{SearchOutputSchema:n}=await Promise.resolve().then(()=>(ge(),ve));await ae(r,async()=>{let{runSearch:s,MAX_SEARCH_RESULTS:o,DEFAULT_SEARCH_RESULTS:i,parseSearchStrategies:a}=await Promise.resolve().then(()=>(ZO(),qO)),c=a(r.strategy),l=i;if(t!==void 0){let p=Number(t);if(!Number.isFinite(p)||p<1||!Number.isInteger(p))throw new Error(`Invalid count "${t}". Must be a positive integer.`);l=p}return l>o&&(console.warn(`Capping search to ${o} results (requested: ${l})`),l=o),r.json||console.log(`
308
+ Persistence: ${r.persistence}`),r.gistId&&console.log(`Gist ID: ${r.gistId}`),r.gistDegraded&&console.log("Status: DEGRADED (using local cache)"),console.log(`Last run: ${r.lastRunAt??"Never"}`),r.invalidEntries)if(r.invalidEntries.length===0)console.log("Validation: no invalid PR URLs in stored state.");else{console.log(`Validation: ${r.invalidEntries.length} stored PR(s) with invalid URLs:`);for(let n of r.invalidEntries)console.log(` [${n.kind}] ${n.url} ${n.title}`)}console.log("")})})}},{name:"search",register(e){e.command("search [count]").description("Search for new issues to work on").option("--json","Output as JSON").option("--strategy <strategies>","Comma-separated discovery phases to rotate through (merged,orgs,starred,broad,maintained,all). Omit for all. Each search runs one of them in turn unless --full is set.").option("--full","Run every enabled strategy in this search instead of one per search in rotation. More API calls, can take a few minutes.").action(async(t,r)=>{let{SearchOutputSchema:n}=await Promise.resolve().then(()=>(ge(),ve));await ae(r,async()=>{let{runSearch:s,MAX_SEARCH_RESULTS:o,DEFAULT_SEARCH_RESULTS:i,parseSearchStrategies:a}=await Promise.resolve().then(()=>(ZO(),qO)),c=a(r.strategy),l=i;if(t!==void 0){let p=Number(t);if(!Number.isFinite(p)||p<1||!Number.isInteger(p))throw new Error(`Invalid count "${t}". Must be a positive integer.`);l=p}return l>o&&(console.warn(`Capping search to ${o} results (requested: ${l})`),l=o),r.json||console.log(`
309
309
  Searching for issues (max ${l})...
310
- `),s({maxResults:l,strategies:c})},s=>{if(s.hiddenOwnPRCount>0&&console.log(`Hidden: ${s.hiddenOwnPRCount} candidate(s) were issues you already have open PRs for.`),s.candidates.length===0){s.rateLimitWarning?console.warn(`
310
+ `),s({maxResults:l,strategies:c,full:r.full})},s=>{if(s.hiddenOwnPRCount>0&&console.log(`Hidden: ${s.hiddenOwnPRCount} candidate(s) were issues you already have open PRs for.`),s.candidates.length===0){s.rateLimitWarning?console.warn(`
311
311
  ${s.rateLimitWarning}
312
312
  `):console.log("No matching issues found.");return}s.rateLimitWarning&&console.warn(`
313
313
  ${s.rateLimitWarning}
@@ -30,17 +30,23 @@ interface SearchOptions {
30
30
  maxResults: number;
31
31
  /**
32
32
  * Restrict discovery to specific scout phases (#1244 selector surface).
33
- * Undefined runs scout's default staged pipeline (all phases). Passed
34
- * straight through to `scout.search`, which gates each phase on the set.
33
+ * Undefined lets scout rotate through all of them, one strategy per search.
34
+ * Passed straight through to `scout.search`.
35
35
  */
36
36
  strategies?: SearchStrategy[];
37
+ /**
38
+ * Run every enabled strategy in this one search instead of one per search in
39
+ * rotation. More API calls (scout's budget tracker paces them), so it suits
40
+ * an interactive search rather than a scheduled one.
41
+ */
42
+ full?: boolean;
37
43
  }
38
44
  /**
39
45
  * Parse and validate a comma-separated `--strategy` value into scout strategies.
40
46
  *
41
47
  * Mirrors oss-scout's own CLI validation so an unknown token fails fast with a
42
48
  * clear message instead of silently running all phases. Returns `undefined`
43
- * for an absent/empty value so scout falls back to its default (all phases).
49
+ * for an absent/empty value so scout falls back to its default rotation.
44
50
  *
45
51
  * @throws {Error} If any token is not a valid scout strategy.
46
52
  */
@@ -35,7 +35,7 @@ export { SEARCH_DIVERSITY_RATIO } from './scout-bridge.js';
35
35
  *
36
36
  * Mirrors oss-scout's own CLI validation so an unknown token fails fast with a
37
37
  * clear message instead of silently running all phases. Returns `undefined`
38
- * for an absent/empty value so scout falls back to its default (all phases).
38
+ * for an absent/empty value so scout falls back to its default rotation.
39
39
  *
40
40
  * @throws {Error} If any token is not a valid scout strategy.
41
41
  */
@@ -176,6 +176,7 @@ export async function runSearch(options) {
176
176
  const result = await scout.search({
177
177
  maxResults: options.maxResults,
178
178
  ...(options.strategies ? { strategies: options.strategies } : {}),
179
+ ...(options.full ? { full: true } : {}),
179
180
  preferLanguages,
180
181
  preferRepos,
181
182
  diversityRatio: SEARCH_DIVERSITY_RATIO,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oss-autopilot/core",
3
- "version": "3.30.0",
3
+ "version": "3.31.0",
4
4
  "description": "CLI and core library for managing open source contributions",
5
5
  "type": "module",
6
6
  "bin": {
@@ -55,7 +55,7 @@
55
55
  "@octokit/plugin-retry": "^8.1.1",
56
56
  "@octokit/plugin-throttling": "^11.0.5",
57
57
  "@octokit/rest": "^22.0.1",
58
- "@oss-scout/core": "^1.8.1",
58
+ "@oss-scout/core": "^1.9.0",
59
59
  "commander": "^15.0.0",
60
60
  "zod": "^4.5.4"
61
61
  },