@kyun.si/codex-hongguo 0.0.34 → 0.0.35-beta.2
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/.codex-plugin/plugin.json +1 -1
- package/README.en.md +14 -1
- package/README.md +14 -1
- package/dist/cli/main.mjs +7 -7
- package/dist/hooks/write.mjs +7 -2
- package/dist/server/index.mjs +13 -8
- package/dist/setup/check.mjs +8 -3
- package/dist/ui/player.html +189 -62
- package/package.json +1 -1
package/dist/server/index.mjs
CHANGED
|
@@ -13,7 +13,7 @@ var n1=Object.create;var Um=Object.defineProperty;var i1=Object.getOwnPropertyDe
|
|
|
13
13
|
`,nexist:"\u2204",nexists:"\u2204",Nfr:"\u{1D511}",nfr:"\u{1D52B}",ngE:"\u2267\u0338",nge:"\u2271",ngeq:"\u2271",ngeqq:"\u2267\u0338",ngeqslant:"\u2A7E\u0338",nges:"\u2A7E\u0338",nGg:"\u22D9\u0338",ngsim:"\u2275",nGt:"\u226B\u20D2",ngt:"\u226F",ngtr:"\u226F",nGtv:"\u226B\u0338",nhArr:"\u21CE",nharr:"\u21AE",nhpar:"\u2AF2",ni:"\u220B",nis:"\u22FC",nisd:"\u22FA",niv:"\u220B",NJcy:"\u040A",njcy:"\u045A",nlArr:"\u21CD",nlarr:"\u219A",nldr:"\u2025",nlE:"\u2266\u0338",nle:"\u2270",nLeftarrow:"\u21CD",nleftarrow:"\u219A",nLeftrightarrow:"\u21CE",nleftrightarrow:"\u21AE",nleq:"\u2270",nleqq:"\u2266\u0338",nleqslant:"\u2A7D\u0338",nles:"\u2A7D\u0338",nless:"\u226E",nLl:"\u22D8\u0338",nlsim:"\u2274",nLt:"\u226A\u20D2",nlt:"\u226E",nltri:"\u22EA",nltrie:"\u22EC",nLtv:"\u226A\u0338",nmid:"\u2224",NoBreak:"\u2060",NonBreakingSpace:"\xA0",Nopf:"\u2115",nopf:"\u{1D55F}",Not:"\u2AEC",not:"\xAC",NotCongruent:"\u2262",NotCupCap:"\u226D",NotDoubleVerticalBar:"\u2226",NotElement:"\u2209",NotEqual:"\u2260",NotEqualTilde:"\u2242\u0338",NotExists:"\u2204",NotGreater:"\u226F",NotGreaterEqual:"\u2271",NotGreaterFullEqual:"\u2267\u0338",NotGreaterGreater:"\u226B\u0338",NotGreaterLess:"\u2279",NotGreaterSlantEqual:"\u2A7E\u0338",NotGreaterTilde:"\u2275",NotHumpDownHump:"\u224E\u0338",NotHumpEqual:"\u224F\u0338",notin:"\u2209",notindot:"\u22F5\u0338",notinE:"\u22F9\u0338",notinva:"\u2209",notinvb:"\u22F7",notinvc:"\u22F6",NotLeftTriangle:"\u22EA",NotLeftTriangleBar:"\u29CF\u0338",NotLeftTriangleEqual:"\u22EC",NotLess:"\u226E",NotLessEqual:"\u2270",NotLessGreater:"\u2278",NotLessLess:"\u226A\u0338",NotLessSlantEqual:"\u2A7D\u0338",NotLessTilde:"\u2274",NotNestedGreaterGreater:"\u2AA2\u0338",NotNestedLessLess:"\u2AA1\u0338",notni:"\u220C",notniva:"\u220C",notnivb:"\u22FE",notnivc:"\u22FD",NotPrecedes:"\u2280",NotPrecedesEqual:"\u2AAF\u0338",NotPrecedesSlantEqual:"\u22E0",NotReverseElement:"\u220C",NotRightTriangle:"\u22EB",NotRightTriangleBar:"\u29D0\u0338",NotRightTriangleEqual:"\u22ED",NotSquareSubset:"\u228F\u0338",NotSquareSubsetEqual:"\u22E2",NotSquareSuperset:"\u2290\u0338",NotSquareSupersetEqual:"\u22E3",NotSubset:"\u2282\u20D2",NotSubsetEqual:"\u2288",NotSucceeds:"\u2281",NotSucceedsEqual:"\u2AB0\u0338",NotSucceedsSlantEqual:"\u22E1",NotSucceedsTilde:"\u227F\u0338",NotSuperset:"\u2283\u20D2",NotSupersetEqual:"\u2289",NotTilde:"\u2241",NotTildeEqual:"\u2244",NotTildeFullEqual:"\u2247",NotTildeTilde:"\u2249",NotVerticalBar:"\u2224",npar:"\u2226",nparallel:"\u2226",nparsl:"\u2AFD\u20E5",npart:"\u2202\u0338",npolint:"\u2A14",npr:"\u2280",nprcue:"\u22E0",npre:"\u2AAF\u0338",nprec:"\u2280",npreceq:"\u2AAF\u0338",nrArr:"\u21CF",nrarr:"\u219B",nrarrc:"\u2933\u0338",nrarrw:"\u219D\u0338",nRightarrow:"\u21CF",nrightarrow:"\u219B",nrtri:"\u22EB",nrtrie:"\u22ED",nsc:"\u2281",nsccue:"\u22E1",nsce:"\u2AB0\u0338",Nscr:"\u{1D4A9}",nscr:"\u{1D4C3}",nshortmid:"\u2224",nshortparallel:"\u2226",nsim:"\u2241",nsime:"\u2244",nsimeq:"\u2244",nsmid:"\u2224",nspar:"\u2226",nsqsube:"\u22E2",nsqsupe:"\u22E3",nsub:"\u2284",nsubE:"\u2AC5\u0338",nsube:"\u2288",nsubset:"\u2282\u20D2",nsubseteq:"\u2288",nsubseteqq:"\u2AC5\u0338",nsucc:"\u2281",nsucceq:"\u2AB0\u0338",nsup:"\u2285",nsupE:"\u2AC6\u0338",nsupe:"\u2289",nsupset:"\u2283\u20D2",nsupseteq:"\u2289",nsupseteqq:"\u2AC6\u0338",ntgl:"\u2279",Ntilde:"\xD1",ntilde:"\xF1",ntlg:"\u2278",ntriangleleft:"\u22EA",ntrianglelefteq:"\u22EC",ntriangleright:"\u22EB",ntrianglerighteq:"\u22ED",Nu:"\u039D",nu:"\u03BD",num:"#",numero:"\u2116",numsp:"\u2007",nvap:"\u224D\u20D2",nVDash:"\u22AF",nVdash:"\u22AE",nvDash:"\u22AD",nvdash:"\u22AC",nvge:"\u2265\u20D2",nvgt:">\u20D2",nvHarr:"\u2904",nvinfin:"\u29DE",nvlArr:"\u2902",nvle:"\u2264\u20D2",nvlt:"<\u20D2",nvltrie:"\u22B4\u20D2",nvrArr:"\u2903",nvrtrie:"\u22B5\u20D2",nvsim:"\u223C\u20D2",nwarhk:"\u2923",nwArr:"\u21D6",nwarr:"\u2196",nwarrow:"\u2196",nwnear:"\u2927",Oacute:"\xD3",oacute:"\xF3",oast:"\u229B",ocir:"\u229A",Ocirc:"\xD4",ocirc:"\xF4",Ocy:"\u041E",ocy:"\u043E",odash:"\u229D",Odblac:"\u0150",odblac:"\u0151",odiv:"\u2A38",odot:"\u2299",odsold:"\u29BC",OElig:"\u0152",oelig:"\u0153",ofcir:"\u29BF",Ofr:"\u{1D512}",ofr:"\u{1D52C}",ogon:"\u02DB",Ograve:"\xD2",ograve:"\xF2",ogt:"\u29C1",ohbar:"\u29B5",ohm:"\u03A9",oint:"\u222E",olarr:"\u21BA",olcir:"\u29BE",olcross:"\u29BB",oline:"\u203E",olt:"\u29C0",Omacr:"\u014C",omacr:"\u014D",Omega:"\u03A9",omega:"\u03C9",Omicron:"\u039F",omicron:"\u03BF",omid:"\u29B6",ominus:"\u2296",Oopf:"\u{1D546}",oopf:"\u{1D560}",opar:"\u29B7",OpenCurlyDoubleQuote:"\u201C",OpenCurlyQuote:"\u2018",operp:"\u29B9",oplus:"\u2295",Or:"\u2A54",or:"\u2228",orarr:"\u21BB",ord:"\u2A5D",order:"\u2134",orderof:"\u2134",ordf:"\xAA",ordm:"\xBA",origof:"\u22B6",oror:"\u2A56",orslope:"\u2A57",orv:"\u2A5B",oS:"\u24C8",Oscr:"\u{1D4AA}",oscr:"\u2134",Oslash:"\xD8",oslash:"\xF8",osol:"\u2298",Otilde:"\xD5",otilde:"\xF5",Otimes:"\u2A37",otimes:"\u2297",otimesas:"\u2A36",Ouml:"\xD6",ouml:"\xF6",ovbar:"\u233D",OverBar:"\u203E",OverBrace:"\u23DE",OverBracket:"\u23B4",OverParenthesis:"\u23DC",par:"\u2225",para:"\xB6",parallel:"\u2225",parsim:"\u2AF3",parsl:"\u2AFD",part:"\u2202",PartialD:"\u2202",Pcy:"\u041F",pcy:"\u043F",percnt:"%",period:".",permil:"\u2030",perp:"\u22A5",pertenk:"\u2031",Pfr:"\u{1D513}",pfr:"\u{1D52D}",Phi:"\u03A6",phi:"\u03C6",phiv:"\u03D5",phmmat:"\u2133",phone:"\u260E",Pi:"\u03A0",pi:"\u03C0",pitchfork:"\u22D4",piv:"\u03D6",planck:"\u210F",planckh:"\u210E",plankv:"\u210F",plus:"+",plusacir:"\u2A23",plusb:"\u229E",pluscir:"\u2A22",plusdo:"\u2214",plusdu:"\u2A25",pluse:"\u2A72",PlusMinus:"\xB1",plusmn:"\xB1",plussim:"\u2A26",plustwo:"\u2A27",pm:"\xB1",Poincareplane:"\u210C",pointint:"\u2A15",Popf:"\u2119",popf:"\u{1D561}",pound:"\xA3",Pr:"\u2ABB",pr:"\u227A",prap:"\u2AB7",prcue:"\u227C",prE:"\u2AB3",pre:"\u2AAF",prec:"\u227A",precapprox:"\u2AB7",preccurlyeq:"\u227C",Precedes:"\u227A",PrecedesEqual:"\u2AAF",PrecedesSlantEqual:"\u227C",PrecedesTilde:"\u227E",preceq:"\u2AAF",precnapprox:"\u2AB9",precneqq:"\u2AB5",precnsim:"\u22E8",precsim:"\u227E",Prime:"\u2033",prime:"\u2032",primes:"\u2119",prnap:"\u2AB9",prnE:"\u2AB5",prnsim:"\u22E8",prod:"\u220F",Product:"\u220F",profalar:"\u232E",profline:"\u2312",profsurf:"\u2313",prop:"\u221D",Proportion:"\u2237",Proportional:"\u221D",propto:"\u221D",prsim:"\u227E",prurel:"\u22B0",Pscr:"\u{1D4AB}",pscr:"\u{1D4C5}",Psi:"\u03A8",psi:"\u03C8",puncsp:"\u2008",Qfr:"\u{1D514}",qfr:"\u{1D52E}",qint:"\u2A0C",Qopf:"\u211A",qopf:"\u{1D562}",qprime:"\u2057",Qscr:"\u{1D4AC}",qscr:"\u{1D4C6}",quaternions:"\u210D",quatint:"\u2A16",quest:"?",questeq:"\u225F",QUOT:'"',quot:'"',rAarr:"\u21DB",race:"\u223D\u0331",Racute:"\u0154",racute:"\u0155",radic:"\u221A",raemptyv:"\u29B3",Rang:"\u27EB",rang:"\u27E9",rangd:"\u2992",range:"\u29A5",rangle:"\u27E9",raquo:"\xBB",Rarr:"\u21A0",rArr:"\u21D2",rarr:"\u2192",rarrap:"\u2975",rarrb:"\u21E5",rarrbfs:"\u2920",rarrc:"\u2933",rarrfs:"\u291E",rarrhk:"\u21AA",rarrlp:"\u21AC",rarrpl:"\u2945",rarrsim:"\u2974",Rarrtl:"\u2916",rarrtl:"\u21A3",rarrw:"\u219D",rAtail:"\u291C",ratail:"\u291A",ratio:"\u2236",rationals:"\u211A",RBarr:"\u2910",rBarr:"\u290F",rbarr:"\u290D",rbbrk:"\u2773",rbrace:"}",rbrack:"]",rbrke:"\u298C",rbrksld:"\u298E",rbrkslu:"\u2990",Rcaron:"\u0158",rcaron:"\u0159",Rcedil:"\u0156",rcedil:"\u0157",rceil:"\u2309",rcub:"}",Rcy:"\u0420",rcy:"\u0440",rdca:"\u2937",rdldhar:"\u2969",rdquo:"\u201D",rdquor:"\u201D",rdsh:"\u21B3",Re:"\u211C",real:"\u211C",realine:"\u211B",realpart:"\u211C",reals:"\u211D",rect:"\u25AD",REG:"\xAE",reg:"\xAE",ReverseElement:"\u220B",ReverseEquilibrium:"\u21CB",ReverseUpEquilibrium:"\u296F",rfisht:"\u297D",rfloor:"\u230B",Rfr:"\u211C",rfr:"\u{1D52F}",rHar:"\u2964",rhard:"\u21C1",rharu:"\u21C0",rharul:"\u296C",Rho:"\u03A1",rho:"\u03C1",rhov:"\u03F1",RightAngleBracket:"\u27E9",RightArrow:"\u2192",Rightarrow:"\u21D2",rightarrow:"\u2192",RightArrowBar:"\u21E5",RightArrowLeftArrow:"\u21C4",rightarrowtail:"\u21A3",RightCeiling:"\u2309",RightDoubleBracket:"\u27E7",RightDownTeeVector:"\u295D",RightDownVector:"\u21C2",RightDownVectorBar:"\u2955",RightFloor:"\u230B",rightharpoondown:"\u21C1",rightharpoonup:"\u21C0",rightleftarrows:"\u21C4",rightleftharpoons:"\u21CC",rightrightarrows:"\u21C9",rightsquigarrow:"\u219D",RightTee:"\u22A2",RightTeeArrow:"\u21A6",RightTeeVector:"\u295B",rightthreetimes:"\u22CC",RightTriangle:"\u22B3",RightTriangleBar:"\u29D0",RightTriangleEqual:"\u22B5",RightUpDownVector:"\u294F",RightUpTeeVector:"\u295C",RightUpVector:"\u21BE",RightUpVectorBar:"\u2954",RightVector:"\u21C0",RightVectorBar:"\u2953",ring:"\u02DA",risingdotseq:"\u2253",rlarr:"\u21C4",rlhar:"\u21CC",rlm:"\u200F",rmoust:"\u23B1",rmoustache:"\u23B1",rnmid:"\u2AEE",roang:"\u27ED",roarr:"\u21FE",robrk:"\u27E7",ropar:"\u2986",Ropf:"\u211D",ropf:"\u{1D563}",roplus:"\u2A2E",rotimes:"\u2A35",RoundImplies:"\u2970",rpar:")",rpargt:"\u2994",rppolint:"\u2A12",rrarr:"\u21C9",Rrightarrow:"\u21DB",rsaquo:"\u203A",Rscr:"\u211B",rscr:"\u{1D4C7}",Rsh:"\u21B1",rsh:"\u21B1",rsqb:"]",rsquo:"\u2019",rsquor:"\u2019",rthree:"\u22CC",rtimes:"\u22CA",rtri:"\u25B9",rtrie:"\u22B5",rtrif:"\u25B8",rtriltri:"\u29CE",RuleDelayed:"\u29F4",ruluhar:"\u2968",rx:"\u211E",Sacute:"\u015A",sacute:"\u015B",sbquo:"\u201A",Sc:"\u2ABC",sc:"\u227B",scap:"\u2AB8",Scaron:"\u0160",scaron:"\u0161",sccue:"\u227D",scE:"\u2AB4",sce:"\u2AB0",Scedil:"\u015E",scedil:"\u015F",Scirc:"\u015C",scirc:"\u015D",scnap:"\u2ABA",scnE:"\u2AB6",scnsim:"\u22E9",scpolint:"\u2A13",scsim:"\u227F",Scy:"\u0421",scy:"\u0441",sdot:"\u22C5",sdotb:"\u22A1",sdote:"\u2A66",searhk:"\u2925",seArr:"\u21D8",searr:"\u2198",searrow:"\u2198",sect:"\xA7",semi:";",seswar:"\u2929",setminus:"\u2216",setmn:"\u2216",sext:"\u2736",Sfr:"\u{1D516}",sfr:"\u{1D530}",sfrown:"\u2322",sharp:"\u266F",SHCHcy:"\u0429",shchcy:"\u0449",SHcy:"\u0428",shcy:"\u0448",ShortDownArrow:"\u2193",ShortLeftArrow:"\u2190",shortmid:"\u2223",shortparallel:"\u2225",ShortRightArrow:"\u2192",ShortUpArrow:"\u2191",shy:"\xAD",Sigma:"\u03A3",sigma:"\u03C3",sigmaf:"\u03C2",sigmav:"\u03C2",sim:"\u223C",simdot:"\u2A6A",sime:"\u2243",simeq:"\u2243",simg:"\u2A9E",simgE:"\u2AA0",siml:"\u2A9D",simlE:"\u2A9F",simne:"\u2246",simplus:"\u2A24",simrarr:"\u2972",slarr:"\u2190",SmallCircle:"\u2218",smallsetminus:"\u2216",smashp:"\u2A33",smeparsl:"\u29E4",smid:"\u2223",smile:"\u2323",smt:"\u2AAA",smte:"\u2AAC",smtes:"\u2AAC\uFE00",SOFTcy:"\u042C",softcy:"\u044C",sol:"/",solb:"\u29C4",solbar:"\u233F",Sopf:"\u{1D54A}",sopf:"\u{1D564}",spades:"\u2660",spadesuit:"\u2660",spar:"\u2225",sqcap:"\u2293",sqcaps:"\u2293\uFE00",sqcup:"\u2294",sqcups:"\u2294\uFE00",Sqrt:"\u221A",sqsub:"\u228F",sqsube:"\u2291",sqsubset:"\u228F",sqsubseteq:"\u2291",sqsup:"\u2290",sqsupe:"\u2292",sqsupset:"\u2290",sqsupseteq:"\u2292",squ:"\u25A1",Square:"\u25A1",square:"\u25A1",SquareIntersection:"\u2293",SquareSubset:"\u228F",SquareSubsetEqual:"\u2291",SquareSuperset:"\u2290",SquareSupersetEqual:"\u2292",SquareUnion:"\u2294",squarf:"\u25AA",squf:"\u25AA",srarr:"\u2192",Sscr:"\u{1D4AE}",sscr:"\u{1D4C8}",ssetmn:"\u2216",ssmile:"\u2323",sstarf:"\u22C6",Star:"\u22C6",star:"\u2606",starf:"\u2605",straightepsilon:"\u03F5",straightphi:"\u03D5",strns:"\xAF",Sub:"\u22D0",sub:"\u2282",subdot:"\u2ABD",subE:"\u2AC5",sube:"\u2286",subedot:"\u2AC3",submult:"\u2AC1",subnE:"\u2ACB",subne:"\u228A",subplus:"\u2ABF",subrarr:"\u2979",Subset:"\u22D0",subset:"\u2282",subseteq:"\u2286",subseteqq:"\u2AC5",SubsetEqual:"\u2286",subsetneq:"\u228A",subsetneqq:"\u2ACB",subsim:"\u2AC7",subsub:"\u2AD5",subsup:"\u2AD3",succ:"\u227B",succapprox:"\u2AB8",succcurlyeq:"\u227D",Succeeds:"\u227B",SucceedsEqual:"\u2AB0",SucceedsSlantEqual:"\u227D",SucceedsTilde:"\u227F",succeq:"\u2AB0",succnapprox:"\u2ABA",succneqq:"\u2AB6",succnsim:"\u22E9",succsim:"\u227F",SuchThat:"\u220B",Sum:"\u2211",sum:"\u2211",sung:"\u266A",Sup:"\u22D1",sup:"\u2283",sup1:"\xB9",sup2:"\xB2",sup3:"\xB3",supdot:"\u2ABE",supdsub:"\u2AD8",supE:"\u2AC6",supe:"\u2287",supedot:"\u2AC4",Superset:"\u2283",SupersetEqual:"\u2287",suphsol:"\u27C9",suphsub:"\u2AD7",suplarr:"\u297B",supmult:"\u2AC2",supnE:"\u2ACC",supne:"\u228B",supplus:"\u2AC0",Supset:"\u22D1",supset:"\u2283",supseteq:"\u2287",supseteqq:"\u2AC6",supsetneq:"\u228B",supsetneqq:"\u2ACC",supsim:"\u2AC8",supsub:"\u2AD4",supsup:"\u2AD6",swarhk:"\u2926",swArr:"\u21D9",swarr:"\u2199",swarrow:"\u2199",swnwar:"\u292A",szlig:"\xDF",Tab:" ",target:"\u2316",Tau:"\u03A4",tau:"\u03C4",tbrk:"\u23B4",Tcaron:"\u0164",tcaron:"\u0165",Tcedil:"\u0162",tcedil:"\u0163",Tcy:"\u0422",tcy:"\u0442",tdot:"\u20DB",telrec:"\u2315",Tfr:"\u{1D517}",tfr:"\u{1D531}",there4:"\u2234",Therefore:"\u2234",therefore:"\u2234",Theta:"\u0398",theta:"\u03B8",thetasym:"\u03D1",thetav:"\u03D1",thickapprox:"\u2248",thicksim:"\u223C",ThickSpace:"\u205F\u200A",thinsp:"\u2009",ThinSpace:"\u2009",thkap:"\u2248",thksim:"\u223C",THORN:"\xDE",thorn:"\xFE",Tilde:"\u223C",tilde:"\u02DC",TildeEqual:"\u2243",TildeFullEqual:"\u2245",TildeTilde:"\u2248",times:"\xD7",timesb:"\u22A0",timesbar:"\u2A31",timesd:"\u2A30",tint:"\u222D",toea:"\u2928",top:"\u22A4",topbot:"\u2336",topcir:"\u2AF1",Topf:"\u{1D54B}",topf:"\u{1D565}",topfork:"\u2ADA",tosa:"\u2929",tprime:"\u2034",TRADE:"\u2122",trade:"\u2122",triangle:"\u25B5",triangledown:"\u25BF",triangleleft:"\u25C3",trianglelefteq:"\u22B4",triangleq:"\u225C",triangleright:"\u25B9",trianglerighteq:"\u22B5",tridot:"\u25EC",trie:"\u225C",triminus:"\u2A3A",TripleDot:"\u20DB",triplus:"\u2A39",trisb:"\u29CD",tritime:"\u2A3B",trpezium:"\u23E2",Tscr:"\u{1D4AF}",tscr:"\u{1D4C9}",TScy:"\u0426",tscy:"\u0446",TSHcy:"\u040B",tshcy:"\u045B",Tstrok:"\u0166",tstrok:"\u0167",twixt:"\u226C",twoheadleftarrow:"\u219E",twoheadrightarrow:"\u21A0",Uacute:"\xDA",uacute:"\xFA",Uarr:"\u219F",uArr:"\u21D1",uarr:"\u2191",Uarrocir:"\u2949",Ubrcy:"\u040E",ubrcy:"\u045E",Ubreve:"\u016C",ubreve:"\u016D",Ucirc:"\xDB",ucirc:"\xFB",Ucy:"\u0423",ucy:"\u0443",udarr:"\u21C5",Udblac:"\u0170",udblac:"\u0171",udhar:"\u296E",ufisht:"\u297E",Ufr:"\u{1D518}",ufr:"\u{1D532}",Ugrave:"\xD9",ugrave:"\xF9",uHar:"\u2963",uharl:"\u21BF",uharr:"\u21BE",uhblk:"\u2580",ulcorn:"\u231C",ulcorner:"\u231C",ulcrop:"\u230F",ultri:"\u25F8",Umacr:"\u016A",umacr:"\u016B",uml:"\xA8",UnderBar:"_",UnderBrace:"\u23DF",UnderBracket:"\u23B5",UnderParenthesis:"\u23DD",Union:"\u22C3",UnionPlus:"\u228E",Uogon:"\u0172",uogon:"\u0173",Uopf:"\u{1D54C}",uopf:"\u{1D566}",UpArrow:"\u2191",Uparrow:"\u21D1",uparrow:"\u2191",UpArrowBar:"\u2912",UpArrowDownArrow:"\u21C5",UpDownArrow:"\u2195",Updownarrow:"\u21D5",updownarrow:"\u2195",UpEquilibrium:"\u296E",upharpoonleft:"\u21BF",upharpoonright:"\u21BE",uplus:"\u228E",UpperLeftArrow:"\u2196",UpperRightArrow:"\u2197",Upsi:"\u03D2",upsi:"\u03C5",upsih:"\u03D2",Upsilon:"\u03A5",upsilon:"\u03C5",UpTee:"\u22A5",UpTeeArrow:"\u21A5",upuparrows:"\u21C8",urcorn:"\u231D",urcorner:"\u231D",urcrop:"\u230E",Uring:"\u016E",uring:"\u016F",urtri:"\u25F9",Uscr:"\u{1D4B0}",uscr:"\u{1D4CA}",utdot:"\u22F0",Utilde:"\u0168",utilde:"\u0169",utri:"\u25B5",utrif:"\u25B4",uuarr:"\u21C8",Uuml:"\xDC",uuml:"\xFC",uwangle:"\u29A7",vangrt:"\u299C",varepsilon:"\u03F5",varkappa:"\u03F0",varnothing:"\u2205",varphi:"\u03D5",varpi:"\u03D6",varpropto:"\u221D",vArr:"\u21D5",varr:"\u2195",varrho:"\u03F1",varsigma:"\u03C2",varsubsetneq:"\u228A\uFE00",varsubsetneqq:"\u2ACB\uFE00",varsupsetneq:"\u228B\uFE00",varsupsetneqq:"\u2ACC\uFE00",vartheta:"\u03D1",vartriangleleft:"\u22B2",vartriangleright:"\u22B3",Vbar:"\u2AEB",vBar:"\u2AE8",vBarv:"\u2AE9",Vcy:"\u0412",vcy:"\u0432",VDash:"\u22AB",Vdash:"\u22A9",vDash:"\u22A8",vdash:"\u22A2",Vdashl:"\u2AE6",Vee:"\u22C1",vee:"\u2228",veebar:"\u22BB",veeeq:"\u225A",vellip:"\u22EE",Verbar:"\u2016",verbar:"|",Vert:"\u2016",vert:"|",VerticalBar:"\u2223",VerticalLine:"|",VerticalSeparator:"\u2758",VerticalTilde:"\u2240",VeryThinSpace:"\u200A",Vfr:"\u{1D519}",vfr:"\u{1D533}",vltri:"\u22B2",vnsub:"\u2282\u20D2",vnsup:"\u2283\u20D2",Vopf:"\u{1D54D}",vopf:"\u{1D567}",vprop:"\u221D",vrtri:"\u22B3",Vscr:"\u{1D4B1}",vscr:"\u{1D4CB}",vsubnE:"\u2ACB\uFE00",vsubne:"\u228A\uFE00",vsupnE:"\u2ACC\uFE00",vsupne:"\u228B\uFE00",Vvdash:"\u22AA",vzigzag:"\u299A",Wcirc:"\u0174",wcirc:"\u0175",wedbar:"\u2A5F",Wedge:"\u22C0",wedge:"\u2227",wedgeq:"\u2259",weierp:"\u2118",Wfr:"\u{1D51A}",wfr:"\u{1D534}",Wopf:"\u{1D54E}",wopf:"\u{1D568}",wp:"\u2118",wr:"\u2240",wreath:"\u2240",Wscr:"\u{1D4B2}",wscr:"\u{1D4CC}",xcap:"\u22C2",xcirc:"\u25EF",xcup:"\u22C3",xdtri:"\u25BD",Xfr:"\u{1D51B}",xfr:"\u{1D535}",xhArr:"\u27FA",xharr:"\u27F7",Xi:"\u039E",xi:"\u03BE",xlArr:"\u27F8",xlarr:"\u27F5",xmap:"\u27FC",xnis:"\u22FB",xodot:"\u2A00",Xopf:"\u{1D54F}",xopf:"\u{1D569}",xoplus:"\u2A01",xotime:"\u2A02",xrArr:"\u27F9",xrarr:"\u27F6",Xscr:"\u{1D4B3}",xscr:"\u{1D4CD}",xsqcup:"\u2A06",xuplus:"\u2A04",xutri:"\u25B3",xvee:"\u22C1",xwedge:"\u22C0",Yacute:"\xDD",yacute:"\xFD",YAcy:"\u042F",yacy:"\u044F",Ycirc:"\u0176",ycirc:"\u0177",Ycy:"\u042B",ycy:"\u044B",yen:"\xA5",Yfr:"\u{1D51C}",yfr:"\u{1D536}",YIcy:"\u0407",yicy:"\u0457",Yopf:"\u{1D550}",yopf:"\u{1D56A}",Yscr:"\u{1D4B4}",yscr:"\u{1D4CE}",YUcy:"\u042E",yucy:"\u044E",Yuml:"\u0178",yuml:"\xFF",Zacute:"\u0179",zacute:"\u017A",Zcaron:"\u017D",zcaron:"\u017E",Zcy:"\u0417",zcy:"\u0437",Zdot:"\u017B",zdot:"\u017C",zeetrf:"\u2128",ZeroWidthSpace:"\u200B",Zeta:"\u0396",zeta:"\u03B6",Zfr:"\u2128",zfr:"\u{1D537}",ZHcy:"\u0416",zhcy:"\u0436",zigrarr:"\u21DD",Zopf:"\u2124",zopf:"\u{1D56B}",Zscr:"\u{1D4B5}",zscr:"\u{1D4CF}",zwj:"\u200D",zwnj:"\u200C"});lc.entityMap=lc.HTML_ENTITIES});var rT=S(e0=>{var pc=pa().NAMESPACE,Wb=pa().tagNamePattern,va=0,jn=1,Aa=2,dc=3,ya=4,_a=5,fc=6,Im=7;function ba(t,e){this.message=t,this.locator=e,Error.captureStackTrace&&Error.captureStackTrace(this,ba)}ba.prototype=new Error;ba.prototype.name=ba.name;function eT(){}eT.prototype={parse:function(t,e,r){var i=this.domBuilder;i.startDocument(),$9(e,e={}),A9(t,e,r,i,this.errorHandler),i.endDocument()}};function A9(t,e,r,i,n){function o(Se){if(Se>65535){Se-=65536;var Ke=55296+(Se>>10),yc=56320+(Se&1023);return String.fromCharCode(Ke,yc)}else return String.fromCharCode(Se)}function a(Se){var Ke=Se.slice(1,-1);return Object.hasOwnProperty.call(r,Ke)?r[Ke]:Ke.charAt(0)==="#"?o(parseInt(Ke.substr(1).replace("x","0x"))):(n.error("entity not found:"+Se),Se)}function s(Se){if(Se>f){var Ke=t.substring(f,Se).replace(/&#?\w+;/g,a);p&&u(f),i.characters(Ke,0,Se-f),f=Se}}function u(Se,Ke){for(;Se>=l&&(Ke=d.exec(t));)c=Ke.index,l=c+Ke[0].length,p.lineNumber++;p.columnNumber=Se-c+1}for(var c=0,l=0,d=/.*(?:\r\n?|\n)|.*$/g,p=i.locator,m=[{currentNSMap:e}],h={},f=0;;){try{var g=t.indexOf("<",f);if(g<0){if(!t.substr(f).match(/^\s*$/)){var y=i.doc,v=y.createTextNode(t.substr(f));y.appendChild(v),i.currentElement=v}return}switch(g>f&&s(g),t.charAt(g+1)){case"/":var X=t.indexOf(">",g+3),A=t.substring(g+2,X).replace(/^([\s\S]*?[^ \t\n\r])?[ \t\n\r]*$/,"$1"),x=m.pop();X<0?(A=t.substring(g+2).replace(/[\s<].*/,""),n.error("end tag name: "+A+" is not complete:"+x.tagName),X=g+1+A.length):A.match(/\s</)?(A=A.replace(/[\s<].*/,""),n.error("end tag name: "+A+" maybe not complete"),X=g+1+A.length):/[ \t\n\r]/.test(A)&&Wb.test(A.split(/[ \t\n\r]/)[0])&&n.error('end tag name is followed by whitespace and trailing content: "'+A+'"');var k=x.localNSMap,N=x.tagName==A,K=N||x.tagName&&x.tagName.toLowerCase()==A.toLowerCase();if(K){if(i.endElement(x.uri,x.localName,A),k)for(var Le in k)Object.prototype.hasOwnProperty.call(k,Le)&&i.endPrefixMapping(Le);N||n.fatalError("end tag name: "+A+" is not match the current start tagName:"+x.tagName)}else m.push(x);X++;break;case"?":p&&u(g),X=w9(t,g,i);break;case"!":p&&u(g),X=I9(t,g,i,n);break;default:p&&u(g);var de=new tT,Ue=m[m.length-1].currentNSMap,X=y9(t,g,de,Ue,a,n),jt=de.length;if(!de.closed&&b9(t,X,de.tagName,h)&&(de.closed=!0,r.nbsp||n.warning("unclosed xml attribute")),p&&jt){for(var nn=YD(p,{}),Bn=0;Bn<jt;Bn++){var Da=de[Bn];u(Da.offset),Da.locator=YD(p,{})}i.locator=nn,WD(de,i,Ue)&&m.push(de),i.locator=p}else WD(de,i,Ue)&&m.push(de);pc.isHTML(de.uri)&&!de.closed?X=_9(t,X,de.tagName,a,i):X++}}catch(Se){if(Se instanceof ba)throw Se;n.error("element parse error: "+Se),X=-1}X>f?f=X:s(Math.max(g,f)+1)}}function YD(t,e){return e.lineNumber=t.lineNumber,e.columnNumber=t.columnNumber,e}function y9(t,e,r,i,n,o){function a(m,h,f){r.attributeNames.hasOwnProperty(m)&&o.fatalError("Attribute "+m+" redefined"),r.addValue(m,h.replace(/[\t\n\r]/g," ").replace(/&#?\w+;/g,n),f)}for(var s,u,c=++e,l=va;;){var d=t.charAt(c);if(l===va&&d==="<")throw new Error("unexpected < in tag name: "+t.slice(e,c));switch(d){case"=":if(l===jn)s=t.slice(e,c),l=dc;else if(l===Aa)l=dc;else throw new Error("attribute equal must after attrName");break;case"'":case'"':if(l===dc||l===jn)if(l===jn&&(o.warning('attribute value must after "="'),s=t.slice(e,c)),e=c+1,c=t.indexOf(d,e),c>0)u=t.slice(e,c),a(s,u,e-1),l=_a;else throw new Error("attribute value no end '"+d+"' match");else if(l==ya)u=t.slice(e,c),a(s,u,e),o.warning('attribute "'+s+'" missed start quot('+d+")!!"),e=c+1,l=_a;else throw new Error('attribute value must after "="');break;case"/":switch(l){case va:r.setTagName(t.slice(e,c));case _a:case fc:case Im:l=Im,r.closed=!0;case ya:case jn:break;case Aa:r.closed=!0;break;default:throw new Error("attribute invalid close char('/')")}break;case"":return o.error("unexpected end of input"),l==va&&r.setTagName(t.slice(e,c)),c;case">":switch(l){case va:r.setTagName(t.slice(e,c));case _a:case fc:case Im:break;case ya:case jn:u=t.slice(e,c),u.slice(-1)==="/"&&(r.closed=!0,u=u.slice(0,-1));case Aa:l===Aa&&(u=s),l==ya?(o.warning('attribute "'+u+'" missed quot(")!'),a(s,u,e)):((!pc.isHTML(i[""])||!u.match(/^(?:disabled|checked|selected)$/i))&&o.warning('attribute "'+u+'" missed value!! "'+u+'" instead!!'),a(u,u,e));break;case dc:throw new Error("attribute value missed!!")}return c;case"\x80":d=" ";default:if(d<=" ")switch(l){case va:r.setTagName(t.slice(e,c)),l=fc;break;case jn:s=t.slice(e,c),l=Aa;break;case ya:var u=t.slice(e,c);o.warning('attribute "'+u+'" missed quot(")!!'),a(s,u,e);case _a:l=fc;break}else switch(l){case Aa:var p=r.tagName;(!pc.isHTML(i[""])||!s.match(/^(?:disabled|checked|selected)$/i))&&o.warning('attribute "'+s+'" missed value!! "'+s+'" instead2!!'),a(s,s,e),e=c,l=jn;break;case _a:o.warning('attribute space is required"'+s+'"!!');case fc:l=jn,e=c;break;case dc:l=ya,e=c;break;case Im:throw new Error("elements closed character '/' and '>' must be connected to")}}c++}}function WD(t,e,r){for(var i=t.tagName,n=null,d=t.length;d--;){var o=t[d],a=o.qName,s=o.value,p=a.indexOf(":");if(p>0)var u=o.prefix=a.slice(0,p),c=a.slice(p+1),l=u==="xmlns"&&c;else c=a,u=null,l=a==="xmlns"&&"";o.localName=c,l!==!1&&(n==null&&(n={},r=Object.create(r)),r[l]=n[l]=s,o.uri=pc.XMLNS,e.startPrefixMapping(l,s))}for(var d=t.length;d--;){o=t[d];var u=o.prefix;u&&(u==="xml"&&(o.uri=pc.XML),u!=="xmlns"&&(o.uri=r[u||""]))}var p=i.indexOf(":");p>0?(u=t.prefix=i.slice(0,p),c=t.localName=i.slice(p+1)):(u=null,c=t.localName=i);var m=t.uri=r[u||""];if(e.startElement(m,c,i,t),t.closed){if(e.endElement(m,c,i),n)for(u in n)Object.prototype.hasOwnProperty.call(n,u)&&e.endPrefixMapping(u)}else return t.currentNSMap=r,t.localNSMap=n,!0}function _9(t,e,r,i,n){if(/^(?:script|textarea)$/i.test(r)){var o=t.indexOf("</"+r+">",e),a=t.substring(e+1,o);if(/[&<]/.test(a))return/^script$/i.test(r)?(n.characters(a,0,a.length),o):(a=a.replace(/&#?\w+;/g,i),n.characters(a,0,a.length),o)}return e+1}function b9(t,e,r,i){var n=i[r];return n==null&&(n=t.lastIndexOf("</"+r+">"),n<e&&(n=t.lastIndexOf("</"+r)),i[r]=n),n<e}function $9(t,e){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}function I9(t,e,r,i){var n=t.charAt(e+2);switch(n){case"-":if(t.charAt(e+3)==="-"){var o=t.indexOf("-->",e+4);return o>e?(r.comment(t,e+4,o-e-4),o+3):(i.error("Unclosed comment"),-1)}else return-1;default:if(t.substr(e+3,6)=="CDATA["){var o=t.indexOf("]]>",e+9);return r.startCDATA(),r.characters(t,e+9,o-e-9),r.endCDATA(),o+3}var a=E9(t,e),s=a.length;if(s>1&&/!doctype/i.test(a[0][0])){var u=a[1][0],c=!1,l=!1;s>3&&(/^public$/i.test(a[2][0])?(c=a[3][0],l=s>4&&a[4][0]):/^system$/i.test(a[2][0])&&(l=a[3][0]));var d=a[s-1];return r.startDTD(u,c,l),r.endDTD(),d.index+d[0].length}}return-1}function w9(t,e,r){var i=t.indexOf("?>",e);if(i){var n=t.substring(e,i).match(/^<\?(\S*)\s*([\s\S]*?)$/);if(n){var o=n[0].length;return r.processingInstruction(n[1],n[2]),i+2}else return-1}return-1}function tT(){this.attributeNames={}}tT.prototype={setTagName:function(t){if(!Wb.test(t))throw new Error("invalid tagName:"+t);this.tagName=t},addValue:function(t,e,r){if(!Wb.test(t))throw new Error("invalid attribute:"+t);this.attributeNames[t]=this.length,this[this.length++]={qName:t,value:e,offset:r}},length:0,getLocalName:function(t){return this[t].localName},getLocator:function(t){return this[t].locator},getQName:function(t){return this[t].qName},getURI:function(t){return this[t].uri},getValue:function(t){return this[t].value}};function E9(t,e){var r,i=[],n=/'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;for(n.lastIndex=e,n.exec(t);r=n.exec(t);)if(i.push(r),r[1])return i}e0.XMLReader=eT;e0.ParseError=ba});var cT=S(Em=>{var x9=pa(),S9=Yb(),nT=XD(),aT=rT(),k9=S9.DOMImplementation,iT=x9.NAMESPACE,C9=aT.ParseError,D9=aT.XMLReader;function sT(t){return t.replace(/\r[\n\u0085]/g,`
|
|
14
14
|
`).replace(/[\r\u0085\u2028]/g,`
|
|
15
15
|
`)}function uT(t){this.options=t||{locator:{}}}uT.prototype.parseFromString=function(t,e){var r=this.options,i=new D9,n=r.domBuilder||new mc,o=r.errorHandler,a=r.locator,s=r.xmlns||{},u=/\/x?html?$/.test(e),c=u?nT.HTML_ENTITIES:nT.XML_ENTITIES;a&&n.setDocumentLocator(a),i.errorHandler=T9(o,n,a),i.domBuilder=r.domBuilder||n,u&&(s[""]=iT.HTML),s.xml=s.xml||iT.XML;var l=r.normalizeLineEndings||sT;return t&&typeof t=="string"?i.parse(l(t),s,c):i.errorHandler.error("invalid doc source"),n.doc};function T9(t,e,r){if(!t){if(e instanceof mc)return e;t=e}var i={},n=t instanceof Function;r=r||{};function o(a){var s=t[a];!s&&n&&(s=t.length==2?function(u){t(a,u)}:t),i[a]=s&&function(u){s("[xmldom "+a+"] "+u+t0(r))}||function(){}}return o("warning"),o("error"),o("fatalError"),i}function mc(){this.cdata=!1}function $a(t,e){e.lineNumber=t.lineNumber,e.columnNumber=t.columnNumber}mc.prototype={startDocument:function(){this.doc=new k9().createDocument(null,null,null),this.locator&&(this.doc.documentURI=this.locator.systemId)},startElement:function(t,e,r,i){var n=this.doc,o=n.createElementNS(t,r||e),a=i.length;wm(this,o),this.currentElement=o,this.locator&&$a(this.locator,o);for(var s=0;s<a;s++){var t=i.getURI(s),u=i.getValue(s),r=i.getQName(s),c=n.createAttributeNS(t,r);this.locator&&$a(i.getLocator(s),c),c.value=c.nodeValue=u,o.setAttributeNode(c)}},endElement:function(t,e,r){var i=this.currentElement,n=i.tagName;this.currentElement=i.parentNode},startPrefixMapping:function(t,e){},endPrefixMapping:function(t){},processingInstruction:function(t,e){var r=this.doc.createProcessingInstruction(t,e);this.locator&&$a(this.locator,r),wm(this,r)},ignorableWhitespace:function(t,e,r){},characters:function(t,e,r){if(t=oT.apply(this,arguments),t){if(this.cdata)var i=this.doc.createCDATASection(t);else var i=this.doc.createTextNode(t);this.currentElement?this.currentElement.appendChild(i):/^\s*$/.test(t)&&this.doc.appendChild(i),this.locator&&$a(this.locator,i)}},skippedEntity:function(t){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(t){(this.locator=t)&&(t.lineNumber=0)},comment:function(t,e,r){t=oT.apply(this,arguments);var i=this.doc.createComment(t);this.locator&&$a(this.locator,i),wm(this,i)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(t,e,r){var i=this.doc.implementation;if(i&&i.createDocumentType){var n=i.createDocumentType(t,e,r);this.locator&&$a(this.locator,n),wm(this,n),this.doc.doctype=n}},warning:function(t){console.warn("[xmldom warning] "+t,t0(this.locator))},error:function(t){console.error("[xmldom error] "+t,t0(this.locator))},fatalError:function(t){throw new C9(t,this.locator)}};function t0(t){if(t)return`
|
|
16
|
-
@`+(t.systemId||"")+"#[line:"+t.lineNumber+",col:"+t.columnNumber+"]"}function oT(t,e,r){return typeof t=="string"?t.substr(e,r):t.length>=e+r||e?new java.lang.String(t,e,r)+"":t}"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(t){mc.prototype[t]=function(){return null}});function wm(t,e){t.currentElement?t.currentElement.appendChild(e):t.doc.appendChild(e)}Em.__DOMHandler=mc;Em.normalizeLineEndings=sT;Em.DOMParser=uT});var dT=S(xm=>{var lT=Yb();xm.DOMImplementation=lT.DOMImplementation;xm.XMLSerializer=lT.XMLSerializer;xm.DOMParser=cT().DOMParser});var CT=S(yr=>{"use strict";Object.defineProperty(yr,"__esModule",{value:!0});var N9=_D(),z9=um(),P9=bD(),O9=zb(),R9=dT();function n0(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var i0=n0(N9),Rt=n0(z9),j9=n0(O9),B9="1.4.1",fT=t=>!!t&&typeof t=="object",Je=(...t)=>t.reduce((e,r)=>(typeof r!="object"||Object.keys(r).forEach(i=>{Array.isArray(e[i])&&Array.isArray(r[i])?e[i]=e[i].concat(r[i]):fT(e[i])&&fT(r[i])?e[i]=Je(e[i],r[i]):e[i]=r[i]}),e),{}),yT=t=>Object.keys(t).map(e=>t[e]),U9=(t,e)=>{let r=[];for(let i=t;i<e;i++)r.push(i);return r},wa=t=>t.reduce((e,r)=>e.concat(r),[]),_T=t=>{if(!t.length)return[];let e=[];for(let r=0;r<t.length;r++)e.push(t[r]);return e},M9=(t,e)=>t.reduce((r,i,n)=>(i[e]&&r.push(n),r),[]),L9=(t,e)=>yT(t.reduce((r,i)=>(i.forEach(n=>{r[e(n)]=n}),r),{})),Ea={INVALID_NUMBER_OF_PERIOD:"INVALID_NUMBER_OF_PERIOD",INVALID_NUMBER_OF_CONTENT_STEERING:"INVALID_NUMBER_OF_CONTENT_STEERING",DASH_EMPTY_MANIFEST:"DASH_EMPTY_MANIFEST",DASH_INVALID_XML:"DASH_INVALID_XML",NO_BASE_URL:"NO_BASE_URL",MISSING_SEGMENT_INFORMATION:"MISSING_SEGMENT_INFORMATION",SEGMENT_TIME_UNSPECIFIED:"SEGMENT_TIME_UNSPECIFIED",UNSUPPORTED_UTC_TIMING_SCHEME:"UNSUPPORTED_UTC_TIMING_SCHEME"},hc=({baseUrl:t="",source:e="",range:r="",indexRange:i=""})=>{let n={uri:e,resolvedUri:i0.default(t||"",e)};if(r||i){let a=(r||i).split("-"),s=Rt.default.BigInt?Rt.default.BigInt(a[0]):parseInt(a[0],10),u=Rt.default.BigInt?Rt.default.BigInt(a[1]):parseInt(a[1],10);s<Number.MAX_SAFE_INTEGER&&typeof s=="bigint"&&(s=Number(s)),u<Number.MAX_SAFE_INTEGER&&typeof u=="bigint"&&(u=Number(u));let c;typeof u=="bigint"||typeof s=="bigint"?c=Rt.default.BigInt(u)-Rt.default.BigInt(s)+Rt.default.BigInt(1):c=u-s+1,typeof c=="bigint"&&c<Number.MAX_SAFE_INTEGER&&(c=Number(c)),n.byterange={length:c,offset:s}}return n},F9=t=>{let e;return typeof t.offset=="bigint"||typeof t.length=="bigint"?e=Rt.default.BigInt(t.offset)+Rt.default.BigInt(t.length)-Rt.default.BigInt(1):e=t.offset+t.length-1,`${t.offset}-${e}`},pT=t=>(t&&typeof t!="number"&&(t=parseInt(t,10)),isNaN(t)?null:t),Z9={static(t){let{duration:e,timescale:r=1,sourceDuration:i,periodDuration:n}=t,o=pT(t.endNumber),a=e/r;return typeof o=="number"?{start:0,end:o}:typeof n=="number"?{start:0,end:n/a}:{start:0,end:i/a}},dynamic(t){let{NOW:e,clientOffset:r,availabilityStartTime:i,timescale:n=1,duration:o,periodStart:a=0,minimumUpdatePeriod:s=0,timeShiftBufferDepth:u=1/0}=t,c=pT(t.endNumber),l=(e+r)/1e3,d=i+a,m=l+s-d,h=Math.ceil(m*n/o),f=Math.floor((l-d-u)*n/o),g=Math.floor((l-d)*n/o);return{start:Math.max(0,f),end:typeof c=="number"?c:Math.min(h,g)}}},Q9=t=>e=>{let{duration:r,timescale:i=1,periodStart:n,startNumber:o=1}=t;return{number:o+e,duration:r/i,timeline:n,time:e*r}},o0=t=>{let{type:e,duration:r,timescale:i=1,periodDuration:n,sourceDuration:o}=t,{start:a,end:s}=Z9[e](t),u=U9(a,s).map(Q9(t));if(e==="static"){let c=u.length-1,l=typeof n=="number"?n:o;u[c].duration=l-r/i*c}return u},bT=t=>{let{baseUrl:e,initialization:r={},sourceDuration:i,indexRange:n="",periodStart:o,presentationTime:a,number:s=0,duration:u}=t;if(!e)throw new Error(Ea.NO_BASE_URL);let c=hc({baseUrl:e,source:r.sourceURL,range:r.range}),l=hc({baseUrl:e,source:e,indexRange:n});if(l.map=c,u){let d=o0(t);d.length&&(l.duration=d[0].duration,l.timeline=d[0].timeline)}else i&&(l.duration=i,l.timeline=o);return l.presentationTime=a||o,l.number=s,[l]},$T=(t,e,r)=>{let i=t.sidx.map?t.sidx.map:null,n=t.sidx.duration,o=t.timeline||0,a=t.sidx.byterange,s=a.offset+a.length,u=e.timescale,c=e.references.filter(g=>g.referenceType!==1),l=[],d=t.endList?"static":"dynamic",p=t.sidx.timeline,m=p,h=t.mediaSequence||0,f;typeof e.firstOffset=="bigint"?f=Rt.default.BigInt(s)+e.firstOffset:f=s+e.firstOffset;for(let g=0;g<c.length;g++){let y=e.references[g],v=y.referencedSize,A=y.subsegmentDuration,x;typeof f=="bigint"?x=f+Rt.default.BigInt(v)-Rt.default.BigInt(1):x=f+v-1;let k=`${f}-${x}`,K=bT({baseUrl:r,timescale:u,timeline:o,periodStart:p,presentationTime:m,number:h,duration:A,sourceDuration:n,indexRange:k,type:d})[0];i&&(K.map=i),l.push(K),typeof f=="bigint"?f+=Rt.default.BigInt(v):f+=v,m+=A/u,h++}return t.segments=l,t},q9=["AUDIO","SUBTITLES"],V9=1/60,IT=t=>L9(t,({timeline:e})=>e).sort((e,r)=>e.timeline>r.timeline?1:-1),H9=(t,e)=>{for(let r=0;r<t.length;r++)if(t[r].attributes.NAME===e)return t[r];return null},mT=t=>{let e=[];return P9.forEachMediaGroup(t,q9,(r,i,n,o)=>{e=e.concat(r.playlists||[])}),e},hT=({playlist:t,mediaSequence:e})=>{t.mediaSequence=e,t.segments.forEach((r,i)=>{r.number=t.mediaSequence+i})},G9=({oldPlaylists:t,newPlaylists:e,timelineStarts:r})=>{e.forEach(i=>{i.discontinuitySequence=r.findIndex(function({timeline:u}){return u===i.timeline});let n=H9(t,i.attributes.NAME);if(!n||i.sidx)return;let o=i.segments[0],a=n.segments.findIndex(function(u){return Math.abs(u.presentationTime-o.presentationTime)<V9});if(a===-1){hT({playlist:i,mediaSequence:n.mediaSequence+n.segments.length}),i.segments[0].discontinuity=!0,i.discontinuityStarts.unshift(0),(!n.segments.length&&i.timeline>n.timeline||n.segments.length&&i.timeline>n.segments[n.segments.length-1].timeline)&&i.discontinuitySequence--;return}n.segments[a].discontinuity&&!o.discontinuity&&(o.discontinuity=!0,i.discontinuityStarts.unshift(0),i.discontinuitySequence--),hT({playlist:i,mediaSequence:n.segments[a].number})})},J9=({oldManifest:t,newManifest:e})=>{let r=t.playlists.concat(mT(t)),i=e.playlists.concat(mT(e));return e.timelineStarts=IT([t.timelineStarts,e.timelineStarts]),G9({oldPlaylists:r,newPlaylists:i,timelineStarts:e.timelineStarts}),e},wT=t=>t&&t.uri+"-"+F9(t.byterange),r0=t=>{let e=t.reduce(function(i,n){return i[n.attributes.baseUrl]||(i[n.attributes.baseUrl]=[]),i[n.attributes.baseUrl].push(n),i},{}),r=[];return Object.values(e).forEach(i=>{let n=yT(i.reduce((o,a)=>{let s=a.attributes.id+(a.attributes.lang||"");return o[s]?(a.segments&&(a.segments[0]&&(a.segments[0].discontinuity=!0),o[s].segments.push(...a.segments)),a.attributes.contentProtection&&(o[s].attributes.contentProtection=a.attributes.contentProtection)):(o[s]=a,o[s].attributes.timelineStarts=[]),o[s].attributes.timelineStarts.push({start:a.attributes.periodStart,timeline:a.attributes.periodStart}),o},{}));r=r.concat(n)}),r.map(i=>(i.discontinuityStarts=M9(i.segments||[],"discontinuity"),i))},a0=(t,e)=>{let r=wT(t.sidx),i=r&&e[r]&&e[r].sidx;return i&&$T(t,i,t.sidx.resolvedUri),t},K9=(t,e={})=>{if(!Object.keys(e).length)return t;for(let r in t)t[r]=a0(t[r],e);return t},X9=({attributes:t,segments:e,sidx:r,mediaSequence:i,discontinuitySequence:n,discontinuityStarts:o},a)=>{let s={attributes:{NAME:t.id,BANDWIDTH:t.bandwidth,CODECS:t.codecs,"PROGRAM-ID":1},uri:"",endList:t.type==="static",timeline:t.periodStart,resolvedUri:t.baseUrl||"",targetDuration:t.duration,discontinuitySequence:n,discontinuityStarts:o,timelineStarts:t.timelineStarts,mediaSequence:i,segments:e};return t.contentProtection&&(s.contentProtection=t.contentProtection),t.serviceLocation&&(s.attributes.serviceLocation=t.serviceLocation),r&&(s.sidx=r),a&&(s.attributes.AUDIO="audio",s.attributes.SUBTITLES="subs"),s},Y9=({attributes:t,segments:e,mediaSequence:r,discontinuityStarts:i,discontinuitySequence:n})=>{typeof e>"u"&&(e=[{uri:t.baseUrl,timeline:t.periodStart,resolvedUri:t.baseUrl||"",duration:t.sourceDuration,number:0}],t.duration=t.sourceDuration);let o={NAME:t.id,BANDWIDTH:t.bandwidth,"PROGRAM-ID":1};t.codecs&&(o.CODECS=t.codecs);let a={attributes:o,uri:"",endList:t.type==="static",timeline:t.periodStart,resolvedUri:t.baseUrl||"",targetDuration:t.duration,timelineStarts:t.timelineStarts,discontinuityStarts:i,discontinuitySequence:n,mediaSequence:r,segments:e};return t.serviceLocation&&(a.attributes.serviceLocation=t.serviceLocation),a},W9=(t,e={},r=!1)=>{let i,n=t.reduce((o,a)=>{let s=a.attributes.role&&a.attributes.role.value||"",u=a.attributes.lang||"",c=a.attributes.label||"main";if(u&&!a.attributes.label){let d=s?` (${s})`:"";c=`${a.attributes.lang}${d}`}o[c]||(o[c]={language:u,autoselect:!0,default:s==="main",playlists:[],uri:""});let l=a0(X9(a,r),e);return o[c].playlists.push(l),typeof i>"u"&&s==="main"&&(i=a,i.default=!0),o},{});if(!i){let o=Object.keys(n)[0];n[o].default=!0}return n},eZ=(t,e={})=>t.reduce((r,i)=>{let n=i.attributes.label||i.attributes.lang||"text",o=i.attributes.lang||"und";return r[n]||(r[n]={language:o,default:!1,autoselect:!1,playlists:[],uri:""}),r[n].playlists.push(a0(Y9(i),e)),r},{}),tZ=t=>t.reduce((e,r)=>(r&&r.forEach(i=>{let{channel:n,language:o}=i;e[o]={autoselect:!1,default:!1,instreamId:n,language:o},i.hasOwnProperty("aspectRatio")&&(e[o].aspectRatio=i.aspectRatio),i.hasOwnProperty("easyReader")&&(e[o].easyReader=i.easyReader),i.hasOwnProperty("3D")&&(e[o]["3D"]=i["3D"])}),e),{}),rZ=({attributes:t,segments:e,sidx:r,discontinuityStarts:i})=>{let n={attributes:{NAME:t.id,AUDIO:"audio",SUBTITLES:"subs",RESOLUTION:{width:t.width,height:t.height},CODECS:t.codecs,BANDWIDTH:t.bandwidth,"PROGRAM-ID":1},uri:"",endList:t.type==="static",timeline:t.periodStart,resolvedUri:t.baseUrl||"",targetDuration:t.duration,discontinuityStarts:i,timelineStarts:t.timelineStarts,segments:e};return t.frameRate&&(n.attributes["FRAME-RATE"]=t.frameRate),t.qualityRanking!==void 0&&(n.attributes.SCORE=1/(t.qualityRanking+1)),t.contentProtection&&(n.contentProtection=t.contentProtection),t.serviceLocation&&(n.attributes.serviceLocation=t.serviceLocation),r&&(n.sidx=r),n},nZ=({attributes:t})=>t.mimeType==="video/mp4"||t.mimeType==="video/webm"||t.contentType==="video",iZ=({attributes:t})=>t.mimeType==="audio/mp4"||t.mimeType==="audio/webm"||t.contentType==="audio",oZ=({attributes:t})=>t.mimeType==="text/vtt"||t.contentType==="text",aZ=(t,e)=>{t.forEach(r=>{r.mediaSequence=0,r.discontinuitySequence=e.findIndex(function({timeline:i}){return i===r.timeline}),r.segments&&r.segments.forEach((i,n)=>{i.number=n})})},gT=t=>t?Object.keys(t).reduce((e,r)=>{let i=t[r];return e.concat(i.playlists)},[]):[],ET=({dashPlaylists:t,locations:e,contentSteering:r,sidxMapping:i={},previousManifest:n,eventStream:o})=>{if(!t.length)return{};let{sourceDuration:a,type:s,suggestedPresentationDelay:u,minimumUpdatePeriod:c}=t[0].attributes,l=r0(t.filter(nZ)).map(rZ),d=r0(t.filter(iZ)),p=r0(t.filter(oZ)),m=t.map(x=>x.attributes.captionServices).filter(Boolean),h={allowCache:!0,discontinuityStarts:[],segments:[],endList:!0,mediaGroups:{AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},uri:"",duration:a,playlists:K9(l,i)};c>=0&&(h.minimumUpdatePeriod=c*1e3),e&&(h.locations=e),r&&(h.contentSteering=r),s==="dynamic"&&(h.suggestedPresentationDelay=u),o&&o.length>0&&(h.eventStream=o);let f=h.playlists.length===0,g=d.length?W9(d,i,f):null,y=p.length?eZ(p,i):null,v=l.concat(gT(g),gT(y)),A=v.map(({timelineStarts:x})=>x);return h.timelineStarts=IT(A),aZ(v,h.timelineStarts),g&&(h.mediaGroups.AUDIO.audio=g),y&&(h.mediaGroups.SUBTITLES.subs=y),m.length&&(h.mediaGroups["CLOSED-CAPTIONS"].cc=tZ(m)),n?J9({oldManifest:n,newManifest:h}):h},sZ=(t,e,r)=>{let{NOW:i,clientOffset:n,availabilityStartTime:o,timescale:a=1,periodStart:s=0,minimumUpdatePeriod:u=0}=t,c=(i+n)/1e3,l=o+s,p=c+u-l;return Math.ceil((p*a-e)/r)},xT=(t,e)=>{let{type:r,minimumUpdatePeriod:i=0,media:n="",sourceDuration:o,timescale:a=1,startNumber:s=1,periodStart:u}=t,c=[],l=-1;for(let d=0;d<e.length;d++){let p=e[d],m=p.d,h=p.r||0,f=p.t||0;l<0&&(l=f),f&&f>l&&(l=f);let g;if(h<0){let A=d+1;A===e.length?r==="dynamic"&&i>0&&n.indexOf("$Number$")>0?g=sZ(t,l,m):g=(o*a-l)/m:g=(e[A].t-l)/m}else g=h+1;let y=s+c.length+g,v=s+c.length;for(;v<y;)c.push({number:v,duration:m/a,time:l,timeline:u}),l+=m,v++}return c},uZ=/\$([A-z]*)(?:(%0)([0-9]+)d)?\$/g,cZ=t=>(e,r,i,n)=>{if(e==="$$")return"$";if(typeof t[r]>"u")return e;let o=""+t[r];return r==="RepresentationID"||(i?n=parseInt(n,10):n=1,o.length>=n)?o:`${new Array(n-o.length+1).join("0")}${o}`},vT=(t,e)=>t.replace(uZ,cZ(e)),lZ=(t,e)=>!t.duration&&!e?[{number:t.startNumber||1,duration:t.sourceDuration,time:0,timeline:t.periodStart}]:t.duration?o0(t):xT(t,e),dZ=(t,e)=>{let r={RepresentationID:t.id,Bandwidth:t.bandwidth||0},{initialization:i={sourceURL:"",range:""}}=t,n=hc({baseUrl:t.baseUrl,source:vT(i.sourceURL,r),range:i.range});return lZ(t,e).map(a=>{r.Number=a.number,r.Time=a.time;let s=vT(t.media||"",r),u=t.timescale||1,c=t.presentationTimeOffset||0,l=t.periodStart+(a.time-c)/u;return{uri:s,timeline:a.timeline,duration:a.duration,resolvedUri:i0.default(t.baseUrl||"",s),map:n,number:a.number,presentationTime:l}})},fZ=(t,e)=>{let{baseUrl:r,initialization:i={}}=t,n=hc({baseUrl:r,source:i.sourceURL,range:i.range}),o=hc({baseUrl:r,source:e.media,range:e.mediaRange});return o.map=n,o},pZ=(t,e)=>{let{duration:r,segmentUrls:i=[],periodStart:n}=t;if(!r&&!e||r&&e)throw new Error(Ea.SEGMENT_TIME_UNSPECIFIED);let o=i.map(u=>fZ(t,u)),a;return r&&(a=o0(t)),e&&(a=xT(t,e)),a.map((u,c)=>{if(o[c]){let l=o[c],d=t.timescale||1,p=t.presentationTimeOffset||0;return l.timeline=u.timeline,l.duration=u.duration,l.number=u.number,l.presentationTime=n+(u.time-p)/d,l}}).filter(u=>u)},mZ=({attributes:t,segmentInfo:e})=>{let r,i;e.template?(i=dZ,r=Je(t,e.template)):e.base?(i=bT,r=Je(t,e.base)):e.list&&(i=pZ,r=Je(t,e.list));let n={attributes:t};if(!i)return n;let o=i(r,e.segmentTimeline);if(r.duration){let{duration:a,timescale:s=1}=r;r.duration=a/s}else o.length?r.duration=o.reduce((a,s)=>Math.max(a,Math.ceil(s.duration)),0):r.duration=0;return n.attributes=r,n.segments=o,e.base&&r.indexRange&&(n.sidx=o[0],n.segments=[]),n},ST=t=>t.map(mZ),Oe=(t,e)=>_T(t.childNodes).filter(({tagName:r})=>r===e),gc=t=>t.textContent.trim(),hZ=t=>parseFloat(t.split("/").reduce((e,r)=>e/r)),Ia=t=>{let s=/P(?:(\d*)Y)?(?:(\d*)M)?(?:(\d*)D)?(?:T(?:(\d*)H)?(?:(\d*)M)?(?:([\d.]*)S)?)?/.exec(t);if(!s)return 0;let[u,c,l,d,p,m]=s.slice(1);return parseFloat(u||0)*31536e3+parseFloat(c||0)*2592e3+parseFloat(l||0)*86400+parseFloat(d||0)*3600+parseFloat(p||0)*60+parseFloat(m||0)},gZ=t=>(/^\d+-\d+-\d+T\d+:\d+:\d+(\.\d+)?$/.test(t)&&(t+="Z"),Date.parse(t)),AT={mediaPresentationDuration(t){return Ia(t)},availabilityStartTime(t){return gZ(t)/1e3},minimumUpdatePeriod(t){return Ia(t)},suggestedPresentationDelay(t){return Ia(t)},type(t){return t},timeShiftBufferDepth(t){return Ia(t)},start(t){return Ia(t)},width(t){return parseInt(t,10)},height(t){return parseInt(t,10)},bandwidth(t){return parseInt(t,10)},frameRate(t){return hZ(t)},startNumber(t){return parseInt(t,10)},timescale(t){return parseInt(t,10)},presentationTimeOffset(t){return parseInt(t,10)},duration(t){let e=parseInt(t,10);return isNaN(e)?Ia(t):e},d(t){return parseInt(t,10)},t(t){return parseInt(t,10)},r(t){return parseInt(t,10)},presentationTime(t){return parseInt(t,10)},qualityRanking(t){return parseInt(t,10)},qualityranking(t){return parseInt(t,10)},DEFAULT(t){return t}},vZ={qualityranking:"qualityRanking"},Me=t=>t&&t.attributes?_T(t.attributes).reduce((e,r)=>{let i=AT[r.name]||AT.DEFAULT,n=vZ[r.name]||r.name;return e[n]=i(r.value),e},{}):{},AZ={"urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b":"org.w3.clearkey","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":"com.widevine.alpha","urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":"com.microsoft.playready","urn:uuid:f239e769-efa3-4850-9c16-a903c6932efb":"com.adobe.primetime","urn:mpeg:dash:mp4protection:2011":"mp4protection"},Sm=(t,e)=>e.length?wa(t.map(function(r){return e.map(function(i){let n=gc(i),o=i0.default(r.baseUrl,n),a=Je(Me(i),{baseUrl:o});return o!==n&&!a.serviceLocation&&r.serviceLocation&&(a.serviceLocation=r.serviceLocation),a})})):t,s0=t=>{let e=Oe(t,"SegmentTemplate")[0],r=Oe(t,"SegmentList")[0],i=r&&Oe(r,"SegmentURL").map(d=>Je({tag:"SegmentURL"},Me(d))),n=Oe(t,"SegmentBase")[0],o=r||e,a=o&&Oe(o,"SegmentTimeline")[0],s=r||n||e,u=s&&Oe(s,"Initialization")[0],c=e&&Me(e);c&&u?c.initialization=u&&Me(u):c&&c.initialization&&(c.initialization={sourceURL:c.initialization});let l={template:c,segmentTimeline:a&&Oe(a,"S").map(d=>Me(d)),list:r&&Je(Me(r),{segmentUrls:i,initialization:Me(u)}),base:n&&Je(Me(n),{initialization:Me(u)})};return Object.keys(l).forEach(d=>{l[d]||delete l[d]}),l},yZ=(t,e,r)=>i=>{let n=Oe(i,"BaseURL"),o=Sm(e,n),a=Je(t,Me(i)),s=s0(i);return o.map(u=>({segmentInfo:Je(r,s),attributes:Je(a,u)}))},_Z=t=>t.reduce((e,r)=>{let i=Me(r);i.schemeIdUri&&(i.schemeIdUri=i.schemeIdUri.toLowerCase());let n=AZ[i.schemeIdUri];if(n){e[n]={attributes:i};let o=Oe(r,"cenc:pssh")[0];if(o){let a=gc(o);e[n].pssh=a&&j9.default(a)}}return e},{}),bZ=t=>{if(t.schemeIdUri==="urn:scte:dash:cc:cea-608:2015")return(typeof t.value!="string"?[]:t.value.split(";")).map(r=>{let i,n;return n=r,/^CC\d=/.test(r)?[i,n]=r.split("="):/^CC\d$/.test(r)&&(i=r),{channel:i,language:n}});if(t.schemeIdUri==="urn:scte:dash:cc:cea-708:2015")return(typeof t.value!="string"?[]:t.value.split(";")).map(r=>{let i={channel:void 0,language:void 0,aspectRatio:1,easyReader:0,"3D":0};if(/=/.test(r)){let[n,o=""]=r.split("=");i.channel=n,i.language=r,o.split(",").forEach(a=>{let[s,u]=a.split(":");s==="lang"?i.language=u:s==="er"?i.easyReader=Number(u):s==="war"?i.aspectRatio=Number(u):s==="3D"&&(i["3D"]=Number(u))})}else i.language=r;return i.channel&&(i.channel="SERVICE"+i.channel),i})},$Z=t=>wa(Oe(t.node,"EventStream").map(e=>{let r=Me(e),i=r.schemeIdUri;return Oe(e,"Event").map(n=>{let o=Me(n),a=o.presentationTime||0,s=r.timescale||1,u=o.duration||0,c=a/s+t.attributes.start;return{schemeIdUri:i,value:r.value,id:o.id,start:c,end:c+u/s,messageData:gc(n)||o.messageData,contentEncoding:r.contentEncoding,presentationTimeOffset:r.presentationTimeOffset||0}})})),IZ=(t,e,r)=>i=>{let n=Me(i),o=Sm(e,Oe(i,"BaseURL")),a=Oe(i,"Role")[0],s={role:Me(a)},u=Je(t,n,s),c=Oe(i,"Accessibility")[0],l=bZ(Me(c));l&&(u=Je(u,{captionServices:l}));let d=Oe(i,"Label")[0];if(d&&d.childNodes.length){let g=d.childNodes[0].nodeValue.trim();u=Je(u,{label:g})}let p=_Z(Oe(i,"ContentProtection"));Object.keys(p).length&&(u=Je(u,{contentProtection:p}));let m=s0(i),h=Oe(i,"Representation"),f=Je(r,m);return wa(h.map(yZ(u,o,f)))},wZ=(t,e)=>(r,i)=>{let n=Sm(e,Oe(r.node,"BaseURL")),o=Je(t,{periodStart:r.attributes.start});typeof r.attributes.duration=="number"&&(o.periodDuration=r.attributes.duration);let a=Oe(r.node,"AdaptationSet"),s=s0(r.node);return wa(a.map(IZ(o,n,s)))},EZ=(t,e)=>{if(t.length>1&&e({type:"warn",message:"The MPD manifest should contain no more than one ContentSteering tag"}),!t.length)return null;let r=Je({serverURL:gc(t[0])},Me(t[0]));return r.queryBeforeStart=r.queryBeforeStart==="true",r},xZ=({attributes:t,priorPeriodAttributes:e,mpdType:r})=>typeof t.start=="number"?t.start:e&&typeof e.start=="number"&&typeof e.duration=="number"?e.start+e.duration:!e&&r==="static"?0:null,kT=(t,e={})=>{let{manifestUri:r="",NOW:i=Date.now(),clientOffset:n=0,eventHandler:o=function(){}}=e,a=Oe(t,"Period");if(!a.length)throw new Error(Ea.INVALID_NUMBER_OF_PERIOD);let s=Oe(t,"Location"),u=Me(t),c=Sm([{baseUrl:r}],Oe(t,"BaseURL")),l=Oe(t,"ContentSteering");u.type=u.type||"static",u.sourceDuration=u.mediaPresentationDuration||0,u.NOW=i,u.clientOffset=n,s.length&&(u.locations=s.map(gc));let d=[];return a.forEach((p,m)=>{let h=Me(p),f=d[m-1];h.start=xZ({attributes:h,priorPeriodAttributes:f?f.attributes:null,mpdType:u.type}),d.push({node:p,attributes:h})}),{locations:u.locations,contentSteeringInfo:EZ(l,o),representationInfo:wa(d.map(wZ(u,c))),eventStream:wa(d.map($Z))}},u0=t=>{if(t==="")throw new Error(Ea.DASH_EMPTY_MANIFEST);let e=new R9.DOMParser,r,i;try{r=e.parseFromString(t,"application/xml"),i=r&&r.documentElement.tagName==="MPD"?r.documentElement:null}catch{}if(!i||i&&i.getElementsByTagName("parsererror").length>0)throw new Error(Ea.DASH_INVALID_XML);return i},SZ=t=>{let e=Oe(t,"UTCTiming")[0];if(!e)return null;let r=Me(e);switch(r.schemeIdUri){case"urn:mpeg:dash:utc:http-head:2014":case"urn:mpeg:dash:utc:http-head:2012":r.method="HEAD";break;case"urn:mpeg:dash:utc:http-xsdate:2014":case"urn:mpeg:dash:utc:http-iso:2014":case"urn:mpeg:dash:utc:http-xsdate:2012":case"urn:mpeg:dash:utc:http-iso:2012":r.method="GET";break;case"urn:mpeg:dash:utc:direct:2014":case"urn:mpeg:dash:utc:direct:2012":r.method="DIRECT",r.value=Date.parse(r.value);break;default:throw new Error(Ea.UNSUPPORTED_UTC_TIMING_SCHEME)}return r},kZ=B9,CZ=(t,e={})=>{let r=kT(u0(t),e),i=ST(r.representationInfo);return ET({dashPlaylists:i,locations:r.locations,contentSteering:r.contentSteeringInfo,sidxMapping:e.sidxMapping,previousManifest:e.previousManifest,eventStream:r.eventStream})},DZ=t=>SZ(u0(t));yr.VERSION=kZ;yr.addSidxSegmentsToPlaylist=$T;yr.generateSidxKey=wT;yr.inheritAttributes=kT;yr.parse=CZ;yr.parseUTCTiming=DZ;yr.stringToMpdXml=u0;yr.toM3u8=ET;yr.toPlaylists=ST});var ue;(function(t){t.assertEqual=n=>{};function e(n){}t.assertIs=e;function r(n){throw new Error}t.assertNever=r,t.arrayToEnum=n=>{let o={};for(let a of n)o[a]=a;return o},t.getValidEnumValues=n=>{let o=t.objectKeys(n).filter(s=>typeof n[n[s]]!="number"),a={};for(let s of o)a[s]=n[s];return t.objectValues(a)},t.objectValues=n=>t.objectKeys(n).map(function(o){return n[o]}),t.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{let o=[];for(let a in n)Object.prototype.hasOwnProperty.call(n,a)&&o.push(a);return o},t.find=(n,o)=>{for(let a of n)if(o(a))return a},t.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function i(n,o=" | "){return n.map(a=>typeof a=="string"?`'${a}'`:a).join(o)}t.joinValues=i,t.jsonStringifyReplacer=(n,o)=>typeof o=="bigint"?o.toString():o})(ue||(ue={}));var y0;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(y0||(y0={}));var R=ue.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Br=t=>{switch(typeof t){case"undefined":return R.undefined;case"string":return R.string;case"number":return Number.isNaN(t)?R.nan:R.number;case"boolean":return R.boolean;case"function":return R.function;case"bigint":return R.bigint;case"symbol":return R.symbol;case"object":return Array.isArray(t)?R.array:t===null?R.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?R.promise:typeof Map<"u"&&t instanceof Map?R.map:typeof Set<"u"&&t instanceof Set?R.set:typeof Date<"u"&&t instanceof Date?R.date:R.object;default:return R.unknown}};var C=ue.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);var Bt=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=i=>{this.issues=[...this.issues,i]},this.addIssues=(i=[])=>{this.issues=[...this.issues,...i]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(o){return o.message},i={_errors:[]},n=o=>{for(let a of o.issues)if(a.code==="invalid_union")a.unionErrors.map(n);else if(a.code==="invalid_return_type")n(a.returnTypeError);else if(a.code==="invalid_arguments")n(a.argumentsError);else if(a.path.length===0)i._errors.push(r(a));else{let s=i,u=0;for(;u<a.path.length;){let c=a.path[u],l=u===a.path.length-1;if(c==="_errors"){l&&s._errors.push(r(a)),u++;continue}Object.prototype.hasOwnProperty.call(s,c)||(c==="__proto__"?Object.defineProperty(s,c,{value:{_errors:[]},writable:!0,enumerable:!0,configurable:!0}):s[c]={_errors:[]}),s=s[c],l&&s._errors.push(r(a)),u++}}};return n(this),i}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ue.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r=Object.create(null),i=[];for(let n of this.issues)if(n.path.length>0){let o=n.path[0];r[o]=r[o]||[],r[o].push(e(n))}else i.push(e(n));return{formErrors:i,fieldErrors:r}}get formErrors(){return this.flatten()}};Bt.create=t=>new Bt(t);var c1=(t,e)=>{let r;switch(t.code){case C.invalid_type:t.received===R.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case C.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,ue.jsonStringifyReplacer)}`;break;case C.unrecognized_keys:r=`Unrecognized key(s) in object: ${ue.joinValues(t.keys,", ")}`;break;case C.invalid_union:r="Invalid input";break;case C.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${ue.joinValues(t.options)}`;break;case C.invalid_enum_value:r=`Invalid enum value. Expected ${ue.joinValues(t.options)}, received '${t.received}'`;break;case C.invalid_arguments:r="Invalid function arguments";break;case C.invalid_return_type:r="Invalid function return type";break;case C.invalid_date:r="Invalid date";break;case C.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:ue.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case C.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case C.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case C.custom:r="Invalid input";break;case C.invalid_intersection_types:r="Intersection results could not be merged";break;case C.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case C.not_finite:r="Number must be finite";break;default:r=e.defaultError,ue.assertNever(t)}return{message:r}},an=c1;var l1=an;function Na(){return l1}var _c=t=>{let{data:e,path:r,errorMaps:i,issueData:n}=t,o=[...r,...n.path||[]],a={...n,path:o};if(n.message!==void 0)return{...n,path:o,message:n.message};let s="",u=i.filter(c=>!!c).slice().reverse();for(let c of u)s=c(a,{data:e,defaultError:s}).message;return{...n,path:o,message:s}};function z(t,e){let r=Na(),i=_c({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===an?void 0:an].filter(n=>!!n)});t.common.issues.push(i)}var ot=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let i=[];for(let n of r){if(n.status==="aborted")return q;n.status==="dirty"&&e.dirty(),i.push(n.value)}return{status:e.value,value:i}}static async mergeObjectAsync(e,r){let i=[];for(let n of r){let o=await n.key,a=await n.value;i.push({key:o,value:a})}return t.mergeObjectSync(e,i)}static mergeObjectSync(e,r){let i={};for(let n of r){let{key:o,value:a}=n;if(o.status==="aborted"||a.status==="aborted")return q;o.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),o.value!=="__proto__"&&(typeof a.value<"u"||n.alwaysSet)&&(i[o.value]=a.value)}return{status:e.value,value:i}}},q=Object.freeze({status:"aborted"}),wi=t=>({status:"dirty",value:t}),pt=t=>({status:"valid",value:t}),Mm=t=>t.status==="aborted",Lm=t=>t.status==="dirty",Mn=t=>t.status==="valid",za=t=>typeof Promise<"u"&&t instanceof Promise;var U;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(U||(U={}));var Ht=class{constructor(e,r,i,n){this._cachedPath=[],this.parent=e,this.data=r,this._path=i,this._key=n}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},_0=(t,e)=>{if(Mn(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new Bt(t.common.issues);return this._error=r,this._error}}};function Y(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:i,description:n}=t;if(e&&(r||i))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(a,s)=>{let{message:u}=t;return a.code==="invalid_enum_value"?{message:u??s.defaultError}:typeof s.data>"u"?{message:u??i??s.defaultError}:a.code!=="invalid_type"?{message:s.defaultError}:{message:u??r??s.defaultError}},description:n}}var ne=class{get description(){return this._def.description}_getType(e){return Br(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Br(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ot,ctx:{common:e.parent.common,data:e.data,parsedType:Br(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(za(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let i=this.safeParse(e,r);if(i.success)return i.data;throw i.error}safeParse(e,r){let i={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Br(e)},n=this._parseSync({data:e,path:i.path,parent:i});return _0(i,n)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Br(e)};if(!this["~standard"].async)try{let i=this._parseSync({data:e,path:[],parent:r});return Mn(i)?{value:i.value}:{issues:r.common.issues}}catch(i){i?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(i=>Mn(i)?{value:i.value}:{issues:r.common.issues})}async parseAsync(e,r){let i=await this.safeParseAsync(e,r);if(i.success)return i.data;throw i.error}async safeParseAsync(e,r){let i={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Br(e)},n=this._parse({data:e,path:i.path,parent:i}),o=await(za(n)?n:Promise.resolve(n));return _0(i,o)}refine(e,r){let i=n=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(n):r;return this._refinement((n,o)=>{let a=e(n),s=()=>o.addIssue({code:C.custom,...i(n)});return typeof Promise<"u"&&a instanceof Promise?a.then(u=>u?!0:(s(),!1)):a?!0:(s(),!1)})}refinement(e,r){return this._refinement((i,n)=>e(i)?!0:(n.addIssue(typeof r=="function"?r(i,n):r),!1))}_refinement(e){return new ar({schema:this,typeName:T.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return or.create(this,this._def)}nullable(){return Lr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return un.create(this)}promise(){return Ln.create(this,this._def)}or(e){return Ci.create([this,e],this._def)}and(e){return Di.create(this,e,this._def)}transform(e){return new ar({...Y(this._def),schema:this,typeName:T.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new Oi({...Y(this._def),innerType:this,defaultValue:r,typeName:T.ZodDefault})}brand(){return new bc({typeName:T.ZodBranded,type:this,...Y(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new Ri({...Y(this._def),innerType:this,catchValue:r,typeName:T.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return $c.create(this,e)}readonly(){return ji.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},d1=/^c[^\s-]{8,}$/i,f1=/^[0-9a-z]+$/,p1=/^[0-9A-HJKMNP-TV-Z]{26}$/i,m1=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,h1=/^[a-z0-9_-]{21}$/i,g1=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,v1=/^[-+]?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)?)??$/,A1=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,y1="^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$",Fm,_1=/^(?:(?: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])$/,b1=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,$1=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,I1=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,w1=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,E1=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,b0="((\\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])))",x1=new RegExp(`^${b0}$`);function $0(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function S1(t){return new RegExp(`^${$0(t)}$`)}function k1(t){let e=`${b0}T${$0(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function C1(t,e){return!!((e==="v4"||!e)&&_1.test(t)||(e==="v6"||!e)&&$1.test(t))}function D1(t,e){if(!g1.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let i=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),n=JSON.parse(atob(i));return!(typeof n!="object"||n===null||"typ"in n&&n?.typ!=="JWT"||!n.alg||e&&n.alg!==e)}catch{return!1}}function T1(t,e){return!!((e==="v4"||!e)&&b1.test(t)||(e==="v6"||!e)&&I1.test(t))}var xi=class t extends ne{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==R.string){let o=this._getOrReturnCtx(e);return z(o,{code:C.invalid_type,expected:R.string,received:o.parsedType}),q}let i=new ot,n;for(let o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(n=this._getOrReturnCtx(e,n),z(n,{code:C.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),i.dirty());else if(o.kind==="max")e.data.length>o.value&&(n=this._getOrReturnCtx(e,n),z(n,{code:C.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),i.dirty());else if(o.kind==="length"){let a=e.data.length>o.value,s=e.data.length<o.value;(a||s)&&(n=this._getOrReturnCtx(e,n),a?z(n,{code:C.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):s&&z(n,{code:C.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),i.dirty())}else if(o.kind==="email")A1.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:"email",code:C.invalid_string,message:o.message}),i.dirty());else if(o.kind==="emoji")Fm||(Fm=new RegExp(y1,"u")),Fm.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:"emoji",code:C.invalid_string,message:o.message}),i.dirty());else if(o.kind==="uuid")m1.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:"uuid",code:C.invalid_string,message:o.message}),i.dirty());else if(o.kind==="nanoid")h1.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:"nanoid",code:C.invalid_string,message:o.message}),i.dirty());else if(o.kind==="cuid")d1.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:"cuid",code:C.invalid_string,message:o.message}),i.dirty());else if(o.kind==="cuid2")f1.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:"cuid2",code:C.invalid_string,message:o.message}),i.dirty());else if(o.kind==="ulid")p1.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:"ulid",code:C.invalid_string,message:o.message}),i.dirty());else if(o.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),z(n,{validation:"url",code:C.invalid_string,message:o.message}),i.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:"regex",code:C.invalid_string,message:o.message}),i.dirty())):o.kind==="trim"?e.data=e.data.trim():o.kind==="includes"?e.data.includes(o.value,o.position)||(n=this._getOrReturnCtx(e,n),z(n,{code:C.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),i.dirty()):o.kind==="toLowerCase"?e.data=e.data.toLowerCase():o.kind==="toUpperCase"?e.data=e.data.toUpperCase():o.kind==="startsWith"?e.data.startsWith(o.value)||(n=this._getOrReturnCtx(e,n),z(n,{code:C.invalid_string,validation:{startsWith:o.value},message:o.message}),i.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(n=this._getOrReturnCtx(e,n),z(n,{code:C.invalid_string,validation:{endsWith:o.value},message:o.message}),i.dirty()):o.kind==="datetime"?k1(o).test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{code:C.invalid_string,validation:"datetime",message:o.message}),i.dirty()):o.kind==="date"?x1.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{code:C.invalid_string,validation:"date",message:o.message}),i.dirty()):o.kind==="time"?S1(o).test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{code:C.invalid_string,validation:"time",message:o.message}),i.dirty()):o.kind==="duration"?v1.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:"duration",code:C.invalid_string,message:o.message}),i.dirty()):o.kind==="ip"?C1(e.data,o.version)||(n=this._getOrReturnCtx(e,n),z(n,{validation:"ip",code:C.invalid_string,message:o.message}),i.dirty()):o.kind==="jwt"?D1(e.data,o.alg)||(n=this._getOrReturnCtx(e,n),z(n,{validation:"jwt",code:C.invalid_string,message:o.message}),i.dirty()):o.kind==="cidr"?T1(e.data,o.version)||(n=this._getOrReturnCtx(e,n),z(n,{validation:"cidr",code:C.invalid_string,message:o.message}),i.dirty()):o.kind==="base64"?w1.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:"base64",code:C.invalid_string,message:o.message}),i.dirty()):o.kind==="base64url"?E1.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:"base64url",code:C.invalid_string,message:o.message}),i.dirty()):ue.assertNever(o);return{status:i.value,value:e.data}}_regex(e,r,i){return this.refinement(n=>e.test(n),{validation:r,code:C.invalid_string,...U.errToObj(i)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...U.errToObj(e)})}url(e){return this._addCheck({kind:"url",...U.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...U.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...U.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...U.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...U.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...U.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...U.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...U.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...U.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...U.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...U.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...U.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...U.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...U.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...U.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...U.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...U.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...U.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...U.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...U.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...U.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...U.errToObj(r)})}nonempty(e){return this.min(1,U.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};xi.create=t=>new xi({checks:[],typeName:T.ZodString,coerce:t?.coerce??!1,...Y(t)});function N1(t,e){let r=(t.toString().split(".")[1]||"").length,i=(e.toString().split(".")[1]||"").length,n=r>i?r:i,o=Number.parseInt(t.toFixed(n).replace(".","")),a=Number.parseInt(e.toFixed(n).replace(".",""));return o%a/10**n}var Pa=class t extends ne{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==R.number){let o=this._getOrReturnCtx(e);return z(o,{code:C.invalid_type,expected:R.number,received:o.parsedType}),q}let i,n=new ot;for(let o of this._def.checks)o.kind==="int"?ue.isInteger(e.data)||(i=this._getOrReturnCtx(e,i),z(i,{code:C.invalid_type,expected:"integer",received:"float",message:o.message}),n.dirty()):o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(i=this._getOrReturnCtx(e,i),z(i,{code:C.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),n.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(i=this._getOrReturnCtx(e,i),z(i,{code:C.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),n.dirty()):o.kind==="multipleOf"?N1(e.data,o.value)!==0&&(i=this._getOrReturnCtx(e,i),z(i,{code:C.not_multiple_of,multipleOf:o.value,message:o.message}),n.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(i=this._getOrReturnCtx(e,i),z(i,{code:C.not_finite,message:o.message}),n.dirty()):ue.assertNever(o);return{status:n.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,U.toString(r))}gt(e,r){return this.setLimit("min",e,!1,U.toString(r))}lte(e,r){return this.setLimit("max",e,!0,U.toString(r))}lt(e,r){return this.setLimit("max",e,!1,U.toString(r))}setLimit(e,r,i,n){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:i,message:U.toString(n)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:U.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:U.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:U.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:U.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:U.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:U.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:U.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:U.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:U.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&ue.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let i of this._def.checks){if(i.kind==="finite"||i.kind==="int"||i.kind==="multipleOf")return!0;i.kind==="min"?(r===null||i.value>r)&&(r=i.value):i.kind==="max"&&(e===null||i.value<e)&&(e=i.value)}return Number.isFinite(r)&&Number.isFinite(e)}};Pa.create=t=>new Pa({checks:[],typeName:T.ZodNumber,coerce:t?.coerce||!1,...Y(t)});var Oa=class t extends ne{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==R.bigint)return this._getInvalidInput(e);let i,n=new ot;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(i=this._getOrReturnCtx(e,i),z(i,{code:C.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),n.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(i=this._getOrReturnCtx(e,i),z(i,{code:C.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),n.dirty()):o.kind==="multipleOf"?e.data%o.value!==BigInt(0)&&(i=this._getOrReturnCtx(e,i),z(i,{code:C.not_multiple_of,multipleOf:o.value,message:o.message}),n.dirty()):ue.assertNever(o);return{status:n.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return z(r,{code:C.invalid_type,expected:R.bigint,received:r.parsedType}),q}gte(e,r){return this.setLimit("min",e,!0,U.toString(r))}gt(e,r){return this.setLimit("min",e,!1,U.toString(r))}lte(e,r){return this.setLimit("max",e,!0,U.toString(r))}lt(e,r){return this.setLimit("max",e,!1,U.toString(r))}setLimit(e,r,i,n){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:i,message:U.toString(n)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:U.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:U.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:U.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:U.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:U.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};Oa.create=t=>new Oa({checks:[],typeName:T.ZodBigInt,coerce:t?.coerce??!1,...Y(t)});var Ra=class extends ne{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==R.boolean){let i=this._getOrReturnCtx(e);return z(i,{code:C.invalid_type,expected:R.boolean,received:i.parsedType}),q}return pt(e.data)}};Ra.create=t=>new Ra({typeName:T.ZodBoolean,coerce:t?.coerce||!1,...Y(t)});var ja=class t extends ne{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==R.date){let o=this._getOrReturnCtx(e);return z(o,{code:C.invalid_type,expected:R.date,received:o.parsedType}),q}if(Number.isNaN(e.data.getTime())){let o=this._getOrReturnCtx(e);return z(o,{code:C.invalid_date}),q}let i=new ot,n;for(let o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(n=this._getOrReturnCtx(e,n),z(n,{code:C.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),i.dirty()):o.kind==="max"?e.data.getTime()>o.value&&(n=this._getOrReturnCtx(e,n),z(n,{code:C.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),i.dirty()):ue.assertNever(o);return{status:i.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:U.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:U.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};ja.create=t=>new ja({checks:[],coerce:t?.coerce||!1,typeName:T.ZodDate,...Y(t)});var Ba=class extends ne{_parse(e){if(this._getType(e)!==R.symbol){let i=this._getOrReturnCtx(e);return z(i,{code:C.invalid_type,expected:R.symbol,received:i.parsedType}),q}return pt(e.data)}};Ba.create=t=>new Ba({typeName:T.ZodSymbol,...Y(t)});var Si=class extends ne{_parse(e){if(this._getType(e)!==R.undefined){let i=this._getOrReturnCtx(e);return z(i,{code:C.invalid_type,expected:R.undefined,received:i.parsedType}),q}return pt(e.data)}};Si.create=t=>new Si({typeName:T.ZodUndefined,...Y(t)});var ki=class extends ne{_parse(e){if(this._getType(e)!==R.null){let i=this._getOrReturnCtx(e);return z(i,{code:C.invalid_type,expected:R.null,received:i.parsedType}),q}return pt(e.data)}};ki.create=t=>new ki({typeName:T.ZodNull,...Y(t)});var Ua=class extends ne{constructor(){super(...arguments),this._any=!0}_parse(e){return pt(e.data)}};Ua.create=t=>new Ua({typeName:T.ZodAny,...Y(t)});var sn=class extends ne{constructor(){super(...arguments),this._unknown=!0}_parse(e){return pt(e.data)}};sn.create=t=>new sn({typeName:T.ZodUnknown,...Y(t)});var br=class extends ne{_parse(e){let r=this._getOrReturnCtx(e);return z(r,{code:C.invalid_type,expected:R.never,received:r.parsedType}),q}};br.create=t=>new br({typeName:T.ZodNever,...Y(t)});var Ma=class extends ne{_parse(e){if(this._getType(e)!==R.undefined){let i=this._getOrReturnCtx(e);return z(i,{code:C.invalid_type,expected:R.void,received:i.parsedType}),q}return pt(e.data)}};Ma.create=t=>new Ma({typeName:T.ZodVoid,...Y(t)});var un=class t extends ne{_parse(e){let{ctx:r,status:i}=this._processInputParams(e),n=this._def;if(r.parsedType!==R.array)return z(r,{code:C.invalid_type,expected:R.array,received:r.parsedType}),q;if(n.exactLength!==null){let a=r.data.length>n.exactLength.value,s=r.data.length<n.exactLength.value;(a||s)&&(z(r,{code:a?C.too_big:C.too_small,minimum:s?n.exactLength.value:void 0,maximum:a?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),i.dirty())}if(n.minLength!==null&&r.data.length<n.minLength.value&&(z(r,{code:C.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),i.dirty()),n.maxLength!==null&&r.data.length>n.maxLength.value&&(z(r,{code:C.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),i.dirty()),r.common.async)return Promise.all([...r.data].map((a,s)=>n.type._parseAsync(new Ht(r,a,r.path,s)))).then(a=>ot.mergeArray(i,a));let o=[...r.data].map((a,s)=>n.type._parseSync(new Ht(r,a,r.path,s)));return ot.mergeArray(i,o)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:U.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:U.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:U.toString(r)}})}nonempty(e){return this.min(1,e)}};un.create=(t,e)=>new un({type:t,minLength:null,maxLength:null,exactLength:null,typeName:T.ZodArray,...Y(e)});function Ei(t){if(t instanceof Ut){let e={};for(let r in t.shape){let i=t.shape[r];e[r]=or.create(Ei(i))}return new Ut({...t._def,shape:()=>e})}else return t instanceof un?new un({...t._def,type:Ei(t.element)}):t instanceof or?or.create(Ei(t.unwrap())):t instanceof Lr?Lr.create(Ei(t.unwrap())):t instanceof Mr?Mr.create(t.items.map(e=>Ei(e))):t}var Ut=class t extends ne{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=ue.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==R.object){let c=this._getOrReturnCtx(e);return z(c,{code:C.invalid_type,expected:R.object,received:c.parsedType}),q}let{status:i,ctx:n}=this._processInputParams(e),{shape:o,keys:a}=this._getCached(),s=[];if(!(this._def.catchall instanceof br&&this._def.unknownKeys==="strip"))for(let c in n.data)a.includes(c)||s.push(c);let u=[];for(let c of a){let l=o[c],d=n.data[c];u.push({key:{status:"valid",value:c},value:l._parse(new Ht(n,d,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof br){let c=this._def.unknownKeys;if(c==="passthrough")for(let l of s)u.push({key:{status:"valid",value:l},value:{status:"valid",value:n.data[l]}});else if(c==="strict")s.length>0&&(z(n,{code:C.unrecognized_keys,keys:s}),i.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let l of s){let d=n.data[l];u.push({key:{status:"valid",value:l},value:c._parse(new Ht(n,d,n.path,l)),alwaysSet:l in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let c=[];for(let l of u){let d=await l.key,p=await l.value;c.push({key:d,value:p,alwaysSet:l.alwaysSet})}return c}).then(c=>ot.mergeObjectSync(i,c)):ot.mergeObjectSync(i,u)}get shape(){return this._def.shape()}strict(e){return U.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,i)=>{let n=this._def.errorMap?.(r,i).message??i.defaultError;return r.code==="unrecognized_keys"?{message:U.errToObj(e).message??n}:{message:n}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:T.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let i of ue.objectKeys(e))e[i]&&this.shape[i]&&(r[i]=this.shape[i]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let i of ue.objectKeys(this.shape))e[i]||(r[i]=this.shape[i]);return new t({...this._def,shape:()=>r})}deepPartial(){return Ei(this)}partial(e){let r={};for(let i of ue.objectKeys(this.shape)){let n=this.shape[i];e&&!e[i]?r[i]=n:r[i]=n.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let i of ue.objectKeys(this.shape))if(e&&!e[i])r[i]=this.shape[i];else{let o=this.shape[i];for(;o instanceof or;)o=o._def.innerType;r[i]=o}return new t({...this._def,shape:()=>r})}keyof(){return I0(ue.objectKeys(this.shape))}};Ut.create=(t,e)=>new Ut({shape:()=>t,unknownKeys:"strip",catchall:br.create(),typeName:T.ZodObject,...Y(e)});Ut.strictCreate=(t,e)=>new Ut({shape:()=>t,unknownKeys:"strict",catchall:br.create(),typeName:T.ZodObject,...Y(e)});Ut.lazycreate=(t,e)=>new Ut({shape:t,unknownKeys:"strip",catchall:br.create(),typeName:T.ZodObject,...Y(e)});var Ci=class extends ne{_parse(e){let{ctx:r}=this._processInputParams(e),i=this._def.options;function n(o){for(let s of o)if(s.result.status==="valid")return s.result;for(let s of o)if(s.result.status==="dirty")return r.common.issues.push(...s.ctx.common.issues),s.result;let a=o.map(s=>new Bt(s.ctx.common.issues));return z(r,{code:C.invalid_union,unionErrors:a}),q}if(r.common.async)return Promise.all(i.map(async o=>{let a={...r,common:{...r.common,issues:[]},parent:null};return{result:await o._parseAsync({data:r.data,path:r.path,parent:a}),ctx:a}})).then(n);{let o,a=[];for(let u of i){let c={...r,common:{...r.common,issues:[]},parent:null},l=u._parseSync({data:r.data,path:r.path,parent:c});if(l.status==="valid")return l;l.status==="dirty"&&!o&&(o={result:l,ctx:c}),c.common.issues.length&&a.push(c.common.issues)}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;let s=a.map(u=>new Bt(u));return z(r,{code:C.invalid_union,unionErrors:s}),q}}get options(){return this._def.options}};Ci.create=(t,e)=>new Ci({options:t,typeName:T.ZodUnion,...Y(e)});var Ur=t=>t instanceof Ti?Ur(t.schema):t instanceof ar?Ur(t.innerType()):t instanceof Ni?[t.value]:t instanceof zi?t.options:t instanceof Pi?ue.objectValues(t.enum):t instanceof Oi?Ur(t._def.innerType):t instanceof Si?[void 0]:t instanceof ki?[null]:t instanceof or?[void 0,...Ur(t.unwrap())]:t instanceof Lr?[null,...Ur(t.unwrap())]:t instanceof bc||t instanceof ji?Ur(t.unwrap()):t instanceof Ri?Ur(t._def.innerType):[],Zm=class t extends ne{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==R.object)return z(r,{code:C.invalid_type,expected:R.object,received:r.parsedType}),q;let i=this.discriminator,n=r.data[i],o=this.optionsMap.get(n);return o?r.common.async?o._parseAsync({data:r.data,path:r.path,parent:r}):o._parseSync({data:r.data,path:r.path,parent:r}):(z(r,{code:C.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[i]}),q)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,i){let n=new Map;for(let o of r){let a=Ur(o.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let s of a){if(n.has(s))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(s)}`);n.set(s,o)}}return new t({typeName:T.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:n,...Y(i)})}};function Qm(t,e){let r=Br(t),i=Br(e);if(t===e)return{valid:!0,data:t};if(r===R.object&&i===R.object){let n=ue.objectKeys(e),o=ue.objectKeys(t).filter(s=>n.indexOf(s)!==-1),a={...t,...e};Object.prototype.hasOwnProperty.call(a,"__proto__")&&delete a.__proto__;for(let s of o){if(s==="__proto__")continue;let u=Qm(t[s],e[s]);if(!u.valid)return{valid:!1};a[s]=u.data}return{valid:!0,data:a}}else if(r===R.array&&i===R.array){if(t.length!==e.length)return{valid:!1};let n=[];for(let o=0;o<t.length;o++){let a=t[o],s=e[o],u=Qm(a,s);if(!u.valid)return{valid:!1};n.push(u.data)}return{valid:!0,data:n}}else return r===R.date&&i===R.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var Di=class extends ne{_parse(e){let{status:r,ctx:i}=this._processInputParams(e),n=(o,a)=>{if(Mm(o)||Mm(a))return q;let s=Qm(o.value,a.value);return s.valid?((Lm(o)||Lm(a))&&r.dirty(),{status:r.value,value:s.data}):(z(i,{code:C.invalid_intersection_types}),q)};return i.common.async?Promise.all([this._def.left._parseAsync({data:i.data,path:i.path,parent:i}),this._def.right._parseAsync({data:i.data,path:i.path,parent:i})]).then(([o,a])=>n(o,a)):n(this._def.left._parseSync({data:i.data,path:i.path,parent:i}),this._def.right._parseSync({data:i.data,path:i.path,parent:i}))}};Di.create=(t,e,r)=>new Di({left:t,right:e,typeName:T.ZodIntersection,...Y(r)});var Mr=class t extends ne{_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.parsedType!==R.array)return z(i,{code:C.invalid_type,expected:R.array,received:i.parsedType}),q;if(i.data.length<this._def.items.length)return z(i,{code:C.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),q;!this._def.rest&&i.data.length>this._def.items.length&&(z(i,{code:C.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let o=[...i.data].map((a,s)=>{let u=this._def.items[s]||this._def.rest;return u?u._parse(new Ht(i,a,i.path,s)):null}).filter(a=>!!a);return i.common.async?Promise.all(o).then(a=>ot.mergeArray(r,a)):ot.mergeArray(r,o)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};Mr.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Mr({items:t,typeName:T.ZodTuple,rest:null,...Y(e)})};var qm=class t extends ne{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.parsedType!==R.object)return z(i,{code:C.invalid_type,expected:R.object,received:i.parsedType}),q;let n=[],o=this._def.keyType,a=this._def.valueType;for(let s in i.data)n.push({key:o._parse(new Ht(i,s,i.path,s)),value:a._parse(new Ht(i,i.data[s],i.path,s)),alwaysSet:s in i.data});return i.common.async?ot.mergeObjectAsync(r,n):ot.mergeObjectSync(r,n)}get element(){return this._def.valueType}static create(e,r,i){return r instanceof ne?new t({keyType:e,valueType:r,typeName:T.ZodRecord,...Y(i)}):new t({keyType:xi.create(),valueType:e,typeName:T.ZodRecord,...Y(r)})}},La=class extends ne{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.parsedType!==R.map)return z(i,{code:C.invalid_type,expected:R.map,received:i.parsedType}),q;let n=this._def.keyType,o=this._def.valueType,a=[...i.data.entries()].map(([s,u],c)=>({key:n._parse(new Ht(i,s,i.path,[c,"key"])),value:o._parse(new Ht(i,u,i.path,[c,"value"]))}));if(i.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let u of a){let c=await u.key,l=await u.value;if(c.status==="aborted"||l.status==="aborted")return q;(c.status==="dirty"||l.status==="dirty")&&r.dirty(),s.set(c.value,l.value)}return{status:r.value,value:s}})}else{let s=new Map;for(let u of a){let c=u.key,l=u.value;if(c.status==="aborted"||l.status==="aborted")return q;(c.status==="dirty"||l.status==="dirty")&&r.dirty(),s.set(c.value,l.value)}return{status:r.value,value:s}}}};La.create=(t,e,r)=>new La({valueType:e,keyType:t,typeName:T.ZodMap,...Y(r)});var Fa=class t extends ne{_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.parsedType!==R.set)return z(i,{code:C.invalid_type,expected:R.set,received:i.parsedType}),q;let n=this._def;n.minSize!==null&&i.data.size<n.minSize.value&&(z(i,{code:C.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),r.dirty()),n.maxSize!==null&&i.data.size>n.maxSize.value&&(z(i,{code:C.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),r.dirty());let o=this._def.valueType;function a(u){let c=new Set;for(let l of u){if(l.status==="aborted")return q;l.status==="dirty"&&r.dirty(),c.add(l.value)}return{status:r.value,value:c}}let s=[...i.data.values()].map((u,c)=>o._parse(new Ht(i,u,i.path,c)));return i.common.async?Promise.all(s).then(u=>a(u)):a(s)}min(e,r){return new t({...this._def,minSize:{value:e,message:U.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:U.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Fa.create=(t,e)=>new Fa({valueType:t,minSize:null,maxSize:null,typeName:T.ZodSet,...Y(e)});var Vm=class t extends ne{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==R.function)return z(r,{code:C.invalid_type,expected:R.function,received:r.parsedType}),q;function i(s,u){return _c({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Na(),an].filter(c=>!!c),issueData:{code:C.invalid_arguments,argumentsError:u}})}function n(s,u){return _c({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Na(),an].filter(c=>!!c),issueData:{code:C.invalid_return_type,returnTypeError:u}})}let o={errorMap:r.common.contextualErrorMap},a=r.data;if(this._def.returns instanceof Ln){let s=this;return pt(async function(...u){let c=new Bt([]),l=await s._def.args.parseAsync(u,o).catch(m=>{throw c.addIssue(i(u,m)),c}),d=await Reflect.apply(a,this,l);return await s._def.returns._def.type.parseAsync(d,o).catch(m=>{throw c.addIssue(n(d,m)),c})})}else{let s=this;return pt(function(...u){let c=s._def.args.safeParse(u,o);if(!c.success)throw new Bt([i(u,c.error)]);let l=Reflect.apply(a,this,c.data),d=s._def.returns.safeParse(l,o);if(!d.success)throw new Bt([n(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Mr.create(e).rest(sn.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,i){return new t({args:e||Mr.create([]).rest(sn.create()),returns:r||sn.create(),typeName:T.ZodFunction,...Y(i)})}},Ti=class extends ne{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};Ti.create=(t,e)=>new Ti({getter:t,typeName:T.ZodLazy,...Y(e)});var Ni=class extends ne{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return z(r,{received:r.data,code:C.invalid_literal,expected:this._def.value}),q}return{status:"valid",value:e.data}}get value(){return this._def.value}};Ni.create=(t,e)=>new Ni({value:t,typeName:T.ZodLiteral,...Y(e)});function I0(t,e){return new zi({values:t,typeName:T.ZodEnum,...Y(e)})}var zi=class t extends ne{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),i=this._def.values;return z(r,{expected:ue.joinValues(i),received:r.parsedType,code:C.invalid_type}),q}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),i=this._def.values;return z(r,{received:r.data,code:C.invalid_enum_value,options:i}),q}return pt(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(i=>!e.includes(i)),{...this._def,...r})}};zi.create=I0;var Pi=class extends ne{_parse(e){let r=ue.getValidEnumValues(this._def.values),i=this._getOrReturnCtx(e);if(i.parsedType!==R.string&&i.parsedType!==R.number){let n=ue.objectValues(r);return z(i,{expected:ue.joinValues(n),received:i.parsedType,code:C.invalid_type}),q}if(this._cache||(this._cache=new Set(ue.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let n=ue.objectValues(r);return z(i,{received:i.data,code:C.invalid_enum_value,options:n}),q}return pt(e.data)}get enum(){return this._def.values}};Pi.create=(t,e)=>new Pi({values:t,typeName:T.ZodNativeEnum,...Y(e)});var Ln=class extends ne{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==R.promise&&r.common.async===!1)return z(r,{code:C.invalid_type,expected:R.promise,received:r.parsedType}),q;let i=r.parsedType===R.promise?r.data:Promise.resolve(r.data);return pt(i.then(n=>this._def.type.parseAsync(n,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Ln.create=(t,e)=>new Ln({type:t,typeName:T.ZodPromise,...Y(e)});var ar=class extends ne{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===T.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:i}=this._processInputParams(e),n=this._def.effect||null,o={addIssue:a=>{z(i,a),a.fatal?r.abort():r.dirty()},get path(){return i.path}};if(o.addIssue=o.addIssue.bind(o),n.type==="preprocess"){let a=n.transform(i.data,o);if(i.common.async)return Promise.resolve(a).then(async s=>{if(r.value==="aborted")return q;let u=await this._def.schema._parseAsync({data:s,path:i.path,parent:i});return u.status==="aborted"?q:u.status==="dirty"?wi(u.value):r.value==="dirty"?wi(u.value):u});{if(r.value==="aborted")return q;let s=this._def.schema._parseSync({data:a,path:i.path,parent:i});return s.status==="aborted"?q:s.status==="dirty"?wi(s.value):r.value==="dirty"?wi(s.value):s}}if(n.type==="refinement"){let a=s=>{let u=n.refinement(s,o);if(i.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(i.common.async===!1){let s=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});return s.status==="aborted"?q:(s.status==="dirty"&&r.dirty(),a(s.value),{status:r.value,value:s.value})}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(s=>s.status==="aborted"?q:(s.status==="dirty"&&r.dirty(),a(s.value).then(()=>({status:r.value,value:s.value}))))}if(n.type==="transform")if(i.common.async===!1){let a=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});if(!Mn(a))return q;let s=n.transform(a.value,o);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:s}}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(a=>Mn(a)?Promise.resolve(n.transform(a.value,o)).then(s=>({status:r.value,value:s})):q);ue.assertNever(n)}};ar.create=(t,e,r)=>new ar({schema:t,typeName:T.ZodEffects,effect:e,...Y(r)});ar.createWithPreprocess=(t,e,r)=>new ar({schema:e,effect:{type:"preprocess",transform:t},typeName:T.ZodEffects,...Y(r)});var or=class extends ne{_parse(e){return this._getType(e)===R.undefined?pt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};or.create=(t,e)=>new or({innerType:t,typeName:T.ZodOptional,...Y(e)});var Lr=class extends ne{_parse(e){return this._getType(e)===R.null?pt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Lr.create=(t,e)=>new Lr({innerType:t,typeName:T.ZodNullable,...Y(e)});var Oi=class extends ne{_parse(e){let{ctx:r}=this._processInputParams(e),i=r.data;return r.parsedType===R.undefined&&(i=this._def.defaultValue()),this._def.innerType._parse({data:i,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Oi.create=(t,e)=>new Oi({innerType:t,typeName:T.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Y(e)});var Ri=class extends ne{_parse(e){let{ctx:r}=this._processInputParams(e),i={...r,common:{...r.common,issues:[]}},n=this._def.innerType._parse({data:i.data,path:i.path,parent:{...i}});return za(n)?n.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Bt(i.common.issues)},input:i.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new Bt(i.common.issues)},input:i.data})}}removeCatch(){return this._def.innerType}};Ri.create=(t,e)=>new Ri({innerType:t,typeName:T.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Y(e)});var Za=class extends ne{_parse(e){if(this._getType(e)!==R.nan){let i=this._getOrReturnCtx(e);return z(i,{code:C.invalid_type,expected:R.nan,received:i.parsedType}),q}return{status:"valid",value:e.data}}};Za.create=t=>new Za({typeName:T.ZodNaN,...Y(t)});var bc=class extends ne{_parse(e){let{ctx:r}=this._processInputParams(e),i=r.data;return this._def.type._parse({data:i,path:r.path,parent:r})}unwrap(){return this._def.type}},$c=class t extends ne{_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.common.async)return(async()=>{let o=await this._def.in._parseAsync({data:i.data,path:i.path,parent:i});return o.status==="aborted"?q:o.status==="dirty"?(r.dirty(),wi(o.value)):this._def.out._parseAsync({data:o.value,path:i.path,parent:i})})();{let n=this._def.in._parseSync({data:i.data,path:i.path,parent:i});return n.status==="aborted"?q:n.status==="dirty"?(r.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:i.path,parent:i})}}static create(e,r){return new t({in:e,out:r,typeName:T.ZodPipeline})}},ji=class extends ne{_parse(e){let r=this._def.innerType._parse(e),i=n=>(Mn(n)&&(n.value=Object.freeze(n.value)),n);return za(r)?r.then(n=>i(n)):i(r)}unwrap(){return this._def.innerType}};ji.create=(t,e)=>new ji({innerType:t,typeName:T.ZodReadonly,...Y(e)});var RQ={object:Ut.lazycreate},T;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(T||(T={}));var jQ=xi.create,BQ=Pa.create,UQ=Za.create,MQ=Oa.create,LQ=Ra.create,FQ=ja.create,ZQ=Ba.create,QQ=Si.create,qQ=ki.create,VQ=Ua.create,HQ=sn.create,GQ=br.create,JQ=Ma.create,KQ=un.create,w0=Ut.create,XQ=Ut.strictCreate,YQ=Ci.create,WQ=Zm.create,e5=Di.create,t5=Mr.create,r5=qm.create,n5=La.create,i5=Fa.create,o5=Vm.create,a5=Ti.create,s5=Ni.create,u5=zi.create,c5=Pi.create,l5=Ln.create,d5=ar.create,f5=or.create,p5=Lr.create,m5=ar.createWithPreprocess,h5=$c.create;var cr={};jr(cr,{$ZodAny:()=>Dl,$ZodArray:()=>Ol,$ZodAsyncError:()=>Et,$ZodBase64:()=>ml,$ZodBase64URL:()=>gl,$ZodBigInt:()=>ds,$ZodBigIntFormat:()=>xl,$ZodBoolean:()=>ro,$ZodCIDRv4:()=>ll,$ZodCIDRv6:()=>fl,$ZodCUID:()=>rl,$ZodCUID2:()=>nl,$ZodCatch:()=>Wl,$ZodCheck:()=>$e,$ZodCheckBigIntFormat:()=>Yh,$ZodCheckEndsWith:()=>lg,$ZodCheckGreaterThan:()=>Lc,$ZodCheckIncludes:()=>ug,$ZodCheckLengthEquals:()=>ig,$ZodCheckLessThan:()=>Mc,$ZodCheckLowerCase:()=>ag,$ZodCheckMaxLength:()=>rg,$ZodCheckMaxSize:()=>Wh,$ZodCheckMimeType:()=>pg,$ZodCheckMinLength:()=>ng,$ZodCheckMinSize:()=>eg,$ZodCheckMultipleOf:()=>Kh,$ZodCheckNumberFormat:()=>Xh,$ZodCheckOverwrite:()=>mg,$ZodCheckProperties:()=>fg,$ZodCheckProperty:()=>dg,$ZodCheckRegex:()=>og,$ZodCheckSizeEquals:()=>tg,$ZodCheckStartsWith:()=>cg,$ZodCheckStringFormat:()=>eo,$ZodCheckUpperCase:()=>sg,$ZodCodec:()=>io,$ZodCreditCard:()=>yl,$ZodCustom:()=>od,$ZodCustomStringFormat:()=>wl,$ZodCyclicError:()=>cd,$ZodDate:()=>Pl,$ZodDefault:()=>Jl,$ZodDiscriminatedUnion:()=>Bl,$ZodE164:()=>vl,$ZodEmail:()=>Jc,$ZodEmoji:()=>el,$ZodEncodeError:()=>ln,$ZodEnum:()=>Zl,$ZodError:()=>lh,$ZodExactOptional:()=>Hl,$ZodFile:()=>ql,$ZodFunction:()=>nd,$ZodGUID:()=>Hc,$ZodIBAN:()=>bl,$ZodIPv4:()=>sl,$ZodIPv6:()=>ul,$ZodISODate:()=>_g,$ZodISODateTime:()=>yg,$ZodISODuration:()=>$g,$ZodISOTime:()=>bg,$ZodIntersection:()=>Ul,$ZodJWT:()=>Il,$ZodKSUID:()=>al,$ZodLazy:()=>oo,$ZodLiteral:()=>Ql,$ZodMAC:()=>cl,$ZodMap:()=>Ll,$ZodNaN:()=>ed,$ZodNanoID:()=>tl,$ZodNever:()=>Nl,$ZodNonOptional:()=>Xl,$ZodNull:()=>Cl,$ZodNullable:()=>Gl,$ZodNumber:()=>ls,$ZodNumberFormat:()=>El,$ZodObject:()=>Rl,$ZodObjectJIT:()=>wg,$ZodOptional:()=>ps,$ZodPipe:()=>ms,$ZodPrefault:()=>Kl,$ZodPreprocess:()=>xg,$ZodPromise:()=>id,$ZodReadonly:()=>td,$ZodRealError:()=>xt,$ZodRecord:()=>Ml,$ZodRegistry:()=>hd,$ZodSet:()=>Fl,$ZodString:()=>dn,$ZodStringFormat:()=>Ae,$ZodSuccess:()=>Yl,$ZodSymbol:()=>Sl,$ZodTemplateLiteral:()=>rd,$ZodTransform:()=>Vl,$ZodTuple:()=>fs,$ZodType:()=>G,$ZodULID:()=>il,$ZodURL:()=>Wc,$ZodUUID:()=>Gc,$ZodUndefined:()=>kl,$ZodUnion:()=>no,$ZodUnknown:()=>Tl,$ZodVoid:()=>zl,$ZodXID:()=>ol,$ZodXor:()=>jl,$brand:()=>sh,$constructor:()=>_,$input:()=>Dg,$output:()=>Cg,Doc:()=>Gn,INVALID:()=>gt,JSONSchema:()=>aw,JSONSchemaGenerator:()=>of,NEVER:()=>ah,TimePrecision:()=>Bg,URL_BAD_FORMAT:()=>vg,URL_UNPARSEABLE:()=>os,ZodCompileAsyncError:()=>sr,ZodCompileUnsupportedError:()=>ae,_any:()=>jd,_array:()=>Zg,_base64:()=>Rs,_base64url:()=>js,_bigint:()=>Td,_boolean:()=>Dd,_catch:()=>bO,_check:()=>QI,_cidrv4:()=>Ps,_cidrv6:()=>Os,_coercedBigint:()=>Lg,_coercedBoolean:()=>Mg,_coercedDate:()=>Fg,_coercedNumber:()=>Ug,_coercedString:()=>jg,_creditCard:()=>$d,_cuid:()=>Ss,_cuid2:()=>ks,_custom:()=>Jd,_date:()=>Ld,_decode:()=>Cc,_decodeAsync:()=>Tc,_default:()=>AO,_discriminatedUnion:()=>aO,_e164:()=>Bs,_email:()=>ys,_emoji:()=>Es,_encode:()=>kc,_encodeAsync:()=>Dc,_endsWith:()=>vo,_enum:()=>fO,_file:()=>Gd,_float32:()=>xd,_float64:()=>Sd,_gt:()=>wr,_gte:()=>Ft,_guid:()=>_s,_iban:()=>Id,_includes:()=>ho,_int:()=>Ed,_int32:()=>kd,_int64:()=>Nd,_intersection:()=>sO,_ipv4:()=>Ns,_ipv6:()=>zs,_isoDate:()=>Ls,_isoDateTime:()=>Ms,_isoDuration:()=>Zs,_isoTime:()=>Fs,_jwt:()=>Us,_ksuid:()=>Ts,_lazy:()=>EO,_length:()=>ei,_literal:()=>mO,_lowercase:()=>po,_lt:()=>Ir,_lte:()=>Lt,_mac:()=>bd,_map:()=>lO,_max:()=>Lt,_maxLength:()=>Wn,_maxSize:()=>mn,_mime:()=>yo,_min:()=>Ft,_minLength:()=>qr,_minSize:()=>Er,_multipleOf:()=>pn,_nan:()=>Fd,_nanoid:()=>xs,_nativeEnum:()=>pO,_negative:()=>Qd,_never:()=>Ud,_nonnegative:()=>Vd,_nonoptional:()=>yO,_nonpositive:()=>qd,_normalize:()=>_o,_null:()=>Rd,_nullable:()=>vO,_number:()=>wd,_optional:()=>gO,_overwrite:()=>ur,_parse:()=>Vi,_parseAsync:()=>Hi,_pipe:()=>$O,_positive:()=>Zd,_promise:()=>xO,_properties:()=>Ao,_property:()=>Hd,_readonly:()=>IO,_record:()=>cO,_refine:()=>Kd,_regex:()=>fo,_safeDecode:()=>zc,_safeDecodeAsync:()=>Oc,_safeEncode:()=>Nc,_safeEncodeAsync:()=>Pc,_safeParse:()=>Gi,_safeParseAsync:()=>Ki,_set:()=>dO,_size:()=>Yn,_slugify:()=>wo,_startsWith:()=>go,_string:()=>_d,_stringFormat:()=>hn,_stringbool:()=>ef,_success:()=>_O,_superRefine:()=>Xd,_symbol:()=>Pd,_templateLiteral:()=>wO,_toLowerCase:()=>$o,_toUpperCase:()=>Io,_transform:()=>hO,_trim:()=>bo,_tuple:()=>uO,_uint32:()=>Cd,_uint64:()=>zd,_ulid:()=>Cs,_undefined:()=>Od,_union:()=>iO,_unknown:()=>Bd,_uppercase:()=>mo,_url:()=>lo,_uuid:()=>bs,_uuidv4:()=>$s,_uuidv6:()=>Is,_uuidv7:()=>ws,_void:()=>Md,_xid:()=>Ds,_xor:()=>oO,base64Charset:()=>pl,base64urlCharset:()=>cs,canParseURL:()=>Ag,clone:()=>he,compile:()=>Pg,compileFn:()=>Ad,config:()=>Re,createStandardJSONSchemaMethod:()=>Eo,createToJSONSchemaMethod:()=>qg,decode:()=>q0,decodeAsync:()=>H0,describe:()=>Yd,encode:()=>Q0,encodeAsync:()=>V0,extractDefs:()=>vn,finalize:()=>An,flattenError:()=>Wa,formatError:()=>es,getDiscriminatedOption:()=>Eg,globalConfig:()=>Ve,globalRegistry:()=>Ye,handleUnrepresentable:()=>Fe,initializeContext:()=>gn,isBackEdge:()=>dd,isRecursiveSchema:()=>ld,isValidBase64:()=>us,isValidBase64URL:()=>hl,isValidCIDRv6:()=>dl,isValidCreditCard:()=>Al,isValidIBAN:()=>_l,isValidIPv6:()=>ss,isValidJWT:()=>$l,locales:()=>uo,memoizer:()=>vs,mergeValues:()=>to,meta:()=>Wd,parse:()=>qn,parseAsync:()=>Vn,parseURLObject:()=>v$,prettifyError:()=>fh,process:()=>_e,processSchema:()=>_e,regexes:()=>Mt,registry:()=>gd,safeDecode:()=>J0,safeDecodeAsync:()=>X0,safeEncode:()=>G0,safeEncodeAsync:()=>K0,safeParse:()=>Ji,safeParseAsync:()=>Xi,standardProps:()=>Vc,stripTabAndNewline:()=>as,toDotPath:()=>F0,toJSONSchema:()=>ti,toZod:()=>Qa,treeifyError:()=>dh,urlHostnameOk:()=>Xc,urlProtocolOk:()=>Yc,util:()=>I,validate:()=>Yi,validateAsync:()=>Wi,validateURL:()=>Kc,version:()=>hg,withParser:()=>vd});var I={};jr(I,{BIGINT_FORMAT_RANGES:()=>Ga,CONSTANT_CATCH:()=>xc,Class:()=>Jm,NUMBER_FORMAT_RANGES:()=>Ha,aborted:()=>ht,allowsEval:()=>Ym,assert:()=>j1,assertEqual:()=>z1,assertIs:()=>O1,assertNever:()=>R1,assertNotEqual:()=>P1,assignProp:()=>Xe,attachSchema:()=>Ja,base64ToUint8Array:()=>R0,base64urlToUint8Array:()=>J1,cached:()=>Li,captureStackTrace:()=>wc,cleanEnum:()=>G1,cleanRegex:()=>Zr,clone:()=>he,cloneDef:()=>M1,codePointLength:()=>Qn,constantCatch:()=>ih,createTransparentProxy:()=>V1,defineLazy:()=>Km,defineLazyInternal:()=>ee,derived:()=>W1,esc:()=>mt,escapeRegex:()=>Kt,explicitlyAborted:()=>th,extend:()=>D0,finalizeIssue:()=>wt,floatSafeRemainder:()=>qa,getElementAtPath:()=>L1,getEnumValues:()=>Ui,getLengthableOrigin:()=>Xa,getParsedType:()=>q1,getSizableOrigin:()=>Ka,hexToUint8Array:()=>X1,hide:()=>Ya,installLazyProp:()=>nh,isObject:()=>Zn,isPlainObject:()=>Jt,issue:()=>qi,joinValues:()=>b,jsonStringifyReplacer:()=>Mi,members:()=>rh,merge:()=>z0,mergeDefs:()=>Gt,normalizeParams:()=>D,nullish:()=>Ic,numKeys:()=>Q1,objectClone:()=>B1,omit:()=>C0,optionalKeys:()=>eh,own:()=>$r,parsedType:()=>E,partial:()=>P0,pick:()=>k0,prefixIssues:()=>It,primitiveTypes:()=>Wm,promiseAllObject:()=>F1,propertyKeyTypes:()=>Va,randomString:()=>Z1,rawShape:()=>Fi,required:()=>O0,safeExtend:()=>N0,shallowClone:()=>Zi,sizeCaps:()=>Qi,slugify:()=>Xm,stringifyPrimitive:()=>w,toZod:()=>Qa,uint8ArrayToBase64:()=>j0,uint8ArrayToBase64url:()=>K1,uint8ArrayToHex:()=>Y1,unwrapMessage:()=>Bi});function z1(t){return t}function P1(t){return t}function Qa(){return t=>t}function O1(t){}function R1(t){throw new Error("Unexpected value in exhaustive check")}function j1(t){}function Ui(t){let e=Object.values(t).filter(i=>typeof i=="number");return Object.entries(t).filter(([i,n])=>e.indexOf(+i)===-1).map(([i,n])=>n)}function b(t,e="|"){return t.map(r=>w(r)).join(e)}function Mi(t,e){return typeof e=="bigint"?e.toString():e}var Gm=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function Li(t){return new Gm(t)}function Ic(t){return t==null}function Zr(t){let e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function qa(t,e){let r=t/e,i=Math.round(r),n=4*Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-i)<n?0:r-i}var E0=Symbol("evaluating");function Km(t,e,r){let i;Object.defineProperty(t,e,{get(){if(i!==E0)return i===void 0&&(i=E0,i=r()),i},set(n){Object.defineProperty(t,e,{value:n})},configurable:!0})}function B1(t){return Object.create(Object.getPrototypeOf(t),Object.getOwnPropertyDescriptors(t))}function Xe(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Fi(t){let e=Object.getOwnPropertyDescriptor(t,"shape");return e?.get?e.get.raw:e?.value}function Fr(t){return Fi(t._zod.def)??t._zod.def.shape}function x0(t,e,r){Object.defineProperty(t,e,{get(){let i=r();return Xe(this,e,i),i},enumerable:!0,configurable:!0})}function S0(t,e,r){e in t?Xe(t,e,r):t[e]=r}function Fn(t,e,r,i){let n=Fr(e);for(let o of r){let a=Object.getOwnPropertyDescriptor(n,o);a.enumerable&&(a.get?x0(t,o,()=>{let s=e._zod.def.shape[o];return i?i(s,o):s}):S0(t,o,i?i(a.value,o):a.value))}}function U1(t,e){for(let r of Reflect.ownKeys(e)){let i=Object.getOwnPropertyDescriptor(e,r);i.enumerable&&(i.get?x0(t,r,()=>e[r]):S0(t,r,i.value))}}function Gt(...t){let e={};for(let r of t){let i=Object.getOwnPropertyDescriptors(r);Object.assign(e,i)}return Object.defineProperties({},e)}function M1(t){return Gt(t._zod.def)}function L1(t,e){return e?e.reduce((r,i)=>r?.[i],t):t}function F1(t){let e=Object.keys(t),r=e.map(i=>t[i]);return Promise.all(r).then(i=>{let n={};for(let o=0;o<e.length;o++)n[e[o]]=i[o];return n})}function Z1(t=10){let e="abcdefghijklmnopqrstuvwxyz",r="";for(let i=0;i<t;i++)r+=e[Math.floor(Math.random()*e.length)];return r}function mt(t){return JSON.stringify(t)}function Xm(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var wc="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function Zn(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var Ym=Li(()=>{if(Ve.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let t=Function;return new t(""),!0}catch{return!1}});function Jt(t){if(Zn(t)===!1)return!1;let e=t.constructor;if(e===void 0||typeof e!="function")return!0;let r=e.prototype;return!(Zn(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Zi(t){return Jt(t)?{...t}:Array.isArray(t)?[...t]:t instanceof Map?new Map(t):t instanceof Set?new Set(t):t}function Q1(t){let e=0;for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&e++;return e}var q1=t=>{let e=typeof t;switch(e){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(t)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(t)?"array":t===null?"null":t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?"promise":typeof Map<"u"&&t instanceof Map?"map":typeof Set<"u"&&t instanceof Set?"set":typeof Date<"u"&&t instanceof Date?"date":typeof File<"u"&&t instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${e}`)}},Va=new Set(["string","number","symbol"]),Wm=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Kt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function he(t,e,r){let i=new t._zod.constr(e??t._zod.def);return(!e||r?.parent)&&(i._zod.parent=t),i}function D(t){let e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function V1(t){let e;return new Proxy({},{get(r,i,n){return e??(e=t()),Reflect.get(e,i,n)},set(r,i,n,o){return e??(e=t()),Reflect.set(e,i,n,o)},has(r,i){return e??(e=t()),Reflect.has(e,i)},deleteProperty(r,i){return e??(e=t()),Reflect.deleteProperty(e,i)},ownKeys(r){return e??(e=t()),Reflect.ownKeys(e)},getOwnPropertyDescriptor(r,i){return e??(e=t()),Reflect.getOwnPropertyDescriptor(e,i)},defineProperty(r,i,n){return e??(e=t()),Reflect.defineProperty(e,i,n)}})}function w(t){return typeof t=="bigint"?t.toString()+"n":typeof t=="string"?`"${t}"`:`${t}`}function eh(t){return Object.keys(t).filter(e=>t[e]._zod.optin!==void 0&&t[e]._zod.optout==="optional")}var Ha={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]},Ga={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function k0(t,e){let r=t._zod.def,i=r.checks;if(i&&i.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let o={};return Fn(o,t,Ec(t,e)),he(t,Gt(r,{shape:o,checks:[]}))}function Ec(t,e){let r=Fr(t),i=[];for(let n of Reflect.ownKeys(e)){if(!Object.getOwnPropertyDescriptor(r,n)?.enumerable)throw new Error(`Unrecognized key: "${String(n)}"`);e[n]&&i.push(n)}return i}function C0(t,e){let r=t._zod.def,i=r.checks;if(i&&i.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let o=new Set(Ec(t,e)),a={};return Fn(a,t,Reflect.ownKeys(Fr(t)).filter(s=>!o.has(s))),he(t,Gt(r,{shape:a,checks:[]}))}function D0(t,e){if(!Jt(e))throw new Error("Invalid input to extend: expected a plain object");let r=t._zod.def.checks;if(r&&r.length>0){let n=Fr(t);for(let o of Reflect.ownKeys(e))if(Object.getOwnPropertyDescriptor(n,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return he(t,Gt(t._zod.def,{shape:T0(t,e)}))}function T0(t,e){let r={};return Fn(r,t,Reflect.ownKeys(Fr(t))),U1(r,e),r}function N0(t,e){if(!Jt(e))throw new Error("Invalid input to safeExtend: expected a plain object");return he(t,Gt(t._zod.def,{shape:T0(t,e)}))}function z0(t,e){if(!e?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(t._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};Fn(r,t,Reflect.ownKeys(Fr(t))),Fn(r,e,Reflect.ownKeys(Fr(e)));let i=Gt(t._zod.def,{shape:r,get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]});return he(t,i)}function P0(t,e,r,i="partial"){let o=e._zod.def.checks;if(o&&o.length>0)throw new Error(`.${i}() cannot be used on object schemas containing refinements`);let s=r?new Set(Ec(e,r)):void 0,u={};return Fn(u,e,Reflect.ownKeys(Fr(e)),t&&((c,l)=>s&&!s.has(l)?c:new t({type:"optional",innerType:c}))),he(e,Gt(e._zod.def,{shape:u,checks:[]}))}function O0(t,e,r){let i=r?new Set(Ec(e,r)):void 0,n={};return Fn(n,e,Reflect.ownKeys(Fr(e)),(o,a)=>i&&!i.has(a)?o:new t({type:"nonoptional",innerType:o})),he(e,Gt(e._zod.def,{shape:n}))}function ht(t,e=0){if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}function th(t,e=0){if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue===!1)return!0;return!1}function It(t,e){return e.map(r=>{var i;return(i=r).path??(i.path=[]),r.path.unshift(t),r})}function Bi(t){return typeof t=="string"?t:t?.message}function Qi(t){let e=[];for(let r of t??[]){let i=r._zod.def;if(!/_(length|size)$|_equals$/.test(i.check))break;let n=i.maximum??i.length??i.size;n>=0&&e.push([n,r])}return e}function Ja(t,e,r){var i;for(let n=e;n<t.length;n++)(i=t[n]).schema??(i.schema=r)}function wt(t,e,r){var i;let n=t.inst?._zod?.traits;n?.has("$ZodType")&&(n.has("$ZodCheck")?(i=t).schema??(i.schema=t.inst):t.schema=t.inst);let o=t.schema!==t.inst?t.schema?._zod.def?.error:void 0,a=t.message?t.message:Bi(t.inst?._zod.def?.error?.(t))??Bi(o?.(t))??Bi(e?.error?.(t))??Bi(r.customError?.(t))??Bi(r.localeError?.(t))??"Invalid input",s={};for(let u of Object.keys(t))u==="inst"||u==="schema"||u==="continue"||u==="input"||u==="__proto__"||(s[u]=t[u]);return s.path??(s.path=[]),s.message=a,e?.reportInput&&(s.input=t.input),s}function Ka(t){return t instanceof Set?"set":t instanceof Map?"map":t instanceof File?"file":"unknown"}var H1=/[\uD800-\uDBFF]/;function Qn(t){let e=t.length;if(!H1.test(t))return e;let r=e;for(let i=0;i<e-1;i++)(t.charCodeAt(i)&64512)===55296&&(t.charCodeAt(i+1)&64512)===56320&&(r--,i++);return r}function Xa(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function E(t){let e=typeof t;switch(e){case"number":return Number.isNaN(t)?"nan":"number";case"object":{if(t===null)return"null";if(Array.isArray(t))return"array";let r=t;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return e}function qi(...t){let[e,r,i]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:i}:{...e}}function G1(t){return Object.entries(t).filter(([e,r])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}function R0(t){let e=atob(t),r=new Uint8Array(e.length);for(let i=0;i<e.length;i++)r[i]=e.charCodeAt(i);return r}function j0(t){let e="";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return btoa(e)}function J1(t){let e=t.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-e.length%4)%4);return R0(e+r)}function K1(t){return j0(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function X1(t){let e=t.replace(/^0x/,"");if(e.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(e.length/2);for(let i=0;i<e.length;i+=2)r[i/2]=Number.parseInt(e.slice(i,i+2),16);return r}function Y1(t){return Array.from(t).map(e=>e.toString(16).padStart(2,"0")).join("")}var Jm=class{constructor(...e){}};function rh(t,e){for(let r in e){let i=Object.getOwnPropertyDescriptor(e,r);i.get?Object.defineProperty(t,r,{...i,enumerable:!1}):eN(t,r,i.value)}}function $r(t,e,r,i=!0){return Object.defineProperty(t,e,{configurable:!0,writable:!0,enumerable:i,value:r}),r}function Ya(t,e,r){return $r(t,e,r,!1)}function W1(t,e){for(let r in t){let i=t[r];Object.defineProperty(e,r,{configurable:!0,enumerable:!0,get(){return $r(this,r,i(this))},set(n){$r(this,r,n)}})}return e}function eN(t,e,r){Object.defineProperty(t,e,{configurable:!0,get(){return this==null?r:$r(this,e,r.bind(this))},set(i){$r(this,e,i)}})}function tN(t,e){let r=Object.getPrototypeOf(t);return e in r?void 0:r}var Hm,cn=!1,rN={configurable:!0,get(){cn=!0}};function ee(t,e,r){let i=Object.getPrototypeOf(t._zod);if(e in i&&Hm!==t._zod){Hm=void 0;return}Hm=t._zod,Object.defineProperty(i,e,{configurable:!0,get(){Object.defineProperty(this,e,rN);let n=cn;cn=!1;try{let o=r(this);return cn?delete this[e]:Object.defineProperty(this,e,{configurable:!0,writable:!0,value:o}),cn=cn||n,o}catch(o){throw delete this[e],cn=cn||n,o}},set(n){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:n})}})}function nh(t,e,r,i){let n=tN(t,e);n&&Object.defineProperty(n,e,{configurable:!0,get(){let o={configurable:!0,writable:!0,enumerable:i,value:void 0};return Object.defineProperty(this,e,o),o.value=r(this),Object.defineProperty(this,e,o),o.value},set(o){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:i,value:o})}})}var xc="~constantCatch";function ih(t){let e=()=>t;return e[xc]=!0,e}var B0,ah=Object.freeze({status:"aborted"}),oh={value:void 0,enumerable:!1},U0="captureStackTrace"in Error?Error:null;function nN(t){let e=U0;if(e){let r=e.stackTraceLimit;if(typeof r=="number"){try{e.stackTraceLimit=0}catch{return U0=null,new t}try{return new t}finally{e.stackTraceLimit=r}}}return new t}function _(t,e,r,i){let n={};function o(p){this.def=p,this.constr=d,this.traits=new Set}o.prototype=n;let a=r,s=a&&new WeakSet;function u(p,m){if(p._zod){if(p._zod.traits.has(t))return}else{oh.value=new o(m);try{Object.defineProperty(p,"_zod",oh)}finally{oh.value=void 0}}if(p._zod.traits.add(t),e(p,m),s){let f=Object.getPrototypeOf(p),g=p._zod.constr.prototype,y=f;for(;y&&y!==g;)y=Object.getPrototypeOf(y);let v=y??f;s.has(v)||(s.add(v),rh(v,a))}let h=d.prototype;for(let f in h)Object.prototype.hasOwnProperty.call(h,f)&&(f in p||(p[f]=h[f].bind(p)))}let c=i?.Parent??Object;class l extends c{}Object.defineProperty(l,"name",{value:t});function d(p){let m=i?.Parent?nN(l):this;u(m,p);let h=m._zod.deferred;if(h){for(let g of h)g();m._zod.deferred=void 0}let f=globalThis.__zod_globalConfig?.postProcessor;return f&&f(m),m}return Object.defineProperty(d,"init",{value:u}),Object.defineProperty(d,Symbol.hasInstance,{value:p=>i?.Parent&&p instanceof i.Parent?!0:p?._zod?.traits?.has(t)}),Object.defineProperty(d,"name",{value:t}),d}var sh=Symbol("zod_brand"),Et=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},ln=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(B0=globalThis).__zod_globalConfig??(B0.__zod_globalConfig={});var Ve=globalThis.__zod_globalConfig;function Re(t){return t&&Object.assign(Ve,t),Ve}function iN(){let t=this._zod;return t.message??(t.message=JSON.stringify(t.def,Mi,2)),t.message}function oN(t){this._zod.message=t}var aN={get:iN,set:oN,enumerable:!0,configurable:!0},ch={value:void 0,enumerable:!1},M0=new WeakSet([Object.prototype,Error.prototype]),L0=(t,e)=>{t.name="$ZodError",ch.value=e,Object.defineProperty(t,"issues",ch),ch.value=void 0,Object.defineProperty(t,"message",aN);let r=Object.getPrototypeOf(t);M0.has(r)||(M0.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let i=()=>this.message;return Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0})}}))},lh=_("$ZodError",L0),xt=_("$ZodError",L0,void 0,{Parent:Error});function sN(t,e,r){return Object.prototype.hasOwnProperty.call(t,e)||(e==="__proto__"?Object.defineProperty(t,e,{value:r(),writable:!0,enumerable:!0,configurable:!0}):t[e]=r()),t[e]}function Wa(t,e=r=>r.message){let r={},i=[];for(let n of t.issues)n.path.length>0?sN(r,n.path[0],()=>[]).push(e(n)):i.push(e(n));return{formErrors:i,fieldErrors:r}}function es(t,e=r=>r.message){let r={_errors:[]},i=(n,o=[])=>{for(let a of n.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(s=>i({issues:s},[...o,...a.path]));else if(a.code==="invalid_key")i({issues:a.issues},[...o,...a.path]);else if(a.code==="invalid_element")i({issues:a.issues},[...o,...a.path]);else{let s=[...o,...a.path];if(s.length===0)r._errors.push(e(a));else{let u=r,c=0;for(;c<s.length;){let l=s[c],d=c===s.length-1;if(l==="_errors"){d&&u._errors.push(e(a)),c++;continue}Object.prototype.hasOwnProperty.call(u,l)||Object.defineProperty(u,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let p=u[l];d&&p._errors.push(e(a)),u=p,c++}}}};return i(t),r}function dh(t,e=r=>r.message){let r={errors:[]},i=(n,o=[])=>{var a;for(let s of n.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(u=>i({issues:u},[...o,...s.path]));else if(s.code==="invalid_key")i({issues:s.issues},[...o,...s.path]);else if(s.code==="invalid_element")i({issues:s.issues},[...o,...s.path]);else{let u=[...o,...s.path];if(u.length===0){r.errors.push(e(s));continue}let c=r,l=0;for(;l<u.length;){let d=u[l],p=l===u.length-1;typeof d=="string"?(c.properties??(c.properties={}),Object.prototype.hasOwnProperty.call(c.properties,d)||Object.defineProperty(c.properties,d,{value:{errors:[]},enumerable:!0,writable:!0,configurable:!0}),c=c.properties[d]):(c.items??(c.items=[]),(a=c.items)[d]??(a[d]={errors:[]}),c=c.items[d]),p&&c.errors.push(e(s)),l++}}};return i(t),r}function F0(t){let e=[],r=t.map(i=>typeof i=="object"?i.key:i);for(let i of r)typeof i=="number"?e.push(`[${i}]`):typeof i=="symbol"?e.push(`[${JSON.stringify(String(i))}]`):/[^\w$]/.test(i)?e.push(`[${JSON.stringify(i)}]`):(e.length&&e.push("."),e.push(i));return e.join("")}function fh(t){let e=[],r=[...t.issues].sort((i,n)=>(i.path??[]).length-(n.path??[]).length);for(let i of r)e.push(`\u2716 ${i.message}`),i.path?.length&&e.push(` \u2192 at ${F0(i.path)}`);return e.join(`
|
|
16
|
+
@`+(t.systemId||"")+"#[line:"+t.lineNumber+",col:"+t.columnNumber+"]"}function oT(t,e,r){return typeof t=="string"?t.substr(e,r):t.length>=e+r||e?new java.lang.String(t,e,r)+"":t}"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(t){mc.prototype[t]=function(){return null}});function wm(t,e){t.currentElement?t.currentElement.appendChild(e):t.doc.appendChild(e)}Em.__DOMHandler=mc;Em.normalizeLineEndings=sT;Em.DOMParser=uT});var dT=S(xm=>{var lT=Yb();xm.DOMImplementation=lT.DOMImplementation;xm.XMLSerializer=lT.XMLSerializer;xm.DOMParser=cT().DOMParser});var CT=S(yr=>{"use strict";Object.defineProperty(yr,"__esModule",{value:!0});var N9=_D(),z9=um(),P9=bD(),O9=zb(),R9=dT();function n0(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var i0=n0(N9),Rt=n0(z9),j9=n0(O9),B9="1.4.1",fT=t=>!!t&&typeof t=="object",Je=(...t)=>t.reduce((e,r)=>(typeof r!="object"||Object.keys(r).forEach(i=>{Array.isArray(e[i])&&Array.isArray(r[i])?e[i]=e[i].concat(r[i]):fT(e[i])&&fT(r[i])?e[i]=Je(e[i],r[i]):e[i]=r[i]}),e),{}),yT=t=>Object.keys(t).map(e=>t[e]),U9=(t,e)=>{let r=[];for(let i=t;i<e;i++)r.push(i);return r},wa=t=>t.reduce((e,r)=>e.concat(r),[]),_T=t=>{if(!t.length)return[];let e=[];for(let r=0;r<t.length;r++)e.push(t[r]);return e},M9=(t,e)=>t.reduce((r,i,n)=>(i[e]&&r.push(n),r),[]),L9=(t,e)=>yT(t.reduce((r,i)=>(i.forEach(n=>{r[e(n)]=n}),r),{})),Ea={INVALID_NUMBER_OF_PERIOD:"INVALID_NUMBER_OF_PERIOD",INVALID_NUMBER_OF_CONTENT_STEERING:"INVALID_NUMBER_OF_CONTENT_STEERING",DASH_EMPTY_MANIFEST:"DASH_EMPTY_MANIFEST",DASH_INVALID_XML:"DASH_INVALID_XML",NO_BASE_URL:"NO_BASE_URL",MISSING_SEGMENT_INFORMATION:"MISSING_SEGMENT_INFORMATION",SEGMENT_TIME_UNSPECIFIED:"SEGMENT_TIME_UNSPECIFIED",UNSUPPORTED_UTC_TIMING_SCHEME:"UNSUPPORTED_UTC_TIMING_SCHEME"},hc=({baseUrl:t="",source:e="",range:r="",indexRange:i=""})=>{let n={uri:e,resolvedUri:i0.default(t||"",e)};if(r||i){let a=(r||i).split("-"),s=Rt.default.BigInt?Rt.default.BigInt(a[0]):parseInt(a[0],10),u=Rt.default.BigInt?Rt.default.BigInt(a[1]):parseInt(a[1],10);s<Number.MAX_SAFE_INTEGER&&typeof s=="bigint"&&(s=Number(s)),u<Number.MAX_SAFE_INTEGER&&typeof u=="bigint"&&(u=Number(u));let c;typeof u=="bigint"||typeof s=="bigint"?c=Rt.default.BigInt(u)-Rt.default.BigInt(s)+Rt.default.BigInt(1):c=u-s+1,typeof c=="bigint"&&c<Number.MAX_SAFE_INTEGER&&(c=Number(c)),n.byterange={length:c,offset:s}}return n},F9=t=>{let e;return typeof t.offset=="bigint"||typeof t.length=="bigint"?e=Rt.default.BigInt(t.offset)+Rt.default.BigInt(t.length)-Rt.default.BigInt(1):e=t.offset+t.length-1,`${t.offset}-${e}`},pT=t=>(t&&typeof t!="number"&&(t=parseInt(t,10)),isNaN(t)?null:t),Z9={static(t){let{duration:e,timescale:r=1,sourceDuration:i,periodDuration:n}=t,o=pT(t.endNumber),a=e/r;return typeof o=="number"?{start:0,end:o}:typeof n=="number"?{start:0,end:n/a}:{start:0,end:i/a}},dynamic(t){let{NOW:e,clientOffset:r,availabilityStartTime:i,timescale:n=1,duration:o,periodStart:a=0,minimumUpdatePeriod:s=0,timeShiftBufferDepth:u=1/0}=t,c=pT(t.endNumber),l=(e+r)/1e3,d=i+a,m=l+s-d,h=Math.ceil(m*n/o),f=Math.floor((l-d-u)*n/o),g=Math.floor((l-d)*n/o);return{start:Math.max(0,f),end:typeof c=="number"?c:Math.min(h,g)}}},Q9=t=>e=>{let{duration:r,timescale:i=1,periodStart:n,startNumber:o=1}=t;return{number:o+e,duration:r/i,timeline:n,time:e*r}},o0=t=>{let{type:e,duration:r,timescale:i=1,periodDuration:n,sourceDuration:o}=t,{start:a,end:s}=Z9[e](t),u=U9(a,s).map(Q9(t));if(e==="static"){let c=u.length-1,l=typeof n=="number"?n:o;u[c].duration=l-r/i*c}return u},bT=t=>{let{baseUrl:e,initialization:r={},sourceDuration:i,indexRange:n="",periodStart:o,presentationTime:a,number:s=0,duration:u}=t;if(!e)throw new Error(Ea.NO_BASE_URL);let c=hc({baseUrl:e,source:r.sourceURL,range:r.range}),l=hc({baseUrl:e,source:e,indexRange:n});if(l.map=c,u){let d=o0(t);d.length&&(l.duration=d[0].duration,l.timeline=d[0].timeline)}else i&&(l.duration=i,l.timeline=o);return l.presentationTime=a||o,l.number=s,[l]},$T=(t,e,r)=>{let i=t.sidx.map?t.sidx.map:null,n=t.sidx.duration,o=t.timeline||0,a=t.sidx.byterange,s=a.offset+a.length,u=e.timescale,c=e.references.filter(g=>g.referenceType!==1),l=[],d=t.endList?"static":"dynamic",p=t.sidx.timeline,m=p,h=t.mediaSequence||0,f;typeof e.firstOffset=="bigint"?f=Rt.default.BigInt(s)+e.firstOffset:f=s+e.firstOffset;for(let g=0;g<c.length;g++){let y=e.references[g],v=y.referencedSize,A=y.subsegmentDuration,x;typeof f=="bigint"?x=f+Rt.default.BigInt(v)-Rt.default.BigInt(1):x=f+v-1;let k=`${f}-${x}`,K=bT({baseUrl:r,timescale:u,timeline:o,periodStart:p,presentationTime:m,number:h,duration:A,sourceDuration:n,indexRange:k,type:d})[0];i&&(K.map=i),l.push(K),typeof f=="bigint"?f+=Rt.default.BigInt(v):f+=v,m+=A/u,h++}return t.segments=l,t},q9=["AUDIO","SUBTITLES"],V9=1/60,IT=t=>L9(t,({timeline:e})=>e).sort((e,r)=>e.timeline>r.timeline?1:-1),H9=(t,e)=>{for(let r=0;r<t.length;r++)if(t[r].attributes.NAME===e)return t[r];return null},mT=t=>{let e=[];return P9.forEachMediaGroup(t,q9,(r,i,n,o)=>{e=e.concat(r.playlists||[])}),e},hT=({playlist:t,mediaSequence:e})=>{t.mediaSequence=e,t.segments.forEach((r,i)=>{r.number=t.mediaSequence+i})},G9=({oldPlaylists:t,newPlaylists:e,timelineStarts:r})=>{e.forEach(i=>{i.discontinuitySequence=r.findIndex(function({timeline:u}){return u===i.timeline});let n=H9(t,i.attributes.NAME);if(!n||i.sidx)return;let o=i.segments[0],a=n.segments.findIndex(function(u){return Math.abs(u.presentationTime-o.presentationTime)<V9});if(a===-1){hT({playlist:i,mediaSequence:n.mediaSequence+n.segments.length}),i.segments[0].discontinuity=!0,i.discontinuityStarts.unshift(0),(!n.segments.length&&i.timeline>n.timeline||n.segments.length&&i.timeline>n.segments[n.segments.length-1].timeline)&&i.discontinuitySequence--;return}n.segments[a].discontinuity&&!o.discontinuity&&(o.discontinuity=!0,i.discontinuityStarts.unshift(0),i.discontinuitySequence--),hT({playlist:i,mediaSequence:n.segments[a].number})})},J9=({oldManifest:t,newManifest:e})=>{let r=t.playlists.concat(mT(t)),i=e.playlists.concat(mT(e));return e.timelineStarts=IT([t.timelineStarts,e.timelineStarts]),G9({oldPlaylists:r,newPlaylists:i,timelineStarts:e.timelineStarts}),e},wT=t=>t&&t.uri+"-"+F9(t.byterange),r0=t=>{let e=t.reduce(function(i,n){return i[n.attributes.baseUrl]||(i[n.attributes.baseUrl]=[]),i[n.attributes.baseUrl].push(n),i},{}),r=[];return Object.values(e).forEach(i=>{let n=yT(i.reduce((o,a)=>{let s=a.attributes.id+(a.attributes.lang||"");return o[s]?(a.segments&&(a.segments[0]&&(a.segments[0].discontinuity=!0),o[s].segments.push(...a.segments)),a.attributes.contentProtection&&(o[s].attributes.contentProtection=a.attributes.contentProtection)):(o[s]=a,o[s].attributes.timelineStarts=[]),o[s].attributes.timelineStarts.push({start:a.attributes.periodStart,timeline:a.attributes.periodStart}),o},{}));r=r.concat(n)}),r.map(i=>(i.discontinuityStarts=M9(i.segments||[],"discontinuity"),i))},a0=(t,e)=>{let r=wT(t.sidx),i=r&&e[r]&&e[r].sidx;return i&&$T(t,i,t.sidx.resolvedUri),t},K9=(t,e={})=>{if(!Object.keys(e).length)return t;for(let r in t)t[r]=a0(t[r],e);return t},X9=({attributes:t,segments:e,sidx:r,mediaSequence:i,discontinuitySequence:n,discontinuityStarts:o},a)=>{let s={attributes:{NAME:t.id,BANDWIDTH:t.bandwidth,CODECS:t.codecs,"PROGRAM-ID":1},uri:"",endList:t.type==="static",timeline:t.periodStart,resolvedUri:t.baseUrl||"",targetDuration:t.duration,discontinuitySequence:n,discontinuityStarts:o,timelineStarts:t.timelineStarts,mediaSequence:i,segments:e};return t.contentProtection&&(s.contentProtection=t.contentProtection),t.serviceLocation&&(s.attributes.serviceLocation=t.serviceLocation),r&&(s.sidx=r),a&&(s.attributes.AUDIO="audio",s.attributes.SUBTITLES="subs"),s},Y9=({attributes:t,segments:e,mediaSequence:r,discontinuityStarts:i,discontinuitySequence:n})=>{typeof e>"u"&&(e=[{uri:t.baseUrl,timeline:t.periodStart,resolvedUri:t.baseUrl||"",duration:t.sourceDuration,number:0}],t.duration=t.sourceDuration);let o={NAME:t.id,BANDWIDTH:t.bandwidth,"PROGRAM-ID":1};t.codecs&&(o.CODECS=t.codecs);let a={attributes:o,uri:"",endList:t.type==="static",timeline:t.periodStart,resolvedUri:t.baseUrl||"",targetDuration:t.duration,timelineStarts:t.timelineStarts,discontinuityStarts:i,discontinuitySequence:n,mediaSequence:r,segments:e};return t.serviceLocation&&(a.attributes.serviceLocation=t.serviceLocation),a},W9=(t,e={},r=!1)=>{let i,n=t.reduce((o,a)=>{let s=a.attributes.role&&a.attributes.role.value||"",u=a.attributes.lang||"",c=a.attributes.label||"main";if(u&&!a.attributes.label){let d=s?` (${s})`:"";c=`${a.attributes.lang}${d}`}o[c]||(o[c]={language:u,autoselect:!0,default:s==="main",playlists:[],uri:""});let l=a0(X9(a,r),e);return o[c].playlists.push(l),typeof i>"u"&&s==="main"&&(i=a,i.default=!0),o},{});if(!i){let o=Object.keys(n)[0];n[o].default=!0}return n},eZ=(t,e={})=>t.reduce((r,i)=>{let n=i.attributes.label||i.attributes.lang||"text",o=i.attributes.lang||"und";return r[n]||(r[n]={language:o,default:!1,autoselect:!1,playlists:[],uri:""}),r[n].playlists.push(a0(Y9(i),e)),r},{}),tZ=t=>t.reduce((e,r)=>(r&&r.forEach(i=>{let{channel:n,language:o}=i;e[o]={autoselect:!1,default:!1,instreamId:n,language:o},i.hasOwnProperty("aspectRatio")&&(e[o].aspectRatio=i.aspectRatio),i.hasOwnProperty("easyReader")&&(e[o].easyReader=i.easyReader),i.hasOwnProperty("3D")&&(e[o]["3D"]=i["3D"])}),e),{}),rZ=({attributes:t,segments:e,sidx:r,discontinuityStarts:i})=>{let n={attributes:{NAME:t.id,AUDIO:"audio",SUBTITLES:"subs",RESOLUTION:{width:t.width,height:t.height},CODECS:t.codecs,BANDWIDTH:t.bandwidth,"PROGRAM-ID":1},uri:"",endList:t.type==="static",timeline:t.periodStart,resolvedUri:t.baseUrl||"",targetDuration:t.duration,discontinuityStarts:i,timelineStarts:t.timelineStarts,segments:e};return t.frameRate&&(n.attributes["FRAME-RATE"]=t.frameRate),t.qualityRanking!==void 0&&(n.attributes.SCORE=1/(t.qualityRanking+1)),t.contentProtection&&(n.contentProtection=t.contentProtection),t.serviceLocation&&(n.attributes.serviceLocation=t.serviceLocation),r&&(n.sidx=r),n},nZ=({attributes:t})=>t.mimeType==="video/mp4"||t.mimeType==="video/webm"||t.contentType==="video",iZ=({attributes:t})=>t.mimeType==="audio/mp4"||t.mimeType==="audio/webm"||t.contentType==="audio",oZ=({attributes:t})=>t.mimeType==="text/vtt"||t.contentType==="text",aZ=(t,e)=>{t.forEach(r=>{r.mediaSequence=0,r.discontinuitySequence=e.findIndex(function({timeline:i}){return i===r.timeline}),r.segments&&r.segments.forEach((i,n)=>{i.number=n})})},gT=t=>t?Object.keys(t).reduce((e,r)=>{let i=t[r];return e.concat(i.playlists)},[]):[],ET=({dashPlaylists:t,locations:e,contentSteering:r,sidxMapping:i={},previousManifest:n,eventStream:o})=>{if(!t.length)return{};let{sourceDuration:a,type:s,suggestedPresentationDelay:u,minimumUpdatePeriod:c}=t[0].attributes,l=r0(t.filter(nZ)).map(rZ),d=r0(t.filter(iZ)),p=r0(t.filter(oZ)),m=t.map(x=>x.attributes.captionServices).filter(Boolean),h={allowCache:!0,discontinuityStarts:[],segments:[],endList:!0,mediaGroups:{AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},uri:"",duration:a,playlists:K9(l,i)};c>=0&&(h.minimumUpdatePeriod=c*1e3),e&&(h.locations=e),r&&(h.contentSteering=r),s==="dynamic"&&(h.suggestedPresentationDelay=u),o&&o.length>0&&(h.eventStream=o);let f=h.playlists.length===0,g=d.length?W9(d,i,f):null,y=p.length?eZ(p,i):null,v=l.concat(gT(g),gT(y)),A=v.map(({timelineStarts:x})=>x);return h.timelineStarts=IT(A),aZ(v,h.timelineStarts),g&&(h.mediaGroups.AUDIO.audio=g),y&&(h.mediaGroups.SUBTITLES.subs=y),m.length&&(h.mediaGroups["CLOSED-CAPTIONS"].cc=tZ(m)),n?J9({oldManifest:n,newManifest:h}):h},sZ=(t,e,r)=>{let{NOW:i,clientOffset:n,availabilityStartTime:o,timescale:a=1,periodStart:s=0,minimumUpdatePeriod:u=0}=t,c=(i+n)/1e3,l=o+s,p=c+u-l;return Math.ceil((p*a-e)/r)},xT=(t,e)=>{let{type:r,minimumUpdatePeriod:i=0,media:n="",sourceDuration:o,timescale:a=1,startNumber:s=1,periodStart:u}=t,c=[],l=-1;for(let d=0;d<e.length;d++){let p=e[d],m=p.d,h=p.r||0,f=p.t||0;l<0&&(l=f),f&&f>l&&(l=f);let g;if(h<0){let A=d+1;A===e.length?r==="dynamic"&&i>0&&n.indexOf("$Number$")>0?g=sZ(t,l,m):g=(o*a-l)/m:g=(e[A].t-l)/m}else g=h+1;let y=s+c.length+g,v=s+c.length;for(;v<y;)c.push({number:v,duration:m/a,time:l,timeline:u}),l+=m,v++}return c},uZ=/\$([A-z]*)(?:(%0)([0-9]+)d)?\$/g,cZ=t=>(e,r,i,n)=>{if(e==="$$")return"$";if(typeof t[r]>"u")return e;let o=""+t[r];return r==="RepresentationID"||(i?n=parseInt(n,10):n=1,o.length>=n)?o:`${new Array(n-o.length+1).join("0")}${o}`},vT=(t,e)=>t.replace(uZ,cZ(e)),lZ=(t,e)=>!t.duration&&!e?[{number:t.startNumber||1,duration:t.sourceDuration,time:0,timeline:t.periodStart}]:t.duration?o0(t):xT(t,e),dZ=(t,e)=>{let r={RepresentationID:t.id,Bandwidth:t.bandwidth||0},{initialization:i={sourceURL:"",range:""}}=t,n=hc({baseUrl:t.baseUrl,source:vT(i.sourceURL,r),range:i.range});return lZ(t,e).map(a=>{r.Number=a.number,r.Time=a.time;let s=vT(t.media||"",r),u=t.timescale||1,c=t.presentationTimeOffset||0,l=t.periodStart+(a.time-c)/u;return{uri:s,timeline:a.timeline,duration:a.duration,resolvedUri:i0.default(t.baseUrl||"",s),map:n,number:a.number,presentationTime:l}})},fZ=(t,e)=>{let{baseUrl:r,initialization:i={}}=t,n=hc({baseUrl:r,source:i.sourceURL,range:i.range}),o=hc({baseUrl:r,source:e.media,range:e.mediaRange});return o.map=n,o},pZ=(t,e)=>{let{duration:r,segmentUrls:i=[],periodStart:n}=t;if(!r&&!e||r&&e)throw new Error(Ea.SEGMENT_TIME_UNSPECIFIED);let o=i.map(u=>fZ(t,u)),a;return r&&(a=o0(t)),e&&(a=xT(t,e)),a.map((u,c)=>{if(o[c]){let l=o[c],d=t.timescale||1,p=t.presentationTimeOffset||0;return l.timeline=u.timeline,l.duration=u.duration,l.number=u.number,l.presentationTime=n+(u.time-p)/d,l}}).filter(u=>u)},mZ=({attributes:t,segmentInfo:e})=>{let r,i;e.template?(i=dZ,r=Je(t,e.template)):e.base?(i=bT,r=Je(t,e.base)):e.list&&(i=pZ,r=Je(t,e.list));let n={attributes:t};if(!i)return n;let o=i(r,e.segmentTimeline);if(r.duration){let{duration:a,timescale:s=1}=r;r.duration=a/s}else o.length?r.duration=o.reduce((a,s)=>Math.max(a,Math.ceil(s.duration)),0):r.duration=0;return n.attributes=r,n.segments=o,e.base&&r.indexRange&&(n.sidx=o[0],n.segments=[]),n},ST=t=>t.map(mZ),Oe=(t,e)=>_T(t.childNodes).filter(({tagName:r})=>r===e),gc=t=>t.textContent.trim(),hZ=t=>parseFloat(t.split("/").reduce((e,r)=>e/r)),Ia=t=>{let s=/P(?:(\d*)Y)?(?:(\d*)M)?(?:(\d*)D)?(?:T(?:(\d*)H)?(?:(\d*)M)?(?:([\d.]*)S)?)?/.exec(t);if(!s)return 0;let[u,c,l,d,p,m]=s.slice(1);return parseFloat(u||0)*31536e3+parseFloat(c||0)*2592e3+parseFloat(l||0)*86400+parseFloat(d||0)*3600+parseFloat(p||0)*60+parseFloat(m||0)},gZ=t=>(/^\d+-\d+-\d+T\d+:\d+:\d+(\.\d+)?$/.test(t)&&(t+="Z"),Date.parse(t)),AT={mediaPresentationDuration(t){return Ia(t)},availabilityStartTime(t){return gZ(t)/1e3},minimumUpdatePeriod(t){return Ia(t)},suggestedPresentationDelay(t){return Ia(t)},type(t){return t},timeShiftBufferDepth(t){return Ia(t)},start(t){return Ia(t)},width(t){return parseInt(t,10)},height(t){return parseInt(t,10)},bandwidth(t){return parseInt(t,10)},frameRate(t){return hZ(t)},startNumber(t){return parseInt(t,10)},timescale(t){return parseInt(t,10)},presentationTimeOffset(t){return parseInt(t,10)},duration(t){let e=parseInt(t,10);return isNaN(e)?Ia(t):e},d(t){return parseInt(t,10)},t(t){return parseInt(t,10)},r(t){return parseInt(t,10)},presentationTime(t){return parseInt(t,10)},qualityRanking(t){return parseInt(t,10)},qualityranking(t){return parseInt(t,10)},DEFAULT(t){return t}},vZ={qualityranking:"qualityRanking"},Me=t=>t&&t.attributes?_T(t.attributes).reduce((e,r)=>{let i=AT[r.name]||AT.DEFAULT,n=vZ[r.name]||r.name;return e[n]=i(r.value),e},{}):{},AZ={"urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b":"org.w3.clearkey","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":"com.widevine.alpha","urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":"com.microsoft.playready","urn:uuid:f239e769-efa3-4850-9c16-a903c6932efb":"com.adobe.primetime","urn:mpeg:dash:mp4protection:2011":"mp4protection"},Sm=(t,e)=>e.length?wa(t.map(function(r){return e.map(function(i){let n=gc(i),o=i0.default(r.baseUrl,n),a=Je(Me(i),{baseUrl:o});return o!==n&&!a.serviceLocation&&r.serviceLocation&&(a.serviceLocation=r.serviceLocation),a})})):t,s0=t=>{let e=Oe(t,"SegmentTemplate")[0],r=Oe(t,"SegmentList")[0],i=r&&Oe(r,"SegmentURL").map(d=>Je({tag:"SegmentURL"},Me(d))),n=Oe(t,"SegmentBase")[0],o=r||e,a=o&&Oe(o,"SegmentTimeline")[0],s=r||n||e,u=s&&Oe(s,"Initialization")[0],c=e&&Me(e);c&&u?c.initialization=u&&Me(u):c&&c.initialization&&(c.initialization={sourceURL:c.initialization});let l={template:c,segmentTimeline:a&&Oe(a,"S").map(d=>Me(d)),list:r&&Je(Me(r),{segmentUrls:i,initialization:Me(u)}),base:n&&Je(Me(n),{initialization:Me(u)})};return Object.keys(l).forEach(d=>{l[d]||delete l[d]}),l},yZ=(t,e,r)=>i=>{let n=Oe(i,"BaseURL"),o=Sm(e,n),a=Je(t,Me(i)),s=s0(i);return o.map(u=>({segmentInfo:Je(r,s),attributes:Je(a,u)}))},_Z=t=>t.reduce((e,r)=>{let i=Me(r);i.schemeIdUri&&(i.schemeIdUri=i.schemeIdUri.toLowerCase());let n=AZ[i.schemeIdUri];if(n){e[n]={attributes:i};let o=Oe(r,"cenc:pssh")[0];if(o){let a=gc(o);e[n].pssh=a&&j9.default(a)}}return e},{}),bZ=t=>{if(t.schemeIdUri==="urn:scte:dash:cc:cea-608:2015")return(typeof t.value!="string"?[]:t.value.split(";")).map(r=>{let i,n;return n=r,/^CC\d=/.test(r)?[i,n]=r.split("="):/^CC\d$/.test(r)&&(i=r),{channel:i,language:n}});if(t.schemeIdUri==="urn:scte:dash:cc:cea-708:2015")return(typeof t.value!="string"?[]:t.value.split(";")).map(r=>{let i={channel:void 0,language:void 0,aspectRatio:1,easyReader:0,"3D":0};if(/=/.test(r)){let[n,o=""]=r.split("=");i.channel=n,i.language=r,o.split(",").forEach(a=>{let[s,u]=a.split(":");s==="lang"?i.language=u:s==="er"?i.easyReader=Number(u):s==="war"?i.aspectRatio=Number(u):s==="3D"&&(i["3D"]=Number(u))})}else i.language=r;return i.channel&&(i.channel="SERVICE"+i.channel),i})},$Z=t=>wa(Oe(t.node,"EventStream").map(e=>{let r=Me(e),i=r.schemeIdUri;return Oe(e,"Event").map(n=>{let o=Me(n),a=o.presentationTime||0,s=r.timescale||1,u=o.duration||0,c=a/s+t.attributes.start;return{schemeIdUri:i,value:r.value,id:o.id,start:c,end:c+u/s,messageData:gc(n)||o.messageData,contentEncoding:r.contentEncoding,presentationTimeOffset:r.presentationTimeOffset||0}})})),IZ=(t,e,r)=>i=>{let n=Me(i),o=Sm(e,Oe(i,"BaseURL")),a=Oe(i,"Role")[0],s={role:Me(a)},u=Je(t,n,s),c=Oe(i,"Accessibility")[0],l=bZ(Me(c));l&&(u=Je(u,{captionServices:l}));let d=Oe(i,"Label")[0];if(d&&d.childNodes.length){let g=d.childNodes[0].nodeValue.trim();u=Je(u,{label:g})}let p=_Z(Oe(i,"ContentProtection"));Object.keys(p).length&&(u=Je(u,{contentProtection:p}));let m=s0(i),h=Oe(i,"Representation"),f=Je(r,m);return wa(h.map(yZ(u,o,f)))},wZ=(t,e)=>(r,i)=>{let n=Sm(e,Oe(r.node,"BaseURL")),o=Je(t,{periodStart:r.attributes.start});typeof r.attributes.duration=="number"&&(o.periodDuration=r.attributes.duration);let a=Oe(r.node,"AdaptationSet"),s=s0(r.node);return wa(a.map(IZ(o,n,s)))},EZ=(t,e)=>{if(t.length>1&&e({type:"warn",message:"The MPD manifest should contain no more than one ContentSteering tag"}),!t.length)return null;let r=Je({serverURL:gc(t[0])},Me(t[0]));return r.queryBeforeStart=r.queryBeforeStart==="true",r},xZ=({attributes:t,priorPeriodAttributes:e,mpdType:r})=>typeof t.start=="number"?t.start:e&&typeof e.start=="number"&&typeof e.duration=="number"?e.start+e.duration:!e&&r==="static"?0:null,kT=(t,e={})=>{let{manifestUri:r="",NOW:i=Date.now(),clientOffset:n=0,eventHandler:o=function(){}}=e,a=Oe(t,"Period");if(!a.length)throw new Error(Ea.INVALID_NUMBER_OF_PERIOD);let s=Oe(t,"Location"),u=Me(t),c=Sm([{baseUrl:r}],Oe(t,"BaseURL")),l=Oe(t,"ContentSteering");u.type=u.type||"static",u.sourceDuration=u.mediaPresentationDuration||0,u.NOW=i,u.clientOffset=n,s.length&&(u.locations=s.map(gc));let d=[];return a.forEach((p,m)=>{let h=Me(p),f=d[m-1];h.start=xZ({attributes:h,priorPeriodAttributes:f?f.attributes:null,mpdType:u.type}),d.push({node:p,attributes:h})}),{locations:u.locations,contentSteeringInfo:EZ(l,o),representationInfo:wa(d.map(wZ(u,c))),eventStream:wa(d.map($Z))}},u0=t=>{if(t==="")throw new Error(Ea.DASH_EMPTY_MANIFEST);let e=new R9.DOMParser,r,i;try{r=e.parseFromString(t,"application/xml"),i=r&&r.documentElement.tagName==="MPD"?r.documentElement:null}catch{}if(!i||i&&i.getElementsByTagName("parsererror").length>0)throw new Error(Ea.DASH_INVALID_XML);return i},SZ=t=>{let e=Oe(t,"UTCTiming")[0];if(!e)return null;let r=Me(e);switch(r.schemeIdUri){case"urn:mpeg:dash:utc:http-head:2014":case"urn:mpeg:dash:utc:http-head:2012":r.method="HEAD";break;case"urn:mpeg:dash:utc:http-xsdate:2014":case"urn:mpeg:dash:utc:http-iso:2014":case"urn:mpeg:dash:utc:http-xsdate:2012":case"urn:mpeg:dash:utc:http-iso:2012":r.method="GET";break;case"urn:mpeg:dash:utc:direct:2014":case"urn:mpeg:dash:utc:direct:2012":r.method="DIRECT",r.value=Date.parse(r.value);break;default:throw new Error(Ea.UNSUPPORTED_UTC_TIMING_SCHEME)}return r},kZ=B9,CZ=(t,e={})=>{let r=kT(u0(t),e),i=ST(r.representationInfo);return ET({dashPlaylists:i,locations:r.locations,contentSteering:r.contentSteeringInfo,sidxMapping:e.sidxMapping,previousManifest:e.previousManifest,eventStream:r.eventStream})},DZ=t=>SZ(u0(t));yr.VERSION=kZ;yr.addSidxSegmentsToPlaylist=$T;yr.generateSidxKey=wT;yr.inheritAttributes=kT;yr.parse=CZ;yr.parseUTCTiming=DZ;yr.stringToMpdXml=u0;yr.toM3u8=ET;yr.toPlaylists=ST});var ue;(function(t){t.assertEqual=n=>{};function e(n){}t.assertIs=e;function r(n){throw new Error}t.assertNever=r,t.arrayToEnum=n=>{let o={};for(let a of n)o[a]=a;return o},t.getValidEnumValues=n=>{let o=t.objectKeys(n).filter(s=>typeof n[n[s]]!="number"),a={};for(let s of o)a[s]=n[s];return t.objectValues(a)},t.objectValues=n=>t.objectKeys(n).map(function(o){return n[o]}),t.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{let o=[];for(let a in n)Object.prototype.hasOwnProperty.call(n,a)&&o.push(a);return o},t.find=(n,o)=>{for(let a of n)if(o(a))return a},t.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function i(n,o=" | "){return n.map(a=>typeof a=="string"?`'${a}'`:a).join(o)}t.joinValues=i,t.jsonStringifyReplacer=(n,o)=>typeof o=="bigint"?o.toString():o})(ue||(ue={}));var y0;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(y0||(y0={}));var R=ue.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Br=t=>{switch(typeof t){case"undefined":return R.undefined;case"string":return R.string;case"number":return Number.isNaN(t)?R.nan:R.number;case"boolean":return R.boolean;case"function":return R.function;case"bigint":return R.bigint;case"symbol":return R.symbol;case"object":return Array.isArray(t)?R.array:t===null?R.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?R.promise:typeof Map<"u"&&t instanceof Map?R.map:typeof Set<"u"&&t instanceof Set?R.set:typeof Date<"u"&&t instanceof Date?R.date:R.object;default:return R.unknown}};var C=ue.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);var Bt=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=i=>{this.issues=[...this.issues,i]},this.addIssues=(i=[])=>{this.issues=[...this.issues,...i]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(o){return o.message},i={_errors:[]},n=o=>{for(let a of o.issues)if(a.code==="invalid_union")a.unionErrors.map(n);else if(a.code==="invalid_return_type")n(a.returnTypeError);else if(a.code==="invalid_arguments")n(a.argumentsError);else if(a.path.length===0)i._errors.push(r(a));else{let s=i,u=0;for(;u<a.path.length;){let c=a.path[u],l=u===a.path.length-1;if(c==="_errors"){l&&s._errors.push(r(a)),u++;continue}Object.prototype.hasOwnProperty.call(s,c)||(c==="__proto__"?Object.defineProperty(s,c,{value:{_errors:[]},writable:!0,enumerable:!0,configurable:!0}):s[c]={_errors:[]}),s=s[c],l&&s._errors.push(r(a)),u++}}};return n(this),i}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ue.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r=Object.create(null),i=[];for(let n of this.issues)if(n.path.length>0){let o=n.path[0];r[o]=r[o]||[],r[o].push(e(n))}else i.push(e(n));return{formErrors:i,fieldErrors:r}}get formErrors(){return this.flatten()}};Bt.create=t=>new Bt(t);var c1=(t,e)=>{let r;switch(t.code){case C.invalid_type:t.received===R.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case C.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,ue.jsonStringifyReplacer)}`;break;case C.unrecognized_keys:r=`Unrecognized key(s) in object: ${ue.joinValues(t.keys,", ")}`;break;case C.invalid_union:r="Invalid input";break;case C.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${ue.joinValues(t.options)}`;break;case C.invalid_enum_value:r=`Invalid enum value. Expected ${ue.joinValues(t.options)}, received '${t.received}'`;break;case C.invalid_arguments:r="Invalid function arguments";break;case C.invalid_return_type:r="Invalid function return type";break;case C.invalid_date:r="Invalid date";break;case C.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:ue.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case C.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case C.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case C.custom:r="Invalid input";break;case C.invalid_intersection_types:r="Intersection results could not be merged";break;case C.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case C.not_finite:r="Number must be finite";break;default:r=e.defaultError,ue.assertNever(t)}return{message:r}},an=c1;var l1=an;function Na(){return l1}var _c=t=>{let{data:e,path:r,errorMaps:i,issueData:n}=t,o=[...r,...n.path||[]],a={...n,path:o};if(n.message!==void 0)return{...n,path:o,message:n.message};let s="",u=i.filter(c=>!!c).slice().reverse();for(let c of u)s=c(a,{data:e,defaultError:s}).message;return{...n,path:o,message:s}};function z(t,e){let r=Na(),i=_c({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===an?void 0:an].filter(n=>!!n)});t.common.issues.push(i)}var ot=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let i=[];for(let n of r){if(n.status==="aborted")return q;n.status==="dirty"&&e.dirty(),i.push(n.value)}return{status:e.value,value:i}}static async mergeObjectAsync(e,r){let i=[];for(let n of r){let o=await n.key,a=await n.value;i.push({key:o,value:a})}return t.mergeObjectSync(e,i)}static mergeObjectSync(e,r){let i={};for(let n of r){let{key:o,value:a}=n;if(o.status==="aborted"||a.status==="aborted")return q;o.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),o.value!=="__proto__"&&(typeof a.value<"u"||n.alwaysSet)&&(i[o.value]=a.value)}return{status:e.value,value:i}}},q=Object.freeze({status:"aborted"}),wi=t=>({status:"dirty",value:t}),pt=t=>({status:"valid",value:t}),Mm=t=>t.status==="aborted",Lm=t=>t.status==="dirty",Mn=t=>t.status==="valid",za=t=>typeof Promise<"u"&&t instanceof Promise;var U;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(U||(U={}));var Ht=class{constructor(e,r,i,n){this._cachedPath=[],this.parent=e,this.data=r,this._path=i,this._key=n}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},_0=(t,e)=>{if(Mn(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new Bt(t.common.issues);return this._error=r,this._error}}};function Y(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:i,description:n}=t;if(e&&(r||i))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(a,s)=>{let{message:u}=t;return a.code==="invalid_enum_value"?{message:u??s.defaultError}:typeof s.data>"u"?{message:u??i??s.defaultError}:a.code!=="invalid_type"?{message:s.defaultError}:{message:u??r??s.defaultError}},description:n}}var ne=class{get description(){return this._def.description}_getType(e){return Br(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Br(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ot,ctx:{common:e.parent.common,data:e.data,parsedType:Br(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(za(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let i=this.safeParse(e,r);if(i.success)return i.data;throw i.error}safeParse(e,r){let i={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Br(e)},n=this._parseSync({data:e,path:i.path,parent:i});return _0(i,n)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Br(e)};if(!this["~standard"].async)try{let i=this._parseSync({data:e,path:[],parent:r});return Mn(i)?{value:i.value}:{issues:r.common.issues}}catch(i){i?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(i=>Mn(i)?{value:i.value}:{issues:r.common.issues})}async parseAsync(e,r){let i=await this.safeParseAsync(e,r);if(i.success)return i.data;throw i.error}async safeParseAsync(e,r){let i={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Br(e)},n=this._parse({data:e,path:i.path,parent:i}),o=await(za(n)?n:Promise.resolve(n));return _0(i,o)}refine(e,r){let i=n=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(n):r;return this._refinement((n,o)=>{let a=e(n),s=()=>o.addIssue({code:C.custom,...i(n)});return typeof Promise<"u"&&a instanceof Promise?a.then(u=>u?!0:(s(),!1)):a?!0:(s(),!1)})}refinement(e,r){return this._refinement((i,n)=>e(i)?!0:(n.addIssue(typeof r=="function"?r(i,n):r),!1))}_refinement(e){return new ar({schema:this,typeName:T.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return or.create(this,this._def)}nullable(){return Lr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return un.create(this)}promise(){return Ln.create(this,this._def)}or(e){return Ci.create([this,e],this._def)}and(e){return Di.create(this,e,this._def)}transform(e){return new ar({...Y(this._def),schema:this,typeName:T.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new Oi({...Y(this._def),innerType:this,defaultValue:r,typeName:T.ZodDefault})}brand(){return new bc({typeName:T.ZodBranded,type:this,...Y(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new Ri({...Y(this._def),innerType:this,catchValue:r,typeName:T.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return $c.create(this,e)}readonly(){return ji.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},d1=/^c[^\s-]{8,}$/i,f1=/^[0-9a-z]+$/,p1=/^[0-9A-HJKMNP-TV-Z]{26}$/i,m1=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,h1=/^[a-z0-9_-]{21}$/i,g1=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,v1=/^[-+]?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)?)??$/,A1=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,y1="^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$",Fm,_1=/^(?:(?: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])$/,b1=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,$1=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,I1=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,w1=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,E1=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,b0="((\\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])))",x1=new RegExp(`^${b0}$`);function $0(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function S1(t){return new RegExp(`^${$0(t)}$`)}function k1(t){let e=`${b0}T${$0(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function C1(t,e){return!!((e==="v4"||!e)&&_1.test(t)||(e==="v6"||!e)&&$1.test(t))}function D1(t,e){if(!g1.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let i=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),n=JSON.parse(atob(i));return!(typeof n!="object"||n===null||"typ"in n&&n?.typ!=="JWT"||!n.alg||e&&n.alg!==e)}catch{return!1}}function T1(t,e){return!!((e==="v4"||!e)&&b1.test(t)||(e==="v6"||!e)&&I1.test(t))}var xi=class t extends ne{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==R.string){let o=this._getOrReturnCtx(e);return z(o,{code:C.invalid_type,expected:R.string,received:o.parsedType}),q}let i=new ot,n;for(let o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(n=this._getOrReturnCtx(e,n),z(n,{code:C.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),i.dirty());else if(o.kind==="max")e.data.length>o.value&&(n=this._getOrReturnCtx(e,n),z(n,{code:C.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),i.dirty());else if(o.kind==="length"){let a=e.data.length>o.value,s=e.data.length<o.value;(a||s)&&(n=this._getOrReturnCtx(e,n),a?z(n,{code:C.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):s&&z(n,{code:C.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),i.dirty())}else if(o.kind==="email")A1.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:"email",code:C.invalid_string,message:o.message}),i.dirty());else if(o.kind==="emoji")Fm||(Fm=new RegExp(y1,"u")),Fm.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:"emoji",code:C.invalid_string,message:o.message}),i.dirty());else if(o.kind==="uuid")m1.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:"uuid",code:C.invalid_string,message:o.message}),i.dirty());else if(o.kind==="nanoid")h1.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:"nanoid",code:C.invalid_string,message:o.message}),i.dirty());else if(o.kind==="cuid")d1.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:"cuid",code:C.invalid_string,message:o.message}),i.dirty());else if(o.kind==="cuid2")f1.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:"cuid2",code:C.invalid_string,message:o.message}),i.dirty());else if(o.kind==="ulid")p1.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:"ulid",code:C.invalid_string,message:o.message}),i.dirty());else if(o.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),z(n,{validation:"url",code:C.invalid_string,message:o.message}),i.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:"regex",code:C.invalid_string,message:o.message}),i.dirty())):o.kind==="trim"?e.data=e.data.trim():o.kind==="includes"?e.data.includes(o.value,o.position)||(n=this._getOrReturnCtx(e,n),z(n,{code:C.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),i.dirty()):o.kind==="toLowerCase"?e.data=e.data.toLowerCase():o.kind==="toUpperCase"?e.data=e.data.toUpperCase():o.kind==="startsWith"?e.data.startsWith(o.value)||(n=this._getOrReturnCtx(e,n),z(n,{code:C.invalid_string,validation:{startsWith:o.value},message:o.message}),i.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(n=this._getOrReturnCtx(e,n),z(n,{code:C.invalid_string,validation:{endsWith:o.value},message:o.message}),i.dirty()):o.kind==="datetime"?k1(o).test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{code:C.invalid_string,validation:"datetime",message:o.message}),i.dirty()):o.kind==="date"?x1.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{code:C.invalid_string,validation:"date",message:o.message}),i.dirty()):o.kind==="time"?S1(o).test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{code:C.invalid_string,validation:"time",message:o.message}),i.dirty()):o.kind==="duration"?v1.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:"duration",code:C.invalid_string,message:o.message}),i.dirty()):o.kind==="ip"?C1(e.data,o.version)||(n=this._getOrReturnCtx(e,n),z(n,{validation:"ip",code:C.invalid_string,message:o.message}),i.dirty()):o.kind==="jwt"?D1(e.data,o.alg)||(n=this._getOrReturnCtx(e,n),z(n,{validation:"jwt",code:C.invalid_string,message:o.message}),i.dirty()):o.kind==="cidr"?T1(e.data,o.version)||(n=this._getOrReturnCtx(e,n),z(n,{validation:"cidr",code:C.invalid_string,message:o.message}),i.dirty()):o.kind==="base64"?w1.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:"base64",code:C.invalid_string,message:o.message}),i.dirty()):o.kind==="base64url"?E1.test(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{validation:"base64url",code:C.invalid_string,message:o.message}),i.dirty()):ue.assertNever(o);return{status:i.value,value:e.data}}_regex(e,r,i){return this.refinement(n=>e.test(n),{validation:r,code:C.invalid_string,...U.errToObj(i)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...U.errToObj(e)})}url(e){return this._addCheck({kind:"url",...U.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...U.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...U.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...U.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...U.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...U.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...U.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...U.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...U.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...U.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...U.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...U.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...U.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...U.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...U.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...U.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...U.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...U.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...U.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...U.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...U.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...U.errToObj(r)})}nonempty(e){return this.min(1,U.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};xi.create=t=>new xi({checks:[],typeName:T.ZodString,coerce:t?.coerce??!1,...Y(t)});function N1(t,e){let r=(t.toString().split(".")[1]||"").length,i=(e.toString().split(".")[1]||"").length,n=r>i?r:i,o=Number.parseInt(t.toFixed(n).replace(".","")),a=Number.parseInt(e.toFixed(n).replace(".",""));return o%a/10**n}var Pa=class t extends ne{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==R.number){let o=this._getOrReturnCtx(e);return z(o,{code:C.invalid_type,expected:R.number,received:o.parsedType}),q}let i,n=new ot;for(let o of this._def.checks)o.kind==="int"?ue.isInteger(e.data)||(i=this._getOrReturnCtx(e,i),z(i,{code:C.invalid_type,expected:"integer",received:"float",message:o.message}),n.dirty()):o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(i=this._getOrReturnCtx(e,i),z(i,{code:C.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),n.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(i=this._getOrReturnCtx(e,i),z(i,{code:C.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),n.dirty()):o.kind==="multipleOf"?N1(e.data,o.value)!==0&&(i=this._getOrReturnCtx(e,i),z(i,{code:C.not_multiple_of,multipleOf:o.value,message:o.message}),n.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(i=this._getOrReturnCtx(e,i),z(i,{code:C.not_finite,message:o.message}),n.dirty()):ue.assertNever(o);return{status:n.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,U.toString(r))}gt(e,r){return this.setLimit("min",e,!1,U.toString(r))}lte(e,r){return this.setLimit("max",e,!0,U.toString(r))}lt(e,r){return this.setLimit("max",e,!1,U.toString(r))}setLimit(e,r,i,n){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:i,message:U.toString(n)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:U.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:U.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:U.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:U.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:U.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:U.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:U.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:U.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:U.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&ue.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let i of this._def.checks){if(i.kind==="finite"||i.kind==="int"||i.kind==="multipleOf")return!0;i.kind==="min"?(r===null||i.value>r)&&(r=i.value):i.kind==="max"&&(e===null||i.value<e)&&(e=i.value)}return Number.isFinite(r)&&Number.isFinite(e)}};Pa.create=t=>new Pa({checks:[],typeName:T.ZodNumber,coerce:t?.coerce||!1,...Y(t)});var Oa=class t extends ne{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==R.bigint)return this._getInvalidInput(e);let i,n=new ot;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(i=this._getOrReturnCtx(e,i),z(i,{code:C.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),n.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(i=this._getOrReturnCtx(e,i),z(i,{code:C.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),n.dirty()):o.kind==="multipleOf"?e.data%o.value!==BigInt(0)&&(i=this._getOrReturnCtx(e,i),z(i,{code:C.not_multiple_of,multipleOf:o.value,message:o.message}),n.dirty()):ue.assertNever(o);return{status:n.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return z(r,{code:C.invalid_type,expected:R.bigint,received:r.parsedType}),q}gte(e,r){return this.setLimit("min",e,!0,U.toString(r))}gt(e,r){return this.setLimit("min",e,!1,U.toString(r))}lte(e,r){return this.setLimit("max",e,!0,U.toString(r))}lt(e,r){return this.setLimit("max",e,!1,U.toString(r))}setLimit(e,r,i,n){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:i,message:U.toString(n)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:U.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:U.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:U.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:U.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:U.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};Oa.create=t=>new Oa({checks:[],typeName:T.ZodBigInt,coerce:t?.coerce??!1,...Y(t)});var Ra=class extends ne{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==R.boolean){let i=this._getOrReturnCtx(e);return z(i,{code:C.invalid_type,expected:R.boolean,received:i.parsedType}),q}return pt(e.data)}};Ra.create=t=>new Ra({typeName:T.ZodBoolean,coerce:t?.coerce||!1,...Y(t)});var ja=class t extends ne{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==R.date){let o=this._getOrReturnCtx(e);return z(o,{code:C.invalid_type,expected:R.date,received:o.parsedType}),q}if(Number.isNaN(e.data.getTime())){let o=this._getOrReturnCtx(e);return z(o,{code:C.invalid_date}),q}let i=new ot,n;for(let o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(n=this._getOrReturnCtx(e,n),z(n,{code:C.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),i.dirty()):o.kind==="max"?e.data.getTime()>o.value&&(n=this._getOrReturnCtx(e,n),z(n,{code:C.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),i.dirty()):ue.assertNever(o);return{status:i.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:U.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:U.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};ja.create=t=>new ja({checks:[],coerce:t?.coerce||!1,typeName:T.ZodDate,...Y(t)});var Ba=class extends ne{_parse(e){if(this._getType(e)!==R.symbol){let i=this._getOrReturnCtx(e);return z(i,{code:C.invalid_type,expected:R.symbol,received:i.parsedType}),q}return pt(e.data)}};Ba.create=t=>new Ba({typeName:T.ZodSymbol,...Y(t)});var Si=class extends ne{_parse(e){if(this._getType(e)!==R.undefined){let i=this._getOrReturnCtx(e);return z(i,{code:C.invalid_type,expected:R.undefined,received:i.parsedType}),q}return pt(e.data)}};Si.create=t=>new Si({typeName:T.ZodUndefined,...Y(t)});var ki=class extends ne{_parse(e){if(this._getType(e)!==R.null){let i=this._getOrReturnCtx(e);return z(i,{code:C.invalid_type,expected:R.null,received:i.parsedType}),q}return pt(e.data)}};ki.create=t=>new ki({typeName:T.ZodNull,...Y(t)});var Ua=class extends ne{constructor(){super(...arguments),this._any=!0}_parse(e){return pt(e.data)}};Ua.create=t=>new Ua({typeName:T.ZodAny,...Y(t)});var sn=class extends ne{constructor(){super(...arguments),this._unknown=!0}_parse(e){return pt(e.data)}};sn.create=t=>new sn({typeName:T.ZodUnknown,...Y(t)});var br=class extends ne{_parse(e){let r=this._getOrReturnCtx(e);return z(r,{code:C.invalid_type,expected:R.never,received:r.parsedType}),q}};br.create=t=>new br({typeName:T.ZodNever,...Y(t)});var Ma=class extends ne{_parse(e){if(this._getType(e)!==R.undefined){let i=this._getOrReturnCtx(e);return z(i,{code:C.invalid_type,expected:R.void,received:i.parsedType}),q}return pt(e.data)}};Ma.create=t=>new Ma({typeName:T.ZodVoid,...Y(t)});var un=class t extends ne{_parse(e){let{ctx:r,status:i}=this._processInputParams(e),n=this._def;if(r.parsedType!==R.array)return z(r,{code:C.invalid_type,expected:R.array,received:r.parsedType}),q;if(n.exactLength!==null){let a=r.data.length>n.exactLength.value,s=r.data.length<n.exactLength.value;(a||s)&&(z(r,{code:a?C.too_big:C.too_small,minimum:s?n.exactLength.value:void 0,maximum:a?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),i.dirty())}if(n.minLength!==null&&r.data.length<n.minLength.value&&(z(r,{code:C.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),i.dirty()),n.maxLength!==null&&r.data.length>n.maxLength.value&&(z(r,{code:C.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),i.dirty()),r.common.async)return Promise.all([...r.data].map((a,s)=>n.type._parseAsync(new Ht(r,a,r.path,s)))).then(a=>ot.mergeArray(i,a));let o=[...r.data].map((a,s)=>n.type._parseSync(new Ht(r,a,r.path,s)));return ot.mergeArray(i,o)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:U.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:U.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:U.toString(r)}})}nonempty(e){return this.min(1,e)}};un.create=(t,e)=>new un({type:t,minLength:null,maxLength:null,exactLength:null,typeName:T.ZodArray,...Y(e)});function Ei(t){if(t instanceof Ut){let e={};for(let r in t.shape){let i=t.shape[r];e[r]=or.create(Ei(i))}return new Ut({...t._def,shape:()=>e})}else return t instanceof un?new un({...t._def,type:Ei(t.element)}):t instanceof or?or.create(Ei(t.unwrap())):t instanceof Lr?Lr.create(Ei(t.unwrap())):t instanceof Mr?Mr.create(t.items.map(e=>Ei(e))):t}var Ut=class t extends ne{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=ue.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==R.object){let c=this._getOrReturnCtx(e);return z(c,{code:C.invalid_type,expected:R.object,received:c.parsedType}),q}let{status:i,ctx:n}=this._processInputParams(e),{shape:o,keys:a}=this._getCached(),s=[];if(!(this._def.catchall instanceof br&&this._def.unknownKeys==="strip"))for(let c in n.data)a.includes(c)||s.push(c);let u=[];for(let c of a){let l=o[c],d=n.data[c];u.push({key:{status:"valid",value:c},value:l._parse(new Ht(n,d,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof br){let c=this._def.unknownKeys;if(c==="passthrough")for(let l of s)u.push({key:{status:"valid",value:l},value:{status:"valid",value:n.data[l]}});else if(c==="strict")s.length>0&&(z(n,{code:C.unrecognized_keys,keys:s}),i.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let l of s){let d=n.data[l];u.push({key:{status:"valid",value:l},value:c._parse(new Ht(n,d,n.path,l)),alwaysSet:l in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let c=[];for(let l of u){let d=await l.key,p=await l.value;c.push({key:d,value:p,alwaysSet:l.alwaysSet})}return c}).then(c=>ot.mergeObjectSync(i,c)):ot.mergeObjectSync(i,u)}get shape(){return this._def.shape()}strict(e){return U.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,i)=>{let n=this._def.errorMap?.(r,i).message??i.defaultError;return r.code==="unrecognized_keys"?{message:U.errToObj(e).message??n}:{message:n}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:T.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let i of ue.objectKeys(e))e[i]&&this.shape[i]&&(r[i]=this.shape[i]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let i of ue.objectKeys(this.shape))e[i]||(r[i]=this.shape[i]);return new t({...this._def,shape:()=>r})}deepPartial(){return Ei(this)}partial(e){let r={};for(let i of ue.objectKeys(this.shape)){let n=this.shape[i];e&&!e[i]?r[i]=n:r[i]=n.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let i of ue.objectKeys(this.shape))if(e&&!e[i])r[i]=this.shape[i];else{let o=this.shape[i];for(;o instanceof or;)o=o._def.innerType;r[i]=o}return new t({...this._def,shape:()=>r})}keyof(){return I0(ue.objectKeys(this.shape))}};Ut.create=(t,e)=>new Ut({shape:()=>t,unknownKeys:"strip",catchall:br.create(),typeName:T.ZodObject,...Y(e)});Ut.strictCreate=(t,e)=>new Ut({shape:()=>t,unknownKeys:"strict",catchall:br.create(),typeName:T.ZodObject,...Y(e)});Ut.lazycreate=(t,e)=>new Ut({shape:t,unknownKeys:"strip",catchall:br.create(),typeName:T.ZodObject,...Y(e)});var Ci=class extends ne{_parse(e){let{ctx:r}=this._processInputParams(e),i=this._def.options;function n(o){for(let s of o)if(s.result.status==="valid")return s.result;for(let s of o)if(s.result.status==="dirty")return r.common.issues.push(...s.ctx.common.issues),s.result;let a=o.map(s=>new Bt(s.ctx.common.issues));return z(r,{code:C.invalid_union,unionErrors:a}),q}if(r.common.async)return Promise.all(i.map(async o=>{let a={...r,common:{...r.common,issues:[]},parent:null};return{result:await o._parseAsync({data:r.data,path:r.path,parent:a}),ctx:a}})).then(n);{let o,a=[];for(let u of i){let c={...r,common:{...r.common,issues:[]},parent:null},l=u._parseSync({data:r.data,path:r.path,parent:c});if(l.status==="valid")return l;l.status==="dirty"&&!o&&(o={result:l,ctx:c}),c.common.issues.length&&a.push(c.common.issues)}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;let s=a.map(u=>new Bt(u));return z(r,{code:C.invalid_union,unionErrors:s}),q}}get options(){return this._def.options}};Ci.create=(t,e)=>new Ci({options:t,typeName:T.ZodUnion,...Y(e)});var Ur=t=>t instanceof Ti?Ur(t.schema):t instanceof ar?Ur(t.innerType()):t instanceof Ni?[t.value]:t instanceof zi?t.options:t instanceof Pi?ue.objectValues(t.enum):t instanceof Oi?Ur(t._def.innerType):t instanceof Si?[void 0]:t instanceof ki?[null]:t instanceof or?[void 0,...Ur(t.unwrap())]:t instanceof Lr?[null,...Ur(t.unwrap())]:t instanceof bc||t instanceof ji?Ur(t.unwrap()):t instanceof Ri?Ur(t._def.innerType):[],Zm=class t extends ne{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==R.object)return z(r,{code:C.invalid_type,expected:R.object,received:r.parsedType}),q;let i=this.discriminator,n=r.data[i],o=this.optionsMap.get(n);return o?r.common.async?o._parseAsync({data:r.data,path:r.path,parent:r}):o._parseSync({data:r.data,path:r.path,parent:r}):(z(r,{code:C.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[i]}),q)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,i){let n=new Map;for(let o of r){let a=Ur(o.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let s of a){if(n.has(s))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(s)}`);n.set(s,o)}}return new t({typeName:T.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:n,...Y(i)})}};function Qm(t,e){let r=Br(t),i=Br(e);if(t===e)return{valid:!0,data:t};if(r===R.object&&i===R.object){let n=ue.objectKeys(e),o=ue.objectKeys(t).filter(s=>n.indexOf(s)!==-1),a={...t,...e};Object.prototype.hasOwnProperty.call(a,"__proto__")&&delete a.__proto__;for(let s of o){if(s==="__proto__")continue;let u=Qm(t[s],e[s]);if(!u.valid)return{valid:!1};a[s]=u.data}return{valid:!0,data:a}}else if(r===R.array&&i===R.array){if(t.length!==e.length)return{valid:!1};let n=[];for(let o=0;o<t.length;o++){let a=t[o],s=e[o],u=Qm(a,s);if(!u.valid)return{valid:!1};n.push(u.data)}return{valid:!0,data:n}}else return r===R.date&&i===R.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var Di=class extends ne{_parse(e){let{status:r,ctx:i}=this._processInputParams(e),n=(o,a)=>{if(Mm(o)||Mm(a))return q;let s=Qm(o.value,a.value);return s.valid?((Lm(o)||Lm(a))&&r.dirty(),{status:r.value,value:s.data}):(z(i,{code:C.invalid_intersection_types}),q)};return i.common.async?Promise.all([this._def.left._parseAsync({data:i.data,path:i.path,parent:i}),this._def.right._parseAsync({data:i.data,path:i.path,parent:i})]).then(([o,a])=>n(o,a)):n(this._def.left._parseSync({data:i.data,path:i.path,parent:i}),this._def.right._parseSync({data:i.data,path:i.path,parent:i}))}};Di.create=(t,e,r)=>new Di({left:t,right:e,typeName:T.ZodIntersection,...Y(r)});var Mr=class t extends ne{_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.parsedType!==R.array)return z(i,{code:C.invalid_type,expected:R.array,received:i.parsedType}),q;if(i.data.length<this._def.items.length)return z(i,{code:C.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),q;!this._def.rest&&i.data.length>this._def.items.length&&(z(i,{code:C.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let o=[...i.data].map((a,s)=>{let u=this._def.items[s]||this._def.rest;return u?u._parse(new Ht(i,a,i.path,s)):null}).filter(a=>!!a);return i.common.async?Promise.all(o).then(a=>ot.mergeArray(r,a)):ot.mergeArray(r,o)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};Mr.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Mr({items:t,typeName:T.ZodTuple,rest:null,...Y(e)})};var qm=class t extends ne{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.parsedType!==R.object)return z(i,{code:C.invalid_type,expected:R.object,received:i.parsedType}),q;let n=[],o=this._def.keyType,a=this._def.valueType;for(let s in i.data)n.push({key:o._parse(new Ht(i,s,i.path,s)),value:a._parse(new Ht(i,i.data[s],i.path,s)),alwaysSet:s in i.data});return i.common.async?ot.mergeObjectAsync(r,n):ot.mergeObjectSync(r,n)}get element(){return this._def.valueType}static create(e,r,i){return r instanceof ne?new t({keyType:e,valueType:r,typeName:T.ZodRecord,...Y(i)}):new t({keyType:xi.create(),valueType:e,typeName:T.ZodRecord,...Y(r)})}},La=class extends ne{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.parsedType!==R.map)return z(i,{code:C.invalid_type,expected:R.map,received:i.parsedType}),q;let n=this._def.keyType,o=this._def.valueType,a=[...i.data.entries()].map(([s,u],c)=>({key:n._parse(new Ht(i,s,i.path,[c,"key"])),value:o._parse(new Ht(i,u,i.path,[c,"value"]))}));if(i.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let u of a){let c=await u.key,l=await u.value;if(c.status==="aborted"||l.status==="aborted")return q;(c.status==="dirty"||l.status==="dirty")&&r.dirty(),s.set(c.value,l.value)}return{status:r.value,value:s}})}else{let s=new Map;for(let u of a){let c=u.key,l=u.value;if(c.status==="aborted"||l.status==="aborted")return q;(c.status==="dirty"||l.status==="dirty")&&r.dirty(),s.set(c.value,l.value)}return{status:r.value,value:s}}}};La.create=(t,e,r)=>new La({valueType:e,keyType:t,typeName:T.ZodMap,...Y(r)});var Fa=class t extends ne{_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.parsedType!==R.set)return z(i,{code:C.invalid_type,expected:R.set,received:i.parsedType}),q;let n=this._def;n.minSize!==null&&i.data.size<n.minSize.value&&(z(i,{code:C.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),r.dirty()),n.maxSize!==null&&i.data.size>n.maxSize.value&&(z(i,{code:C.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),r.dirty());let o=this._def.valueType;function a(u){let c=new Set;for(let l of u){if(l.status==="aborted")return q;l.status==="dirty"&&r.dirty(),c.add(l.value)}return{status:r.value,value:c}}let s=[...i.data.values()].map((u,c)=>o._parse(new Ht(i,u,i.path,c)));return i.common.async?Promise.all(s).then(u=>a(u)):a(s)}min(e,r){return new t({...this._def,minSize:{value:e,message:U.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:U.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Fa.create=(t,e)=>new Fa({valueType:t,minSize:null,maxSize:null,typeName:T.ZodSet,...Y(e)});var Vm=class t extends ne{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==R.function)return z(r,{code:C.invalid_type,expected:R.function,received:r.parsedType}),q;function i(s,u){return _c({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Na(),an].filter(c=>!!c),issueData:{code:C.invalid_arguments,argumentsError:u}})}function n(s,u){return _c({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Na(),an].filter(c=>!!c),issueData:{code:C.invalid_return_type,returnTypeError:u}})}let o={errorMap:r.common.contextualErrorMap},a=r.data;if(this._def.returns instanceof Ln){let s=this;return pt(async function(...u){let c=new Bt([]),l=await s._def.args.parseAsync(u,o).catch(m=>{throw c.addIssue(i(u,m)),c}),d=await Reflect.apply(a,this,l);return await s._def.returns._def.type.parseAsync(d,o).catch(m=>{throw c.addIssue(n(d,m)),c})})}else{let s=this;return pt(function(...u){let c=s._def.args.safeParse(u,o);if(!c.success)throw new Bt([i(u,c.error)]);let l=Reflect.apply(a,this,c.data),d=s._def.returns.safeParse(l,o);if(!d.success)throw new Bt([n(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Mr.create(e).rest(sn.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,i){return new t({args:e||Mr.create([]).rest(sn.create()),returns:r||sn.create(),typeName:T.ZodFunction,...Y(i)})}},Ti=class extends ne{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};Ti.create=(t,e)=>new Ti({getter:t,typeName:T.ZodLazy,...Y(e)});var Ni=class extends ne{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return z(r,{received:r.data,code:C.invalid_literal,expected:this._def.value}),q}return{status:"valid",value:e.data}}get value(){return this._def.value}};Ni.create=(t,e)=>new Ni({value:t,typeName:T.ZodLiteral,...Y(e)});function I0(t,e){return new zi({values:t,typeName:T.ZodEnum,...Y(e)})}var zi=class t extends ne{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),i=this._def.values;return z(r,{expected:ue.joinValues(i),received:r.parsedType,code:C.invalid_type}),q}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),i=this._def.values;return z(r,{received:r.data,code:C.invalid_enum_value,options:i}),q}return pt(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(i=>!e.includes(i)),{...this._def,...r})}};zi.create=I0;var Pi=class extends ne{_parse(e){let r=ue.getValidEnumValues(this._def.values),i=this._getOrReturnCtx(e);if(i.parsedType!==R.string&&i.parsedType!==R.number){let n=ue.objectValues(r);return z(i,{expected:ue.joinValues(n),received:i.parsedType,code:C.invalid_type}),q}if(this._cache||(this._cache=new Set(ue.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let n=ue.objectValues(r);return z(i,{received:i.data,code:C.invalid_enum_value,options:n}),q}return pt(e.data)}get enum(){return this._def.values}};Pi.create=(t,e)=>new Pi({values:t,typeName:T.ZodNativeEnum,...Y(e)});var Ln=class extends ne{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==R.promise&&r.common.async===!1)return z(r,{code:C.invalid_type,expected:R.promise,received:r.parsedType}),q;let i=r.parsedType===R.promise?r.data:Promise.resolve(r.data);return pt(i.then(n=>this._def.type.parseAsync(n,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Ln.create=(t,e)=>new Ln({type:t,typeName:T.ZodPromise,...Y(e)});var ar=class extends ne{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===T.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:i}=this._processInputParams(e),n=this._def.effect||null,o={addIssue:a=>{z(i,a),a.fatal?r.abort():r.dirty()},get path(){return i.path}};if(o.addIssue=o.addIssue.bind(o),n.type==="preprocess"){let a=n.transform(i.data,o);if(i.common.async)return Promise.resolve(a).then(async s=>{if(r.value==="aborted")return q;let u=await this._def.schema._parseAsync({data:s,path:i.path,parent:i});return u.status==="aborted"?q:u.status==="dirty"?wi(u.value):r.value==="dirty"?wi(u.value):u});{if(r.value==="aborted")return q;let s=this._def.schema._parseSync({data:a,path:i.path,parent:i});return s.status==="aborted"?q:s.status==="dirty"?wi(s.value):r.value==="dirty"?wi(s.value):s}}if(n.type==="refinement"){let a=s=>{let u=n.refinement(s,o);if(i.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(i.common.async===!1){let s=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});return s.status==="aborted"?q:(s.status==="dirty"&&r.dirty(),a(s.value),{status:r.value,value:s.value})}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(s=>s.status==="aborted"?q:(s.status==="dirty"&&r.dirty(),a(s.value).then(()=>({status:r.value,value:s.value}))))}if(n.type==="transform")if(i.common.async===!1){let a=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});if(!Mn(a))return q;let s=n.transform(a.value,o);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:s}}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(a=>Mn(a)?Promise.resolve(n.transform(a.value,o)).then(s=>({status:r.value,value:s})):q);ue.assertNever(n)}};ar.create=(t,e,r)=>new ar({schema:t,typeName:T.ZodEffects,effect:e,...Y(r)});ar.createWithPreprocess=(t,e,r)=>new ar({schema:e,effect:{type:"preprocess",transform:t},typeName:T.ZodEffects,...Y(r)});var or=class extends ne{_parse(e){return this._getType(e)===R.undefined?pt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};or.create=(t,e)=>new or({innerType:t,typeName:T.ZodOptional,...Y(e)});var Lr=class extends ne{_parse(e){return this._getType(e)===R.null?pt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Lr.create=(t,e)=>new Lr({innerType:t,typeName:T.ZodNullable,...Y(e)});var Oi=class extends ne{_parse(e){let{ctx:r}=this._processInputParams(e),i=r.data;return r.parsedType===R.undefined&&(i=this._def.defaultValue()),this._def.innerType._parse({data:i,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Oi.create=(t,e)=>new Oi({innerType:t,typeName:T.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Y(e)});var Ri=class extends ne{_parse(e){let{ctx:r}=this._processInputParams(e),i={...r,common:{...r.common,issues:[]}},n=this._def.innerType._parse({data:i.data,path:i.path,parent:{...i}});return za(n)?n.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Bt(i.common.issues)},input:i.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new Bt(i.common.issues)},input:i.data})}}removeCatch(){return this._def.innerType}};Ri.create=(t,e)=>new Ri({innerType:t,typeName:T.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Y(e)});var Za=class extends ne{_parse(e){if(this._getType(e)!==R.nan){let i=this._getOrReturnCtx(e);return z(i,{code:C.invalid_type,expected:R.nan,received:i.parsedType}),q}return{status:"valid",value:e.data}}};Za.create=t=>new Za({typeName:T.ZodNaN,...Y(t)});var bc=class extends ne{_parse(e){let{ctx:r}=this._processInputParams(e),i=r.data;return this._def.type._parse({data:i,path:r.path,parent:r})}unwrap(){return this._def.type}},$c=class t extends ne{_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.common.async)return(async()=>{let o=await this._def.in._parseAsync({data:i.data,path:i.path,parent:i});return o.status==="aborted"?q:o.status==="dirty"?(r.dirty(),wi(o.value)):this._def.out._parseAsync({data:o.value,path:i.path,parent:i})})();{let n=this._def.in._parseSync({data:i.data,path:i.path,parent:i});return n.status==="aborted"?q:n.status==="dirty"?(r.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:i.path,parent:i})}}static create(e,r){return new t({in:e,out:r,typeName:T.ZodPipeline})}},ji=class extends ne{_parse(e){let r=this._def.innerType._parse(e),i=n=>(Mn(n)&&(n.value=Object.freeze(n.value)),n);return za(r)?r.then(n=>i(n)):i(r)}unwrap(){return this._def.innerType}};ji.create=(t,e)=>new ji({innerType:t,typeName:T.ZodReadonly,...Y(e)});var R5={object:Ut.lazycreate},T;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(T||(T={}));var j5=xi.create,B5=Pa.create,U5=Za.create,M5=Oa.create,L5=Ra.create,F5=ja.create,Z5=Ba.create,Q5=Si.create,q5=ki.create,V5=Ua.create,H5=sn.create,G5=br.create,J5=Ma.create,K5=un.create,w0=Ut.create,X5=Ut.strictCreate,Y5=Ci.create,W5=Zm.create,eQ=Di.create,tQ=Mr.create,rQ=qm.create,nQ=La.create,iQ=Fa.create,oQ=Vm.create,aQ=Ti.create,sQ=Ni.create,uQ=zi.create,cQ=Pi.create,lQ=Ln.create,dQ=ar.create,fQ=or.create,pQ=Lr.create,mQ=ar.createWithPreprocess,hQ=$c.create;var cr={};jr(cr,{$ZodAny:()=>Dl,$ZodArray:()=>Ol,$ZodAsyncError:()=>Et,$ZodBase64:()=>ml,$ZodBase64URL:()=>gl,$ZodBigInt:()=>ds,$ZodBigIntFormat:()=>xl,$ZodBoolean:()=>ro,$ZodCIDRv4:()=>ll,$ZodCIDRv6:()=>fl,$ZodCUID:()=>rl,$ZodCUID2:()=>nl,$ZodCatch:()=>Wl,$ZodCheck:()=>$e,$ZodCheckBigIntFormat:()=>Yh,$ZodCheckEndsWith:()=>lg,$ZodCheckGreaterThan:()=>Lc,$ZodCheckIncludes:()=>ug,$ZodCheckLengthEquals:()=>ig,$ZodCheckLessThan:()=>Mc,$ZodCheckLowerCase:()=>ag,$ZodCheckMaxLength:()=>rg,$ZodCheckMaxSize:()=>Wh,$ZodCheckMimeType:()=>pg,$ZodCheckMinLength:()=>ng,$ZodCheckMinSize:()=>eg,$ZodCheckMultipleOf:()=>Kh,$ZodCheckNumberFormat:()=>Xh,$ZodCheckOverwrite:()=>mg,$ZodCheckProperties:()=>fg,$ZodCheckProperty:()=>dg,$ZodCheckRegex:()=>og,$ZodCheckSizeEquals:()=>tg,$ZodCheckStartsWith:()=>cg,$ZodCheckStringFormat:()=>eo,$ZodCheckUpperCase:()=>sg,$ZodCodec:()=>io,$ZodCreditCard:()=>yl,$ZodCustom:()=>od,$ZodCustomStringFormat:()=>wl,$ZodCyclicError:()=>cd,$ZodDate:()=>Pl,$ZodDefault:()=>Jl,$ZodDiscriminatedUnion:()=>Bl,$ZodE164:()=>vl,$ZodEmail:()=>Jc,$ZodEmoji:()=>el,$ZodEncodeError:()=>ln,$ZodEnum:()=>Zl,$ZodError:()=>lh,$ZodExactOptional:()=>Hl,$ZodFile:()=>ql,$ZodFunction:()=>nd,$ZodGUID:()=>Hc,$ZodIBAN:()=>bl,$ZodIPv4:()=>sl,$ZodIPv6:()=>ul,$ZodISODate:()=>_g,$ZodISODateTime:()=>yg,$ZodISODuration:()=>$g,$ZodISOTime:()=>bg,$ZodIntersection:()=>Ul,$ZodJWT:()=>Il,$ZodKSUID:()=>al,$ZodLazy:()=>oo,$ZodLiteral:()=>Ql,$ZodMAC:()=>cl,$ZodMap:()=>Ll,$ZodNaN:()=>ed,$ZodNanoID:()=>tl,$ZodNever:()=>Nl,$ZodNonOptional:()=>Xl,$ZodNull:()=>Cl,$ZodNullable:()=>Gl,$ZodNumber:()=>ls,$ZodNumberFormat:()=>El,$ZodObject:()=>Rl,$ZodObjectJIT:()=>wg,$ZodOptional:()=>ps,$ZodPipe:()=>ms,$ZodPrefault:()=>Kl,$ZodPreprocess:()=>xg,$ZodPromise:()=>id,$ZodReadonly:()=>td,$ZodRealError:()=>xt,$ZodRecord:()=>Ml,$ZodRegistry:()=>hd,$ZodSet:()=>Fl,$ZodString:()=>dn,$ZodStringFormat:()=>Ae,$ZodSuccess:()=>Yl,$ZodSymbol:()=>Sl,$ZodTemplateLiteral:()=>rd,$ZodTransform:()=>Vl,$ZodTuple:()=>fs,$ZodType:()=>G,$ZodULID:()=>il,$ZodURL:()=>Wc,$ZodUUID:()=>Gc,$ZodUndefined:()=>kl,$ZodUnion:()=>no,$ZodUnknown:()=>Tl,$ZodVoid:()=>zl,$ZodXID:()=>ol,$ZodXor:()=>jl,$brand:()=>sh,$constructor:()=>_,$input:()=>Dg,$output:()=>Cg,Doc:()=>Gn,INVALID:()=>gt,JSONSchema:()=>aw,JSONSchemaGenerator:()=>of,NEVER:()=>ah,TimePrecision:()=>Bg,URL_BAD_FORMAT:()=>vg,URL_UNPARSEABLE:()=>os,ZodCompileAsyncError:()=>sr,ZodCompileUnsupportedError:()=>ae,_any:()=>jd,_array:()=>Zg,_base64:()=>Rs,_base64url:()=>js,_bigint:()=>Td,_boolean:()=>Dd,_catch:()=>bO,_check:()=>QI,_cidrv4:()=>Ps,_cidrv6:()=>Os,_coercedBigint:()=>Lg,_coercedBoolean:()=>Mg,_coercedDate:()=>Fg,_coercedNumber:()=>Ug,_coercedString:()=>jg,_creditCard:()=>$d,_cuid:()=>Ss,_cuid2:()=>ks,_custom:()=>Jd,_date:()=>Ld,_decode:()=>Cc,_decodeAsync:()=>Tc,_default:()=>AO,_discriminatedUnion:()=>aO,_e164:()=>Bs,_email:()=>ys,_emoji:()=>Es,_encode:()=>kc,_encodeAsync:()=>Dc,_endsWith:()=>vo,_enum:()=>fO,_file:()=>Gd,_float32:()=>xd,_float64:()=>Sd,_gt:()=>wr,_gte:()=>Ft,_guid:()=>_s,_iban:()=>Id,_includes:()=>ho,_int:()=>Ed,_int32:()=>kd,_int64:()=>Nd,_intersection:()=>sO,_ipv4:()=>Ns,_ipv6:()=>zs,_isoDate:()=>Ls,_isoDateTime:()=>Ms,_isoDuration:()=>Zs,_isoTime:()=>Fs,_jwt:()=>Us,_ksuid:()=>Ts,_lazy:()=>EO,_length:()=>ei,_literal:()=>mO,_lowercase:()=>po,_lt:()=>Ir,_lte:()=>Lt,_mac:()=>bd,_map:()=>lO,_max:()=>Lt,_maxLength:()=>Wn,_maxSize:()=>mn,_mime:()=>yo,_min:()=>Ft,_minLength:()=>qr,_minSize:()=>Er,_multipleOf:()=>pn,_nan:()=>Fd,_nanoid:()=>xs,_nativeEnum:()=>pO,_negative:()=>Qd,_never:()=>Ud,_nonnegative:()=>Vd,_nonoptional:()=>yO,_nonpositive:()=>qd,_normalize:()=>_o,_null:()=>Rd,_nullable:()=>vO,_number:()=>wd,_optional:()=>gO,_overwrite:()=>ur,_parse:()=>Vi,_parseAsync:()=>Hi,_pipe:()=>$O,_positive:()=>Zd,_promise:()=>xO,_properties:()=>Ao,_property:()=>Hd,_readonly:()=>IO,_record:()=>cO,_refine:()=>Kd,_regex:()=>fo,_safeDecode:()=>zc,_safeDecodeAsync:()=>Oc,_safeEncode:()=>Nc,_safeEncodeAsync:()=>Pc,_safeParse:()=>Gi,_safeParseAsync:()=>Ki,_set:()=>dO,_size:()=>Yn,_slugify:()=>wo,_startsWith:()=>go,_string:()=>_d,_stringFormat:()=>hn,_stringbool:()=>ef,_success:()=>_O,_superRefine:()=>Xd,_symbol:()=>Pd,_templateLiteral:()=>wO,_toLowerCase:()=>$o,_toUpperCase:()=>Io,_transform:()=>hO,_trim:()=>bo,_tuple:()=>uO,_uint32:()=>Cd,_uint64:()=>zd,_ulid:()=>Cs,_undefined:()=>Od,_union:()=>iO,_unknown:()=>Bd,_uppercase:()=>mo,_url:()=>lo,_uuid:()=>bs,_uuidv4:()=>$s,_uuidv6:()=>Is,_uuidv7:()=>ws,_void:()=>Md,_xid:()=>Ds,_xor:()=>oO,base64Charset:()=>pl,base64urlCharset:()=>cs,canParseURL:()=>Ag,clone:()=>he,compile:()=>Pg,compileFn:()=>Ad,config:()=>Re,createStandardJSONSchemaMethod:()=>Eo,createToJSONSchemaMethod:()=>qg,decode:()=>q0,decodeAsync:()=>H0,describe:()=>Yd,encode:()=>Q0,encodeAsync:()=>V0,extractDefs:()=>vn,finalize:()=>An,flattenError:()=>Wa,formatError:()=>es,getDiscriminatedOption:()=>Eg,globalConfig:()=>Ve,globalRegistry:()=>Ye,handleUnrepresentable:()=>Fe,initializeContext:()=>gn,isBackEdge:()=>dd,isRecursiveSchema:()=>ld,isValidBase64:()=>us,isValidBase64URL:()=>hl,isValidCIDRv6:()=>dl,isValidCreditCard:()=>Al,isValidIBAN:()=>_l,isValidIPv6:()=>ss,isValidJWT:()=>$l,locales:()=>uo,memoizer:()=>vs,mergeValues:()=>to,meta:()=>Wd,parse:()=>qn,parseAsync:()=>Vn,parseURLObject:()=>v$,prettifyError:()=>fh,process:()=>_e,processSchema:()=>_e,regexes:()=>Mt,registry:()=>gd,safeDecode:()=>J0,safeDecodeAsync:()=>X0,safeEncode:()=>G0,safeEncodeAsync:()=>K0,safeParse:()=>Ji,safeParseAsync:()=>Xi,standardProps:()=>Vc,stripTabAndNewline:()=>as,toDotPath:()=>F0,toJSONSchema:()=>ti,toZod:()=>Qa,treeifyError:()=>dh,urlHostnameOk:()=>Xc,urlProtocolOk:()=>Yc,util:()=>I,validate:()=>Yi,validateAsync:()=>Wi,validateURL:()=>Kc,version:()=>hg,withParser:()=>vd});var I={};jr(I,{BIGINT_FORMAT_RANGES:()=>Ga,CONSTANT_CATCH:()=>xc,Class:()=>Jm,NUMBER_FORMAT_RANGES:()=>Ha,aborted:()=>ht,allowsEval:()=>Ym,assert:()=>j1,assertEqual:()=>z1,assertIs:()=>O1,assertNever:()=>R1,assertNotEqual:()=>P1,assignProp:()=>Xe,attachSchema:()=>Ja,base64ToUint8Array:()=>R0,base64urlToUint8Array:()=>J1,cached:()=>Li,captureStackTrace:()=>wc,cleanEnum:()=>G1,cleanRegex:()=>Zr,clone:()=>he,cloneDef:()=>M1,codePointLength:()=>Qn,constantCatch:()=>ih,createTransparentProxy:()=>V1,defineLazy:()=>Km,defineLazyInternal:()=>ee,derived:()=>W1,esc:()=>mt,escapeRegex:()=>Kt,explicitlyAborted:()=>th,extend:()=>D0,finalizeIssue:()=>wt,floatSafeRemainder:()=>qa,getElementAtPath:()=>L1,getEnumValues:()=>Ui,getLengthableOrigin:()=>Xa,getParsedType:()=>q1,getSizableOrigin:()=>Ka,hexToUint8Array:()=>X1,hide:()=>Ya,installLazyProp:()=>nh,isObject:()=>Zn,isPlainObject:()=>Jt,issue:()=>qi,joinValues:()=>b,jsonStringifyReplacer:()=>Mi,members:()=>rh,merge:()=>z0,mergeDefs:()=>Gt,normalizeParams:()=>D,nullish:()=>Ic,numKeys:()=>Q1,objectClone:()=>B1,omit:()=>C0,optionalKeys:()=>eh,own:()=>$r,parsedType:()=>E,partial:()=>P0,pick:()=>k0,prefixIssues:()=>It,primitiveTypes:()=>Wm,promiseAllObject:()=>F1,propertyKeyTypes:()=>Va,randomString:()=>Z1,rawShape:()=>Fi,required:()=>O0,safeExtend:()=>N0,shallowClone:()=>Zi,sizeCaps:()=>Qi,slugify:()=>Xm,stringifyPrimitive:()=>w,toZod:()=>Qa,uint8ArrayToBase64:()=>j0,uint8ArrayToBase64url:()=>K1,uint8ArrayToHex:()=>Y1,unwrapMessage:()=>Bi});function z1(t){return t}function P1(t){return t}function Qa(){return t=>t}function O1(t){}function R1(t){throw new Error("Unexpected value in exhaustive check")}function j1(t){}function Ui(t){let e=Object.values(t).filter(i=>typeof i=="number");return Object.entries(t).filter(([i,n])=>e.indexOf(+i)===-1).map(([i,n])=>n)}function b(t,e="|"){return t.map(r=>w(r)).join(e)}function Mi(t,e){return typeof e=="bigint"?e.toString():e}var Gm=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function Li(t){return new Gm(t)}function Ic(t){return t==null}function Zr(t){let e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function qa(t,e){let r=t/e,i=Math.round(r),n=4*Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-i)<n?0:r-i}var E0=Symbol("evaluating");function Km(t,e,r){let i;Object.defineProperty(t,e,{get(){if(i!==E0)return i===void 0&&(i=E0,i=r()),i},set(n){Object.defineProperty(t,e,{value:n})},configurable:!0})}function B1(t){return Object.create(Object.getPrototypeOf(t),Object.getOwnPropertyDescriptors(t))}function Xe(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Fi(t){let e=Object.getOwnPropertyDescriptor(t,"shape");return e?.get?e.get.raw:e?.value}function Fr(t){return Fi(t._zod.def)??t._zod.def.shape}function x0(t,e,r){Object.defineProperty(t,e,{get(){let i=r();return Xe(this,e,i),i},enumerable:!0,configurable:!0})}function S0(t,e,r){e in t?Xe(t,e,r):t[e]=r}function Fn(t,e,r,i){let n=Fr(e);for(let o of r){let a=Object.getOwnPropertyDescriptor(n,o);a.enumerable&&(a.get?x0(t,o,()=>{let s=e._zod.def.shape[o];return i?i(s,o):s}):S0(t,o,i?i(a.value,o):a.value))}}function U1(t,e){for(let r of Reflect.ownKeys(e)){let i=Object.getOwnPropertyDescriptor(e,r);i.enumerable&&(i.get?x0(t,r,()=>e[r]):S0(t,r,i.value))}}function Gt(...t){let e={};for(let r of t){let i=Object.getOwnPropertyDescriptors(r);Object.assign(e,i)}return Object.defineProperties({},e)}function M1(t){return Gt(t._zod.def)}function L1(t,e){return e?e.reduce((r,i)=>r?.[i],t):t}function F1(t){let e=Object.keys(t),r=e.map(i=>t[i]);return Promise.all(r).then(i=>{let n={};for(let o=0;o<e.length;o++)n[e[o]]=i[o];return n})}function Z1(t=10){let e="abcdefghijklmnopqrstuvwxyz",r="";for(let i=0;i<t;i++)r+=e[Math.floor(Math.random()*e.length)];return r}function mt(t){return JSON.stringify(t)}function Xm(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var wc="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function Zn(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var Ym=Li(()=>{if(Ve.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let t=Function;return new t(""),!0}catch{return!1}});function Jt(t){if(Zn(t)===!1)return!1;let e=t.constructor;if(e===void 0||typeof e!="function")return!0;let r=e.prototype;return!(Zn(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Zi(t){return Jt(t)?{...t}:Array.isArray(t)?[...t]:t instanceof Map?new Map(t):t instanceof Set?new Set(t):t}function Q1(t){let e=0;for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&e++;return e}var q1=t=>{let e=typeof t;switch(e){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(t)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(t)?"array":t===null?"null":t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?"promise":typeof Map<"u"&&t instanceof Map?"map":typeof Set<"u"&&t instanceof Set?"set":typeof Date<"u"&&t instanceof Date?"date":typeof File<"u"&&t instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${e}`)}},Va=new Set(["string","number","symbol"]),Wm=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Kt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function he(t,e,r){let i=new t._zod.constr(e??t._zod.def);return(!e||r?.parent)&&(i._zod.parent=t),i}function D(t){let e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function V1(t){let e;return new Proxy({},{get(r,i,n){return e??(e=t()),Reflect.get(e,i,n)},set(r,i,n,o){return e??(e=t()),Reflect.set(e,i,n,o)},has(r,i){return e??(e=t()),Reflect.has(e,i)},deleteProperty(r,i){return e??(e=t()),Reflect.deleteProperty(e,i)},ownKeys(r){return e??(e=t()),Reflect.ownKeys(e)},getOwnPropertyDescriptor(r,i){return e??(e=t()),Reflect.getOwnPropertyDescriptor(e,i)},defineProperty(r,i,n){return e??(e=t()),Reflect.defineProperty(e,i,n)}})}function w(t){return typeof t=="bigint"?t.toString()+"n":typeof t=="string"?`"${t}"`:`${t}`}function eh(t){return Object.keys(t).filter(e=>t[e]._zod.optin!==void 0&&t[e]._zod.optout==="optional")}var Ha={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]},Ga={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function k0(t,e){let r=t._zod.def,i=r.checks;if(i&&i.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let o={};return Fn(o,t,Ec(t,e)),he(t,Gt(r,{shape:o,checks:[]}))}function Ec(t,e){let r=Fr(t),i=[];for(let n of Reflect.ownKeys(e)){if(!Object.getOwnPropertyDescriptor(r,n)?.enumerable)throw new Error(`Unrecognized key: "${String(n)}"`);e[n]&&i.push(n)}return i}function C0(t,e){let r=t._zod.def,i=r.checks;if(i&&i.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let o=new Set(Ec(t,e)),a={};return Fn(a,t,Reflect.ownKeys(Fr(t)).filter(s=>!o.has(s))),he(t,Gt(r,{shape:a,checks:[]}))}function D0(t,e){if(!Jt(e))throw new Error("Invalid input to extend: expected a plain object");let r=t._zod.def.checks;if(r&&r.length>0){let n=Fr(t);for(let o of Reflect.ownKeys(e))if(Object.getOwnPropertyDescriptor(n,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return he(t,Gt(t._zod.def,{shape:T0(t,e)}))}function T0(t,e){let r={};return Fn(r,t,Reflect.ownKeys(Fr(t))),U1(r,e),r}function N0(t,e){if(!Jt(e))throw new Error("Invalid input to safeExtend: expected a plain object");return he(t,Gt(t._zod.def,{shape:T0(t,e)}))}function z0(t,e){if(!e?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(t._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};Fn(r,t,Reflect.ownKeys(Fr(t))),Fn(r,e,Reflect.ownKeys(Fr(e)));let i=Gt(t._zod.def,{shape:r,get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]});return he(t,i)}function P0(t,e,r,i="partial"){let o=e._zod.def.checks;if(o&&o.length>0)throw new Error(`.${i}() cannot be used on object schemas containing refinements`);let s=r?new Set(Ec(e,r)):void 0,u={};return Fn(u,e,Reflect.ownKeys(Fr(e)),t&&((c,l)=>s&&!s.has(l)?c:new t({type:"optional",innerType:c}))),he(e,Gt(e._zod.def,{shape:u,checks:[]}))}function O0(t,e,r){let i=r?new Set(Ec(e,r)):void 0,n={};return Fn(n,e,Reflect.ownKeys(Fr(e)),(o,a)=>i&&!i.has(a)?o:new t({type:"nonoptional",innerType:o})),he(e,Gt(e._zod.def,{shape:n}))}function ht(t,e=0){if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}function th(t,e=0){if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue===!1)return!0;return!1}function It(t,e){return e.map(r=>{var i;return(i=r).path??(i.path=[]),r.path.unshift(t),r})}function Bi(t){return typeof t=="string"?t:t?.message}function Qi(t){let e=[];for(let r of t??[]){let i=r._zod.def;if(!/_(length|size)$|_equals$/.test(i.check))break;let n=i.maximum??i.length??i.size;n>=0&&e.push([n,r])}return e}function Ja(t,e,r){var i;for(let n=e;n<t.length;n++)(i=t[n]).schema??(i.schema=r)}function wt(t,e,r){var i;let n=t.inst?._zod?.traits;n?.has("$ZodType")&&(n.has("$ZodCheck")?(i=t).schema??(i.schema=t.inst):t.schema=t.inst);let o=t.schema!==t.inst?t.schema?._zod.def?.error:void 0,a=t.message?t.message:Bi(t.inst?._zod.def?.error?.(t))??Bi(o?.(t))??Bi(e?.error?.(t))??Bi(r.customError?.(t))??Bi(r.localeError?.(t))??"Invalid input",s={};for(let u of Object.keys(t))u==="inst"||u==="schema"||u==="continue"||u==="input"||u==="__proto__"||(s[u]=t[u]);return s.path??(s.path=[]),s.message=a,e?.reportInput&&(s.input=t.input),s}function Ka(t){return t instanceof Set?"set":t instanceof Map?"map":t instanceof File?"file":"unknown"}var H1=/[\uD800-\uDBFF]/;function Qn(t){let e=t.length;if(!H1.test(t))return e;let r=e;for(let i=0;i<e-1;i++)(t.charCodeAt(i)&64512)===55296&&(t.charCodeAt(i+1)&64512)===56320&&(r--,i++);return r}function Xa(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function E(t){let e=typeof t;switch(e){case"number":return Number.isNaN(t)?"nan":"number";case"object":{if(t===null)return"null";if(Array.isArray(t))return"array";let r=t;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return e}function qi(...t){let[e,r,i]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:i}:{...e}}function G1(t){return Object.entries(t).filter(([e,r])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}function R0(t){let e=atob(t),r=new Uint8Array(e.length);for(let i=0;i<e.length;i++)r[i]=e.charCodeAt(i);return r}function j0(t){let e="";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return btoa(e)}function J1(t){let e=t.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-e.length%4)%4);return R0(e+r)}function K1(t){return j0(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function X1(t){let e=t.replace(/^0x/,"");if(e.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(e.length/2);for(let i=0;i<e.length;i+=2)r[i/2]=Number.parseInt(e.slice(i,i+2),16);return r}function Y1(t){return Array.from(t).map(e=>e.toString(16).padStart(2,"0")).join("")}var Jm=class{constructor(...e){}};function rh(t,e){for(let r in e){let i=Object.getOwnPropertyDescriptor(e,r);i.get?Object.defineProperty(t,r,{...i,enumerable:!1}):eN(t,r,i.value)}}function $r(t,e,r,i=!0){return Object.defineProperty(t,e,{configurable:!0,writable:!0,enumerable:i,value:r}),r}function Ya(t,e,r){return $r(t,e,r,!1)}function W1(t,e){for(let r in t){let i=t[r];Object.defineProperty(e,r,{configurable:!0,enumerable:!0,get(){return $r(this,r,i(this))},set(n){$r(this,r,n)}})}return e}function eN(t,e,r){Object.defineProperty(t,e,{configurable:!0,get(){return this==null?r:$r(this,e,r.bind(this))},set(i){$r(this,e,i)}})}function tN(t,e){let r=Object.getPrototypeOf(t);return e in r?void 0:r}var Hm,cn=!1,rN={configurable:!0,get(){cn=!0}};function ee(t,e,r){let i=Object.getPrototypeOf(t._zod);if(e in i&&Hm!==t._zod){Hm=void 0;return}Hm=t._zod,Object.defineProperty(i,e,{configurable:!0,get(){Object.defineProperty(this,e,rN);let n=cn;cn=!1;try{let o=r(this);return cn?delete this[e]:Object.defineProperty(this,e,{configurable:!0,writable:!0,value:o}),cn=cn||n,o}catch(o){throw delete this[e],cn=cn||n,o}},set(n){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:n})}})}function nh(t,e,r,i){let n=tN(t,e);n&&Object.defineProperty(n,e,{configurable:!0,get(){let o={configurable:!0,writable:!0,enumerable:i,value:void 0};return Object.defineProperty(this,e,o),o.value=r(this),Object.defineProperty(this,e,o),o.value},set(o){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:i,value:o})}})}var xc="~constantCatch";function ih(t){let e=()=>t;return e[xc]=!0,e}var B0,ah=Object.freeze({status:"aborted"}),oh={value:void 0,enumerable:!1},U0="captureStackTrace"in Error?Error:null;function nN(t){let e=U0;if(e){let r=e.stackTraceLimit;if(typeof r=="number"){try{e.stackTraceLimit=0}catch{return U0=null,new t}try{return new t}finally{e.stackTraceLimit=r}}}return new t}function _(t,e,r,i){let n={};function o(p){this.def=p,this.constr=d,this.traits=new Set}o.prototype=n;let a=r,s=a&&new WeakSet;function u(p,m){if(p._zod){if(p._zod.traits.has(t))return}else{oh.value=new o(m);try{Object.defineProperty(p,"_zod",oh)}finally{oh.value=void 0}}if(p._zod.traits.add(t),e(p,m),s){let f=Object.getPrototypeOf(p),g=p._zod.constr.prototype,y=f;for(;y&&y!==g;)y=Object.getPrototypeOf(y);let v=y??f;s.has(v)||(s.add(v),rh(v,a))}let h=d.prototype;for(let f in h)Object.prototype.hasOwnProperty.call(h,f)&&(f in p||(p[f]=h[f].bind(p)))}let c=i?.Parent??Object;class l extends c{}Object.defineProperty(l,"name",{value:t});function d(p){let m=i?.Parent?nN(l):this;u(m,p);let h=m._zod.deferred;if(h){for(let g of h)g();m._zod.deferred=void 0}let f=globalThis.__zod_globalConfig?.postProcessor;return f&&f(m),m}return Object.defineProperty(d,"init",{value:u}),Object.defineProperty(d,Symbol.hasInstance,{value:p=>i?.Parent&&p instanceof i.Parent?!0:p?._zod?.traits?.has(t)}),Object.defineProperty(d,"name",{value:t}),d}var sh=Symbol("zod_brand"),Et=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},ln=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(B0=globalThis).__zod_globalConfig??(B0.__zod_globalConfig={});var Ve=globalThis.__zod_globalConfig;function Re(t){return t&&Object.assign(Ve,t),Ve}function iN(){let t=this._zod;return t.message??(t.message=JSON.stringify(t.def,Mi,2)),t.message}function oN(t){this._zod.message=t}var aN={get:iN,set:oN,enumerable:!0,configurable:!0},ch={value:void 0,enumerable:!1},M0=new WeakSet([Object.prototype,Error.prototype]),L0=(t,e)=>{t.name="$ZodError",ch.value=e,Object.defineProperty(t,"issues",ch),ch.value=void 0,Object.defineProperty(t,"message",aN);let r=Object.getPrototypeOf(t);M0.has(r)||(M0.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let i=()=>this.message;return Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0})}}))},lh=_("$ZodError",L0),xt=_("$ZodError",L0,void 0,{Parent:Error});function sN(t,e,r){return Object.prototype.hasOwnProperty.call(t,e)||(e==="__proto__"?Object.defineProperty(t,e,{value:r(),writable:!0,enumerable:!0,configurable:!0}):t[e]=r()),t[e]}function Wa(t,e=r=>r.message){let r={},i=[];for(let n of t.issues)n.path.length>0?sN(r,n.path[0],()=>[]).push(e(n)):i.push(e(n));return{formErrors:i,fieldErrors:r}}function es(t,e=r=>r.message){let r={_errors:[]},i=(n,o=[])=>{for(let a of n.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(s=>i({issues:s},[...o,...a.path]));else if(a.code==="invalid_key")i({issues:a.issues},[...o,...a.path]);else if(a.code==="invalid_element")i({issues:a.issues},[...o,...a.path]);else{let s=[...o,...a.path];if(s.length===0)r._errors.push(e(a));else{let u=r,c=0;for(;c<s.length;){let l=s[c],d=c===s.length-1;if(l==="_errors"){d&&u._errors.push(e(a)),c++;continue}Object.prototype.hasOwnProperty.call(u,l)||Object.defineProperty(u,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let p=u[l];d&&p._errors.push(e(a)),u=p,c++}}}};return i(t),r}function dh(t,e=r=>r.message){let r={errors:[]},i=(n,o=[])=>{var a;for(let s of n.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(u=>i({issues:u},[...o,...s.path]));else if(s.code==="invalid_key")i({issues:s.issues},[...o,...s.path]);else if(s.code==="invalid_element")i({issues:s.issues},[...o,...s.path]);else{let u=[...o,...s.path];if(u.length===0){r.errors.push(e(s));continue}let c=r,l=0;for(;l<u.length;){let d=u[l],p=l===u.length-1;typeof d=="string"?(c.properties??(c.properties={}),Object.prototype.hasOwnProperty.call(c.properties,d)||Object.defineProperty(c.properties,d,{value:{errors:[]},enumerable:!0,writable:!0,configurable:!0}),c=c.properties[d]):(c.items??(c.items=[]),(a=c.items)[d]??(a[d]={errors:[]}),c=c.items[d]),p&&c.errors.push(e(s)),l++}}};return i(t),r}function F0(t){let e=[],r=t.map(i=>typeof i=="object"?i.key:i);for(let i of r)typeof i=="number"?e.push(`[${i}]`):typeof i=="symbol"?e.push(`[${JSON.stringify(String(i))}]`):/[^\w$]/.test(i)?e.push(`[${JSON.stringify(i)}]`):(e.length&&e.push("."),e.push(i));return e.join("")}function fh(t){let e=[],r=[...t.issues].sort((i,n)=>(i.path??[]).length-(n.path??[]).length);for(let i of r)e.push(`\u2716 ${i.message}`),i.path?.length&&e.push(` \u2192 at ${F0(i.path)}`);return e.join(`
|
|
17
17
|
`)}function Sc(t,e){return{callee:e?.callee??t,Err:e?.Err}}var Vi=t=>{let e=(r,i,n,o)=>{let a=n?{...n,async:!1}:{async:!1},s=r._zod.run({value:i,issues:[]},a);if(s instanceof Promise)throw new Et;if(s.issues.length){let u=new(o?.Err??t)(s.issues.map(c=>wt(c,a,Re())));throw wc(u,o?.callee??e),u}return s.value};return e},qn=Vi(xt),Hi=t=>{let e=async(r,i,n,o)=>{let a=n?{...n,async:!0}:{async:!0},s=r._zod.run({value:i,issues:[]},a);if(s instanceof Promise&&(s=await s),s.issues.length){let u=new(o?.Err??t)(s.issues.map(c=>wt(c,a,Re())));throw wc(u,o?.callee??e),u}return s.value};return e},Vn=Hi(xt),Gi=t=>(e,r,i)=>{let n=i?{...i,async:!1}:{async:!1},o=e._zod.run({value:r,issues:[]},n);if(o instanceof Promise)throw new Et;return o.issues.length?Z0(t,o.issues,n):{success:!0,data:o.value}},Ji=Gi(xt);function Z0(t,e,r){let i;return{success:!1,get error(){return i||(i=new t(e.map(n=>wt(n,r,Re()))),e=void 0,r=void 0),i},set error(n){i=n,e=void 0,r=void 0}}}var Ki=t=>async(e,r,i)=>{let n=i?{...i,async:!0}:{async:!0},o=e._zod.run({value:r,issues:[]},n);return o instanceof Promise&&(o=await o),o.issues.length?Z0(t,o.issues,n):{success:!0,data:o.value}},Xi=Ki(xt),cN=Symbol.for("zod.compile.invalid"),lN=Symbol.for("zod.compile.fallback"),Yi=((t,e,r)=>{let i=t._zod.bag.validator;if(i!==void 0){if(i(e)!==cN)return!0;if(i.definite===!0&&r===void 0)return!1}return dN(t,e,r)});function dN(t,e,r){let i=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},n=t._zod.bag.fallbackRun,o;if(n?(i[lN]=!0,o=n({value:e,issues:[]},i)):o=t._zod.run({value:e,issues:[]},i),o instanceof Promise)throw new Et;return o.issues.length===0}var Wi=async(t,e,r)=>{let i=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},n=t._zod.run({value:e,issues:[]},i);return n instanceof Promise&&(n=await n),n.issues.length===0},kc=t=>{let e=Vi(t),r=(i,n,o,a)=>{let s=o?{...o,direction:"backward"}:{direction:"backward"};return e(i,n,s,Sc(r,a))};return r},Q0=kc(xt),Cc=t=>{let e=Vi(t),r=(i,n,o,a)=>e(i,n,o,Sc(r,a));return r},q0=Cc(xt),Dc=t=>{let e=Hi(t),r=async(i,n,o,a)=>{let s=o?{...o,direction:"backward"}:{direction:"backward"};return await e(i,n,s,Sc(r,a))};return r},V0=Dc(xt),Tc=t=>{let e=Hi(t),r=async(i,n,o,a)=>await e(i,n,o,Sc(r,a));return r},H0=Tc(xt),Nc=t=>(e,r,i)=>{let n=i?{...i,direction:"backward"}:{direction:"backward"};return Gi(t)(e,r,n)},G0=Nc(xt),zc=t=>(e,r,i)=>Gi(t)(e,r,i),J0=zc(xt),Pc=t=>async(e,r,i)=>{let n=i?{...i,direction:"backward"}:{direction:"backward"};return Ki(t)(e,r,n)},K0=Pc(xt),Oc=t=>async(e,r,i)=>Ki(t)(e,r,i),X0=Oc(xt);var Mt={};jr(Mt,{anyString:()=>Uh,base64:()=>Dh,base64url:()=>Th,bigint:()=>Lh,boolean:()=>Fh,browserEmail:()=>yN,cidrv4:()=>kh,cidrv6:()=>Ch,creditCard:()=>Rc,cuid:()=>mh,cuid2:()=>hh,currencyCode:()=>Oh,date:()=>Rh,datetime:()=>Bh,domain:()=>zh,duration:()=>bh,e164:()=>Ph,email:()=>Ih,emoji:()=>wh,extendedDuration:()=>fN,guid:()=>$h,hex:()=>Hh,hostname:()=>Nh,html5Email:()=>gN,httpProtocol:()=>ts,iban:()=>jc,idnEmail:()=>AN,integer:()=>rs,ipv4:()=>Eh,ipv6:()=>xh,ksuid:()=>Ah,lowercase:()=>qh,mac:()=>Sh,md5_base64:()=>IN,md5_base64url:()=>wN,md5_hex:()=>$N,nanoid:()=>yh,nanoidOfLength:()=>_h,null:()=>Zh,number:()=>Qr,rfc5322Email:()=>vN,sha1_base64:()=>xN,sha1_base64url:()=>SN,sha1_hex:()=>EN,sha256_base64:()=>CN,sha256_base64url:()=>DN,sha256_hex:()=>kN,sha384_base64:()=>NN,sha384_base64url:()=>zN,sha384_hex:()=>TN,sha512_base64:()=>ON,sha512_base64url:()=>RN,sha512_hex:()=>PN,string:()=>Mh,time:()=>jh,ulid:()=>gh,undefined:()=>Qh,unicodeEmail:()=>Y0,uppercase:()=>Vh,uuid:()=>Hn,uuid4:()=>pN,uuid6:()=>mN,uuid7:()=>hN,xid:()=>vh});var mh=/^[cC][0-9a-z]{6,}$/,hh=/^[0-9a-z]+$/,gh=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,vh=/^[0-9a-vA-V]{20}$/,Ah=/^[A-Za-z0-9]{27}$/,yh=/^[a-zA-Z0-9_-]{21}$/;function _h(t){return new RegExp(`^[a-zA-Z0-9_-]{${t}}$`)}var bh=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,fN=/^[-+]?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)?)??$/,$h=/^([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})$/,Hn=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[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)$/,pN=Hn(4),mN=Hn(6),hN=Hn(7),Ih=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,gN=/^[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])?)*$/,vN=/^(([^<>()\[\]\\.,;:\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,}))$/,Y0=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,AN=Y0,yN=/^[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])?)*$/,_N="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function wh(){return new RegExp(_N,"u")}var Eh=/^(?:(?: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])$/,xh=/^(([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}|:))$/,Sh=t=>{let e=Kt(t??":");return new RegExp(`^(?:[0-9A-F]{2}${e}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${e}){5}[0-9a-f]{2}$`)},kh=/^((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])$/,Ch=/^(([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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Dh=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Th=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Nh=/^(?=.{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])?)*\.?$/,zh=/^(?=.{1,253}$)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/,ts=/^https?$/,Ph=/^\+[1-9]\d{6,14}$/,Rc=/^\d(?:[ -]?\d){11,18}$/,Oh=/^(?:AED|AFN|ALL|AMD|AOA|ARS|AUD|AWG|AZN|BAM|BBD|BDT|BHD|BIF|BMD|BND|BOB|BOV|BRL|BSD|BTN|BWP|BYN|BZD|CAD|CDF|CHE|CHF|CHW|CLF|CLP|CNY|COP|COU|CRC|CUP|CVE|CZK|DJF|DKK|DOP|DZD|EGP|ERN|ETB|EUR|FJD|FKP|GBP|GEL|GHS|GIP|GMD|GNF|GTQ|GYD|HKD|HNL|HTG|HUF|IDR|ILS|INR|IQD|IRR|ISK|JMD|JOD|JPY|KES|KGS|KHR|KMF|KPW|KRW|KWD|KYD|KZT|LAK|LBP|LKR|LRD|LSL|LYD|MAD|MDL|MGA|MKD|MMK|MNT|MOP|MRU|MUR|MVR|MWK|MXN|MXV|MYR|MZN|NAD|NGN|NIO|NOK|NPR|NZD|OMR|PAB|PEN|PGK|PHP|PKR|PLN|PYG|QAR|RON|RSD|RUB|RWF|SAR|SBD|SCR|SDG|SEK|SGD|SHP|SLE|SOS|SRD|SSP|STN|SVC|SYP|SZL|THB|TJS|TMT|TND|TOP|TRY|TTD|TWD|TZS|UAH|UGX|USD|USN|UYI|UYU|UYW|UZS|VED|VES|VND|VUV|WST|XAD|XAF|XAG|XAU|XBA|XBB|XBC|XBD|XCD|XCG|XDR|XOF|XPD|XPF|XPT|XSU|XTS|XUA|XXX|YER|ZAR|ZMW|ZWG)$/,jc=/^[A-Z]{2}(?!00|01|99)\d{2}[A-Z0-9]{11,30}$/,W0="(?:(?:\\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])))";function bN(t){return new RegExp(`^${t}$`)}var Rh=bN(W0);function ph(t){let e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:t.seconds?`${e}:[0-5]\\d(?:\\.\\d+)?`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function jh(t){return new RegExp(`^${ph(t)}$`)}function Bh(t){let e=["Z"];t.offset&&e.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${ph({precision:t.precision,seconds:!0})}(?:${e.join("|")})`,i=t.local?`${r}|${ph({precision:t.precision})}`:r;return new RegExp(`^${W0}T(?:${i})$`)}var Uh=/^[\s\S]{0,}$/,Mh=t=>{let e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},Lh=/^-?\d+n?$/,rs=/^-?\d+$/,Qr=/^-?\d+(?:\.\d+)?$/,Fh=/^(?:true|false)$/i,Zh=/^null$/i;var Qh=/^undefined$/i;var qh=/^[^A-Z]*$/,Vh=/^[^a-z]*$/,Hh=/^[0-9a-fA-F]*$/;function ns(t,e){return new RegExp(`^[A-Za-z0-9+/]{${t}}${e}$`)}function is(t){return new RegExp(`^[A-Za-z0-9_-]{${t}}$`)}var $N=/^[0-9a-fA-F]{32}$/,IN=ns(22,"=="),wN=is(22),EN=/^[0-9a-fA-F]{40}$/,xN=ns(27,"="),SN=is(27),kN=/^[0-9a-fA-F]{64}$/,CN=ns(43,"="),DN=is(43),TN=/^[0-9a-fA-F]{96}$/,NN=ns(64,""),zN=is(64),PN=/^[0-9a-fA-F]{128}$/,ON=ns(86,"=="),RN=is(86);var $e=_("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),Gh=t=>{let e=t.value;return!Ic(e)&&e.size!==void 0},Jh=t=>{let e=t.value;return!Ic(e)&&e.length!==void 0},Bc={number:"number",bigint:"bigint",object:"date"},Mc=_("$ZodCheckLessThan",(t,e)=>{$e.init(t,e);let r=Bc[typeof e.value];t._zod.check=i=>{(e.inclusive?i.value<=e.value:i.value<e.value)||i.issues.push({origin:Bc[typeof i.value]??r,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:i.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),Lc=_("$ZodCheckGreaterThan",(t,e)=>{$e.init(t,e);let r=Bc[typeof e.value];t._zod.check=i=>{(e.inclusive?i.value>=e.value:i.value>e.value)||i.issues.push({origin:Bc[typeof i.value]??r,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:i.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),Kh=_("$ZodCheckMultipleOf",(t,e)=>{$e.init(t,e),t._zod.check=r=>{if(typeof r.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?e.value!==BigInt(0)&&r.value%e.value===BigInt(0):qa(r.value,e.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:e.value,input:r.value,inst:t,continue:!e.abort})}}),Xh=_("$ZodCheckNumberFormat",(t,e)=>{$e.init(t,e),e.format=e.format||"float64";let r=e.format?.includes("int"),i=r?"int":"number",[n,o]=Ha[e.format];t._zod.check=a=>{let s=a.value;if(r){if(!Number.isInteger(s)){a.issues.push({expected:i,format:e.format,code:"invalid_type",continue:!1,input:s,inst:t});return}if(!Number.isSafeInteger(s)){s>0?a.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:i,inclusive:!0,continue:!e.abort}):a.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:i,inclusive:!0,continue:!e.abort});return}}s<n&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:n,inclusive:!0,inst:t,continue:!e.abort}),s>o&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:o,inclusive:!0,inst:t,continue:!e.abort})}}),Yh=_("$ZodCheckBigIntFormat",(t,e)=>{$e.init(t,e);let[r,i]=Ga[e.format];t._zod.check=n=>{let o=n.value;o<r&&n.issues.push({origin:"bigint",input:o,code:"too_small",minimum:r,inclusive:!0,inst:t,continue:!e.abort}),o>i&&n.issues.push({origin:"bigint",input:o,code:"too_big",maximum:i,inclusive:!0,inst:t,continue:!e.abort})}}),Wh=_("$ZodCheckMaxSize",(t,e)=>{var r;$e.init(t,e),(r=t._zod.def).when??(r.when=Gh),t._zod.check=i=>{let n=i.value;n.size<=e.maximum||i.issues.push({origin:Ka(n),code:"too_big",maximum:e.maximum,inclusive:!0,input:n,inst:t,continue:!e.abort})}}),eg=_("$ZodCheckMinSize",(t,e)=>{var r;$e.init(t,e),(r=t._zod.def).when??(r.when=Gh),t._zod.check=i=>{let n=i.value;n.size>=e.minimum||i.issues.push({origin:Ka(n),code:"too_small",minimum:e.minimum,inclusive:!0,input:n,inst:t,continue:!e.abort})}}),tg=_("$ZodCheckSizeEquals",(t,e)=>{var r;$e.init(t,e),(r=t._zod.def).when??(r.when=Gh),t._zod.check=i=>{let n=i.value,o=n.size;if(o===e.size)return;let a=o>e.size;i.issues.push({origin:Ka(n),...a?{code:"too_big",maximum:e.size}:{code:"too_small",minimum:e.size},inclusive:!0,exact:!0,input:i.value,inst:t,continue:!e.abort})}}),rg=_("$ZodCheckMaxLength",(t,e)=>{var r;$e.init(t,e),(r=t._zod.def).when??(r.when=Jh),t._zod.check=i=>{let n=i.value,o=n.length;if((typeof n=="string"&&o>e.maximum?Qn(n):o)<=e.maximum)return;let s=Xa(n);i.issues.push({origin:s,code:"too_big",maximum:e.maximum,inclusive:!0,input:n,inst:t,continue:!e.abort})}}),ng=_("$ZodCheckMinLength",(t,e)=>{var r;$e.init(t,e),(r=t._zod.def).when??(r.when=Jh),t._zod.check=i=>{let n=i.value,o=n.length;if((typeof n=="string"&&o>=e.minimum&&o<e.minimum*2?Qn(n):o)>=e.minimum)return;let s=Xa(n);i.issues.push({origin:s,code:"too_small",minimum:e.minimum,inclusive:!0,input:n,inst:t,continue:!e.abort})}}),ig=_("$ZodCheckLengthEquals",(t,e)=>{var r;$e.init(t,e),(r=t._zod.def).when??(r.when=Jh),t._zod.check=i=>{let n=i.value,o=n.length,a=typeof n=="string"&&o>=e.length&&o<=e.length*2?Qn(n):o;if(a===e.length)return;let s=Xa(n),u=a>e.length;i.issues.push({origin:s,...u?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:i.value,inst:t,continue:!e.abort})}}),eo=_("$ZodCheckStringFormat",(t,e)=>{var r,i;$e.init(t,e),e.pattern?(r=t._zod).check??(r.check=n=>{e.pattern.lastIndex=0,!e.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:e.format,input:n.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(i=t._zod).check??(i.check=()=>{})}),og=_("$ZodCheckRegex",(t,e)=>{eo.init(t,e),t._zod.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),ag=_("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=qh),eo.init(t,e)}),sg=_("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=Vh),eo.init(t,e)}),ug=_("$ZodCheckIncludes",(t,e)=>{$e.init(t,e);let r=Kt(e.includes),i=new RegExp(typeof e.position=="number"?`^.{${e.position},}${r}`:r);e.pattern=i,t._zod.check=n=>{n.value.includes(e.includes,e.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:n.value,inst:t,continue:!e.abort})}}),cg=_("$ZodCheckStartsWith",(t,e)=>{$e.init(t,e);let r=new RegExp(`^${Kt(e.prefix)}.*`);e.pattern??(e.pattern=r),t._zod.check=i=>{i.value.startsWith(e.prefix)||i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:i.value,inst:t,continue:!e.abort})}}),lg=_("$ZodCheckEndsWith",(t,e)=>{$e.init(t,e);let r=new RegExp(`.*${Kt(e.suffix)}$`);e.pattern??(e.pattern=r),t._zod.check=i=>{i.value.endsWith(e.suffix)||i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:i.value,inst:t,continue:!e.abort})}});function Uc(t,e,r){t.issues.length&&e.issues.push(...It(r,t.issues))}var dg=_("$ZodCheckProperty",(t,e)=>{$e.init(t,e),t._zod.check=r=>{let i=e.schema._zod.run({value:r.value[e.property],issues:[]},{});if(i instanceof Promise)return i.then(n=>Uc(n,r,e.property));Uc(i,r,e.property)}}),fg=_("$ZodCheckProperties",(t,e)=>{$e.init(t,e),Ya(t,Symbol.iterator,function*(){yield t});let r;t._zod.check=i=>{if(i.value==null){i.issues.push({expected:"object",code:"invalid_type",input:i.value,inst:t});return}r??(r=Reflect.ownKeys(e.shape).map(a=>[a,e.shape[a]]));let n=i.value,o;for(let[a,s]of r){let u=s._zod.run({value:n[a],issues:[]},{});u instanceof Promise?(o??(o=[]),o.push(u.then(c=>Uc(c,i,a)))):Uc(u,i,a)}if(o)return Promise.all(o).then(()=>{})}}),pg=_("$ZodCheckMimeType",(t,e)=>{$e.init(t,e);let r=new Set(e.mime);t._zod.check=i=>{r.has(i.value.type)||i.issues.push({code:"invalid_value",values:e.mime,input:i.value.type,inst:t,continue:!e.abort})}}),mg=_("$ZodCheckOverwrite",(t,e)=>{$e.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});var Gn=class{constructor(e=[],r={}){this.content=[],this.indent=0,this.args=e,this.closed=r}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let i=e.split(`
|
|
18
18
|
`).filter(a=>a),n=Math.min(...i.map(a=>a.length-a.trimStart().length)),o=i.map(a=>a.slice(n)).map(a=>" ".repeat(this.indent*2)+a);for(let a of o)this.content.push(a)}compile(){let e=Function,r=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
19
19
|
${r.join(`
|
|
@@ -75,13 +75,13 @@ ${u}
|
|
|
75
75
|
}`,p;try{p=new l(...a,d)(...s)}catch(m){throw new ae(`this schema (generated code failed to evaluate: ${m.message})`)}return e?.debug&&(p.code=c),p.definite=i.definite,p}function V(t,e){for(let[i,n]of t.constants)if(n===e)return i;let r=`c${t.constantCounter++}`;return t.constants.set(r,e),r}function Kn(t,e){return t.definite=!1,V(t,e)}function Q(t){return`v${t.varCounter++}`}function sP(t,e){let r=t._zod.run({value:e,issues:[]},{});if(r&&typeof r.then=="function")return gt;let i=r;return i.issues.length===0?i.value:gt}function at(t,e,r,i,n=!0){let o=t.content.length,a=e.constants.size,s=e.constantCounter,u=e.varCounter;try{return ze(t,e,r,i,n)}catch(c){if(!(c instanceof ae)||!c.islandable)throw c;if(t.content.length=o,e.constants.size>a){let l=Array.from(e.constants.keys()).slice(a);for(let d of l)e.constants.delete(d)}return e.constantCounter=s,e.varCounter=u,uP(t,e,r,i)}}function uP(t,e,r,i){e.definite=!1;let n=V(e,r),o=V(e,sP),a=Q(e);return t.write(`const ${a} = ${o}(${n}, ${i});`),t.write(`if (${a} === INVALID) return INVALID;`),a}var cP=new Set(["max_size","min_size","size_equals","max_length","min_length","length_equals"]);function lP(t,e,r,i){let n=r._zod.def.checks;if(!n||n.length===0)return i;let o=i;for(let a of n){let s=a._zod.def;if(s.when&&!cP.has(s.check))throw new ae('check with a custom "when" condition');switch(s.check){case"greater_than":dP(t,e,s,o);break;case"less_than":fP(t,e,s,o);break;case"multiple_of":pP(t,e,s,o);break;case"number_format":FI(t,s,o);break;case"min_length":{let u=fn(s.minimum,"min_length"),c=Tg(t,e,o,`${o}.length >= ${u} && ${o}.length < ${s.minimum*2}`);t.write(`if (${c} < ${u}) return INVALID;`);break}case"max_length":{let u=fn(s.maximum,"max_length"),c=Tg(t,e,o,`${o}.length > ${u}`);t.write(`if (${c} > ${u}) return INVALID;`);break}case"length_equals":{let u=fn(s.length,"length_equals"),c=Tg(t,e,o,`${o}.length >= ${u} && ${o}.length <= ${s.length*2}`);t.write(`if (${c} !== ${u}) return INVALID;`);break}case"min_size":t.write(`if (${o}.size < ${fn(s.minimum,"min_size")}) return INVALID;`);break;case"max_size":t.write(`if (${o}.size > ${fn(s.maximum,"max_size")}) return INVALID;`);break;case"size_equals":t.write(`if (${o}.size !== ${fn(s.size,"size_equals")}) return INVALID;`);break;case"string_format":o=ZI(t,e,s,o);break;case"custom":o=yP(t,e,a,o);break;case"bigint_format":mP(t,s,o);break;case"mime_type":hP(t,e,s,o);break;case"property":vP(t,e,s,o);break;case"properties":gP(t,e,s,o);break;case"overwrite":{let u=Q(e);AP(t,e,a,o,u),o=u;break}default:throw new ae(`check type ${s.check}`)}}return o}function Tg(t,e,r,i){let n=V(e,Qn),o=Q(e);return t.write(`const ${o} = typeof ${r} === "string" && ${i} ? ${n}(${r}) : ${r}.length;`),o}function fn(t,e){if(typeof t!="number"||!Number.isFinite(t))throw new ae(`${e} bound of type ${typeof t}`);return`${t}`}function LI(t,e){if(typeof e=="bigint")return`${e}n`;if(typeof e=="number"){if(Number.isNaN(e))throw new ae("comparison check with NaN bound");return`${e}`}if(e instanceof Date){if(Number.isNaN(e.getTime()))throw new ae("comparison check with Invalid Date bound");return V(t,e)}throw new ae(`comparison check bound of type ${typeof e}`)}function dP(t,e,r,i){let n=r.inclusive?"<":"<=";t.write(`if (${i} ${n} ${LI(e,r.value)}) return INVALID;`)}function fP(t,e,r,i){let n=r.inclusive?">":">=";t.write(`if (${i} ${n} ${LI(e,r.value)}) return INVALID;`)}function pP(t,e,r,i){if(typeof r.value=="bigint"){if(r.value===BigInt(0))throw new ae("multiple_of check with a zero divisor");t.write(`if (${i} % ${r.value}n !== 0n) return INVALID;`)}else{let n=V(e,qa);t.write(`if (${n}(${i}, ${fn(r.value,"multiple_of")}) !== 0) return INVALID;`)}}function FI(t,e,r){let i=e.format;switch(i){case"safeint":t.write(`if (!Number.isSafeInteger(${r})) return INVALID;`);break;case"int32":t.write(`if (!Number.isInteger(${r}) || ${r} < -2147483648 || ${r} > 2147483647) return INVALID;`);break;case"uint32":t.write(`if (!Number.isInteger(${r}) || ${r} < 0 || ${r} > 4294967295) return INVALID;`);break;case"float32":t.write(`if (!Number.isFinite(${r}) || ${r} < -3.4028234663852886e38 || ${r} > 3.4028234663852886e38) return INVALID;`);break;case"float64":t.write(`if (!Number.isFinite(${r})) return INVALID;`);break;default:throw new ae(`number format ${i}`)}}function mP(t,e,r){let i=e.format;if(i)switch(i){case"int64":t.write(`if (${r} < -9223372036854775808n || ${r} > 9223372036854775807n) return INVALID;`);break;case"uint64":t.write(`if (${r} < 0n || ${r} > 18446744073709551615n) return INVALID;`);break;default:throw new ae(`bigint format ${i}`)}}function hP(t,e,r,i){let n=r.mime;if(n&&n.length>0){let o=V(e,new Set(n));t.write(`if (!${o}.has(${i}.type)) return INVALID;`)}}function gP(t,e,r,i){if(r.when)throw new ae('check with a custom "when" condition');t.write(`if (${i} == null) return INVALID;`);let n=r.shape;for(let o of Reflect.ownKeys(n)){let a=typeof o=="symbol"?V(e,o):mt(o),s=Q(e);t.write(`const ${s} = ${i}[${a}];`),at(t,e,n[o],s,!1)}}function vP(t,e,r,i){let n=`${i}[${JSON.stringify(r.property)}]`;ze(t,e,r.schema,n)}function AP(t,e,r,i,n){let o=r._zod.def.tx;if(!o)throw new ae("overwrite check without a transform function");if(Xn(o))throw new sr("z.compile: async overwrite transforms are not supported");let a=V(e,o);t.write(`const ${n} = ${a}(${i});`)}function Ng(){throw new Et}function Og(t){this.issues.push(t)}function yP(t,e,r,i){let n=r._zod.def;if(n.fn){if(Xn(n.fn))throw new sr("z.compile: async .refine() predicates are not supported");let o=Kn(e,n.fn),a=V(e,Ng),s=Q(e);return t.write(`const ${s} = ${o}(${i});`),t.write(`if (${s} instanceof Promise) ${a}();`),t.write(`if (!${s}) return INVALID;`),i}if(r._zod.check){if(Xn(r._zod.check))throw new sr("z.compile: async .superRefine() / check functions are not supported");let o=r._zod.check,s=Kn(e,c=>{let l={value:c,issues:[],addIssue:Og};return o(l)instanceof Promise&&Ng(),l.issues.length===0?l.value:gt}),u=Q(e);return t.write(`const ${u} = ${s}(${i});`),t.write(`if (${u} === INVALID) return INVALID;`),u}throw new ae("custom check without a predicate or check function")}var _P=new Set(["cidrv4","cuid","cuid2","date","datetime","duration","e164","email","emoji","ends_with","guid","includes","ipv4","ksuid","lowercase","mac","nanoid","regex","starts_with","time","ulid","uppercase","uuid","xid"]);function ZI(t,e,r,i,n=!0){let o=r.format;if(o==="base64"){let c=V(e,us);return t.write(`if (!${c}(${i})) return INVALID;`),i}if(o==="base64url"){let c=V(e,hl);return t.write(`if (!${c}(${i})) return INVALID;`),i}if(o==="jwt"){let c=V(e,$l),l=V(e,r.alg??null);return t.write(`if (!${c}(${i}, ${l})) return INVALID;`),i}if(o==="ipv6"){let c=V(e,ss);return t.write(`if (!${c}(${i})) return INVALID;`),i}if(o==="cidrv6"){let c=V(e,dl);return t.write(`if (!${c}(${i})) return INVALID;`),i}if(o==="credit_card"){let c=V(e,Al);return t.write(`if (!${c}(${i})) return INVALID;`),i}if(o==="iban"){let c=V(e,_l);return t.write(`if (!${c}(${i})) return INVALID;`),i}let a=r;if(o==="url"||o==="httpurl"||a.normalize||a.hostname!==void 0||a.protocol!==void 0){let c=V(e,Kc),l=V(e,r),d=Q(e),p=Q(e);if(t.write(`const ${d} = ${i}.trim();`),t.write(`const ${p} = ${c}(${d}, ${l});`),t.write(`if (typeof ${p} === "number") return INVALID;`),a.hostname!==void 0){let f=V(e,Xc);t.write(`if (!${f}(${p}, ${l}.hostname)) return INVALID;`)}if(a.protocol!==void 0){let f=V(e,Yc);t.write(`if (!${f}(${p}, ${l}.protocol)) return INVALID;`)}if(!n)return null;let m=Q(e),h=a.normalize?`${p}.href`:`${V(e,as)}(${d})`;return t.write(`const ${m} = ${h};`),m}let s=r.fn;if(s){if(Xn(s))throw new ae(`async string format ${o}`);let c=V(e,s);return t.write(`if (!${c}(${i})) return INVALID;`),i}if(_P.has(o)&&r.pattern){let c=V(e,r.pattern);return t.write(`${c}.lastIndex = 0;`),t.write(`if (!${c}.test(${i})) return INVALID;`),i}let u=r.format;switch(u){case"regex":throw new ae("regex format without a pattern");case"lowercase":t.write(`if (${i} !== ${i}.toLowerCase()) return INVALID;`);break;case"uppercase":t.write(`if (${i} !== ${i}.toUpperCase()) return INVALID;`);break;case"includes":t.write(`if (!${i}.includes(${mt(r.includes)})) return INVALID;`);break;case"starts_with":{let c=r.prefix;t.write(`if (${i}.slice(0, ${c.length}) !== ${mt(c)}) return INVALID;`);break}case"ends_with":{let c=r.suffix;t.write(`if (${i}.slice(-${c.length}) !== ${mt(c)}) return INVALID;`);break}default:throw new ae(`string format ${u}`)}return i}function ze(t,e,r,i,n=!0){let o=r._zod.def,a=o.type;if(o.coerce)throw new ae(`coercion (z.coerce.${a}())`);let s=n||!!o.checks?.length,u;switch(a){case"string":u=bP(t,e,r,i,s);break;case"number":u=$P(t,r,i);break;case"boolean":u=IP(t,i);break;case"bigint":u=wP(t,r,i);break;case"symbol":u=EP(t,i);break;case"undefined":u=xP(t,i);break;case"null":u=SP(t,i);break;case"any":case"unknown":u=i;break;case"never":t.write("return INVALID;"),u=i;break;case"void":u=kP(t,i);break;case"nan":u=CP(t,i);break;case"date":u=DP(t,i);break;case"object":u=TP(t,e,r,i,s);break;case"optional":u=NP(t,e,r,i,s);break;case"nullable":u=OP(t,e,r,i,s);break;case"array":u=RP(t,e,r,i,s);break;case"literal":u=jP(t,e,r,i);break;case"enum":u=BP(t,e,r,i);break;case"readonly":{let c=BI(t,e,r,i),l=Q(e);t.write(`const ${l} = Object.freeze(${c});`),u=l;break}case"success":BI(t,e,r,i),u="true";break;case"default":case"prefault":u=UP(t,e,r,i);break;case"nonoptional":u=MP(t,e,r,i);break;case"tuple":u=LP(t,e,r,i);break;case"union":u=FP(t,e,r,i);break;case"intersection":u=qP(t,e,r,i);break;case"record":u=VP(t,e,r,i);break;case"map":u=GP(t,e,r,i);break;case"set":u=JP(t,e,r,i);break;case"file":u=KP(t,i);break;case"template_literal":u=XP(t,e,r,i);break;case"lazy":u=YP(t,e,r,i);break;case"pipe":u=WP(t,e,r,i);break;case"custom":u=eO(t,e,r,i);break;case"transform":u=nO(t,e,r,i);break;case"catch":u=rO(t,e,r,i);break;default:throw new ae(`schema type ${a}`)}return u===null?null:lP(t,e,r,u)}function bP(t,e,r,i,n=!0){t.write(`if (typeof ${i} !== "string") return INVALID;`);let o=r._zod.def;return o.format===void 0?i:ZI(t,e,o,i,n)}function $P(t,e,r){t.write(`if (typeof ${r} !== "number" || !Number.isFinite(${r})) return INVALID;`);let i=e._zod.def;return i.check==="number_format"&&i.format&&FI(t,{format:i.format},r),r}function IP(t,e){return t.write(`if (typeof ${e} !== "boolean") return INVALID;`),e}function wP(t,e,r){t.write(`if (typeof ${r} !== "bigint") return INVALID;`);let i=e._zod.def;if(i.format)switch(i.format){case"int64":t.write(`if (${r} < -9223372036854775808n || ${r} > 9223372036854775807n) return INVALID;`);break;case"uint64":t.write(`if (${r} < 0n || ${r} > 18446744073709551615n) return INVALID;`);break}return r}function EP(t,e){return t.write(`if (typeof ${e} !== "symbol") return INVALID;`),e}function xP(t,e){return t.write(`if (${e} !== undefined) return INVALID;`),e}function SP(t,e){return t.write(`if (${e} !== null) return INVALID;`),e}function kP(t,e){return t.write(`if (${e} !== undefined) return INVALID;`),e}function CP(t,e){return t.write(`if (typeof ${e} !== "number" || !Number.isNaN(${e})) return INVALID;`),e}function DP(t,e){return t.write(`if (!(${e} instanceof Date) || Number.isNaN(${e}.getTime())) return INVALID;`),e}function TP(t,e,r,i,n=!0){let o=r._zod.def;t.write(`if (typeof ${i} !== "object" || ${i} === null || Array.isArray(${i})) return INVALID;`);let a=o.shape,s=Object.keys(a),u=Object.getOwnPropertySymbols(a),c=u.length?[...s,...u]:s,l=v=>typeof v=="symbol"?V(e,v):mt(v),d=v=>typeof v=="symbol"?`[${l(v)}]`:mt(v),p=a;if(s.includes("__proto__"))throw new ae('object shape key "__proto__"');let m=new Map;for(let v of c){let A=p[v],x=l(v),k=Q(e);if(t.write(`const ${k} = ${i}[${x}];`),A._zod.optin!==void 0){let N=Q(e);t.write(`let ${N} = (() => {`),t.indented(K=>{let Le=at(K,e,A,k);K.write(`return ${Le};`)}),t.write("})();"),A._zod.optout==="optional"?(t.write(`if (${N} === INVALID) {`),t.indented(K=>{K.write(`if (${x} in ${i}) return INVALID;`),K.write(`${N} = undefined;`)}),t.write("}")):t.write(`if (${N} === INVALID) return INVALID;`),m.set(v,N)}else{PP(A)&&t.write(`if (!(${x} in ${i})) return INVALID;`);let N=at(t,e,A,k,n);N!==null&&m.set(v,N)}}let h=o.catchall,f="none";if(h){let v=h._zod.def.type;if(v==="never"){let A=s.map(x=>`k !== ${mt(x)}`).join(" && ")||"true";t.write(`for (const k in ${i}) {`),t.indented(x=>{x.write(`if (${A}) return INVALID;`)}),t.write("}")}else(v==="unknown"||v==="any")&&!h._zod.def.checks?.length?f="passthrough":f="schema"}let g=Q(e),y=c.some(v=>jI(p[v])||zg(p[v]));if(!n){if(f==="schema"){let v=s.length>0?V(e,new Set(s)):null;t.write(`for (const k in ${i}) {`),t.indented(A=>{A.write('if (k === "__proto__") continue;'),v&&A.write(`if (${v}.has(k)) continue;`);let x=Q(e);A.write(`const ${x} = ${i}[k];`),at(A,e,h,x,!1)}),t.write("}")}return null}if(y){t.write(`const ${g} = {};`);for(let v of c){let A=l(v),x=m.get(v);zg(p[v])?t.write(`if (${A} in ${i}) ${g}[${A}] = ${x};`):jI(p[v])?t.write(`if (${x} !== undefined || ${A} in ${i}) ${g}[${A}] = ${x};`):t.write(`${g}[${A}] = ${x};`)}}else{let v=c.map(A=>`${d(A)}: ${m.get(A)}`).join(", ");t.write(`const ${g} = { ${v} };`)}if(f!=="none"){let v=s.length>0?V(e,new Set(s)):null;t.write(`for (const k in ${i}) {`),t.indented(A=>{if(A.write('if (k === "__proto__") continue;'),v&&A.write(`if (${v}.has(k)) continue;`),f==="passthrough")A.write(`${g}[k] = ${i}[k];`);else{let x=Q(e);A.write(`const ${x} = ${i}[k];`);let k=at(A,e,h,x);A.write(`${g}[k] = ${k};`)}}),t.write("}")}return g}function NP(t,e,r,i,n=!0){let o=r._zod.def;if(zP(r))return ze(t,e,o.innerType,i,n);if(o.innerType._zod.optin==="defaulted"){let s=Q(e),u=Q(e);return t.write(`let ${s};`),t.write(`if (${i} === undefined) {`),t.indented(c=>{c.write(`const ${u} = (() => {`),c.indented(l=>{let d=ze(l,e,o.innerType,i);l.write(`return ${d};`)}),c.write("})();"),c.write(`if (${u} !== INVALID) ${s} = ${u};`)}),t.write("} else {"),t.indented(c=>{let l=ze(c,e,o.innerType,i);c.write(`${s} = ${l};`)}),t.write("}"),s}let a=n?Q(e):null;return a&&t.write(`let ${a};`),t.write(`if (${i} !== undefined) {`),t.indented(s=>{let u=ze(s,e,o.innerType,i,n);a&&u!==null&&s.write(`${a} = ${u};`)}),t.write("}"),a}function zP(t){return t._zod.traits?.has("$ZodExactOptional")===!0}function PP(t){return t._zod.optin===void 0&&Jn(t)}function Jn(t){if(t._zod.def.coerce)return!0;let e=t._zod.def;switch(e.type){case"any":case"unknown":case"undefined":case"void":case"default":case"prefault":case"transform":case"custom":case"lazy":return!0;case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"never":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":return!1;case"nonoptional":return e.innerType?Jn(e.innerType):!1;case"literal":return!!e.values?.includes(void 0);case"enum":return!!t._zod.values?.has(void 0);case"optional":case"nullable":case"readonly":case"success":return e.innerType?Jn(e.innerType):!0;case"catch":return!0;case"union":return e.options?e.options.some(Jn):!0;case"intersection":return!e.left||!e.right?!0:Jn(e.left)&&Jn(e.right);case"pipe":return e.in?Jn(e.in):!0;default:return!0}}function zg(t){return t._zod.optin==="optional"&&t._zod.optout==="optional"}function jI(t){return(t._zod.optin!=="defaulted"||t._zod.optout==="optional")&&co(t)}function co(t){let e=t._zod.def;switch(e.type){case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":case"never":case"success":return!1;case"literal":return!!e.values?.includes(void 0);case"enum":return!!t._zod.values?.has(void 0);case"optional":return!0;case"nullable":case"readonly":case"nonoptional":return e.innerType?co(e.innerType):!0;case"union":return e.options?e.options.some(co):!0;case"intersection":return!e.left||!e.right||co(e.left)||co(e.right);case"pipe":return e.out?co(e.out):!0;default:return!0}}function OP(t,e,r,i,n=!0){let o=r._zod.def,a=n?Q(e):null;return a&&t.write(`let ${a} = null;`),t.write(`if (${i} !== null) {`),t.indented(s=>{let u=ze(s,e,o.innerType,i,n);a&&u!==null&&s.write(`${a} = ${u};`)}),t.write("}"),a}function Rg(t,e,r){for(let[i,n]of Qi(e._zod.def.checks))t.write(`if (${r} > ${fn(i,n._zod.def.check)}) return INVALID;`)}function RP(t,e,r,i,n=!0){let o=r._zod.def;t.write(`if (!Array.isArray(${i})) return INVALID;`),Rg(t,r,`${i}.length`);let a=n?Q(e):null,s=Q(e),u=Q(e);return a&&t.write(`const ${a} = new Array(${i}.length);`),t.write(`for (let ${s} = 0; ${s} < ${i}.length; ${s}++) {`),t.indented(c=>{c.write(`const ${u} = ${i}[${s}];`);let l=at(c,e,o.element,u,n);a&&l!==null&&c.write(`${a}[${s}] = ${l};`)}),t.write("}"),a}function jP(t,e,r,i){let o=r._zod.def.values;if(o.length!==1){let s=V(e,new Set(o));return t.write(`if (!${s}.has(${i})) return INVALID;`),i}let a=o[0];if(typeof a=="number"&&Number.isNaN(a)){let s=V(e,new Set(o));return t.write(`if (!${s}.has(${i})) return INVALID;`),i}if(typeof a=="string")t.write(`if (${i} !== ${mt(a)}) return INVALID;`);else if(typeof a=="number"||typeof a=="boolean")t.write(`if (${i} !== ${a}) return INVALID;`);else if(a===null)t.write(`if (${i} !== null) return INVALID;`);else if(a===void 0)t.write(`if (${i} !== undefined) return INVALID;`);else if(typeof a=="bigint")t.write(`if (${i} !== ${a}n) return INVALID;`);else throw new ae(`literal type ${typeof a}`);return i}function BP(t,e,r,i){let n=r._zod.values;if(!n)throw new ae("enum schema without enumerated values");let o=V(e,n);return t.write(`if (!${o}.has(${i})) return INVALID;`),i}function BI(t,e,r,i){let n=r._zod.def;return ze(t,e,n.innerType,i)}function UP(t,e,r,i){let n=r._zod.def,a=Object.getOwnPropertyDescriptor(r._zod.def,"defaultValue")?()=>r._zod.def.defaultValue:void 0;if(r._zod.def.type==="prefault"){if(!a)return ze(t,e,n.innerType,i);let u=V(e,a),c=Q(e);return t.write(`let ${c} = ${i};`),t.write(`if (${i} === undefined) ${c} = ${u}();`),ze(t,e,n.innerType,c)}let s=Q(e);if(a){let u=V(e,a),c=V(e,Zi);t.write(`let ${s};`),t.write(`if (${i} === undefined) {`),t.indented(l=>{l.write(`${s} = ${c}(${u}());`)}),t.write("} else {"),t.indented(l=>{let d=ze(l,e,n.innerType,i);l.write(`${s} = ${d} === undefined ? ${c}(${u}()) : ${d};`)}),t.write("}")}else t.write(`let ${s};`),t.write(`if (${i} !== undefined) {`),t.indented(u=>{let c=ze(u,e,n.innerType,i);u.write(`${s} = ${c};`)}),t.write("}");return s}function MP(t,e,r,i){let n=r._zod.def,o=ze(t,e,n.innerType,i),a=Q(e);return t.write(`const ${a} = ${o};`),t.write(`if (${a} === undefined) return INVALID;`),a}function LP(t,e,r,i){let n=r._zod.def,o=n.items,a=n.rest;t.write(`if (!Array.isArray(${i})) return INVALID;`);let s=UI(o,"optin"),u=UI(o,"optout");a?t.write(`if (${i}.length < ${s}) return INVALID;`):t.write(`if (${i}.length < ${s} || ${i}.length > ${o.length}) return INVALID;`);let c=Q(e);t.write(`const ${c} = [];`);for(let l=0;l<o.length;l++){let d=o[l];if(l>=u)t.write(`if (${c}.length === ${l}) {`),t.indented(p=>{p.write(`if (${l} < ${i}.length) {`),p.indented(m=>{let h=Q(e);m.write(`const ${h} = ${i}[${l}];`);let f=at(m,e,d,h);m.write(`${c}[${l}] = ${f};`)}),p.write("} else {"),p.indented(m=>{if(zg(d)){m.write(`${c}.length = ${l};`);return}let h=Q(e),f=Q(e);m.write(`const ${h} = undefined;`),m.write(`const ${f} = (() => {`),m.indented(g=>{let y=at(g,e,d,h);g.write(`return ${y};`)}),m.write("})();"),m.write(`if (${f} === INVALID || ${f} === undefined) ${c}.length = ${l};`),m.write(`else ${c}[${l}] = ${f};`)}),p.write("}")}),t.write("}");else{let p=Q(e);t.write(`const ${p} = ${i}[${l}];`);let m=at(t,e,d,p);t.write(`${c}[${l}] = ${m};`)}}if(a){let l=Q(e),d=Q(e);t.write(`for (let ${l} = ${o.length}; ${l} < ${i}.length; ${l}++) {`),t.indented(p=>{p.write(`const ${d} = ${i}[${l}];`);let m=at(p,e,a,d);p.write(`${c}[${l}] = ${m};`)}),t.write("}")}return c}function UI(t,e){for(let r=t.length-1;r>=0;r--)if(!(e==="optin"?t[r]._zod.optin!==void 0:t[r]._zod.optout==="optional"))return r+1;return 0}function FP(t,e,r,i){let n=r._zod.def,o=n.options;if(n.discriminator)return ZP(t,e,n,i);if(n.inclusive===!1)throw new ae("exclusive unions (z.xor)");if(o.length===0)return t.write("return INVALID;"),i;if(o.length===1)return ze(t,e,o[0],i);if(o.every(u=>u._zod.def.type==="literal"&&!u._zod.def.checks?.length)){let u=new Set(o.flatMap(l=>l._zod.def.values)),c=V(e,u);return t.write(`if (!${c}.has(${i})) return INVALID;`),i}let s=Q(e);t.write(`let ${s};`);for(let u=0;u<o.length;u++){let c=o[u];u===0?t.write(`${s} = (() => {`):t.write(`if (${s} === INVALID) ${s} = (() => {`),t.indented(l=>{let d=ze(l,e,c,i);l.write(`return ${d};`)}),t.write("})();")}return t.write(`if (${s} === INVALID) return INVALID;`),s}function ZP(t,e,r,i){if(r.unionFallback)throw new ae("discriminated union with unionFallback");if(r.options.length===0)return t.write("return INVALID;"),i;let n=Q(e),o=Q(e);t.write(`const ${n} = ${i}?.[${mt(r.discriminator)}];`),t.write(`let ${o};`);let a=!0,s=new Set;for(let u of r.options){let c=u._zod.propValues?.[r.discriminator];if(!c||c.size===0)throw new ae("discriminated union option without static discriminator values");for(let p of c){if(s.has(p))throw new ae(`duplicate discriminator value ${String(p)}`);s.add(p)}let l=Array.from(c,p=>QP(e,n,p)),d=a?"if":"else if";t.write(`${d} (${l.join(" || ")}) {`),t.indented(p=>{let m=ze(p,e,u,i);p.write(`${o} = ${m};`)}),t.write("}"),a=!1}return t.write("else { return INVALID; }"),o}function QP(t,e,r){if(typeof r=="string")return`${e} === ${mt(r)}`;if(typeof r=="number")return Number.isNaN(r)?`Number.isNaN(${e})`:`${e} === ${r}`;if(typeof r=="boolean")return`${e} === ${r}`;if(r===null)return`${e} === null`;if(r===void 0)return`${e} === undefined`;if(typeof r=="bigint")return`${e} === ${r}n`;if(typeof r=="symbol"){let i=V(t,r);return`${e} === ${i}`}throw new ae(`literal discriminator value ${String(r)}`)}function qP(t,e,r,i){let n=r._zod.def;e.definite=!1;let o=at(t,e,n.left,i),a=at(t,e,n.right,i),s=V(e,to),u=Q(e);return t.write(`const ${u} = ${s}(${o}, ${a});`),t.write(`if (!${u}.valid) return INVALID;`),`${u}.data`}function VP(t,e,r,i){let n=r._zod.def,o=V(e,Jt);t.write(`if (!${o}(${i})) return INVALID;`);let a=Q(e),s=Q(e),u=Q(e);t.write(`const ${a} = {};`);let c=n,l=c.partial?void 0:n.keyType._zod.values;if(l){let m=[];for(let f of l){if(!(typeof f=="string"||typeof f=="number"||typeof f=="symbol"))throw new ae(`record key value ${String(f)}`);let g=typeof f=="number"?f.toString():f;if(g==="__proto__")throw new ae('record key "__proto__"');m.push(g);let y=V(e,f),v=ze(t,e,n.keyType,y),A=Q(e);t.write(`const ${A} = ${i}[${HP(e,g)}];`);let x=at(t,e,n.valueType,A);t.write(`${a}[${v}] = ${x};`)}let h=V(e,new Set(m));return t.write(`for (const ${s} in ${i}) {`),t.indented(f=>{f.write(`if (${h}.has(${s})) continue;`),c.mode==="loose"?f.write(`if (${s} !== "__proto__") ${a}[${s}] = ${i}[${s}];`):f.write("return INVALID;")}),t.write("}"),a}let d=n.keyType._zod.def;if(!(d.type==="string"&&d.format===void 0&&!d.coerce&&(d.checks?.length??0)===0)){let m=n.mode==="loose",h=Ad(n.keyType);h.definite===!1&&(e.definite=!1);let f=V(e,h),g=V(e,Qr),y=Q(e);return MI(t,e,i,s,v=>{v.write(`let ${y} = ${f}(${s});`),v.write(`if (${y} === INVALID && typeof ${s} === "string" && ${g}.test(${s})) ${y} = ${f}(Number(${s}));`),m?v.write(`if (${y} === INVALID) { ${a}[${s}] = ${i}[${s}]; continue; }`):v.write(`if (${y} === INVALID) return INVALID;`),v.write(`if (${y} === "__proto__") continue;`);let A=Q(e);v.write(`const ${A} = ${i}[${s}];`);let x=at(v,e,n.valueType,A);v.write(`${a}[${y}] = ${x};`)}),a}return MI(t,e,i,s,m=>{m.write(`const ${u} = ${i}[${s}];`);let h=at(m,e,n.valueType,u);m.write(`${a}[${s}] = ${h};`)},"return INVALID;"),a}function MI(t,e,r,i,n,o){let a=V(e,Object.prototype.propertyIsEnumerable),s=Q(e),u=Q(e),c=Q(e);t.write(`const ${s} = Object.getOwnPropertySymbols(${r});`),t.write(`const ${u} = Object.getOwnPropertyNames(${r});`),t.write(`for (let ${c} = 0; ${c} < ${u}.length; ${c}++) {`),t.indented(l=>{l.write(`const ${i} = ${u}[${c}];`),l.write(`if (${i} === "__proto__" || !${a}.call(${r}, ${i})) continue;`),n(l)}),t.write("}"),t.write(`for (let ${c} = 0; ${c} < ${s}.length; ${c}++) {`),t.indented(l=>{l.write(`const ${i} = ${s}[${c}];`),l.write(`if (!${a}.call(${r}, ${i})) continue;`),o?l.write(o):n(l)}),t.write("}")}function HP(t,e){return typeof e=="string"?mt(e):V(t,e)}function GP(t,e,r,i){let n=r._zod.def;t.write(`if (!(${i} instanceof Map)) return INVALID;`),Rg(t,r,`${i}.size`);let o=Q(e),a=Q(e),s=Q(e);return t.write(`const ${o} = new Map();`),t.write(`for (const [${a}, ${s}] of ${i}) {`),t.indented(u=>{let c=ze(u,e,n.keyType,a),l=ze(u,e,n.valueType,s);u.write(`${o}.set(${c}, ${l});`)}),t.write("}"),o}function JP(t,e,r,i){let n=r._zod.def;t.write(`if (!(${i} instanceof Set)) return INVALID;`),Rg(t,r,`${i}.size`);let o=Q(e),a=Q(e);return t.write(`const ${o} = new Set();`),t.write(`for (const ${a} of ${i}) {`),t.indented(s=>{let u=ze(s,e,n.valueType,a);s.write(`${o}.add(${u});`)}),t.write("}"),o}function KP(t,e){return t.write(`if (!(${e} instanceof File)) return INVALID;`),e}function XP(t,e,r,i){t.write(`if (typeof ${i} !== "string") return INVALID;`);let n=r._zod.pattern;if(n){let o=V(e,n);t.write(`${o}.lastIndex = 0;`),t.write(`if (!${o}.test(${i})) return INVALID;`)}return i}function YP(t,e,r,i){let n=r._zod.def,o=Kn(e,n.getter),a=V(e,{parser:null});t.write(`if (!${a}.parser) {`),t.indented(u=>{u.write(`const inner = ${o}();`),u.write(`${a}.parser = function(input) {`),u.indented(c=>{c.write("const result = inner._zod.run({ value: input, issues: [] }, {});"),c.write("return result.issues.length === 0 ? result.value : INVALID;")}),u.write("};")}),t.write("}");let s=Q(e);return t.write(`const ${s} = ${a}.parser(${i});`),t.write(`if (${s} === INVALID) return INVALID;`),s}function WP(t,e,r,i){let n=r._zod.def,o=ze(t,e,n.in,i);if(n.transform){if(Xn(n.transform))throw new sr("z.compile: async transforms in pipes are not supported");let a=n.transform,u=Kn(e,l=>{let d={value:l,issues:[],addIssue:Og},p=a(l,d);return p instanceof Promise?gt:d.issues.length===0?p:gt}),c=Q(e);return t.write(`const ${c} = ${u}(${o});`),t.write(`if (${c} === INVALID) return INVALID;`),ze(t,e,n.out,c)}else return ze(t,e,n.out,o)}function Xn(t){return typeof t=="function"&&(t.constructor.name==="AsyncFunction"||t[Symbol.toStringTag]==="AsyncFunction")}function eO(t,e,r,i){let n=r._zod.def;if(n.fn){if(Xn(n.fn))throw new sr("z.compile: async custom predicates are not supported");let o=Kn(e,n.fn),a=V(e,Ng),s=Q(e);t.write(`const ${s} = ${o}(${i});`),t.write(`if (${s} instanceof Promise) ${a}();`),t.write(`if (!${s}) return INVALID;`)}else throw new ae("custom schema without a predicate function");return i}function tO(t,e,r){let i=t._zod.run({value:r,issues:[]},{});if(i&&typeof i.then=="function")return gt;let n=i;return n.issues.length===0?n.value:e()}function rO(t,e,r,i){let n=r._zod.def;if(!n.catchValue[xc])throw new ae("catch with a callback (only a constant catch value compiles)",!1);let o=Q(e);t.write(`let ${o} = (() => {`),t.indented(c=>{let l=at(c,e,n.innerType,i);c.write(`return ${l};`)}),t.write("})();");let a=V(e,n.innerType),s=Kn(e,n.catchValue),u=V(e,tO);return t.write(`if (${o} === INVALID) {`),t.indented(c=>{c.write(`${o} = ${u}(${a}, ${s}, ${i});`),c.write(`if (${o} === INVALID) return INVALID;`)}),t.write("}"),o}function nO(t,e,r,i){let n=r._zod.def;if(n.transform){if(Xn(n.transform))throw new sr("z.compile: async transforms are not supported");let o=n.transform,s=Kn(e,c=>{let l={value:c,issues:[],addIssue:Og},d=o(c,l);return d instanceof Promise?gt:l.issues.length===0?d:gt}),u=Q(e);return t.write(`const ${u} = ${s}(${i});`),t.write(`if (${u} === INVALID) return INVALID;`),u}return i}function yd(t){return t.checks&&(t.checks=[...t.checks]),t}function _d(t,e){return new t(yd({type:"string",...D(e)}))}function jg(t,e){return new t(yd({type:"string",coerce:!0,...D(e)}))}function ys(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...D(e)})}function _s(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...D(e)})}function bs(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...D(e)})}function $s(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...D(e)})}function Is(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...D(e)})}function ws(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...D(e)})}function lo(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...D(e)})}function Es(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...D(e)})}function xs(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...D(e)})}function Ss(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...D(e)})}function ks(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...D(e)})}function Cs(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...D(e)})}function Ds(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...D(e)})}function Ts(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...D(e)})}function Ns(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...D(e)})}function zs(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...D(e)})}function bd(t,e){return new t({type:"string",format:"mac",check:"string_format",abort:!1,...D(e)})}function Ps(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...D(e)})}function Os(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...D(e)})}function Rs(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...D(e)})}function js(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...D(e)})}function Bs(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...D(e)})}function $d(t,e){return new t({type:"string",format:"credit_card",check:"string_format",abort:!1,...D(e)})}function Id(t,e){return new t({type:"string",format:"iban",check:"string_format",abort:!1,...D(e)})}function Us(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...D(e)})}var Bg={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function Ms(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...D(e)})}function Ls(t,e){return new t({type:"string",format:"date",check:"string_format",...D(e)})}function Fs(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...D(e)})}function Zs(t,e){return new t({type:"string",format:"duration",check:"string_format",...D(e)})}function wd(t,e){return new t(yd({type:"number",checks:[],...D(e)}))}function Ug(t,e){return new t(yd({type:"number",coerce:!0,checks:[],...D(e)}))}function Ed(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...D(e)})}function xd(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"float32",...D(e)})}function Sd(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"float64",...D(e)})}function kd(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"int32",...D(e)})}function Cd(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"uint32",...D(e)})}function Dd(t,e){return new t({type:"boolean",...D(e)})}function Mg(t,e){return new t({type:"boolean",coerce:!0,...D(e)})}function Td(t,e){return new t({type:"bigint",...D(e)})}function Lg(t,e){return new t({type:"bigint",coerce:!0,...D(e)})}function Nd(t,e){return new t({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...D(e)})}function zd(t,e){return new t({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...D(e)})}function Pd(t,e){return new t({type:"symbol",...D(e)})}function Od(t,e){return new t({type:"undefined",...D(e)})}function Rd(t,e){return new t({type:"null",...D(e)})}function jd(t){return new t({type:"any"})}function Bd(t){return new t({type:"unknown"})}function Ud(t,e){return new t({type:"never",...D(e)})}function Md(t,e){return new t({type:"void",...D(e)})}function Ld(t,e){return new t({type:"date",...D(e)})}function Fg(t,e){return new t({type:"date",coerce:!0,...D(e)})}function Fd(t,e){return new t({type:"nan",...D(e)})}function Ir(t,e){return new Mc({check:"less_than",...D(e),value:t,inclusive:!1})}function Lt(t,e){return new Mc({check:"less_than",...D(e),value:t,inclusive:!0})}function wr(t,e){return new Lc({check:"greater_than",...D(e),value:t,inclusive:!1})}function Ft(t,e){return new Lc({check:"greater_than",...D(e),value:t,inclusive:!0})}function Zd(t){return wr(0,t)}function Qd(t){return Ir(0,t)}function qd(t){return Lt(0,t)}function Vd(t){return Ft(0,t)}function pn(t,e){return new Kh({check:"multiple_of",...D(e),value:t})}function mn(t,e){return new Wh({check:"max_size",...D(e),maximum:t})}function Er(t,e){return new eg({check:"min_size",...D(e),minimum:t})}function Yn(t,e){return new tg({check:"size_equals",...D(e),size:t})}function Wn(t,e){return new rg({check:"max_length",...D(e),maximum:t})}function qr(t,e){return new ng({check:"min_length",...D(e),minimum:t})}function ei(t,e){return new ig({check:"length_equals",...D(e),length:t})}function fo(t,e){return new og({check:"string_format",format:"regex",...D(e),pattern:t})}function po(t){return new ag({check:"string_format",format:"lowercase",...D(t)})}function mo(t){return new sg({check:"string_format",format:"uppercase",...D(t)})}function ho(t,e){return new ug({check:"string_format",format:"includes",...D(e),includes:t})}function go(t,e){return new cg({check:"string_format",format:"starts_with",...D(e),prefix:t})}function vo(t,e){return new lg({check:"string_format",format:"ends_with",...D(e),suffix:t})}function Hd(t,e,r){return new dg({check:"property",property:t,schema:e,...D(r)})}function Ao(t,e){return new fg({check:"properties",shape:t,...D(e)})}function yo(t,e){return new pg({check:"mime_type",mime:t,...D(e)})}function ur(t){return new mg({check:"overwrite",tx:t})}function _o(t){return ur(e=>e.normalize(t))}function bo(){return ur(t=>t.trim())}function $o(){return ur(t=>t.toLowerCase())}function Io(){return ur(t=>t.toUpperCase())}function wo(){return ur(t=>Xm(t))}function Zg(t,e,r){return new t({type:"array",element:e,...D(r)})}function iO(t,e,r){return new t({type:"union",options:e,...D(r)})}function oO(t,e,r){return new t({type:"union",options:e,inclusive:!1,...D(r)})}function aO(t,e,r,i){return new t({type:"union",options:r,discriminator:e,...D(i)})}function sO(t,e,r){return new t({type:"intersection",left:e,right:r})}function uO(t,e,r,i){let n=r instanceof G,o=n?i:r,a=n?r:null;return new t({type:"tuple",items:e,rest:a,...D(o)})}function cO(t,e,r,i){return new t({type:"record",keyType:e,valueType:r,...D(i)})}function lO(t,e,r,i){return new t({type:"map",keyType:e,valueType:r,...D(i)})}function dO(t,e,r){return new t({type:"set",valueType:e,...D(r)})}function fO(t,e,r){let i=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new t({type:"enum",entries:i,...D(r)})}function pO(t,e,r){return new t({type:"enum",entries:e,...D(r)})}function mO(t,e,r){return new t({type:"literal",values:Array.isArray(e)?e:[e],...D(r)})}function Gd(t,e){return new t({type:"file",...D(e)})}function hO(t,e){return new t({type:"transform",transform:e})}function gO(t,e){return new t({type:"optional",innerType:e})}function vO(t,e){return new t({type:"nullable",innerType:e})}function AO(t,e,r){return new t({type:"default",innerType:e,get defaultValue(){return typeof r=="function"?r():Zi(r)}})}function yO(t,e,r){return new t({type:"nonoptional",innerType:e,...D(r)})}function _O(t,e){return new t({type:"success",innerType:e})}function bO(t,e,r){return new t({type:"catch",innerType:e,catchValue:typeof r=="function"?r:ih(r)})}function $O(t,e,r){return new t({type:"pipe",in:e,out:r})}function IO(t,e){return new t({type:"readonly",innerType:e})}function wO(t,e,r){return new t({type:"template_literal",parts:e,...D(r)})}function EO(t,e){return new t({type:"lazy",getter:e})}function xO(t,e){return new t({type:"promise",innerType:e})}function Jd(t,e,r){let i=D(r);return i.abort??(i.abort=!0),new t({type:"custom",check:"custom",fn:e,...i})}function Kd(t,e,r){return new t({type:"custom",check:"custom",fn:e,...D(r)})}function Xd(t,e){let r=QI(i=>(i.addIssue=n=>{if(typeof n=="string")i.issues.push(qi(n,i.value,r._zod.def));else{let o=n;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),"input"in o||(o.input=i.value),o.inst??(o.inst=r),o.continue??(o.continue=!r._zod.def.abort),i.issues.push(qi(o))}},t(i.value,i)),e);return r}function QI(t,e){let r=new $e({check:"custom",...D(e)});return r._zod.check=t,r}function Yd(t){let e=new $e({check:"describe"});return e._zod.onattach=[r=>{let i=Ye.get(r)??{};Ye.add(r,{...i,description:t})}],e._zod.check=()=>{},e}function Wd(t){let e=new $e({check:"meta"});return e._zod.onattach=[r=>{let i=Ye.get(r)??{};Ye.add(r,{...i,...t})}],e._zod.check=()=>{},e}function ef(t,e){let r=D(e),i=r.truthy??["true","1","yes","on","y","enabled"],n=r.falsy??["false","0","no","off","n","disabled"];r.case!=="sensitive"&&(i=i.map(m=>typeof m=="string"?m.toLowerCase():m),n=n.map(m=>typeof m=="string"?m.toLowerCase():m));let o=new Set(i),a=new Set(n),s=t.Codec??io,u=t.Boolean??ro,c=t.String??dn,l=new c({type:"string",error:r.error}),d=new u({type:"boolean",error:r.error}),p=new s({type:"pipe",in:l,out:d,transform:((m,h)=>{let f=m;return r.case!=="sensitive"&&(f=f.toLowerCase()),o.has(f)?!0:a.has(f)?!1:(h.issues.push({code:"invalid_value",expected:"stringbool",values:[...o,...a],input:h.value,inst:p,continue:!1}),{})}),reverseTransform:((m,h)=>m===!0?i[0]||"true":n[0]||"false"),error:r.error});return p._zod.bag.truthy=i,p._zod.bag.falsy=n,p._zod.bag.case=r.case??"insensitive",p}function hn(t,e,r,i={}){let n=D(i),o={check:"string_format",type:"string",format:e,fn:typeof r=="function"?r:s=>r.test(s),...n};return r instanceof RegExp&&(o.pattern=r),new t(o)}function Qs(t,...e){for(let r of e)for(let i of Reflect.ownKeys(r))Object.prototype.propertyIsEnumerable.call(r,i)&&Xe(t,i,r[i]);return t}function gn(t){let e=t?.target??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:t.processors??{},metadataRegistry:t?.metadata??Ye,target:e,unrepresentable:t?.unrepresentable??"throw",override:t?.override??(()=>{}),io:t?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:t?.cycles??"ref",reused:t?.reused??"inline",intersections:[],deferred:[],external:t?.external??void 0}}function Fe(t,e,r,i,n){let o=typeof e.unrepresentable=="function"?e.unrepresentable({zodSchema:t,path:i.path,message:n}):e.unrepresentable;if(o==="any")return!1;if(o===void 0||o==="throw")throw new Error(n);return Object.assign(r,o),!0}function _e(t,e,r={path:[],schemaPath:[]}){var i;let n=t._zod.def,o=e.seen.get(t);if(o)return o.count++,r.schemaPath.includes(t)&&(o.cycle=r.path),o.schema;let a={schema:{},count:1,cycle:void 0,path:r.path};e.seen.set(t,a),e.sharedDefsExtractedFor=void 0,e.sharedEmitDoneFor=void 0;let s=t._zod.toJSONSchema?.();if(s)a.schema=s;else{let l={...r,schemaPath:[...r.schemaPath,t],path:r.path};if(t._zod.processJSONSchema)t._zod.processJSONSchema(e,a.schema,l);else{let p=a.schema,m=e.processors[n.type];if(!m)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);m(t,e,p,l)}let d=t._zod.parent;d&&(a.ref||(a.ref=d),_e(d,e,l),e.seen.get(d).isParent=!0)}let u=e.metadataRegistry.get(t);return u&&Qs(a.schema,u),e.io==="input"&&vt(t)&&(delete a.schema.examples,delete a.schema.default),e.io==="input"&&"_prefault"in a.schema&&((i=a.schema).default??(i.default=a.schema._prefault)),delete a.schema._prefault,e.seen.get(t).schema}function qI(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}function vn(t,e){let r=t.seen.get(e);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");if(t.external&&t.sharedDefsExtractedFor===t.external)return;let i=new Map;for(let a of t.seen.entries()){let s=t.metadataRegistry.get(a[0])?.id;if(s){let u=i.get(s);if(u&&u!==a[0])throw new Error(`Duplicate schema id "${s}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(s,a[0])}}let n=a=>{let s=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){let d=t.external.registry.get(a[0])?.id,p=t.external.uri??(h=>h);if(d)return{ref:p(d)};let m=a[1].defId??a[1].schema.id??`schema${t.counter++}`;return a[1].defId=m,{defId:m,ref:`${p("__shared")}#/${s}/${qI(m)}`}}let u="#",c=`${u}/${s}/`;if(a[1]===r&&!a[1].schema.id)return{ref:u};let l=a[1].schema.id??`__schema${t.counter++}`;return{defId:l,ref:c+qI(l)}},o=a=>{if(a[1].schema.$ref)return;let s=a[1],{ref:u,defId:c}=n(a);s.def={...s.schema},c&&(s.defId=c);let l=s.schema;for(let d in l)delete l[d];l.$ref=u};if(t.cycles==="throw")for(let a of t.seen.entries()){let s=a[1];if(s.cycle)throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
|
|
76
76
|
|
|
77
77
|
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of t.seen.entries()){let s=a[1];if(e===a[0]){o(a);continue}if(t.external){let c=t.external.registry.get(a[0])?.id;if(e!==a[0]&&c){o(a);continue}}if(t.metadataRegistry.get(a[0])?.id){o(a);continue}if(s.cycle){o(a);continue}s.count>1&&t.reused==="ref"&&o(a)}t.external&&(t.sharedDefsExtractedFor=t.external)}function GI(t){let e=t.anyOf;if(!Array.isArray(e)||e.length===0||t.type!==void 0)return;let r=[];for(let i of e){if(!i||typeof i!="object")return;GI(i);let n=Object.keys(i);if(n.length!==1||n[0]!=="type")return;let o=i.type;for(let a of Array.isArray(o)?o:[o]){if(typeof a!="string")return;r.includes(a)||r.push(a)}}delete t.anyOf,t.type=r.length===1?r[0]:r}var JI=new Set(["type","properties","required","additionalProperties"]),VI=["oneOf","anyOf"];function HI(t){let e=t.additionalProperties;return e===void 0||e===!1||typeof e!="object"||e===null?null:Object.keys(e).length?e:null}function Qg(t){let e=[];for(let o of t){if(typeof o!="object"||o.type!=="object")return null;for(let a in o)if(!JI.has(a))return null;e.push(o)}let r={},i=new Set;for(let o of e){for(let a in o.properties){if(Object.prototype.hasOwnProperty.call(r,a))continue;let s=[];for(let c of e){let l=c.properties?.[a]??HI(c);l!=null&&(s.some(d=>JSON.stringify(d)===JSON.stringify(l))||s.push(l))}let u=s.length===1?s[0]:Qg(s)??{allOf:s};Xe(r,a,u)}for(let a of o.required??[])i.add(a)}let n={type:"object",properties:r};if(i.size&&(n.required=[...i]),e.every(o=>o.additionalProperties===!1))n.additionalProperties=!1;else{let o=[];for(let a of e){let s=HI(a);s&&!o.some(u=>JSON.stringify(u)===JSON.stringify(s))&&o.push(s)}o.length===1?n.additionalProperties=o[0]:o.length>1&&(n.additionalProperties={allOf:o})}return n}function SO(t){let e=t.allOf;if(!Array.isArray(e)||e.length<2)return;for(let n of JI)if(n in t)return;let r=e.filter(n=>VI.some(o=>Array.isArray(n[o]))),i=null;if(!r.length)i=Qg(e);else{let n=r[0],o=VI.find(u=>Array.isArray(n[u]));if(Object.keys(n).length!==1)return;let a=e.filter(u=>u!==n),s=n[o].map(u=>Qg([...a,u]));if(s.some(u=>!u))return;i={[o]:s}}i&&(delete t.allOf,Qs(t,i))}function An(t,e){let r=t.seen.get(e);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=s=>{let u=t.seen.get(s);if(u.ref===null)return;let c=u.def??u.schema,l={...c},d=u.ref;if(u.ref=null,d){i(d);let m=t.seen.get(d),h=m.schema;if(h.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(h)):Qs(c,h),Qs(c,l),s._zod.parent===d)for(let g in c)g==="$ref"||g==="allOf"||g in l||delete c[g];if(h.$ref&&m.def)for(let g in c)g==="$ref"||g==="allOf"||g in m.def&&JSON.stringify(c[g])===JSON.stringify(m.def[g])&&delete c[g]}let p=s._zod.parent;if(p&&p!==d){i(p);let m=t.seen.get(p);if(m?.schema.$ref&&(c.$ref=m.schema.$ref,m.def))for(let h in c)h==="$ref"||h==="allOf"||h in m.def&&JSON.stringify(c[h])===JSON.stringify(m.def[h])&&delete c[h]}t.override({zodSchema:s,jsonSchema:c,path:u.path??[]})};if(!t.external||t.sharedEmitDoneFor!==t.external){for(let s of[...t.seen.entries()].reverse())i(s[0]);if(t.target!=="openapi-3.0")for(let s of t.seen.entries())GI(s[1].def??s[1].schema);for(let s of t.deferred)s();if(t.intersections.length){let s=new Map;for(let u of t.seen.values())for(let c of[u.schema,u.def]){let l=c?.allOf;if(!Array.isArray(l))continue;let d=s.get(l);d?d.push(c):s.set(l,[c])}for(let u of t.intersections)for(let c of s.get(u)??[])SO(c)}}let n={};if(t.target==="draft-2020-12"?n.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?n.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?n.$schema="http://json-schema.org/draft-04/schema#":t.target,t.external?.uri){let s=t.external.registry.get(e)?.id;if(!s)throw new Error("Schema is missing an `id` property");n.$id=t.external.uri(s)}Qs(n,r.defId?r.schema:r.def??r.schema);let o=t.metadataRegistry.get(e)?.id;o!==void 0&&n.id===o&&delete n.id;let a=t.external?.defs??{};if(!t.external||t.sharedEmitDoneFor!==t.external)for(let s of t.seen.entries()){let u=s[1];u.def&&u.defId&&(u.def.id===u.defId&&delete u.def.id,Xe(a,u.defId,u.def))}t.external&&(t.sharedEmitDoneFor=t.external),t.external||Object.keys(a).length>0&&(t.target==="draft-2020-12"?n.$defs=a:n.definitions=a);try{let s=JSON.parse(JSON.stringify(n));return Object.defineProperty(s,"~standard",{value:{...e["~standard"],jsonSchema:{input:Eo(e,"input",t.processors),output:Eo(e,"output",t.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function vt(t,e){let r=e??{seen:new Set};if(r.seen.has(t))return!1;r.seen.add(t);let i=t._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return vt(i.element,r);if(i.type==="set")return vt(i.valueType,r);if(i.type==="lazy")return vt(i.getter(),r);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault"||i.type==="catch")return vt(i.innerType,r);if(i.type==="intersection")return vt(i.left,r)||vt(i.right,r);if(i.type==="record"||i.type==="map")return vt(i.keyType,r)||vt(i.valueType,r);if(i.type==="pipe")return t._zod.traits.has("$ZodCodec")?!0:vt(i.in,r)||vt(i.out,r);if(i.type==="object"){for(let n in i.shape)if(vt(i.shape[n],r))return!0;return!1}if(i.type==="union"){for(let n of i.options)if(vt(n,r))return!0;return!1}if(i.type==="tuple"){for(let n of i.items)if(vt(n,r))return!0;return!!(i.rest&&vt(i.rest,r))}return!1}var qg=(t,e={})=>r=>{let i=gn({...r,processors:e});return _e(t,i),vn(i,t),An(i,t)},Eo=(t,e,r={})=>i=>{let{libraryOptions:n,target:o}=i??{},a=gn({...n??{},target:o,io:e,processors:r});return _e(t,a),vn(a,t),An(a,t)};var xo=(t,e,r)=>{(t[e]===void 0||r>t[e])&&(t[e]=r)},So=(t,e,r)=>{(t[e]===void 0||r<t[e])&&(t[e]=r)},KI=(t,e)=>{xo(t,"minimum",e),So(t,"maximum",e)},ew=(t,e)=>{t.multipleOf??(t.multipleOf=[]),t.multipleOf.includes(e)||t.multipleOf.push(e)},tw=(t,e)=>{t.patterns??(t.patterns=new Set),t.patterns.add(e)},rw=(t,e)=>{t.mime=t.mime?t.mime.filter(r=>e.includes(r)):[...e]},nw=(t,e)=>{t.format=e,e.includes("int")&&(t.isInt=!0)},XI=(t,e)=>xo(t,"minimum",e.minimum),YI=(t,e)=>So(t,"maximum",e.maximum),WI=t=>(e,r)=>{nw(e,r.format);let[i,n]=t[r.format];xo(e,"minimum",i),So(e,"maximum",n)},kO={greater_than:(t,e)=>xo(t,e.inclusive?"minimum":"exclusiveMinimum",e.value),less_than:(t,e)=>So(t,e.inclusive?"maximum":"exclusiveMaximum",e.value),multiple_of:(t,e)=>ew(t,e.value),number_format:WI(Ha),bigint_format:WI(Ga),min_length:XI,max_length:YI,length_equals:(t,e)=>KI(t,e.length),min_size:XI,max_size:YI,size_equals:(t,e)=>KI(t,e.size),string_format:(t,e)=>{nw(t,e.format),e.pattern&&tw(t,e.pattern),(e.format==="base64"||e.format==="base64url")&&(t.contentEncoding=e.format),(e.local||e.precision===-1)&&(t.laxFormat=!0)},mime_type:(t,e)=>rw(t,e.mime)};function Ze(t){let e={},r=t._zod.def,i=t._zod.traits.has("$ZodCheck")?[t,...r.checks??[]]:r.checks??[];for(let o of i)kO[o._zod.def.check]?.(e,o._zod.def);let n=t._zod.bag;n.minimum!==void 0&&xo(e,"minimum",n.minimum),n.exclusiveMinimum!==void 0&&xo(e,"exclusiveMinimum",n.exclusiveMinimum),n.maximum!==void 0&&So(e,"maximum",n.maximum),n.exclusiveMaximum!==void 0&&So(e,"exclusiveMaximum",n.exclusiveMaximum),n.multipleOf!==void 0&&ew(e,n.multipleOf),n.format!==void 0&&(e.format??(e.format=n.format),n.format.includes("int")&&(e.isInt=!0)),n.mime&&rw(e,n.mime);for(let o of n.patterns??[])tw(e,o);return e}var CO={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},DO=new Map([[pl,Dh],[cs,Th]]),iw=t=>DO.get(t)??t,Gg=(t,e,r,i)=>{let n=r;n.type="string";let{minimum:o,maximum:a,format:s,patterns:u,contentEncoding:c,laxFormat:l}=Ze(t);if(typeof o=="number"&&(n.minLength=o),typeof a=="number"&&(n.maxLength=a),s&&(n.format=CO[s]??s,n.format===""&&delete n.format,(s==="time"||l)&&delete n.format),c&&(n.contentEncoding=c),u&&u.size>0){let d=[...u].map(iw);d.length===1?n.pattern=d[0].source:d.length>1&&(n.allOf=[...d.map(p=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},Jg=(t,e,r,i)=>{let n=r,{minimum:o,maximum:a,multipleOf:s,exclusiveMaximum:u,exclusiveMinimum:c,isInt:l}=Ze(t);n.type=l?"integer":"number";let d=typeof c=="number"&&c>=(o??Number.NEGATIVE_INFINITY),p=typeof u=="number"&&u<=(a??Number.POSITIVE_INFINITY),m=e.target==="draft-04"||e.target==="openapi-3.0";if(d?m?(n.minimum=c,n.exclusiveMinimum=!0):n.exclusiveMinimum=c:typeof o=="number"&&(n.minimum=o),p?m?(n.maximum=u,n.exclusiveMaximum=!0):n.exclusiveMaximum=u:typeof a=="number"&&(n.maximum=a),s){let h=new Set;for(let y of s)Number.isFinite(y)&&y!==0?h.add(Math.abs(y)):Fe(t,e,n,i,`A multipleOf divisor of ${y} cannot be represented in JSON Schema`);let[f,...g]=h;f!==void 0&&(n.multipleOf=f),g.length&&(n.allOf=[...n.allOf??[],...g.map(y=>({multipleOf:y}))])}},Kg=(t,e,r,i)=>{r.type="boolean"},Xg=(t,e,r,i)=>{Fe(t,e,r,i,"BigInt cannot be represented in JSON Schema")},Yg=(t,e,r,i)=>{Fe(t,e,r,i,"Symbols cannot be represented in JSON Schema")},Wg=(t,e,r,i)=>{e.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},ev=(t,e,r,i)=>{Fe(t,e,r,i,"Undefined cannot be represented in JSON Schema")},tv=(t,e,r,i)=>{Fe(t,e,r,i,"Void cannot be represented in JSON Schema")},rv=(t,e,r,i)=>{r.not={}},nv=(t,e,r,i)=>{},iv=(t,e,r,i)=>{},ov=(t,e,r,i)=>{Fe(t,e,r,i,"Date cannot be represented in JSON Schema")},av=(t,e,r,i)=>{let n=t._zod.def,o=Ui(n.entries);if(o.length===0){r.not={};return}o.every(a=>typeof a=="number")&&(r.type="number"),o.every(a=>typeof a=="string")&&(r.type="string"),r.enum=o},sv=(t,e,r,i)=>{let n=t._zod.def;if(n.values.length===0){r.not={};return}let o=[];for(let a of n.values)if(a===void 0){if(Fe(t,e,r,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof a=="bigint"){if(Fe(t,e,r,i,"BigInt literals cannot be represented in JSON Schema"))return;o.push(Number(a))}else o.push(a);if(o.length!==0)if(o.length===1){let a=o[0];r.type=a===null?"null":typeof a,e.target==="draft-04"||e.target==="openapi-3.0"?r.enum=[a]:r.const=a}else o.every(a=>typeof a=="number")&&(r.type="number"),o.every(a=>typeof a=="string")&&(r.type="string"),o.every(a=>typeof a=="boolean")&&(r.type="boolean"),o.every(a=>a===null)&&(r.type="null"),r.enum=o},uv=(t,e,r,i)=>{Fe(t,e,r,i,"NaN cannot be represented in JSON Schema")},cv=(t,e,r,i)=>{let n=r,o=t._zod.pattern;if(!o)throw new Error("Pattern not found in template literal");n.type="string",n.pattern=o.source},lv=(t,e,r,i)=>{let n=r;n.type="string",n.format="binary",n.contentEncoding="binary";let{minimum:o,maximum:a,mime:s}=Ze(t);o!==void 0&&(n.minLength=o),a!==void 0&&(n.maxLength=a),s&&(s.length===0?n.not={}:s.length===1?n.contentMediaType=s[0]:n.anyOf=s.map(u=>({contentMediaType:u})))},dv=(t,e,r,i)=>{r.type="boolean"},fv=(t,e,r,i)=>{Fe(t,e,r,i,"Custom types cannot be represented in JSON Schema")},pv=(t,e,r,i)=>{Fe(t,e,r,i,"Function types cannot be represented in JSON Schema")},mv=(t,e,r,i)=>{Fe(t,e,r,i,"Transforms cannot be represented in JSON Schema")},hv=(t,e,r,i)=>{Fe(t,e,r,i,"Map cannot be represented in JSON Schema")},gv=(t,e,r,i)=>{Fe(t,e,r,i,"Set cannot be represented in JSON Schema")},vv=(t,e,r,i)=>{let n=r,o=t._zod.def,{minimum:a,maximum:s}=Ze(t);typeof a=="number"&&(n.minItems=a),typeof s=="number"&&(n.maxItems=s),n.type="array",n.items=_e(o.element,e,{...i,path:[...i.path,"items"]})};function qs(t){let e=t._zod.def;return e.type==="pipe"&&e.in._zod.traits.has("$ZodTransform")?qs(e.out):e.type==="catch"?qs(e.innerType):t._zod.optin}var Av=(t,e,r,i)=>{let n=r,o=t._zod.def,a=o.shape;if(Object.getOwnPropertySymbols(a).length&&Fe(t,e,n,i,"Symbol keys cannot be represented in JSON Schema"))return;n.type="object",n.properties={};for(let c in a)Xe(n.properties,c,_e(a[c],e,{...i,path:[...i.path,"properties",c]}));let u=[];for(let c of Object.keys(a)){let l=o.shape[c];(e.io==="input"?qs(l)===void 0:l._zod.optout===void 0)&&u.push(c)}u.length>0&&(n.required=u),o.catchall?._zod.def.type==="never"?n.additionalProperties=!1:o.catchall?o.catchall&&(n.additionalProperties=_e(o.catchall,e,{...i,path:[...i.path,"additionalProperties"]})):e.io==="output"&&(n.additionalProperties=!1)},rf=(t,e,r,i)=>{let n=t._zod.def,o=n.inclusive===!1,a=n.options.map((s,u)=>_e(s,e,{...i,path:[...i.path,o?"oneOf":"anyOf",u]}));o?r.oneOf=a:r.anyOf=a},yv=(t,e,r,i)=>{let n=t._zod.def,o=_e(n.left,e,{...i,path:[...i.path,"allOf",0]}),a=_e(n.right,e,{...i,path:[...i.path,"allOf",1]}),s=c=>"allOf"in c&&Object.keys(c).length===1,u=[...s(o)?o.allOf:[o],...s(a)?a.allOf:[a]];r.allOf=u,e.intersections.push(u)},_v=(t,e,r,i)=>{let n=r,o=t._zod.def;n.type="array";let a=e.target==="draft-2020-12"?"prefixItems":"items",s=e.target==="draft-2020-12"||e.target==="openapi-3.0"?"items":"additionalItems",u=o.items.map((f,g)=>_e(f,e,{...i,path:[...i.path,a,g]})),c=o.rest?_e(o.rest,e,{...i,path:[...i.path,s,...e.target==="openapi-3.0"?[o.items.length]:[]]}):null,l=o.items.length;for(;l>0;){let f=o.items[l-1];if(!(e.io==="input"?qs(f)!==void 0:f._zod.optout==="optional"))break;l--}let d=o.items.length,p=!o.rest;e.target==="draft-2020-12"?(n.prefixItems=u,p?n.items=!1:c&&(n.items=c),l>0&&(n.minItems=l),p&&(n.maxItems=d)):e.target==="openapi-3.0"?(n.items={anyOf:u},c&&n.items.anyOf.push(c),l>0&&(n.minItems=l),p&&(n.maxItems=d)):(n.items=u,p?n.additionalItems=!1:c&&(n.additionalItems=c),l>0&&(n.minItems=l),p&&(n.maxItems=d));let{minimum:m,maximum:h}=Ze(t);typeof m=="number"&&(n.minItems=m),typeof h=="number"&&(n.maxItems=h)};function Vg(t,e,r){if(e.$ref){if(r.has(e))return e;r.add(e);let h=t.get(e)?.def;if(!h)return e;let f=Vg(t,h,r);return f===h?e:f}for(let h of["anyOf","oneOf"]){let f=e[h];if(!Array.isArray(f))continue;let g=f.map(y=>Vg(t,y,r));g.some((y,v)=>y!==f[v])&&(e={...e,[h]:g})}let i=Array.isArray(e.type)?e.type:[e.type],n=!i.includes("string")&&i.some(h=>h==="number"||h==="integer"),o=e.enum??(e.const!==void 0?[e.const]:void 0);if(!n&&!o?.some(h=>typeof h=="number"))return e;let{minimum:a,maximum:s,exclusiveMinimum:u,exclusiveMaximum:c,multipleOf:l,format:d,id:p,...m}=e;return m.enum?m.enum=m.enum.map(h=>typeof h=="number"?String(h):h):typeof m.const=="number"&&(m.const=String(m.const)),n&&(m.type="string",o||(m.pattern=(i.includes("number")?Qr:rs).source)),m}var Hg=new WeakMap;function TO(t){let e=new Map;for(let i of t.seen.values())i.def&&!e.has(i.schema)&&e.set(i.schema,i);let r=new Map;for(let i of Hg.get(t)??[]){let n=t.seen.get(i),o=(n?.def??n?.schema)?.propertyNames;if(!o||o===!0||r.has(o))continue;let a=Vg(e,o,new Set);a!==o&&r.set(o,a)}if(r.size)for(let i of t.seen.values())for(let n of[i.schema,i.def]){let o=n&&r.get(n.propertyNames);o&&(n.propertyNames=o)}}var bv=(t,e,r,i)=>{let n=r,o=t._zod.def;n.type="object";let a=o.keyType,s=Ze(a).patterns;if(o.mode==="loose"&&s&&s.size>0){let l=_e(o.valueType,e,{...i,path:[...i.path,"patternProperties","*"]});n.patternProperties={};for(let d of s)Xe(n.patternProperties,iw(d).source,l)}else{if(e.target==="draft-07"||e.target==="draft-2020-12"){n.propertyNames=_e(o.keyType,e,{...i,path:[...i.path,"propertyNames"]});let l=Hg.get(e);l||(l=[],Hg.set(e,l),e.deferred.push(()=>TO(e))),l.push(t)}n.additionalProperties=_e(o.valueType,e,{...i,path:[...i.path,"additionalProperties"]})}let u=a._zod.values,c=e.io==="input"&&qs(o.valueType)!==void 0;if(u&&!o.partial&&!c){let l=[...u].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(n.required=l.map(String))}},$v=(t,e,r,i)=>{let n=t._zod.def,o=_e(n.innerType,e,i),a=e.seen.get(t);e.target==="openapi-3.0"?(a.ref=n.innerType,r.nullable=!0):r.anyOf=[o,{type:"null"}]},Iv=(t,e,r,i)=>{let n=t._zod.def;_e(n.innerType,e,i);let o=e.seen.get(t);o.ref=n.innerType},wv=Symbol();function ow(t,e,r,i,n){let o=!1,a=JSON.stringify(t,(s,u)=>typeof u!="bigint"?u:(o=!0,null));return o?(Fe(e,r,i,n,"BigInt defaults cannot be represented in JSON Schema"),wv):JSON.parse(a)}var Ev=(t,e,r,i)=>{let n=t._zod.def;_e(n.innerType,e,i);let o=e.seen.get(t);o.ref=n.innerType;let a=ow(n.defaultValue,t,e,r,i);a!==wv&&(r.default=a)},xv=(t,e,r,i)=>{let n=t._zod.def;_e(n.innerType,e,i);let o=e.seen.get(t);if(o.ref=n.innerType,e.io!=="input")return;let a=ow(n.defaultValue,t,e,r,i);a!==wv&&(r._prefault=a)},Sv=(t,e,r,i)=>{let n=t._zod.def;_e(n.innerType,e,i);let o=e.seen.get(t);o.ref=n.innerType;let a;try{a=n.catchValue(void 0)}catch{Fe(t,e,r,i,"Dynamic catch values are not supported in JSON Schema");return}r.default=a},kv=(t,e,r,i)=>{let n=t._zod.def,o=n.in._zod.traits.has("$ZodTransform"),a=e.io==="input"?o?n.out:n.in:n.out;_e(a,e,i);let s=e.seen.get(t);s.ref=a},Cv=(t,e,r,i)=>{let n=t._zod.def;_e(n.innerType,e,i);let o=e.seen.get(t);o.ref=n.innerType,r.readOnly=!0},Dv=(t,e,r,i)=>{let n=t._zod.def;_e(n.innerType,e,i);let o=e.seen.get(t);o.ref=n.innerType},nf=(t,e,r,i)=>{let n=t._zod.def;_e(n.innerType,e,i);let o=e.seen.get(t);o.ref=n.innerType},Tv=(t,e,r,i)=>{let n=t._zod.innerType;_e(n,e,i);let o=e.seen.get(t);o.ref=n},tf={string:Gg,number:Jg,boolean:Kg,bigint:Xg,symbol:Yg,null:Wg,undefined:ev,void:tv,never:rv,any:nv,unknown:iv,date:ov,enum:av,literal:sv,nan:uv,template_literal:cv,file:lv,success:dv,custom:fv,function:pv,transform:mv,map:hv,set:gv,array:vv,object:Av,union:rf,intersection:yv,tuple:_v,record:bv,nullable:$v,nonoptional:Iv,default:Ev,prefault:xv,catch:Sv,pipe:kv,readonly:Cv,promise:Dv,optional:nf,lazy:Tv};function ti(t,e){if("_idmap"in t){let i=t,n=gn({...e,processors:tf}),o={};for(let u of i._idmap.entries()){let[c,l]=u;_e(l,n)}let a={},s={registry:i,uri:e?.uri,defs:o};n.external=s;for(let u of i._idmap.entries()){let[c,l]=u;vn(n,l),Xe(a,c,An(n,l))}if(Object.keys(o).length>0){let u=n.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[u]:o}}return{schemas:a}}let r=gn({...e,processors:tf});return _e(t,r),vn(r,t),An(r,t)}var of=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(e){this.ctx.counter=e}get seen(){return this.ctx.seen}constructor(e){let r=e?.target??"draft-2020-12";r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),this.ctx=gn({processors:tf,target:r,...e?.metadata&&{metadata:e.metadata},...e?.unrepresentable&&{unrepresentable:e.unrepresentable},...e?.override&&{override:e.override},...e?.io&&{io:e.io}})}process(e,r={path:[],schemaPath:[]}){return _e(e,this.ctx,r)}emit(e,r){r&&(r.cycles&&(this.ctx.cycles=r.cycles),r.reused&&(this.ctx.reused=r.reused),r.external&&(this.ctx.external=r.external)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,vn(this.ctx,e);let i=An(this.ctx,e),{"~standard":n,...o}=i;return o}};var aw={};var PO=_("ZodMiniType",(t,e)=>{if(!t._zod)throw new Error("Uninitialized schema in ZodMiniType.");G.init(t,e),t.def=e,t.type=e.type},{get with(){return this.check},set with(t){$r(this,"with",t)},parse(t,e){return qn(this,t,e,{callee:this.parse})},parseAsync(t,e){return Vn(this,t,e,{callee:this.parseAsync})},safeParse(t,e){return Ji(this,t,e)},safeParseAsync(t,e){return Xi(this,t,e)},check(...t){let e=this.def;return this.clone({...e,checks:[...e.checks??[],...t.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]},{parent:!0})},clone(t,e){return he(this,t,e)},brand(){return this},register(t,e){return t.add(this,e),this},apply(t,...e){return e.length===0?t(this):t(this,...e)}});var OO=_("ZodMiniObject",(t,e)=>{Rl.init(t,e),PO.init(t,e),nh(t,"shape",r=>r._zod.def.shape,!1)});function Nv(t,e){let r={type:"object",shape:t??{},...D(e)};return new OO(r)}var sw=Symbol("z.visit/resolving");function Vs(t,e){let r=typeof e=="function"?e:(a,s)=>{let u=e[a._zod.def.type];return u?u(a,s):a},i=new Map;function n(a){let s=i.get(a);if(s===sw)return new oo({type:"lazy",getter:()=>i.get(a)});if(s!==void 0)return s;i.set(a,sw);let u=o(a),c=r(u,u!==a);return i.set(a,c),c}function o(a){let s=a._zod.def,u=s.type;switch(u){case"object":{let c=s.shape,l=Object.keys(c),d=!1,p={};for(let h of l){let f=n(c[h]);f!==c[h]&&(d=!0),p[h]=f}let m=s.catchall;return s.catchall&&(m=n(s.catchall),m!==s.catchall&&(d=!0)),d?he(a,{...s,shape:p,catchall:m}):a}case"array":{let c=n(s.element);return c===s.element?a:he(a,{...s,element:c})}case"tuple":{let c=s.items,l=!1,d=[];for(let m of c){let h=n(m);h!==m&&(l=!0),d.push(h)}let p=s.rest;return s.rest&&(p=n(s.rest),p!==s.rest&&(l=!0)),l?he(a,{...s,items:d,rest:p}):a}case"record":case"map":{let c=n(s.keyType),l=n(s.valueType);return c===s.keyType&&l===s.valueType?a:he(a,{...s,keyType:c,valueType:l})}case"set":{let c=n(s.valueType);return c===s.valueType?a:he(a,{...s,valueType:c})}case"union":{let c=s.options,l=!1,d=[];for(let p of c){let m=n(p);m!==p&&(l=!0),d.push(m)}return l?he(a,{...s,options:d}):a}case"intersection":{let c=n(s.left),l=n(s.right);return c===s.left&&l===s.right?a:he(a,{...s,left:c,right:l})}case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":{let c=n(s.innerType);return c===s.innerType?a:he(a,{...s,innerType:c})}case"pipe":{let c=n(s.in),l=n(s.out);return c===s.in&&l===s.out?a:he(a,{...s,in:c,out:l})}case"function":{let c=n(s.input),l=n(s.output);return c===s.input&&l===s.output?a:he(a,{...s,input:c,output:l})}case"lazy":{let c=s.getter,{_cachedInner:l,...d}=s;return he(a,{...d,getter:()=>n(c())})}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":return a;default:return a}}return n(t)}function xr(t){return!!t._zod}function ri(t){let e=Object.values(t);if(e.length===0)return Nv({});let r=e.every(xr),i=e.every(n=>!xr(n));if(r)return Nv(t);if(i)return w0(t);throw new Error("Mixed Zod versions detected in object shape.")}function yn(t,e){return xr(t)?Ji(t,e):t.safeParse(e)}async function af(t,e){return xr(t)?await Xi(t,e):await t.safeParseAsync(e)}function _n(t){if(!t)return;let e;if(xr(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function ko(t){if(t){if(typeof t=="object"){let e=t,r=t;if(!e._def&&!r._zod){let i=Object.values(t);if(i.length>0&&i.every(n=>typeof n=="object"&&n!==null&&(n._def!==void 0||n._zod!==void 0||typeof n.parse=="function")))return ri(t)}}if(xr(t)){let r=t._zod?.def;if(r&&(r.type==="object"||r.shape!==void 0))return t}else if(t.shape!==void 0)return t}}function jO(t){return t.length===0?"object root":t.reduce((e,r,i)=>i===0?String(r):typeof r=="number"?`${e}[${r}]`:`${e}.${r}`,"")}function sf(t){if(t&&typeof t=="object"){if("issues"in t&&Array.isArray(t.issues)&&t.issues.length>0)return t.issues.map(e=>e.path?.length?`${e.message} at ${jO(e.path)}`:e.message).join(`
|
|
78
|
-
`);if("message"in t&&typeof t.message=="string")return t.message;try{return JSON.stringify(t)}catch{return String(t)}}return String(t)}function uw(t){return t.description}function cw(t){if(xr(t))return t._zod?.def?.type==="optional";let e=t;return typeof t.isOptional=="function"?t.isOptional():e._def?.typeName==="ZodOptional"}function Co(t){if(xr(t)){let o=t._zod?.def;if(o){if(o.value!==void 0)return o.value;if(Array.isArray(o.values)&&o.values.length>0)return o.values[0]}}let r=t._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let i=t.value;if(i!==void 0)return i}var L={};jr(L,{$brand:()=>sh,$input:()=>Dg,$output:()=>Cg,INVALID:()=>gt,NEVER:()=>ah,TimePrecision:()=>Bg,ZodAny:()=>Xv,ZodArray:()=>tA,ZodBase64:()=>xf,ZodBase64URL:()=>Sf,ZodBigInt:()=>Oo,ZodBigIntFormat:()=>Df,ZodBoolean:()=>Po,ZodCIDRv4:()=>wf,ZodCIDRv6:()=>Ef,ZodCUID:()=>vf,ZodCUID2:()=>Af,ZodCatch:()=>_A,ZodCodec:()=>tu,ZodCompileAsyncError:()=>sr,ZodCompileUnsupportedError:()=>ae,ZodCreditCard:()=>Vv,ZodCustom:()=>ru,ZodCustomStringFormat:()=>ii,ZodDate:()=>Ks,ZodDefault:()=>mA,ZodDiscriminatedUnion:()=>nA,ZodE164:()=>kf,ZodEmail:()=>pf,ZodEmoji:()=>hf,ZodEnum:()=>To,ZodError:()=>BO,ZodExactOptional:()=>zf,ZodFile:()=>lA,ZodFirstPartyTypeKind:()=>PA,ZodFunction:()=>DA,ZodGUID:()=>mf,ZodIBAN:()=>Hv,ZodIPv4:()=>$f,ZodIPv6:()=>If,ZodISODate:()=>$n,ZodISODateTime:()=>bn,ZodISODuration:()=>wn,ZodISOTime:()=>In,ZodInstanceOf:()=>zA,ZodIntersection:()=>iA,ZodIssueCode:()=>LO,ZodJWT:()=>Cf,ZodKSUID:()=>bf,ZodLazy:()=>SA,ZodLiteral:()=>cA,ZodMAC:()=>qv,ZodMap:()=>sA,ZodNaN:()=>$A,ZodNanoID:()=>gf,ZodNever:()=>Wv,ZodNonOptional:()=>Pf,ZodNull:()=>Kv,ZodNullable:()=>pA,ZodNumber:()=>zo,ZodNumberFormat:()=>oi,ZodObject:()=>Xs,ZodOptional:()=>ai,ZodPipe:()=>eu,ZodPrefault:()=>gA,ZodPreprocess:()=>IA,ZodPromise:()=>CA,ZodReadonly:()=>wA,ZodRealError:()=>St,ZodRecord:()=>Do,ZodSet:()=>uA,ZodString:()=>No,ZodStringFormat:()=>we,ZodSuccess:()=>yA,ZodSymbol:()=>Gv,ZodTemplateLiteral:()=>xA,ZodTransform:()=>dA,ZodTuple:()=>oA,ZodType:()=>W,ZodULID:()=>yf,ZodURL:()=>Gs,ZodUUID:()=>Sr,ZodUndefined:()=>Jv,ZodUnion:()=>Ys,ZodUnknown:()=>Yv,ZodVoid:()=>eA,ZodXID:()=>_f,ZodXor:()=>rA,_ZodString:()=>ff,_default:()=>hA,_function:()=>vE,any:()=>Yw,array:()=>ie,base64:()=>Nw,base64url:()=>zw,bigint:()=>Hw,boolean:()=>je,catch:()=>bA,check:()=>AE,cidrv4:()=>Dw,cidrv6:()=>Tw,clone:()=>he,codec:()=>pE,coerce:()=>RA,compile:()=>Pg,config:()=>Re,core:()=>cr,creditCard:()=>Ow,cuid:()=>$w,cuid2:()=>Iw,currencyCode:()=>Lw,custom:()=>Of,date:()=>eE,decode:()=>Bv,decodeAsync:()=>Mv,deepPartial:()=>CE,describe:()=>yE,discriminatedUnion:()=>Ws,e164:()=>Pw,email:()=>fw,emoji:()=>_w,encode:()=>jv,encodeAsync:()=>Uv,endsWith:()=>vo,enum:()=>et,exactOptional:()=>fA,file:()=>cE,flattenError:()=>Wa,float32:()=>Zw,float64:()=>Qw,formatError:()=>es,fromJSONSchema:()=>kE,function:()=>vE,getDiscriminatedOption:()=>Eg,getErrorMap:()=>ZO,globalRegistry:()=>Ye,gt:()=>wr,gte:()=>Ft,guid:()=>pw,hash:()=>Fw,hex:()=>Mw,hostname:()=>Uw,httpUrl:()=>yw,iban:()=>Rw,includes:()=>ho,input:()=>TE,instanceof:()=>bE,int:()=>lf,int32:()=>qw,int64:()=>Gw,intersection:()=>Ro,invertCodec:()=>mE,ipv4:()=>Sw,ipv6:()=>Cw,iso:()=>si,json:()=>IE,jwt:()=>jw,keyof:()=>tE,ksuid:()=>xw,lazy:()=>kA,length:()=>ei,literal:()=>M,locales:()=>uo,looseObject:()=>We,looseRecord:()=>oE,lowercase:()=>po,lt:()=>Ir,lte:()=>Lt,mac:()=>kw,map:()=>aE,maxLength:()=>Wn,maxSize:()=>mn,memoizer:()=>vs,meta:()=>_E,mime:()=>yo,minLength:()=>qr,minSize:()=>Er,multipleOf:()=>pn,nan:()=>fE,nanoid:()=>bw,nativeEnum:()=>uE,negative:()=>Qd,never:()=>Tf,nonnegative:()=>Vd,nonoptional:()=>AA,nonpositive:()=>qd,normalize:()=>_o,null:()=>Js,nullable:()=>Hs,nullish:()=>lE,number:()=>ge,object:()=>O,optional:()=>Ie,output:()=>NE,overwrite:()=>ur,parse:()=>zv,parseAsync:()=>Pv,partialRecord:()=>iE,pipe:()=>df,positive:()=>Zd,prefault:()=>vA,preprocess:()=>nu,prettifyError:()=>fh,promise:()=>gE,properties:()=>Ao,property:()=>Hd,readonly:()=>EA,record:()=>Ee,refine:()=>TA,regex:()=>fo,regexes:()=>Mt,registry:()=>gd,safeDecode:()=>Fv,safeDecodeAsync:()=>Qv,safeEncode:()=>Lv,safeEncodeAsync:()=>Zv,safeParse:()=>Ov,safeParseAsync:()=>Rv,set:()=>sE,setErrorMap:()=>FO,size:()=>Yn,slugify:()=>wo,startsWith:()=>go,strictObject:()=>rE,string:()=>$,stringFormat:()=>Bw,stringbool:()=>$E,success:()=>dE,superRefine:()=>NA,symbol:()=>Kw,templateLiteral:()=>hE,toJSONSchema:()=>ti,toLowerCase:()=>$o,toUpperCase:()=>Io,toZod:()=>Qa,transform:()=>Nf,treeifyError:()=>dh,trim:()=>bo,tuple:()=>aA,uint32:()=>Vw,uint64:()=>Jw,ulid:()=>ww,undefined:()=>Xw,union:()=>be,unknown:()=>ke,uppercase:()=>mo,url:()=>Aw,util:()=>I,uuid:()=>mw,uuidv4:()=>hw,uuidv6:()=>gw,uuidv7:()=>vw,validate:()=>Yi,validateAsync:()=>Wi,void:()=>Ww,withParser:()=>vd,xid:()=>Ew,xor:()=>nE});var jo={};jr(jo,{ZodAny:()=>Xv,ZodArray:()=>tA,ZodBase64:()=>xf,ZodBase64URL:()=>Sf,ZodBigInt:()=>Oo,ZodBigIntFormat:()=>Df,ZodBoolean:()=>Po,ZodCIDRv4:()=>wf,ZodCIDRv6:()=>Ef,ZodCUID:()=>vf,ZodCUID2:()=>Af,ZodCatch:()=>_A,ZodCodec:()=>tu,ZodCreditCard:()=>Vv,ZodCustom:()=>ru,ZodCustomStringFormat:()=>ii,ZodDate:()=>Ks,ZodDefault:()=>mA,ZodDiscriminatedUnion:()=>nA,ZodE164:()=>kf,ZodEmail:()=>pf,ZodEmoji:()=>hf,ZodEnum:()=>To,ZodExactOptional:()=>zf,ZodFile:()=>lA,ZodFunction:()=>DA,ZodGUID:()=>mf,ZodIBAN:()=>Hv,ZodIPv4:()=>$f,ZodIPv6:()=>If,ZodISODate:()=>$n,ZodISODateTime:()=>bn,ZodISODuration:()=>wn,ZodISOTime:()=>In,ZodInstanceOf:()=>zA,ZodIntersection:()=>iA,ZodJWT:()=>Cf,ZodKSUID:()=>bf,ZodLazy:()=>SA,ZodLiteral:()=>cA,ZodMAC:()=>qv,ZodMap:()=>sA,ZodNaN:()=>$A,ZodNanoID:()=>gf,ZodNever:()=>Wv,ZodNonOptional:()=>Pf,ZodNull:()=>Kv,ZodNullable:()=>pA,ZodNumber:()=>zo,ZodNumberFormat:()=>oi,ZodObject:()=>Xs,ZodOptional:()=>ai,ZodPipe:()=>eu,ZodPrefault:()=>gA,ZodPreprocess:()=>IA,ZodPromise:()=>CA,ZodReadonly:()=>wA,ZodRecord:()=>Do,ZodSet:()=>uA,ZodString:()=>No,ZodStringFormat:()=>we,ZodSuccess:()=>yA,ZodSymbol:()=>Gv,ZodTemplateLiteral:()=>xA,ZodTransform:()=>dA,ZodTuple:()=>oA,ZodType:()=>W,ZodULID:()=>yf,ZodURL:()=>Gs,ZodUUID:()=>Sr,ZodUndefined:()=>Jv,ZodUnion:()=>Ys,ZodUnknown:()=>Yv,ZodVoid:()=>eA,ZodXID:()=>_f,ZodXor:()=>rA,_ZodString:()=>ff,_default:()=>hA,_function:()=>vE,any:()=>Yw,array:()=>ie,base64:()=>Nw,base64url:()=>zw,bigint:()=>Hw,boolean:()=>je,catch:()=>bA,check:()=>AE,cidrv4:()=>Dw,cidrv6:()=>Tw,codec:()=>pE,creditCard:()=>Ow,cuid:()=>$w,cuid2:()=>Iw,currencyCode:()=>Lw,custom:()=>Of,date:()=>eE,describe:()=>yE,discriminatedUnion:()=>Ws,e164:()=>Pw,email:()=>fw,emoji:()=>_w,enum:()=>et,exactOptional:()=>fA,file:()=>cE,float32:()=>Zw,float64:()=>Qw,function:()=>vE,guid:()=>pw,hash:()=>Fw,hex:()=>Mw,hostname:()=>Uw,httpUrl:()=>yw,iban:()=>Rw,instanceof:()=>bE,int:()=>lf,int32:()=>qw,int64:()=>Gw,intersection:()=>Ro,invertCodec:()=>mE,ipv4:()=>Sw,ipv6:()=>Cw,json:()=>IE,jwt:()=>jw,keyof:()=>tE,ksuid:()=>xw,lazy:()=>kA,literal:()=>M,looseObject:()=>We,looseRecord:()=>oE,mac:()=>kw,map:()=>aE,meta:()=>_E,nan:()=>fE,nanoid:()=>bw,nativeEnum:()=>uE,never:()=>Tf,nonoptional:()=>AA,null:()=>Js,nullable:()=>Hs,nullish:()=>lE,number:()=>ge,object:()=>O,optional:()=>Ie,partialRecord:()=>iE,pipe:()=>df,prefault:()=>vA,preprocess:()=>nu,promise:()=>gE,readonly:()=>EA,record:()=>Ee,refine:()=>TA,set:()=>sE,strictObject:()=>rE,string:()=>$,stringFormat:()=>Bw,stringbool:()=>$E,success:()=>dE,superRefine:()=>NA,symbol:()=>Kw,templateLiteral:()=>hE,transform:()=>Nf,tuple:()=>aA,uint32:()=>Vw,uint64:()=>Jw,ulid:()=>ww,undefined:()=>Xw,union:()=>be,unknown:()=>ke,url:()=>Aw,uuid:()=>mw,uuidv4:()=>hw,uuidv6:()=>gw,uuidv7:()=>vw,void:()=>Ww,xid:()=>Ew,xor:()=>nE});var uf={};jr(uf,{endsWith:()=>vo,gt:()=>wr,gte:()=>Ft,includes:()=>ho,length:()=>ei,lowercase:()=>po,lt:()=>Ir,lte:()=>Lt,maxLength:()=>Wn,maxSize:()=>mn,mime:()=>yo,minLength:()=>qr,minSize:()=>Er,multipleOf:()=>pn,negative:()=>Qd,nonnegative:()=>Vd,nonpositive:()=>qd,normalize:()=>_o,overwrite:()=>ur,positive:()=>Zd,properties:()=>Ao,property:()=>Hd,regex:()=>fo,size:()=>Yn,slugify:()=>wo,startsWith:()=>go,toLowerCase:()=>$o,toUpperCase:()=>Io,trim:()=>bo,uppercase:()=>mo});var lw=new WeakSet([Object.prototype,Error.prototype]);function cf(t,e,r){Object.defineProperty(t,e,{configurable:!0,enumerable:!1,get(){let i=r(this);return Object.defineProperty(this,e,{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,e,{value:i,configurable:!0,writable:!0})}})}var dw=(t,e)=>{lh.init(t,e),t.name="ZodError";let r=Object.getPrototypeOf(t);lw.has(r)||(lw.add(r),cf(r,"format",i=>n=>es(i,n)),cf(r,"flatten",i=>n=>Wa(i,n)),cf(r,"addIssue",i=>n=>{i.issues.push(n),i.message=JSON.stringify(i.issues,Mi,2)}),cf(r,"addIssues",i=>n=>{i.issues.push(...n),i.message=JSON.stringify(i.issues,Mi,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},BO=_("ZodError",dw),St=_("ZodError",dw,void 0,{Parent:Error});var zv=Vi(St),Pv=Hi(St),Ov=Gi(St),Rv=Ki(St),jv=kc(St),Bv=Cc(St),Uv=Dc(St),Mv=Tc(St),Lv=Nc(St),Fv=zc(St),Zv=Pc(St),Qv=Oc(St);function MO(){Ve.localeError||Re(fd())}function ni(){Ve.memoizer||Re({memoizer:vs()})}var W=_("ZodType",(t,e)=>(MO(),G.init(t,e),t.def=e,t.type=e.type,t),{check(...t){let e=this.def;return this.clone(I.mergeDefs(e,{checks:[...e.checks??[],...t.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...t){return this.check(...t)},clone(t,e){return he(this,t,e)},brand(){return this},register(t,e){return t.add(this,e),this},refine(t,e){return this.check(TA(t,e))},superRefine(t,e){return this.check(NA(t,e))},overwrite(t){return this.check(ur(t))},optional(){return Ie(this)},exactOptional(){return fA(this)},nullable(){return Hs(this)},nullish(){return Ie(Hs(this))},nonoptional(t){return AA(this,t)},array(){return ie(this)},or(t){return be([this,t])},and(t){return Ro(this,t)},transform(t){return df(this,Nf(t))},default(t){return hA(this,t)},prefault(t){return vA(this,t)},catch(t){return bA(this,t)},pipe(t){return df(this,t)},readonly(){return EA(this)},describe(t){let e=this.clone();return Ye.add(e,{description:t}),e},meta(...t){if(t.length===0)return Ye.get(this);let e=this.clone();return Ye.add(e,t[0]),e},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(t,...e){return e.length===0?t(this):t(this,...e)},get"~standard"(){return I.hide(this,"~standard",{...Vc(this),jsonSchema:{input:Eo(this,"input"),output:Eo(this,"output")}})},set"~standard"(t){I.own(this,"~standard",t)},parse:function t(e,r){return zv(this,e,r,{callee:t})},parseAsync:async function t(e,r){return await Pv(this,e,r,{callee:t})},safeParse(t,e){return Ov(this,t,e)},async safeParseAsync(t,e){return Rv(this,t,e)},get spa(){return this?.safeParseAsync},set spa(t){I.own(this,"spa",t)},validate(t,e){return Yi(this,t,e)},validateAsync(t,e){return Wi(this,t,e)},encode:function t(e,r){return jv(this,e,r,{callee:t})},decode:function t(e,r){return Bv(this,e,r,{callee:t})},encodeAsync:async function t(e,r){return await Uv(this,e,r,{callee:t})},decodeAsync:async function t(e,r){return await Mv(this,e,r,{callee:t})},safeEncode(t,e){return Lv(this,t,e)},safeDecode(t,e){return Fv(this,t,e)},async safeEncodeAsync(t,e){return Zv(this,t,e)},async safeDecodeAsync(t,e){return Qv(this,t,e)},toJSONSchema(t){return qg(this,{})(t)},get description(){return Ye.get(this)?.description},get _def(){return this._zod.def}}),ff=_("_ZodString",(t,e)=>{dn.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Gg(t,r,i,n)},I.derived({format:t=>Ze(t).format??null,minLength:t=>Ze(t).minimum??null,maxLength:t=>Ze(t).maximum??null},{regex(...t){return this.check(fo(...t))},includes(...t){return this.check(ho(...t))},startsWith(...t){return this.check(go(...t))},endsWith(...t){return this.check(vo(...t))},min(...t){return this.check(qr(...t))},max(...t){return this.check(Wn(...t))},length(...t){return this.check(ei(...t))},nonempty(...t){return this.check(qr(1,...t))},lowercase(t){return this.check(po(t))},uppercase(t){return this.check(mo(t))},trim(){return this.check(bo())},normalize(...t){return this.check(_o(...t))},toLowerCase(){return this.check($o())},toUpperCase(){return this.check(Io())},slugify(){return this.check(wo())}})),No=_("ZodString",(t,e)=>{dn.init(t,e),ff.init(t,e)},{email(t){return this.check(ys(pf,t))},url(t){return this.check(lo(Gs,t))},jwt(t){return this.check(Us(Cf,t))},emoji(t){return this.check(Es(hf,t))},guid(t){return this.check(_s(mf,t))},uuid(t){return this.check(bs(Sr,t))},uuidv4(t){return this.check($s(Sr,t))},uuidv6(t){return this.check(Is(Sr,t))},uuidv7(t){return this.check(ws(Sr,t))},nanoid(t){return this.check(xs(gf,t))},cuid(t){return this.check(Ss(vf,t))},cuid2(t){return this.check(ks(Af,t))},ulid(t){return this.check(Cs(yf,t))},base64(t){return this.check(Rs(xf,t))},base64url(t){return this.check(js(Sf,t))},xid(t){return this.check(Ds(_f,t))},ksuid(t){return this.check(Ts(bf,t))},ipv4(t){return this.check(Ns($f,t))},ipv6(t){return this.check(zs(If,t))},cidrv4(t){return this.check(Ps(wf,t))},cidrv6(t){return this.check(Os(Ef,t))},e164(t){return this.check(Bs(kf,t))},datetime(t){return this.check(Ms(bn,t))},date(t){return this.check(Ls($n,t))},time(t){return this.check(Fs(In,t))},duration(t){return this.check(Zs(wn,t))}});function $(t){return _d(No,t)}var we=_("ZodStringFormat",(t,e)=>{Ae.init(t,e),ff.init(t,e)}),bn=_("ZodISODateTime",(t,e)=>{yg.init(t,e),we.init(t,e)}),$n=_("ZodISODate",(t,e)=>{_g.init(t,e),we.init(t,e)}),In=_("ZodISOTime",(t,e)=>{bg.init(t,e),we.init(t,e)}),wn=_("ZodISODuration",(t,e)=>{$g.init(t,e),we.init(t,e)}),pf=_("ZodEmail",(t,e)=>{Jc.init(t,e),we.init(t,e)});function fw(t){return ys(pf,t)}var mf=_("ZodGUID",(t,e)=>{Hc.init(t,e),we.init(t,e)});function pw(t){return _s(mf,t)}var Sr=_("ZodUUID",(t,e)=>{Gc.init(t,e),we.init(t,e)});function mw(t){return bs(Sr,t)}function hw(t){return $s(Sr,t)}function gw(t){return Is(Sr,t)}function vw(t){return ws(Sr,t)}var Gs=_("ZodURL",(t,e)=>{Wc.init(t,e),we.init(t,e)});function Aw(t){return lo(Gs,t)}function yw(t){return lo(Gs,{protocol:ts,hostname:zh,...I.normalizeParams(t)})}var hf=_("ZodEmoji",(t,e)=>{el.init(t,e),we.init(t,e)});function _w(t){return Es(hf,t)}var gf=_("ZodNanoID",(t,e)=>{tl.init(t,e),we.init(t,e)});function bw(t){return xs(gf,t)}var vf=_("ZodCUID",(t,e)=>{rl.init(t,e),we.init(t,e)});function $w(t){return Ss(vf,t)}var Af=_("ZodCUID2",(t,e)=>{nl.init(t,e),we.init(t,e)});function Iw(t){return ks(Af,t)}var yf=_("ZodULID",(t,e)=>{il.init(t,e),we.init(t,e)});function ww(t){return Cs(yf,t)}var _f=_("ZodXID",(t,e)=>{ol.init(t,e),we.init(t,e)});function Ew(t){return Ds(_f,t)}var bf=_("ZodKSUID",(t,e)=>{al.init(t,e),we.init(t,e)});function xw(t){return Ts(bf,t)}var $f=_("ZodIPv4",(t,e)=>{sl.init(t,e),we.init(t,e)});function Sw(t){return Ns($f,t)}var qv=_("ZodMAC",(t,e)=>{cl.init(t,e),we.init(t,e)});function kw(t){return bd(qv,t)}var If=_("ZodIPv6",(t,e)=>{ul.init(t,e),we.init(t,e)});function Cw(t){return zs(If,t)}var wf=_("ZodCIDRv4",(t,e)=>{ll.init(t,e),we.init(t,e)});function Dw(t){return Ps(wf,t)}var Ef=_("ZodCIDRv6",(t,e)=>{fl.init(t,e),we.init(t,e)});function Tw(t){return Os(Ef,t)}var xf=_("ZodBase64",(t,e)=>{ml.init(t,e),we.init(t,e)});function Nw(t){return Rs(xf,t)}var Sf=_("ZodBase64URL",(t,e)=>{gl.init(t,e),we.init(t,e)});function zw(t){return js(Sf,t)}var kf=_("ZodE164",(t,e)=>{vl.init(t,e),we.init(t,e)});function Pw(t){return Bs(kf,t)}var Vv=_("ZodCreditCard",(t,e)=>{yl.init(t,e),we.init(t,e)});function Ow(t){return $d(Vv,t)}var Hv=_("ZodIBAN",(t,e)=>{bl.init(t,e),we.init(t,e)});function Rw(t){return Id(Hv,t)}var Cf=_("ZodJWT",(t,e)=>{Il.init(t,e),we.init(t,e)});function jw(t){return Us(Cf,t)}var ii=_("ZodCustomStringFormat",(t,e)=>{wl.init(t,e),we.init(t,e)});function Bw(t,e,r={}){return hn(ii,t,e,r)}function Uw(t){return hn(ii,"hostname",Nh,t)}function Mw(t){return hn(ii,"hex",Hh,t)}function Lw(t){return hn(ii,"currency_code",Oh,t)}function Fw(t,e){let r=e?.enc??"hex",i=`${t}_${r}`,n=Mt[i];if(!n)throw new Error(`Unrecognized hash format: ${i}`);return hn(ii,i,n,e)}var zo=_("ZodNumber",(t,e)=>{ls.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Jg(t,r,i,n),t.isFinite=!0},I.derived({minValue:t=>{let{minimum:e,exclusiveMinimum:r}=Ze(t);return Math.max(e??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:t=>{let{maximum:e,exclusiveMaximum:r}=Ze(t);return Math.min(e??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:t=>{let{isInt:e,multipleOf:r}=Ze(t);return!!e||!!r?.some(Number.isSafeInteger)},format:t=>Ze(t).format??null},{gt(t,e){return this.check(wr(t,e))},gte(t,e){return this.check(Ft(t,e))},min(t,e){return this.check(Ft(t,e))},lt(t,e){return this.check(Ir(t,e))},lte(t,e){return this.check(Lt(t,e))},max(t,e){return this.check(Lt(t,e))},int(t){return this.check(lf(t))},safe(t){return this.check(lf(t))},positive(t){return this.check(wr(0,t))},nonnegative(t){return this.check(Ft(0,t))},negative(t){return this.check(Ir(0,t))},nonpositive(t){return this.check(Lt(0,t))},multipleOf(t,e){return this.check(pn(t,e))},step(t,e){return this.check(pn(t,e))},finite(){return this}}));function ge(t){return wd(zo,t)}var oi=_("ZodNumberFormat",(t,e)=>{El.init(t,e),zo.init(t,e)});function lf(t){return Ed(oi,t)}function Zw(t){return xd(oi,t)}function Qw(t){return Sd(oi,t)}function qw(t){return kd(oi,t)}function Vw(t){return Cd(oi,t)}var Po=_("ZodBoolean",(t,e)=>{ro.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Kg(t,r,i,n)});function je(t){return Dd(Po,t)}var Oo=_("ZodBigInt",(t,e)=>{ds.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Xg(t,r,i,n)},I.derived({minValue:t=>Ze(t).minimum??null,maxValue:t=>Ze(t).maximum??null,format:t=>Ze(t).format??null},{gte(t,e){return this.check(Ft(t,e))},min(t,e){return this.check(Ft(t,e))},gt(t,e){return this.check(wr(t,e))},lt(t,e){return this.check(Ir(t,e))},lte(t,e){return this.check(Lt(t,e))},max(t,e){return this.check(Lt(t,e))},positive(t){return this.check(wr(BigInt(0),t))},negative(t){return this.check(Ir(BigInt(0),t))},nonpositive(t){return this.check(Lt(BigInt(0),t))},nonnegative(t){return this.check(Ft(BigInt(0),t))},multipleOf(t,e){return this.check(pn(t,e))}}));function Hw(t){return Td(Oo,t)}var Df=_("ZodBigIntFormat",(t,e)=>{xl.init(t,e),Oo.init(t,e)});function Gw(t){return Nd(Df,t)}function Jw(t){return zd(Df,t)}var Gv=_("ZodSymbol",(t,e)=>{Sl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Yg(t,r,i,n)});function Kw(t){return Pd(Gv,t)}var Jv=_("ZodUndefined",(t,e)=>{kl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>ev(t,r,i,n)});function Xw(t){return Od(Jv,t)}var Kv=_("ZodNull",(t,e)=>{Cl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Wg(t,r,i,n)});function Js(t){return Rd(Kv,t)}var Xv=_("ZodAny",(t,e)=>{Dl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>nv(t,r,i,n)});function Yw(){return jd(Xv)}var Yv=_("ZodUnknown",(t,e)=>{Tl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>iv(t,r,i,n)});function ke(){return Bd(Yv)}var Wv=_("ZodNever",(t,e)=>{Nl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>rv(t,r,i,n)});function Tf(t){return Ud(Wv,t)}var eA=_("ZodVoid",(t,e)=>{zl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>tv(t,r,i,n)});function Ww(t){return Md(eA,t)}var Ks=_("ZodDate",(t,e)=>{Pl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>ov(t,r,i,n),t.min=(r,i)=>t.check(Ft(r,i)),t.max=(r,i)=>t.check(Lt(r,i))},I.derived({minDate:t=>{let{minimum:e}=Ze(t);return e?new Date(e):null},maxDate:t=>{let{maximum:e}=Ze(t);return e?new Date(e):null}},{}));function eE(t){return Ld(Ks,t)}var tA=_("ZodArray",(t,e)=>{ni(),Ol.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>vv(t,r,i,n),t.element=e.element},{min(t,e){return this.check(qr(t,e))},nonempty(t){return this.check(qr(1,t))},max(t,e){return this.check(Wn(t,e))},length(t,e){return this.check(ei(t,e))},unwrap(){return this.element}});function ie(t,e){return Zg(tA,t,e)}function tE(t){let e=t._zod.def.shape;return et(Object.keys(e))}var Xs=_("ZodObject",(t,e)=>{ni(),wg.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Av(t,r,i,n),I.installLazyProp(t,"shape",r=>r._zod.def.shape,!1)},{keyof(){return et(Object.keys(this._zod.def.shape))},catchall(t){return this.clone(I.mergeDefs(this._zod.def,{catchall:t}))},passthrough(){return this.clone(I.mergeDefs(this._zod.def,{catchall:ke()}))},loose(){return this.clone(I.mergeDefs(this._zod.def,{catchall:ke()}))},strict(){return this.clone(I.mergeDefs(this._zod.def,{catchall:Tf()}))},strip(){return this.clone(I.mergeDefs(this._zod.def,{catchall:void 0}))},extend(t){return I.extend(this,t)},safeExtend(t){return I.safeExtend(this,t)},merge(t){return I.merge(this,t)},pick(t){return I.pick(this,t)},omit(t){return I.omit(this,t)},partial(...t){return I.partial(ai,this,t[0])},exactPartial(...t){return I.partial(zf,this,t[0],"exactPartial")},required(...t){return I.required(Pf,this,t[0])}});function O(t,e){let r={type:"object",shape:t??{},...I.normalizeParams(e)};return new Xs(r)}function rE(t,e){return new Xs({type:"object",shape:t,catchall:Tf(),...I.normalizeParams(e)})}function We(t,e){return new Xs({type:"object",shape:t,catchall:ke(),...I.normalizeParams(e)})}var Ys=_("ZodUnion",(t,e)=>{no.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>rf(t,r,i,n),t.options=e.options});function be(t,e){return new Ys({type:"union",options:t,...I.normalizeParams(e)})}var rA=_("ZodXor",(t,e)=>{Ys.init(t,e),jl.init(t,e),t._zod.processJSONSchema=(r,i,n)=>rf(t,r,i,n),t.options=e.options});function nE(t,e){return new rA({type:"union",options:t,inclusive:!1,...I.normalizeParams(e)})}var nA=_("ZodDiscriminatedUnion",(t,e)=>{Ys.init(t,e),Bl.init(t,e)});function Ws(t,e,r){return new nA({type:"union",options:e,discriminator:t,...I.normalizeParams(r)})}var iA=_("ZodIntersection",(t,e)=>{Ul.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>yv(t,r,i,n)});function Ro(t,e){return new iA({type:"intersection",left:t,right:e})}var oA=_("ZodTuple",(t,e)=>{ni(),fs.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>_v(t,r,i,n)},{rest(t){return this.clone({...this._zod.def,rest:t})},partial(){let t=this._zod.def;if(t.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...t,items:t.items.map(e=>new ai({type:"optional",innerType:e}))})}});function aA(t,e,r){let i=e instanceof G,n=i?r:e,o=i?e:null;return new oA({type:"tuple",items:t,rest:o,...I.normalizeParams(n)})}var Do=_("ZodRecord",(t,e)=>{ni(),Ml.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>bv(t,r,i,n),t.keyType=e.keyType,t.valueType=e.valueType});function Ee(t,e,r){return!e||!e._zod?new Do({type:"record",keyType:$(),valueType:t,...I.normalizeParams(e)}):new Do({type:"record",keyType:t,valueType:e,...I.normalizeParams(r)})}function iE(t,e,r){return new Do({type:"record",keyType:t,valueType:e,...I.normalizeParams(r),partial:!0})}function oE(t,e,r){return new Do({type:"record",keyType:t,valueType:e,mode:"loose",...I.normalizeParams(r)})}var sA=_("ZodMap",(t,e)=>{ni(),Ll.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>hv(t,r,i,n),t.keyType=e.keyType,t.valueType=e.valueType,t.min=(...r)=>t.check(Er(...r)),t.nonempty=r=>t.check(Er(1,r)),t.max=(...r)=>t.check(mn(...r)),t.size=(...r)=>t.check(Yn(...r))});function aE(t,e,r){return new sA({type:"map",keyType:t,valueType:e,...I.normalizeParams(r)})}var uA=_("ZodSet",(t,e)=>{ni(),Fl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>gv(t,r,i,n),t.min=(...r)=>t.check(Er(...r)),t.nonempty=r=>t.check(Er(1,r)),t.max=(...r)=>t.check(mn(...r)),t.size=(...r)=>t.check(Yn(...r))});function sE(t,e){return new uA({type:"set",valueType:t,...I.normalizeParams(e)})}var To=_("ZodEnum",(t,e)=>{Zl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(i,n,o)=>av(t,i,n,o),t.enum=e.entries,t.options=[...t._zod.values];let r=new Set(Object.keys(e.entries));t.extract=(i,n)=>{let o={};for(let a of i)if(r.has(a))o[a]=e.entries[a];else throw new Error(`Key ${a} not found in enum`);return new To({...e,checks:[],...I.normalizeParams(n),entries:o})},t.exclude=(i,n)=>{let o={...e.entries};for(let a of i)if(r.has(a))delete o[a];else throw new Error(`Key ${a} not found in enum`);return new To({...e,checks:[],...I.normalizeParams(n),entries:o})}});function et(t,e){let r=Array.isArray(t)?Object.fromEntries(t.map(i=>[i,i])):t;return new To({type:"enum",entries:r,...I.normalizeParams(e)})}function uE(t,e){return new To({type:"enum",entries:t,...I.normalizeParams(e)})}var cA=_("ZodLiteral",(t,e)=>{Ql.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>sv(t,r,i,n),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function M(t,e){return new cA({type:"literal",values:Array.isArray(t)?t:[t],...I.normalizeParams(e)})}var lA=_("ZodFile",(t,e)=>{ql.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>lv(t,r,i,n),t.min=(r,i)=>t.check(Er(r,i)),t.max=(r,i)=>t.check(mn(r,i)),t.mime=(r,i)=>t.check(yo(Array.isArray(r)?r:[r],i))});function cE(t){return Gd(lA,t)}var dA=_("ZodTransform",(t,e)=>{ni(),Vl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>mv(t,r,i,n),t._zod.parse=(r,i)=>{if(i.direction==="backward")throw new ln(t.constructor.name);r.addIssue=o=>{if(typeof o=="string")r.issues.push(I.issue(o,r.value,e));else{let a=o;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),"input"in a||(a.input=r.value),a.inst??(a.inst=t),r.issues.push(I.issue(a))}};let n=e.transform(r.value,r);return n instanceof Promise?n.then(o=>(r.value=o,r)):(r.value=n,r)}});function Nf(t){return new dA({type:"transform",transform:t})}var ai=_("ZodOptional",(t,e)=>{ps.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>nf(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});function Ie(t){return new ai({type:"optional",innerType:t})}var zf=_("ZodExactOptional",(t,e)=>{Hl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>nf(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});function fA(t){return new zf({type:"optional",innerType:t})}var pA=_("ZodNullable",(t,e)=>{Gl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>$v(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});function Hs(t){return new pA({type:"nullable",innerType:t})}function lE(t){return Ie(Hs(t))}var mA=_("ZodDefault",(t,e)=>{Jl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Ev(t,r,i,n),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function hA(t,e){return new mA({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():I.shallowClone(e)}})}var gA=_("ZodPrefault",(t,e)=>{Kl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>xv(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});function vA(t,e){return new gA({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():I.shallowClone(e)}})}var Pf=_("ZodNonOptional",(t,e)=>{Xl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Iv(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});function AA(t,e){return new Pf({type:"nonoptional",innerType:t,...I.normalizeParams(e)})}var yA=_("ZodSuccess",(t,e)=>{Yl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>dv(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});function dE(t){return new yA({type:"success",innerType:t})}var _A=_("ZodCatch",(t,e)=>{Wl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Sv(t,r,i,n),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function bA(t,e){return new _A({type:"catch",innerType:t,catchValue:typeof e=="function"?e:I.constantCatch(e)})}var $A=_("ZodNaN",(t,e)=>{ed.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>uv(t,r,i,n)});function fE(t){return Fd($A,t)}var eu=_("ZodPipe",(t,e)=>{ms.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>kv(t,r,i,n),t.in=e.in,t.out=e.out});function df(t,e){return new eu({type:"pipe",in:t,out:e})}var tu=_("ZodCodec",(t,e)=>{eu.init(t,e),io.init(t,e)});function pE(t,e,r){return new tu({type:"pipe",in:t,out:e,transform:r.decode,reverseTransform:r.encode})}function mE(t){let e=t._zod.def;return new tu({type:"pipe",in:e.out,out:e.in,transform:e.reverseTransform,reverseTransform:e.transform})}var IA=_("ZodPreprocess",(t,e)=>{eu.init(t,e),xg.init(t,e)}),wA=_("ZodReadonly",(t,e)=>{td.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Cv(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});function EA(t){return new wA({type:"readonly",innerType:t})}var xA=_("ZodTemplateLiteral",(t,e)=>{rd.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>cv(t,r,i,n)});function hE(t,e){return new xA({type:"template_literal",parts:t,...I.normalizeParams(e)})}var SA=_("ZodLazy",(t,e)=>{oo.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Tv(t,r,i,n),t.unwrap=()=>t._zod.def.getter()});function kA(t){return new SA({type:"lazy",getter:t})}var CA=_("ZodPromise",(t,e)=>{id.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Dv(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});function gE(t){return new CA({type:"promise",innerType:t})}var DA=_("ZodFunction",(t,e)=>{nd.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>pv(t,r,i,n)});function vE(t){return new DA({type:"function",input:Array.isArray(t?.input)?aA(t?.input):t?.input??ie(ke()),output:t?.output??ke()})}var ru=_("ZodCustom",(t,e)=>{od.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>fv(t,r,i,n)});function AE(t){let e=new $e({check:"custom"});return e._zod.check=t,e}function Of(t,e){return Jd(ru,t??(()=>!0),e)}function TA(t,e={}){return Kd(ru,t,e)}function NA(t,e){return Xd(t,e)}var yE=Yd,_E=Wd,zA=_("ZodInstanceOf",(t,e)=>{ru.init(t,e)},{properties(t,e){return this.check(Ao(t,e))}});function bE(t,e={}){let r=new zA({type:"custom",check:"custom",fn:i=>i instanceof t,abort:!0,...I.normalizeParams(e)});return r._zod.bag.Class=t,r._zod.check=i=>{i.value instanceof t||i.issues.push({code:"invalid_type",expected:t.name,input:i.value,inst:r,path:[...r._zod.def.path??[]]})},r}var $E=(...t)=>ef({Codec:tu,Boolean:Po,String:No},...t);function IE(t){let e=kA(()=>be([$(t),ge(),je(),Js(),ie(e),Ee($(),e)]));return e}function nu(t,e){return new IA({type:"pipe",in:Nf(t),out:e})}var LO={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function FO(t){Re({customError:t})}function ZO(){return Re().customError}var PA;PA||(PA={});var si={};jr(si,{ZodISODate:()=>$n,ZodISODateTime:()=>bn,ZodISODuration:()=>wn,ZodISOTime:()=>In,date:()=>qO,datetime:()=>QO,duration:()=>HO,time:()=>VO});function QO(t){return Ms(bn,t)}function qO(t){return Ls($n,t)}function VO(t){return Fs(In,t)}function HO(t){return Zs(wn,t)}var P={...jo,...uf,iso:si},GO=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function JO(t,e){let r=t.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":e??"draft-2020-12"}function wE(t,e){return t.map((r,i)=>i<e?r:r.optional())}function KO(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}function XO(t,e){if(!t.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let r=t.slice(1).split("/").filter(Boolean);if(r.length===0)return e.rootSchema;let i=e.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===i){let n=r[1]===void 0?void 0:KO(r[1]);if(!n||!e.defs[n])throw new Error(`Reference not found: ${t}`);return e.defs[n]}throw new Error(`Reference not found: ${t}`)}function YO(t,e){return P.transform(i=>i).check(i=>{let n=i.value;if(typeof n!="object"||n===null||Array.isArray(n))return;let o=Object.getOwnPropertyNames(n);if(e.minProperties!==void 0&&o.length<e.minProperties&&i.issues.push({origin:"object",code:"too_small",minimum:e.minProperties,inclusive:!0,message:`Too small: expected object to have >=${e.minProperties} properties`,input:n,inst:t,continue:!0}),e.maxProperties!==void 0&&o.length>e.maxProperties&&i.issues.push({origin:"object",code:"too_big",maximum:e.maxProperties,inclusive:!0,message:`Too big: expected object to have <=${e.maxProperties} properties`,input:n,inst:t,continue:!0}),e.keySchema)for(let a of o){let s=e.keySchema.safeParse(a);s.success||i.issues.push({code:"invalid_key",origin:"record",issues:s.error.issues,input:a,path:[a],continue:!0})}}).pipe(t)}function OA(t,e){if(t===null)return"z";let r=typeof t;if(r!=="object"){if(r==="number"&&Number.isNaN(t))return null;let i=String(t);return`${r[0]}${i.length}:${i}`}if(e.has(t))return null;e.add(t);try{if(Array.isArray(t)){let o=[];for(let a of t){let s=OA(a,e);if(s===null)return null;o.push(s)}return`a${o.length}:[${o.join(",")}]`}let i=Object.keys(t).sort(),n=[];for(let o of i){let a=OA(t[o],e);if(a===null)return null;n.push(`${o.length}:${o}=${a}`)}return`o${n.length}:{${n.join(",")}}`}finally{e.delete(t)}}var WO=new Set(["items","prefixItems","additionalItems","additionalProperties","contains","propertyNames","not","if","then","else","allOf","anyOf","oneOf","unevaluatedItems","unevaluatedProperties","contentSchema"]),eR=new Set(["properties","patternProperties","dependentSchemas","dependencies","$defs","definitions"]);function iu(t){return typeof t!="object"||t===null?!1:Array.isArray(t)?t.some(iu):typeof t.$ref=="string"?!0:Object.entries(t).some(([e,r])=>WO.has(e)?iu(r):!eR.has(e)||typeof r!="object"||r===null?!1:Object.values(r).some(iu))}function EE(t){return t===1?"element":"elements"}function tR(t,e){return P.transform(i=>i).check(i=>{let n=i.value;if(Array.isArray(n)){if(e.uniqueItems===!0){let o=new Map;for(let a=0;a<n.length;a++){let s=OA(n[a],new Set);if(s===null)continue;let u=o.get(s);if(u===void 0){o.set(s,a);continue}i.issues.push({code:"custom",message:`Array items must be unique: element at index ${a} duplicates the one at index ${u}`,input:n,path:[a],continue:!0})}}if(e.containsSchema){let o=e.minContains??1,a=e.maxContains!==void 0?e.maxContains+1:Number.POSITIVE_INFINITY,s=0;for(let u of n)if(e.containsSchema.safeParse(u).success&&++s>=a)break;s<o&&i.issues.push({code:"custom",message:`Array must contain at least ${o} matching ${EE(o)}; found ${s}`,input:n,continue:!0}),e.maxContains!==void 0&&s>e.maxContains&&i.issues.push({code:"custom",message:`Array must contain at most ${e.maxContains} matching ${EE(e.maxContains)}`,input:n,continue:!0})}}}).pipe(t)}function xE(t,e){if(t!==!1)return t===void 0||t===!0?P.any():At(t,e)}var rR=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function SE(t,e){if(t.not!==void 0){if(typeof t.not=="object"&&Object.keys(t.not).length===0)return P.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(t.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(t.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(t.if!==void 0||t.then!==void 0||t.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(t.dependentSchemas!==void 0||t.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(t.$ref){let n=t.$ref;if(e.refs.has(n))return e.refs.get(n);if(e.processing.has(n))return P.lazy(()=>{if(!e.refs.has(n))throw new Error(`Circular reference not resolved: ${n}`);return e.refs.get(n)});e.processing.add(n);let o=XO(n,e),a=At(o,e);return e.refs.set(n,a),e.processing.delete(n),a}if(t.enum!==void 0){let n=t.enum;if(e.version==="openapi-3.0"&&t.nullable===!0&&n.length===1&&n[0]===null)return P.null();if(n.length===0)return P.never();if(n.length===1)return P.literal(n[0]);if(n.every(a=>typeof a=="string"))return P.enum(n);let o=n.map(a=>P.literal(a));return o.length<2?o[0]:P.union([o[0],o[1],...o.slice(2)])}if(t.const!==void 0)return P.literal(t.const);let r=t.type;if(Array.isArray(r)){let n=r.map(o=>{let a={...t,type:o};return SE(a,e)});return n.length===0?P.never():n.length===1?n[0]:P.union(n)}if(!r)return P.any();let i;switch(r){case"string":{let n=P.string();if(t.format){let o=t.format;o==="email"?n=n.check(P.email()):o==="uri"||o==="uri-reference"?n=n.check(P.url()):o==="uuid"||o==="guid"?n=n.check(P.uuid()):o==="date-time"?n=n.check(P.iso.datetime({offset:!0})):o==="date"?n=n.check(P.iso.date()):o==="time"?n=n.check(P.regex(rR)):o==="duration"?n=n.check(P.iso.duration()):o==="hostname"?n=n.check(P.hostname()):o==="ipv4"?n=n.check(P.ipv4()):o==="ipv6"?n=n.check(P.ipv6()):o==="mac"?n=n.check(P.mac()):o==="cidr"?n=n.check(P.cidrv4()):o==="cidr-v6"?n=n.check(P.cidrv6()):o==="base64"?n=n.check(P.base64()):o==="base64url"?n=n.check(P.base64url()):o==="e164"?n=n.check(P.e164()):o==="credit_card"?n=n.check(P.creditCard()):o==="iban"?n=n.check(P.iban()):o==="jwt"?n=n.check(P.jwt()):o==="emoji"?n=n.check(P.emoji()):o==="nanoid"?n=n.check(P.nanoid()):o==="cuid"?n=n.check(P.cuid()):o==="cuid2"?n=n.check(P.cuid2()):o==="ulid"?n=n.check(P.ulid()):o==="xid"?n=n.check(P.xid()):o==="ksuid"&&(n=n.check(P.ksuid()))}typeof t.minLength=="number"&&(n=n.min(t.minLength)),typeof t.maxLength=="number"&&(n=n.max(t.maxLength)),t.pattern&&(n=n.regex(new RegExp(t.pattern))),i=n;break}case"number":case"integer":{let n=r==="integer"?P.number().int():P.number();typeof t.minimum=="number"&&t.exclusiveMinimum!==!0&&(n=n.min(t.minimum)),typeof t.maximum=="number"&&t.exclusiveMaximum!==!0&&(n=n.max(t.maximum)),typeof t.exclusiveMinimum=="number"?n=n.gt(t.exclusiveMinimum):t.exclusiveMinimum===!0&&typeof t.minimum=="number"&&(n=n.gt(t.minimum)),typeof t.exclusiveMaximum=="number"?n=n.lt(t.exclusiveMaximum):t.exclusiveMaximum===!0&&typeof t.maximum=="number"&&(n=n.lt(t.maximum)),typeof t.multipleOf=="number"&&(n=n.multipleOf(t.multipleOf)),i=n;break}case"boolean":{i=P.boolean();break}case"null":{i=P.null();break}case"object":{let n={},o=t.properties||{},a=new Set(t.required||[]),s=typeof t.additionalProperties=="object"?At(t.additionalProperties,e):void 0;for(let[d,p]of Object.entries(o)){let m=At(p,e);Xe(n,d,a.has(d)?m:m.optional())}if(t.patternProperties){let d=t.patternProperties,p=Object.keys(d),m=[];for(let f of p){let g=At(d[f],e),y=P.string().regex(new RegExp(f));m.push(P.looseRecord(y,g))}let h=[];if(Object.keys(n).length>0&&h.push(P.object(n).passthrough()),h.push(...m),h.length===0)i=P.object({}).passthrough();else if(h.length===1)i=h[0];else{let f=P.intersection(h[0],h[1]);for(let g=2;g<h.length;g++)f=P.intersection(f,h[g]);i=f}if(t.additionalProperties===!1){let f=Object.keys(n),g=p.map(v=>new RegExp(v)),y=i;i=i.check(v=>{if(!Jt(v.value))return;let A=[];for(let x of Object.keys(v.value))f.includes(x)||g.some(k=>k.test(x))||A.push(x);A.length&&v.issues.push({code:"unrecognized_keys",keys:A,input:v.value,inst:y})})}}else{let d=P.object(n);t.additionalProperties===!1?i=d.strict():s?i=d.catchall(s):i=d.passthrough()}let u=t.propertyNames!==void 0&&t.propertyNames!==!0,c=typeof t.minProperties=="number"?t.minProperties:void 0,l=typeof t.maxProperties=="number"?t.maxProperties:void 0;if(u||c!==void 0||l!==void 0){let d;if(u){let p=typeof t.propertyNames=="object"&&t.propertyNames.type===void 0?{type:"string",...t.propertyNames}:t.propertyNames;d=At(p,e)}i=YO(i,{keySchema:d,minProperties:c,maxProperties:l})}break}case"array":{let n=t.prefixItems,o=t.items;if(n&&Array.isArray(n)){let a=typeof t.minItems=="number"?t.minItems:0,s=n.map(d=>At(d,e)),u=wE(s,a),c=Array.isArray(o)?void 0:xE(o,e),l=P.tuple(u);i=c?l.rest(c):l,typeof t.minItems=="number"&&(i=i.check(P.minLength(t.minItems))),typeof t.maxItems=="number"&&(i=i.check(P.maxLength(t.maxItems)))}else if(Array.isArray(o)){let a=typeof t.minItems=="number"?t.minItems:0,s=o.map(d=>At(d,e)),u=wE(s,a),c=xE(t.additionalItems,e),l=P.tuple(u);i=c?l.rest(c):l,typeof t.minItems=="number"&&(i=i.check(P.minLength(t.minItems))),typeof t.maxItems=="number"&&(i=i.check(P.maxLength(t.maxItems)))}else if(o!==void 0){let a=At(o,e),s=P.array(a);typeof t.minItems=="number"&&(s=s.min(t.minItems)),typeof t.maxItems=="number"&&(s=s.max(t.maxItems)),i=s}else i=P.array(P.any());(t.uniqueItems===!0||t.contains!==void 0)&&(i=tR(i,{uniqueItems:t.uniqueItems===!0,containsSchema:t.contains!==void 0?At(t.contains,e):void 0,minContains:typeof t.minContains=="number"?t.minContains:void 0,maxContains:typeof t.maxContains=="number"?t.maxContains:void 0}));break}default:throw new Error(`Unsupported type: ${r}`)}return i}function At(t,e){if(typeof t=="boolean")return t?P.any():P.never();let r=SE(t,e),i=t.type||t.enum!==void 0||t.const!==void 0;if(t.anyOf&&Array.isArray(t.anyOf)){let s=t.anyOf.map(c=>At(c,e)),u=P.union(s);r=i?P.intersection(r,u):u}if(t.oneOf&&Array.isArray(t.oneOf)){let s=t.oneOf.map(c=>At(c,e)),u=P.xor(s);r=i?P.intersection(r,u):u}if(t.allOf&&Array.isArray(t.allOf))if(t.allOf.length===0)r=i?r:P.any();else{let s=i?r:At(t.allOf[0],e),u=i?0:1;for(let c=u;c<t.allOf.length;c++)s=P.intersection(s,At(t.allOf[c],e));r=s}t.nullable===!0&&e.version==="openapi-3.0"&&(r=P.nullable(r)),t.readOnly===!0&&(r=P.readonly(r)),t.default!==void 0&&(r=r.default(t.default));let n={},o=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let s of o)s in t&&(n[s]=t[s]);let a=["contentEncoding","contentMediaType","contentSchema"];for(let s of a)s in t&&(n[s]=t[s]);if(t.type==="object"&&t.$ref===void 0){t.propertyNames!==void 0&&!iu(t.propertyNames)&&(n.propertyNames=t.propertyNames);for(let s of["minProperties","maxProperties"])t[s]!==void 0&&(n[s]=t[s])}if(t.type==="array"&&t.$ref===void 0){t.contains!==void 0&&!iu(t.contains)&&(n.contains=t.contains);for(let s of["uniqueItems","minContains","maxContains"])t[s]!==void 0&&(n[s]=t[s])}for(let s of Object.keys(t))GO.has(s)||Xe(n,s,t[s]);return Object.keys(n).length>0&&e.registry.add(r,n),t.description&&(r=r.describe(t.description)),r}function kE(t,e){if(typeof t=="boolean")return t?P.any():P.never();let r;try{r=JSON.parse(JSON.stringify(t))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let i=JO(r,e?.defaultTarget),n=r.$defs||r.definitions||{},o={version:i,defs:n,refs:new Map,processing:new Set,rootSchema:r,registry:e?.registry??Ye};return At(r,o)}function CE(t){return Vs(t,{object:e=>e.partial(),union:e=>{let r=e._zod.def;return r.discriminator===void 0?e:be(r.options)}})}function nR(t,e){if(!e?.length)return t;let r=t._zod.def;return he(t,Gt(r,{checks:[...r.checks??[],...e]}),{parent:!0})}function DE(t){return nR(t.out,t.checks)}function iR(t){return t.in._zod.traits.has("$ZodTransform")?DE(t):t.in}function TE(t){return Vs(t,{pipe:e=>iR(e._zod.def),default:(e,r)=>r?Ie(e._zod.def.innerType):e,catch:(e,r)=>r?e._zod.def.innerType:e})}function NE(t){return Vs(t,{pipe:e=>DE(e._zod.def),prefault:(e,r)=>r?e._zod.def.innerType:e})}var RA={};jr(RA,{bigint:()=>uR,boolean:()=>sR,date:()=>cR,number:()=>aR,string:()=>oR});function oR(t){return jg(No,t)}function aR(t){return Ug(zo,t)}function sR(t){return Mg(Po,t)}function uR(t){return Lg(Oo,t)}function cR(t){return Fg(Ks,t)}var BA="2025-11-25";var zE=[BA,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],En="io.modelcontextprotocol/related-task",jf="2.0",Qe=Of(t=>t!==null&&(typeof t=="object"||typeof t=="function")),PE=be([$(),ge().int()]),OE=$(),mH=We({ttl:ge().optional(),pollInterval:ge().optional()}),lR=O({ttl:ge().optional()}),dR=O({taskId:$()}),UA=We({progressToken:PE.optional(),[En]:dR.optional()}),Zt=O({_meta:UA.optional()}),ou=Zt.extend({task:lR.optional()}),RE=t=>ou.safeParse(t).success,tt=O({method:$(),params:Zt.loose().optional()}),Xt=O({_meta:UA.optional()}),Yt=O({method:$(),params:Xt.loose().optional()}),rt=We({_meta:UA.optional()}),Bf=be([$(),ge().int()]),jE=O({jsonrpc:M(jf),id:Bf,...tt.shape}).strict(),MA=t=>jE.safeParse(t).success,BE=O({jsonrpc:M(jf),...Yt.shape}).strict(),UE=t=>BE.safeParse(t).success,LA=O({jsonrpc:M(jf),id:Bf,result:rt}).strict(),au=t=>LA.safeParse(t).success;var F;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(F||(F={}));var FA=O({jsonrpc:M(jf),id:Bf.optional(),error:O({code:ge().int(),message:$(),data:ke().optional()})}).strict();var ME=t=>FA.safeParse(t).success;var LE=be([jE,BE,LA,FA]),hH=be([LA,FA]),Uf=rt.strict(),fR=Xt.extend({requestId:Bf.optional(),reason:$().optional()}),Mf=Yt.extend({method:M("notifications/cancelled"),params:fR}),pR=O({src:$(),mimeType:$().optional(),sizes:ie($()).optional(),theme:et(["light","dark"]).optional()}),su=O({icons:ie(pR).optional()}),Bo=O({name:$(),title:$().optional()}),FE=Bo.extend({...Bo.shape,...su.shape,version:$(),websiteUrl:$().optional(),description:$().optional()}),mR=Ro(O({applyDefaults:je().optional()}),Ee($(),ke())),hR=nu(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,Ro(O({form:mR.optional(),url:Qe.optional()}),Ee($(),ke()).optional())),gR=We({list:Qe.optional(),cancel:Qe.optional(),requests:We({sampling:We({createMessage:Qe.optional()}).optional(),elicitation:We({create:Qe.optional()}).optional()}).optional()}),vR=We({list:Qe.optional(),cancel:Qe.optional(),requests:We({tools:We({call:Qe.optional()}).optional()}).optional()}),AR=O({experimental:Ee($(),Qe).optional(),sampling:O({context:Qe.optional(),tools:Qe.optional()}).optional(),elicitation:hR.optional(),roots:O({listChanged:je().optional()}).optional(),tasks:gR.optional(),extensions:Ee($(),Qe).optional()}),yR=Zt.extend({protocolVersion:$(),capabilities:AR,clientInfo:FE}),ZA=tt.extend({method:M("initialize"),params:yR});var _R=O({experimental:Ee($(),Qe).optional(),logging:Qe.optional(),completions:Qe.optional(),prompts:O({listChanged:je().optional()}).optional(),resources:O({subscribe:je().optional(),listChanged:je().optional()}).optional(),tools:O({listChanged:je().optional()}).optional(),tasks:vR.optional(),extensions:Ee($(),Qe).optional()}),bR=rt.extend({protocolVersion:$(),capabilities:_R,serverInfo:FE,instructions:$().optional()}),QA=Yt.extend({method:M("notifications/initialized"),params:Xt.optional()});var Lf=tt.extend({method:M("ping"),params:Zt.optional()}),$R=O({progress:ge(),total:Ie(ge()),message:Ie($())}),IR=O({...Xt.shape,...$R.shape,progressToken:PE}),Ff=Yt.extend({method:M("notifications/progress"),params:IR}),wR=Zt.extend({cursor:OE.optional()}),uu=tt.extend({params:wR.optional()}),cu=rt.extend({nextCursor:OE.optional()}),ER=et(["working","input_required","completed","failed","cancelled"]),lu=O({taskId:$(),status:ER,ttl:be([ge(),Js()]),createdAt:$(),lastUpdatedAt:$(),pollInterval:Ie(ge()),statusMessage:Ie($())}),Uo=rt.extend({task:lu}),xR=Xt.merge(lu),du=Yt.extend({method:M("notifications/tasks/status"),params:xR}),Zf=tt.extend({method:M("tasks/get"),params:Zt.extend({taskId:$()})}),Qf=rt.merge(lu),qf=tt.extend({method:M("tasks/result"),params:Zt.extend({taskId:$()})}),gH=rt.loose(),Vf=uu.extend({method:M("tasks/list")}),Hf=cu.extend({tasks:ie(lu)}),Gf=tt.extend({method:M("tasks/cancel"),params:Zt.extend({taskId:$()})}),ZE=rt.merge(lu),QE=O({uri:$(),mimeType:Ie($()),_meta:Ee($(),ke()).optional()}),qE=QE.extend({text:$()}),qA=$().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),VE=QE.extend({blob:qA}),fu=et(["user","assistant"]),Mo=O({audience:ie(fu).optional(),priority:ge().min(0).max(1).optional(),lastModified:si.datetime({offset:!0}).optional()}),HE=O({...Bo.shape,...su.shape,uri:$(),description:Ie($()),mimeType:Ie($()),size:Ie(ge()),annotations:Mo.optional(),_meta:Ie(We({}))}),SR=O({...Bo.shape,...su.shape,uriTemplate:$(),description:Ie($()),mimeType:Ie($()),annotations:Mo.optional(),_meta:Ie(We({}))}),Jf=uu.extend({method:M("resources/list")}),kR=cu.extend({resources:ie(HE)}),Kf=uu.extend({method:M("resources/templates/list")}),CR=cu.extend({resourceTemplates:ie(SR)}),VA=Zt.extend({uri:$()}),DR=VA,Xf=tt.extend({method:M("resources/read"),params:DR}),TR=rt.extend({contents:ie(be([qE,VE]))}),NR=Yt.extend({method:M("notifications/resources/list_changed"),params:Xt.optional()}),zR=VA,PR=tt.extend({method:M("resources/subscribe"),params:zR}),OR=VA,RR=tt.extend({method:M("resources/unsubscribe"),params:OR}),jR=Xt.extend({uri:$()}),BR=Yt.extend({method:M("notifications/resources/updated"),params:jR}),UR=O({name:$(),description:Ie($()),required:Ie(je())}),MR=O({...Bo.shape,...su.shape,description:Ie($()),arguments:Ie(ie(UR)),_meta:Ie(We({}))}),Yf=uu.extend({method:M("prompts/list")}),LR=cu.extend({prompts:ie(MR)}),FR=Zt.extend({name:$(),arguments:Ee($(),$()).optional()}),Wf=tt.extend({method:M("prompts/get"),params:FR}),HA=O({type:M("text"),text:$(),annotations:Mo.optional(),_meta:Ee($(),ke()).optional()}),GA=O({type:M("image"),data:qA,mimeType:$(),annotations:Mo.optional(),_meta:Ee($(),ke()).optional()}),JA=O({type:M("audio"),data:qA,mimeType:$(),annotations:Mo.optional(),_meta:Ee($(),ke()).optional()}),ZR=O({type:M("tool_use"),name:$(),id:$(),input:Ee($(),ke()),_meta:Ee($(),ke()).optional()}),QR=O({type:M("resource"),resource:be([qE,VE]),annotations:Mo.optional(),_meta:Ee($(),ke()).optional()}),qR=HE.extend({type:M("resource_link")}),KA=be([HA,GA,JA,qR,QR]),VR=O({role:fu,content:KA}),HR=rt.extend({description:$().optional(),messages:ie(VR)}),GR=Yt.extend({method:M("notifications/prompts/list_changed"),params:Xt.optional()}),JR=O({title:$().optional(),readOnlyHint:je().optional(),destructiveHint:je().optional(),idempotentHint:je().optional(),openWorldHint:je().optional()}),KR=O({taskSupport:et(["required","optional","forbidden"]).optional()}),GE=O({...Bo.shape,...su.shape,description:$().optional(),inputSchema:O({type:M("object"),properties:Ee($(),Qe).optional(),required:ie($()).optional()}).catchall(ke()),outputSchema:O({type:M("object"),properties:Ee($(),Qe).optional(),required:ie($()).optional()}).catchall(ke()).optional(),annotations:JR.optional(),execution:KR.optional(),_meta:Ee($(),ke()).optional()}),ep=uu.extend({method:M("tools/list")}),XR=cu.extend({tools:ie(GE)}),tp=rt.extend({content:ie(KA).default([]),structuredContent:Ee($(),ke()).optional(),isError:je().optional()}),vH=tp.or(rt.extend({toolResult:ke()})),YR=ou.extend({name:$(),arguments:Ee($(),ke()).optional()}),Lo=tt.extend({method:M("tools/call"),params:YR}),WR=Yt.extend({method:M("notifications/tools/list_changed"),params:Xt.optional()}),AH=O({autoRefresh:je().default(!0),debounceMs:ge().int().nonnegative().default(300)}),pu=et(["debug","info","notice","warning","error","critical","alert","emergency"]),e4=Zt.extend({level:pu}),XA=tt.extend({method:M("logging/setLevel"),params:e4}),t4=Xt.extend({level:pu,logger:$().optional(),data:ke()}),r4=Yt.extend({method:M("notifications/message"),params:t4}),n4=O({name:$().optional()}),i4=O({hints:ie(n4).optional(),costPriority:ge().min(0).max(1).optional(),speedPriority:ge().min(0).max(1).optional(),intelligencePriority:ge().min(0).max(1).optional()}),o4=O({mode:et(["auto","required","none"]).optional()}),a4=O({type:M("tool_result"),toolUseId:$().describe("The unique identifier for the corresponding tool call."),content:ie(KA).default([]),structuredContent:O({}).loose().optional(),isError:je().optional(),_meta:Ee($(),ke()).optional()}),s4=Ws("type",[HA,GA,JA]),Rf=Ws("type",[HA,GA,JA,ZR,a4]),u4=O({role:fu,content:be([Rf,ie(Rf)]),_meta:Ee($(),ke()).optional()}),c4=ou.extend({messages:ie(u4),modelPreferences:i4.optional(),systemPrompt:$().optional(),includeContext:et(["none","thisServer","allServers"]).optional(),temperature:ge().optional(),maxTokens:ge().int(),stopSequences:ie($()).optional(),metadata:Qe.optional(),tools:ie(GE).optional(),toolChoice:o4.optional()}),l4=tt.extend({method:M("sampling/createMessage"),params:c4}),mu=rt.extend({model:$(),stopReason:Ie(et(["endTurn","stopSequence","maxTokens"]).or($())),role:fu,content:s4}),YA=rt.extend({model:$(),stopReason:Ie(et(["endTurn","stopSequence","maxTokens","toolUse"]).or($())),role:fu,content:be([Rf,ie(Rf)])}),d4=O({type:M("boolean"),title:$().optional(),description:$().optional(),default:je().optional()}),f4=O({type:M("string"),title:$().optional(),description:$().optional(),minLength:ge().optional(),maxLength:ge().optional(),format:et(["email","uri","date","date-time"]).optional(),default:$().optional()}),p4=O({type:et(["number","integer"]),title:$().optional(),description:$().optional(),minimum:ge().optional(),maximum:ge().optional(),default:ge().optional()}),m4=O({type:M("string"),title:$().optional(),description:$().optional(),enum:ie($()),default:$().optional()}),h4=O({type:M("string"),title:$().optional(),description:$().optional(),oneOf:ie(O({const:$(),title:$()})),default:$().optional()}),g4=O({type:M("string"),title:$().optional(),description:$().optional(),enum:ie($()),enumNames:ie($()).optional(),default:$().optional()}),v4=be([m4,h4]),A4=O({type:M("array"),title:$().optional(),description:$().optional(),minItems:ge().optional(),maxItems:ge().optional(),items:O({type:M("string"),enum:ie($())}),default:ie($()).optional()}),y4=O({type:M("array"),title:$().optional(),description:$().optional(),minItems:ge().optional(),maxItems:ge().optional(),items:O({anyOf:ie(O({const:$(),title:$()}))}),default:ie($()).optional()}),_4=be([A4,y4]),b4=be([g4,v4,_4]),$4=be([b4,d4,f4,p4]),I4=ou.extend({mode:M("form").optional(),message:$(),requestedSchema:O({type:M("object"),properties:Ee($(),$4),required:ie($()).optional()})}),w4=ou.extend({mode:M("url"),message:$(),elicitationId:$(),url:$().url()}),E4=be([I4,w4]),x4=tt.extend({method:M("elicitation/create"),params:E4}),S4=Xt.extend({elicitationId:$()}),k4=Yt.extend({method:M("notifications/elicitation/complete"),params:S4}),Fo=rt.extend({action:et(["accept","decline","cancel"]),content:nu(t=>t===null?void 0:t,Ee($(),be([$(),ge(),je(),ie($())])).optional())}),C4=O({type:M("ref/resource"),uri:$()});var D4=O({type:M("ref/prompt"),name:$()}),T4=Zt.extend({ref:be([D4,C4]),argument:O({name:$(),value:$()}),context:O({arguments:Ee($(),$()).optional()}).optional()}),rp=tt.extend({method:M("completion/complete"),params:T4});function JE(t){if(t.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${t.params.ref.type}`)}function KE(t){if(t.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${t.params.ref.type}`)}var N4=rt.extend({completion:We({values:ie($()).max(100),total:Ie(ge().int()),hasMore:Ie(je())})}),z4=O({uri:$().startsWith("file://"),name:$().optional(),_meta:Ee($(),ke()).optional()}),P4=tt.extend({method:M("roots/list"),params:Zt.optional()}),WA=rt.extend({roots:ie(z4)}),O4=Yt.extend({method:M("notifications/roots/list_changed"),params:Xt.optional()}),yH=be([Lf,ZA,rp,XA,Wf,Yf,Jf,Kf,Xf,PR,RR,Lo,ep,Zf,qf,Vf,Gf]),_H=be([Mf,Ff,QA,O4,du]),bH=be([Uf,mu,YA,Fo,WA,Qf,Hf,Uo]),$H=be([Lf,l4,x4,P4,Zf,qf,Vf,Gf]),IH=be([Mf,Ff,r4,BR,NR,WR,GR,du,k4]),wH=be([Uf,bR,N4,HR,LR,kR,CR,TR,tp,XR,Qf,Hf,Uo]),B=class t extends Error{constructor(e,r,i){super(`MCP error ${e}: ${r}`),this.code=e,this.data=i,this.name="McpError"}static fromError(e,r,i){if(e===F.UrlElicitationRequired&&i){let n=i;if(n.elicitations)return new jA(n.elicitations,r)}return new t(e,r,i)}},jA=class extends B{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(F.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function xn(t){return t==="completed"||t==="failed"||t==="cancelled"}var YE=Symbol("Let zodToJsonSchema decide on which parser to use");var XE={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},WE=t=>typeof t=="string"?{...XE,name:t}:{...XE,...t};var ex=t=>{let e=WE(t),r=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([i,n])=>[n._def,{def:n._def,path:[...e.basePath,e.definitionPath,i],jsonSchema:void 0}]))}};function ey(t,e,r,i){i?.errorMessages&&r&&(t.errorMessage={...t.errorMessage,[e]:r})}function ce(t,e,r,i,n){t[e]=r,ey(t,e,i,n)}var np=(t,e)=>{let r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];r++);return[(t.length-r).toString(),...e.slice(r)].join("/")};function Pe(t){if(t.target!=="openAi")return{};let e=[...t.basePath,t.definitionPath,t.openAiAnyTypeName];return t.flags.hasReferencedOpenAiAnyType=!0,{$ref:t.$refStrategy==="relative"?np(e,t.currentPath):e.join("/")}}function tx(t,e){let r={type:"array"};return t.type?._def&&t.type?._def?.typeName!==T.ZodAny&&(r.items=H(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&ce(r,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&ce(r,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(ce(r,"minItems",t.exactLength.value,t.exactLength.message,e),ce(r,"maxItems",t.exactLength.value,t.exactLength.message,e)),r}function rx(t,e){let r={type:"integer",format:"int64"};if(!t.checks)return r;for(let i of t.checks)switch(i.kind){case"min":e.target==="jsonSchema7"?i.inclusive?ce(r,"minimum",i.value,i.message,e):ce(r,"exclusiveMinimum",i.value,i.message,e):(i.inclusive||(r.exclusiveMinimum=!0),ce(r,"minimum",i.value,i.message,e));break;case"max":e.target==="jsonSchema7"?i.inclusive?ce(r,"maximum",i.value,i.message,e):ce(r,"exclusiveMaximum",i.value,i.message,e):(i.inclusive||(r.exclusiveMaximum=!0),ce(r,"maximum",i.value,i.message,e));break;case"multipleOf":ce(r,"multipleOf",i.value,i.message,e);break}return r}function nx(){return{type:"boolean"}}function ip(t,e){return H(t.type._def,e)}var ix=(t,e)=>H(t.innerType._def,e);function ty(t,e,r){let i=r??e.dateStrategy;if(Array.isArray(i))return{anyOf:i.map((n,o)=>ty(t,e,n))};switch(i){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return R4(t,e)}}var R4=(t,e)=>{let r={type:"integer",format:"unix-time"};if(e.target==="openApi3")return r;for(let i of t.checks)switch(i.kind){case"min":ce(r,"minimum",i.value,i.message,e);break;case"max":ce(r,"maximum",i.value,i.message,e);break}return r};function ox(t,e){return{...H(t.innerType._def,e),default:t.defaultValue()}}function ax(t,e){return e.effectStrategy==="input"?H(t.schema._def,e):Pe(e)}function sx(t){return{type:"string",enum:Array.from(t.values)}}var j4=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function ux(t,e){let r=[H(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),H(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(o=>!!o),i=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,n=[];return r.forEach(o=>{if(j4(o))n.push(...o.allOf),o.unevaluatedProperties===void 0&&(i=void 0);else{let a=o;if("additionalProperties"in o&&o.additionalProperties===!1){let{additionalProperties:s,...u}=o;a=u}else i=void 0;n.push(a)}}),n.length?{allOf:n,...i}:void 0}function cx(t,e){let r=typeof t.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[t.value]}:{type:r==="bigint"?"integer":r,const:t.value}}var ry,lr={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(ry===void 0&&(ry=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),ry),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?: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])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function op(t,e){let r={type:"string"};if(t.checks)for(let i of t.checks)switch(i.kind){case"min":ce(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,i.value):i.value,i.message,e);break;case"max":ce(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,i.value):i.value,i.message,e);break;case"email":switch(e.emailStrategy){case"format:email":dr(r,"email",i.message,e);break;case"format:idn-email":dr(r,"idn-email",i.message,e);break;case"pattern:zod":yt(r,lr.email,i.message,e);break}break;case"url":dr(r,"uri",i.message,e);break;case"uuid":dr(r,"uuid",i.message,e);break;case"regex":yt(r,i.regex,i.message,e);break;case"cuid":yt(r,lr.cuid,i.message,e);break;case"cuid2":yt(r,lr.cuid2,i.message,e);break;case"startsWith":yt(r,RegExp(`^${ny(i.value,e)}`),i.message,e);break;case"endsWith":yt(r,RegExp(`${ny(i.value,e)}$`),i.message,e);break;case"datetime":dr(r,"date-time",i.message,e);break;case"date":dr(r,"date",i.message,e);break;case"time":dr(r,"time",i.message,e);break;case"duration":dr(r,"duration",i.message,e);break;case"length":ce(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,i.value):i.value,i.message,e),ce(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,i.value):i.value,i.message,e);break;case"includes":{yt(r,RegExp(ny(i.value,e)),i.message,e);break}case"ip":{i.version!=="v6"&&dr(r,"ipv4",i.message,e),i.version!=="v4"&&dr(r,"ipv6",i.message,e);break}case"base64url":yt(r,lr.base64url,i.message,e);break;case"jwt":yt(r,lr.jwt,i.message,e);break;case"cidr":{i.version!=="v6"&&yt(r,lr.ipv4Cidr,i.message,e),i.version!=="v4"&&yt(r,lr.ipv6Cidr,i.message,e);break}case"emoji":yt(r,lr.emoji(),i.message,e);break;case"ulid":{yt(r,lr.ulid,i.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{dr(r,"binary",i.message,e);break}case"contentEncoding:base64":{ce(r,"contentEncoding","base64",i.message,e);break}case"pattern:zod":{yt(r,lr.base64,i.message,e);break}}break}case"nanoid":yt(r,lr.nanoid,i.message,e);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function ny(t,e){return e.patternStrategy==="escape"?U4(t):t}var B4=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function U4(t){let e="";for(let r=0;r<t.length;r++)B4.has(t[r])||(e+="\\"),e+=t[r];return e}function dr(t,e,r,i){t.format||t.anyOf?.some(n=>n.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format,...t.errorMessage&&i.errorMessages&&{errorMessage:{format:t.errorMessage.format}}}),delete t.format,t.errorMessage&&(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.anyOf.push({format:e,...r&&i.errorMessages&&{errorMessage:{format:r}}})):ce(t,"format",e,r,i)}function yt(t,e,r,i){t.pattern||t.allOf?.some(n=>n.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern,...t.errorMessage&&i.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}}}),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.allOf.push({pattern:lx(e,i),...r&&i.errorMessages&&{errorMessage:{pattern:r}}})):ce(t,"pattern",lx(e,i),r,i)}function lx(t,e){if(!e.applyRegexFlags||!t.flags)return t.source;let r={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},i=r.i?t.source.toLowerCase():t.source,n="",o=!1,a=!1,s=!1;for(let u=0;u<i.length;u++){if(o){n+=i[u],o=!1;continue}if(r.i){if(a){if(i[u].match(/[a-z]/)){s?(n+=i[u],n+=`${i[u-2]}-${i[u]}`.toUpperCase(),s=!1):i[u+1]==="-"&&i[u+2]?.match(/[a-z]/)?(n+=i[u],s=!0):n+=`${i[u]}${i[u].toUpperCase()}`;continue}}else if(i[u].match(/[a-z]/)){n+=`[${i[u]}${i[u].toUpperCase()}]`;continue}}if(r.m){if(i[u]==="^"){n+=`(^|(?<=[\r
|
|
78
|
+
`);if("message"in t&&typeof t.message=="string")return t.message;try{return JSON.stringify(t)}catch{return String(t)}}return String(t)}function uw(t){return t.description}function cw(t){if(xr(t))return t._zod?.def?.type==="optional";let e=t;return typeof t.isOptional=="function"?t.isOptional():e._def?.typeName==="ZodOptional"}function Co(t){if(xr(t)){let o=t._zod?.def;if(o){if(o.value!==void 0)return o.value;if(Array.isArray(o.values)&&o.values.length>0)return o.values[0]}}let r=t._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let i=t.value;if(i!==void 0)return i}var M={};jr(M,{$brand:()=>sh,$input:()=>Dg,$output:()=>Cg,INVALID:()=>gt,NEVER:()=>ah,TimePrecision:()=>Bg,ZodAny:()=>Xv,ZodArray:()=>tA,ZodBase64:()=>xf,ZodBase64URL:()=>Sf,ZodBigInt:()=>Oo,ZodBigIntFormat:()=>Df,ZodBoolean:()=>Po,ZodCIDRv4:()=>wf,ZodCIDRv6:()=>Ef,ZodCUID:()=>vf,ZodCUID2:()=>Af,ZodCatch:()=>_A,ZodCodec:()=>tu,ZodCompileAsyncError:()=>sr,ZodCompileUnsupportedError:()=>ae,ZodCreditCard:()=>Vv,ZodCustom:()=>ru,ZodCustomStringFormat:()=>ii,ZodDate:()=>Ks,ZodDefault:()=>mA,ZodDiscriminatedUnion:()=>nA,ZodE164:()=>kf,ZodEmail:()=>pf,ZodEmoji:()=>hf,ZodEnum:()=>To,ZodError:()=>BO,ZodExactOptional:()=>zf,ZodFile:()=>lA,ZodFirstPartyTypeKind:()=>PA,ZodFunction:()=>DA,ZodGUID:()=>mf,ZodIBAN:()=>Hv,ZodIPv4:()=>$f,ZodIPv6:()=>If,ZodISODate:()=>$n,ZodISODateTime:()=>bn,ZodISODuration:()=>wn,ZodISOTime:()=>In,ZodInstanceOf:()=>zA,ZodIntersection:()=>iA,ZodIssueCode:()=>LO,ZodJWT:()=>Cf,ZodKSUID:()=>bf,ZodLazy:()=>SA,ZodLiteral:()=>cA,ZodMAC:()=>qv,ZodMap:()=>sA,ZodNaN:()=>$A,ZodNanoID:()=>gf,ZodNever:()=>Wv,ZodNonOptional:()=>Pf,ZodNull:()=>Kv,ZodNullable:()=>pA,ZodNumber:()=>zo,ZodNumberFormat:()=>oi,ZodObject:()=>Xs,ZodOptional:()=>ai,ZodPipe:()=>eu,ZodPrefault:()=>gA,ZodPreprocess:()=>IA,ZodPromise:()=>CA,ZodReadonly:()=>wA,ZodRealError:()=>St,ZodRecord:()=>Do,ZodSet:()=>uA,ZodString:()=>No,ZodStringFormat:()=>we,ZodSuccess:()=>yA,ZodSymbol:()=>Gv,ZodTemplateLiteral:()=>xA,ZodTransform:()=>dA,ZodTuple:()=>oA,ZodType:()=>W,ZodULID:()=>yf,ZodURL:()=>Gs,ZodUUID:()=>Sr,ZodUndefined:()=>Jv,ZodUnion:()=>Ys,ZodUnknown:()=>Yv,ZodVoid:()=>eA,ZodXID:()=>_f,ZodXor:()=>rA,_ZodString:()=>ff,_default:()=>hA,_function:()=>vE,any:()=>Yw,array:()=>ie,base64:()=>Nw,base64url:()=>zw,bigint:()=>Hw,boolean:()=>je,catch:()=>bA,check:()=>AE,cidrv4:()=>Dw,cidrv6:()=>Tw,clone:()=>he,codec:()=>pE,coerce:()=>RA,compile:()=>Pg,config:()=>Re,core:()=>cr,creditCard:()=>Ow,cuid:()=>$w,cuid2:()=>Iw,currencyCode:()=>Lw,custom:()=>Of,date:()=>eE,decode:()=>Bv,decodeAsync:()=>Mv,deepPartial:()=>CE,describe:()=>yE,discriminatedUnion:()=>Ws,e164:()=>Pw,email:()=>fw,emoji:()=>_w,encode:()=>jv,encodeAsync:()=>Uv,endsWith:()=>vo,enum:()=>et,exactOptional:()=>fA,file:()=>cE,flattenError:()=>Wa,float32:()=>Zw,float64:()=>Qw,formatError:()=>es,fromJSONSchema:()=>kE,function:()=>vE,getDiscriminatedOption:()=>Eg,getErrorMap:()=>ZO,globalRegistry:()=>Ye,gt:()=>wr,gte:()=>Ft,guid:()=>pw,hash:()=>Fw,hex:()=>Mw,hostname:()=>Uw,httpUrl:()=>yw,iban:()=>Rw,includes:()=>ho,input:()=>TE,instanceof:()=>bE,int:()=>lf,int32:()=>qw,int64:()=>Gw,intersection:()=>Ro,invertCodec:()=>mE,ipv4:()=>Sw,ipv6:()=>Cw,iso:()=>si,json:()=>IE,jwt:()=>jw,keyof:()=>tE,ksuid:()=>xw,lazy:()=>kA,length:()=>ei,literal:()=>L,locales:()=>uo,looseObject:()=>We,looseRecord:()=>oE,lowercase:()=>po,lt:()=>Ir,lte:()=>Lt,mac:()=>kw,map:()=>aE,maxLength:()=>Wn,maxSize:()=>mn,memoizer:()=>vs,meta:()=>_E,mime:()=>yo,minLength:()=>qr,minSize:()=>Er,multipleOf:()=>pn,nan:()=>fE,nanoid:()=>bw,nativeEnum:()=>uE,negative:()=>Qd,never:()=>Tf,nonnegative:()=>Vd,nonoptional:()=>AA,nonpositive:()=>qd,normalize:()=>_o,null:()=>Js,nullable:()=>Hs,nullish:()=>lE,number:()=>ge,object:()=>O,optional:()=>Ie,output:()=>NE,overwrite:()=>ur,parse:()=>zv,parseAsync:()=>Pv,partialRecord:()=>iE,pipe:()=>df,positive:()=>Zd,prefault:()=>vA,preprocess:()=>nu,prettifyError:()=>fh,promise:()=>gE,properties:()=>Ao,property:()=>Hd,readonly:()=>EA,record:()=>Ee,refine:()=>TA,regex:()=>fo,regexes:()=>Mt,registry:()=>gd,safeDecode:()=>Fv,safeDecodeAsync:()=>Qv,safeEncode:()=>Lv,safeEncodeAsync:()=>Zv,safeParse:()=>Ov,safeParseAsync:()=>Rv,set:()=>sE,setErrorMap:()=>FO,size:()=>Yn,slugify:()=>wo,startsWith:()=>go,strictObject:()=>rE,string:()=>$,stringFormat:()=>Bw,stringbool:()=>$E,success:()=>dE,superRefine:()=>NA,symbol:()=>Kw,templateLiteral:()=>hE,toJSONSchema:()=>ti,toLowerCase:()=>$o,toUpperCase:()=>Io,toZod:()=>Qa,transform:()=>Nf,treeifyError:()=>dh,trim:()=>bo,tuple:()=>aA,uint32:()=>Vw,uint64:()=>Jw,ulid:()=>ww,undefined:()=>Xw,union:()=>be,unknown:()=>ke,uppercase:()=>mo,url:()=>Aw,util:()=>I,uuid:()=>mw,uuidv4:()=>hw,uuidv6:()=>gw,uuidv7:()=>vw,validate:()=>Yi,validateAsync:()=>Wi,void:()=>Ww,withParser:()=>vd,xid:()=>Ew,xor:()=>nE});var jo={};jr(jo,{ZodAny:()=>Xv,ZodArray:()=>tA,ZodBase64:()=>xf,ZodBase64URL:()=>Sf,ZodBigInt:()=>Oo,ZodBigIntFormat:()=>Df,ZodBoolean:()=>Po,ZodCIDRv4:()=>wf,ZodCIDRv6:()=>Ef,ZodCUID:()=>vf,ZodCUID2:()=>Af,ZodCatch:()=>_A,ZodCodec:()=>tu,ZodCreditCard:()=>Vv,ZodCustom:()=>ru,ZodCustomStringFormat:()=>ii,ZodDate:()=>Ks,ZodDefault:()=>mA,ZodDiscriminatedUnion:()=>nA,ZodE164:()=>kf,ZodEmail:()=>pf,ZodEmoji:()=>hf,ZodEnum:()=>To,ZodExactOptional:()=>zf,ZodFile:()=>lA,ZodFunction:()=>DA,ZodGUID:()=>mf,ZodIBAN:()=>Hv,ZodIPv4:()=>$f,ZodIPv6:()=>If,ZodISODate:()=>$n,ZodISODateTime:()=>bn,ZodISODuration:()=>wn,ZodISOTime:()=>In,ZodInstanceOf:()=>zA,ZodIntersection:()=>iA,ZodJWT:()=>Cf,ZodKSUID:()=>bf,ZodLazy:()=>SA,ZodLiteral:()=>cA,ZodMAC:()=>qv,ZodMap:()=>sA,ZodNaN:()=>$A,ZodNanoID:()=>gf,ZodNever:()=>Wv,ZodNonOptional:()=>Pf,ZodNull:()=>Kv,ZodNullable:()=>pA,ZodNumber:()=>zo,ZodNumberFormat:()=>oi,ZodObject:()=>Xs,ZodOptional:()=>ai,ZodPipe:()=>eu,ZodPrefault:()=>gA,ZodPreprocess:()=>IA,ZodPromise:()=>CA,ZodReadonly:()=>wA,ZodRecord:()=>Do,ZodSet:()=>uA,ZodString:()=>No,ZodStringFormat:()=>we,ZodSuccess:()=>yA,ZodSymbol:()=>Gv,ZodTemplateLiteral:()=>xA,ZodTransform:()=>dA,ZodTuple:()=>oA,ZodType:()=>W,ZodULID:()=>yf,ZodURL:()=>Gs,ZodUUID:()=>Sr,ZodUndefined:()=>Jv,ZodUnion:()=>Ys,ZodUnknown:()=>Yv,ZodVoid:()=>eA,ZodXID:()=>_f,ZodXor:()=>rA,_ZodString:()=>ff,_default:()=>hA,_function:()=>vE,any:()=>Yw,array:()=>ie,base64:()=>Nw,base64url:()=>zw,bigint:()=>Hw,boolean:()=>je,catch:()=>bA,check:()=>AE,cidrv4:()=>Dw,cidrv6:()=>Tw,codec:()=>pE,creditCard:()=>Ow,cuid:()=>$w,cuid2:()=>Iw,currencyCode:()=>Lw,custom:()=>Of,date:()=>eE,describe:()=>yE,discriminatedUnion:()=>Ws,e164:()=>Pw,email:()=>fw,emoji:()=>_w,enum:()=>et,exactOptional:()=>fA,file:()=>cE,float32:()=>Zw,float64:()=>Qw,function:()=>vE,guid:()=>pw,hash:()=>Fw,hex:()=>Mw,hostname:()=>Uw,httpUrl:()=>yw,iban:()=>Rw,instanceof:()=>bE,int:()=>lf,int32:()=>qw,int64:()=>Gw,intersection:()=>Ro,invertCodec:()=>mE,ipv4:()=>Sw,ipv6:()=>Cw,json:()=>IE,jwt:()=>jw,keyof:()=>tE,ksuid:()=>xw,lazy:()=>kA,literal:()=>L,looseObject:()=>We,looseRecord:()=>oE,mac:()=>kw,map:()=>aE,meta:()=>_E,nan:()=>fE,nanoid:()=>bw,nativeEnum:()=>uE,never:()=>Tf,nonoptional:()=>AA,null:()=>Js,nullable:()=>Hs,nullish:()=>lE,number:()=>ge,object:()=>O,optional:()=>Ie,partialRecord:()=>iE,pipe:()=>df,prefault:()=>vA,preprocess:()=>nu,promise:()=>gE,readonly:()=>EA,record:()=>Ee,refine:()=>TA,set:()=>sE,strictObject:()=>rE,string:()=>$,stringFormat:()=>Bw,stringbool:()=>$E,success:()=>dE,superRefine:()=>NA,symbol:()=>Kw,templateLiteral:()=>hE,transform:()=>Nf,tuple:()=>aA,uint32:()=>Vw,uint64:()=>Jw,ulid:()=>ww,undefined:()=>Xw,union:()=>be,unknown:()=>ke,url:()=>Aw,uuid:()=>mw,uuidv4:()=>hw,uuidv6:()=>gw,uuidv7:()=>vw,void:()=>Ww,xid:()=>Ew,xor:()=>nE});var uf={};jr(uf,{endsWith:()=>vo,gt:()=>wr,gte:()=>Ft,includes:()=>ho,length:()=>ei,lowercase:()=>po,lt:()=>Ir,lte:()=>Lt,maxLength:()=>Wn,maxSize:()=>mn,mime:()=>yo,minLength:()=>qr,minSize:()=>Er,multipleOf:()=>pn,negative:()=>Qd,nonnegative:()=>Vd,nonpositive:()=>qd,normalize:()=>_o,overwrite:()=>ur,positive:()=>Zd,properties:()=>Ao,property:()=>Hd,regex:()=>fo,size:()=>Yn,slugify:()=>wo,startsWith:()=>go,toLowerCase:()=>$o,toUpperCase:()=>Io,trim:()=>bo,uppercase:()=>mo});var lw=new WeakSet([Object.prototype,Error.prototype]);function cf(t,e,r){Object.defineProperty(t,e,{configurable:!0,enumerable:!1,get(){let i=r(this);return Object.defineProperty(this,e,{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,e,{value:i,configurable:!0,writable:!0})}})}var dw=(t,e)=>{lh.init(t,e),t.name="ZodError";let r=Object.getPrototypeOf(t);lw.has(r)||(lw.add(r),cf(r,"format",i=>n=>es(i,n)),cf(r,"flatten",i=>n=>Wa(i,n)),cf(r,"addIssue",i=>n=>{i.issues.push(n),i.message=JSON.stringify(i.issues,Mi,2)}),cf(r,"addIssues",i=>n=>{i.issues.push(...n),i.message=JSON.stringify(i.issues,Mi,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},BO=_("ZodError",dw),St=_("ZodError",dw,void 0,{Parent:Error});var zv=Vi(St),Pv=Hi(St),Ov=Gi(St),Rv=Ki(St),jv=kc(St),Bv=Cc(St),Uv=Dc(St),Mv=Tc(St),Lv=Nc(St),Fv=zc(St),Zv=Pc(St),Qv=Oc(St);function MO(){Ve.localeError||Re(fd())}function ni(){Ve.memoizer||Re({memoizer:vs()})}var W=_("ZodType",(t,e)=>(MO(),G.init(t,e),t.def=e,t.type=e.type,t),{check(...t){let e=this.def;return this.clone(I.mergeDefs(e,{checks:[...e.checks??[],...t.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...t){return this.check(...t)},clone(t,e){return he(this,t,e)},brand(){return this},register(t,e){return t.add(this,e),this},refine(t,e){return this.check(TA(t,e))},superRefine(t,e){return this.check(NA(t,e))},overwrite(t){return this.check(ur(t))},optional(){return Ie(this)},exactOptional(){return fA(this)},nullable(){return Hs(this)},nullish(){return Ie(Hs(this))},nonoptional(t){return AA(this,t)},array(){return ie(this)},or(t){return be([this,t])},and(t){return Ro(this,t)},transform(t){return df(this,Nf(t))},default(t){return hA(this,t)},prefault(t){return vA(this,t)},catch(t){return bA(this,t)},pipe(t){return df(this,t)},readonly(){return EA(this)},describe(t){let e=this.clone();return Ye.add(e,{description:t}),e},meta(...t){if(t.length===0)return Ye.get(this);let e=this.clone();return Ye.add(e,t[0]),e},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(t,...e){return e.length===0?t(this):t(this,...e)},get"~standard"(){return I.hide(this,"~standard",{...Vc(this),jsonSchema:{input:Eo(this,"input"),output:Eo(this,"output")}})},set"~standard"(t){I.own(this,"~standard",t)},parse:function t(e,r){return zv(this,e,r,{callee:t})},parseAsync:async function t(e,r){return await Pv(this,e,r,{callee:t})},safeParse(t,e){return Ov(this,t,e)},async safeParseAsync(t,e){return Rv(this,t,e)},get spa(){return this?.safeParseAsync},set spa(t){I.own(this,"spa",t)},validate(t,e){return Yi(this,t,e)},validateAsync(t,e){return Wi(this,t,e)},encode:function t(e,r){return jv(this,e,r,{callee:t})},decode:function t(e,r){return Bv(this,e,r,{callee:t})},encodeAsync:async function t(e,r){return await Uv(this,e,r,{callee:t})},decodeAsync:async function t(e,r){return await Mv(this,e,r,{callee:t})},safeEncode(t,e){return Lv(this,t,e)},safeDecode(t,e){return Fv(this,t,e)},async safeEncodeAsync(t,e){return Zv(this,t,e)},async safeDecodeAsync(t,e){return Qv(this,t,e)},toJSONSchema(t){return qg(this,{})(t)},get description(){return Ye.get(this)?.description},get _def(){return this._zod.def}}),ff=_("_ZodString",(t,e)=>{dn.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Gg(t,r,i,n)},I.derived({format:t=>Ze(t).format??null,minLength:t=>Ze(t).minimum??null,maxLength:t=>Ze(t).maximum??null},{regex(...t){return this.check(fo(...t))},includes(...t){return this.check(ho(...t))},startsWith(...t){return this.check(go(...t))},endsWith(...t){return this.check(vo(...t))},min(...t){return this.check(qr(...t))},max(...t){return this.check(Wn(...t))},length(...t){return this.check(ei(...t))},nonempty(...t){return this.check(qr(1,...t))},lowercase(t){return this.check(po(t))},uppercase(t){return this.check(mo(t))},trim(){return this.check(bo())},normalize(...t){return this.check(_o(...t))},toLowerCase(){return this.check($o())},toUpperCase(){return this.check(Io())},slugify(){return this.check(wo())}})),No=_("ZodString",(t,e)=>{dn.init(t,e),ff.init(t,e)},{email(t){return this.check(ys(pf,t))},url(t){return this.check(lo(Gs,t))},jwt(t){return this.check(Us(Cf,t))},emoji(t){return this.check(Es(hf,t))},guid(t){return this.check(_s(mf,t))},uuid(t){return this.check(bs(Sr,t))},uuidv4(t){return this.check($s(Sr,t))},uuidv6(t){return this.check(Is(Sr,t))},uuidv7(t){return this.check(ws(Sr,t))},nanoid(t){return this.check(xs(gf,t))},cuid(t){return this.check(Ss(vf,t))},cuid2(t){return this.check(ks(Af,t))},ulid(t){return this.check(Cs(yf,t))},base64(t){return this.check(Rs(xf,t))},base64url(t){return this.check(js(Sf,t))},xid(t){return this.check(Ds(_f,t))},ksuid(t){return this.check(Ts(bf,t))},ipv4(t){return this.check(Ns($f,t))},ipv6(t){return this.check(zs(If,t))},cidrv4(t){return this.check(Ps(wf,t))},cidrv6(t){return this.check(Os(Ef,t))},e164(t){return this.check(Bs(kf,t))},datetime(t){return this.check(Ms(bn,t))},date(t){return this.check(Ls($n,t))},time(t){return this.check(Fs(In,t))},duration(t){return this.check(Zs(wn,t))}});function $(t){return _d(No,t)}var we=_("ZodStringFormat",(t,e)=>{Ae.init(t,e),ff.init(t,e)}),bn=_("ZodISODateTime",(t,e)=>{yg.init(t,e),we.init(t,e)}),$n=_("ZodISODate",(t,e)=>{_g.init(t,e),we.init(t,e)}),In=_("ZodISOTime",(t,e)=>{bg.init(t,e),we.init(t,e)}),wn=_("ZodISODuration",(t,e)=>{$g.init(t,e),we.init(t,e)}),pf=_("ZodEmail",(t,e)=>{Jc.init(t,e),we.init(t,e)});function fw(t){return ys(pf,t)}var mf=_("ZodGUID",(t,e)=>{Hc.init(t,e),we.init(t,e)});function pw(t){return _s(mf,t)}var Sr=_("ZodUUID",(t,e)=>{Gc.init(t,e),we.init(t,e)});function mw(t){return bs(Sr,t)}function hw(t){return $s(Sr,t)}function gw(t){return Is(Sr,t)}function vw(t){return ws(Sr,t)}var Gs=_("ZodURL",(t,e)=>{Wc.init(t,e),we.init(t,e)});function Aw(t){return lo(Gs,t)}function yw(t){return lo(Gs,{protocol:ts,hostname:zh,...I.normalizeParams(t)})}var hf=_("ZodEmoji",(t,e)=>{el.init(t,e),we.init(t,e)});function _w(t){return Es(hf,t)}var gf=_("ZodNanoID",(t,e)=>{tl.init(t,e),we.init(t,e)});function bw(t){return xs(gf,t)}var vf=_("ZodCUID",(t,e)=>{rl.init(t,e),we.init(t,e)});function $w(t){return Ss(vf,t)}var Af=_("ZodCUID2",(t,e)=>{nl.init(t,e),we.init(t,e)});function Iw(t){return ks(Af,t)}var yf=_("ZodULID",(t,e)=>{il.init(t,e),we.init(t,e)});function ww(t){return Cs(yf,t)}var _f=_("ZodXID",(t,e)=>{ol.init(t,e),we.init(t,e)});function Ew(t){return Ds(_f,t)}var bf=_("ZodKSUID",(t,e)=>{al.init(t,e),we.init(t,e)});function xw(t){return Ts(bf,t)}var $f=_("ZodIPv4",(t,e)=>{sl.init(t,e),we.init(t,e)});function Sw(t){return Ns($f,t)}var qv=_("ZodMAC",(t,e)=>{cl.init(t,e),we.init(t,e)});function kw(t){return bd(qv,t)}var If=_("ZodIPv6",(t,e)=>{ul.init(t,e),we.init(t,e)});function Cw(t){return zs(If,t)}var wf=_("ZodCIDRv4",(t,e)=>{ll.init(t,e),we.init(t,e)});function Dw(t){return Ps(wf,t)}var Ef=_("ZodCIDRv6",(t,e)=>{fl.init(t,e),we.init(t,e)});function Tw(t){return Os(Ef,t)}var xf=_("ZodBase64",(t,e)=>{ml.init(t,e),we.init(t,e)});function Nw(t){return Rs(xf,t)}var Sf=_("ZodBase64URL",(t,e)=>{gl.init(t,e),we.init(t,e)});function zw(t){return js(Sf,t)}var kf=_("ZodE164",(t,e)=>{vl.init(t,e),we.init(t,e)});function Pw(t){return Bs(kf,t)}var Vv=_("ZodCreditCard",(t,e)=>{yl.init(t,e),we.init(t,e)});function Ow(t){return $d(Vv,t)}var Hv=_("ZodIBAN",(t,e)=>{bl.init(t,e),we.init(t,e)});function Rw(t){return Id(Hv,t)}var Cf=_("ZodJWT",(t,e)=>{Il.init(t,e),we.init(t,e)});function jw(t){return Us(Cf,t)}var ii=_("ZodCustomStringFormat",(t,e)=>{wl.init(t,e),we.init(t,e)});function Bw(t,e,r={}){return hn(ii,t,e,r)}function Uw(t){return hn(ii,"hostname",Nh,t)}function Mw(t){return hn(ii,"hex",Hh,t)}function Lw(t){return hn(ii,"currency_code",Oh,t)}function Fw(t,e){let r=e?.enc??"hex",i=`${t}_${r}`,n=Mt[i];if(!n)throw new Error(`Unrecognized hash format: ${i}`);return hn(ii,i,n,e)}var zo=_("ZodNumber",(t,e)=>{ls.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Jg(t,r,i,n),t.isFinite=!0},I.derived({minValue:t=>{let{minimum:e,exclusiveMinimum:r}=Ze(t);return Math.max(e??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:t=>{let{maximum:e,exclusiveMaximum:r}=Ze(t);return Math.min(e??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:t=>{let{isInt:e,multipleOf:r}=Ze(t);return!!e||!!r?.some(Number.isSafeInteger)},format:t=>Ze(t).format??null},{gt(t,e){return this.check(wr(t,e))},gte(t,e){return this.check(Ft(t,e))},min(t,e){return this.check(Ft(t,e))},lt(t,e){return this.check(Ir(t,e))},lte(t,e){return this.check(Lt(t,e))},max(t,e){return this.check(Lt(t,e))},int(t){return this.check(lf(t))},safe(t){return this.check(lf(t))},positive(t){return this.check(wr(0,t))},nonnegative(t){return this.check(Ft(0,t))},negative(t){return this.check(Ir(0,t))},nonpositive(t){return this.check(Lt(0,t))},multipleOf(t,e){return this.check(pn(t,e))},step(t,e){return this.check(pn(t,e))},finite(){return this}}));function ge(t){return wd(zo,t)}var oi=_("ZodNumberFormat",(t,e)=>{El.init(t,e),zo.init(t,e)});function lf(t){return Ed(oi,t)}function Zw(t){return xd(oi,t)}function Qw(t){return Sd(oi,t)}function qw(t){return kd(oi,t)}function Vw(t){return Cd(oi,t)}var Po=_("ZodBoolean",(t,e)=>{ro.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Kg(t,r,i,n)});function je(t){return Dd(Po,t)}var Oo=_("ZodBigInt",(t,e)=>{ds.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Xg(t,r,i,n)},I.derived({minValue:t=>Ze(t).minimum??null,maxValue:t=>Ze(t).maximum??null,format:t=>Ze(t).format??null},{gte(t,e){return this.check(Ft(t,e))},min(t,e){return this.check(Ft(t,e))},gt(t,e){return this.check(wr(t,e))},lt(t,e){return this.check(Ir(t,e))},lte(t,e){return this.check(Lt(t,e))},max(t,e){return this.check(Lt(t,e))},positive(t){return this.check(wr(BigInt(0),t))},negative(t){return this.check(Ir(BigInt(0),t))},nonpositive(t){return this.check(Lt(BigInt(0),t))},nonnegative(t){return this.check(Ft(BigInt(0),t))},multipleOf(t,e){return this.check(pn(t,e))}}));function Hw(t){return Td(Oo,t)}var Df=_("ZodBigIntFormat",(t,e)=>{xl.init(t,e),Oo.init(t,e)});function Gw(t){return Nd(Df,t)}function Jw(t){return zd(Df,t)}var Gv=_("ZodSymbol",(t,e)=>{Sl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Yg(t,r,i,n)});function Kw(t){return Pd(Gv,t)}var Jv=_("ZodUndefined",(t,e)=>{kl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>ev(t,r,i,n)});function Xw(t){return Od(Jv,t)}var Kv=_("ZodNull",(t,e)=>{Cl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Wg(t,r,i,n)});function Js(t){return Rd(Kv,t)}var Xv=_("ZodAny",(t,e)=>{Dl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>nv(t,r,i,n)});function Yw(){return jd(Xv)}var Yv=_("ZodUnknown",(t,e)=>{Tl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>iv(t,r,i,n)});function ke(){return Bd(Yv)}var Wv=_("ZodNever",(t,e)=>{Nl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>rv(t,r,i,n)});function Tf(t){return Ud(Wv,t)}var eA=_("ZodVoid",(t,e)=>{zl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>tv(t,r,i,n)});function Ww(t){return Md(eA,t)}var Ks=_("ZodDate",(t,e)=>{Pl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>ov(t,r,i,n),t.min=(r,i)=>t.check(Ft(r,i)),t.max=(r,i)=>t.check(Lt(r,i))},I.derived({minDate:t=>{let{minimum:e}=Ze(t);return e?new Date(e):null},maxDate:t=>{let{maximum:e}=Ze(t);return e?new Date(e):null}},{}));function eE(t){return Ld(Ks,t)}var tA=_("ZodArray",(t,e)=>{ni(),Ol.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>vv(t,r,i,n),t.element=e.element},{min(t,e){return this.check(qr(t,e))},nonempty(t){return this.check(qr(1,t))},max(t,e){return this.check(Wn(t,e))},length(t,e){return this.check(ei(t,e))},unwrap(){return this.element}});function ie(t,e){return Zg(tA,t,e)}function tE(t){let e=t._zod.def.shape;return et(Object.keys(e))}var Xs=_("ZodObject",(t,e)=>{ni(),wg.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Av(t,r,i,n),I.installLazyProp(t,"shape",r=>r._zod.def.shape,!1)},{keyof(){return et(Object.keys(this._zod.def.shape))},catchall(t){return this.clone(I.mergeDefs(this._zod.def,{catchall:t}))},passthrough(){return this.clone(I.mergeDefs(this._zod.def,{catchall:ke()}))},loose(){return this.clone(I.mergeDefs(this._zod.def,{catchall:ke()}))},strict(){return this.clone(I.mergeDefs(this._zod.def,{catchall:Tf()}))},strip(){return this.clone(I.mergeDefs(this._zod.def,{catchall:void 0}))},extend(t){return I.extend(this,t)},safeExtend(t){return I.safeExtend(this,t)},merge(t){return I.merge(this,t)},pick(t){return I.pick(this,t)},omit(t){return I.omit(this,t)},partial(...t){return I.partial(ai,this,t[0])},exactPartial(...t){return I.partial(zf,this,t[0],"exactPartial")},required(...t){return I.required(Pf,this,t[0])}});function O(t,e){let r={type:"object",shape:t??{},...I.normalizeParams(e)};return new Xs(r)}function rE(t,e){return new Xs({type:"object",shape:t,catchall:Tf(),...I.normalizeParams(e)})}function We(t,e){return new Xs({type:"object",shape:t,catchall:ke(),...I.normalizeParams(e)})}var Ys=_("ZodUnion",(t,e)=>{no.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>rf(t,r,i,n),t.options=e.options});function be(t,e){return new Ys({type:"union",options:t,...I.normalizeParams(e)})}var rA=_("ZodXor",(t,e)=>{Ys.init(t,e),jl.init(t,e),t._zod.processJSONSchema=(r,i,n)=>rf(t,r,i,n),t.options=e.options});function nE(t,e){return new rA({type:"union",options:t,inclusive:!1,...I.normalizeParams(e)})}var nA=_("ZodDiscriminatedUnion",(t,e)=>{Ys.init(t,e),Bl.init(t,e)});function Ws(t,e,r){return new nA({type:"union",options:e,discriminator:t,...I.normalizeParams(r)})}var iA=_("ZodIntersection",(t,e)=>{Ul.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>yv(t,r,i,n)});function Ro(t,e){return new iA({type:"intersection",left:t,right:e})}var oA=_("ZodTuple",(t,e)=>{ni(),fs.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>_v(t,r,i,n)},{rest(t){return this.clone({...this._zod.def,rest:t})},partial(){let t=this._zod.def;if(t.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...t,items:t.items.map(e=>new ai({type:"optional",innerType:e}))})}});function aA(t,e,r){let i=e instanceof G,n=i?r:e,o=i?e:null;return new oA({type:"tuple",items:t,rest:o,...I.normalizeParams(n)})}var Do=_("ZodRecord",(t,e)=>{ni(),Ml.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>bv(t,r,i,n),t.keyType=e.keyType,t.valueType=e.valueType});function Ee(t,e,r){return!e||!e._zod?new Do({type:"record",keyType:$(),valueType:t,...I.normalizeParams(e)}):new Do({type:"record",keyType:t,valueType:e,...I.normalizeParams(r)})}function iE(t,e,r){return new Do({type:"record",keyType:t,valueType:e,...I.normalizeParams(r),partial:!0})}function oE(t,e,r){return new Do({type:"record",keyType:t,valueType:e,mode:"loose",...I.normalizeParams(r)})}var sA=_("ZodMap",(t,e)=>{ni(),Ll.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>hv(t,r,i,n),t.keyType=e.keyType,t.valueType=e.valueType,t.min=(...r)=>t.check(Er(...r)),t.nonempty=r=>t.check(Er(1,r)),t.max=(...r)=>t.check(mn(...r)),t.size=(...r)=>t.check(Yn(...r))});function aE(t,e,r){return new sA({type:"map",keyType:t,valueType:e,...I.normalizeParams(r)})}var uA=_("ZodSet",(t,e)=>{ni(),Fl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>gv(t,r,i,n),t.min=(...r)=>t.check(Er(...r)),t.nonempty=r=>t.check(Er(1,r)),t.max=(...r)=>t.check(mn(...r)),t.size=(...r)=>t.check(Yn(...r))});function sE(t,e){return new uA({type:"set",valueType:t,...I.normalizeParams(e)})}var To=_("ZodEnum",(t,e)=>{Zl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(i,n,o)=>av(t,i,n,o),t.enum=e.entries,t.options=[...t._zod.values];let r=new Set(Object.keys(e.entries));t.extract=(i,n)=>{let o={};for(let a of i)if(r.has(a))o[a]=e.entries[a];else throw new Error(`Key ${a} not found in enum`);return new To({...e,checks:[],...I.normalizeParams(n),entries:o})},t.exclude=(i,n)=>{let o={...e.entries};for(let a of i)if(r.has(a))delete o[a];else throw new Error(`Key ${a} not found in enum`);return new To({...e,checks:[],...I.normalizeParams(n),entries:o})}});function et(t,e){let r=Array.isArray(t)?Object.fromEntries(t.map(i=>[i,i])):t;return new To({type:"enum",entries:r,...I.normalizeParams(e)})}function uE(t,e){return new To({type:"enum",entries:t,...I.normalizeParams(e)})}var cA=_("ZodLiteral",(t,e)=>{Ql.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>sv(t,r,i,n),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function L(t,e){return new cA({type:"literal",values:Array.isArray(t)?t:[t],...I.normalizeParams(e)})}var lA=_("ZodFile",(t,e)=>{ql.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>lv(t,r,i,n),t.min=(r,i)=>t.check(Er(r,i)),t.max=(r,i)=>t.check(mn(r,i)),t.mime=(r,i)=>t.check(yo(Array.isArray(r)?r:[r],i))});function cE(t){return Gd(lA,t)}var dA=_("ZodTransform",(t,e)=>{ni(),Vl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>mv(t,r,i,n),t._zod.parse=(r,i)=>{if(i.direction==="backward")throw new ln(t.constructor.name);r.addIssue=o=>{if(typeof o=="string")r.issues.push(I.issue(o,r.value,e));else{let a=o;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),"input"in a||(a.input=r.value),a.inst??(a.inst=t),r.issues.push(I.issue(a))}};let n=e.transform(r.value,r);return n instanceof Promise?n.then(o=>(r.value=o,r)):(r.value=n,r)}});function Nf(t){return new dA({type:"transform",transform:t})}var ai=_("ZodOptional",(t,e)=>{ps.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>nf(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});function Ie(t){return new ai({type:"optional",innerType:t})}var zf=_("ZodExactOptional",(t,e)=>{Hl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>nf(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});function fA(t){return new zf({type:"optional",innerType:t})}var pA=_("ZodNullable",(t,e)=>{Gl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>$v(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});function Hs(t){return new pA({type:"nullable",innerType:t})}function lE(t){return Ie(Hs(t))}var mA=_("ZodDefault",(t,e)=>{Jl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Ev(t,r,i,n),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function hA(t,e){return new mA({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():I.shallowClone(e)}})}var gA=_("ZodPrefault",(t,e)=>{Kl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>xv(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});function vA(t,e){return new gA({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():I.shallowClone(e)}})}var Pf=_("ZodNonOptional",(t,e)=>{Xl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Iv(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});function AA(t,e){return new Pf({type:"nonoptional",innerType:t,...I.normalizeParams(e)})}var yA=_("ZodSuccess",(t,e)=>{Yl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>dv(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});function dE(t){return new yA({type:"success",innerType:t})}var _A=_("ZodCatch",(t,e)=>{Wl.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Sv(t,r,i,n),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function bA(t,e){return new _A({type:"catch",innerType:t,catchValue:typeof e=="function"?e:I.constantCatch(e)})}var $A=_("ZodNaN",(t,e)=>{ed.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>uv(t,r,i,n)});function fE(t){return Fd($A,t)}var eu=_("ZodPipe",(t,e)=>{ms.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>kv(t,r,i,n),t.in=e.in,t.out=e.out});function df(t,e){return new eu({type:"pipe",in:t,out:e})}var tu=_("ZodCodec",(t,e)=>{eu.init(t,e),io.init(t,e)});function pE(t,e,r){return new tu({type:"pipe",in:t,out:e,transform:r.decode,reverseTransform:r.encode})}function mE(t){let e=t._zod.def;return new tu({type:"pipe",in:e.out,out:e.in,transform:e.reverseTransform,reverseTransform:e.transform})}var IA=_("ZodPreprocess",(t,e)=>{eu.init(t,e),xg.init(t,e)}),wA=_("ZodReadonly",(t,e)=>{td.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Cv(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});function EA(t){return new wA({type:"readonly",innerType:t})}var xA=_("ZodTemplateLiteral",(t,e)=>{rd.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>cv(t,r,i,n)});function hE(t,e){return new xA({type:"template_literal",parts:t,...I.normalizeParams(e)})}var SA=_("ZodLazy",(t,e)=>{oo.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Tv(t,r,i,n),t.unwrap=()=>t._zod.def.getter()});function kA(t){return new SA({type:"lazy",getter:t})}var CA=_("ZodPromise",(t,e)=>{id.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>Dv(t,r,i,n),t.unwrap=()=>t._zod.def.innerType});function gE(t){return new CA({type:"promise",innerType:t})}var DA=_("ZodFunction",(t,e)=>{nd.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>pv(t,r,i,n)});function vE(t){return new DA({type:"function",input:Array.isArray(t?.input)?aA(t?.input):t?.input??ie(ke()),output:t?.output??ke()})}var ru=_("ZodCustom",(t,e)=>{od.init(t,e),W.init(t,e),t._zod.processJSONSchema=(r,i,n)=>fv(t,r,i,n)});function AE(t){let e=new $e({check:"custom"});return e._zod.check=t,e}function Of(t,e){return Jd(ru,t??(()=>!0),e)}function TA(t,e={}){return Kd(ru,t,e)}function NA(t,e){return Xd(t,e)}var yE=Yd,_E=Wd,zA=_("ZodInstanceOf",(t,e)=>{ru.init(t,e)},{properties(t,e){return this.check(Ao(t,e))}});function bE(t,e={}){let r=new zA({type:"custom",check:"custom",fn:i=>i instanceof t,abort:!0,...I.normalizeParams(e)});return r._zod.bag.Class=t,r._zod.check=i=>{i.value instanceof t||i.issues.push({code:"invalid_type",expected:t.name,input:i.value,inst:r,path:[...r._zod.def.path??[]]})},r}var $E=(...t)=>ef({Codec:tu,Boolean:Po,String:No},...t);function IE(t){let e=kA(()=>be([$(t),ge(),je(),Js(),ie(e),Ee($(),e)]));return e}function nu(t,e){return new IA({type:"pipe",in:Nf(t),out:e})}var LO={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function FO(t){Re({customError:t})}function ZO(){return Re().customError}var PA;PA||(PA={});var si={};jr(si,{ZodISODate:()=>$n,ZodISODateTime:()=>bn,ZodISODuration:()=>wn,ZodISOTime:()=>In,date:()=>qO,datetime:()=>QO,duration:()=>HO,time:()=>VO});function QO(t){return Ms(bn,t)}function qO(t){return Ls($n,t)}function VO(t){return Fs(In,t)}function HO(t){return Zs(wn,t)}var P={...jo,...uf,iso:si},GO=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function JO(t,e){let r=t.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":e??"draft-2020-12"}function wE(t,e){return t.map((r,i)=>i<e?r:r.optional())}function KO(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}function XO(t,e){if(!t.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let r=t.slice(1).split("/").filter(Boolean);if(r.length===0)return e.rootSchema;let i=e.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===i){let n=r[1]===void 0?void 0:KO(r[1]);if(!n||!e.defs[n])throw new Error(`Reference not found: ${t}`);return e.defs[n]}throw new Error(`Reference not found: ${t}`)}function YO(t,e){return P.transform(i=>i).check(i=>{let n=i.value;if(typeof n!="object"||n===null||Array.isArray(n))return;let o=Object.getOwnPropertyNames(n);if(e.minProperties!==void 0&&o.length<e.minProperties&&i.issues.push({origin:"object",code:"too_small",minimum:e.minProperties,inclusive:!0,message:`Too small: expected object to have >=${e.minProperties} properties`,input:n,inst:t,continue:!0}),e.maxProperties!==void 0&&o.length>e.maxProperties&&i.issues.push({origin:"object",code:"too_big",maximum:e.maxProperties,inclusive:!0,message:`Too big: expected object to have <=${e.maxProperties} properties`,input:n,inst:t,continue:!0}),e.keySchema)for(let a of o){let s=e.keySchema.safeParse(a);s.success||i.issues.push({code:"invalid_key",origin:"record",issues:s.error.issues,input:a,path:[a],continue:!0})}}).pipe(t)}function OA(t,e){if(t===null)return"z";let r=typeof t;if(r!=="object"){if(r==="number"&&Number.isNaN(t))return null;let i=String(t);return`${r[0]}${i.length}:${i}`}if(e.has(t))return null;e.add(t);try{if(Array.isArray(t)){let o=[];for(let a of t){let s=OA(a,e);if(s===null)return null;o.push(s)}return`a${o.length}:[${o.join(",")}]`}let i=Object.keys(t).sort(),n=[];for(let o of i){let a=OA(t[o],e);if(a===null)return null;n.push(`${o.length}:${o}=${a}`)}return`o${n.length}:{${n.join(",")}}`}finally{e.delete(t)}}var WO=new Set(["items","prefixItems","additionalItems","additionalProperties","contains","propertyNames","not","if","then","else","allOf","anyOf","oneOf","unevaluatedItems","unevaluatedProperties","contentSchema"]),eR=new Set(["properties","patternProperties","dependentSchemas","dependencies","$defs","definitions"]);function iu(t){return typeof t!="object"||t===null?!1:Array.isArray(t)?t.some(iu):typeof t.$ref=="string"?!0:Object.entries(t).some(([e,r])=>WO.has(e)?iu(r):!eR.has(e)||typeof r!="object"||r===null?!1:Object.values(r).some(iu))}function EE(t){return t===1?"element":"elements"}function tR(t,e){return P.transform(i=>i).check(i=>{let n=i.value;if(Array.isArray(n)){if(e.uniqueItems===!0){let o=new Map;for(let a=0;a<n.length;a++){let s=OA(n[a],new Set);if(s===null)continue;let u=o.get(s);if(u===void 0){o.set(s,a);continue}i.issues.push({code:"custom",message:`Array items must be unique: element at index ${a} duplicates the one at index ${u}`,input:n,path:[a],continue:!0})}}if(e.containsSchema){let o=e.minContains??1,a=e.maxContains!==void 0?e.maxContains+1:Number.POSITIVE_INFINITY,s=0;for(let u of n)if(e.containsSchema.safeParse(u).success&&++s>=a)break;s<o&&i.issues.push({code:"custom",message:`Array must contain at least ${o} matching ${EE(o)}; found ${s}`,input:n,continue:!0}),e.maxContains!==void 0&&s>e.maxContains&&i.issues.push({code:"custom",message:`Array must contain at most ${e.maxContains} matching ${EE(e.maxContains)}`,input:n,continue:!0})}}}).pipe(t)}function xE(t,e){if(t!==!1)return t===void 0||t===!0?P.any():At(t,e)}var rR=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function SE(t,e){if(t.not!==void 0){if(typeof t.not=="object"&&Object.keys(t.not).length===0)return P.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(t.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(t.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(t.if!==void 0||t.then!==void 0||t.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(t.dependentSchemas!==void 0||t.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(t.$ref){let n=t.$ref;if(e.refs.has(n))return e.refs.get(n);if(e.processing.has(n))return P.lazy(()=>{if(!e.refs.has(n))throw new Error(`Circular reference not resolved: ${n}`);return e.refs.get(n)});e.processing.add(n);let o=XO(n,e),a=At(o,e);return e.refs.set(n,a),e.processing.delete(n),a}if(t.enum!==void 0){let n=t.enum;if(e.version==="openapi-3.0"&&t.nullable===!0&&n.length===1&&n[0]===null)return P.null();if(n.length===0)return P.never();if(n.length===1)return P.literal(n[0]);if(n.every(a=>typeof a=="string"))return P.enum(n);let o=n.map(a=>P.literal(a));return o.length<2?o[0]:P.union([o[0],o[1],...o.slice(2)])}if(t.const!==void 0)return P.literal(t.const);let r=t.type;if(Array.isArray(r)){let n=r.map(o=>{let a={...t,type:o};return SE(a,e)});return n.length===0?P.never():n.length===1?n[0]:P.union(n)}if(!r)return P.any();let i;switch(r){case"string":{let n=P.string();if(t.format){let o=t.format;o==="email"?n=n.check(P.email()):o==="uri"||o==="uri-reference"?n=n.check(P.url()):o==="uuid"||o==="guid"?n=n.check(P.uuid()):o==="date-time"?n=n.check(P.iso.datetime({offset:!0})):o==="date"?n=n.check(P.iso.date()):o==="time"?n=n.check(P.regex(rR)):o==="duration"?n=n.check(P.iso.duration()):o==="hostname"?n=n.check(P.hostname()):o==="ipv4"?n=n.check(P.ipv4()):o==="ipv6"?n=n.check(P.ipv6()):o==="mac"?n=n.check(P.mac()):o==="cidr"?n=n.check(P.cidrv4()):o==="cidr-v6"?n=n.check(P.cidrv6()):o==="base64"?n=n.check(P.base64()):o==="base64url"?n=n.check(P.base64url()):o==="e164"?n=n.check(P.e164()):o==="credit_card"?n=n.check(P.creditCard()):o==="iban"?n=n.check(P.iban()):o==="jwt"?n=n.check(P.jwt()):o==="emoji"?n=n.check(P.emoji()):o==="nanoid"?n=n.check(P.nanoid()):o==="cuid"?n=n.check(P.cuid()):o==="cuid2"?n=n.check(P.cuid2()):o==="ulid"?n=n.check(P.ulid()):o==="xid"?n=n.check(P.xid()):o==="ksuid"&&(n=n.check(P.ksuid()))}typeof t.minLength=="number"&&(n=n.min(t.minLength)),typeof t.maxLength=="number"&&(n=n.max(t.maxLength)),t.pattern&&(n=n.regex(new RegExp(t.pattern))),i=n;break}case"number":case"integer":{let n=r==="integer"?P.number().int():P.number();typeof t.minimum=="number"&&t.exclusiveMinimum!==!0&&(n=n.min(t.minimum)),typeof t.maximum=="number"&&t.exclusiveMaximum!==!0&&(n=n.max(t.maximum)),typeof t.exclusiveMinimum=="number"?n=n.gt(t.exclusiveMinimum):t.exclusiveMinimum===!0&&typeof t.minimum=="number"&&(n=n.gt(t.minimum)),typeof t.exclusiveMaximum=="number"?n=n.lt(t.exclusiveMaximum):t.exclusiveMaximum===!0&&typeof t.maximum=="number"&&(n=n.lt(t.maximum)),typeof t.multipleOf=="number"&&(n=n.multipleOf(t.multipleOf)),i=n;break}case"boolean":{i=P.boolean();break}case"null":{i=P.null();break}case"object":{let n={},o=t.properties||{},a=new Set(t.required||[]),s=typeof t.additionalProperties=="object"?At(t.additionalProperties,e):void 0;for(let[d,p]of Object.entries(o)){let m=At(p,e);Xe(n,d,a.has(d)?m:m.optional())}if(t.patternProperties){let d=t.patternProperties,p=Object.keys(d),m=[];for(let f of p){let g=At(d[f],e),y=P.string().regex(new RegExp(f));m.push(P.looseRecord(y,g))}let h=[];if(Object.keys(n).length>0&&h.push(P.object(n).passthrough()),h.push(...m),h.length===0)i=P.object({}).passthrough();else if(h.length===1)i=h[0];else{let f=P.intersection(h[0],h[1]);for(let g=2;g<h.length;g++)f=P.intersection(f,h[g]);i=f}if(t.additionalProperties===!1){let f=Object.keys(n),g=p.map(v=>new RegExp(v)),y=i;i=i.check(v=>{if(!Jt(v.value))return;let A=[];for(let x of Object.keys(v.value))f.includes(x)||g.some(k=>k.test(x))||A.push(x);A.length&&v.issues.push({code:"unrecognized_keys",keys:A,input:v.value,inst:y})})}}else{let d=P.object(n);t.additionalProperties===!1?i=d.strict():s?i=d.catchall(s):i=d.passthrough()}let u=t.propertyNames!==void 0&&t.propertyNames!==!0,c=typeof t.minProperties=="number"?t.minProperties:void 0,l=typeof t.maxProperties=="number"?t.maxProperties:void 0;if(u||c!==void 0||l!==void 0){let d;if(u){let p=typeof t.propertyNames=="object"&&t.propertyNames.type===void 0?{type:"string",...t.propertyNames}:t.propertyNames;d=At(p,e)}i=YO(i,{keySchema:d,minProperties:c,maxProperties:l})}break}case"array":{let n=t.prefixItems,o=t.items;if(n&&Array.isArray(n)){let a=typeof t.minItems=="number"?t.minItems:0,s=n.map(d=>At(d,e)),u=wE(s,a),c=Array.isArray(o)?void 0:xE(o,e),l=P.tuple(u);i=c?l.rest(c):l,typeof t.minItems=="number"&&(i=i.check(P.minLength(t.minItems))),typeof t.maxItems=="number"&&(i=i.check(P.maxLength(t.maxItems)))}else if(Array.isArray(o)){let a=typeof t.minItems=="number"?t.minItems:0,s=o.map(d=>At(d,e)),u=wE(s,a),c=xE(t.additionalItems,e),l=P.tuple(u);i=c?l.rest(c):l,typeof t.minItems=="number"&&(i=i.check(P.minLength(t.minItems))),typeof t.maxItems=="number"&&(i=i.check(P.maxLength(t.maxItems)))}else if(o!==void 0){let a=At(o,e),s=P.array(a);typeof t.minItems=="number"&&(s=s.min(t.minItems)),typeof t.maxItems=="number"&&(s=s.max(t.maxItems)),i=s}else i=P.array(P.any());(t.uniqueItems===!0||t.contains!==void 0)&&(i=tR(i,{uniqueItems:t.uniqueItems===!0,containsSchema:t.contains!==void 0?At(t.contains,e):void 0,minContains:typeof t.minContains=="number"?t.minContains:void 0,maxContains:typeof t.maxContains=="number"?t.maxContains:void 0}));break}default:throw new Error(`Unsupported type: ${r}`)}return i}function At(t,e){if(typeof t=="boolean")return t?P.any():P.never();let r=SE(t,e),i=t.type||t.enum!==void 0||t.const!==void 0;if(t.anyOf&&Array.isArray(t.anyOf)){let s=t.anyOf.map(c=>At(c,e)),u=P.union(s);r=i?P.intersection(r,u):u}if(t.oneOf&&Array.isArray(t.oneOf)){let s=t.oneOf.map(c=>At(c,e)),u=P.xor(s);r=i?P.intersection(r,u):u}if(t.allOf&&Array.isArray(t.allOf))if(t.allOf.length===0)r=i?r:P.any();else{let s=i?r:At(t.allOf[0],e),u=i?0:1;for(let c=u;c<t.allOf.length;c++)s=P.intersection(s,At(t.allOf[c],e));r=s}t.nullable===!0&&e.version==="openapi-3.0"&&(r=P.nullable(r)),t.readOnly===!0&&(r=P.readonly(r)),t.default!==void 0&&(r=r.default(t.default));let n={},o=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let s of o)s in t&&(n[s]=t[s]);let a=["contentEncoding","contentMediaType","contentSchema"];for(let s of a)s in t&&(n[s]=t[s]);if(t.type==="object"&&t.$ref===void 0){t.propertyNames!==void 0&&!iu(t.propertyNames)&&(n.propertyNames=t.propertyNames);for(let s of["minProperties","maxProperties"])t[s]!==void 0&&(n[s]=t[s])}if(t.type==="array"&&t.$ref===void 0){t.contains!==void 0&&!iu(t.contains)&&(n.contains=t.contains);for(let s of["uniqueItems","minContains","maxContains"])t[s]!==void 0&&(n[s]=t[s])}for(let s of Object.keys(t))GO.has(s)||Xe(n,s,t[s]);return Object.keys(n).length>0&&e.registry.add(r,n),t.description&&(r=r.describe(t.description)),r}function kE(t,e){if(typeof t=="boolean")return t?P.any():P.never();let r;try{r=JSON.parse(JSON.stringify(t))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let i=JO(r,e?.defaultTarget),n=r.$defs||r.definitions||{},o={version:i,defs:n,refs:new Map,processing:new Set,rootSchema:r,registry:e?.registry??Ye};return At(r,o)}function CE(t){return Vs(t,{object:e=>e.partial(),union:e=>{let r=e._zod.def;return r.discriminator===void 0?e:be(r.options)}})}function nR(t,e){if(!e?.length)return t;let r=t._zod.def;return he(t,Gt(r,{checks:[...r.checks??[],...e]}),{parent:!0})}function DE(t){return nR(t.out,t.checks)}function iR(t){return t.in._zod.traits.has("$ZodTransform")?DE(t):t.in}function TE(t){return Vs(t,{pipe:e=>iR(e._zod.def),default:(e,r)=>r?Ie(e._zod.def.innerType):e,catch:(e,r)=>r?e._zod.def.innerType:e})}function NE(t){return Vs(t,{pipe:e=>DE(e._zod.def),prefault:(e,r)=>r?e._zod.def.innerType:e})}var RA={};jr(RA,{bigint:()=>uR,boolean:()=>sR,date:()=>cR,number:()=>aR,string:()=>oR});function oR(t){return jg(No,t)}function aR(t){return Ug(zo,t)}function sR(t){return Mg(Po,t)}function uR(t){return Lg(Oo,t)}function cR(t){return Fg(Ks,t)}var BA="2025-11-25";var zE=[BA,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],En="io.modelcontextprotocol/related-task",jf="2.0",Qe=Of(t=>t!==null&&(typeof t=="object"||typeof t=="function")),PE=be([$(),ge().int()]),OE=$(),mH=We({ttl:ge().optional(),pollInterval:ge().optional()}),lR=O({ttl:ge().optional()}),dR=O({taskId:$()}),UA=We({progressToken:PE.optional(),[En]:dR.optional()}),Zt=O({_meta:UA.optional()}),ou=Zt.extend({task:lR.optional()}),RE=t=>ou.safeParse(t).success,tt=O({method:$(),params:Zt.loose().optional()}),Xt=O({_meta:UA.optional()}),Yt=O({method:$(),params:Xt.loose().optional()}),rt=We({_meta:UA.optional()}),Bf=be([$(),ge().int()]),jE=O({jsonrpc:L(jf),id:Bf,...tt.shape}).strict(),MA=t=>jE.safeParse(t).success,BE=O({jsonrpc:L(jf),...Yt.shape}).strict(),UE=t=>BE.safeParse(t).success,LA=O({jsonrpc:L(jf),id:Bf,result:rt}).strict(),au=t=>LA.safeParse(t).success;var F;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(F||(F={}));var FA=O({jsonrpc:L(jf),id:Bf.optional(),error:O({code:ge().int(),message:$(),data:ke().optional()})}).strict();var ME=t=>FA.safeParse(t).success;var LE=be([jE,BE,LA,FA]),hH=be([LA,FA]),Uf=rt.strict(),fR=Xt.extend({requestId:Bf.optional(),reason:$().optional()}),Mf=Yt.extend({method:L("notifications/cancelled"),params:fR}),pR=O({src:$(),mimeType:$().optional(),sizes:ie($()).optional(),theme:et(["light","dark"]).optional()}),su=O({icons:ie(pR).optional()}),Bo=O({name:$(),title:$().optional()}),FE=Bo.extend({...Bo.shape,...su.shape,version:$(),websiteUrl:$().optional(),description:$().optional()}),mR=Ro(O({applyDefaults:je().optional()}),Ee($(),ke())),hR=nu(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,Ro(O({form:mR.optional(),url:Qe.optional()}),Ee($(),ke()).optional())),gR=We({list:Qe.optional(),cancel:Qe.optional(),requests:We({sampling:We({createMessage:Qe.optional()}).optional(),elicitation:We({create:Qe.optional()}).optional()}).optional()}),vR=We({list:Qe.optional(),cancel:Qe.optional(),requests:We({tools:We({call:Qe.optional()}).optional()}).optional()}),AR=O({experimental:Ee($(),Qe).optional(),sampling:O({context:Qe.optional(),tools:Qe.optional()}).optional(),elicitation:hR.optional(),roots:O({listChanged:je().optional()}).optional(),tasks:gR.optional(),extensions:Ee($(),Qe).optional()}),yR=Zt.extend({protocolVersion:$(),capabilities:AR,clientInfo:FE}),ZA=tt.extend({method:L("initialize"),params:yR});var _R=O({experimental:Ee($(),Qe).optional(),logging:Qe.optional(),completions:Qe.optional(),prompts:O({listChanged:je().optional()}).optional(),resources:O({subscribe:je().optional(),listChanged:je().optional()}).optional(),tools:O({listChanged:je().optional()}).optional(),tasks:vR.optional(),extensions:Ee($(),Qe).optional()}),bR=rt.extend({protocolVersion:$(),capabilities:_R,serverInfo:FE,instructions:$().optional()}),QA=Yt.extend({method:L("notifications/initialized"),params:Xt.optional()});var Lf=tt.extend({method:L("ping"),params:Zt.optional()}),$R=O({progress:ge(),total:Ie(ge()),message:Ie($())}),IR=O({...Xt.shape,...$R.shape,progressToken:PE}),Ff=Yt.extend({method:L("notifications/progress"),params:IR}),wR=Zt.extend({cursor:OE.optional()}),uu=tt.extend({params:wR.optional()}),cu=rt.extend({nextCursor:OE.optional()}),ER=et(["working","input_required","completed","failed","cancelled"]),lu=O({taskId:$(),status:ER,ttl:be([ge(),Js()]),createdAt:$(),lastUpdatedAt:$(),pollInterval:Ie(ge()),statusMessage:Ie($())}),Uo=rt.extend({task:lu}),xR=Xt.merge(lu),du=Yt.extend({method:L("notifications/tasks/status"),params:xR}),Zf=tt.extend({method:L("tasks/get"),params:Zt.extend({taskId:$()})}),Qf=rt.merge(lu),qf=tt.extend({method:L("tasks/result"),params:Zt.extend({taskId:$()})}),gH=rt.loose(),Vf=uu.extend({method:L("tasks/list")}),Hf=cu.extend({tasks:ie(lu)}),Gf=tt.extend({method:L("tasks/cancel"),params:Zt.extend({taskId:$()})}),ZE=rt.merge(lu),QE=O({uri:$(),mimeType:Ie($()),_meta:Ee($(),ke()).optional()}),qE=QE.extend({text:$()}),qA=$().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),VE=QE.extend({blob:qA}),fu=et(["user","assistant"]),Mo=O({audience:ie(fu).optional(),priority:ge().min(0).max(1).optional(),lastModified:si.datetime({offset:!0}).optional()}),HE=O({...Bo.shape,...su.shape,uri:$(),description:Ie($()),mimeType:Ie($()),size:Ie(ge()),annotations:Mo.optional(),_meta:Ie(We({}))}),SR=O({...Bo.shape,...su.shape,uriTemplate:$(),description:Ie($()),mimeType:Ie($()),annotations:Mo.optional(),_meta:Ie(We({}))}),Jf=uu.extend({method:L("resources/list")}),kR=cu.extend({resources:ie(HE)}),Kf=uu.extend({method:L("resources/templates/list")}),CR=cu.extend({resourceTemplates:ie(SR)}),VA=Zt.extend({uri:$()}),DR=VA,Xf=tt.extend({method:L("resources/read"),params:DR}),TR=rt.extend({contents:ie(be([qE,VE]))}),NR=Yt.extend({method:L("notifications/resources/list_changed"),params:Xt.optional()}),zR=VA,PR=tt.extend({method:L("resources/subscribe"),params:zR}),OR=VA,RR=tt.extend({method:L("resources/unsubscribe"),params:OR}),jR=Xt.extend({uri:$()}),BR=Yt.extend({method:L("notifications/resources/updated"),params:jR}),UR=O({name:$(),description:Ie($()),required:Ie(je())}),MR=O({...Bo.shape,...su.shape,description:Ie($()),arguments:Ie(ie(UR)),_meta:Ie(We({}))}),Yf=uu.extend({method:L("prompts/list")}),LR=cu.extend({prompts:ie(MR)}),FR=Zt.extend({name:$(),arguments:Ee($(),$()).optional()}),Wf=tt.extend({method:L("prompts/get"),params:FR}),HA=O({type:L("text"),text:$(),annotations:Mo.optional(),_meta:Ee($(),ke()).optional()}),GA=O({type:L("image"),data:qA,mimeType:$(),annotations:Mo.optional(),_meta:Ee($(),ke()).optional()}),JA=O({type:L("audio"),data:qA,mimeType:$(),annotations:Mo.optional(),_meta:Ee($(),ke()).optional()}),ZR=O({type:L("tool_use"),name:$(),id:$(),input:Ee($(),ke()),_meta:Ee($(),ke()).optional()}),QR=O({type:L("resource"),resource:be([qE,VE]),annotations:Mo.optional(),_meta:Ee($(),ke()).optional()}),qR=HE.extend({type:L("resource_link")}),KA=be([HA,GA,JA,qR,QR]),VR=O({role:fu,content:KA}),HR=rt.extend({description:$().optional(),messages:ie(VR)}),GR=Yt.extend({method:L("notifications/prompts/list_changed"),params:Xt.optional()}),JR=O({title:$().optional(),readOnlyHint:je().optional(),destructiveHint:je().optional(),idempotentHint:je().optional(),openWorldHint:je().optional()}),KR=O({taskSupport:et(["required","optional","forbidden"]).optional()}),GE=O({...Bo.shape,...su.shape,description:$().optional(),inputSchema:O({type:L("object"),properties:Ee($(),Qe).optional(),required:ie($()).optional()}).catchall(ke()),outputSchema:O({type:L("object"),properties:Ee($(),Qe).optional(),required:ie($()).optional()}).catchall(ke()).optional(),annotations:JR.optional(),execution:KR.optional(),_meta:Ee($(),ke()).optional()}),ep=uu.extend({method:L("tools/list")}),XR=cu.extend({tools:ie(GE)}),tp=rt.extend({content:ie(KA).default([]),structuredContent:Ee($(),ke()).optional(),isError:je().optional()}),vH=tp.or(rt.extend({toolResult:ke()})),YR=ou.extend({name:$(),arguments:Ee($(),ke()).optional()}),Lo=tt.extend({method:L("tools/call"),params:YR}),WR=Yt.extend({method:L("notifications/tools/list_changed"),params:Xt.optional()}),AH=O({autoRefresh:je().default(!0),debounceMs:ge().int().nonnegative().default(300)}),pu=et(["debug","info","notice","warning","error","critical","alert","emergency"]),e4=Zt.extend({level:pu}),XA=tt.extend({method:L("logging/setLevel"),params:e4}),t4=Xt.extend({level:pu,logger:$().optional(),data:ke()}),r4=Yt.extend({method:L("notifications/message"),params:t4}),n4=O({name:$().optional()}),i4=O({hints:ie(n4).optional(),costPriority:ge().min(0).max(1).optional(),speedPriority:ge().min(0).max(1).optional(),intelligencePriority:ge().min(0).max(1).optional()}),o4=O({mode:et(["auto","required","none"]).optional()}),a4=O({type:L("tool_result"),toolUseId:$().describe("The unique identifier for the corresponding tool call."),content:ie(KA).default([]),structuredContent:O({}).loose().optional(),isError:je().optional(),_meta:Ee($(),ke()).optional()}),s4=Ws("type",[HA,GA,JA]),Rf=Ws("type",[HA,GA,JA,ZR,a4]),u4=O({role:fu,content:be([Rf,ie(Rf)]),_meta:Ee($(),ke()).optional()}),c4=ou.extend({messages:ie(u4),modelPreferences:i4.optional(),systemPrompt:$().optional(),includeContext:et(["none","thisServer","allServers"]).optional(),temperature:ge().optional(),maxTokens:ge().int(),stopSequences:ie($()).optional(),metadata:Qe.optional(),tools:ie(GE).optional(),toolChoice:o4.optional()}),l4=tt.extend({method:L("sampling/createMessage"),params:c4}),mu=rt.extend({model:$(),stopReason:Ie(et(["endTurn","stopSequence","maxTokens"]).or($())),role:fu,content:s4}),YA=rt.extend({model:$(),stopReason:Ie(et(["endTurn","stopSequence","maxTokens","toolUse"]).or($())),role:fu,content:be([Rf,ie(Rf)])}),d4=O({type:L("boolean"),title:$().optional(),description:$().optional(),default:je().optional()}),f4=O({type:L("string"),title:$().optional(),description:$().optional(),minLength:ge().optional(),maxLength:ge().optional(),format:et(["email","uri","date","date-time"]).optional(),default:$().optional()}),p4=O({type:et(["number","integer"]),title:$().optional(),description:$().optional(),minimum:ge().optional(),maximum:ge().optional(),default:ge().optional()}),m4=O({type:L("string"),title:$().optional(),description:$().optional(),enum:ie($()),default:$().optional()}),h4=O({type:L("string"),title:$().optional(),description:$().optional(),oneOf:ie(O({const:$(),title:$()})),default:$().optional()}),g4=O({type:L("string"),title:$().optional(),description:$().optional(),enum:ie($()),enumNames:ie($()).optional(),default:$().optional()}),v4=be([m4,h4]),A4=O({type:L("array"),title:$().optional(),description:$().optional(),minItems:ge().optional(),maxItems:ge().optional(),items:O({type:L("string"),enum:ie($())}),default:ie($()).optional()}),y4=O({type:L("array"),title:$().optional(),description:$().optional(),minItems:ge().optional(),maxItems:ge().optional(),items:O({anyOf:ie(O({const:$(),title:$()}))}),default:ie($()).optional()}),_4=be([A4,y4]),b4=be([g4,v4,_4]),$4=be([b4,d4,f4,p4]),I4=ou.extend({mode:L("form").optional(),message:$(),requestedSchema:O({type:L("object"),properties:Ee($(),$4),required:ie($()).optional()})}),w4=ou.extend({mode:L("url"),message:$(),elicitationId:$(),url:$().url()}),E4=be([I4,w4]),x4=tt.extend({method:L("elicitation/create"),params:E4}),S4=Xt.extend({elicitationId:$()}),k4=Yt.extend({method:L("notifications/elicitation/complete"),params:S4}),Fo=rt.extend({action:et(["accept","decline","cancel"]),content:nu(t=>t===null?void 0:t,Ee($(),be([$(),ge(),je(),ie($())])).optional())}),C4=O({type:L("ref/resource"),uri:$()});var D4=O({type:L("ref/prompt"),name:$()}),T4=Zt.extend({ref:be([D4,C4]),argument:O({name:$(),value:$()}),context:O({arguments:Ee($(),$()).optional()}).optional()}),rp=tt.extend({method:L("completion/complete"),params:T4});function JE(t){if(t.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${t.params.ref.type}`)}function KE(t){if(t.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${t.params.ref.type}`)}var N4=rt.extend({completion:We({values:ie($()).max(100),total:Ie(ge().int()),hasMore:Ie(je())})}),z4=O({uri:$().startsWith("file://"),name:$().optional(),_meta:Ee($(),ke()).optional()}),P4=tt.extend({method:L("roots/list"),params:Zt.optional()}),WA=rt.extend({roots:ie(z4)}),O4=Yt.extend({method:L("notifications/roots/list_changed"),params:Xt.optional()}),yH=be([Lf,ZA,rp,XA,Wf,Yf,Jf,Kf,Xf,PR,RR,Lo,ep,Zf,qf,Vf,Gf]),_H=be([Mf,Ff,QA,O4,du]),bH=be([Uf,mu,YA,Fo,WA,Qf,Hf,Uo]),$H=be([Lf,l4,x4,P4,Zf,qf,Vf,Gf]),IH=be([Mf,Ff,r4,BR,NR,WR,GR,du,k4]),wH=be([Uf,bR,N4,HR,LR,kR,CR,TR,tp,XR,Qf,Hf,Uo]),B=class t extends Error{constructor(e,r,i){super(`MCP error ${e}: ${r}`),this.code=e,this.data=i,this.name="McpError"}static fromError(e,r,i){if(e===F.UrlElicitationRequired&&i){let n=i;if(n.elicitations)return new jA(n.elicitations,r)}return new t(e,r,i)}},jA=class extends B{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(F.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function xn(t){return t==="completed"||t==="failed"||t==="cancelled"}var YE=Symbol("Let zodToJsonSchema decide on which parser to use");var XE={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},WE=t=>typeof t=="string"?{...XE,name:t}:{...XE,...t};var ex=t=>{let e=WE(t),r=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([i,n])=>[n._def,{def:n._def,path:[...e.basePath,e.definitionPath,i],jsonSchema:void 0}]))}};function ey(t,e,r,i){i?.errorMessages&&r&&(t.errorMessage={...t.errorMessage,[e]:r})}function ce(t,e,r,i,n){t[e]=r,ey(t,e,i,n)}var np=(t,e)=>{let r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];r++);return[(t.length-r).toString(),...e.slice(r)].join("/")};function Pe(t){if(t.target!=="openAi")return{};let e=[...t.basePath,t.definitionPath,t.openAiAnyTypeName];return t.flags.hasReferencedOpenAiAnyType=!0,{$ref:t.$refStrategy==="relative"?np(e,t.currentPath):e.join("/")}}function tx(t,e){let r={type:"array"};return t.type?._def&&t.type?._def?.typeName!==T.ZodAny&&(r.items=H(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&ce(r,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&ce(r,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(ce(r,"minItems",t.exactLength.value,t.exactLength.message,e),ce(r,"maxItems",t.exactLength.value,t.exactLength.message,e)),r}function rx(t,e){let r={type:"integer",format:"int64"};if(!t.checks)return r;for(let i of t.checks)switch(i.kind){case"min":e.target==="jsonSchema7"?i.inclusive?ce(r,"minimum",i.value,i.message,e):ce(r,"exclusiveMinimum",i.value,i.message,e):(i.inclusive||(r.exclusiveMinimum=!0),ce(r,"minimum",i.value,i.message,e));break;case"max":e.target==="jsonSchema7"?i.inclusive?ce(r,"maximum",i.value,i.message,e):ce(r,"exclusiveMaximum",i.value,i.message,e):(i.inclusive||(r.exclusiveMaximum=!0),ce(r,"maximum",i.value,i.message,e));break;case"multipleOf":ce(r,"multipleOf",i.value,i.message,e);break}return r}function nx(){return{type:"boolean"}}function ip(t,e){return H(t.type._def,e)}var ix=(t,e)=>H(t.innerType._def,e);function ty(t,e,r){let i=r??e.dateStrategy;if(Array.isArray(i))return{anyOf:i.map((n,o)=>ty(t,e,n))};switch(i){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return R4(t,e)}}var R4=(t,e)=>{let r={type:"integer",format:"unix-time"};if(e.target==="openApi3")return r;for(let i of t.checks)switch(i.kind){case"min":ce(r,"minimum",i.value,i.message,e);break;case"max":ce(r,"maximum",i.value,i.message,e);break}return r};function ox(t,e){return{...H(t.innerType._def,e),default:t.defaultValue()}}function ax(t,e){return e.effectStrategy==="input"?H(t.schema._def,e):Pe(e)}function sx(t){return{type:"string",enum:Array.from(t.values)}}var j4=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function ux(t,e){let r=[H(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),H(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(o=>!!o),i=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,n=[];return r.forEach(o=>{if(j4(o))n.push(...o.allOf),o.unevaluatedProperties===void 0&&(i=void 0);else{let a=o;if("additionalProperties"in o&&o.additionalProperties===!1){let{additionalProperties:s,...u}=o;a=u}else i=void 0;n.push(a)}}),n.length?{allOf:n,...i}:void 0}function cx(t,e){let r=typeof t.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[t.value]}:{type:r==="bigint"?"integer":r,const:t.value}}var ry,lr={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(ry===void 0&&(ry=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),ry),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?: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])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function op(t,e){let r={type:"string"};if(t.checks)for(let i of t.checks)switch(i.kind){case"min":ce(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,i.value):i.value,i.message,e);break;case"max":ce(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,i.value):i.value,i.message,e);break;case"email":switch(e.emailStrategy){case"format:email":dr(r,"email",i.message,e);break;case"format:idn-email":dr(r,"idn-email",i.message,e);break;case"pattern:zod":yt(r,lr.email,i.message,e);break}break;case"url":dr(r,"uri",i.message,e);break;case"uuid":dr(r,"uuid",i.message,e);break;case"regex":yt(r,i.regex,i.message,e);break;case"cuid":yt(r,lr.cuid,i.message,e);break;case"cuid2":yt(r,lr.cuid2,i.message,e);break;case"startsWith":yt(r,RegExp(`^${ny(i.value,e)}`),i.message,e);break;case"endsWith":yt(r,RegExp(`${ny(i.value,e)}$`),i.message,e);break;case"datetime":dr(r,"date-time",i.message,e);break;case"date":dr(r,"date",i.message,e);break;case"time":dr(r,"time",i.message,e);break;case"duration":dr(r,"duration",i.message,e);break;case"length":ce(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,i.value):i.value,i.message,e),ce(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,i.value):i.value,i.message,e);break;case"includes":{yt(r,RegExp(ny(i.value,e)),i.message,e);break}case"ip":{i.version!=="v6"&&dr(r,"ipv4",i.message,e),i.version!=="v4"&&dr(r,"ipv6",i.message,e);break}case"base64url":yt(r,lr.base64url,i.message,e);break;case"jwt":yt(r,lr.jwt,i.message,e);break;case"cidr":{i.version!=="v6"&&yt(r,lr.ipv4Cidr,i.message,e),i.version!=="v4"&&yt(r,lr.ipv6Cidr,i.message,e);break}case"emoji":yt(r,lr.emoji(),i.message,e);break;case"ulid":{yt(r,lr.ulid,i.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{dr(r,"binary",i.message,e);break}case"contentEncoding:base64":{ce(r,"contentEncoding","base64",i.message,e);break}case"pattern:zod":{yt(r,lr.base64,i.message,e);break}}break}case"nanoid":yt(r,lr.nanoid,i.message,e);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function ny(t,e){return e.patternStrategy==="escape"?U4(t):t}var B4=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function U4(t){let e="";for(let r=0;r<t.length;r++)B4.has(t[r])||(e+="\\"),e+=t[r];return e}function dr(t,e,r,i){t.format||t.anyOf?.some(n=>n.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format,...t.errorMessage&&i.errorMessages&&{errorMessage:{format:t.errorMessage.format}}}),delete t.format,t.errorMessage&&(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.anyOf.push({format:e,...r&&i.errorMessages&&{errorMessage:{format:r}}})):ce(t,"format",e,r,i)}function yt(t,e,r,i){t.pattern||t.allOf?.some(n=>n.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern,...t.errorMessage&&i.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}}}),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.allOf.push({pattern:lx(e,i),...r&&i.errorMessages&&{errorMessage:{pattern:r}}})):ce(t,"pattern",lx(e,i),r,i)}function lx(t,e){if(!e.applyRegexFlags||!t.flags)return t.source;let r={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},i=r.i?t.source.toLowerCase():t.source,n="",o=!1,a=!1,s=!1;for(let u=0;u<i.length;u++){if(o){n+=i[u],o=!1;continue}if(r.i){if(a){if(i[u].match(/[a-z]/)){s?(n+=i[u],n+=`${i[u-2]}-${i[u]}`.toUpperCase(),s=!1):i[u+1]==="-"&&i[u+2]?.match(/[a-z]/)?(n+=i[u],s=!0):n+=`${i[u]}${i[u].toUpperCase()}`;continue}}else if(i[u].match(/[a-z]/)){n+=`[${i[u]}${i[u].toUpperCase()}]`;continue}}if(r.m){if(i[u]==="^"){n+=`(^|(?<=[\r
|
|
79
79
|
]))`;continue}else if(i[u]==="$"){n+=`($|(?=[\r
|
|
80
80
|
]))`;continue}}if(r.s&&i[u]==="."){n+=a?`${i[u]}\r
|
|
81
81
|
`:`[${i[u]}\r
|
|
82
82
|
]`;continue}n+=i[u],i[u]==="\\"?o=!0:a&&i[u]==="]"?a=!1:!a&&i[u]==="["&&(a=!0)}try{new RegExp(n)}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),t.source}return n}function ap(t,e){if(e.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),e.target==="openApi3"&&t.keyType?._def.typeName===T.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((i,n)=>({...i,[n]:H(t.valueType._def,{...e,currentPath:[...e.currentPath,"properties",n]})??Pe(e)}),{}),additionalProperties:e.rejectedAdditionalProperties};let r={type:"object",additionalProperties:H(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return r;if(t.keyType?._def.typeName===T.ZodString&&t.keyType._def.checks?.length){let{type:i,...n}=op(t.keyType._def,e);return{...r,propertyNames:n}}else{if(t.keyType?._def.typeName===T.ZodEnum)return{...r,propertyNames:{enum:t.keyType._def.values}};if(t.keyType?._def.typeName===T.ZodBranded&&t.keyType._def.type._def.typeName===T.ZodString&&t.keyType._def.type._def.checks?.length){let{type:i,...n}=ip(t.keyType._def,e);return{...r,propertyNames:n}}}return r}function dx(t,e){if(e.mapStrategy==="record")return ap(t,e);let r=H(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||Pe(e),i=H(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||Pe(e);return{type:"array",maxItems:125,items:{type:"array",items:[r,i],minItems:2,maxItems:2}}}function fx(t){let e=t.values,i=Object.keys(t.values).filter(o=>typeof e[e[o]]!="number").map(o=>e[o]),n=Array.from(new Set(i.map(o=>typeof o)));return{type:n.length===1?n[0]==="string"?"string":"number":["string","number"],enum:i}}function px(t){return t.target==="openAi"?void 0:{not:Pe({...t,currentPath:[...t.currentPath,"not"]})}}function mx(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var hu={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function gx(t,e){if(e.target==="openApi3")return hx(t,e);let r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(i=>i._def.typeName in hu&&(!i._def.checks||!i._def.checks.length))){let i=r.reduce((n,o)=>{let a=hu[o._def.typeName];return a&&!n.includes(a)?[...n,a]:n},[]);return{type:i.length>1?i:i[0]}}else if(r.every(i=>i._def.typeName==="ZodLiteral"&&!i.description)){let i=r.reduce((n,o)=>{let a=typeof o._def.value;switch(a){case"string":case"number":case"boolean":return[...n,a];case"bigint":return[...n,"integer"];case"object":if(o._def.value===null)return[...n,"null"];default:return n}},[]);if(i.length===r.length){let n=i.filter((o,a,s)=>s.indexOf(o)===a);return{type:n.length>1?n:n[0],enum:r.reduce((o,a)=>o.includes(a._def.value)?o:[...o,a._def.value],[])}}}else if(r.every(i=>i._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((i,n)=>[...i,...n._def.values.filter(o=>!i.includes(o))],[])};return hx(t,e)}var hx=(t,e)=>{let r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((i,n)=>H(i._def,{...e,currentPath:[...e.currentPath,"anyOf",`${n}`]})).filter(i=>!!i&&(!e.strictUnions||typeof i=="object"&&Object.keys(i).length>0));return r.length?{anyOf:r}:void 0};function vx(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return e.target==="openApi3"?{type:hu[t.innerType._def.typeName],nullable:!0}:{type:[hu[t.innerType._def.typeName],"null"]};if(e.target==="openApi3"){let i=H(t.innerType._def,{...e,currentPath:[...e.currentPath]});return i&&"$ref"in i?{allOf:[i],nullable:!0}:i&&{...i,nullable:!0}}let r=H(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function Ax(t,e){let r={type:"number"};if(!t.checks)return r;for(let i of t.checks)switch(i.kind){case"int":r.type="integer",ey(r,"type",i.message,e);break;case"min":e.target==="jsonSchema7"?i.inclusive?ce(r,"minimum",i.value,i.message,e):ce(r,"exclusiveMinimum",i.value,i.message,e):(i.inclusive||(r.exclusiveMinimum=!0),ce(r,"minimum",i.value,i.message,e));break;case"max":e.target==="jsonSchema7"?i.inclusive?ce(r,"maximum",i.value,i.message,e):ce(r,"exclusiveMaximum",i.value,i.message,e):(i.inclusive||(r.exclusiveMaximum=!0),ce(r,"maximum",i.value,i.message,e));break;case"multipleOf":ce(r,"multipleOf",i.value,i.message,e);break}return r}function yx(t,e){let r=e.target==="openAi",i={type:"object",properties:{}},n=[],o=t.shape();for(let s in o){let u=o[s];if(u===void 0||u._def===void 0)continue;let c=L4(u);c&&r&&(u._def.typeName==="ZodOptional"&&(u=u._def.innerType),u.isNullable()||(u=u.nullable()),c=!1);let l=H(u._def,{...e,currentPath:[...e.currentPath,"properties",s],propertyPath:[...e.currentPath,"properties",s]});l!==void 0&&(i.properties[s]=l,c||n.push(s))}n.length&&(i.required=n);let a=M4(t,e);return a!==void 0&&(i.additionalProperties=a),i}function M4(t,e){if(t.catchall._def.typeName!=="ZodNever")return H(t.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]});switch(t.unknownKeys){case"passthrough":return e.allowedAdditionalProperties;case"strict":return e.rejectedAdditionalProperties;case"strip":return e.removeAdditionalStrategy==="strict"?e.allowedAdditionalProperties:e.rejectedAdditionalProperties}}function L4(t){try{return t.isOptional()}catch{return!0}}var _x=(t,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return H(t.innerType._def,e);let r=H(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return r?{anyOf:[{not:Pe(e)},r]}:Pe(e)};var bx=(t,e)=>{if(e.pipeStrategy==="input")return H(t.in._def,e);if(e.pipeStrategy==="output")return H(t.out._def,e);let r=H(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),i=H(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,i].filter(n=>n!==void 0)}};function $x(t,e){return H(t.type._def,e)}function Ix(t,e){let i={type:"array",uniqueItems:!0,items:H(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&ce(i,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&ce(i,"maxItems",t.maxSize.value,t.maxSize.message,e),i}function wx(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,i)=>H(r._def,{...e,currentPath:[...e.currentPath,"items",`${i}`]})).reduce((r,i)=>i===void 0?r:[...r,i],[]),additionalItems:H(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,i)=>H(r._def,{...e,currentPath:[...e.currentPath,"items",`${i}`]})).reduce((r,i)=>i===void 0?r:[...r,i],[])}}function Ex(t){return{not:Pe(t)}}function xx(t){return Pe(t)}var Sx=(t,e)=>H(t.innerType._def,e);var kx=(t,e,r)=>{switch(e){case T.ZodString:return op(t,r);case T.ZodNumber:return Ax(t,r);case T.ZodObject:return yx(t,r);case T.ZodBigInt:return rx(t,r);case T.ZodBoolean:return nx();case T.ZodDate:return ty(t,r);case T.ZodUndefined:return Ex(r);case T.ZodNull:return mx(r);case T.ZodArray:return tx(t,r);case T.ZodUnion:case T.ZodDiscriminatedUnion:return gx(t,r);case T.ZodIntersection:return ux(t,r);case T.ZodTuple:return wx(t,r);case T.ZodRecord:return ap(t,r);case T.ZodLiteral:return cx(t,r);case T.ZodEnum:return sx(t);case T.ZodNativeEnum:return fx(t);case T.ZodNullable:return vx(t,r);case T.ZodOptional:return _x(t,r);case T.ZodMap:return dx(t,r);case T.ZodSet:return Ix(t,r);case T.ZodLazy:return()=>t.getter()._def;case T.ZodPromise:return $x(t,r);case T.ZodNaN:case T.ZodNever:return px(r);case T.ZodEffects:return ax(t,r);case T.ZodAny:return Pe(r);case T.ZodUnknown:return xx(r);case T.ZodDefault:return ox(t,r);case T.ZodBranded:return ip(t,r);case T.ZodReadonly:return Sx(t,r);case T.ZodCatch:return ix(t,r);case T.ZodPipeline:return bx(t,r);case T.ZodFunction:case T.ZodVoid:case T.ZodSymbol:return;default:return(i=>{})(e)}};function H(t,e,r=!1){let i=e.seen.get(t);if(e.override){let s=e.override?.(t,e,i,r);if(s!==YE)return s}if(i&&!r){let s=F4(i,e);if(s!==void 0)return s}let n={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,n);let o=kx(t,t.typeName,e),a=typeof o=="function"?H(o(),e):o;if(a&&Z4(t,e,a),e.postProcess){let s=e.postProcess(a,t,e);return n.jsonSchema=a,s}return n.jsonSchema=a,a}var F4=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:np(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((r,i)=>e.currentPath[i]===r)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),Pe(e)):e.$refStrategy==="seen"?Pe(e):void 0}},Z4=(t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),r);var iy=(t,e)=>{let r=ex(e),i=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((u,[c,l])=>({...u,[c]:H(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,c]},!0)??Pe(r)}),{}):void 0,n=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,o=H(t._def,n===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,n]},!1)??Pe(r),a=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;a!==void 0&&(o.title=a),r.flags.hasReferencedOpenAiAnyType&&(i||(i={}),i[r.openAiAnyTypeName]||(i[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:r.$refStrategy==="relative"?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));let s=n===void 0?i?{...o,[r.definitionPath]:i}:o:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,n].join("/"),[r.definitionPath]:{...i,[n]:o}};return r.target==="jsonSchema7"?s.$schema="http://json-schema.org/draft-07/schema#":(r.target==="jsonSchema2019-09"||r.target==="openAi")&&(s.$schema="https://json-schema.org/draft/2019-09/schema#"),r.target==="openAi"&&("anyOf"in s||"oneOf"in s||"allOf"in s||"type"in s&&Array.isArray(s.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),s};function Q4(t){return!t||t==="jsonSchema7"||t==="draft-7"?"draft-7":t==="jsonSchema2019-09"||t==="draft-2020-12"?"draft-2020-12":"draft-7"}function oy(t,e){return xr(t)?ti(t,{target:Q4(e?.target),io:e?.pipeStrategy??"input"}):iy(t,{strictUnions:e?.strictUnions??!0,pipeStrategy:e?.pipeStrategy??"input"})}function ay(t){let r=_n(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let i=Co(r);if(typeof i!="string")throw new Error("Schema method literal must be a string");return i}function sy(t,e){let r=yn(t,e);if(!r.success)throw r.error;return r.data}var q4=6e4,sp=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Mf,r=>{this._oncancel(r)}),this.setNotificationHandler(Ff,r=>{this._onprogress(r)}),this.setRequestHandler(Lf,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Zf,async(r,i)=>{let n=await this._taskStore.getTask(r.params.taskId,i.sessionId);if(!n)throw new B(F.InvalidParams,"Failed to retrieve task: Task not found");return{...n}}),this.setRequestHandler(qf,async(r,i)=>{let n=async()=>{let o=r.params.taskId;if(!await this._taskStore.getTask(o,i.sessionId))throw new B(F.InvalidParams,`Task not found: ${o}`);if(this._taskMessageQueue){let s;for(;s=await this._taskMessageQueue.dequeue(o,i.sessionId);){if(s.type==="response"||s.type==="error"){let u=s.message,c=u.id,l=this._requestResolvers.get(c);if(l)if(this._requestResolvers.delete(c),s.type==="response")l(u);else{let d=u,p=new B(d.error.code,d.error.message,d.error.data);l(p)}else{let d=s.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${c}`))}continue}await this._transport?.send(s.message,{relatedRequestId:i.requestId})}}let a=await this._taskStore.getTask(o,i.sessionId);if(!a)throw new B(F.InvalidParams,`Task not found: ${o}`);if(!xn(a.status))return await this._waitForTaskUpdate(o,i.signal,i.sessionId),await n();if(xn(a.status)){let s=await this._taskStore.getTaskResult(o,i.sessionId);return this._clearTaskQueue(o,i.sessionId),{...s,_meta:{...s._meta,[En]:{taskId:o}}}}return await n()};return await n()}),this.setRequestHandler(Vf,async(r,i)=>{try{let{tasks:n,nextCursor:o}=await this._taskStore.listTasks(r.params?.cursor,i.sessionId);return{tasks:n,nextCursor:o,_meta:{}}}catch(n){throw new B(F.InvalidParams,`Failed to list tasks: ${n instanceof Error?n.message:String(n)}`)}}),this.setRequestHandler(Gf,async(r,i)=>{try{let n=await this._taskStore.getTask(r.params.taskId,i.sessionId);if(!n)throw new B(F.InvalidParams,`Task not found: ${r.params.taskId}`);if(xn(n.status))throw new B(F.InvalidParams,`Cannot cancel task in terminal status: ${n.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",i.sessionId),this._clearTaskQueue(r.params.taskId,i.sessionId);let o=await this._taskStore.getTask(r.params.taskId,i.sessionId);if(!o)throw new B(F.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...o}}catch(n){throw n instanceof B?n:new B(F.InvalidRequest,`Failed to cancel task: ${n instanceof Error?n.message:String(n)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,r,i,n,o=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(n,r),startTime:Date.now(),timeout:r,maxTotalTimeout:i,resetTimeoutOnProgress:o,onTimeout:n})}_resetTimeout(e){let r=this._timeoutInfo.get(e);if(!r)return!1;let i=Date.now()-r.startTime;if(r.maxTotalTimeout&&i>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),B.fromError(F.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:i});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){let r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let i=this.transport?.onerror;this._transport.onerror=o=>{i?.(o),this._onerror(o)};let n=this._transport?.onmessage;this._transport.onmessage=(o,a)=>{n?.(o,a),au(o)||ME(o)?this._onresponse(o):MA(o)?this._onrequest(o,a):UE(o)?this._onnotification(o):this._onerror(new Error(`Unknown message type: ${JSON.stringify(o)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let i of this._timeoutInfo.values())clearTimeout(i.timeoutId);this._timeoutInfo.clear();for(let i of this._requestHandlerAbortControllers.values())i.abort();this._requestHandlerAbortControllers.clear();let r=B.fromError(F.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let i of e.values())i(r)}_onerror(e){this.onerror?.(e)}_onnotification(e){let r=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(e)).catch(i=>this._onerror(new Error(`Uncaught error in notification handler: ${i}`)))}_onrequest(e,r){let i=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,n=this._transport,o=e.params?._meta?.[En]?.taskId,a=n?.sessionId,s=this._taskStore,u=!0,c;if(o&&s&&this._taskMessageQueue&&a!==void 0&&(u=!1,c=(async()=>{if(!await s.getTask(o,a))throw new B(F.InvalidParams,`Task not found: ${o}`);u=!0})()),i===void 0){let h={jsonrpc:"2.0",id:e.id,error:{code:F.MethodNotFound,message:"Method not found"}};if(o&&c){let f={type:"error",message:h,timestamp:Date.now()};c.then(()=>this._enqueueTaskMessage(o,f,a),()=>n?.send(h)).catch(g=>this._onerror(new Error(`Failed to send an error response: ${g}`)))}else o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:h,timestamp:Date.now()},n?.sessionId).catch(f=>this._onerror(new Error(`Failed to enqueue error response: ${f}`))):n?.send(h).catch(f=>this._onerror(new Error(`Failed to send an error response: ${f}`)));return}let l=new AbortController;this._requestHandlerAbortControllers.set(e.id,l);let d=RE(e.params)?e.params.task:void 0,p=this._taskStore?this.requestTaskStore(e,n?.sessionId):void 0,m={signal:l.signal,sessionId:n?.sessionId,_meta:e.params?._meta,sendNotification:async h=>{if(l.signal.aborted)return;let f={relatedRequestId:e.id};o&&(f.relatedTask={taskId:o}),await this.notification(h,f)},sendRequest:async(h,f,g)=>{if(l.signal.aborted)throw new B(F.ConnectionClosed,"Request was cancelled");let y={...g,relatedRequestId:e.id};o&&!y.relatedTask&&(y.relatedTask={taskId:o});let v=y.relatedTask?.taskId??o;return v&&p&&await p.updateTaskStatus(v,"input_required"),await this.request(h,f,y)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:o,taskStore:p,taskRequestedTtl:d?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};(c??Promise.resolve()).then(()=>{if(c&&l.signal.aborted)throw new B(F.ConnectionClosed,"Request was cancelled");d&&this.assertTaskHandlerCapability(e.method)}).then(()=>i(e,m)).then(async h=>{if(l.signal.aborted)return;let f={result:h,jsonrpc:"2.0",id:e.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:f,timestamp:Date.now()},n?.sessionId):await n?.send(f)},async h=>{if(l.signal.aborted)return;let f={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(h.code)?h.code:F.InternalError,message:h.message??"Internal error",...h.data!==void 0&&{data:h.data}}};o&&this._taskMessageQueue&&u?await this._enqueueTaskMessage(o,{type:"error",message:f,timestamp:Date.now()},n?.sessionId):await n?.send(f)}).catch(h=>this._onerror(new Error(`Failed to send response: ${h}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===l&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:r,...i}=e.params,n=Number(r),o=this._progressHandlers.get(n);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(n),s=this._timeoutInfo.get(n);if(s&&a&&s.resetTimeoutOnProgress)try{this._resetTimeout(n)}catch(u){this._responseHandlers.delete(n),this._progressHandlers.delete(n),this._cleanupTimeout(n),a(u);return}o(i)}_onresponse(e){let r=Number(e.id),i=this._requestResolvers.get(r);if(i){if(this._requestResolvers.delete(r),au(e))i(e);else{let a=new B(e.error.code,e.error.message,e.error.data);i(a)}return}let n=this._responseHandlers.get(r);if(n===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let o=!1;if(au(e)&&e.result&&typeof e.result=="object"){let a=e.result;if(a.task&&typeof a.task=="object"){let s=a.task;typeof s.taskId=="string"&&(o=!0,this._taskProgressTokens.set(s.taskId,r))}}if(o||this._progressHandlers.delete(r),au(e))n(e);else{let a=B.fromError(e.error.code,e.error.message,e.error.data);n(a)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,r,i){let{task:n}=i??{};if(!n){try{yield{type:"result",result:await this.request(e,r,i)}}catch(a){yield{type:"error",error:a instanceof B?a:new B(F.InternalError,String(a))}}return}let o;try{let a=await this.request(e,Uo,i);if(a.task)o=a.task.taskId,yield{type:"taskCreated",task:a.task};else throw new B(F.InternalError,"Task creation did not return a task");for(;;){let s=await this.getTask({taskId:o},i);if(yield{type:"taskStatus",task:s},xn(s.status)){s.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},r,i)}:s.status==="failed"?yield{type:"error",error:new B(F.InternalError,`Task ${o} failed`)}:s.status==="cancelled"&&(yield{type:"error",error:new B(F.InternalError,`Task ${o} was cancelled`)});return}if(s.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:o},r,i)};return}let u=s.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(c=>setTimeout(c,u)),i?.signal?.throwIfAborted()}}catch(a){yield{type:"error",error:a instanceof B?a:new B(F.InternalError,String(a))}}}request(e,r,i){let{relatedRequestId:n,resumptionToken:o,onresumptiontoken:a,task:s,relatedTask:u}=i??{};return new Promise((c,l)=>{let d=v=>{l(v)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),s&&this.assertTaskCapability(e.method)}catch(v){d(v);return}i?.signal?.throwIfAborted();let p=this._requestMessageId++,m={...e,jsonrpc:"2.0",id:p};i?.onprogress&&(this._progressHandlers.set(p,i.onprogress),m.params={...e.params,_meta:{...e.params?._meta||{},progressToken:p}}),s&&(m.params={...m.params,task:s}),u&&(m.params={...m.params,_meta:{...m.params?._meta||{},[En]:u}});let h=v=>{this._responseHandlers.delete(p),this._progressHandlers.delete(p),this._cleanupTimeout(p),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:p,reason:String(v)}},{relatedRequestId:n,resumptionToken:o,onresumptiontoken:a}).catch(x=>this._onerror(new Error(`Failed to send cancellation: ${x}`)));let A=v instanceof B?v:new B(F.RequestTimeout,String(v));l(A)};this._responseHandlers.set(p,v=>{if(!i?.signal?.aborted){if(v instanceof Error)return l(v);try{let A=yn(r,v.result);A.success?c(A.data):l(A.error)}catch(A){l(A)}}}),i?.signal?.addEventListener("abort",()=>{h(i?.signal?.reason)});let f=i?.timeout??q4,g=()=>h(B.fromError(F.RequestTimeout,"Request timed out",{timeout:f}));this._setupTimeout(p,f,i?.maxTotalTimeout,g,i?.resetTimeoutOnProgress??!1);let y=u?.taskId;if(y){let v=A=>{let x=this._responseHandlers.get(p);x?x(A):this._onerror(new Error(`Response handler missing for side-channeled request ${p}`))};this._requestResolvers.set(p,v),this._enqueueTaskMessage(y,{type:"request",message:m,timestamp:Date.now()}).catch(A=>{this._cleanupTimeout(p),l(A)})}else this._transport.send(m,{relatedRequestId:n,resumptionToken:o,onresumptiontoken:a}).catch(v=>{this._cleanupTimeout(p),l(v)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},Qf,r)}async getTaskResult(e,r,i){return this.request({method:"tasks/result",params:e},r,i)}async listTasks(e,r){return this.request({method:"tasks/list",params:e},Hf,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},ZE,r)}async notification(e,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let i=r?.relatedTask?.taskId;if(i){let s={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[En]:r.relatedTask}}};await this._enqueueTaskMessage(i,{type:"notification",message:s,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let s={...e,jsonrpc:"2.0"};r?.relatedTask&&(s={...s,params:{...s.params,_meta:{...s.params?._meta||{},[En]:r.relatedTask}}}),this._transport?.send(s,r).catch(u=>this._onerror(u))});return}let a={...e,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[En]:r.relatedTask}}}),await this._transport.send(a,r)}setRequestHandler(e,r){let i=ay(e);this.assertRequestHandlerCapability(i),this._requestHandlers.set(i,(n,o)=>{let a=sy(e,n);return Promise.resolve(r(a,o))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,r){let i=ay(e);this._notificationHandlers.set(i,n=>{let o=sy(e,n);return Promise.resolve(r(o))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let r=this._taskProgressTokens.get(e);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,r,i){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let n=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,r,i??this._transport?.sessionId,n)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){let i=await this._taskMessageQueue.dequeueAll(e,r);for(let n of i)if(n.type==="request"&&MA(n.message)){let o=n.message.id,a=this._requestResolvers.get(o);a?(a(new B(F.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(o)):this._onerror(new Error(`Resolver missing for request ${o} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r,i){let n=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(e,i);o?.pollInterval&&(n=o.pollInterval)}catch{}return new Promise((o,a)=>{if(r.aborted){a(new B(F.InvalidRequest,"Request cancelled"));return}let s=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(s),a(new B(F.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){let i=this._taskStore;if(!i)throw new Error("No task store configured");return{createTask:async n=>{if(!e)throw new Error("No request provided");return await i.createTask(n,e.id,{method:e.method,params:e.params},r)},getTask:async n=>{let o=await i.getTask(n,r);if(!o)throw new B(F.InvalidParams,"Failed to retrieve task: Task not found");return o},storeTaskResult:async(n,o,a)=>{await i.storeTaskResult(n,o,a,r);let s=await i.getTask(n,r);if(s){let u=du.parse({method:"notifications/tasks/status",params:s});await this.notification(u),xn(s.status)&&this._cleanupTaskProgressHandler(n)}},getTaskResult:n=>i.getTaskResult(n,r),updateTaskStatus:async(n,o,a)=>{let s=await i.getTask(n,r);if(!s)throw new B(F.InvalidParams,`Task "${n}" not found - it may have been cleaned up`);if(xn(s.status))throw new B(F.InvalidParams,`Cannot update task "${n}" from terminal status "${s.status}" to "${o}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await i.updateTaskStatus(n,o,a,r);let u=await i.getTask(n,r);if(u){let c=du.parse({method:"notifications/tasks/status",params:u});await this.notification(c),xn(u.status)&&this._cleanupTaskProgressHandler(n)}},listTasks:n=>i.listTasks(n,r)}}};function Cx(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Dx(t,e){let r={...t};for(let i in e){let n=i,o=e[n];if(o===void 0)continue;let a=r[n];Cx(a)&&Cx(o)?r[n]={...a,...o}:r[n]=o}return r}var Nk=Un(Y_(),1),zk=Un(Tk(),1);function i3(){let t=new Nk.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,zk.default)(t),t}var Vp=class{constructor(e){this._ajv=e??i3()}getValidator(e){let r="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return i=>r(i)?{valid:!0,data:i,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var Hp=class{constructor(e){this._server=e}requestStream(e,r,i){return this._server.requestStream(e,r,i)}createMessageStream(e,r){let i=this._server.getClientCapabilities();if((e.tools||e.toolChoice)&&!i?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let n=e.messages[e.messages.length-1],o=Array.isArray(n.content)?n.content:[n.content],a=o.some(l=>l.type==="tool_result"),s=e.messages.length>1?e.messages[e.messages.length-2]:void 0,u=s?Array.isArray(s.content)?s.content:[s.content]:[],c=u.some(l=>l.type==="tool_use");if(a){if(o.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let l=new Set(u.filter(p=>p.type==="tool_use").map(p=>p.id)),d=new Set(o.filter(p=>p.type==="tool_result").map(p=>p.toolUseId));if(l.size!==d.size||![...l].every(p=>d.has(p)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:e},mu,r)}elicitInputStream(e,r){let i=this._server.getClientCapabilities(),n=e.mode??"form";switch(n){case"url":{if(!i?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!i?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let o=n==="form"&&e.mode===void 0?{...e,mode:"form"}:e;return this.requestStream({method:"elicitation/create",params:o},Fo,r)}async getTask(e,r){return this._server.getTask({taskId:e},r)}async getTaskResult(e,r,i){return this._server.getTaskResult({taskId:e},r,i)}async listTasks(e,r){return this._server.listTasks(e?{cursor:e}:void 0,r)}async cancelTask(e,r){return this._server.cancelTask({taskId:e},r)}};function Pk(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!t.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${e})`);break;default:break}}function Ok(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!t.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!t.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${e})`);break;default:break}}var Gp=class extends sp{constructor(e,r){super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(pu.options.map((i,n)=>[i,n])),this.isMessageIgnored=(i,n)=>{let o=this._loggingLevels.get(n);return o?this.LOG_LEVEL_SEVERITY.get(i)<this.LOG_LEVEL_SEVERITY.get(o):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new Vp,this.setRequestHandler(ZA,i=>this._oninitialize(i)),this.setNotificationHandler(QA,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(XA,async(i,n)=>{let o=n.sessionId||n.requestInfo?.headers["mcp-session-id"]||void 0,{level:a}=i.params,s=pu.safeParse(a);return s.success&&this._loggingLevels.set(o,s.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new Hp(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Dx(this._capabilities,e)}setRequestHandler(e,r){let n=_n(e)?.method;if(!n)throw new Error("Schema is missing a method literal");let o=Co(n);if(typeof o!="string")throw new Error("Schema method literal must be a string");if(o==="tools/call"){let s=async(u,c)=>{let l=yn(Lo,u);if(!l.success){let h=l.error instanceof Error?l.error.message:String(l.error);throw new B(F.InvalidParams,`Invalid tools/call request: ${h}`)}let{params:d}=l.data,p=await Promise.resolve(r(u,c));if(d.task){let h=yn(Uo,p);if(!h.success){let f=h.error instanceof Error?h.error.message:String(h.error);throw new B(F.InvalidParams,`Invalid task creation result: ${f}`)}return h.data}let m=yn(tp,p);if(!m.success){let h=m.error instanceof Error?m.error.message:String(m.error);throw new B(F.InvalidParams,`Invalid tools/call result: ${h}`)}return m.data};return super.setRequestHandler(e,s)}return super.setRequestHandler(e,r)}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${e})`);break;case"ping":break}}assertNotificationCapability(e){switch(e){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${e})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${e})`);break;case"ping":case"initialize":break}}assertTaskCapability(e){Ok(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&Pk(this._capabilities.tasks?.requests,e,"Server")}async _oninitialize(e){let r=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:zE.includes(r)?r:BA,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},Uf)}async createMessage(e,r){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let i=e.messages[e.messages.length-1],n=Array.isArray(i.content)?i.content:[i.content],o=n.some(c=>c.type==="tool_result"),a=e.messages.length>1?e.messages[e.messages.length-2]:void 0,s=a?Array.isArray(a.content)?a.content:[a.content]:[],u=s.some(c=>c.type==="tool_use");if(o){if(n.some(c=>c.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){let c=new Set(s.filter(d=>d.type==="tool_use").map(d=>d.id)),l=new Set(n.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(c.size!==l.size||![...c].every(d=>l.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return e.tools?this.request({method:"sampling/createMessage",params:e},YA,r):this.request({method:"sampling/createMessage",params:e},mu,r)}async elicitInput(e,r){switch(e.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let n=e;return this.request({method:"elicitation/create",params:n},Fo,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let n=e.mode==="form"?e:{...e,mode:"form"},o=await this.request({method:"elicitation/create",params:n},Fo,r);if(o.action==="accept"&&o.content&&n.requestedSchema)try{let s=this._jsonSchemaValidator.getValidator(n.requestedSchema)(o.content);if(!s.valid)throw new B(F.InvalidParams,`Elicitation response content does not match requested schema: ${s.errorMessage}`)}catch(a){throw a instanceof B?a:new B(F.InternalError,`Error validating elicitation response: ${a instanceof Error?a.message:String(a)}`)}return o}}}createElicitationCompletionNotifier(e,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:e}},r)}async listRoots(e,r){return this.request({method:"roots/list",params:e},WA,r)}async sendLoggingMessage(e,r){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,r))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};var jk=Symbol.for("mcp.completable");function ab(t){return!!t&&typeof t=="object"&&jk in t}function Bk(t){return t[jk]?.complete}var Rk;(function(t){t.Completable="McpCompletable"})(Rk||(Rk={}));var Jp=class t{static isTemplate(e){return/\{[^}\s]+\}/.test(e)}static validateLength(e,r,i){if(e.length>r)throw new Error(`${i} exceeds maximum length of ${r} characters (got ${e.length})`)}get variableNames(){return this.parts.flatMap(e=>typeof e=="string"?[]:e.names)}constructor(e){t.validateLength(e,1e6,"Template"),this.template=e,this.parts=this.parse(e)}toString(){return this.template}parse(e){let r=[],i="",n=0,o=0;for(;n<e.length;)if(e[n]==="{"){i&&(r.push(i),i="");let a=e.indexOf("}",n);if(a===-1)throw new Error("Unclosed template expression");if(o++,o>1e4)throw new Error("Template contains too many expressions (max 10000)");let s=e.slice(n+1,a),u=this.getOperator(s),c=s.includes("*"),l=this.getNames(s),d=l[0];for(let p of l)t.validateLength(p,1e6,"Variable name");r.push({name:d,operator:u,names:l,exploded:c}),n=a+1}else i+=e[n],n++;return i&&r.push(i),r}getOperator(e){return["+","#",".","/","?","&"].find(i=>e.startsWith(i))||""}getNames(e){let r=this.getOperator(e);return e.slice(r.length).split(",").map(i=>i.replace("*","").trim()).filter(i=>i.length>0)}encodeValue(e,r){return t.validateLength(e,1e6,"Variable value"),r==="+"||r==="#"?encodeURI(e):encodeURIComponent(e)}expandPart(e,r){if(e.operator==="?"||e.operator==="&"){let a=e.names.map(u=>{let c=r[u];if(c===void 0)return"";let l=Array.isArray(c)?c.map(d=>this.encodeValue(d,e.operator)).join(","):this.encodeValue(c.toString(),e.operator);return`${u}=${l}`}).filter(u=>u.length>0);return a.length===0?"":(e.operator==="?"?"?":"&")+a.join("&")}if(e.names.length>1){let a=e.names.map(s=>r[s]).filter(s=>s!==void 0);return a.length===0?"":a.map(s=>Array.isArray(s)?s[0]:s).join(",")}let i=r[e.name];if(i===void 0)return"";let o=(Array.isArray(i)?i:[i]).map(a=>this.encodeValue(a,e.operator));switch(e.operator){case"":return o.join(",");case"+":return o.join(",");case"#":return"#"+o.join(",");case".":return"."+o.join(".");case"/":return"/"+o.join("/");default:return o.join(",")}}expand(e){let r="",i=!1;for(let n of this.parts){if(typeof n=="string"){r+=n;continue}let o=this.expandPart(n,e);o&&((n.operator==="?"||n.operator==="&")&&i?r+=o.replace("?","&"):r+=o,(n.operator==="?"||n.operator==="&")&&(i=!0))}return r}escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}partToRegExp(e){let r=[];for(let o of e.names)t.validateLength(o,1e6,"Variable name");if(e.operator==="?"||e.operator==="&"){for(let o=0;o<e.names.length;o++){let a=e.names[o],s=o===0?"\\"+e.operator:"&";r.push({pattern:s+this.escapeRegExp(a)+"=([^&]+)",name:a})}return r}let i,n=e.name;switch(e.operator){case"":i=e.exploded?"([^/,]+(?:,[^/,]+)*)":"([^/,]+)";break;case"+":case"#":i="(.+)";break;case".":i="\\.([^/,]+)";break;case"/":i="/"+(e.exploded?"([^/,]+(?:,[^/,]+)*)":"([^/,]+)");break;default:i="([^/]+)"}return r.push({pattern:i,name:n}),r}match(e){t.validateLength(e,1e6,"URI");let r="^",i=[];for(let s of this.parts)if(typeof s=="string")r+=this.escapeRegExp(s);else{let u=this.partToRegExp(s);for(let{pattern:c,name:l}of u)r+=c,i.push({name:l,exploded:s.exploded})}r+="$",t.validateLength(r,1e6,"Generated regex pattern");let n=new RegExp(r),o=e.match(n);if(!o)return null;let a={};for(let s=0;s<i.length;s++){let{name:u,exploded:c}=i[s],l=o[s+1],d=u.replace("*","");c&&l.includes(",")?a[d]=l.split(","):a[d]=l}return a}};var o3=/^[A-Za-z0-9._-]{1,128}$/;function a3(t){let e=[];if(t.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(t.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${t.length})`]};if(t.includes(" ")&&e.push("Tool name contains spaces, which may cause parsing issues"),t.includes(",")&&e.push("Tool name contains commas, which may cause parsing issues"),(t.startsWith("-")||t.endsWith("-"))&&e.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(t.startsWith(".")||t.endsWith("."))&&e.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!o3.test(t)){let r=t.split("").filter(i=>!/[A-Za-z0-9._-]/.test(i)).filter((i,n,o)=>o.indexOf(i)===n);return e.push(`Tool name contains invalid characters: ${r.map(i=>`"${i}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:e}}return{isValid:!0,warnings:e}}function s3(t,e){if(e.length>0){console.warn(`Tool name validation warning for "${t}":`);for(let r of e)console.warn(` - ${r}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}function sb(t){let e=a3(t);return s3(t,e.warnings),e.isValid}var Kp=class{constructor(e){this._mcpServer=e}registerToolTask(e,r,i){let n={taskSupport:"required",...r.execution};if(n.taskSupport==="forbidden")throw new Error(`Cannot register task-based tool '${e}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(e,r.title,r.description,r.inputSchema,r.outputSchema,r.annotations,n,r._meta,i)}};function u3(t,e){let r=0,i=[t];for(;i.length>0;){let n=i.pop();if(!(n===null||typeof n!="object"))if(Array.isArray(n))for(let o of n){if(++r>e)return r;o!==null&&typeof o=="object"&&i.push(o)}else for(let o in n){if(!Object.prototype.hasOwnProperty.call(n,o))continue;if(++r>e)return r;let a=n[o];a!==null&&typeof a=="object"&&i.push(a)}}return r}function c3(t){if(!(t===void 0||t===1/0)){if(typeof t!="number"||Number.isNaN(t)||t<1)throw new RangeError(`maxToolInputElements must be a number of at least 1, or Infinity, got ${String(t)}`);return t}}var Xp=class{constructor(e,r){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new Gp(e,r),this._maxToolInputElements=c3(r?.maxToolInputElements),r?.capabilities?.tools&&this.setToolRequestHandlers(),r?.capabilities?.resources&&this.setResourceRequestHandlers(),r?.capabilities?.prompts&&this.setPromptRequestHandlers()}get experimental(){return this._experimental||(this._experimental={tasks:new Kp(this)}),this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(On(ep)),this.server.assertCanSetRequestHandler(On(Lo)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(ep,()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,r])=>{let i={name:e,title:r.title,description:r.description,inputSchema:(()=>{let n=ko(r.inputSchema);return n?oy(n,{strictUnions:!0,pipeStrategy:"input"}):l3})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let n=ko(r.outputSchema);n&&(i.outputSchema=oy(n,{strictUnions:!0,pipeStrategy:"output"}))}return i})})),this.server.setRequestHandler(Lo,async(e,r)=>{try{let i=this._registeredTools[e.params.name];if(!i)throw new B(F.InvalidParams,`Tool ${e.params.name} not found`);if(!i.enabled)throw new B(F.InvalidParams,`Tool ${e.params.name} disabled`);let n=!!e.params.task,o=i.execution?.taskSupport,a="createTask"in i.handler;if((o==="required"||o==="optional")&&!a)throw new B(F.InternalError,`Tool ${e.params.name} has taskSupport '${o}' but was not registered with registerToolTask`);if(o==="required"&&!n)throw new B(F.MethodNotFound,`Tool ${e.params.name} requires task augmentation (taskSupport: 'required')`);if(o==="optional"&&!n&&a)return await this.handleAutomaticTaskPolling(i,e,r);let s=await this.validateToolInput(i,e.params.arguments,e.params.name),u=await this.executeToolHandler(i,s,r);return n||await this.validateToolOutput(i,u,e.params.name),u}catch(i){if(i instanceof B&&i.code===F.UrlElicitationRequired)throw i;return this.createToolError(i instanceof Error?i.message:String(i))}}),this._toolHandlersInitialized=!0)}createToolError(e){return{content:[{type:"text",text:e}],isError:!0}}async validateToolInput(e,r,i){if(this._maxToolInputElements!==void 0&&u3(r,this._maxToolInputElements)>this._maxToolInputElements)throw new B(F.InvalidParams,`Invalid arguments for tool ${i}: arguments contain more than the maximum of ${this._maxToolInputElements} elements`);if(!e.inputSchema)return;let o=ko(e.inputSchema)??e.inputSchema,a=await af(o,r??{});if(!a.success){let s="error"in a?a.error:"Unknown error",u=sf(s);throw new B(F.InvalidParams,`Input validation error: Invalid arguments for tool ${i}: ${u}`)}return a.data}async validateToolOutput(e,r,i){if(!e.outputSchema||!("content"in r)||r.isError)return;if(!r.structuredContent)throw new B(F.InvalidParams,`Output validation error: Tool ${i} has an output schema but no structured content was provided`);let n=ko(e.outputSchema),o=await af(n,r.structuredContent);if(!o.success){let a="error"in o?o.error:"Unknown error",s=sf(a);throw new B(F.InvalidParams,`Output validation error: Invalid structured content for tool ${i}: ${s}`)}}async executeToolHandler(e,r,i){let n=e.handler;if("createTask"in n){if(!i.taskStore)throw new Error("No task store provided.");let a={...i,taskStore:i.taskStore};if(e.inputSchema){let s=n;return await Promise.resolve(s.createTask(r,a))}else{let s=n;return await Promise.resolve(s.createTask(a))}}if(e.inputSchema){let a=n;return await Promise.resolve(a(r,i))}else{let a=n;return await Promise.resolve(a(i))}}async handleAutomaticTaskPolling(e,r,i){if(!i.taskStore)throw new Error("No task store provided for task-capable tool.");let n=await this.validateToolInput(e,r.params.arguments,r.params.name),o=e.handler,a={...i,taskStore:i.taskStore},s=n?await Promise.resolve(o.createTask(n,a)):await Promise.resolve(o.createTask(a)),u=s.task.taskId,c=s.task,l=c.pollInterval??5e3;for(;c.status!=="completed"&&c.status!=="failed"&&c.status!=="cancelled";){await new Promise(p=>setTimeout(p,l));let d=await i.taskStore.getTask(u);if(!d)throw new B(F.InternalError,`Task ${u} not found during polling`);c=d}return await i.taskStore.getTaskResult(u)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(On(rp)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(rp,async e=>{switch(e.params.ref.type){case"ref/prompt":return JE(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return KE(e),this.handleResourceCompletion(e,e.params.ref);default:throw new B(F.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,r){let i=this._registeredPrompts[r.name];if(!i)throw new B(F.InvalidParams,`Prompt ${r.name} not found`);if(!i.enabled)throw new B(F.InvalidParams,`Prompt ${r.name} disabled`);if(!i.argsSchema)return Vu;let o=_n(i.argsSchema)?.[e.params.argument.name];if(!ab(o))return Vu;let a=Bk(o);if(!a)return Vu;let s=await a(e.params.argument.value,e.params.context);return Mk(s)}async handleResourceCompletion(e,r){let i=Object.values(this._registeredResourceTemplates).find(a=>a.resourceTemplate.uriTemplate.toString()===r.uri);if(!i){if(this._registeredResources[r.uri])return Vu;throw new B(F.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let n=i.resourceTemplate.completeCallback(e.params.argument.name);if(!n)return Vu;let o=await n(e.params.argument.value,e.params.context);return Mk(o)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(On(Jf)),this.server.assertCanSetRequestHandler(On(Kf)),this.server.assertCanSetRequestHandler(On(Xf)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(Jf,async(e,r)=>{let i=Object.entries(this._registeredResources).filter(([o,a])=>a.enabled).map(([o,a])=>({uri:o,name:a.name,...a.metadata})),n=[];for(let o of Object.values(this._registeredResourceTemplates)){if(!o.resourceTemplate.listCallback)continue;let a=await o.resourceTemplate.listCallback(r);for(let s of a.resources)n.push({...o.metadata,...s})}return{resources:[...i,...n]}}),this.server.setRequestHandler(Kf,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,i])=>({name:r,uriTemplate:i.resourceTemplate.uriTemplate.toString(),...i.metadata}))})),this.server.setRequestHandler(Xf,async(e,r)=>{let i=new URL(e.params.uri),n=this._registeredResources[i.toString()];if(n){if(!n.enabled)throw new B(F.InvalidParams,`Resource ${i} disabled`);return n.readCallback(i,r)}for(let o of Object.values(this._registeredResourceTemplates)){let a=o.resourceTemplate.uriTemplate.match(i.toString());if(a)return o.readCallback(i,a,r)}throw new B(F.InvalidParams,`Resource ${i} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(On(Yf)),this.server.assertCanSetRequestHandler(On(Wf)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(Yf,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,r])=>({name:e,title:r.title,description:r.description,arguments:r.argsSchema?d3(r.argsSchema):void 0}))})),this.server.setRequestHandler(Wf,async(e,r)=>{let i=this._registeredPrompts[e.params.name];if(!i)throw new B(F.InvalidParams,`Prompt ${e.params.name} not found`);if(!i.enabled)throw new B(F.InvalidParams,`Prompt ${e.params.name} disabled`);if(i.argsSchema){let n=ko(i.argsSchema),o=await af(n,e.params.arguments??{});if(!o.success){let u="error"in o?o.error:"Unknown error",c=sf(u);throw new B(F.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${c}`)}let a=o.data,s=i.callback;return await Promise.resolve(s(a,r))}else{let n=i.callback;return await Promise.resolve(n(r))}}),this._promptHandlersInitialized=!0)}resource(e,r,...i){let n;typeof i[0]=="object"&&(n=i.shift());let o=i[0];if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let a=this._createRegisteredResource(e,void 0,r,n,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),a}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let a=this._createRegisteredResourceTemplate(e,void 0,r,n,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),a}}registerResource(e,r,i,n){if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let o=this._createRegisteredResource(e,i.title,r,i,n);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let o=this._createRegisteredResourceTemplate(e,i.title,r,i,n);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}}_createRegisteredResource(e,r,i,n,o){let a={name:e,title:r,metadata:n,readCallback:o,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({uri:null}),update:s=>{typeof s.uri<"u"&&s.uri!==i&&(delete this._registeredResources[i],s.uri&&(this._registeredResources[s.uri]=a)),typeof s.name<"u"&&(a.name=s.name),typeof s.title<"u"&&(a.title=s.title),typeof s.metadata<"u"&&(a.metadata=s.metadata),typeof s.callback<"u"&&(a.readCallback=s.callback),typeof s.enabled<"u"&&(a.enabled=s.enabled),this.sendResourceListChanged()}};return this._registeredResources[i]=a,a}_createRegisteredResourceTemplate(e,r,i,n,o){let a={resourceTemplate:i,title:r,metadata:n,readCallback:o,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({name:null}),update:c=>{typeof c.name<"u"&&c.name!==e&&(delete this._registeredResourceTemplates[e],c.name&&(this._registeredResourceTemplates[c.name]=a)),typeof c.title<"u"&&(a.title=c.title),typeof c.template<"u"&&(a.resourceTemplate=c.template),typeof c.metadata<"u"&&(a.metadata=c.metadata),typeof c.callback<"u"&&(a.readCallback=c.callback),typeof c.enabled<"u"&&(a.enabled=c.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=a;let s=i.uriTemplate.variableNames;return Array.isArray(s)&&s.some(c=>!!i.completeCallback(c))&&this.setCompletionRequestHandler(),a}_createRegisteredPrompt(e,r,i,n,o){let a={title:r,description:i,argsSchema:n===void 0?void 0:ri(n),callback:o,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({name:null}),update:s=>{typeof s.name<"u"&&s.name!==e&&(delete this._registeredPrompts[e],s.name&&(this._registeredPrompts[s.name]=a)),typeof s.title<"u"&&(a.title=s.title),typeof s.description<"u"&&(a.description=s.description),typeof s.argsSchema<"u"&&(a.argsSchema=ri(s.argsSchema)),typeof s.callback<"u"&&(a.callback=s.callback),typeof s.enabled<"u"&&(a.enabled=s.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[e]=a,n&&Object.values(n).some(u=>{let c=u instanceof ai?u._def?.innerType:u;return ab(c)})&&this.setCompletionRequestHandler(),a}_createRegisteredTool(e,r,i,n,o,a,s,u,c){sb(e);let l={title:r,description:i,inputSchema:Uk(n),outputSchema:Uk(o),annotations:a,execution:s,_meta:u,handler:c,enabled:!0,disable:()=>l.update({enabled:!1}),enable:()=>l.update({enabled:!0}),remove:()=>l.update({name:null}),update:d=>{typeof d.name<"u"&&d.name!==e&&(typeof d.name=="string"&&sb(d.name),delete this._registeredTools[e],d.name&&(this._registeredTools[d.name]=l)),typeof d.title<"u"&&(l.title=d.title),typeof d.description<"u"&&(l.description=d.description),typeof d.paramsSchema<"u"&&(l.inputSchema=ri(d.paramsSchema)),typeof d.outputSchema<"u"&&(l.outputSchema=ri(d.outputSchema)),typeof d.callback<"u"&&(l.handler=d.callback),typeof d.annotations<"u"&&(l.annotations=d.annotations),typeof d._meta<"u"&&(l._meta=d._meta),typeof d.enabled<"u"&&(l.enabled=d.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=l,this.setToolRequestHandlers(),this.sendToolListChanged(),l}tool(e,...r){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let i,n,o,a;if(typeof r[0]=="string"&&(i=r.shift()),r.length>1){let u=r[0];if(ub(u))n=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!ub(r[0])&&(a=r.shift());else if(typeof u=="object"&&u!==null){if(Object.values(u).some(c=>typeof c=="object"&&c!==null))throw new Error(`Tool ${e} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);a=r.shift()}}let s=r[0];return this._createRegisteredTool(e,void 0,i,n,o,a,{taskSupport:"forbidden"},void 0,s)}registerTool(e,r,i){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let{title:n,description:o,inputSchema:a,outputSchema:s,annotations:u,_meta:c}=r;return this._createRegisteredTool(e,n,o,a,s,u,{taskSupport:"forbidden"},c,i)}prompt(e,...r){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let i;typeof r[0]=="string"&&(i=r.shift());let n;r.length>1&&(n=r.shift());let o=r[0],a=this._createRegisteredPrompt(e,void 0,i,n,o);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),a}registerPrompt(e,r,i){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let{title:n,description:o,argsSchema:a}=r,s=this._createRegisteredPrompt(e,n,o,a,i);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),s}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(e,r){return this.server.sendLoggingMessage(e,r)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}},Yp=class{constructor(e,r){this._callbacks=r,this._uriTemplate=typeof e=="string"?new Jp(e):e}get uriTemplate(){return this._uriTemplate}get listCallback(){return this._callbacks.list}completeCallback(e){return this._callbacks.complete?.[e]}},l3={type:"object",properties:{}};function Lk(t){return t!==null&&typeof t=="object"&&"parse"in t&&typeof t.parse=="function"&&"safeParse"in t&&typeof t.safeParse=="function"}function Fk(t){return"_def"in t||"_zod"in t||Lk(t)}function ub(t){return typeof t!="object"||t===null||Fk(t)?!1:Object.keys(t).length===0?!0:Object.values(t).some(Lk)}function Uk(t){if(t){if(ub(t))return ri(t);if(!Fk(t))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return t}}function d3(t){let e=_n(t);return e?Object.entries(e).map(([r,i])=>{let n=uw(i),o=cw(i);return{name:r,description:n,required:!o}}):[]}function On(t){let r=_n(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let i=Co(r);if(typeof i=="string")return i;throw new Error("Schema method literal must be a string")}function Mk(t){return{completion:{values:t.slice(0,100),total:t.length,hasMore:t.length>100}}}var Vu={completion:{values:[],hasMore:!1}};import Qk from"node:process";var f3=10*1024*1024,Wp=class{constructor(e){this._maxBufferSize=e?.maxBufferSize??f3}append(e){if((this._buffer?.length??0)+e.length>this._maxBufferSize)throw this.clear(),new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
|
|
83
83
|
`);if(e===-1)return null;let r=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),p3(r)}clear(){this._buffer=void 0}};function p3(t){return LE.parse(JSON.parse(t))}function Zk(t){return JSON.stringify(t)+`
|
|
84
|
-
`}var em=class{constructor(e=Qk.stdin,r=Qk.stdout,i){this._stdin=e,this._stdout=r,this._started=!1,this._ondata=n=>{try{this._readBuffer.append(n),this.processReadBuffer()}catch(o){this.onerror?.(o),this.close().catch(()=>{})}},this._onerror=n=>{this.onerror?.(n)},this._readBuffer=new Wp({maxBufferSize:i?.maxBufferSize})}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(e){return new Promise(r=>{let i=Zk(e);this._stdout.write(i)?r():this._stdout.once("drain",r)})}};import{readFileSync as
|
|
84
|
+
`}var em=class{constructor(e=Qk.stdin,r=Qk.stdout,i){this._stdin=e,this._stdout=r,this._started=!1,this._ondata=n=>{try{this._readBuffer.append(n),this.processReadBuffer()}catch(o){this.onerror?.(o),this.close().catch(()=>{})}},this._onerror=n=>{this.onerror?.(n)},this._readBuffer=new Wp({maxBufferSize:i?.maxBufferSize})}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(e){return new Promise(r=>{let i=Zk(e);this._stdout.write(i)?r():this._stdout.once("drain",r)})}};import{readFileSync as g5}from"node:fs";import{join as v5}from"node:path";var qk={name:"@kyun.si/codex-hongguo",version:"0.0.35-beta.2",private:!0,license:"MIT",type:"module",engines:{node:">=22.16"},scripts:{"version:patch":"npm version patch --no-git-tag-version","version:beta":"node scripts/version.mjs --beta",preversion:"node scripts/version.mjs --next",version:"node scripts/version.mjs --sync",prebuild:"node scripts/version.mjs",build:"node scripts/build.mjs",test:"npm run build && node scripts/prepare-media.mjs && node --test --test-timeout=180000 test/*.test.mjs",package:"npm run build && node scripts/package.mjs","verify:install":"node scripts/verify-install.mjs","release:preview":"node scripts/publish.mjs --dry-run","release:publish":"node scripts/publish.mjs --publish"},dependencies:{"@modelcontextprotocol/ext-apps":"1.7.5","@modelcontextprotocol/sdk":"1.32.2","cross-spawn":"7.0.6",fflate:"0.8.3","hls.js":"1.7.4","m3u8-parser":"7.2.1","mpd-parser":"1.4.1",openhongguo:"0.2.0","xz-decompress":"0.2.3",zod:"4.6.7"},devDependencies:{"@types/node":"22.20.5",esbuild:"0.28.2",typescript:"5.9.3"}};import{homedir as h3}from"node:os";import{posix as g3,win32 as v3}from"node:path";import{fileURLToPath as A3}from"node:url";var aa=A3(new URL("../../",import.meta.url));function Vk({env:t=process.env,home:e=h3(),platform:r=process.platform}={}){let{join:i}=r==="win32"?v3:g3;return t.HONGGUO_DATA_DIR?t.HONGGUO_DATA_DIR:r==="darwin"?i(e,"Library","Application Support","CodexHongguo"):r==="win32"?i(t.LOCALAPPDATA||i(e,"AppData","Local"),"CodexHongguo"):i(t.XDG_DATA_HOME||i(e,".local","share"),"codex-hongguo")}import{DatabaseSync as y3}from"node:sqlite";import{mkdirSync as _3}from"node:fs";import{join as b3}from"node:path";function cb(t){return typeof t=="string"&&/^[A-Za-z0-9_-]{1,128}$/.test(t)}function tm(t={}){let e=[t.thread_id,t.threadId].filter(r=>r!==void 0);return e.length&&e.every(r=>cb(r)&&r===e[0])?e[0]:null}function Hk(t){let e=new Map;for(let{id:r,title:i}of t)if(/^hg-\d{1,32}$/.test(r)&&typeof i=="string"&&i.trim()&&!e.has(r)&&e.set(r,{id:r,title:i}),e.size===48)break;return[...e.values()]}var Hu=class{constructor(e=Vk(),r=!1){r||_3(e,{recursive:!0,mode:448}),this.persistent=!r,this.root=e,this.db=new y3(r?":memory:":b3(e,"player.sqlite")),this.db.exec(`PRAGMA busy_timeout=250; PRAGMA journal_mode=WAL;
|
|
85
85
|
CREATE TABLE IF NOT EXISTS turn_state (
|
|
86
86
|
session_id TEXT NOT NULL, turn_id TEXT NOT NULL, submitted_at INTEGER,
|
|
87
87
|
stop_kind TEXT, interrupted INTEGER NOT NULL DEFAULT 0, stopped INTEGER NOT NULL DEFAULT 0,
|
|
@@ -112,10 +112,15 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
112
112
|
position_ms INTEGER NOT NULL, duration_ms INTEGER NOT NULL, updated_at INTEGER NOT NULL,
|
|
113
113
|
PRIMARY KEY(series_id,episode_id));
|
|
114
114
|
CREATE TABLE IF NOT EXISTS watch_restart (
|
|
115
|
-
series_id TEXT NOT NULL, episode_id TEXT NOT NULL, PRIMARY KEY(series_id,episode_id))
|
|
115
|
+
series_id TEXT NOT NULL, episode_id TEXT NOT NULL, PRIMARY KEY(series_id,episode_id));
|
|
116
|
+
CREATE TABLE IF NOT EXISTS player_preferences(id INTEGER PRIMARY KEY, body TEXT NOT NULL);`),this.db.prepare("PRAGMA user_version").get().user_version===0&&this.db.exec(`BEGIN IMMEDIATE;
|
|
116
117
|
DELETE FROM watch_progress WHERE series_id IN ('tide','ridge');
|
|
117
118
|
PRAGMA user_version=1;
|
|
118
|
-
COMMIT;`)
|
|
119
|
+
COMMIT;`),this.db.prepare("PRAGMA user_version").get().user_version<2&&this.db.exec(`BEGIN IMMEDIATE;
|
|
120
|
+
UPDATE player_preferences SET body=json_remove(body, '$.decoyUrl', '$.decoyFrameUrl')
|
|
121
|
+
WHERE json_type(body, '$.decoyUrl') IS NOT NULL OR json_type(body, '$.decoyFrameUrl') IS NOT NULL;
|
|
122
|
+
PRAGMA user_version=2;
|
|
123
|
+
COMMIT;`)}preferences(){let e=this.db.prepare("SELECT body FROM player_preferences WHERE id=1").get(),r={autoPrompt:!0,autoplayNext:!0,autoPauseOnFinish:!0,autoPlayOnStart:!0,defaultMuted:!0,volume:.7,hoverDecoyEnabled:!1,searchTerms:["\u603B\u88C1","\u91CD\u751F","\u9006\u88AD"]};return e?{...r,...JSON.parse(e.body)}:r}setupDismissed(){return this.db.prepare("SELECT dismissed FROM player_onboarding WHERE id=1").get()?.dismissed===1}setSetupDismissed(e){return this.db.prepare("INSERT OR REPLACE INTO player_onboarding VALUES(1,?)").run(Number(e)),{dismissed:e}}setPreferences(e){return this.transaction(()=>{let r=this.preferences(),i={...r,...e};return this.db.prepare("INSERT OR REPLACE INTO player_preferences VALUES(1,?)").run(JSON.stringify(i)),JSON.stringify(r.searchTerms)!==JSON.stringify(i.searchTerms)&&(this.db.exec("DELETE FROM recommendation_feed"),this.db.exec("DELETE FROM catalog_cache WHERE key LIKE 'feed:%'")),i})}event({session_id:e,turn_id:r,hook_event_name:i},n=Date.now()){if(!cb(e)||!cb(r)||!["UserPromptSubmit","Stop","Interrupt"].includes(i))return;let o=+(i==="Stop"),a=+(i==="Interrupt");return this.db.prepare(`INSERT INTO turn_state(session_id,turn_id,submitted_at,stop_kind,stopped,interrupted,observed_at)
|
|
119
124
|
VALUES(?,?,?,?,?,?,?) ON CONFLICT(session_id,turn_id) DO UPDATE SET
|
|
120
125
|
submitted_at=COALESCE(submitted_at,CASE WHEN excluded.submitted_at IS NOT NULL THEN min(observed_at,excluded.submitted_at) END),
|
|
121
126
|
stop_kind=COALESCE(excluded.stop_kind,stop_kind), stopped=max(stopped,excluded.stopped),
|
|
@@ -132,18 +137,18 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
132
137
|
ORDER BY e.last_shown, c.key`).all(JSON.stringify(Hk(n))).map(({id:p,title:m})=>({id:p,title:m}));l.sort((p,m)=>Number(u.has(p.id))-Number(u.has(m.id)));let d=i?[i,...l.filter(p=>p.id!==i.id).slice(0,2)]:l.slice(0,3);return d.length&&this.db.prepare("INSERT INTO turn_picks(session_id,turn_id,items,reserved_at) VALUES(?,?,?,?)").run(e,r,JSON.stringify(d),o?Date.now():null),d})}markPicksShown(e,r,i){return this.transaction(()=>{let n=i()&&this.db.prepare("UPDATE turn_picks SET shown=1 WHERE session_id=? AND turn_id=? AND shown=0 RETURNING items").get(e,r);if(n){let o=this.db.prepare("SELECT coalesce(max(last_shown),0)+1 AS n FROM pick_exposure").get().n,a=this.db.prepare("INSERT OR REPLACE INTO pick_exposure(series_id,last_shown) VALUES(?,?)");for(let s of JSON.parse(n.items))s.episodeId||a.run(s.id,o)}return{recorded:!!n}})}state(e,r){let i=e&&(r?this.db.prepare("SELECT * FROM turn_state WHERE session_id=? AND turn_id=?").get(e,r):this.db.prepare("SELECT * FROM turn_state WHERE session_id=? ORDER BY (submitted_at IS NOT NULL) DESC,coalesce(submitted_at,observed_at) DESC,rowid DESC LIMIT 1").get(e));if(!i)return{sessionId:null,turnId:null,state:"unknown",revision:0,observedAt:null};let n=i.interrupted?"interrupted":i.stopped?"stopped":"submitted";return{sessionId:i.session_id,turnId:i.turn_id,state:n,revision:i.revision,observedAt:i.observed_at}}candidates(){return this.db.prepare("SELECT session_id, max(observed_at) AS at FROM turn_state GROUP BY session_id ORDER BY at DESC LIMIT 8").all()}save({seriesId:e,episodeId:r,title:i,label:n,positionMs:o,durationMs:a,reset:s=!1}){return o<=0&&!s?{saved:!1}:this.transaction(()=>(o===0?this.db.prepare("INSERT OR IGNORE INTO watch_restart VALUES(?,?)").run(e,r):this.db.prepare("DELETE FROM watch_restart WHERE series_id=? AND episode_id=?").run(e,r),this.db.prepare(`INSERT INTO watch_progress VALUES(?,?,?,?,?,?,max(?,coalesce((SELECT max(updated_at)+1 FROM watch_progress),0))) ON CONFLICT(series_id,episode_id) DO UPDATE SET
|
|
133
138
|
title=excluded.title,label=excluded.label,position_ms=excluded.position_ms,duration_ms=excluded.duration_ms,updated_at=excluded.updated_at`).run(e,r,i,n,Math.min(o,a),a,Date.now()),{saved:!0}))}history(e,r,i=30){let n="series_id AS seriesId,episode_id AS episodeId,title,label,position_ms AS positionMs,duration_ms AS durationMs,updated_at AS updatedAt",o="(position_ms>0 OR (series_id,episode_id) IN (SELECT series_id,episode_id FROM watch_restart))";return e&&r?this.db.prepare("SELECT "+n+" FROM watch_progress WHERE series_id=? AND episode_id=? AND "+o).all(e,r):e?this.db.prepare("SELECT "+n+" FROM watch_progress WHERE series_id=? AND "+o+" ORDER BY updated_at DESC,rowid DESC LIMIT 1").all(e):this.db.prepare("SELECT "+n+` FROM (SELECT *, row_number() OVER(PARTITION BY series_id ORDER BY updated_at DESC,rowid DESC) AS rank
|
|
134
139
|
FROM watch_progress WHERE ${o} AND series_id GLOB 'hg-*' AND episode_id GLOB 'hg-*')
|
|
135
|
-
WHERE rank=1 ORDER BY updated_at DESC LIMIT ?`).all(i)}removeHistory(e){return this.transaction(()=>(this.db.prepare("DELETE FROM watch_progress WHERE series_id=?").run(e),this.db.prepare("DELETE FROM watch_restart WHERE series_id=?").run(e),{removed:!0}))}writable(){if(!this.persistent)return!1;try{return this.db.exec("UPDATE watch_progress SET updated_at=updated_at WHERE 0"),!0}catch{return!1}}close(){this.db.close()}};import{randomBytes as I3}from"node:crypto";var j=class extends Error{constructor(e,r=400){super(e),this.status=r}};function rm(t){return t instanceof j?t.message:"\u672C\u673A\u670D\u52A1\u6216\u7247\u6E90\u6682\u65F6\u4E0D\u53EF\u8FBE\uFF0C\u8BF7\u91CD\u8BD5"}var $3="\u8BF7\u5728 Codex \u8BBE\u7F6E \u2192 Hooks \u2192 \u7EA2\u679C\u77ED\u5267\u4E2D\u68C0\u67E5\u6388\u6743\uFF0C\u5BA1\u67E5\u3001\u4FE1\u4EFB\u5E76\u542F\u7528 UserPromptSubmit\u3001Stop\u3001Interrupt\u3002";function Gk(){return{status:"manual_check",events:["userPromptSubmit","stop","interrupt"].map(t=>({event:t,status:"manual_check"})),message:$3}}var Gu=()=>I3(24).toString("base64url"),zr=L.string().regex(/^[a-zA-Z0-9_-]{1,128}$/),dt=L.string().regex(/^hg-[0-9]{1,32}$/),Jk=L.string().max(4096).optional(),lb=L.string().min(1).max(320),Kk=L.number().int().min(0).max(24*3600*1e3),db={get_run_state:L.object({turnId:zr.optional(),playerInstance:zr.optional(),observeSession:L.literal(!0).optional()}),set_player_visible:L.object({instance:zr,visible:L.boolean()}),get_waiting_picks:L.object({turnId:zr.optional(),inView:L.literal(!0).optional()}),mark_waiting_picks_shown:L.object({turnId:zr.optional()}),get_waiting_status:L.object({}),dismiss_waiting_picks:L.object({turnId:zr.optional()}),browse_waiting_catalog:L.object({}),select_waiting_pick:L.object({seriesId:dt}),activate_waiting_player:L.object({}),confirm_waiting_playback:L.object({playbackId:L.number().int().positive()}),list_sessions:L.object({}),select_session:L.object({choice:zr}),list_series:L.object({source:L.literal("hongguo").optional(),preview:L.literal(!0).optional(),query:L.string().max(120).optional(),cursor:Jk}),get_cover:L.object({seriesId:dt}),get_episodes:L.object({seriesId:dt,cursor:Jk}),get_history:L.object({seriesId:dt.optional(),episodeId:dt.optional()}),save_progress:L.object({seriesId:dt,episodeId:dt,title:lb,label:lb,positionMs:Kk,durationMs:Kk.positive(),reset:L.literal(!0).optional()}),prepare_playback:L.object({episodeId:dt,retry:L.boolean().optional()}),preload_playback:L.object({episodeId:dt}),create_browser_pairing:L.object({follow:L.boolean().optional(),turnId:zr.optional(),seriesId:dt.optional(),episodeId:dt.optional(),title:lb.optional()}),get_health:L.object({}),get_setup_status:L.object({}),set_setup_dismissed:L.object({dismissed:L.boolean()}),get_preferences:L.object({}),set_preferences:L.object({autoPrompt:L.boolean().optional(),searchTerms:L.array(L.string().trim().min(1).max(30)).min(1).max(6).optional(),autoplayNext:L.boolean().optional(),autoPauseOnFinish:L.boolean().optional(),autoPlayOnStart:L.boolean().optional(),defaultMuted:L.boolean().optional(),volume:L.number().positive().max(1).optional()}),read_panel_chunk:L.object({episodeId:dt,stream:zr,asset:L.string().max(32),offset:L.number().int().nonnegative().max(32*1024*1024)}),read_panel_manifest:L.object({episodeId:dt,stream:zr}),remove_history:L.object({seriesId:dt})},nm=class{constructor(e,r){this.store=e,this.catalog=r,this.panels=new Map}open(e){let r=Gu(),i={sessionId:tm(e),choices:new Map,lastSeen:Date.now()};for(let[n,o]of this.panels)Date.now()-o.lastSeen>12*36e5&&this.panels.delete(n);return i.caller=i.sessionId,this.panels.set(r,i),{panel:r,state:this.store.state(i.sessionId),identified:!!i.sessionId}}openWaiting(e,r){let i=tm(e);if(!i||[e?.turn_id,e?.turnId].some(o=>o!==void 0&&o!==r)||!this.store.claimCard(i,r))return null;let n=this.open(e);return this.panels.get(n.panel).waiting={turnId:r,selected:null,taken:!1},n}async resumePick(){for(let e of this.store.history(void 0,void 0,-1)){if(!dt.safeParse(e.seriesId).success||!dt.safeParse(e.episodeId).success)continue;let r={id:e.seriesId,title:e.title};if(e.positionMs<e.durationMs)return{...r,episodeId:e.episodeId,kind:"resume"};try{let i=await this.catalog.nextEpisode(e.seriesId,e.episodeId);if(i)return{...r,...i}}catch{continue}}return null}async waitingPicks(e,r,i,n){if(!n())return{items:[]};let o=this.store.turnPicks(e,r);if(o.length)return{items:o};let[a,s]=await Promise.all([this.catalog.waitingRecommendations().catch(()=>[]),this.resumePick()]);return{items:this.store.allocatePicks(e,r,s,a,i,n)}}panel(e,r){let i=this.panels.get(e);if(!i||Date.now()-i.lastSeen>12*36e5)throw new j("\u8BF7\u91CD\u65B0\u6253\u5F00\u77ED\u5267\u9762\u677F",401);if((r?.thread_id!==void 0||r?.threadId!==void 0)&&tm(r)!==i.caller)throw new j("\u4F1A\u8BDD\u4E0D\u5339\u914D",403);return i.lastSeen=Date.now(),i}async call(e,r,i,n=!1){let o=db[r]?.strict().safeParse(i);if(!o?.success)throw new j("\u8BF7\u6C42\u53C2\u6570\u65E0\u6548");let a=o.data;switch(r){case"get_waiting_status":case"browse_waiting_catalog":{let s=e.waiting;if(n||!s)throw new j("\u8BF7\u4ECE\u672C\u8F6E\u63A8\u8350\u4E2D\u9009\u5267",403);return r==="get_waiting_status"?{visible:this.store.offerable(e.sessionId,s.turnId)}:(s.selected=null,s.taken=!1,s.browsing=!0,s.played=!0,{})}case"dismiss_waiting_picks":{let s=a.turnId??e.waiting?.turnId;if(!e.sessionId||!s||e.waiting&&s!==e.waiting.turnId||n&&e.fixedTurn&&s!==e.fixedTurn||!this.store.state(e.sessionId,s).turnId)throw new j("\u8BF7\u4ECE\u672C\u8F6E\u63A8\u8350\u4E2D\u9009\u5267",403);return this.store.dismissPicks(e.sessionId,s)}case"get_waiting_picks":case"mark_waiting_picks_shown":{let s=e.waiting,u=a.turnId??s?.turnId;if(!e.sessionId||!u||n&&e.fixedTurn&&u!==e.fixedTurn||s&&a.turnId&&!s.taken)throw new j("\u8BF7\u4ECE\u672C\u8F6E\u63A8\u8350\u4E2D\u9009\u5267",403);let c=()=>a.turnId?this.store.activeTurn(e.sessionId,u)&&this.store.preferences().autoPrompt&&!this.store.picksDismissed(e.sessionId,u):this.store.offerable(e.sessionId,u);return r==="mark_waiting_picks_shown"?this.store.markPicksShown(e.sessionId,u,c):this.waitingPicks(e.sessionId,u,!!a.inView,c)}case"select_waiting_pick":case"confirm_waiting_playback":case"activate_waiting_player":{let s=e.waiting;if(n||!s)throw new j("\u8BF7\u4ECE\u672C\u8F6E\u63A8\u8350\u4E2D\u9009\u5267",403);if(r==="confirm_waiting_playback")return s.playbackId===a.playbackId&&(s.played=!0),{};if(r==="select_waiting_pick"){if(!this.store.offerable(e.sessionId,s.turnId))throw new j("\u8FD9\u6761\u63A8\u8350\u5DF2\u7ED3\u675F");let l=this.store.turnPicks(e.sessionId,s.turnId).find(d=>d.id===a.seriesId);if(!l)throw new j("\u8BF7\u4ECE\u672C\u8F6E\u63A8\u8350\u4E2D\u9009\u5267",403);return this.store.markPicksShown(e.sessionId,s.turnId,()=>this.store.offerable(e.sessionId,s.turnId)),s.selected=l,s.taken=!1,s.browsing=!1,s.played=!1,s.playbackId=(s.playbackId||0)+1,{}}let u=this.store.activeTurn(e.sessionId,s.turnId),c=!!s.selected&&!s.played&&u&&!this.store.picksDismissed(e.sessionId,s.turnId);return s.taken=!0,s.browsing&&(this.store.dismissPicks(e.sessionId,s.turnId),s.browsing=!1),{pick:s.selected,turnId:s.turnId,play:c,...c?{playbackId:s.playbackId}:{},...s.selected&&!u?{reason:"turn-ended"}:{}}}case"set_player_visible":if(e.waiting&&!e.waiting.taken)throw new j("\u8BF7\u4ECE\u672C\u8F6E\u63A8\u8350\u4E2D\u9009\u5267",403);return this.store.playerVisible(e.sessionId,a.instance,a.visible),{};case"get_run_state":{if(!this.store.persistent)throw new j("\u672C\u673A\u4F1A\u8BDD\u72B6\u6001\u4E0D\u53EF\u8FBE",503);if(this.store.touchPlayer(e.sessionId,a.playerInstance),a.observeSession){if(a.turnId||e.waiting&&!e.waiting.taken)throw new j("\u8BF7\u5148\u6253\u5F00\u64AD\u653E\u5668",403);return{...this.store.state(e.sessionId,n?e.fixedTurn:void 0),preferences:this.store.preferences()}}let s=e.waiting?.turnId??(n?e.fixedTurn:null);if(s&&a.turnId&&a.turnId!==s)throw new j("\u64AD\u653E\u5668\u5DF2\u7ED1\u5B9A\u5176\u4ED6\u56DE\u5408",403);let u=s??a.turnId,c=this.store.state(e.sessionId,u);return e.waiting&&c.state==="submitted"&&!this.store.activeTurn(e.sessionId,u)?{...c,state:"unknown"}:c}case"list_sessions":if(n||e.sessionId)throw new j("\u5F53\u524D\u5165\u53E3\u4E0D\u5141\u8BB8\u9009\u62E9\u5176\u4ED6\u4F1A\u8BDD",403);return e.choices.clear(),{items:this.store.candidates().map(s=>{let u=Gu();return e.choices.set(u,s.session_id),{choice:u,suffix:s.session_id.slice(-8),at:s.at}})};case"select_session":if(n||e.sessionId||!e.choices.has(a.choice))throw new j("\u8BF7\u91CD\u65B0\u9009\u62E9\u4F1A\u8BDD",403);return e.sessionId=e.choices.get(a.choice),e.choices.clear(),this.store.state(e.sessionId);case"list_series":return this.catalog.list(a);case"get_cover":return this.catalog.cover(a.seriesId);case"get_episodes":{let s=await this.catalog.episodes(a);e.allowed??=new Set;for(let u of s.items)u.playable&&e.allowed.add(u.id);return s}case"get_history":return{items:this.store.history(a.seriesId,a.episodeId)};case"remove_history":return this.store.removeHistory(a.seriesId);case"read_panel_chunk":case"read_panel_manifest":if(n||e.streams?.get(a.episodeId)!==a.stream)throw new j("\u8BF7\u5148\u51C6\u5907\u5F53\u524D\u5206\u96C6",403);return r==="read_panel_manifest"?this.catalog.panelMedia.manifest(a.episodeId,a.stream):this.catalog.panelMedia.chunk(a.episodeId,a.stream,a.asset,a.offset);case"save_progress":if(!this.store.persistent)throw new j("\u672C\u673A\u8FDB\u5EA6\u76EE\u5F55\u4E0D\u53EF\u5199",503);return this.catalog.cache?.hold(a.episodeId),this.store.save(a);case"preload_playback":{if(!e.allowed?.has(a.episodeId))throw new j("\u8BF7\u5148\u9009\u62E9\u53EF\u64AD\u653E\u7684\u5206\u96C6",403);let{status:s}=this.catalog.prepare(a.episodeId,n,!1,!0);return{status:s}}case"prepare_playback":{if(!e.allowed?.has(a.episodeId))throw new j("\u8BF7\u5148\u9009\u62E9\u53EF\u64AD\u653E\u7684\u5206\u96C6",403);!n&&e.playing!==a.episodeId&&(this.catalog.panelMedia?.unpin(e.playing,e),e.streams?.clear(),e.playing=a.episodeId);let s=this.catalog.prepare(a.episodeId,n,!!a.retry);return n&&s.status==="ready"&&e.grants.add(a.episodeId),!n&&s.stream&&(this.catalog.panelMedia.pin(a.episodeId,e),e.streams??=new Map,e.streams.set(a.episodeId,s.stream)),s}case"get_preferences":return this.store.preferences();case"set_preferences":{if(!this.store.persistent)throw new j("\u672C\u673A\u8BBE\u7F6E\u76EE\u5F55\u4E0D\u53EF\u5199",503);let s=this.store.preferences(),u=this.store.setPreferences(a);return JSON.stringify(s.searchTerms)!==JSON.stringify(u.searchTerms)&&(this.catalog.feed=null,this.catalog.refresh=null),u}case"get_health":return this.catalog.ffmpeg||this.catalog.prepareMediaRuntime?.().catch(()=>{}),{runtime:process.version,database:this.store.writable(),ffmpeg:this.catalog.ffmpeg};case"get_setup_status":return this.catalog.ffmpeg||this.catalog.prepareMediaRuntime?.().catch(()=>{}),{runtime:process.version,database:this.store.writable(),ffmpeg:this.catalog.ffmpeg,dismissed:this.store.setupDismissed(),hooks:Gk()};case"set_setup_dismissed":if(!this.store.persistent)throw new j("\u672C\u673A\u8BBE\u7F6E\u76EE\u5F55\u4E0D\u53EF\u5199",503);return this.store.setSetupDismissed(a.dismissed);case"create_browser_pairing":{if(n)throw new j("\u8BF7\u4ECE\u4F1A\u8BDD\u9762\u677F\u6253\u5F00\u5206\u5C4F",403);let s=a.follow&&this.store.state(e.sessionId,a.turnId);if(a.follow&&(!a.turnId||s.state!=="submitted"))throw new j("\u5F53\u524D\u56DE\u5408\u65E0\u6CD5\u7ED1\u5B9A\uFF0C\u8BF7\u9009\u62E9\u624B\u52A8\u64AD\u653E");return this.pair({sessionId:a.follow===!1?null:e.sessionId,fixedTurn:a.follow?a.turnId:null,selection:a.seriesId?{seriesId:a.seriesId,episodeId:a.episodeId,title:a.title}:null})}}}};import{join as VT}from"node:path";import{pathToFileURL as oQ}from"node:url";import{Writable as aQ}from"node:stream";import{pipeline as sQ}from"node:stream/promises";import{spawn as zZ}from"node:child_process";var MF=Un(jC(),1),LF=Un(gb(),1);import{accessSync as OF,constants as uD,statSync as RF}from"node:fs";import{homedir as jF}from"node:os";import{posix as BF,win32 as UF}from"node:path";import{createHash as JC,randomUUID as AF}from"node:crypto";import{createReadStream as KC}from"node:fs";import{mkdir as HC,lstat as yF,open as XC,readFile as YC,writeFile as _F,rename as bF,rm as da,chmod as $F,stat as GC,unlink as iY,rmdir as oY}from"node:fs/promises";import{lstatSync as IF}from"node:fs";import{homedir as wF}from"node:os";import{posix as WC,win32 as eD}from"node:path";import{spawnSync as EF}from"node:child_process";import{createRequire as K3}from"module";var X3=K3("/"),la,Y3,W3;try{la=X3("worker_threads"),Y3=la.Worker,W3=la.isMarkedAsUntransferable}catch{}var qt=Uint8Array,ca=Uint16Array,eF=Int32Array,BC=new qt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),UC=new qt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),tF=new qt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),MC=function(t,e){for(var r=new ca(31),i=0;i<31;++i)r[i]=e+=1<<t[i-1];for(var n=new eF(r[30]),i=1;i<30;++i)for(var o=r[i];o<r[i+1];++o)n[o]=o-r[i]<<5|i;return{b:r,r:n}},la=MC(BC,2),LC=la.b,rF=la.r;LC[28]=258,rF[258]=28;var FC=MC(UC,0),nF=FC.b,YX=FC.r,Eb=new ca(32768);for(ye=0;ye<32768;++ye)Kr=(ye&43690)>>1|(ye&21845)<<1,Kr=(Kr&52428)>>2|(Kr&13107)<<2,Kr=(Kr&61680)>>4|(Kr&3855)<<4,Eb[ye]=((Kr&65280)>>8|(Kr&255)<<8)>>1;var Kr,ye,Ju=(function(t,e,r){for(var i=t.length,n=0,o=new ca(e);n<i;++n)t[n]&&++o[t[n]-1];var a=new ca(e);for(n=1;n<e;++n)a[n]=a[n-1]+o[n-1]<<1;var s;if(r){s=new ca(1<<e);var u=15-e;for(n=0;n<i;++n)if(t[n])for(var c=n<<4|t[n],l=e-t[n],d=a[t[n]-1]++<<l,p=d|(1<<l)-1;d<=p;++d)s[Eb[d]>>u]=c}else for(s=new ca(i),n=0;n<i;++n)t[n]&&(s[n]=Eb[a[t[n]-1]++]>>15-t[n]);return s}),Ku=new qt(288);for(ye=0;ye<144;++ye)Ku[ye]=8;var ye;for(ye=144;ye<256;++ye)Ku[ye]=9;var ye;for(ye=256;ye<280;++ye)Ku[ye]=7;var ye;for(ye=280;ye<288;++ye)Ku[ye]=8;var ye,ZC=new qt(32);for(ye=0;ye<32;++ye)ZC[ye]=5;var ye;var iF=Ju(Ku,9,1);var oF=Ju(ZC,5,1),$b=function(t){for(var e=t[0],r=1;r<t.length;++r)t[r]>e&&(e=t[r]);return e},vr=function(t,e,r){var i=e/8|0;return(t[i]|t[i+1]<<8)>>(e&7)&r},Ib=function(t,e){var r=e/8|0;return(t[r]|t[r+1]<<8|t[r+2]<<16)>>(e&7)},aF=function(t){return(t+7)/8|0},Sb=function(t,e,r){return(e==null||e<0)&&(e=0),(r==null||r>t.length)&&(r=t.length),new qt(t.subarray(e,r))};var sF=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Qt=function(t,e,r){var i=new Error(e||sF[t]);if(i.code=t,Error.captureStackTrace&&Error.captureStackTrace(i,Qt),!r)throw i;return i},uF=function(t,e,r,i){var n=t.length,o=i?i.length:0;if(!n||e.f&&!e.l)return r||new qt(0);var a=!r,s=a||e.i!=2,u=e.i;a&&(r=new qt(n*3));var c=function(g0){var v0=r.length;if(g0>v0){var A0=new qt(Math.max(v0*2,g0));A0.set(r),r=A0}},l=e.f||0,d=e.p||0,p=e.b||0,m=e.l,h=e.d,f=e.m,g=e.n,y=n*8;do{if(!m){l=vr(t,d,1);var v=vr(t,d+1,3);if(d+=3,v)if(v==1)m=iF,h=oF,f=9,g=5;else if(v==2){var N=vr(t,d,31)+257,K=vr(t,d+10,15)+4,Le=N+vr(t,d+5,31)+1;d+=14;for(var de=new qt(Le),Ue=new qt(19),X=0;X<K;++X)Ue[tF[X]]=vr(t,d+X*3,7);d+=K*3;for(var jt=$b(Ue),nn=(1<<jt)-1,Bn=Ju(Ue,jt,1),X=0;X<Le;){var Da=Bn[vr(t,d,nn)];d+=Da&15;var A=Da>>4;if(A<16)de[X++]=A;else{var Se=0,Ke=0;for(A==16?(Ke=3+vr(t,d,3),d+=2,Se=de[X-1]):A==17?(Ke=3+vr(t,d,7),d+=3):A==18&&(Ke=11+vr(t,d,127),d+=7);Ke--;)de[X++]=Se}}var yc=de.subarray(0,N),on=de.subarray(N);f=$b(yc),g=$b(on),m=Ju(yc,f,1),h=Ju(on,g,1)}else Qt(1);else{var A=aF(d)+4,x=t[A-4]|t[A-3]<<8,k=A+x;if(k>n){u&&Qt(0);break}s&&c(p+x),r.set(t.subarray(A,k),p),e.b=p+=x,e.p=d=k*8,e.f=l;continue}if(d>y){u&&Qt(0);break}}s&&c(p+131072);for(var e1=(1<<f)-1,t1=(1<<g)-1,Rm=d;;Rm=d){var Se=m[Ib(t,d)&e1],Ii=Se>>4;if(d+=Se&15,d>y){u&&Qt(0);break}if(Se||Qt(2),Ii<256)r[p++]=Ii;else if(Ii==256){Rm=d,m=null;break}else{var p0=Ii-254;if(Ii>264){var X=Ii-257,Ta=BC[X];p0=vr(t,d,(1<<Ta)-1)+LC[X],d+=Ta}var jm=h[Ib(t,d)&t1],Bm=jm>>4;jm||Qt(3),d+=jm&15;var on=nF[Bm];if(Bm>3){var Ta=UC[Bm];on+=Ib(t,d)&(1<<Ta)-1,d+=Ta}if(d>y){u&&Qt(0);break}s&&c(p+131072);var m0=p+p0;if(p<on){var h0=o-on,r1=Math.min(on,m0);for(h0+p<0&&Qt(3);p<r1;++p)r[p]=i[h0+p]}for(;p<m0;++p)r[p]=r[p-on]}}e.l=m,e.p=Rm,e.b=p,e.f=l,m&&(l=1,e.m=f,e.d=h,e.n=g)}while(!l);return p!=r.length&&a?Sb(r,0,p):r.subarray(0,p)};var cF=new qt(0);var Pr=function(t,e){return t[e]|t[e+1]<<8},nr=function(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0},wb=function(t,e){return nr(t,e)+nr(t,e+4)*4294967296};function lF(t,e){return uF(t,{i:2},e&&e.out,e&&e.dictionary)}var xb=typeof TextDecoder<"u"&&new TextDecoder,dF=0;try{xb.decode(cF,{stream:!0}),dF=1}catch{}var fF=function(t){for(var e="",r=0;;){var i=t[r++],n=(i>127)+(i>223)+(i>239);if(r+n>t.length)return{s:e,r:Sb(t,r-1)};n?n==3?(i=((i&15)<<18|(t[r++]&63)<<12|(t[r++]&63)<<6|t[r++]&63)-65536,e+=String.fromCharCode(55296|i>>10,56320|i&1023)):n&1?e+=String.fromCharCode((i&31)<<6|t[r++]&63):e+=String.fromCharCode((i&15)<<12|(t[r++]&63)<<6|t[r++]&63):e+=String.fromCharCode(i)}};function pF(t,e){if(e){for(var r="",i=0;i<t.length;i+=16384)r+=String.fromCharCode.apply(null,t.subarray(i,i+16384));return r}else{if(xb)return xb.decode(t);var n=fF(t),o=n.s,r=n.r;return r.length&&Qt(8),o}}var mF=function(t,e){return e+30+Pr(t,e+26)+Pr(t,e+28)},hF=function(t,e,r){var i=Pr(t,e+28),n=Pr(t,e+30),o=pF(t.subarray(e+46,e+46+i),!(Pr(t,e+8)&2048)),a=e+46+i,s=gF(t,a,n,r,nr(t,e+20),nr(t,e+24),nr(t,e+42)),u=s[0],c=s[1],l=s[2];return[Pr(t,e+10),u,c,o,a+n+Pr(t,e+32),l]},gF=function(t,e,r,i,n,o,a){var s=n==4294967295,u=o==4294967295,c=a==4294967295,l=e+r,d=s+u+c;if(i&&d){for(;e+4<l;e+=4+Pr(t,e+2))if(Pr(t,e)==1)return[s?wb(t,e+4+8*u):n,u?wb(t,e+4):o,c?wb(t,e+4+8*(u+s)):a,1];i<2&&Qt(13)}return[n,o,a,0]};function QC(t,e){for(var r={},i=t.length-22;nr(t,i)!=101010256;--i)(!i||t.length-i>65558)&&Qt(13);var n=Pr(t,i+8);if(!n)return{};var o=nr(t,i+16),a=nr(t,i-20)==117853008;if(a){var s=nr(t,i-12);a=nr(t,s)==101075792,a&&(n=nr(t,s+32),o=nr(t,s+48))}for(var u=e&&e.filter,c=0;c<n;++c){var l=hF(t,o,a),d=l[0],p=l[1],m=l[2],h=l[3],f=l[4],g=l[5],y=mF(t,g);o=f,(!u||u({name:h,size:p,originalSize:m,compression:d}))&&(d?d==8?r[h]=lF(t.subarray(y,y+p),{out:new qt(m)}):Qt(14,"unknown compression type "+d):r[h]=Sb(t,y,y+p))}return r}var tD=Un(qC(),1);var VC={"darwin-arm64":{version:"9.0.2",url:"https://www.osxexperts.net/ffmpeg902arm.zip",format:"zip",entry:"ffmpeg",archiveBytes:22665869,archiveSha256:"07e00300593799005b060c03a99fe648b1edda0f30c36b0c1adafe8e3247e586",binaryBytes:52160568,binarySha256:"762f16b2913b8d3b8fdb8092df12b691053b035b13ae9b88205513c55cb8e71e"},"darwin-x64":{version:"9.0.2",url:"https://evermeet.cx/ffmpeg/ffmpeg-9.0.2.zip",format:"zip",entry:"ffmpeg",archiveBytes:26198325,archiveSha256:"4acc0be580f9b2788029eb7bd4d645ff87968911b0a62aeeb3940d42d54558d5",binaryBytes:80827688,binarySha256:"a45b462cf91ed89148ae218c4577e30896485d7a6792c3673bcf5f823fa01b63"},"linux-x64":{version:"9.0.2-20261031",url:"https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2026-10-31-12-59/ffmpeg-n9.0.2-39-g7adfbe40dc-linux64-gpl-9.0.tar.xz",format:"tar.xz",entry:"ffmpeg-n9.0.2-39-g7adfbe40dc-linux64-gpl-9.0/bin/ffmpeg",archiveBytes:153175100,archiveSha256:"73e29a56974ae5a651133a04584c7483b21afe941e17dc91d79814a758b608d3"},"linux-arm64":{version:"9.0.2-20261031",url:"https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2026-10-31-12-59/ffmpeg-n9.0.2-39-g7adfbe40dc-linuxarm64-gpl-9.0.tar.xz",format:"tar.xz",entry:"ffmpeg-n9.0.2-39-g7adfbe40dc-linuxarm64-gpl-9.0/bin/ffmpeg",archiveBytes:128664064,archiveSha256:"6cad88ae5bcec356cfc5d7979a036cc4007128201928a0cf243df3db483276cc"},"win32-x64":{version:"9.0.2-20261031",url:"https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2026-10-31-12-59/ffmpeg-n9.0.2-39-g7adfbe40dc-win64-gpl-9.0.zip",format:"zip",entry:"ffmpeg-n9.0.2-39-g7adfbe40dc-win64-gpl-9.0/bin/ffmpeg.exe",archiveBytes:195110184,archiveSha256:"693f3e224bc184b40524a62ca47526cfebaf2504414021b92fe75f677ad868b9"},"win32-arm64":{version:"9.0.2-20261031",url:"https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2026-10-31-12-59/ffmpeg-n9.0.2-39-g7adfbe40dc-winarm64-gpl-9.0.zip",format:"zip",entry:"ffmpeg-n9.0.2-39-g7adfbe40dc-winarm64-gpl-9.0/bin/ffmpeg.exe",archiveBytes:136603040,archiveSha256:"8b3c394762f26716ccef03ac1b7ac76430759080e1255aa9bc01d74db590bcb5",binaryBytes:95170560,binarySha256:"e2248aa5ecd155814e951fd0606df71589699a2fd4db14a9323a0b400a6c9b06"}};var fa=new Map,om=new Map,xF="@kyun.si/codex-hongguo",rD=new Set(["prepare","download","download-url","download-http","download-network","archive-size","archive-hash","extract","binary-hash","probe","publish"]),SF=new Set(["UND_ERR_CONNECT_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_BODY_TIMEOUT","UND_ERR_SOCKET","ECONNRESET","ECONNREFUSED","ETIMEDOUT","EAI_AGAIN","ENETUNREACH","EHOSTUNREACH"]),kF=new Set([408,429,500,502,503,504]),qe=(t="prepare",e)=>Object.assign(Error("\u64AD\u653E\u7EC4\u4EF6\u81EA\u52A8\u51C6\u5907\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC\u548C\u7F13\u5B58\u76EE\u5F55\u6743\u9650\u540E\u91CD\u8BD5\u5B89\u88C5\u3002"),{code:t,...Number.isInteger(e)&&e>=400&&e<=599?{httpStatus:e}:{}}),nD=t=>new Promise(e=>setTimeout(e,t));function iD(t={}){let{env:e=process.env,home:r=wF(),platform:i=process.platform,arch:n=process.arch}=t,o=i==="win32"?eD:WC;if(e.HONGGUO_FFMPEG){if(!o.isAbsolute(e.HONGGUO_FFMPEG))throw qe();return{...t,env:e,platform:i,target:e.HONGGUO_FFMPEG,override:!0}}let a=(t.artifacts||VC)[i+"-"+n];if(!a)throw Error("\u5F53\u524D\u7CFB\u7EDF\u67B6\u6784\u6682\u4E0D\u652F\u6301\u81EA\u52A8\u51C6\u5907\u64AD\u653E\u7EC4\u4EF6\u3002");let s=CF({env:e,home:r,platform:i,paths:o}),u=o.join(s,"runtime","ffmpeg",a.archiveSha256.slice(0,16),i+"-"+n);return{...t,env:e,platform:i,artifact:a,directory:u,target:o.join(u,i==="win32"?"ffmpeg.exe":"ffmpeg")}}function CF({env:t,home:e,platform:r,paths:i}){return t.HONGGUO_RUNTIME_DIR?i.join(t.HONGGUO_RUNTIME_DIR,"codex-hongguo"):r==="darwin"?i.join(e,"Library","Caches","CodexHongguo"):r==="win32"?i.join(t.LOCALAPPDATA||i.join(e,"AppData","Local"),"CodexHongguo","Cache"):i.join(t.XDG_CACHE_HOME||i.join(e,".cache"),"codex-hongguo")}function Db(t){return iD(t).target}function am(t){try{let e=IF(t);return e.isFile()&&!e.isSymbolicLink()?`${e.size}:${e.mtimeMs}:${e.ctimeMs}`:null}catch{return null}}function oD(t){try{let e=Db(t);return!!fa.get(e)&&fa.get(e)===am(e)}catch{return!1}}async function aD(t){let e=JC("sha256");for await(let r of KC(t))e.update(r);return e.digest("hex")}function sD(t,e){return e.probe?e.probe(t):EF(t,["-version"],{stdio:"ignore",timeout:5e3,windowsHide:!0}).status===0}async function Cb(t){let{target:e,artifact:r}=t;if(fa.get(e)&&fa.get(e)===am(e))return!0;try{let i=await yF(e);if(!i.isFile()||i.isSymbolicLink())return!1;if(r){let n=JSON.parse(await YC(e+".json","utf8"));if(n.archiveSha256!==r.archiveSha256||!/^[a-f0-9]{64}$/.test(n.binarySha256)||i.size!==(r.binaryBytes||n.binaryBytes)||await aD(e)!==(r.binarySha256||n.binarySha256))return!1}return sD(e,t)?(fa.set(e,am(e)),!0):!1}catch{return!1}}async function DF(t,e,r){let i=AbortSignal.timeout(3e5);for(let n=0;;n++)try{return await TF(t,e,r,i)}catch(o){await da(e,{force:!0});let a=SF.has(o?.cause?.code||o?.code);if(!(a||o?.code==="download-http"&&kF.has(o.httpStatus))||n>=2||i.aborted)throw qe(a?"download-network":rD.has(o?.code)?o.code:"download",o?.httpStatus);await nD((n+1)*1e3)}}async function TF(t,e,r,i){let n=new Set(["github.com","release-assets.githubusercontent.com","objects.githubusercontent.com","evermeet.cx","www.osxexperts.net"]),o=new URL(t.url),a;for(let l=0;l<=6;l++){if(o.protocol!=="https:"||o.username||o.password||o.port||!n.has(o.hostname))throw qe("download-url");if(a=await r(o,{redirect:"manual",signal:i}),![301,302,303,307,308].includes(a.status))break;let d=a.headers.get("location");if(await a.body?.cancel(),!d||l===6)throw qe("download-url");o=new URL(d,o)}if(!a.ok||!a.body)throw await a.body?.cancel(),qe("download-http",a.status);if(Number(a.headers.get("content-length"))>t.archiveBytes)throw await a.body.cancel(),qe("archive-size");let s=await XC(e,"wx",384),u=JC("sha256"),c=0;try{for await(let l of a.body){if(c+=l.length,c>t.archiveBytes)throw qe("archive-size");u.update(l),await s.writeFile(l)}if(c!==t.archiveBytes)throw qe("archive-size");if(u.digest("hex")!==t.archiveSha256)throw qe("archive-hash")}finally{await s.close()}}async function NF(t,e,r){let i=await XC(r,"wx",384);try{if(t.format==="zip"){let p=QC(await YC(e),{filter:m=>m.name===t.entry&&m.originalSize<=(t.binaryBytes||268435456)})[t.entry];if(!p||t.binaryBytes&&p.length!==t.binaryBytes)throw qe();await i.writeFile(p);return}let n=new tD.default.XzReadableStream(zF(e)),o=n.getReader(),a=Buffer.alloc(0),s=0,u=0,c=!1,l=0;try{for(;;){let{value:d,done:p}=await o.read();if(p)break;if(l+=d.length,l>1024*1024*1024)throw qe();for(a=Buffer.concat([a,d]);a.length;)if(s){let m=Math.min(s,a.length);if(c&&await i.writeFile(a.subarray(0,m)),a=a.subarray(m),s-=m,!s&&c)return}else if(u){let m=Math.min(u,a.length);a=a.subarray(m),u-=m}else{if(a.length<512)break;let m=a.subarray(0,512);a=a.subarray(512);let h=(y,v)=>m.subarray(y,v).toString("utf8").split("\0")[0],f=[h(345,500),h(0,100)].filter(Boolean).join("/"),g=parseInt(h(124,136).trim()||"0",8);if(!Number.isSafeInteger(g)||g<0||g>512*1024*1024||(c=f===t.entry,c&&(t.binaryBytes&&g!==t.binaryBytes||g>256*1024*1024||![0,48].includes(m[156]))))throw qe();s=g,u=(512-g%512)%512}}throw qe()}finally{await o.cancel().catch(()=>{})}}finally{await i.close()}}function zF(t){let e=KC(t)[Symbol.asyncIterator]();return new ReadableStream({async pull(r){let{value:i,done:n}=await e.next();n?r.close():r.enqueue(i)},async cancel(){await e.return?.()}})}async function sm(t={}){let e=iD(t);if(await Cb(e))return e.target;if(e.override)throw qe();if(om.has(e.target))return om.get(e.target);let r=PF(e).finally(()=>om.delete(e.target));return om.set(e.target,r),r}async function PF(t){let{directory:e,target:r,artifact:i}=t,n=e+".lock",o=Date.now()+42e4;await HC(e,{recursive:!0,mode:448});let a=!1;for(;!a;)try{await HC(n,{mode:448}),a=!0}catch(p){if(p.code!=="EEXIST"||Date.now()>o)throw qe();if(await Cb(t))return r;try{Date.now()-(await GC(n)).mtimeMs>6e5&&await da(n,{recursive:!0,force:!0})}catch{}await nD(200)}let s=t.platform==="win32"?eD:WC,u=s.basename(r)+"."+AF(),c=s.join(e,u+".archive"),l=s.join(e,u+".part"),d="download";try{if(await Cb(t))return r;await DF(i,c,t.fetchImpl||fetch),d="extract",await NF(i,c,l);let p=await aD(l);if(i.binarySha256&&p!==i.binarySha256)throw qe("binary-hash");if(await $F(l,493),!sD(l,t))throw qe("probe");return d="publish",t.platform==="win32"&&await da(r,{force:!0}),await bF(l,r),await _F(r+".json",JSON.stringify({owner:xF,schema:1,archiveSha256:i.archiveSha256,binarySha256:p,binaryBytes:(await GC(r)).size,version:i.version})+`
|
|
140
|
+
WHERE rank=1 ORDER BY updated_at DESC LIMIT ?`).all(i)}removeHistory(e){return this.transaction(()=>(this.db.prepare("DELETE FROM watch_progress WHERE series_id=?").run(e),this.db.prepare("DELETE FROM watch_restart WHERE series_id=?").run(e),{removed:!0}))}writable(){if(!this.persistent)return!1;try{return this.db.exec("UPDATE watch_progress SET updated_at=updated_at WHERE 0"),!0}catch{return!1}}close(){this.db.close()}};import{randomBytes as I3}from"node:crypto";var j=class extends Error{constructor(e,r=400){super(e),this.status=r}};function rm(t){return t instanceof j?t.message:"\u672C\u673A\u670D\u52A1\u6216\u7247\u6E90\u6682\u65F6\u4E0D\u53EF\u8FBE\uFF0C\u8BF7\u91CD\u8BD5"}var $3="\u8BF7\u5728 Codex \u8BBE\u7F6E \u2192 Hooks \u2192 \u7EA2\u679C\u77ED\u5267\u4E2D\u68C0\u67E5\u6388\u6743\uFF0C\u5BA1\u67E5\u3001\u4FE1\u4EFB\u5E76\u542F\u7528 UserPromptSubmit\u3001Stop\u3001Interrupt\u3002";function Gk(){return{status:"manual_check",events:["userPromptSubmit","stop","interrupt"].map(t=>({event:t,status:"manual_check"})),message:$3}}var Gu=()=>I3(24).toString("base64url"),zr=M.string().regex(/^[a-zA-Z0-9_-]{1,128}$/),dt=M.string().regex(/^hg-[0-9]{1,32}$/),Jk=M.string().max(4096).optional(),lb=M.string().min(1).max(320),Kk=M.number().int().min(0).max(24*3600*1e3),db={get_run_state:M.object({turnId:zr.optional(),playerInstance:zr.optional(),observeSession:M.literal(!0).optional()}),set_player_visible:M.object({instance:zr,visible:M.boolean()}),get_waiting_picks:M.object({turnId:zr.optional(),inView:M.literal(!0).optional()}),mark_waiting_picks_shown:M.object({turnId:zr.optional()}),get_waiting_status:M.object({}),dismiss_waiting_picks:M.object({turnId:zr.optional()}),browse_waiting_catalog:M.object({}),select_waiting_pick:M.object({seriesId:dt}),activate_waiting_player:M.object({}),confirm_waiting_playback:M.object({playbackId:M.number().int().positive()}),list_sessions:M.object({}),select_session:M.object({choice:zr}),list_series:M.object({source:M.literal("hongguo").optional(),preview:M.literal(!0).optional(),query:M.string().max(120).optional(),cursor:Jk}),get_cover:M.object({seriesId:dt}),get_episodes:M.object({seriesId:dt,cursor:Jk}),get_history:M.object({seriesId:dt.optional(),episodeId:dt.optional()}),save_progress:M.object({seriesId:dt,episodeId:dt,title:lb,label:lb,positionMs:Kk,durationMs:Kk.positive(),reset:M.literal(!0).optional()}),prepare_playback:M.object({episodeId:dt,retry:M.boolean().optional()}),preload_playback:M.object({episodeId:dt}),create_browser_pairing:M.object({follow:M.boolean().optional(),turnId:zr.optional(),seriesId:dt.optional(),episodeId:dt.optional(),title:lb.optional()}),get_health:M.object({}),get_setup_status:M.object({}),set_setup_dismissed:M.object({dismissed:M.boolean()}),get_preferences:M.object({}),set_preferences:M.object({autoPrompt:M.boolean().optional(),searchTerms:M.array(M.string().trim().min(1).max(30)).min(1).max(6).optional(),autoplayNext:M.boolean().optional(),autoPauseOnFinish:M.boolean().optional(),autoPlayOnStart:M.boolean().optional(),defaultMuted:M.boolean().optional(),hoverDecoyEnabled:M.boolean().optional(),volume:M.number().positive().max(1).optional()}),read_panel_chunk:M.object({episodeId:dt,stream:zr,asset:M.string().max(32),offset:M.number().int().nonnegative().max(32*1024*1024)}),read_panel_manifest:M.object({episodeId:dt,stream:zr}),remove_history:M.object({seriesId:dt})},nm=class{constructor(e,r){this.store=e,this.catalog=r,this.panels=new Map}open(e){let r=Gu(),i={sessionId:tm(e),choices:new Map,lastSeen:Date.now()};for(let[n,o]of this.panels)Date.now()-o.lastSeen>12*36e5&&this.panels.delete(n);return i.caller=i.sessionId,this.panels.set(r,i),{panel:r,state:this.store.state(i.sessionId),identified:!!i.sessionId}}openWaiting(e,r){let i=tm(e);if(!i||[e?.turn_id,e?.turnId].some(o=>o!==void 0&&o!==r)||!this.store.claimCard(i,r))return null;let n=this.open(e);return this.panels.get(n.panel).waiting={turnId:r,selected:null,taken:!1},n}async resumePick(){for(let e of this.store.history(void 0,void 0,-1)){if(!dt.safeParse(e.seriesId).success||!dt.safeParse(e.episodeId).success)continue;let r={id:e.seriesId,title:e.title};if(e.positionMs<e.durationMs)return{...r,episodeId:e.episodeId,kind:"resume"};try{let i=await this.catalog.nextEpisode(e.seriesId,e.episodeId);if(i)return{...r,...i}}catch{continue}}return null}async waitingPicks(e,r,i,n){if(!n())return{items:[]};let o=this.store.turnPicks(e,r);if(o.length)return{items:o};let[a,s]=await Promise.all([this.catalog.waitingRecommendations().catch(()=>[]),this.resumePick()]);return{items:this.store.allocatePicks(e,r,s,a,i,n)}}panel(e,r){let i=this.panels.get(e);if(!i||Date.now()-i.lastSeen>12*36e5)throw new j("\u8BF7\u91CD\u65B0\u6253\u5F00\u77ED\u5267\u9762\u677F",401);if((r?.thread_id!==void 0||r?.threadId!==void 0)&&tm(r)!==i.caller)throw new j("\u4F1A\u8BDD\u4E0D\u5339\u914D",403);return i.lastSeen=Date.now(),i}async call(e,r,i,n=!1){let o=db[r]?.strict().safeParse(i);if(!o?.success)throw new j("\u8BF7\u6C42\u53C2\u6570\u65E0\u6548");let a=o.data;switch(r){case"get_waiting_status":case"browse_waiting_catalog":{let s=e.waiting;if(n||!s)throw new j("\u8BF7\u4ECE\u672C\u8F6E\u63A8\u8350\u4E2D\u9009\u5267",403);return r==="get_waiting_status"?{visible:this.store.offerable(e.sessionId,s.turnId)}:(s.selected=null,s.taken=!1,s.browsing=!0,s.played=!0,{})}case"dismiss_waiting_picks":{let s=a.turnId??e.waiting?.turnId;if(!e.sessionId||!s||e.waiting&&s!==e.waiting.turnId||n&&e.fixedTurn&&s!==e.fixedTurn||!this.store.state(e.sessionId,s).turnId)throw new j("\u8BF7\u4ECE\u672C\u8F6E\u63A8\u8350\u4E2D\u9009\u5267",403);return this.store.dismissPicks(e.sessionId,s)}case"get_waiting_picks":case"mark_waiting_picks_shown":{let s=e.waiting,u=a.turnId??s?.turnId;if(!e.sessionId||!u||n&&e.fixedTurn&&u!==e.fixedTurn||s&&a.turnId&&!s.taken)throw new j("\u8BF7\u4ECE\u672C\u8F6E\u63A8\u8350\u4E2D\u9009\u5267",403);let c=()=>a.turnId?this.store.activeTurn(e.sessionId,u)&&this.store.preferences().autoPrompt&&!this.store.picksDismissed(e.sessionId,u):this.store.offerable(e.sessionId,u);return r==="mark_waiting_picks_shown"?this.store.markPicksShown(e.sessionId,u,c):this.waitingPicks(e.sessionId,u,!!a.inView,c)}case"select_waiting_pick":case"confirm_waiting_playback":case"activate_waiting_player":{let s=e.waiting;if(n||!s)throw new j("\u8BF7\u4ECE\u672C\u8F6E\u63A8\u8350\u4E2D\u9009\u5267",403);if(r==="confirm_waiting_playback")return s.playbackId===a.playbackId&&(s.played=!0),{};if(r==="select_waiting_pick"){if(!this.store.offerable(e.sessionId,s.turnId))throw new j("\u8FD9\u6761\u63A8\u8350\u5DF2\u7ED3\u675F");let l=this.store.turnPicks(e.sessionId,s.turnId).find(d=>d.id===a.seriesId);if(!l)throw new j("\u8BF7\u4ECE\u672C\u8F6E\u63A8\u8350\u4E2D\u9009\u5267",403);return this.store.markPicksShown(e.sessionId,s.turnId,()=>this.store.offerable(e.sessionId,s.turnId)),s.selected=l,s.taken=!1,s.browsing=!1,s.played=!1,s.playbackId=(s.playbackId||0)+1,{}}let u=this.store.activeTurn(e.sessionId,s.turnId),c=!!s.selected&&!s.played&&u&&!this.store.picksDismissed(e.sessionId,s.turnId);return s.taken=!0,s.browsing&&(this.store.dismissPicks(e.sessionId,s.turnId),s.browsing=!1),{pick:s.selected,turnId:s.turnId,play:c,...c?{playbackId:s.playbackId}:{},...s.selected&&!u?{reason:"turn-ended"}:{}}}case"set_player_visible":if(e.waiting&&!e.waiting.taken)throw new j("\u8BF7\u4ECE\u672C\u8F6E\u63A8\u8350\u4E2D\u9009\u5267",403);return this.store.playerVisible(e.sessionId,a.instance,a.visible),{};case"get_run_state":{if(!this.store.persistent)throw new j("\u672C\u673A\u4F1A\u8BDD\u72B6\u6001\u4E0D\u53EF\u8FBE",503);if(this.store.touchPlayer(e.sessionId,a.playerInstance),a.observeSession){if(a.turnId||e.waiting&&!e.waiting.taken)throw new j("\u8BF7\u5148\u6253\u5F00\u64AD\u653E\u5668",403);return{...this.store.state(e.sessionId,n?e.fixedTurn:void 0),preferences:this.store.preferences()}}let s=e.waiting?.turnId??(n?e.fixedTurn:null);if(s&&a.turnId&&a.turnId!==s)throw new j("\u64AD\u653E\u5668\u5DF2\u7ED1\u5B9A\u5176\u4ED6\u56DE\u5408",403);let u=s??a.turnId,c=this.store.state(e.sessionId,u);return e.waiting&&c.state==="submitted"&&!this.store.activeTurn(e.sessionId,u)?{...c,state:"unknown"}:c}case"list_sessions":if(n||e.sessionId)throw new j("\u5F53\u524D\u5165\u53E3\u4E0D\u5141\u8BB8\u9009\u62E9\u5176\u4ED6\u4F1A\u8BDD",403);return e.choices.clear(),{items:this.store.candidates().map(s=>{let u=Gu();return e.choices.set(u,s.session_id),{choice:u,suffix:s.session_id.slice(-8),at:s.at}})};case"select_session":if(n||e.sessionId||!e.choices.has(a.choice))throw new j("\u8BF7\u91CD\u65B0\u9009\u62E9\u4F1A\u8BDD",403);return e.sessionId=e.choices.get(a.choice),e.choices.clear(),this.store.state(e.sessionId);case"list_series":return this.catalog.list(a);case"get_cover":return this.catalog.cover(a.seriesId);case"get_episodes":{let s=await this.catalog.episodes(a);e.allowed??=new Set;for(let u of s.items)u.playable&&e.allowed.add(u.id);return s}case"get_history":return{items:this.store.history(a.seriesId,a.episodeId)};case"remove_history":return this.store.removeHistory(a.seriesId);case"read_panel_chunk":case"read_panel_manifest":if(n||e.streams?.get(a.episodeId)!==a.stream)throw new j("\u8BF7\u5148\u51C6\u5907\u5F53\u524D\u5206\u96C6",403);return r==="read_panel_manifest"?this.catalog.panelMedia.manifest(a.episodeId,a.stream):this.catalog.panelMedia.chunk(a.episodeId,a.stream,a.asset,a.offset);case"save_progress":if(!this.store.persistent)throw new j("\u672C\u673A\u8FDB\u5EA6\u76EE\u5F55\u4E0D\u53EF\u5199",503);return this.catalog.cache?.hold(a.episodeId),this.store.save(a);case"preload_playback":{if(!e.allowed?.has(a.episodeId))throw new j("\u8BF7\u5148\u9009\u62E9\u53EF\u64AD\u653E\u7684\u5206\u96C6",403);let{status:s}=this.catalog.prepare(a.episodeId,n,!1,!0);return{status:s}}case"prepare_playback":{if(!e.allowed?.has(a.episodeId))throw new j("\u8BF7\u5148\u9009\u62E9\u53EF\u64AD\u653E\u7684\u5206\u96C6",403);!n&&e.playing!==a.episodeId&&(this.catalog.panelMedia?.unpin(e.playing,e),e.streams?.clear(),e.playing=a.episodeId);let s=this.catalog.prepare(a.episodeId,n,!!a.retry);return n&&s.status==="ready"&&e.grants.add(a.episodeId),!n&&s.stream&&(this.catalog.panelMedia.pin(a.episodeId,e),e.streams??=new Map,e.streams.set(a.episodeId,s.stream)),s}case"get_preferences":return this.store.preferences();case"set_preferences":{if(!this.store.persistent)throw new j("\u672C\u673A\u8BBE\u7F6E\u76EE\u5F55\u4E0D\u53EF\u5199",503);let s=this.store.preferences(),u=this.store.setPreferences(a);return JSON.stringify(s.searchTerms)!==JSON.stringify(u.searchTerms)&&(this.catalog.feed=null,this.catalog.refresh=null),u}case"get_health":return this.catalog.ffmpeg||this.catalog.prepareMediaRuntime?.().catch(()=>{}),{runtime:process.version,database:this.store.writable(),ffmpeg:this.catalog.ffmpeg};case"get_setup_status":return this.catalog.ffmpeg||this.catalog.prepareMediaRuntime?.().catch(()=>{}),{runtime:process.version,database:this.store.writable(),ffmpeg:this.catalog.ffmpeg,dismissed:this.store.setupDismissed(),hooks:Gk()};case"set_setup_dismissed":if(!this.store.persistent)throw new j("\u672C\u673A\u8BBE\u7F6E\u76EE\u5F55\u4E0D\u53EF\u5199",503);return this.store.setSetupDismissed(a.dismissed);case"create_browser_pairing":{if(n)throw new j("\u8BF7\u4ECE\u4F1A\u8BDD\u9762\u677F\u6253\u5F00\u5206\u5C4F",403);let s=a.follow&&this.store.state(e.sessionId,a.turnId);if(a.follow&&(!a.turnId||s.state!=="submitted"))throw new j("\u5F53\u524D\u56DE\u5408\u65E0\u6CD5\u7ED1\u5B9A\uFF0C\u8BF7\u9009\u62E9\u624B\u52A8\u64AD\u653E");return this.pair({sessionId:a.follow===!1?null:e.sessionId,fixedTurn:a.follow?a.turnId:null,selection:a.seriesId?{seriesId:a.seriesId,episodeId:a.episodeId,title:a.title}:null})}}}};import{join as VT}from"node:path";import{pathToFileURL as o5}from"node:url";import{Writable as a5}from"node:stream";import{pipeline as s5}from"node:stream/promises";import{spawn as zZ}from"node:child_process";var MF=Un(jC(),1),LF=Un(gb(),1);import{accessSync as OF,constants as uD,statSync as RF}from"node:fs";import{homedir as jF}from"node:os";import{posix as BF,win32 as UF}from"node:path";import{createHash as JC,randomUUID as AF}from"node:crypto";import{createReadStream as KC}from"node:fs";import{mkdir as HC,lstat as yF,open as XC,readFile as YC,writeFile as _F,rename as bF,rm as da,chmod as $F,stat as GC,unlink as iY,rmdir as oY}from"node:fs/promises";import{lstatSync as IF}from"node:fs";import{homedir as wF}from"node:os";import{posix as WC,win32 as eD}from"node:path";import{spawnSync as EF}from"node:child_process";import{createRequire as K3}from"module";var X3=K3("/"),la,Y3,W3;try{la=X3("worker_threads"),Y3=la.Worker,W3=la.isMarkedAsUntransferable}catch{}var qt=Uint8Array,ca=Uint16Array,eF=Int32Array,BC=new qt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),UC=new qt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),tF=new qt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),MC=function(t,e){for(var r=new ca(31),i=0;i<31;++i)r[i]=e+=1<<t[i-1];for(var n=new eF(r[30]),i=1;i<30;++i)for(var o=r[i];o<r[i+1];++o)n[o]=o-r[i]<<5|i;return{b:r,r:n}},la=MC(BC,2),LC=la.b,rF=la.r;LC[28]=258,rF[258]=28;var FC=MC(UC,0),nF=FC.b,YX=FC.r,Eb=new ca(32768);for(ye=0;ye<32768;++ye)Kr=(ye&43690)>>1|(ye&21845)<<1,Kr=(Kr&52428)>>2|(Kr&13107)<<2,Kr=(Kr&61680)>>4|(Kr&3855)<<4,Eb[ye]=((Kr&65280)>>8|(Kr&255)<<8)>>1;var Kr,ye,Ju=(function(t,e,r){for(var i=t.length,n=0,o=new ca(e);n<i;++n)t[n]&&++o[t[n]-1];var a=new ca(e);for(n=1;n<e;++n)a[n]=a[n-1]+o[n-1]<<1;var s;if(r){s=new ca(1<<e);var u=15-e;for(n=0;n<i;++n)if(t[n])for(var c=n<<4|t[n],l=e-t[n],d=a[t[n]-1]++<<l,p=d|(1<<l)-1;d<=p;++d)s[Eb[d]>>u]=c}else for(s=new ca(i),n=0;n<i;++n)t[n]&&(s[n]=Eb[a[t[n]-1]++]>>15-t[n]);return s}),Ku=new qt(288);for(ye=0;ye<144;++ye)Ku[ye]=8;var ye;for(ye=144;ye<256;++ye)Ku[ye]=9;var ye;for(ye=256;ye<280;++ye)Ku[ye]=7;var ye;for(ye=280;ye<288;++ye)Ku[ye]=8;var ye,ZC=new qt(32);for(ye=0;ye<32;++ye)ZC[ye]=5;var ye;var iF=Ju(Ku,9,1);var oF=Ju(ZC,5,1),$b=function(t){for(var e=t[0],r=1;r<t.length;++r)t[r]>e&&(e=t[r]);return e},vr=function(t,e,r){var i=e/8|0;return(t[i]|t[i+1]<<8)>>(e&7)&r},Ib=function(t,e){var r=e/8|0;return(t[r]|t[r+1]<<8|t[r+2]<<16)>>(e&7)},aF=function(t){return(t+7)/8|0},Sb=function(t,e,r){return(e==null||e<0)&&(e=0),(r==null||r>t.length)&&(r=t.length),new qt(t.subarray(e,r))};var sF=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Qt=function(t,e,r){var i=new Error(e||sF[t]);if(i.code=t,Error.captureStackTrace&&Error.captureStackTrace(i,Qt),!r)throw i;return i},uF=function(t,e,r,i){var n=t.length,o=i?i.length:0;if(!n||e.f&&!e.l)return r||new qt(0);var a=!r,s=a||e.i!=2,u=e.i;a&&(r=new qt(n*3));var c=function(g0){var v0=r.length;if(g0>v0){var A0=new qt(Math.max(v0*2,g0));A0.set(r),r=A0}},l=e.f||0,d=e.p||0,p=e.b||0,m=e.l,h=e.d,f=e.m,g=e.n,y=n*8;do{if(!m){l=vr(t,d,1);var v=vr(t,d+1,3);if(d+=3,v)if(v==1)m=iF,h=oF,f=9,g=5;else if(v==2){var N=vr(t,d,31)+257,K=vr(t,d+10,15)+4,Le=N+vr(t,d+5,31)+1;d+=14;for(var de=new qt(Le),Ue=new qt(19),X=0;X<K;++X)Ue[tF[X]]=vr(t,d+X*3,7);d+=K*3;for(var jt=$b(Ue),nn=(1<<jt)-1,Bn=Ju(Ue,jt,1),X=0;X<Le;){var Da=Bn[vr(t,d,nn)];d+=Da&15;var A=Da>>4;if(A<16)de[X++]=A;else{var Se=0,Ke=0;for(A==16?(Ke=3+vr(t,d,3),d+=2,Se=de[X-1]):A==17?(Ke=3+vr(t,d,7),d+=3):A==18&&(Ke=11+vr(t,d,127),d+=7);Ke--;)de[X++]=Se}}var yc=de.subarray(0,N),on=de.subarray(N);f=$b(yc),g=$b(on),m=Ju(yc,f,1),h=Ju(on,g,1)}else Qt(1);else{var A=aF(d)+4,x=t[A-4]|t[A-3]<<8,k=A+x;if(k>n){u&&Qt(0);break}s&&c(p+x),r.set(t.subarray(A,k),p),e.b=p+=x,e.p=d=k*8,e.f=l;continue}if(d>y){u&&Qt(0);break}}s&&c(p+131072);for(var e1=(1<<f)-1,t1=(1<<g)-1,Rm=d;;Rm=d){var Se=m[Ib(t,d)&e1],Ii=Se>>4;if(d+=Se&15,d>y){u&&Qt(0);break}if(Se||Qt(2),Ii<256)r[p++]=Ii;else if(Ii==256){Rm=d,m=null;break}else{var p0=Ii-254;if(Ii>264){var X=Ii-257,Ta=BC[X];p0=vr(t,d,(1<<Ta)-1)+LC[X],d+=Ta}var jm=h[Ib(t,d)&t1],Bm=jm>>4;jm||Qt(3),d+=jm&15;var on=nF[Bm];if(Bm>3){var Ta=UC[Bm];on+=Ib(t,d)&(1<<Ta)-1,d+=Ta}if(d>y){u&&Qt(0);break}s&&c(p+131072);var m0=p+p0;if(p<on){var h0=o-on,r1=Math.min(on,m0);for(h0+p<0&&Qt(3);p<r1;++p)r[p]=i[h0+p]}for(;p<m0;++p)r[p]=r[p-on]}}e.l=m,e.p=Rm,e.b=p,e.f=l,m&&(l=1,e.m=f,e.d=h,e.n=g)}while(!l);return p!=r.length&&a?Sb(r,0,p):r.subarray(0,p)};var cF=new qt(0);var Pr=function(t,e){return t[e]|t[e+1]<<8},nr=function(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0},wb=function(t,e){return nr(t,e)+nr(t,e+4)*4294967296};function lF(t,e){return uF(t,{i:2},e&&e.out,e&&e.dictionary)}var xb=typeof TextDecoder<"u"&&new TextDecoder,dF=0;try{xb.decode(cF,{stream:!0}),dF=1}catch{}var fF=function(t){for(var e="",r=0;;){var i=t[r++],n=(i>127)+(i>223)+(i>239);if(r+n>t.length)return{s:e,r:Sb(t,r-1)};n?n==3?(i=((i&15)<<18|(t[r++]&63)<<12|(t[r++]&63)<<6|t[r++]&63)-65536,e+=String.fromCharCode(55296|i>>10,56320|i&1023)):n&1?e+=String.fromCharCode((i&31)<<6|t[r++]&63):e+=String.fromCharCode((i&15)<<12|(t[r++]&63)<<6|t[r++]&63):e+=String.fromCharCode(i)}};function pF(t,e){if(e){for(var r="",i=0;i<t.length;i+=16384)r+=String.fromCharCode.apply(null,t.subarray(i,i+16384));return r}else{if(xb)return xb.decode(t);var n=fF(t),o=n.s,r=n.r;return r.length&&Qt(8),o}}var mF=function(t,e){return e+30+Pr(t,e+26)+Pr(t,e+28)},hF=function(t,e,r){var i=Pr(t,e+28),n=Pr(t,e+30),o=pF(t.subarray(e+46,e+46+i),!(Pr(t,e+8)&2048)),a=e+46+i,s=gF(t,a,n,r,nr(t,e+20),nr(t,e+24),nr(t,e+42)),u=s[0],c=s[1],l=s[2];return[Pr(t,e+10),u,c,o,a+n+Pr(t,e+32),l]},gF=function(t,e,r,i,n,o,a){var s=n==4294967295,u=o==4294967295,c=a==4294967295,l=e+r,d=s+u+c;if(i&&d){for(;e+4<l;e+=4+Pr(t,e+2))if(Pr(t,e)==1)return[s?wb(t,e+4+8*u):n,u?wb(t,e+4):o,c?wb(t,e+4+8*(u+s)):a,1];i<2&&Qt(13)}return[n,o,a,0]};function QC(t,e){for(var r={},i=t.length-22;nr(t,i)!=101010256;--i)(!i||t.length-i>65558)&&Qt(13);var n=Pr(t,i+8);if(!n)return{};var o=nr(t,i+16),a=nr(t,i-20)==117853008;if(a){var s=nr(t,i-12);a=nr(t,s)==101075792,a&&(n=nr(t,s+32),o=nr(t,s+48))}for(var u=e&&e.filter,c=0;c<n;++c){var l=hF(t,o,a),d=l[0],p=l[1],m=l[2],h=l[3],f=l[4],g=l[5],y=mF(t,g);o=f,(!u||u({name:h,size:p,originalSize:m,compression:d}))&&(d?d==8?r[h]=lF(t.subarray(y,y+p),{out:new qt(m)}):Qt(14,"unknown compression type "+d):r[h]=Sb(t,y,y+p))}return r}var tD=Un(qC(),1);var VC={"darwin-arm64":{version:"9.0.2",url:"https://www.osxexperts.net/ffmpeg902arm.zip",format:"zip",entry:"ffmpeg",archiveBytes:22665869,archiveSha256:"07e00300593799005b060c03a99fe648b1edda0f30c36b0c1adafe8e3247e586",binaryBytes:52160568,binarySha256:"762f16b2913b8d3b8fdb8092df12b691053b035b13ae9b88205513c55cb8e71e"},"darwin-x64":{version:"9.0.2",url:"https://evermeet.cx/ffmpeg/ffmpeg-9.0.2.zip",format:"zip",entry:"ffmpeg",archiveBytes:26198325,archiveSha256:"4acc0be580f9b2788029eb7bd4d645ff87968911b0a62aeeb3940d42d54558d5",binaryBytes:80827688,binarySha256:"a45b462cf91ed89148ae218c4577e30896485d7a6792c3673bcf5f823fa01b63"},"linux-x64":{version:"9.0.2-20261031",url:"https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2026-10-31-12-59/ffmpeg-n9.0.2-39-g7adfbe40dc-linux64-gpl-9.0.tar.xz",format:"tar.xz",entry:"ffmpeg-n9.0.2-39-g7adfbe40dc-linux64-gpl-9.0/bin/ffmpeg",archiveBytes:153175100,archiveSha256:"73e29a56974ae5a651133a04584c7483b21afe941e17dc91d79814a758b608d3"},"linux-arm64":{version:"9.0.2-20261031",url:"https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2026-10-31-12-59/ffmpeg-n9.0.2-39-g7adfbe40dc-linuxarm64-gpl-9.0.tar.xz",format:"tar.xz",entry:"ffmpeg-n9.0.2-39-g7adfbe40dc-linuxarm64-gpl-9.0/bin/ffmpeg",archiveBytes:128664064,archiveSha256:"6cad88ae5bcec356cfc5d7979a036cc4007128201928a0cf243df3db483276cc"},"win32-x64":{version:"9.0.2-20261031",url:"https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2026-10-31-12-59/ffmpeg-n9.0.2-39-g7adfbe40dc-win64-gpl-9.0.zip",format:"zip",entry:"ffmpeg-n9.0.2-39-g7adfbe40dc-win64-gpl-9.0/bin/ffmpeg.exe",archiveBytes:195110184,archiveSha256:"693f3e224bc184b40524a62ca47526cfebaf2504414021b92fe75f677ad868b9"},"win32-arm64":{version:"9.0.2-20261031",url:"https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2026-10-31-12-59/ffmpeg-n9.0.2-39-g7adfbe40dc-winarm64-gpl-9.0.zip",format:"zip",entry:"ffmpeg-n9.0.2-39-g7adfbe40dc-winarm64-gpl-9.0/bin/ffmpeg.exe",archiveBytes:136603040,archiveSha256:"8b3c394762f26716ccef03ac1b7ac76430759080e1255aa9bc01d74db590bcb5",binaryBytes:95170560,binarySha256:"e2248aa5ecd155814e951fd0606df71589699a2fd4db14a9323a0b400a6c9b06"}};var fa=new Map,om=new Map,xF="@kyun.si/codex-hongguo",rD=new Set(["prepare","download","download-url","download-http","download-network","archive-size","archive-hash","extract","binary-hash","probe","publish"]),SF=new Set(["UND_ERR_CONNECT_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_BODY_TIMEOUT","UND_ERR_SOCKET","ECONNRESET","ECONNREFUSED","ETIMEDOUT","EAI_AGAIN","ENETUNREACH","EHOSTUNREACH"]),kF=new Set([408,429,500,502,503,504]),qe=(t="prepare",e)=>Object.assign(Error("\u64AD\u653E\u7EC4\u4EF6\u81EA\u52A8\u51C6\u5907\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC\u548C\u7F13\u5B58\u76EE\u5F55\u6743\u9650\u540E\u91CD\u8BD5\u5B89\u88C5\u3002"),{code:t,...Number.isInteger(e)&&e>=400&&e<=599?{httpStatus:e}:{}}),nD=t=>new Promise(e=>setTimeout(e,t));function iD(t={}){let{env:e=process.env,home:r=wF(),platform:i=process.platform,arch:n=process.arch}=t,o=i==="win32"?eD:WC;if(e.HONGGUO_FFMPEG){if(!o.isAbsolute(e.HONGGUO_FFMPEG))throw qe();return{...t,env:e,platform:i,target:e.HONGGUO_FFMPEG,override:!0}}let a=(t.artifacts||VC)[i+"-"+n];if(!a)throw Error("\u5F53\u524D\u7CFB\u7EDF\u67B6\u6784\u6682\u4E0D\u652F\u6301\u81EA\u52A8\u51C6\u5907\u64AD\u653E\u7EC4\u4EF6\u3002");let s=CF({env:e,home:r,platform:i,paths:o}),u=o.join(s,"runtime","ffmpeg",a.archiveSha256.slice(0,16),i+"-"+n);return{...t,env:e,platform:i,artifact:a,directory:u,target:o.join(u,i==="win32"?"ffmpeg.exe":"ffmpeg")}}function CF({env:t,home:e,platform:r,paths:i}){return t.HONGGUO_RUNTIME_DIR?i.join(t.HONGGUO_RUNTIME_DIR,"codex-hongguo"):r==="darwin"?i.join(e,"Library","Caches","CodexHongguo"):r==="win32"?i.join(t.LOCALAPPDATA||i.join(e,"AppData","Local"),"CodexHongguo","Cache"):i.join(t.XDG_CACHE_HOME||i.join(e,".cache"),"codex-hongguo")}function Db(t){return iD(t).target}function am(t){try{let e=IF(t);return e.isFile()&&!e.isSymbolicLink()?`${e.size}:${e.mtimeMs}:${e.ctimeMs}`:null}catch{return null}}function oD(t){try{let e=Db(t);return!!fa.get(e)&&fa.get(e)===am(e)}catch{return!1}}async function aD(t){let e=JC("sha256");for await(let r of KC(t))e.update(r);return e.digest("hex")}function sD(t,e){return e.probe?e.probe(t):EF(t,["-version"],{stdio:"ignore",timeout:5e3,windowsHide:!0}).status===0}async function Cb(t){let{target:e,artifact:r}=t;if(fa.get(e)&&fa.get(e)===am(e))return!0;try{let i=await yF(e);if(!i.isFile()||i.isSymbolicLink())return!1;if(r){let n=JSON.parse(await YC(e+".json","utf8"));if(n.archiveSha256!==r.archiveSha256||!/^[a-f0-9]{64}$/.test(n.binarySha256)||i.size!==(r.binaryBytes||n.binaryBytes)||await aD(e)!==(r.binarySha256||n.binarySha256))return!1}return sD(e,t)?(fa.set(e,am(e)),!0):!1}catch{return!1}}async function DF(t,e,r){let i=AbortSignal.timeout(3e5);for(let n=0;;n++)try{return await TF(t,e,r,i)}catch(o){await da(e,{force:!0});let a=SF.has(o?.cause?.code||o?.code);if(!(a||o?.code==="download-http"&&kF.has(o.httpStatus))||n>=2||i.aborted)throw qe(a?"download-network":rD.has(o?.code)?o.code:"download",o?.httpStatus);await nD((n+1)*1e3)}}async function TF(t,e,r,i){let n=new Set(["github.com","release-assets.githubusercontent.com","objects.githubusercontent.com","evermeet.cx","www.osxexperts.net"]),o=new URL(t.url),a;for(let l=0;l<=6;l++){if(o.protocol!=="https:"||o.username||o.password||o.port||!n.has(o.hostname))throw qe("download-url");if(a=await r(o,{redirect:"manual",signal:i}),![301,302,303,307,308].includes(a.status))break;let d=a.headers.get("location");if(await a.body?.cancel(),!d||l===6)throw qe("download-url");o=new URL(d,o)}if(!a.ok||!a.body)throw await a.body?.cancel(),qe("download-http",a.status);if(Number(a.headers.get("content-length"))>t.archiveBytes)throw await a.body.cancel(),qe("archive-size");let s=await XC(e,"wx",384),u=JC("sha256"),c=0;try{for await(let l of a.body){if(c+=l.length,c>t.archiveBytes)throw qe("archive-size");u.update(l),await s.writeFile(l)}if(c!==t.archiveBytes)throw qe("archive-size");if(u.digest("hex")!==t.archiveSha256)throw qe("archive-hash")}finally{await s.close()}}async function NF(t,e,r){let i=await XC(r,"wx",384);try{if(t.format==="zip"){let p=QC(await YC(e),{filter:m=>m.name===t.entry&&m.originalSize<=(t.binaryBytes||268435456)})[t.entry];if(!p||t.binaryBytes&&p.length!==t.binaryBytes)throw qe();await i.writeFile(p);return}let n=new tD.default.XzReadableStream(zF(e)),o=n.getReader(),a=Buffer.alloc(0),s=0,u=0,c=!1,l=0;try{for(;;){let{value:d,done:p}=await o.read();if(p)break;if(l+=d.length,l>1024*1024*1024)throw qe();for(a=Buffer.concat([a,d]);a.length;)if(s){let m=Math.min(s,a.length);if(c&&await i.writeFile(a.subarray(0,m)),a=a.subarray(m),s-=m,!s&&c)return}else if(u){let m=Math.min(u,a.length);a=a.subarray(m),u-=m}else{if(a.length<512)break;let m=a.subarray(0,512);a=a.subarray(512);let h=(y,v)=>m.subarray(y,v).toString("utf8").split("\0")[0],f=[h(345,500),h(0,100)].filter(Boolean).join("/"),g=parseInt(h(124,136).trim()||"0",8);if(!Number.isSafeInteger(g)||g<0||g>512*1024*1024||(c=f===t.entry,c&&(t.binaryBytes&&g!==t.binaryBytes||g>256*1024*1024||![0,48].includes(m[156]))))throw qe();s=g,u=(512-g%512)%512}}throw qe()}finally{await o.cancel().catch(()=>{})}}finally{await i.close()}}function zF(t){let e=KC(t)[Symbol.asyncIterator]();return new ReadableStream({async pull(r){let{value:i,done:n}=await e.next();n?r.close():r.enqueue(i)},async cancel(){await e.return?.()}})}async function sm(t={}){let e=iD(t);if(await Cb(e))return e.target;if(e.override)throw qe();if(om.has(e.target))return om.get(e.target);let r=PF(e).finally(()=>om.delete(e.target));return om.set(e.target,r),r}async function PF(t){let{directory:e,target:r,artifact:i}=t,n=e+".lock",o=Date.now()+42e4;await HC(e,{recursive:!0,mode:448});let a=!1;for(;!a;)try{await HC(n,{mode:448}),a=!0}catch(p){if(p.code!=="EEXIST"||Date.now()>o)throw qe();if(await Cb(t))return r;try{Date.now()-(await GC(n)).mtimeMs>6e5&&await da(n,{recursive:!0,force:!0})}catch{}await nD(200)}let s=t.platform==="win32"?eD:WC,u=s.basename(r)+"."+AF(),c=s.join(e,u+".archive"),l=s.join(e,u+".part"),d="download";try{if(await Cb(t))return r;await DF(i,c,t.fetchImpl||fetch),d="extract",await NF(i,c,l);let p=await aD(l);if(i.binarySha256&&p!==i.binarySha256)throw qe("binary-hash");if(await $F(l,493),!sD(l,t))throw qe("probe");return d="publish",t.platform==="win32"&&await da(r,{force:!0}),await bF(l,r),await _F(r+".json",JSON.stringify({owner:xF,schema:1,archiveSha256:i.archiveSha256,binarySha256:p,binaryBytes:(await GC(r)).size,version:i.version})+`
|
|
136
141
|
`,{mode:384}),fa.set(r,am(r)),r}catch(p){throw qe(rD.has(p?.code)&&p.code!=="prepare"?p.code:d,p?.httpStatus)}finally{await Promise.all([da(c,{force:!0}),da(l,{force:!0}),da(n,{recursive:!0,force:!0})])}}function cD(t,e,{env:r=process.env,home:i=jF(),platform:n=process.platform,arch:o=process.arch}={}){if(e)return e;if(t==="ffmpeg")return Db({env:r,home:i,platform:n,arch:o});let{delimiter:a,dirname:s,join:u,isAbsolute:c,extname:l}=n==="win32"?UF:BF,d=Object.keys(r).find(f=>f.toUpperCase()==="PATH")||"PATH",p=[s(process.execPath),...(r[d]||"").split(a).filter(Boolean).map(f=>f.replace(/^"(.*)"$/,"$1"))];n!=="win32"?p.push("/opt/homebrew/bin","/usr/local/bin","/usr/bin","/bin",u(i,".volta/bin"),u(i,".local/bin")):p.push(u(r.APPDATA||u(i,"AppData","Roaming"),"npm"),u(i,".volta","bin"));let m=n!=="win32"||l(t)?[""]:[".exe",".com",".cmd",".bat"],h=p.filter(c).flatMap(f=>m.map(g=>u(f,t+g)));t==="codex"&&n==="darwin"&&h.push("/Applications/Codex.app/Contents/Resources/codex");for(let f of h)try{if(OF(f,n==="win32"?uD.F_OK:uD.X_OK),RF(f).isFile())return f}catch{}return t}import{createWriteStream as PZ,existsSync as OZ,mkdirSync as PT,readdirSync as RZ,renameSync as jZ,rmSync as xa,statSync as OT}from"node:fs";import{basename as BZ,dirname as UZ,join as Sa}from"node:path";import{randomUUID as MZ}from"node:crypto";import{Transform as LZ}from"node:stream";import{pipeline as FZ}from"node:stream/promises";var TT=Un(vD(),1),NT=Un(CT(),1);import{open as TZ}from"node:fs/promises";import{join as NZ}from"node:path";var Vt=()=>new j("\u8BE5\u5206\u6BB5\u7247\u6E90\u6682\u4E0D\u652F\u6301\uFF0C\u53EF\u91CD\u8BD5\u5176\u4ED6\u7247\u6E90");function DT(t,e){let r=t.mediaGroups?.AUDIO?.[e.attributes?.AUDIO]||{},i=Object.values(r);return i.find(n=>n.default)||i[0]}async function c0(t,e,r=0){if(r>3)throw Vt();let i=await e(t,256*1024),n=i.bytes.toString("utf8").trimStart();if(n.startsWith("#EXTM3U")){let m=new TT.Parser;m.push(n),m.end();let h=m.manifest;if(!h.playlists?.length)return[{playlist:h,base:i.url}];let f=h.playlists[0],g=await c0(new URL(f.uri,i.url),e,r+1),y=DT(h,f);if(y?.uri&&g.length===1){let[v]=await c0(new URL(y.uri,i.url),e,r+1);g.push(v)}return g}if(!/<MPD[\s>]/.test(n)||/<!DOCTYPE|<!ENTITY|<ContentProtection|type\s*=\s*["']dynamic/i.test(n))throw Vt();let o=n.match(/mediaPresentationDuration=["']PT(?:(\d+)H)?(?:(\d+)M)?(?:([\d.]+)S)?["']/);if(!o)throw Vt();let a=(+o[1]||0)*3600+(+o[2]||0)*60+(+o[3]||0);if(!(a>0&&a<=3600))throw Vt();let s=m=>Array.from(n.matchAll(m),h=>Number(h[1])),u=s(/\btimescale\s*=\s*["'](.*?)["']/g),c=s(/\br\s*=\s*["'](.*?)["']/g);if(u.some(m=>!Number.isSafeInteger(m)||m<1||m>1e9)||c.some(m=>!Number.isSafeInteger(m)||m<0||m>2048)||c.reduce((m,h)=>m+h,0)>8192||(n.match(/<Representation\b/g)||[]).length>32||(n.match(/<S\s/g)||[]).length>4096)throw Vt();for(let m of s(/\b(?:d|duration)\s*=\s*["']([\d.]+)["']/g))if(!(m>0)||a*Math.max(1,...u)/m>8192)throw Vt();let l=(0,NT.parse)(n,{manifestUri:i.url}),d=l.playlists?.[0];if(!d?.segments?.length)throw Vt();let p=DT(l,d)?.playlists?.[0];return[d,p].filter(Boolean).map(m=>({playlist:m,base:i.url}))}async function zT(t,e,r,{cdn:i,run:n,codec:o,budget:a}){let s=Date.now()+18e4;async function u(d,p,m){let h=Math.min(p,a);if(h<=0||Date.now()>=s)throw Vt();let f=await i(d,h,Math.min(2e4,s-Date.now()),0,m),g=0,y=[];for await(let v of f.body){if(g+=v.byteLength,g>h)throw Vt();y.push(v)}if(!g||m&&g!==m.length)throw Vt();return a-=g,{bytes:Buffer.concat(y),url:f.url}}let c=await c0(t,u),l=[];for(let[d,{playlist:p,base:m}]of c.entries()){let h=p.segments;if(!p.endList||!h?.length||h.length>2048)throw Vt();let f=NZ(e,"track"+d),g=await TZ(f,"wx",384),y;try{for(let v of h){if(v.key||v.discontinuity||v.gap)throw Vt();for(let A of[v.map,v]){if(!A)continue;let x=new URL(A.resolvedUri||A.uri,m),k=JSON.stringify([x.href,A.byterange]);if(A===v.map&&y===k)continue;if(A===v.map&&y)throw Vt();let{bytes:N}=await u(x,32*1024*1024,A.byterange);await g.writeFile(N),A===v.map&&(y=k)}}}finally{await g.close()}l.push("-protocol_whitelist","file","-f",y?"mov":"mpegts","-i",f)}await n([...l,"-map","0:v:0","-map",c.length===2?"1:a:0":"0:a:0?","-c","copy",.../hevc|h265|bytevc1/i.test(o)?["-tag:v","hvc1"]:[],"-movflags","+faststart","-f","mp4",r])}var km=1024*1024,RT=256*km,ZZ=/(?:^|\.)(?:qznovelvod\.com|byteimg\.com|fqnovelpic\.com|douyinvod\.com|bytecdn\.cn|ibytedtos\.com|snssdk\.com|pstatp\.com)$/i;async function vc(t,e,r,i=0,n){let o=new URL(t);if(o.protocol==="http:"&&(o.protocol="https:"),o.protocol!=="https:"||o.port||o.username||o.password||!ZZ.test(o.hostname))throw new j("\u7247\u6E90\u5730\u5740\u4E0D\u5728\u652F\u6301\u7684\u5A92\u4F53\u57DF\u540D\u5185");let a={};if(n){if(!Number.isSafeInteger(n.offset)||n.offset<0||!Number.isSafeInteger(n.length)||n.length<1||n.length>e||!Number.isSafeInteger(n.offset+n.length))throw new j("\u7247\u6E90\u5B57\u8282\u8303\u56F4\u65E0\u6548");a.Range="bytes="+n.offset+"-"+(n.offset+n.length-1)}let s=await fetch(o,{headers:a,redirect:"manual",signal:AbortSignal.timeout(r)});if([301,302,303,307,308].includes(s.status)&&i<3&&s.headers.get("location"))return await s.body?.cancel(),vc(new URL(s.headers.get("location"),o),e,r,i+1,n);if(!(!n||s.status===206&&s.headers.get("content-range")?.split("/")[0]==="bytes "+n.offset+"-"+(n.offset+n.length-1))||!s.ok||!s.body||Number(s.headers.get("content-length"))>e)throw await s.body?.cancel(),new j("\u5A92\u4F53\u5730\u5740\u5DF2\u5931\u6548\u6216\u8D85\u8FC7\u5927\u5C0F\u9650\u5236\uFF0C\u8BF7\u91CD\u8BD5");let c=0,l=new LZ({transform(d,p,m){c+=d.length,m(c>e?new j("\u7D20\u6750\u8D85\u8FC7\u5927\u5C0F\u9650\u5236"):null,d)}});return{body:s.body,limit:l,url:o.href}}var QZ=cD("ffmpeg",process.env.HONGGUO_FFMPEG);function jT(){return oD()}async function ka(t,e=null,r=!1,i=void 0){return await sm(),new Promise((n,o)=>{let a=zZ(QZ,["-hide_banner","-loglevel","error","-nostdin",...t],{cwd:i,stdio:["pipe",r?"pipe":"ignore","ignore"],windowsHide:!0,timeout:12e4,killSignal:"SIGKILL"}),s=[],u=0;a.stdout?.on("data",c=>{u+=c.length,u<=km?s.push(c):a.kill()}),a.stdin.on("error",()=>{}),a.stdin.end(e),a.on("error",()=>o(new j("FFmpeg \u542F\u52A8\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A\u5B89\u88C5"))),a.on("close",c=>c===0&&u<=km?n(Buffer.concat(s)):o(new j("FFmpeg \u65E0\u6CD5\u5904\u7406\u8BE5\u7D20\u6750\u6216\u5F53\u524D\u7F16\u7801")))})}async function qZ(t,e,r,i){let n=BZ(t);if(!/^[a-zA-Z0-9.-]+$/.test(n)||i&&!/^[0-9a-f]{32}$/i.test(i))throw new j("\u5206\u96C6\u6388\u6743\u6216\u7D20\u6750\u540D\u79F0\u65E0\u6548");let o=i?`ffconcat version 1.0
|
|
137
142
|
file 'file:`+n+`'
|
|
138
143
|
option decryption_key `+i+`
|
|
139
144
|
`:null;await ka(["-protocol_whitelist","file,pipe",...i?["-format_whitelist","concat,mov","-safe","0","-f","concat","-i","pipe:0"]:["-f","mov","-i",t],"-map","0:v:0","-map","0:a:0?","-c","copy",.../hevc|h265|bytevc1/i.test(r)?["-tag:v","hvc1"]:[],"-movflags","+faststart","-f","mp4",e],o,!1,UZ(t))}var Cm=class{constructor(e,r,{maxFiles:i=40,maxBytes:n=1024*km}={}){this.db=e.db,this.resolve=r,this.dir=Sa(e.root,"media"),this.maxFiles=i,this.maxBytes=n,PT(this.dir,{recursive:!0,mode:448}),this.db.exec(`CREATE TABLE IF NOT EXISTS media (
|
|
140
145
|
id TEXT PRIMARY KEY, status TEXT, owner TEXT, expires INTEGER, accessed INTEGER, size INTEGER DEFAULT 0,
|
|
141
146
|
codec TEXT DEFAULT '', reason TEXT DEFAULT '', hold_until INTEGER DEFAULT 0)`);for(let o of RZ(this.dir))/^[a-f0-9-]+\.part\.(source|mp4)$/.test(o)&&Date.now()-OT(Sa(this.dir,o),{throwIfNoEntry:!1})?.mtimeMs>36e5&&xa(Sa(this.dir,o),{recursive:!0,force:!0})}transaction(e){this.db.exec("BEGIN IMMEDIATE");try{let r=e();return this.db.exec("COMMIT"),r}catch(r){throw this.db.exec("ROLLBACK"),r}}path(e){if(!/^hg-[0-9]{1,32}$/.test(e))throw new j("\u65E0\u6548\u5206\u96C6");return Sa(this.dir,e+".mp4")}hold(e){this.db.prepare("UPDATE media SET hold_until=?,accessed=? WHERE id=? AND status='ready'").run(Date.now()+12e4,Date.now(),e)}prepare(e,r=!1){let i=this.path(e),n=Date.now(),o=MZ(),a=this.transaction(()=>{let s=this.db.prepare("SELECT * FROM media WHERE id=?").get(e);return s?.status==="ready"&&OZ(i)?(this.hold(e),{status:"ready",codec:s.codec}):s?.status==="error"&&!r&&s.expires>n?{status:"error",reason:s.reason}:s?.status==="working"&&s.expires>n?{status:"preparing"}:this.db.prepare("SELECT count(*) AS n FROM media WHERE status='working' AND expires>?").get(n).n>=2?{status:"preparing"}:(this.db.prepare(`INSERT INTO media(id,status,owner,expires,accessed) VALUES(?,'working',?,?,?)
|
|
142
|
-
ON CONFLICT(id) DO UPDATE SET status='working', owner=excluded.owner,expires=excluded.expires,accessed=excluded.accessed`).run(e,o,n+6e5,n),null)});return a||(this.build(e,o).catch(()=>{}),{status:"preparing"})}async build(e,r){let i=Sa(this.dir,r+".part.source"),n=Sa(this.dir,r+".part.mp4");try{let{playback:o,contentKey:a}=await this.resolve(e.slice(3)),s=(o.streams||[]).filter(h=>h.url),u=s.find(h=>!h.hls&&!h.dash),c=a?.key,l=[u&&(u.protected||o.protected)?u:void 0,s.find(h=>h.hls),s.find(h=>h.dash),u].filter(Boolean),d,p=new j("\u8BE5\u96C6\u6682\u672A\u63D0\u4F9B\u53EF\u64AD\u653E\u7684\u7247\u6E90");for(let h of new Set(l)){d=String(h.codec||"MP4").replace(/[^\w.-]/g,"").slice(0,24);try{if(h.hls||h.dash){if(h.protected||o.protected)throw new j("\u8BE5\u5206\u6BB5\u7247\u6E90\u9700\u8981\u5355\u6587\u4EF6\u64AD\u653E\u6388\u6743");PT(i,{mode:448}),await zT(h.url,i,n,{cdn:vc,run:ka,codec:d,budget:RT})}else{if((o.protected||h.protected)&&!/^[a-f0-9]{32}$/i.test(c||""))throw new j("\u7247\u6E90\u672A\u63D0\u4F9B\u53EF\u7528\u7684\u64AD\u653E\u6388\u6743");let{body:f,limit:g}=await vc(h.url,RT,6e4);await FZ(f,g,PZ(i,{mode:384,flags:"wx"})),await qZ(i,n,d,c)}p=null;break}catch(f){p=f,xa(n,{force:!0})}finally{xa(i,{recursive:!0,force:!0})}}if(p)throw p;let m=OT(n).size;this.transaction(()=>{if(this.db.prepare("SELECT owner FROM media WHERE id=?").get(e)?.owner!==r)return;let h=this.db.prepare("SELECT id,size,hold_until FROM media WHERE status='ready' ORDER BY accessed").all(),f=m+h.reduce((v,A)=>v+A.size,0),g=h.length+1,y=[];for(let v of h){if(f<=this.maxBytes&&g<=this.maxFiles)break;v.hold_until>Date.now()||(y.push(v.id),f-=v.size,g--)}if(f>this.maxBytes||g>this.maxFiles)throw new j("\u7F13\u5B58\u5DF2\u6EE1\uFF0C\u7A0D\u540E\u91CD\u8BD5");for(let v of y)xa(this.path(v),{force:!0}),this.db.prepare("DELETE FROM media WHERE id=?").run(v);jZ(n,this.path(e)),this.db.prepare("UPDATE media SET status='ready',size=?,codec=?,hold_until=? WHERE id=?").run(m,d,Date.now()+12e4,e)})}catch(o){this.db.prepare("UPDATE media SET status='error',reason=?,expires=? WHERE id=? AND owner=?").run(o instanceof j?o.message:"\u5A92\u4F53\u51C6\u5907\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5",Date.now()+3e4,e,r)}finally{xa(i,{recursive:!0,force:!0}),xa(n,{force:!0})}}};import{createHash as uQ}from"node:crypto";import{randomUUID as VZ}from"node:crypto";var HZ=15*6e4,Dm=()=>new j("\u7EA2\u679C\u7247\u6E90\u6682\u65F6\u4E0D\u53EF\u8FBE\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5",503),BT=(t,e,r)=>t?.value!==void 0&&e>=t.updatedAt&&e-t.updatedAt<r,Tm=class{constructor(e,{now:r=Date.now,ttl:i=HZ,lease:n=3e4,poll:o=150,wait:a=75e3}={}){this.store=e,this.now=r,this.ttl=i,this.lease=n,this.poll=o,this.wait=a,this.jobs=new Map}async get(e,r,{stale:i=!0,feed:n=!1}={}){let o=this.store.catalogCache(e);if(BT(o,this.now(),this.ttl))return o.value;let a=this.refresh(e,r,n);return i&&o?.value!==void 0?(a.catch(()=>{}),o.value):a}refresh(e,r,i){if(this.jobs.has(e))return this.jobs.get(e);let n=this.run(e,r,i).finally(()=>{this.jobs.get(e)===n&&this.jobs.delete(e)});return this.jobs.set(e,n),n}async run(e,r,i){let n=VZ(),o=performance.now()+this.wait;for(;;){let s=this.now(),u=this.store.catalogCache(e);if(BT(u,s,this.ttl))return u.value;if(u?.retryAt>s)throw Dm();let c=!1;try{c=this.store.claimCatalogCache(e,n,s,this.ttl,this.lease)}catch(l){if(![5,6].includes(l.errcode))throw l}if(c)break;if(performance.now()>=o)throw Dm();await new Promise(l=>setTimeout(l,this.poll))}let a=setInterval(()=>{try{this.store.renewCatalogCache(e,n,this.now(),this.lease)}catch{}},this.lease/3);a.unref();try{let s=await r();if(!this.store.completeCatalogCache(e,n,s,this.now(),i))throw Dm();return s}catch(s){try{this.store.failCatalogCache(e,n,this.now())}catch{}throw s instanceof j?s:Dm()}finally{clearInterval(a)}}};import{randomUUID as JZ}from"node:crypto";import{mkdirSync as MT,readFileSync as KZ,readdirSync as LT,rmSync as l0,statSync as FT,utimesSync as XZ}from"node:fs";import{open as YZ,readFile as WZ}from"node:fs/promises";import{join as bi}from"node:path";import{open as GZ}from"node:fs/promises";async function UT(t){let e=await GZ(t,"r");try{let{size:r}=await e.stat();async function i(n,o){let a=Buffer.alloc(16),{bytesRead:s}=await e.read(a,0,Math.min(16,o-n),n);if(s<8)return;let u=a.readUInt32BE(0),c=8;if(u===1){if(s<16)return;let l=a.readBigUInt64BE(8);if(l>BigInt(Number.MAX_SAFE_INTEGER))return;u=Number(l),c=16}else u===0&&(u=o-n);if(!(u<c||u>o-n))return{type:a.toString("ascii",4,8),payload:n+c,end:n+u}}for(let n=0,o=0;n<r&&o<1024;o++){let a=await i(n,r);if(!a)return;if(a.type==="moov"){for(let s=a.payload,u=0;s<a.end&&u<1024;u++){let c=await i(s,a.end);if(!c)return;if(c.type==="mvhd"){let l=Buffer.alloc(32),{bytesRead:d}=await e.read(l,0,Math.min(32,c.end-c.payload),c.payload),p=l[0];if(p===0&&d<20||p===1&&d<32||p>1)return;let m=l.readUInt32BE(p===0?12:20),h=p===0?l.readUInt32BE(16):Number(l.readBigUInt64BE(24)),f=Math.round(h/m*1e3);return Number.isSafeInteger(h)&&m>0&&f>0&&f<=864e5?f:void 0}s=c.end}return}n=a.end}}finally{await e.close()}}var ZT=10*6e4,eQ=192*1024,qT=2,tQ=/^(?:init\.mp4|seg[0-9]{5}\.m4s)$/,rQ={darwin:["h264_videotoolbox"],win32:["h264_nvenc","h264_qsv","h264_amf"],linux:["h264_nvenc","h264_qsv","h264_vaapi","h264_v4l2m2m"]},QT=["-f","hls","-hls_time",String(qT),"-hls_list_size","0","-hls_segment_type","fmp4","-hls_playlist_type","event","-hls_segment_filename","seg%05d.m4s","index.m3u8"];async function nQ(t,e){let i=(await t([...e,"-c","copy","-frames:v","0","-frames:a","0","-f","framehash","pipe:1"],null,!0)).toString("utf8"),n=/^#codec_id 0: (\S+)/m.exec(i)?.[1];if(!n)throw Error("Missing video stream");return{video:n,audio:/^#codec_id 1: (\S+)/m.exec(i)?.[1]}}function iQ(t,e){let r=t==="libx264",i="pad=ceil(iw/2)*2:ceil(ih/2)*2,format="+(r?"yuv420p":"nv12");return["-vf",t==="h264_vaapi"?i+",hwupload":i,"-c:v",t,"-tag:v","avc1","-force_key_frames",`expr:gte(t,n_forced*${qT})`,...r?["-preset","veryfast","-crf","22"]:["-b:v","3M"],...t==="h264_videotoolbox"?["-allow_sw","0"]:[],"-c:a",e]}var Nm=class{constructor(e,r=ka){this.root=bi(e,"panel-media"),this.run=r,this.entries=new Map,MT(this.root,{recursive:!0,mode:448});for(let i of LT(this.root,{withFileTypes:!0})){let n=bi(this.root,i.name);i.isDirectory()&&/^[0-9a-f-]{36}$/.test(i.name)&&Date.now()-FT(n,{throwIfNoEntry:!1})?.mtimeMs>864e5&&l0(n,{recursive:!0,force:!0})}this.timer=setInterval(()=>this.sweep(),ZT).unref()}drop(e){this.entries.delete(e.id),l0(e.dir,{recursive:!0,force:!0})}sweep(){for(let e of this.entries.values())!e.pending&&Date.now()-e.used>ZT&&this.drop(e)}touch(e){let r=Date.now();r-(e.touched||0)>6e4&&(XZ(e.dir,new Date(r),new Date(r)),e.touched=r),e.used=r}prepare(e,r,i,n,o=!1){this.sweep();let a=this.entries.get(e);if(a?.error&&i&&(this.drop(a),a=null),!a){if(this.entries.size>=4){let c=[...this.entries.values()].filter(l=>!l.pending&&(!l.viewers.size||!o&&Date.now()-l.used>3e4)).sort((l,d)=>l.used-d.used)[0];if(!c)throw new j("\u4FA7\u680F\u64AD\u653E\u5668\u6B63\u5FD9\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u6216\u4F7F\u7528\u5206\u5C4F");this.drop(c)}let s=JZ(),u=bi(this.root,s);MT(u,{mode:448}),a={id:e,dir:u,stream:s,used:Date.now(),pending:!0,viewers:new Set},this.entries.set(e,a),a.job=this.build(a,r,n).catch(()=>{a.error=!0}).finally(()=>{a.pending=!1})}if(this.touch(a),a.error)throw new j("\u4FA7\u680F\u5206\u6BB5\u51C6\u5907\u5931\u8D25\uFF0C\u53EF\u4F7F\u7528\u540C\u7A97\u5206\u5C4F");return a.pending&&(!a.durationMs||!this.snapshot(a))?{status:"preparing"}:(a.exposed=!0,{status:"ready",stream:a.stream,manifest:a.manifest,codec:a.codec,durationMs:a.durationMs})}snapshot(e){try{let r=bi(e.dir,"index.m3u8");if(FT(r).size>256*1024)throw Error("playlist limit");let i=KZ(r,"utf8"),n=i.match(/#EXTINF:/g)?.length||0;return!n||n<2&&!i.includes("#EXT-X-ENDLIST")?!1:(e.manifest=i,!0)}catch(r){if(r.code==="ENOENT")return!1;throw new j("\u4FA7\u680F\u5206\u6BB5\u51C6\u5907\u5931\u8D25\uFF0C\u53EF\u4F7F\u7528\u540C\u7A97\u5206\u5C4F")}}manifest(e,r){let i=this.entries.get(e);if(!i||i.stream!==r||i.error||!i.manifest)throw new j("\u8BE5\u64AD\u653E\u5206\u6BB5\u5DF2\u5931\u6548\uFF0C\u8BF7\u91CD\u65B0\u70B9\u64AD",404);return i.pending&&this.snapshot(i),this.touch(i),{manifest:i.manifest}}async build(e,r,i){let n=["-protocol_whitelist","file","-f","mov","-i",r,"-map","0:v:0","-map","0:a:0?"],[o,a]=await Promise.all([nQ(this.run,n),UT(r)]);e.durationMs=a;let s=o.audio&&o.audio!=="aac"?"aac":"copy",u=o.video==="hevc"||/bytevc1|hevc|h\.?265|hvc1|hev1/i.test(i??"");if(e.codec=u?"h264":o.video,u)for(let l of[...rQ[process.platform]??[],"libx264"]){let d=l==="h264_vaapi"?["-init_hw_device","vaapi=panel","-filter_hw_device","panel"]:[];try{let p=iQ(l,s);await this.run([...d,...n,...p,...QT],null,!1,e.dir);break}catch(p){if(l==="libx264"||e.exposed)throw p;for(let m of LT(e.dir))l0(bi(e.dir,m),{force:!0})}}else{let l=s==="copy"?["-c","copy"]:["-c:v","copy","-c:a",s];await this.run([...n,...l,...QT],null,!1,e.dir)}let c=await WZ(bi(e.dir,"index.m3u8"),"utf8");if(c.length>256*1024)throw Error("playlist limit");e.manifest=c}async chunk(e,r,i,n){let o=this.entries.get(e);if(!o||o.stream!==r||o.error||!o.manifest||!tQ.test(i))throw new j("\u8BE5\u64AD\u653E\u5206\u6BB5\u5DF2\u5931\u6548\uFF0C\u8BF7\u91CD\u65B0\u70B9\u64AD",404);this.touch(o);let a=await YZ(bi(o.dir,i),"r");try{let{size:s}=await a.stat();if(s>32*1024*1024||n>=s)throw new j("\u5206\u6BB5\u8D85\u51FA\u652F\u6301\u8303\u56F4");let u=Buffer.alloc(Math.min(eQ,s-n)),{bytesRead:c}=await a.read(u,0,u.length,n);if(c!==u.length)throw new j("\u5206\u6BB5\u8BFB\u53D6\u5931\u8D25");return{size:s,bytes:u.toString("base64")}}finally{await a.close()}}pin(e,r){this.entries.get(e)?.viewers.add(r)}unpin(e,r){this.entries.get(e)?.viewers.delete(r)}close(){clearInterval(this.timer);for(let e of this.entries.values())e.pending?e.job.finally(()=>this.drop(e)):this.drop(e)}};function HT(t){let e={ANONYMOUS_LIMITED:"\u4E0A\u6E38\u6682\u65F6\u9650\u5236\u533F\u540D\u64AD\u653E",RATE_LIMITED:"\u8BF7\u6C42\u8FC7\u4E8E\u9891\u7E41",AUTHENTICATION_REQUIRED:"\u7247\u6E90\u9700\u8981\u767B\u5F55",CONTENT_UNAVAILABLE:"\u7247\u6E90\u6682\u4E0D\u53EF\u7528"};return new j((e[t?.code]||"\u7EA2\u679C\u7247\u6E90\u6682\u65F6\u4E0D\u53EF\u8FBE")+"\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5",503)}var zm=class{constructor(e){this.store=e,this.ffmpeg=jT(),this.covers=new Map,this.coverLookups=new Map,this.metadata=new Tm(e),this.firstPages=new Map,this.coverJobs=0,this.prepareMediaRuntime().catch(()=>{})}prepareMediaRuntime(){return this.preparingRuntime??=sm().then(()=>{this.ffmpeg=!0}).catch(e=>{throw this.ffmpeg=!1,e}).finally(()=>{this.preparingRuntime=null}),this.preparingRuntime}async sdk(){return this.client??=import(oQ(VT(aa,"dist/vendor/openhongguo/index.js")).href).then(e=>e.createClient({profile:process.env.HONGGUO_PROFILE_PATH||VT(this.store.root,"device","anonymous.json"),timeoutMs:1e4,retryAttempts:2,deviceResets:2})).catch(e=>{throw this.client=null,HT(e)}),this.client}async sdkCall(e,...r){try{return await(await this.sdk())[e](...r)}catch(i){throw HT(i)}}async list({query:e="",cursor:r,preview:i}={}){if(!e)return{items:await this.recommendations(i),cursor:null};let n=await this.sdkCall("search",e,{cursor:r,pageSize:16,filters:["content_type_short_play"]});return{items:this.rows(n,!0),cursor:n.has_more&&n.cursor||null}}async recommendations(e=!1){let r=this.store.preferences().searchTerms,i="feed:"+uQ("sha256").update(JSON.stringify(r)).digest("hex"),n=this.store.catalogCache(i)?.value,o=e&&!n?this.store.waitingFeed(!0):[],a=this.metadata.get(i,async()=>{let u=Promise.withResolvers();this.firstPages.set(i,u.promise);try{let c=await this.collectFeed(u.resolve,r);if(!c.length)throw new j("\u7EA2\u679C\u7247\u6E90\u6682\u65F6\u4E0D\u53EF\u8FBE\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5",503);let l=c.filter(d=>d.hasCover);return{items:(l.length>=12?l:c).slice(0,48),titles:c.map(({id:d,title:p})=>({id:d,title:p})),covers:c.flatMap(({id:d})=>this.covers.get(d)?.url?[[d,this.covers.get(d).url]]:[])}}finally{this.firstPages.delete(i)}},{feed:!0}).then(u=>this.feedItems(u));if(e&&(n||o.length))return a.catch(()=>{}),n?this.feedItems(n):o;let s=this.firstPages.get(i);return e&&s?Promise.race([s,a]):a}feedItems(e){for(let[r,i]of e.covers)this.covers.get(r)?.url!==i&&this.covers.set(r,{url:i});for(;this.covers.size>160;)this.covers.delete(this.covers.keys().next().value);return e.items}async waitingRecommendations(){let e=this.store.waitingFeed();if(e.length)return e;let r=this.store.waitingFeed(!0),i=this.recommendations();return r.length?(i.catch(()=>{}),r):(await i,this.store.waitingFeed(!0))}async collectFeed(e,r=this.store.preferences().searchTerms){let i=new Map,n=new Set,o=u=>{let c=!i.size;for(let l of this.rows(u))(!i.has(l.id)||!i.get(l.id).hasCover&&l.hasCover)&&i.set(l.id,l);c&&i.size&&e([...i.values()])},a,s;for(let u=0;u<6&&i.size<48;u++)try{let c=await this.sdkCall("discover",{cursor:a});if(o(c),a=c.has_more&&c.cursor,!a||n.has(a))break;n.add(a)}catch(c){s=c;break}for(let u of r){if(i.size>=24)break;try{o(await this.sdkCall("search",u,{filters:["content_type_short_play"]}))}catch(c){s=c}}if(!i.size&&s)throw s;return[...i.values()]}rows(e,r=!1){let i=(e.items||[]).filter(n=>/^\d{1,32}$/.test(n.id)).map(n=>{let o="hg-"+n.id;return n.cover_url&&this.covers.get(o)?.url!==n.cover_url&&this.covers.set(o,{url:n.cover_url}),{id:o,title:n.title,description:n.description||"",episodes:n.episode_count||null,hasCover:!!this.covers.get(o)?.url,...r?{lookupCover:!0}:{}}});for(;this.covers.size>160;)this.covers.delete(this.covers.keys().next().value);return i}async cover(e){if(!this.ffmpeg)return{cover:null};let r=this.covers.get(e);if(r?.cover!==void 0)return{cover:r.cover};if(this.coverLookups.has(e))return this.coverLookups.get(e);if(this.coverJobs>=3)return{cover:null};this.coverJobs++;let i=this.loadCover(e).finally(()=>{this.coverJobs--,this.coverLookups.delete(e)});return this.coverLookups.set(e,i),i}async loadCover(e){let r=this.covers.get(e);try{if(!r?.url){let s=await this.sdkCall("getSeries",e.slice(3));if(!s?.cover_url)return{cover:null};for(r={url:s.cover_url},this.covers.set(e,r);this.covers.size>160;)this.covers.delete(this.covers.keys().next().value)}let{body:i,limit:n}=await vc(r.url,3*1024*1024,7e3),o=[];await sQ(i,n,new aQ({write(s,u,c){o.push(s),c()}}));let a=await ka(["-protocol_whitelist","pipe","-i","pipe:0","-vf","scale=240:320:force_original_aspect_ratio=decrease","-frames:v","1","-f","image2pipe","-c:v","mjpeg","pipe:1"],Buffer.concat(o),!0);r.cover="data:image/jpeg;base64,"+a.toString("base64")}catch{return{cover:null}}return{cover:r.cover}}async episodes({seriesId:e,cursor:r}){let i="episodes:"+JSON.stringify([e,r??null]),n=await this.metadata.get(i,()=>this.loadEpisodes(e,r));return{...n,items:n.items.map(o=>({...o,playable:o.playable&&this.ffmpeg}))}}async loadEpisodes(e,r){let i=await this.sdkCall("listEpisodes",e.slice(3),{cursor:r,pageSize:120});return{items:(i.items||[]).filter(n=>/^\d{1,32}$/.test(n.id)).map(n=>({id:"hg-"+n.id,number:n.number,label:n.title||"\u7B2C "+n.number+" \u96C6",codec:"",playable:n.playable!==!1})),cursor:i.has_more&&i.cursor||null}}async nextEpisode(e,r){let i,n=!1,o=new Set,a=new Set;do{let s=await this.episodes({seriesId:e,cursor:i});for(let u of s.items)if(!a.has(u.id)){if(a.add(u.id),u.id===r)n=!0;else if(n&&u.playable){let[c]=this.store.history(e,u.id);if(!c||c.positionMs<c.durationMs)return{episodeId:u.id,kind:c?"resume":"next"}}}if(i=s.cursor,o.has(i))break;o.add(i)}while(i);return null}prepare(e,r,i,n=!1){if(!this.ffmpeg)return this.prepareMediaRuntime().catch(()=>{}),{status:"preparing"};this.cache??=new Cm(this.store,a=>this.sdkCall("resolvePlayback",a));let o=this.cache.prepare(e,i);return o.status!=="ready"?o:r?{...o,src:"media/"+e}:(this.panelMedia??=new Nm(this.store.root),{...o,...this.panelMedia.prepare(e,this.cache.path(e),i,o.codec,n)})}};import{createServer as cQ}from"node:http";import{createReadStream as lQ,statSync as dQ,readFileSync as fQ}from"node:fs";import{join as pQ}from"node:path";import{randomBytes as GT}from"node:crypto";function mQ(t,e){if(t===void 0)return null;let r=/^bytes=(\d*)-(\d*)$/.exec(t);if(!r||!r[1]&&!r[2]||e===0)return!1;let i=Number(r[1]),n=Number(r[2]);if(!Number.isSafeInteger(i)||!Number.isSafeInteger(n))return!1;let o=r[1]?i:Math.max(0,e-n),a=r[1]&&r[2]?Math.min(e-1,n):e-1;return o>=e||a<o?!1:[o,a]}async function JT(t){if(t.headers["content-type"]?.split(";")[0]!=="application/json")throw new j("\u9700\u8981 JSON \u8BF7\u6C42",415);let e=[],r=0;for await(let i of t){if(r+=i.length,r>16384)throw new j("\u8BF7\u6C42\u8FC7\u5927",413);e.push(i)}try{return JSON.parse(Buffer.concat(e).toString())}catch{throw new j("\u8BF7\u6C42\u683C\u5F0F\u65E0\u6548")}}var hQ=`<!doctype html><html lang="zh-CN"><meta charset="utf-8"><title>\u7EA2\u679C\u77ED\u5267 \xB7 \u8FDE\u63A5\u5206\u5C4F</title><p>\u6B63\u5728\u8FDE\u63A5\u672C\u673A\u4F1A\u8BDD\u2026</p><script nonce="__NONCE__">
|
|
147
|
+
ON CONFLICT(id) DO UPDATE SET status='working', owner=excluded.owner,expires=excluded.expires,accessed=excluded.accessed`).run(e,o,n+6e5,n),null)});return a||(this.build(e,o).catch(()=>{}),{status:"preparing"})}async build(e,r){let i=Sa(this.dir,r+".part.source"),n=Sa(this.dir,r+".part.mp4");try{let{playback:o,contentKey:a}=await this.resolve(e.slice(3)),s=(o.streams||[]).filter(h=>h.url),u=s.find(h=>!h.hls&&!h.dash),c=a?.key,l=[u&&(u.protected||o.protected)?u:void 0,s.find(h=>h.hls),s.find(h=>h.dash),u].filter(Boolean),d,p=new j("\u8BE5\u96C6\u6682\u672A\u63D0\u4F9B\u53EF\u64AD\u653E\u7684\u7247\u6E90");for(let h of new Set(l)){d=String(h.codec||"MP4").replace(/[^\w.-]/g,"").slice(0,24);try{if(h.hls||h.dash){if(h.protected||o.protected)throw new j("\u8BE5\u5206\u6BB5\u7247\u6E90\u9700\u8981\u5355\u6587\u4EF6\u64AD\u653E\u6388\u6743");PT(i,{mode:448}),await zT(h.url,i,n,{cdn:vc,run:ka,codec:d,budget:RT})}else{if((o.protected||h.protected)&&!/^[a-f0-9]{32}$/i.test(c||""))throw new j("\u7247\u6E90\u672A\u63D0\u4F9B\u53EF\u7528\u7684\u64AD\u653E\u6388\u6743");let{body:f,limit:g}=await vc(h.url,RT,6e4);await FZ(f,g,PZ(i,{mode:384,flags:"wx"})),await qZ(i,n,d,c)}p=null;break}catch(f){p=f,xa(n,{force:!0})}finally{xa(i,{recursive:!0,force:!0})}}if(p)throw p;let m=OT(n).size;this.transaction(()=>{if(this.db.prepare("SELECT owner FROM media WHERE id=?").get(e)?.owner!==r)return;let h=this.db.prepare("SELECT id,size,hold_until FROM media WHERE status='ready' ORDER BY accessed").all(),f=m+h.reduce((v,A)=>v+A.size,0),g=h.length+1,y=[];for(let v of h){if(f<=this.maxBytes&&g<=this.maxFiles)break;v.hold_until>Date.now()||(y.push(v.id),f-=v.size,g--)}if(f>this.maxBytes||g>this.maxFiles)throw new j("\u7F13\u5B58\u5DF2\u6EE1\uFF0C\u7A0D\u540E\u91CD\u8BD5");for(let v of y)xa(this.path(v),{force:!0}),this.db.prepare("DELETE FROM media WHERE id=?").run(v);jZ(n,this.path(e)),this.db.prepare("UPDATE media SET status='ready',size=?,codec=?,hold_until=? WHERE id=?").run(m,d,Date.now()+12e4,e)})}catch(o){this.db.prepare("UPDATE media SET status='error',reason=?,expires=? WHERE id=? AND owner=?").run(o instanceof j?o.message:"\u5A92\u4F53\u51C6\u5907\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5",Date.now()+3e4,e,r)}finally{xa(i,{recursive:!0,force:!0}),xa(n,{force:!0})}}};import{createHash as u5}from"node:crypto";import{randomUUID as VZ}from"node:crypto";var HZ=15*6e4,Dm=()=>new j("\u7EA2\u679C\u7247\u6E90\u6682\u65F6\u4E0D\u53EF\u8FBE\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5",503),BT=(t,e,r)=>t?.value!==void 0&&e>=t.updatedAt&&e-t.updatedAt<r,Tm=class{constructor(e,{now:r=Date.now,ttl:i=HZ,lease:n=3e4,poll:o=150,wait:a=75e3}={}){this.store=e,this.now=r,this.ttl=i,this.lease=n,this.poll=o,this.wait=a,this.jobs=new Map}async get(e,r,{stale:i=!0,feed:n=!1}={}){let o=this.store.catalogCache(e);if(BT(o,this.now(),this.ttl))return o.value;let a=this.refresh(e,r,n);return i&&o?.value!==void 0?(a.catch(()=>{}),o.value):a}refresh(e,r,i){if(this.jobs.has(e))return this.jobs.get(e);let n=this.run(e,r,i).finally(()=>{this.jobs.get(e)===n&&this.jobs.delete(e)});return this.jobs.set(e,n),n}async run(e,r,i){let n=VZ(),o=performance.now()+this.wait;for(;;){let s=this.now(),u=this.store.catalogCache(e);if(BT(u,s,this.ttl))return u.value;if(u?.retryAt>s)throw Dm();let c=!1;try{c=this.store.claimCatalogCache(e,n,s,this.ttl,this.lease)}catch(l){if(![5,6].includes(l.errcode))throw l}if(c)break;if(performance.now()>=o)throw Dm();await new Promise(l=>setTimeout(l,this.poll))}let a=setInterval(()=>{try{this.store.renewCatalogCache(e,n,this.now(),this.lease)}catch{}},this.lease/3);a.unref();try{let s=await r();if(!this.store.completeCatalogCache(e,n,s,this.now(),i))throw Dm();return s}catch(s){try{this.store.failCatalogCache(e,n,this.now())}catch{}throw s instanceof j?s:Dm()}finally{clearInterval(a)}}};import{randomUUID as JZ}from"node:crypto";import{mkdirSync as MT,readFileSync as KZ,readdirSync as LT,rmSync as l0,statSync as FT,utimesSync as XZ}from"node:fs";import{open as YZ,readFile as WZ}from"node:fs/promises";import{join as bi}from"node:path";import{open as GZ}from"node:fs/promises";async function UT(t){let e=await GZ(t,"r");try{let{size:r}=await e.stat();async function i(n,o){let a=Buffer.alloc(16),{bytesRead:s}=await e.read(a,0,Math.min(16,o-n),n);if(s<8)return;let u=a.readUInt32BE(0),c=8;if(u===1){if(s<16)return;let l=a.readBigUInt64BE(8);if(l>BigInt(Number.MAX_SAFE_INTEGER))return;u=Number(l),c=16}else u===0&&(u=o-n);if(!(u<c||u>o-n))return{type:a.toString("ascii",4,8),payload:n+c,end:n+u}}for(let n=0,o=0;n<r&&o<1024;o++){let a=await i(n,r);if(!a)return;if(a.type==="moov"){for(let s=a.payload,u=0;s<a.end&&u<1024;u++){let c=await i(s,a.end);if(!c)return;if(c.type==="mvhd"){let l=Buffer.alloc(32),{bytesRead:d}=await e.read(l,0,Math.min(32,c.end-c.payload),c.payload),p=l[0];if(p===0&&d<20||p===1&&d<32||p>1)return;let m=l.readUInt32BE(p===0?12:20),h=p===0?l.readUInt32BE(16):Number(l.readBigUInt64BE(24)),f=Math.round(h/m*1e3);return Number.isSafeInteger(h)&&m>0&&f>0&&f<=864e5?f:void 0}s=c.end}return}n=a.end}}finally{await e.close()}}var ZT=10*6e4,e5=192*1024,qT=2,t5=/^(?:init\.mp4|seg[0-9]{5}\.m4s)$/,r5={darwin:["h264_videotoolbox"],win32:["h264_nvenc","h264_qsv","h264_amf"],linux:["h264_nvenc","h264_qsv","h264_vaapi","h264_v4l2m2m"]},QT=["-f","hls","-hls_time",String(qT),"-hls_list_size","0","-hls_segment_type","fmp4","-hls_playlist_type","event","-hls_segment_filename","seg%05d.m4s","index.m3u8"];async function n5(t,e){let i=(await t([...e,"-c","copy","-frames:v","0","-frames:a","0","-f","framehash","pipe:1"],null,!0)).toString("utf8"),n=/^#codec_id 0: (\S+)/m.exec(i)?.[1];if(!n)throw Error("Missing video stream");return{video:n,audio:/^#codec_id 1: (\S+)/m.exec(i)?.[1]}}function i5(t,e){let r=t==="libx264",i="pad=ceil(iw/2)*2:ceil(ih/2)*2,format="+(r?"yuv420p":"nv12");return["-vf",t==="h264_vaapi"?i+",hwupload":i,"-c:v",t,"-tag:v","avc1","-force_key_frames",`expr:gte(t,n_forced*${qT})`,...r?["-preset","veryfast","-crf","22"]:["-b:v","3M"],...t==="h264_videotoolbox"?["-allow_sw","0"]:[],"-c:a",e]}var Nm=class{constructor(e,r=ka){this.root=bi(e,"panel-media"),this.run=r,this.entries=new Map,MT(this.root,{recursive:!0,mode:448});for(let i of LT(this.root,{withFileTypes:!0})){let n=bi(this.root,i.name);i.isDirectory()&&/^[0-9a-f-]{36}$/.test(i.name)&&Date.now()-FT(n,{throwIfNoEntry:!1})?.mtimeMs>864e5&&l0(n,{recursive:!0,force:!0})}this.timer=setInterval(()=>this.sweep(),ZT).unref()}drop(e){this.entries.delete(e.id),l0(e.dir,{recursive:!0,force:!0})}sweep(){for(let e of this.entries.values())!e.pending&&Date.now()-e.used>ZT&&this.drop(e)}touch(e){let r=Date.now();r-(e.touched||0)>6e4&&(XZ(e.dir,new Date(r),new Date(r)),e.touched=r),e.used=r}prepare(e,r,i,n,o=!1){this.sweep();let a=this.entries.get(e);if(a?.error&&i&&(this.drop(a),a=null),!a){if(this.entries.size>=4){let c=[...this.entries.values()].filter(l=>!l.pending&&(!l.viewers.size||!o&&Date.now()-l.used>3e4)).sort((l,d)=>l.used-d.used)[0];if(!c)throw new j("\u4FA7\u680F\u64AD\u653E\u5668\u6B63\u5FD9\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u6216\u4F7F\u7528\u5206\u5C4F");this.drop(c)}let s=JZ(),u=bi(this.root,s);MT(u,{mode:448}),a={id:e,dir:u,stream:s,used:Date.now(),pending:!0,viewers:new Set},this.entries.set(e,a),a.job=this.build(a,r,n).catch(()=>{a.error=!0}).finally(()=>{a.pending=!1})}if(this.touch(a),a.error)throw new j("\u4FA7\u680F\u5206\u6BB5\u51C6\u5907\u5931\u8D25\uFF0C\u53EF\u4F7F\u7528\u540C\u7A97\u5206\u5C4F");return a.pending&&(!a.durationMs||!this.snapshot(a))?{status:"preparing"}:(a.exposed=!0,{status:"ready",stream:a.stream,manifest:a.manifest,codec:a.codec,durationMs:a.durationMs})}snapshot(e){try{let r=bi(e.dir,"index.m3u8");if(FT(r).size>256*1024)throw Error("playlist limit");let i=KZ(r,"utf8"),n=i.match(/#EXTINF:/g)?.length||0;return!n||n<2&&!i.includes("#EXT-X-ENDLIST")?!1:(e.manifest=i,!0)}catch(r){if(r.code==="ENOENT")return!1;throw new j("\u4FA7\u680F\u5206\u6BB5\u51C6\u5907\u5931\u8D25\uFF0C\u53EF\u4F7F\u7528\u540C\u7A97\u5206\u5C4F")}}manifest(e,r){let i=this.entries.get(e);if(!i||i.stream!==r||i.error||!i.manifest)throw new j("\u8BE5\u64AD\u653E\u5206\u6BB5\u5DF2\u5931\u6548\uFF0C\u8BF7\u91CD\u65B0\u70B9\u64AD",404);return i.pending&&this.snapshot(i),this.touch(i),{manifest:i.manifest}}async build(e,r,i){let n=["-protocol_whitelist","file","-f","mov","-i",r,"-map","0:v:0","-map","0:a:0?"],[o,a]=await Promise.all([n5(this.run,n),UT(r)]);e.durationMs=a;let s=o.audio&&o.audio!=="aac"?"aac":"copy",u=o.video==="hevc"||/bytevc1|hevc|h\.?265|hvc1|hev1/i.test(i??"");if(e.codec=u?"h264":o.video,u)for(let l of[...r5[process.platform]??[],"libx264"]){let d=l==="h264_vaapi"?["-init_hw_device","vaapi=panel","-filter_hw_device","panel"]:[];try{let p=i5(l,s);await this.run([...d,...n,...p,...QT],null,!1,e.dir);break}catch(p){if(l==="libx264"||e.exposed)throw p;for(let m of LT(e.dir))l0(bi(e.dir,m),{force:!0})}}else{let l=s==="copy"?["-c","copy"]:["-c:v","copy","-c:a",s];await this.run([...n,...l,...QT],null,!1,e.dir)}let c=await WZ(bi(e.dir,"index.m3u8"),"utf8");if(c.length>256*1024)throw Error("playlist limit");e.manifest=c}async chunk(e,r,i,n){let o=this.entries.get(e);if(!o||o.stream!==r||o.error||!o.manifest||!t5.test(i))throw new j("\u8BE5\u64AD\u653E\u5206\u6BB5\u5DF2\u5931\u6548\uFF0C\u8BF7\u91CD\u65B0\u70B9\u64AD",404);this.touch(o);let a=await YZ(bi(o.dir,i),"r");try{let{size:s}=await a.stat();if(s>32*1024*1024||n>=s)throw new j("\u5206\u6BB5\u8D85\u51FA\u652F\u6301\u8303\u56F4");let u=Buffer.alloc(Math.min(e5,s-n)),{bytesRead:c}=await a.read(u,0,u.length,n);if(c!==u.length)throw new j("\u5206\u6BB5\u8BFB\u53D6\u5931\u8D25");return{size:s,bytes:u.toString("base64")}}finally{await a.close()}}pin(e,r){this.entries.get(e)?.viewers.add(r)}unpin(e,r){this.entries.get(e)?.viewers.delete(r)}close(){clearInterval(this.timer);for(let e of this.entries.values())e.pending?e.job.finally(()=>this.drop(e)):this.drop(e)}};function HT(t){let e={ANONYMOUS_LIMITED:"\u4E0A\u6E38\u6682\u65F6\u9650\u5236\u533F\u540D\u64AD\u653E",RATE_LIMITED:"\u8BF7\u6C42\u8FC7\u4E8E\u9891\u7E41",AUTHENTICATION_REQUIRED:"\u7247\u6E90\u9700\u8981\u767B\u5F55",CONTENT_UNAVAILABLE:"\u7247\u6E90\u6682\u4E0D\u53EF\u7528"};return new j((e[t?.code]||"\u7EA2\u679C\u7247\u6E90\u6682\u65F6\u4E0D\u53EF\u8FBE")+"\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5",503)}var zm=class{constructor(e){this.store=e,this.ffmpeg=jT(),this.covers=new Map,this.coverLookups=new Map,this.metadata=new Tm(e),this.firstPages=new Map,this.coverJobs=0,this.prepareMediaRuntime().catch(()=>{})}prepareMediaRuntime(){return this.preparingRuntime??=sm().then(()=>{this.ffmpeg=!0}).catch(e=>{throw this.ffmpeg=!1,e}).finally(()=>{this.preparingRuntime=null}),this.preparingRuntime}async sdk(){return this.client??=import(o5(VT(aa,"dist/vendor/openhongguo/index.js")).href).then(e=>e.createClient({profile:process.env.HONGGUO_PROFILE_PATH||VT(this.store.root,"device","anonymous.json"),timeoutMs:1e4,retryAttempts:2,deviceResets:2})).catch(e=>{throw this.client=null,HT(e)}),this.client}async sdkCall(e,...r){try{return await(await this.sdk())[e](...r)}catch(i){throw HT(i)}}async list({query:e="",cursor:r,preview:i}={}){if(!e)return{items:await this.recommendations(i),cursor:null};let n=await this.sdkCall("search",e,{cursor:r,pageSize:16,filters:["content_type_short_play"]});return{items:this.rows(n,!0),cursor:n.has_more&&n.cursor||null}}async recommendations(e=!1){let r=this.store.preferences().searchTerms,i="feed:"+u5("sha256").update(JSON.stringify(r)).digest("hex"),n=this.store.catalogCache(i)?.value,o=e&&!n?this.store.waitingFeed(!0):[],a=this.metadata.get(i,async()=>{let u=Promise.withResolvers();this.firstPages.set(i,u.promise);try{let c=await this.collectFeed(u.resolve,r);if(!c.length)throw new j("\u7EA2\u679C\u7247\u6E90\u6682\u65F6\u4E0D\u53EF\u8FBE\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5",503);let l=c.filter(d=>d.hasCover);return{items:(l.length>=12?l:c).slice(0,48),titles:c.map(({id:d,title:p})=>({id:d,title:p})),covers:c.flatMap(({id:d})=>this.covers.get(d)?.url?[[d,this.covers.get(d).url]]:[])}}finally{this.firstPages.delete(i)}},{feed:!0}).then(u=>this.feedItems(u));if(e&&(n||o.length))return a.catch(()=>{}),n?this.feedItems(n):o;let s=this.firstPages.get(i);return e&&s?Promise.race([s,a]):a}feedItems(e){for(let[r,i]of e.covers)this.covers.get(r)?.url!==i&&this.covers.set(r,{url:i});for(;this.covers.size>160;)this.covers.delete(this.covers.keys().next().value);return e.items}async waitingRecommendations(){let e=this.store.waitingFeed();if(e.length)return e;let r=this.store.waitingFeed(!0),i=this.recommendations();return r.length?(i.catch(()=>{}),r):(await i,this.store.waitingFeed(!0))}async collectFeed(e,r=this.store.preferences().searchTerms){let i=new Map,n=new Set,o=u=>{let c=!i.size;for(let l of this.rows(u))(!i.has(l.id)||!i.get(l.id).hasCover&&l.hasCover)&&i.set(l.id,l);c&&i.size&&e([...i.values()])},a,s;for(let u=0;u<6&&i.size<48;u++)try{let c=await this.sdkCall("discover",{cursor:a});if(o(c),a=c.has_more&&c.cursor,!a||n.has(a))break;n.add(a)}catch(c){s=c;break}for(let u of r){if(i.size>=24)break;try{o(await this.sdkCall("search",u,{filters:["content_type_short_play"]}))}catch(c){s=c}}if(!i.size&&s)throw s;return[...i.values()]}rows(e,r=!1){let i=(e.items||[]).filter(n=>/^\d{1,32}$/.test(n.id)).map(n=>{let o="hg-"+n.id;return n.cover_url&&this.covers.get(o)?.url!==n.cover_url&&this.covers.set(o,{url:n.cover_url}),{id:o,title:n.title,description:n.description||"",episodes:n.episode_count||null,hasCover:!!this.covers.get(o)?.url,...r?{lookupCover:!0}:{}}});for(;this.covers.size>160;)this.covers.delete(this.covers.keys().next().value);return i}async cover(e){if(!this.ffmpeg)return{cover:null};let r=this.covers.get(e);if(r?.cover!==void 0)return{cover:r.cover};if(this.coverLookups.has(e))return this.coverLookups.get(e);if(this.coverJobs>=3)return{cover:null};this.coverJobs++;let i=this.loadCover(e).finally(()=>{this.coverJobs--,this.coverLookups.delete(e)});return this.coverLookups.set(e,i),i}async loadCover(e){let r=this.covers.get(e);try{if(!r?.url){let s=await this.sdkCall("getSeries",e.slice(3));if(!s?.cover_url)return{cover:null};for(r={url:s.cover_url},this.covers.set(e,r);this.covers.size>160;)this.covers.delete(this.covers.keys().next().value)}let{body:i,limit:n}=await vc(r.url,3*1024*1024,7e3),o=[];await s5(i,n,new a5({write(s,u,c){o.push(s),c()}}));let a=await ka(["-protocol_whitelist","pipe","-i","pipe:0","-vf","scale=240:320:force_original_aspect_ratio=decrease","-frames:v","1","-f","image2pipe","-c:v","mjpeg","pipe:1"],Buffer.concat(o),!0);r.cover="data:image/jpeg;base64,"+a.toString("base64")}catch{return{cover:null}}return{cover:r.cover}}async episodes({seriesId:e,cursor:r}){let i="episodes:"+JSON.stringify([e,r??null]),n=await this.metadata.get(i,()=>this.loadEpisodes(e,r));return{...n,items:n.items.map(o=>({...o,playable:o.playable&&this.ffmpeg}))}}async loadEpisodes(e,r){let i=await this.sdkCall("listEpisodes",e.slice(3),{cursor:r,pageSize:120});return{items:(i.items||[]).filter(n=>/^\d{1,32}$/.test(n.id)).map(n=>({id:"hg-"+n.id,number:n.number,label:n.title||"\u7B2C "+n.number+" \u96C6",codec:"",playable:n.playable!==!1})),cursor:i.has_more&&i.cursor||null}}async nextEpisode(e,r){let i,n=!1,o=new Set,a=new Set;do{let s=await this.episodes({seriesId:e,cursor:i});for(let u of s.items)if(!a.has(u.id)){if(a.add(u.id),u.id===r)n=!0;else if(n&&u.playable){let[c]=this.store.history(e,u.id);if(!c||c.positionMs<c.durationMs)return{episodeId:u.id,kind:c?"resume":"next"}}}if(i=s.cursor,o.has(i))break;o.add(i)}while(i);return null}prepare(e,r,i,n=!1){if(!this.ffmpeg)return this.prepareMediaRuntime().catch(()=>{}),{status:"preparing"};this.cache??=new Cm(this.store,a=>this.sdkCall("resolvePlayback",a));let o=this.cache.prepare(e,i);return o.status!=="ready"?o:r?{...o,src:"media/"+e}:(this.panelMedia??=new Nm(this.store.root),{...o,...this.panelMedia.prepare(e,this.cache.path(e),i,o.codec,n)})}};import{createServer as c5}from"node:http";import{createReadStream as l5,statSync as d5,readFileSync as f5}from"node:fs";import{join as p5}from"node:path";import{randomBytes as GT}from"node:crypto";function m5(t,e){if(t===void 0)return null;let r=/^bytes=(\d*)-(\d*)$/.exec(t);if(!r||!r[1]&&!r[2]||e===0)return!1;let i=Number(r[1]),n=Number(r[2]);if(!Number.isSafeInteger(i)||!Number.isSafeInteger(n))return!1;let o=r[1]?i:Math.max(0,e-n),a=r[1]&&r[2]?Math.min(e-1,n):e-1;return o>=e||a<o?!1:[o,a]}async function JT(t){if(t.headers["content-type"]?.split(";")[0]!=="application/json")throw new j("\u9700\u8981 JSON \u8BF7\u6C42",415);let e=[],r=0;for await(let i of t){if(r+=i.length,r>16384)throw new j("\u8BF7\u6C42\u8FC7\u5927",413);e.push(i)}try{return JSON.parse(Buffer.concat(e).toString())}catch{throw new j("\u8BF7\u6C42\u683C\u5F0F\u65E0\u6548")}}var h5=`<!doctype html><html lang="zh-CN"><meta charset="utf-8"><title>\u7EA2\u679C\u77ED\u5267 \xB7 \u8FDE\u63A5\u5206\u5C4F</title><p>\u6B63\u5728\u8FDE\u63A5\u672C\u673A\u4F1A\u8BDD\u2026</p><script nonce="__NONCE__">
|
|
143
148
|
(async()=>{const ticket=location.hash.slice(1);history.replaceState(null,'','/pair');
|
|
144
149
|
try {const r=await fetch('/exchange',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({ticket})});
|
|
145
150
|
if(!r.ok)throw Error();location.replace((await r.json()).page);}catch{document.querySelector('p').textContent='\u5206\u5C4F\u94FE\u63A5\u5DF2\u8FC7\u671F\u6216\u5DF2\u4F7F\u7528\u3002\u8BF7\u56DE\u5230\u77ED\u5267\u9762\u677F\u91CD\u65B0\u83B7\u53D6\u3002';}})()
|
|
146
|
-
</script></html>`,Pm=class{constructor(e){this.service=e,this.tickets=new Map,this.sessions=new Map}async listen(){return this.starting||(this.server=
|
|
151
|
+
</script></html>`,Pm=class{constructor(e){this.service=e,this.tickets=new Map,this.sessions=new Map}async listen(){return this.starting||(this.server=c5((e,r)=>this.request(e,r).catch(i=>{if(r.headersSent){r.destroy();return}r.writeHead(i instanceof j?i.status:503,{"Content-Type":"application/json"}),r.end(JSON.stringify({error:rm(i)}))})),this.server.headersTimeout=1e4,this.server.requestTimeout=15e3,this.starting=new Promise((e,r)=>{this.server.once("error",r),this.server.listen(0,"127.0.0.1",()=>{this.origin="http://127.0.0.1:"+this.server.address().port,e()})}).catch(e=>{throw this.starting=null,e})),this.starting}prune(){for(let e of[this.sessions,this.tickets])for(let[r,i]of e)i.expires<Date.now()&&e.delete(r)}async pair(e){await this.listen(),this.prune();let r=Gu();return this.tickets.set(r,{scope:e,expires:Date.now()+6e4}),{url:this.origin+"/pair#"+r,expiresIn:60}}async request(e,r){if(r.setHeader("Cache-Control","no-store"),r.setHeader("Referrer-Policy","no-referrer"),r.setHeader("X-Content-Type-Options","nosniff"),e.headers.host!==new URL(this.origin).host)throw new j("\u4E3B\u673A\u65E0\u6548",403);if(e.method==="POST"&&e.headers.origin!==this.origin)throw new j("\u8BF7\u6C42\u6765\u6E90\u65E0\u6548",403);let i=e.url,n=GT(16).toString("base64");r.setHeader("Content-Security-Policy",`default-src 'none'; script-src 'nonce-${n}'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; media-src 'self' blob:; connect-src 'self'; frame-ancestors 'none'; base-uri 'none'; form-action 'none'`);let o=l=>{r.setHeader("Content-Type","text/html; charset=utf-8"),r.end(l.replaceAll("__NONCE__",n))},a=l=>{r.setHeader("Content-Type","application/json"),r.end(JSON.stringify(l))};if(i==="/pair"&&e.method==="GET")return o(h5);if(this.prune(),i==="/exchange"&&e.method==="POST"){let l=await JT(e),d=this.tickets.get(l?.ticket);if(!d||d.expires<Date.now())throw new j("\u5206\u5C4F\u94FE\u63A5\u65E0\u6548",403);this.tickets.delete(l.ticket);let p=GT(12).toString("hex"),m=Gu(),h="/p/"+p+"/";return this.sessions.set(p,{...d.scope,key:m,grants:new Set,expires:Date.now()+12*36e5}),r.setHeader("Set-Cookie","hg="+m+"; Path="+h+"; HttpOnly; SameSite=Strict"),a({page:h})}let s=/^\/p\/([a-f0-9]{24})\/(.*)$/.exec(i),u=s&&this.sessions.get(s[1]);if(!u||!(e.headers.cookie||"").split(/;\s*/).includes("hg="+u.key))throw new j("\u8BF7\u4ECE\u4F1A\u8BDD\u9762\u677F\u91CD\u65B0\u6253\u5F00\u5206\u5C4F",401);u.expires=Date.now()+12*36e5;let c=s[2];if(!c&&e.method==="GET")return o(f5(p5(aa,"dist/ui/player.html"),"utf8").replace('data-host="panel"','data-host="browser"'));if(c==="context"&&e.method==="GET")return a({identified:!!u.sessionId,turnId:u.fixedTurn,selection:u.selection});if(c.startsWith("api/")&&e.method==="POST")return a(await this.service.call(u,c.slice(4),await JT(e),!0));if(c.startsWith("media/")&&["GET","HEAD"].includes(e.method)){let l=c.slice(6);if(!u.grants.has(l))throw new j("\u8BF7\u5148\u9009\u62E9\u8BE5\u96C6",403);let d=this.service.catalog.cache?.path(l);if(!d)throw new j("\u7D20\u6750\u5F85\u91CD\u65B0\u51C6\u5907",404);let p=d5(d,{throwIfNoEntry:!1})?.size;if(!p)throw new j("\u7F13\u5B58\u5DF2\u6E05\u7406\uFF0C\u8BF7\u91CD\u65B0\u51C6\u5907\u8BE5\u96C6",404);this.service.catalog.cache?.hold(l);let m=m5(e.headers.range,p);if(r.setHeader("Accept-Ranges","bytes"),r.setHeader("Content-Type","video/mp4"),m===!1)return r.writeHead(416,{"Content-Range":"bytes */"+p}),r.end();let[h,f]=m||[0,p-1];if(m&&r.setHeader("Content-Range",`bytes ${h}-${f}/${p}`),r.writeHead(m?206:200,{"Content-Length":f-h+1}),e.method==="HEAD")return r.end();let g=l5(d,{start:h,end:f}),y=setInterval(()=>this.service.catalog.cache?.hold(l),3e4);r.on("close",()=>{clearInterval(y),g.destroy()}),g.on("error",()=>r.destroy()),g.pipe(r);return}throw new j("\u627E\u4E0D\u5230\u8BE5\u9875\u9762",404)}close(){this.server?.closeAllConnections(),this.server?.close()}};process.umask(63);var Ac;try{Ac=new Hu}catch{Ac=new Hu(void 0,!0)}var f0=new zm(Ac),Ca=new nm(Ac,f0),XT=new Pm(Ca);Ca.pair=t=>XT.pair(t);var $i=new Xp({name:"codex-hongguo",version:qk.version}),YT="ui://hongguo/v24/player",Om="ui://hongguo/v24/waiting",d0="text/html;profile=mcp-app",WT={visibility:["app"]},KT={ui:{csp:{connectDomains:[],resourceDomains:["blob:"]},prefersBorder:!1}};for(let[t,e]of[[YT,"\u7EA2\u679C\u77ED\u5267"],[Om,"\u7B49\u5F85\u65F6\u770B\u4E00\u96C6"]]){let r=t===Om,i=r?{...KT,"openai/widgetShowCodexWidgetInline":!0,"openai/widgetHeightHint":96,"openai/widgetMinFrameHeight":1,"openai/ui":{availableDisplayModes:["inline","fullscreen"],preferredDisplayMode:"inline"}}:KT,n=o=>{let a=g5(v5(aa,"dist/ui/player.html"),"utf8");return{contents:[{uri:o.href,mimeType:d0,_meta:i,text:r?a.replace('data-surface="player"','data-surface="waiting"'):a}]}};$i.registerResource(e,t,{mimeType:d0,_meta:i},n);for(let o of["ui://hongguo/","ui://hongguo/v2/","ui://hongguo/v3/","ui://hongguo/v4/","ui://hongguo/v5/","ui://hongguo/v6/","ui://hongguo/v7/","ui://hongguo/v8/","ui://hongguo/v9/","ui://hongguo/v10/","ui://hongguo/v11/","ui://hongguo/v12/","ui://hongguo/v13/","ui://hongguo/v14/","ui://hongguo/v15/","ui://hongguo/v16/","ui://hongguo/v17/","ui://hongguo/v18/","ui://hongguo/v19/"]){let a=o+(r?"waiting":"player");if(a===t)continue;let s=new Yp(a,{list:void 0});$i.registerResource(e+"\uFF08"+o+"\uFF09",s,{mimeType:d0,_meta:i},n)}}$i.registerTool("show_waiting_picks",{title:"\u7B49\u5F85\u65F6\u770B\u4E00\u96C6",description:"Show optional Hongguo titles inline when requested by the Hongguo turn-start hook. Returns immediately.",inputSchema:{turnId:M.string().regex(/^[A-Za-z0-9_-]{1,128}$/)},annotations:{readOnlyHint:!0,openWorldHint:!1},_meta:{ui:{visibility:["model"],resourceUri:Om},"openai/ui":{preferredModelDisplayMode:"inline"}}},({turnId:t},e)=>{let r=Ca.openWaiting(e._meta,t);return{content:[],structuredContent:{shown:!!r},_meta:r?{panel:r.panel,waitingTurn:t,ui:{resourceUri:Om}}:{}}});$i.registerTool("open_drama_panel",{title:"\u7EA2\u679C\u77ED\u5267",description:"\u5728\u5F53\u524D\u4F1A\u8BDD\u9009\u5267\u4E0E\u7EED\u64AD",inputSchema:{},_meta:{ui:{...WT,resourceUri:YT},"openai/ui":{entrypoints:[{type:"thread"},{type:"global"}]}}},(t,e)=>{let r=Ca.open(e._meta);return f0.recommendations().catch(()=>{}),{content:[],structuredContent:{state:r.state,identified:r.identified},_meta:{panel:r.panel}}});for(let[t,e]of Object.entries(db))$i.registerTool(t,{inputSchema:{...e.shape,panel:M.string().max(80)},_meta:{ui:WT}},async({panel:r,...i},n)=>{try{let o=await Ca.call(Ca.panel(r,n._meta),t,i);return{content:[],_meta:{data:o}}}catch(o){return{isError:!0,content:[{type:"text",text:rm(o)}]}}});$i.server.onclose=()=>{f0.panelMedia?.close(),XT.close(),Ac.close()};await $i.connect(new em);
|
|
147
152
|
/*! Bundled license information:
|
|
148
153
|
|
|
149
154
|
xz-decompress/dist/package/xz-decompress.js:
|