allwright 1.108.0 → 1.110.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.
Files changed (2) hide show
  1. package/bin/allwright.js +11 -7
  2. package/package.json +1 -1
package/bin/allwright.js CHANGED
@@ -21,7 +21,7 @@ Expecting one of '${r.join("', '")}'`);return this._lifeCycleHooks[e]?this._life
21
21
  `),this._exit(0,"commander.version",e)}),this}description(e,n){return e===void 0&&n===void 0?this._description:(this._description=e,n&&(this._argsDescription=n),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let n=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(n=this.commands[this.commands.length-1]),e===n._name)throw new Error("Command alias can't be the same as its name");let r=this.parent?._findCommand(e);if(r){let s=[r.name()].concat(r.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${s}'`)}return n._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(n=>this.alias(n)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let n=this.registeredArguments.map(r=>uk(r));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?n:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=gn.basename(e,gn.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let n=this.createHelp();return n.helpWidth===void 0&&(n.helpWidth=e&&e.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),n.formatHelp(this,n)}_getHelpContext(e){e=e||{};let n={error:!!e.error},r;return n.error?r=s=>this._outputConfiguration.writeErr(s):r=s=>this._outputConfiguration.writeOut(s),n.write=e.write||r,n.command=this,n}outputHelp(e){let n;typeof e=="function"&&(n=e,e=void 0);let r=this._getHelpContext(e);this._getCommandAndAncestors().reverse().forEach(i=>i.emit("beforeAllHelp",r)),this.emit("beforeHelp",r);let s=this.helpInformation(r);if(n&&(s=n(s),typeof s!="string"&&!Buffer.isBuffer(s)))throw new Error("outputHelp callback must return a string or a Buffer");r.write(s),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",r),this._getCommandAndAncestors().forEach(i=>i.emit("afterAllHelp",r))}helpOption(e,n){return typeof e=="boolean"?(e?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(e=e??"-h, --help",n=n??"display help for command",this._helpOption=this.createOption(e,n),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this}help(e){this.outputHelp(e);let n=Me.exitCode||0;n===0&&e&&typeof e!="function"&&e.error&&(n=1),this._exit(n,"commander.help","(outputHelp)")}addHelpText(e,n){let r=["beforeAll","before","after","afterAll"];if(!r.includes(e))throw new Error(`Unexpected value for position to addHelpText.
22
22
  Expecting one of '${r.join("', '")}'`);let s=`${e}Help`;return this.on(s,i=>{let a;typeof n=="function"?a=n({error:i.error,command:i.command}):a=n,a&&i.write(`${a}
23
23
  `)}),this}_outputHelpIfRequested(e){let n=this._getHelpOption();n&&e.find(s=>n.is(s))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Lh(t){return t.map(e=>{if(!e.startsWith("--inspect"))return e;let n,r="127.0.0.1",s="9229",i;return(i=e.match(/^(--inspect(-brk)?)$/))!==null?n=i[1]:(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(n=i[1],/^\d+$/.test(i[3])?s=i[3]:r=i[3]):(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(n=i[1],r=i[3],s=i[4]),n&&s!=="0"?`${n}=${r}:${parseInt(s)+1}`:e})}Uh.Command=ml});var Kh=me(wt=>{var{Argument:Fh}=Uo(),{Command:gl}=qh(),{CommanderError:pk,InvalidArgumentError:Bh}=Mi(),{Help:fk}=al(),{Option:Hh}=dl();wt.program=new gl;wt.createCommand=t=>new gl(t);wt.createOption=(t,e)=>new Hh(t,e);wt.createArgument=(t,e)=>new Fh(t,e);wt.Command=gl;wt.Option=Hh;wt.Argument=Fh;wt.Help=fk;wt.CommanderError=pk;wt.InvalidArgumentError=Bh;wt.InvalidOptionArgumentError=Bh});var de,yl,G,Yt,ji=X(()=>{(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function n(s){throw new Error}t.assertNever=n,t.arrayToEnum=s=>{let i={};for(let a of s)i[a]=a;return i},t.getValidEnumValues=s=>{let i=t.objectKeys(s).filter(c=>typeof s[s[c]]!="number"),a={};for(let c of i)a[c]=s[c];return t.objectValues(a)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},t.find=(s,i)=>{for(let a of s)if(i(a))return a},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}t.joinValues=r,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(de||(de={}));(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(yl||(yl={}));G=de.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Yt=t=>{switch(typeof t){case"undefined":return G.undefined;case"string":return G.string;case"number":return Number.isNaN(t)?G.nan:G.number;case"boolean":return G.boolean;case"function":return G.function;case"bigint":return G.bigint;case"symbol":return G.symbol;case"object":return Array.isArray(t)?G.array:t===null?G.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?G.promise:typeof Map<"u"&&t instanceof Map?G.map:typeof Set<"u"&&t instanceof Set?G.set:typeof Date<"u"&&t instanceof Date?G.date:G.object;default:return G.unknown}}});var O,mk,it,qo=X(()=>{ji();O=de.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),mk=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),it=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){let n=e||function(i){return i.message},r={_errors:[]},s=i=>{for(let a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else{let c=r,l=0;for(;l<a.path.length;){let u=a.path[l];l===a.path.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(n(a))):c[u]=c[u]||{_errors:[]},c=c[u],l++}}};return s(this),r}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,de.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let s of this.issues)if(s.path.length>0){let i=s.path[0];n[i]=n[i]||[],n[i].push(e(s))}else r.push(e(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};it.create=t=>new it(t)});var gk,yn,bl=X(()=>{qo();ji();gk=(t,e)=>{let n;switch(t.code){case O.invalid_type:t.received===G.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case O.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,de.jsonStringifyReplacer)}`;break;case O.unrecognized_keys:n=`Unrecognized key(s) in object: ${de.joinValues(t.keys,", ")}`;break;case O.invalid_union:n="Invalid input";break;case O.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${de.joinValues(t.options)}`;break;case O.invalid_enum_value:n=`Invalid enum value. Expected ${de.joinValues(t.options)}, received '${t.received}'`;break;case O.invalid_arguments:n="Invalid function arguments";break;case O.invalid_return_type:n="Invalid function return type";break;case O.invalid_date:n="Invalid date";break;case O.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:de.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case O.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case O.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case O.custom:n="Invalid input";break;case O.invalid_intersection_types:n="Intersection results could not be merged";break;case O.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case O.not_finite:n="Number must be finite";break;default:n=e.defaultError,de.assertNever(t)}return{message:n}},yn=gk});function yk(t){Zh=t}function js(){return Zh}var Zh,Fo=X(()=>{bl();Zh=yn});function K(t,e){let n=js(),r=Oi({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===yn?void 0:yn].filter(s=>!!s)});t.common.issues.push(r)}var Oi,bk,Ke,ne,wr,Ve,Bo,Ho,Fn,Os,wl=X(()=>{Fo();bl();Oi=t=>{let{data:e,path:n,errorMaps:r,issueData:s}=t,i=[...n,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let c="",l=r.filter(u=>!!u).slice().reverse();for(let u of l)c=u(a,{data:e,defaultError:c}).message;return{...s,path:i,message:c}},bk=[];Ke=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){let r=[];for(let s of n){if(s.status==="aborted")return ne;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let s of n){let i=await s.key,a=await s.value;r.push({key:i,value:a})}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let s of n){let{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return ne;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(r[i.value]=a.value)}return{status:e.value,value:r}}},ne=Object.freeze({status:"aborted"}),wr=t=>({status:"dirty",value:t}),Ve=t=>({status:"valid",value:t}),Bo=t=>t.status==="aborted",Ho=t=>t.status==="dirty",Fn=t=>t.status==="valid",Os=t=>typeof Promise<"u"&&t instanceof Promise});var Vh=X(()=>{});var Q,Yh=X(()=>{(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(Q||(Q={}))});function ae(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:s}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,c)=>{let{message:l}=t;return a.code==="invalid_enum_value"?{message:l??c.defaultError}:typeof c.data>"u"?{message:l??r??c.defaultError}:a.code!=="invalid_type"?{message:c.defaultError}:{message:l??n??c.defaultError}},description:s}}function ep(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function jk(t){return new RegExp(`^${ep(t)}$`)}function tp(t){let e=`${Qh}T${ep(t)}`,n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function Ok(t,e){return!!((e==="v4"||!e)&&Ek.test(t)||(e==="v6"||!e)&&$k.test(t))}function zk(t,e){if(!xk.test(t))return!1;try{let[n]=t.split(".");if(!n)return!1;let r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function Dk(t,e){return!!((e==="v4"||!e)&&Ak.test(t)||(e==="v6"||!e)&&Ck.test(t))}function Lk(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(t.toFixed(s).replace(".","")),a=Number.parseInt(e.toFixed(s).replace(".",""));return i%a/10**s}function zs(t){if(t instanceof ot){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=vt.create(zs(r))}return new ot({...t._def,shape:()=>e})}else return t instanceof vn?new vn({...t._def,type:zs(t.element)}):t instanceof vt?vt.create(zs(t.unwrap())):t instanceof Xt?Xt.create(zs(t.unwrap())):t instanceof Jt?Jt.create(t.items.map(e=>zs(e))):t}function kl(t,e){let n=Yt(t),r=Yt(e);if(t===e)return{valid:!0,data:t};if(n===G.object&&r===G.object){let s=de.objectKeys(e),i=de.objectKeys(t).filter(c=>s.indexOf(c)!==-1),a={...t,...e};for(let c of i){let l=kl(t[c],e[c]);if(!l.valid)return{valid:!1};a[c]=l.data}return{valid:!0,data:a}}else if(n===G.array&&r===G.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let a=t[i],c=e[i],l=kl(a,c);if(!l.valid)return{valid:!1};s.push(l.data)}return{valid:!0,data:s}}else return n===G.date&&r===G.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}function np(t,e){return new $r({values:t,typeName:re.ZodEnum,...ae(e)})}function Xh(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function rp(t,e={},n){return t?Hn.create().superRefine((r,s)=>{let i=t(r);if(i instanceof Promise)return i.then(a=>{if(!a){let c=Xh(e,r),l=c.fatal??n??!0;s.addIssue({code:"custom",...c,fatal:l})}});if(!i){let a=Xh(e,r),c=a.fatal??n??!0;s.addIssue({code:"custom",...a,fatal:c})}}):Hn.create()}var kt,Jh,ue,wk,vk,kk,Sk,_k,xk,Tk,Rk,Ik,vl,Ek,Ak,$k,Ck,Pk,Nk,Qh,Mk,Bn,vr,kr,Sr,_r,Ds,xr,Tr,Hn,wn,Ut,Ls,vn,ot,Rr,bn,Ko,Ir,Jt,Wo,Us,qs,Go,Er,Ar,$r,Cr,Kn,St,vt,Xt,Pr,Nr,Fs,Uk,zi,Di,Mr,qk,re,Fk,sp,ip,Bk,Hk,op,Kk,Wk,Gk,Zk,Vk,Yk,Jk,Xk,Qk,e0,t0,n0,r0,s0,i0,o0,a0,c0,l0,u0,d0,h0,p0,f0,m0,g0,y0,b0,w0,v0,k0,S0,_0,x0,ap=X(()=>{qo();Fo();Yh();wl();ji();kt=class{constructor(e,n,r,s){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Jh=(t,e)=>{if(Fn(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let n=new it(t.common.issues);return this._error=n,this._error}}};ue=class{get description(){return this._def.description}_getType(e){return Yt(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:Yt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ke,ctx:{common:e.parent.common,data:e.data,parsedType:Yt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(Os(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){let r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Yt(e)},s=this._parseSync({data:e,path:r.path,parent:r});return Jh(r,s)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Yt(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return Fn(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(r=>Fn(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Yt(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(Os(s)?s:Promise.resolve(s));return Jh(r,i)}refine(e,n){let r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{let a=e(s),c=()=>i.addIssue({code:O.custom,...r(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(l=>l?!0:(c(),!1)):a?!0:(c(),!1)})}refinement(e,n){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(e){return new St({schema:this,typeName:re.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return vt.create(this,this._def)}nullable(){return Xt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return vn.create(this)}promise(){return Kn.create(this,this._def)}or(e){return Rr.create([this,e],this._def)}and(e){return Ir.create(this,e,this._def)}transform(e){return new St({...ae(this._def),schema:this,typeName:re.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new Pr({...ae(this._def),innerType:this,defaultValue:n,typeName:re.ZodDefault})}brand(){return new zi({typeName:re.ZodBranded,type:this,...ae(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new Nr({...ae(this._def),innerType:this,catchValue:n,typeName:re.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Di.create(this,e)}readonly(){return Mr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},wk=/^c[^\s-]{8,}$/i,vk=/^[0-9a-z]+$/,kk=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Sk=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,_k=/^[a-z0-9_-]{21}$/i,xk=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Tk=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Rk=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ik="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Ek=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Ak=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,$k=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Ck=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Pk=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Nk=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Qh="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Mk=new RegExp(`^${Qh}$`);Bn=class t extends ue{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==G.string){let i=this._getOrReturnCtx(e);return K(i,{code:O.invalid_type,expected:G.string,received:i.parsedType}),ne}let r=new Ke,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),K(s,{code:O.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),K(s,{code:O.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){let a=e.data.length>i.value,c=e.data.length<i.value;(a||c)&&(s=this._getOrReturnCtx(e,s),a?K(s,{code:O.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):c&&K(s,{code:O.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")Rk.test(e.data)||(s=this._getOrReturnCtx(e,s),K(s,{validation:"email",code:O.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")vl||(vl=new RegExp(Ik,"u")),vl.test(e.data)||(s=this._getOrReturnCtx(e,s),K(s,{validation:"emoji",code:O.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")Sk.test(e.data)||(s=this._getOrReturnCtx(e,s),K(s,{validation:"uuid",code:O.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")_k.test(e.data)||(s=this._getOrReturnCtx(e,s),K(s,{validation:"nanoid",code:O.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")wk.test(e.data)||(s=this._getOrReturnCtx(e,s),K(s,{validation:"cuid",code:O.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")vk.test(e.data)||(s=this._getOrReturnCtx(e,s),K(s,{validation:"cuid2",code:O.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")kk.test(e.data)||(s=this._getOrReturnCtx(e,s),K(s,{validation:"ulid",code:O.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),K(s,{validation:"url",code:O.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),K(s,{validation:"regex",code:O.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),K(s,{code:O.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),K(s,{code:O.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),K(s,{code:O.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?tp(i).test(e.data)||(s=this._getOrReturnCtx(e,s),K(s,{code:O.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?Mk.test(e.data)||(s=this._getOrReturnCtx(e,s),K(s,{code:O.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?jk(i).test(e.data)||(s=this._getOrReturnCtx(e,s),K(s,{code:O.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?Tk.test(e.data)||(s=this._getOrReturnCtx(e,s),K(s,{validation:"duration",code:O.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?Ok(e.data,i.version)||(s=this._getOrReturnCtx(e,s),K(s,{validation:"ip",code:O.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?zk(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),K(s,{validation:"jwt",code:O.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?Dk(e.data,i.version)||(s=this._getOrReturnCtx(e,s),K(s,{validation:"cidr",code:O.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?Pk.test(e.data)||(s=this._getOrReturnCtx(e,s),K(s,{validation:"base64",code:O.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?Nk.test(e.data)||(s=this._getOrReturnCtx(e,s),K(s,{validation:"base64url",code:O.invalid_string,message:i.message}),r.dirty()):de.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(s=>e.test(s),{validation:n,code:O.invalid_string,...Q.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Q.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Q.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Q.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Q.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Q.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Q.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Q.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Q.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Q.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Q.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Q.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Q.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Q.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...Q.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...Q.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...Q.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...Q.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...Q.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...Q.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...Q.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...Q.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...Q.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...Q.errToObj(n)})}nonempty(e){return this.min(1,Q.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};Bn.create=t=>new Bn({checks:[],typeName:re.ZodString,coerce:t?.coerce??!1,...ae(t)});vr=class t extends ue{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==G.number){let i=this._getOrReturnCtx(e);return K(i,{code:O.invalid_type,expected:G.number,received:i.parsedType}),ne}let r,s=new Ke;for(let i of this._def.checks)i.kind==="int"?de.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),K(r,{code:O.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),K(r,{code:O.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),K(r,{code:O.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Lk(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),K(r,{code:O.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),K(r,{code:O.not_finite,message:i.message}),s.dirty()):de.assertNever(i);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,Q.toString(n))}gt(e,n){return this.setLimit("min",e,!1,Q.toString(n))}lte(e,n){return this.setLimit("max",e,!0,Q.toString(n))}lt(e,n){return this.setLimit("max",e,!1,Q.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:Q.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Q.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Q.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Q.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Q.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Q.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:Q.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:Q.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Q.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Q.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&de.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}};vr.create=t=>new vr({checks:[],typeName:re.ZodNumber,coerce:t?.coerce||!1,...ae(t)});kr=class t extends ue{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==G.bigint)return this._getInvalidInput(e);let r,s=new Ke;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),K(r,{code:O.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),K(r,{code:O.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),K(r,{code:O.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):de.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return K(n,{code:O.invalid_type,expected:G.bigint,received:n.parsedType}),ne}gte(e,n){return this.setLimit("min",e,!0,Q.toString(n))}gt(e,n){return this.setLimit("min",e,!1,Q.toString(n))}lte(e,n){return this.setLimit("max",e,!0,Q.toString(n))}lt(e,n){return this.setLimit("max",e,!1,Q.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:Q.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Q.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Q.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Q.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Q.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:Q.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};kr.create=t=>new kr({checks:[],typeName:re.ZodBigInt,coerce:t?.coerce??!1,...ae(t)});Sr=class extends ue{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==G.boolean){let r=this._getOrReturnCtx(e);return K(r,{code:O.invalid_type,expected:G.boolean,received:r.parsedType}),ne}return Ve(e.data)}};Sr.create=t=>new Sr({typeName:re.ZodBoolean,coerce:t?.coerce||!1,...ae(t)});_r=class t extends ue{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==G.date){let i=this._getOrReturnCtx(e);return K(i,{code:O.invalid_type,expected:G.date,received:i.parsedType}),ne}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return K(i,{code:O.invalid_date}),ne}let r=new Ke,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),K(s,{code:O.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),K(s,{code:O.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):de.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:Q.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:Q.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}};_r.create=t=>new _r({checks:[],coerce:t?.coerce||!1,typeName:re.ZodDate,...ae(t)});Ds=class extends ue{_parse(e){if(this._getType(e)!==G.symbol){let r=this._getOrReturnCtx(e);return K(r,{code:O.invalid_type,expected:G.symbol,received:r.parsedType}),ne}return Ve(e.data)}};Ds.create=t=>new Ds({typeName:re.ZodSymbol,...ae(t)});xr=class extends ue{_parse(e){if(this._getType(e)!==G.undefined){let r=this._getOrReturnCtx(e);return K(r,{code:O.invalid_type,expected:G.undefined,received:r.parsedType}),ne}return Ve(e.data)}};xr.create=t=>new xr({typeName:re.ZodUndefined,...ae(t)});Tr=class extends ue{_parse(e){if(this._getType(e)!==G.null){let r=this._getOrReturnCtx(e);return K(r,{code:O.invalid_type,expected:G.null,received:r.parsedType}),ne}return Ve(e.data)}};Tr.create=t=>new Tr({typeName:re.ZodNull,...ae(t)});Hn=class extends ue{constructor(){super(...arguments),this._any=!0}_parse(e){return Ve(e.data)}};Hn.create=t=>new Hn({typeName:re.ZodAny,...ae(t)});wn=class extends ue{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ve(e.data)}};wn.create=t=>new wn({typeName:re.ZodUnknown,...ae(t)});Ut=class extends ue{_parse(e){let n=this._getOrReturnCtx(e);return K(n,{code:O.invalid_type,expected:G.never,received:n.parsedType}),ne}};Ut.create=t=>new Ut({typeName:re.ZodNever,...ae(t)});Ls=class extends ue{_parse(e){if(this._getType(e)!==G.undefined){let r=this._getOrReturnCtx(e);return K(r,{code:O.invalid_type,expected:G.void,received:r.parsedType}),ne}return Ve(e.data)}};Ls.create=t=>new Ls({typeName:re.ZodVoid,...ae(t)});vn=class t extends ue{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==G.array)return K(n,{code:O.invalid_type,expected:G.array,received:n.parsedType}),ne;if(s.exactLength!==null){let a=n.data.length>s.exactLength.value,c=n.data.length<s.exactLength.value;(a||c)&&(K(n,{code:a?O.too_big:O.too_small,minimum:c?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&(K(n,{code:O.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(K(n,{code:O.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((a,c)=>s.type._parseAsync(new kt(n,a,n.path,c)))).then(a=>Ke.mergeArray(r,a));let i=[...n.data].map((a,c)=>s.type._parseSync(new kt(n,a,n.path,c)));return Ke.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:Q.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:Q.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:Q.toString(n)}})}nonempty(e){return this.min(1,e)}};vn.create=(t,e)=>new vn({type:t,minLength:null,maxLength:null,exactLength:null,typeName:re.ZodArray,...ae(e)});ot=class t extends ue{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),n=de.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==G.object){let u=this._getOrReturnCtx(e);return K(u,{code:O.invalid_type,expected:G.object,received:u.parsedType}),ne}let{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),c=[];if(!(this._def.catchall instanceof Ut&&this._def.unknownKeys==="strip"))for(let u in s.data)a.includes(u)||c.push(u);let l=[];for(let u of a){let p=i[u],f=s.data[u];l.push({key:{status:"valid",value:u},value:p._parse(new kt(s,f,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof Ut){let u=this._def.unknownKeys;if(u==="passthrough")for(let p of c)l.push({key:{status:"valid",value:p},value:{status:"valid",value:s.data[p]}});else if(u==="strict")c.length>0&&(K(s,{code:O.unrecognized_keys,keys:c}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let p of c){let f=s.data[p];l.push({key:{status:"valid",value:p},value:u._parse(new kt(s,f,s.path,p)),alwaysSet:p in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let u=[];for(let p of l){let f=await p.key,g=await p.value;u.push({key:f,value:g,alwaysSet:p.alwaysSet})}return u}).then(u=>Ke.mergeObjectSync(r,u)):Ke.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return Q.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{let s=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:Q.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:re.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let n={};for(let r of de.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}omit(e){let n={};for(let r of de.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return zs(this)}partial(e){let n={};for(let r of de.objectKeys(this.shape)){let s=this.shape[r];e&&!e[r]?n[r]=s:n[r]=s.optional()}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of de.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof vt;)i=i._def.innerType;n[r]=i}return new t({...this._def,shape:()=>n})}keyof(){return np(de.objectKeys(this.shape))}};ot.create=(t,e)=>new ot({shape:()=>t,unknownKeys:"strip",catchall:Ut.create(),typeName:re.ZodObject,...ae(e)});ot.strictCreate=(t,e)=>new ot({shape:()=>t,unknownKeys:"strict",catchall:Ut.create(),typeName:re.ZodObject,...ae(e)});ot.lazycreate=(t,e)=>new ot({shape:t,unknownKeys:"strip",catchall:Ut.create(),typeName:re.ZodObject,...ae(e)});Rr=class extends ue{_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function s(i){for(let c of i)if(c.result.status==="valid")return c.result;for(let c of i)if(c.result.status==="dirty")return n.common.issues.push(...c.ctx.common.issues),c.result;let a=i.map(c=>new it(c.ctx.common.issues));return K(n,{code:O.invalid_union,unionErrors:a}),ne}if(n.common.async)return Promise.all(r.map(async i=>{let a={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:a}),ctx:a}})).then(s);{let i,a=[];for(let l of r){let u={...n,common:{...n.common,issues:[]},parent:null},p=l._parseSync({data:n.data,path:n.path,parent:u});if(p.status==="valid")return p;p.status==="dirty"&&!i&&(i={result:p,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;let c=a.map(l=>new it(l));return K(n,{code:O.invalid_union,unionErrors:c}),ne}}get options(){return this._def.options}};Rr.create=(t,e)=>new Rr({options:t,typeName:re.ZodUnion,...ae(e)});bn=t=>t instanceof Er?bn(t.schema):t instanceof St?bn(t.innerType()):t instanceof Ar?[t.value]:t instanceof $r?t.options:t instanceof Cr?de.objectValues(t.enum):t instanceof Pr?bn(t._def.innerType):t instanceof xr?[void 0]:t instanceof Tr?[null]:t instanceof vt?[void 0,...bn(t.unwrap())]:t instanceof Xt?[null,...bn(t.unwrap())]:t instanceof zi||t instanceof Mr?bn(t.unwrap()):t instanceof Nr?bn(t._def.innerType):[],Ko=class t extends ue{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==G.object)return K(n,{code:O.invalid_type,expected:G.object,received:n.parsedType}),ne;let r=this.discriminator,s=n.data[r],i=this.optionsMap.get(s);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(K(n,{code:O.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),ne)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let s=new Map;for(let i of n){let a=bn(i.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let c of a){if(s.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);s.set(c,i)}}return new t({typeName:re.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:s,...ae(r)})}};Ir=class extends ue{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=(i,a)=>{if(Bo(i)||Bo(a))return ne;let c=kl(i.value,a.value);return c.valid?((Ho(i)||Ho(a))&&n.dirty(),{status:n.value,value:c.data}):(K(r,{code:O.invalid_intersection_types}),ne)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};Ir.create=(t,e,n)=>new Ir({left:t,right:e,typeName:re.ZodIntersection,...ae(n)});Jt=class t extends ue{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==G.array)return K(r,{code:O.invalid_type,expected:G.array,received:r.parsedType}),ne;if(r.data.length<this._def.items.length)return K(r,{code:O.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ne;!this._def.rest&&r.data.length>this._def.items.length&&(K(r,{code:O.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let i=[...r.data].map((a,c)=>{let l=this._def.items[c]||this._def.rest;return l?l._parse(new kt(r,a,r.path,c)):null}).filter(a=>!!a);return r.common.async?Promise.all(i).then(a=>Ke.mergeArray(n,a)):Ke.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};Jt.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Jt({items:t,typeName:re.ZodTuple,rest:null,...ae(e)})};Wo=class t extends ue{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==G.object)return K(r,{code:O.invalid_type,expected:G.object,received:r.parsedType}),ne;let s=[],i=this._def.keyType,a=this._def.valueType;for(let c in r.data)s.push({key:i._parse(new kt(r,c,r.path,c)),value:a._parse(new kt(r,r.data[c],r.path,c)),alwaysSet:c in r.data});return r.common.async?Ke.mergeObjectAsync(n,s):Ke.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof ue?new t({keyType:e,valueType:n,typeName:re.ZodRecord,...ae(r)}):new t({keyType:Bn.create(),valueType:e,typeName:re.ZodRecord,...ae(n)})}},Us=class extends ue{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==G.map)return K(r,{code:O.invalid_type,expected:G.map,received:r.parsedType}),ne;let s=this._def.keyType,i=this._def.valueType,a=[...r.data.entries()].map(([c,l],u)=>({key:s._parse(new kt(r,c,r.path,[u,"key"])),value:i._parse(new kt(r,l,r.path,[u,"value"]))}));if(r.common.async){let c=new Map;return Promise.resolve().then(async()=>{for(let l of a){let u=await l.key,p=await l.value;if(u.status==="aborted"||p.status==="aborted")return ne;(u.status==="dirty"||p.status==="dirty")&&n.dirty(),c.set(u.value,p.value)}return{status:n.value,value:c}})}else{let c=new Map;for(let l of a){let u=l.key,p=l.value;if(u.status==="aborted"||p.status==="aborted")return ne;(u.status==="dirty"||p.status==="dirty")&&n.dirty(),c.set(u.value,p.value)}return{status:n.value,value:c}}}};Us.create=(t,e,n)=>new Us({valueType:e,keyType:t,typeName:re.ZodMap,...ae(n)});qs=class t extends ue{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==G.set)return K(r,{code:O.invalid_type,expected:G.set,received:r.parsedType}),ne;let s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(K(r,{code:O.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(K(r,{code:O.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());let i=this._def.valueType;function a(l){let u=new Set;for(let p of l){if(p.status==="aborted")return ne;p.status==="dirty"&&n.dirty(),u.add(p.value)}return{status:n.value,value:u}}let c=[...r.data.values()].map((l,u)=>i._parse(new kt(r,l,r.path,u)));return r.common.async?Promise.all(c).then(l=>a(l)):a(c)}min(e,n){return new t({...this._def,minSize:{value:e,message:Q.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:Q.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};qs.create=(t,e)=>new qs({valueType:t,minSize:null,maxSize:null,typeName:re.ZodSet,...ae(e)});Go=class t extends ue{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==G.function)return K(n,{code:O.invalid_type,expected:G.function,received:n.parsedType}),ne;function r(c,l){return Oi({data:c,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,js(),yn].filter(u=>!!u),issueData:{code:O.invalid_arguments,argumentsError:l}})}function s(c,l){return Oi({data:c,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,js(),yn].filter(u=>!!u),issueData:{code:O.invalid_return_type,returnTypeError:l}})}let i={errorMap:n.common.contextualErrorMap},a=n.data;if(this._def.returns instanceof Kn){let c=this;return Ve(async function(...l){let u=new it([]),p=await c._def.args.parseAsync(l,i).catch(v=>{throw u.addIssue(r(l,v)),u}),f=await Reflect.apply(a,this,p);return await c._def.returns._def.type.parseAsync(f,i).catch(v=>{throw u.addIssue(s(f,v)),u})})}else{let c=this;return Ve(function(...l){let u=c._def.args.safeParse(l,i);if(!u.success)throw new it([r(l,u.error)]);let p=Reflect.apply(a,this,u.data),f=c._def.returns.safeParse(p,i);if(!f.success)throw new it([s(p,f.error)]);return f.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Jt.create(e).rest(wn.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new t({args:e||Jt.create([]).rest(wn.create()),returns:n||wn.create(),typeName:re.ZodFunction,...ae(r)})}},Er=class extends ue{get schema(){return this._def.getter()}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};Er.create=(t,e)=>new Er({getter:t,typeName:re.ZodLazy,...ae(e)});Ar=class extends ue{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return K(n,{received:n.data,code:O.invalid_literal,expected:this._def.value}),ne}return{status:"valid",value:e.data}}get value(){return this._def.value}};Ar.create=(t,e)=>new Ar({value:t,typeName:re.ZodLiteral,...ae(e)});$r=class t extends ue{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return K(n,{expected:de.joinValues(r),received:n.parsedType,code:O.invalid_type}),ne}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),r=this._def.values;return K(n,{received:n.data,code:O.invalid_enum_value,options:r}),ne}return Ve(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}};$r.create=np;Cr=class extends ue{_parse(e){let n=de.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==G.string&&r.parsedType!==G.number){let s=de.objectValues(n);return K(r,{expected:de.joinValues(s),received:r.parsedType,code:O.invalid_type}),ne}if(this._cache||(this._cache=new Set(de.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=de.objectValues(n);return K(r,{received:r.data,code:O.invalid_enum_value,options:s}),ne}return Ve(e.data)}get enum(){return this._def.values}};Cr.create=(t,e)=>new Cr({values:t,typeName:re.ZodNativeEnum,...ae(e)});Kn=class extends ue{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==G.promise&&n.common.async===!1)return K(n,{code:O.invalid_type,expected:G.promise,received:n.parsedType}),ne;let r=n.parsedType===G.promise?n.data:Promise.resolve(n.data);return Ve(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}};Kn.create=(t,e)=>new Kn({type:t,typeName:re.ZodPromise,...ae(e)});St=class extends ue{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===re.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a=>{K(r,a),a.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let a=s.transform(r.data,i);if(r.common.async)return Promise.resolve(a).then(async c=>{if(n.value==="aborted")return ne;let l=await this._def.schema._parseAsync({data:c,path:r.path,parent:r});return l.status==="aborted"?ne:l.status==="dirty"?wr(l.value):n.value==="dirty"?wr(l.value):l});{if(n.value==="aborted")return ne;let c=this._def.schema._parseSync({data:a,path:r.path,parent:r});return c.status==="aborted"?ne:c.status==="dirty"?wr(c.value):n.value==="dirty"?wr(c.value):c}}if(s.type==="refinement"){let a=c=>{let l=s.refinement(c,i);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(r.common.async===!1){let c=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return c.status==="aborted"?ne:(c.status==="dirty"&&n.dirty(),a(c.value),{status:n.value,value:c.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(c=>c.status==="aborted"?ne:(c.status==="dirty"&&n.dirty(),a(c.value).then(()=>({status:n.value,value:c.value}))))}if(s.type==="transform")if(r.common.async===!1){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Fn(a))return ne;let c=s.transform(a.value,i);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:c}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>Fn(a)?Promise.resolve(s.transform(a.value,i)).then(c=>({status:n.value,value:c})):ne);de.assertNever(s)}};St.create=(t,e,n)=>new St({schema:t,typeName:re.ZodEffects,effect:e,...ae(n)});St.createWithPreprocess=(t,e,n)=>new St({schema:e,effect:{type:"preprocess",transform:t},typeName:re.ZodEffects,...ae(n)});vt=class extends ue{_parse(e){return this._getType(e)===G.undefined?Ve(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};vt.create=(t,e)=>new vt({innerType:t,typeName:re.ZodOptional,...ae(e)});Xt=class extends ue{_parse(e){return this._getType(e)===G.null?Ve(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Xt.create=(t,e)=>new Xt({innerType:t,typeName:re.ZodNullable,...ae(e)});Pr=class extends ue{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===G.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};Pr.create=(t,e)=>new Pr({innerType:t,typeName:re.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ae(e)});Nr=class extends ue{_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Os(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new it(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new it(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};Nr.create=(t,e)=>new Nr({innerType:t,typeName:re.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ae(e)});Fs=class extends ue{_parse(e){if(this._getType(e)!==G.nan){let r=this._getOrReturnCtx(e);return K(r,{code:O.invalid_type,expected:G.nan,received:r.parsedType}),ne}return{status:"valid",value:e.data}}};Fs.create=t=>new Fs({typeName:re.ZodNaN,...ae(t)});Uk=Symbol("zod_brand"),zi=class extends ue{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},Di=class t extends ue{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?ne:i.status==="dirty"?(n.dirty(),wr(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{let s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?ne:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:re.ZodPipeline})}},Mr=class extends ue{_parse(e){let n=this._def.innerType._parse(e),r=s=>(Fn(s)&&(s.value=Object.freeze(s.value)),s);return Os(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}};Mr.create=(t,e)=>new Mr({innerType:t,typeName:re.ZodReadonly,...ae(e)});qk={object:ot.lazycreate};(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(re||(re={}));Fk=(t,e={message:`Input not instance of ${t.name}`})=>rp(n=>n instanceof t,e),sp=Bn.create,ip=vr.create,Bk=Fs.create,Hk=kr.create,op=Sr.create,Kk=_r.create,Wk=Ds.create,Gk=xr.create,Zk=Tr.create,Vk=Hn.create,Yk=wn.create,Jk=Ut.create,Xk=Ls.create,Qk=vn.create,e0=ot.create,t0=ot.strictCreate,n0=Rr.create,r0=Ko.create,s0=Ir.create,i0=Jt.create,o0=Wo.create,a0=Us.create,c0=qs.create,l0=Go.create,u0=Er.create,d0=Ar.create,h0=$r.create,p0=Cr.create,f0=Kn.create,m0=St.create,g0=vt.create,y0=Xt.create,b0=St.createWithPreprocess,w0=Di.create,v0=()=>sp().optional(),k0=()=>ip().optional(),S0=()=>op().optional(),_0={string:(t=>Bn.create({...t,coerce:!0})),number:(t=>vr.create({...t,coerce:!0})),boolean:(t=>Sr.create({...t,coerce:!0})),bigint:(t=>kr.create({...t,coerce:!0})),date:(t=>_r.create({...t,coerce:!0}))},x0=ne});var S={};De(S,{BRAND:()=>Uk,DIRTY:()=>wr,EMPTY_PATH:()=>bk,INVALID:()=>ne,NEVER:()=>x0,OK:()=>Ve,ParseStatus:()=>Ke,Schema:()=>ue,ZodAny:()=>Hn,ZodArray:()=>vn,ZodBigInt:()=>kr,ZodBoolean:()=>Sr,ZodBranded:()=>zi,ZodCatch:()=>Nr,ZodDate:()=>_r,ZodDefault:()=>Pr,ZodDiscriminatedUnion:()=>Ko,ZodEffects:()=>St,ZodEnum:()=>$r,ZodError:()=>it,ZodFirstPartyTypeKind:()=>re,ZodFunction:()=>Go,ZodIntersection:()=>Ir,ZodIssueCode:()=>O,ZodLazy:()=>Er,ZodLiteral:()=>Ar,ZodMap:()=>Us,ZodNaN:()=>Fs,ZodNativeEnum:()=>Cr,ZodNever:()=>Ut,ZodNull:()=>Tr,ZodNullable:()=>Xt,ZodNumber:()=>vr,ZodObject:()=>ot,ZodOptional:()=>vt,ZodParsedType:()=>G,ZodPipeline:()=>Di,ZodPromise:()=>Kn,ZodReadonly:()=>Mr,ZodRecord:()=>Wo,ZodSchema:()=>ue,ZodSet:()=>qs,ZodString:()=>Bn,ZodSymbol:()=>Ds,ZodTransformer:()=>St,ZodTuple:()=>Jt,ZodType:()=>ue,ZodUndefined:()=>xr,ZodUnion:()=>Rr,ZodUnknown:()=>wn,ZodVoid:()=>Ls,addIssueToContext:()=>K,any:()=>Vk,array:()=>Qk,bigint:()=>Hk,boolean:()=>op,coerce:()=>_0,custom:()=>rp,date:()=>Kk,datetimeRegex:()=>tp,defaultErrorMap:()=>yn,discriminatedUnion:()=>r0,effect:()=>m0,enum:()=>h0,function:()=>l0,getErrorMap:()=>js,getParsedType:()=>Yt,instanceof:()=>Fk,intersection:()=>s0,isAborted:()=>Bo,isAsync:()=>Os,isDirty:()=>Ho,isValid:()=>Fn,late:()=>qk,lazy:()=>u0,literal:()=>d0,makeIssue:()=>Oi,map:()=>a0,nan:()=>Bk,nativeEnum:()=>p0,never:()=>Jk,null:()=>Zk,nullable:()=>y0,number:()=>ip,object:()=>e0,objectUtil:()=>yl,oboolean:()=>S0,onumber:()=>k0,optional:()=>g0,ostring:()=>v0,pipeline:()=>w0,preprocess:()=>b0,promise:()=>f0,quotelessJson:()=>mk,record:()=>o0,set:()=>c0,setErrorMap:()=>yk,strictObject:()=>t0,string:()=>sp,symbol:()=>Wk,transformer:()=>m0,tuple:()=>i0,undefined:()=>Gk,union:()=>n0,unknown:()=>Yk,util:()=>de,void:()=>Xk});var Sl=X(()=>{Fo();wl();Vh();ji();ap();qo()});var _t=X(()=>{Sl();Sl()});function te(){let t=process.env.ALLWRIGHT_CONFIG_DIR??process.env.TICKETPILOT_CONFIG_DIR;if(t)return t;let e=Vo.default.join(Zo.default.homedir(),".config","allwright"),n=Vo.default.join(Zo.default.homedir(),".config","ticketpilot");return!kn.default.existsSync(e)&&kn.default.existsSync(n)?n:e}function Sn(){return Vo.default.join(te(),"runner.json")}function _e(){let t=Sn();if(!kn.default.existsSync(t))return null;let e=JSON.parse(kn.default.readFileSync(t,"utf8"));return _l.parse(e)}function xe(t){let e=te();kn.default.mkdirSync(e,{recursive:!0,mode:448});let n=Sn(),r=n+".tmp";kn.default.writeFileSync(r,JSON.stringify(t,null,2)+`
24
- `,{mode:384}),kn.default.renameSync(r,n),kn.default.chmodSync(n,384)}function Yo(t,e){return`${t}:${e}`}function Qt(t,e,n){return t.environments[Yo(e,n)]?.secrets??{}}function Li(t,e){return t.repos[e]?.jira??t.jira}function Ui(t){return!t.jira&&!Object.values(t.repos).some(e=>e.jira)}function he(){let t=_e();if(!t)throw new Error(`No runner config found at ${Sn()}. Run \`allwright init\` first.`);return t}var kn,Zo,Vo,cp,_l,Ae=X(()=>{"use strict";kn=E(require("node:fs"),1),Zo=E(require("node:os"),1),Vo=E(require("node:path"),1);_t();cp=S.object({baseUrl:S.string().url(),email:S.string().email(),apiToken:S.string().min(1)}),_l=S.object({controlPlaneUrl:S.string().url(),runnerId:S.string().optional(),runnerToken:S.string().optional(),runnerName:S.string().default(Zo.default.hostname()),jira:cp.optional(),repos:S.record(S.object({path:S.string(),jira:cp.optional(),github:S.object({token:S.string().min(1),login:S.string().optional()}).optional()})).default({}),github:S.object({token:S.string().min(1),login:S.string().optional()}).optional(),githubUsers:S.record(S.object({token:S.string().min(1),login:S.string().optional()})).default({}),deploy:S.object({enabled:S.boolean().default(!1)}).default({enabled:!1}),environments:S.record(S.object({secrets:S.record(S.string()).default({})})).default({}),claudeProfiles:S.record(S.object({configDir:S.string()})).default({}),claudeBin:S.string().default("claude"),agents:S.record(S.object({bin:S.string()})).default({}),jiraUsers:S.record(S.object({email:S.string().email(),apiToken:S.string().min(1)})).default({}),auditSchedules:S.array(S.object({repoName:S.string(),role:S.enum(["security","testing"]),intervalHours:S.number().int().min(6).max(720)})).default([]),pollIntervalSeconds:S.number().int().min(10).max(600).default(30),operatorEnabled:S.boolean().default(!1)})});var qi=me(Te=>{"use strict";Object.defineProperty(Te,"__esModule",{value:!0});Te.getParsedType=Te.ZodParsedType=Te.objectUtil=Te.util=void 0;var xl;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function n(s){throw new Error}t.assertNever=n,t.arrayToEnum=s=>{let i={};for(let a of s)i[a]=a;return i},t.getValidEnumValues=s=>{let i=t.objectKeys(s).filter(c=>typeof s[s[c]]!="number"),a={};for(let c of i)a[c]=s[c];return t.objectValues(a)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},t.find=(s,i)=>{for(let a of s)if(i(a))return a},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}t.joinValues=r,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(xl||(Te.util=xl={}));var dp;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(dp||(Te.objectUtil=dp={}));Te.ZodParsedType=xl.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);var I0=t=>{switch(typeof t){case"undefined":return Te.ZodParsedType.undefined;case"string":return Te.ZodParsedType.string;case"number":return Number.isNaN(t)?Te.ZodParsedType.nan:Te.ZodParsedType.number;case"boolean":return Te.ZodParsedType.boolean;case"function":return Te.ZodParsedType.function;case"bigint":return Te.ZodParsedType.bigint;case"symbol":return Te.ZodParsedType.symbol;case"object":return Array.isArray(t)?Te.ZodParsedType.array:t===null?Te.ZodParsedType.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?Te.ZodParsedType.promise:typeof Map<"u"&&t instanceof Map?Te.ZodParsedType.map:typeof Set<"u"&&t instanceof Set?Te.ZodParsedType.set:typeof Date<"u"&&t instanceof Date?Te.ZodParsedType.date:Te.ZodParsedType.object;default:return Te.ZodParsedType.unknown}};Te.getParsedType=I0});var Qo=me(Wn=>{"use strict";Object.defineProperty(Wn,"__esModule",{value:!0});Wn.ZodError=Wn.quotelessJson=Wn.ZodIssueCode=void 0;var hp=qi();Wn.ZodIssueCode=hp.util.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);var E0=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");Wn.quotelessJson=E0;var Fi=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){let n=e||function(i){return i.message},r={_errors:[]},s=i=>{for(let a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else{let c=r,l=0;for(;l<a.path.length;){let u=a.path[l];l===a.path.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(n(a))):c[u]=c[u]||{_errors:[]},c=c[u],l++}}};return s(this),r}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,hp.util.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let s of this.issues)if(s.path.length>0){let i=s.path[0];n[i]=n[i]||[],n[i].push(e(s))}else r.push(e(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};Wn.ZodError=Fi;Fi.create=t=>new Fi(t)});var Rl=me(Tl=>{"use strict";Object.defineProperty(Tl,"__esModule",{value:!0});var Ye=Qo(),jr=qi(),A0=(t,e)=>{let n;switch(t.code){case Ye.ZodIssueCode.invalid_type:t.received===jr.ZodParsedType.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case Ye.ZodIssueCode.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,jr.util.jsonStringifyReplacer)}`;break;case Ye.ZodIssueCode.unrecognized_keys:n=`Unrecognized key(s) in object: ${jr.util.joinValues(t.keys,", ")}`;break;case Ye.ZodIssueCode.invalid_union:n="Invalid input";break;case Ye.ZodIssueCode.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${jr.util.joinValues(t.options)}`;break;case Ye.ZodIssueCode.invalid_enum_value:n=`Invalid enum value. Expected ${jr.util.joinValues(t.options)}, received '${t.received}'`;break;case Ye.ZodIssueCode.invalid_arguments:n="Invalid function arguments";break;case Ye.ZodIssueCode.invalid_return_type:n="Invalid function return type";break;case Ye.ZodIssueCode.invalid_date:n="Invalid date";break;case Ye.ZodIssueCode.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:jr.util.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case Ye.ZodIssueCode.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case Ye.ZodIssueCode.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case Ye.ZodIssueCode.custom:n="Invalid input";break;case Ye.ZodIssueCode.invalid_intersection_types:n="Intersection results could not be merged";break;case Ye.ZodIssueCode.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case Ye.ZodIssueCode.not_finite:n="Number must be finite";break;default:n=e.defaultError,jr.util.assertNever(t)}return{message:n}};Tl.default=A0});var ea=me(Gn=>{"use strict";var $0=Gn&&Gn.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Gn,"__esModule",{value:!0});Gn.defaultErrorMap=void 0;Gn.setErrorMap=C0;Gn.getErrorMap=P0;var pp=$0(Rl());Gn.defaultErrorMap=pp.default;var fp=pp.default;function C0(t){fp=t}function P0(){return fp}});var El=me(ye=>{"use strict";var N0=ye&&ye.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(ye,"__esModule",{value:!0});ye.isAsync=ye.isValid=ye.isDirty=ye.isAborted=ye.OK=ye.DIRTY=ye.INVALID=ye.ParseStatus=ye.EMPTY_PATH=ye.makeIssue=void 0;ye.addIssueToContext=O0;var M0=ea(),mp=N0(Rl()),j0=t=>{let{data:e,path:n,errorMaps:r,issueData:s}=t,i=[...n,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let c="",l=r.filter(u=>!!u).slice().reverse();for(let u of l)c=u(a,{data:e,defaultError:c}).message;return{...s,path:i,message:c}};ye.makeIssue=j0;ye.EMPTY_PATH=[];function O0(t,e){let n=(0,M0.getErrorMap)(),r=(0,ye.makeIssue)({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===mp.default?void 0:mp.default].filter(s=>!!s)});t.common.issues.push(r)}var Il=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){let r=[];for(let s of n){if(s.status==="aborted")return ye.INVALID;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let s of n){let i=await s.key,a=await s.value;r.push({key:i,value:a})}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let s of n){let{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return ye.INVALID;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(r[i.value]=a.value)}return{status:e.value,value:r}}};ye.ParseStatus=Il;ye.INVALID=Object.freeze({status:"aborted"});var z0=t=>({status:"dirty",value:t});ye.DIRTY=z0;var D0=t=>({status:"valid",value:t});ye.OK=D0;var L0=t=>t.status==="aborted";ye.isAborted=L0;var U0=t=>t.status==="dirty";ye.isDirty=U0;var q0=t=>t.status==="valid";ye.isValid=q0;var F0=t=>typeof Promise<"u"&&t instanceof Promise;ye.isAsync=F0});var yp=me(gp=>{"use strict";Object.defineProperty(gp,"__esModule",{value:!0})});var wp=me(ta=>{"use strict";Object.defineProperty(ta,"__esModule",{value:!0});ta.errorUtil=void 0;var bp;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(bp||(ta.errorUtil=bp={}))});var Cp=me(R=>{"use strict";Object.defineProperty(R,"__esModule",{value:!0});R.discriminatedUnion=R.date=R.boolean=R.bigint=R.array=R.any=R.coerce=R.ZodFirstPartyTypeKind=R.late=R.ZodSchema=R.Schema=R.ZodReadonly=R.ZodPipeline=R.ZodBranded=R.BRAND=R.ZodNaN=R.ZodCatch=R.ZodDefault=R.ZodNullable=R.ZodOptional=R.ZodTransformer=R.ZodEffects=R.ZodPromise=R.ZodNativeEnum=R.ZodEnum=R.ZodLiteral=R.ZodLazy=R.ZodFunction=R.ZodSet=R.ZodMap=R.ZodRecord=R.ZodTuple=R.ZodIntersection=R.ZodDiscriminatedUnion=R.ZodUnion=R.ZodObject=R.ZodArray=R.ZodVoid=R.ZodNever=R.ZodUnknown=R.ZodAny=R.ZodNull=R.ZodUndefined=R.ZodSymbol=R.ZodDate=R.ZodBoolean=R.ZodBigInt=R.ZodNumber=R.ZodString=R.ZodType=void 0;R.NEVER=R.void=R.unknown=R.union=R.undefined=R.tuple=R.transformer=R.symbol=R.string=R.strictObject=R.set=R.record=R.promise=R.preprocess=R.pipeline=R.ostring=R.optional=R.onumber=R.oboolean=R.object=R.number=R.nullable=R.null=R.never=R.nativeEnum=R.nan=R.map=R.literal=R.lazy=R.intersection=R.instanceof=R.function=R.enum=R.effect=void 0;R.datetimeRegex=xp;R.custom=Rp;var q=Qo(),na=ea(),ee=wp(),I=El(),B=qi(),Tt=class{constructor(e,n,r,s){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},vp=(t,e)=>{if((0,I.isValid)(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let n=new q.ZodError(t.common.issues);return this._error=n,this._error}}};function ce(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:s}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,c)=>{let{message:l}=t;return a.code==="invalid_enum_value"?{message:l??c.defaultError}:typeof c.data>"u"?{message:l??r??c.defaultError}:a.code!=="invalid_type"?{message:c.defaultError}:{message:l??n??c.defaultError}},description:s}}var le=class{get description(){return this._def.description}_getType(e){return(0,B.getParsedType)(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:(0,B.getParsedType)(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new I.ParseStatus,ctx:{common:e.parent.common,data:e.data,parsedType:(0,B.getParsedType)(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if((0,I.isAsync)(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){let r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0,B.getParsedType)(e)},s=this._parseSync({data:e,path:r.path,parent:r});return vp(r,s)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0,B.getParsedType)(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return(0,I.isValid)(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(r=>(0,I.isValid)(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0,B.getParsedType)(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await((0,I.isAsync)(s)?s:Promise.resolve(s));return vp(r,i)}refine(e,n){let r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{let a=e(s),c=()=>i.addIssue({code:q.ZodIssueCode.custom,...r(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(l=>l?!0:(c(),!1)):a?!0:(c(),!1)})}refinement(e,n){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(e){return new ht({schema:this,typeName:se.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return xt.create(this,this._def)}nullable(){return tn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Tn.create(this)}promise(){return Yn.create(this,this._def)}or(e){return Fr.create([this,e],this._def)}and(e){return Br.create(this,e,this._def)}transform(e){return new ht({...ce(this._def),schema:this,typeName:se.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new Zr({...ce(this._def),innerType:this,defaultValue:n,typeName:se.ZodDefault})}brand(){return new Bi({typeName:se.ZodBranded,type:this,...ce(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new Vr({...ce(this._def),innerType:this,catchValue:n,typeName:se.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Hi.create(this,e)}readonly(){return Yr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};R.ZodType=le;R.Schema=le;R.ZodSchema=le;var B0=/^c[^\s-]{8,}$/i,H0=/^[0-9a-z]+$/,K0=/^[0-9A-HJKMNP-TV-Z]{26}$/i,W0=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,G0=/^[a-z0-9_-]{21}$/i,Z0=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,V0=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Y0=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,J0="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Al,X0=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Q0=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,eS=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,tS=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,nS=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,rS=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Sp="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",sS=new RegExp(`^${Sp}$`);function _p(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function iS(t){return new RegExp(`^${_p(t)}$`)}function xp(t){let e=`${Sp}T${_p(t)}`,n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function oS(t,e){return!!((e==="v4"||!e)&&X0.test(t)||(e==="v6"||!e)&&eS.test(t))}function aS(t,e){if(!Z0.test(t))return!1;try{let[n]=t.split(".");if(!n)return!1;let r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function cS(t,e){return!!((e==="v4"||!e)&&Q0.test(t)||(e==="v6"||!e)&&tS.test(t))}var Zn=class t extends le{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==B.ZodParsedType.string){let i=this._getOrReturnCtx(e);return(0,I.addIssueToContext)(i,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.string,received:i.parsedType}),I.INVALID}let r=new I.ParseStatus,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{code:q.ZodIssueCode.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{code:q.ZodIssueCode.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){let a=e.data.length>i.value,c=e.data.length<i.value;(a||c)&&(s=this._getOrReturnCtx(e,s),a?(0,I.addIssueToContext)(s,{code:q.ZodIssueCode.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):c&&(0,I.addIssueToContext)(s,{code:q.ZodIssueCode.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")Y0.test(e.data)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{validation:"email",code:q.ZodIssueCode.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Al||(Al=new RegExp(J0,"u")),Al.test(e.data)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{validation:"emoji",code:q.ZodIssueCode.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")W0.test(e.data)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{validation:"uuid",code:q.ZodIssueCode.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")G0.test(e.data)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{validation:"nanoid",code:q.ZodIssueCode.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")B0.test(e.data)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{validation:"cuid",code:q.ZodIssueCode.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")H0.test(e.data)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{validation:"cuid2",code:q.ZodIssueCode.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")K0.test(e.data)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{validation:"ulid",code:q.ZodIssueCode.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{validation:"url",code:q.ZodIssueCode.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{validation:"regex",code:q.ZodIssueCode.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{code:q.ZodIssueCode.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{code:q.ZodIssueCode.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{code:q.ZodIssueCode.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?xp(i).test(e.data)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{code:q.ZodIssueCode.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?sS.test(e.data)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{code:q.ZodIssueCode.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?iS(i).test(e.data)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{code:q.ZodIssueCode.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?V0.test(e.data)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{validation:"duration",code:q.ZodIssueCode.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?oS(e.data,i.version)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{validation:"ip",code:q.ZodIssueCode.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?aS(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{validation:"jwt",code:q.ZodIssueCode.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?cS(e.data,i.version)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{validation:"cidr",code:q.ZodIssueCode.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?nS.test(e.data)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{validation:"base64",code:q.ZodIssueCode.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?rS.test(e.data)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{validation:"base64url",code:q.ZodIssueCode.invalid_string,message:i.message}),r.dirty()):B.util.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(s=>e.test(s),{validation:n,code:q.ZodIssueCode.invalid_string,...ee.errorUtil.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...ee.errorUtil.errToObj(e)})}url(e){return this._addCheck({kind:"url",...ee.errorUtil.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...ee.errorUtil.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...ee.errorUtil.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...ee.errorUtil.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...ee.errorUtil.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...ee.errorUtil.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...ee.errorUtil.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...ee.errorUtil.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...ee.errorUtil.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...ee.errorUtil.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...ee.errorUtil.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...ee.errorUtil.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...ee.errorUtil.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...ee.errorUtil.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...ee.errorUtil.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...ee.errorUtil.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...ee.errorUtil.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...ee.errorUtil.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...ee.errorUtil.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...ee.errorUtil.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...ee.errorUtil.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...ee.errorUtil.errToObj(n)})}nonempty(e){return this.min(1,ee.errorUtil.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};R.ZodString=Zn;Zn.create=t=>new Zn({checks:[],typeName:se.ZodString,coerce:t?.coerce??!1,...ce(t)});function lS(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(t.toFixed(s).replace(".","")),a=Number.parseInt(e.toFixed(s).replace(".",""));return i%a/10**s}var Or=class t extends le{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==B.ZodParsedType.number){let i=this._getOrReturnCtx(e);return(0,I.addIssueToContext)(i,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.number,received:i.parsedType}),I.INVALID}let r,s=new I.ParseStatus;for(let i of this._def.checks)i.kind==="int"?B.util.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?lS(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.not_finite,message:i.message}),s.dirty()):B.util.assertNever(i);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,ee.errorUtil.toString(n))}gt(e,n){return this.setLimit("min",e,!1,ee.errorUtil.toString(n))}lte(e,n){return this.setLimit("max",e,!0,ee.errorUtil.toString(n))}lt(e,n){return this.setLimit("max",e,!1,ee.errorUtil.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:ee.errorUtil.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:ee.errorUtil.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ee.errorUtil.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ee.errorUtil.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ee.errorUtil.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ee.errorUtil.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:ee.errorUtil.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:ee.errorUtil.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ee.errorUtil.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ee.errorUtil.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&B.util.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}};R.ZodNumber=Or;Or.create=t=>new Or({checks:[],typeName:se.ZodNumber,coerce:t?.coerce||!1,...ce(t)});var zr=class t extends le{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==B.ZodParsedType.bigint)return this._getInvalidInput(e);let r,s=new I.ParseStatus;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):B.util.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return(0,I.addIssueToContext)(n,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.bigint,received:n.parsedType}),I.INVALID}gte(e,n){return this.setLimit("min",e,!0,ee.errorUtil.toString(n))}gt(e,n){return this.setLimit("min",e,!1,ee.errorUtil.toString(n))}lte(e,n){return this.setLimit("max",e,!0,ee.errorUtil.toString(n))}lt(e,n){return this.setLimit("max",e,!1,ee.errorUtil.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:ee.errorUtil.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ee.errorUtil.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ee.errorUtil.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ee.errorUtil.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ee.errorUtil.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:ee.errorUtil.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};R.ZodBigInt=zr;zr.create=t=>new zr({checks:[],typeName:se.ZodBigInt,coerce:t?.coerce??!1,...ce(t)});var Dr=class extends le{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==B.ZodParsedType.boolean){let r=this._getOrReturnCtx(e);return(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.boolean,received:r.parsedType}),I.INVALID}return(0,I.OK)(e.data)}};R.ZodBoolean=Dr;Dr.create=t=>new Dr({typeName:se.ZodBoolean,coerce:t?.coerce||!1,...ce(t)});var Lr=class t extends le{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==B.ZodParsedType.date){let i=this._getOrReturnCtx(e);return(0,I.addIssueToContext)(i,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.date,received:i.parsedType}),I.INVALID}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return(0,I.addIssueToContext)(i,{code:q.ZodIssueCode.invalid_date}),I.INVALID}let r=new I.ParseStatus,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{code:q.ZodIssueCode.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{code:q.ZodIssueCode.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):B.util.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:ee.errorUtil.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:ee.errorUtil.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}};R.ZodDate=Lr;Lr.create=t=>new Lr({checks:[],coerce:t?.coerce||!1,typeName:se.ZodDate,...ce(t)});var Hs=class extends le{_parse(e){if(this._getType(e)!==B.ZodParsedType.symbol){let r=this._getOrReturnCtx(e);return(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.symbol,received:r.parsedType}),I.INVALID}return(0,I.OK)(e.data)}};R.ZodSymbol=Hs;Hs.create=t=>new Hs({typeName:se.ZodSymbol,...ce(t)});var Ur=class extends le{_parse(e){if(this._getType(e)!==B.ZodParsedType.undefined){let r=this._getOrReturnCtx(e);return(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.undefined,received:r.parsedType}),I.INVALID}return(0,I.OK)(e.data)}};R.ZodUndefined=Ur;Ur.create=t=>new Ur({typeName:se.ZodUndefined,...ce(t)});var qr=class extends le{_parse(e){if(this._getType(e)!==B.ZodParsedType.null){let r=this._getOrReturnCtx(e);return(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.null,received:r.parsedType}),I.INVALID}return(0,I.OK)(e.data)}};R.ZodNull=qr;qr.create=t=>new qr({typeName:se.ZodNull,...ce(t)});var Vn=class extends le{constructor(){super(...arguments),this._any=!0}_parse(e){return(0,I.OK)(e.data)}};R.ZodAny=Vn;Vn.create=t=>new Vn({typeName:se.ZodAny,...ce(t)});var xn=class extends le{constructor(){super(...arguments),this._unknown=!0}_parse(e){return(0,I.OK)(e.data)}};R.ZodUnknown=xn;xn.create=t=>new xn({typeName:se.ZodUnknown,...ce(t)});var qt=class extends le{_parse(e){let n=this._getOrReturnCtx(e);return(0,I.addIssueToContext)(n,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.never,received:n.parsedType}),I.INVALID}};R.ZodNever=qt;qt.create=t=>new qt({typeName:se.ZodNever,...ce(t)});var Ks=class extends le{_parse(e){if(this._getType(e)!==B.ZodParsedType.undefined){let r=this._getOrReturnCtx(e);return(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.void,received:r.parsedType}),I.INVALID}return(0,I.OK)(e.data)}};R.ZodVoid=Ks;Ks.create=t=>new Ks({typeName:se.ZodVoid,...ce(t)});var Tn=class t extends le{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==B.ZodParsedType.array)return(0,I.addIssueToContext)(n,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.array,received:n.parsedType}),I.INVALID;if(s.exactLength!==null){let a=n.data.length>s.exactLength.value,c=n.data.length<s.exactLength.value;(a||c)&&((0,I.addIssueToContext)(n,{code:a?q.ZodIssueCode.too_big:q.ZodIssueCode.too_small,minimum:c?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&((0,I.addIssueToContext)(n,{code:q.ZodIssueCode.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&((0,I.addIssueToContext)(n,{code:q.ZodIssueCode.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((a,c)=>s.type._parseAsync(new Tt(n,a,n.path,c)))).then(a=>I.ParseStatus.mergeArray(r,a));let i=[...n.data].map((a,c)=>s.type._parseSync(new Tt(n,a,n.path,c)));return I.ParseStatus.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:ee.errorUtil.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:ee.errorUtil.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:ee.errorUtil.toString(n)}})}nonempty(e){return this.min(1,e)}};R.ZodArray=Tn;Tn.create=(t,e)=>new Tn({type:t,minLength:null,maxLength:null,exactLength:null,typeName:se.ZodArray,...ce(e)});function Bs(t){if(t instanceof at){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=xt.create(Bs(r))}return new at({...t._def,shape:()=>e})}else return t instanceof Tn?new Tn({...t._def,type:Bs(t.element)}):t instanceof xt?xt.create(Bs(t.unwrap())):t instanceof tn?tn.create(Bs(t.unwrap())):t instanceof en?en.create(t.items.map(e=>Bs(e))):t}var at=class t extends le{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),n=B.util.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==B.ZodParsedType.object){let u=this._getOrReturnCtx(e);return(0,I.addIssueToContext)(u,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.object,received:u.parsedType}),I.INVALID}let{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),c=[];if(!(this._def.catchall instanceof qt&&this._def.unknownKeys==="strip"))for(let u in s.data)a.includes(u)||c.push(u);let l=[];for(let u of a){let p=i[u],f=s.data[u];l.push({key:{status:"valid",value:u},value:p._parse(new Tt(s,f,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof qt){let u=this._def.unknownKeys;if(u==="passthrough")for(let p of c)l.push({key:{status:"valid",value:p},value:{status:"valid",value:s.data[p]}});else if(u==="strict")c.length>0&&((0,I.addIssueToContext)(s,{code:q.ZodIssueCode.unrecognized_keys,keys:c}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let p of c){let f=s.data[p];l.push({key:{status:"valid",value:p},value:u._parse(new Tt(s,f,s.path,p)),alwaysSet:p in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let u=[];for(let p of l){let f=await p.key,g=await p.value;u.push({key:f,value:g,alwaysSet:p.alwaysSet})}return u}).then(u=>I.ParseStatus.mergeObjectSync(r,u)):I.ParseStatus.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return ee.errorUtil.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{let s=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:ee.errorUtil.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:se.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let n={};for(let r of B.util.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}omit(e){let n={};for(let r of B.util.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return Bs(this)}partial(e){let n={};for(let r of B.util.objectKeys(this.shape)){let s=this.shape[r];e&&!e[r]?n[r]=s:n[r]=s.optional()}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of B.util.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof xt;)i=i._def.innerType;n[r]=i}return new t({...this._def,shape:()=>n})}keyof(){return Tp(B.util.objectKeys(this.shape))}};R.ZodObject=at;at.create=(t,e)=>new at({shape:()=>t,unknownKeys:"strip",catchall:qt.create(),typeName:se.ZodObject,...ce(e)});at.strictCreate=(t,e)=>new at({shape:()=>t,unknownKeys:"strict",catchall:qt.create(),typeName:se.ZodObject,...ce(e)});at.lazycreate=(t,e)=>new at({shape:t,unknownKeys:"strip",catchall:qt.create(),typeName:se.ZodObject,...ce(e)});var Fr=class extends le{_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function s(i){for(let c of i)if(c.result.status==="valid")return c.result;for(let c of i)if(c.result.status==="dirty")return n.common.issues.push(...c.ctx.common.issues),c.result;let a=i.map(c=>new q.ZodError(c.ctx.common.issues));return(0,I.addIssueToContext)(n,{code:q.ZodIssueCode.invalid_union,unionErrors:a}),I.INVALID}if(n.common.async)return Promise.all(r.map(async i=>{let a={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:a}),ctx:a}})).then(s);{let i,a=[];for(let l of r){let u={...n,common:{...n.common,issues:[]},parent:null},p=l._parseSync({data:n.data,path:n.path,parent:u});if(p.status==="valid")return p;p.status==="dirty"&&!i&&(i={result:p,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;let c=a.map(l=>new q.ZodError(l));return(0,I.addIssueToContext)(n,{code:q.ZodIssueCode.invalid_union,unionErrors:c}),I.INVALID}}get options(){return this._def.options}};R.ZodUnion=Fr;Fr.create=(t,e)=>new Fr({options:t,typeName:se.ZodUnion,...ce(e)});var _n=t=>t instanceof Hr?_n(t.schema):t instanceof ht?_n(t.innerType()):t instanceof Kr?[t.value]:t instanceof Wr?t.options:t instanceof Gr?B.util.objectValues(t.enum):t instanceof Zr?_n(t._def.innerType):t instanceof Ur?[void 0]:t instanceof qr?[null]:t instanceof xt?[void 0,..._n(t.unwrap())]:t instanceof tn?[null,..._n(t.unwrap())]:t instanceof Bi||t instanceof Yr?_n(t.unwrap()):t instanceof Vr?_n(t._def.innerType):[],ra=class t extends le{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==B.ZodParsedType.object)return(0,I.addIssueToContext)(n,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.object,received:n.parsedType}),I.INVALID;let r=this.discriminator,s=n.data[r],i=this.optionsMap.get(s);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):((0,I.addIssueToContext)(n,{code:q.ZodIssueCode.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),I.INVALID)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let s=new Map;for(let i of n){let a=_n(i.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let c of a){if(s.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);s.set(c,i)}}return new t({typeName:se.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:s,...ce(r)})}};R.ZodDiscriminatedUnion=ra;function $l(t,e){let n=(0,B.getParsedType)(t),r=(0,B.getParsedType)(e);if(t===e)return{valid:!0,data:t};if(n===B.ZodParsedType.object&&r===B.ZodParsedType.object){let s=B.util.objectKeys(e),i=B.util.objectKeys(t).filter(c=>s.indexOf(c)!==-1),a={...t,...e};for(let c of i){let l=$l(t[c],e[c]);if(!l.valid)return{valid:!1};a[c]=l.data}return{valid:!0,data:a}}else if(n===B.ZodParsedType.array&&r===B.ZodParsedType.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let a=t[i],c=e[i],l=$l(a,c);if(!l.valid)return{valid:!1};s.push(l.data)}return{valid:!0,data:s}}else return n===B.ZodParsedType.date&&r===B.ZodParsedType.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var Br=class extends le{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=(i,a)=>{if((0,I.isAborted)(i)||(0,I.isAborted)(a))return I.INVALID;let c=$l(i.value,a.value);return c.valid?(((0,I.isDirty)(i)||(0,I.isDirty)(a))&&n.dirty(),{status:n.value,value:c.data}):((0,I.addIssueToContext)(r,{code:q.ZodIssueCode.invalid_intersection_types}),I.INVALID)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};R.ZodIntersection=Br;Br.create=(t,e,n)=>new Br({left:t,right:e,typeName:se.ZodIntersection,...ce(n)});var en=class t extends le{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==B.ZodParsedType.array)return(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.array,received:r.parsedType}),I.INVALID;if(r.data.length<this._def.items.length)return(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),I.INVALID;!this._def.rest&&r.data.length>this._def.items.length&&((0,I.addIssueToContext)(r,{code:q.ZodIssueCode.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let i=[...r.data].map((a,c)=>{let l=this._def.items[c]||this._def.rest;return l?l._parse(new Tt(r,a,r.path,c)):null}).filter(a=>!!a);return r.common.async?Promise.all(i).then(a=>I.ParseStatus.mergeArray(n,a)):I.ParseStatus.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};R.ZodTuple=en;en.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new en({items:t,typeName:se.ZodTuple,rest:null,...ce(e)})};var sa=class t extends le{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==B.ZodParsedType.object)return(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.object,received:r.parsedType}),I.INVALID;let s=[],i=this._def.keyType,a=this._def.valueType;for(let c in r.data)s.push({key:i._parse(new Tt(r,c,r.path,c)),value:a._parse(new Tt(r,r.data[c],r.path,c)),alwaysSet:c in r.data});return r.common.async?I.ParseStatus.mergeObjectAsync(n,s):I.ParseStatus.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof le?new t({keyType:e,valueType:n,typeName:se.ZodRecord,...ce(r)}):new t({keyType:Zn.create(),valueType:e,typeName:se.ZodRecord,...ce(n)})}};R.ZodRecord=sa;var Ws=class extends le{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==B.ZodParsedType.map)return(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.map,received:r.parsedType}),I.INVALID;let s=this._def.keyType,i=this._def.valueType,a=[...r.data.entries()].map(([c,l],u)=>({key:s._parse(new Tt(r,c,r.path,[u,"key"])),value:i._parse(new Tt(r,l,r.path,[u,"value"]))}));if(r.common.async){let c=new Map;return Promise.resolve().then(async()=>{for(let l of a){let u=await l.key,p=await l.value;if(u.status==="aborted"||p.status==="aborted")return I.INVALID;(u.status==="dirty"||p.status==="dirty")&&n.dirty(),c.set(u.value,p.value)}return{status:n.value,value:c}})}else{let c=new Map;for(let l of a){let u=l.key,p=l.value;if(u.status==="aborted"||p.status==="aborted")return I.INVALID;(u.status==="dirty"||p.status==="dirty")&&n.dirty(),c.set(u.value,p.value)}return{status:n.value,value:c}}}};R.ZodMap=Ws;Ws.create=(t,e,n)=>new Ws({valueType:e,keyType:t,typeName:se.ZodMap,...ce(n)});var Gs=class t extends le{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==B.ZodParsedType.set)return(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.set,received:r.parsedType}),I.INVALID;let s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&((0,I.addIssueToContext)(r,{code:q.ZodIssueCode.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&((0,I.addIssueToContext)(r,{code:q.ZodIssueCode.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());let i=this._def.valueType;function a(l){let u=new Set;for(let p of l){if(p.status==="aborted")return I.INVALID;p.status==="dirty"&&n.dirty(),u.add(p.value)}return{status:n.value,value:u}}let c=[...r.data.values()].map((l,u)=>i._parse(new Tt(r,l,r.path,u)));return r.common.async?Promise.all(c).then(l=>a(l)):a(c)}min(e,n){return new t({...this._def,minSize:{value:e,message:ee.errorUtil.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:ee.errorUtil.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};R.ZodSet=Gs;Gs.create=(t,e)=>new Gs({valueType:t,minSize:null,maxSize:null,typeName:se.ZodSet,...ce(e)});var ia=class t extends le{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==B.ZodParsedType.function)return(0,I.addIssueToContext)(n,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.function,received:n.parsedType}),I.INVALID;function r(c,l){return(0,I.makeIssue)({data:c,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,(0,na.getErrorMap)(),na.defaultErrorMap].filter(u=>!!u),issueData:{code:q.ZodIssueCode.invalid_arguments,argumentsError:l}})}function s(c,l){return(0,I.makeIssue)({data:c,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,(0,na.getErrorMap)(),na.defaultErrorMap].filter(u=>!!u),issueData:{code:q.ZodIssueCode.invalid_return_type,returnTypeError:l}})}let i={errorMap:n.common.contextualErrorMap},a=n.data;if(this._def.returns instanceof Yn){let c=this;return(0,I.OK)(async function(...l){let u=new q.ZodError([]),p=await c._def.args.parseAsync(l,i).catch(v=>{throw u.addIssue(r(l,v)),u}),f=await Reflect.apply(a,this,p);return await c._def.returns._def.type.parseAsync(f,i).catch(v=>{throw u.addIssue(s(f,v)),u})})}else{let c=this;return(0,I.OK)(function(...l){let u=c._def.args.safeParse(l,i);if(!u.success)throw new q.ZodError([r(l,u.error)]);let p=Reflect.apply(a,this,u.data),f=c._def.returns.safeParse(p,i);if(!f.success)throw new q.ZodError([s(p,f.error)]);return f.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:en.create(e).rest(xn.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new t({args:e||en.create([]).rest(xn.create()),returns:n||xn.create(),typeName:se.ZodFunction,...ce(r)})}};R.ZodFunction=ia;var Hr=class extends le{get schema(){return this._def.getter()}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};R.ZodLazy=Hr;Hr.create=(t,e)=>new Hr({getter:t,typeName:se.ZodLazy,...ce(e)});var Kr=class extends le{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return(0,I.addIssueToContext)(n,{received:n.data,code:q.ZodIssueCode.invalid_literal,expected:this._def.value}),I.INVALID}return{status:"valid",value:e.data}}get value(){return this._def.value}};R.ZodLiteral=Kr;Kr.create=(t,e)=>new Kr({value:t,typeName:se.ZodLiteral,...ce(e)});function Tp(t,e){return new Wr({values:t,typeName:se.ZodEnum,...ce(e)})}var Wr=class t extends le{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return(0,I.addIssueToContext)(n,{expected:B.util.joinValues(r),received:n.parsedType,code:q.ZodIssueCode.invalid_type}),I.INVALID}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),r=this._def.values;return(0,I.addIssueToContext)(n,{received:n.data,code:q.ZodIssueCode.invalid_enum_value,options:r}),I.INVALID}return(0,I.OK)(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}};R.ZodEnum=Wr;Wr.create=Tp;var Gr=class extends le{_parse(e){let n=B.util.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==B.ZodParsedType.string&&r.parsedType!==B.ZodParsedType.number){let s=B.util.objectValues(n);return(0,I.addIssueToContext)(r,{expected:B.util.joinValues(s),received:r.parsedType,code:q.ZodIssueCode.invalid_type}),I.INVALID}if(this._cache||(this._cache=new Set(B.util.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=B.util.objectValues(n);return(0,I.addIssueToContext)(r,{received:r.data,code:q.ZodIssueCode.invalid_enum_value,options:s}),I.INVALID}return(0,I.OK)(e.data)}get enum(){return this._def.values}};R.ZodNativeEnum=Gr;Gr.create=(t,e)=>new Gr({values:t,typeName:se.ZodNativeEnum,...ce(e)});var Yn=class extends le{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==B.ZodParsedType.promise&&n.common.async===!1)return(0,I.addIssueToContext)(n,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.promise,received:n.parsedType}),I.INVALID;let r=n.parsedType===B.ZodParsedType.promise?n.data:Promise.resolve(n.data);return(0,I.OK)(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}};R.ZodPromise=Yn;Yn.create=(t,e)=>new Yn({type:t,typeName:se.ZodPromise,...ce(e)});var ht=class extends le{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===se.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a=>{(0,I.addIssueToContext)(r,a),a.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let a=s.transform(r.data,i);if(r.common.async)return Promise.resolve(a).then(async c=>{if(n.value==="aborted")return I.INVALID;let l=await this._def.schema._parseAsync({data:c,path:r.path,parent:r});return l.status==="aborted"?I.INVALID:l.status==="dirty"||n.value==="dirty"?(0,I.DIRTY)(l.value):l});{if(n.value==="aborted")return I.INVALID;let c=this._def.schema._parseSync({data:a,path:r.path,parent:r});return c.status==="aborted"?I.INVALID:c.status==="dirty"||n.value==="dirty"?(0,I.DIRTY)(c.value):c}}if(s.type==="refinement"){let a=c=>{let l=s.refinement(c,i);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(r.common.async===!1){let c=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return c.status==="aborted"?I.INVALID:(c.status==="dirty"&&n.dirty(),a(c.value),{status:n.value,value:c.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(c=>c.status==="aborted"?I.INVALID:(c.status==="dirty"&&n.dirty(),a(c.value).then(()=>({status:n.value,value:c.value}))))}if(s.type==="transform")if(r.common.async===!1){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!(0,I.isValid)(a))return I.INVALID;let c=s.transform(a.value,i);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:c}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>(0,I.isValid)(a)?Promise.resolve(s.transform(a.value,i)).then(c=>({status:n.value,value:c})):I.INVALID);B.util.assertNever(s)}};R.ZodEffects=ht;R.ZodTransformer=ht;ht.create=(t,e,n)=>new ht({schema:t,typeName:se.ZodEffects,effect:e,...ce(n)});ht.createWithPreprocess=(t,e,n)=>new ht({schema:e,effect:{type:"preprocess",transform:t},typeName:se.ZodEffects,...ce(n)});var xt=class extends le{_parse(e){return this._getType(e)===B.ZodParsedType.undefined?(0,I.OK)(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};R.ZodOptional=xt;xt.create=(t,e)=>new xt({innerType:t,typeName:se.ZodOptional,...ce(e)});var tn=class extends le{_parse(e){return this._getType(e)===B.ZodParsedType.null?(0,I.OK)(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};R.ZodNullable=tn;tn.create=(t,e)=>new tn({innerType:t,typeName:se.ZodNullable,...ce(e)});var Zr=class extends le{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===B.ZodParsedType.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};R.ZodDefault=Zr;Zr.create=(t,e)=>new Zr({innerType:t,typeName:se.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ce(e)});var Vr=class extends le{_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return(0,I.isAsync)(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new q.ZodError(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new q.ZodError(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};R.ZodCatch=Vr;Vr.create=(t,e)=>new Vr({innerType:t,typeName:se.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ce(e)});var Zs=class extends le{_parse(e){if(this._getType(e)!==B.ZodParsedType.nan){let r=this._getOrReturnCtx(e);return(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.nan,received:r.parsedType}),I.INVALID}return{status:"valid",value:e.data}}};R.ZodNaN=Zs;Zs.create=t=>new Zs({typeName:se.ZodNaN,...ce(t)});R.BRAND=Symbol("zod_brand");var Bi=class extends le{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}};R.ZodBranded=Bi;var Hi=class t extends le{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?I.INVALID:i.status==="dirty"?(n.dirty(),(0,I.DIRTY)(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{let s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?I.INVALID:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:se.ZodPipeline})}};R.ZodPipeline=Hi;var Yr=class extends le{_parse(e){let n=this._def.innerType._parse(e),r=s=>((0,I.isValid)(s)&&(s.value=Object.freeze(s.value)),s);return(0,I.isAsync)(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}};R.ZodReadonly=Yr;Yr.create=(t,e)=>new Yr({innerType:t,typeName:se.ZodReadonly,...ce(e)});function kp(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function Rp(t,e={},n){return t?Vn.create().superRefine((r,s)=>{let i=t(r);if(i instanceof Promise)return i.then(a=>{if(!a){let c=kp(e,r),l=c.fatal??n??!0;s.addIssue({code:"custom",...c,fatal:l})}});if(!i){let a=kp(e,r),c=a.fatal??n??!0;s.addIssue({code:"custom",...a,fatal:c})}}):Vn.create()}R.late={object:at.lazycreate};var se;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(se||(R.ZodFirstPartyTypeKind=se={}));var uS=(t,e={message:`Input not instance of ${t.name}`})=>Rp(n=>n instanceof t,e);R.instanceof=uS;var Ip=Zn.create;R.string=Ip;var Ep=Or.create;R.number=Ep;var dS=Zs.create;R.nan=dS;var hS=zr.create;R.bigint=hS;var Ap=Dr.create;R.boolean=Ap;var pS=Lr.create;R.date=pS;var fS=Hs.create;R.symbol=fS;var mS=Ur.create;R.undefined=mS;var gS=qr.create;R.null=gS;var yS=Vn.create;R.any=yS;var bS=xn.create;R.unknown=bS;var wS=qt.create;R.never=wS;var vS=Ks.create;R.void=vS;var kS=Tn.create;R.array=kS;var SS=at.create;R.object=SS;var _S=at.strictCreate;R.strictObject=_S;var xS=Fr.create;R.union=xS;var TS=ra.create;R.discriminatedUnion=TS;var RS=Br.create;R.intersection=RS;var IS=en.create;R.tuple=IS;var ES=sa.create;R.record=ES;var AS=Ws.create;R.map=AS;var $S=Gs.create;R.set=$S;var CS=ia.create;R.function=CS;var PS=Hr.create;R.lazy=PS;var NS=Kr.create;R.literal=NS;var MS=Wr.create;R.enum=MS;var jS=Gr.create;R.nativeEnum=jS;var OS=Yn.create;R.promise=OS;var $p=ht.create;R.effect=$p;R.transformer=$p;var zS=xt.create;R.optional=zS;var DS=tn.create;R.nullable=DS;var LS=ht.createWithPreprocess;R.preprocess=LS;var US=Hi.create;R.pipeline=US;var qS=()=>Ip().optional();R.ostring=qS;var FS=()=>Ep().optional();R.onumber=FS;var BS=()=>Ap().optional();R.oboolean=BS;R.coerce={string:(t=>Zn.create({...t,coerce:!0})),number:(t=>Or.create({...t,coerce:!0})),boolean:(t=>Dr.create({...t,coerce:!0})),bigint:(t=>zr.create({...t,coerce:!0})),date:(t=>Lr.create({...t,coerce:!0}))};R.NEVER=I.INVALID});var Cl=me(Rt=>{"use strict";var HS=Rt&&Rt.__createBinding||(Object.create?(function(t,e,n,r){r===void 0&&(r=n);var s=Object.getOwnPropertyDescriptor(e,n);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,s)}):(function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]})),Vs=Rt&&Rt.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&HS(e,t,n)};Object.defineProperty(Rt,"__esModule",{value:!0});Vs(ea(),Rt);Vs(El(),Rt);Vs(yp(),Rt);Vs(qi(),Rt);Vs(Cp(),Rt);Vs(Qo(),Rt)});var Mp=me(ct=>{"use strict";var Pp=ct&&ct.__createBinding||(Object.create?(function(t,e,n,r){r===void 0&&(r=n);var s=Object.getOwnPropertyDescriptor(e,n);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,s)}):(function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]})),KS=ct&&ct.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),WS=ct&&ct.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&Pp(e,t,n);return KS(e,t),e},GS=ct&&ct.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&Pp(e,t,n)};Object.defineProperty(ct,"__esModule",{value:!0});ct.z=void 0;var Np=WS(Cl());ct.z=Np;GS(Cl(),ct);ct.default=Np});var Ne=me(h=>{"use strict";Object.defineProperty(h,"__esModule",{value:!0});h.RunContextMsg=h.FailedTest=h.RunUsageMsg=h.RunLogMsg=h.RunClaimMsg=h.HeartbeatMsg=h.HelloMsg=h.AiSpendMsg=h.AI_SPEND_SURFACES=h.MONITOR_CATALOG=h.MONITOR_BASELINE_TYPES=h.MONITOR_PARAM_SCHEMAS=h.MonitorCheckConfig=h.MonitorParseRules=h.MonitorCommand=h.MonitorSchedule=h.MonitorStatus=h.RuleConfig=h.PACK_CATALOG=h.ProjectConfig=h.ActionConfig=h.DeployAction=h.EnvironmentConfig=h.PromotionMode=h.DeployStep=h.RespondAction=h.ImplementAction=h.PlanOnlyAction=h.TriggerConfig=h.StatusChangedTrigger=h.CommentKeywordTrigger=h.LabelAddedTrigger=h.ActionType=h.TriggerType=h.ACTIVE_RUN_STATUSES=h.RunStatus=h.needsInputMarkerIn=h.LEGACY_NEEDS_INPUT_COMMENT_MARKERS=h.NEEDS_INPUT_COMMENT_MARKER=h.NEEDS_INPUT_LABEL=h.NEEDS_INPUT_ASK_FENCE=h.NEEDS_INPUT_MARKER=h.BRANCH_DEPLOY_ISSUE_KEY=h.REQUIRED_AGENT_CAPABILITIES=h.DEFAULT_AGENT_ID=h.REGISTERED_AGENTS=h.DEPLOY_DOC_CANDIDATES=h.RUNNER_UNINSTALL_COMMAND=h.PROTOCOL_VERSION=h.GITHUB_TOKEN_PERMISSIONS=void 0;h.ChatDiagnosticResultMsg=h.ChatDiagnosticMsg=h.AuditListResultMsg=h.AuditStatsResultMsg=h.AuditStatsMsg=h.AuditListMsg=h.AuditStartResultMsg=h.AuditStartMsg=h.AuditRecord=h.AuditFinding=h.AuditDetailLevel=h.AuditScope=h.AuditSeverity=h.KnowledgeRole=h.AuditRole=h.EpicSuggestResultMsg=h.EpicSuggestMsg=h.EpicListResultMsg=h.EpicChild=h.EpicListMsg=h.BoardTriggerResultMsg=h.BoardTriggerMsg=h.BoardFetchResultMsg=h.BoardFetchMsg=h.RepoDocReadResultMsg=h.RepoDocReadMsg=h.RepoDocsResultMsg=h.RepoDocsMsg=h.ChatLoadResultMsg=h.TICKET_RULES_APPENDIX=h.COMPOSE_COMMANDS=h.MAX_FAILURE_CHARS=h.MAX_FAILURE_LINES=h.FAILURE_BLOCK_LINES=h.FAILURE_CONTEXT_LINES=h.REPLY_STYLES=h.BUILTIN_REPLY_LANGUAGES=h.ChatLoadMsg=h.ChatListResultMsg=h.ChatListMsg=h.ChatSessionMsg=h.ChatActivityMsg=h.ChatUsageMsg=h.ChatStreamMsg=h.JiraUsersResultMsg=h.DeployClaimResultMsg=h.DeployClaimMsg=h.RuleDiagnoseResultMsg=h.ProjectTestResultMsg=h.RunStatusMsg=void 0;h.RunPrConflictMsg=h.RunResolveConflictResultMsg=h.RunAnswerResultMsg=h.RunAnswerMsg=h.RunTestFixResultMsg=h.RunTestFixMsg=h.RunResolveConflictMsg=h.RunnerUninstallMsg=h.RunnerUpdateMsg=h.RepoDocSaveResultMsg=h.RepoDocSaveMsg=h.SetupClaudeMdSaveResultMsg=h.SetupClaudeMdSaveMsg=h.SetupAskResultMsg=h.SetupAskMsg=h.SetupClaudeMdGenerateResultMsg=h.SetupClaudeMdGenerateMsg=h.SetupRecheckResultMsg=h.SetupRecheckMsg=h.RepoUnmapResultMsg=h.RepoUnmapMsg=h.SetupStatusResultMsg=h.SetupStatusMsg=h.DeploySuggestResultMsg=h.SelfMigrationApplyResultMsg=h.SelfMigrationApplyMsg=h.SELF_MIGRATION_DIR=h.EnvPreflightResultMsg=h.EnvPreflightMsg=h.ChatCreateTicketResultMsg=h.ChatCreateTicketMsg=h.ChatTurnResultMsg=h.ChatTurnMsg=h.ChatFile=h.TeamCredsResultMsg=h.TeamCredsMsg=h.KnowledgeSaveResultMsg=h.KnowledgeSaveMsg=h.KnowledgeListResultMsg=h.KnowledgeFile=h.KnowledgeListMsg=h.AuditReviewResultMsg=h.AuditReviewMsg=h.AuditGetResultMsg=h.AuditGetMsg=h.AuditExplainResultMsg=h.AuditExplainMsg=h.ChatCancelMsg=h.ChatStepRunResultMsg=h.ChatStepRunMsg=void 0;h.DeployFixMsg=h.DeployStartMsg=h.RunRetryPushMsg=h.RunRejectedMsg=h.RunApprovedMsg=h.RunCancelMsg=h.RuleDiagnoseMsg=h.ProjectTestMsg=h.RunClaimResultMsg=h.ConfigMsg=h.HelloAckMsg=h.RunnerToServerMsg=h.RebirthStudyResultMsg=h.RebirthStudyUpdateMsg=h.RebirthStudyMsg=h.TimelineDigestResultMsg=h.TimelineDigestMsg=h.RebirthDesignResultMsg=h.RebirthDesignMsg=h.RebirthUploadChunkResultMsg=h.RebirthUploadChunkMsg=h.RebirthUploadBeginResultMsg=h.RebirthUploadBeginMsg=h.SiteAuditResultMsg=h.SiteAuditMsg=h.ServerDecommissionProgressMsg=h.ServerDecommissionResultMsg=h.ServerDecommissionExecuteMsg=h.ServerDecommissionPlanResultMsg=h.ServerDecommissionPlanMsg=h.MonitorDiscoverResultMsg=h.MonitorDiscoverMsg=h.MonitorRebaselineResultMsg=h.MonitorRebaselineMsg=h.MonitorSuggestResultMsg=h.MonitorSuggestMsg=h.MonitorRunResultMsg=h.MonitorRunMsg=h.MonitorResultMsg=h.ServerInventoryResultMsg=h.ServerInventoryMsg=h.AutopilotReportMsg=h.AutopilotNextResultMsg=h.AutopilotPlanResultMsg=h.AutopilotPlanMsg=h.AutopilotNextMsg=h.RunnerUninstallResultMsg=h.RunnerUpdateResultMsg=h.AgentProfilesResultMsg=h.AgentProfilesMsg=void 0;h.DEFAULT_DEPLOY_SUGGEST_PROMPT_TEMPLATE=h.DEPLOY_DOC_SUGGEST_PROMPT_TEMPLATE=h.DEPLOY_FIX_PROMPT_TEMPLATE=h.PROMPT_PRESETS=h.DEFAULT_RESPOND_PROMPT_TEMPLATE=h.BUGFIX_IMPLEMENT_PROMPT_TEMPLATE=h.BUG_INVESTIGATION_PROMPT_TEMPLATE=h.TECHNICAL_PLAN_PROMPT_TEMPLATE=h.MEMORY_UPDATE_PROMPT=h.DEFAULT_IMPLEMENT_PROMPT_TEMPLATE=h.WRITE_TESTS_PROMPT=h.REVISION_PROMPT=h.FOCUSED_READING_PROMPT=h.NEEDS_INPUT_OPTIONS_PROMPT=h.DEFAULT_PLAN_PROMPT_TEMPLATE=h.EnrollResponse=h.EnrollRequest=h.ServerToRunnerMsg=h.JiraUsersMsg=h.DeploySuggestMsg=void 0;h.missingAgentCapabilities=ZS;h.replyPreferenceAppendix=YS;h.monitorChecksAppendix=JS;h.pendingMigrationsAppendix=XS;h.deployTargetsAppendix=QS;h.savedStepChecksAppendix=e_;h.failureCollector=jp;h.failureLines=s_;h.composeCommandAppendix=i_;h.isSelfMigrationFilename=o_;h.parseRunnerMsg=a_;h.parseServerMsg=c_;var o=Mp();h.GITHUB_TOKEN_PERMISSIONS={where:"github.com/settings/personal-access-tokens/new (fine-grained token)",steps:["Resource owner: the org or user that OWNS the repo - not your personal account, unless the repo is under it","Repository access: Only select repositories -> pick this repo","Contents: Read and write - pushing the agent's branch","Pull requests: Read and write - opening the PR, and merging it when you approve","Metadata: Read-only - GitHub adds this itself and will not let you remove it","Workflows: Read and write - ONLY if changes may touch .github/workflows; without it GitHub rejects those pushes"],note:"A fine-grained token covers exactly ONE resource owner, so a repo in a different org always needs its own token. A classic token with the `repo` scope also works and is simpler, but it reaches every repository you can see - prefer fine-grained."};h.PROTOCOL_VERSION="1.118";h.RUNNER_UNINSTALL_COMMAND="sudo allwright service uninstall";h.DEPLOY_DOC_CANDIDATES=[".ticketpilot/deploy.md","DEPLOY.md","DEPLOYMENT.md","docs/DEPLOY.md","docs/deploy.md","docs/deployment.md"];h.REGISTERED_AGENTS=[{id:"claude-code",displayName:"Claude Code",capabilities:{readOnlyJail:!0,editNoShellJail:!0,sessionResume:!0,costReporting:!0,modelSelection:!0,loginProfiles:!0,fullAccess:!0},suggestedModels:["claude-fable-5","claude-opus-5","claude-sonnet-5","claude-haiku-4-5-20251001"],experimental:!1},{id:"codex",displayName:"OpenAI Codex CLI (experimental)",capabilities:{readOnlyJail:!0,editNoShellJail:!1,sessionResume:!1,costReporting:!1,modelSelection:!0,loginProfiles:!1,fullAccess:!1},suggestedModels:[],experimental:!0},{id:"kimi",displayName:"Moonshot Kimi Code CLI",capabilities:{readOnlyJail:!0,editNoShellJail:!1,sessionResume:!0,costReporting:!1,modelSelection:!0,loginProfiles:!1,fullAccess:!1},suggestedModels:[],experimental:!0}];h.DEFAULT_AGENT_ID="claude-code";h.REQUIRED_AGENT_CAPABILITIES={plan_only:["readOnlyJail","sessionResume"],respond:["readOnlyJail"],implement:["editNoShellJail","sessionResume"],deploy:[],chat:["readOnlyJail","sessionResume"],assist:["readOnlyJail"],operator:["fullAccess","sessionResume"]};function ZS(t,e){let n=h.REGISTERED_AGENTS.find(r=>r.id===t);return n?(h.REQUIRED_AGENT_CAPABILITIES[e]??[]).filter(r=>!n.capabilities[r]):null}h.BRANCH_DEPLOY_ISSUE_KEY="(branch deploy)";h.NEEDS_INPUT_MARKER="NEEDS-INPUT";h.NEEDS_INPUT_ASK_FENCE="ask";h.NEEDS_INPUT_LABEL="agent-needs-input";h.NEEDS_INPUT_COMMENT_MARKER="Allwright needs your input";h.LEGACY_NEEDS_INPUT_COMMENT_MARKERS=["TicketPilot needs your input"];var VS=t=>t.includes(h.NEEDS_INPUT_COMMENT_MARKER)||h.LEGACY_NEEDS_INPUT_COMMENT_MARKERS.some(e=>t.includes(e));h.needsInputMarkerIn=VS;h.RunStatus=o.z.enum(["queued","running","posting","awaiting_approval","needs_input","succeeded","failed","timed_out"]);h.ACTIVE_RUN_STATUSES=["queued","running","posting","awaiting_approval"];h.TriggerType=o.z.enum(["label_added","comment_keyword","status_changed"]);h.ActionType=o.z.enum(["plan_only","implement","respond","deploy"]);h.LabelAddedTrigger=o.z.object({type:o.z.literal("label_added"),label:o.z.string().min(1),doneLabel:o.z.string().min(1).default("agent-planned"),failedLabel:o.z.string().min(1).default("agent-failed")});h.CommentKeywordTrigger=o.z.object({type:o.z.literal("comment_keyword"),keyword:o.z.string().min(1),doneLabel:o.z.string().min(1).default("agent-implemented"),failedLabel:o.z.string().min(1).default("agent-failed")});h.StatusChangedTrigger=o.z.object({type:o.z.literal("status_changed"),status:o.z.string().min(1),doneLabel:o.z.string().min(1).default("agent-deployed"),failedLabel:o.z.string().min(1).default("agent-failed")});h.TriggerConfig=o.z.discriminatedUnion("type",[h.LabelAddedTrigger,h.CommentKeywordTrigger,h.StatusChangedTrigger]);h.PlanOnlyAction=o.z.object({type:o.z.literal("plan_only"),promptTemplate:o.z.string().min(1),allowWeb:o.z.boolean().default(!1),timeoutSeconds:o.z.number().int().positive().max(3600).default(900),agent:o.z.string().default(h.DEFAULT_AGENT_ID),model:o.z.string().default("")});h.ImplementAction=o.z.object({type:o.z.literal("implement"),promptTemplate:o.z.string().min(1),timeoutSeconds:o.z.number().int().positive().max(7200).default(1800),maxTurns:o.z.number().int().positive().max(500).default(120),maxCostUsd:o.z.number().positive().optional(),requireApproval:o.z.boolean().default(!0),branchTemplate:o.z.string().min(1).default("agent/{{issueKey}}").refine(t=>t.includes("{{issueKey}}"),{message:"branchTemplate must contain {{issueKey}}"}),baseBranch:o.z.string().min(1).default("main"),jiraTransition:o.z.string().optional(),jiraTransitionOnStart:o.z.string().optional(),jiraTransitionOnMerge:o.z.string().optional(),agent:o.z.string().default(h.DEFAULT_AGENT_ID),model:o.z.string().default(""),updateMemory:o.z.boolean().default(!1),allowWeb:o.z.boolean().default(!1),writeTests:o.z.boolean().default(!0),runTests:o.z.boolean().default(!0),mergeOnApprove:o.z.boolean().default(!0),mergeMethod:o.z.enum(["squash","merge","rebase"]).default("squash"),autoMerge:o.z.boolean().default(!0)});h.RespondAction=o.z.object({type:o.z.literal("respond"),promptTemplate:o.z.string().min(1),timeoutSeconds:o.z.number().int().positive().max(3600).default(600),agent:o.z.string().default(h.DEFAULT_AGENT_ID),model:o.z.string().default("")});h.DeployStep=o.z.object({name:o.z.string().min(1).max(120),run:o.z.string().min(1).max(4e3),continueOnError:o.z.boolean().default(!1)});h.PromotionMode=o.z.enum(["deploy_only","merge_and_deploy"]);h.EnvironmentConfig=o.z.object({id:o.z.string(),projectId:o.z.string(),name:o.z.string(),rank:o.z.number().int().nonnegative(),auditBeforeDeploy:o.z.enum(["","security","testing"]).default(""),branch:o.z.string().default(""),publicUrl:o.z.string().default(""),servePath:o.z.string().default(""),useDedicatedCheckout:o.z.boolean().default(!1),promotionMode:h.PromotionMode.default("deploy_only"),ticketBranchTemplate:o.z.string().default("agent/{{issueKey}}"),steps:o.z.array(h.DeployStep).default([]),workdir:o.z.string().default(""),timeoutSeconds:o.z.number().int().positive().max(21600).default(1800),requiredSecrets:o.z.array(o.z.string()).default([]),requireApproval:o.z.boolean().default(!1),requireSyncCheck:o.z.boolean().default(!1),previousEnvBranch:o.z.string().optional(),deployFromColumn:o.z.string().default(""),deployToColumn:o.z.string().default("")});h.DeployAction=o.z.object({type:o.z.literal("deploy"),envSelection:o.z.enum(["fixed","from_comment"]).default("from_comment"),environmentId:o.z.string().optional(),requireStatus:o.z.string().optional()});h.ActionConfig=o.z.discriminatedUnion("type",[h.PlanOnlyAction,h.ImplementAction,h.RespondAction,h.DeployAction]);h.ProjectConfig=o.z.object({id:o.z.string(),name:o.z.string(),jiraProjectKey:o.z.string(),goLiveIssueKey:o.z.string().default(""),repoName:o.z.string(),jiraSiteUrl:o.z.string().default(""),defaultAgent:o.z.string().default("claude-code"),componentRoutes:o.z.array(o.z.object({component:o.z.string().min(1),repoName:o.z.string().min(1)})).default([]),packs:o.z.array(o.z.string().max(60)).max(40).default([])});h.PACK_CATALOG=[{id:"owasp",title:"OWASP Top 10",kind:"compliance",description:"Security audits cite OWASP Top 10 (2021) categories - findings carry OWASP-A01\u2026A10 ids.",roles:["security"]},{id:"pci-dss",title:"PCI DSS",kind:"compliance",description:"Payment-card compliance: findings cite PCI DSS requirement numbers (PCI-3.x, PCI-6.x\u2026).",roles:["security"]},{id:"laravel",title:"Laravel conventions",kind:"stack",description:"Laravel-specific rules for implement runs and architecture audits.",roles:["implement","architecture"]},{id:"react",title:"React conventions",kind:"stack",description:"React/Next-specific rules for implement runs and architecture audits.",roles:["implement","architecture"]},{id:"node",title:"Node.js backend conventions",kind:"stack",description:"Node/Express/Nest backend rules for implement runs and architecture audits.",roles:["implement","architecture"]}];h.RuleConfig=o.z.object({id:o.z.string(),projectId:o.z.string(),name:o.z.string(),enabled:o.z.boolean(),trigger:h.TriggerConfig,action:h.ActionConfig});h.MonitorStatus=o.z.enum(["green","amber","red","error","skipped"]);h.MonitorSchedule=o.z.discriminatedUnion("kind",[o.z.object({kind:o.z.literal("every"),minutes:o.z.number().int().min(1).max(1440)}),o.z.object({kind:o.z.literal("daily"),at:o.z.string().regex(/^\d{2}:\d{2}$/)}),o.z.object({kind:o.z.literal("weekly"),day:o.z.number().int().min(0).max(6),at:o.z.string().regex(/^\d{2}:\d{2}$/)})]);h.MonitorCommand=o.z.object({name:o.z.string().min(1).max(120),run:o.z.string().min(1).max(4e3)});h.MonitorParseRules=o.z.object({amberPattern:o.z.string().max(400).default(""),redPattern:o.z.string().max(400).default(""),greenRequires:o.z.string().max(400).default("")});h.MonitorCheckConfig=o.z.object({id:o.z.string(),type:o.z.string().max(60),name:o.z.string().min(1).max(120),projectId:o.z.string().default(""),params:o.z.record(o.z.unknown()).default({}),schedule:h.MonitorSchedule,shell:o.z.enum(["bash","powershell"]).default("bash"),commands:o.z.array(h.MonitorCommand).max(20).default([]),parseRules:h.MonitorParseRules.default({}),enabled:o.z.boolean().default(!0),jiraNotify:o.z.boolean().default(!1)});h.MONITOR_PARAM_SCHEMAS={disk_space:o.z.object({warnPct:o.z.number().int().min(1).max(99).default(80),critPct:o.z.number().int().min(1).max(99).default(90),mounts:o.z.array(o.z.string().max(300)).max(20).default([])}),memory:o.z.object({warnPct:o.z.number().int().min(1).max(99).default(85),critPct:o.z.number().int().min(1).max(99).default(95)}),cpu_load:o.z.object({warnPerCore:o.z.number().positive().max(64).default(2),critPerCore:o.z.number().positive().max(64).default(4)}),uptime_reboot:o.z.object({maxUptimeDays:o.z.number().int().positive().max(3650).default(180)}),services:o.z.object({names:o.z.array(o.z.string().min(1).max(120)).min(1).max(40)}),http_check:o.z.object({url:o.z.string().min(1).max(500),expectStatus:o.z.number().int().min(100).max(599).default(200),expectString:o.z.string().max(200).default(""),warnMs:o.z.number().int().positive().max(6e4).default(2e3),timeoutMs:o.z.number().int().positive().max(6e4).default(1e4)}),tls_cert:o.z.object({domains:o.z.array(o.z.string().min(1).max(253)).min(1).max(40),warnDays:o.z.number().int().min(1).max(365).default(21),critDays:o.z.number().int().min(0).max(364).default(7)}),sites:o.z.object({extraHosts:o.z.array(o.z.string().min(1).max(253)).max(30).default([]),excludeHosts:o.z.array(o.z.string().min(1).max(253)).max(30).default([]),warnMs:o.z.number().int().positive().max(6e4).default(3e3),certWarnDays:o.z.number().int().min(1).max(365).default(21),certCritDays:o.z.number().int().min(0).max(364).default(7)}),db_health:o.z.object({repoName:o.z.string().min(1).max(200),envName:o.z.string().min(1).max(100),secretName:o.z.string().min(1).max(100).default("DATABASE_URL"),warnConnections:o.z.number().int().positive().max(1e4).default(50),longQuerySeconds:o.z.number().int().positive().max(3600).default(60)}),docker_containers:o.z.object({expected:o.z.array(o.z.string().min(1).max(120)).max(40).default([])}),log_scan:o.z.object({files:o.z.array(o.z.string().min(1).max(400)).min(1).max(10),hardPatterns:o.z.array(o.z.string().max(200)).max(10).default(["oom-killer","kernel panic","segfault"]),errorPattern:o.z.string().max(200).default("\\b(error|fatal)\\b"),warnCount:o.z.number().int().positive().max(1e5).default(50),tailKB:o.z.number().int().min(16).max(1024).default(256)}),backup_freshness:o.z.object({noBackups:o.z.boolean().default(!1),targets:o.z.array(o.z.object({pathGlob:o.z.string().min(1).max(500),maxAgeHours:o.z.number().positive().max(2160).default(26),minSizeMB:o.z.number().nonnegative().max(1e6).default(1)})).max(20).default([])}),ports_baseline:o.z.object({}),users_baseline:o.z.object({}),cron_baseline:o.z.object({}),auth_activity:o.z.object({failedWarnCount:o.z.number().int().positive().max(1e5).default(100)}),webroot_integrity:o.z.object({roots:o.z.array(o.z.string().min(1).max(400)).min(1).max(10),excludes:o.z.array(o.z.string().min(1).max(200)).max(20).default(["node_modules",".git","cache","wp-content/uploads",".next","vendor"])}),wordpress:o.z.object({wpPaths:o.z.array(o.z.string().min(1).max(400)).min(1).max(10)}),process_hog:o.z.object({cpuPct:o.z.number().min(1).max(100).default(80)}),windows_update:o.z.object({maxHotfixAgeDays:o.z.number().int().positive().max(3650).default(60)}),custom:o.z.object({})};h.MONITOR_BASELINE_TYPES=["ports_baseline","users_baseline","cron_baseline","auth_activity","webroot_integrity","wordpress"];h.MONITOR_CATALOG=[{id:"disk_space",title:"Disk space",group:"health",question:"Is any filesystem filling up?",os:"both",minMinutes:5,defaultSchedule:{kind:"every",minutes:15}},{id:"memory",title:"Memory & swap",group:"health",question:"Is the machine under memory pressure?",os:"both",minMinutes:5,defaultSchedule:{kind:"every",minutes:15}},{id:"cpu_load",title:"CPU load",group:"health",question:"Is the load average sustainably high?",os:"linux",minMinutes:5,defaultSchedule:{kind:"every",minutes:15}},{id:"uptime_reboot",title:"Uptime & pending restart",group:"health",question:"When did this box last boot, and does the OS want a reboot?",os:"linux",minMinutes:60,defaultSchedule:{kind:"daily",at:"06:00"}},{id:"services",title:"Services running",group:"health",question:"Are these named services active?",os:"linux",minMinutes:5,defaultSchedule:{kind:"every",minutes:5}},{id:"http_check",title:"HTTP check",group:"web",question:"Does this URL answer correctly, and fast enough?",os:"both",minMinutes:1,defaultSchedule:{kind:"every",minutes:5}},{id:"tls_cert",title:"TLS certificate expiry",group:"web",question:"How many days are left on these certificates?",os:"both",minMinutes:60,defaultSchedule:{kind:"daily",at:"07:00"}},{id:"backup_freshness",title:"Backup freshness",group:"backups",question:"Did a fresh, healthy-sized backup actually appear?",os:"both",minMinutes:60,defaultSchedule:{kind:"daily",at:"08:00"}},{id:"sites",title:"Sites this box serves",group:"web",question:"Every nginx/caddy/IIS vhost, live-probed: up, fast, certified?",os:"both",minMinutes:5,defaultSchedule:{kind:"every",minutes:15}},{id:"db_health",title:"Database health",group:"db",question:"Reachable, size, connections, long-running queries?",os:"linux",minMinutes:5,defaultSchedule:{kind:"every",minutes:30}},{id:"docker_containers",title:"Docker containers",group:"health",question:"Are the containers running - and staying up?",os:"linux",minMinutes:5,defaultSchedule:{kind:"every",minutes:5}},{id:"log_scan",title:"Log scan",group:"health",question:"Are named logs quiet - no OOM kills, no error spikes?",os:"linux",minMinutes:15,defaultSchedule:{kind:"every",minutes:60}},{id:"ports_baseline",title:"Listening ports vs baseline",group:"security",question:"Did a new port start listening that no one vouched for?",os:"both",minMinutes:30,defaultSchedule:{kind:"every",minutes:60}},{id:"users_baseline",title:"System users vs baseline",group:"security",question:"Did a new account appear - especially a root-level one?",os:"linux",minMinutes:60,defaultSchedule:{kind:"daily",at:"05:00"}},{id:"cron_baseline",title:"Cron vs baseline",group:"security",question:"Did any crontab change since a human last accepted it?",os:"linux",minMinutes:60,defaultSchedule:{kind:"daily",at:"05:10"}},{id:"auth_activity",title:"SSH & access grants",group:"security",question:"Brute-force spikes; new authorized_keys or sudoers grants?",os:"linux",minMinutes:30,defaultSchedule:{kind:"every",minutes:60}},{id:"webroot_integrity",title:"Webroot integrity",group:"security",question:"Did site files change outside a deploy?",os:"linux",minMinutes:60,defaultSchedule:{kind:"daily",at:"05:20"}},{id:"wordpress",title:"WordPress compromise signals",group:"security",question:"Core checksums, PHP in uploads, new admin users?",os:"linux",minMinutes:60,defaultSchedule:{kind:"daily",at:"05:30"}},{id:"process_hog",title:"Runaway process",group:"security",question:"Is something eating the CPU - from a location it shouldn't?",os:"linux",minMinutes:15,defaultSchedule:{kind:"every",minutes:30}},{id:"windows_update",title:"Windows updates",group:"health",question:"Pending reboot; how stale is the newest hotfix?",os:"windows",minMinutes:60,defaultSchedule:{kind:"daily",at:"06:30"}},{id:"custom",title:"Custom check",group:"custom",question:"Your own saved commands - exit code decides, patterns refine.",os:"both",minMinutes:5,defaultSchedule:{kind:"daily",at:"06:00"}}];h.AI_SPEND_SURFACES=[{id:"run_plan",label:"Plan runs",group:"people"},{id:"run_implement",label:"Implement runs",group:"people"},{id:"run_respond",label:"Ticket answers",group:"people"},{id:"run_testfix",label:"Test fixes",group:"people"},{id:"run_conflict_resolve",label:"Conflict resolves",group:"people"},{id:"chat_turn",label:"Compose chat",group:"people"},{id:"audit",label:"Audits",group:"people"},{id:"audit_explain",label:"Audit explanations",group:"people"},{id:"rebirth_study",label:"Rebirth studies",group:"people"},{id:"rebirth_refold",label:"Rebirth refolds",group:"people"},{id:"rebirth_design",label:"Rebirth design passes",group:"people"},{id:"rebirth_techstack",label:"Rebirth tech-stack passes",group:"people"},{id:"deploy_fix",label:"Deploy-failure diagnoses",group:"people"},{id:"deploy_suggest",label:"Deploy step proposals",group:"people"},{id:"setup_docs",label:"Setup doc drafting",group:"people"},{id:"setup_ask",label:"Setup questions",group:"people"},{id:"incident_diagnosis",label:"Incident diagnoses",group:"people"},{id:"monitor_suggest",label:"Check proposals",group:"people"},{id:"chat_compact",label:"Chat compaction",group:"platform"},{id:"chat_capsule",label:"Ticket context capsules",group:"platform"},{id:"repo_brief",label:"Repo briefs",group:"platform"},{id:"timeline_digest",label:"Timeline digests",group:"platform"},{id:"autopilot_plan",label:"Autopilot planning",group:"platform"},{id:"epic_suggest",label:"Epic suggestions",group:"platform"}];h.AiSpendMsg=o.z.object({type:o.z.literal("ai.spend"),eventKey:o.z.string().min(1).max(200),surface:o.z.string().max(60),projectId:o.z.string().default(""),userId:o.z.string().default(""),agentId:o.z.string().default(""),model:o.z.string().max(200).default(""),billingMode:o.z.string().max(20).default(""),claudeProfile:o.z.string().max(200).default(""),inputTokens:o.z.number().int().nonnegative().default(0),outputTokens:o.z.number().int().nonnegative().default(0),cacheReadTokens:o.z.number().int().nonnegative().default(0),costUsd:o.z.number().nonnegative().default(0),turns:o.z.number().int().nonnegative().default(0),refKind:o.z.string().max(20).default(""),refId:o.z.string().max(200).default(""),refLabel:o.z.string().max(200).default(""),at:o.z.string().default("")});h.HelloMsg=o.z.object({type:o.z.literal("hello"),protocolVersion:o.z.string(),runnerVersion:o.z.string(),platform:o.z.string(),justBooted:o.z.boolean().optional()});h.HeartbeatMsg=o.z.object({type:o.z.literal("heartbeat"),ts:o.z.string()});h.RunClaimMsg=o.z.object({type:o.z.literal("run.claim"),requestId:o.z.string(),ruleId:o.z.string(),issueKey:o.z.string(),issueSummary:o.z.string().default(""),triggerFingerprint:o.z.string(),dedupKey:o.z.string().optional(),triggeredByAccountId:o.z.string().optional()});h.RunLogMsg=o.z.object({type:o.z.literal("run.log"),runId:o.z.string(),seq:o.z.number().int().nonnegative(),ts:o.z.string(),level:o.z.enum(["info","warn","error","agent"]),message:o.z.string().max(16384)});h.RunUsageMsg=o.z.object({type:o.z.literal("run.usage"),runId:o.z.string(),inputTokens:o.z.number().int().nonnegative(),outputTokens:o.z.number().int().nonnegative(),cacheReadTokens:o.z.number().int().nonnegative().optional(),costUsd:o.z.number().nonnegative().optional(),turns:o.z.number().int().nonnegative().optional()});h.FailedTest=o.z.object({command:o.z.string().max(500),exitCode:o.z.number().int(),tail:o.z.string().max(4e3)});h.RunContextMsg=o.z.object({type:o.z.literal("run.context"),runId:o.z.string(),pieces:o.z.array(o.z.object({part:o.z.string().max(80),chars:o.z.number().int().nonnegative()})).max(30),totalChars:o.z.number().int().nonnegative(),sessionMode:o.z.enum(["fresh","chained","timeout-resume","preflight-resume"])});h.RunStatusMsg=o.z.object({type:o.z.literal("run.status"),runId:o.z.string(),status:h.RunStatus,error:o.z.string().optional(),note:o.z.string().max(300).optional(),errorKind:o.z.enum(["guard"]).optional(),costUsd:o.z.number().nonnegative().optional(),inputTokens:o.z.number().int().nonnegative().optional(),outputTokens:o.z.number().int().nonnegative().optional(),cacheReadTokens:o.z.number().int().nonnegative().optional(),resultSummary:o.z.string().max(2e3).optional(),billingMode:o.z.enum(["subscription","api","unknown"]).optional(),model:o.z.string().max(200).optional(),prUrl:o.z.string().optional(),headSha:o.z.string().optional(),deployedRef:o.z.string().optional(),retryAvailable:o.z.boolean().optional(),failedTests:o.z.array(h.FailedTest).max(20).optional(),testsPassed:o.z.number().int().nonnegative().optional(),testsTotal:o.z.number().int().nonnegative().optional(),manualSteps:o.z.array(o.z.object({command:o.z.string().max(500),why:o.z.string().max(300).default("")})).max(20).optional(),goLiveDraft:o.z.string().max(4e3).optional(),inputQuestions:o.z.string().max(4e3).optional(),inputOptions:o.z.array(o.z.string().max(200)).max(5).optional()});h.ProjectTestResultMsg=o.z.object({type:o.z.literal("project.test.result"),requestId:o.z.string(),ok:o.z.boolean(),checks:o.z.array(o.z.object({name:o.z.string(),ok:o.z.boolean(),detail:o.z.string(),kind:o.z.enum(["connection","content"]).default("connection"),fix:o.z.array(o.z.string()).default([]),fixNote:o.z.string().default("")}))});h.RuleDiagnoseResultMsg=o.z.object({type:o.z.literal("rule.diagnose.result"),requestId:o.z.string(),checks:o.z.array(o.z.object({name:o.z.string(),ok:o.z.boolean(),detail:o.z.string(),kind:o.z.enum(["connection","content"]).default("connection"),fix:o.z.array(o.z.string()).default([]),fixNote:o.z.string().default("")})),matchedCount:o.z.number().int().nonnegative(),excludedCount:o.z.number().int().nonnegative(),excludedSample:o.z.array(o.z.string()).max(5)});h.DeployClaimMsg=o.z.object({type:o.z.literal("deploy.claim"),requestId:o.z.string(),projectId:o.z.string(),ruleId:o.z.string(),issueKey:o.z.string(),issueSummary:o.z.string().default(""),environmentName:o.z.string(),requestedByAccountId:o.z.string().optional(),requestedByDisplayName:o.z.string().default(""),dedupKey:o.z.string(),triggerFingerprint:o.z.string()});h.DeployClaimResultMsg=o.z.object({type:o.z.literal("deploy.claim.result"),requestId:o.z.string(),accepted:o.z.boolean(),runId:o.z.string().optional(),environment:h.EnvironmentConfig.optional(),reason:o.z.string().optional(),code:o.z.enum(["ok","duplicate","unknown_environment","not_permitted","unlinked_jira_account","promotion_order","jira_disabled","rule_disabled","cap"]).optional()});h.JiraUsersResultMsg=o.z.object({type:o.z.literal("jira.users.result"),requestId:o.z.string(),ok:o.z.boolean(),users:o.z.array(o.z.object({accountId:o.z.string(),displayName:o.z.string(),email:o.z.string().default(""),active:o.z.boolean().default(!0)})).default([]),error:o.z.string().optional()});h.ChatStreamMsg=o.z.object({type:o.z.literal("chat.stream"),requestId:o.z.string(),seq:o.z.number().int().nonnegative(),text:o.z.string().max(8e3)});h.ChatUsageMsg=o.z.object({type:o.z.literal("chat.usage"),requestId:o.z.string(),inputTokens:o.z.number().int().nonnegative(),outputTokens:o.z.number().int().nonnegative(),cacheReadTokens:o.z.number().int().nonnegative().optional(),turns:o.z.number().int().nonnegative().optional()});h.ChatActivityMsg=o.z.object({type:o.z.literal("chat.activity"),requestId:o.z.string(),seq:o.z.number().int().nonnegative(),verb:o.z.string().max(40),target:o.z.string().max(200).default("")});h.ChatSessionMsg=o.z.object({type:o.z.literal("chat.session"),requestId:o.z.string(),sessionId:o.z.string()});h.ChatListMsg=o.z.object({type:o.z.literal("chat.list"),requestId:o.z.string(),projectId:o.z.string()});h.ChatListResultMsg=o.z.object({type:o.z.literal("chat.list.result"),requestId:o.z.string(),sessions:o.z.array(o.z.object({sessionId:o.z.string(),title:o.z.string().default(""),updatedAt:o.z.string().default(""),messageCount:o.z.number().int().nonnegative().default(0),ownerUserId:o.z.string().default(""),agentId:o.z.string().default("")})).default([])});h.ChatLoadMsg=o.z.object({type:o.z.literal("chat.load"),requestId:o.z.string(),sessionId:o.z.string()});h.BUILTIN_REPLY_LANGUAGES=[{name:"English",instruction:"Write your prose in English."},{name:"Hindi",instruction:"Write your prose in Hindi, in the Devanagari script. Keep technical terms that have no everyday Hindi equivalent in English rather than inventing a translation."},{name:"Hinglish",instruction:"Write your prose in Hinglish: conversational Hindi written in the Latin alphabet, with English technical words left in English - the way an Indian developer talks at work."}];h.REPLY_STYLES=[{id:"technical",label:"Technical",hint:"Full detail - names files, functions and trade-offs",instruction:"Answer at full technical depth: name the files, functions and data structures involved, and state trade-offs precisely. Assume the reader reads code every day."},{id:"balanced",label:"Balanced",hint:"Plain explanation, with the technical detail that matters",instruction:"Explain in plain language first, then add the technical detail that actually matters for the decision. Assume the reader is technical but does not know this codebase."},{id:"simple",label:"Simple",hint:"Everyday words - no jargon unless it is unavoidable",instruction:"Answer in everyday words, as if to someone who does not write code. Avoid jargon; when a technical term is unavoidable, explain it in half a sentence. Prefer short paragraphs and concrete examples over precision about internals."}];function YS(t){let e=[],n=(t.language??"").trim();if(n){let s=h.BUILTIN_REPLY_LANGUAGES.find(i=>i.name.toLowerCase()===n.toLowerCase());e.push((t.languageInstruction??"").trim()||s?.instruction||`Write your prose in ${n}.`),e.push("Code, file paths, identifiers, commands, error text and log output stay exactly as they are - only your own prose changes language."),e.push("The ```ticket block is the exception: its summary and description are ALWAYS written in English, because the ticket is read by other people and by the implementing agent.")}let r=h.REPLY_STYLES.find(s=>s.id===(t.style??"").trim());return r&&e.push(r.instruction),e.length?`
24
+ `,{mode:384}),kn.default.renameSync(r,n),kn.default.chmodSync(n,384)}function Yo(t,e){return`${t}:${e}`}function Qt(t,e,n){return t.environments[Yo(e,n)]?.secrets??{}}function Li(t,e){return t.repos[e]?.jira??t.jira}function Ui(t){return!t.jira&&!Object.values(t.repos).some(e=>e.jira)}function he(){let t=_e();if(!t)throw new Error(`No runner config found at ${Sn()}. Run \`allwright init\` first.`);return t}var kn,Zo,Vo,cp,_l,Ae=X(()=>{"use strict";kn=E(require("node:fs"),1),Zo=E(require("node:os"),1),Vo=E(require("node:path"),1);_t();cp=S.object({baseUrl:S.string().url(),email:S.string().email(),apiToken:S.string().min(1)}),_l=S.object({controlPlaneUrl:S.string().url(),runnerId:S.string().optional(),runnerToken:S.string().optional(),runnerName:S.string().default(Zo.default.hostname()),jira:cp.optional(),repos:S.record(S.object({path:S.string(),jira:cp.optional(),github:S.object({token:S.string().min(1),login:S.string().optional()}).optional()})).default({}),github:S.object({token:S.string().min(1),login:S.string().optional()}).optional(),githubUsers:S.record(S.object({token:S.string().min(1),login:S.string().optional()})).default({}),deploy:S.object({enabled:S.boolean().default(!1)}).default({enabled:!1}),environments:S.record(S.object({secrets:S.record(S.string()).default({})})).default({}),claudeProfiles:S.record(S.object({configDir:S.string()})).default({}),claudeBin:S.string().default("claude"),agents:S.record(S.object({bin:S.string()})).default({}),jiraUsers:S.record(S.object({email:S.string().email(),apiToken:S.string().min(1)})).default({}),auditSchedules:S.array(S.object({repoName:S.string(),role:S.enum(["security","testing"]),intervalHours:S.number().int().min(6).max(720)})).default([]),pollIntervalSeconds:S.number().int().min(10).max(600).default(30),operatorEnabled:S.boolean().default(!1)})});var qi=me(Te=>{"use strict";Object.defineProperty(Te,"__esModule",{value:!0});Te.getParsedType=Te.ZodParsedType=Te.objectUtil=Te.util=void 0;var xl;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function n(s){throw new Error}t.assertNever=n,t.arrayToEnum=s=>{let i={};for(let a of s)i[a]=a;return i},t.getValidEnumValues=s=>{let i=t.objectKeys(s).filter(c=>typeof s[s[c]]!="number"),a={};for(let c of i)a[c]=s[c];return t.objectValues(a)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},t.find=(s,i)=>{for(let a of s)if(i(a))return a},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}t.joinValues=r,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(xl||(Te.util=xl={}));var dp;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(dp||(Te.objectUtil=dp={}));Te.ZodParsedType=xl.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);var I0=t=>{switch(typeof t){case"undefined":return Te.ZodParsedType.undefined;case"string":return Te.ZodParsedType.string;case"number":return Number.isNaN(t)?Te.ZodParsedType.nan:Te.ZodParsedType.number;case"boolean":return Te.ZodParsedType.boolean;case"function":return Te.ZodParsedType.function;case"bigint":return Te.ZodParsedType.bigint;case"symbol":return Te.ZodParsedType.symbol;case"object":return Array.isArray(t)?Te.ZodParsedType.array:t===null?Te.ZodParsedType.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?Te.ZodParsedType.promise:typeof Map<"u"&&t instanceof Map?Te.ZodParsedType.map:typeof Set<"u"&&t instanceof Set?Te.ZodParsedType.set:typeof Date<"u"&&t instanceof Date?Te.ZodParsedType.date:Te.ZodParsedType.object;default:return Te.ZodParsedType.unknown}};Te.getParsedType=I0});var Qo=me(Wn=>{"use strict";Object.defineProperty(Wn,"__esModule",{value:!0});Wn.ZodError=Wn.quotelessJson=Wn.ZodIssueCode=void 0;var hp=qi();Wn.ZodIssueCode=hp.util.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);var E0=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");Wn.quotelessJson=E0;var Fi=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){let n=e||function(i){return i.message},r={_errors:[]},s=i=>{for(let a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else{let c=r,l=0;for(;l<a.path.length;){let u=a.path[l];l===a.path.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(n(a))):c[u]=c[u]||{_errors:[]},c=c[u],l++}}};return s(this),r}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,hp.util.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let s of this.issues)if(s.path.length>0){let i=s.path[0];n[i]=n[i]||[],n[i].push(e(s))}else r.push(e(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};Wn.ZodError=Fi;Fi.create=t=>new Fi(t)});var Rl=me(Tl=>{"use strict";Object.defineProperty(Tl,"__esModule",{value:!0});var Ye=Qo(),jr=qi(),A0=(t,e)=>{let n;switch(t.code){case Ye.ZodIssueCode.invalid_type:t.received===jr.ZodParsedType.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case Ye.ZodIssueCode.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,jr.util.jsonStringifyReplacer)}`;break;case Ye.ZodIssueCode.unrecognized_keys:n=`Unrecognized key(s) in object: ${jr.util.joinValues(t.keys,", ")}`;break;case Ye.ZodIssueCode.invalid_union:n="Invalid input";break;case Ye.ZodIssueCode.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${jr.util.joinValues(t.options)}`;break;case Ye.ZodIssueCode.invalid_enum_value:n=`Invalid enum value. Expected ${jr.util.joinValues(t.options)}, received '${t.received}'`;break;case Ye.ZodIssueCode.invalid_arguments:n="Invalid function arguments";break;case Ye.ZodIssueCode.invalid_return_type:n="Invalid function return type";break;case Ye.ZodIssueCode.invalid_date:n="Invalid date";break;case Ye.ZodIssueCode.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:jr.util.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case Ye.ZodIssueCode.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case Ye.ZodIssueCode.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case Ye.ZodIssueCode.custom:n="Invalid input";break;case Ye.ZodIssueCode.invalid_intersection_types:n="Intersection results could not be merged";break;case Ye.ZodIssueCode.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case Ye.ZodIssueCode.not_finite:n="Number must be finite";break;default:n=e.defaultError,jr.util.assertNever(t)}return{message:n}};Tl.default=A0});var ea=me(Gn=>{"use strict";var $0=Gn&&Gn.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Gn,"__esModule",{value:!0});Gn.defaultErrorMap=void 0;Gn.setErrorMap=C0;Gn.getErrorMap=P0;var pp=$0(Rl());Gn.defaultErrorMap=pp.default;var fp=pp.default;function C0(t){fp=t}function P0(){return fp}});var El=me(ye=>{"use strict";var N0=ye&&ye.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(ye,"__esModule",{value:!0});ye.isAsync=ye.isValid=ye.isDirty=ye.isAborted=ye.OK=ye.DIRTY=ye.INVALID=ye.ParseStatus=ye.EMPTY_PATH=ye.makeIssue=void 0;ye.addIssueToContext=O0;var M0=ea(),mp=N0(Rl()),j0=t=>{let{data:e,path:n,errorMaps:r,issueData:s}=t,i=[...n,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let c="",l=r.filter(u=>!!u).slice().reverse();for(let u of l)c=u(a,{data:e,defaultError:c}).message;return{...s,path:i,message:c}};ye.makeIssue=j0;ye.EMPTY_PATH=[];function O0(t,e){let n=(0,M0.getErrorMap)(),r=(0,ye.makeIssue)({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===mp.default?void 0:mp.default].filter(s=>!!s)});t.common.issues.push(r)}var Il=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){let r=[];for(let s of n){if(s.status==="aborted")return ye.INVALID;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let s of n){let i=await s.key,a=await s.value;r.push({key:i,value:a})}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let s of n){let{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return ye.INVALID;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(r[i.value]=a.value)}return{status:e.value,value:r}}};ye.ParseStatus=Il;ye.INVALID=Object.freeze({status:"aborted"});var z0=t=>({status:"dirty",value:t});ye.DIRTY=z0;var D0=t=>({status:"valid",value:t});ye.OK=D0;var L0=t=>t.status==="aborted";ye.isAborted=L0;var U0=t=>t.status==="dirty";ye.isDirty=U0;var q0=t=>t.status==="valid";ye.isValid=q0;var F0=t=>typeof Promise<"u"&&t instanceof Promise;ye.isAsync=F0});var yp=me(gp=>{"use strict";Object.defineProperty(gp,"__esModule",{value:!0})});var wp=me(ta=>{"use strict";Object.defineProperty(ta,"__esModule",{value:!0});ta.errorUtil=void 0;var bp;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(bp||(ta.errorUtil=bp={}))});var Cp=me(R=>{"use strict";Object.defineProperty(R,"__esModule",{value:!0});R.discriminatedUnion=R.date=R.boolean=R.bigint=R.array=R.any=R.coerce=R.ZodFirstPartyTypeKind=R.late=R.ZodSchema=R.Schema=R.ZodReadonly=R.ZodPipeline=R.ZodBranded=R.BRAND=R.ZodNaN=R.ZodCatch=R.ZodDefault=R.ZodNullable=R.ZodOptional=R.ZodTransformer=R.ZodEffects=R.ZodPromise=R.ZodNativeEnum=R.ZodEnum=R.ZodLiteral=R.ZodLazy=R.ZodFunction=R.ZodSet=R.ZodMap=R.ZodRecord=R.ZodTuple=R.ZodIntersection=R.ZodDiscriminatedUnion=R.ZodUnion=R.ZodObject=R.ZodArray=R.ZodVoid=R.ZodNever=R.ZodUnknown=R.ZodAny=R.ZodNull=R.ZodUndefined=R.ZodSymbol=R.ZodDate=R.ZodBoolean=R.ZodBigInt=R.ZodNumber=R.ZodString=R.ZodType=void 0;R.NEVER=R.void=R.unknown=R.union=R.undefined=R.tuple=R.transformer=R.symbol=R.string=R.strictObject=R.set=R.record=R.promise=R.preprocess=R.pipeline=R.ostring=R.optional=R.onumber=R.oboolean=R.object=R.number=R.nullable=R.null=R.never=R.nativeEnum=R.nan=R.map=R.literal=R.lazy=R.intersection=R.instanceof=R.function=R.enum=R.effect=void 0;R.datetimeRegex=xp;R.custom=Rp;var q=Qo(),na=ea(),ee=wp(),I=El(),B=qi(),Tt=class{constructor(e,n,r,s){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},vp=(t,e)=>{if((0,I.isValid)(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let n=new q.ZodError(t.common.issues);return this._error=n,this._error}}};function ce(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:s}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,c)=>{let{message:l}=t;return a.code==="invalid_enum_value"?{message:l??c.defaultError}:typeof c.data>"u"?{message:l??r??c.defaultError}:a.code!=="invalid_type"?{message:c.defaultError}:{message:l??n??c.defaultError}},description:s}}var le=class{get description(){return this._def.description}_getType(e){return(0,B.getParsedType)(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:(0,B.getParsedType)(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new I.ParseStatus,ctx:{common:e.parent.common,data:e.data,parsedType:(0,B.getParsedType)(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if((0,I.isAsync)(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){let r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0,B.getParsedType)(e)},s=this._parseSync({data:e,path:r.path,parent:r});return vp(r,s)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0,B.getParsedType)(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return(0,I.isValid)(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(r=>(0,I.isValid)(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0,B.getParsedType)(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await((0,I.isAsync)(s)?s:Promise.resolve(s));return vp(r,i)}refine(e,n){let r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{let a=e(s),c=()=>i.addIssue({code:q.ZodIssueCode.custom,...r(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(l=>l?!0:(c(),!1)):a?!0:(c(),!1)})}refinement(e,n){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(e){return new ht({schema:this,typeName:se.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return xt.create(this,this._def)}nullable(){return tn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Tn.create(this)}promise(){return Yn.create(this,this._def)}or(e){return Fr.create([this,e],this._def)}and(e){return Br.create(this,e,this._def)}transform(e){return new ht({...ce(this._def),schema:this,typeName:se.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new Zr({...ce(this._def),innerType:this,defaultValue:n,typeName:se.ZodDefault})}brand(){return new Bi({typeName:se.ZodBranded,type:this,...ce(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new Vr({...ce(this._def),innerType:this,catchValue:n,typeName:se.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Hi.create(this,e)}readonly(){return Yr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};R.ZodType=le;R.Schema=le;R.ZodSchema=le;var B0=/^c[^\s-]{8,}$/i,H0=/^[0-9a-z]+$/,K0=/^[0-9A-HJKMNP-TV-Z]{26}$/i,W0=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,G0=/^[a-z0-9_-]{21}$/i,Z0=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,V0=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Y0=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,J0="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Al,X0=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Q0=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,eS=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,tS=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,nS=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,rS=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Sp="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",sS=new RegExp(`^${Sp}$`);function _p(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function iS(t){return new RegExp(`^${_p(t)}$`)}function xp(t){let e=`${Sp}T${_p(t)}`,n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function oS(t,e){return!!((e==="v4"||!e)&&X0.test(t)||(e==="v6"||!e)&&eS.test(t))}function aS(t,e){if(!Z0.test(t))return!1;try{let[n]=t.split(".");if(!n)return!1;let r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function cS(t,e){return!!((e==="v4"||!e)&&Q0.test(t)||(e==="v6"||!e)&&tS.test(t))}var Zn=class t extends le{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==B.ZodParsedType.string){let i=this._getOrReturnCtx(e);return(0,I.addIssueToContext)(i,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.string,received:i.parsedType}),I.INVALID}let r=new I.ParseStatus,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{code:q.ZodIssueCode.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{code:q.ZodIssueCode.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){let a=e.data.length>i.value,c=e.data.length<i.value;(a||c)&&(s=this._getOrReturnCtx(e,s),a?(0,I.addIssueToContext)(s,{code:q.ZodIssueCode.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):c&&(0,I.addIssueToContext)(s,{code:q.ZodIssueCode.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")Y0.test(e.data)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{validation:"email",code:q.ZodIssueCode.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Al||(Al=new RegExp(J0,"u")),Al.test(e.data)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{validation:"emoji",code:q.ZodIssueCode.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")W0.test(e.data)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{validation:"uuid",code:q.ZodIssueCode.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")G0.test(e.data)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{validation:"nanoid",code:q.ZodIssueCode.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")B0.test(e.data)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{validation:"cuid",code:q.ZodIssueCode.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")H0.test(e.data)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{validation:"cuid2",code:q.ZodIssueCode.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")K0.test(e.data)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{validation:"ulid",code:q.ZodIssueCode.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{validation:"url",code:q.ZodIssueCode.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{validation:"regex",code:q.ZodIssueCode.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{code:q.ZodIssueCode.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{code:q.ZodIssueCode.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{code:q.ZodIssueCode.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?xp(i).test(e.data)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{code:q.ZodIssueCode.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?sS.test(e.data)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{code:q.ZodIssueCode.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?iS(i).test(e.data)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{code:q.ZodIssueCode.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?V0.test(e.data)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{validation:"duration",code:q.ZodIssueCode.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?oS(e.data,i.version)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{validation:"ip",code:q.ZodIssueCode.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?aS(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{validation:"jwt",code:q.ZodIssueCode.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?cS(e.data,i.version)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{validation:"cidr",code:q.ZodIssueCode.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?nS.test(e.data)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{validation:"base64",code:q.ZodIssueCode.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?rS.test(e.data)||(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{validation:"base64url",code:q.ZodIssueCode.invalid_string,message:i.message}),r.dirty()):B.util.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(s=>e.test(s),{validation:n,code:q.ZodIssueCode.invalid_string,...ee.errorUtil.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...ee.errorUtil.errToObj(e)})}url(e){return this._addCheck({kind:"url",...ee.errorUtil.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...ee.errorUtil.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...ee.errorUtil.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...ee.errorUtil.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...ee.errorUtil.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...ee.errorUtil.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...ee.errorUtil.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...ee.errorUtil.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...ee.errorUtil.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...ee.errorUtil.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...ee.errorUtil.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...ee.errorUtil.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...ee.errorUtil.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...ee.errorUtil.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...ee.errorUtil.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...ee.errorUtil.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...ee.errorUtil.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...ee.errorUtil.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...ee.errorUtil.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...ee.errorUtil.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...ee.errorUtil.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...ee.errorUtil.errToObj(n)})}nonempty(e){return this.min(1,ee.errorUtil.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};R.ZodString=Zn;Zn.create=t=>new Zn({checks:[],typeName:se.ZodString,coerce:t?.coerce??!1,...ce(t)});function lS(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(t.toFixed(s).replace(".","")),a=Number.parseInt(e.toFixed(s).replace(".",""));return i%a/10**s}var Or=class t extends le{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==B.ZodParsedType.number){let i=this._getOrReturnCtx(e);return(0,I.addIssueToContext)(i,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.number,received:i.parsedType}),I.INVALID}let r,s=new I.ParseStatus;for(let i of this._def.checks)i.kind==="int"?B.util.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?lS(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.not_finite,message:i.message}),s.dirty()):B.util.assertNever(i);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,ee.errorUtil.toString(n))}gt(e,n){return this.setLimit("min",e,!1,ee.errorUtil.toString(n))}lte(e,n){return this.setLimit("max",e,!0,ee.errorUtil.toString(n))}lt(e,n){return this.setLimit("max",e,!1,ee.errorUtil.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:ee.errorUtil.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:ee.errorUtil.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ee.errorUtil.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ee.errorUtil.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ee.errorUtil.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ee.errorUtil.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:ee.errorUtil.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:ee.errorUtil.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ee.errorUtil.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ee.errorUtil.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&B.util.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}};R.ZodNumber=Or;Or.create=t=>new Or({checks:[],typeName:se.ZodNumber,coerce:t?.coerce||!1,...ce(t)});var zr=class t extends le{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==B.ZodParsedType.bigint)return this._getInvalidInput(e);let r,s=new I.ParseStatus;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):B.util.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return(0,I.addIssueToContext)(n,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.bigint,received:n.parsedType}),I.INVALID}gte(e,n){return this.setLimit("min",e,!0,ee.errorUtil.toString(n))}gt(e,n){return this.setLimit("min",e,!1,ee.errorUtil.toString(n))}lte(e,n){return this.setLimit("max",e,!0,ee.errorUtil.toString(n))}lt(e,n){return this.setLimit("max",e,!1,ee.errorUtil.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:ee.errorUtil.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ee.errorUtil.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ee.errorUtil.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ee.errorUtil.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ee.errorUtil.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:ee.errorUtil.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};R.ZodBigInt=zr;zr.create=t=>new zr({checks:[],typeName:se.ZodBigInt,coerce:t?.coerce??!1,...ce(t)});var Dr=class extends le{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==B.ZodParsedType.boolean){let r=this._getOrReturnCtx(e);return(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.boolean,received:r.parsedType}),I.INVALID}return(0,I.OK)(e.data)}};R.ZodBoolean=Dr;Dr.create=t=>new Dr({typeName:se.ZodBoolean,coerce:t?.coerce||!1,...ce(t)});var Lr=class t extends le{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==B.ZodParsedType.date){let i=this._getOrReturnCtx(e);return(0,I.addIssueToContext)(i,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.date,received:i.parsedType}),I.INVALID}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return(0,I.addIssueToContext)(i,{code:q.ZodIssueCode.invalid_date}),I.INVALID}let r=new I.ParseStatus,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{code:q.ZodIssueCode.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),(0,I.addIssueToContext)(s,{code:q.ZodIssueCode.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):B.util.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:ee.errorUtil.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:ee.errorUtil.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}};R.ZodDate=Lr;Lr.create=t=>new Lr({checks:[],coerce:t?.coerce||!1,typeName:se.ZodDate,...ce(t)});var Hs=class extends le{_parse(e){if(this._getType(e)!==B.ZodParsedType.symbol){let r=this._getOrReturnCtx(e);return(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.symbol,received:r.parsedType}),I.INVALID}return(0,I.OK)(e.data)}};R.ZodSymbol=Hs;Hs.create=t=>new Hs({typeName:se.ZodSymbol,...ce(t)});var Ur=class extends le{_parse(e){if(this._getType(e)!==B.ZodParsedType.undefined){let r=this._getOrReturnCtx(e);return(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.undefined,received:r.parsedType}),I.INVALID}return(0,I.OK)(e.data)}};R.ZodUndefined=Ur;Ur.create=t=>new Ur({typeName:se.ZodUndefined,...ce(t)});var qr=class extends le{_parse(e){if(this._getType(e)!==B.ZodParsedType.null){let r=this._getOrReturnCtx(e);return(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.null,received:r.parsedType}),I.INVALID}return(0,I.OK)(e.data)}};R.ZodNull=qr;qr.create=t=>new qr({typeName:se.ZodNull,...ce(t)});var Vn=class extends le{constructor(){super(...arguments),this._any=!0}_parse(e){return(0,I.OK)(e.data)}};R.ZodAny=Vn;Vn.create=t=>new Vn({typeName:se.ZodAny,...ce(t)});var xn=class extends le{constructor(){super(...arguments),this._unknown=!0}_parse(e){return(0,I.OK)(e.data)}};R.ZodUnknown=xn;xn.create=t=>new xn({typeName:se.ZodUnknown,...ce(t)});var qt=class extends le{_parse(e){let n=this._getOrReturnCtx(e);return(0,I.addIssueToContext)(n,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.never,received:n.parsedType}),I.INVALID}};R.ZodNever=qt;qt.create=t=>new qt({typeName:se.ZodNever,...ce(t)});var Ks=class extends le{_parse(e){if(this._getType(e)!==B.ZodParsedType.undefined){let r=this._getOrReturnCtx(e);return(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.void,received:r.parsedType}),I.INVALID}return(0,I.OK)(e.data)}};R.ZodVoid=Ks;Ks.create=t=>new Ks({typeName:se.ZodVoid,...ce(t)});var Tn=class t extends le{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==B.ZodParsedType.array)return(0,I.addIssueToContext)(n,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.array,received:n.parsedType}),I.INVALID;if(s.exactLength!==null){let a=n.data.length>s.exactLength.value,c=n.data.length<s.exactLength.value;(a||c)&&((0,I.addIssueToContext)(n,{code:a?q.ZodIssueCode.too_big:q.ZodIssueCode.too_small,minimum:c?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&((0,I.addIssueToContext)(n,{code:q.ZodIssueCode.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&((0,I.addIssueToContext)(n,{code:q.ZodIssueCode.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((a,c)=>s.type._parseAsync(new Tt(n,a,n.path,c)))).then(a=>I.ParseStatus.mergeArray(r,a));let i=[...n.data].map((a,c)=>s.type._parseSync(new Tt(n,a,n.path,c)));return I.ParseStatus.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:ee.errorUtil.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:ee.errorUtil.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:ee.errorUtil.toString(n)}})}nonempty(e){return this.min(1,e)}};R.ZodArray=Tn;Tn.create=(t,e)=>new Tn({type:t,minLength:null,maxLength:null,exactLength:null,typeName:se.ZodArray,...ce(e)});function Bs(t){if(t instanceof at){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=xt.create(Bs(r))}return new at({...t._def,shape:()=>e})}else return t instanceof Tn?new Tn({...t._def,type:Bs(t.element)}):t instanceof xt?xt.create(Bs(t.unwrap())):t instanceof tn?tn.create(Bs(t.unwrap())):t instanceof en?en.create(t.items.map(e=>Bs(e))):t}var at=class t extends le{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),n=B.util.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==B.ZodParsedType.object){let u=this._getOrReturnCtx(e);return(0,I.addIssueToContext)(u,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.object,received:u.parsedType}),I.INVALID}let{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),c=[];if(!(this._def.catchall instanceof qt&&this._def.unknownKeys==="strip"))for(let u in s.data)a.includes(u)||c.push(u);let l=[];for(let u of a){let p=i[u],f=s.data[u];l.push({key:{status:"valid",value:u},value:p._parse(new Tt(s,f,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof qt){let u=this._def.unknownKeys;if(u==="passthrough")for(let p of c)l.push({key:{status:"valid",value:p},value:{status:"valid",value:s.data[p]}});else if(u==="strict")c.length>0&&((0,I.addIssueToContext)(s,{code:q.ZodIssueCode.unrecognized_keys,keys:c}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let p of c){let f=s.data[p];l.push({key:{status:"valid",value:p},value:u._parse(new Tt(s,f,s.path,p)),alwaysSet:p in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let u=[];for(let p of l){let f=await p.key,g=await p.value;u.push({key:f,value:g,alwaysSet:p.alwaysSet})}return u}).then(u=>I.ParseStatus.mergeObjectSync(r,u)):I.ParseStatus.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return ee.errorUtil.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{let s=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:ee.errorUtil.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:se.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let n={};for(let r of B.util.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}omit(e){let n={};for(let r of B.util.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return Bs(this)}partial(e){let n={};for(let r of B.util.objectKeys(this.shape)){let s=this.shape[r];e&&!e[r]?n[r]=s:n[r]=s.optional()}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of B.util.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof xt;)i=i._def.innerType;n[r]=i}return new t({...this._def,shape:()=>n})}keyof(){return Tp(B.util.objectKeys(this.shape))}};R.ZodObject=at;at.create=(t,e)=>new at({shape:()=>t,unknownKeys:"strip",catchall:qt.create(),typeName:se.ZodObject,...ce(e)});at.strictCreate=(t,e)=>new at({shape:()=>t,unknownKeys:"strict",catchall:qt.create(),typeName:se.ZodObject,...ce(e)});at.lazycreate=(t,e)=>new at({shape:t,unknownKeys:"strip",catchall:qt.create(),typeName:se.ZodObject,...ce(e)});var Fr=class extends le{_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function s(i){for(let c of i)if(c.result.status==="valid")return c.result;for(let c of i)if(c.result.status==="dirty")return n.common.issues.push(...c.ctx.common.issues),c.result;let a=i.map(c=>new q.ZodError(c.ctx.common.issues));return(0,I.addIssueToContext)(n,{code:q.ZodIssueCode.invalid_union,unionErrors:a}),I.INVALID}if(n.common.async)return Promise.all(r.map(async i=>{let a={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:a}),ctx:a}})).then(s);{let i,a=[];for(let l of r){let u={...n,common:{...n.common,issues:[]},parent:null},p=l._parseSync({data:n.data,path:n.path,parent:u});if(p.status==="valid")return p;p.status==="dirty"&&!i&&(i={result:p,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;let c=a.map(l=>new q.ZodError(l));return(0,I.addIssueToContext)(n,{code:q.ZodIssueCode.invalid_union,unionErrors:c}),I.INVALID}}get options(){return this._def.options}};R.ZodUnion=Fr;Fr.create=(t,e)=>new Fr({options:t,typeName:se.ZodUnion,...ce(e)});var _n=t=>t instanceof Hr?_n(t.schema):t instanceof ht?_n(t.innerType()):t instanceof Kr?[t.value]:t instanceof Wr?t.options:t instanceof Gr?B.util.objectValues(t.enum):t instanceof Zr?_n(t._def.innerType):t instanceof Ur?[void 0]:t instanceof qr?[null]:t instanceof xt?[void 0,..._n(t.unwrap())]:t instanceof tn?[null,..._n(t.unwrap())]:t instanceof Bi||t instanceof Yr?_n(t.unwrap()):t instanceof Vr?_n(t._def.innerType):[],ra=class t extends le{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==B.ZodParsedType.object)return(0,I.addIssueToContext)(n,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.object,received:n.parsedType}),I.INVALID;let r=this.discriminator,s=n.data[r],i=this.optionsMap.get(s);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):((0,I.addIssueToContext)(n,{code:q.ZodIssueCode.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),I.INVALID)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let s=new Map;for(let i of n){let a=_n(i.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let c of a){if(s.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);s.set(c,i)}}return new t({typeName:se.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:s,...ce(r)})}};R.ZodDiscriminatedUnion=ra;function $l(t,e){let n=(0,B.getParsedType)(t),r=(0,B.getParsedType)(e);if(t===e)return{valid:!0,data:t};if(n===B.ZodParsedType.object&&r===B.ZodParsedType.object){let s=B.util.objectKeys(e),i=B.util.objectKeys(t).filter(c=>s.indexOf(c)!==-1),a={...t,...e};for(let c of i){let l=$l(t[c],e[c]);if(!l.valid)return{valid:!1};a[c]=l.data}return{valid:!0,data:a}}else if(n===B.ZodParsedType.array&&r===B.ZodParsedType.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let a=t[i],c=e[i],l=$l(a,c);if(!l.valid)return{valid:!1};s.push(l.data)}return{valid:!0,data:s}}else return n===B.ZodParsedType.date&&r===B.ZodParsedType.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var Br=class extends le{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=(i,a)=>{if((0,I.isAborted)(i)||(0,I.isAborted)(a))return I.INVALID;let c=$l(i.value,a.value);return c.valid?(((0,I.isDirty)(i)||(0,I.isDirty)(a))&&n.dirty(),{status:n.value,value:c.data}):((0,I.addIssueToContext)(r,{code:q.ZodIssueCode.invalid_intersection_types}),I.INVALID)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};R.ZodIntersection=Br;Br.create=(t,e,n)=>new Br({left:t,right:e,typeName:se.ZodIntersection,...ce(n)});var en=class t extends le{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==B.ZodParsedType.array)return(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.array,received:r.parsedType}),I.INVALID;if(r.data.length<this._def.items.length)return(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),I.INVALID;!this._def.rest&&r.data.length>this._def.items.length&&((0,I.addIssueToContext)(r,{code:q.ZodIssueCode.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let i=[...r.data].map((a,c)=>{let l=this._def.items[c]||this._def.rest;return l?l._parse(new Tt(r,a,r.path,c)):null}).filter(a=>!!a);return r.common.async?Promise.all(i).then(a=>I.ParseStatus.mergeArray(n,a)):I.ParseStatus.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};R.ZodTuple=en;en.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new en({items:t,typeName:se.ZodTuple,rest:null,...ce(e)})};var sa=class t extends le{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==B.ZodParsedType.object)return(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.object,received:r.parsedType}),I.INVALID;let s=[],i=this._def.keyType,a=this._def.valueType;for(let c in r.data)s.push({key:i._parse(new Tt(r,c,r.path,c)),value:a._parse(new Tt(r,r.data[c],r.path,c)),alwaysSet:c in r.data});return r.common.async?I.ParseStatus.mergeObjectAsync(n,s):I.ParseStatus.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof le?new t({keyType:e,valueType:n,typeName:se.ZodRecord,...ce(r)}):new t({keyType:Zn.create(),valueType:e,typeName:se.ZodRecord,...ce(n)})}};R.ZodRecord=sa;var Ws=class extends le{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==B.ZodParsedType.map)return(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.map,received:r.parsedType}),I.INVALID;let s=this._def.keyType,i=this._def.valueType,a=[...r.data.entries()].map(([c,l],u)=>({key:s._parse(new Tt(r,c,r.path,[u,"key"])),value:i._parse(new Tt(r,l,r.path,[u,"value"]))}));if(r.common.async){let c=new Map;return Promise.resolve().then(async()=>{for(let l of a){let u=await l.key,p=await l.value;if(u.status==="aborted"||p.status==="aborted")return I.INVALID;(u.status==="dirty"||p.status==="dirty")&&n.dirty(),c.set(u.value,p.value)}return{status:n.value,value:c}})}else{let c=new Map;for(let l of a){let u=l.key,p=l.value;if(u.status==="aborted"||p.status==="aborted")return I.INVALID;(u.status==="dirty"||p.status==="dirty")&&n.dirty(),c.set(u.value,p.value)}return{status:n.value,value:c}}}};R.ZodMap=Ws;Ws.create=(t,e,n)=>new Ws({valueType:e,keyType:t,typeName:se.ZodMap,...ce(n)});var Gs=class t extends le{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==B.ZodParsedType.set)return(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.set,received:r.parsedType}),I.INVALID;let s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&((0,I.addIssueToContext)(r,{code:q.ZodIssueCode.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&((0,I.addIssueToContext)(r,{code:q.ZodIssueCode.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());let i=this._def.valueType;function a(l){let u=new Set;for(let p of l){if(p.status==="aborted")return I.INVALID;p.status==="dirty"&&n.dirty(),u.add(p.value)}return{status:n.value,value:u}}let c=[...r.data.values()].map((l,u)=>i._parse(new Tt(r,l,r.path,u)));return r.common.async?Promise.all(c).then(l=>a(l)):a(c)}min(e,n){return new t({...this._def,minSize:{value:e,message:ee.errorUtil.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:ee.errorUtil.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};R.ZodSet=Gs;Gs.create=(t,e)=>new Gs({valueType:t,minSize:null,maxSize:null,typeName:se.ZodSet,...ce(e)});var ia=class t extends le{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==B.ZodParsedType.function)return(0,I.addIssueToContext)(n,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.function,received:n.parsedType}),I.INVALID;function r(c,l){return(0,I.makeIssue)({data:c,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,(0,na.getErrorMap)(),na.defaultErrorMap].filter(u=>!!u),issueData:{code:q.ZodIssueCode.invalid_arguments,argumentsError:l}})}function s(c,l){return(0,I.makeIssue)({data:c,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,(0,na.getErrorMap)(),na.defaultErrorMap].filter(u=>!!u),issueData:{code:q.ZodIssueCode.invalid_return_type,returnTypeError:l}})}let i={errorMap:n.common.contextualErrorMap},a=n.data;if(this._def.returns instanceof Yn){let c=this;return(0,I.OK)(async function(...l){let u=new q.ZodError([]),p=await c._def.args.parseAsync(l,i).catch(v=>{throw u.addIssue(r(l,v)),u}),f=await Reflect.apply(a,this,p);return await c._def.returns._def.type.parseAsync(f,i).catch(v=>{throw u.addIssue(s(f,v)),u})})}else{let c=this;return(0,I.OK)(function(...l){let u=c._def.args.safeParse(l,i);if(!u.success)throw new q.ZodError([r(l,u.error)]);let p=Reflect.apply(a,this,u.data),f=c._def.returns.safeParse(p,i);if(!f.success)throw new q.ZodError([s(p,f.error)]);return f.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:en.create(e).rest(xn.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new t({args:e||en.create([]).rest(xn.create()),returns:n||xn.create(),typeName:se.ZodFunction,...ce(r)})}};R.ZodFunction=ia;var Hr=class extends le{get schema(){return this._def.getter()}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};R.ZodLazy=Hr;Hr.create=(t,e)=>new Hr({getter:t,typeName:se.ZodLazy,...ce(e)});var Kr=class extends le{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return(0,I.addIssueToContext)(n,{received:n.data,code:q.ZodIssueCode.invalid_literal,expected:this._def.value}),I.INVALID}return{status:"valid",value:e.data}}get value(){return this._def.value}};R.ZodLiteral=Kr;Kr.create=(t,e)=>new Kr({value:t,typeName:se.ZodLiteral,...ce(e)});function Tp(t,e){return new Wr({values:t,typeName:se.ZodEnum,...ce(e)})}var Wr=class t extends le{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return(0,I.addIssueToContext)(n,{expected:B.util.joinValues(r),received:n.parsedType,code:q.ZodIssueCode.invalid_type}),I.INVALID}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),r=this._def.values;return(0,I.addIssueToContext)(n,{received:n.data,code:q.ZodIssueCode.invalid_enum_value,options:r}),I.INVALID}return(0,I.OK)(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}};R.ZodEnum=Wr;Wr.create=Tp;var Gr=class extends le{_parse(e){let n=B.util.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==B.ZodParsedType.string&&r.parsedType!==B.ZodParsedType.number){let s=B.util.objectValues(n);return(0,I.addIssueToContext)(r,{expected:B.util.joinValues(s),received:r.parsedType,code:q.ZodIssueCode.invalid_type}),I.INVALID}if(this._cache||(this._cache=new Set(B.util.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=B.util.objectValues(n);return(0,I.addIssueToContext)(r,{received:r.data,code:q.ZodIssueCode.invalid_enum_value,options:s}),I.INVALID}return(0,I.OK)(e.data)}get enum(){return this._def.values}};R.ZodNativeEnum=Gr;Gr.create=(t,e)=>new Gr({values:t,typeName:se.ZodNativeEnum,...ce(e)});var Yn=class extends le{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==B.ZodParsedType.promise&&n.common.async===!1)return(0,I.addIssueToContext)(n,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.promise,received:n.parsedType}),I.INVALID;let r=n.parsedType===B.ZodParsedType.promise?n.data:Promise.resolve(n.data);return(0,I.OK)(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}};R.ZodPromise=Yn;Yn.create=(t,e)=>new Yn({type:t,typeName:se.ZodPromise,...ce(e)});var ht=class extends le{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===se.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a=>{(0,I.addIssueToContext)(r,a),a.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let a=s.transform(r.data,i);if(r.common.async)return Promise.resolve(a).then(async c=>{if(n.value==="aborted")return I.INVALID;let l=await this._def.schema._parseAsync({data:c,path:r.path,parent:r});return l.status==="aborted"?I.INVALID:l.status==="dirty"||n.value==="dirty"?(0,I.DIRTY)(l.value):l});{if(n.value==="aborted")return I.INVALID;let c=this._def.schema._parseSync({data:a,path:r.path,parent:r});return c.status==="aborted"?I.INVALID:c.status==="dirty"||n.value==="dirty"?(0,I.DIRTY)(c.value):c}}if(s.type==="refinement"){let a=c=>{let l=s.refinement(c,i);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(r.common.async===!1){let c=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return c.status==="aborted"?I.INVALID:(c.status==="dirty"&&n.dirty(),a(c.value),{status:n.value,value:c.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(c=>c.status==="aborted"?I.INVALID:(c.status==="dirty"&&n.dirty(),a(c.value).then(()=>({status:n.value,value:c.value}))))}if(s.type==="transform")if(r.common.async===!1){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!(0,I.isValid)(a))return I.INVALID;let c=s.transform(a.value,i);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:c}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>(0,I.isValid)(a)?Promise.resolve(s.transform(a.value,i)).then(c=>({status:n.value,value:c})):I.INVALID);B.util.assertNever(s)}};R.ZodEffects=ht;R.ZodTransformer=ht;ht.create=(t,e,n)=>new ht({schema:t,typeName:se.ZodEffects,effect:e,...ce(n)});ht.createWithPreprocess=(t,e,n)=>new ht({schema:e,effect:{type:"preprocess",transform:t},typeName:se.ZodEffects,...ce(n)});var xt=class extends le{_parse(e){return this._getType(e)===B.ZodParsedType.undefined?(0,I.OK)(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};R.ZodOptional=xt;xt.create=(t,e)=>new xt({innerType:t,typeName:se.ZodOptional,...ce(e)});var tn=class extends le{_parse(e){return this._getType(e)===B.ZodParsedType.null?(0,I.OK)(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};R.ZodNullable=tn;tn.create=(t,e)=>new tn({innerType:t,typeName:se.ZodNullable,...ce(e)});var Zr=class extends le{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===B.ZodParsedType.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};R.ZodDefault=Zr;Zr.create=(t,e)=>new Zr({innerType:t,typeName:se.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ce(e)});var Vr=class extends le{_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return(0,I.isAsync)(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new q.ZodError(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new q.ZodError(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};R.ZodCatch=Vr;Vr.create=(t,e)=>new Vr({innerType:t,typeName:se.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ce(e)});var Zs=class extends le{_parse(e){if(this._getType(e)!==B.ZodParsedType.nan){let r=this._getOrReturnCtx(e);return(0,I.addIssueToContext)(r,{code:q.ZodIssueCode.invalid_type,expected:B.ZodParsedType.nan,received:r.parsedType}),I.INVALID}return{status:"valid",value:e.data}}};R.ZodNaN=Zs;Zs.create=t=>new Zs({typeName:se.ZodNaN,...ce(t)});R.BRAND=Symbol("zod_brand");var Bi=class extends le{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}};R.ZodBranded=Bi;var Hi=class t extends le{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?I.INVALID:i.status==="dirty"?(n.dirty(),(0,I.DIRTY)(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{let s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?I.INVALID:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:se.ZodPipeline})}};R.ZodPipeline=Hi;var Yr=class extends le{_parse(e){let n=this._def.innerType._parse(e),r=s=>((0,I.isValid)(s)&&(s.value=Object.freeze(s.value)),s);return(0,I.isAsync)(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}};R.ZodReadonly=Yr;Yr.create=(t,e)=>new Yr({innerType:t,typeName:se.ZodReadonly,...ce(e)});function kp(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function Rp(t,e={},n){return t?Vn.create().superRefine((r,s)=>{let i=t(r);if(i instanceof Promise)return i.then(a=>{if(!a){let c=kp(e,r),l=c.fatal??n??!0;s.addIssue({code:"custom",...c,fatal:l})}});if(!i){let a=kp(e,r),c=a.fatal??n??!0;s.addIssue({code:"custom",...a,fatal:c})}}):Vn.create()}R.late={object:at.lazycreate};var se;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(se||(R.ZodFirstPartyTypeKind=se={}));var uS=(t,e={message:`Input not instance of ${t.name}`})=>Rp(n=>n instanceof t,e);R.instanceof=uS;var Ip=Zn.create;R.string=Ip;var Ep=Or.create;R.number=Ep;var dS=Zs.create;R.nan=dS;var hS=zr.create;R.bigint=hS;var Ap=Dr.create;R.boolean=Ap;var pS=Lr.create;R.date=pS;var fS=Hs.create;R.symbol=fS;var mS=Ur.create;R.undefined=mS;var gS=qr.create;R.null=gS;var yS=Vn.create;R.any=yS;var bS=xn.create;R.unknown=bS;var wS=qt.create;R.never=wS;var vS=Ks.create;R.void=vS;var kS=Tn.create;R.array=kS;var SS=at.create;R.object=SS;var _S=at.strictCreate;R.strictObject=_S;var xS=Fr.create;R.union=xS;var TS=ra.create;R.discriminatedUnion=TS;var RS=Br.create;R.intersection=RS;var IS=en.create;R.tuple=IS;var ES=sa.create;R.record=ES;var AS=Ws.create;R.map=AS;var $S=Gs.create;R.set=$S;var CS=ia.create;R.function=CS;var PS=Hr.create;R.lazy=PS;var NS=Kr.create;R.literal=NS;var MS=Wr.create;R.enum=MS;var jS=Gr.create;R.nativeEnum=jS;var OS=Yn.create;R.promise=OS;var $p=ht.create;R.effect=$p;R.transformer=$p;var zS=xt.create;R.optional=zS;var DS=tn.create;R.nullable=DS;var LS=ht.createWithPreprocess;R.preprocess=LS;var US=Hi.create;R.pipeline=US;var qS=()=>Ip().optional();R.ostring=qS;var FS=()=>Ep().optional();R.onumber=FS;var BS=()=>Ap().optional();R.oboolean=BS;R.coerce={string:(t=>Zn.create({...t,coerce:!0})),number:(t=>Or.create({...t,coerce:!0})),boolean:(t=>Dr.create({...t,coerce:!0})),bigint:(t=>zr.create({...t,coerce:!0})),date:(t=>Lr.create({...t,coerce:!0}))};R.NEVER=I.INVALID});var Cl=me(Rt=>{"use strict";var HS=Rt&&Rt.__createBinding||(Object.create?(function(t,e,n,r){r===void 0&&(r=n);var s=Object.getOwnPropertyDescriptor(e,n);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,s)}):(function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]})),Vs=Rt&&Rt.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&HS(e,t,n)};Object.defineProperty(Rt,"__esModule",{value:!0});Vs(ea(),Rt);Vs(El(),Rt);Vs(yp(),Rt);Vs(qi(),Rt);Vs(Cp(),Rt);Vs(Qo(),Rt)});var Mp=me(ct=>{"use strict";var Pp=ct&&ct.__createBinding||(Object.create?(function(t,e,n,r){r===void 0&&(r=n);var s=Object.getOwnPropertyDescriptor(e,n);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,s)}):(function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]})),KS=ct&&ct.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),WS=ct&&ct.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var n in t)n!=="default"&&Object.prototype.hasOwnProperty.call(t,n)&&Pp(e,t,n);return KS(e,t),e},GS=ct&&ct.__exportStar||function(t,e){for(var n in t)n!=="default"&&!Object.prototype.hasOwnProperty.call(e,n)&&Pp(e,t,n)};Object.defineProperty(ct,"__esModule",{value:!0});ct.z=void 0;var Np=WS(Cl());ct.z=Np;GS(Cl(),ct);ct.default=Np});var Ne=me(h=>{"use strict";Object.defineProperty(h,"__esModule",{value:!0});h.RunContextMsg=h.FailedTest=h.RunUsageMsg=h.RunLogMsg=h.RunClaimMsg=h.HeartbeatMsg=h.HelloMsg=h.AiSpendMsg=h.AI_SPEND_SURFACES=h.MONITOR_CATALOG=h.MONITOR_BASELINE_TYPES=h.MONITOR_PARAM_SCHEMAS=h.MonitorCheckConfig=h.MonitorParseRules=h.MonitorCommand=h.MonitorSchedule=h.MonitorStatus=h.RuleConfig=h.PACK_CATALOG=h.ProjectConfig=h.ActionConfig=h.DeployAction=h.EnvironmentConfig=h.PromotionMode=h.DeployStep=h.RespondAction=h.ImplementAction=h.PlanOnlyAction=h.TriggerConfig=h.StatusChangedTrigger=h.CommentKeywordTrigger=h.LabelAddedTrigger=h.ActionType=h.TriggerType=h.ACTIVE_RUN_STATUSES=h.RunStatus=h.needsInputMarkerIn=h.LEGACY_NEEDS_INPUT_COMMENT_MARKERS=h.NEEDS_INPUT_COMMENT_MARKER=h.NEEDS_INPUT_LABEL=h.NEEDS_INPUT_ASK_FENCE=h.NEEDS_INPUT_MARKER=h.BRANCH_DEPLOY_ISSUE_KEY=h.REQUIRED_AGENT_CAPABILITIES=h.DEFAULT_AGENT_ID=h.REGISTERED_AGENTS=h.DEPLOY_DOC_CANDIDATES=h.RUNNER_UNINSTALL_COMMAND=h.PROTOCOL_VERSION=h.GITHUB_TOKEN_PERMISSIONS=void 0;h.ChatDiagnosticResultMsg=h.ChatDiagnosticMsg=h.AuditListResultMsg=h.AuditStatsResultMsg=h.AuditStatsMsg=h.AuditListMsg=h.AuditStartResultMsg=h.AuditStartMsg=h.AuditRecord=h.AuditFinding=h.AuditDetailLevel=h.AuditScope=h.AuditSeverity=h.KnowledgeRole=h.AuditRole=h.EpicSuggestResultMsg=h.EpicSuggestMsg=h.EpicListResultMsg=h.EpicChild=h.EpicListMsg=h.BoardTriggerResultMsg=h.BoardTriggerMsg=h.BoardFetchResultMsg=h.BoardFetchMsg=h.RepoDocReadResultMsg=h.RepoDocReadMsg=h.RepoDocsResultMsg=h.RepoDocsMsg=h.ChatLoadResultMsg=h.TICKET_RULES_APPENDIX=h.COMPOSE_COMMANDS=h.MAX_FAILURE_CHARS=h.MAX_FAILURE_LINES=h.FAILURE_BLOCK_LINES=h.FAILURE_CONTEXT_LINES=h.REPLY_STYLES=h.BUILTIN_REPLY_LANGUAGES=h.ChatLoadMsg=h.ChatListResultMsg=h.ChatListMsg=h.ChatSessionMsg=h.ChatActivityMsg=h.ChatUsageMsg=h.ChatStreamMsg=h.JiraUsersResultMsg=h.DeployClaimResultMsg=h.DeployClaimMsg=h.RuleDiagnoseResultMsg=h.ProjectTestResultMsg=h.RunStatusMsg=void 0;h.RunPrConflictMsg=h.RunResolveConflictResultMsg=h.RunAnswerResultMsg=h.RunAnswerMsg=h.RunTestFixResultMsg=h.RunTestFixMsg=h.RunResolveConflictMsg=h.RunnerUninstallMsg=h.RunnerUpdateMsg=h.RepoDocSaveResultMsg=h.RepoDocSaveMsg=h.SetupClaudeMdSaveResultMsg=h.SetupClaudeMdSaveMsg=h.SetupAskResultMsg=h.SetupAskMsg=h.SetupClaudeMdGenerateResultMsg=h.SetupClaudeMdGenerateMsg=h.SetupRecheckResultMsg=h.SetupRecheckMsg=h.RepoUnmapResultMsg=h.RepoUnmapMsg=h.SetupStatusResultMsg=h.SetupStatusMsg=h.DeploySuggestResultMsg=h.SelfMigrationApplyResultMsg=h.SelfMigrationApplyMsg=h.SELF_MIGRATION_DIR=h.EnvPreflightResultMsg=h.EnvPreflightMsg=h.ChatCreateTicketResultMsg=h.ChatCreateTicketMsg=h.ChatTurnResultMsg=h.ChatTurnMsg=h.ChatFile=h.TeamCredsResultMsg=h.TeamCredsMsg=h.KnowledgeSaveResultMsg=h.KnowledgeSaveMsg=h.KnowledgeListResultMsg=h.KnowledgeFile=h.KnowledgeListMsg=h.AuditReviewResultMsg=h.AuditReviewMsg=h.AuditGetResultMsg=h.AuditGetMsg=h.AuditExplainResultMsg=h.AuditExplainMsg=h.ChatCancelMsg=h.ChatStepRunResultMsg=h.ChatStepRunMsg=void 0;h.DeployFixMsg=h.DeployStartMsg=h.RunRetryPushMsg=h.RunRejectedMsg=h.RunApprovedMsg=h.RunCancelMsg=h.RuleDiagnoseMsg=h.ProjectTestMsg=h.RunClaimResultMsg=h.ConfigMsg=h.HelloAckMsg=h.RunnerToServerMsg=h.RebirthStudyResultMsg=h.RebirthStudyUpdateMsg=h.RebirthStudyMsg=h.TimelineDigestResultMsg=h.TimelineDigestMsg=h.RebirthDesignResultMsg=h.RebirthDesignMsg=h.RebirthUploadChunkResultMsg=h.RebirthUploadChunkMsg=h.RebirthUploadBeginResultMsg=h.RebirthUploadBeginMsg=h.SiteAuditResultMsg=h.SiteAuditMsg=h.ServerDecommissionProgressMsg=h.ServerDecommissionResultMsg=h.ServerDecommissionExecuteMsg=h.ServerDecommissionPlanResultMsg=h.ServerDecommissionPlanMsg=h.MonitorDiscoverResultMsg=h.MonitorDiscoverMsg=h.MonitorRebaselineResultMsg=h.MonitorRebaselineMsg=h.MonitorSuggestResultMsg=h.MonitorSuggestMsg=h.MonitorRunResultMsg=h.MonitorRunMsg=h.MonitorResultMsg=h.ServerInventoryResultMsg=h.ServerInventoryMsg=h.AutopilotReportMsg=h.AutopilotNextResultMsg=h.AutopilotPlanResultMsg=h.AutopilotPlanMsg=h.AutopilotNextMsg=h.RunnerUninstallResultMsg=h.RunnerUpdateResultMsg=h.AgentProfilesResultMsg=h.AgentProfilesMsg=void 0;h.DEFAULT_DEPLOY_SUGGEST_PROMPT_TEMPLATE=h.DEPLOY_DOC_SUGGEST_PROMPT_TEMPLATE=h.DEPLOY_FIX_PROMPT_TEMPLATE=h.PROMPT_PRESETS=h.DEFAULT_RESPOND_PROMPT_TEMPLATE=h.BUGFIX_IMPLEMENT_PROMPT_TEMPLATE=h.BUG_INVESTIGATION_PROMPT_TEMPLATE=h.TECHNICAL_PLAN_PROMPT_TEMPLATE=h.MEMORY_UPDATE_PROMPT=h.DEFAULT_IMPLEMENT_PROMPT_TEMPLATE=h.WRITE_TESTS_PROMPT=h.REVISION_PROMPT=h.FOCUSED_READING_PROMPT=h.NEEDS_INPUT_OPTIONS_PROMPT=h.DEFAULT_PLAN_PROMPT_TEMPLATE=h.EnrollResponse=h.EnrollRequest=h.ServerToRunnerMsg=h.JiraUsersMsg=h.DeploySuggestMsg=void 0;h.missingAgentCapabilities=ZS;h.replyPreferenceAppendix=YS;h.monitorChecksAppendix=JS;h.pendingMigrationsAppendix=XS;h.deployTargetsAppendix=QS;h.savedStepChecksAppendix=e_;h.failureCollector=jp;h.failureLines=s_;h.composeCommandAppendix=i_;h.isSelfMigrationFilename=o_;h.parseRunnerMsg=a_;h.parseServerMsg=c_;var o=Mp();h.GITHUB_TOKEN_PERMISSIONS={where:"github.com/settings/personal-access-tokens/new (fine-grained token)",steps:["Resource owner: the org or user that OWNS the repo - not your personal account, unless the repo is under it","Repository access: Only select repositories -> pick this repo","Contents: Read and write - pushing the agent's branch","Pull requests: Read and write - opening the PR, and merging it when you approve","Metadata: Read-only - GitHub adds this itself and will not let you remove it","Workflows: Read and write - ONLY if changes may touch .github/workflows; without it GitHub rejects those pushes"],note:"A fine-grained token covers exactly ONE resource owner, so a repo in a different org always needs its own token. A classic token with the `repo` scope also works and is simpler, but it reaches every repository you can see - prefer fine-grained."};h.PROTOCOL_VERSION="1.119";h.RUNNER_UNINSTALL_COMMAND="sudo allwright service uninstall";h.DEPLOY_DOC_CANDIDATES=[".ticketpilot/deploy.md","DEPLOY.md","DEPLOYMENT.md","docs/DEPLOY.md","docs/deploy.md","docs/deployment.md"];h.REGISTERED_AGENTS=[{id:"claude-code",displayName:"Claude Code",capabilities:{readOnlyJail:!0,editNoShellJail:!0,sessionResume:!0,costReporting:!0,modelSelection:!0,loginProfiles:!0,fullAccess:!0},suggestedModels:["claude-fable-5","claude-opus-5","claude-sonnet-5","claude-haiku-4-5-20251001"],experimental:!1},{id:"codex",displayName:"OpenAI Codex CLI (experimental)",capabilities:{readOnlyJail:!0,editNoShellJail:!1,sessionResume:!1,costReporting:!1,modelSelection:!0,loginProfiles:!1,fullAccess:!1},suggestedModels:[],experimental:!0},{id:"kimi",displayName:"Moonshot Kimi Code CLI",capabilities:{readOnlyJail:!0,editNoShellJail:!1,sessionResume:!0,costReporting:!1,modelSelection:!0,loginProfiles:!1,fullAccess:!1},suggestedModels:[],experimental:!0}];h.DEFAULT_AGENT_ID="claude-code";h.REQUIRED_AGENT_CAPABILITIES={plan_only:["readOnlyJail","sessionResume"],respond:["readOnlyJail"],implement:["editNoShellJail","sessionResume"],deploy:[],chat:["readOnlyJail","sessionResume"],assist:["readOnlyJail"],operator:["fullAccess","sessionResume"]};function ZS(t,e){let n=h.REGISTERED_AGENTS.find(r=>r.id===t);return n?(h.REQUIRED_AGENT_CAPABILITIES[e]??[]).filter(r=>!n.capabilities[r]):null}h.BRANCH_DEPLOY_ISSUE_KEY="(branch deploy)";h.NEEDS_INPUT_MARKER="NEEDS-INPUT";h.NEEDS_INPUT_ASK_FENCE="ask";h.NEEDS_INPUT_LABEL="agent-needs-input";h.NEEDS_INPUT_COMMENT_MARKER="Allwright needs your input";h.LEGACY_NEEDS_INPUT_COMMENT_MARKERS=["TicketPilot needs your input"];var VS=t=>t.includes(h.NEEDS_INPUT_COMMENT_MARKER)||h.LEGACY_NEEDS_INPUT_COMMENT_MARKERS.some(e=>t.includes(e));h.needsInputMarkerIn=VS;h.RunStatus=o.z.enum(["queued","running","posting","awaiting_approval","needs_input","succeeded","failed","timed_out"]);h.ACTIVE_RUN_STATUSES=["queued","running","posting","awaiting_approval"];h.TriggerType=o.z.enum(["label_added","comment_keyword","status_changed"]);h.ActionType=o.z.enum(["plan_only","implement","respond","deploy"]);h.LabelAddedTrigger=o.z.object({type:o.z.literal("label_added"),label:o.z.string().min(1),doneLabel:o.z.string().min(1).default("agent-planned"),failedLabel:o.z.string().min(1).default("agent-failed")});h.CommentKeywordTrigger=o.z.object({type:o.z.literal("comment_keyword"),keyword:o.z.string().min(1),doneLabel:o.z.string().min(1).default("agent-implemented"),failedLabel:o.z.string().min(1).default("agent-failed")});h.StatusChangedTrigger=o.z.object({type:o.z.literal("status_changed"),status:o.z.string().min(1),doneLabel:o.z.string().min(1).default("agent-deployed"),failedLabel:o.z.string().min(1).default("agent-failed")});h.TriggerConfig=o.z.discriminatedUnion("type",[h.LabelAddedTrigger,h.CommentKeywordTrigger,h.StatusChangedTrigger]);h.PlanOnlyAction=o.z.object({type:o.z.literal("plan_only"),promptTemplate:o.z.string().min(1),allowWeb:o.z.boolean().default(!1),timeoutSeconds:o.z.number().int().positive().max(3600).default(900),agent:o.z.string().default(h.DEFAULT_AGENT_ID),model:o.z.string().default("")});h.ImplementAction=o.z.object({type:o.z.literal("implement"),promptTemplate:o.z.string().min(1),timeoutSeconds:o.z.number().int().positive().max(7200).default(1800),maxTurns:o.z.number().int().positive().max(500).default(120),maxCostUsd:o.z.number().positive().optional(),requireApproval:o.z.boolean().default(!0),branchTemplate:o.z.string().min(1).default("agent/{{issueKey}}").refine(t=>t.includes("{{issueKey}}"),{message:"branchTemplate must contain {{issueKey}}"}),baseBranch:o.z.string().min(1).default("main"),jiraTransition:o.z.string().optional(),jiraTransitionOnStart:o.z.string().optional(),jiraTransitionOnMerge:o.z.string().optional(),agent:o.z.string().default(h.DEFAULT_AGENT_ID),model:o.z.string().default(""),updateMemory:o.z.boolean().default(!1),allowWeb:o.z.boolean().default(!1),writeTests:o.z.boolean().default(!0),runTests:o.z.boolean().default(!0),mergeOnApprove:o.z.boolean().default(!0),mergeMethod:o.z.enum(["squash","merge","rebase"]).default("squash"),autoMerge:o.z.boolean().default(!0)});h.RespondAction=o.z.object({type:o.z.literal("respond"),promptTemplate:o.z.string().min(1),timeoutSeconds:o.z.number().int().positive().max(3600).default(600),agent:o.z.string().default(h.DEFAULT_AGENT_ID),model:o.z.string().default("")});h.DeployStep=o.z.object({name:o.z.string().min(1).max(120),run:o.z.string().min(1).max(4e3),continueOnError:o.z.boolean().default(!1)});h.PromotionMode=o.z.enum(["deploy_only","merge_and_deploy"]);h.EnvironmentConfig=o.z.object({id:o.z.string(),projectId:o.z.string(),name:o.z.string(),rank:o.z.number().int().nonnegative(),auditBeforeDeploy:o.z.enum(["","security","testing"]).default(""),branch:o.z.string().default(""),publicUrl:o.z.string().default(""),servePath:o.z.string().default(""),useDedicatedCheckout:o.z.boolean().default(!1),promotionMode:h.PromotionMode.default("deploy_only"),ticketBranchTemplate:o.z.string().default("agent/{{issueKey}}"),steps:o.z.array(h.DeployStep).default([]),workdir:o.z.string().default(""),timeoutSeconds:o.z.number().int().positive().max(21600).default(1800),requiredSecrets:o.z.array(o.z.string()).default([]),requireApproval:o.z.boolean().default(!1),requireSyncCheck:o.z.boolean().default(!1),previousEnvBranch:o.z.string().optional(),deployFromColumn:o.z.string().default(""),deployToColumn:o.z.string().default("")});h.DeployAction=o.z.object({type:o.z.literal("deploy"),envSelection:o.z.enum(["fixed","from_comment"]).default("from_comment"),environmentId:o.z.string().optional(),requireStatus:o.z.string().optional()});h.ActionConfig=o.z.discriminatedUnion("type",[h.PlanOnlyAction,h.ImplementAction,h.RespondAction,h.DeployAction]);h.ProjectConfig=o.z.object({id:o.z.string(),name:o.z.string(),jiraProjectKey:o.z.string(),goLiveIssueKey:o.z.string().default(""),repoName:o.z.string(),jiraSiteUrl:o.z.string().default(""),defaultAgent:o.z.string().default("claude-code"),componentRoutes:o.z.array(o.z.object({component:o.z.string().min(1),repoName:o.z.string().min(1)})).default([]),packs:o.z.array(o.z.string().max(60)).max(40).default([])});h.PACK_CATALOG=[{id:"owasp",title:"OWASP Top 10",kind:"compliance",description:"Security audits cite OWASP Top 10 (2021) categories - findings carry OWASP-A01\u2026A10 ids.",roles:["security"]},{id:"pci-dss",title:"PCI DSS",kind:"compliance",description:"Payment-card compliance: findings cite PCI DSS requirement numbers (PCI-3.x, PCI-6.x\u2026).",roles:["security"]},{id:"laravel",title:"Laravel conventions",kind:"stack",description:"Laravel-specific rules for implement runs and architecture audits.",roles:["implement","architecture"]},{id:"react",title:"React conventions",kind:"stack",description:"React/Next-specific rules for implement runs and architecture audits.",roles:["implement","architecture"]},{id:"node",title:"Node.js backend conventions",kind:"stack",description:"Node/Express/Nest backend rules for implement runs and architecture audits.",roles:["implement","architecture"]}];h.RuleConfig=o.z.object({id:o.z.string(),projectId:o.z.string(),name:o.z.string(),enabled:o.z.boolean(),trigger:h.TriggerConfig,action:h.ActionConfig});h.MonitorStatus=o.z.enum(["green","amber","red","error","skipped"]);h.MonitorSchedule=o.z.discriminatedUnion("kind",[o.z.object({kind:o.z.literal("every"),minutes:o.z.number().int().min(1).max(1440)}),o.z.object({kind:o.z.literal("daily"),at:o.z.string().regex(/^\d{2}:\d{2}$/)}),o.z.object({kind:o.z.literal("weekly"),day:o.z.number().int().min(0).max(6),at:o.z.string().regex(/^\d{2}:\d{2}$/)})]);h.MonitorCommand=o.z.object({name:o.z.string().min(1).max(120),run:o.z.string().min(1).max(4e3)});h.MonitorParseRules=o.z.object({amberPattern:o.z.string().max(400).default(""),redPattern:o.z.string().max(400).default(""),greenRequires:o.z.string().max(400).default("")});h.MonitorCheckConfig=o.z.object({id:o.z.string(),type:o.z.string().max(60),name:o.z.string().min(1).max(120),projectId:o.z.string().default(""),params:o.z.record(o.z.unknown()).default({}),schedule:h.MonitorSchedule,shell:o.z.enum(["bash","powershell"]).default("bash"),commands:o.z.array(h.MonitorCommand).max(20).default([]),parseRules:h.MonitorParseRules.default({}),enabled:o.z.boolean().default(!0),jiraNotify:o.z.boolean().default(!1)});h.MONITOR_PARAM_SCHEMAS={disk_space:o.z.object({warnPct:o.z.number().int().min(1).max(99).default(80),critPct:o.z.number().int().min(1).max(99).default(90),mounts:o.z.array(o.z.string().max(300)).max(20).default([])}),memory:o.z.object({warnPct:o.z.number().int().min(1).max(99).default(85),critPct:o.z.number().int().min(1).max(99).default(95)}),cpu_load:o.z.object({warnPerCore:o.z.number().positive().max(64).default(2),critPerCore:o.z.number().positive().max(64).default(4)}),uptime_reboot:o.z.object({maxUptimeDays:o.z.number().int().positive().max(3650).default(180)}),services:o.z.object({names:o.z.array(o.z.string().min(1).max(120)).min(1).max(40)}),http_check:o.z.object({url:o.z.string().min(1).max(500),expectStatus:o.z.number().int().min(100).max(599).default(200),expectString:o.z.string().max(200).default(""),warnMs:o.z.number().int().positive().max(6e4).default(2e3),timeoutMs:o.z.number().int().positive().max(6e4).default(1e4)}),tls_cert:o.z.object({domains:o.z.array(o.z.string().min(1).max(253)).min(1).max(40),warnDays:o.z.number().int().min(1).max(365).default(21),critDays:o.z.number().int().min(0).max(364).default(7)}),sites:o.z.object({extraHosts:o.z.array(o.z.string().min(1).max(253)).max(30).default([]),excludeHosts:o.z.array(o.z.string().min(1).max(253)).max(30).default([]),warnMs:o.z.number().int().positive().max(6e4).default(3e3),certWarnDays:o.z.number().int().min(1).max(365).default(21),certCritDays:o.z.number().int().min(0).max(364).default(7)}),db_health:o.z.object({repoName:o.z.string().min(1).max(200),envName:o.z.string().min(1).max(100),secretName:o.z.string().min(1).max(100).default("DATABASE_URL"),warnConnections:o.z.number().int().positive().max(1e4).default(50),longQuerySeconds:o.z.number().int().positive().max(3600).default(60)}),docker_containers:o.z.object({expected:o.z.array(o.z.string().min(1).max(120)).max(40).default([])}),log_scan:o.z.object({files:o.z.array(o.z.string().min(1).max(400)).min(1).max(10),hardPatterns:o.z.array(o.z.string().max(200)).max(10).default(["oom-killer","kernel panic","segfault"]),errorPattern:o.z.string().max(200).default("\\b(error|fatal)\\b"),warnCount:o.z.number().int().positive().max(1e5).default(50),tailKB:o.z.number().int().min(16).max(1024).default(256)}),backup_freshness:o.z.object({noBackups:o.z.boolean().default(!1),targets:o.z.array(o.z.object({pathGlob:o.z.string().min(1).max(500),maxAgeHours:o.z.number().positive().max(2160).default(26),minSizeMB:o.z.number().nonnegative().max(1e6).default(1)})).max(20).default([])}),ports_baseline:o.z.object({}),users_baseline:o.z.object({}),cron_baseline:o.z.object({}),auth_activity:o.z.object({failedWarnCount:o.z.number().int().positive().max(1e5).default(100)}),webroot_integrity:o.z.object({roots:o.z.array(o.z.string().min(1).max(400)).min(1).max(10),excludes:o.z.array(o.z.string().min(1).max(200)).max(20).default(["node_modules",".git","cache","wp-content/uploads",".next","vendor"])}),wordpress:o.z.object({wpPaths:o.z.array(o.z.string().min(1).max(400)).min(1).max(10)}),process_hog:o.z.object({cpuPct:o.z.number().min(1).max(100).default(80)}),windows_update:o.z.object({maxHotfixAgeDays:o.z.number().int().positive().max(3650).default(60)}),custom:o.z.object({})};h.MONITOR_BASELINE_TYPES=["ports_baseline","users_baseline","cron_baseline","auth_activity","webroot_integrity","wordpress"];h.MONITOR_CATALOG=[{id:"disk_space",title:"Disk space",group:"health",question:"Is any filesystem filling up?",os:"both",minMinutes:5,defaultSchedule:{kind:"every",minutes:15}},{id:"memory",title:"Memory & swap",group:"health",question:"Is the machine under memory pressure?",os:"both",minMinutes:5,defaultSchedule:{kind:"every",minutes:15}},{id:"cpu_load",title:"CPU load",group:"health",question:"Is the load average sustainably high?",os:"linux",minMinutes:5,defaultSchedule:{kind:"every",minutes:15}},{id:"uptime_reboot",title:"Uptime & pending restart",group:"health",question:"When did this box last boot, and does the OS want a reboot?",os:"linux",minMinutes:60,defaultSchedule:{kind:"daily",at:"06:00"}},{id:"services",title:"Services running",group:"health",question:"Are these named services active?",os:"linux",minMinutes:5,defaultSchedule:{kind:"every",minutes:5}},{id:"http_check",title:"HTTP check",group:"web",question:"Does this URL answer correctly, and fast enough?",os:"both",minMinutes:1,defaultSchedule:{kind:"every",minutes:5}},{id:"tls_cert",title:"TLS certificate expiry",group:"web",question:"How many days are left on these certificates?",os:"both",minMinutes:60,defaultSchedule:{kind:"daily",at:"07:00"}},{id:"backup_freshness",title:"Backup freshness",group:"backups",question:"Did a fresh, healthy-sized backup actually appear?",os:"both",minMinutes:60,defaultSchedule:{kind:"daily",at:"08:00"}},{id:"sites",title:"Sites this box serves",group:"web",question:"Every nginx/caddy/IIS vhost, live-probed: up, fast, certified?",os:"both",minMinutes:5,defaultSchedule:{kind:"every",minutes:15}},{id:"db_health",title:"Database health",group:"db",question:"Reachable, size, connections, long-running queries?",os:"linux",minMinutes:5,defaultSchedule:{kind:"every",minutes:30}},{id:"docker_containers",title:"Docker containers",group:"health",question:"Are the containers running - and staying up?",os:"linux",minMinutes:5,defaultSchedule:{kind:"every",minutes:5}},{id:"log_scan",title:"Log scan",group:"health",question:"Are named logs quiet - no OOM kills, no error spikes?",os:"linux",minMinutes:15,defaultSchedule:{kind:"every",minutes:60}},{id:"ports_baseline",title:"Listening ports vs baseline",group:"security",question:"Did a new port start listening that no one vouched for?",os:"both",minMinutes:30,defaultSchedule:{kind:"every",minutes:60}},{id:"users_baseline",title:"System users vs baseline",group:"security",question:"Did a new account appear - especially a root-level one?",os:"linux",minMinutes:60,defaultSchedule:{kind:"daily",at:"05:00"}},{id:"cron_baseline",title:"Cron vs baseline",group:"security",question:"Did any crontab change since a human last accepted it?",os:"linux",minMinutes:60,defaultSchedule:{kind:"daily",at:"05:10"}},{id:"auth_activity",title:"SSH & access grants",group:"security",question:"Brute-force spikes; new authorized_keys or sudoers grants?",os:"linux",minMinutes:30,defaultSchedule:{kind:"every",minutes:60}},{id:"webroot_integrity",title:"Webroot integrity",group:"security",question:"Did site files change outside a deploy?",os:"linux",minMinutes:60,defaultSchedule:{kind:"daily",at:"05:20"}},{id:"wordpress",title:"WordPress compromise signals",group:"security",question:"Core checksums, PHP in uploads, new admin users?",os:"linux",minMinutes:60,defaultSchedule:{kind:"daily",at:"05:30"}},{id:"process_hog",title:"Runaway process",group:"security",question:"Is something eating the CPU - from a location it shouldn't?",os:"linux",minMinutes:15,defaultSchedule:{kind:"every",minutes:30}},{id:"windows_update",title:"Windows updates",group:"health",question:"Pending reboot; how stale is the newest hotfix?",os:"windows",minMinutes:60,defaultSchedule:{kind:"daily",at:"06:30"}},{id:"custom",title:"Custom check",group:"custom",question:"Your own saved commands - exit code decides, patterns refine.",os:"both",minMinutes:5,defaultSchedule:{kind:"daily",at:"06:00"}}];h.AI_SPEND_SURFACES=[{id:"run_plan",label:"Plan runs",group:"people"},{id:"run_implement",label:"Implement runs",group:"people"},{id:"run_respond",label:"Ticket answers",group:"people"},{id:"run_testfix",label:"Test fixes",group:"people"},{id:"run_conflict_resolve",label:"Conflict resolves",group:"people"},{id:"chat_turn",label:"Compose chat",group:"people"},{id:"audit",label:"Audits",group:"people"},{id:"audit_explain",label:"Audit explanations",group:"people"},{id:"rebirth_study",label:"Rebirth studies",group:"people"},{id:"rebirth_refold",label:"Rebirth refolds",group:"people"},{id:"rebirth_design",label:"Rebirth design passes",group:"people"},{id:"rebirth_techstack",label:"Rebirth tech-stack passes",group:"people"},{id:"deploy_fix",label:"Deploy-failure diagnoses",group:"people"},{id:"deploy_suggest",label:"Deploy step proposals",group:"people"},{id:"setup_docs",label:"Setup doc drafting",group:"people"},{id:"setup_ask",label:"Setup questions",group:"people"},{id:"incident_diagnosis",label:"Incident diagnoses",group:"people"},{id:"monitor_suggest",label:"Check proposals",group:"people"},{id:"chat_compact",label:"Chat compaction",group:"platform"},{id:"chat_capsule",label:"Ticket context capsules",group:"platform"},{id:"repo_brief",label:"Repo briefs",group:"platform"},{id:"timeline_digest",label:"Timeline digests",group:"platform"},{id:"autopilot_plan",label:"Autopilot planning",group:"platform"},{id:"epic_suggest",label:"Epic suggestions",group:"platform"}];h.AiSpendMsg=o.z.object({type:o.z.literal("ai.spend"),eventKey:o.z.string().min(1).max(200),surface:o.z.string().max(60),projectId:o.z.string().default(""),userId:o.z.string().default(""),agentId:o.z.string().default(""),model:o.z.string().max(200).default(""),billingMode:o.z.string().max(20).default(""),claudeProfile:o.z.string().max(200).default(""),inputTokens:o.z.number().int().nonnegative().default(0),outputTokens:o.z.number().int().nonnegative().default(0),cacheReadTokens:o.z.number().int().nonnegative().default(0),costUsd:o.z.number().nonnegative().default(0),turns:o.z.number().int().nonnegative().default(0),refKind:o.z.string().max(20).default(""),refId:o.z.string().max(200).default(""),refLabel:o.z.string().max(200).default(""),at:o.z.string().default("")});h.HelloMsg=o.z.object({type:o.z.literal("hello"),protocolVersion:o.z.string(),runnerVersion:o.z.string(),platform:o.z.string(),justBooted:o.z.boolean().optional()});h.HeartbeatMsg=o.z.object({type:o.z.literal("heartbeat"),ts:o.z.string()});h.RunClaimMsg=o.z.object({type:o.z.literal("run.claim"),requestId:o.z.string(),ruleId:o.z.string(),issueKey:o.z.string(),issueSummary:o.z.string().default(""),triggerFingerprint:o.z.string(),dedupKey:o.z.string().optional(),triggeredByAccountId:o.z.string().optional()});h.RunLogMsg=o.z.object({type:o.z.literal("run.log"),runId:o.z.string(),seq:o.z.number().int().nonnegative(),ts:o.z.string(),level:o.z.enum(["info","warn","error","agent"]),message:o.z.string().max(16384)});h.RunUsageMsg=o.z.object({type:o.z.literal("run.usage"),runId:o.z.string(),inputTokens:o.z.number().int().nonnegative(),outputTokens:o.z.number().int().nonnegative(),cacheReadTokens:o.z.number().int().nonnegative().optional(),costUsd:o.z.number().nonnegative().optional(),turns:o.z.number().int().nonnegative().optional()});h.FailedTest=o.z.object({command:o.z.string().max(500),exitCode:o.z.number().int(),tail:o.z.string().max(4e3)});h.RunContextMsg=o.z.object({type:o.z.literal("run.context"),runId:o.z.string(),pieces:o.z.array(o.z.object({part:o.z.string().max(80),chars:o.z.number().int().nonnegative()})).max(30),totalChars:o.z.number().int().nonnegative(),sessionMode:o.z.enum(["fresh","chained","timeout-resume","preflight-resume"])});h.RunStatusMsg=o.z.object({type:o.z.literal("run.status"),runId:o.z.string(),status:h.RunStatus,error:o.z.string().optional(),note:o.z.string().max(300).optional(),errorKind:o.z.enum(["guard"]).optional(),costUsd:o.z.number().nonnegative().optional(),inputTokens:o.z.number().int().nonnegative().optional(),outputTokens:o.z.number().int().nonnegative().optional(),cacheReadTokens:o.z.number().int().nonnegative().optional(),resultSummary:o.z.string().max(2e3).optional(),billingMode:o.z.enum(["subscription","api","unknown"]).optional(),model:o.z.string().max(200).optional(),prUrl:o.z.string().optional(),headSha:o.z.string().optional(),deployedRef:o.z.string().optional(),retryAvailable:o.z.boolean().optional(),failedTests:o.z.array(h.FailedTest).max(20).optional(),testsPassed:o.z.number().int().nonnegative().optional(),testsTotal:o.z.number().int().nonnegative().optional(),manualSteps:o.z.array(o.z.object({command:o.z.string().max(500),why:o.z.string().max(300).default("")})).max(20).optional(),goLiveDraft:o.z.string().max(4e3).optional(),inputQuestions:o.z.string().max(4e3).optional(),inputOptions:o.z.array(o.z.string().max(200)).max(5).optional()});h.ProjectTestResultMsg=o.z.object({type:o.z.literal("project.test.result"),requestId:o.z.string(),ok:o.z.boolean(),checks:o.z.array(o.z.object({name:o.z.string(),ok:o.z.boolean(),detail:o.z.string(),kind:o.z.enum(["connection","content"]).default("connection"),fix:o.z.array(o.z.string()).default([]),fixNote:o.z.string().default("")}))});h.RuleDiagnoseResultMsg=o.z.object({type:o.z.literal("rule.diagnose.result"),requestId:o.z.string(),checks:o.z.array(o.z.object({name:o.z.string(),ok:o.z.boolean(),detail:o.z.string(),kind:o.z.enum(["connection","content"]).default("connection"),fix:o.z.array(o.z.string()).default([]),fixNote:o.z.string().default("")})),matchedCount:o.z.number().int().nonnegative(),excludedCount:o.z.number().int().nonnegative(),excludedSample:o.z.array(o.z.string()).max(5)});h.DeployClaimMsg=o.z.object({type:o.z.literal("deploy.claim"),requestId:o.z.string(),projectId:o.z.string(),ruleId:o.z.string(),issueKey:o.z.string(),issueSummary:o.z.string().default(""),environmentName:o.z.string(),requestedByAccountId:o.z.string().optional(),requestedByDisplayName:o.z.string().default(""),dedupKey:o.z.string(),triggerFingerprint:o.z.string()});h.DeployClaimResultMsg=o.z.object({type:o.z.literal("deploy.claim.result"),requestId:o.z.string(),accepted:o.z.boolean(),runId:o.z.string().optional(),environment:h.EnvironmentConfig.optional(),reason:o.z.string().optional(),code:o.z.enum(["ok","duplicate","unknown_environment","not_permitted","unlinked_jira_account","promotion_order","jira_disabled","rule_disabled","cap"]).optional()});h.JiraUsersResultMsg=o.z.object({type:o.z.literal("jira.users.result"),requestId:o.z.string(),ok:o.z.boolean(),users:o.z.array(o.z.object({accountId:o.z.string(),displayName:o.z.string(),email:o.z.string().default(""),active:o.z.boolean().default(!0)})).default([]),error:o.z.string().optional()});h.ChatStreamMsg=o.z.object({type:o.z.literal("chat.stream"),requestId:o.z.string(),seq:o.z.number().int().nonnegative(),text:o.z.string().max(8e3)});h.ChatUsageMsg=o.z.object({type:o.z.literal("chat.usage"),requestId:o.z.string(),inputTokens:o.z.number().int().nonnegative(),outputTokens:o.z.number().int().nonnegative(),cacheReadTokens:o.z.number().int().nonnegative().optional(),turns:o.z.number().int().nonnegative().optional()});h.ChatActivityMsg=o.z.object({type:o.z.literal("chat.activity"),requestId:o.z.string(),seq:o.z.number().int().nonnegative(),verb:o.z.string().max(40),target:o.z.string().max(200).default("")});h.ChatSessionMsg=o.z.object({type:o.z.literal("chat.session"),requestId:o.z.string(),sessionId:o.z.string()});h.ChatListMsg=o.z.object({type:o.z.literal("chat.list"),requestId:o.z.string(),projectId:o.z.string()});h.ChatListResultMsg=o.z.object({type:o.z.literal("chat.list.result"),requestId:o.z.string(),sessions:o.z.array(o.z.object({sessionId:o.z.string(),title:o.z.string().default(""),updatedAt:o.z.string().default(""),messageCount:o.z.number().int().nonnegative().default(0),ownerUserId:o.z.string().default(""),agentId:o.z.string().default("")})).default([])});h.ChatLoadMsg=o.z.object({type:o.z.literal("chat.load"),requestId:o.z.string(),sessionId:o.z.string()});h.BUILTIN_REPLY_LANGUAGES=[{name:"English",instruction:"Write your prose in English."},{name:"Hindi",instruction:"Write your prose in Hindi, in the Devanagari script. Keep technical terms that have no everyday Hindi equivalent in English rather than inventing a translation."},{name:"Hinglish",instruction:"Write your prose in Hinglish: conversational Hindi written in the Latin alphabet, with English technical words left in English - the way an Indian developer talks at work."}];h.REPLY_STYLES=[{id:"technical",label:"Technical",hint:"Full detail - names files, functions and trade-offs",instruction:"Answer at full technical depth: name the files, functions and data structures involved, and state trade-offs precisely. Assume the reader reads code every day."},{id:"balanced",label:"Balanced",hint:"Plain explanation, with the technical detail that matters",instruction:"Explain in plain language first, then add the technical detail that actually matters for the decision. Assume the reader is technical but does not know this codebase."},{id:"simple",label:"Simple",hint:"Everyday words - no jargon unless it is unavoidable",instruction:"Answer in everyday words, as if to someone who does not write code. Avoid jargon; when a technical term is unavoidable, explain it in half a sentence. Prefer short paragraphs and concrete examples over precision about internals."}];function YS(t){let e=[],n=(t.language??"").trim();if(n){let s=h.BUILTIN_REPLY_LANGUAGES.find(i=>i.name.toLowerCase()===n.toLowerCase());e.push((t.languageInstruction??"").trim()||s?.instruction||`Write your prose in ${n}.`),e.push("Code, file paths, identifiers, commands, error text and log output stay exactly as they are - only your own prose changes language."),e.push("The ```ticket block is the exception: its summary and description are ALWAYS written in English, because the ticket is read by other people and by the implementing agent.")}let r=h.REPLY_STYLES.find(s=>s.id===(t.style??"").trim());return r&&e.push(r.instruction),e.length?`
25
25
 
26
26
  HOW TO WRITE THE REPLY - the person you are answering chose this, so it applies to every reply in this conversation:
27
27
  - ${e.join(`
@@ -68,7 +68,7 @@ Rules, and they are hard ones. Only ask for a step that CHECKS something - a tes
68
68
 
69
69
  WHAT THIS TURN IS FOR (the user chose "/${e.name}"):
70
70
  ${e.instruction}
71
- `:""}h.TICKET_RULES_APPENDIX='\n\nONLY when the user explicitly asks for a ticket, propose it by ending your reply with EXACTLY one fenced block in this shape:\n```ticket\n{"summary": "\u2026", "description": "\u2026"}\n```\nBefore drafting, re-read this ENTIRE conversation from its first message and fold in every decision, constraint, and correction agreed along the way - the ticket reflects the final state of the whole discussion, not just the last message.\nRIGHT-SIZE every ticket - it is a work order for ONE agent run. One ticket = one concern: a single feature, fix or change an engineer would land as one reviewable PR. The test for TOO BIG: the summary needs an "and", the Expected Flow forks into unrelated flows, or the acceptance criteria span unrelated screens or modules - split there, into an epic batch if the pieces belong together. Queued tickets share a warm agent session and one branch, so splitting is cheap; an oversized ticket is the single biggest driver of runaway agent cost and un-reviewable diffs. Trivial same-file touches (a rename plus its comment) stay together - splitting has to buy a smaller review, not ceremony. If the user explicitly asks to split or to merge, their word wins.\nWrite the description in plain human language, structured with these Markdown section headings in this order:\nStory: - one or two sentences: who needs this and why.\nDescription: - what to build and WHERE, as bullet points that name exact files, directories or symbols whenever the conversation or repo makes them known - the implementing agent starts cold, and every named path saves it a paid search.\nExpected Flow: - the flow once this ticket is done, as numbered steps.\nCurrent Flow: - how it behaves today; include ONLY when current behavior exists.\nAcceptance Criteria: - testable bullet points a reviewer can check off one by one.\nInclude a section only when it carries real content, and add extra sections (Out of Scope, Notes, \u2026) when the work genuinely needs them. Use as many bullets as the work needs - no artificial length cap, but no padding either. It must stay concrete enough that a developer (or an agent) can implement it without asking questions. NEVER paste the conversation into the description; distill it. Refine the draft over further turns if the user asks.\nTHE READER IS A COLD AGENT: whoever implements this sees the ticket alone, never this conversation. Anything that is obvious only from the chat must be written into the ticket; anything the repo already documents is referenced by path, not restated.\nEXCEPTION - verbatim payloads: when the user supplies literal content that must land in the ticket exactly (file contents, error logs, specs, commands), include it in the description IN FULL inside a fenced code block - the word budget applies to your own prose around it, never to the user\'s payload. Never summarize such content and never replace it with a placeholder like "[insert content here]": a placeholder makes the ticket unimplementable, because the implementing agent only ever sees the ticket. Inside the ```ticket JSON, fence such payloads with ~~~ (tildes), NEVER with triple backticks - a nested ``` would end the outer block early and corrupt the draft.\nEXCEPTION - several tickets at once: when the user asks for more than one ticket, asks for an epic with sub-tickets, or asks to ticket something clearly too large for one ticket, break it down and emit ONE ```ticket block of this shape:\n{"tickets": [{"summary": "\u2026", "description": "\u2026"}, \u2026]}\nAdd an "epic" key ONLY when the pieces genuinely belong under one parent goal:\n{"epic": {"summary": "\u2026", "description": "\u2026"}, "tickets": [ \u2026 ]}\nNever invent a parent to hold tickets that are simply independent - "make these three tickets" means three tickets, and the person chooses in the dashboard whether they become tasks, epics, or one epic with children. NEVER emit a second ```ticket block to add more tickets: only the last block in a reply is read, so a second one silently discards the first.\n3-8 tickets, each sized for ONE short agent run and structured with the same section headings as above, ordered so foundations come first; the epic description is the overall goal in under 100 words. When one ticket needs another from the SAME batch, reference it as "Ticket #N" (its position in the list) - Allwright rewrites those into the real Jira keys at creation, and any other phrasing survives as a dangling reference nobody can follow.\nRE-EMIT, never refer back: when the user asks for the ticket again, says it did not appear, or a quick action repeats the request, emit the COMPLETE ```ticket block again in that reply. The dashboard only acts on a block in the NEWEST reply, and a long earlier reply can be cut off in transport without you ever knowing - so "I already sent it" is never a valid answer, and explaining your capabilities instead of re-emitting the block is never what was asked.\nSIZE: a reply that outgrows the transport is cut off mid-block and creates NOTHING - and you cannot tell it happened, because your own memory holds the text you meant to send. So when several tickets will not fit, emit FEWER entries, complete, and say which ones you left out for a follow-up turn; never open a block you cannot finish, and never spend the budget on prose before it - the block comes last, so prose is what pushes it over the edge. A payload that lives in the repo is referenced by exact path, never inlined - the implementing agent has the checkout. A pasted payload too large to inline safely (more than ~200 lines) is distilled into the description sections instead; say plainly that you distilled it and ask the user to attach the original file to the ticket so nothing is lost.\n\nA MACHINE ACTION IS NOT A TICKET. When the answer is an action ON A MACHINE rather than a change to this repository - installing a package, restarting or enabling a service, a DNS record, storing a credential, a permissions or sudoers change - do NOT propose a ticket for it. An implement run has NO SHELL and is path-jailed to this checkout, so no agent can carry a machine action out: such a ticket sits in the backlog forever or fails its run. What the person needs is the exact command and which machine to run it on, so end your reply with EXACTLY one fenced block:\n```command\n{"server": "<machine name if known, else empty>", "why": "<one line: what this fixes>", "commands": ["<exact shell command>", "\u2026"]}\n```\nCommands are EXACT and copy-pasteable - no placeholders, no prose, at most 5. NEVER include a secret VALUE: write $NAMES and let the person supply them.\nNEVER invent a server name - leave "server" empty when you are not sure which machine it is. When part of the fix is a code change and part is a machine action, emit BOTH blocks - the ```ticket block for the code half, the ```command block for the machine half - and say in ONE line which half is which.';h.ChatLoadResultMsg=o.z.object({type:o.z.literal("chat.load.result"),requestId:o.z.string(),ok:o.z.boolean(),projectId:o.z.string().default(""),ownerUserId:o.z.string().default(""),agentId:o.z.string().default(""),messages:o.z.array(o.z.object({role:o.z.enum(["user","agent"]),text:o.z.string(),steps:o.z.array(o.z.string()).default([]),tokens:o.z.number().int().nonnegative().default(0),files:o.z.array(o.z.string()).default([]),at:o.z.string().default(""),ms:o.z.number().int().nonnegative().default(0)})).default([]),error:o.z.string().optional()});h.RepoDocsMsg=o.z.object({type:o.z.literal("repo.docs"),requestId:o.z.string(),projectId:o.z.string()});h.RepoDocsResultMsg=o.z.object({type:o.z.literal("repo.docs.result"),requestId:o.z.string(),ok:o.z.boolean(),docs:o.z.array(o.z.object({path:o.z.string(),sizeBytes:o.z.number().int().nonnegative().default(0),updatedAt:o.z.string().default("")})).default([]),error:o.z.string().optional()});h.RepoDocReadMsg=o.z.object({type:o.z.literal("repo.doc.read"),requestId:o.z.string(),projectId:o.z.string(),path:o.z.string().max(400)});h.RepoDocReadResultMsg=o.z.object({type:o.z.literal("repo.doc.read.result"),requestId:o.z.string(),ok:o.z.boolean(),path:o.z.string().default(""),content:o.z.string().default(""),truncated:o.z.boolean().default(!1),error:o.z.string().optional()});h.BoardFetchMsg=o.z.object({type:o.z.literal("board.fetch"),requestId:o.z.string(),projectId:o.z.string()});h.BoardFetchResultMsg=o.z.object({type:o.z.literal("board.fetch.result"),requestId:o.z.string(),ok:o.z.boolean(),browseBaseUrl:o.z.string().default(""),columns:o.z.array(o.z.object({name:o.z.string(),issues:o.z.array(o.z.object({key:o.z.string(),summary:o.z.string(),labels:o.z.array(o.z.string()).default([])})).default([])})).default([]),error:o.z.string().optional()});h.BoardTriggerMsg=o.z.object({type:o.z.literal("board.trigger"),requestId:o.z.string(),projectId:o.z.string(),issueKey:o.z.string(),comment:o.z.string().max(2e3).default(""),removeLabel:o.z.string().default(""),requestedBy:o.z.string().default(""),requestedByEmail:o.z.string().default(""),reimplement:o.z.boolean().default(!1),agentId:o.z.string().max(60).default("")});h.BoardTriggerResultMsg=o.z.object({type:o.z.literal("board.trigger.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional()});h.EpicListMsg=o.z.object({type:o.z.literal("epic.list"),requestId:o.z.string(),projectId:o.z.string(),epicKey:o.z.string().default("")});h.EpicChild=o.z.object({key:o.z.string(),summary:o.z.string(),status:o.z.string(),statusCategory:o.z.string(),labels:o.z.array(o.z.string()).default([])});h.EpicListResultMsg=o.z.object({type:o.z.literal("epic.list.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),epics:o.z.array(o.z.object({key:o.z.string(),summary:o.z.string(),status:o.z.string()})).default([]),children:o.z.array(h.EpicChild).default([])});h.EpicSuggestMsg=o.z.object({type:o.z.literal("epic.suggest"),requestId:o.z.string(),projectId:o.z.string(),epicKey:o.z.string().min(1),model:o.z.string().default("")});h.EpicSuggestResultMsg=o.z.object({type:o.z.literal("epic.suggest.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),issueKey:o.z.string().default(""),reason:o.z.string().default(""),considered:o.z.number().int().default(0)});h.AuditRole=o.z.enum(["security","testing","architecture","functional","engineering","incident","seo"]);h.KnowledgeRole=o.z.enum(["security","testing","architecture","functional","engineering","seo","incident","implement","compose"]);h.AuditSeverity=o.z.enum(["critical","high","medium","low","info"]);h.AuditScope=o.z.object({kind:o.z.enum(["repo","ticket","branch"]).default("repo"),ref:o.z.string().default("")});h.AuditDetailLevel=o.z.enum(["simple","technical"]);h.AuditFinding=o.z.object({id:o.z.string().min(1),title:o.z.string().min(1),ruleId:o.z.string().max(20).default(""),severity:h.AuditSeverity,area:o.z.string().default(""),evidence:o.z.array(o.z.object({file:o.z.string().min(1),line:o.z.number().int().positive().optional(),note:o.z.string().default("")})).min(1),fix:o.z.string().default("")});h.AuditRecord=o.z.object({id:o.z.string(),role:h.AuditRole,createdAt:o.z.string(),model:o.z.string().default(""),summary:o.z.string().default(""),packNames:o.z.array(o.z.string()).default([]),findings:o.z.array(h.AuditFinding).default([]),costUsd:o.z.number().default(0),inputTokens:o.z.number().int().nonnegative().default(0),outputTokens:o.z.number().int().nonnegative().default(0),cacheReadTokens:o.z.number().int().nonnegative().default(0),review:o.z.object({selected:o.z.array(o.z.string()),updatedAt:o.z.string()}).optional(),verdicts:o.z.record(o.z.object({verdict:o.z.enum(["valid","false-positive","wont-fix"]),note:o.z.string().default(""),by:o.z.string().default(""),at:o.z.string().default("")})).default({}),lessonsWritten:o.z.array(o.z.string()).default([]),ticketed:o.z.record(o.z.string()).default({}),scope:h.AuditScope.default({kind:"repo",ref:""}),detailLevel:h.AuditDetailLevel.default("technical"),testRun:o.z.array(o.z.object({command:o.z.string(),exitCode:o.z.number().int(),durationMs:o.z.number().int().default(0),tail:o.z.string().default("")})).optional()});h.AuditStartMsg=o.z.object({type:o.z.literal("audit.start"),requestId:o.z.string(),projectId:o.z.string(),role:h.AuditRole,model:o.z.string().default(""),scope:h.AuditScope.default({kind:"repo",ref:""}),detailLevel:h.AuditDetailLevel.default("technical"),baseUrl:o.z.string().default(""),brief:o.z.string().max(16e3).default("")});h.AuditStartResultMsg=o.z.object({type:o.z.literal("audit.start.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),audit:h.AuditRecord.optional()});h.AuditListMsg=o.z.object({type:o.z.literal("audit.list"),requestId:o.z.string(),projectId:o.z.string()});h.AuditStatsMsg=o.z.object({type:o.z.literal("audit.stats"),requestId:o.z.string(),projectIds:o.z.array(o.z.string()).max(200).default([]),since:o.z.string().default("")});h.AuditStatsResultMsg=o.z.object({type:o.z.literal("audit.stats.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),byProject:o.z.record(o.z.object({audits:o.z.number().int().default(0),findings:o.z.number().int().default(0),valid:o.z.number().int().default(0),falsePositive:o.z.number().int().default(0),wontFix:o.z.number().int().default(0),unreviewed:o.z.number().int().default(0)})).default({})});h.AuditListResultMsg=o.z.object({type:o.z.literal("audit.list.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),audits:o.z.array(o.z.object({id:o.z.string(),role:h.AuditRole,createdAt:o.z.string(),findingCount:o.z.number().int(),bySeverity:o.z.record(o.z.number().int()).default({}),costUsd:o.z.number().default(0),inputTokens:o.z.number().int().nonnegative().default(0),outputTokens:o.z.number().int().nonnegative().default(0),detailLevel:h.AuditDetailLevel.default("technical")})).default([])});h.ChatDiagnosticMsg=o.z.object({type:o.z.literal("chat.diagnostic"),requestId:o.z.string(),projectId:o.z.string(),command:o.z.string().max(40),args:o.z.record(o.z.unknown()).default({})});h.ChatDiagnosticResultMsg=o.z.object({type:o.z.literal("chat.diagnostic.result"),requestId:o.z.string(),ok:o.z.boolean().default(!0),commandLine:o.z.string().default(""),output:o.z.string().default("")});h.ChatStepRunMsg=o.z.object({type:o.z.literal("chat.step.run"),requestId:o.z.string(),projectId:o.z.string(),environmentName:o.z.string(),stepIndex:o.z.number().int().nonnegative(),stepName:o.z.string()});h.ChatStepRunResultMsg=o.z.object({type:o.z.literal("chat.step.run.result"),requestId:o.z.string(),ok:o.z.boolean().default(!0),stepName:o.z.string().default(""),commandLine:o.z.string().default(""),exitCode:o.z.number().int().default(0),timedOut:o.z.boolean().default(!1),output:o.z.string().default(""),error:o.z.string().default("")});h.ChatCancelMsg=o.z.object({type:o.z.literal("chat.cancel"),requestId:o.z.string(),turnId:o.z.string()});h.AuditExplainMsg=o.z.object({type:o.z.literal("audit.explain"),requestId:o.z.string(),projectId:o.z.string(),auditId:o.z.string(),findingId:o.z.string()});h.AuditExplainResultMsg=o.z.object({type:o.z.literal("audit.explain.result"),requestId:o.z.string(),ok:o.z.boolean().default(!0),error:o.z.string().default(""),explanation:o.z.string().default("")});h.AuditGetMsg=o.z.object({type:o.z.literal("audit.get"),requestId:o.z.string(),projectId:o.z.string(),auditId:o.z.string()});h.AuditGetResultMsg=o.z.object({type:o.z.literal("audit.get.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),audit:h.AuditRecord.optional()});h.AuditReviewMsg=o.z.object({type:o.z.literal("audit.review"),requestId:o.z.string(),projectId:o.z.string(),auditId:o.z.string(),selected:o.z.array(o.z.string()).optional(),ticketed:o.z.array(o.z.object({findingId:o.z.string(),issueKey:o.z.string()})).default([]),verdicts:o.z.array(o.z.object({findingId:o.z.string(),verdict:o.z.enum(["valid","false-positive","wont-fix"]),note:o.z.string().max(2e3).default("")})).default([]),verdictBy:o.z.string().default("")});h.AuditReviewResultMsg=o.z.object({type:o.z.literal("audit.review.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),audit:h.AuditRecord.optional()});h.KnowledgeListMsg=o.z.object({type:o.z.literal("knowledge.list"),requestId:o.z.string(),projectId:o.z.string()});h.KnowledgeFile=o.z.object({role:h.KnowledgeRole,level:o.z.enum(["global","org","project"]),source:o.z.enum(["pack","lessons","memory"]),name:o.z.string(),content:o.z.string(),editable:o.z.boolean().default(!1)});h.KnowledgeListResultMsg=o.z.object({type:o.z.literal("knowledge.list.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),files:o.z.array(h.KnowledgeFile).default([])});h.KnowledgeSaveMsg=o.z.object({type:o.z.literal("knowledge.save"),requestId:o.z.string(),projectId:o.z.string(),role:h.KnowledgeRole,level:o.z.enum(["org","project"]),source:o.z.enum(["pack","lessons"]),name:o.z.string().min(1).max(100),content:o.z.string().max(6e4),append:o.z.boolean().default(!1),by:o.z.string().default("")});h.KnowledgeSaveResultMsg=o.z.object({type:o.z.literal("knowledge.save.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional()});h.TeamCredsMsg=o.z.object({type:o.z.literal("team.creds"),requestId:o.z.string(),emails:o.z.array(o.z.string()).max(200)});h.TeamCredsResultMsg=o.z.object({type:o.z.literal("team.creds.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),githubShared:o.z.boolean().default(!1),sharedGithubLogin:o.z.string().default(""),entries:o.z.array(o.z.object({email:o.z.string(),jira:o.z.enum(["own","runner-account","missing"]),jiraAs:o.z.string().default(""),github:o.z.enum(["own","shared","missing"]),githubAs:o.z.string().default("")})).default([])});h.ChatFile=o.z.object({name:o.z.string().min(1).max(255),contentBase64:o.z.string().min(1).max(225e5)});h.ChatTurnMsg=o.z.object({type:o.z.literal("chat.turn"),requestId:o.z.string(),projectId:o.z.string(),sessionId:o.z.string().optional(),message:o.z.string().min(1).max(2e4),userName:o.z.string().default(""),userId:o.z.string().max(80).default(""),model:o.z.string().default(""),agentId:o.z.string().max(60).default(""),files:o.z.array(h.ChatFile).max(8).default([]),replyLanguage:o.z.string().max(60).default(""),replyLanguageInstruction:o.z.string().max(600).default(""),replyStyle:o.z.string().max(30).default(""),command:o.z.string().max(40).default(""),pendingMigrations:o.z.array(o.z.string().max(200)).max(50).default([]),monitorChecks:o.z.array(o.z.object({id:o.z.string().max(40),name:o.z.string().max(120),status:o.z.string().max(12).default("")})).max(40).default([]),operator:o.z.boolean().default(!1),environments:o.z.array(o.z.string().max(60)).max(20).default([]),environmentSteps:o.z.array(o.z.object({environment:o.z.string().max(60),steps:o.z.array(o.z.string().max(120)).max(40).default([])})).max(20).default([])});h.ChatTurnResultMsg=o.z.object({type:o.z.literal("chat.turn.result"),requestId:o.z.string(),ok:o.z.boolean(),sessionId:o.z.string().default(""),reply:o.z.string().default(""),error:o.z.string().optional(),inputTokens:o.z.number().int().nonnegative().default(0),outputTokens:o.z.number().int().nonnegative().default(0),cacheReadTokens:o.z.number().int().nonnegative().default(0),costUsd:o.z.number().nonnegative().default(0),model:o.z.string().max(200).default(""),contextTokens:o.z.number().int().nonnegative().default(0),contextLimit:o.z.number().int().nonnegative().default(0),compacted:o.z.boolean().default(!1),compactedMessages:o.z.number().int().nonnegative().default(0),outputTruncated:o.z.boolean().default(!1)});h.ChatCreateTicketMsg=o.z.object({type:o.z.literal("chat.create.ticket"),requestId:o.z.string(),projectId:o.z.string(),summary:o.z.string().min(1).max(250),description:o.z.string().default(""),triggerComment:o.z.string().default(""),requestedBy:o.z.string().default(""),requestedByEmail:o.z.string().default(""),asEpic:o.z.boolean().default(!1),children:o.z.array(o.z.object({summary:o.z.string().min(1),description:o.z.string().default("")})).max(20).default([]),createAs:o.z.enum(["epic_with_children","separate_epics","separate_tasks"]).default("epic_with_children"),files:o.z.array(h.ChatFile).max(8).default([]),component:o.z.string().max(120).default(""),chatSessionId:o.z.string().max(64).default(""),userId:o.z.string().max(80).default("")});h.ChatCreateTicketResultMsg=o.z.object({type:o.z.literal("chat.create.ticket.result"),requestId:o.z.string(),ok:o.z.boolean(),issueKey:o.z.string().default(""),error:o.z.string().optional(),childKeys:o.z.array(o.z.string()).default([])});h.EnvPreflightMsg=o.z.object({type:o.z.literal("env.preflight"),requestId:o.z.string(),projectId:o.z.string(),environmentName:o.z.string().default(""),steps:o.z.array(h.DeployStep).default([]),requiredSecrets:o.z.array(o.z.string()).default([]),workdir:o.z.string().default(""),branch:o.z.string().default(""),publicUrl:o.z.string().default("")});h.EnvPreflightResultMsg=o.z.object({type:o.z.literal("env.preflight.result"),requestId:o.z.string(),ok:o.z.boolean(),checks:o.z.array(o.z.object({name:o.z.string(),ok:o.z.boolean(),detail:o.z.string().default(""),kind:o.z.enum(["connection","content"]).default("connection"),fix:o.z.array(o.z.string()).default([]),fixNote:o.z.string().default("")})).default([])});h.SELF_MIGRATION_DIR="apps/api/prisma/manual";function o_(t){return/^[A-Za-z0-9][A-Za-z0-9._-]*\.sql$/.test(t)&&!t.includes("..")}h.SelfMigrationApplyMsg=o.z.object({type:o.z.literal("selfmigration.apply"),requestId:o.z.string(),projectId:o.z.string(),environmentName:o.z.string().default(""),file:o.z.string(),urlSecret:o.z.string().default("DATABASE_URL")});h.SelfMigrationApplyResultMsg=o.z.object({type:o.z.literal("selfmigration.apply.result"),requestId:o.z.string(),ok:o.z.boolean(),file:o.z.string().default(""),checks:o.z.array(o.z.object({name:o.z.string(),ok:o.z.boolean(),detail:o.z.string().default(""),fix:o.z.array(o.z.string()).default([])})).default([]),output:o.z.string().max(2e4).default(""),error:o.z.string().default("")});h.DeploySuggestResultMsg=o.z.object({type:o.z.literal("deploy.suggest.result"),requestId:o.z.string(),ok:o.z.boolean(),steps:o.z.array(h.DeployStep).default([]),requiredSecrets:o.z.array(o.z.string()).default([]),notes:o.z.string().default(""),error:o.z.string().optional(),docPath:o.z.string().default(""),docContent:o.z.string().max(1e5).default(""),fixTicketSummary:o.z.string().max(250).default(""),fixTicketDescription:o.z.string().max(2e4).default("")});h.SetupStatusMsg=o.z.object({type:o.z.literal("setup.status"),requestId:o.z.string(),repoNames:o.z.array(o.z.string()).max(100).default([])});h.SetupStatusResultMsg=o.z.object({type:o.z.literal("setup.status.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),jiraConfigured:o.z.boolean().default(!1),jiraEmail:o.z.string().default(""),serviceProtected:o.z.boolean().nullable().optional(),serviceProtectFix:o.z.string().max(500).default(""),agents:o.z.record(o.z.object({installed:o.z.boolean(),version:o.z.string().default(""),loggedIn:o.z.boolean()})).default({}),claude:o.z.object({installed:o.z.boolean(),version:o.z.string().default(""),loggedIn:o.z.boolean()}).optional(),githubTokenSet:o.z.boolean().default(!1),githubLogin:o.z.string().default(""),deploysEnabled:o.z.boolean().default(!1),jiraUserCount:o.z.number().int().default(0),repos:o.z.array(o.z.object({repoName:o.z.string(),path:o.z.string().default(""),mapped:o.z.boolean(),liveMapped:o.z.boolean().default(!0),pathExists:o.z.boolean().default(!1),currentBranch:o.z.string().default(""),isGit:o.z.boolean().default(!1),claudeMd:o.z.boolean().default(!1),deployMd:o.z.boolean().default(!1),testMd:o.z.boolean().default(!1),defaultBranch:o.z.string().default(""),githubToken:o.z.boolean().default(!1),githubTokenOwn:o.z.boolean().default(!1),architecture:o.z.object({languages:o.z.array(o.z.string()).max(4).default([]),frameworks:o.z.array(o.z.string()).max(6).default([]),databases:o.z.array(o.z.string()).max(4).default([]),docker:o.z.boolean().default(!1),dockerCompose:o.z.boolean().default(!1),packageManager:o.z.string().default(""),monorepo:o.z.string().default("")}).optional()})).default([])});h.RepoUnmapMsg=o.z.object({type:o.z.literal("repo.unmap"),requestId:o.z.string(),repoName:o.z.string()});h.RepoUnmapResultMsg=o.z.object({type:o.z.literal("repo.unmap.result"),requestId:o.z.string(),ok:o.z.boolean().default(!0),error:o.z.string().default(""),removedPath:o.z.string().default("")});h.SetupRecheckMsg=o.z.object({type:o.z.literal("setup.recheck"),requestId:o.z.string(),projectId:o.z.string(),environments:o.z.array(o.z.object({name:o.z.string(),branch:o.z.string().default(""),publicUrl:o.z.string().default(""),workdir:o.z.string().default(""),servePath:o.z.string().default("")})).default([])});h.SetupRecheckResultMsg=o.z.object({type:o.z.literal("setup.recheck.result"),requestId:o.z.string(),ok:o.z.boolean().default(!0),error:o.z.string().default(""),checks:o.z.array(o.z.object({environment:o.z.string().default(""),question:o.z.string(),ok:o.z.boolean(),detail:o.z.string().default(""),blocking:o.z.boolean().default(!0)})).default([])});h.SetupClaudeMdGenerateMsg=o.z.object({type:o.z.literal("setup.claudemd.generate"),requestId:o.z.string(),projectId:o.z.string(),kind:o.z.enum(["claude","deploy","design","unblock"]).default("claude"),blockers:o.z.array(o.z.string().max(400)).max(20).default([]),machineState:o.z.array(o.z.string().max(400)).max(40).default([]),streamId:o.z.string().default(""),environments:o.z.array(o.z.object({name:o.z.string(),branch:o.z.string().default(""),publicUrl:o.z.string().default(""),workdir:o.z.string().default(""),dedicatedCheckout:o.z.boolean().default(!1),onThisRunner:o.z.boolean().default(!0)})).default([])});h.SetupClaudeMdGenerateResultMsg=o.z.object({type:o.z.literal("setup.claudemd.generate.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),content:o.z.string().default(""),truncated:o.z.boolean().default(!1)});h.SetupAskMsg=o.z.object({type:o.z.literal("setup.ask"),requestId:o.z.string(),projectId:o.z.string(),subject:o.z.string().max(600).default(""),command:o.z.string().max(2e3).default(""),machineState:o.z.array(o.z.string().max(400)).max(40).default([]),history:o.z.array(o.z.object({role:o.z.enum(["user","agent"]),text:o.z.string().max(4e3)})).max(8).default([]),question:o.z.string().max(4e3)});h.SetupAskResultMsg=o.z.object({type:o.z.literal("setup.ask.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),answer:o.z.string().default("")});h.SetupClaudeMdSaveMsg=o.z.object({type:o.z.literal("setup.claudemd.save"),requestId:o.z.string(),projectId:o.z.string(),kind:o.z.enum(["claude","deploy","design"]).default("claude"),overwrite:o.z.boolean().default(!1),content:o.z.string().max(1e5)});h.SetupClaudeMdSaveResultMsg=o.z.object({type:o.z.literal("setup.claudemd.save.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),note:o.z.string().default("")});h.RepoDocSaveMsg=o.z.object({type:o.z.literal("repo.doc.save"),requestId:o.z.string(),projectId:o.z.string(),relPath:o.z.string().min(1).max(200),overwrite:o.z.boolean().default(!1),content:o.z.string().max(2e5)});h.RepoDocSaveResultMsg=o.z.object({type:o.z.literal("repo.doc.save.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),note:o.z.string().default("")});h.RunnerUpdateMsg=o.z.object({type:o.z.literal("runner.update"),requestId:o.z.string(),version:o.z.string().max(20).default("")});h.RunnerUninstallMsg=o.z.object({type:o.z.literal("runner.uninstall"),requestId:o.z.string()});h.RunResolveConflictMsg=o.z.object({type:o.z.literal("run.resolve.conflict"),requestId:o.z.string(),runId:o.z.string()});h.RunTestFixMsg=o.z.object({type:o.z.literal("run.testfix"),requestId:o.z.string(),runId:o.z.string(),failedTests:o.z.array(h.FailedTest).max(20).default([]),finding:o.z.object({id:o.z.string().max(200),title:o.z.string().max(300),detail:o.z.string().max(8e3)}).optional()});h.RunTestFixResultMsg=o.z.object({type:o.z.literal("run.testfix.result"),requestId:o.z.string(),ok:o.z.boolean(),note:o.z.string().default(""),headSha:o.z.string().default(""),remaining:o.z.array(h.FailedTest).default([]),costUsd:o.z.number().nonnegative().optional(),inputTokens:o.z.number().int().nonnegative().optional(),outputTokens:o.z.number().int().nonnegative().optional()});h.RunAnswerMsg=o.z.object({type:o.z.literal("run.answer"),requestId:o.z.string(),runId:o.z.string(),text:o.z.string().min(1).max(4e3),answeredBy:o.z.string().default("")});h.RunAnswerResultMsg=o.z.object({type:o.z.literal("run.answer.result"),requestId:o.z.string(),ok:o.z.boolean(),note:o.z.string().default(""),error:o.z.string().optional()});h.RunResolveConflictResultMsg=o.z.object({type:o.z.literal("run.resolve.conflict.result"),requestId:o.z.string(),ok:o.z.boolean(),note:o.z.string().default(""),freeOfCharge:o.z.boolean().default(!1),headSha:o.z.string().default(""),costUsd:o.z.number().nonnegative().optional(),inputTokens:o.z.number().int().nonnegative().optional(),outputTokens:o.z.number().int().nonnegative().optional()});h.RunPrConflictMsg=o.z.object({type:o.z.literal("run.pr.conflict"),runId:o.z.string(),conflicted:o.z.boolean()});h.AgentProfilesMsg=o.z.object({type:o.z.literal("agent.profiles"),requestId:o.z.string()});h.AgentProfilesResultMsg=o.z.object({type:o.z.literal("agent.profiles.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),profiles:o.z.array(o.z.object({agent:o.z.string(),name:o.z.string(),loggedIn:o.z.boolean()})).max(200).default([]),defaultLoggedIn:o.z.boolean().default(!1),agentsWithoutProfiles:o.z.array(o.z.string()).max(20).default([])});h.RunnerUpdateResultMsg=o.z.object({type:o.z.literal("runner.update.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),note:o.z.string().default(""),scheduled:o.z.boolean().default(!1)});h.RunnerUninstallResultMsg=o.z.object({type:o.z.literal("runner.uninstall.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),note:o.z.string().default(""),serviceRemoved:o.z.boolean().default(!1),configRemoved:o.z.boolean().default(!1)});h.AutopilotNextMsg=o.z.object({type:o.z.literal("autopilot.next"),requestId:o.z.string()});h.AutopilotPlanMsg=o.z.object({type:o.z.literal("autopilot.plan"),requestId:o.z.string(),projectId:o.z.string(),batchId:o.z.string(),issueKeys:o.z.array(o.z.string()).min(1).max(50)});h.AutopilotPlanResultMsg=o.z.object({type:o.z.literal("autopilot.plan.result"),requestId:o.z.string(),ok:o.z.boolean().default(!0),error:o.z.string().default(""),order:o.z.array(o.z.string()).default([]),chains:o.z.array(o.z.array(o.z.string())).default([]),dependencies:o.z.array(o.z.tuple([o.z.string(),o.z.string()])).default([]),reasoning:o.z.string().default("")});h.AutopilotNextResultMsg=o.z.object({type:o.z.literal("autopilot.next.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),item:o.z.object({id:o.z.string(),projectId:o.z.string(),issueKey:o.z.string(),ruleId:o.z.string(),baseOverride:o.z.string().default(""),branchOverride:o.z.string().default(""),continueBranch:o.z.boolean().default(!1),batchId:o.z.string().default(""),autoMerge:o.z.boolean().default(!1),remainingInBatch:o.z.number().int().min(0).default(0),agentId:o.z.string().max(60).default("")}).nullable().default(null),pausedUntil:o.z.string().default("")});h.AutopilotReportMsg=o.z.object({type:o.z.literal("autopilot.report"),requestId:o.z.string(),itemId:o.z.string(),outcome:o.z.enum(["claimed","failed","paused"]),runId:o.z.string().default(""),error:o.z.string().default("")});h.ServerInventoryMsg=o.z.object({type:o.z.literal("server.inventory"),requestId:o.z.string()});h.ServerInventoryResultMsg=o.z.object({type:o.z.literal("server.inventory.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),checkouts:o.z.array(o.z.object({path:o.z.string(),repoName:o.z.string().default(""),remoteUrl:o.z.string().default(""),branch:o.z.string().default("")})).max(60).default([]),services:o.z.array(o.z.object({name:o.z.string(),description:o.z.string().default(""),active:o.z.string().default("")})).max(150).default([]),containers:o.z.array(o.z.object({name:o.z.string(),image:o.z.string().default(""),status:o.z.string().default(""),ports:o.z.string().default("")})).max(60).default([]),ports:o.z.array(o.z.object({port:o.z.number().int().nonnegative(),process:o.z.string().default(""),pid:o.z.number().int().nonnegative().default(0)})).max(150).default([]),processes:o.z.array(o.z.object({pid:o.z.number().int().nonnegative(),user:o.z.string().default(""),cpuPct:o.z.number().default(0),memPct:o.z.number().default(0),command:o.z.string().default("")})).max(40).default([])});h.MonitorResultMsg=o.z.object({type:o.z.literal("monitor.result"),resultId:o.z.string().max(120),checkId:o.z.string(),ranAt:o.z.string(),status:h.MonitorStatus,late:o.z.boolean().default(!1),summary:o.z.string().max(300).default(""),metricsJson:o.z.string().max(8e3).default(""),excerpt:o.z.string().max(4e3).default(""),durationMs:o.z.number().int().nonnegative().default(0)});h.MonitorRunMsg=o.z.object({type:o.z.literal("monitor.run"),requestId:o.z.string(),checkId:o.z.string()});h.MonitorRunResultMsg=o.z.object({type:o.z.literal("monitor.run.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional()});h.MonitorSuggestMsg=o.z.object({type:o.z.literal("monitor.suggest"),requestId:o.z.string(),projectId:o.z.string(),notes:o.z.string().min(1).max(2e3)});h.MonitorSuggestResultMsg=o.z.object({type:o.z.literal("monitor.suggest.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),name:o.z.string().max(120).default(""),commands:o.z.array(h.MonitorCommand).max(20).default([]),parseRules:h.MonitorParseRules.default({}),schedule:h.MonitorSchedule.optional(),notes:o.z.string().max(2e3).default("")});h.MonitorRebaselineMsg=o.z.object({type:o.z.literal("monitor.rebaseline"),requestId:o.z.string(),checkId:o.z.string()});h.MonitorRebaselineResultMsg=o.z.object({type:o.z.literal("monitor.rebaseline.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional()});h.MonitorDiscoverMsg=o.z.object({type:o.z.literal("monitor.discover"),requestId:o.z.string()});h.MonitorDiscoverResultMsg=o.z.object({type:o.z.literal("monitor.discover.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),os:o.z.object({platform:o.z.string().default(""),arch:o.z.string().default(""),release:o.z.string().default("")}).default({}),services:o.z.array(o.z.object({name:o.z.string().max(120),kind:o.z.string().max(40).default("")})).max(40).default([]),webServers:o.z.array(o.z.string().max(20)).max(10).default([]),backupCandidates:o.z.array(o.z.object({path:o.z.string().max(400),newestFile:o.z.string().max(200).default(""),newestAgeHours:o.z.number().nonnegative().default(0),sizeMB:o.z.number().nonnegative().default(0)})).max(20).default([]),dbHints:o.z.array(o.z.object({kind:o.z.string().max(20),port:o.z.number().int().nonnegative().default(0)})).max(10).default([])});h.ServerDecommissionPlanMsg=o.z.object({type:o.z.literal("server.decommission.plan"),requestId:o.z.string(),path:o.z.string().min(1).max(500)});h.ServerDecommissionPlanResultMsg=o.z.object({type:o.z.literal("server.decommission.plan.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),path:o.z.string().default(""),sizeMb:o.z.number().default(0),services:o.z.array(o.z.object({name:o.z.string(),detail:o.z.string().default("")})).max(30).default([]),processes:o.z.array(o.z.object({pid:o.z.number().int().nonnegative(),command:o.z.string().default(""),ports:o.z.array(o.z.number().int()).max(20).default([])})).max(50).default([]),containers:o.z.array(o.z.object({name:o.z.string(),image:o.z.string().default("")})).max(30).default([]),databases:o.z.array(o.z.object({name:o.z.string(),engine:o.z.string(),source:o.z.string()})).max(10).default([]),warnings:o.z.array(o.z.string().max(300)).max(20).default([])});h.ServerDecommissionExecuteMsg=o.z.object({type:o.z.literal("server.decommission.execute"),requestId:o.z.string(),opToken:o.z.string().min(1).max(60),path:o.z.string().min(1).max(500),deleteFolder:o.z.boolean().default(!0),services:o.z.array(o.z.string().max(120)).max(30).default([]),pids:o.z.array(o.z.number().int().positive()).max(50).default([]),containers:o.z.array(o.z.string().max(120)).max(30).default([]),databases:o.z.array(o.z.string().max(120)).max(10).default([])});h.ServerDecommissionResultMsg=o.z.object({type:o.z.literal("server.decommission.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional()});h.ServerDecommissionProgressMsg=o.z.object({type:o.z.literal("server.decommission.progress"),opToken:o.z.string(),step:o.z.object({label:o.z.string().max(200),ok:o.z.boolean(),detail:o.z.string().max(500).default("")}).optional(),done:o.z.boolean().default(!1),error:o.z.string().max(500).default("")});h.SiteAuditMsg=o.z.object({type:o.z.literal("site.audit"),requestId:o.z.string(),url:o.z.string().min(4).max(500)});h.SiteAuditResultMsg=o.z.object({type:o.z.literal("site.audit.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),url:o.z.string().default(""),overall:o.z.number().default(0),categories:o.z.array(o.z.object({key:o.z.string(),label:o.z.string(),score:o.z.number().nullable()})).max(10).default([]),checks:o.z.array(o.z.object({id:o.z.string(),category:o.z.string(),label:o.z.string().max(200),status:o.z.enum(["pass","warn","fail","info"]),detail:o.z.string().max(500).default("")})).max(100).default([])});h.RebirthUploadBeginMsg=o.z.object({type:o.z.literal("rebirth.upload.begin"),requestId:o.z.string(),rebirthId:o.z.string(),kind:o.z.enum(["frontend","backend","docs","dump"]),name:o.z.string().min(1).max(200),sizeBytes:o.z.number().int().positive().max(2*1024*1024*1024)});h.RebirthUploadBeginResultMsg=o.z.object({type:o.z.literal("rebirth.upload.begin.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),uploadId:o.z.string().default("")});h.RebirthUploadChunkMsg=o.z.object({type:o.z.literal("rebirth.upload.chunk"),requestId:o.z.string(),uploadId:o.z.string(),seq:o.z.number().int().nonnegative(),dataBase64:o.z.string().max(6e6),last:o.z.boolean().default(!1)});h.RebirthUploadChunkResultMsg=o.z.object({type:o.z.literal("rebirth.upload.chunk.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),storedPath:o.z.string().default(""),note:o.z.string().default("")});h.RebirthDesignMsg=o.z.object({type:o.z.literal("rebirth.design"),requestId:o.z.string(),projectId:o.z.string(),rebirthId:o.z.string(),spec:o.z.string().max(1e5).default(""),brief:o.z.string().max(6e4).default(""),refineMessage:o.z.string().max(1e4).default(""),currentDirection:o.z.string().max(1e5).default(""),screenName:o.z.string().max(80).default(""),screenBrief:o.z.string().max(4e3).default(""),currentScreenHtml:o.z.string().max(2e5).default(""),specOnly:o.z.boolean().default(!1),screenSpec:o.z.string().max(3e4).default(""),existingScreenNames:o.z.array(o.z.string().max(80)).max(60).default([]),referenceScreenHtml:o.z.string().max(2e5).default(""),stackOnly:o.z.boolean().default(!1),currentStack:o.z.string().max(4e4).default("")});h.RebirthDesignResultMsg=o.z.object({type:o.z.literal("rebirth.design.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional()});h.TimelineDigestMsg=o.z.object({type:o.z.literal("timeline.digest"),requestId:o.z.string(),projectId:o.z.string(),prompt:o.z.string().min(1).max(6e4)});h.TimelineDigestResultMsg=o.z.object({type:o.z.literal("timeline.digest.result"),requestId:o.z.string(),ok:o.z.boolean(),text:o.z.string().default(""),error:o.z.string().optional()});h.RebirthStudyMsg=o.z.object({type:o.z.literal("rebirth.study"),requestId:o.z.string(),projectId:o.z.string(),rebirthId:o.z.string(),dbDumpPath:o.z.string().max(500).default(""),legacyJiraKey:o.z.string().max(30).default(""),legacyJiraSiteUrl:o.z.string().max(300).default(""),maxJiraIssues:o.z.number().int().min(0).max(2e3).default(0),extraContext:o.z.string().max(6e4).default(""),refineMessage:o.z.string().max(32e3).default(""),refineScope:o.z.enum(["all","brief","understanding","requirements","spec"]).default("all"),currentDocsIncluded:o.z.boolean().default(!1),currentBrief:o.z.string().max(1e5).default(""),currentUnderstanding:o.z.string().max(2e5).default(""),currentRequirements:o.z.string().max(2e5).default(""),currentSpec:o.z.string().max(2e5).default("")});h.RebirthStudyUpdateMsg=o.z.object({type:o.z.literal("rebirth.study.update"),rebirthId:o.z.string(),stageNumber:o.z.number().int().min(1).max(8),status:o.z.enum(["in_progress","done","failed","skipped"]),note:o.z.string().max(500).default(""),progressDone:o.z.number().int().nonnegative().default(0),progressTotal:o.z.number().int().nonnegative().default(0),artifact:o.z.string().max(2e5).default(""),items:o.z.array(o.z.object({title:o.z.string().max(300),detail:o.z.string().max(4e3).default("")})).max(60).default([]),design:o.z.object({direction:o.z.string().max(1e5).default(""),screens:o.z.array(o.z.object({name:o.z.string().max(80),html:o.z.string().max(2e5)})).max(8).default([]),inventory:o.z.array(o.z.object({name:o.z.string().max(80),note:o.z.string().max(200).default("")})).max(40).default([]),specs:o.z.array(o.z.object({name:o.z.string().max(80),doc:o.z.string().max(3e4)})).max(8).default([]),partial:o.z.boolean().default(!1)}).optional(),brief:o.z.string().max(1e5).default(""),techStack:o.z.string().max(4e4).optional(),proposal:o.z.object({message:o.z.string().max(32e3).default(""),scope:o.z.enum(["all","brief","understanding","requirements","spec"]).default("all"),docs:o.z.array(o.z.object({doc:o.z.enum(["brief","understanding","requirements","spec"]),proposed:o.z.string().max(2e5)})).max(4).default([]),tickets:o.z.array(o.z.object({title:o.z.string().max(300),detail:o.z.string().max(4e3).default("")})).max(60).default([]),working:o.z.boolean().default(!1),error:o.z.string().max(2e3).default("")}).optional(),runFinished:o.z.object({kind:o.z.enum(["study","refine","design","screen","techstack"]).default("study"),ok:o.z.boolean().default(!0),error:o.z.string().max(2e3).default("")}).optional(),usageDelta:o.z.object({inputTokens:o.z.number().int().nonnegative().default(0),outputTokens:o.z.number().int().nonnegative().default(0),cacheReadTokens:o.z.number().int().nonnegative().default(0),costUsd:o.z.number().nonnegative().default(0)}).default({inputTokens:0,outputTokens:0,cacheReadTokens:0,costUsd:0})});h.RebirthStudyResultMsg=o.z.object({type:o.z.literal("rebirth.study.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional()});h.RunnerToServerMsg=o.z.discriminatedUnion("type",[h.HelloMsg,h.HeartbeatMsg,h.RunClaimMsg,h.RunLogMsg,h.RunContextMsg,h.RunUsageMsg,h.RunStatusMsg,h.ProjectTestResultMsg,h.RuleDiagnoseResultMsg,h.DeployClaimMsg,h.DeploySuggestResultMsg,h.EnvPreflightResultMsg,h.SelfMigrationApplyResultMsg,h.ChatTurnResultMsg,h.ChatStreamMsg,h.ChatUsageMsg,h.ChatSessionMsg,h.ChatActivityMsg,h.ChatCreateTicketResultMsg,h.ChatListResultMsg,h.RepoDocsResultMsg,h.RepoDocReadResultMsg,h.ChatLoadResultMsg,h.BoardFetchResultMsg,h.BoardTriggerResultMsg,h.TeamCredsResultMsg,h.AuditStartResultMsg,h.AuditListResultMsg,h.AuditGetResultMsg,h.AuditExplainResultMsg,h.AuditReviewResultMsg,h.KnowledgeListResultMsg,h.KnowledgeSaveResultMsg,h.EpicListResultMsg,h.EpicSuggestResultMsg,h.JiraUsersResultMsg,h.SetupStatusResultMsg,h.SetupClaudeMdGenerateResultMsg,h.SetupAskResultMsg,h.SetupRecheckResultMsg,h.RepoUnmapResultMsg,h.SetupClaudeMdSaveResultMsg,h.RepoDocSaveResultMsg,h.RunnerUpdateResultMsg,h.RunnerUninstallResultMsg,h.AgentProfilesResultMsg,h.RunPrConflictMsg,h.RunResolveConflictResultMsg,h.RunTestFixResultMsg,h.RunAnswerResultMsg,h.AuditStatsResultMsg,h.AutopilotNextMsg,h.AutopilotReportMsg,h.AutopilotPlanResultMsg,h.ChatDiagnosticResultMsg,h.ChatStepRunResultMsg,h.ServerInventoryResultMsg,h.ServerDecommissionPlanResultMsg,h.SiteAuditResultMsg,h.RebirthUploadBeginResultMsg,h.RebirthDesignResultMsg,h.RebirthUploadChunkResultMsg,h.ServerDecommissionResultMsg,h.ServerDecommissionProgressMsg,h.TimelineDigestResultMsg,h.RebirthStudyUpdateMsg,h.RebirthStudyResultMsg,h.MonitorResultMsg,h.MonitorRunResultMsg,h.MonitorDiscoverResultMsg,h.MonitorRebaselineResultMsg,h.MonitorSuggestResultMsg,h.AiSpendMsg]);h.HelloAckMsg=o.z.object({type:o.z.literal("hello.ack"),runnerId:o.z.string(),runnerName:o.z.string(),serverTime:o.z.string()});h.ConfigMsg=o.z.object({type:o.z.literal("config"),projects:o.z.array(h.ProjectConfig),rules:o.z.array(h.RuleConfig),environments:o.z.array(h.EnvironmentConfig).default([]),monitors:o.z.array(h.MonitorCheckConfig).default([]),pollingPaused:o.z.boolean().default(!1),publicIp:o.z.string().default("")});h.RunClaimResultMsg=o.z.object({type:o.z.literal("run.claim.result"),requestId:o.z.string(),accepted:o.z.boolean(),runId:o.z.string().optional(),reason:o.z.string().optional(),claudeProfile:o.z.string().optional(),actorEmail:o.z.string().optional()});h.ProjectTestMsg=o.z.object({type:o.z.literal("project.test"),requestId:o.z.string(),projectId:o.z.string()});h.RuleDiagnoseMsg=o.z.object({type:o.z.literal("rule.diagnose"),requestId:o.z.string(),ruleId:o.z.string()});h.RunCancelMsg=o.z.object({type:o.z.literal("run.cancel"),runId:o.z.string()});h.RunApprovedMsg=o.z.object({type:o.z.literal("run.approved"),runId:o.z.string(),headSha:o.z.string().optional()});h.RunRejectedMsg=o.z.object({type:o.z.literal("run.rejected"),runId:o.z.string()});h.RunRetryPushMsg=o.z.object({type:o.z.literal("run.retryPush"),runId:o.z.string()});h.DeployStartMsg=o.z.object({type:o.z.literal("deploy.start"),runId:o.z.string(),projectId:o.z.string(),issueKey:o.z.string(),issueSummary:o.z.string().default(""),environment:h.EnvironmentConfig,requestedBy:o.z.string().default(""),attempt:o.z.number().int().positive().default(1)});h.DeployFixMsg=o.z.object({type:o.z.literal("deploy.fix"),requestId:o.z.string(),projectId:o.z.string(),environmentName:o.z.string(),steps:o.z.array(o.z.object({name:o.z.string(),run:o.z.string(),continueOnError:o.z.boolean().default(!1)})),failedStep:o.z.string().default(""),errorText:o.z.string().max(8e3).default("")});h.DeploySuggestMsg=o.z.object({type:o.z.literal("deploy.suggest"),requestId:o.z.string(),projectId:o.z.string(),environmentName:o.z.string(),notes:o.z.string().default(""),timeoutSeconds:o.z.number().int().positive().max(1800).default(300)});h.JiraUsersMsg=o.z.object({type:o.z.literal("jira.users"),requestId:o.z.string(),query:o.z.string().default("")});h.ServerToRunnerMsg=o.z.discriminatedUnion("type",[h.HelloAckMsg,h.ConfigMsg,h.ServerInventoryMsg,h.ServerDecommissionPlanMsg,h.SiteAuditMsg,h.RebirthUploadBeginMsg,h.RebirthDesignMsg,h.RebirthUploadChunkMsg,h.ServerDecommissionExecuteMsg,h.TimelineDigestMsg,h.RebirthStudyMsg,h.RunClaimResultMsg,h.ProjectTestMsg,h.RuleDiagnoseMsg,h.RunCancelMsg,h.RunApprovedMsg,h.RunRejectedMsg,h.RunRetryPushMsg,h.DeployClaimResultMsg,h.DeployStartMsg,h.DeploySuggestMsg,h.DeployFixMsg,h.EnvPreflightMsg,h.SelfMigrationApplyMsg,h.ChatTurnMsg,h.ChatCreateTicketMsg,h.ChatListMsg,h.RepoDocsMsg,h.RepoDocReadMsg,h.ChatLoadMsg,h.BoardFetchMsg,h.BoardTriggerMsg,h.TeamCredsMsg,h.AuditStartMsg,h.AuditListMsg,h.AuditGetMsg,h.AuditExplainMsg,h.ChatCancelMsg,h.ChatDiagnosticMsg,h.ChatStepRunMsg,h.AuditReviewMsg,h.KnowledgeListMsg,h.KnowledgeSaveMsg,h.EpicListMsg,h.EpicSuggestMsg,h.JiraUsersMsg,h.SetupStatusMsg,h.SetupClaudeMdGenerateMsg,h.SetupAskMsg,h.SetupRecheckMsg,h.RepoUnmapMsg,h.SetupClaudeMdSaveMsg,h.RepoDocSaveMsg,h.RunnerUpdateMsg,h.RunnerUninstallMsg,h.AgentProfilesMsg,h.RunResolveConflictMsg,h.RunTestFixMsg,h.RunAnswerMsg,h.AuditStatsMsg,h.AutopilotNextResultMsg,h.AutopilotPlanMsg,h.MonitorRunMsg,h.MonitorDiscoverMsg,h.MonitorRebaselineMsg,h.MonitorSuggestMsg]);h.EnrollRequest=o.z.object({enrollToken:o.z.string().min(10),name:o.z.string().min(1).max(100),platform:o.z.string(),runnerVersion:o.z.string()});h.EnrollResponse=o.z.object({runnerId:o.z.string(),runnerToken:o.z.string(),controlPlaneWsUrl:o.z.string()});function a_(t){return h.RunnerToServerMsg.parse(t)}function c_(t){return h.ServerToRunnerMsg.parse(t)}h.DEFAULT_PLAN_PROMPT_TEMPLATE=`You are a senior engineer asked to assess a Jira ticket. You have read-only access to the repository - do not attempt to modify anything.
71
+ `:""}h.TICKET_RULES_APPENDIX='\n\nONLY when the user explicitly asks for a ticket, propose it by ending your reply with EXACTLY one fenced block in this shape:\n```ticket\n{"summary": "\u2026", "description": "\u2026"}\n```\nBefore drafting, re-read this ENTIRE conversation from its first message and fold in every decision, constraint, and correction agreed along the way - the ticket reflects the final state of the whole discussion, not just the last message.\nRIGHT-SIZE every ticket - it is a work order for ONE agent run. One ticket = one concern: a single feature, fix or change an engineer would land as one reviewable PR. The test for TOO BIG: the summary needs an "and", the Expected Flow forks into unrelated flows, or the acceptance criteria span unrelated screens or modules - split there, into an epic batch if the pieces belong together. Queued tickets share a warm agent session and one branch, so splitting is cheap; an oversized ticket is the single biggest driver of runaway agent cost and un-reviewable diffs. Trivial same-file touches (a rename plus its comment) stay together - splitting has to buy a smaller review, not ceremony. If the user explicitly asks to split or to merge, their word wins.\nWrite the description in plain human language, structured with these Markdown section headings in this order:\nStory: - one or two sentences: who needs this and why.\nDescription: - what to build and WHERE, as bullet points that name exact files, directories or symbols whenever the conversation or repo makes them known - the implementing agent starts cold, and every named path saves it a paid search.\nExpected Flow: - the flow once this ticket is done, as numbered steps.\nCurrent Flow: - how it behaves today; include ONLY when current behavior exists.\nAcceptance Criteria: - testable bullet points a reviewer can check off one by one.\nInclude a section only when it carries real content, and add extra sections (Out of Scope, Notes, \u2026) when the work genuinely needs them. Use as many bullets as the work needs - no artificial length cap, but no padding either. It must stay concrete enough that a developer (or an agent) can implement it without asking questions. NEVER paste the conversation into the description; distill it. Refine the draft over further turns if the user asks.\nTHE READER IS A COLD AGENT: whoever implements this sees the ticket alone, never this conversation. Anything that is obvious only from the chat must be written into the ticket; anything the repo already documents is referenced by path, not restated.\nEXCEPTION - verbatim payloads: when the user supplies literal content that must land in the ticket exactly (file contents, error logs, specs, commands), include it in the description IN FULL inside a fenced code block - the word budget applies to your own prose around it, never to the user\'s payload. Never summarize such content and never replace it with a placeholder like "[insert content here]": a placeholder makes the ticket unimplementable, because the implementing agent only ever sees the ticket. Inside the ```ticket JSON, fence such payloads with ~~~ (tildes), NEVER with triple backticks - a nested ``` would end the outer block early and corrupt the draft.\nEXCEPTION - several tickets at once: when the user asks for more than one ticket, asks for an epic with sub-tickets, or asks to ticket something clearly too large for one ticket, break it down and emit ONE ```ticket block of this shape:\n{"tickets": [{"summary": "\u2026", "description": "\u2026"}, \u2026]}\nAdd an "epic" key ONLY when the pieces genuinely belong under one parent goal:\n{"epic": {"summary": "\u2026", "description": "\u2026"}, "tickets": [ \u2026 ]}\nNever invent a parent to hold tickets that are simply independent - "make these three tickets" means three tickets, and the person chooses in the dashboard whether they become tasks, epics, or one epic with children. NEVER emit a second ```ticket block to add more tickets: only the last block in a reply is read, so a second one silently discards the first.\n3-8 tickets, each sized for ONE short agent run and structured with the same section headings as above, ordered so foundations come first; the epic description is the overall goal in under 100 words. When one ticket needs another from the SAME batch, reference it as "Ticket #N" (its position in the list) - Allwright rewrites those into the real Jira keys at creation, and any other phrasing survives as a dangling reference nobody can follow.\nRE-EMIT, never refer back: when the user asks for the ticket again, says it did not appear, or a quick action repeats the request, emit the COMPLETE ```ticket block again in that reply. The dashboard only acts on a block in the NEWEST reply, and a long earlier reply can be cut off in transport without you ever knowing - so "I already sent it" is never a valid answer, and explaining your capabilities instead of re-emitting the block is never what was asked.\nSIZE: a reply that outgrows the transport is cut off mid-block and creates NOTHING - and you cannot tell it happened, because your own memory holds the text you meant to send. So when several tickets will not fit, emit FEWER entries, complete, and say which ones you left out for a follow-up turn; never open a block you cannot finish, and never spend the budget on prose before it - the block comes last, so prose is what pushes it over the edge. A payload that lives in the repo is referenced by exact path, never inlined - the implementing agent has the checkout. A pasted payload too large to inline safely (more than ~200 lines) is distilled into the description sections instead; say plainly that you distilled it and ask the user to attach the original file to the ticket so nothing is lost.\n\nA MACHINE ACTION IS NOT A TICKET. When the answer is an action ON A MACHINE rather than a change to this repository - installing a package, restarting or enabling a service, a DNS record, storing a credential, a permissions or sudoers change - do NOT propose a ticket for it. An implement run has NO SHELL and is path-jailed to this checkout, so no agent can carry a machine action out: such a ticket sits in the backlog forever or fails its run. What the person needs is the exact command and which machine to run it on, so end your reply with EXACTLY one fenced block:\n```command\n{"server": "<machine name if known, else empty>", "why": "<one line: what this fixes>", "commands": ["<exact shell command>", "\u2026"]}\n```\nCommands are EXACT and copy-pasteable - no placeholders, no prose, at most 5. NEVER include a secret VALUE: write $NAMES and let the person supply them.\nNEVER invent a server name - leave "server" empty when you are not sure which machine it is. When part of the fix is a code change and part is a machine action, emit BOTH blocks - the ```ticket block for the code half, the ```command block for the machine half - and say in ONE line which half is which.';h.ChatLoadResultMsg=o.z.object({type:o.z.literal("chat.load.result"),requestId:o.z.string(),ok:o.z.boolean(),projectId:o.z.string().default(""),ownerUserId:o.z.string().default(""),agentId:o.z.string().default(""),messages:o.z.array(o.z.object({role:o.z.enum(["user","agent"]),text:o.z.string(),steps:o.z.array(o.z.string()).default([]),tokens:o.z.number().int().nonnegative().default(0),files:o.z.array(o.z.string()).default([]),at:o.z.string().default(""),ms:o.z.number().int().nonnegative().default(0)})).default([]),error:o.z.string().optional()});h.RepoDocsMsg=o.z.object({type:o.z.literal("repo.docs"),requestId:o.z.string(),projectId:o.z.string()});h.RepoDocsResultMsg=o.z.object({type:o.z.literal("repo.docs.result"),requestId:o.z.string(),ok:o.z.boolean(),docs:o.z.array(o.z.object({path:o.z.string(),sizeBytes:o.z.number().int().nonnegative().default(0),updatedAt:o.z.string().default("")})).default([]),error:o.z.string().optional()});h.RepoDocReadMsg=o.z.object({type:o.z.literal("repo.doc.read"),requestId:o.z.string(),projectId:o.z.string(),path:o.z.string().max(400)});h.RepoDocReadResultMsg=o.z.object({type:o.z.literal("repo.doc.read.result"),requestId:o.z.string(),ok:o.z.boolean(),path:o.z.string().default(""),content:o.z.string().default(""),truncated:o.z.boolean().default(!1),error:o.z.string().optional()});h.BoardFetchMsg=o.z.object({type:o.z.literal("board.fetch"),requestId:o.z.string(),projectId:o.z.string()});h.BoardFetchResultMsg=o.z.object({type:o.z.literal("board.fetch.result"),requestId:o.z.string(),ok:o.z.boolean(),browseBaseUrl:o.z.string().default(""),columns:o.z.array(o.z.object({name:o.z.string(),issues:o.z.array(o.z.object({key:o.z.string(),summary:o.z.string(),labels:o.z.array(o.z.string()).default([])})).default([])})).default([]),error:o.z.string().optional()});h.BoardTriggerMsg=o.z.object({type:o.z.literal("board.trigger"),requestId:o.z.string(),projectId:o.z.string(),issueKey:o.z.string(),comment:o.z.string().max(2e3).default(""),removeLabel:o.z.string().default(""),requestedBy:o.z.string().default(""),requestedByEmail:o.z.string().default(""),reimplement:o.z.boolean().default(!1),agentId:o.z.string().max(60).default("")});h.BoardTriggerResultMsg=o.z.object({type:o.z.literal("board.trigger.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional()});h.EpicListMsg=o.z.object({type:o.z.literal("epic.list"),requestId:o.z.string(),projectId:o.z.string(),epicKey:o.z.string().default("")});h.EpicChild=o.z.object({key:o.z.string(),summary:o.z.string(),status:o.z.string(),statusCategory:o.z.string(),labels:o.z.array(o.z.string()).default([])});h.EpicListResultMsg=o.z.object({type:o.z.literal("epic.list.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),epics:o.z.array(o.z.object({key:o.z.string(),summary:o.z.string(),status:o.z.string()})).default([]),children:o.z.array(h.EpicChild).default([])});h.EpicSuggestMsg=o.z.object({type:o.z.literal("epic.suggest"),requestId:o.z.string(),projectId:o.z.string(),epicKey:o.z.string().min(1),model:o.z.string().default("")});h.EpicSuggestResultMsg=o.z.object({type:o.z.literal("epic.suggest.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),issueKey:o.z.string().default(""),reason:o.z.string().default(""),considered:o.z.number().int().default(0)});h.AuditRole=o.z.enum(["security","testing","architecture","functional","engineering","incident","seo"]);h.KnowledgeRole=o.z.enum(["security","testing","architecture","functional","engineering","seo","incident","implement","compose"]);h.AuditSeverity=o.z.enum(["critical","high","medium","low","info"]);h.AuditScope=o.z.object({kind:o.z.enum(["repo","ticket","branch"]).default("repo"),ref:o.z.string().default("")});h.AuditDetailLevel=o.z.enum(["simple","technical"]);h.AuditFinding=o.z.object({id:o.z.string().min(1),title:o.z.string().min(1),ruleId:o.z.string().max(20).default(""),severity:h.AuditSeverity,area:o.z.string().default(""),evidence:o.z.array(o.z.object({file:o.z.string().min(1),line:o.z.number().int().positive().optional(),note:o.z.string().default("")})).min(1),fix:o.z.string().default("")});h.AuditRecord=o.z.object({id:o.z.string(),role:h.AuditRole,createdAt:o.z.string(),model:o.z.string().default(""),summary:o.z.string().default(""),packNames:o.z.array(o.z.string()).default([]),findings:o.z.array(h.AuditFinding).default([]),costUsd:o.z.number().default(0),inputTokens:o.z.number().int().nonnegative().default(0),outputTokens:o.z.number().int().nonnegative().default(0),cacheReadTokens:o.z.number().int().nonnegative().default(0),review:o.z.object({selected:o.z.array(o.z.string()),updatedAt:o.z.string()}).optional(),verdicts:o.z.record(o.z.object({verdict:o.z.enum(["valid","false-positive","wont-fix"]),note:o.z.string().default(""),by:o.z.string().default(""),at:o.z.string().default("")})).default({}),lessonsWritten:o.z.array(o.z.string()).default([]),ticketed:o.z.record(o.z.string()).default({}),scope:h.AuditScope.default({kind:"repo",ref:""}),detailLevel:h.AuditDetailLevel.default("technical"),testRun:o.z.array(o.z.object({command:o.z.string(),exitCode:o.z.number().int(),durationMs:o.z.number().int().default(0),tail:o.z.string().default("")})).optional()});h.AuditStartMsg=o.z.object({type:o.z.literal("audit.start"),requestId:o.z.string(),projectId:o.z.string(),role:h.AuditRole,model:o.z.string().default(""),scope:h.AuditScope.default({kind:"repo",ref:""}),detailLevel:h.AuditDetailLevel.default("technical"),baseUrl:o.z.string().default(""),brief:o.z.string().max(16e3).default("")});h.AuditStartResultMsg=o.z.object({type:o.z.literal("audit.start.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),audit:h.AuditRecord.optional()});h.AuditListMsg=o.z.object({type:o.z.literal("audit.list"),requestId:o.z.string(),projectId:o.z.string()});h.AuditStatsMsg=o.z.object({type:o.z.literal("audit.stats"),requestId:o.z.string(),projectIds:o.z.array(o.z.string()).max(200).default([]),since:o.z.string().default("")});h.AuditStatsResultMsg=o.z.object({type:o.z.literal("audit.stats.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),byProject:o.z.record(o.z.object({audits:o.z.number().int().default(0),findings:o.z.number().int().default(0),valid:o.z.number().int().default(0),falsePositive:o.z.number().int().default(0),wontFix:o.z.number().int().default(0),unreviewed:o.z.number().int().default(0)})).default({})});h.AuditListResultMsg=o.z.object({type:o.z.literal("audit.list.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),audits:o.z.array(o.z.object({id:o.z.string(),role:h.AuditRole,createdAt:o.z.string(),findingCount:o.z.number().int(),bySeverity:o.z.record(o.z.number().int()).default({}),costUsd:o.z.number().default(0),inputTokens:o.z.number().int().nonnegative().default(0),outputTokens:o.z.number().int().nonnegative().default(0),detailLevel:h.AuditDetailLevel.default("technical")})).default([])});h.ChatDiagnosticMsg=o.z.object({type:o.z.literal("chat.diagnostic"),requestId:o.z.string(),projectId:o.z.string(),command:o.z.string().max(40),args:o.z.record(o.z.unknown()).default({})});h.ChatDiagnosticResultMsg=o.z.object({type:o.z.literal("chat.diagnostic.result"),requestId:o.z.string(),ok:o.z.boolean().default(!0),commandLine:o.z.string().default(""),output:o.z.string().default("")});h.ChatStepRunMsg=o.z.object({type:o.z.literal("chat.step.run"),requestId:o.z.string(),projectId:o.z.string(),environmentName:o.z.string(),stepIndex:o.z.number().int().nonnegative(),stepName:o.z.string()});h.ChatStepRunResultMsg=o.z.object({type:o.z.literal("chat.step.run.result"),requestId:o.z.string(),ok:o.z.boolean().default(!0),stepName:o.z.string().default(""),commandLine:o.z.string().default(""),exitCode:o.z.number().int().default(0),timedOut:o.z.boolean().default(!1),output:o.z.string().default(""),error:o.z.string().default("")});h.ChatCancelMsg=o.z.object({type:o.z.literal("chat.cancel"),requestId:o.z.string(),turnId:o.z.string()});h.AuditExplainMsg=o.z.object({type:o.z.literal("audit.explain"),requestId:o.z.string(),projectId:o.z.string(),auditId:o.z.string(),findingId:o.z.string()});h.AuditExplainResultMsg=o.z.object({type:o.z.literal("audit.explain.result"),requestId:o.z.string(),ok:o.z.boolean().default(!0),error:o.z.string().default(""),explanation:o.z.string().default("")});h.AuditGetMsg=o.z.object({type:o.z.literal("audit.get"),requestId:o.z.string(),projectId:o.z.string(),auditId:o.z.string()});h.AuditGetResultMsg=o.z.object({type:o.z.literal("audit.get.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),audit:h.AuditRecord.optional()});h.AuditReviewMsg=o.z.object({type:o.z.literal("audit.review"),requestId:o.z.string(),projectId:o.z.string(),auditId:o.z.string(),selected:o.z.array(o.z.string()).optional(),ticketed:o.z.array(o.z.object({findingId:o.z.string(),issueKey:o.z.string()})).default([]),verdicts:o.z.array(o.z.object({findingId:o.z.string(),verdict:o.z.enum(["valid","false-positive","wont-fix"]),note:o.z.string().max(2e3).default("")})).default([]),verdictBy:o.z.string().default("")});h.AuditReviewResultMsg=o.z.object({type:o.z.literal("audit.review.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),audit:h.AuditRecord.optional()});h.KnowledgeListMsg=o.z.object({type:o.z.literal("knowledge.list"),requestId:o.z.string(),projectId:o.z.string()});h.KnowledgeFile=o.z.object({role:h.KnowledgeRole,level:o.z.enum(["global","org","project"]),source:o.z.enum(["pack","lessons","memory"]),name:o.z.string(),content:o.z.string(),editable:o.z.boolean().default(!1)});h.KnowledgeListResultMsg=o.z.object({type:o.z.literal("knowledge.list.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),files:o.z.array(h.KnowledgeFile).default([])});h.KnowledgeSaveMsg=o.z.object({type:o.z.literal("knowledge.save"),requestId:o.z.string(),projectId:o.z.string(),role:h.KnowledgeRole,level:o.z.enum(["org","project"]),source:o.z.enum(["pack","lessons"]),name:o.z.string().min(1).max(100),content:o.z.string().max(6e4),append:o.z.boolean().default(!1),by:o.z.string().default("")});h.KnowledgeSaveResultMsg=o.z.object({type:o.z.literal("knowledge.save.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional()});h.TeamCredsMsg=o.z.object({type:o.z.literal("team.creds"),requestId:o.z.string(),emails:o.z.array(o.z.string()).max(200)});h.TeamCredsResultMsg=o.z.object({type:o.z.literal("team.creds.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),githubShared:o.z.boolean().default(!1),sharedGithubLogin:o.z.string().default(""),entries:o.z.array(o.z.object({email:o.z.string(),jira:o.z.enum(["own","runner-account","missing"]),jiraAs:o.z.string().default(""),github:o.z.enum(["own","shared","missing"]),githubAs:o.z.string().default("")})).default([])});h.ChatFile=o.z.object({name:o.z.string().min(1).max(255),contentBase64:o.z.string().min(1).max(225e5)});h.ChatTurnMsg=o.z.object({type:o.z.literal("chat.turn"),requestId:o.z.string(),projectId:o.z.string(),sessionId:o.z.string().optional(),message:o.z.string().min(1).max(2e4),userName:o.z.string().default(""),userId:o.z.string().max(80).default(""),model:o.z.string().default(""),agentId:o.z.string().max(60).default(""),files:o.z.array(h.ChatFile).max(8).default([]),replyLanguage:o.z.string().max(60).default(""),replyLanguageInstruction:o.z.string().max(600).default(""),replyStyle:o.z.string().max(30).default(""),command:o.z.string().max(40).default(""),pendingMigrations:o.z.array(o.z.string().max(200)).max(50).default([]),monitorChecks:o.z.array(o.z.object({id:o.z.string().max(40),name:o.z.string().max(120),status:o.z.string().max(12).default("")})).max(40).default([]),operator:o.z.boolean().default(!1),environments:o.z.array(o.z.string().max(60)).max(20).default([]),environmentSteps:o.z.array(o.z.object({environment:o.z.string().max(60),steps:o.z.array(o.z.string().max(120)).max(40).default([])})).max(20).default([])});h.ChatTurnResultMsg=o.z.object({type:o.z.literal("chat.turn.result"),requestId:o.z.string(),ok:o.z.boolean(),sessionId:o.z.string().default(""),reply:o.z.string().default(""),error:o.z.string().optional(),inputTokens:o.z.number().int().nonnegative().default(0),outputTokens:o.z.number().int().nonnegative().default(0),cacheReadTokens:o.z.number().int().nonnegative().default(0),costUsd:o.z.number().nonnegative().default(0),model:o.z.string().max(200).default(""),contextTokens:o.z.number().int().nonnegative().default(0),contextLimit:o.z.number().int().nonnegative().default(0),compacted:o.z.boolean().default(!1),compactedMessages:o.z.number().int().nonnegative().default(0),outputTruncated:o.z.boolean().default(!1)});h.ChatCreateTicketMsg=o.z.object({type:o.z.literal("chat.create.ticket"),requestId:o.z.string(),projectId:o.z.string(),summary:o.z.string().min(1).max(250),description:o.z.string().default(""),triggerComment:o.z.string().default(""),requestedBy:o.z.string().default(""),requestedByEmail:o.z.string().default(""),asEpic:o.z.boolean().default(!1),children:o.z.array(o.z.object({summary:o.z.string().min(1),description:o.z.string().default("")})).max(20).default([]),createAs:o.z.enum(["epic_with_children","separate_epics","separate_tasks"]).default("epic_with_children"),files:o.z.array(h.ChatFile).max(8).default([]),component:o.z.string().max(120).default(""),chatSessionId:o.z.string().max(64).default(""),userId:o.z.string().max(80).default("")});h.ChatCreateTicketResultMsg=o.z.object({type:o.z.literal("chat.create.ticket.result"),requestId:o.z.string(),ok:o.z.boolean(),issueKey:o.z.string().default(""),error:o.z.string().optional(),childKeys:o.z.array(o.z.string()).default([])});h.EnvPreflightMsg=o.z.object({type:o.z.literal("env.preflight"),requestId:o.z.string(),projectId:o.z.string(),environmentName:o.z.string().default(""),steps:o.z.array(h.DeployStep).default([]),requiredSecrets:o.z.array(o.z.string()).default([]),workdir:o.z.string().default(""),branch:o.z.string().default(""),publicUrl:o.z.string().default("")});h.EnvPreflightResultMsg=o.z.object({type:o.z.literal("env.preflight.result"),requestId:o.z.string(),ok:o.z.boolean(),checks:o.z.array(o.z.object({name:o.z.string(),ok:o.z.boolean(),detail:o.z.string().default(""),kind:o.z.enum(["connection","content"]).default("connection"),fix:o.z.array(o.z.string()).default([]),fixNote:o.z.string().default("")})).default([])});h.SELF_MIGRATION_DIR="apps/api/prisma/manual";function o_(t){return/^[A-Za-z0-9][A-Za-z0-9._-]*\.sql$/.test(t)&&!t.includes("..")}h.SelfMigrationApplyMsg=o.z.object({type:o.z.literal("selfmigration.apply"),requestId:o.z.string(),projectId:o.z.string(),environmentName:o.z.string().default(""),file:o.z.string(),urlSecret:o.z.string().default("DATABASE_URL")});h.SelfMigrationApplyResultMsg=o.z.object({type:o.z.literal("selfmigration.apply.result"),requestId:o.z.string(),ok:o.z.boolean(),file:o.z.string().default(""),checks:o.z.array(o.z.object({name:o.z.string(),ok:o.z.boolean(),detail:o.z.string().default(""),fix:o.z.array(o.z.string()).default([])})).default([]),output:o.z.string().max(2e4).default(""),error:o.z.string().default("")});h.DeploySuggestResultMsg=o.z.object({type:o.z.literal("deploy.suggest.result"),requestId:o.z.string(),ok:o.z.boolean(),steps:o.z.array(h.DeployStep).default([]),requiredSecrets:o.z.array(o.z.string()).default([]),notes:o.z.string().default(""),error:o.z.string().optional(),docPath:o.z.string().default(""),docContent:o.z.string().max(1e5).default(""),fixTicketSummary:o.z.string().max(250).default(""),fixTicketDescription:o.z.string().max(2e4).default("")});h.SetupStatusMsg=o.z.object({type:o.z.literal("setup.status"),requestId:o.z.string(),repoNames:o.z.array(o.z.string()).max(100).default([])});h.SetupStatusResultMsg=o.z.object({type:o.z.literal("setup.status.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),jiraConfigured:o.z.boolean().default(!1),jiraEmail:o.z.string().default(""),serviceProtected:o.z.boolean().nullable().optional(),serviceProtectFix:o.z.string().max(500).default(""),agents:o.z.record(o.z.object({installed:o.z.boolean(),version:o.z.string().default(""),loggedIn:o.z.boolean()})).default({}),claude:o.z.object({installed:o.z.boolean(),version:o.z.string().default(""),loggedIn:o.z.boolean()}).optional(),githubTokenSet:o.z.boolean().default(!1),githubLogin:o.z.string().default(""),deploysEnabled:o.z.boolean().default(!1),jiraUserCount:o.z.number().int().default(0),repos:o.z.array(o.z.object({repoName:o.z.string(),path:o.z.string().default(""),mapped:o.z.boolean(),liveMapped:o.z.boolean().default(!0),pathExists:o.z.boolean().default(!1),currentBranch:o.z.string().default(""),isGit:o.z.boolean().default(!1),claudeMd:o.z.boolean().default(!1),deployMd:o.z.boolean().default(!1),testMd:o.z.boolean().default(!1),defaultBranch:o.z.string().default(""),githubToken:o.z.boolean().default(!1),githubTokenOwn:o.z.boolean().default(!1),architecture:o.z.object({languages:o.z.array(o.z.string()).max(4).default([]),frameworks:o.z.array(o.z.string()).max(6).default([]),databases:o.z.array(o.z.string()).max(4).default([]),docker:o.z.boolean().default(!1),dockerCompose:o.z.boolean().default(!1),packageManager:o.z.string().default(""),monorepo:o.z.string().default("")}).optional()})).default([])});h.RepoUnmapMsg=o.z.object({type:o.z.literal("repo.unmap"),requestId:o.z.string(),repoName:o.z.string()});h.RepoUnmapResultMsg=o.z.object({type:o.z.literal("repo.unmap.result"),requestId:o.z.string(),ok:o.z.boolean().default(!0),error:o.z.string().default(""),removedPath:o.z.string().default("")});h.SetupRecheckMsg=o.z.object({type:o.z.literal("setup.recheck"),requestId:o.z.string(),projectId:o.z.string(),environments:o.z.array(o.z.object({name:o.z.string(),branch:o.z.string().default(""),publicUrl:o.z.string().default(""),workdir:o.z.string().default(""),servePath:o.z.string().default("")})).default([])});h.SetupRecheckResultMsg=o.z.object({type:o.z.literal("setup.recheck.result"),requestId:o.z.string(),ok:o.z.boolean().default(!0),error:o.z.string().default(""),checks:o.z.array(o.z.object({environment:o.z.string().default(""),question:o.z.string(),ok:o.z.boolean(),detail:o.z.string().default(""),blocking:o.z.boolean().default(!0)})).default([])});h.SetupClaudeMdGenerateMsg=o.z.object({type:o.z.literal("setup.claudemd.generate"),requestId:o.z.string(),projectId:o.z.string(),kind:o.z.enum(["claude","deploy","design","unblock"]).default("claude"),blockers:o.z.array(o.z.string().max(400)).max(20).default([]),machineState:o.z.array(o.z.string().max(400)).max(40).default([]),streamId:o.z.string().default(""),environments:o.z.array(o.z.object({name:o.z.string(),branch:o.z.string().default(""),publicUrl:o.z.string().default(""),workdir:o.z.string().default(""),dedicatedCheckout:o.z.boolean().default(!1),onThisRunner:o.z.boolean().default(!0)})).default([])});h.SetupClaudeMdGenerateResultMsg=o.z.object({type:o.z.literal("setup.claudemd.generate.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),content:o.z.string().default(""),truncated:o.z.boolean().default(!1)});h.SetupAskMsg=o.z.object({type:o.z.literal("setup.ask"),requestId:o.z.string(),projectId:o.z.string(),subject:o.z.string().max(600).default(""),command:o.z.string().max(2e3).default(""),machineState:o.z.array(o.z.string().max(400)).max(40).default([]),history:o.z.array(o.z.object({role:o.z.enum(["user","agent"]),text:o.z.string().max(4e3)})).max(8).default([]),question:o.z.string().max(4e3)});h.SetupAskResultMsg=o.z.object({type:o.z.literal("setup.ask.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),answer:o.z.string().default("")});h.SetupClaudeMdSaveMsg=o.z.object({type:o.z.literal("setup.claudemd.save"),requestId:o.z.string(),projectId:o.z.string(),kind:o.z.enum(["claude","deploy","design"]).default("claude"),overwrite:o.z.boolean().default(!1),content:o.z.string().max(1e5)});h.SetupClaudeMdSaveResultMsg=o.z.object({type:o.z.literal("setup.claudemd.save.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),note:o.z.string().default("")});h.RepoDocSaveMsg=o.z.object({type:o.z.literal("repo.doc.save"),requestId:o.z.string(),projectId:o.z.string(),relPath:o.z.string().min(1).max(200),overwrite:o.z.boolean().default(!1),content:o.z.string().max(2e5)});h.RepoDocSaveResultMsg=o.z.object({type:o.z.literal("repo.doc.save.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),note:o.z.string().default("")});h.RunnerUpdateMsg=o.z.object({type:o.z.literal("runner.update"),requestId:o.z.string(),version:o.z.string().max(20).default("")});h.RunnerUninstallMsg=o.z.object({type:o.z.literal("runner.uninstall"),requestId:o.z.string()});h.RunResolveConflictMsg=o.z.object({type:o.z.literal("run.resolve.conflict"),requestId:o.z.string(),runId:o.z.string()});h.RunTestFixMsg=o.z.object({type:o.z.literal("run.testfix"),requestId:o.z.string(),runId:o.z.string(),failedTests:o.z.array(h.FailedTest).max(20).default([]),finding:o.z.object({id:o.z.string().max(200),title:o.z.string().max(300),detail:o.z.string().max(8e3)}).optional()});h.RunTestFixResultMsg=o.z.object({type:o.z.literal("run.testfix.result"),requestId:o.z.string(),ok:o.z.boolean(),note:o.z.string().default(""),headSha:o.z.string().default(""),remaining:o.z.array(h.FailedTest).default([]),costUsd:o.z.number().nonnegative().optional(),inputTokens:o.z.number().int().nonnegative().optional(),outputTokens:o.z.number().int().nonnegative().optional()});h.RunAnswerMsg=o.z.object({type:o.z.literal("run.answer"),requestId:o.z.string(),runId:o.z.string(),text:o.z.string().min(1).max(4e3),answeredBy:o.z.string().default("")});h.RunAnswerResultMsg=o.z.object({type:o.z.literal("run.answer.result"),requestId:o.z.string(),ok:o.z.boolean(),note:o.z.string().default(""),error:o.z.string().optional()});h.RunResolveConflictResultMsg=o.z.object({type:o.z.literal("run.resolve.conflict.result"),requestId:o.z.string(),ok:o.z.boolean(),note:o.z.string().default(""),freeOfCharge:o.z.boolean().default(!1),headSha:o.z.string().default(""),costUsd:o.z.number().nonnegative().optional(),inputTokens:o.z.number().int().nonnegative().optional(),outputTokens:o.z.number().int().nonnegative().optional()});h.RunPrConflictMsg=o.z.object({type:o.z.literal("run.pr.conflict"),runId:o.z.string(),conflicted:o.z.boolean()});h.AgentProfilesMsg=o.z.object({type:o.z.literal("agent.profiles"),requestId:o.z.string()});h.AgentProfilesResultMsg=o.z.object({type:o.z.literal("agent.profiles.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),profiles:o.z.array(o.z.object({agent:o.z.string(),name:o.z.string(),loggedIn:o.z.boolean()})).max(200).default([]),defaultLoggedIn:o.z.boolean().default(!1),agentsWithoutProfiles:o.z.array(o.z.string()).max(20).default([])});h.RunnerUpdateResultMsg=o.z.object({type:o.z.literal("runner.update.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),note:o.z.string().default(""),scheduled:o.z.boolean().default(!1)});h.RunnerUninstallResultMsg=o.z.object({type:o.z.literal("runner.uninstall.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),note:o.z.string().default(""),serviceRemoved:o.z.boolean().default(!1),configRemoved:o.z.boolean().default(!1)});h.AutopilotNextMsg=o.z.object({type:o.z.literal("autopilot.next"),requestId:o.z.string()});h.AutopilotPlanMsg=o.z.object({type:o.z.literal("autopilot.plan"),requestId:o.z.string(),projectId:o.z.string(),batchId:o.z.string(),issueKeys:o.z.array(o.z.string()).min(1).max(50)});h.AutopilotPlanResultMsg=o.z.object({type:o.z.literal("autopilot.plan.result"),requestId:o.z.string(),ok:o.z.boolean().default(!0),error:o.z.string().default(""),order:o.z.array(o.z.string()).default([]),chains:o.z.array(o.z.array(o.z.string())).default([]),dependencies:o.z.array(o.z.tuple([o.z.string(),o.z.string()])).default([]),reasoning:o.z.string().default("")});h.AutopilotNextResultMsg=o.z.object({type:o.z.literal("autopilot.next.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),item:o.z.object({id:o.z.string(),projectId:o.z.string(),issueKey:o.z.string(),ruleId:o.z.string(),baseOverride:o.z.string().default(""),branchOverride:o.z.string().default(""),continueBranch:o.z.boolean().default(!1),batchId:o.z.string().default(""),autoMerge:o.z.boolean().default(!1),remainingInBatch:o.z.number().int().min(0).default(0),agentId:o.z.string().max(60).default("")}).nullable().default(null),pausedUntil:o.z.string().default("")});h.AutopilotReportMsg=o.z.object({type:o.z.literal("autopilot.report"),requestId:o.z.string(),itemId:o.z.string(),outcome:o.z.enum(["claimed","failed","paused"]),runId:o.z.string().default(""),error:o.z.string().default("")});h.ServerInventoryMsg=o.z.object({type:o.z.literal("server.inventory"),requestId:o.z.string()});h.ServerInventoryResultMsg=o.z.object({type:o.z.literal("server.inventory.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),checkouts:o.z.array(o.z.object({path:o.z.string(),repoName:o.z.string().default(""),remoteUrl:o.z.string().default(""),branch:o.z.string().default("")})).max(60).default([]),services:o.z.array(o.z.object({name:o.z.string(),description:o.z.string().default(""),active:o.z.string().default("")})).max(150).default([]),containers:o.z.array(o.z.object({name:o.z.string(),image:o.z.string().default(""),status:o.z.string().default(""),ports:o.z.string().default("")})).max(60).default([]),ports:o.z.array(o.z.object({port:o.z.number().int().nonnegative(),process:o.z.string().default(""),pid:o.z.number().int().nonnegative().default(0)})).max(150).default([]),processes:o.z.array(o.z.object({pid:o.z.number().int().nonnegative(),user:o.z.string().default(""),cpuPct:o.z.number().default(0),memPct:o.z.number().default(0),command:o.z.string().default("")})).max(40).default([])});h.MonitorResultMsg=o.z.object({type:o.z.literal("monitor.result"),resultId:o.z.string().max(120),checkId:o.z.string(),ranAt:o.z.string(),status:h.MonitorStatus,late:o.z.boolean().default(!1),summary:o.z.string().max(300).default(""),metricsJson:o.z.string().max(8e3).default(""),excerpt:o.z.string().max(4e3).default(""),durationMs:o.z.number().int().nonnegative().default(0)});h.MonitorRunMsg=o.z.object({type:o.z.literal("monitor.run"),requestId:o.z.string(),checkId:o.z.string()});h.MonitorRunResultMsg=o.z.object({type:o.z.literal("monitor.run.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional()});h.MonitorSuggestMsg=o.z.object({type:o.z.literal("monitor.suggest"),requestId:o.z.string(),projectId:o.z.string(),notes:o.z.string().min(1).max(2e3)});h.MonitorSuggestResultMsg=o.z.object({type:o.z.literal("monitor.suggest.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),name:o.z.string().max(120).default(""),commands:o.z.array(h.MonitorCommand).max(20).default([]),parseRules:h.MonitorParseRules.default({}),schedule:h.MonitorSchedule.optional(),notes:o.z.string().max(2e3).default("")});h.MonitorRebaselineMsg=o.z.object({type:o.z.literal("monitor.rebaseline"),requestId:o.z.string(),checkId:o.z.string()});h.MonitorRebaselineResultMsg=o.z.object({type:o.z.literal("monitor.rebaseline.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional()});h.MonitorDiscoverMsg=o.z.object({type:o.z.literal("monitor.discover"),requestId:o.z.string()});h.MonitorDiscoverResultMsg=o.z.object({type:o.z.literal("monitor.discover.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),os:o.z.object({platform:o.z.string().default(""),arch:o.z.string().default(""),release:o.z.string().default("")}).default({}),services:o.z.array(o.z.object({name:o.z.string().max(120),kind:o.z.string().max(40).default("")})).max(40).default([]),webServers:o.z.array(o.z.string().max(20)).max(10).default([]),backupCandidates:o.z.array(o.z.object({path:o.z.string().max(400),newestFile:o.z.string().max(200).default(""),newestAgeHours:o.z.number().nonnegative().default(0),sizeMB:o.z.number().nonnegative().default(0)})).max(20).default([]),dbHints:o.z.array(o.z.object({kind:o.z.string().max(20),port:o.z.number().int().nonnegative().default(0)})).max(10).default([])});h.ServerDecommissionPlanMsg=o.z.object({type:o.z.literal("server.decommission.plan"),requestId:o.z.string(),path:o.z.string().min(1).max(500)});h.ServerDecommissionPlanResultMsg=o.z.object({type:o.z.literal("server.decommission.plan.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),path:o.z.string().default(""),sizeMb:o.z.number().default(0),services:o.z.array(o.z.object({name:o.z.string(),detail:o.z.string().default("")})).max(30).default([]),processes:o.z.array(o.z.object({pid:o.z.number().int().nonnegative(),command:o.z.string().default(""),ports:o.z.array(o.z.number().int()).max(20).default([])})).max(50).default([]),containers:o.z.array(o.z.object({name:o.z.string(),image:o.z.string().default("")})).max(30).default([]),databases:o.z.array(o.z.object({name:o.z.string(),engine:o.z.string(),source:o.z.string()})).max(10).default([]),warnings:o.z.array(o.z.string().max(300)).max(20).default([])});h.ServerDecommissionExecuteMsg=o.z.object({type:o.z.literal("server.decommission.execute"),requestId:o.z.string(),opToken:o.z.string().min(1).max(60),path:o.z.string().min(1).max(500),deleteFolder:o.z.boolean().default(!0),services:o.z.array(o.z.string().max(120)).max(30).default([]),pids:o.z.array(o.z.number().int().positive()).max(50).default([]),containers:o.z.array(o.z.string().max(120)).max(30).default([]),databases:o.z.array(o.z.string().max(120)).max(10).default([])});h.ServerDecommissionResultMsg=o.z.object({type:o.z.literal("server.decommission.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional()});h.ServerDecommissionProgressMsg=o.z.object({type:o.z.literal("server.decommission.progress"),opToken:o.z.string(),step:o.z.object({label:o.z.string().max(200),ok:o.z.boolean(),detail:o.z.string().max(500).default("")}).optional(),done:o.z.boolean().default(!1),error:o.z.string().max(500).default("")});h.SiteAuditMsg=o.z.object({type:o.z.literal("site.audit"),requestId:o.z.string(),url:o.z.string().min(4).max(500)});h.SiteAuditResultMsg=o.z.object({type:o.z.literal("site.audit.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),url:o.z.string().default(""),overall:o.z.number().default(0),categories:o.z.array(o.z.object({key:o.z.string(),label:o.z.string(),score:o.z.number().nullable()})).max(10).default([]),checks:o.z.array(o.z.object({id:o.z.string(),category:o.z.string(),label:o.z.string().max(200),status:o.z.enum(["pass","warn","fail","info"]),detail:o.z.string().max(500).default("")})).max(100).default([])});h.RebirthUploadBeginMsg=o.z.object({type:o.z.literal("rebirth.upload.begin"),requestId:o.z.string(),rebirthId:o.z.string(),kind:o.z.enum(["frontend","backend","docs","dump"]),name:o.z.string().min(1).max(200),sizeBytes:o.z.number().int().positive().max(2*1024*1024*1024)});h.RebirthUploadBeginResultMsg=o.z.object({type:o.z.literal("rebirth.upload.begin.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),uploadId:o.z.string().default("")});h.RebirthUploadChunkMsg=o.z.object({type:o.z.literal("rebirth.upload.chunk"),requestId:o.z.string(),uploadId:o.z.string(),seq:o.z.number().int().nonnegative(),dataBase64:o.z.string().max(6e6),last:o.z.boolean().default(!1)});h.RebirthUploadChunkResultMsg=o.z.object({type:o.z.literal("rebirth.upload.chunk.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional(),storedPath:o.z.string().default(""),note:o.z.string().default("")});h.RebirthDesignMsg=o.z.object({type:o.z.literal("rebirth.design"),requestId:o.z.string(),projectId:o.z.string(),rebirthId:o.z.string(),spec:o.z.string().max(1e5).default(""),brief:o.z.string().max(6e4).default(""),refineMessage:o.z.string().max(1e4).default(""),currentDirection:o.z.string().max(1e5).default(""),screenName:o.z.string().max(80).default(""),screenBrief:o.z.string().max(4e3).default(""),currentScreenHtml:o.z.string().max(2e5).default(""),specOnly:o.z.boolean().default(!1),screenSpec:o.z.string().max(3e4).default(""),existingScreenNames:o.z.array(o.z.string().max(80)).max(60).default([]),referenceScreenHtml:o.z.string().max(2e5).default(""),stackOnly:o.z.boolean().default(!1),currentStack:o.z.string().max(4e4).default("")});h.RebirthDesignResultMsg=o.z.object({type:o.z.literal("rebirth.design.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional()});h.TimelineDigestMsg=o.z.object({type:o.z.literal("timeline.digest"),requestId:o.z.string(),projectId:o.z.string(),prompt:o.z.string().min(1).max(6e4)});h.TimelineDigestResultMsg=o.z.object({type:o.z.literal("timeline.digest.result"),requestId:o.z.string(),ok:o.z.boolean(),text:o.z.string().default(""),error:o.z.string().optional()});h.RebirthStudyMsg=o.z.object({type:o.z.literal("rebirth.study"),requestId:o.z.string(),projectId:o.z.string(),rebirthId:o.z.string(),dbDumpPath:o.z.string().max(500).default(""),legacyJiraKey:o.z.string().max(30).default(""),legacyJiraSiteUrl:o.z.string().max(300).default(""),maxJiraIssues:o.z.number().int().min(0).max(2e3).default(0),extraContext:o.z.string().max(6e4).default(""),gdprRequired:o.z.boolean().default(!1),refineMessage:o.z.string().max(32e3).default(""),refineScope:o.z.enum(["all","brief","understanding","requirements","spec"]).default("all"),currentDocsIncluded:o.z.boolean().default(!1),currentBrief:o.z.string().max(1e5).default(""),currentUnderstanding:o.z.string().max(2e5).default(""),currentRequirements:o.z.string().max(2e5).default(""),currentSpec:o.z.string().max(2e5).default("")});h.RebirthStudyUpdateMsg=o.z.object({type:o.z.literal("rebirth.study.update"),rebirthId:o.z.string(),stageNumber:o.z.number().int().min(1).max(8),status:o.z.enum(["in_progress","done","failed","skipped"]),note:o.z.string().max(500).default(""),progressDone:o.z.number().int().nonnegative().default(0),progressTotal:o.z.number().int().nonnegative().default(0),artifact:o.z.string().max(2e5).default(""),items:o.z.array(o.z.object({title:o.z.string().max(300),detail:o.z.string().max(4e3).default("")})).max(60).default([]),design:o.z.object({direction:o.z.string().max(1e5).default(""),screens:o.z.array(o.z.object({name:o.z.string().max(80),html:o.z.string().max(2e5)})).max(8).default([]),inventory:o.z.array(o.z.object({name:o.z.string().max(80),note:o.z.string().max(200).default("")})).max(40).default([]),specs:o.z.array(o.z.object({name:o.z.string().max(80),doc:o.z.string().max(3e4)})).max(8).default([]),partial:o.z.boolean().default(!1)}).optional(),brief:o.z.string().max(1e5).default(""),techStack:o.z.string().max(4e4).optional(),proposal:o.z.object({message:o.z.string().max(32e3).default(""),scope:o.z.enum(["all","brief","understanding","requirements","spec"]).default("all"),docs:o.z.array(o.z.object({doc:o.z.enum(["brief","understanding","requirements","spec"]),proposed:o.z.string().max(2e5)})).max(4).default([]),tickets:o.z.array(o.z.object({title:o.z.string().max(300),detail:o.z.string().max(4e3).default("")})).max(60).default([]),working:o.z.boolean().default(!1),error:o.z.string().max(2e3).default("")}).optional(),runFinished:o.z.object({kind:o.z.enum(["study","refine","design","screen","techstack"]).default("study"),ok:o.z.boolean().default(!0),error:o.z.string().max(2e3).default("")}).optional(),usageDelta:o.z.object({inputTokens:o.z.number().int().nonnegative().default(0),outputTokens:o.z.number().int().nonnegative().default(0),cacheReadTokens:o.z.number().int().nonnegative().default(0),costUsd:o.z.number().nonnegative().default(0)}).default({inputTokens:0,outputTokens:0,cacheReadTokens:0,costUsd:0})});h.RebirthStudyResultMsg=o.z.object({type:o.z.literal("rebirth.study.result"),requestId:o.z.string(),ok:o.z.boolean(),error:o.z.string().optional()});h.RunnerToServerMsg=o.z.discriminatedUnion("type",[h.HelloMsg,h.HeartbeatMsg,h.RunClaimMsg,h.RunLogMsg,h.RunContextMsg,h.RunUsageMsg,h.RunStatusMsg,h.ProjectTestResultMsg,h.RuleDiagnoseResultMsg,h.DeployClaimMsg,h.DeploySuggestResultMsg,h.EnvPreflightResultMsg,h.SelfMigrationApplyResultMsg,h.ChatTurnResultMsg,h.ChatStreamMsg,h.ChatUsageMsg,h.ChatSessionMsg,h.ChatActivityMsg,h.ChatCreateTicketResultMsg,h.ChatListResultMsg,h.RepoDocsResultMsg,h.RepoDocReadResultMsg,h.ChatLoadResultMsg,h.BoardFetchResultMsg,h.BoardTriggerResultMsg,h.TeamCredsResultMsg,h.AuditStartResultMsg,h.AuditListResultMsg,h.AuditGetResultMsg,h.AuditExplainResultMsg,h.AuditReviewResultMsg,h.KnowledgeListResultMsg,h.KnowledgeSaveResultMsg,h.EpicListResultMsg,h.EpicSuggestResultMsg,h.JiraUsersResultMsg,h.SetupStatusResultMsg,h.SetupClaudeMdGenerateResultMsg,h.SetupAskResultMsg,h.SetupRecheckResultMsg,h.RepoUnmapResultMsg,h.SetupClaudeMdSaveResultMsg,h.RepoDocSaveResultMsg,h.RunnerUpdateResultMsg,h.RunnerUninstallResultMsg,h.AgentProfilesResultMsg,h.RunPrConflictMsg,h.RunResolveConflictResultMsg,h.RunTestFixResultMsg,h.RunAnswerResultMsg,h.AuditStatsResultMsg,h.AutopilotNextMsg,h.AutopilotReportMsg,h.AutopilotPlanResultMsg,h.ChatDiagnosticResultMsg,h.ChatStepRunResultMsg,h.ServerInventoryResultMsg,h.ServerDecommissionPlanResultMsg,h.SiteAuditResultMsg,h.RebirthUploadBeginResultMsg,h.RebirthDesignResultMsg,h.RebirthUploadChunkResultMsg,h.ServerDecommissionResultMsg,h.ServerDecommissionProgressMsg,h.TimelineDigestResultMsg,h.RebirthStudyUpdateMsg,h.RebirthStudyResultMsg,h.MonitorResultMsg,h.MonitorRunResultMsg,h.MonitorDiscoverResultMsg,h.MonitorRebaselineResultMsg,h.MonitorSuggestResultMsg,h.AiSpendMsg]);h.HelloAckMsg=o.z.object({type:o.z.literal("hello.ack"),runnerId:o.z.string(),runnerName:o.z.string(),serverTime:o.z.string()});h.ConfigMsg=o.z.object({type:o.z.literal("config"),projects:o.z.array(h.ProjectConfig),rules:o.z.array(h.RuleConfig),environments:o.z.array(h.EnvironmentConfig).default([]),monitors:o.z.array(h.MonitorCheckConfig).default([]),pollingPaused:o.z.boolean().default(!1),publicIp:o.z.string().default("")});h.RunClaimResultMsg=o.z.object({type:o.z.literal("run.claim.result"),requestId:o.z.string(),accepted:o.z.boolean(),runId:o.z.string().optional(),reason:o.z.string().optional(),claudeProfile:o.z.string().optional(),actorEmail:o.z.string().optional()});h.ProjectTestMsg=o.z.object({type:o.z.literal("project.test"),requestId:o.z.string(),projectId:o.z.string()});h.RuleDiagnoseMsg=o.z.object({type:o.z.literal("rule.diagnose"),requestId:o.z.string(),ruleId:o.z.string()});h.RunCancelMsg=o.z.object({type:o.z.literal("run.cancel"),runId:o.z.string()});h.RunApprovedMsg=o.z.object({type:o.z.literal("run.approved"),runId:o.z.string(),headSha:o.z.string().optional()});h.RunRejectedMsg=o.z.object({type:o.z.literal("run.rejected"),runId:o.z.string()});h.RunRetryPushMsg=o.z.object({type:o.z.literal("run.retryPush"),runId:o.z.string()});h.DeployStartMsg=o.z.object({type:o.z.literal("deploy.start"),runId:o.z.string(),projectId:o.z.string(),issueKey:o.z.string(),issueSummary:o.z.string().default(""),environment:h.EnvironmentConfig,requestedBy:o.z.string().default(""),attempt:o.z.number().int().positive().default(1)});h.DeployFixMsg=o.z.object({type:o.z.literal("deploy.fix"),requestId:o.z.string(),projectId:o.z.string(),environmentName:o.z.string(),steps:o.z.array(o.z.object({name:o.z.string(),run:o.z.string(),continueOnError:o.z.boolean().default(!1)})),failedStep:o.z.string().default(""),errorText:o.z.string().max(8e3).default("")});h.DeploySuggestMsg=o.z.object({type:o.z.literal("deploy.suggest"),requestId:o.z.string(),projectId:o.z.string(),environmentName:o.z.string(),notes:o.z.string().default(""),timeoutSeconds:o.z.number().int().positive().max(1800).default(300)});h.JiraUsersMsg=o.z.object({type:o.z.literal("jira.users"),requestId:o.z.string(),query:o.z.string().default("")});h.ServerToRunnerMsg=o.z.discriminatedUnion("type",[h.HelloAckMsg,h.ConfigMsg,h.ServerInventoryMsg,h.ServerDecommissionPlanMsg,h.SiteAuditMsg,h.RebirthUploadBeginMsg,h.RebirthDesignMsg,h.RebirthUploadChunkMsg,h.ServerDecommissionExecuteMsg,h.TimelineDigestMsg,h.RebirthStudyMsg,h.RunClaimResultMsg,h.ProjectTestMsg,h.RuleDiagnoseMsg,h.RunCancelMsg,h.RunApprovedMsg,h.RunRejectedMsg,h.RunRetryPushMsg,h.DeployClaimResultMsg,h.DeployStartMsg,h.DeploySuggestMsg,h.DeployFixMsg,h.EnvPreflightMsg,h.SelfMigrationApplyMsg,h.ChatTurnMsg,h.ChatCreateTicketMsg,h.ChatListMsg,h.RepoDocsMsg,h.RepoDocReadMsg,h.ChatLoadMsg,h.BoardFetchMsg,h.BoardTriggerMsg,h.TeamCredsMsg,h.AuditStartMsg,h.AuditListMsg,h.AuditGetMsg,h.AuditExplainMsg,h.ChatCancelMsg,h.ChatDiagnosticMsg,h.ChatStepRunMsg,h.AuditReviewMsg,h.KnowledgeListMsg,h.KnowledgeSaveMsg,h.EpicListMsg,h.EpicSuggestMsg,h.JiraUsersMsg,h.SetupStatusMsg,h.SetupClaudeMdGenerateMsg,h.SetupAskMsg,h.SetupRecheckMsg,h.RepoUnmapMsg,h.SetupClaudeMdSaveMsg,h.RepoDocSaveMsg,h.RunnerUpdateMsg,h.RunnerUninstallMsg,h.AgentProfilesMsg,h.RunResolveConflictMsg,h.RunTestFixMsg,h.RunAnswerMsg,h.AuditStatsMsg,h.AutopilotNextResultMsg,h.AutopilotPlanMsg,h.MonitorRunMsg,h.MonitorDiscoverMsg,h.MonitorRebaselineMsg,h.MonitorSuggestMsg]);h.EnrollRequest=o.z.object({enrollToken:o.z.string().min(10),name:o.z.string().min(1).max(100),platform:o.z.string(),runnerVersion:o.z.string()});h.EnrollResponse=o.z.object({runnerId:o.z.string(),runnerToken:o.z.string(),controlPlaneWsUrl:o.z.string()});function a_(t){return h.RunnerToServerMsg.parse(t)}function c_(t){return h.ServerToRunnerMsg.parse(t)}h.DEFAULT_PLAN_PROMPT_TEMPLATE=`You are a senior engineer asked to assess a Jira ticket. You have read-only access to the repository - do not attempt to modify anything.
72
72
 
73
73
  Ticket {{issueKey}}: {{summary}}
74
74
 
@@ -1266,7 +1266,7 @@ ${p}`)}je(["systemctl","reload","nginx"]),b.info(`\u2713 nginx: ${t.hostname} \u
1266
1266
  `).map(g=>g.trim()).filter(g=>g&&!/^(PRIMARY|UNIQUE|KEY|CONSTRAINT|FOREIGN|INDEX)/i.test(g)).map(g=>g.split(/\s+/)[0].replace(/[`",]/g,"")).filter(Boolean);c.push({name:u[1],columns:f,rows:0})}for(let u of c){let p=u.name.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),f=0;for(let v of e.matchAll(new RegExp(`INSERT INTO [\`"]?${p}[\`"]?[^;]*;`,"gi")))f+=(v[0].match(/\),\s*\(/g)?.length??0)+1;let g=e.match(new RegExp(`COPY [\`"]?${p}[\`"]?[^\\n]*FROM stdin;\\n([\\s\\S]*?)\\n\\\\\\.`,"i"));g&&(f+=g[1].split(`
1267
1267
  `).filter(Boolean).length),u.rows=f}let l=["# Data profile (from the dump, by code - no database was connected)","",`${c.length} table(s) found in \`${t}\`${a?" (large dump - schema read from its head; row counts are minimums)":""}.`,"",`| Table | Columns | Rows${a?" (\u2265)":""} |`,"| --- | --- | --- |",...c.sort((u,p)=>p.rows-u.rows).map(u=>`| ${u.name} | ${u.columns.length} | ${u.rows.toLocaleString()} |`),"","## Columns",...c.map(u=>`- **${u.name}**: ${u.columns.join(", ")||"(none parsed)"}`)];return{ok:c.length>0,markdown:l.join(`
1268
1268
  `).slice(0,6e4),tables:c.length}}catch(n){return{ok:!1,markdown:`Could not read the dump at \`${t}\`: ${n instanceof Error?n.message:n}`,tables:0}}}function No(t,e){let n=t.trim().length,r=e.trim().length;return n<2e3||r>=n*.9?"":` WARNING: it came back ${Math.round(100-r/n*100)}% smaller than the current version - check the diff for lost detail before approving.`}function gr(t,e){let r=new RegExp("```"+e+"\\n([\\s\\S]*?)```","").exec(t);return r?{block:r[1].trim(),rest:t.replace(r[0],"").trim()}:{block:"",rest:t}}function NA(t,e,n,r){t.send({type:"rebirth.study.update",rebirthId:e,stageNumber:1,status:"in_progress",note:"",progressDone:0,progressTotal:0,artifact:"",items:[],brief:"",runFinished:{kind:n,ok:r.ok,error:(r.error??"").slice(0,2e3)},usageDelta:{inputTokens:0,outputTokens:0,cacheReadTokens:0,costUsd:0}})}async function MA(t){let{msg:e,transport:n}=t;if(Bc.has(e.rebirthId))return{ok:!1,error:"a study is already running for this rebirth - it reports as it goes"};Bc.add(e.rebirthId);let r={inputTokens:0,outputTokens:0,cacheReadTokens:0,costUsd:0},s=i=>{let a=r;r={inputTokens:0,outputTokens:0,cacheReadTokens:0,costUsd:0},n.send({type:"rebirth.study.update",rebirthId:e.rebirthId,stageNumber:i.stageNumber,status:i.status,note:i.note??"",progressDone:i.progressDone??0,progressTotal:i.progressTotal??0,artifact:i.artifact??"",items:i.items??[],brief:i.brief??"",...i.proposal?{proposal:i.proposal}:{},usageDelta:a})};try{let i=$e(t.cfg,t.project,"assist");if("error"in i)return{ok:!1,error:i.error};let a=(0,Kc.randomUUID)(),c=!1,l=e.refineMessage.trim()?"rebirth_refold":"rebirth_study",u=async(_,$,D=60)=>{let z=await i.adapter.run({repoPath:t.repoPath,prompt:_,timeoutSeconds:$*60,bin:i.bin,mode:"read_only",maxTurns:D,sessionId:a,resume:c,onLog:()=>{}});return c=!0,be({surface:l,projectId:t.project.id,agentId:i.adapter.id,refKind:"rebirth",refId:e.rebirthId,...we(z)}),r={inputTokens:r.inputTokens+(z.inputTokens??0),outputTokens:r.outputTokens+(z.outputTokens??0),cacheReadTokens:r.cacheReadTokens+(z.cacheReadTokens??0),costUsd:r.costUsd+(z.costUsd??0)},z};if(e.refineMessage.trim()){let _=e.refineScope,$=(L,V)=>s({stageNumber:4,status:"in_progress",note:V,proposal:{message:e.refineMessage,scope:_,docs:L.docs??[],tickets:L.tickets??[],working:L.working??!1,error:L.error??""}});if(!e.currentDocsIncluded){let L="refine refused: this control plane does not send the current documents with a correction, so the refine would rewrite the plan from scratch and lose everything the correction does not mention. Update the control plane, then refine again.";return s({stageNumber:4,status:"failed",note:L}),{ok:!1,error:L}}$({working:!0},"Folding your correction into the plan - the result comes back as proposed changes for your review\u2026"),c=!1;let D=await u(PA(e.refineMessage,{brief:e.currentBrief,understanding:e.currentUnderstanding,requirements:e.currentRequirements,spec:e.currentSpec},_),60,150);if(!D.ok||!D.resultText.trim())return $({error:D.error??"the refine pass produced nothing"},"The refold failed - nothing was changed"),{ok:!1,error:D.error??"the refine pass produced nothing"};let z=gr(D.resultText,"brief"),A=gr(z.rest,"understanding"),P=gr(A.rest,"requirements"),w=L=>_==="all"||_===L,j=[],W=[];if(w("brief")&&z.block&&j.push({doc:"brief",proposed:z.block.slice(0,1e5)}),w("understanding")&&A.block&&j.push({doc:"understanding",proposed:A.block.slice(0,2e5)}),w("requirements")&&P.block&&j.push({doc:"requirements",proposed:P.block.slice(0,2e5)}),w("spec")&&P.rest.trim()){let L=kh(P.rest);L.spec.trim()&&(j.push({doc:"spec",proposed:L.spec}),W=L.tickets)}return j.length?($({docs:j,tickets:W},"Refold ready - review the proposed changes (nothing applied yet)"),{ok:!0}):($({error:"the refold answer held no usable document block - try again"},"The refold failed - nothing was changed"),{ok:!1,error:"no usable document block in the refold answer"})}let p=[];if(t.repoAvailable){s({stageNumber:1,status:"in_progress",note:"Reading the codebase - this is the long part"});let _=await u(IA(e.currentUnderstanding),20);!_.ok||!_.resultText.trim()?(s({stageNumber:1,status:"failed",note:_.error??"the study pass produced nothing"}),p.push("the code study failed - its findings are not in this plan")):s({stageNumber:1,status:"done",note:"Codebase studied"+No(e.currentUnderstanding,_.resultText),artifact:_.resultText.trim().slice(0,1e5)})}else s({stageNumber:1,status:"skipped",note:"no code yet - map the legacy checkout on the runner (allwright repo add) and re-run the study to fold it in"}),p.push("the CODE was not available - nothing here is based on reading it");if(e.dbDumpPath.trim()){s({stageNumber:2,status:"in_progress",note:`Profiling the dump at ${e.dbDumpPath}`});let _=av(e.dbDumpPath.trim());s({stageNumber:2,status:_.ok?"done":"failed",note:_.ok?`${_.tables} table(s) profiled`:"the dump could not be profiled",artifact:_.markdown})}else s({stageNumber:2,status:"skipped",note:"no DB dump given - add one and re-run the study to profile the data"}),p.push("the DATABASE was not profiled - data shapes in this plan are inferred, not read");let f=!1;if(e.legacyJiraKey.trim()&&t.jira){let _=e.legacyJiraKey.trim().toUpperCase(),$=Math.min(2e3,Math.max(50,e.maxJiraIssues||ov));s({stageNumber:3,status:"in_progress",note:`Reading ${_} tickets - 0/?`,progressDone:0});try{let z=(await t.jira.searchHistory(`project = ${_} ORDER BY created DESC`,{max:$,pageSize:RA,onPage:A=>s({stageNumber:3,status:"in_progress",note:`Reading ${_} tickets - ${A} read (max ${$})`,progressDone:A,progressTotal:$})})).map(A=>`${A.key} [${A.status}] ${A.summary}`);if(z.length){s({stageNumber:3,status:"in_progress",note:`Distilling ${z.length} tickets into the requirements ledger\u2026`,progressDone:z.length,progressTotal:z.length});let A=await u(EA(z.join(`
1269
- `).slice(0,12e4),e.currentRequirements),12);A.ok&&A.resultText.trim()?(s({stageNumber:3,status:"done",note:`${z.length} tickets distilled`+No(e.currentRequirements,A.resultText),artifact:A.resultText.trim().slice(0,1e5),progressDone:z.length,progressTotal:z.length}),f=!0):s({stageNumber:3,status:"failed",note:A.error??"the distill pass produced nothing"})}else s({stageNumber:3,status:"skipped",note:`${_} returned no readable tickets - either the board is empty, or this server's Jira account cannot see it (wrong site or not invited). Check the credential, then run the study again`}),p.push(`the JIRA HISTORY came back EMPTY for ${_} - requirements are not based on the old board`)}catch(D){s({stageNumber:3,status:"failed",note:`Jira read failed: ${D instanceof Error?D.message:D}`})}}else s({stageNumber:3,status:"skipped",note:e.legacyJiraKey?"no Jira credential on this runner":"no legacy Jira key given"}),p.push("the JIRA HISTORY was not read - requirements come only from what else was provided");s({stageNumber:4,status:"in_progress",note:"Writing the SPEC from everything studied\u2026"});let g=await u(AA(e.extraContext.trim(),p,e.currentSpec),15);if(!g.ok||!g.resultText.trim())return s({stageNumber:4,status:"failed",note:g.error??"the SPEC pass produced nothing"}),{ok:!1,error:g.error??"SPEC generation failed"};let{spec:v,tickets:k}=kh(g.resultText);s({stageNumber:4,status:"done",note:"SPEC drafted - review it, refine it in your words if something is missing, then approve"+No(e.currentSpec,v),artifact:v}),s({stageNumber:1,status:"done",note:"Writing the project understanding (plain language)\u2026"});let T=await u($A(e.currentBrief),8);return T.ok&&T.resultText.trim()&&s({stageNumber:1,status:"done",note:"Project understanding ready - read and verify it"+No(e.currentBrief,T.resultText),brief:T.resultText.trim().slice(0,1e5)}),k.length&&s({stageNumber:6,status:"in_progress",note:`${k.length} tickets proposed by the SPEC - created on Jira after you approve`,items:k}),b.info(`rebirth study done for ${e.rebirthId}: code \u2713, data ${e.dbDumpPath?"\u2713":"skipped"}, requirements ${f?"\u2713":"skipped/failed"}, SPEC \u2713 (${k.length} tickets proposed)`),{ok:!0}}catch(i){return{ok:!1,error:i instanceof Error?i.message:String(i)}}finally{Bc.delete(e.rebirthId)}}function kh(t){let e=/```json\s*\n([\s\S]*?)```/.exec(t),n=[];if(e)try{n=(JSON.parse(e[1]).tickets??[]).filter(s=>typeof s.title=="string"&&s.title.trim()).slice(0,60).map(s=>({title:s.title.trim().slice(0,300),detail:typeof s.detail=="string"?s.detail.trim().slice(0,4e3):""}))}catch{}return{spec:t.replace(/```json\s*\n[\s\S]*?```/g,"").trim().slice(0,15e4),tickets:n}}function Hc(t){let e=gr(t,"direction").block,n=[],r=/```screen:([^\n]+)\n([\s\S]*?)```/g,s;for(;(s=r.exec(t))&&n.length<8;)n.push({name:s[1].trim().slice(0,80),html:s[2].trim().slice(0,2e5)});let i=[];try{let a=JSON.parse(gr(t,"inventory").block||"[]");Array.isArray(a)&&(i=a.filter(c=>!!c&&typeof c=="object").map(c=>({name:String(c.name??"").slice(0,80),note:String(c.note??"").slice(0,200)})).filter(c=>c.name).slice(0,40))}catch{}return{direction:e,screens:n,inventory:i}}async function LA(t){let{msg:e,transport:n}=t,r=s=>n.send({type:"rebirth.study.update",rebirthId:e.rebirthId,stageNumber:4,status:"in_progress",note:s,progressDone:0,progressTotal:0,artifact:"",items:[],brief:"",design:{direction:"",screens:[],inventory:[],specs:[],partial:!0},usageDelta:{inputTokens:0,outputTokens:0,cacheReadTokens:0,costUsd:0}});try{let s=$e(t.cfg,t.project,"assist");if("error"in s)return{ok:!1,error:s.error};let i=!!e.screenName;r(e.stackOnly?e.refineMessage?"Revising the tech stack recommendation with your reasoning\u2026":"Working out the tech stack recommendation from the SPEC and the legacy code\u2026":e.specOnly?`Reading the legacy code for "${e.screenName}" - fields, filters, conditions\u2026`:i?`Designing the "${e.screenName}" screen\u2026`:e.refineMessage?"Revising the UI design with your correction\u2026":"Designing the UI - direction first, then the screens\u2026");let a=await s.adapter.run({repoPath:t.repoPath,prompt:e.stackOnly?DA(e.spec,e.brief,e.refineMessage,e.currentStack):e.specOnly?zA(e.screenName,"",e.screenBrief,e.screenSpec):i?sv(e.screenName,e.screenBrief,e.currentDirection,e.currentScreenHtml,e.screenSpec,e.referenceScreenHtml):jA(e.spec,e.brief,e.refineMessage,e.currentDirection),timeoutSeconds:1200,bin:s.bin,mode:"read_only",maxTurns:60,sessionId:(0,Kc.randomUUID)(),onLog:()=>{}});if(be({surface:e.stackOnly?"rebirth_techstack":"rebirth_design",projectId:t.project.id,agentId:s.adapter.id,refKind:"rebirth",refId:e.rebirthId,refLabel:e.specOnly||i?e.screenName:"",...we(a)}),!a.ok||!a.resultText.trim())return r(`UI design failed: ${a.error??"no answer"}`),{ok:!1,error:a.error??"the design pass produced nothing"};if(e.stackOnly){let D=gr(a.resultText,"techstack").block.slice(0,4e4);return D?(n.send({type:"rebirth.study.update",rebirthId:e.rebirthId,stageNumber:6,status:"in_progress",note:"Tech stack recommendation ready - review it, reason with it, then confirm to unlock Build.",progressDone:0,progressTotal:0,artifact:"",items:[],brief:"",techStack:D,usageDelta:{inputTokens:a.inputTokens??0,outputTokens:a.outputTokens??0,cacheReadTokens:a.cacheReadTokens??0,costUsd:a.costUsd??0}}),{ok:!0}):(r("The tech stack recommendation did not come back - try again"),{ok:!1,error:"no techstack block in the answer"})}if(e.specOnly){let D=gr(a.resultText,"screenspec").block.slice(0,3e4);return D?(n.send({type:"rebirth.study.update",rebirthId:e.rebirthId,stageNumber:4,status:"in_progress",note:`The "${e.screenName}" details are ready.`,progressDone:0,progressTotal:0,artifact:"",items:[],brief:"",design:{direction:"",screens:[],inventory:[],specs:[{name:e.screenName,doc:D}],partial:!0},usageDelta:{inputTokens:a.inputTokens??0,outputTokens:a.outputTokens??0,cacheReadTokens:a.cacheReadTokens??0,costUsd:a.costUsd??0}}),{ok:!0}):(r(`The "${e.screenName}" details did not come back - try again`),{ok:!1,error:"no screenspec block in the answer"})}let c=D=>({inputTokens:D.inputTokens??0,outputTokens:D.outputTokens??0,cacheReadTokens:D.cacheReadTokens??0,costUsd:D.costUsd??0}),l=(D,z,A)=>n.send({type:"rebirth.study.update",rebirthId:e.rebirthId,stageNumber:4,status:"in_progress",note:z,progressDone:0,progressTotal:0,artifact:"",items:[],brief:"",design:D,usageDelta:A});if(i){let z=Hc(a.resultText).screens.filter(A=>A.name===e.screenName).slice(0,1);return z.length?(l({direction:"",screens:z,inventory:[],specs:[],partial:!0},`The "${e.screenName}" screen is ready.`,c(a)),{ok:!0}):(r(`The "${e.screenName}" screen did not come back named right - try again`),{ok:!1,error:"the screen block was missing from the answer"})}let u=Hc(a.resultText);if(!u.inventory.length)return r("The design plan came back without a screen inventory - run it again"),{ok:!1,error:"no inventory in the plan answer"};l({direction:u.direction,screens:[],inventory:u.inventory,specs:[],partial:!0},`Screen list ready - ${u.inventory.length} screen(s) mapped. Drawing the missing ones\u2026`,c(a));let p=u.direction||e.currentDirection,f=new Set(e.existingScreenNames),g=u.inventory.filter(D=>!f.has(D.name)),k=g.slice(0,6),T=0,_=e.referenceScreenHtml;for(let[D,z]of k.entries()){r(`Drawing "${z.name}" (${D+1}/${k.length})\u2026`);let A=await s.adapter.run({repoPath:t.repoPath,prompt:sv(z.name,z.note,p,"","",_),timeoutSeconds:900,bin:s.bin,mode:"read_only",maxTurns:40,sessionId:(0,Kc.randomUUID)(),onLog:()=>{}});be({surface:"rebirth_design",projectId:t.project.id,agentId:s.adapter.id,refKind:"rebirth",refId:e.rebirthId,refLabel:z.name,...we(A)});let P=A.ok?Hc(A.resultText).screens.find(w=>w.name===z.name):void 0;P?(T+=1,_||(_=P.html),l({direction:"",screens:[P],inventory:[],specs:[],partial:!0},`"${z.name}" is ready (${T}/${k.length}). ${D+1<k.length?"Drawing the next\u2026":""}`,c(A))):l({direction:"",screens:[],inventory:[],specs:[],partial:!0},`"${z.name}" did not come back usable - skipped (ask for it again per-screen).`,c(A))}let $=g.length-k.length;return r(`UI design ready - ${T} screen(s) drawn this run`+($>0?`, ${$} still to design (open each and click Design, or run this again)`:"")+". Open the studio to review."),{ok:!0}}catch(s){return{ok:!1,error:s instanceof Error?s.message:String(s)}}}var Ps,iv,Kc,Bc,ov,RA,Wc,IA,EA,AA,$A,CA,PA,jA,OA,zA,DA,sv,_h=X(()=>{"use strict";Ps=E(require("node:fs"),1),iv=E(require("node:zlib"),1),Kc=require("node:crypto");Et();lt();nn();rv();Bc=new Set;ov=500,RA=50;Wc=(t,e)=>e.trim()?`A reviewed ${t} already exists - it is below. UPDATE IT IN PLACE rather than writing a new one: keep every still-true sentence VERBATIM (same words, same order, same headings - the reviewer reads a green/red diff of your answer against this text, and every needless rewording costs them a re-review of something that never changed), fold in only what this fresh read adds or corrects, and never drop or compress detail the document already records. Any word limit below applies to a FRESH document - an updated one may exceed it, and trimming existing detail to fit a limit is the failure, not the fix.
1269
+ `).slice(0,12e4),e.currentRequirements),12);A.ok&&A.resultText.trim()?(s({stageNumber:3,status:"done",note:`${z.length} tickets distilled`+No(e.currentRequirements,A.resultText),artifact:A.resultText.trim().slice(0,1e5),progressDone:z.length,progressTotal:z.length}),f=!0):s({stageNumber:3,status:"failed",note:A.error??"the distill pass produced nothing"})}else s({stageNumber:3,status:"skipped",note:`${_} returned no readable tickets - either the board is empty, or this server's Jira account cannot see it (wrong site or not invited). Check the credential, then run the study again`}),p.push(`the JIRA HISTORY came back EMPTY for ${_} - requirements are not based on the old board`)}catch(D){s({stageNumber:3,status:"failed",note:`Jira read failed: ${D instanceof Error?D.message:D}`})}}else s({stageNumber:3,status:"skipped",note:e.legacyJiraKey?"no Jira credential on this runner":"no legacy Jira key given"}),p.push("the JIRA HISTORY was not read - requirements come only from what else was provided");s({stageNumber:4,status:"in_progress",note:"Writing the SPEC from everything studied\u2026"});let g=await u(AA(e.extraContext.trim(),p,e.currentSpec,e.gdprRequired),15);if(!g.ok||!g.resultText.trim())return s({stageNumber:4,status:"failed",note:g.error??"the SPEC pass produced nothing"}),{ok:!1,error:g.error??"SPEC generation failed"};let{spec:v,tickets:k}=kh(g.resultText);s({stageNumber:4,status:"done",note:"SPEC drafted - review it, refine it in your words if something is missing, then approve"+No(e.currentSpec,v),artifact:v}),s({stageNumber:1,status:"done",note:"Writing the project understanding (plain language)\u2026"});let T=await u($A(e.currentBrief),8);return T.ok&&T.resultText.trim()&&s({stageNumber:1,status:"done",note:"Project understanding ready - read and verify it"+No(e.currentBrief,T.resultText),brief:T.resultText.trim().slice(0,1e5)}),k.length&&s({stageNumber:6,status:"in_progress",note:`${k.length} tickets proposed by the SPEC - created on Jira after you approve`,items:k}),b.info(`rebirth study done for ${e.rebirthId}: code \u2713, data ${e.dbDumpPath?"\u2713":"skipped"}, requirements ${f?"\u2713":"skipped/failed"}, SPEC \u2713 (${k.length} tickets proposed)`),{ok:!0}}catch(i){return{ok:!1,error:i instanceof Error?i.message:String(i)}}finally{Bc.delete(e.rebirthId)}}function kh(t){let e=/```json\s*\n([\s\S]*?)```/.exec(t),n=[];if(e)try{n=(JSON.parse(e[1]).tickets??[]).filter(s=>typeof s.title=="string"&&s.title.trim()).slice(0,60).map(s=>({title:s.title.trim().slice(0,300),detail:typeof s.detail=="string"?s.detail.trim().slice(0,4e3):""}))}catch{}return{spec:t.replace(/```json\s*\n[\s\S]*?```/g,"").trim().slice(0,15e4),tickets:n}}function Hc(t){let e=gr(t,"direction").block,n=[],r=/```screen:([^\n]+)\n([\s\S]*?)```/g,s;for(;(s=r.exec(t))&&n.length<8;)n.push({name:s[1].trim().slice(0,80),html:s[2].trim().slice(0,2e5)});let i=[];try{let a=JSON.parse(gr(t,"inventory").block||"[]");Array.isArray(a)&&(i=a.filter(c=>!!c&&typeof c=="object").map(c=>({name:String(c.name??"").slice(0,80),note:String(c.note??"").slice(0,200)})).filter(c=>c.name).slice(0,40))}catch{}return{direction:e,screens:n,inventory:i}}async function LA(t){let{msg:e,transport:n}=t,r=s=>n.send({type:"rebirth.study.update",rebirthId:e.rebirthId,stageNumber:4,status:"in_progress",note:s,progressDone:0,progressTotal:0,artifact:"",items:[],brief:"",design:{direction:"",screens:[],inventory:[],specs:[],partial:!0},usageDelta:{inputTokens:0,outputTokens:0,cacheReadTokens:0,costUsd:0}});try{let s=$e(t.cfg,t.project,"assist");if("error"in s)return{ok:!1,error:s.error};let i=!!e.screenName;r(e.stackOnly?e.refineMessage?"Revising the tech stack recommendation with your reasoning\u2026":"Working out the tech stack recommendation from the SPEC and the legacy code\u2026":e.specOnly?`Reading the legacy code for "${e.screenName}" - fields, filters, conditions\u2026`:i?`Designing the "${e.screenName}" screen\u2026`:e.refineMessage?"Revising the UI design with your correction\u2026":"Designing the UI - direction first, then the screens\u2026");let a=await s.adapter.run({repoPath:t.repoPath,prompt:e.stackOnly?DA(e.spec,e.brief,e.refineMessage,e.currentStack):e.specOnly?zA(e.screenName,"",e.screenBrief,e.screenSpec):i?sv(e.screenName,e.screenBrief,e.currentDirection,e.currentScreenHtml,e.screenSpec,e.referenceScreenHtml):jA(e.spec,e.brief,e.refineMessage,e.currentDirection),timeoutSeconds:1200,bin:s.bin,mode:"read_only",maxTurns:60,sessionId:(0,Kc.randomUUID)(),onLog:()=>{}});if(be({surface:e.stackOnly?"rebirth_techstack":"rebirth_design",projectId:t.project.id,agentId:s.adapter.id,refKind:"rebirth",refId:e.rebirthId,refLabel:e.specOnly||i?e.screenName:"",...we(a)}),!a.ok||!a.resultText.trim())return r(`UI design failed: ${a.error??"no answer"}`),{ok:!1,error:a.error??"the design pass produced nothing"};if(e.stackOnly){let D=gr(a.resultText,"techstack").block.slice(0,4e4);return D?(n.send({type:"rebirth.study.update",rebirthId:e.rebirthId,stageNumber:6,status:"in_progress",note:"Tech stack recommendation ready - review it, reason with it, then confirm to unlock Build.",progressDone:0,progressTotal:0,artifact:"",items:[],brief:"",techStack:D,usageDelta:{inputTokens:a.inputTokens??0,outputTokens:a.outputTokens??0,cacheReadTokens:a.cacheReadTokens??0,costUsd:a.costUsd??0}}),{ok:!0}):(r("The tech stack recommendation did not come back - try again"),{ok:!1,error:"no techstack block in the answer"})}if(e.specOnly){let D=gr(a.resultText,"screenspec").block.slice(0,3e4);return D?(n.send({type:"rebirth.study.update",rebirthId:e.rebirthId,stageNumber:4,status:"in_progress",note:`The "${e.screenName}" details are ready.`,progressDone:0,progressTotal:0,artifact:"",items:[],brief:"",design:{direction:"",screens:[],inventory:[],specs:[{name:e.screenName,doc:D}],partial:!0},usageDelta:{inputTokens:a.inputTokens??0,outputTokens:a.outputTokens??0,cacheReadTokens:a.cacheReadTokens??0,costUsd:a.costUsd??0}}),{ok:!0}):(r(`The "${e.screenName}" details did not come back - try again`),{ok:!1,error:"no screenspec block in the answer"})}let c=D=>({inputTokens:D.inputTokens??0,outputTokens:D.outputTokens??0,cacheReadTokens:D.cacheReadTokens??0,costUsd:D.costUsd??0}),l=(D,z,A)=>n.send({type:"rebirth.study.update",rebirthId:e.rebirthId,stageNumber:4,status:"in_progress",note:z,progressDone:0,progressTotal:0,artifact:"",items:[],brief:"",design:D,usageDelta:A});if(i){let z=Hc(a.resultText).screens.filter(A=>A.name===e.screenName).slice(0,1);return z.length?(l({direction:"",screens:z,inventory:[],specs:[],partial:!0},`The "${e.screenName}" screen is ready.`,c(a)),{ok:!0}):(r(`The "${e.screenName}" screen did not come back named right - try again`),{ok:!1,error:"the screen block was missing from the answer"})}let u=Hc(a.resultText);if(!u.inventory.length)return r("The design plan came back without a screen inventory - run it again"),{ok:!1,error:"no inventory in the plan answer"};l({direction:u.direction,screens:[],inventory:u.inventory,specs:[],partial:!0},`Screen list ready - ${u.inventory.length} screen(s) mapped. Drawing the missing ones\u2026`,c(a));let p=u.direction||e.currentDirection,f=new Set(e.existingScreenNames),g=u.inventory.filter(D=>!f.has(D.name)),k=g.slice(0,6),T=0,_=e.referenceScreenHtml;for(let[D,z]of k.entries()){r(`Drawing "${z.name}" (${D+1}/${k.length})\u2026`);let A=await s.adapter.run({repoPath:t.repoPath,prompt:sv(z.name,z.note,p,"","",_),timeoutSeconds:900,bin:s.bin,mode:"read_only",maxTurns:40,sessionId:(0,Kc.randomUUID)(),onLog:()=>{}});be({surface:"rebirth_design",projectId:t.project.id,agentId:s.adapter.id,refKind:"rebirth",refId:e.rebirthId,refLabel:z.name,...we(A)});let P=A.ok?Hc(A.resultText).screens.find(w=>w.name===z.name):void 0;P?(T+=1,_||(_=P.html),l({direction:"",screens:[P],inventory:[],specs:[],partial:!0},`"${z.name}" is ready (${T}/${k.length}). ${D+1<k.length?"Drawing the next\u2026":""}`,c(A))):l({direction:"",screens:[],inventory:[],specs:[],partial:!0},`"${z.name}" did not come back usable - skipped (ask for it again per-screen).`,c(A))}let $=g.length-k.length;return r(`UI design ready - ${T} screen(s) drawn this run`+($>0?`, ${$} still to design (open each and click Design, or run this again)`:"")+". Open the studio to review."),{ok:!0}}catch(s){return{ok:!1,error:s instanceof Error?s.message:String(s)}}}var Ps,iv,Kc,Bc,ov,RA,Wc,IA,EA,AA,$A,CA,PA,jA,OA,zA,DA,sv,_h=X(()=>{"use strict";Ps=E(require("node:fs"),1),iv=E(require("node:zlib"),1),Kc=require("node:crypto");Et();lt();nn();rv();Bc=new Set;ov=500,RA=50;Wc=(t,e)=>e.trim()?`A reviewed ${t} already exists - it is below. UPDATE IT IN PLACE rather than writing a new one: keep every still-true sentence VERBATIM (same words, same order, same headings - the reviewer reads a green/red diff of your answer against this text, and every needless rewording costs them a re-review of something that never changed), fold in only what this fresh read adds or corrects, and never drop or compress detail the document already records. Any word limit below applies to a FRESH document - an updated one may exceed it, and trimming existing detail to fit a limit is the failure, not the fix.
1270
1270
 
1271
1271
  --- CURRENT ${t.toUpperCase()} ---
1272
1272
  ${e}
@@ -1291,16 +1291,18 @@ Behavioural rules in the tickets: field rules, status meanings, permission asks,
1291
1291
  Under 2000 words. Cite ticket keys inline where they anchor a claim. Depth beats brevity - this ledger is what stops the rebuild from silently dropping a rule someone fought for.
1292
1292
 
1293
1293
  TICKETS:
1294
- ${t}`,AA=(t,e=[],n="")=>Wc("SPEC",n)+`Now write the SPEC for the rebuild, from everything you have studied (the code document, the data profile, the requirements ledger${t?", and the extra context below":""}). A human reviews and approves this document; nothing downstream starts until they do - and the BUILD works from this document, so a condition the study found but the SPEC omits will be missing from the product.
1294
+ ${t}`,AA=(t,e=[],n="",r=!1)=>Wc("SPEC",n)+`Now write the SPEC for the rebuild, from everything you have studied (the code document, the data profile, the requirements ledger${t?", and the extra context below":""}). A human reviews and approves this document; nothing downstream starts until they do - and the BUILD works from this document, so a condition the study found but the SPEC omits will be missing from the product.
1295
1295
  Headings:
1296
1296
  Goal: what the rebuilt product is, in one paragraph.
1297
1297
  Target architecture & stack: concrete choices, with one line of why each.
1298
1298
  Scope: what is IN the rebuild; what is deliberately OUT (with why).
1299
1299
  Modules & behaviour: EVERY module/area in scope, with the concrete behaviour the rebuild must honour - fields with their validations and conditional visibility, status transitions (each status field separately when there are several), permission/role gates per action, every flag that branches behaviour with BOTH branches spelled out, naming/suffix conventions, single-vs-bulk differences, import/export rules. Carry these forward from the understanding and requirements documents - list the rules themselves, never a heading that gestures at them. This is the SPEC's longest section by design.
1300
1300
  Data: how the legacy data maps on - what carries over, what dies.
1301
- Risks: what could sink this, from evidence in the study.
1301
+ Testing strategy: how the rebuild proves itself and keeps proving itself - CHARACTERISATION tests pinning the legacy behaviour BEFORE any port (same fixtures against old and new); unit tests for the logic the new architecture makes testable; API/integration tests carrying the acceptance criteria; a SMALL end-to-end suite for the few costliest flows, named here - never blanket coverage; all of it run on every change (CI). Say what the schema now enforces and therefore needs no test. The ticket breakdown must honour this: characterisation tests are their own ticket sequenced BEFORE the port work, and every build ticket carries its own tests.
1302
+ `+(r?`GDPR compliance: REQUIRED for this rebuild. A table of the personal-data duties, one row each, NOW vs REBUILD in plain words the owner can read without a lawyer: what personal data is held and where; lawful basis & consent; access, export and erasure requests; retention & deletion; data minimisation; security (encryption, access control, audit trail); breach readiness; processors & data residency. NOW is evidence from the legacy code/data - met, partial or absent, never guessed; REBUILD is what the new build will do about it. Close with the honest summary: how compliant it is today, how compliant the rebuild will be, and what stays a human/legal task (policies, DPAs) that no code can close.
1303
+ `:"")+`Risks: what could sink this, from evidence in the study.
1302
1304
  `+(e.length?`Open gaps: these inputs were NOT available - name what the plan assumes because of each, so the reader knows what to provide next:
1303
- ${e.map(r=>`- ${r}`).join(`
1305
+ ${e.map(s=>`- ${s}`).join(`
1304
1306
  `)}
1305
1307
  `:"")+(t?`
1306
1308
  EXTRA CONTEXT from the person who knows this project:
@@ -1407,6 +1409,8 @@ Answer with exactly one fenced block:
1407
1409
  # Tech stack
1408
1410
  ## Recommendation
1409
1411
  - one line per layer: frontend, backend, database, hosting/infra, integrations - the concrete choice, version-current
1412
+ ## What stays, what changes
1413
+ - per layer: KEPT, upgraded, rewritten or replaced - in plain words the person deciding can follow without being an engineer: what happens to the working domain logic, how building a feature changes day to day after the move, and THE one choice that moves cost the most, named as such
1410
1414
  ## Why this fits THIS product
1411
1415
  - reasoning anchored in the spec/legacy evidence (team realities, data shapes, integrations, migration path) - never generic praise
1412
1416
  ## Alternatives considered
@@ -1416,7 +1420,7 @@ Answer with exactly one fenced block:
1416
1420
  ## Open questions
1417
1421
  - what the person confirming should decide or verify
1418
1422
  \`\`\`
1419
- Under 1200 words. Concrete names and versions, honest trade-offs.`,sv=(t,e,n,r,s,i)=>`You are designing ONE screen of a product whose UI direction is already decided. Follow the direction exactly - same palette, same type, same components - so this screen sits beside the existing set seamlessly. The legacy frontend code may be in your working directory for reference.
1423
+ Under 1400 words. Concrete names and versions, honest trade-offs.`,sv=(t,e,n,r,s,i)=>`You are designing ONE screen of a product whose UI direction is already decided. Follow the direction exactly - same palette, same type, same components - so this screen sits beside the existing set seamlessly. The legacy frontend code may be in your working directory for reference.
1420
1424
 
1421
1425
  `+(i?"A FINISHED screen of this product is below. Its SHELL - the sidebar/menu (same items, same order, same markup), header, fonts, colors, spacing tokens - is the product's shell: COPY it verbatim, mark this screen's own nav item active, and design ONLY the content area. Two screens of one product never get two different menus.\n\n```html\n"+i.slice(0,12e4)+"\n```\n\n":"")+`THE DIRECTION:
1422
1426
  ${n.slice(0,4e4)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "allwright",
3
- "version": "1.108.0",
3
+ "version": "1.110.0",
4
4
  "description": "Allwright — the AI teammate that runs on YOUR machine. Polls your Jira, runs jailed agents in your local checkouts, opens PRs, executes approved deploys, and audits security/testing/architecture. Credentials and code never leave your host.",
5
5
  "bin": {
6
6
  "allwright": "bin/allwright.js",