chief-clancy 0.6.0 → 0.7.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.
- package/README.md +3 -2
- package/dist/bundle/clancy-afk.js +6 -2
- package/dist/bundle/clancy-once.js +40 -39
- package/dist/installer/hook-installer/hook-installer.d.ts +2 -0
- package/dist/installer/hook-installer/hook-installer.d.ts.map +1 -1
- package/dist/installer/hook-installer/hook-installer.js +36 -1
- package/dist/installer/hook-installer/hook-installer.js.map +1 -1
- package/dist/installer/install.js +8 -0
- package/dist/installer/install.js.map +1 -1
- package/dist/schemas/env.d.ts +20 -0
- package/dist/schemas/env.d.ts.map +1 -1
- package/dist/schemas/env.js +6 -0
- package/dist/schemas/env.js.map +1 -1
- package/dist/scripts/afk/afk.d.ts.map +1 -1
- package/dist/scripts/afk/afk.js +27 -0
- package/dist/scripts/afk/afk.js.map +1 -1
- package/dist/scripts/afk/report/report.d.ts +47 -0
- package/dist/scripts/afk/report/report.d.ts.map +1 -0
- package/dist/scripts/afk/report/report.js +194 -0
- package/dist/scripts/afk/report/report.js.map +1 -0
- package/dist/scripts/once/cost/cost.d.ts +10 -0
- package/dist/scripts/once/cost/cost.d.ts.map +1 -0
- package/dist/scripts/once/cost/cost.js +23 -0
- package/dist/scripts/once/cost/cost.js.map +1 -0
- package/dist/scripts/once/deliver/deliver.d.ts.map +1 -1
- package/dist/scripts/once/deliver/deliver.js +18 -1
- package/dist/scripts/once/deliver/deliver.js.map +1 -1
- package/dist/scripts/once/lock/lock.d.ts +17 -0
- package/dist/scripts/once/lock/lock.d.ts.map +1 -0
- package/dist/scripts/once/lock/lock.js +70 -0
- package/dist/scripts/once/lock/lock.js.map +1 -0
- package/dist/scripts/once/once.d.ts.map +1 -1
- package/dist/scripts/once/once.js +100 -4
- package/dist/scripts/once/once.js.map +1 -1
- package/dist/scripts/once/resume/resume.d.ts +24 -0
- package/dist/scripts/once/resume/resume.d.ts.map +1 -0
- package/dist/scripts/once/resume/resume.js +159 -0
- package/dist/scripts/once/resume/resume.js.map +1 -0
- package/dist/scripts/shared/format/format.d.ts.map +1 -1
- package/dist/scripts/shared/format/format.js +6 -1
- package/dist/scripts/shared/format/format.js.map +1 -1
- package/dist/scripts/shared/progress/progress.d.ts +13 -0
- package/dist/scripts/shared/progress/progress.d.ts.map +1 -1
- package/dist/scripts/shared/progress/progress.js +1 -1
- package/dist/scripts/shared/progress/progress.js.map +1 -1
- package/dist/scripts/shared/pull-request/pr-body/pr-body.d.ts +2 -1
- package/dist/scripts/shared/pull-request/pr-body/pr-body.d.ts.map +1 -1
- package/dist/scripts/shared/pull-request/pr-body/pr-body.js +10 -1
- package/dist/scripts/shared/pull-request/pr-body/pr-body.js.map +1 -1
- package/dist/types/remote.d.ts +1 -1
- package/dist/types/remote.d.ts.map +1 -1
- package/hooks/clancy-branch-guard.js +129 -0
- package/hooks/clancy-context-monitor.js +134 -46
- package/hooks/clancy-post-compact.js +53 -0
- package/hooks/package.json +3 -0
- package/package.json +3 -2
- package/src/agents/verification-gate.md +128 -0
- package/src/roles/setup/workflows/init.md +45 -0
- package/src/roles/setup/workflows/scaffold.md +30 -0
- package/src/roles/setup/workflows/settings.md +56 -0
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
var Sl=Object.defineProperty;var we=(e,t)=>{for(var r in t)Sl(e,r,{get:t[r],enumerable:!0})};import{resolve as Th}from"node:path";import{fileURLToPath as Ah}from"node:url";function zt(e,t){return e==="github"?`feature/issue-${t.replace("#","")}`:`feature/${t.toLowerCase()}`}function yr(e,t,r){return r?e==="github"?`milestone/${r.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"")}`:`epic/${r.toLowerCase()}`:t}import{spawnSync as sc}from"node:child_process";function cc(e,t){let r=["-p","--dangerously-skip-permissions"];t&&r.push("--model",t);let n=sc("claude",r,{input:e,stdio:["pipe","pipe","pipe"],encoding:"utf8"});return{stdout:n.stdout??"",ok:n.status===0&&!n.error}}function ac(e,t){let r=["--dangerously-skip-permissions"];t&&r.push("--model",t);let n=sc("claude",r,{input:e,stdio:["pipe","inherit","inherit"],encoding:"utf8"});return n.status===0&&!n.error}var l={};we(l,{$brand:()=>$r,$input:()=>ti,$output:()=>ei,NEVER:()=>xr,TimePrecision:()=>Si,ZodMiniAny:()=>ha,ZodMiniArray:()=>xa,ZodMiniBase64:()=>ca,ZodMiniBase64URL:()=>aa,ZodMiniBigInt:()=>_t,ZodMiniBigIntFormat:()=>Ts,ZodMiniBoolean:()=>gt,ZodMiniCIDRv4:()=>oa,ZodMiniCIDRv6:()=>ia,ZodMiniCUID:()=>Wc,ZodMiniCUID2:()=>Xc,ZodMiniCatch:()=>Ma,ZodMiniCodec:()=>js,ZodMiniCustom:()=>Os,ZodMiniCustomStringFormat:()=>mt,ZodMiniDate:()=>tr,ZodMiniDefault:()=>ja,ZodMiniDiscriminatedUnion:()=>wa,ZodMiniE164:()=>ua,ZodMiniEmail:()=>Yc,ZodMiniEmoji:()=>Kc,ZodMiniEnum:()=>Rs,ZodMiniExactOptional:()=>Ca,ZodMiniFile:()=>Ra,ZodMiniFunction:()=>Ya,ZodMiniGUID:()=>Hc,ZodMiniIPv4:()=>ra,ZodMiniIPv6:()=>na,ZodMiniISODate:()=>sr,ZodMiniISODateTime:()=>ir,ZodMiniISODuration:()=>ar,ZodMiniISOTime:()=>cr,ZodMiniIntersection:()=>za,ZodMiniJWT:()=>la,ZodMiniKSUID:()=>ta,ZodMiniLazy:()=>Fa,ZodMiniLiteral:()=>Aa,ZodMiniMAC:()=>sa,ZodMiniMap:()=>Ea,ZodMiniNaN:()=>Da,ZodMiniNanoID:()=>Vc,ZodMiniNever:()=>_a,ZodMiniNonOptional:()=>Cs,ZodMiniNull:()=>da,ZodMiniNullable:()=>Na,ZodMiniNumber:()=>ht,ZodMiniNumberFormat:()=>Be,ZodMiniObject:()=>rr,ZodMiniOptional:()=>Zs,ZodMiniPipe:()=>Ns,ZodMiniPrefault:()=>Oa,ZodMiniPromise:()=>qa,ZodMiniReadonly:()=>Ua,ZodMiniRecord:()=>nr,ZodMiniSet:()=>Ia,ZodMiniString:()=>Ue,ZodMiniStringFormat:()=>A,ZodMiniSuccess:()=>La,ZodMiniSymbol:()=>pa,ZodMiniTemplateLiteral:()=>Ba,ZodMiniTransform:()=>Za,ZodMiniTuple:()=>ka,ZodMiniType:()=>z,ZodMiniULID:()=>Qc,ZodMiniURL:()=>Is,ZodMiniUUID:()=>dt,ZodMiniUndefined:()=>fa,ZodMiniUnion:()=>As,ZodMiniUnknown:()=>ga,ZodMiniVoid:()=>ya,ZodMiniXID:()=>ea,ZodMiniXor:()=>va,_default:()=>Vd,_function:()=>hm,any:()=>zd,array:()=>U,base64:()=>sd,base64url:()=>cd,bigint:()=>yd,boolean:()=>Fe,catch:()=>em,catchall:()=>jd,check:()=>cm,cidrv4:()=>nd,cidrv6:()=>od,clone:()=>M,codec:()=>nm,coerce:()=>Ms,config:()=>L,core:()=>De,cuid:()=>Vf,cuid2:()=>Wf,custom:()=>Ga,date:()=>Sd,decode:()=>Fr,decodeAsync:()=>qr,describe:()=>lm,discriminatedUnion:()=>Ld,e164:()=>ad,email:()=>Df,emoji:()=>Hf,encode:()=>Br,encodeAsync:()=>Jr,endsWith:()=>ms,enum:()=>Ta,exactOptional:()=>Hd,extend:()=>bt,file:()=>Gd,flattenError:()=>Lr,float32:()=>hd,float64:()=>gd,formatError:()=>Mr,function:()=>hm,globalRegistry:()=>se,gt:()=>Vt,gte:()=>lt,guid:()=>Uf,hash:()=>dd,hex:()=>fd,hostname:()=>pd,httpUrl:()=>Yf,includes:()=>fs,instanceof:()=>fm,int:()=>md,int32:()=>_d,int64:()=>xd,intersection:()=>Md,ipv4:()=>td,ipv6:()=>rd,iso:()=>Ls,json:()=>mm,jwt:()=>ud,keyof:()=>Pd,ksuid:()=>ed,lazy:()=>Ja,length:()=>us,literal:()=>qd,locales:()=>at,looseObject:()=>Id,looseRecord:()=>Ud,lowercase:()=>ls,lt:()=>Kt,lte:()=>ut,mac:()=>id,map:()=>Bd,maxLength:()=>as,maxSize:()=>is,maximum:()=>ut,merge:()=>Ad,meta:()=>pm,mime:()=>gs,minLength:()=>pt,minSize:()=>ss,minimum:()=>lt,multipleOf:()=>os,nan:()=>tm,nanoid:()=>Kf,nativeEnum:()=>Jd,negative:()=>ts,never:()=>ba,nonnegative:()=>ns,nonoptional:()=>Xd,nonpositive:()=>rs,normalize:()=>_s,null:()=>ma,nullable:()=>or,nullish:()=>Kd,number:()=>ye,object:()=>E,omit:()=>Zd,optional:()=>x,overwrite:()=>he,parse:()=>de,parseAsync:()=>me,partial:()=>Cd,partialRecord:()=>Dd,pick:()=>Rd,pipe:()=>rm,positive:()=>es,prefault:()=>Wd,prettifyError:()=>Ur,promise:()=>sm,property:()=>hs,readonly:()=>om,record:()=>Pa,refine:()=>am,regex:()=>ft,regexes:()=>Q,registry:()=>Yt,required:()=>Nd,safeDecode:()=>Yr,safeDecodeAsync:()=>Kr,safeEncode:()=>Gr,safeEncodeAsync:()=>Hr,safeExtend:()=>Td,safeParse:()=>ke,safeParseAsync:()=>Se,set:()=>Fd,size:()=>cs,startsWith:()=>ds,strictObject:()=>Ed,string:()=>y,stringFormat:()=>ld,stringbool:()=>dm,success:()=>Qd,superRefine:()=>um,symbol:()=>vd,templateLiteral:()=>im,toJSONSchema:()=>Xt,toLowerCase:()=>ys,toUpperCase:()=>xs,transform:()=>Yd,treeifyError:()=>Dr,trim:()=>bs,tuple:()=>Sa,uint32:()=>bd,uint64:()=>$d,ulid:()=>Xf,undefined:()=>wd,union:()=>$a,unknown:()=>er,uppercase:()=>ps,url:()=>Gf,util:()=>X,uuid:()=>Bf,uuidv4:()=>Ff,uuidv6:()=>Jf,uuidv7:()=>qf,void:()=>kd,xid:()=>Qf,xor:()=>Od});var De={};we(De,{$ZodAny:()=>wo,$ZodArray:()=>Eo,$ZodAsyncError:()=>ne,$ZodBase64:()=>fo,$ZodBase64URL:()=>mo,$ZodBigInt:()=>Bt,$ZodBigIntFormat:()=>yo,$ZodBoolean:()=>it,$ZodCIDRv4:()=>uo,$ZodCIDRv6:()=>lo,$ZodCUID:()=>Wn,$ZodCUID2:()=>Xn,$ZodCatch:()=>qo,$ZodCheck:()=>T,$ZodCheckBigIntFormat:()=>Pn,$ZodCheckEndsWith:()=>Mn,$ZodCheckGreaterThan:()=>Nt,$ZodCheckIncludes:()=>On,$ZodCheckLengthEquals:()=>Zn,$ZodCheckLessThan:()=>Ct,$ZodCheckLowerCase:()=>Nn,$ZodCheckMaxLength:()=>An,$ZodCheckMaxSize:()=>En,$ZodCheckMimeType:()=>Un,$ZodCheckMinLength:()=>Rn,$ZodCheckMinSize:()=>In,$ZodCheckMultipleOf:()=>kn,$ZodCheckNumberFormat:()=>Sn,$ZodCheckOverwrite:()=>Bn,$ZodCheckProperty:()=>Dn,$ZodCheckRegex:()=>Cn,$ZodCheckSizeEquals:()=>Tn,$ZodCheckStartsWith:()=>Ln,$ZodCheckStringFormat:()=>Oe,$ZodCheckUpperCase:()=>jn,$ZodCodec:()=>ct,$ZodCustom:()=>Qo,$ZodCustomStringFormat:()=>_o,$ZodDate:()=>Po,$ZodDefault:()=>Uo,$ZodDiscriminatedUnion:()=>To,$ZodE164:()=>ho,$ZodEmail:()=>Yn,$ZodEmoji:()=>Kn,$ZodEncodeError:()=>Ze,$ZodEnum:()=>No,$ZodError:()=>Or,$ZodExactOptional:()=>Mo,$ZodFile:()=>Oo,$ZodFunction:()=>Vo,$ZodGUID:()=>qn,$ZodIPv4:()=>so,$ZodIPv6:()=>co,$ZodISODate:()=>no,$ZodISODateTime:()=>ro,$ZodISODuration:()=>io,$ZodISOTime:()=>oo,$ZodIntersection:()=>Ao,$ZodJWT:()=>go,$ZodKSUID:()=>to,$ZodLazy:()=>Xo,$ZodLiteral:()=>jo,$ZodMAC:()=>ao,$ZodMap:()=>Zo,$ZodNaN:()=>Go,$ZodNanoID:()=>Vn,$ZodNever:()=>ko,$ZodNonOptional:()=>Fo,$ZodNull:()=>vo,$ZodNullable:()=>Do,$ZodNumber:()=>Ut,$ZodNumberFormat:()=>bo,$ZodObject:()=>Ft,$ZodObjectJIT:()=>vp,$ZodOptional:()=>qt,$ZodPipe:()=>Yo,$ZodPrefault:()=>Bo,$ZodPromise:()=>Wo,$ZodReadonly:()=>Ho,$ZodRealError:()=>G,$ZodRecord:()=>Ro,$ZodRegistry:()=>Gt,$ZodSet:()=>Co,$ZodString:()=>Le,$ZodStringFormat:()=>I,$ZodSuccess:()=>Jo,$ZodSymbol:()=>xo,$ZodTemplateLiteral:()=>Ko,$ZodTransform:()=>Lo,$ZodTuple:()=>Jt,$ZodType:()=>$,$ZodULID:()=>Qn,$ZodURL:()=>Hn,$ZodUUID:()=>Gn,$ZodUndefined:()=>$o,$ZodUnion:()=>st,$ZodUnknown:()=>zo,$ZodVoid:()=>So,$ZodXID:()=>eo,$ZodXor:()=>Io,$brand:()=>$r,$constructor:()=>f,$input:()=>ti,$output:()=>ei,Doc:()=>ot,JSONSchema:()=>Gc,JSONSchemaGenerator:()=>Qt,NEVER:()=>xr,TimePrecision:()=>Si,_any:()=>Yi,_array:()=>Pp,_base64:()=>vi,_base64url:()=>wi,_bigint:()=>Di,_boolean:()=>Li,_catch:()=>qp,_check:()=>qc,_cidrv4:()=>xi,_cidrv6:()=>$i,_coercedBigint:()=>Ui,_coercedBoolean:()=>Mi,_coercedDate:()=>Xi,_coercedNumber:()=>Ri,_coercedString:()=>ni,_cuid:()=>fi,_cuid2:()=>di,_custom:()=>vs,_date:()=>Wi,_decode:()=>gc,_decodeAsync:()=>bc,_default:()=>Bp,_discriminatedUnion:()=>Tp,_e164:()=>zi,_email:()=>oi,_emoji:()=>li,_encode:()=>hc,_encodeAsync:()=>_c,_endsWith:()=>ms,_enum:()=>jp,_file:()=>$s,_float32:()=>Ci,_float64:()=>Ni,_gt:()=>Vt,_gte:()=>lt,_guid:()=>ii,_includes:()=>fs,_int:()=>Zi,_int32:()=>ji,_int64:()=>Bi,_intersection:()=>Ap,_ipv4:()=>_i,_ipv6:()=>bi,_isoDate:()=>Ei,_isoDateTime:()=>Pi,_isoDuration:()=>Ti,_isoTime:()=>Ii,_jwt:()=>ki,_ksuid:()=>gi,_lazy:()=>Kp,_length:()=>us,_literal:()=>Lp,_lowercase:()=>ls,_lt:()=>Kt,_lte:()=>ut,_mac:()=>yi,_map:()=>Cp,_max:()=>ut,_maxLength:()=>as,_maxSize:()=>is,_mime:()=>gs,_min:()=>lt,_minLength:()=>pt,_minSize:()=>ss,_multipleOf:()=>os,_nan:()=>Qi,_nanoid:()=>pi,_nativeEnum:()=>Op,_negative:()=>ts,_never:()=>Ki,_nonnegative:()=>ns,_nonoptional:()=>Fp,_nonpositive:()=>rs,_normalize:()=>_s,_null:()=>Gi,_nullable:()=>Up,_number:()=>Ai,_optional:()=>Dp,_overwrite:()=>he,_parse:()=>Et,_parseAsync:()=>It,_pipe:()=>Gp,_positive:()=>es,_promise:()=>Vp,_property:()=>hs,_readonly:()=>Yp,_record:()=>Zp,_refine:()=>ws,_regex:()=>ft,_safeDecode:()=>xc,_safeDecodeAsync:()=>vc,_safeEncode:()=>yc,_safeEncodeAsync:()=>$c,_safeParse:()=>Tt,_safeParseAsync:()=>At,_set:()=>Np,_size:()=>cs,_slugify:()=>Sp,_startsWith:()=>ds,_string:()=>ri,_stringFormat:()=>Me,_stringbool:()=>Ps,_success:()=>Jp,_superRefine:()=>zs,_symbol:()=>Ji,_templateLiteral:()=>Hp,_toLowerCase:()=>ys,_toUpperCase:()=>xs,_transform:()=>Mp,_trim:()=>bs,_tuple:()=>Rp,_uint32:()=>Oi,_uint64:()=>Fi,_ulid:()=>mi,_undefined:()=>qi,_union:()=>Ep,_unknown:()=>Hi,_uppercase:()=>ps,_url:()=>Ht,_uuid:()=>si,_uuidv4:()=>ci,_uuidv6:()=>ai,_uuidv7:()=>ui,_void:()=>Vi,_xid:()=>hi,_xor:()=>Ip,clone:()=>M,config:()=>L,createStandardJSONSchemaMethod:()=>Es,createToJSONSchemaMethod:()=>Wp,decode:()=>Fr,decodeAsync:()=>qr,describe:()=>ks,encode:()=>Br,encodeAsync:()=>Jr,extractDefs:()=>_e,finalize:()=>be,flattenError:()=>Lr,formatError:()=>Mr,globalConfig:()=>Ke,globalRegistry:()=>se,initializeContext:()=>ge,isValidBase64:()=>po,isValidBase64URL:()=>Dc,isValidJWT:()=>Uc,locales:()=>at,meta:()=>Ss,parse:()=>de,parseAsync:()=>me,prettifyError:()=>Ur,process:()=>P,regexes:()=>Q,registry:()=>Yt,safeDecode:()=>Yr,safeDecodeAsync:()=>Kr,safeEncode:()=>Gr,safeEncodeAsync:()=>Hr,safeParse:()=>ke,safeParseAsync:()=>Se,toDotPath:()=>mc,toJSONSchema:()=>Xt,treeifyError:()=>Dr,util:()=>X,version:()=>Fn});var xr=Object.freeze({status:"aborted"});function f(e,t,r){function n(c,a){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:a,constr:s,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,a);let u=s.prototype,p=Object.keys(u);for(let d=0;d<p.length;d++){let m=p[d];m in c||(c[m]=u[m].bind(c))}}let o=r?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function s(c){var a;let u=r?.Parent?new i:this;n(u,c),(a=u._zod).deferred??(a.deferred=[]);for(let p of u._zod.deferred)p();return u}return Object.defineProperty(s,"init",{value:n}),Object.defineProperty(s,Symbol.hasInstance,{value:c=>r?.Parent&&c instanceof r.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}var $r=Symbol("zod_brand"),ne=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Ze=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}},Ke={};function L(e){return e&&Object.assign(Ke,e),Ke}var X={};we(X,{BIGINT_FORMAT_RANGES:()=>Ar,Class:()=>wr,NUMBER_FORMAT_RANGES:()=>Tr,aborted:()=>fe,allowsEval:()=>Pr,assert:()=>Al,assertEqual:()=>Pl,assertIs:()=>Il,assertNever:()=>Tl,assertNotEqual:()=>El,assignProp:()=>le,base64ToUint8Array:()=>pc,base64urlToUint8Array:()=>Jl,cached:()=>Ce,captureStackTrace:()=>St,cleanEnum:()=>Fl,cleanRegex:()=>Xe,clone:()=>M,cloneDef:()=>Cl,createTransparentProxy:()=>Dl,defineLazy:()=>w,esc:()=>kt,escapeRegex:()=>W,extend:()=>Pt,finalizeIssue:()=>q,floatSafeRemainder:()=>kr,getElementAtPath:()=>Nl,getEnumValues:()=>We,getLengthableOrigin:()=>tt,getParsedType:()=>Ml,getSizableOrigin:()=>et,hexToUint8Array:()=>Gl,isObject:()=>ze,isPlainObject:()=>pe,issue:()=>je,joinValues:()=>Rl,jsonStringifyReplacer:()=>zr,merge:()=>Ul,mergeDefs:()=>ce,normalizeParams:()=>_,nullish:()=>ue,numKeys:()=>Ll,objectClone:()=>Zl,omit:()=>Zr,optionalKeys:()=>Ir,parsedType:()=>Bl,partial:()=>Nr,pick:()=>Rr,prefixIssues:()=>K,primitiveTypes:()=>Er,promiseAllObject:()=>jl,propertyKeyTypes:()=>Qe,randomString:()=>Ol,required:()=>jr,safeExtend:()=>Cr,shallowClone:()=>Ne,slugify:()=>Sr,stringifyPrimitive:()=>lc,uint8ArrayToBase64:()=>fc,uint8ArrayToBase64url:()=>ql,uint8ArrayToHex:()=>Yl,unwrapMessage:()=>Ve});function Pl(e){return e}function El(e){return e}function Il(e){}function Tl(e){throw new Error("Unexpected value in exhaustive check")}function Al(e){}function We(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function Rl(e,t="|"){return e.map(r=>lc(r)).join(t)}function zr(e,t){return typeof t=="bigint"?t.toString():t}function Ce(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function ue(e){return e==null}function Xe(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function kr(e,t){let r=(e.toString().split(".")[1]||"").length,n=t.toString(),o=(n.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(n)){let a=n.match(/\d?e-(\d?)/);a?.[1]&&(o=Number.parseInt(a[1]))}let i=r>o?r:o,s=Number.parseInt(e.toFixed(i).replace(".","")),c=Number.parseInt(t.toFixed(i).replace(".",""));return s%c/10**i}var uc=Symbol("evaluating");function w(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==uc)return n===void 0&&(n=uc,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function Zl(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function le(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function ce(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function Cl(e){return ce(e._zod.def)}function Nl(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function jl(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let o={};for(let i=0;i<t.length;i++)o[t[i]]=n[i];return o})}function Ol(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function kt(e){return JSON.stringify(e)}function Sr(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var St="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ze(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Pr=Ce(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function pe(e){if(ze(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(ze(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Ne(e){return pe(e)?{...e}:Array.isArray(e)?[...e]:e}function Ll(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var Ml=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},Qe=new Set(["string","number","symbol"]),Er=new Set(["string","number","bigint","boolean","symbol","undefined"]);function W(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function M(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function _(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Dl(e){let t;return new Proxy({},{get(r,n,o){return t??(t=e()),Reflect.get(t,n,o)},set(r,n,o,i){return t??(t=e()),Reflect.set(t,n,o,i)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,o){return t??(t=e()),Reflect.defineProperty(t,n,o)}})}function lc(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Ir(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Tr={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Ar={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Rr(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let i=ce(e._zod.def,{get shape(){let s={};for(let c in t){if(!(c in r.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&(s[c]=r.shape[c])}return le(this,"shape",s),s},checks:[]});return M(e,i)}function Zr(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let i=ce(e._zod.def,{get shape(){let s={...e._zod.def.shape};for(let c in t){if(!(c in r.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&delete s[c]}return le(this,"shape",s),s},checks:[]});return M(e,i)}function Pt(e,t){if(!pe(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let i=e._zod.def.shape;for(let s in t)if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let o=ce(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return le(this,"shape",i),i}});return M(e,o)}function Cr(e,t){if(!pe(t))throw new Error("Invalid input to safeExtend: expected a plain object");let r=ce(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return le(this,"shape",n),n}});return M(e,r)}function Ul(e,t){let r=ce(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return le(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return M(e,r)}function Nr(e,t,r){let o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let s=ce(t._zod.def,{get shape(){let c=t._zod.def.shape,a={...c};if(r)for(let u in r){if(!(u in c))throw new Error(`Unrecognized key: "${u}"`);r[u]&&(a[u]=e?new e({type:"optional",innerType:c[u]}):c[u])}else for(let u in c)a[u]=e?new e({type:"optional",innerType:c[u]}):c[u];return le(this,"shape",a),a},checks:[]});return M(t,s)}function jr(e,t,r){let n=ce(t._zod.def,{get shape(){let o=t._zod.def.shape,i={...o};if(r)for(let s in r){if(!(s in i))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(i[s]=new e({type:"nonoptional",innerType:o[s]}))}else for(let s in o)i[s]=new e({type:"nonoptional",innerType:o[s]});return le(this,"shape",i),i}});return M(t,n)}function fe(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function K(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Ve(e){return typeof e=="string"?e:e?.message}function q(e,t,r){let n={...e,path:e.path??[]};if(!e.message){let o=Ve(e.inst?._zod.def?.error?.(e))??Ve(t?.error?.(e))??Ve(r.customError?.(e))??Ve(r.localeError?.(e))??"Invalid input";n.message=o}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function et(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function tt(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Bl(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function je(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function Fl(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function pc(e){let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function fc(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function Jl(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return pc(t+r)}function ql(e){return fc(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Gl(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)r[n/2]=Number.parseInt(t.slice(n,n+2),16);return r}function Yl(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var wr=class{constructor(...t){}};var dc=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,zr,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Or=f("$ZodError",dc),G=f("$ZodError",dc,{Parent:Error});function Lr(e,t=r=>r.message){let r={},n=[];for(let o of e.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(t(o))):n.push(t(o));return{formErrors:n,fieldErrors:r}}function Mr(e,t=r=>r.message){let r={_errors:[]},n=o=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(s=>n({issues:s}));else if(i.code==="invalid_key")n({issues:i.issues});else if(i.code==="invalid_element")n({issues:i.issues});else if(i.path.length===0)r._errors.push(t(i));else{let s=r,c=0;for(;c<i.path.length;){let a=i.path[c];c===i.path.length-1?(s[a]=s[a]||{_errors:[]},s[a]._errors.push(t(i))):s[a]=s[a]||{_errors:[]},s=s[a],c++}}};return n(e),r}function Dr(e,t=r=>r.message){let r={errors:[]},n=(o,i=[])=>{var s,c;for(let a of o.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(u=>n({issues:u},a.path));else if(a.code==="invalid_key")n({issues:a.issues},a.path);else if(a.code==="invalid_element")n({issues:a.issues},a.path);else{let u=[...i,...a.path];if(u.length===0){r.errors.push(t(a));continue}let p=r,d=0;for(;d<u.length;){let m=u[d],h=d===u.length-1;typeof m=="string"?(p.properties??(p.properties={}),(s=p.properties)[m]??(s[m]={errors:[]}),p=p.properties[m]):(p.items??(p.items=[]),(c=p.items)[m]??(c[m]={errors:[]}),p=p.items[m]),h&&p.errors.push(t(a)),d++}}};return n(e),r}function mc(e){let t=[],r=e.map(n=>typeof n=="object"?n.key:n);for(let n of r)typeof n=="number"?t.push(`[${n}]`):typeof n=="symbol"?t.push(`[${JSON.stringify(String(n))}]`):/[^\w$]/.test(n)?t.push(`[${JSON.stringify(n)}]`):(t.length&&t.push("."),t.push(n));return t.join("")}function Ur(e){let t=[],r=[...e.issues].sort((n,o)=>(n.path??[]).length-(o.path??[]).length);for(let n of r)t.push(`\u2716 ${n.message}`),n.path?.length&&t.push(` \u2192 at ${mc(n.path)}`);return t.join(`
|
|
2
|
-
`)}var Et=e=>(t,r,n,o)=>{let i=n?Object.assign(n,{async:!1}):{async:!1},s=t._zod.run({value:r,issues:[]},i);if(s instanceof Promise)throw new ne;if(s.issues.length){let c=new(o?.Err??e)(s.issues.map(a=>q(a,i,L())));throw St(c,o?.callee),c}return s.value},de=Et(G),It=e=>async(t,r,n,o)=>{let i=n?Object.assign(n,{async:!0}):{async:!0},s=t._zod.run({value:r,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){let c=new(o?.Err??e)(s.issues.map(a=>q(a,i,L())));throw St(c,o?.callee),c}return s.value},me=It(G),Tt=e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},o);if(i instanceof Promise)throw new ne;return i.issues.length?{success:!1,error:new(e??Or)(i.issues.map(s=>q(s,o,L())))}:{success:!0,data:i.value}},ke=Tt(G),At=e=>async(t,r,n)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},i=t._zod.run({value:r,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>q(s,o,L())))}:{success:!0,data:i.value}},Se=At(G),hc=e=>(t,r,n)=>{let o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Et(e)(t,r,o)},Br=hc(G),gc=e=>(t,r,n)=>Et(e)(t,r,n),Fr=gc(G),_c=e=>async(t,r,n)=>{let o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return It(e)(t,r,o)},Jr=_c(G),bc=e=>async(t,r,n)=>It(e)(t,r,n),qr=bc(G),yc=e=>(t,r,n)=>{let o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Tt(e)(t,r,o)},Gr=yc(G),xc=e=>(t,r,n)=>Tt(e)(t,r,n),Yr=xc(G),$c=e=>async(t,r,n)=>{let o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return At(e)(t,r,o)},Hr=$c(G),vc=e=>async(t,r,n)=>At(e)(t,r,n),Kr=vc(G);var Q={};we(Q,{base64:()=>fn,base64url:()=>Rt,bigint:()=>bn,boolean:()=>xn,browserEmail:()=>rp,cidrv4:()=>ln,cidrv6:()=>pn,cuid:()=>Vr,cuid2:()=>Wr,date:()=>mn,datetime:()=>gn,domain:()=>ip,duration:()=>rn,e164:()=>dn,email:()=>on,emoji:()=>sn,extendedDuration:()=>Kl,guid:()=>nn,hex:()=>sp,hostname:()=>op,html5Email:()=>Ql,idnEmail:()=>tp,integer:()=>yn,ipv4:()=>cn,ipv6:()=>an,ksuid:()=>en,lowercase:()=>wn,mac:()=>un,md5_base64:()=>ap,md5_base64url:()=>up,md5_hex:()=>cp,nanoid:()=>tn,null:()=>$n,number:()=>Zt,rfc5322Email:()=>ep,sha1_base64:()=>pp,sha1_base64url:()=>fp,sha1_hex:()=>lp,sha256_base64:()=>mp,sha256_base64url:()=>hp,sha256_hex:()=>dp,sha384_base64:()=>_p,sha384_base64url:()=>bp,sha384_hex:()=>gp,sha512_base64:()=>xp,sha512_base64url:()=>$p,sha512_hex:()=>yp,string:()=>_n,time:()=>hn,ulid:()=>Xr,undefined:()=>vn,unicodeEmail:()=>wc,uppercase:()=>zn,uuid:()=>Pe,uuid4:()=>Vl,uuid6:()=>Wl,uuid7:()=>Xl,xid:()=>Qr});var Vr=/^[cC][^\s-]{8,}$/,Wr=/^[0-9a-z]+$/,Xr=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Qr=/^[0-9a-vA-V]{20}$/,en=/^[A-Za-z0-9]{27}$/,tn=/^[a-zA-Z0-9_-]{21}$/,rn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Kl=/^[-+]?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)?)??$/,nn=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Pe=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Vl=Pe(4),Wl=Pe(6),Xl=Pe(7),on=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Ql=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,ep=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,wc=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,tp=wc,rp=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,np="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function sn(){return new RegExp(np,"u")}var cn=/^(?:(?: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])$/,an=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,un=e=>{let t=W(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},ln=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,pn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,fn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Rt=/^[A-Za-z0-9_-]*$/,op=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,ip=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,dn=/^\+[1-9]\d{6,14}$/,zc="(?:(?:\\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])))",mn=new RegExp(`^${zc}$`);function kc(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function hn(e){return new RegExp(`^${kc(e)}$`)}function gn(e){let t=kc({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${t}(?:${r.join("|")})`;return new RegExp(`^${zc}T(?:${n})$`)}var _n=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},bn=/^-?\d+n?$/,yn=/^-?\d+$/,Zt=/^-?\d+(?:\.\d+)?$/,xn=/^(?:true|false)$/i,$n=/^null$/i;var vn=/^undefined$/i;var wn=/^[^A-Z]*$/,zn=/^[^a-z]*$/,sp=/^[0-9a-fA-F]*$/;function rt(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function nt(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var cp=/^[0-9a-fA-F]{32}$/,ap=rt(22,"=="),up=nt(22),lp=/^[0-9a-fA-F]{40}$/,pp=rt(27,"="),fp=nt(27),dp=/^[0-9a-fA-F]{64}$/,mp=rt(43,"="),hp=nt(43),gp=/^[0-9a-fA-F]{96}$/,_p=rt(64,""),bp=nt(64),yp=/^[0-9a-fA-F]{128}$/,xp=rt(86,"=="),$p=nt(86);var T=f("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Pc={number:"number",bigint:"bigint",object:"date"},Ct=f("$ZodCheckLessThan",(e,t)=>{T.init(e,t);let r=Pc[typeof t.value];e._zod.onattach.push(n=>{let o=n._zod.bag,i=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Nt=f("$ZodCheckGreaterThan",(e,t)=>{T.init(e,t);let r=Pc[typeof t.value];e._zod.onattach.push(n=>{let o=n._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),kn=f("$ZodCheckMultipleOf",(e,t)=>{T.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):kr(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Sn=f("$ZodCheckNumberFormat",(e,t)=>{T.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,i]=Tr[t.format];e._zod.onattach.push(s=>{let c=s._zod.bag;c.format=t.format,c.minimum=o,c.maximum=i,r&&(c.pattern=yn)}),e._zod.check=s=>{let c=s.value;if(r){if(!Number.isInteger(c)){s.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?s.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):s.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}c<o&&s.issues.push({origin:"number",input:c,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),c>i&&s.issues.push({origin:"number",input:c,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),Pn=f("$ZodCheckBigIntFormat",(e,t)=>{T.init(e,t);let[r,n]=Ar[t.format];e._zod.onattach.push(o=>{let i=o._zod.bag;i.format=t.format,i.minimum=r,i.maximum=n}),e._zod.check=o=>{let i=o.value;i<r&&o.issues.push({origin:"bigint",input:i,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),i>n&&o.issues.push({origin:"bigint",input:i,code:"too_big",maximum:n,inclusive:!0,inst:e,continue:!t.abort})}}),En=f("$ZodCheckMaxSize",(e,t)=>{var r;T.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!ue(o)&&o.size!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let o=n.value;o.size<=t.maximum||n.issues.push({origin:et(o),code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),In=f("$ZodCheckMinSize",(e,t)=>{var r;T.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!ue(o)&&o.size!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let o=n.value;o.size>=t.minimum||n.issues.push({origin:et(o),code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Tn=f("$ZodCheckSizeEquals",(e,t)=>{var r;T.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!ue(o)&&o.size!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag;o.minimum=t.size,o.maximum=t.size,o.size=t.size}),e._zod.check=n=>{let o=n.value,i=o.size;if(i===t.size)return;let s=i>t.size;n.issues.push({origin:et(o),...s?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),An=f("$ZodCheckMaxLength",(e,t)=>{var r;T.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!ue(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let o=n.value;if(o.length<=t.maximum)return;let s=tt(o);n.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Rn=f("$ZodCheckMinLength",(e,t)=>{var r;T.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!ue(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let o=n.value;if(o.length>=t.minimum)return;let s=tt(o);n.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Zn=f("$ZodCheckLengthEquals",(e,t)=>{var r;T.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!ue(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=n=>{let o=n.value,i=o.length;if(i===t.length)return;let s=tt(o),c=i>t.length;n.issues.push({origin:s,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Oe=f("$ZodCheckStringFormat",(e,t)=>{var r,n;T.init(e,t),e._zod.onattach.push(o=>{let i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Cn=f("$ZodCheckRegex",(e,t)=>{Oe.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Nn=f("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=wn),Oe.init(e,t)}),jn=f("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=zn),Oe.init(e,t)}),On=f("$ZodCheckIncludes",(e,t)=>{T.init(e,t);let r=W(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(o=>{let i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Ln=f("$ZodCheckStartsWith",(e,t)=>{T.init(e,t);let r=new RegExp(`^${W(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Mn=f("$ZodCheckEndsWith",(e,t)=>{T.init(e,t);let r=new RegExp(`.*${W(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});function Sc(e,t,r){e.issues.length&&t.issues.push(...K(r,e.issues))}var Dn=f("$ZodCheckProperty",(e,t)=>{T.init(e,t),e._zod.check=r=>{let n=t.schema._zod.run({value:r.value[t.property],issues:[]},{});if(n instanceof Promise)return n.then(o=>Sc(o,r,t.property));Sc(n,r,t.property)}}),Un=f("$ZodCheckMimeType",(e,t)=>{T.init(e,t);let r=new Set(t.mime);e._zod.onattach.push(n=>{n._zod.bag.mime=t.mime}),e._zod.check=n=>{r.has(n.value.type)||n.issues.push({code:"invalid_value",values:t.mime,input:n.value.type,inst:e,continue:!t.abort})}}),Bn=f("$ZodCheckOverwrite",(e,t)=>{T.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var ot=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let n=t.split(`
|
|
1
|
+
var Dl=Object.defineProperty;var Se=(e,t)=>{for(var r in t)Dl(e,r,{get:t[r],enumerable:!0})};import{resolve as tg}from"node:path";import{fileURLToPath as rg}from"node:url";function Et(e,t){return e==="github"?`feature/issue-${t.replace("#","")}`:`feature/${t.toLowerCase()}`}function Pr(e,t,r){return r?e==="github"?`milestone/${r.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"")}`:`epic/${r.toLowerCase()}`:t}import{spawnSync as yc}from"node:child_process";function bc(e,t){let r=["-p","--dangerously-skip-permissions"];t&&r.push("--model",t);let n=yc("claude",r,{input:e,stdio:["pipe","pipe","pipe"],encoding:"utf8"});return{stdout:n.stdout??"",ok:n.status===0&&!n.error}}function xc(e,t){let r=["--dangerously-skip-permissions"];t&&r.push("--model",t);let n=yc("claude",r,{input:e,stdio:["pipe","inherit","inherit"],encoding:"utf8"});return n.status===0&&!n.error}var l={};Se(l,{$brand:()=>Ir,$input:()=>ui,$output:()=>ai,NEVER:()=>Er,TimePrecision:()=>Zi,ZodMiniAny:()=>Pa,ZodMiniArray:()=>Ra,ZodMiniBase64:()=>ba,ZodMiniBase64URL:()=>xa,ZodMiniBigInt:()=>_t,ZodMiniBigIntFormat:()=>Ls,ZodMiniBoolean:()=>gt,ZodMiniCIDRv4:()=>ga,ZodMiniCIDRv6:()=>_a,ZodMiniCUID:()=>ua,ZodMiniCUID2:()=>la,ZodMiniCatch:()=>Wa,ZodMiniCodec:()=>Js,ZodMiniCustom:()=>Ks,ZodMiniCustomStringFormat:()=>mt,ZodMiniDate:()=>ir,ZodMiniDefault:()=>Ya,ZodMiniDiscriminatedUnion:()=>Na,ZodMiniE164:()=>$a,ZodMiniEmail:()=>ia,ZodMiniEmoji:()=>ca,ZodMiniEnum:()=>Ds,ZodMiniExactOptional:()=>qa,ZodMiniFile:()=>Ja,ZodMiniFunction:()=>iu,ZodMiniGUID:()=>sa,ZodMiniIPv4:()=>ma,ZodMiniIPv6:()=>ha,ZodMiniISODate:()=>lr,ZodMiniISODateTime:()=>ur,ZodMiniISODuration:()=>fr,ZodMiniISOTime:()=>pr,ZodMiniIntersection:()=>ja,ZodMiniJWT:()=>va,ZodMiniKSUID:()=>da,ZodMiniLazy:()=>tu,ZodMiniLiteral:()=>Fa,ZodMiniMAC:()=>ya,ZodMiniMap:()=>Da,ZodMiniNaN:()=>Xa,ZodMiniNanoID:()=>aa,ZodMiniNever:()=>Ia,ZodMiniNonOptional:()=>Bs,ZodMiniNull:()=>ka,ZodMiniNullable:()=>Ga,ZodMiniNumber:()=>ht,ZodMiniNumberFormat:()=>Je,ZodMiniObject:()=>sr,ZodMiniOptional:()=>Us,ZodMiniPipe:()=>Fs,ZodMiniPrefault:()=>Ha,ZodMiniPromise:()=>nu,ZodMiniReadonly:()=>Qa,ZodMiniRecord:()=>cr,ZodMiniSet:()=>Ua,ZodMiniString:()=>Fe,ZodMiniStringFormat:()=>Z,ZodMiniSuccess:()=>Va,ZodMiniSymbol:()=>wa,ZodMiniTemplateLiteral:()=>eu,ZodMiniTransform:()=>Ka,ZodMiniTuple:()=>Oa,ZodMiniType:()=>k,ZodMiniULID:()=>pa,ZodMiniURL:()=>Os,ZodMiniUUID:()=>dt,ZodMiniUndefined:()=>za,ZodMiniUnion:()=>Ms,ZodMiniUnknown:()=>Ea,ZodMiniVoid:()=>Ta,ZodMiniXID:()=>fa,ZodMiniXor:()=>Za,_default:()=>lm,_function:()=>Im,any:()=>Ld,array:()=>K,base64:()=>xd,base64url:()=>$d,bigint:()=>Cd,boolean:()=>Ke,catch:()=>mm,catchall:()=>Vd,check:()=>$m,cidrv4:()=>_d,cidrv6:()=>yd,clone:()=>F,codec:()=>_m,coerce:()=>Gs,config:()=>D,core:()=>Be,cuid:()=>ld,cuid2:()=>pd,custom:()=>ou,date:()=>Dd,decode:()=>Wr,decodeAsync:()=>Qr,describe:()=>zm,discriminatedUnion:()=>Xd,e164:()=>vd,email:()=>ed,emoji:()=>ad,encode:()=>Vr,encodeAsync:()=>Xr,endsWith:()=>vs,enum:()=>Ba,exactOptional:()=>am,extend:()=>yt,file:()=>sm,flattenError:()=>qr,float32:()=>Id,float64:()=>Ad,formatError:()=>Gr,function:()=>Im,globalRegistry:()=>ce,gt:()=>er,gte:()=>lt,guid:()=>td,hash:()=>Pd,hex:()=>Sd,hostname:()=>kd,httpUrl:()=>cd,includes:()=>xs,instanceof:()=>Sm,int:()=>Ed,int32:()=>Td,int64:()=>Zd,intersection:()=>Qd,ipv4:()=>hd,ipv6:()=>gd,iso:()=>qs,json:()=>Em,jwt:()=>wd,keyof:()=>Ud,ksuid:()=>md,lazy:()=>ru,length:()=>_s,literal:()=>im,locales:()=>at,looseObject:()=>Fd,looseRecord:()=>tm,lowercase:()=>ys,lt:()=>Qt,lte:()=>ut,mac:()=>bd,map:()=>rm,maxLength:()=>gs,maxSize:()=>ds,maximum:()=>ut,merge:()=>Kd,meta:()=>km,mime:()=>zs,minLength:()=>pt,minSize:()=>ms,minimum:()=>lt,multipleOf:()=>fs,nan:()=>hm,nanoid:()=>ud,nativeEnum:()=>om,negative:()=>us,never:()=>Aa,nonnegative:()=>ps,nonoptional:()=>fm,nonpositive:()=>ls,normalize:()=>ks,null:()=>Sa,nullable:()=>ar,nullish:()=>um,number:()=>ve,object:()=>E,omit:()=>Gd,optional:()=>$,overwrite:()=>ye,parse:()=>ge,parseAsync:()=>_e,partial:()=>Yd,partialRecord:()=>em,pick:()=>qd,pipe:()=>gm,positive:()=>as,prefault:()=>pm,prettifyError:()=>Hr,promise:()=>xm,property:()=>ws,readonly:()=>ym,record:()=>Ma,refine:()=>vm,regex:()=>ft,regexes:()=>te,registry:()=>Wt,required:()=>Hd,safeDecode:()=>tn,safeDecodeAsync:()=>nn,safeEncode:()=>en,safeEncodeAsync:()=>rn,safeExtend:()=>Jd,safeParse:()=>Ee,safeParseAsync:()=>Ie,set:()=>nm,size:()=>hs,startsWith:()=>$s,strictObject:()=>Bd,string:()=>x,stringFormat:()=>zd,stringbool:()=>Pm,success:()=>dm,superRefine:()=>wm,symbol:()=>jd,templateLiteral:()=>bm,toJSONSchema:()=>rr,toLowerCase:()=>Ps,toUpperCase:()=>Es,transform:()=>cm,treeifyError:()=>Yr,trim:()=>Ss,tuple:()=>La,uint32:()=>Rd,uint64:()=>Nd,ulid:()=>fd,undefined:()=>Od,union:()=>Ca,unknown:()=>or,uppercase:()=>bs,url:()=>sd,util:()=>ee,uuid:()=>rd,uuidv4:()=>nd,uuidv6:()=>od,uuidv7:()=>id,void:()=>Md,xid:()=>dd,xor:()=>Wd});var Be={};Se(Be,{$ZodAny:()=>To,$ZodArray:()=>jo,$ZodAsyncError:()=>ie,$ZodBase64:()=>$o,$ZodBase64URL:()=>vo,$ZodBigInt:()=>qt,$ZodBigIntFormat:()=>Po,$ZodBoolean:()=>it,$ZodCIDRv4:()=>yo,$ZodCIDRv6:()=>bo,$ZodCUID:()=>io,$ZodCUID2:()=>so,$ZodCatch:()=>Qo,$ZodCheck:()=>C,$ZodCheckBigIntFormat:()=>Nn,$ZodCheckEndsWith:()=>Gn,$ZodCheckGreaterThan:()=>Mt,$ZodCheckIncludes:()=>Kn,$ZodCheckLengthEquals:()=>Un,$ZodCheckLessThan:()=>Lt,$ZodCheckLowerCase:()=>Fn,$ZodCheckMaxLength:()=>Mn,$ZodCheckMaxSize:()=>jn,$ZodCheckMimeType:()=>Hn,$ZodCheckMinLength:()=>Dn,$ZodCheckMinSize:()=>On,$ZodCheckMultipleOf:()=>Cn,$ZodCheckNumberFormat:()=>Zn,$ZodCheckOverwrite:()=>Vn,$ZodCheckProperty:()=>Yn,$ZodCheckRegex:()=>Bn,$ZodCheckSizeEquals:()=>Ln,$ZodCheckStartsWith:()=>qn,$ZodCheckStringFormat:()=>Me,$ZodCheckUpperCase:()=>Jn,$ZodCodec:()=>ct,$ZodCustom:()=>ci,$ZodCustomStringFormat:()=>ko,$ZodDate:()=>No,$ZodDefault:()=>Ho,$ZodDiscriminatedUnion:()=>Lo,$ZodE164:()=>wo,$ZodEmail:()=>to,$ZodEmoji:()=>no,$ZodEncodeError:()=>Ne,$ZodEnum:()=>Fo,$ZodError:()=>Kr,$ZodExactOptional:()=>Go,$ZodFile:()=>Ko,$ZodFunction:()=>oi,$ZodGUID:()=>Qn,$ZodIPv4:()=>ho,$ZodIPv6:()=>go,$ZodISODate:()=>po,$ZodISODateTime:()=>lo,$ZodISODuration:()=>mo,$ZodISOTime:()=>fo,$ZodIntersection:()=>Mo,$ZodJWT:()=>zo,$ZodKSUID:()=>uo,$ZodLazy:()=>si,$ZodLiteral:()=>Jo,$ZodMAC:()=>_o,$ZodMap:()=>Uo,$ZodNaN:()=>ei,$ZodNanoID:()=>oo,$ZodNever:()=>Co,$ZodNonOptional:()=>Wo,$ZodNull:()=>Ao,$ZodNullable:()=>Yo,$ZodNumber:()=>Kt,$ZodNumberFormat:()=>So,$ZodObject:()=>Gt,$ZodObjectJIT:()=>jp,$ZodOptional:()=>Ht,$ZodPipe:()=>ti,$ZodPrefault:()=>Vo,$ZodPromise:()=>ii,$ZodReadonly:()=>ri,$ZodRealError:()=>H,$ZodRecord:()=>Do,$ZodRegistry:()=>Vt,$ZodSet:()=>Bo,$ZodString:()=>De,$ZodStringFormat:()=>T,$ZodSuccess:()=>Xo,$ZodSymbol:()=>Eo,$ZodTemplateLiteral:()=>ni,$ZodTransform:()=>qo,$ZodTuple:()=>Yt,$ZodType:()=>v,$ZodULID:()=>co,$ZodURL:()=>ro,$ZodUUID:()=>eo,$ZodUndefined:()=>Io,$ZodUnion:()=>st,$ZodUnknown:()=>Ro,$ZodVoid:()=>Zo,$ZodXID:()=>ao,$ZodXor:()=>Oo,$brand:()=>Ir,$constructor:()=>f,$input:()=>ui,$output:()=>ai,Doc:()=>ot,JSONSchema:()=>oa,JSONSchemaGenerator:()=>nr,NEVER:()=>Er,TimePrecision:()=>Zi,_any:()=>ts,_array:()=>Up,_base64:()=>Ai,_base64url:()=>Ti,_bigint:()=>Yi,_boolean:()=>qi,_catch:()=>sf,_check:()=>na,_cidrv4:()=>Ei,_cidrv6:()=>Ii,_coercedBigint:()=>Hi,_coercedBoolean:()=>Gi,_coercedDate:()=>ss,_coercedNumber:()=>Di,_coercedString:()=>pi,_cuid:()=>xi,_cuid2:()=>$i,_custom:()=>As,_date:()=>is,_decode:()=>Ec,_decodeAsync:()=>Ac,_default:()=>rf,_discriminatedUnion:()=>Jp,_e164:()=>Ri,_email:()=>fi,_emoji:()=>yi,_encode:()=>Pc,_encodeAsync:()=>Ic,_endsWith:()=>vs,_enum:()=>Vp,_file:()=>Is,_float32:()=>Bi,_float64:()=>Fi,_gt:()=>er,_gte:()=>lt,_guid:()=>di,_includes:()=>xs,_int:()=>Ui,_int32:()=>Ji,_int64:()=>Vi,_intersection:()=>Kp,_ipv4:()=>ki,_ipv6:()=>Si,_isoDate:()=>ji,_isoDateTime:()=>Ni,_isoDuration:()=>Li,_isoTime:()=>Oi,_jwt:()=>Ci,_ksuid:()=>zi,_lazy:()=>lf,_length:()=>_s,_literal:()=>Xp,_lowercase:()=>ys,_lt:()=>Qt,_lte:()=>ut,_mac:()=>Pi,_map:()=>Yp,_max:()=>ut,_maxLength:()=>gs,_maxSize:()=>ds,_mime:()=>zs,_min:()=>lt,_minLength:()=>pt,_minSize:()=>ms,_multipleOf:()=>fs,_nan:()=>cs,_nanoid:()=>bi,_nativeEnum:()=>Wp,_negative:()=>us,_never:()=>ns,_nonnegative:()=>ps,_nonoptional:()=>nf,_nonpositive:()=>ls,_normalize:()=>ks,_null:()=>es,_nullable:()=>tf,_number:()=>Mi,_optional:()=>ef,_overwrite:()=>ye,_parse:()=>Rt,_parseAsync:()=>Ct,_pipe:()=>cf,_positive:()=>as,_promise:()=>pf,_property:()=>ws,_readonly:()=>af,_record:()=>Gp,_refine:()=>Ts,_regex:()=>ft,_safeDecode:()=>Rc,_safeDecodeAsync:()=>Zc,_safeEncode:()=>Tc,_safeEncodeAsync:()=>Cc,_safeParse:()=>Zt,_safeParseAsync:()=>Nt,_set:()=>Hp,_size:()=>hs,_slugify:()=>Dp,_startsWith:()=>$s,_string:()=>li,_stringFormat:()=>Ue,_stringbool:()=>Ns,_success:()=>of,_superRefine:()=>Rs,_symbol:()=>Xi,_templateLiteral:()=>uf,_toLowerCase:()=>Ps,_toUpperCase:()=>Es,_transform:()=>Qp,_trim:()=>Ss,_tuple:()=>qp,_uint32:()=>Ki,_uint64:()=>Wi,_ulid:()=>vi,_undefined:()=>Qi,_union:()=>Bp,_unknown:()=>rs,_uppercase:()=>bs,_url:()=>Xt,_uuid:()=>mi,_uuidv4:()=>hi,_uuidv6:()=>gi,_uuidv7:()=>_i,_void:()=>os,_xid:()=>wi,_xor:()=>Fp,clone:()=>F,config:()=>D,createStandardJSONSchemaMethod:()=>js,createToJSONSchemaMethod:()=>ff,decode:()=>Wr,decodeAsync:()=>Qr,describe:()=>Cs,encode:()=>Vr,encodeAsync:()=>Xr,extractDefs:()=>xe,finalize:()=>$e,flattenError:()=>qr,formatError:()=>Gr,globalConfig:()=>He,globalRegistry:()=>ce,initializeContext:()=>be,isValidBase64:()=>xo,isValidBase64URL:()=>Xc,isValidJWT:()=>Qc,locales:()=>at,meta:()=>Zs,parse:()=>ge,parseAsync:()=>_e,prettifyError:()=>Hr,process:()=>P,regexes:()=>te,registry:()=>Wt,safeDecode:()=>tn,safeDecodeAsync:()=>nn,safeEncode:()=>en,safeEncodeAsync:()=>rn,safeParse:()=>Ee,safeParseAsync:()=>Ie,toDotPath:()=>Sc,toJSONSchema:()=>rr,treeifyError:()=>Yr,util:()=>ee,version:()=>Wn});var Er=Object.freeze({status:"aborted"});function f(e,t,r){function n(c,a){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:a,constr:s,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,a);let u=s.prototype,p=Object.keys(u);for(let d=0;d<p.length;d++){let h=p[d];h in c||(c[h]=u[h].bind(c))}}let o=r?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function s(c){var a;let u=r?.Parent?new i:this;n(u,c),(a=u._zod).deferred??(a.deferred=[]);for(let p of u._zod.deferred)p();return u}return Object.defineProperty(s,"init",{value:n}),Object.defineProperty(s,Symbol.hasInstance,{value:c=>r?.Parent&&c instanceof r.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}var Ir=Symbol("zod_brand"),ie=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Ne=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}},He={};function D(e){return e&&Object.assign(He,e),He}var ee={};Se(ee,{BIGINT_FORMAT_RANGES:()=>Mr,Class:()=>Tr,NUMBER_FORMAT_RANGES:()=>Lr,aborted:()=>he,allowsEval:()=>Nr,assert:()=>Kl,assertEqual:()=>Ul,assertIs:()=>Fl,assertNever:()=>Jl,assertNotEqual:()=>Bl,assignProp:()=>de,base64ToUint8Array:()=>wc,base64urlToUint8Array:()=>op,cached:()=>je,captureStackTrace:()=>At,cleanEnum:()=>np,cleanRegex:()=>Xe,clone:()=>F,cloneDef:()=>Yl,createTransparentProxy:()=>ep,defineLazy:()=>z,esc:()=>It,escapeRegex:()=>Q,extend:()=>Tt,finalizeIssue:()=>Y,floatSafeRemainder:()=>Cr,getElementAtPath:()=>Hl,getEnumValues:()=>We,getLengthableOrigin:()=>tt,getParsedType:()=>Ql,getSizableOrigin:()=>et,hexToUint8Array:()=>sp,isObject:()=>Pe,isPlainObject:()=>me,issue:()=>Le,joinValues:()=>ql,jsonStringifyReplacer:()=>Rr,merge:()=>tp,mergeDefs:()=>ue,normalizeParams:()=>g,nullish:()=>fe,numKeys:()=>Xl,objectClone:()=>Gl,omit:()=>Ur,optionalKeys:()=>Or,parsedType:()=>rp,partial:()=>Fr,pick:()=>Dr,prefixIssues:()=>V,primitiveTypes:()=>jr,promiseAllObject:()=>Vl,propertyKeyTypes:()=>Qe,randomString:()=>Wl,required:()=>Jr,safeExtend:()=>Br,shallowClone:()=>Oe,slugify:()=>Zr,stringifyPrimitive:()=>vc,uint8ArrayToBase64:()=>zc,uint8ArrayToBase64url:()=>ip,uint8ArrayToHex:()=>cp,unwrapMessage:()=>Ve});function Ul(e){return e}function Bl(e){return e}function Fl(e){}function Jl(e){throw new Error("Unexpected value in exhaustive check")}function Kl(e){}function We(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function ql(e,t="|"){return e.map(r=>vc(r)).join(t)}function Rr(e,t){return typeof t=="bigint"?t.toString():t}function je(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function fe(e){return e==null}function Xe(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Cr(e,t){let r=(e.toString().split(".")[1]||"").length,n=t.toString(),o=(n.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(n)){let a=n.match(/\d?e-(\d?)/);a?.[1]&&(o=Number.parseInt(a[1]))}let i=r>o?r:o,s=Number.parseInt(e.toFixed(i).replace(".","")),c=Number.parseInt(t.toFixed(i).replace(".",""));return s%c/10**i}var $c=Symbol("evaluating");function z(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==$c)return n===void 0&&(n=$c,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function Gl(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function de(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function ue(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function Yl(e){return ue(e._zod.def)}function Hl(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function Vl(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let o={};for(let i=0;i<t.length;i++)o[t[i]]=n[i];return o})}function Wl(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function It(e){return JSON.stringify(e)}function Zr(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var At="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Pe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Nr=je(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function me(e){if(Pe(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Pe(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Oe(e){return me(e)?{...e}:Array.isArray(e)?[...e]:e}function Xl(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var Ql=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},Qe=new Set(["string","number","symbol"]),jr=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Q(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function F(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function g(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function ep(e){let t;return new Proxy({},{get(r,n,o){return t??(t=e()),Reflect.get(t,n,o)},set(r,n,o,i){return t??(t=e()),Reflect.set(t,n,o,i)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,o){return t??(t=e()),Reflect.defineProperty(t,n,o)}})}function vc(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Or(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Lr={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Mr={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Dr(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let i=ue(e._zod.def,{get shape(){let s={};for(let c in t){if(!(c in r.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&(s[c]=r.shape[c])}return de(this,"shape",s),s},checks:[]});return F(e,i)}function Ur(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let i=ue(e._zod.def,{get shape(){let s={...e._zod.def.shape};for(let c in t){if(!(c in r.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&delete s[c]}return de(this,"shape",s),s},checks:[]});return F(e,i)}function Tt(e,t){if(!me(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let i=e._zod.def.shape;for(let s in t)if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let o=ue(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return de(this,"shape",i),i}});return F(e,o)}function Br(e,t){if(!me(t))throw new Error("Invalid input to safeExtend: expected a plain object");let r=ue(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return de(this,"shape",n),n}});return F(e,r)}function tp(e,t){let r=ue(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return de(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return F(e,r)}function Fr(e,t,r){let o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let s=ue(t._zod.def,{get shape(){let c=t._zod.def.shape,a={...c};if(r)for(let u in r){if(!(u in c))throw new Error(`Unrecognized key: "${u}"`);r[u]&&(a[u]=e?new e({type:"optional",innerType:c[u]}):c[u])}else for(let u in c)a[u]=e?new e({type:"optional",innerType:c[u]}):c[u];return de(this,"shape",a),a},checks:[]});return F(t,s)}function Jr(e,t,r){let n=ue(t._zod.def,{get shape(){let o=t._zod.def.shape,i={...o};if(r)for(let s in r){if(!(s in i))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(i[s]=new e({type:"nonoptional",innerType:o[s]}))}else for(let s in o)i[s]=new e({type:"nonoptional",innerType:o[s]});return de(this,"shape",i),i}});return F(t,n)}function he(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function V(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Ve(e){return typeof e=="string"?e:e?.message}function Y(e,t,r){let n={...e,path:e.path??[]};if(!e.message){let o=Ve(e.inst?._zod.def?.error?.(e))??Ve(t?.error?.(e))??Ve(r.customError?.(e))??Ve(r.localeError?.(e))??"Invalid input";n.message=o}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function et(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function tt(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function rp(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function Le(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function np(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function wc(e){let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function zc(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function op(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return wc(t+r)}function ip(e){return zc(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function sp(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)r[n/2]=Number.parseInt(t.slice(n,n+2),16);return r}function cp(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var Tr=class{constructor(...t){}};var kc=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Rr,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Kr=f("$ZodError",kc),H=f("$ZodError",kc,{Parent:Error});function qr(e,t=r=>r.message){let r={},n=[];for(let o of e.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(t(o))):n.push(t(o));return{formErrors:n,fieldErrors:r}}function Gr(e,t=r=>r.message){let r={_errors:[]},n=o=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(s=>n({issues:s}));else if(i.code==="invalid_key")n({issues:i.issues});else if(i.code==="invalid_element")n({issues:i.issues});else if(i.path.length===0)r._errors.push(t(i));else{let s=r,c=0;for(;c<i.path.length;){let a=i.path[c];c===i.path.length-1?(s[a]=s[a]||{_errors:[]},s[a]._errors.push(t(i))):s[a]=s[a]||{_errors:[]},s=s[a],c++}}};return n(e),r}function Yr(e,t=r=>r.message){let r={errors:[]},n=(o,i=[])=>{var s,c;for(let a of o.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(u=>n({issues:u},a.path));else if(a.code==="invalid_key")n({issues:a.issues},a.path);else if(a.code==="invalid_element")n({issues:a.issues},a.path);else{let u=[...i,...a.path];if(u.length===0){r.errors.push(t(a));continue}let p=r,d=0;for(;d<u.length;){let h=u[d],m=d===u.length-1;typeof h=="string"?(p.properties??(p.properties={}),(s=p.properties)[h]??(s[h]={errors:[]}),p=p.properties[h]):(p.items??(p.items=[]),(c=p.items)[h]??(c[h]={errors:[]}),p=p.items[h]),m&&p.errors.push(t(a)),d++}}};return n(e),r}function Sc(e){let t=[],r=e.map(n=>typeof n=="object"?n.key:n);for(let n of r)typeof n=="number"?t.push(`[${n}]`):typeof n=="symbol"?t.push(`[${JSON.stringify(String(n))}]`):/[^\w$]/.test(n)?t.push(`[${JSON.stringify(n)}]`):(t.length&&t.push("."),t.push(n));return t.join("")}function Hr(e){let t=[],r=[...e.issues].sort((n,o)=>(n.path??[]).length-(o.path??[]).length);for(let n of r)t.push(`\u2716 ${n.message}`),n.path?.length&&t.push(` \u2192 at ${Sc(n.path)}`);return t.join(`
|
|
2
|
+
`)}var Rt=e=>(t,r,n,o)=>{let i=n?Object.assign(n,{async:!1}):{async:!1},s=t._zod.run({value:r,issues:[]},i);if(s instanceof Promise)throw new ie;if(s.issues.length){let c=new(o?.Err??e)(s.issues.map(a=>Y(a,i,D())));throw At(c,o?.callee),c}return s.value},ge=Rt(H),Ct=e=>async(t,r,n,o)=>{let i=n?Object.assign(n,{async:!0}):{async:!0},s=t._zod.run({value:r,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){let c=new(o?.Err??e)(s.issues.map(a=>Y(a,i,D())));throw At(c,o?.callee),c}return s.value},_e=Ct(H),Zt=e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},o);if(i instanceof Promise)throw new ie;return i.issues.length?{success:!1,error:new(e??Kr)(i.issues.map(s=>Y(s,o,D())))}:{success:!0,data:i.value}},Ee=Zt(H),Nt=e=>async(t,r,n)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},i=t._zod.run({value:r,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>Y(s,o,D())))}:{success:!0,data:i.value}},Ie=Nt(H),Pc=e=>(t,r,n)=>{let o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Rt(e)(t,r,o)},Vr=Pc(H),Ec=e=>(t,r,n)=>Rt(e)(t,r,n),Wr=Ec(H),Ic=e=>async(t,r,n)=>{let o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Ct(e)(t,r,o)},Xr=Ic(H),Ac=e=>async(t,r,n)=>Ct(e)(t,r,n),Qr=Ac(H),Tc=e=>(t,r,n)=>{let o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Zt(e)(t,r,o)},en=Tc(H),Rc=e=>(t,r,n)=>Zt(e)(t,r,n),tn=Rc(H),Cc=e=>async(t,r,n)=>{let o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Nt(e)(t,r,o)},rn=Cc(H),Zc=e=>async(t,r,n)=>Nt(e)(t,r,n),nn=Zc(H);var te={};Se(te,{base64:()=>xn,base64url:()=>jt,bigint:()=>Sn,boolean:()=>En,browserEmail:()=>gp,cidrv4:()=>yn,cidrv6:()=>bn,cuid:()=>on,cuid2:()=>sn,date:()=>vn,datetime:()=>zn,domain:()=>bp,duration:()=>pn,e164:()=>$n,email:()=>dn,emoji:()=>mn,extendedDuration:()=>up,guid:()=>fn,hex:()=>xp,hostname:()=>yp,html5Email:()=>dp,idnEmail:()=>hp,integer:()=>Pn,ipv4:()=>hn,ipv6:()=>gn,ksuid:()=>un,lowercase:()=>Tn,mac:()=>_n,md5_base64:()=>vp,md5_base64url:()=>wp,md5_hex:()=>$p,nanoid:()=>ln,null:()=>In,number:()=>Ot,rfc5322Email:()=>mp,sha1_base64:()=>kp,sha1_base64url:()=>Sp,sha1_hex:()=>zp,sha256_base64:()=>Ep,sha256_base64url:()=>Ip,sha256_hex:()=>Pp,sha384_base64:()=>Tp,sha384_base64url:()=>Rp,sha384_hex:()=>Ap,sha512_base64:()=>Zp,sha512_base64url:()=>Np,sha512_hex:()=>Cp,string:()=>kn,time:()=>wn,ulid:()=>cn,undefined:()=>An,unicodeEmail:()=>Nc,uppercase:()=>Rn,uuid:()=>Ae,uuid4:()=>lp,uuid6:()=>pp,uuid7:()=>fp,xid:()=>an});var on=/^[cC][^\s-]{8,}$/,sn=/^[0-9a-z]+$/,cn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,an=/^[0-9a-vA-V]{20}$/,un=/^[A-Za-z0-9]{27}$/,ln=/^[a-zA-Z0-9_-]{21}$/,pn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,up=/^[-+]?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)?)??$/,fn=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Ae=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,lp=Ae(4),pp=Ae(6),fp=Ae(7),dn=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,dp=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,mp=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,Nc=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,hp=Nc,gp=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,_p="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function mn(){return new RegExp(_p,"u")}var hn=/^(?:(?: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])$/,gn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,_n=e=>{let t=Q(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},yn=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,bn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,xn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,jt=/^[A-Za-z0-9_-]*$/,yp=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,bp=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,$n=/^\+[1-9]\d{6,14}$/,jc="(?:(?:\\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])))",vn=new RegExp(`^${jc}$`);function Oc(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function wn(e){return new RegExp(`^${Oc(e)}$`)}function zn(e){let t=Oc({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${t}(?:${r.join("|")})`;return new RegExp(`^${jc}T(?:${n})$`)}var kn=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Sn=/^-?\d+n?$/,Pn=/^-?\d+$/,Ot=/^-?\d+(?:\.\d+)?$/,En=/^(?:true|false)$/i,In=/^null$/i;var An=/^undefined$/i;var Tn=/^[^A-Z]*$/,Rn=/^[^a-z]*$/,xp=/^[0-9a-fA-F]*$/;function rt(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function nt(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var $p=/^[0-9a-fA-F]{32}$/,vp=rt(22,"=="),wp=nt(22),zp=/^[0-9a-fA-F]{40}$/,kp=rt(27,"="),Sp=nt(27),Pp=/^[0-9a-fA-F]{64}$/,Ep=rt(43,"="),Ip=nt(43),Ap=/^[0-9a-fA-F]{96}$/,Tp=rt(64,""),Rp=nt(64),Cp=/^[0-9a-fA-F]{128}$/,Zp=rt(86,"=="),Np=nt(86);var C=f("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Mc={number:"number",bigint:"bigint",object:"date"},Lt=f("$ZodCheckLessThan",(e,t)=>{C.init(e,t);let r=Mc[typeof t.value];e._zod.onattach.push(n=>{let o=n._zod.bag,i=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Mt=f("$ZodCheckGreaterThan",(e,t)=>{C.init(e,t);let r=Mc[typeof t.value];e._zod.onattach.push(n=>{let o=n._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Cn=f("$ZodCheckMultipleOf",(e,t)=>{C.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):Cr(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Zn=f("$ZodCheckNumberFormat",(e,t)=>{C.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,i]=Lr[t.format];e._zod.onattach.push(s=>{let c=s._zod.bag;c.format=t.format,c.minimum=o,c.maximum=i,r&&(c.pattern=Pn)}),e._zod.check=s=>{let c=s.value;if(r){if(!Number.isInteger(c)){s.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?s.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):s.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}c<o&&s.issues.push({origin:"number",input:c,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),c>i&&s.issues.push({origin:"number",input:c,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),Nn=f("$ZodCheckBigIntFormat",(e,t)=>{C.init(e,t);let[r,n]=Mr[t.format];e._zod.onattach.push(o=>{let i=o._zod.bag;i.format=t.format,i.minimum=r,i.maximum=n}),e._zod.check=o=>{let i=o.value;i<r&&o.issues.push({origin:"bigint",input:i,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),i>n&&o.issues.push({origin:"bigint",input:i,code:"too_big",maximum:n,inclusive:!0,inst:e,continue:!t.abort})}}),jn=f("$ZodCheckMaxSize",(e,t)=>{var r;C.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!fe(o)&&o.size!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let o=n.value;o.size<=t.maximum||n.issues.push({origin:et(o),code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),On=f("$ZodCheckMinSize",(e,t)=>{var r;C.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!fe(o)&&o.size!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let o=n.value;o.size>=t.minimum||n.issues.push({origin:et(o),code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Ln=f("$ZodCheckSizeEquals",(e,t)=>{var r;C.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!fe(o)&&o.size!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag;o.minimum=t.size,o.maximum=t.size,o.size=t.size}),e._zod.check=n=>{let o=n.value,i=o.size;if(i===t.size)return;let s=i>t.size;n.issues.push({origin:et(o),...s?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Mn=f("$ZodCheckMaxLength",(e,t)=>{var r;C.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!fe(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let o=n.value;if(o.length<=t.maximum)return;let s=tt(o);n.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Dn=f("$ZodCheckMinLength",(e,t)=>{var r;C.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!fe(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let o=n.value;if(o.length>=t.minimum)return;let s=tt(o);n.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Un=f("$ZodCheckLengthEquals",(e,t)=>{var r;C.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!fe(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=n=>{let o=n.value,i=o.length;if(i===t.length)return;let s=tt(o),c=i>t.length;n.issues.push({origin:s,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Me=f("$ZodCheckStringFormat",(e,t)=>{var r,n;C.init(e,t),e._zod.onattach.push(o=>{let i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Bn=f("$ZodCheckRegex",(e,t)=>{Me.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Fn=f("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Tn),Me.init(e,t)}),Jn=f("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Rn),Me.init(e,t)}),Kn=f("$ZodCheckIncludes",(e,t)=>{C.init(e,t);let r=Q(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(o=>{let i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),qn=f("$ZodCheckStartsWith",(e,t)=>{C.init(e,t);let r=new RegExp(`^${Q(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Gn=f("$ZodCheckEndsWith",(e,t)=>{C.init(e,t);let r=new RegExp(`.*${Q(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});function Lc(e,t,r){e.issues.length&&t.issues.push(...V(r,e.issues))}var Yn=f("$ZodCheckProperty",(e,t)=>{C.init(e,t),e._zod.check=r=>{let n=t.schema._zod.run({value:r.value[t.property],issues:[]},{});if(n instanceof Promise)return n.then(o=>Lc(o,r,t.property));Lc(n,r,t.property)}}),Hn=f("$ZodCheckMimeType",(e,t)=>{C.init(e,t);let r=new Set(t.mime);e._zod.onattach.push(n=>{n._zod.bag.mime=t.mime}),e._zod.check=n=>{r.has(n.value.type)||n.issues.push({code:"invalid_value",values:t.mime,input:n.value.type,inst:e,continue:!t.abort})}}),Vn=f("$ZodCheckOverwrite",(e,t)=>{C.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var ot=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let n=t.split(`
|
|
3
3
|
`).filter(s=>s),o=Math.min(...n.map(s=>s.length-s.trimStart().length)),i=n.map(s=>s.slice(o)).map(s=>" ".repeat(this.indent*2)+s);for(let s of i)this.content.push(s)}compile(){let t=Function,r=this?.args,o=[...(this?.content??[""]).map(i=>` ${i}`)];return new t(...r,o.join(`
|
|
4
|
-
`))}};var Fn={major:4,minor:3,patch:6};var $=f("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Fn;let n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(let o of n)for(let i of o._zod.onattach)i(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let o=(s,c,a)=>{let u=fe(s),p;for(let d of c){if(d._zod.def.when){if(!d._zod.def.when(s))continue}else if(u)continue;let m=s.issues.length,h=d._zod.check(s);if(h instanceof Promise&&a?.async===!1)throw new ne;if(p||h instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await h,s.issues.length!==m&&(u||(u=fe(s,m)))});else{if(s.issues.length===m)continue;u||(u=fe(s,m))}}return p?p.then(()=>s):s},i=(s,c,a)=>{if(fe(s))return s.aborted=!0,s;let u=o(c,n,a);if(u instanceof Promise){if(a.async===!1)throw new ne;return u.then(p=>e._zod.parse(p,a))}return e._zod.parse(u,a)};e._zod.run=(s,c)=>{if(c.skipChecks)return e._zod.parse(s,c);if(c.direction==="backward"){let u=e._zod.parse({value:s.value,issues:[]},{...c,skipChecks:!0});return u instanceof Promise?u.then(p=>i(p,s,c)):i(u,s,c)}let a=e._zod.parse(s,c);if(a instanceof Promise){if(c.async===!1)throw new ne;return a.then(u=>o(u,n,c))}return o(a,n,c)}}w(e,"~standard",()=>({validate:o=>{try{let i=ke(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return Se(e,o).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),Le=f("$ZodString",(e,t)=>{$.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??_n(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),I=f("$ZodStringFormat",(e,t)=>{Oe.init(e,t),Le.init(e,t)}),qn=f("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=nn),I.init(e,t)}),Gn=f("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Pe(n))}else t.pattern??(t.pattern=Pe());I.init(e,t)}),Yn=f("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=on),I.init(e,t)}),Hn=f("$ZodURL",(e,t)=>{I.init(e,t),e._zod.check=r=>{try{let n=r.value.trim(),o=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=o.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Kn=f("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=sn()),I.init(e,t)}),Vn=f("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=tn),I.init(e,t)}),Wn=f("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Vr),I.init(e,t)}),Xn=f("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Wr),I.init(e,t)}),Qn=f("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Xr),I.init(e,t)}),eo=f("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Qr),I.init(e,t)}),to=f("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=en),I.init(e,t)}),ro=f("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=gn(t)),I.init(e,t)}),no=f("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=mn),I.init(e,t)}),oo=f("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=hn(t)),I.init(e,t)}),io=f("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=rn),I.init(e,t)}),so=f("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=cn),I.init(e,t),e._zod.bag.format="ipv4"}),co=f("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=an),I.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),ao=f("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=un(t.delimiter)),I.init(e,t),e._zod.bag.format="mac"}),uo=f("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ln),I.init(e,t)}),lo=f("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=pn),I.init(e,t),e._zod.check=r=>{let n=r.value.split("/");try{if(n.length!==2)throw new Error;let[o,i]=n;if(!i)throw new Error;let s=Number(i);if(`${s}`!==i)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${o}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function po(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var fo=f("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=fn),I.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{po(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function Dc(e){if(!Rt.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return po(r)}var mo=f("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Rt),I.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{Dc(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),ho=f("$ZodE164",(e,t)=>{t.pattern??(t.pattern=dn),I.init(e,t)});function Uc(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}var go=f("$ZodJWT",(e,t)=>{I.init(e,t),e._zod.check=r=>{Uc(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),_o=f("$ZodCustomStringFormat",(e,t)=>{I.init(e,t),e._zod.check=r=>{t.fn(r.value)||r.issues.push({code:"invalid_format",format:t.format,input:r.value,inst:e,continue:!t.abort})}}),Ut=f("$ZodNumber",(e,t)=>{$.init(e,t),e._zod.pattern=e._zod.bag.pattern??Zt,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),r}}),bo=f("$ZodNumberFormat",(e,t)=>{Sn.init(e,t),Ut.init(e,t)}),it=f("$ZodBoolean",(e,t)=>{$.init(e,t),e._zod.pattern=xn,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}}),Bt=f("$ZodBigInt",(e,t)=>{$.init(e,t),e._zod.pattern=bn,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch{}return typeof r.value=="bigint"||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}}),yo=f("$ZodBigIntFormat",(e,t)=>{Pn.init(e,t),Bt.init(e,t)}),xo=f("$ZodSymbol",(e,t)=>{$.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;return typeof o=="symbol"||r.issues.push({expected:"symbol",code:"invalid_type",input:o,inst:e}),r}}),$o=f("$ZodUndefined",(e,t)=>{$.init(e,t),e._zod.pattern=vn,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(r,n)=>{let o=r.value;return typeof o>"u"||r.issues.push({expected:"undefined",code:"invalid_type",input:o,inst:e}),r}}),vo=f("$ZodNull",(e,t)=>{$.init(e,t),e._zod.pattern=$n,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let o=r.value;return o===null||r.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),r}}),wo=f("$ZodAny",(e,t)=>{$.init(e,t),e._zod.parse=r=>r}),zo=f("$ZodUnknown",(e,t)=>{$.init(e,t),e._zod.parse=r=>r}),ko=f("$ZodNever",(e,t)=>{$.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)}),So=f("$ZodVoid",(e,t)=>{$.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;return typeof o>"u"||r.issues.push({expected:"void",code:"invalid_type",input:o,inst:e}),r}}),Po=f("$ZodDate",(e,t)=>{$.init(e,t),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=new Date(r.value)}catch{}let o=r.value,i=o instanceof Date;return i&&!Number.isNaN(o.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:o,...i?{received:"Invalid Date"}:{},inst:e}),r}});function Ic(e,t,r){e.issues.length&&t.issues.push(...K(r,e.issues)),t.value[r]=e.value}var Eo=f("$ZodArray",(e,t)=>{$.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=Array(o.length);let i=[];for(let s=0;s<o.length;s++){let c=o[s],a=t.element._zod.run({value:c,issues:[]},n);a instanceof Promise?i.push(a.then(u=>Ic(u,r,s))):Ic(a,r,s)}return i.length?Promise.all(i).then(()=>r):r}});function Dt(e,t,r,n,o){if(e.issues.length){if(o&&!(r in n))return;t.issues.push(...K(r,e.issues))}e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}function Bc(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);let r=Ir(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function Fc(e,t,r,n,o,i){let s=[],c=o.keySet,a=o.catchall._zod,u=a.def.type,p=a.optout==="optional";for(let d in t){if(c.has(d))continue;if(u==="never"){s.push(d);continue}let m=a.run({value:t[d],issues:[]},n);m instanceof Promise?e.push(m.then(h=>Dt(h,r,d,t,p))):Dt(m,r,d,t,p)}return s.length&&r.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then(()=>r):r}var Ft=f("$ZodObject",(e,t)=>{if($.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let c=t.shape;Object.defineProperty(t,"shape",{get:()=>{let a={...c};return Object.defineProperty(t,"shape",{value:a}),a}})}let n=Ce(()=>Bc(t));w(e._zod,"propValues",()=>{let c=t.shape,a={};for(let u in c){let p=c[u]._zod;if(p.values){a[u]??(a[u]=new Set);for(let d of p.values)a[u].add(d)}}return a});let o=ze,i=t.catchall,s;e._zod.parse=(c,a)=>{s??(s=n.value);let u=c.value;if(!o(u))return c.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),c;c.value={};let p=[],d=s.shape;for(let m of s.keys){let h=d[m],b=h._zod.optout==="optional",g=h._zod.run({value:u[m],issues:[]},a);g instanceof Promise?p.push(g.then(v=>Dt(v,c,m,u,b))):Dt(g,c,m,u,b)}return i?Fc(p,u,c,a,n.value,e):p.length?Promise.all(p).then(()=>c):c}}),vp=f("$ZodObjectJIT",(e,t)=>{Ft.init(e,t);let r=e._zod.parse,n=Ce(()=>Bc(t)),o=m=>{let h=new ot(["shape","payload","ctx"]),b=n.value,g=S=>{let N=kt(S);return`shape[${N}]._zod.run({ value: input[${N}], issues: [] }, ctx)`};h.write("const input = payload.value;");let v=Object.create(null),te=0;for(let S of b.keys)v[S]=`key_${te++}`;h.write("const newResult = {};");for(let S of b.keys){let N=v[S],j=kt(S),ae=m[S]?._zod?.optout==="optional";h.write(`const ${N} = ${g(S)};`),ae?h.write(`
|
|
5
|
-
if (${
|
|
4
|
+
`))}};var Wn={major:4,minor:3,patch:6};var v=f("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Wn;let n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(let o of n)for(let i of o._zod.onattach)i(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let o=(s,c,a)=>{let u=he(s),p;for(let d of c){if(d._zod.def.when){if(!d._zod.def.when(s))continue}else if(u)continue;let h=s.issues.length,m=d._zod.check(s);if(m instanceof Promise&&a?.async===!1)throw new ie;if(p||m instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await m,s.issues.length!==h&&(u||(u=he(s,h)))});else{if(s.issues.length===h)continue;u||(u=he(s,h))}}return p?p.then(()=>s):s},i=(s,c,a)=>{if(he(s))return s.aborted=!0,s;let u=o(c,n,a);if(u instanceof Promise){if(a.async===!1)throw new ie;return u.then(p=>e._zod.parse(p,a))}return e._zod.parse(u,a)};e._zod.run=(s,c)=>{if(c.skipChecks)return e._zod.parse(s,c);if(c.direction==="backward"){let u=e._zod.parse({value:s.value,issues:[]},{...c,skipChecks:!0});return u instanceof Promise?u.then(p=>i(p,s,c)):i(u,s,c)}let a=e._zod.parse(s,c);if(a instanceof Promise){if(c.async===!1)throw new ie;return a.then(u=>o(u,n,c))}return o(a,n,c)}}z(e,"~standard",()=>({validate:o=>{try{let i=Ee(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return Ie(e,o).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),De=f("$ZodString",(e,t)=>{v.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??kn(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),T=f("$ZodStringFormat",(e,t)=>{Me.init(e,t),De.init(e,t)}),Qn=f("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=fn),T.init(e,t)}),eo=f("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Ae(n))}else t.pattern??(t.pattern=Ae());T.init(e,t)}),to=f("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=dn),T.init(e,t)}),ro=f("$ZodURL",(e,t)=>{T.init(e,t),e._zod.check=r=>{try{let n=r.value.trim(),o=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=o.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),no=f("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=mn()),T.init(e,t)}),oo=f("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=ln),T.init(e,t)}),io=f("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=on),T.init(e,t)}),so=f("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=sn),T.init(e,t)}),co=f("$ZodULID",(e,t)=>{t.pattern??(t.pattern=cn),T.init(e,t)}),ao=f("$ZodXID",(e,t)=>{t.pattern??(t.pattern=an),T.init(e,t)}),uo=f("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=un),T.init(e,t)}),lo=f("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=zn(t)),T.init(e,t)}),po=f("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=vn),T.init(e,t)}),fo=f("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=wn(t)),T.init(e,t)}),mo=f("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=pn),T.init(e,t)}),ho=f("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=hn),T.init(e,t),e._zod.bag.format="ipv4"}),go=f("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=gn),T.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),_o=f("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=_n(t.delimiter)),T.init(e,t),e._zod.bag.format="mac"}),yo=f("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=yn),T.init(e,t)}),bo=f("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=bn),T.init(e,t),e._zod.check=r=>{let n=r.value.split("/");try{if(n.length!==2)throw new Error;let[o,i]=n;if(!i)throw new Error;let s=Number(i);if(`${s}`!==i)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${o}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function xo(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var $o=f("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=xn),T.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{xo(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function Xc(e){if(!jt.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return xo(r)}var vo=f("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=jt),T.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{Xc(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),wo=f("$ZodE164",(e,t)=>{t.pattern??(t.pattern=$n),T.init(e,t)});function Qc(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}var zo=f("$ZodJWT",(e,t)=>{T.init(e,t),e._zod.check=r=>{Qc(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),ko=f("$ZodCustomStringFormat",(e,t)=>{T.init(e,t),e._zod.check=r=>{t.fn(r.value)||r.issues.push({code:"invalid_format",format:t.format,input:r.value,inst:e,continue:!t.abort})}}),Kt=f("$ZodNumber",(e,t)=>{v.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ot,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),r}}),So=f("$ZodNumberFormat",(e,t)=>{Zn.init(e,t),Kt.init(e,t)}),it=f("$ZodBoolean",(e,t)=>{v.init(e,t),e._zod.pattern=En,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}}),qt=f("$ZodBigInt",(e,t)=>{v.init(e,t),e._zod.pattern=Sn,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch{}return typeof r.value=="bigint"||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}}),Po=f("$ZodBigIntFormat",(e,t)=>{Nn.init(e,t),qt.init(e,t)}),Eo=f("$ZodSymbol",(e,t)=>{v.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;return typeof o=="symbol"||r.issues.push({expected:"symbol",code:"invalid_type",input:o,inst:e}),r}}),Io=f("$ZodUndefined",(e,t)=>{v.init(e,t),e._zod.pattern=An,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(r,n)=>{let o=r.value;return typeof o>"u"||r.issues.push({expected:"undefined",code:"invalid_type",input:o,inst:e}),r}}),Ao=f("$ZodNull",(e,t)=>{v.init(e,t),e._zod.pattern=In,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let o=r.value;return o===null||r.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),r}}),To=f("$ZodAny",(e,t)=>{v.init(e,t),e._zod.parse=r=>r}),Ro=f("$ZodUnknown",(e,t)=>{v.init(e,t),e._zod.parse=r=>r}),Co=f("$ZodNever",(e,t)=>{v.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)}),Zo=f("$ZodVoid",(e,t)=>{v.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;return typeof o>"u"||r.issues.push({expected:"void",code:"invalid_type",input:o,inst:e}),r}}),No=f("$ZodDate",(e,t)=>{v.init(e,t),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=new Date(r.value)}catch{}let o=r.value,i=o instanceof Date;return i&&!Number.isNaN(o.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:o,...i?{received:"Invalid Date"}:{},inst:e}),r}});function Uc(e,t,r){e.issues.length&&t.issues.push(...V(r,e.issues)),t.value[r]=e.value}var jo=f("$ZodArray",(e,t)=>{v.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=Array(o.length);let i=[];for(let s=0;s<o.length;s++){let c=o[s],a=t.element._zod.run({value:c,issues:[]},n);a instanceof Promise?i.push(a.then(u=>Uc(u,r,s))):Uc(a,r,s)}return i.length?Promise.all(i).then(()=>r):r}});function Jt(e,t,r,n,o){if(e.issues.length){if(o&&!(r in n))return;t.issues.push(...V(r,e.issues))}e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}function ea(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);let r=Or(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function ta(e,t,r,n,o,i){let s=[],c=o.keySet,a=o.catchall._zod,u=a.def.type,p=a.optout==="optional";for(let d in t){if(c.has(d))continue;if(u==="never"){s.push(d);continue}let h=a.run({value:t[d],issues:[]},n);h instanceof Promise?e.push(h.then(m=>Jt(m,r,d,t,p))):Jt(h,r,d,t,p)}return s.length&&r.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then(()=>r):r}var Gt=f("$ZodObject",(e,t)=>{if(v.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let c=t.shape;Object.defineProperty(t,"shape",{get:()=>{let a={...c};return Object.defineProperty(t,"shape",{value:a}),a}})}let n=je(()=>ea(t));z(e._zod,"propValues",()=>{let c=t.shape,a={};for(let u in c){let p=c[u]._zod;if(p.values){a[u]??(a[u]=new Set);for(let d of p.values)a[u].add(d)}}return a});let o=Pe,i=t.catchall,s;e._zod.parse=(c,a)=>{s??(s=n.value);let u=c.value;if(!o(u))return c.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),c;c.value={};let p=[],d=s.shape;for(let h of s.keys){let m=d[h],_=m._zod.optout==="optional",y=m._zod.run({value:u[h],issues:[]},a);y instanceof Promise?p.push(y.then(S=>Jt(S,c,h,u,_))):Jt(y,c,h,u,_)}return i?ta(p,u,c,a,n.value,e):p.length?Promise.all(p).then(()=>c):c}}),jp=f("$ZodObjectJIT",(e,t)=>{Gt.init(e,t);let r=e._zod.parse,n=je(()=>ea(t)),o=h=>{let m=new ot(["shape","payload","ctx"]),_=n.value,y=N=>{let I=It(N);return`shape[${I}]._zod.run({ value: input[${I}], issues: [] }, ctx)`};m.write("const input = payload.value;");let S=Object.create(null),b=0;for(let N of _.keys)S[N]=`key_${b++}`;m.write("const newResult = {};");for(let N of _.keys){let I=S[N],j=It(N),ae=h[N]?._zod?.optout==="optional";m.write(`const ${I} = ${y(N)};`),ae?m.write(`
|
|
5
|
+
if (${I}.issues.length) {
|
|
6
6
|
if (${j} in input) {
|
|
7
|
-
payload.issues = payload.issues.concat(${
|
|
7
|
+
payload.issues = payload.issues.concat(${I}.issues.map(iss => ({
|
|
8
8
|
...iss,
|
|
9
9
|
path: iss.path ? [${j}, ...iss.path] : [${j}]
|
|
10
10
|
})));
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
if (${
|
|
14
|
+
if (${I}.value === undefined) {
|
|
15
15
|
if (${j} in input) {
|
|
16
16
|
newResult[${j}] = undefined;
|
|
17
17
|
}
|
|
18
18
|
} else {
|
|
19
|
-
newResult[${j}] = ${
|
|
19
|
+
newResult[${j}] = ${I}.value;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
`):
|
|
23
|
-
if (${
|
|
24
|
-
payload.issues = payload.issues.concat(${
|
|
22
|
+
`):m.write(`
|
|
23
|
+
if (${I}.issues.length) {
|
|
24
|
+
payload.issues = payload.issues.concat(${I}.issues.map(iss => ({
|
|
25
25
|
...iss,
|
|
26
26
|
path: iss.path ? [${j}, ...iss.path] : [${j}]
|
|
27
27
|
})));
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
if (${
|
|
30
|
+
if (${I}.value === undefined) {
|
|
31
31
|
if (${j} in input) {
|
|
32
32
|
newResult[${j}] = undefined;
|
|
33
33
|
}
|
|
34
34
|
} else {
|
|
35
|
-
newResult[${j}] = ${
|
|
35
|
+
newResult[${j}] = ${I}.value;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
`)}h.write("payload.value = newResult;"),h.write("return payload;");let Z=h.compile();return(S,N)=>Z(m,S,N)},i,s=ze,c=!Ke.jitless,u=c&&Pr.value,p=t.catchall,d;e._zod.parse=(m,h)=>{d??(d=n.value);let b=m.value;return s(b)?c&&u&&h?.async===!1&&h.jitless!==!0?(i||(i=o(t.shape)),m=i(m,h),p?Fc([],b,m,h,d,e):m):r(m,h):(m.issues.push({expected:"object",code:"invalid_type",input:b,inst:e}),m)}});function Tc(e,t,r,n){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let o=e.filter(i=>!fe(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(s=>q(s,n,L())))}),t)}var st=f("$ZodUnion",(e,t)=>{$.init(e,t),w(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),w(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),w(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),w(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){let o=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>Xe(i.source)).join("|")})$`)}});let r=t.options.length===1,n=t.options[0]._zod.run;e._zod.parse=(o,i)=>{if(r)return n(o,i);let s=!1,c=[];for(let a of t.options){let u=a._zod.run({value:o.value,issues:[]},i);if(u instanceof Promise)c.push(u),s=!0;else{if(u.issues.length===0)return u;c.push(u)}}return s?Promise.all(c).then(a=>Tc(a,o,e,i)):Tc(c,o,e,i)}});function Ac(e,t,r,n){let o=e.filter(i=>i.issues.length===0);return o.length===1?(t.value=o[0].value,t):(o.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(s=>q(s,n,L())))}):t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:[],inclusive:!1}),t)}var Io=f("$ZodXor",(e,t)=>{st.init(e,t),t.inclusive=!1;let r=t.options.length===1,n=t.options[0]._zod.run;e._zod.parse=(o,i)=>{if(r)return n(o,i);let s=!1,c=[];for(let a of t.options){let u=a._zod.run({value:o.value,issues:[]},i);u instanceof Promise?(c.push(u),s=!0):c.push(u)}return s?Promise.all(c).then(a=>Ac(a,o,e,i)):Ac(c,o,e,i)}}),To=f("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,st.init(e,t);let r=e._zod.parse;w(e._zod,"propValues",()=>{let o={};for(let i of t.options){let s=i._zod.propValues;if(!s||Object.keys(s).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(let[c,a]of Object.entries(s)){o[c]||(o[c]=new Set);for(let u of a)o[c].add(u)}}return o});let n=Ce(()=>{let o=t.options,i=new Map;for(let s of o){let c=s._zod.propValues?.[t.discriminator];if(!c||c.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let a of c){if(i.has(a))throw new Error(`Duplicate discriminator value "${String(a)}"`);i.set(a,s)}}return i});e._zod.parse=(o,i)=>{let s=o.value;if(!ze(s))return o.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),o;let c=n.value.get(s?.[t.discriminator]);return c?c._zod.run(o,i):t.unionFallback?r(o,i):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:s,path:[t.discriminator],inst:e}),o)}}),Ao=f("$ZodIntersection",(e,t)=>{$.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,i=t.left._zod.run({value:o,issues:[]},n),s=t.right._zod.run({value:o,issues:[]},n);return i instanceof Promise||s instanceof Promise?Promise.all([i,s]).then(([a,u])=>Rc(r,a,u)):Rc(r,i,s)}});function Jn(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(pe(e)&&pe(t)){let r=Object.keys(t),n=Object.keys(e).filter(i=>r.indexOf(i)!==-1),o={...e,...t};for(let i of n){let s=Jn(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let o=e[n],i=t[n],s=Jn(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[n,...s.mergeErrorPath]};r.push(s.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Rc(e,t,r){let n=new Map,o;for(let c of t.issues)if(c.code==="unrecognized_keys"){o??(o=c);for(let a of c.keys)n.has(a)||n.set(a,{}),n.get(a).l=!0}else e.issues.push(c);for(let c of r.issues)if(c.code==="unrecognized_keys")for(let a of c.keys)n.has(a)||n.set(a,{}),n.get(a).r=!0;else e.issues.push(c);let i=[...n].filter(([,c])=>c.l&&c.r).map(([c])=>c);if(i.length&&o&&e.issues.push({...o,keys:i}),fe(e))return e;let s=Jn(t.value,r.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}var Jt=f("$ZodTuple",(e,t)=>{$.init(e,t);let r=t.items;e._zod.parse=(n,o)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({input:i,inst:e,expected:"tuple",code:"invalid_type"}),n;n.value=[];let s=[],c=[...r].reverse().findIndex(p=>p._zod.optin!=="optional"),a=c===-1?0:r.length-c;if(!t.rest){let p=i.length>r.length,d=i.length<a-1;if(p||d)return n.issues.push({...p?{code:"too_big",maximum:r.length,inclusive:!0}:{code:"too_small",minimum:r.length},input:i,inst:e,origin:"array"}),n}let u=-1;for(let p of r){if(u++,u>=i.length&&u>=a)continue;let d=p._zod.run({value:i[u],issues:[]},o);d instanceof Promise?s.push(d.then(m=>jt(m,n,u))):jt(d,n,u)}if(t.rest){let p=i.slice(r.length);for(let d of p){u++;let m=t.rest._zod.run({value:d,issues:[]},o);m instanceof Promise?s.push(m.then(h=>jt(h,n,u))):jt(m,n,u)}}return s.length?Promise.all(s).then(()=>n):n}});function jt(e,t,r){e.issues.length&&t.issues.push(...K(r,e.issues)),t.value[r]=e.value}var Ro=f("$ZodRecord",(e,t)=>{$.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!pe(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),r;let i=[],s=t.keyType._zod.values;if(s){r.value={};let c=new Set;for(let u of s)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){c.add(typeof u=="number"?u.toString():u);let p=t.valueType._zod.run({value:o[u],issues:[]},n);p instanceof Promise?i.push(p.then(d=>{d.issues.length&&r.issues.push(...K(u,d.issues)),r.value[u]=d.value})):(p.issues.length&&r.issues.push(...K(u,p.issues)),r.value[u]=p.value)}let a;for(let u in o)c.has(u)||(a=a??[],a.push(u));a&&a.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:a})}else{r.value={};for(let c of Reflect.ownKeys(o)){if(c==="__proto__")continue;let a=t.keyType._zod.run({value:c,issues:[]},n);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof c=="string"&&Zt.test(c)&&a.issues.length){let d=t.keyType._zod.run({value:Number(c),issues:[]},n);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");d.issues.length===0&&(a=d)}if(a.issues.length){t.mode==="loose"?r.value[c]=o[c]:r.issues.push({code:"invalid_key",origin:"record",issues:a.issues.map(d=>q(d,n,L())),input:c,path:[c],inst:e});continue}let p=t.valueType._zod.run({value:o[c],issues:[]},n);p instanceof Promise?i.push(p.then(d=>{d.issues.length&&r.issues.push(...K(c,d.issues)),r.value[a.value]=d.value})):(p.issues.length&&r.issues.push(...K(c,p.issues)),r.value[a.value]=p.value)}}return i.length?Promise.all(i).then(()=>r):r}}),Zo=f("$ZodMap",(e,t)=>{$.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!(o instanceof Map))return r.issues.push({expected:"map",code:"invalid_type",input:o,inst:e}),r;let i=[];r.value=new Map;for(let[s,c]of o){let a=t.keyType._zod.run({value:s,issues:[]},n),u=t.valueType._zod.run({value:c,issues:[]},n);a instanceof Promise||u instanceof Promise?i.push(Promise.all([a,u]).then(([p,d])=>{Zc(p,d,r,s,o,e,n)})):Zc(a,u,r,s,o,e,n)}return i.length?Promise.all(i).then(()=>r):r}});function Zc(e,t,r,n,o,i,s){e.issues.length&&(Qe.has(typeof n)?r.issues.push(...K(n,e.issues)):r.issues.push({code:"invalid_key",origin:"map",input:o,inst:i,issues:e.issues.map(c=>q(c,s,L()))})),t.issues.length&&(Qe.has(typeof n)?r.issues.push(...K(n,t.issues)):r.issues.push({origin:"map",code:"invalid_element",input:o,inst:i,key:n,issues:t.issues.map(c=>q(c,s,L()))})),r.value.set(e.value,t.value)}var Co=f("$ZodSet",(e,t)=>{$.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!(o instanceof Set))return r.issues.push({input:o,inst:e,expected:"set",code:"invalid_type"}),r;let i=[];r.value=new Set;for(let s of o){let c=t.valueType._zod.run({value:s,issues:[]},n);c instanceof Promise?i.push(c.then(a=>Cc(a,r))):Cc(c,r)}return i.length?Promise.all(i).then(()=>r):r}});function Cc(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}var No=f("$ZodEnum",(e,t)=>{$.init(e,t);let r=We(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(o=>Qe.has(typeof o)).map(o=>typeof o=="string"?W(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{let s=o.value;return n.has(s)||o.issues.push({code:"invalid_value",values:r,input:s,inst:e}),o}}),jo=f("$ZodLiteral",(e,t)=>{if($.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");let r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?W(n):n?W(n.toString()):String(n)).join("|")})$`),e._zod.parse=(n,o)=>{let i=n.value;return r.has(i)||n.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),n}}),Oo=f("$ZodFile",(e,t)=>{$.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;return o instanceof File||r.issues.push({expected:"file",code:"invalid_type",input:o,inst:e}),r}}),Lo=f("$ZodTransform",(e,t)=>{$.init(e,t),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Ze(e.constructor.name);let o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(s=>(r.value=s,r));if(o instanceof Promise)throw new ne;return r.value=o,r}});function Nc(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var qt=f("$ZodOptional",(e,t)=>{$.init(e,t),e._zod.optin="optional",e._zod.optout="optional",w(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),w(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Xe(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>Nc(i,r.value)):Nc(o,r.value)}return r.value===void 0?r:t.innerType._zod.run(r,n)}}),Mo=f("$ZodExactOptional",(e,t)=>{qt.init(e,t),w(e._zod,"values",()=>t.innerType._zod.values),w(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Do=f("$ZodNullable",(e,t)=>{$.init(e,t),w(e._zod,"optin",()=>t.innerType._zod.optin),w(e._zod,"optout",()=>t.innerType._zod.optout),w(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Xe(r.source)}|null)$`):void 0}),w(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),Uo=f("$ZodDefault",(e,t)=>{$.init(e,t),e._zod.optin="optional",w(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>jc(i,t)):jc(o,t)}});function jc(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Bo=f("$ZodPrefault",(e,t)=>{$.init(e,t),e._zod.optin="optional",w(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),Fo=f("$ZodNonOptional",(e,t)=>{$.init(e,t),w(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>Oc(i,e)):Oc(o,e)}});function Oc(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var Jo=f("$ZodSuccess",(e,t)=>{$.init(e,t),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Ze("ZodSuccess");let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>(r.value=i.issues.length===0,r)):(r.value=o.issues.length===0,r)}}),qo=f("$ZodCatch",(e,t)=>{$.init(e,t),w(e._zod,"optin",()=>t.innerType._zod.optin),w(e._zod,"optout",()=>t.innerType._zod.optout),w(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>(r.value=i.value,i.issues.length&&(r.value=t.catchValue({...r,error:{issues:i.issues.map(s=>q(s,n,L()))},input:r.value}),r.issues=[]),r)):(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(i=>q(i,n,L()))},input:r.value}),r.issues=[]),r)}}),Go=f("$ZodNaN",(e,t)=>{$.init(e,t),e._zod.parse=(r,n)=>((typeof r.value!="number"||!Number.isNaN(r.value))&&r.issues.push({input:r.value,inst:e,expected:"nan",code:"invalid_type"}),r)}),Yo=f("$ZodPipe",(e,t)=>{$.init(e,t),w(e._zod,"values",()=>t.in._zod.values),w(e._zod,"optin",()=>t.in._zod.optin),w(e._zod,"optout",()=>t.out._zod.optout),w(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let i=t.out._zod.run(r,n);return i instanceof Promise?i.then(s=>Ot(s,t.in,n)):Ot(i,t.in,n)}let o=t.in._zod.run(r,n);return o instanceof Promise?o.then(i=>Ot(i,t.out,n)):Ot(o,t.out,n)}});function Ot(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}var ct=f("$ZodCodec",(e,t)=>{$.init(e,t),w(e._zod,"values",()=>t.in._zod.values),w(e._zod,"optin",()=>t.in._zod.optin),w(e._zod,"optout",()=>t.out._zod.optout),w(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if((n.direction||"forward")==="forward"){let i=t.in._zod.run(r,n);return i instanceof Promise?i.then(s=>Lt(s,t,n)):Lt(i,t,n)}else{let i=t.out._zod.run(r,n);return i instanceof Promise?i.then(s=>Lt(s,t,n)):Lt(i,t,n)}}});function Lt(e,t,r){if(e.issues.length)return e.aborted=!0,e;if((r.direction||"forward")==="forward"){let o=t.transform(e.value,e);return o instanceof Promise?o.then(i=>Mt(e,i,t.out,r)):Mt(e,o,t.out,r)}else{let o=t.reverseTransform(e.value,e);return o instanceof Promise?o.then(i=>Mt(e,i,t.in,r)):Mt(e,o,t.in,r)}}function Mt(e,t,r,n){return e.issues.length?(e.aborted=!0,e):r._zod.run({value:t,issues:e.issues},n)}var Ho=f("$ZodReadonly",(e,t)=>{$.init(e,t),w(e._zod,"propValues",()=>t.innerType._zod.propValues),w(e._zod,"values",()=>t.innerType._zod.values),w(e._zod,"optin",()=>t.innerType?._zod?.optin),w(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(Lc):Lc(o)}});function Lc(e){return e.value=Object.freeze(e.value),e}var Ko=f("$ZodTemplateLiteral",(e,t)=>{$.init(e,t);let r=[];for(let n of t.parts)if(typeof n=="object"&&n!==null){if(!n._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...n._zod.traits].shift()}`);let o=n._zod.pattern instanceof RegExp?n._zod.pattern.source:n._zod.pattern;if(!o)throw new Error(`Invalid template literal part: ${n._zod.traits}`);let i=o.startsWith("^")?1:0,s=o.endsWith("$")?o.length-1:o.length;r.push(o.slice(i,s))}else if(n===null||Er.has(typeof n))r.push(W(`${n}`));else throw new Error(`Invalid template literal part: ${n}`);e._zod.pattern=new RegExp(`^${r.join("")}$`),e._zod.parse=(n,o)=>typeof n.value!="string"?(n.issues.push({input:n.value,inst:e,expected:"string",code:"invalid_type"}),n):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(n.value)||n.issues.push({input:n.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),n)}),Vo=f("$ZodFunction",(e,t)=>($.init(e,t),e._def=t,e._zod.def=t,e.implement=r=>{if(typeof r!="function")throw new Error("implement() must be called with a function");return function(...n){let o=e._def.input?de(e._def.input,n):n,i=Reflect.apply(r,this,o);return e._def.output?de(e._def.output,i):i}},e.implementAsync=r=>{if(typeof r!="function")throw new Error("implementAsync() must be called with a function");return async function(...n){let o=e._def.input?await me(e._def.input,n):n,i=await Reflect.apply(r,this,o);return e._def.output?await me(e._def.output,i):i}},e._zod.parse=(r,n)=>typeof r.value!="function"?(r.issues.push({code:"invalid_type",expected:"function",input:r.value,inst:e}),r):(e._def.output&&e._def.output._zod.def.type==="promise"?r.value=e.implementAsync(r.value):r.value=e.implement(r.value),r),e.input=(...r)=>{let n=e.constructor;return Array.isArray(r[0])?new n({type:"function",input:new Jt({type:"tuple",items:r[0],rest:r[1]}),output:e._def.output}):new n({type:"function",input:r[0],output:e._def.output})},e.output=r=>{let n=e.constructor;return new n({type:"function",input:e._def.input,output:r})},e)),Wo=f("$ZodPromise",(e,t)=>{$.init(e,t),e._zod.parse=(r,n)=>Promise.resolve(r.value).then(o=>t.innerType._zod.run({value:o,issues:[]},n))}),Xo=f("$ZodLazy",(e,t)=>{$.init(e,t),w(e._zod,"innerType",()=>t.getter()),w(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),w(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),w(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),w(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(r,n)=>e._zod.innerType._zod.run(r,n)}),Qo=f("$ZodCustom",(e,t)=>{T.init(e,t),$.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(i=>Mc(i,r,n,e));Mc(o,r,n,e)}});function Mc(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(je(o))}}var at={};we(at,{default:()=>zp});var zp={};var Jc,ei=Symbol("ZodOutput"),ti=Symbol("ZodInput"),Gt=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let o={...n,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function Yt(){return new Gt}(Jc=globalThis).__zod_globalRegistry??(Jc.__zod_globalRegistry=Yt());var se=globalThis.__zod_globalRegistry;function ri(e,t){return new e({type:"string",..._(t)})}function ni(e,t){return new e({type:"string",coerce:!0,..._(t)})}function oi(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,..._(t)})}function ii(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,..._(t)})}function si(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,..._(t)})}function ci(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",..._(t)})}function ai(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",..._(t)})}function ui(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",..._(t)})}function Ht(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,..._(t)})}function li(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,..._(t)})}function pi(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,..._(t)})}function fi(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,..._(t)})}function di(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,..._(t)})}function mi(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,..._(t)})}function hi(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,..._(t)})}function gi(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,..._(t)})}function _i(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,..._(t)})}function bi(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,..._(t)})}function yi(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,..._(t)})}function xi(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,..._(t)})}function $i(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,..._(t)})}function vi(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,..._(t)})}function wi(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,..._(t)})}function zi(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,..._(t)})}function ki(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,..._(t)})}var Si={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function Pi(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,..._(t)})}function Ei(e,t){return new e({type:"string",format:"date",check:"string_format",..._(t)})}function Ii(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,..._(t)})}function Ti(e,t){return new e({type:"string",format:"duration",check:"string_format",..._(t)})}function Ai(e,t){return new e({type:"number",checks:[],..._(t)})}function Ri(e,t){return new e({type:"number",coerce:!0,checks:[],..._(t)})}function Zi(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",..._(t)})}function Ci(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",..._(t)})}function Ni(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",..._(t)})}function ji(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",..._(t)})}function Oi(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",..._(t)})}function Li(e,t){return new e({type:"boolean",..._(t)})}function Mi(e,t){return new e({type:"boolean",coerce:!0,..._(t)})}function Di(e,t){return new e({type:"bigint",..._(t)})}function Ui(e,t){return new e({type:"bigint",coerce:!0,..._(t)})}function Bi(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",..._(t)})}function Fi(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",..._(t)})}function Ji(e,t){return new e({type:"symbol",..._(t)})}function qi(e,t){return new e({type:"undefined",..._(t)})}function Gi(e,t){return new e({type:"null",..._(t)})}function Yi(e){return new e({type:"any"})}function Hi(e){return new e({type:"unknown"})}function Ki(e,t){return new e({type:"never",..._(t)})}function Vi(e,t){return new e({type:"void",..._(t)})}function Wi(e,t){return new e({type:"date",..._(t)})}function Xi(e,t){return new e({type:"date",coerce:!0,..._(t)})}function Qi(e,t){return new e({type:"nan",..._(t)})}function Kt(e,t){return new Ct({check:"less_than",..._(t),value:e,inclusive:!1})}function ut(e,t){return new Ct({check:"less_than",..._(t),value:e,inclusive:!0})}function Vt(e,t){return new Nt({check:"greater_than",..._(t),value:e,inclusive:!1})}function lt(e,t){return new Nt({check:"greater_than",..._(t),value:e,inclusive:!0})}function es(e){return Vt(0,e)}function ts(e){return Kt(0,e)}function rs(e){return ut(0,e)}function ns(e){return lt(0,e)}function os(e,t){return new kn({check:"multiple_of",..._(t),value:e})}function is(e,t){return new En({check:"max_size",..._(t),maximum:e})}function ss(e,t){return new In({check:"min_size",..._(t),minimum:e})}function cs(e,t){return new Tn({check:"size_equals",..._(t),size:e})}function as(e,t){return new An({check:"max_length",..._(t),maximum:e})}function pt(e,t){return new Rn({check:"min_length",..._(t),minimum:e})}function us(e,t){return new Zn({check:"length_equals",..._(t),length:e})}function ft(e,t){return new Cn({check:"string_format",format:"regex",..._(t),pattern:e})}function ls(e){return new Nn({check:"string_format",format:"lowercase",..._(e)})}function ps(e){return new jn({check:"string_format",format:"uppercase",..._(e)})}function fs(e,t){return new On({check:"string_format",format:"includes",..._(t),includes:e})}function ds(e,t){return new Ln({check:"string_format",format:"starts_with",..._(t),prefix:e})}function ms(e,t){return new Mn({check:"string_format",format:"ends_with",..._(t),suffix:e})}function hs(e,t,r){return new Dn({check:"property",property:e,schema:t,..._(r)})}function gs(e,t){return new Un({check:"mime_type",mime:e,..._(t)})}function he(e){return new Bn({check:"overwrite",tx:e})}function _s(e){return he(t=>t.normalize(e))}function bs(){return he(e=>e.trim())}function ys(){return he(e=>e.toLowerCase())}function xs(){return he(e=>e.toUpperCase())}function Sp(){return he(e=>Sr(e))}function Pp(e,t,r){return new e({type:"array",element:t,..._(r)})}function Ep(e,t,r){return new e({type:"union",options:t,..._(r)})}function Ip(e,t,r){return new e({type:"union",options:t,inclusive:!1,..._(r)})}function Tp(e,t,r,n){return new e({type:"union",options:r,discriminator:t,..._(n)})}function Ap(e,t,r){return new e({type:"intersection",left:t,right:r})}function Rp(e,t,r,n){let o=r instanceof $,i=o?n:r,s=o?r:null;return new e({type:"tuple",items:t,rest:s,..._(i)})}function Zp(e,t,r,n){return new e({type:"record",keyType:t,valueType:r,..._(n)})}function Cp(e,t,r,n){return new e({type:"map",keyType:t,valueType:r,..._(n)})}function Np(e,t,r){return new e({type:"set",valueType:t,..._(r)})}function jp(e,t,r){let n=Array.isArray(t)?Object.fromEntries(t.map(o=>[o,o])):t;return new e({type:"enum",entries:n,..._(r)})}function Op(e,t,r){return new e({type:"enum",entries:t,..._(r)})}function Lp(e,t,r){return new e({type:"literal",values:Array.isArray(t)?t:[t],..._(r)})}function $s(e,t){return new e({type:"file",..._(t)})}function Mp(e,t){return new e({type:"transform",transform:t})}function Dp(e,t){return new e({type:"optional",innerType:t})}function Up(e,t){return new e({type:"nullable",innerType:t})}function Bp(e,t,r){return new e({type:"default",innerType:t,get defaultValue(){return typeof r=="function"?r():Ne(r)}})}function Fp(e,t,r){return new e({type:"nonoptional",innerType:t,..._(r)})}function Jp(e,t){return new e({type:"success",innerType:t})}function qp(e,t,r){return new e({type:"catch",innerType:t,catchValue:typeof r=="function"?r:()=>r})}function Gp(e,t,r){return new e({type:"pipe",in:t,out:r})}function Yp(e,t){return new e({type:"readonly",innerType:t})}function Hp(e,t,r){return new e({type:"template_literal",parts:t,..._(r)})}function Kp(e,t){return new e({type:"lazy",getter:t})}function Vp(e,t){return new e({type:"promise",innerType:t})}function vs(e,t,r){let n=_(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function ws(e,t,r){return new e({type:"custom",check:"custom",fn:t,..._(r)})}function zs(e){let t=qc(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(je(n,r.value,t._zod.def));else{let o=n;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),r.issues.push(je(o))}},e(r.value,r)));return t}function qc(e,t){let r=new T({check:"custom",..._(t)});return r._zod.check=e,r}function ks(e){let t=new T({check:"describe"});return t._zod.onattach=[r=>{let n=se.get(r)??{};se.add(r,{...n,description:e})}],t._zod.check=()=>{},t}function Ss(e){let t=new T({check:"meta"});return t._zod.onattach=[r=>{let n=se.get(r)??{};se.add(r,{...n,...e})}],t._zod.check=()=>{},t}function Ps(e,t){let r=_(t),n=r.truthy??["true","1","yes","on","y","enabled"],o=r.falsy??["false","0","no","off","n","disabled"];r.case!=="sensitive"&&(n=n.map(h=>typeof h=="string"?h.toLowerCase():h),o=o.map(h=>typeof h=="string"?h.toLowerCase():h));let i=new Set(n),s=new Set(o),c=e.Codec??ct,a=e.Boolean??it,u=e.String??Le,p=new u({type:"string",error:r.error}),d=new a({type:"boolean",error:r.error}),m=new c({type:"pipe",in:p,out:d,transform:((h,b)=>{let g=h;return r.case!=="sensitive"&&(g=g.toLowerCase()),i.has(g)?!0:s.has(g)?!1:(b.issues.push({code:"invalid_value",expected:"stringbool",values:[...i,...s],input:b.value,inst:m,continue:!1}),{})}),reverseTransform:((h,b)=>h===!0?n[0]||"true":o[0]||"false"),error:r.error});return m}function Me(e,t,r,n={}){let o=_(n),i={..._(n),check:"string_format",type:"string",format:t,fn:typeof r=="function"?r:c=>r.test(c),...o};return r instanceof RegExp&&(i.pattern=r),new e(i)}function ge(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??se,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function P(e,t,r={path:[],schemaPath:[]}){var n;let o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;let s={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,s);let c=e._zod.toJSONSchema?.();if(c)s.schema=c;else{let p={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,p);else{let m=s.schema,h=t.processors[o.type];if(!h)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);h(e,t,m,p)}let d=e._zod.parent;d&&(s.ref||(s.ref=d),P(d,t,p),t.seen.get(d).isParent=!0)}let a=t.metadataRegistry.get(e);return a&&Object.assign(s.schema,a),t.io==="input"&&D(e)&&(delete s.schema.examples,delete s.schema.default),t.io==="input"&&s.schema._prefault&&((n=s.schema).default??(n.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function _e(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=new Map;for(let s of e.seen.entries()){let c=e.metadataRegistry.get(s[0])?.id;if(c){let a=n.get(c);if(a&&a!==s[0])throw new Error(`Duplicate schema id "${c}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(c,s[0])}}let o=s=>{let c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(s[0])?.id,m=e.external.uri??(b=>b);if(d)return{ref:m(d)};let h=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=h,{defId:h,ref:`${m("__shared")}#/${c}/${h}`}}if(s[1]===r)return{ref:"#"};let u=`#/${c}/`,p=s[1].schema.id??`__schema${e.counter++}`;return{defId:p,ref:u+p}},i=s=>{if(s[1].schema.$ref)return;let c=s[1],{ref:a,defId:u}=o(s);c.def={...c.schema},u&&(c.defId=u);let p=c.schema;for(let d in p)delete p[d];p.$ref=a};if(e.cycles==="throw")for(let s of e.seen.entries()){let c=s[1];if(c.cycle)throw new Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
|
|
39
|
-
|
|
40
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let c=s[1];if(t===s[0]){i(s);continue}if(e.external){let u=e.external.registry.get(s[0])?.id;if(t!==s[0]&&u){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(c.cycle){i(s);continue}if(c.count>1&&e.reused==="ref"){i(s);continue}}}function be(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=s=>{let c=e.seen.get(s);if(c.ref===null)return;let a=c.def??c.schema,u={...a},p=c.ref;if(c.ref=null,p){n(p);let m=e.seen.get(p),h=m.schema;if(h.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(a.allOf=a.allOf??[],a.allOf.push(h)):Object.assign(a,h),Object.assign(a,u),s._zod.parent===p)for(let g in a)g==="$ref"||g==="allOf"||g in u||delete a[g];if(h.$ref&&m.def)for(let g in a)g==="$ref"||g==="allOf"||g in m.def&&JSON.stringify(a[g])===JSON.stringify(m.def[g])&&delete a[g]}let d=s._zod.parent;if(d&&d!==p){n(d);let m=e.seen.get(d);if(m?.schema.$ref&&(a.$ref=m.schema.$ref,m.def))for(let h in a)h==="$ref"||h==="allOf"||h in m.def&&JSON.stringify(a[h])===JSON.stringify(m.def[h])&&delete a[h]}e.override({zodSchema:s,jsonSchema:a,path:c.path??[]})};for(let s of[...e.seen.entries()].reverse())n(s[0]);let o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let s=e.external.registry.get(t)?.id;if(!s)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(s)}Object.assign(o,r.def??r.schema);let i=e.external?.defs??{};for(let s of e.seen.entries()){let c=s[1];c.def&&c.defId&&(i[c.defId]=c.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{let s=JSON.parse(JSON.stringify(o));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:Es(t,"input",e.processors),output:Es(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function D(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return D(n.element,r);if(n.type==="set")return D(n.valueType,r);if(n.type==="lazy")return D(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return D(n.innerType,r);if(n.type==="intersection")return D(n.left,r)||D(n.right,r);if(n.type==="record"||n.type==="map")return D(n.keyType,r)||D(n.valueType,r);if(n.type==="pipe")return D(n.in,r)||D(n.out,r);if(n.type==="object"){for(let o in n.shape)if(D(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(D(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(D(o,r))return!0;return!!(n.rest&&D(n.rest,r))}return!1}var Wp=(e,t={})=>r=>{let n=ge({...r,processors:t});return P(e,n),_e(n,e),be(n,e)},Es=(e,t,r={})=>n=>{let{libraryOptions:o,target:i}=n??{},s=ge({...o??{},target:i,io:t,processors:r});return P(e,s),_e(s,e),be(s,e)};var Xp={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Qp=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:i,maximum:s,format:c,patterns:a,contentEncoding:u}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof s=="number"&&(o.maxLength=s),c&&(o.format=Xp[c]??c,o.format===""&&delete o.format,c==="time"&&delete o.format),u&&(o.contentEncoding=u),a&&a.size>0){let p=[...a];p.length===1?o.pattern=p[0].source:p.length>1&&(o.allOf=[...p.map(d=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},ef=(e,t,r,n)=>{let o=r,{minimum:i,maximum:s,format:c,multipleOf:a,exclusiveMaximum:u,exclusiveMinimum:p}=e._zod.bag;typeof c=="string"&&c.includes("int")?o.type="integer":o.type="number",typeof p=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.minimum=p,o.exclusiveMinimum=!0):o.exclusiveMinimum=p),typeof i=="number"&&(o.minimum=i,typeof p=="number"&&t.target!=="draft-04"&&(p>=i?delete o.minimum:delete o.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.maximum=u,o.exclusiveMaximum=!0):o.exclusiveMaximum=u),typeof s=="number"&&(o.maximum=s,typeof u=="number"&&t.target!=="draft-04"&&(u<=s?delete o.maximum:delete o.exclusiveMaximum)),typeof a=="number"&&(o.multipleOf=a)},tf=(e,t,r,n)=>{r.type="boolean"},rf=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},nf=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},of=(e,t,r,n)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},sf=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},cf=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},af=(e,t,r,n)=>{r.not={}},uf=(e,t,r,n)=>{},lf=(e,t,r,n)=>{},pf=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},ff=(e,t,r,n)=>{let o=e._zod.def,i=We(o.entries);i.every(s=>typeof s=="number")&&(r.type="number"),i.every(s=>typeof s=="string")&&(r.type="string"),r.enum=i},df=(e,t,r,n)=>{let o=e._zod.def,i=[];for(let s of o.values)if(s===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof s=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(s))}else i.push(s);if(i.length!==0)if(i.length===1){let s=i[0];r.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[s]:r.const=s}else i.every(s=>typeof s=="number")&&(r.type="number"),i.every(s=>typeof s=="string")&&(r.type="string"),i.every(s=>typeof s=="boolean")&&(r.type="boolean"),i.every(s=>s===null)&&(r.type="null"),r.enum=i},mf=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},hf=(e,t,r,n)=>{let o=r,i=e._zod.pattern;if(!i)throw new Error("Pattern not found in template literal");o.type="string",o.pattern=i.source},gf=(e,t,r,n)=>{let o=r,i={type:"string",format:"binary",contentEncoding:"binary"},{minimum:s,maximum:c,mime:a}=e._zod.bag;s!==void 0&&(i.minLength=s),c!==void 0&&(i.maxLength=c),a?a.length===1?(i.contentMediaType=a[0],Object.assign(o,i)):(Object.assign(o,i),o.anyOf=a.map(u=>({contentMediaType:u}))):Object.assign(o,i)},_f=(e,t,r,n)=>{r.type="boolean"},bf=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},yf=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},xf=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},$f=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},vf=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},wf=(e,t,r,n)=>{let o=r,i=e._zod.def,{minimum:s,maximum:c}=e._zod.bag;typeof s=="number"&&(o.minItems=s),typeof c=="number"&&(o.maxItems=c),o.type="array",o.items=P(i.element,t,{...n,path:[...n.path,"items"]})},zf=(e,t,r,n)=>{let o=r,i=e._zod.def;o.type="object",o.properties={};let s=i.shape;for(let u in s)o.properties[u]=P(s[u],t,{...n,path:[...n.path,"properties",u]});let c=new Set(Object.keys(s)),a=new Set([...c].filter(u=>{let p=i.shape[u]._zod;return t.io==="input"?p.optin===void 0:p.optout===void 0}));a.size>0&&(o.required=Array.from(a)),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=P(i.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},kf=(e,t,r,n)=>{let o=e._zod.def,i=o.inclusive===!1,s=o.options.map((c,a)=>P(c,t,{...n,path:[...n.path,i?"oneOf":"anyOf",a]}));i?r.oneOf=s:r.anyOf=s},Sf=(e,t,r,n)=>{let o=e._zod.def,i=P(o.left,t,{...n,path:[...n.path,"allOf",0]}),s=P(o.right,t,{...n,path:[...n.path,"allOf",1]}),c=u=>"allOf"in u&&Object.keys(u).length===1,a=[...c(i)?i.allOf:[i],...c(s)?s.allOf:[s]];r.allOf=a},Pf=(e,t,r,n)=>{let o=r,i=e._zod.def;o.type="array";let s=t.target==="draft-2020-12"?"prefixItems":"items",c=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",a=i.items.map((m,h)=>P(m,t,{...n,path:[...n.path,s,h]})),u=i.rest?P(i.rest,t,{...n,path:[...n.path,c,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;t.target==="draft-2020-12"?(o.prefixItems=a,u&&(o.items=u)):t.target==="openapi-3.0"?(o.items={anyOf:a},u&&o.items.anyOf.push(u),o.minItems=a.length,u||(o.maxItems=a.length)):(o.items=a,u&&(o.additionalItems=u));let{minimum:p,maximum:d}=e._zod.bag;typeof p=="number"&&(o.minItems=p),typeof d=="number"&&(o.maxItems=d)},Ef=(e,t,r,n)=>{let o=r,i=e._zod.def;o.type="object";let s=i.keyType,a=s._zod.bag?.patterns;if(i.mode==="loose"&&a&&a.size>0){let p=P(i.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let d of a)o.patternProperties[d.source]=p}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(o.propertyNames=P(i.keyType,t,{...n,path:[...n.path,"propertyNames"]})),o.additionalProperties=P(i.valueType,t,{...n,path:[...n.path,"additionalProperties"]});let u=s._zod.values;if(u){let p=[...u].filter(d=>typeof d=="string"||typeof d=="number");p.length>0&&(o.required=p)}},If=(e,t,r,n)=>{let o=e._zod.def,i=P(o.innerType,t,n),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=o.innerType,r.nullable=!0):r.anyOf=[i,{type:"null"}]},Tf=(e,t,r,n)=>{let o=e._zod.def;P(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType},Af=(e,t,r,n)=>{let o=e._zod.def;P(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType,r.default=JSON.parse(JSON.stringify(o.defaultValue))},Rf=(e,t,r,n)=>{let o=e._zod.def;P(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},Zf=(e,t,r,n)=>{let o=e._zod.def;P(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=s},Cf=(e,t,r,n)=>{let o=e._zod.def,i=t.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;P(i,t,n);let s=t.seen.get(e);s.ref=i},Nf=(e,t,r,n)=>{let o=e._zod.def;P(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType,r.readOnly=!0},jf=(e,t,r,n)=>{let o=e._zod.def;P(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType},Of=(e,t,r,n)=>{let o=e._zod.def;P(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType},Lf=(e,t,r,n)=>{let o=e._zod.innerType;P(o,t,n);let i=t.seen.get(e);i.ref=o},Wt={string:Qp,number:ef,boolean:tf,bigint:rf,symbol:nf,null:of,undefined:sf,void:cf,never:af,any:uf,unknown:lf,date:pf,enum:ff,literal:df,nan:mf,template_literal:hf,file:gf,success:_f,custom:bf,function:yf,transform:xf,map:$f,set:vf,array:wf,object:zf,union:kf,intersection:Sf,tuple:Pf,record:Ef,nullable:If,nonoptional:Tf,default:Af,prefault:Rf,catch:Zf,pipe:Cf,readonly:Nf,promise:jf,optional:Of,lazy:Lf};function Xt(e,t){if("_idmap"in e){let n=e,o=ge({...t,processors:Wt}),i={};for(let a of n._idmap.entries()){let[u,p]=a;P(p,o)}let s={},c={registry:n,uri:t?.uri,defs:i};o.external=c;for(let a of n._idmap.entries()){let[u,p]=a;_e(o,p),s[u]=be(o,p)}if(Object.keys(i).length>0){let a=o.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[a]:i}}return{schemas:s}}let r=ge({...t,processors:Wt});return P(e,r),_e(r,e),be(r,e)}var Qt=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let r=t?.target??"draft-2020-12";r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),this.ctx=ge({processors:Wt,target:r,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,r={path:[],schemaPath:[]}){return P(t,this.ctx,r)}emit(t,r){r&&(r.cycles&&(this.ctx.cycles=r.cycles),r.reused&&(this.ctx.reused=r.reused),r.external&&(this.ctx.external=r.external)),_e(this.ctx,t);let n=be(this.ctx,t),{"~standard":o,...i}=n;return i}};var Gc={};var z=f("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");$.init(e,t),e.def=t,e.type=t.type,e.parse=(r,n)=>de(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>ke(e,r,n),e.parseAsync=async(r,n)=>me(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>Se(e,r,n),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]},{parent:!0}),e.with=e.check,e.clone=(r,n)=>M(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.apply=r=>r(e)}),Ue=f("ZodMiniString",(e,t)=>{Le.init(e,t),z.init(e,t)});function y(e){return ri(Ue,e)}var A=f("ZodMiniStringFormat",(e,t)=>{I.init(e,t),Ue.init(e,t)}),Yc=f("ZodMiniEmail",(e,t)=>{Yn.init(e,t),A.init(e,t)});function Df(e){return oi(Yc,e)}var Hc=f("ZodMiniGUID",(e,t)=>{qn.init(e,t),A.init(e,t)});function Uf(e){return ii(Hc,e)}var dt=f("ZodMiniUUID",(e,t)=>{Gn.init(e,t),A.init(e,t)});function Bf(e){return si(dt,e)}function Ff(e){return ci(dt,e)}function Jf(e){return ai(dt,e)}function qf(e){return ui(dt,e)}var Is=f("ZodMiniURL",(e,t)=>{Hn.init(e,t),A.init(e,t)});function Gf(e){return Ht(Is,e)}function Yf(e){return Ht(Is,{protocol:/^https?$/,hostname:Q.domain,..._(e)})}var Kc=f("ZodMiniEmoji",(e,t)=>{Kn.init(e,t),A.init(e,t)});function Hf(e){return li(Kc,e)}var Vc=f("ZodMiniNanoID",(e,t)=>{Vn.init(e,t),A.init(e,t)});function Kf(e){return pi(Vc,e)}var Wc=f("ZodMiniCUID",(e,t)=>{Wn.init(e,t),A.init(e,t)});function Vf(e){return fi(Wc,e)}var Xc=f("ZodMiniCUID2",(e,t)=>{Xn.init(e,t),A.init(e,t)});function Wf(e){return di(Xc,e)}var Qc=f("ZodMiniULID",(e,t)=>{Qn.init(e,t),A.init(e,t)});function Xf(e){return mi(Qc,e)}var ea=f("ZodMiniXID",(e,t)=>{eo.init(e,t),A.init(e,t)});function Qf(e){return hi(ea,e)}var ta=f("ZodMiniKSUID",(e,t)=>{to.init(e,t),A.init(e,t)});function ed(e){return gi(ta,e)}var ra=f("ZodMiniIPv4",(e,t)=>{so.init(e,t),A.init(e,t)});function td(e){return _i(ra,e)}var na=f("ZodMiniIPv6",(e,t)=>{co.init(e,t),A.init(e,t)});function rd(e){return bi(na,e)}var oa=f("ZodMiniCIDRv4",(e,t)=>{uo.init(e,t),A.init(e,t)});function nd(e){return xi(oa,e)}var ia=f("ZodMiniCIDRv6",(e,t)=>{lo.init(e,t),A.init(e,t)});function od(e){return $i(ia,e)}var sa=f("ZodMiniMAC",(e,t)=>{ao.init(e,t),A.init(e,t)});function id(e){return yi(sa,e)}var ca=f("ZodMiniBase64",(e,t)=>{fo.init(e,t),A.init(e,t)});function sd(e){return vi(ca,e)}var aa=f("ZodMiniBase64URL",(e,t)=>{mo.init(e,t),A.init(e,t)});function cd(e){return wi(aa,e)}var ua=f("ZodMiniE164",(e,t)=>{ho.init(e,t),A.init(e,t)});function ad(e){return zi(ua,e)}var la=f("ZodMiniJWT",(e,t)=>{go.init(e,t),A.init(e,t)});function ud(e){return ki(la,e)}var mt=f("ZodMiniCustomStringFormat",(e,t)=>{_o.init(e,t),A.init(e,t)});function ld(e,t,r={}){return Me(mt,e,t,r)}function pd(e){return Me(mt,"hostname",Q.hostname,e)}function fd(e){return Me(mt,"hex",Q.hex,e)}function dd(e,t){let r=t?.enc??"hex",n=`${e}_${r}`,o=Q[n];if(!o)throw new Error(`Unrecognized hash format: ${n}`);return Me(mt,n,o,t)}var ht=f("ZodMiniNumber",(e,t)=>{Ut.init(e,t),z.init(e,t)});function ye(e){return Ai(ht,e)}var Be=f("ZodMiniNumberFormat",(e,t)=>{bo.init(e,t),ht.init(e,t)});function md(e){return Zi(Be,e)}function hd(e){return Ci(Be,e)}function gd(e){return Ni(Be,e)}function _d(e){return ji(Be,e)}function bd(e){return Oi(Be,e)}var gt=f("ZodMiniBoolean",(e,t)=>{it.init(e,t),z.init(e,t)});function Fe(e){return Li(gt,e)}var _t=f("ZodMiniBigInt",(e,t)=>{Bt.init(e,t),z.init(e,t)});function yd(e){return Di(_t,e)}var Ts=f("ZodMiniBigIntFormat",(e,t)=>{yo.init(e,t),_t.init(e,t)});function xd(e){return Bi(Ts,e)}function $d(e){return Fi(Ts,e)}var pa=f("ZodMiniSymbol",(e,t)=>{xo.init(e,t),z.init(e,t)});function vd(e){return Ji(pa,e)}var fa=f("ZodMiniUndefined",(e,t)=>{$o.init(e,t),z.init(e,t)});function wd(e){return qi(fa,e)}var da=f("ZodMiniNull",(e,t)=>{vo.init(e,t),z.init(e,t)});function ma(e){return Gi(da,e)}var ha=f("ZodMiniAny",(e,t)=>{wo.init(e,t),z.init(e,t)});function zd(){return Yi(ha)}var ga=f("ZodMiniUnknown",(e,t)=>{zo.init(e,t),z.init(e,t)});function er(){return Hi(ga)}var _a=f("ZodMiniNever",(e,t)=>{ko.init(e,t),z.init(e,t)});function ba(e){return Ki(_a,e)}var ya=f("ZodMiniVoid",(e,t)=>{So.init(e,t),z.init(e,t)});function kd(e){return Vi(ya,e)}var tr=f("ZodMiniDate",(e,t)=>{Po.init(e,t),z.init(e,t)});function Sd(e){return Wi(tr,e)}var xa=f("ZodMiniArray",(e,t)=>{Eo.init(e,t),z.init(e,t)});function U(e,t){return new xa({type:"array",element:e,..._(t)})}function Pd(e){let t=e._zod.def.shape;return Ta(Object.keys(t))}var rr=f("ZodMiniObject",(e,t)=>{Ft.init(e,t),z.init(e,t),w(e,"shape",()=>t.shape)});function E(e,t){let r={type:"object",shape:e??{},..._(t)};return new rr(r)}function Ed(e,t){return new rr({type:"object",shape:e,catchall:ba(),..._(t)})}function Id(e,t){return new rr({type:"object",shape:e,catchall:er(),..._(t)})}function bt(e,t){return Pt(e,t)}function Td(e,t){return Cr(e,t)}function Ad(e,t){return Pt(e,t)}function Rd(e,t){return Rr(e,t)}function Zd(e,t){return Zr(e,t)}function Cd(e,t){return Nr(Zs,e,t)}function Nd(e,t){return jr(Cs,e,t)}function jd(e,t){return e.clone({...e._zod.def,catchall:t})}var As=f("ZodMiniUnion",(e,t)=>{st.init(e,t),z.init(e,t)});function $a(e,t){return new As({type:"union",options:e,..._(t)})}var va=f("ZodMiniXor",(e,t)=>{As.init(e,t),Io.init(e,t)});function Od(e,t){return new va({type:"union",options:e,inclusive:!1,..._(t)})}var wa=f("ZodMiniDiscriminatedUnion",(e,t)=>{To.init(e,t),z.init(e,t)});function Ld(e,t,r){return new wa({type:"union",options:t,discriminator:e,..._(r)})}var za=f("ZodMiniIntersection",(e,t)=>{Ao.init(e,t),z.init(e,t)});function Md(e,t){return new za({type:"intersection",left:e,right:t})}var ka=f("ZodMiniTuple",(e,t)=>{Jt.init(e,t),z.init(e,t)});function Sa(e,t,r){let n=t instanceof $,o=n?r:t,i=n?t:null;return new ka({type:"tuple",items:e,rest:i,..._(o)})}var nr=f("ZodMiniRecord",(e,t)=>{Ro.init(e,t),z.init(e,t)});function Pa(e,t,r){return new nr({type:"record",keyType:e,valueType:t,..._(r)})}function Dd(e,t,r){let n=M(e);return n._zod.values=void 0,new nr({type:"record",keyType:n,valueType:t,..._(r)})}function Ud(e,t,r){return new nr({type:"record",keyType:e,valueType:t,mode:"loose",..._(r)})}var Ea=f("ZodMiniMap",(e,t)=>{Zo.init(e,t),z.init(e,t)});function Bd(e,t,r){return new Ea({type:"map",keyType:e,valueType:t,..._(r)})}var Ia=f("ZodMiniSet",(e,t)=>{Co.init(e,t),z.init(e,t)});function Fd(e,t){return new Ia({type:"set",valueType:e,..._(t)})}var Rs=f("ZodMiniEnum",(e,t)=>{No.init(e,t),z.init(e,t),e.options=Object.values(t.entries)});function Ta(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Rs({type:"enum",entries:r,..._(t)})}function Jd(e,t){return new Rs({type:"enum",entries:e,..._(t)})}var Aa=f("ZodMiniLiteral",(e,t)=>{jo.init(e,t),z.init(e,t)});function qd(e,t){return new Aa({type:"literal",values:Array.isArray(e)?e:[e],..._(t)})}var Ra=f("ZodMiniFile",(e,t)=>{Oo.init(e,t),z.init(e,t)});function Gd(e){return $s(Ra,e)}var Za=f("ZodMiniTransform",(e,t)=>{Lo.init(e,t),z.init(e,t)});function Yd(e){return new Za({type:"transform",transform:e})}var Zs=f("ZodMiniOptional",(e,t)=>{qt.init(e,t),z.init(e,t)});function x(e){return new Zs({type:"optional",innerType:e})}var Ca=f("ZodMiniExactOptional",(e,t)=>{Mo.init(e,t),z.init(e,t)});function Hd(e){return new Ca({type:"optional",innerType:e})}var Na=f("ZodMiniNullable",(e,t)=>{Do.init(e,t),z.init(e,t)});function or(e){return new Na({type:"nullable",innerType:e})}function Kd(e){return x(or(e))}var ja=f("ZodMiniDefault",(e,t)=>{Uo.init(e,t),z.init(e,t)});function Vd(e,t){return new ja({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Ne(t)}})}var Oa=f("ZodMiniPrefault",(e,t)=>{Bo.init(e,t),z.init(e,t)});function Wd(e,t){return new Oa({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Ne(t)}})}var Cs=f("ZodMiniNonOptional",(e,t)=>{Fo.init(e,t),z.init(e,t)});function Xd(e,t){return new Cs({type:"nonoptional",innerType:e,..._(t)})}var La=f("ZodMiniSuccess",(e,t)=>{Jo.init(e,t),z.init(e,t)});function Qd(e){return new La({type:"success",innerType:e})}var Ma=f("ZodMiniCatch",(e,t)=>{qo.init(e,t),z.init(e,t)});function em(e,t){return new Ma({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var Da=f("ZodMiniNaN",(e,t)=>{Go.init(e,t),z.init(e,t)});function tm(e){return Qi(Da,e)}var Ns=f("ZodMiniPipe",(e,t)=>{Yo.init(e,t),z.init(e,t)});function rm(e,t){return new Ns({type:"pipe",in:e,out:t})}var js=f("ZodMiniCodec",(e,t)=>{Ns.init(e,t),ct.init(e,t)});function nm(e,t,r){return new js({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}var Ua=f("ZodMiniReadonly",(e,t)=>{Ho.init(e,t),z.init(e,t)});function om(e){return new Ua({type:"readonly",innerType:e})}var Ba=f("ZodMiniTemplateLiteral",(e,t)=>{Ko.init(e,t),z.init(e,t)});function im(e,t){return new Ba({type:"template_literal",parts:e,..._(t)})}var Fa=f("ZodMiniLazy",(e,t)=>{Xo.init(e,t),z.init(e,t)});function Ja(e){return new Fa({type:"lazy",getter:e})}var qa=f("ZodMiniPromise",(e,t)=>{Wo.init(e,t),z.init(e,t)});function sm(e){return new qa({type:"promise",innerType:e})}var Os=f("ZodMiniCustom",(e,t)=>{Qo.init(e,t),z.init(e,t)});function cm(e,t){let r=new T({check:"custom",..._(t)});return r._zod.check=e,r}function Ga(e,t){return vs(Os,e??(()=>!0),t)}function am(e,t={}){return ws(Os,e,t)}function um(e){return zs(e)}var lm=ks,pm=Ss;function fm(e,t={}){let r=Ga(n=>n instanceof e,t);return r._zod.bag.Class=e,r._zod.check=n=>{n.value instanceof e||n.issues.push({code:"invalid_type",expected:e.name,input:n.value,inst:r,path:[...r._zod.def.path??[]]})},r}var dm=(...e)=>Ps({Codec:js,Boolean:gt,String:Ue},...e);function mm(){let e=Ja(()=>$a([y(),ye(),Fe(),ma(),U(e),Pa(y(),e)]));return e}var Ya=f("ZodMiniFunction",(e,t)=>{Vo.init(e,t),z.init(e,t)});function hm(e){return new Ya({type:"function",input:Array.isArray(e?.input)?Sa(e?.input):e?.input??U(er()),output:e?.output??er()})}var Ls={};we(Ls,{ZodMiniISODate:()=>sr,ZodMiniISODateTime:()=>ir,ZodMiniISODuration:()=>ar,ZodMiniISOTime:()=>cr,date:()=>_m,datetime:()=>gm,duration:()=>ym,time:()=>bm});var ir=f("ZodMiniISODateTime",(e,t)=>{ro.init(e,t),A.init(e,t)});function gm(e){return Pi(ir,e)}var sr=f("ZodMiniISODate",(e,t)=>{no.init(e,t),A.init(e,t)});function _m(e){return Ei(sr,e)}var cr=f("ZodMiniISOTime",(e,t)=>{oo.init(e,t),A.init(e,t)});function bm(e){return Ii(cr,e)}var ar=f("ZodMiniISODuration",(e,t)=>{io.init(e,t),A.init(e,t)});function ym(e){return Ti(ar,e)}var Ms={};we(Ms,{bigint:()=>wm,boolean:()=>vm,date:()=>zm,number:()=>$m,string:()=>xm});function xm(e){return ni(Ue,e)}function $m(e){return Ri(ht,e)}function vm(e){return Mi(gt,e)}function wm(e){return Ui(_t,e)}function zm(e){return Xi(tr,e)}var Ee=y().check(pt(1)),km=y().check(ft(/^https?:\/\/.+/)),Us=E({CLANCY_BASE_BRANCH:x(y()),CLANCY_LABEL:x(y()),CLANCY_MODEL:x(y()),CLANCY_NOTIFY_WEBHOOK:x(y()),CLANCY_STATUS_IN_PROGRESS:x(y()),CLANCY_STATUS_DONE:x(y()),CLANCY_STATUS_REVIEW:x(y()),MAX_ITERATIONS:x(y()),PLAYWRIGHT_ENABLED:x(y()),PLAYWRIGHT_DEV_PORT:x(y()),CLANCY_ROLES:x(y()),CLANCY_PLAN_STATUS:x(y()),CLANCY_PLAN_LABEL:x(y()),CLANCY_PLAN_STATE_TYPE:x(y()),CLANCY_STATUS_PLANNED:x(y()),CLANCY_SKIP_COMMENTS:x(y()),GITHUB_TOKEN:x(y()),GITLAB_TOKEN:x(y()),BITBUCKET_USER:x(y()),BITBUCKET_TOKEN:x(y()),CLANCY_GIT_PLATFORM:x(y()),CLANCY_GIT_API_URL:x(y()),CLANCY_MAX_REWORK:x(y()),CLANCY_TDD:x(y()),CLANCY_MODE:x(y()),CLANCY_BRIEF_ISSUE_TYPE:x(y()),CLANCY_BRIEF_EPIC:x(y()),CLANCY_COMPONENT:x(y())}),Ka=bt(Us,{JIRA_BASE_URL:km,JIRA_USER:Ee,JIRA_API_TOKEN:Ee,JIRA_PROJECT_KEY:Ee,CLANCY_JQL_STATUS:x(y()),CLANCY_JQL_SPRINT:x(y())}),Va=bt(Us,{GITHUB_TOKEN:Ee,GITHUB_REPO:Ee}),Wa=bt(Us,{LINEAR_API_KEY:Ee,LINEAR_TEAM_ID:Ee});function Xa(e){if(e.JIRA_BASE_URL){let t=Ka.safeParse(e);return t.success?{provider:"jira",env:t.data}:`\u2717 Jira env validation failed: ${t.error.message}`}if(e.GITHUB_TOKEN&&e.GITHUB_REPO){let t=Va.safeParse(e);return t.success?{provider:"github",env:t.data}:`\u2717 GitHub env validation failed: ${t.error.message}`}if(e.LINEAR_API_KEY){let t=Wa.safeParse(e);return t.success?{provider:"linear",env:t.data}:`\u2717 Linear env validation failed: ${t.error.message}`}return"\u2717 No board detected \u2014 set Jira, GitHub, or Linear credentials in .clancy/.env"}function Sm(e){return["You are evaluating whether a ticket can be implemented as pure code changes in a repository.","",`Ticket: [${e.key}] ${e.title}`,"Description:",e.description,"","Can this ticket be completed entirely through code changes committed to a git repository?","","Answer INFEASIBLE if the ticket requires ANY of:","- Manual testing or configuration in external tools or admin panels","- Access to external services, APIs, or platforms not available in the codebase","- Physical, hardware, or infrastructure changes","- Design assets that do not yet exist","- Deployment or infrastructure changes outside the repository","- Human judgment calls that require stakeholder input","","Answer with exactly one line in this format:","FEASIBLE","or","INFEASIBLE: one-line reason","","Do not include any other text."].join(`
|
|
41
|
-
`)}function
|
|
42
|
-
`).pop()?.trim()??"";return/^INFEASIBLE/i.test(t)?{feasible:!1,reason:t.replace(/^INFEASIBLE:?\s*/i,"").trim()||void 0}:{feasible:!0}}function
|
|
43
|
-
... (truncated)`:r:void 0}catch{return}}function
|
|
44
|
-
`)){let n=r.trim();if(!n||n.startsWith("#"))continue;let o=n.indexOf("=");if(o===-1)continue;let i=n.slice(0,o).trim(),s=n.slice(o+1).trim();s.length>=2&&(s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'"))&&(s=s.slice(1,-1)),t[i]=s}return t}function
|
|
45
|
-
${n}`:n}return{ok:!0,env:t,warning:r}}import{appendFileSync as
|
|
46
|
-
`;
|
|
47
|
-
`;
|
|
48
|
-
`)){let i=o.trim();if(!i)continue;let s=i.split(" | ");if(s.length<4)continue;let c=s[0];if(s[1]==="BRIEF"||s[1]==="APPROVE_BRIEF"){n.push({timestamp:c,key:s[2],summary:s.slice(3).join(" | "),status:s[1]});continue}let a=s[1],u,p,d,
|
|
38
|
+
`)}m.write("payload.value = newResult;"),m.write("return payload;");let O=m.compile();return(N,I)=>O(h,N,I)},i,s=Pe,c=!He.jitless,u=c&&Nr.value,p=t.catchall,d;e._zod.parse=(h,m)=>{d??(d=n.value);let _=h.value;return s(_)?c&&u&&m?.async===!1&&m.jitless!==!0?(i||(i=o(t.shape)),h=i(h,m),p?ta([],_,h,m,d,e):h):r(h,m):(h.issues.push({expected:"object",code:"invalid_type",input:_,inst:e}),h)}});function Bc(e,t,r,n){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let o=e.filter(i=>!he(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(s=>Y(s,n,D())))}),t)}var st=f("$ZodUnion",(e,t)=>{v.init(e,t),z(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),z(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),z(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),z(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){let o=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>Xe(i.source)).join("|")})$`)}});let r=t.options.length===1,n=t.options[0]._zod.run;e._zod.parse=(o,i)=>{if(r)return n(o,i);let s=!1,c=[];for(let a of t.options){let u=a._zod.run({value:o.value,issues:[]},i);if(u instanceof Promise)c.push(u),s=!0;else{if(u.issues.length===0)return u;c.push(u)}}return s?Promise.all(c).then(a=>Bc(a,o,e,i)):Bc(c,o,e,i)}});function Fc(e,t,r,n){let o=e.filter(i=>i.issues.length===0);return o.length===1?(t.value=o[0].value,t):(o.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(s=>Y(s,n,D())))}):t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:[],inclusive:!1}),t)}var Oo=f("$ZodXor",(e,t)=>{st.init(e,t),t.inclusive=!1;let r=t.options.length===1,n=t.options[0]._zod.run;e._zod.parse=(o,i)=>{if(r)return n(o,i);let s=!1,c=[];for(let a of t.options){let u=a._zod.run({value:o.value,issues:[]},i);u instanceof Promise?(c.push(u),s=!0):c.push(u)}return s?Promise.all(c).then(a=>Fc(a,o,e,i)):Fc(c,o,e,i)}}),Lo=f("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,st.init(e,t);let r=e._zod.parse;z(e._zod,"propValues",()=>{let o={};for(let i of t.options){let s=i._zod.propValues;if(!s||Object.keys(s).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(let[c,a]of Object.entries(s)){o[c]||(o[c]=new Set);for(let u of a)o[c].add(u)}}return o});let n=je(()=>{let o=t.options,i=new Map;for(let s of o){let c=s._zod.propValues?.[t.discriminator];if(!c||c.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let a of c){if(i.has(a))throw new Error(`Duplicate discriminator value "${String(a)}"`);i.set(a,s)}}return i});e._zod.parse=(o,i)=>{let s=o.value;if(!Pe(s))return o.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),o;let c=n.value.get(s?.[t.discriminator]);return c?c._zod.run(o,i):t.unionFallback?r(o,i):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:s,path:[t.discriminator],inst:e}),o)}}),Mo=f("$ZodIntersection",(e,t)=>{v.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,i=t.left._zod.run({value:o,issues:[]},n),s=t.right._zod.run({value:o,issues:[]},n);return i instanceof Promise||s instanceof Promise?Promise.all([i,s]).then(([a,u])=>Jc(r,a,u)):Jc(r,i,s)}});function Xn(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(me(e)&&me(t)){let r=Object.keys(t),n=Object.keys(e).filter(i=>r.indexOf(i)!==-1),o={...e,...t};for(let i of n){let s=Xn(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let o=e[n],i=t[n],s=Xn(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[n,...s.mergeErrorPath]};r.push(s.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Jc(e,t,r){let n=new Map,o;for(let c of t.issues)if(c.code==="unrecognized_keys"){o??(o=c);for(let a of c.keys)n.has(a)||n.set(a,{}),n.get(a).l=!0}else e.issues.push(c);for(let c of r.issues)if(c.code==="unrecognized_keys")for(let a of c.keys)n.has(a)||n.set(a,{}),n.get(a).r=!0;else e.issues.push(c);let i=[...n].filter(([,c])=>c.l&&c.r).map(([c])=>c);if(i.length&&o&&e.issues.push({...o,keys:i}),he(e))return e;let s=Xn(t.value,r.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}var Yt=f("$ZodTuple",(e,t)=>{v.init(e,t);let r=t.items;e._zod.parse=(n,o)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({input:i,inst:e,expected:"tuple",code:"invalid_type"}),n;n.value=[];let s=[],c=[...r].reverse().findIndex(p=>p._zod.optin!=="optional"),a=c===-1?0:r.length-c;if(!t.rest){let p=i.length>r.length,d=i.length<a-1;if(p||d)return n.issues.push({...p?{code:"too_big",maximum:r.length,inclusive:!0}:{code:"too_small",minimum:r.length},input:i,inst:e,origin:"array"}),n}let u=-1;for(let p of r){if(u++,u>=i.length&&u>=a)continue;let d=p._zod.run({value:i[u],issues:[]},o);d instanceof Promise?s.push(d.then(h=>Dt(h,n,u))):Dt(d,n,u)}if(t.rest){let p=i.slice(r.length);for(let d of p){u++;let h=t.rest._zod.run({value:d,issues:[]},o);h instanceof Promise?s.push(h.then(m=>Dt(m,n,u))):Dt(h,n,u)}}return s.length?Promise.all(s).then(()=>n):n}});function Dt(e,t,r){e.issues.length&&t.issues.push(...V(r,e.issues)),t.value[r]=e.value}var Do=f("$ZodRecord",(e,t)=>{v.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!me(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),r;let i=[],s=t.keyType._zod.values;if(s){r.value={};let c=new Set;for(let u of s)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){c.add(typeof u=="number"?u.toString():u);let p=t.valueType._zod.run({value:o[u],issues:[]},n);p instanceof Promise?i.push(p.then(d=>{d.issues.length&&r.issues.push(...V(u,d.issues)),r.value[u]=d.value})):(p.issues.length&&r.issues.push(...V(u,p.issues)),r.value[u]=p.value)}let a;for(let u in o)c.has(u)||(a=a??[],a.push(u));a&&a.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:a})}else{r.value={};for(let c of Reflect.ownKeys(o)){if(c==="__proto__")continue;let a=t.keyType._zod.run({value:c,issues:[]},n);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof c=="string"&&Ot.test(c)&&a.issues.length){let d=t.keyType._zod.run({value:Number(c),issues:[]},n);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");d.issues.length===0&&(a=d)}if(a.issues.length){t.mode==="loose"?r.value[c]=o[c]:r.issues.push({code:"invalid_key",origin:"record",issues:a.issues.map(d=>Y(d,n,D())),input:c,path:[c],inst:e});continue}let p=t.valueType._zod.run({value:o[c],issues:[]},n);p instanceof Promise?i.push(p.then(d=>{d.issues.length&&r.issues.push(...V(c,d.issues)),r.value[a.value]=d.value})):(p.issues.length&&r.issues.push(...V(c,p.issues)),r.value[a.value]=p.value)}}return i.length?Promise.all(i).then(()=>r):r}}),Uo=f("$ZodMap",(e,t)=>{v.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!(o instanceof Map))return r.issues.push({expected:"map",code:"invalid_type",input:o,inst:e}),r;let i=[];r.value=new Map;for(let[s,c]of o){let a=t.keyType._zod.run({value:s,issues:[]},n),u=t.valueType._zod.run({value:c,issues:[]},n);a instanceof Promise||u instanceof Promise?i.push(Promise.all([a,u]).then(([p,d])=>{Kc(p,d,r,s,o,e,n)})):Kc(a,u,r,s,o,e,n)}return i.length?Promise.all(i).then(()=>r):r}});function Kc(e,t,r,n,o,i,s){e.issues.length&&(Qe.has(typeof n)?r.issues.push(...V(n,e.issues)):r.issues.push({code:"invalid_key",origin:"map",input:o,inst:i,issues:e.issues.map(c=>Y(c,s,D()))})),t.issues.length&&(Qe.has(typeof n)?r.issues.push(...V(n,t.issues)):r.issues.push({origin:"map",code:"invalid_element",input:o,inst:i,key:n,issues:t.issues.map(c=>Y(c,s,D()))})),r.value.set(e.value,t.value)}var Bo=f("$ZodSet",(e,t)=>{v.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!(o instanceof Set))return r.issues.push({input:o,inst:e,expected:"set",code:"invalid_type"}),r;let i=[];r.value=new Set;for(let s of o){let c=t.valueType._zod.run({value:s,issues:[]},n);c instanceof Promise?i.push(c.then(a=>qc(a,r))):qc(c,r)}return i.length?Promise.all(i).then(()=>r):r}});function qc(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}var Fo=f("$ZodEnum",(e,t)=>{v.init(e,t);let r=We(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(o=>Qe.has(typeof o)).map(o=>typeof o=="string"?Q(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{let s=o.value;return n.has(s)||o.issues.push({code:"invalid_value",values:r,input:s,inst:e}),o}}),Jo=f("$ZodLiteral",(e,t)=>{if(v.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");let r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?Q(n):n?Q(n.toString()):String(n)).join("|")})$`),e._zod.parse=(n,o)=>{let i=n.value;return r.has(i)||n.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),n}}),Ko=f("$ZodFile",(e,t)=>{v.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;return o instanceof File||r.issues.push({expected:"file",code:"invalid_type",input:o,inst:e}),r}}),qo=f("$ZodTransform",(e,t)=>{v.init(e,t),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Ne(e.constructor.name);let o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(s=>(r.value=s,r));if(o instanceof Promise)throw new ie;return r.value=o,r}});function Gc(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var Ht=f("$ZodOptional",(e,t)=>{v.init(e,t),e._zod.optin="optional",e._zod.optout="optional",z(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),z(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Xe(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>Gc(i,r.value)):Gc(o,r.value)}return r.value===void 0?r:t.innerType._zod.run(r,n)}}),Go=f("$ZodExactOptional",(e,t)=>{Ht.init(e,t),z(e._zod,"values",()=>t.innerType._zod.values),z(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Yo=f("$ZodNullable",(e,t)=>{v.init(e,t),z(e._zod,"optin",()=>t.innerType._zod.optin),z(e._zod,"optout",()=>t.innerType._zod.optout),z(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Xe(r.source)}|null)$`):void 0}),z(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),Ho=f("$ZodDefault",(e,t)=>{v.init(e,t),e._zod.optin="optional",z(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>Yc(i,t)):Yc(o,t)}});function Yc(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Vo=f("$ZodPrefault",(e,t)=>{v.init(e,t),e._zod.optin="optional",z(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),Wo=f("$ZodNonOptional",(e,t)=>{v.init(e,t),z(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>Hc(i,e)):Hc(o,e)}});function Hc(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var Xo=f("$ZodSuccess",(e,t)=>{v.init(e,t),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Ne("ZodSuccess");let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>(r.value=i.issues.length===0,r)):(r.value=o.issues.length===0,r)}}),Qo=f("$ZodCatch",(e,t)=>{v.init(e,t),z(e._zod,"optin",()=>t.innerType._zod.optin),z(e._zod,"optout",()=>t.innerType._zod.optout),z(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>(r.value=i.value,i.issues.length&&(r.value=t.catchValue({...r,error:{issues:i.issues.map(s=>Y(s,n,D()))},input:r.value}),r.issues=[]),r)):(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(i=>Y(i,n,D()))},input:r.value}),r.issues=[]),r)}}),ei=f("$ZodNaN",(e,t)=>{v.init(e,t),e._zod.parse=(r,n)=>((typeof r.value!="number"||!Number.isNaN(r.value))&&r.issues.push({input:r.value,inst:e,expected:"nan",code:"invalid_type"}),r)}),ti=f("$ZodPipe",(e,t)=>{v.init(e,t),z(e._zod,"values",()=>t.in._zod.values),z(e._zod,"optin",()=>t.in._zod.optin),z(e._zod,"optout",()=>t.out._zod.optout),z(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let i=t.out._zod.run(r,n);return i instanceof Promise?i.then(s=>Ut(s,t.in,n)):Ut(i,t.in,n)}let o=t.in._zod.run(r,n);return o instanceof Promise?o.then(i=>Ut(i,t.out,n)):Ut(o,t.out,n)}});function Ut(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}var ct=f("$ZodCodec",(e,t)=>{v.init(e,t),z(e._zod,"values",()=>t.in._zod.values),z(e._zod,"optin",()=>t.in._zod.optin),z(e._zod,"optout",()=>t.out._zod.optout),z(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if((n.direction||"forward")==="forward"){let i=t.in._zod.run(r,n);return i instanceof Promise?i.then(s=>Bt(s,t,n)):Bt(i,t,n)}else{let i=t.out._zod.run(r,n);return i instanceof Promise?i.then(s=>Bt(s,t,n)):Bt(i,t,n)}}});function Bt(e,t,r){if(e.issues.length)return e.aborted=!0,e;if((r.direction||"forward")==="forward"){let o=t.transform(e.value,e);return o instanceof Promise?o.then(i=>Ft(e,i,t.out,r)):Ft(e,o,t.out,r)}else{let o=t.reverseTransform(e.value,e);return o instanceof Promise?o.then(i=>Ft(e,i,t.in,r)):Ft(e,o,t.in,r)}}function Ft(e,t,r,n){return e.issues.length?(e.aborted=!0,e):r._zod.run({value:t,issues:e.issues},n)}var ri=f("$ZodReadonly",(e,t)=>{v.init(e,t),z(e._zod,"propValues",()=>t.innerType._zod.propValues),z(e._zod,"values",()=>t.innerType._zod.values),z(e._zod,"optin",()=>t.innerType?._zod?.optin),z(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(Vc):Vc(o)}});function Vc(e){return e.value=Object.freeze(e.value),e}var ni=f("$ZodTemplateLiteral",(e,t)=>{v.init(e,t);let r=[];for(let n of t.parts)if(typeof n=="object"&&n!==null){if(!n._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...n._zod.traits].shift()}`);let o=n._zod.pattern instanceof RegExp?n._zod.pattern.source:n._zod.pattern;if(!o)throw new Error(`Invalid template literal part: ${n._zod.traits}`);let i=o.startsWith("^")?1:0,s=o.endsWith("$")?o.length-1:o.length;r.push(o.slice(i,s))}else if(n===null||jr.has(typeof n))r.push(Q(`${n}`));else throw new Error(`Invalid template literal part: ${n}`);e._zod.pattern=new RegExp(`^${r.join("")}$`),e._zod.parse=(n,o)=>typeof n.value!="string"?(n.issues.push({input:n.value,inst:e,expected:"string",code:"invalid_type"}),n):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(n.value)||n.issues.push({input:n.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),n)}),oi=f("$ZodFunction",(e,t)=>(v.init(e,t),e._def=t,e._zod.def=t,e.implement=r=>{if(typeof r!="function")throw new Error("implement() must be called with a function");return function(...n){let o=e._def.input?ge(e._def.input,n):n,i=Reflect.apply(r,this,o);return e._def.output?ge(e._def.output,i):i}},e.implementAsync=r=>{if(typeof r!="function")throw new Error("implementAsync() must be called with a function");return async function(...n){let o=e._def.input?await _e(e._def.input,n):n,i=await Reflect.apply(r,this,o);return e._def.output?await _e(e._def.output,i):i}},e._zod.parse=(r,n)=>typeof r.value!="function"?(r.issues.push({code:"invalid_type",expected:"function",input:r.value,inst:e}),r):(e._def.output&&e._def.output._zod.def.type==="promise"?r.value=e.implementAsync(r.value):r.value=e.implement(r.value),r),e.input=(...r)=>{let n=e.constructor;return Array.isArray(r[0])?new n({type:"function",input:new Yt({type:"tuple",items:r[0],rest:r[1]}),output:e._def.output}):new n({type:"function",input:r[0],output:e._def.output})},e.output=r=>{let n=e.constructor;return new n({type:"function",input:e._def.input,output:r})},e)),ii=f("$ZodPromise",(e,t)=>{v.init(e,t),e._zod.parse=(r,n)=>Promise.resolve(r.value).then(o=>t.innerType._zod.run({value:o,issues:[]},n))}),si=f("$ZodLazy",(e,t)=>{v.init(e,t),z(e._zod,"innerType",()=>t.getter()),z(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),z(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),z(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),z(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(r,n)=>e._zod.innerType._zod.run(r,n)}),ci=f("$ZodCustom",(e,t)=>{C.init(e,t),v.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(i=>Wc(i,r,n,e));Wc(o,r,n,e)}});function Wc(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(Le(o))}}var at={};Se(at,{default:()=>Lp});var Lp={};var ra,ai=Symbol("ZodOutput"),ui=Symbol("ZodInput"),Vt=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let o={...n,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function Wt(){return new Vt}(ra=globalThis).__zod_globalRegistry??(ra.__zod_globalRegistry=Wt());var ce=globalThis.__zod_globalRegistry;function li(e,t){return new e({type:"string",...g(t)})}function pi(e,t){return new e({type:"string",coerce:!0,...g(t)})}function fi(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...g(t)})}function di(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...g(t)})}function mi(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...g(t)})}function hi(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...g(t)})}function gi(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...g(t)})}function _i(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...g(t)})}function Xt(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...g(t)})}function yi(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...g(t)})}function bi(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...g(t)})}function xi(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...g(t)})}function $i(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...g(t)})}function vi(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...g(t)})}function wi(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...g(t)})}function zi(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...g(t)})}function ki(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...g(t)})}function Si(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...g(t)})}function Pi(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...g(t)})}function Ei(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...g(t)})}function Ii(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...g(t)})}function Ai(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...g(t)})}function Ti(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...g(t)})}function Ri(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...g(t)})}function Ci(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...g(t)})}var Zi={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function Ni(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...g(t)})}function ji(e,t){return new e({type:"string",format:"date",check:"string_format",...g(t)})}function Oi(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...g(t)})}function Li(e,t){return new e({type:"string",format:"duration",check:"string_format",...g(t)})}function Mi(e,t){return new e({type:"number",checks:[],...g(t)})}function Di(e,t){return new e({type:"number",coerce:!0,checks:[],...g(t)})}function Ui(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...g(t)})}function Bi(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...g(t)})}function Fi(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...g(t)})}function Ji(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...g(t)})}function Ki(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...g(t)})}function qi(e,t){return new e({type:"boolean",...g(t)})}function Gi(e,t){return new e({type:"boolean",coerce:!0,...g(t)})}function Yi(e,t){return new e({type:"bigint",...g(t)})}function Hi(e,t){return new e({type:"bigint",coerce:!0,...g(t)})}function Vi(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...g(t)})}function Wi(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...g(t)})}function Xi(e,t){return new e({type:"symbol",...g(t)})}function Qi(e,t){return new e({type:"undefined",...g(t)})}function es(e,t){return new e({type:"null",...g(t)})}function ts(e){return new e({type:"any"})}function rs(e){return new e({type:"unknown"})}function ns(e,t){return new e({type:"never",...g(t)})}function os(e,t){return new e({type:"void",...g(t)})}function is(e,t){return new e({type:"date",...g(t)})}function ss(e,t){return new e({type:"date",coerce:!0,...g(t)})}function cs(e,t){return new e({type:"nan",...g(t)})}function Qt(e,t){return new Lt({check:"less_than",...g(t),value:e,inclusive:!1})}function ut(e,t){return new Lt({check:"less_than",...g(t),value:e,inclusive:!0})}function er(e,t){return new Mt({check:"greater_than",...g(t),value:e,inclusive:!1})}function lt(e,t){return new Mt({check:"greater_than",...g(t),value:e,inclusive:!0})}function as(e){return er(0,e)}function us(e){return Qt(0,e)}function ls(e){return ut(0,e)}function ps(e){return lt(0,e)}function fs(e,t){return new Cn({check:"multiple_of",...g(t),value:e})}function ds(e,t){return new jn({check:"max_size",...g(t),maximum:e})}function ms(e,t){return new On({check:"min_size",...g(t),minimum:e})}function hs(e,t){return new Ln({check:"size_equals",...g(t),size:e})}function gs(e,t){return new Mn({check:"max_length",...g(t),maximum:e})}function pt(e,t){return new Dn({check:"min_length",...g(t),minimum:e})}function _s(e,t){return new Un({check:"length_equals",...g(t),length:e})}function ft(e,t){return new Bn({check:"string_format",format:"regex",...g(t),pattern:e})}function ys(e){return new Fn({check:"string_format",format:"lowercase",...g(e)})}function bs(e){return new Jn({check:"string_format",format:"uppercase",...g(e)})}function xs(e,t){return new Kn({check:"string_format",format:"includes",...g(t),includes:e})}function $s(e,t){return new qn({check:"string_format",format:"starts_with",...g(t),prefix:e})}function vs(e,t){return new Gn({check:"string_format",format:"ends_with",...g(t),suffix:e})}function ws(e,t,r){return new Yn({check:"property",property:e,schema:t,...g(r)})}function zs(e,t){return new Hn({check:"mime_type",mime:e,...g(t)})}function ye(e){return new Vn({check:"overwrite",tx:e})}function ks(e){return ye(t=>t.normalize(e))}function Ss(){return ye(e=>e.trim())}function Ps(){return ye(e=>e.toLowerCase())}function Es(){return ye(e=>e.toUpperCase())}function Dp(){return ye(e=>Zr(e))}function Up(e,t,r){return new e({type:"array",element:t,...g(r)})}function Bp(e,t,r){return new e({type:"union",options:t,...g(r)})}function Fp(e,t,r){return new e({type:"union",options:t,inclusive:!1,...g(r)})}function Jp(e,t,r,n){return new e({type:"union",options:r,discriminator:t,...g(n)})}function Kp(e,t,r){return new e({type:"intersection",left:t,right:r})}function qp(e,t,r,n){let o=r instanceof v,i=o?n:r,s=o?r:null;return new e({type:"tuple",items:t,rest:s,...g(i)})}function Gp(e,t,r,n){return new e({type:"record",keyType:t,valueType:r,...g(n)})}function Yp(e,t,r,n){return new e({type:"map",keyType:t,valueType:r,...g(n)})}function Hp(e,t,r){return new e({type:"set",valueType:t,...g(r)})}function Vp(e,t,r){let n=Array.isArray(t)?Object.fromEntries(t.map(o=>[o,o])):t;return new e({type:"enum",entries:n,...g(r)})}function Wp(e,t,r){return new e({type:"enum",entries:t,...g(r)})}function Xp(e,t,r){return new e({type:"literal",values:Array.isArray(t)?t:[t],...g(r)})}function Is(e,t){return new e({type:"file",...g(t)})}function Qp(e,t){return new e({type:"transform",transform:t})}function ef(e,t){return new e({type:"optional",innerType:t})}function tf(e,t){return new e({type:"nullable",innerType:t})}function rf(e,t,r){return new e({type:"default",innerType:t,get defaultValue(){return typeof r=="function"?r():Oe(r)}})}function nf(e,t,r){return new e({type:"nonoptional",innerType:t,...g(r)})}function of(e,t){return new e({type:"success",innerType:t})}function sf(e,t,r){return new e({type:"catch",innerType:t,catchValue:typeof r=="function"?r:()=>r})}function cf(e,t,r){return new e({type:"pipe",in:t,out:r})}function af(e,t){return new e({type:"readonly",innerType:t})}function uf(e,t,r){return new e({type:"template_literal",parts:t,...g(r)})}function lf(e,t){return new e({type:"lazy",getter:t})}function pf(e,t){return new e({type:"promise",innerType:t})}function As(e,t,r){let n=g(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function Ts(e,t,r){return new e({type:"custom",check:"custom",fn:t,...g(r)})}function Rs(e){let t=na(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(Le(n,r.value,t._zod.def));else{let o=n;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),r.issues.push(Le(o))}},e(r.value,r)));return t}function na(e,t){let r=new C({check:"custom",...g(t)});return r._zod.check=e,r}function Cs(e){let t=new C({check:"describe"});return t._zod.onattach=[r=>{let n=ce.get(r)??{};ce.add(r,{...n,description:e})}],t._zod.check=()=>{},t}function Zs(e){let t=new C({check:"meta"});return t._zod.onattach=[r=>{let n=ce.get(r)??{};ce.add(r,{...n,...e})}],t._zod.check=()=>{},t}function Ns(e,t){let r=g(t),n=r.truthy??["true","1","yes","on","y","enabled"],o=r.falsy??["false","0","no","off","n","disabled"];r.case!=="sensitive"&&(n=n.map(m=>typeof m=="string"?m.toLowerCase():m),o=o.map(m=>typeof m=="string"?m.toLowerCase():m));let i=new Set(n),s=new Set(o),c=e.Codec??ct,a=e.Boolean??it,u=e.String??De,p=new u({type:"string",error:r.error}),d=new a({type:"boolean",error:r.error}),h=new c({type:"pipe",in:p,out:d,transform:((m,_)=>{let y=m;return r.case!=="sensitive"&&(y=y.toLowerCase()),i.has(y)?!0:s.has(y)?!1:(_.issues.push({code:"invalid_value",expected:"stringbool",values:[...i,...s],input:_.value,inst:h,continue:!1}),{})}),reverseTransform:((m,_)=>m===!0?n[0]||"true":o[0]||"false"),error:r.error});return h}function Ue(e,t,r,n={}){let o=g(n),i={...g(n),check:"string_format",type:"string",format:t,fn:typeof r=="function"?r:c=>r.test(c),...o};return r instanceof RegExp&&(i.pattern=r),new e(i)}function be(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??ce,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function P(e,t,r={path:[],schemaPath:[]}){var n;let o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;let s={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,s);let c=e._zod.toJSONSchema?.();if(c)s.schema=c;else{let p={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,p);else{let h=s.schema,m=t.processors[o.type];if(!m)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);m(e,t,h,p)}let d=e._zod.parent;d&&(s.ref||(s.ref=d),P(d,t,p),t.seen.get(d).isParent=!0)}let a=t.metadataRegistry.get(e);return a&&Object.assign(s.schema,a),t.io==="input"&&J(e)&&(delete s.schema.examples,delete s.schema.default),t.io==="input"&&s.schema._prefault&&((n=s.schema).default??(n.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function xe(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=new Map;for(let s of e.seen.entries()){let c=e.metadataRegistry.get(s[0])?.id;if(c){let a=n.get(c);if(a&&a!==s[0])throw new Error(`Duplicate schema id "${c}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(c,s[0])}}let o=s=>{let c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(s[0])?.id,h=e.external.uri??(_=>_);if(d)return{ref:h(d)};let m=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=m,{defId:m,ref:`${h("__shared")}#/${c}/${m}`}}if(s[1]===r)return{ref:"#"};let u=`#/${c}/`,p=s[1].schema.id??`__schema${e.counter++}`;return{defId:p,ref:u+p}},i=s=>{if(s[1].schema.$ref)return;let c=s[1],{ref:a,defId:u}=o(s);c.def={...c.schema},u&&(c.defId=u);let p=c.schema;for(let d in p)delete p[d];p.$ref=a};if(e.cycles==="throw")for(let s of e.seen.entries()){let c=s[1];if(c.cycle)throw new Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
|
|
39
|
+
|
|
40
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let c=s[1];if(t===s[0]){i(s);continue}if(e.external){let u=e.external.registry.get(s[0])?.id;if(t!==s[0]&&u){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(c.cycle){i(s);continue}if(c.count>1&&e.reused==="ref"){i(s);continue}}}function $e(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=s=>{let c=e.seen.get(s);if(c.ref===null)return;let a=c.def??c.schema,u={...a},p=c.ref;if(c.ref=null,p){n(p);let h=e.seen.get(p),m=h.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(a.allOf=a.allOf??[],a.allOf.push(m)):Object.assign(a,m),Object.assign(a,u),s._zod.parent===p)for(let y in a)y==="$ref"||y==="allOf"||y in u||delete a[y];if(m.$ref&&h.def)for(let y in a)y==="$ref"||y==="allOf"||y in h.def&&JSON.stringify(a[y])===JSON.stringify(h.def[y])&&delete a[y]}let d=s._zod.parent;if(d&&d!==p){n(d);let h=e.seen.get(d);if(h?.schema.$ref&&(a.$ref=h.schema.$ref,h.def))for(let m in a)m==="$ref"||m==="allOf"||m in h.def&&JSON.stringify(a[m])===JSON.stringify(h.def[m])&&delete a[m]}e.override({zodSchema:s,jsonSchema:a,path:c.path??[]})};for(let s of[...e.seen.entries()].reverse())n(s[0]);let o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let s=e.external.registry.get(t)?.id;if(!s)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(s)}Object.assign(o,r.def??r.schema);let i=e.external?.defs??{};for(let s of e.seen.entries()){let c=s[1];c.def&&c.defId&&(i[c.defId]=c.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{let s=JSON.parse(JSON.stringify(o));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:js(t,"input",e.processors),output:js(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function J(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return J(n.element,r);if(n.type==="set")return J(n.valueType,r);if(n.type==="lazy")return J(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return J(n.innerType,r);if(n.type==="intersection")return J(n.left,r)||J(n.right,r);if(n.type==="record"||n.type==="map")return J(n.keyType,r)||J(n.valueType,r);if(n.type==="pipe")return J(n.in,r)||J(n.out,r);if(n.type==="object"){for(let o in n.shape)if(J(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(J(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(J(o,r))return!0;return!!(n.rest&&J(n.rest,r))}return!1}var ff=(e,t={})=>r=>{let n=be({...r,processors:t});return P(e,n),xe(n,e),$e(n,e)},js=(e,t,r={})=>n=>{let{libraryOptions:o,target:i}=n??{},s=be({...o??{},target:i,io:t,processors:r});return P(e,s),xe(s,e),$e(s,e)};var df={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},mf=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:i,maximum:s,format:c,patterns:a,contentEncoding:u}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof s=="number"&&(o.maxLength=s),c&&(o.format=df[c]??c,o.format===""&&delete o.format,c==="time"&&delete o.format),u&&(o.contentEncoding=u),a&&a.size>0){let p=[...a];p.length===1?o.pattern=p[0].source:p.length>1&&(o.allOf=[...p.map(d=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},hf=(e,t,r,n)=>{let o=r,{minimum:i,maximum:s,format:c,multipleOf:a,exclusiveMaximum:u,exclusiveMinimum:p}=e._zod.bag;typeof c=="string"&&c.includes("int")?o.type="integer":o.type="number",typeof p=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.minimum=p,o.exclusiveMinimum=!0):o.exclusiveMinimum=p),typeof i=="number"&&(o.minimum=i,typeof p=="number"&&t.target!=="draft-04"&&(p>=i?delete o.minimum:delete o.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.maximum=u,o.exclusiveMaximum=!0):o.exclusiveMaximum=u),typeof s=="number"&&(o.maximum=s,typeof u=="number"&&t.target!=="draft-04"&&(u<=s?delete o.maximum:delete o.exclusiveMaximum)),typeof a=="number"&&(o.multipleOf=a)},gf=(e,t,r,n)=>{r.type="boolean"},_f=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},yf=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},bf=(e,t,r,n)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},xf=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},$f=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},vf=(e,t,r,n)=>{r.not={}},wf=(e,t,r,n)=>{},zf=(e,t,r,n)=>{},kf=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},Sf=(e,t,r,n)=>{let o=e._zod.def,i=We(o.entries);i.every(s=>typeof s=="number")&&(r.type="number"),i.every(s=>typeof s=="string")&&(r.type="string"),r.enum=i},Pf=(e,t,r,n)=>{let o=e._zod.def,i=[];for(let s of o.values)if(s===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof s=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(s))}else i.push(s);if(i.length!==0)if(i.length===1){let s=i[0];r.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[s]:r.const=s}else i.every(s=>typeof s=="number")&&(r.type="number"),i.every(s=>typeof s=="string")&&(r.type="string"),i.every(s=>typeof s=="boolean")&&(r.type="boolean"),i.every(s=>s===null)&&(r.type="null"),r.enum=i},Ef=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},If=(e,t,r,n)=>{let o=r,i=e._zod.pattern;if(!i)throw new Error("Pattern not found in template literal");o.type="string",o.pattern=i.source},Af=(e,t,r,n)=>{let o=r,i={type:"string",format:"binary",contentEncoding:"binary"},{minimum:s,maximum:c,mime:a}=e._zod.bag;s!==void 0&&(i.minLength=s),c!==void 0&&(i.maxLength=c),a?a.length===1?(i.contentMediaType=a[0],Object.assign(o,i)):(Object.assign(o,i),o.anyOf=a.map(u=>({contentMediaType:u}))):Object.assign(o,i)},Tf=(e,t,r,n)=>{r.type="boolean"},Rf=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Cf=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},Zf=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Nf=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},jf=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},Of=(e,t,r,n)=>{let o=r,i=e._zod.def,{minimum:s,maximum:c}=e._zod.bag;typeof s=="number"&&(o.minItems=s),typeof c=="number"&&(o.maxItems=c),o.type="array",o.items=P(i.element,t,{...n,path:[...n.path,"items"]})},Lf=(e,t,r,n)=>{let o=r,i=e._zod.def;o.type="object",o.properties={};let s=i.shape;for(let u in s)o.properties[u]=P(s[u],t,{...n,path:[...n.path,"properties",u]});let c=new Set(Object.keys(s)),a=new Set([...c].filter(u=>{let p=i.shape[u]._zod;return t.io==="input"?p.optin===void 0:p.optout===void 0}));a.size>0&&(o.required=Array.from(a)),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=P(i.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},Mf=(e,t,r,n)=>{let o=e._zod.def,i=o.inclusive===!1,s=o.options.map((c,a)=>P(c,t,{...n,path:[...n.path,i?"oneOf":"anyOf",a]}));i?r.oneOf=s:r.anyOf=s},Df=(e,t,r,n)=>{let o=e._zod.def,i=P(o.left,t,{...n,path:[...n.path,"allOf",0]}),s=P(o.right,t,{...n,path:[...n.path,"allOf",1]}),c=u=>"allOf"in u&&Object.keys(u).length===1,a=[...c(i)?i.allOf:[i],...c(s)?s.allOf:[s]];r.allOf=a},Uf=(e,t,r,n)=>{let o=r,i=e._zod.def;o.type="array";let s=t.target==="draft-2020-12"?"prefixItems":"items",c=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",a=i.items.map((h,m)=>P(h,t,{...n,path:[...n.path,s,m]})),u=i.rest?P(i.rest,t,{...n,path:[...n.path,c,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;t.target==="draft-2020-12"?(o.prefixItems=a,u&&(o.items=u)):t.target==="openapi-3.0"?(o.items={anyOf:a},u&&o.items.anyOf.push(u),o.minItems=a.length,u||(o.maxItems=a.length)):(o.items=a,u&&(o.additionalItems=u));let{minimum:p,maximum:d}=e._zod.bag;typeof p=="number"&&(o.minItems=p),typeof d=="number"&&(o.maxItems=d)},Bf=(e,t,r,n)=>{let o=r,i=e._zod.def;o.type="object";let s=i.keyType,a=s._zod.bag?.patterns;if(i.mode==="loose"&&a&&a.size>0){let p=P(i.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let d of a)o.patternProperties[d.source]=p}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(o.propertyNames=P(i.keyType,t,{...n,path:[...n.path,"propertyNames"]})),o.additionalProperties=P(i.valueType,t,{...n,path:[...n.path,"additionalProperties"]});let u=s._zod.values;if(u){let p=[...u].filter(d=>typeof d=="string"||typeof d=="number");p.length>0&&(o.required=p)}},Ff=(e,t,r,n)=>{let o=e._zod.def,i=P(o.innerType,t,n),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=o.innerType,r.nullable=!0):r.anyOf=[i,{type:"null"}]},Jf=(e,t,r,n)=>{let o=e._zod.def;P(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType},Kf=(e,t,r,n)=>{let o=e._zod.def;P(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType,r.default=JSON.parse(JSON.stringify(o.defaultValue))},qf=(e,t,r,n)=>{let o=e._zod.def;P(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},Gf=(e,t,r,n)=>{let o=e._zod.def;P(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=s},Yf=(e,t,r,n)=>{let o=e._zod.def,i=t.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;P(i,t,n);let s=t.seen.get(e);s.ref=i},Hf=(e,t,r,n)=>{let o=e._zod.def;P(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType,r.readOnly=!0},Vf=(e,t,r,n)=>{let o=e._zod.def;P(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType},Wf=(e,t,r,n)=>{let o=e._zod.def;P(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType},Xf=(e,t,r,n)=>{let o=e._zod.innerType;P(o,t,n);let i=t.seen.get(e);i.ref=o},tr={string:mf,number:hf,boolean:gf,bigint:_f,symbol:yf,null:bf,undefined:xf,void:$f,never:vf,any:wf,unknown:zf,date:kf,enum:Sf,literal:Pf,nan:Ef,template_literal:If,file:Af,success:Tf,custom:Rf,function:Cf,transform:Zf,map:Nf,set:jf,array:Of,object:Lf,union:Mf,intersection:Df,tuple:Uf,record:Bf,nullable:Ff,nonoptional:Jf,default:Kf,prefault:qf,catch:Gf,pipe:Yf,readonly:Hf,promise:Vf,optional:Wf,lazy:Xf};function rr(e,t){if("_idmap"in e){let n=e,o=be({...t,processors:tr}),i={};for(let a of n._idmap.entries()){let[u,p]=a;P(p,o)}let s={},c={registry:n,uri:t?.uri,defs:i};o.external=c;for(let a of n._idmap.entries()){let[u,p]=a;xe(o,p),s[u]=$e(o,p)}if(Object.keys(i).length>0){let a=o.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[a]:i}}return{schemas:s}}let r=be({...t,processors:tr});return P(e,r),xe(r,e),$e(r,e)}var nr=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let r=t?.target??"draft-2020-12";r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),this.ctx=be({processors:tr,target:r,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,r={path:[],schemaPath:[]}){return P(t,this.ctx,r)}emit(t,r){r&&(r.cycles&&(this.ctx.cycles=r.cycles),r.reused&&(this.ctx.reused=r.reused),r.external&&(this.ctx.external=r.external)),xe(this.ctx,t);let n=$e(this.ctx,t),{"~standard":o,...i}=n;return i}};var oa={};var k=f("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");v.init(e,t),e.def=t,e.type=t.type,e.parse=(r,n)=>ge(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>Ee(e,r,n),e.parseAsync=async(r,n)=>_e(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>Ie(e,r,n),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]},{parent:!0}),e.with=e.check,e.clone=(r,n)=>F(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.apply=r=>r(e)}),Fe=f("ZodMiniString",(e,t)=>{De.init(e,t),k.init(e,t)});function x(e){return li(Fe,e)}var Z=f("ZodMiniStringFormat",(e,t)=>{T.init(e,t),Fe.init(e,t)}),ia=f("ZodMiniEmail",(e,t)=>{to.init(e,t),Z.init(e,t)});function ed(e){return fi(ia,e)}var sa=f("ZodMiniGUID",(e,t)=>{Qn.init(e,t),Z.init(e,t)});function td(e){return di(sa,e)}var dt=f("ZodMiniUUID",(e,t)=>{eo.init(e,t),Z.init(e,t)});function rd(e){return mi(dt,e)}function nd(e){return hi(dt,e)}function od(e){return gi(dt,e)}function id(e){return _i(dt,e)}var Os=f("ZodMiniURL",(e,t)=>{ro.init(e,t),Z.init(e,t)});function sd(e){return Xt(Os,e)}function cd(e){return Xt(Os,{protocol:/^https?$/,hostname:te.domain,...g(e)})}var ca=f("ZodMiniEmoji",(e,t)=>{no.init(e,t),Z.init(e,t)});function ad(e){return yi(ca,e)}var aa=f("ZodMiniNanoID",(e,t)=>{oo.init(e,t),Z.init(e,t)});function ud(e){return bi(aa,e)}var ua=f("ZodMiniCUID",(e,t)=>{io.init(e,t),Z.init(e,t)});function ld(e){return xi(ua,e)}var la=f("ZodMiniCUID2",(e,t)=>{so.init(e,t),Z.init(e,t)});function pd(e){return $i(la,e)}var pa=f("ZodMiniULID",(e,t)=>{co.init(e,t),Z.init(e,t)});function fd(e){return vi(pa,e)}var fa=f("ZodMiniXID",(e,t)=>{ao.init(e,t),Z.init(e,t)});function dd(e){return wi(fa,e)}var da=f("ZodMiniKSUID",(e,t)=>{uo.init(e,t),Z.init(e,t)});function md(e){return zi(da,e)}var ma=f("ZodMiniIPv4",(e,t)=>{ho.init(e,t),Z.init(e,t)});function hd(e){return ki(ma,e)}var ha=f("ZodMiniIPv6",(e,t)=>{go.init(e,t),Z.init(e,t)});function gd(e){return Si(ha,e)}var ga=f("ZodMiniCIDRv4",(e,t)=>{yo.init(e,t),Z.init(e,t)});function _d(e){return Ei(ga,e)}var _a=f("ZodMiniCIDRv6",(e,t)=>{bo.init(e,t),Z.init(e,t)});function yd(e){return Ii(_a,e)}var ya=f("ZodMiniMAC",(e,t)=>{_o.init(e,t),Z.init(e,t)});function bd(e){return Pi(ya,e)}var ba=f("ZodMiniBase64",(e,t)=>{$o.init(e,t),Z.init(e,t)});function xd(e){return Ai(ba,e)}var xa=f("ZodMiniBase64URL",(e,t)=>{vo.init(e,t),Z.init(e,t)});function $d(e){return Ti(xa,e)}var $a=f("ZodMiniE164",(e,t)=>{wo.init(e,t),Z.init(e,t)});function vd(e){return Ri($a,e)}var va=f("ZodMiniJWT",(e,t)=>{zo.init(e,t),Z.init(e,t)});function wd(e){return Ci(va,e)}var mt=f("ZodMiniCustomStringFormat",(e,t)=>{ko.init(e,t),Z.init(e,t)});function zd(e,t,r={}){return Ue(mt,e,t,r)}function kd(e){return Ue(mt,"hostname",te.hostname,e)}function Sd(e){return Ue(mt,"hex",te.hex,e)}function Pd(e,t){let r=t?.enc??"hex",n=`${e}_${r}`,o=te[n];if(!o)throw new Error(`Unrecognized hash format: ${n}`);return Ue(mt,n,o,t)}var ht=f("ZodMiniNumber",(e,t)=>{Kt.init(e,t),k.init(e,t)});function ve(e){return Mi(ht,e)}var Je=f("ZodMiniNumberFormat",(e,t)=>{So.init(e,t),ht.init(e,t)});function Ed(e){return Ui(Je,e)}function Id(e){return Bi(Je,e)}function Ad(e){return Fi(Je,e)}function Td(e){return Ji(Je,e)}function Rd(e){return Ki(Je,e)}var gt=f("ZodMiniBoolean",(e,t)=>{it.init(e,t),k.init(e,t)});function Ke(e){return qi(gt,e)}var _t=f("ZodMiniBigInt",(e,t)=>{qt.init(e,t),k.init(e,t)});function Cd(e){return Yi(_t,e)}var Ls=f("ZodMiniBigIntFormat",(e,t)=>{Po.init(e,t),_t.init(e,t)});function Zd(e){return Vi(Ls,e)}function Nd(e){return Wi(Ls,e)}var wa=f("ZodMiniSymbol",(e,t)=>{Eo.init(e,t),k.init(e,t)});function jd(e){return Xi(wa,e)}var za=f("ZodMiniUndefined",(e,t)=>{Io.init(e,t),k.init(e,t)});function Od(e){return Qi(za,e)}var ka=f("ZodMiniNull",(e,t)=>{Ao.init(e,t),k.init(e,t)});function Sa(e){return es(ka,e)}var Pa=f("ZodMiniAny",(e,t)=>{To.init(e,t),k.init(e,t)});function Ld(){return ts(Pa)}var Ea=f("ZodMiniUnknown",(e,t)=>{Ro.init(e,t),k.init(e,t)});function or(){return rs(Ea)}var Ia=f("ZodMiniNever",(e,t)=>{Co.init(e,t),k.init(e,t)});function Aa(e){return ns(Ia,e)}var Ta=f("ZodMiniVoid",(e,t)=>{Zo.init(e,t),k.init(e,t)});function Md(e){return os(Ta,e)}var ir=f("ZodMiniDate",(e,t)=>{No.init(e,t),k.init(e,t)});function Dd(e){return is(ir,e)}var Ra=f("ZodMiniArray",(e,t)=>{jo.init(e,t),k.init(e,t)});function K(e,t){return new Ra({type:"array",element:e,...g(t)})}function Ud(e){let t=e._zod.def.shape;return Ba(Object.keys(t))}var sr=f("ZodMiniObject",(e,t)=>{Gt.init(e,t),k.init(e,t),z(e,"shape",()=>t.shape)});function E(e,t){let r={type:"object",shape:e??{},...g(t)};return new sr(r)}function Bd(e,t){return new sr({type:"object",shape:e,catchall:Aa(),...g(t)})}function Fd(e,t){return new sr({type:"object",shape:e,catchall:or(),...g(t)})}function yt(e,t){return Tt(e,t)}function Jd(e,t){return Br(e,t)}function Kd(e,t){return Tt(e,t)}function qd(e,t){return Dr(e,t)}function Gd(e,t){return Ur(e,t)}function Yd(e,t){return Fr(Us,e,t)}function Hd(e,t){return Jr(Bs,e,t)}function Vd(e,t){return e.clone({...e._zod.def,catchall:t})}var Ms=f("ZodMiniUnion",(e,t)=>{st.init(e,t),k.init(e,t)});function Ca(e,t){return new Ms({type:"union",options:e,...g(t)})}var Za=f("ZodMiniXor",(e,t)=>{Ms.init(e,t),Oo.init(e,t)});function Wd(e,t){return new Za({type:"union",options:e,inclusive:!1,...g(t)})}var Na=f("ZodMiniDiscriminatedUnion",(e,t)=>{Lo.init(e,t),k.init(e,t)});function Xd(e,t,r){return new Na({type:"union",options:t,discriminator:e,...g(r)})}var ja=f("ZodMiniIntersection",(e,t)=>{Mo.init(e,t),k.init(e,t)});function Qd(e,t){return new ja({type:"intersection",left:e,right:t})}var Oa=f("ZodMiniTuple",(e,t)=>{Yt.init(e,t),k.init(e,t)});function La(e,t,r){let n=t instanceof v,o=n?r:t,i=n?t:null;return new Oa({type:"tuple",items:e,rest:i,...g(o)})}var cr=f("ZodMiniRecord",(e,t)=>{Do.init(e,t),k.init(e,t)});function Ma(e,t,r){return new cr({type:"record",keyType:e,valueType:t,...g(r)})}function em(e,t,r){let n=F(e);return n._zod.values=void 0,new cr({type:"record",keyType:n,valueType:t,...g(r)})}function tm(e,t,r){return new cr({type:"record",keyType:e,valueType:t,mode:"loose",...g(r)})}var Da=f("ZodMiniMap",(e,t)=>{Uo.init(e,t),k.init(e,t)});function rm(e,t,r){return new Da({type:"map",keyType:e,valueType:t,...g(r)})}var Ua=f("ZodMiniSet",(e,t)=>{Bo.init(e,t),k.init(e,t)});function nm(e,t){return new Ua({type:"set",valueType:e,...g(t)})}var Ds=f("ZodMiniEnum",(e,t)=>{Fo.init(e,t),k.init(e,t),e.options=Object.values(t.entries)});function Ba(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Ds({type:"enum",entries:r,...g(t)})}function om(e,t){return new Ds({type:"enum",entries:e,...g(t)})}var Fa=f("ZodMiniLiteral",(e,t)=>{Jo.init(e,t),k.init(e,t)});function im(e,t){return new Fa({type:"literal",values:Array.isArray(e)?e:[e],...g(t)})}var Ja=f("ZodMiniFile",(e,t)=>{Ko.init(e,t),k.init(e,t)});function sm(e){return Is(Ja,e)}var Ka=f("ZodMiniTransform",(e,t)=>{qo.init(e,t),k.init(e,t)});function cm(e){return new Ka({type:"transform",transform:e})}var Us=f("ZodMiniOptional",(e,t)=>{Ht.init(e,t),k.init(e,t)});function $(e){return new Us({type:"optional",innerType:e})}var qa=f("ZodMiniExactOptional",(e,t)=>{Go.init(e,t),k.init(e,t)});function am(e){return new qa({type:"optional",innerType:e})}var Ga=f("ZodMiniNullable",(e,t)=>{Yo.init(e,t),k.init(e,t)});function ar(e){return new Ga({type:"nullable",innerType:e})}function um(e){return $(ar(e))}var Ya=f("ZodMiniDefault",(e,t)=>{Ho.init(e,t),k.init(e,t)});function lm(e,t){return new Ya({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Oe(t)}})}var Ha=f("ZodMiniPrefault",(e,t)=>{Vo.init(e,t),k.init(e,t)});function pm(e,t){return new Ha({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Oe(t)}})}var Bs=f("ZodMiniNonOptional",(e,t)=>{Wo.init(e,t),k.init(e,t)});function fm(e,t){return new Bs({type:"nonoptional",innerType:e,...g(t)})}var Va=f("ZodMiniSuccess",(e,t)=>{Xo.init(e,t),k.init(e,t)});function dm(e){return new Va({type:"success",innerType:e})}var Wa=f("ZodMiniCatch",(e,t)=>{Qo.init(e,t),k.init(e,t)});function mm(e,t){return new Wa({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var Xa=f("ZodMiniNaN",(e,t)=>{ei.init(e,t),k.init(e,t)});function hm(e){return cs(Xa,e)}var Fs=f("ZodMiniPipe",(e,t)=>{ti.init(e,t),k.init(e,t)});function gm(e,t){return new Fs({type:"pipe",in:e,out:t})}var Js=f("ZodMiniCodec",(e,t)=>{Fs.init(e,t),ct.init(e,t)});function _m(e,t,r){return new Js({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}var Qa=f("ZodMiniReadonly",(e,t)=>{ri.init(e,t),k.init(e,t)});function ym(e){return new Qa({type:"readonly",innerType:e})}var eu=f("ZodMiniTemplateLiteral",(e,t)=>{ni.init(e,t),k.init(e,t)});function bm(e,t){return new eu({type:"template_literal",parts:e,...g(t)})}var tu=f("ZodMiniLazy",(e,t)=>{si.init(e,t),k.init(e,t)});function ru(e){return new tu({type:"lazy",getter:e})}var nu=f("ZodMiniPromise",(e,t)=>{ii.init(e,t),k.init(e,t)});function xm(e){return new nu({type:"promise",innerType:e})}var Ks=f("ZodMiniCustom",(e,t)=>{ci.init(e,t),k.init(e,t)});function $m(e,t){let r=new C({check:"custom",...g(t)});return r._zod.check=e,r}function ou(e,t){return As(Ks,e??(()=>!0),t)}function vm(e,t={}){return Ts(Ks,e,t)}function wm(e){return Rs(e)}var zm=Cs,km=Zs;function Sm(e,t={}){let r=ou(n=>n instanceof e,t);return r._zod.bag.Class=e,r._zod.check=n=>{n.value instanceof e||n.issues.push({code:"invalid_type",expected:e.name,input:n.value,inst:r,path:[...r._zod.def.path??[]]})},r}var Pm=(...e)=>Ns({Codec:Js,Boolean:gt,String:Fe},...e);function Em(){let e=ru(()=>Ca([x(),ve(),Ke(),Sa(),K(e),Ma(x(),e)]));return e}var iu=f("ZodMiniFunction",(e,t)=>{oi.init(e,t),k.init(e,t)});function Im(e){return new iu({type:"function",input:Array.isArray(e?.input)?La(e?.input):e?.input??K(or()),output:e?.output??or()})}var qs={};Se(qs,{ZodMiniISODate:()=>lr,ZodMiniISODateTime:()=>ur,ZodMiniISODuration:()=>fr,ZodMiniISOTime:()=>pr,date:()=>Tm,datetime:()=>Am,duration:()=>Cm,time:()=>Rm});var ur=f("ZodMiniISODateTime",(e,t)=>{lo.init(e,t),Z.init(e,t)});function Am(e){return Ni(ur,e)}var lr=f("ZodMiniISODate",(e,t)=>{po.init(e,t),Z.init(e,t)});function Tm(e){return ji(lr,e)}var pr=f("ZodMiniISOTime",(e,t)=>{fo.init(e,t),Z.init(e,t)});function Rm(e){return Oi(pr,e)}var fr=f("ZodMiniISODuration",(e,t)=>{mo.init(e,t),Z.init(e,t)});function Cm(e){return Li(fr,e)}var Gs={};Se(Gs,{bigint:()=>Om,boolean:()=>jm,date:()=>Lm,number:()=>Nm,string:()=>Zm});function Zm(e){return pi(Fe,e)}function Nm(e){return Di(ht,e)}function jm(e){return Gi(gt,e)}function Om(e){return Hi(_t,e)}function Lm(e){return ss(ir,e)}var Te=x().check(pt(1)),Mm=x().check(ft(/^https?:\/\/.+/)),Hs=E({CLANCY_BASE_BRANCH:$(x()),CLANCY_LABEL:$(x()),CLANCY_MODEL:$(x()),CLANCY_NOTIFY_WEBHOOK:$(x()),CLANCY_STATUS_IN_PROGRESS:$(x()),CLANCY_STATUS_DONE:$(x()),CLANCY_STATUS_REVIEW:$(x()),MAX_ITERATIONS:$(x()),PLAYWRIGHT_ENABLED:$(x()),PLAYWRIGHT_DEV_PORT:$(x()),CLANCY_ROLES:$(x()),CLANCY_PLAN_STATUS:$(x()),CLANCY_PLAN_LABEL:$(x()),CLANCY_PLAN_STATE_TYPE:$(x()),CLANCY_STATUS_PLANNED:$(x()),CLANCY_SKIP_COMMENTS:$(x()),GITHUB_TOKEN:$(x()),GITLAB_TOKEN:$(x()),BITBUCKET_USER:$(x()),BITBUCKET_TOKEN:$(x()),CLANCY_GIT_PLATFORM:$(x()),CLANCY_GIT_API_URL:$(x()),CLANCY_MAX_REWORK:$(x()),CLANCY_TDD:$(x()),CLANCY_MODE:$(x()),CLANCY_BRIEF_ISSUE_TYPE:$(x()),CLANCY_BRIEF_EPIC:$(x()),CLANCY_COMPONENT:$(x()),CLANCY_FIX_RETRIES:$(x()),CLANCY_VERIFY_COMMANDS:$(x()),CLANCY_TOKEN_RATE:$(x()),CLANCY_TIME_LIMIT:$(x()),CLANCY_BRANCH_GUARD:$(x())}),cu=yt(Hs,{JIRA_BASE_URL:Mm,JIRA_USER:Te,JIRA_API_TOKEN:Te,JIRA_PROJECT_KEY:Te,CLANCY_JQL_STATUS:$(x()),CLANCY_JQL_SPRINT:$(x())}),au=yt(Hs,{GITHUB_TOKEN:Te,GITHUB_REPO:Te}),uu=yt(Hs,{LINEAR_API_KEY:Te,LINEAR_TEAM_ID:Te});function Vs(e){if(e.JIRA_BASE_URL){let t=cu.safeParse(e);return t.success?{provider:"jira",env:t.data}:`\u2717 Jira env validation failed: ${t.error.message}`}if(e.GITHUB_TOKEN&&e.GITHUB_REPO){let t=au.safeParse(e);return t.success?{provider:"github",env:t.data}:`\u2717 GitHub env validation failed: ${t.error.message}`}if(e.LINEAR_API_KEY){let t=uu.safeParse(e);return t.success?{provider:"linear",env:t.data}:`\u2717 Linear env validation failed: ${t.error.message}`}return"\u2717 No board detected \u2014 set Jira, GitHub, or Linear credentials in .clancy/.env"}function Dm(e){return["You are evaluating whether a ticket can be implemented as pure code changes in a repository.","",`Ticket: [${e.key}] ${e.title}`,"Description:",e.description,"","Can this ticket be completed entirely through code changes committed to a git repository?","","Answer INFEASIBLE if the ticket requires ANY of:","- Manual testing or configuration in external tools or admin panels","- Access to external services, APIs, or platforms not available in the codebase","- Physical, hardware, or infrastructure changes","- Design assets that do not yet exist","- Deployment or infrastructure changes outside the repository","- Human judgment calls that require stakeholder input","","Answer with exactly one line in this format:","FEASIBLE","or","INFEASIBLE: one-line reason","","Do not include any other text."].join(`
|
|
41
|
+
`)}function Um(e){let t=e.trim().split(`
|
|
42
|
+
`).pop()?.trim()??"";return/^INFEASIBLE/i.test(t)?{feasible:!1,reason:t.replace(/^INFEASIBLE:?\s*/i,"").trim()||void 0}:{feasible:!0}}function lu(e,t){let r=Dm(e),{stdout:n,ok:o}=bc(r,t);return o?Um(n):{feasible:!0}}function bt(e){let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let r=Math.floor(t/60),n=t%60;if(r<60)return n>0?`${r}m ${n}s`:`${r}m`;let o=Math.floor(r/60),i=r%60;return i>0?`${o}h ${i}m`:`${o}h`}import{execFileSync as we}from"node:child_process";function Ws(...e){return we("git",e,{encoding:"utf8"}).trim()}function pu(){return Ws("rev-parse","--abbrev-ref","HEAD")}function dr(){try{return we("git",["diff","--quiet"],{stdio:"ignore"}),we("git",["diff","--cached","--quiet"],{stdio:"ignore"}),!1}catch{return!0}}function xt(e){try{return we("git",["show-ref","--verify","--quiet",`refs/heads/${e}`],{stdio:"ignore"}),!0}catch{return!1}}function Xs(e,t){xt(e)||Ws("checkout","-b",e,t)}function L(e,t=!1){Ws("checkout",...t?["-B"]:[],e)}function fu(e){try{return we("git",["ls-remote","--heads","origin",e],{encoding:"utf8",timeout:15e3}).trim().length>0}catch{return!1}}function mr(e){try{return we("git",["fetch","origin",`${e}:${e}`],{encoding:"utf8",stdio:["pipe","pipe","pipe"]}),!0}catch{return!1}}function du(e,t=8e3){try{let r=we("git",["diff",`${e}...HEAD`,"--stat"],{encoding:"utf8",timeout:1e4}).trim();return r?r.length>t?r.slice(0,t)+`
|
|
43
|
+
... (truncated)`:r:void 0}catch{return}}function $t(e){try{return we("git",["push","-u","origin",e],{encoding:"utf8",stdio:["pipe","pipe","pipe"]}),!0}catch{return!1}}function Bm(e){return e.includes("hooks.slack.com")}function Fm(e){return JSON.stringify({text:e})}function Jm(e){return JSON.stringify({type:"message",attachments:[{contentType:"application/vnd.microsoft.card.adaptive",content:{$schema:"http://adaptivecards.io/schemas/adaptive-card.json",type:"AdaptiveCard",version:"1.4",body:[{type:"TextBlock",text:e,wrap:!0}]}}]})}async function mu(e,t){let r=Bm(e)?Fm(t):Jm(t);try{let n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:r});n.ok||console.warn(`\u26A0 Notification failed: HTTP ${n.status}`)}catch{console.warn("\u26A0 Notification failed: could not reach webhook")}}import{execFileSync as Qs}from"node:child_process";import{existsSync as Km,readFileSync as qm}from"node:fs";import{join as Gm}from"node:path";function Ym(e){let t={};for(let r of e.split(`
|
|
44
|
+
`)){let n=r.trim();if(!n||n.startsWith("#"))continue;let o=n.indexOf("=");if(o===-1)continue;let i=n.slice(0,o).trim(),s=n.slice(o+1).trim();s.length>=2&&(s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'"))&&(s=s.slice(1,-1)),t[i]=s}return t}function hu(e){let t=Gm(e,".clancy",".env");if(!Km(t))return;let r=qm(t,"utf8");return Ym(r)}function Hm(e){try{return Qs("which",[e],{stdio:"ignore"}),!0}catch{return!1}}function Vm(){try{return Qs("git",["rev-parse","--git-dir"],{stdio:"ignore"}),!0}catch{return!1}}function ec(e){for(let n of["claude","git"])if(!Hm(n))return{ok:!1,error:`\u2717 ${n} is required but not found`};let t=hu(e);if(!t)return{ok:!1,error:"\u2717 .clancy/.env not found \u2014 run /clancy:init first"};if(!Vm())return{ok:!1,error:"\u2717 Not inside a git repository"};let r;try{Qs("git",["ls-remote","origin","HEAD"],{encoding:"utf8",timeout:5e3,stdio:["pipe","pipe","pipe"]})}catch{r="\u26A0 Could not reach origin. PR creation and rework detection may not work."}if(dr()){let n="\u26A0 Working directory has uncommitted changes \u2014 they will be included in the branch";r=r?`${r}
|
|
45
|
+
${n}`:n}return{ok:!0,env:t,warning:r}}import{appendFileSync as gu,mkdirSync as Wm,readFileSync as Xm}from"node:fs";import{dirname as Qm,join as _u}from"node:path";function eh(e){let t=e.getUTCFullYear(),r=String(e.getUTCMonth()+1).padStart(2,"0"),n=String(e.getUTCDate()).padStart(2,"0"),o=String(e.getUTCHours()).padStart(2,"0"),i=String(e.getUTCMinutes()).padStart(2,"0");return`${t}-${r}-${n} ${o}:${i}`}function M(e,t,r,n,o,i){let s=_u(e,".clancy","progress.txt");Wm(Qm(s),{recursive:!0});let c=eh(new Date);if(n==="BRIEF"||n==="APPROVE_BRIEF"){let d=`${c} | ${n} | ${t} | ${r}
|
|
46
|
+
`;gu(s,d,"utf8");return}let a=o!=null?` | pr:${o}`:"",u=i?` | parent:${i}`:"",p=`${c} | ${t} | ${r} | ${n}${a}${u}
|
|
47
|
+
`;gu(s,p,"utf8")}function yu(e){let t=_u(e,".clancy","progress.txt"),r;try{r=Xm(t,"utf8")}catch{return[]}let n=[];for(let o of r.split(`
|
|
48
|
+
`)){let i=o.trim();if(!i)continue;let s=i.split(" | ");if(s.length<4)continue;let c=s[0];if(s[1]==="BRIEF"||s[1]==="APPROVE_BRIEF"){n.push({timestamp:c,key:s[2],summary:s.slice(3).join(" | "),status:s[1]});continue}let a=s[1],u,p,d,h=[];for(let m=2;m<s.length;m++){let _=s[m],y=_.match(/^pr:(\d+)$/),S=_.match(/^parent:(.+)$/);y?p=parseInt(y[1],10):S?d=S[1]:m>=3&&!u&&_===_.toUpperCase()&&_.length>1?u=_:h.push(_)}u&&(u==="APPROVE"&&(u="APPROVE_PLAN"),n.push({timestamp:c,key:a,summary:h.join(" | "),status:u,...p!=null&&{prNumber:p},...d!=null&&{parent:d}}))}return n}function bu(e,t){let r=yu(e),n=t.toLowerCase(),o=0;for(let i of r)i.key.toLowerCase()===n&&i.status==="REWORK"&&o++;return o}function q(e,t){let r=yu(e),n=new Map;for(let o of r)n.set(o.key,o);return[...n.values()].filter(o=>o.status===t)}var xu=`
|
|
49
49
|
## Test-Driven Development
|
|
50
50
|
|
|
51
51
|
You MUST follow the red-green-refactor cycle for every behaviour change:
|
|
@@ -59,7 +59,7 @@ You MUST follow the red-green-refactor cycle for every behaviour change:
|
|
|
59
59
|
|
|
60
60
|
Repeat for each behaviour. Do not write implementation code without a failing test first.
|
|
61
61
|
Design interfaces for testability \u2014 prefer pure functions and thin boundaries
|
|
62
|
-
so modules are easy to test in isolation.`;function
|
|
62
|
+
so modules are easy to test in isolation.`;function th(e){switch(e){case"jira":return"Jira ticket";case"github":return"GitHub Issue";case"linear":return"Linear issue"}}function rh(e){return e==="github"?"Milestone":"Epic"}function $u(e){let t=e.feedbackComments.length>0?e.feedbackComments.map((n,o)=>`${o+1}. ${n}`).join(`
|
|
63
63
|
`):"No reviewer comments found. Review the existing implementation and fix any issues.",r=e.previousContext?`
|
|
64
64
|
|
|
65
65
|
## Previous Implementation
|
|
@@ -75,7 +75,7 @@ ${e.description}
|
|
|
75
75
|
|
|
76
76
|
${t}${r}
|
|
77
77
|
|
|
78
|
-
Address the specific feedback above. Don't re-implement unrelated areas. Focus only on what was flagged.${e.tdd?
|
|
78
|
+
Address the specific feedback above. Don't re-implement unrelated areas. Focus only on what was flagged.${e.tdd?xu:""}
|
|
79
79
|
|
|
80
80
|
Steps:
|
|
81
81
|
1. Read core docs in .clancy/docs/: STACK.md, ARCHITECTURE.md, CONVENTIONS.md, GIT.md, DEFINITION-OF-DONE.md, CONCERNS.md
|
|
@@ -83,7 +83,7 @@ Steps:
|
|
|
83
83
|
2. Follow the conventions in GIT.md exactly
|
|
84
84
|
3. Fix the issues identified in the reviewer feedback
|
|
85
85
|
4. Commit your work following the conventions in GIT.md
|
|
86
|
-
5. When done, confirm you are finished.`}function
|
|
86
|
+
5. When done, confirm you are finished.`}function vu(e){let t=th(e.provider),r=rh(e.provider),n=e.blockers&&e.provider!=="github"?`
|
|
87
87
|
Blockers: ${e.blockers}`:"";return`You are implementing ${t} ${e.key}.
|
|
88
88
|
|
|
89
89
|
${e.provider==="github"?"Title":"Summary"}: ${e.title}
|
|
@@ -103,13 +103,13 @@ If you must SKIP this ${e.provider==="github"?"issue":"ticket"}:
|
|
|
103
103
|
3. Append to .clancy/progress.txt: YYYY-MM-DD HH:MM | ${e.key} | {reason} | SKIPPED
|
|
104
104
|
4. Stop \u2014 no branches, no file changes, no git operations.
|
|
105
105
|
|
|
106
|
-
If the ${e.provider==="github"?"issue":"ticket"} IS implementable, continue:${e.tdd?
|
|
106
|
+
If the ${e.provider==="github"?"issue":"ticket"} IS implementable, continue:${e.tdd?xu:""}
|
|
107
107
|
1. Read core docs in .clancy/docs/: STACK.md, ARCHITECTURE.md, CONVENTIONS.md, GIT.md, DEFINITION-OF-DONE.md, CONCERNS.md
|
|
108
108
|
Also read if relevant to this ticket: INTEGRATIONS.md (external APIs/services/auth), TESTING.md (tests/specs/coverage), DESIGN-SYSTEM.md (UI/components/styles), ACCESSIBILITY.md (accessibility/ARIA/WCAG)
|
|
109
109
|
2. Follow the conventions in GIT.md exactly
|
|
110
110
|
3. Implement the ${e.provider==="github"?"issue":"ticket"} fully
|
|
111
111
|
4. Commit your work following the conventions in GIT.md
|
|
112
|
-
5. When done, confirm you are finished.`}var k=e=>`\x1B[2m${e}\x1B[0m`,lr=e=>`\x1B[1m${e}\x1B[0m`;var oe=e=>`\x1B[32m${e}\x1B[0m`,Je=e=>`\x1B[31m${e}\x1B[0m`,C=e=>`\x1B[33m${e}\x1B[0m`;var Fm=l.object({number:l.number(),title:l.string(),body:l.optional(l.nullable(l.string())),pull_request:l.optional(l.unknown()),milestone:l.optional(l.nullable(l.object({title:l.string()}))),labels:l.optional(l.array(l.object({name:l.optional(l.string())})))}),mu=l.array(Fm),Jm=l.object({id:l.number(),body:l.optional(l.nullable(l.string())),created_at:l.string(),user:l.optional(l.object({login:l.string()}))}),Ys=l.array(Jm),qm=l.object({number:l.number(),html_url:l.string(),state:l.string()}),hu=l.array(qm),Gm=l.object({state:l.string(),user:l.object({login:l.string()}),submitted_at:l.string()}),gu=l.array(Gm),Ym=l.object({body:l.optional(l.nullable(l.string())),path:l.optional(l.string()),created_at:l.optional(l.string()),user:l.optional(l.object({login:l.string()}))}),Hs=l.array(Ym);var V="https://api.github.com";async function pr(e,t,r,n){try{let o=new AbortController,i=setTimeout(()=>o.abort(),1e4),s=await fetch(e,{headers:t,signal:o.signal});if(clearTimeout(i),s.ok)return{ok:!0};let c=r[s.status];return c?{ok:!1,error:c}:{ok:!1,error:`\u2717 HTTP ${s.status}`}}catch{return{ok:!1,error:n}}}function ee(e){return{Authorization:`Bearer ${e}`,Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28"}}function $e(e){return{Authorization:`Basic ${e}`,Accept:"application/json"}}var Hm=l.object({login:l.string()}),Km=/^[a-zA-Z0-9_.-]+\/[a-zA-Z0-9_.-]+$/,fr;function dr(e){return Km.test(e)}async function bu(e,t){return pr(`${V}/repos/${t}`,ee(e),{401:"\u2717 GitHub auth failed \u2014 check GITHUB_TOKEN",403:"\u2717 GitHub permission denied",404:`\u2717 GitHub repo "${t}" not found`},"\u2717 Could not reach GitHub \u2014 check network")}async function mr(e,t){if(fr)return fr;try{let r=await fetch(`${t??V}/user`,{headers:ee(e)});if(!r.ok){let i=r.status===401||r.status===403?' Fine-grained PATs need "Account permissions \u2192 read" (or classic PATs need read:user scope).':"";return console.warn(`\u26A0 GitHub /user returned HTTP ${r.status} \u2014 falling back to @me.${i}`),"@me"}let n=await r.json(),o=Hm.safeParse(n);if(o.success)return fr=o.data.login,fr;console.warn("\u26A0 Unexpected GitHub /user response \u2014 falling back to @me")}catch(r){console.warn(`\u26A0 GitHub /user request failed: ${r instanceof Error?r.message:String(r)} \u2014 falling back to @me`)}return"@me"}async function yu(e,t,r,n,o,i=5){let s,c=new URLSearchParams({state:"open",assignee:n??"@me",per_page:"10"});r&&c.set("labels",r);try{s=await fetch(`${V}/repos/${t}/issues?${c}`,{headers:ee(e)})}catch(d){return console.warn(`\u26A0 GitHub API request failed: ${d instanceof Error?d.message:String(d)}`),[]}if(!s.ok)return console.warn(`\u26A0 GitHub API returned HTTP ${s.status}`),[];let a;try{a=await s.json()}catch{return console.warn("\u26A0 GitHub API returned invalid JSON"),[]}let u=mu.safeParse(a);if(!u.success)return console.warn(`\u26A0 Unexpected GitHub response shape: ${u.error.message}`),[];let p=u.data.filter(d=>!d.pull_request);return o&&(p=p.filter(d=>!d.labels?.some(m=>m.name==="clancy:hitl"))),p.slice(0,i).map(d=>({key:`#${d.number}`,title:d.title,description:d.body??"",provider:"github",milestone:d.milestone?.title}))}async function xu(e,t,r,n){if(!dr(t))return!1;let o=/Blocked by #(\d+)/gi,i=new Set,s;for(;(s=o.exec(n))!==null;){let c=parseInt(s[1],10);!Number.isNaN(c)&&c!==r&&i.add(c)}if(!i.size)return!1;try{for(let c of i){let a=await fetch(`${V}/repos/${t}/issues/${c}`,{headers:ee(e)});if(!a.ok)continue;if((await a.json()).state!=="closed")return!0}return!1}catch{return!1}}async function $u(e,t,r){if(dr(t))try{let n=await _u(e,t,`Epic: #${r}`);return n&&n.total>0?n:await _u(e,t,`Parent: #${r}`)}catch{return}}async function _u(e,t,r){let n=ee(e),o=`"${r}" repo:${t} is:issue`,i=new URLSearchParams({q:o,per_page:"1"}),s=await fetch(`${V}/search/issues?${i}`,{headers:n});if(!s.ok)return;let a=(await s.json()).total_count??0;if(a===0)return{total:0,incomplete:0};let u=`"${r}" repo:${t} is:issue is:open`,p=new URLSearchParams({q:u,per_page:"1"}),d=await fetch(`${V}/search/issues?${p}`,{headers:n});if(!d.ok)return{total:a,incomplete:a};let h=(await d.json()).total_count??0;return{total:a,incomplete:h}}var Vm=l.object({type:l.optional(l.object({name:l.optional(l.string())})),inwardIssue:l.optional(l.object({key:l.optional(l.string())}))}),Wm=l.object({summary:l.string(),description:l.optional(l.unknown()),issuelinks:l.optional(l.array(Vm)),parent:l.optional(l.object({key:l.optional(l.string())})),customfield_10014:l.optional(l.nullable(l.string()))}),Xm=l.object({key:l.string(),fields:Wm}),vu=l.object({total:l.optional(l.number()),isLast:l.optional(l.boolean()),issues:l.array(Xm)}),Qm=l.object({id:l.string(),name:l.string()}),wu=l.object({transitions:l.array(Qm)}),eh=l.object({type:l.optional(l.object({name:l.optional(l.string())})),inwardIssue:l.optional(l.object({key:l.optional(l.string()),fields:l.optional(l.object({status:l.optional(l.object({statusCategory:l.optional(l.object({key:l.optional(l.string())}))}))}))}))}),zu=l.object({fields:l.optional(l.object({issuelinks:l.optional(l.array(eh))}))});var th=/^[a-zA-Z0-9 _\-'.]+$/,Ks=/^[A-Z][A-Z0-9]+-\d+$/;function Ie(e,t){return Buffer.from(`${e}:${t}`).toString("base64")}function hr(e){return th.test(e)}async function Su(e,t,r){return pr(`${e}/rest/api/3/project/${t}`,$e(r),{401:"\u2717 Jira auth failed \u2014 check credentials",403:"\u2717 Jira permission denied for this project",404:`\u2717 Jira project "${t}" not found`},"\u2717 Could not reach Jira \u2014 check network")}function rh(e,t,r,n,o){let i=[`project="${e}"`];return r&&i.push("sprint in openSprints()"),n&&i.push(`labels = "${n}"`),o&&i.push('labels != "clancy:hitl"'),i.push("assignee=currentUser()"),i.push(`status="${t}"`),i.join(" AND ")+" ORDER BY priority ASC"}function nh(e){if(!e||typeof e!="object")return"";let t=[];function r(n){if(typeof n=="string"){t.push(n);return}if(Array.isArray(n)){for(let o of n)r(o);return}if(n&&typeof n=="object")for(let o of Object.values(n))r(o)}return r(e),t.join(" ")}async function Pu(e,t,r,n,o,i,s,c=5){let a=rh(r,n,o,i,s),u;try{u=await fetch(`${e}/rest/api/3/search/jql`,{method:"POST",headers:{...$e(t),"Content-Type":"application/json"},body:JSON.stringify({jql:a,maxResults:c,fields:["summary","description","issuelinks","parent","customfield_10014"]})})}catch(m){return console.warn(`\u26A0 Jira API request failed: ${m instanceof Error?m.message:String(m)}`),[]}if(!u.ok)return console.warn(`\u26A0 Jira API returned HTTP ${u.status}`),[];let p;try{p=await u.json()}catch{return console.warn("\u26A0 Jira API returned invalid JSON"),[]}let d=vu.safeParse(p);return d.success?d.data.issues.map(m=>{let h=m.fields,b=(h.issuelinks??[]).filter(v=>v.type?.name==="Blocks"&&v.inwardIssue?.key).map(v=>v.inwardIssue?.key).filter(v=>!!v),g=h.parent?.key??h.customfield_10014??void 0;return{key:m.key,title:h.summary,description:nh(h.description),provider:"jira",epicKey:g,blockers:b}}):(console.warn(`\u26A0 Unexpected Jira response shape: ${d.error.message}`),[])}async function Eu(e,t,r){if(!Ks.test(r))return!1;try{let n=await fetch(`${e}/rest/api/3/issue/${r}?fields=issuelinks`,{headers:$e(t)});if(!n.ok)return!1;let o=await n.json(),i=zu.safeParse(o);return i.success?(i.data.fields?.issuelinks??[]).some(c=>{if(c.type?.name!=="Blocks"||!c.inwardIssue?.key)return!1;let a=c.inwardIssue.fields?.status?.statusCategory?.key;return a?a!=="done":!1}):!1}catch{return!1}}async function Iu(e,t,r){if(Ks.test(r))try{let n=r.split("-")[0],o=await ku(e,t,`project = "${n}" AND description ~ "Epic: ${r}"`);return o&&o.total>0?o:await ku(e,t,`parent = ${r}`)}catch{return}}async function ku(e,t,r){let n=await fetch(`${e}/rest/api/3/search/jql`,{method:"POST",headers:{...$e(t),"Content-Type":"application/json"},body:JSON.stringify({jql:r,maxResults:0})});if(!n.ok)return;let i=(await n.json()).total??0;if(i===0)return{total:0,incomplete:0};let s=await fetch(`${e}/rest/api/3/search/jql`,{method:"POST",headers:{...$e(t),"Content-Type":"application/json"},body:JSON.stringify({jql:`${r} AND statusCategory != "done"`,maxResults:0})});if(!s.ok)return;let a=(await s.json()).total??0;return{total:i,incomplete:a}}async function oh(e,t,r,n){if(!Ks.test(r))return;let o;try{o=await fetch(`${e}/rest/api/3/issue/${r}/transitions`,{headers:$e(t)})}catch(a){console.warn(`\u26A0 Jira transitions request failed: ${a instanceof Error?a.message:String(a)}`);return}if(!o.ok)return;let i;try{i=await o.json()}catch{console.warn("\u26A0 Jira transitions returned invalid JSON");return}let s=wu.safeParse(i);if(!s.success){console.warn(`\u26A0 Unexpected Jira transitions response: ${s.error.message}`);return}return s.data.transitions.find(a=>a.name===n)?.id}async function Tu(e,t,r,n){try{let o=await oh(e,t,r,n);return o?(await fetch(`${e}/rest/api/3/issue/${r}/transitions`,{method:"POST",headers:{...$e(t),"Content-Type":"application/json"},body:JSON.stringify({transition:{id:o}})})).ok:(console.warn(`\u26A0 Jira transition "${n}" not found for ${r}`),!1)}catch{return!1}}var ih=l.object({id:l.string(),identifier:l.string(),title:l.string(),description:l.optional(l.nullable(l.string())),parent:l.optional(l.nullable(l.object({identifier:l.string(),title:l.optional(l.string())}))),labels:l.optional(l.object({nodes:l.array(l.object({name:l.string()}))}))}),Au=l.object({data:l.optional(l.object({viewer:l.optional(l.object({assignedIssues:l.optional(l.object({nodes:l.array(ih)}))}))}))}),Ru=l.object({data:l.optional(l.object({viewer:l.optional(l.object({id:l.optional(l.string())}))}))}),Zu=l.object({data:l.optional(l.object({workflowStates:l.optional(l.object({nodes:l.array(l.object({id:l.string()}))}))}))}),Cu=l.object({data:l.optional(l.object({issueUpdate:l.optional(l.object({success:l.optional(l.boolean())}))}))}),sh=l.object({type:l.string(),relatedIssue:l.optional(l.object({state:l.optional(l.object({type:l.optional(l.string())}))}))}),Nu=l.object({data:l.optional(l.object({issue:l.optional(l.object({relations:l.optional(l.object({nodes:l.array(sh)}))}))}))}),ch=l.object({state:l.optional(l.object({type:l.optional(l.string())}))}),ju=l.object({data:l.optional(l.object({issueSearch:l.optional(l.object({nodes:l.array(ch)}))}))});var ah=/^[a-zA-Z0-9_-]+$/,Ou="https://api.linear.app/graphql";function Lu(e){return ah.test(e)}async function qe(e,t,r){let n;try{n=await fetch(Ou,{method:"POST",headers:{Authorization:e,"Content-Type":"application/json"},body:JSON.stringify({query:t,variables:r})})}catch(o){console.warn(`\u26A0 Linear API request failed: ${o instanceof Error?o.message:String(o)}`);return}if(!n.ok){console.warn(`\u26A0 Linear API returned HTTP ${n.status}`);return}try{return await n.json()}catch{console.warn("\u26A0 Linear API returned invalid JSON");return}}async function Mu(e){let t;try{t=await fetch(Ou,{method:"POST",headers:{Authorization:e,"Content-Type":"application/json"},body:JSON.stringify({query:"{ viewer { id } }"})})}catch{return{ok:!1,error:"\u2717 Could not reach Linear \u2014 check network"}}if(!t.ok)return t.status===401||t.status===403?{ok:!1,error:"\u2717 Linear auth failed \u2014 check LINEAR_API_KEY"}:{ok:!1,error:`\u2717 Linear API returned HTTP ${t.status}`};try{let r=await t.json(),n=Ru.safeParse(r);if(n.success&&n.data.data?.viewer?.id)return{ok:!0}}catch{}return{ok:!1,error:"\u2717 Linear auth failed \u2014 check LINEAR_API_KEY"}}async function Du(e,t,r=5){let n=e.CLANCY_LABEL?.trim(),o=!!n,i=o?"labels: { name: { eq: $label } }":"",s=["$teamId: String!",...o?["$label: String!"]:[]],c=['state: { type: { eq: "unstarted" } }',"team: { id: { eq: $teamId } }",i].filter(Boolean),a=`
|
|
112
|
+
5. When done, confirm you are finished.`}var w=e=>`\x1B[2m${e}\x1B[0m`,hr=e=>`\x1B[1m${e}\x1B[0m`;var U=e=>`\x1B[32m${e}\x1B[0m`,qe=e=>`\x1B[31m${e}\x1B[0m`,R=e=>`\x1B[33m${e}\x1B[0m`;var nh=l.object({number:l.number(),title:l.string(),body:l.optional(l.nullable(l.string())),pull_request:l.optional(l.unknown()),milestone:l.optional(l.nullable(l.object({title:l.string()}))),labels:l.optional(l.array(l.object({name:l.optional(l.string())})))}),wu=l.array(nh),oh=l.object({id:l.number(),body:l.optional(l.nullable(l.string())),created_at:l.string(),user:l.optional(l.object({login:l.string()}))}),tc=l.array(oh),ih=l.object({number:l.number(),html_url:l.string(),state:l.string()}),zu=l.array(ih),sh=l.object({state:l.string(),user:l.object({login:l.string()}),submitted_at:l.string()}),ku=l.array(sh),ch=l.object({body:l.optional(l.nullable(l.string())),path:l.optional(l.string()),created_at:l.optional(l.string()),user:l.optional(l.object({login:l.string()}))}),rc=l.array(ch);var W="https://api.github.com";async function gr(e,t,r,n){try{let o=new AbortController,i=setTimeout(()=>o.abort(),1e4),s=await fetch(e,{headers:t,signal:o.signal});if(clearTimeout(i),s.ok)return{ok:!0};let c=r[s.status];return c?{ok:!1,error:c}:{ok:!1,error:`\u2717 HTTP ${s.status}`}}catch{return{ok:!1,error:n}}}function re(e){return{Authorization:`Bearer ${e}`,Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28"}}function ze(e){return{Authorization:`Basic ${e}`,Accept:"application/json"}}var ah=l.object({login:l.string()}),uh=/^[a-zA-Z0-9_.-]+\/[a-zA-Z0-9_.-]+$/,_r;function yr(e){return uh.test(e)}async function Pu(e,t){return gr(`${W}/repos/${t}`,re(e),{401:"\u2717 GitHub auth failed \u2014 check GITHUB_TOKEN",403:"\u2717 GitHub permission denied",404:`\u2717 GitHub repo "${t}" not found`},"\u2717 Could not reach GitHub \u2014 check network")}async function br(e,t){if(_r)return _r;try{let r=await fetch(`${t??W}/user`,{headers:re(e)});if(!r.ok){let i=r.status===401||r.status===403?' Fine-grained PATs need "Account permissions \u2192 read" (or classic PATs need read:user scope).':"";return console.warn(`\u26A0 GitHub /user returned HTTP ${r.status} \u2014 falling back to @me.${i}`),"@me"}let n=await r.json(),o=ah.safeParse(n);if(o.success)return _r=o.data.login,_r;console.warn("\u26A0 Unexpected GitHub /user response \u2014 falling back to @me")}catch(r){console.warn(`\u26A0 GitHub /user request failed: ${r instanceof Error?r.message:String(r)} \u2014 falling back to @me`)}return"@me"}async function Eu(e,t,r,n,o,i=5){let s,c=new URLSearchParams({state:"open",assignee:n??"@me",per_page:"10"});r&&c.set("labels",r);try{s=await fetch(`${W}/repos/${t}/issues?${c}`,{headers:re(e)})}catch(d){return console.warn(`\u26A0 GitHub API request failed: ${d instanceof Error?d.message:String(d)}`),[]}if(!s.ok)return console.warn(`\u26A0 GitHub API returned HTTP ${s.status}`),[];let a;try{a=await s.json()}catch{return console.warn("\u26A0 GitHub API returned invalid JSON"),[]}let u=wu.safeParse(a);if(!u.success)return console.warn(`\u26A0 Unexpected GitHub response shape: ${u.error.message}`),[];let p=u.data.filter(d=>!d.pull_request);return o&&(p=p.filter(d=>!d.labels?.some(h=>h.name==="clancy:hitl"))),p.slice(0,i).map(d=>({key:`#${d.number}`,title:d.title,description:d.body??"",provider:"github",milestone:d.milestone?.title}))}async function Iu(e,t,r,n){if(!yr(t))return!1;let o=/Blocked by #(\d+)/gi,i=new Set,s;for(;(s=o.exec(n))!==null;){let c=parseInt(s[1],10);!Number.isNaN(c)&&c!==r&&i.add(c)}if(!i.size)return!1;try{for(let c of i){let a=await fetch(`${W}/repos/${t}/issues/${c}`,{headers:re(e)});if(!a.ok)continue;if((await a.json()).state!=="closed")return!0}return!1}catch{return!1}}async function Au(e,t,r){if(yr(t))try{let n=await Su(e,t,`Epic: #${r}`);return n&&n.total>0?n:await Su(e,t,`Parent: #${r}`)}catch{return}}async function Su(e,t,r){let n=re(e),o=`"${r}" repo:${t} is:issue`,i=new URLSearchParams({q:o,per_page:"1"}),s=await fetch(`${W}/search/issues?${i}`,{headers:n});if(!s.ok)return;let a=(await s.json()).total_count??0;if(a===0)return{total:0,incomplete:0};let u=`"${r}" repo:${t} is:issue is:open`,p=new URLSearchParams({q:u,per_page:"1"}),d=await fetch(`${W}/search/issues?${p}`,{headers:n});if(!d.ok)return{total:a,incomplete:a};let m=(await d.json()).total_count??0;return{total:a,incomplete:m}}var lh=l.object({type:l.optional(l.object({name:l.optional(l.string())})),inwardIssue:l.optional(l.object({key:l.optional(l.string())}))}),ph=l.object({summary:l.string(),description:l.optional(l.unknown()),issuelinks:l.optional(l.array(lh)),parent:l.optional(l.object({key:l.optional(l.string())})),customfield_10014:l.optional(l.nullable(l.string()))}),fh=l.object({key:l.string(),fields:ph}),Tu=l.object({total:l.optional(l.number()),isLast:l.optional(l.boolean()),issues:l.array(fh)}),dh=l.object({id:l.string(),name:l.string()}),Ru=l.object({transitions:l.array(dh)}),mh=l.object({type:l.optional(l.object({name:l.optional(l.string())})),inwardIssue:l.optional(l.object({key:l.optional(l.string()),fields:l.optional(l.object({status:l.optional(l.object({statusCategory:l.optional(l.object({key:l.optional(l.string())}))}))}))}))}),Cu=l.object({fields:l.optional(l.object({issuelinks:l.optional(l.array(mh))}))});var hh=/^[a-zA-Z0-9 _\-'.]+$/,nc=/^[A-Z][A-Z0-9]+-\d+$/;function Re(e,t){return Buffer.from(`${e}:${t}`).toString("base64")}function xr(e){return hh.test(e)}async function Nu(e,t,r){return gr(`${e}/rest/api/3/project/${t}`,ze(r),{401:"\u2717 Jira auth failed \u2014 check credentials",403:"\u2717 Jira permission denied for this project",404:`\u2717 Jira project "${t}" not found`},"\u2717 Could not reach Jira \u2014 check network")}function gh(e,t,r,n,o){let i=[`project="${e}"`];return r&&i.push("sprint in openSprints()"),n&&i.push(`labels = "${n}"`),o&&i.push('labels != "clancy:hitl"'),i.push("assignee=currentUser()"),i.push(`status="${t}"`),i.join(" AND ")+" ORDER BY priority ASC"}function _h(e){if(!e||typeof e!="object")return"";let t=[];function r(n){if(typeof n=="string"){t.push(n);return}if(Array.isArray(n)){for(let o of n)r(o);return}if(n&&typeof n=="object")for(let o of Object.values(n))r(o)}return r(e),t.join(" ")}async function ju(e,t,r,n,o,i,s,c=5){let a=gh(r,n,o,i,s),u;try{u=await fetch(`${e}/rest/api/3/search/jql`,{method:"POST",headers:{...ze(t),"Content-Type":"application/json"},body:JSON.stringify({jql:a,maxResults:c,fields:["summary","description","issuelinks","parent","customfield_10014"]})})}catch(h){return console.warn(`\u26A0 Jira API request failed: ${h instanceof Error?h.message:String(h)}`),[]}if(!u.ok)return console.warn(`\u26A0 Jira API returned HTTP ${u.status}`),[];let p;try{p=await u.json()}catch{return console.warn("\u26A0 Jira API returned invalid JSON"),[]}let d=Tu.safeParse(p);return d.success?d.data.issues.map(h=>{let m=h.fields,_=(m.issuelinks??[]).filter(S=>S.type?.name==="Blocks"&&S.inwardIssue?.key).map(S=>S.inwardIssue?.key).filter(S=>!!S),y=m.parent?.key??m.customfield_10014??void 0;return{key:h.key,title:m.summary,description:_h(m.description),provider:"jira",epicKey:y,blockers:_}}):(console.warn(`\u26A0 Unexpected Jira response shape: ${d.error.message}`),[])}async function Ou(e,t,r){if(!nc.test(r))return!1;try{let n=await fetch(`${e}/rest/api/3/issue/${r}?fields=issuelinks`,{headers:ze(t)});if(!n.ok)return!1;let o=await n.json(),i=Cu.safeParse(o);return i.success?(i.data.fields?.issuelinks??[]).some(c=>{if(c.type?.name!=="Blocks"||!c.inwardIssue?.key)return!1;let a=c.inwardIssue.fields?.status?.statusCategory?.key;return a?a!=="done":!1}):!1}catch{return!1}}async function Lu(e,t,r){if(nc.test(r))try{let n=r.split("-")[0],o=await Zu(e,t,`project = "${n}" AND description ~ "Epic: ${r}"`);return o&&o.total>0?o:await Zu(e,t,`parent = ${r}`)}catch{return}}async function Zu(e,t,r){let n=await fetch(`${e}/rest/api/3/search/jql`,{method:"POST",headers:{...ze(t),"Content-Type":"application/json"},body:JSON.stringify({jql:r,maxResults:0})});if(!n.ok)return;let i=(await n.json()).total??0;if(i===0)return{total:0,incomplete:0};let s=await fetch(`${e}/rest/api/3/search/jql`,{method:"POST",headers:{...ze(t),"Content-Type":"application/json"},body:JSON.stringify({jql:`${r} AND statusCategory != "done"`,maxResults:0})});if(!s.ok)return;let a=(await s.json()).total??0;return{total:i,incomplete:a}}async function yh(e,t,r,n){if(!nc.test(r))return;let o;try{o=await fetch(`${e}/rest/api/3/issue/${r}/transitions`,{headers:ze(t)})}catch(a){console.warn(`\u26A0 Jira transitions request failed: ${a instanceof Error?a.message:String(a)}`);return}if(!o.ok)return;let i;try{i=await o.json()}catch{console.warn("\u26A0 Jira transitions returned invalid JSON");return}let s=Ru.safeParse(i);if(!s.success){console.warn(`\u26A0 Unexpected Jira transitions response: ${s.error.message}`);return}return s.data.transitions.find(a=>a.name===n)?.id}async function Mu(e,t,r,n){try{let o=await yh(e,t,r,n);return o?(await fetch(`${e}/rest/api/3/issue/${r}/transitions`,{method:"POST",headers:{...ze(t),"Content-Type":"application/json"},body:JSON.stringify({transition:{id:o}})})).ok:(console.warn(`\u26A0 Jira transition "${n}" not found for ${r}`),!1)}catch{return!1}}var bh=l.object({id:l.string(),identifier:l.string(),title:l.string(),description:l.optional(l.nullable(l.string())),parent:l.optional(l.nullable(l.object({identifier:l.string(),title:l.optional(l.string())}))),labels:l.optional(l.object({nodes:l.array(l.object({name:l.string()}))}))}),Du=l.object({data:l.optional(l.object({viewer:l.optional(l.object({assignedIssues:l.optional(l.object({nodes:l.array(bh)}))}))}))}),Uu=l.object({data:l.optional(l.object({viewer:l.optional(l.object({id:l.optional(l.string())}))}))}),Bu=l.object({data:l.optional(l.object({workflowStates:l.optional(l.object({nodes:l.array(l.object({id:l.string()}))}))}))}),Fu=l.object({data:l.optional(l.object({issueUpdate:l.optional(l.object({success:l.optional(l.boolean())}))}))}),xh=l.object({type:l.string(),relatedIssue:l.optional(l.object({state:l.optional(l.object({type:l.optional(l.string())}))}))}),Ju=l.object({data:l.optional(l.object({issue:l.optional(l.object({relations:l.optional(l.object({nodes:l.array(xh)}))}))}))}),$h=l.object({state:l.optional(l.object({type:l.optional(l.string())}))}),Ku=l.object({data:l.optional(l.object({issueSearch:l.optional(l.object({nodes:l.array($h)}))}))});var vh=/^[a-zA-Z0-9_-]+$/,qu="https://api.linear.app/graphql";function Gu(e){return vh.test(e)}async function Ge(e,t,r){let n;try{n=await fetch(qu,{method:"POST",headers:{Authorization:e,"Content-Type":"application/json"},body:JSON.stringify({query:t,variables:r})})}catch(o){console.warn(`\u26A0 Linear API request failed: ${o instanceof Error?o.message:String(o)}`);return}if(!n.ok){console.warn(`\u26A0 Linear API returned HTTP ${n.status}`);return}try{return await n.json()}catch{console.warn("\u26A0 Linear API returned invalid JSON");return}}async function Yu(e){let t;try{t=await fetch(qu,{method:"POST",headers:{Authorization:e,"Content-Type":"application/json"},body:JSON.stringify({query:"{ viewer { id } }"})})}catch{return{ok:!1,error:"\u2717 Could not reach Linear \u2014 check network"}}if(!t.ok)return t.status===401||t.status===403?{ok:!1,error:"\u2717 Linear auth failed \u2014 check LINEAR_API_KEY"}:{ok:!1,error:`\u2717 Linear API returned HTTP ${t.status}`};try{let r=await t.json(),n=Uu.safeParse(r);if(n.success&&n.data.data?.viewer?.id)return{ok:!0}}catch{}return{ok:!1,error:"\u2717 Linear auth failed \u2014 check LINEAR_API_KEY"}}async function Hu(e,t,r=5){let n=e.CLANCY_LABEL?.trim(),o=!!n,i=o?"labels: { name: { eq: $label } }":"",s=["$teamId: String!",...o?["$label: String!"]:[]],c=['state: { type: { eq: "unstarted" } }',"team: { id: { eq: $teamId } }",i].filter(Boolean),a=`
|
|
113
113
|
query(${s.join(", ")}) {
|
|
114
114
|
viewer {
|
|
115
115
|
assignedIssues(
|
|
@@ -131,7 +131,7 @@ If the ${e.provider==="github"?"issue":"ticket"} IS implementable, continue:${e.
|
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
-
`,u={teamId:e.LINEAR_TEAM_ID};o&&(u.label=n);let p=await
|
|
134
|
+
`,u={teamId:e.LINEAR_TEAM_ID};o&&(u.label=n);let p=await Ge(e.LINEAR_API_KEY,a,u),d=Du.safeParse(p);if(!d.success)return console.warn(`\u26A0 Unexpected Linear response shape: ${d.error.message}`),[];let h=d.data.data?.viewer?.assignedIssues?.nodes;return h?.length?(t&&(h=h.filter(m=>!m.labels?.nodes?.some(_=>_.name==="clancy:hitl"))),h=h.slice(0,r),h.map(m=>({key:m.identifier,title:m.title,description:m.description??"",provider:"linear",issueId:m.id,parentIdentifier:m.parent?.identifier}))):[]}async function Vu(e,t){let n=await Ge(e,`
|
|
135
135
|
query($issueId: String!) {
|
|
136
136
|
issue(id: $issueId) {
|
|
137
137
|
relations {
|
|
@@ -144,7 +144,7 @@ If the ${e.provider==="github"?"issue":"ticket"} IS implementable, continue:${e.
|
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
|
-
`,{issueId:t}),o=
|
|
147
|
+
`,{issueId:t}),o=Ju.safeParse(n);if(!o.success)return!1;let i=o.data.data?.issue?.relations?.nodes??[],s=new Set(["completed","canceled"]);return i.some(c=>{if(c.type!=="blockedBy")return!1;let a=c.relatedIssue?.state?.type;return a?!s.has(a):!1})}async function Wu(e,t,r){try{if(r){let n=await wh(e,`Epic: ${r}`);if(n&&n.total>0)return n}return await zh(e,t)}catch{return}}async function wh(e,t){let n=await Ge(e,`
|
|
148
148
|
query($filter: String!) {
|
|
149
149
|
issueSearch(query: $filter) {
|
|
150
150
|
nodes {
|
|
@@ -152,7 +152,7 @@ If the ${e.provider==="github"?"issue":"ticket"} IS implementable, continue:${e.
|
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
|
-
`,{filter:t}),o=
|
|
155
|
+
`,{filter:t}),o=Ku.safeParse(n);if(!o.success)return;let i=o.data.data?.issueSearch?.nodes??[],s=i.length,c=new Set(["completed","canceled"]),a=i.filter(u=>!u.state?.type||!c.has(u.state.type)).length;return{total:s,incomplete:a}}async function zh(e,t){let n=await Ge(e,`
|
|
156
156
|
query($issueId: String!) {
|
|
157
157
|
issue(id: $issueId) {
|
|
158
158
|
children {
|
|
@@ -162,7 +162,7 @@ If the ${e.provider==="github"?"issue":"ticket"} IS implementable, continue:${e.
|
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
|
-
`,{issueId:t});if(!n||typeof n!="object")return;let i=n.data?.issue?.children?.nodes;if(!i)return;let s=i.length,c=new Set(["completed","canceled"]),a=i.filter(u=>!u.state?.type||!c.has(u.state.type)).length;return{total:s,incomplete:a}}async function
|
|
165
|
+
`,{issueId:t});if(!n||typeof n!="object")return;let i=n.data?.issue?.children?.nodes;if(!i)return;let s=i.length,c=new Set(["completed","canceled"]),a=i.filter(u=>!u.state?.type||!c.has(u.state.type)).length;return{total:s,incomplete:a}}async function kh(e,t,r){let o=await Ge(e,`
|
|
166
166
|
query($teamId: String!, $name: String!) {
|
|
167
167
|
workflowStates(filter: {
|
|
168
168
|
team: { id: { eq: $teamId } }
|
|
@@ -171,18 +171,19 @@ If the ${e.provider==="github"?"issue":"ticket"} IS implementable, continue:${e.
|
|
|
171
171
|
nodes { id }
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
|
-
`,{teamId:t,name:r}),i=
|
|
174
|
+
`,{teamId:t,name:r}),i=Bu.safeParse(o);if(!i.success){console.warn(`\u26A0 Unexpected Linear workflowStates response: ${i.error.message}`);return}return i.data.data?.workflowStates?.nodes?.[0]?.id}async function Sh(e,t,r){let o=await Ge(e,`
|
|
175
175
|
mutation($issueId: String!, $stateId: String!) {
|
|
176
176
|
issueUpdate(id: $issueId, input: { stateId: $stateId }) {
|
|
177
177
|
success
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
|
-
`,{issueId:t,stateId:r}),i=
|
|
181
|
-
|
|
182
|
-
`)}import{execFileSync as mh}from"node:child_process";function Hu(e){let t=e.trim().replace(/\.git$/,""),r=t.match(/^git@([^:]+):(.+)$/),n=t.match(/^(?:https?|ssh):\/\/(?:[^@]+@)?([^/:]+)(?::\d+)?\/(.+)$/),o=r?.[1]??n?.[1],i=r?.[2]??n?.[2];if(!(!o||!i))return{hostname:o,path:i}}function hh(e){let t=Hu(e);if(!t)return{host:"unknown",url:e};let{hostname:r,path:n}=t;switch(gh(r)){case"github":{let i=n.split("/");return i.length>=2?{host:"github",owner:i[0],repo:i[1],hostname:r}:{host:"unknown",url:e}}case"gitlab":return{host:"gitlab",projectPath:n,hostname:r};case"bitbucket":{let i=n.match(/^scm\/([^/]+)\/(.+)$/);if(i)return{host:"bitbucket-server",projectKey:i[1],repoSlug:i[2],hostname:r};let s=n.split("/");return s.length>=2?{host:"bitbucket",workspace:s[0],repoSlug:s[1],hostname:r}:{host:"unknown",url:e}}case"azure":return{host:"azure",url:e};default:return{host:"unknown",url:e}}}function gh(e){let t=e.toLowerCase();return t==="github.com"||t.includes("github")?"github":t==="gitlab.com"||t.includes("gitlab")?"gitlab":t==="bitbucket.org"||t.includes("bitbucket")?"bitbucket":t.includes("dev.azure")||t.includes("visualstudio")?"azure":"unknown"}function Ge(e){let t;try{t=mh("git",["remote","get-url","origin"],{encoding:"utf8"}).trim()}catch{return{host:"none"}}return t?e?_h(t,e):hh(t):{host:"none"}}function _h(e,t){let r=Hu(e);if(!r)return{host:"unknown",url:e};let{hostname:n,path:o}=r;switch(t.toLowerCase()){case"github":{let i=o.split("/");return i.length>=2?{host:"github",owner:i[0],repo:i[1],hostname:n}:{host:"unknown",url:e}}case"gitlab":return{host:"gitlab",projectPath:o,hostname:n};case"bitbucket":{let i=o.split("/");return i.length>=2?{host:"bitbucket",workspace:i[0],repoSlug:i[1],hostname:n}:{host:"unknown",url:e}}case"bitbucket-server":{let i=o.match(/^scm\/([^/]+)\/(.+)$/);if(i)return{host:"bitbucket-server",projectKey:i[1],repoSlug:i[2],hostname:n};let s=o.split("/");return s.length>=2?{host:"bitbucket-server",projectKey:s[0],repoSlug:s[1],hostname:n}:{host:"unknown",url:e}}default:return{host:"unknown",url:e}}}function $t(e,t){if(t)return t.replace(/\/$/,"");switch(e.host){case"github":return e.hostname==="github.com"?"https://api.github.com":`https://${e.hostname}/api/v3`;case"gitlab":return`https://${e.hostname}/api/v4`;case"bitbucket":return"https://api.bitbucket.org/2.0";case"bitbucket-server":return`https://${e.hostname}/rest/api/1.0`;default:return}}var bh=E({id:ye(),links:E({html:x(E({href:x(y())}))}),participants:U(E({state:x(y()),role:y()}))}),Ku=E({values:U(bh)}),yh=E({content:E({raw:y()}),inline:x(E({path:x(y())})),created_on:y(),user:x(E({nickname:x(y())}))}),Ws=E({values:U(yh)}),xh=E({id:ye(),links:E({self:x(U(E({href:x(y())})))}),reviewers:U(E({status:y()}))}),Vu=E({values:U(xh)}),$h=E({text:y(),anchor:x(E({path:x(y())})),createdDate:ye(),author:x(E({slug:x(y())}))}),vh=E({action:y(),comment:x($h)}),Xs=E({values:U(vh)});async function Te(e,t,r,n,o){let i=new AbortController,s=setTimeout(()=>i.abort(),3e4);try{let c=await fetch(e,{method:"POST",headers:{...t,"Content-Type":"application/json"},body:JSON.stringify(r),signal:i.signal});if(!c.ok){let p=await c.text().catch(()=>""),d=o?.(c.status,p)??!1;return{ok:!1,error:`HTTP ${c.status}${p?`: ${p.slice(0,200)}`:""}`,alreadyExists:d}}let a=await c.json(),u=n(a);return!u.url&&!u.number?{ok:!1,error:"PR created but response missing URL and number"}:{ok:!0,url:u.url,number:u.number}}catch(c){return{ok:!1,error:c instanceof Error?c.message:String(c)}}finally{clearTimeout(s)}}function Ye(e,t){return`Basic ${Buffer.from(`${e}:${t}`).toString("base64")}`}function ie(e){return e.trim().toLowerCase().startsWith("rework:")}function Ae(e){return e.trim().replace(/^rework:\s*/i,"").trim()}async function Wu(e,t,r,n,o,i,s,c){return Te(`https://api.bitbucket.org/2.0/repositories/${r}/${n}/pullrequests`,{Authorization:Ye(e,t)},{title:s,description:c,source:{branch:{name:o}},destination:{branch:{name:i}},close_source_branch:!0},a=>{let u=a;return{url:u.links?.html?.href??"",number:u.id??0}},(a,u)=>a===409&&u.includes("already exists"))}async function Xu(e,t,r,n,o,i,s,c){return Te(`${t}/projects/${r}/repos/${n}/pull-requests`,{Authorization:`Bearer ${e}`},{title:s,description:c,fromRef:{id:`refs/heads/${o}`,repository:{slug:n,project:{key:r}}},toRef:{id:`refs/heads/${i}`,repository:{slug:n,project:{key:r}}}},a=>{let u=a;return{url:u.links?.self?.[0]?.href??"",number:u.id??0}},(a,u)=>a===409&&(u.includes("already exists")||u.includes("Only one pull request")))}async function Qu(e,t,r,n,o,i){try{return(await fetch(`https://api.bitbucket.org/2.0/repositories/${r}/${n}/pullrequests/${o}/comments`,{method:"POST",headers:{Authorization:Ye(e,t),"Content-Type":"application/json"},body:JSON.stringify({content:{raw:i}})})).ok}catch{return!1}}async function el(e,t,r,n,o,i){try{return(await fetch(`${t}/projects/${r}/repos/${n}/pull-requests/${o}/comments`,{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify({text:i})})).ok}catch{return!1}}async function tl(e,t,r,n,o,i){try{let s=`https://api.bitbucket.org/2.0/repositories/${r}/${n}/pullrequests?q=source.branch.name="${o}"&state=OPEN`,c=await fetch(s,{headers:{Authorization:Ye(e,t)}});if(!c.ok)return;let a=Ku.parse(await c.json());if(a.values.length===0)return;let u=a.values[0],p=u.links.html?.href??"",d=`https://api.bitbucket.org/2.0/repositories/${r}/${n}/pullrequests/${u.id}/comments?pagelen=100`,m=await fetch(d,{headers:{Authorization:Ye(e,t)}});if(!m.ok)return;let h=Ws.parse(await m.json()),b=i?h.values.filter(Z=>Z.created_on>i):h.values,g=b.some(Z=>Z.inline!=null),v=b.some(Z=>Z.inline==null&&ie(Z.content.raw));return{changesRequested:g||v,prNumber:u.id,prUrl:p}}catch{return}}async function rl(e,t,r,n,o,i){try{let s=`https://api.bitbucket.org/2.0/repositories/${r}/${n}/pullrequests/${o}/comments?pagelen=100`,c=await fetch(s,{headers:{Authorization:Ye(e,t)}});if(!c.ok)return[];let a=Ws.parse(await c.json()),u=i?a.values.filter(d=>d.created_on>i):a.values,p=[];for(let d of u)if(d.inline!=null){let m=d.inline.path?`[${d.inline.path}] `:"";p.push(`${m}${d.content.raw}`)}else ie(d.content.raw)&&p.push(Ae(d.content.raw));return p}catch{return[]}}async function nl(e,t,r,n,o,i){try{let s=`${t}/projects/${r}/repos/${n}/pull-requests?state=OPEN&at=refs/heads/${o}`,c=await fetch(s,{headers:{Authorization:`Bearer ${e}`}});if(!c.ok)return;let a=Vu.parse(await c.json());if(a.values.length===0)return;let u=a.values[0],p=u.links.self?.[0]?.href??"",d=`${t}/projects/${r}/repos/${n}/pull-requests/${u.id}/activities?limit=100`,m=await fetch(d,{headers:{Authorization:`Bearer ${e}`}});if(!m.ok)return;let h=Xs.parse(await m.json()),b=i?Date.parse(i):void 0,g=h.values.filter(S=>S.action==="COMMENTED"&&S.comment&&(b==null||S.comment.createdDate>b)),v=g.some(S=>S.comment.anchor!=null),te=g.some(S=>S.comment.anchor==null&&ie(S.comment.text));return{changesRequested:v||te,prNumber:u.id,prUrl:p}}catch{return}}async function ol(e,t,r,n,o,i){try{let s=`${t}/projects/${r}/repos/${n}/pull-requests/${o}/activities?limit=100`,c=await fetch(s,{headers:{Authorization:`Bearer ${e}`}});if(!c.ok)return[];let a=Xs.parse(await c.json()),u=i?Date.parse(i):void 0,p=[];for(let d of a.values){if(d.action!=="COMMENTED"||!d.comment||u!=null&&d.comment.createdDate<=u)continue;let m=d.comment;if(m.anchor!=null){let h=m.anchor.path?`[${m.anchor.path}] `:"";p.push(`${h}${m.text}`)}else ie(m.text)&&p.push(Ae(m.text))}return p}catch{return[]}}async function il(e,t,r,n,o=V,i,s){try{let c=ee(e),a=await fetch(`${o}/repos/${t}/pulls?head=${n}:${r}&state=open`,{headers:c});if(!a.ok)return;let u=hu.parse(await a.json());if(u.length===0)return;let p=u[0],d=i?`&since=${i}`:"",[m,h]=await Promise.all([fetch(`${o}/repos/${t}/pulls/${p.number}/comments?per_page=100${d}`,{headers:c}),fetch(`${o}/repos/${t}/issues/${p.number}/comments?per_page=100${d}`,{headers:c})]);if(!m.ok||!h.ok)return;let b=Hs.parse(await m.json()),g=Ys.parse(await h.json()),v=s?b.filter(O=>O.user?.login!==s):b,te=s?g.filter(O=>O.user?.login!==s):g,Z=v.length>0,S=te.some(O=>O.body&&ie(O.body)),N=Z||S,j;if(!N)try{let O=await fetch(`${o}/repos/${t}/pulls/${p.number}/reviews?per_page=100`,{headers:c});if(O.ok){let ae=gu.parse(await O.json()),He=new Map;for(let re of ae)re.state==="PENDING"||re.state==="DISMISSED"||He.set(re.user.login,re.state);let Re=[...He.entries()].filter(([,re])=>re==="CHANGES_REQUESTED");Re.length>0&&(N=!0,j=Re.map(([re])=>re))}}catch{}return{changesRequested:N,prNumber:p.number,prUrl:p.html_url,reviewers:j}}catch{return}}async function sl(e,t,r,n=V,o,i){try{let s=ee(e),c=o?`&since=${o}`:"",[a,u]=await Promise.all([fetch(`${n}/repos/${t}/pulls/${r}/comments?per_page=100${c}`,{headers:s}),fetch(`${n}/repos/${t}/issues/${r}/comments?per_page=100${c}`,{headers:s})]);if(!a.ok||!u.ok)return[];let p=Hs.parse(await a.json()),d=Ys.parse(await u.json()),m=i?p.filter(g=>g.user?.login!==i):p,h=i?d.filter(g=>g.user?.login!==i):d,b=[];for(let g of m){if(!g.body)continue;let v=g.path?`[${g.path}] `:"";b.push(`${v}${g.body}`)}for(let g of h)g.body&&ie(g.body)&&b.push(Ae(g.body));return b}catch{return[]}}async function cl(e,t,r,n,o=V){try{return(await fetch(`${o}/repos/${t}/issues/${r}/comments`,{method:"POST",headers:{...ee(e),"Content-Type":"application/json"},body:JSON.stringify({body:n})})).ok}catch{return!1}}async function al(e,t,r,n,o=V){try{return(await fetch(`${o}/repos/${t}/pulls/${r}/requested_reviewers`,{method:"POST",headers:{...ee(e),"Content-Type":"application/json"},body:JSON.stringify({reviewers:n})})).ok}catch{return!1}}async function ul(e,t,r,n,o,i,s=V){return Te(`${s}/repos/${t}/pulls`,ee(e),{title:o,head:r,base:n,body:i},c=>{let a=c;return{url:a.html_url??"",number:a.number??0}},(c,a)=>c===422&&a.includes("already exists"))}var wh=E({iid:ye(),web_url:y(),detailed_merge_status:x(y())}),ll=U(wh),zh=E({body:y(),resolvable:Fe(),resolved:x(Fe()),system:Fe(),type:x(or(y())),created_at:x(y()),position:x(E({new_path:x(y())})),author:x(E({username:y()}))}),kh=E({id:x(y()),notes:U(zh)}),Qs=U(kh);async function pl(e,t,r,n,o,i,s){let c=encodeURIComponent(r);return Te(`${t}/projects/${c}/merge_requests`,{"PRIVATE-TOKEN":e},{source_branch:n,target_branch:o,title:i,description:s,remove_source_branch:!0},a=>{let u=a;return{url:u.web_url??"",number:u.iid??0}},(a,u)=>a===409&&u.includes("already exists"))}async function fl(e,t,r,n,o){try{let i=encodeURIComponent(r);return(await fetch(`${t}/projects/${i}/merge_requests/${n}/notes`,{method:"POST",headers:{"PRIVATE-TOKEN":e,"Content-Type":"application/json"},body:JSON.stringify({body:o})})).ok}catch{return!1}}async function dl(e,t,r,n,o){let i=encodeURIComponent(r),s=0;for(let c of o)try{(await fetch(`${t}/projects/${i}/merge_requests/${n}/discussions/${c}`,{method:"PUT",headers:{"PRIVATE-TOKEN":e,"Content-Type":"application/json"},body:JSON.stringify({resolved:!0})})).ok&&s++}catch{}return s}async function ml(e,t,r,n,o){try{let i=encodeURIComponent(r),s=`${t}/projects/${i}/merge_requests?source_branch=${n}&state=opened`,c=await fetch(s,{headers:{"PRIVATE-TOKEN":e}});if(!c.ok)return;let a=ll.parse(await c.json());if(a.length===0)return;let u=a[0],p=`${t}/projects/${i}/merge_requests/${u.iid}/discussions?per_page=100`,d=await fetch(p,{headers:{"PRIVATE-TOKEN":e}});if(!d.ok)return;let m=Qs.parse(await d.json()),h=!1;for(let b of m){for(let g of b.notes)if(!g.system&&!(o&&g.created_at&&g.created_at<=o)){if(g.type==="DiffNote"&&g.resolvable!==!1&&g.resolved!==!0){h=!0;break}if(ie(g.body)){h=!0;break}}if(h)break}return{changesRequested:h,prNumber:u.iid,prUrl:u.web_url}}catch{return}}async function hl(e,t,r,n,o){try{let i=encodeURIComponent(r),s=`${t}/projects/${i}/merge_requests/${n}/discussions?per_page=100`,c=await fetch(s,{headers:{"PRIVATE-TOKEN":e}});if(!c.ok)return{comments:[],discussionIds:[]};let a=Qs.parse(await c.json()),u=[],p=[];for(let d of a){let m=!1;for(let h of d.notes)if(!h.system&&!(o&&h.created_at&&h.created_at<=o))if(h.type==="DiffNote"&&h.resolvable!==!1&&h.resolved!==!0){let b=h.position?.new_path?`[${h.position.new_path}] `:"";u.push(`${b}${h.body}`),m=!0}else ie(h.body)&&(u.push(Ae(h.body)),m=!0);m&&d.id&&p.push(d.id)}return{comments:u,discussionIds:p}}catch{return{comments:[],discussionIds:[]}}}function vt(e,t){let r=H(e);switch(t.host){case"github":if(r.GITHUB_TOKEN)return{token:r.GITHUB_TOKEN};break;case"gitlab":if(r.GITLAB_TOKEN)return{token:r.GITLAB_TOKEN};break;case"bitbucket":if(r.BITBUCKET_USER&&r.BITBUCKET_TOKEN)return{token:r.BITBUCKET_TOKEN,username:r.BITBUCKET_USER};break;case"bitbucket-server":if(r.BITBUCKET_TOKEN)return{token:r.BITBUCKET_TOKEN};break}}async function ec(e,t,r,n,o,i){let s=vt(e,t);if(!s)return;let c=$t(t,H(e).CLANCY_GIT_API_URL);if(c)switch(t.host){case"github":return ul(s.token,`${t.owner}/${t.repo}`,r,n,o,i,c);case"gitlab":return pl(s.token,c,t.projectPath,r,n,o,i);case"bitbucket":return Wu(s.username,s.token,t.workspace,t.repoSlug,r,n,o,i);case"bitbucket-server":return Xu(s.token,c,t.projectKey,t.repoSlug,r,n,o,i);default:return}}function gr(e,t,r){let n=encodeURIComponent(t),o=encodeURIComponent(r);if(e.host==="github")return`https://${e.hostname}/${e.owner}/${e.repo}/compare/${o}...${n}`;if(e.host==="gitlab")return`https://${e.hostname}/${e.projectPath}/-/merge_requests/new?merge_request[source_branch]=${n}&merge_request[target_branch]=${o}`;if(e.host==="bitbucket")return`https://${e.hostname}/${e.workspace}/${e.repoSlug}/pull-requests/new?source=${n}&dest=${o}`;if(e.host==="bitbucket-server")return`https://${e.hostname}/projects/${e.projectKey}/repos/${e.repoSlug}/pull-requests?create&sourceBranch=refs/heads/${n}&targetBranch=refs/heads/${o}`}function tc(e,t){let r=ru(e),n=Fs(e);if(r)return ur(e)?!0:(console.log(C(`\u26A0 Epic branch ${e} exists on remote but could not be fetched.`)),!1);if(n)return console.log(Je(`\u2717 Epic branch ${e} exists locally but not on remote.`)),console.log(C(" This may contain work from a previous Clancy version that squash-merged locally.")),console.log(k(" To preserve this work, push it manually:")),console.log(k(` git push -u origin ${e}`)),console.log(k(" Then re-run /clancy:once to continue.")),!1;try{if(gl("git",["fetch","origin",t],{encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:15e3}),gl("git",["checkout","-b",e,`origin/${t}`],{encoding:"utf8"}),qs(e))console.log(oe(` \u2713 Created epic branch ${e}`));else return console.log(C(`\u26A0 Created ${e} locally but could not push to origin.`)),!1;return!0}catch(o){return console.log(Je(`\u2717 Could not create epic branch: ${o instanceof Error?o.message:String(o)}`)),!1}}async function rc(e,t,r,n,o,i=!1,s){if(!qs(r)){console.log(C(`\u26A0 Could not push ${r} to origin.`)),console.log(k(" The branch is still available locally. Push manually:")),console.log(k(` git push -u origin ${r}`)),i||B(process.cwd(),t.key,t.title,"PUSH_FAILED",void 0,s),Y(n);let m=yt(Date.now()-o);return console.log(""),console.log(C(`\u26A0 ${t.key} implemented but push failed`)+k(` (${m})`)),!1}console.log(oe(` \u2713 Pushed ${r}`));let a=H(e).CLANCY_GIT_PLATFORM,u=Ge(a),p=`feat(${t.key}): ${t.title}`,d=Gu(e,{key:t.key,title:t.title,description:t.description,provider:e.provider},n);if(u.host!=="none"&&u.host!=="unknown"&&u.host!=="azure"){let m=await ec(e,u,r,n,p,d);if(m?.ok)console.log(oe(` \u2713 PR created: ${m.url}`)),i||B(process.cwd(),t.key,t.title,"PR_CREATED",m.number,s);else if(m&&!m.ok&&m.alreadyExists)console.log(C(` \u26A0 A PR/MR already exists for ${r}. Branch pushed.`)),i||B(process.cwd(),t.key,t.title,"PUSHED",void 0,s);else if(m&&!m.ok){console.log(C(` \u26A0 PR/MR creation failed: ${m.error}`));let h=gr(u,r,n);console.log(h?k(` Create one manually: ${h}`):k(" Branch pushed \u2014 create a PR/MR manually.")),i||B(process.cwd(),t.key,t.title,"PUSHED",void 0,s)}else{let h=gr(u,r,n);console.log(h?k(` Create a PR: ${h}`):k(" Branch pushed to remote. Create a PR/MR manually.")),i||B(process.cwd(),t.key,t.title,"PUSHED",void 0,s)}}else u.host==="none"?(console.log(C(`\u26A0 No git remote configured. Branch available locally: ${r}`)),i||B(process.cwd(),t.key,t.title,"LOCAL",void 0,s)):(console.log(k(" Branch pushed to remote. Create a PR/MR manually.")),i||B(process.cwd(),t.key,t.title,"PUSHED",void 0,s));if(e.provider!=="github"){let m=e.env.CLANCY_STATUS_REVIEW??e.env.CLANCY_STATUS_DONE;m&&await xt(e,t,m)}return Y(n),!0}async function _l(e,t,r,n,o){console.log(""),console.log(oe(`\u{1F389} All children of ${t} are done!`)),console.log(k(` Creating epic PR: ${n} \u2192 ${o}`));let i=F(process.cwd(),"PR_CREATED"),s=F(process.cwd(),"DONE"),c=F(process.cwd(),"REWORK"),a=F(process.cwd(),"PUSHED"),u=[...i,...s,...c,...a].filter(v=>v.parent===t),p=H(e).CLANCY_GIT_PLATFORM,d=Ge(p),m=`feat(${t}): ${r}`,h=Yu(t,r,u);if(d.host==="none"||d.host==="unknown"||d.host==="azure")return console.log(C("\u26A0 Cannot create epic PR \u2014 no supported git remote detected.")),console.log(k(` Push manually: git push origin ${n}`)),console.log(k(` Then create a PR targeting ${o}`)),!1;let b=await ec(e,d,n,o,m,h);if(b?.ok){if(console.log(oe(` \u2713 Epic PR created: ${b.url}`)),B(process.cwd(),t,r,"EPIC_PR_CREATED",b.number),e.provider!=="github"){let v=e.env.CLANCY_STATUS_REVIEW??e.env.CLANCY_STATUS_DONE;v&&await xt(e,{key:t,title:r,description:"",parentInfo:"none",blockers:"None"},v)}return!0}if(b&&!b.ok&&b.alreadyExists)return console.log(C(` \u26A0 An epic PR already exists for ${n}.`)),B(process.cwd(),t,r,"EPIC_PR_CREATED"),!0;console.log(C(`\u26A0 Epic PR creation failed: ${b?.error??"unknown error"}`)),console.log(k(" Create it manually:")),console.log(k(` Branch: ${n} \u2192 ${o}`));let g=gr(d,n,o);return g&&console.log(k(` ${g}`)),!1}function Sh(e){return e?.isAfk??process.env.CLANCY_AFK_MODE==="1"}async function Ph(e,t){switch(e.provider){case"jira":{let{env:r}=e,n=Ie(r.JIRA_USER,r.JIRA_API_TOKEN);return(await Pu(r.JIRA_BASE_URL,n,r.JIRA_PROJECT_KEY,r.CLANCY_JQL_STATUS??"To Do",r.CLANCY_JQL_SPRINT,r.CLANCY_LABEL,t)).map(i=>{let s=i.blockers.length?`Blocked by: ${i.blockers.join(", ")}`:"None";return{key:i.key,title:i.title,description:i.description,parentInfo:i.epicKey??"none",blockers:s}})}case"github":{let{env:r}=e,n=await mr(r.GITHUB_TOKEN);return(await yu(r.GITHUB_TOKEN,r.GITHUB_REPO,r.CLANCY_LABEL,n,t)).map(i=>({key:i.key,title:i.title,description:i.description,parentInfo:i.milestone??"none",blockers:"None"}))}case"linear":{let{env:r}=e;return(await Du({LINEAR_API_KEY:r.LINEAR_API_KEY,LINEAR_TEAM_ID:r.LINEAR_TEAM_ID,CLANCY_LABEL:r.CLANCY_LABEL},t)).map(o=>({key:o.key,title:o.title,description:o.description,parentInfo:o.parentIdentifier??"none",blockers:"None",linearIssueId:o.issueId,issueId:o.issueId}))}}}async function Eh(e,t){switch(e.provider){case"jira":{let{env:r}=e,n=Ie(r.JIRA_USER,r.JIRA_API_TOKEN);return Eu(r.JIRA_BASE_URL,n,t.key)}case"github":{let{env:r}=e,n=parseInt(t.key.replace("#",""),10);return Number.isNaN(n)?!1:xu(r.GITHUB_TOKEN,r.GITHUB_REPO,n,t.description)}case"linear":{let{env:r}=e;return t.issueId?Uu(r.LINEAR_API_KEY,t.issueId):!1}}}async function bl(e,t){let r=Sh(t),n=await Ph(e,r);if(n.length)for(let o of n){if(!await Eh(e,o))return o;console.log(`Skipping ${o.key} \u2014 blocked`)}}async function yl(e){let t=F(process.cwd(),"PR_CREATED"),r=F(process.cwd(),"REWORK"),n=F(process.cwd(),"PUSHED"),o=F(process.cwd(),"PUSH_FAILED"),i=[...t,...r,...n,...o];if(i.length===0)return;let s=H(e).CLANCY_GIT_PLATFORM,c=Ge(s);if(c.host==="none"||c.host==="unknown"||c.host==="azure")return;let a=vt(e,c);if(!a)return;let u=$t(c,H(e).CLANCY_GIT_API_URL);if(!u)return;let p;if(c.host==="github")try{p=await mr(a.token,u)}catch{}let d=i.slice(0,5);for(let m of d){let h=zt(e.provider,m.key),b;if(m.timestamp){let v=new Date(m.timestamp.replace(" ","T")+"Z");b=Number.isNaN(v.getTime())?void 0:v.toISOString()}let g;switch(c.host){case"github":g=await il(a.token,`${c.owner}/${c.repo}`,h,c.owner,u,b,p);break;case"gitlab":g=await ml(a.token,u,c.projectPath,h,b);break;case"bitbucket":g=await tl(a.username,a.token,c.workspace,c.repoSlug,h,b);break;case"bitbucket-server":g=await nl(a.token,u,c.projectKey,c.repoSlug,h,b);break}if(g?.changesRequested){let v=[],te;switch(c.host){case"github":v=await sl(a.token,`${c.owner}/${c.repo}`,g.prNumber,u,b,p);break;case"gitlab":{let S=await hl(a.token,u,c.projectPath,g.prNumber,b);v=S.comments,te=S.discussionIds;break}case"bitbucket":v=await rl(a.username,a.token,c.workspace,c.repoSlug,g.prNumber,b);break;case"bitbucket-server":v=await ol(a.token,u,c.projectKey,c.repoSlug,g.prNumber,b);break}return{ticket:{key:m.key,title:m.summary,description:m.summary,parentInfo:m.parent??"none",blockers:"None"},feedback:v,prNumber:g.prNumber,discussionIds:te,reviewers:g.reviewers??[]}}}}function Ih(e){if(e.length===0)return"[clancy] Rework pushed addressing reviewer feedback.";let t=e.length,r=e.slice(0,3).map(o=>`- ${o.slice(0,80)}`).join(`
|
|
180
|
+
`,{issueId:t,stateId:r}),i=Fu.safeParse(o);return i.success?i.data.data?.issueUpdate?.success===!0:(console.warn(`\u26A0 Unexpected Linear issueUpdate response: ${i.error.message}`),!1)}async function Xu(e,t,r,n){try{let o=await kh(e,t,n);return o?await Sh(e,r,o):(console.warn(`\u26A0 Linear workflow state "${n}" not found \u2014 check team configuration`),!1)}catch{return!1}}function B(e){return e.env}async function Qu(e){switch(e.provider){case"jira":{let{env:t}=e,r=Re(t.JIRA_USER,t.JIRA_API_TOKEN);return Nu(t.JIRA_BASE_URL,t.JIRA_PROJECT_KEY,r)}case"github":return Pu(e.env.GITHUB_TOKEN,e.env.GITHUB_REPO);case"linear":return Yu(e.env.LINEAR_API_KEY)}}function el(e){switch(e.provider){case"jira":{let{env:t}=e;return xr(t.JIRA_PROJECT_KEY)?t.CLANCY_LABEL&&!xr(t.CLANCY_LABEL)?"\u2717 CLANCY_LABEL contains invalid characters":t.CLANCY_JQL_STATUS&&!xr(t.CLANCY_JQL_STATUS)?"\u2717 CLANCY_JQL_STATUS contains invalid characters":void 0:"\u2717 JIRA_PROJECT_KEY contains invalid characters"}case"github":return yr(e.env.GITHUB_REPO)?void 0:"\u2717 GITHUB_REPO format is invalid \u2014 expected owner/repo";case"linear":return Gu(e.env.LINEAR_TEAM_ID)?void 0:"\u2717 LINEAR_TEAM_ID contains invalid characters"}}async function vt(e,t,r){switch(e.provider){case"jira":{let{env:n}=e,o=Re(n.JIRA_USER,n.JIRA_API_TOKEN),i=t.key;await Mu(n.JIRA_BASE_URL,o,i,r)&&console.log(` \u2192 Transitioned to ${r}`);break}case"github":break;case"linear":{let{env:n}=e;if(!t.linearIssueId)break;await Xu(n.LINEAR_API_KEY,n.LINEAR_TEAM_ID,t.linearIssueId,r)&&console.log(` \u2192 Transitioned to ${r}`);break}}}async function oc(e,t,r){switch(e.provider){case"jira":{let{env:n}=e,o=Re(n.JIRA_USER,n.JIRA_API_TOKEN);return Lu(n.JIRA_BASE_URL,o,t)}case"github":{let n=parseInt(t.replace("#",""),10);return Number.isNaN(n)?void 0:Au(e.env.GITHUB_TOKEN,e.env.GITHUB_REPO,n)}case"linear":return r?Wu(e.env.LINEAR_API_KEY,r,t):void 0}}import{appendFileSync as Ph,mkdirSync as Eh}from"node:fs";import{dirname as Ih,join as Ah}from"node:path";function tl(e,t,r,n=6600){let o=Ah(e,".clancy","costs.log");Eh(Ih(o),{recursive:!0});let i=new Date(r).getTime(),s=Date.now(),c=Number.isNaN(i)?0:Math.max(0,s-i),a=Math.round(c/6e4),u=Math.round(a*n),d=`${new Date().toISOString()} | ${t} | ${a}min | ~${u} tokens (estimated)
|
|
181
|
+
`;Ph(o,d,"utf8")}import{execFileSync as kl}from"node:child_process";import{readFileSync as Jh}from"node:fs";import{join as Kh}from"node:path";function Th(e){return e.startsWith("epic/")||e.startsWith("milestone/")}function $r(e,t,r,n){let o=[],i=r?Th(r):!1;switch(e.provider){case"github":o.push(i?`Part of ${t.key}`:`Closes ${t.key}`);break;case"jira":o.push(`**Jira:** [${t.key}](${e.env.JIRA_BASE_URL}/browse/${t.key})`);break;case"linear":o.push(`**Linear:** ${t.key}`);break}return o.push(""),t.description&&(o.push("## Description"),o.push(""),o.push(t.description),o.push("")),n&&(o.push("## \u26A0 Verification Warning"),o.push(""),o.push(n),o.push(""),o.push("This PR may need manual fixes before merging."),o.push("")),o.push("---"),o.push("*Created by [Clancy](https://github.com/Pushedskydiver/clancy)*"),o.push(""),o.push("---"),o.push("<details>"),o.push("<summary><strong>Rework instructions</strong> (click to expand)</summary>"),o.push(""),o.push("To request changes:"),o.push("- **Code comments** \u2014 leave inline comments on specific lines. These are always picked up automatically."),o.push("- **General feedback** \u2014 reply with a comment starting with `Rework:` followed by what needs fixing. Comments without the `Rework:` prefix are treated as discussion."),o.push(""),o.push("Example: `Rework: The form validation doesn't handle empty passwords`"),o.push(""),o.push("</details>"),o.join(`
|
|
182
|
+
`)}function rl(e,t,r){let n=[];n.push(`## ${e} \u2014 ${t}`),n.push(""),n.push("### Children"),n.push("");for(let o of r){let i=o.prNumber?` (#${o.prNumber})`:"";n.push(`- ${o.key} \u2014 ${o.summary}${i}`)}return n.push(""),n.push("---"),n.push("*Created by [Clancy](https://github.com/Pushedskydiver/clancy)*"),n.join(`
|
|
183
|
+
`)}import{execFileSync as Rh}from"node:child_process";function nl(e){let t=e.trim().replace(/\.git$/,""),r=t.match(/^git@([^:]+):(.+)$/),n=t.match(/^(?:https?|ssh):\/\/(?:[^@]+@)?([^/:]+)(?::\d+)?\/(.+)$/),o=r?.[1]??n?.[1],i=r?.[2]??n?.[2];if(!(!o||!i))return{hostname:o,path:i}}function Ch(e){let t=nl(e);if(!t)return{host:"unknown",url:e};let{hostname:r,path:n}=t;switch(Zh(r)){case"github":{let i=n.split("/");return i.length>=2?{host:"github",owner:i[0],repo:i[1],hostname:r}:{host:"unknown",url:e}}case"gitlab":return{host:"gitlab",projectPath:n,hostname:r};case"bitbucket":{let i=n.match(/^scm\/([^/]+)\/(.+)$/);if(i)return{host:"bitbucket-server",projectKey:i[1],repoSlug:i[2],hostname:r};let s=n.split("/");return s.length>=2?{host:"bitbucket",workspace:s[0],repoSlug:s[1],hostname:r}:{host:"unknown",url:e}}case"azure":return{host:"azure",url:e};default:return{host:"unknown",url:e}}}function Zh(e){let t=e.toLowerCase();return t==="github.com"||t.includes("github")?"github":t==="gitlab.com"||t.includes("gitlab")?"gitlab":t==="bitbucket.org"||t.includes("bitbucket")?"bitbucket":t.includes("dev.azure")||t.includes("visualstudio")?"azure":"unknown"}function ke(e){let t;try{t=Rh("git",["remote","get-url","origin"],{encoding:"utf8"}).trim()}catch{return{host:"none"}}return t?e?Nh(t,e):Ch(t):{host:"none"}}function Nh(e,t){let r=nl(e);if(!r)return{host:"unknown",url:e};let{hostname:n,path:o}=r;switch(t.toLowerCase()){case"github":{let i=o.split("/");return i.length>=2?{host:"github",owner:i[0],repo:i[1],hostname:n}:{host:"unknown",url:e}}case"gitlab":return{host:"gitlab",projectPath:o,hostname:n};case"bitbucket":{let i=o.split("/");return i.length>=2?{host:"bitbucket",workspace:i[0],repoSlug:i[1],hostname:n}:{host:"unknown",url:e}}case"bitbucket-server":{let i=o.match(/^scm\/([^/]+)\/(.+)$/);if(i)return{host:"bitbucket-server",projectKey:i[1],repoSlug:i[2],hostname:n};let s=o.split("/");return s.length>=2?{host:"bitbucket-server",projectKey:s[0],repoSlug:s[1],hostname:n}:{host:"unknown",url:e}}default:return{host:"unknown",url:e}}}function wt(e,t){if(t)return t.replace(/\/$/,"");switch(e.host){case"github":return e.hostname==="github.com"?"https://api.github.com":`https://${e.hostname}/api/v3`;case"gitlab":return`https://${e.hostname}/api/v4`;case"bitbucket":return"https://api.bitbucket.org/2.0";case"bitbucket-server":return`https://${e.hostname}/rest/api/1.0`;default:return}}var jh=E({id:ve(),links:E({html:$(E({href:$(x())}))}),participants:K(E({state:$(x()),role:x()}))}),ol=E({values:K(jh)}),Oh=E({content:E({raw:x()}),inline:$(E({path:$(x())})),created_on:x(),user:$(E({nickname:$(x())}))}),ic=E({values:K(Oh)}),Lh=E({id:ve(),links:E({self:$(K(E({href:$(x())})))}),reviewers:K(E({status:x()}))}),il=E({values:K(Lh)}),Mh=E({text:x(),anchor:$(E({path:$(x())})),createdDate:ve(),author:$(E({slug:$(x())}))}),Dh=E({action:x(),comment:$(Mh)}),sc=E({values:K(Dh)});async function Ce(e,t,r,n,o){let i=new AbortController,s=setTimeout(()=>i.abort(),3e4);try{let c=await fetch(e,{method:"POST",headers:{...t,"Content-Type":"application/json"},body:JSON.stringify(r),signal:i.signal});if(!c.ok){let p=await c.text().catch(()=>""),d=o?.(c.status,p)??!1;return{ok:!1,error:`HTTP ${c.status}${p?`: ${p.slice(0,200)}`:""}`,alreadyExists:d}}let a=await c.json(),u=n(a);return!u.url&&!u.number?{ok:!1,error:"PR created but response missing URL and number"}:{ok:!0,url:u.url,number:u.number}}catch(c){return{ok:!1,error:c instanceof Error?c.message:String(c)}}finally{clearTimeout(s)}}function Ye(e,t){return`Basic ${Buffer.from(`${e}:${t}`).toString("base64")}`}function se(e){return e.trim().toLowerCase().startsWith("rework:")}function Ze(e){return e.trim().replace(/^rework:\s*/i,"").trim()}async function sl(e,t,r,n,o,i,s,c){return Ce(`https://api.bitbucket.org/2.0/repositories/${r}/${n}/pullrequests`,{Authorization:Ye(e,t)},{title:s,description:c,source:{branch:{name:o}},destination:{branch:{name:i}},close_source_branch:!0},a=>{let u=a;return{url:u.links?.html?.href??"",number:u.id??0}},(a,u)=>a===409&&u.includes("already exists"))}async function cl(e,t,r,n,o,i,s,c){return Ce(`${t}/projects/${r}/repos/${n}/pull-requests`,{Authorization:`Bearer ${e}`},{title:s,description:c,fromRef:{id:`refs/heads/${o}`,repository:{slug:n,project:{key:r}}},toRef:{id:`refs/heads/${i}`,repository:{slug:n,project:{key:r}}}},a=>{let u=a;return{url:u.links?.self?.[0]?.href??"",number:u.id??0}},(a,u)=>a===409&&(u.includes("already exists")||u.includes("Only one pull request")))}async function al(e,t,r,n,o,i){try{return(await fetch(`https://api.bitbucket.org/2.0/repositories/${r}/${n}/pullrequests/${o}/comments`,{method:"POST",headers:{Authorization:Ye(e,t),"Content-Type":"application/json"},body:JSON.stringify({content:{raw:i}})})).ok}catch{return!1}}async function ul(e,t,r,n,o,i){try{return(await fetch(`${t}/projects/${r}/repos/${n}/pull-requests/${o}/comments`,{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify({text:i})})).ok}catch{return!1}}async function ll(e,t,r,n,o,i){try{let s=`https://api.bitbucket.org/2.0/repositories/${r}/${n}/pullrequests?q=source.branch.name="${o}"&state=OPEN`,c=await fetch(s,{headers:{Authorization:Ye(e,t)}});if(!c.ok)return;let a=ol.parse(await c.json());if(a.values.length===0)return;let u=a.values[0],p=u.links.html?.href??"",d=`https://api.bitbucket.org/2.0/repositories/${r}/${n}/pullrequests/${u.id}/comments?pagelen=100`,h=await fetch(d,{headers:{Authorization:Ye(e,t)}});if(!h.ok)return;let m=ic.parse(await h.json()),_=i?m.values.filter(O=>O.created_on>i):m.values,y=_.some(O=>O.inline!=null),S=_.some(O=>O.inline==null&&se(O.content.raw));return{changesRequested:y||S,prNumber:u.id,prUrl:p}}catch{return}}async function pl(e,t,r,n,o,i){try{let s=`https://api.bitbucket.org/2.0/repositories/${r}/${n}/pullrequests/${o}/comments?pagelen=100`,c=await fetch(s,{headers:{Authorization:Ye(e,t)}});if(!c.ok)return[];let a=ic.parse(await c.json()),u=i?a.values.filter(d=>d.created_on>i):a.values,p=[];for(let d of u)if(d.inline!=null){let h=d.inline.path?`[${d.inline.path}] `:"";p.push(`${h}${d.content.raw}`)}else se(d.content.raw)&&p.push(Ze(d.content.raw));return p}catch{return[]}}async function fl(e,t,r,n,o,i){try{let s=`${t}/projects/${r}/repos/${n}/pull-requests?state=OPEN&at=refs/heads/${o}`,c=await fetch(s,{headers:{Authorization:`Bearer ${e}`}});if(!c.ok)return;let a=il.parse(await c.json());if(a.values.length===0)return;let u=a.values[0],p=u.links.self?.[0]?.href??"",d=`${t}/projects/${r}/repos/${n}/pull-requests/${u.id}/activities?limit=100`,h=await fetch(d,{headers:{Authorization:`Bearer ${e}`}});if(!h.ok)return;let m=sc.parse(await h.json()),_=i?Date.parse(i):void 0,y=m.values.filter(N=>N.action==="COMMENTED"&&N.comment&&(_==null||N.comment.createdDate>_)),S=y.some(N=>N.comment.anchor!=null),b=y.some(N=>N.comment.anchor==null&&se(N.comment.text));return{changesRequested:S||b,prNumber:u.id,prUrl:p}}catch{return}}async function dl(e,t,r,n,o,i){try{let s=`${t}/projects/${r}/repos/${n}/pull-requests/${o}/activities?limit=100`,c=await fetch(s,{headers:{Authorization:`Bearer ${e}`}});if(!c.ok)return[];let a=sc.parse(await c.json()),u=i?Date.parse(i):void 0,p=[];for(let d of a.values){if(d.action!=="COMMENTED"||!d.comment||u!=null&&d.comment.createdDate<=u)continue;let h=d.comment;if(h.anchor!=null){let m=h.anchor.path?`[${h.anchor.path}] `:"";p.push(`${m}${h.text}`)}else se(h.text)&&p.push(Ze(h.text))}return p}catch{return[]}}async function ml(e,t,r,n,o=W,i,s){try{let c=re(e),a=await fetch(`${o}/repos/${t}/pulls?head=${n}:${r}&state=open`,{headers:c});if(!a.ok)return;let u=zu.parse(await a.json());if(u.length===0)return;let p=u[0],d=i?`&since=${i}`:"",[h,m]=await Promise.all([fetch(`${o}/repos/${t}/pulls/${p.number}/comments?per_page=100${d}`,{headers:c}),fetch(`${o}/repos/${t}/issues/${p.number}/comments?per_page=100${d}`,{headers:c})]);if(!h.ok||!m.ok)return;let _=rc.parse(await h.json()),y=tc.parse(await m.json()),S=s?_.filter(X=>X.user?.login!==s):_,b=s?y.filter(X=>X.user?.login!==s):y,O=S.length>0,N=b.some(X=>X.body&&se(X.body)),I=O||N,j;if(!I)try{let X=await fetch(`${o}/repos/${t}/pulls/${p.number}/reviews?per_page=100`,{headers:c});if(X.ok){let ae=ku.parse(await X.json()),le=new Map;for(let ne of ae)ne.state==="PENDING"||ne.state==="DISMISSED"||le.set(ne.user.login,ne.state);let pe=[...le.entries()].filter(([,ne])=>ne==="CHANGES_REQUESTED");pe.length>0&&(I=!0,j=pe.map(([ne])=>ne))}}catch{}return{changesRequested:I,prNumber:p.number,prUrl:p.html_url,reviewers:j}}catch{return}}async function hl(e,t,r,n=W,o,i){try{let s=re(e),c=o?`&since=${o}`:"",[a,u]=await Promise.all([fetch(`${n}/repos/${t}/pulls/${r}/comments?per_page=100${c}`,{headers:s}),fetch(`${n}/repos/${t}/issues/${r}/comments?per_page=100${c}`,{headers:s})]);if(!a.ok||!u.ok)return[];let p=rc.parse(await a.json()),d=tc.parse(await u.json()),h=i?p.filter(y=>y.user?.login!==i):p,m=i?d.filter(y=>y.user?.login!==i):d,_=[];for(let y of h){if(!y.body)continue;let S=y.path?`[${y.path}] `:"";_.push(`${S}${y.body}`)}for(let y of m)y.body&&se(y.body)&&_.push(Ze(y.body));return _}catch{return[]}}async function gl(e,t,r,n,o=W){try{return(await fetch(`${o}/repos/${t}/issues/${r}/comments`,{method:"POST",headers:{...re(e),"Content-Type":"application/json"},body:JSON.stringify({body:n})})).ok}catch{return!1}}async function _l(e,t,r,n,o=W){try{return(await fetch(`${o}/repos/${t}/pulls/${r}/requested_reviewers`,{method:"POST",headers:{...re(e),"Content-Type":"application/json"},body:JSON.stringify({reviewers:n})})).ok}catch{return!1}}async function yl(e,t,r,n,o,i,s=W){return Ce(`${s}/repos/${t}/pulls`,re(e),{title:o,head:r,base:n,body:i},c=>{let a=c;return{url:a.html_url??"",number:a.number??0}},(c,a)=>c===422&&a.includes("already exists"))}var Uh=E({iid:ve(),web_url:x(),detailed_merge_status:$(x())}),bl=K(Uh),Bh=E({body:x(),resolvable:Ke(),resolved:$(Ke()),system:Ke(),type:$(ar(x())),created_at:$(x()),position:$(E({new_path:$(x())})),author:$(E({username:x()}))}),Fh=E({id:$(x()),notes:K(Bh)}),cc=K(Fh);async function xl(e,t,r,n,o,i,s){let c=encodeURIComponent(r);return Ce(`${t}/projects/${c}/merge_requests`,{"PRIVATE-TOKEN":e},{source_branch:n,target_branch:o,title:i,description:s,remove_source_branch:!0},a=>{let u=a;return{url:u.web_url??"",number:u.iid??0}},(a,u)=>a===409&&u.includes("already exists"))}async function $l(e,t,r,n,o){try{let i=encodeURIComponent(r);return(await fetch(`${t}/projects/${i}/merge_requests/${n}/notes`,{method:"POST",headers:{"PRIVATE-TOKEN":e,"Content-Type":"application/json"},body:JSON.stringify({body:o})})).ok}catch{return!1}}async function vl(e,t,r,n,o){let i=encodeURIComponent(r),s=0;for(let c of o)try{(await fetch(`${t}/projects/${i}/merge_requests/${n}/discussions/${c}`,{method:"PUT",headers:{"PRIVATE-TOKEN":e,"Content-Type":"application/json"},body:JSON.stringify({resolved:!0})})).ok&&s++}catch{}return s}async function wl(e,t,r,n,o){try{let i=encodeURIComponent(r),s=`${t}/projects/${i}/merge_requests?source_branch=${n}&state=opened`,c=await fetch(s,{headers:{"PRIVATE-TOKEN":e}});if(!c.ok)return;let a=bl.parse(await c.json());if(a.length===0)return;let u=a[0],p=`${t}/projects/${i}/merge_requests/${u.iid}/discussions?per_page=100`,d=await fetch(p,{headers:{"PRIVATE-TOKEN":e}});if(!d.ok)return;let h=cc.parse(await d.json()),m=!1;for(let _ of h){for(let y of _.notes)if(!y.system&&!(o&&y.created_at&&y.created_at<=o)){if(y.type==="DiffNote"&&y.resolvable!==!1&&y.resolved!==!0){m=!0;break}if(se(y.body)){m=!0;break}}if(m)break}return{changesRequested:m,prNumber:u.iid,prUrl:u.web_url}}catch{return}}async function zl(e,t,r,n,o){try{let i=encodeURIComponent(r),s=`${t}/projects/${i}/merge_requests/${n}/discussions?per_page=100`,c=await fetch(s,{headers:{"PRIVATE-TOKEN":e}});if(!c.ok)return{comments:[],discussionIds:[]};let a=cc.parse(await c.json()),u=[],p=[];for(let d of a){let h=!1;for(let m of d.notes)if(!m.system&&!(o&&m.created_at&&m.created_at<=o))if(m.type==="DiffNote"&&m.resolvable!==!1&&m.resolved!==!0){let _=m.position?.new_path?`[${m.position.new_path}] `:"";u.push(`${_}${m.body}`),h=!0}else se(m.body)&&(u.push(Ze(m.body)),h=!0);h&&d.id&&p.push(d.id)}return{comments:u,discussionIds:p}}catch{return{comments:[],discussionIds:[]}}}function zt(e,t){let r=B(e);switch(t.host){case"github":if(r.GITHUB_TOKEN)return{token:r.GITHUB_TOKEN};break;case"gitlab":if(r.GITLAB_TOKEN)return{token:r.GITLAB_TOKEN};break;case"bitbucket":if(r.BITBUCKET_USER&&r.BITBUCKET_TOKEN)return{token:r.BITBUCKET_TOKEN,username:r.BITBUCKET_USER};break;case"bitbucket-server":if(r.BITBUCKET_TOKEN)return{token:r.BITBUCKET_TOKEN};break}}async function kt(e,t,r,n,o,i){let s=zt(e,t);if(!s)return;let c=wt(t,B(e).CLANCY_GIT_API_URL);if(c)switch(t.host){case"github":return yl(s.token,`${t.owner}/${t.repo}`,r,n,o,i,c);case"gitlab":return xl(s.token,c,t.projectPath,r,n,o,i);case"bitbucket":return sl(s.username,s.token,t.workspace,t.repoSlug,r,n,o,i);case"bitbucket-server":return cl(s.token,c,t.projectKey,t.repoSlug,r,n,o,i);default:return}}function vr(e,t,r){let n=encodeURIComponent(t),o=encodeURIComponent(r);if(e.host==="github")return`https://${e.hostname}/${e.owner}/${e.repo}/compare/${o}...${n}`;if(e.host==="gitlab")return`https://${e.hostname}/${e.projectPath}/-/merge_requests/new?merge_request[source_branch]=${n}&merge_request[target_branch]=${o}`;if(e.host==="bitbucket")return`https://${e.hostname}/${e.workspace}/${e.repoSlug}/pull-requests/new?source=${n}&dest=${o}`;if(e.host==="bitbucket-server")return`https://${e.hostname}/projects/${e.projectKey}/repos/${e.repoSlug}/pull-requests?create&sourceBranch=refs/heads/${n}&targetBranch=refs/heads/${o}`}function ac(e,t){let r=fu(e),n=xt(e);if(r)return mr(e)?!0:(console.log(R(`\u26A0 Epic branch ${e} exists on remote but could not be fetched.`)),!1);if(n)return console.log(qe(`\u2717 Epic branch ${e} exists locally but not on remote.`)),console.log(R(" This may contain work from a previous Clancy version that squash-merged locally.")),console.log(w(" To preserve this work, push it manually:")),console.log(w(` git push -u origin ${e}`)),console.log(w(" Then re-run /clancy:once to continue.")),!1;try{if(kl("git",["fetch","origin",t],{encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:15e3}),kl("git",["checkout","-b",e,`origin/${t}`],{encoding:"utf8"}),$t(e))console.log(U(` \u2713 Created epic branch ${e}`));else return console.log(R(`\u26A0 Created ${e} locally but could not push to origin.`)),!1;return!0}catch(o){return console.log(qe(`\u2717 Could not create epic branch: ${o instanceof Error?o.message:String(o)}`)),!1}}async function uc(e,t,r,n,o,i=!1,s){if(!$t(r)){console.log(R(`\u26A0 Could not push ${r} to origin.`)),console.log(w(" The branch is still available locally. Push manually:")),console.log(w(` git push -u origin ${r}`)),i||M(process.cwd(),t.key,t.title,"PUSH_FAILED",void 0,s),L(n);let m=bt(Date.now()-o);return console.log(""),console.log(R(`\u26A0 ${t.key} implemented but push failed`)+w(` (${m})`)),!1}console.log(U(` \u2713 Pushed ${r}`));let a;try{let m=Kh(process.cwd(),".clancy","verify-attempt.txt"),_=Jh(m,"utf8").trim(),y=parseInt(_,10);y>0&&(a=`Verification checks did not fully pass (${y} attempt(s)). Review carefully.`)}catch{}let u=B(e).CLANCY_GIT_PLATFORM,p=ke(u),d=`feat(${t.key}): ${t.title}`,h=$r(e,{key:t.key,title:t.title,description:t.description,provider:e.provider},n,a);if(p.host!=="none"&&p.host!=="unknown"&&p.host!=="azure"){let m=await kt(e,p,r,n,d,h);if(m?.ok)console.log(U(` \u2713 PR created: ${m.url}`)),i||M(process.cwd(),t.key,t.title,"PR_CREATED",m.number,s);else if(m&&!m.ok&&m.alreadyExists)console.log(R(` \u26A0 A PR/MR already exists for ${r}. Branch pushed.`)),i||M(process.cwd(),t.key,t.title,"PUSHED",void 0,s);else if(m&&!m.ok){console.log(R(` \u26A0 PR/MR creation failed: ${m.error}`));let _=vr(p,r,n);console.log(_?w(` Create one manually: ${_}`):w(" Branch pushed \u2014 create a PR/MR manually.")),i||M(process.cwd(),t.key,t.title,"PUSHED",void 0,s)}else{let _=vr(p,r,n);console.log(_?w(` Create a PR: ${_}`):w(" Branch pushed to remote. Create a PR/MR manually.")),i||M(process.cwd(),t.key,t.title,"PUSHED",void 0,s)}}else p.host==="none"?(console.log(R(`\u26A0 No git remote configured. Branch available locally: ${r}`)),i||M(process.cwd(),t.key,t.title,"LOCAL",void 0,s)):(console.log(w(" Branch pushed to remote. Create a PR/MR manually.")),i||M(process.cwd(),t.key,t.title,"PUSHED",void 0,s));if(e.provider!=="github"){let m=e.env.CLANCY_STATUS_REVIEW??e.env.CLANCY_STATUS_DONE;m&&await vt(e,t,m)}return L(n),!0}async function Sl(e,t,r,n,o){console.log(""),console.log(U(`\u{1F389} All children of ${t} are done!`)),console.log(w(` Creating epic PR: ${n} \u2192 ${o}`));let i=q(process.cwd(),"PR_CREATED"),s=q(process.cwd(),"DONE"),c=q(process.cwd(),"REWORK"),a=q(process.cwd(),"PUSHED"),u=[...i,...s,...c,...a].filter(S=>S.parent===t),p=B(e).CLANCY_GIT_PLATFORM,d=ke(p),h=`feat(${t}): ${r}`,m=rl(t,r,u);if(d.host==="none"||d.host==="unknown"||d.host==="azure")return console.log(R("\u26A0 Cannot create epic PR \u2014 no supported git remote detected.")),console.log(w(` Push manually: git push origin ${n}`)),console.log(w(` Then create a PR targeting ${o}`)),!1;let _=await kt(e,d,n,o,h,m);if(_?.ok){if(console.log(U(` \u2713 Epic PR created: ${_.url}`)),M(process.cwd(),t,r,"EPIC_PR_CREATED",_.number),e.provider!=="github"){let S=e.env.CLANCY_STATUS_REVIEW??e.env.CLANCY_STATUS_DONE;S&&await vt(e,{key:t,title:r,description:"",parentInfo:"none",blockers:"None"},S)}return!0}if(_&&!_.ok&&_.alreadyExists)return console.log(R(` \u26A0 An epic PR already exists for ${n}.`)),M(process.cwd(),t,r,"EPIC_PR_CREATED"),!0;console.log(R(`\u26A0 Epic PR creation failed: ${_?.error??"unknown error"}`)),console.log(w(" Create it manually:")),console.log(w(` Branch: ${n} \u2192 ${o}`));let y=vr(d,n,o);return y&&console.log(w(` ${y}`)),!1}function qh(e){return e?.isAfk??process.env.CLANCY_AFK_MODE==="1"}async function Gh(e,t){switch(e.provider){case"jira":{let{env:r}=e,n=Re(r.JIRA_USER,r.JIRA_API_TOKEN);return(await ju(r.JIRA_BASE_URL,n,r.JIRA_PROJECT_KEY,r.CLANCY_JQL_STATUS??"To Do",r.CLANCY_JQL_SPRINT,r.CLANCY_LABEL,t)).map(i=>{let s=i.blockers.length?`Blocked by: ${i.blockers.join(", ")}`:"None";return{key:i.key,title:i.title,description:i.description,parentInfo:i.epicKey??"none",blockers:s}})}case"github":{let{env:r}=e,n=await br(r.GITHUB_TOKEN);return(await Eu(r.GITHUB_TOKEN,r.GITHUB_REPO,r.CLANCY_LABEL,n,t)).map(i=>({key:i.key,title:i.title,description:i.description,parentInfo:i.milestone??"none",blockers:"None"}))}case"linear":{let{env:r}=e;return(await Hu({LINEAR_API_KEY:r.LINEAR_API_KEY,LINEAR_TEAM_ID:r.LINEAR_TEAM_ID,CLANCY_LABEL:r.CLANCY_LABEL},t)).map(o=>({key:o.key,title:o.title,description:o.description,parentInfo:o.parentIdentifier??"none",blockers:"None",linearIssueId:o.issueId,issueId:o.issueId}))}}}async function Yh(e,t){switch(e.provider){case"jira":{let{env:r}=e,n=Re(r.JIRA_USER,r.JIRA_API_TOKEN);return Ou(r.JIRA_BASE_URL,n,t.key)}case"github":{let{env:r}=e,n=parseInt(t.key.replace("#",""),10);return Number.isNaN(n)?!1:Iu(r.GITHUB_TOKEN,r.GITHUB_REPO,n,t.description)}case"linear":{let{env:r}=e;return t.issueId?Vu(r.LINEAR_API_KEY,t.issueId):!1}}}async function Pl(e,t){let r=qh(t),n=await Gh(e,r);if(n.length)for(let o of n){if(!await Yh(e,o))return o;console.log(`Skipping ${o.key} \u2014 blocked`)}}import{mkdirSync as Hh,readFileSync as Vh,unlinkSync as El,writeFileSync as Wh}from"node:fs";import{dirname as Xh,join as wr}from"node:path";function Il(e,t){let r=wr(e,".clancy","lock.json");Hh(Xh(r),{recursive:!0}),Wh(r,JSON.stringify(t,null,2),"utf8")}function lc(e){let t=wr(e,".clancy","lock.json");try{let r=Vh(t,"utf8");return JSON.parse(r)}catch{return}}function pc(e){let t=wr(e,".clancy","lock.json");try{El(t)}catch{}}function fc(e){let t=wr(e,".clancy","verify-attempt.txt");try{El(t)}catch{}}function Qh(e){try{return process.kill(e,0),!0}catch(t){return t instanceof Error&&"code"in t&&t.code==="EPERM"}}function Al(e){if(!Qh(e.pid))return!0;let t=Date.now()-new Date(e.startedAt).getTime();if(Number.isNaN(t))return!0;let r=1440*60*1e3;return t>r}import{execFileSync as St}from"node:child_process";function Tl(e){let t=e.ticketBranch;if(!xt(t))return;let r;try{r=St("git",["rev-parse","--abbrev-ref","HEAD"],{encoding:"utf8"}).trim()}catch{return}try{L(t)}catch{return}let n=!1,o=!1;try{n=dr()}catch{}try{o=St("git",["log",`origin/${t}..${t}`,"--oneline"],{encoding:"utf8"}).trim().length>0}catch{try{o=St("git",["log",`origin/${e.targetBranch}..${t}`,"--oneline"],{encoding:"utf8"}).trim().length>0}catch{}}try{L(r)}catch{}if(!(!n&&!o))return{branch:t,hasUncommitted:n,hasUnpushed:o}}async function Rl(e,t,r){try{if(L(r.branch),r.hasUncommitted)try{St("git",["add","-A"],{encoding:"utf8"}),St("git",["commit","-m",`fix(${t.ticketKey}): resume after crash`],{encoding:"utf8"}),console.log(U(` \u2713 Committed in-progress work for ${t.ticketKey}`))}catch{return console.log(R(` \u26A0 Could not commit changes on ${r.branch}`)),!1}if(!$t(r.branch))return console.log(R(` \u26A0 Could not push ${r.branch} to origin`)),!1;console.log(U(` \u2713 Pushed ${r.branch}`));let o=B(e).CLANCY_GIT_PLATFORM,i=ke(o),s=`feat(${t.ticketKey}): ${t.ticketTitle}`,c=$r(e,{key:t.ticketKey,title:t.ticketTitle,description:"",provider:e.provider},t.targetBranch);if(i.host!=="none"&&i.host!=="unknown"&&i.host!=="azure"){let a=await kt(e,i,r.branch,t.targetBranch,s,c);a?.ok?(console.log(U(` \u2713 PR created: ${a.url}`)),M(process.cwd(),t.ticketKey,t.ticketTitle,"RESUMED",a.number,t.parentKey&&t.parentKey!=="none"?t.parentKey:void 0)):(console.log(w(" Branch pushed \u2014 create a PR manually.")),M(process.cwd(),t.ticketKey,t.ticketTitle,"RESUMED",void 0,t.parentKey&&t.parentKey!=="none"?t.parentKey:void 0))}else M(process.cwd(),t.ticketKey,t.ticketTitle,"RESUMED",void 0,t.parentKey&&t.parentKey!=="none"?t.parentKey:void 0);try{L(t.targetBranch)}catch{}return!0}catch(n){return console.log(R(` \u26A0 Resume failed: ${n instanceof Error?n.message:String(n)}`)),!1}}async function Cl(e){let t=q(process.cwd(),"PR_CREATED"),r=q(process.cwd(),"REWORK"),n=q(process.cwd(),"PUSHED"),o=q(process.cwd(),"PUSH_FAILED"),i=[...t,...r,...n,...o];if(i.length===0)return;let s=B(e).CLANCY_GIT_PLATFORM,c=ke(s);if(c.host==="none"||c.host==="unknown"||c.host==="azure")return;let a=zt(e,c);if(!a)return;let u=wt(c,B(e).CLANCY_GIT_API_URL);if(!u)return;let p;if(c.host==="github")try{p=await br(a.token,u)}catch{}let d=i.slice(0,5);for(let h of d){let m=Et(e.provider,h.key),_;if(h.timestamp){let S=new Date(h.timestamp.replace(" ","T")+"Z");_=Number.isNaN(S.getTime())?void 0:S.toISOString()}let y;switch(c.host){case"github":y=await ml(a.token,`${c.owner}/${c.repo}`,m,c.owner,u,_,p);break;case"gitlab":y=await wl(a.token,u,c.projectPath,m,_);break;case"bitbucket":y=await ll(a.username,a.token,c.workspace,c.repoSlug,m,_);break;case"bitbucket-server":y=await fl(a.token,u,c.projectKey,c.repoSlug,m,_);break}if(y?.changesRequested){let S=[],b;switch(c.host){case"github":S=await hl(a.token,`${c.owner}/${c.repo}`,y.prNumber,u,_,p);break;case"gitlab":{let N=await zl(a.token,u,c.projectPath,y.prNumber,_);S=N.comments,b=N.discussionIds;break}case"bitbucket":S=await pl(a.username,a.token,c.workspace,c.repoSlug,y.prNumber,_);break;case"bitbucket-server":S=await dl(a.token,u,c.projectKey,c.repoSlug,y.prNumber,_);break}return{ticket:{key:h.key,title:h.summary,description:h.summary,parentInfo:h.parent??"none",blockers:"None"},feedback:S,prNumber:y.prNumber,discussionIds:b,reviewers:y.reviewers??[]}}}}function eg(e){if(e.length===0)return"[clancy] Rework pushed addressing reviewer feedback.";let t=e.length,r=e.slice(0,3).map(o=>`- ${o.slice(0,80)}`).join(`
|
|
183
184
|
`),n=e.length>3?`
|
|
184
185
|
- ...`:"";return`[clancy] Rework pushed addressing ${t} feedback item${t!==1?"s":""}.
|
|
185
186
|
|
|
186
|
-
${r}${n}`}async function
|
|
187
|
-
git push origin ${
|
|
188
|
-
Then create a PR targeting ${
|
|
187
|
+
${r}${n}`}async function Zl(e,t,r,n,o){let i=B(e).CLANCY_GIT_PLATFORM,s=ke(i);if(s.host==="none"||s.host==="unknown"||s.host==="azure")return;let c=zt(e,s);if(!c)return;let a=wt(s,B(e).CLANCY_GIT_API_URL);if(!a)return;let u=eg(r);try{let p=!1;switch(s.host){case"github":p=await gl(c.token,`${s.owner}/${s.repo}`,t,u,a);break;case"gitlab":p=await $l(c.token,a,s.projectPath,t,u);break;case"bitbucket":p=await al(c.username,c.token,s.workspace,s.repoSlug,t,u);break;case"bitbucket-server":p=await ul(c.token,a,s.projectKey,s.repoSlug,t,u);break}p&&console.log(w(" \u2713 Posted rework comment"))}catch{}if(s.host==="gitlab"&&n&&n.length>0)try{let p=await vl(c.token,a,s.projectPath,t,n);p>0&&console.log(w(` \u2713 Resolved ${p} discussion thread${p!==1?"s":""}`))}catch{}if(s.host==="github"&&o&&o.length>0)try{await _l(c.token,`${s.owner}/${s.repo}`,t,o,a)&&console.log(w(` \u2713 Re-requested review from ${o.join(", ")}`))}catch{}}async function ng(e){let t=e.includes("--dry-run"),r=e.includes("--skip-feasibility"),n=Date.now();console.log(w("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510")),console.log(w("\u2502")+hr(" \u{1F916} Clancy \u2014 once mode ")+w("\u2502")),console.log(w("\u2502")+w(` "Let's roll." `)+w("\u2502")),console.log(w("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518")),console.log("");let o=!1,i=lc(process.cwd());if(i){if(!Al(i)){console.log(R(`\u26A0 Another Clancy session is running (PID ${i.pid}, ticket ${i.ticketKey}). Aborting.`));return}console.log(w(` Stale lock found (PID ${i.pid}, ticket ${i.ticketKey}). Cleaning up...`)),pc(process.cwd()),fc(process.cwd());try{let c=Tl(i);if(c)if(process.env.CLANCY_AFK_MODE==="1"){console.log(R(` \u21BB Resuming crashed session: ${i.ticketKey} on ${c.branch}`));let u=ec(process.cwd());if(u.ok){let p=Vs(u.env);if(typeof p!="string"&&await Rl(p,i,c)){console.log(U(` \u2713 Resumed ${i.ticketKey}`));return}}}else console.log(R(` Found in-progress work on ${c.branch}.`+(c.hasUncommitted?" Has uncommitted changes.":"")+(c.hasUnpushed?" Has unpushed commits.":""))),console.log(w(" Run in AFK mode (CLANCY_AFK_MODE=1) to auto-resume, or handle manually."))}catch{}}let s;try{let c=ec(process.cwd());if(!c.ok){console.log(c.error);return}c.warning&&console.log(c.warning);let a=Vs(c.env);if(typeof a=="string"){console.log(a);return}let u=a,p=el(u);if(p){console.log(p);return}let d=await Qu(u);if(!d.ok){console.log(d.error);return}console.log(U("\u2705 Preflight passed"));try{let A=q(process.cwd(),"PR_CREATED"),oe=q(process.cwd(),"REWORK"),gc=q(process.cwd(),"PUSHED"),jl=[...A,...oe,...gc],Ol=new Set(q(process.cwd(),"EPIC_PR_CREATED").map(G=>G.key)),Ll=new Set(jl.map(G=>G.parent).filter(G=>!!G).filter(G=>!Ol.has(G))),kr=u.env.CLANCY_BASE_BRANCH??"main";for(let G of Ll){let Sr=await oc(u,G);if(Sr&&Sr.incomplete===0&&Sr.total>0){let _c=Pr(u.provider,kr,G),Ml=await Sl(u,G,G,_c,kr);console.log(Ml?U(` \u2713 Epic ${G} complete \u2014 PR created`):R(`\u26A0 Epic PR creation failed for ${G}. Create manually:
|
|
188
|
+
git push origin ${_c}
|
|
189
|
+
Then create a PR targeting ${kr}`))}}}catch{}let h=!1,m,_,y,S,b;try{let A=await Cl(u);A&&(h=!0,b=A.ticket,m=A.feedback,_=A.prNumber,y=A.discussionIds,S=A.reviewers,console.log(R(` \u21BB PR rework: [${b.key}] ${b.title}`)))}catch{}if(b||(b=await Pl(u)),!b){console.log(w("No tickets found. All done!"));return}if(h){let A=parseInt(B(u).CLANCY_MAX_REWORK??"3",10),oe=Number.isFinite(A)&&A>0?A:3;if(bu(process.cwd(),b.key)>=oe){console.log(R(`\u26A0 ${b.key} has reached max rework cycles (${oe}) \u2014 needs human intervention`)),M(process.cwd(),b.key,b.title,"SKIPPED");return}}let O=u.env.CLANCY_BASE_BRANCH??"main",N=b.parentInfo!=="none"?b.parentInfo:void 0,I=Et(u.provider,b.key),j=Pr(u.provider,O,N);if(t){let A=u.provider==="github"?"Milestone":"Epic";console.log(""),console.log(R("\u2500\u2500 Dry Run \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),console.log(` Ticket: ${hr(`[${b.key}]`)} ${b.title}`),h&&console.log(" Mode: Rework"),console.log(` ${A}:${" ".repeat(14-A.length)}${b.parentInfo}`),u.provider!=="github"&&console.log(` Blockers: ${b.blockers}`),console.log(` Target branch: ${I} \u2192 ${j}`),b.description&&console.log(` Description: ${b.description}`),console.log(R("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),console.log(w(" No changes made. Remove --dry-run to run for real."));return}let X=u.provider==="github"?"Milestone":"Epic";if(console.log(""),console.log(`\u{1F3AB} ${hr(`[${b.key}]`)} ${b.title}`),console.log(w(` ${X}: ${b.parentInfo} | Branch: ${I} \u2192 ${j}`)),u.provider!=="github"&&b.blockers!=="None"&&console.log(R(` Blockers: ${b.blockers}`)),console.log(""),!h&&!r){console.log(w(" Checking feasibility..."));let A=lu({key:b.key,title:b.title,description:b.description},u.env.CLANCY_MODEL);if(!A.feasible){let oe=A.reason??"not implementable as code changes";console.log(R(`\u23ED\uFE0F Ticket skipped [${b.key}]: ${oe}`)),M(process.cwd(),b.key,b.title,"SKIPPED");return}console.log(U(" \u2713 Feasibility check passed"))}console.log(""),s=pu();let ae=b.parentInfo!=="none",le=!1;if(ae&&!h){let A=await oc(u,b.parentInfo,b.linearIssueId);A&&A.total===1&&(le=!0)}let pe=ae&&!le?j:O;if(h){if(ae&&!le){if(!ac(j,O)){s&&L(s);return}}else Xs(pe,O);mr(I)?L(I):(L(pe),L(I,!0))}else if(ae&&!le){if(!ac(j,O)){s&&L(s);return}L(j),L(I,!0)}else Xs(O,O),L(O),L(I,!0);try{Il(process.cwd(),{pid:process.pid,ticketKey:b.key,ticketTitle:b.title,ticketBranch:I,targetBranch:pe,parentKey:b.parentInfo,description:(b.description??"").slice(0,2e3),startedAt:new Date().toISOString()}),o=!0}catch{console.log(w(" (warning: could not write lock file \u2014 crash recovery disabled)"))}let ne=u.env.CLANCY_STATUS_IN_PROGRESS;ne&&await vt(u,b,ne);let zr,dc=u.env.CLANCY_TDD==="true";h?zr=$u({key:b.key,title:b.title,description:b.description,provider:u.provider,feedbackComments:m??[],previousContext:du(j),tdd:dc}):zr=vu({provider:u.provider,key:b.key,title:b.title,description:b.description,parentInfo:b.parentInfo,blockers:u.provider!=="github"?b.blockers:void 0,tdd:dc}),process.env.CLANCY_ONCE_ACTIVE="1";let mc;try{mc=xc(zr,u.env.CLANCY_MODEL)}finally{delete process.env.CLANCY_ONCE_ACTIVE}if(!mc){console.log(R("\u26A0 Claude session exited with an error. Skipping merge."));return}let Pt=ae&&!le?b.parentInfo:void 0;if(h){if(!await uc(u,b,I,pe,n,!0,Pt)){M(process.cwd(),b.key,b.title,"PUSH_FAILED",void 0,Pt);return}M(process.cwd(),b.key,b.title,"REWORK",_,Pt),_!=null&&await Zl(u,_,m??[],y,S)}else if(!await uc(u,b,I,pe,n,!1,Pt))return;try{let A=lc(process.cwd());if(A){let oe=Number(u.env.CLANCY_TOKEN_RATE??"6600");tl(process.cwd(),b.key,A.startedAt,Number.isFinite(oe)&&oe>0?oe:6600)}}catch{}let Nl=bt(Date.now()-n);console.log(""),console.log(U(`\u{1F3C1} ${b.key} complete`)+w(` (${Nl})`)),console.log(w(` "Bake 'em away, toys."`));let hc=u.env.CLANCY_NOTIFY_WEBHOOK;hc&&await mu(hc,`\u2713 Clancy completed [${b.key}] ${b.title}`)}catch(c){let a=c instanceof Error?c.message:String(c),u=bt(Date.now()-n);if(console.error(""),console.error(qe("\u274C Clancy stopped")+w(` (${u})`)),console.error(qe(` ${a}`)),console.error(w(` "I'd rather let Herman go."`)),s)try{L(s)}catch{}}finally{o&&(pc(process.cwd()),fc(process.cwd()))}}process.argv[1]&&rg(import.meta.url)===tg(process.argv[1])&&ng(process.argv);export{ng as run};
|