greptile 3.5.1 → 3.5.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/CHANGELOG.md CHANGED
@@ -4,6 +4,23 @@ All notable changes to the Greptile CLI.
4
4
 
5
5
  ## Unreleased
6
6
 
7
+ ## 3.5.2 - 2026-09-04
8
+
9
+ Republishes 3.5.1 for npm. The 3.5.1 npm publish landed during an
10
+ [npm registry incident](https://status.npmjs.org/incidents/b6958bgj1sm3) on
11
+ 2026-09-03 and its tarball was never stored, so
12
+ `npm install greptile@3.5.1` fails. Homebrew and the GitHub release of 3.5.1
13
+ were unaffected.
14
+
15
+ ### Added
16
+
17
+ - The README now documents telemetry: the eight events sent, what they carry
18
+ and what they never carry, the difference between the anonymous default and
19
+ opt-in account-linked reporting, and every way to turn it off
20
+ (`greptile settings set telemetry false`, `GREPTILE_TELEMETRY_DISABLED`,
21
+ `DO_NOT_TRACK`, `CI`, or a self-hosted deployment). The `telemetry` setting
22
+ and its two environment variables are now listed in the reference tables.
23
+
7
24
  ## 3.5.1 - 2026-09-03
8
25
 
9
26
  ### Changed
package/README.md CHANGED
@@ -13,6 +13,7 @@ Greptile code review in your terminal. Runs the same review Greptile posts on yo
13
13
  - [Diagrams](#diagrams)
14
14
  - [Fix in Claude Code](#fix-in-claude-code)
15
15
  - [Updating](#updating)
16
+ - [Telemetry](#telemetry)
16
17
  - [Reference](#reference)
17
18
 
18
19
  ## Install
@@ -208,13 +209,14 @@ greptile settings list # every setting and where it comes fr
208
209
  greptile settings unset review.layout # back to the default
209
210
  ```
210
211
 
211
- | Setting | Values | Matching flag |
212
- | ---------------- | --------------------------------------- | ------------------------------------------------------ |
213
- | `color` | `true` (default), `false` | `--color` / `--no-color` |
214
- | `review.output` | `auto` (default), `text`, `json` | `--text` / `--json` |
215
- | `review.layout` | `comments` (default), `diff` | `--layout` (`--diff` is shorthand for `--layout diff`) |
216
- | `review.context` | `0` to `60` (default `15`) | `--context` |
217
- | `review.width` | `40` to `240` (default: terminal width) | `--width` |
212
+ | Setting | Values | Matching flag |
213
+ | ---------------- | ---------------------------------------- | ------------------------------------------------------ |
214
+ | `color` | `true` (default), `false` | `--color` / `--no-color` |
215
+ | `review.output` | `auto` (default), `text`, `json` | `--text` / `--json` |
216
+ | `review.layout` | `comments` (default), `diff` | `--layout` (`--diff` is shorthand for `--layout diff`) |
217
+ | `review.context` | `0` to `60` (default `15`) | `--context` |
218
+ | `review.width` | `40` to `240` (default: terminal width) | `--width` |
219
+ | `telemetry` | `true`, `false` (unset until you decide) | — (see [Telemetry](#telemetry)) |
218
220
 
219
221
  A flag passed on the command line always wins over a saved setting for that run.
220
222
 
@@ -287,6 +289,44 @@ greptile update
287
289
 
288
290
  This checks for a newer release and upgrades in place for npm, bun, pnpm, and standalone `install.sh` installs. Three cases are handled differently: Homebrew prints `brew upgrade greptile` for you to run, a CLI that ships inside a Claude Code plugin is updated by updating the plugin, and an install the CLI can't identify — a distro package, a Nix store path, a version-manager shim, a binary copied onto your `PATH` — is reported as such so you can update it the way you installed it. The CLI also checks for updates once a day and prints a notice when one is available; set `GREPTILE_NO_UPDATE_CHECK=1` to turn that off.
289
291
 
292
+ ## Telemetry
293
+
294
+ greptile reports anonymous usage events to help us see which commands people
295
+ run and where they get stuck. The events are lifecycle signals —
296
+ `cli_first_run`, `cli_login_started`, `cli_login_failed`,
297
+ `cli_onboarding_started`, `cli_skill_installed`, `cli_skill_updated`,
298
+ `cli_review_blocked`, `cli_update_completed` — carrying how you installed the
299
+ CLI, your OS and architecture, whether the run was interactive, and which agent
300
+ surface it ran under if any. Never your code, repository or branch names, file
301
+ paths, or review content. Event-specific fields are fixed values: `method`,
302
+ `exit_code`, `reason`, the version strings on an update, and the name of the
303
+ Greptile-authored skill on `cli_skill_installed` and `cli_skill_updated`.
304
+
305
+ There are two tiers, and they are treated differently:
306
+
307
+ - **Anonymous** — a random per-machine identifier, no account attached, and no
308
+ profile built on the other end. This is the default and it is opt-out.
309
+ - **Linked to your account** — the same events, attributed to you. This is
310
+ opt-in, and greptile asks once, on the first interactive run, before sending
311
+ anything under your account.
312
+
313
+ Until you answer that prompt, greptile stays anonymous — including in runs that
314
+ cannot show it at all, such as every run inside an AI coding agent. Once you
315
+ have answered, your answer is what applies: accept, and later agent and script
316
+ runs are account-linked too, because the decision is yours and not the
317
+ terminal's. Declining silences both tiers, not just the linked one.
318
+
319
+ Any one of these turns it off:
320
+
321
+ ```sh
322
+ greptile settings set telemetry false # persistent
323
+ export GREPTILE_TELEMETRY_DISABLED=1 # this shell
324
+ export DO_NOT_TRACK=1 # this shell, and every tool that honors it
325
+ ```
326
+
327
+ It is also off automatically when `CI` is set, and a CLI pointed at a
328
+ self-hosted Greptile sends no telemetry at all.
329
+
290
330
  ## Reference
291
331
 
292
332
  ### Command synopsis
@@ -305,15 +345,17 @@ greptile update
305
345
 
306
346
  ### Environment variables
307
347
 
308
- | Variable | What it does |
309
- | -------------------------- | --------------------------------------------------------------------- |
310
- | `GREPTILE_API_KEY` | Authenticate with an API key; takes precedence over a stored sign-in. |
311
- | `GREPTILE_INLINE_IMAGES` | Force inline diagrams on (`1`, `true`, `kitty`) or off (`0`, `off`). |
312
- | `GREPTILE_NO_AUTO_INSTALL` | Skip the one-time diagram renderer download. |
313
- | `GREPTILE_NO_UPDATE_CHECK` | Skip the daily check for a newer CLI release. |
314
- | `NO_COLOR` | Turn off ANSI color. |
315
- | `FORCE_COLOR` | Turn on ANSI color even when output is piped. |
316
- | `COLUMNS` | Override the output width. |
348
+ | Variable | What it does |
349
+ | ----------------------------- | --------------------------------------------------------------------- |
350
+ | `GREPTILE_API_KEY` | Authenticate with an API key; takes precedence over a stored sign-in. |
351
+ | `GREPTILE_INLINE_IMAGES` | Force inline diagrams on (`1`, `true`, `kitty`) or off (`0`, `off`). |
352
+ | `GREPTILE_NO_AUTO_INSTALL` | Skip the one-time diagram renderer download. |
353
+ | `GREPTILE_NO_UPDATE_CHECK` | Skip the daily check for a newer CLI release. |
354
+ | `GREPTILE_TELEMETRY_DISABLED` | Turn off anonymous usage telemetry. |
355
+ | `DO_NOT_TRACK` | Same, honored alongside other tools that read it. |
356
+ | `NO_COLOR` | Turn off ANSI color. |
357
+ | `FORCE_COLOR` | Turn on ANSI color even when output is piped. |
358
+ | `COLUMNS` | Override the output width. |
317
359
 
318
360
  ### Exit codes
319
361
 
package/dist/greptile.js CHANGED
@@ -293,7 +293,7 @@ Read about how to prevent this error on https://github.com/vadimdemedes/ink/#isr
293
293
  `)r+=u};let s,A=pa.createContainer(a,iL.LegacyRoot,null,!1,null,"render-to-string",(u)=>{s??=u},()=>{},()=>{},()=>{}),l=!1;try{pa.updateContainerSync(e,A,null,()=>{}),pa.flushSyncWork();let{output:u}=ub(a,!1);if(pa.updateContainerSync(null,A,null,()=>{}),pa.flushSyncWork(),l=!0,a.yogaNode.free(),s!==void 0)throw s instanceof Error?s:Error(String(s));let m=r.endsWith(`
294
294
  `)?r.slice(0,-1):r;if(m&&u)return m+`
295
295
  `+u;return m||u}finally{if(!l&&a.yogaNode)try{a.yogaNode.freeRecursive()}catch{}}},ad;var rL=h(async()=>{await Kn([EA(),sb(),LI(),Wg()]);iL=re(ww(),1),ad=Oue});function DB(e){let{items:n,children:t,style:a}=e,[r,s]=gc.useState(0),A=gc.useMemo(()=>{return n.slice(r)},[n,r]);gc.useLayoutEffect(()=>{s(n.length)},[n.length]);let l=A.map((m,b)=>{return t(m,r+b)}),u=gc.useMemo(()=>({position:"absolute",flexDirection:"column",...a}),[a]);return gc.default.createElement("ink-box",{internal_static:!0,style:u},l)}var gc;var oL=h(()=>{gc=re(Be(),1)});var sL;var cL=h(()=>{yp();sL=re(Be(),1)});var Yue;var AL=h(()=>{Yue=re(Be(),1)});var Kue;var lL=h(()=>{BB();Kue=re(Be(),1)});function fL(e){if(e===3)return"release";if(e===2)return"repeat";return"press"}function hL(e){return{ctrl:!!(e&ms.ctrl),shift:!!(e&ms.shift),meta:!!(e&(ms.meta|ms.alt)),super:!!(e&ms.super),hyper:!!(e&ms.hyper),capsLock:!!(e&ms.capsLock),numLock:!!(e&ms.numLock)}}var dL,Zue,Jue,pL,mL,Wue=(e)=>{return["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(e)},Vue=(e)=>{return["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(e)},gL,Xue,epe,npe,uL,bL=(e)=>e>=0&&e<=1114111&&!(e>=55296&&e<=57343),ov=(e)=>bL(e)?String.fromCodePoint(e):"?",tpe=(e)=>{let n=gL.exec(e);if(!n)return null;let t=parseInt(n[1],10),a=n[2]?Math.max(0,parseInt(n[2],10)-1):0,r=n[3]?parseInt(n[3],10):1,s=n[4];if(!bL(t))return null;let A;if(s)A=s.split(":").map((m)=>ov(parseInt(m,10))).join("");let l,u;if(t===32)l="space",u=!0;else if(t===13)l="return",u=!0;else if(uL[t])l=uL[t],u=!1;else if(t>=1&&t<=26)l=String.fromCodePoint(t+96),u=!1;else l=ov(t).toLowerCase(),u=!0;if(u&&!A)A=ov(t);return{name:l,...hL(a),eventType:fL(r),sequence:e,raw:e,isKittyProtocol:!0,isPrintable:u,text:A}},ape=(e)=>{let n=Xue.exec(e);if(!n)return null;let t=parseInt(n[1],10),a=Math.max(0,parseInt(n[2],10)-1),r=parseInt(n[3],10),s=n[4],A=s==="~"?npe[t]:epe[s];if(!A)return null;return{name:A,...hL(a),eventType:fL(r),sequence:e,raw:e,isKittyProtocol:!0,isPrintable:!1}},ipe=(e="")=>{let n;if(e instanceof Uint8Array)if(e[0]>127&&e[1]===void 0)e[0]-=128,e="\x1B"+dL.decode(e);else e=dL.decode(e);else if(e!==void 0&&typeof e!=="string")e=String(e);else if(!e)e="";let t=tpe(e);if(t)return t;let a=ape(e);if(a)return a;if(gL.test(e))return{name:"",ctrl:!1,meta:!1,shift:!1,sequence:e,raw:e,isKittyProtocol:!0,isPrintable:!1};let r={name:"",ctrl:!1,meta:!1,shift:!1,sequence:e,raw:e};if(r.sequence=r.sequence||e||r.name,e==="\r"||e==="\x1B\r")r.raw=void 0,r.name="return",r.meta=e.length===2;else if(e===`
296
- `)r.name="enter";else if(e==="\t")r.name="tab";else if(e==="\b"||e==="\x1B\b")r.name="backspace",r.meta=e.charAt(0)==="\x1B";else if(e===""||e==="\x1B")r.name="backspace",r.meta=e.charAt(0)==="\x1B";else if(e==="\x1B"||e==="\x1B\x1B")r.name="escape",r.meta=e.length===2;else if(e===" "||e==="\x1B ")r.name="space",r.meta=e.length===2;else if(e.length===1&&e<="\x1A")r.name=String.fromCharCode(e.charCodeAt(0)+97-1),r.ctrl=!0;else if(e.length===1&&e>="0"&&e<="9")r.name="number";else if(e.length===1&&e>="a"&&e<="z")r.name=e;else if(e.length===1&&e>="A"&&e<="Z")r.name=e.toLowerCase(),r.shift=!0;else if(n=Zue.exec(e))r.name=n[1].toLowerCase(),r.meta=!0,r.shift=/^[A-Z]$/.test(n[1]);else if(n=Jue.exec(e)){let s=[...e];if(s[0]==="\x1B"&&s[1]==="\x1B")r.meta=!0;let A=[n[1],n[2],n[4],n[6]].filter(Boolean).join(""),l=(n[3]||n[5]||1)-1;r.ctrl=!!(l&4),r.meta=r.meta||!!(l&10),r.shift=!!(l&1),r.code=A,r.name=pL[A]??"",r.shift=Wue(A)||r.shift,r.ctrl=Vue(A)||r.ctrl}return r},yL;var wL=h(()=>{EB();dL=new TextDecoder,Zue=/^(?:\x1b)([a-zA-Z0-9])$/,Jue=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,pL={OP:"f1",OQ:"f2",OR:"f3",OS:"f4","[P":"f1","[Q":"f2","[R":"f3","[S":"f4","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[A":"up","[B":"down","[C":"right","[D":"left","[E":"clear","[F":"end","[H":"home",OA:"up",OB:"down",OC:"right",OD:"left",OE:"clear",OF:"end",OH:"home","[1~":"home","[2~":"insert","[3~":"delete","[4~":"end","[5~":"pageup","[6~":"pagedown","[[5~":"pageup","[[6~":"pagedown","[7~":"home","[8~":"end","[a":"up","[b":"down","[c":"right","[d":"left","[e":"clear","[2$":"insert","[3$":"delete","[5$":"pageup","[6$":"pagedown","[7$":"home","[8$":"end",Oa:"up",Ob:"down",Oc:"right",Od:"left",Oe:"clear","[2^":"insert","[3^":"delete","[5^":"pageup","[6^":"pagedown","[7^":"home","[8^":"end","[Z":"tab"},mL=[...Object.values(pL),"backspace"],gL=/^\x1b\[(\d+)(?:;(\d+)(?::(\d+))?(?:;([\d:]+))?)?u$/,Xue=/^\x1b\[(\d+);(\d+):(\d+)([A-Za-z~])$/,epe={A:"up",B:"down",C:"right",D:"left",E:"clear",F:"end",H:"home",P:"f1",Q:"f2",R:"f3",S:"f4"},npe={2:"insert",3:"delete",5:"pageup",6:"pagedown",7:"home",8:"end",11:"f1",12:"f2",13:"f3",14:"f4",15:"f5",17:"f6",18:"f7",19:"f8",20:"f9",21:"f10",23:"f11",24:"f12"},uL={27:"escape",9:"tab",127:"backspace",8:"backspace",57358:"capslock",57359:"scrolllock",57360:"numlock",57361:"printscreen",57362:"pause",57363:"menu",57376:"f13",57377:"f14",57378:"f15",57379:"f16",57380:"f17",57381:"f18",57382:"f19",57383:"f20",57384:"f21",57385:"f22",57386:"f23",57387:"f24",57388:"f25",57389:"f26",57390:"f27",57391:"f28",57392:"f29",57393:"f30",57394:"f31",57395:"f32",57396:"f33",57397:"f34",57398:"f35",57399:"kp0",57400:"kp1",57401:"kp2",57402:"kp3",57403:"kp4",57404:"kp5",57405:"kp6",57406:"kp7",57407:"kp8",57408:"kp9",57409:"kpdecimal",57410:"kpdivide",57411:"kpmultiply",57412:"kpsubtract",57413:"kpadd",57414:"kpenter",57415:"kpequal",57416:"kpseparator",57417:"kpleft",57418:"kpright",57419:"kpup",57420:"kpdown",57421:"kppageup",57422:"kppagedown",57423:"kphome",57424:"kpend",57425:"kpinsert",57426:"kpdelete",57427:"kpbegin",57428:"mediaplay",57429:"mediapause",57430:"mediaplaypause",57431:"mediareverse",57432:"mediastop",57433:"mediafastforward",57434:"mediarewind",57435:"mediatracknext",57436:"mediatrackprevious",57437:"mediarecord",57438:"lowervolume",57439:"raisevolume",57440:"mutevolume",57441:"leftshift",57442:"leftcontrol",57443:"leftalt",57444:"leftsuper",57445:"lefthyper",57446:"leftmeta",57447:"rightshift",57448:"rightcontrol",57449:"rightalt",57450:"rightsuper",57451:"righthyper",57452:"rightmeta",57453:"isoLevel3Shift",57454:"isoLevel5Shift"};yL=ipe});var BL,sv=()=>BL.useContext(bB);var wb=h(()=>{UI();BL=re(Be(),1)});var Bb,rpe=(e,n={})=>{let{setRawMode:t,internal_exitOnCtrlC:a,internal_eventEmitter:r}=sv();Bb.useEffect(()=>{if(n.isActive===!1)return;return t(!0),()=>{t(!1)}},[n.isActive,t]);let s=Bb.useEffectEvent((A)=>{let l=yL(A),u={upArrow:l.name==="up",downArrow:l.name==="down",leftArrow:l.name==="left",rightArrow:l.name==="right",pageDown:l.name==="pagedown",pageUp:l.name==="pageup",home:l.name==="home",end:l.name==="end",return:l.name==="return",escape:l.name==="escape",ctrl:l.ctrl,shift:l.shift,tab:l.name==="tab",backspace:l.name==="backspace",delete:l.name==="delete",meta:l.meta,super:l.super??!1,hyper:l.hyper??!1,capsLock:l.capsLock??!1,numLock:l.numLock??!1,eventType:l.eventType},m;if(l.isKittyProtocol)if(l.isPrintable)m=l.text??l.name;else if(l.ctrl&&l.name.length===1)m=l.name;else m="";else if(l.ctrl)m=l.name??"";else m=l.sequence;if(!l.isKittyProtocol&&mL.includes(l.name))m="";if(m.startsWith("\x1B"))m=m.slice(1);if(m.length===1&&/[A-Z]/.test(m))u.shift=!0;if(m==="c"&&u.ctrl&&a)return;pa.discreteUpdates(()=>{e(m,u)})});Bb.useEffect(()=>{if(n.isActive===!1)return;return r.on("input",s),()=>{r.removeListener("input",s)}},[n.isActive,r,s])},rt;var kL=h(async()=>{wL();wb();await sb();Bb=re(Be(),1),rt=rpe});var CL;var _L=h(async()=>{wb();await sb();CL=re(Be(),1)});var EL,ope=()=>EL.useContext(gB),Qo;var QL=h(()=>{PI();EL=re(Be(),1),Qo=ope});var IL,spe=()=>IL.useContext(fB),bc;var FB=h(()=>{TI();IL=re(Be(),1),bc=spe});var cpe;var vL=h(()=>{YI();cpe=re(Be(),1)});var cv;var xL=h(()=>{yB();wb();cv=re(Be(),1)});var lpe;var DL=h(()=>{yB();lpe=re(Be(),1)});var dpe;var FL=h(()=>{yp();dpe=re(Be(),1)});var SB;var SL=h(()=>{WI();SB=re(Be(),1)});var kb;var $L=h(()=>{ZI();kb=re(Be(),1)});var NL;var jL=h(()=>{L0();FB();NL=re(Be(),1)});var $B;var LL=h(async()=>{FB();await Wg();$B=re(Be(),1)});var ML=()=>{};var nn=h(async()=>{BB();ev();oL();cL();AL();lL();QL();wb();FB();vL();xL();DL();FL();SL();$L();jL();ML();EB();await Kn([aL(),rL(),kL(),_L(),LL()])});var Bt="#28E99F",qL;var fc=h(()=>{qL=[" .##."," .######+"," -######## .+"," .######### .####+."," .######## ########. "," -######## ########. "," ########+. +######## ","#+. ########. .######### .#","####. ################ +###","######. ############ .######"," ######. ######## .####### "," ######. ### -#######"," ######+ .#######"," ##### ######"," ### ####"," # #"]});function id(e,n,t,a){function r(s){return s instanceof t?s:new t(function(A){A(s)})}return new(t||(t=Promise))(function(s,A){function l(b){try{m(a.next(b))}catch(f){A(f)}}function u(b){try{m(a.throw(b))}catch(f){A(f)}}function m(b){b.done?s(b.value):r(b.value).then(l,u)}m((a=a.apply(e,n||[])).next())})}function PL(e){var n=typeof Symbol==="function"&&Symbol.iterator,t=n&&e[n],a=0;if(t)return t.call(e);if(e&&typeof e.length==="number")return{next:function(){if(e&&a>=e.length)e=void 0;return{value:e&&e[a++],done:!e}}};throw TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function gs(e){return this instanceof gs?(this.v=e,this):new gs(e)}function UL(e,n,t){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var a=t.apply(e,n||[]),r,s=[];return r=Object.create((typeof AsyncIterator==="function"?AsyncIterator:Object).prototype),l("next"),l("throw"),l("return",A),r[Symbol.asyncIterator]=function(){return this},r;function A(B){return function(k){return Promise.resolve(k).then(B,f)}}function l(B,k){if(a[B]){if(r[B]=function(E){return new Promise(function(_,x){s.push([B,E,_,x])>1||u(B,E)})},k)r[B]=k(r[B])}}function u(B,k){try{m(a[B](k))}catch(E){y(s[0][3],E)}}function m(B){B.value instanceof gs?Promise.resolve(B.value.v).then(b,f):y(s[0][2],B)}function b(B){u("next",B)}function f(B){u("throw",B)}function y(B,k){if(B(k),s.shift(),s.length)u(s[0][0],s[0][1])}}function ype(e){var n,t;return n={},a("next"),a("throw",function(r){throw r}),a("return"),n[Symbol.iterator]=function(){return this},n;function a(r,s){n[r]=e[r]?function(A){return(t=!t)?{value:gs(e[r](A)),done:!1}:s?s(A):A}:s}}function wpe(e){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var n=e[Symbol.asyncIterator],t;return n?n.call(e):(e=typeof PL==="function"?PL(e):e[Symbol.iterator](),t={},a("next"),a("throw"),a("return"),t[Symbol.asyncIterator]=function(){return this},t);function a(s){t[s]=e[s]&&function(A){return new Promise(function(l,u){A=e[s](A),r(l,u,A.done,A.value)})}}function r(s,A,l,u){Promise.resolve(u).then(function(m){s({value:m,done:l})},A)}}function Bpe(e){return new oa(Promise.resolve(new Ur(e)))}function Cb(e){return new oa(Promise.resolve(new Tr(e)))}function hc(e){return new Ur(e)}function Io(e){return new Tr(e)}function _pe(e){let n=e().next();if(n instanceof Promise)return new oa(n.then((t)=>t.value));return n.value}var hpe,TL=(e,n,t=hpe)=>{let a=n.isOk()?{type:"Ok",value:n.value}:{type:"Err",value:n.error},r=t.withStackTrace?Error().stack:void 0;return{data:a,message:e,stack:r}},oa,zZe,HZe,PZe,OL=(e)=>{let n=hc([]);for(let t of e)if(t.isErr()){n=Io(t.error);break}else n.map((a)=>a.push(t.value));return n},kpe=(e)=>oa.fromSafePromise(Promise.all(e)).andThen(OL),YL=(e)=>{let n=hc([]);for(let t of e)if(t.isErr()&&n.isErr())n.error.push(t.error);else if(t.isErr()&&n.isOk())n=Io([t.error]);else if(t.isOk()&&n.isOk())n.value.push(t.value);return n},Cpe=(e)=>oa.fromSafePromise(Promise.all(e)).andThen(YL),vt=void 0,Ur,Tr,UZe,Hn,ie,Av,me,Nt,ma;var Vt=h(()=>{hpe={withStackTrace:!1};oa=class oa{constructor(e){this._promise=e}static fromSafePromise(e){let n=e.then((t)=>new Ur(t));return new oa(n)}static fromPromise(e,n){let t=e.then((a)=>new Ur(a)).catch((a)=>new Tr(n(a)));return new oa(t)}static fromThrowable(e,n){return(...t)=>{return new oa((()=>id(this,void 0,void 0,function*(){try{return new Ur(yield e(...t))}catch(a){return new Tr(n?n(a):a)}}))())}}static combine(e){return kpe(e)}static combineWithAllErrors(e){return Cpe(e)}map(e){return new oa(this._promise.then((n)=>id(this,void 0,void 0,function*(){if(n.isErr())return new Tr(n.error);return new Ur(yield e(n.value))})))}andThrough(e){return new oa(this._promise.then((n)=>id(this,void 0,void 0,function*(){if(n.isErr())return new Tr(n.error);let t=yield e(n.value);if(t.isErr())return new Tr(t.error);return new Ur(n.value)})))}andTee(e){return new oa(this._promise.then((n)=>id(this,void 0,void 0,function*(){if(n.isErr())return new Tr(n.error);try{yield e(n.value)}catch(t){}return new Ur(n.value)})))}orTee(e){return new oa(this._promise.then((n)=>id(this,void 0,void 0,function*(){if(n.isOk())return new Ur(n.value);try{yield e(n.error)}catch(t){}return new Tr(n.error)})))}mapErr(e){return new oa(this._promise.then((n)=>id(this,void 0,void 0,function*(){if(n.isOk())return new Ur(n.value);return new Tr(yield e(n.error))})))}andThen(e){return new oa(this._promise.then((n)=>{if(n.isErr())return new Tr(n.error);let t=e(n.value);return t instanceof oa?t._promise:t}))}orElse(e){return new oa(this._promise.then((n)=>id(this,void 0,void 0,function*(){if(n.isErr())return e(n.error);return new Ur(n.value)})))}match(e,n){return this._promise.then((t)=>t.match(e,n))}unwrapOr(e){return this._promise.then((n)=>n.unwrapOr(e))}safeUnwrap(){return UL(this,arguments,function*(){return yield gs(yield gs(yield*ype(wpe(yield gs(this._promise.then((n)=>n.safeUnwrap()))))))})}then(e,n){return this._promise.then(e,n)}[Symbol.asyncIterator](){return UL(this,arguments,function*(){let n=yield gs(this._promise);if(n.isErr())yield yield gs(Cb(n.error));return yield gs(n.value)})}};zZe=oa.fromPromise,HZe=oa.fromSafePromise,PZe=oa.fromThrowable;(function(e){function n(r,s){return(...A)=>{try{let l=r(...A);return hc(l)}catch(l){return Io(s?s(l):l)}}}e.fromThrowable=n;function t(r){return OL(r)}e.combine=t;function a(r){return YL(r)}e.combineWithAllErrors=a})(vt||(vt={}));Ur=class Ur{constructor(e){this.value=e}isOk(){return!0}isErr(){return!this.isOk()}map(e){return hc(e(this.value))}mapErr(e){return hc(this.value)}andThen(e){return e(this.value)}andThrough(e){return e(this.value).map((n)=>this.value)}andTee(e){try{e(this.value)}catch(n){}return hc(this.value)}orTee(e){return hc(this.value)}orElse(e){return hc(this.value)}asyncAndThen(e){return e(this.value)}asyncAndThrough(e){return e(this.value).map(()=>this.value)}asyncMap(e){return oa.fromSafePromise(e(this.value))}unwrapOr(e){return this.value}match(e,n){return e(this.value)}safeUnwrap(){let e=this.value;return function*(){return e}()}_unsafeUnwrap(e){return this.value}_unsafeUnwrapErr(e){throw TL("Called `_unsafeUnwrapErr` on an Ok",this,e)}*[Symbol.iterator](){return this.value}};Tr=class Tr{constructor(e){this.error=e}isOk(){return!1}isErr(){return!this.isOk()}map(e){return Io(this.error)}mapErr(e){return Io(e(this.error))}andThrough(e){return Io(this.error)}andTee(e){return Io(this.error)}orTee(e){try{e(this.error)}catch(n){}return Io(this.error)}andThen(e){return Io(this.error)}orElse(e){return e(this.error)}asyncAndThen(e){return Cb(this.error)}asyncAndThrough(e){return Cb(this.error)}asyncMap(e){return Cb(this.error)}unwrapOr(e){return e}match(e,n){return n(this.error)}safeUnwrap(){let e=this.error;return function*(){throw yield Io(e),Error("Do not use this generator out of `safeTry`")}()}_unsafeUnwrap(e){throw TL("Called `_unsafeUnwrap` on an Err",this,e)}_unsafeUnwrapErr(e){return this.error}*[Symbol.iterator](){let e=this;return yield e,e}};UZe=vt.fromThrowable;Hn=oa,ie=Io,Av=Cb,me=hc,Nt=Bpe,ma=_pe});var jn,lv,xe,bs=(e)=>{switch(typeof e){case"undefined":return xe.undefined;case"string":return xe.string;case"number":return Number.isNaN(e)?xe.nan:xe.number;case"boolean":return xe.boolean;case"function":return xe.function;case"bigint":return xe.bigint;case"symbol":return xe.symbol;case"object":if(Array.isArray(e))return xe.array;if(e===null)return xe.null;if(e.then&&typeof e.then==="function"&&e.catch&&typeof e.catch==="function")return xe.promise;if(typeof Map<"u"&&e instanceof Map)return xe.map;if(typeof Set<"u"&&e instanceof Set)return xe.set;if(typeof Date<"u"&&e instanceof Date)return xe.date;return xe.object;default:return xe.unknown}};var _b=h(()=>{(function(e){e.assertEqual=(r)=>{};function n(r){}e.assertIs=n;function t(r){throw Error()}e.assertNever=t,e.arrayToEnum=(r)=>{let s={};for(let A of r)s[A]=A;return s},e.getValidEnumValues=(r)=>{let s=e.objectKeys(r).filter((l)=>typeof r[r[l]]!=="number"),A={};for(let l of s)A[l]=r[l];return e.objectValues(A)},e.objectValues=(r)=>{return e.objectKeys(r).map(function(s){return r[s]})},e.objectKeys=typeof Object.keys==="function"?(r)=>Object.keys(r):(r)=>{let s=[];for(let A in r)if(Object.prototype.hasOwnProperty.call(r,A))s.push(A);return s},e.find=(r,s)=>{for(let A of r)if(s(A))return A;return},e.isInteger=typeof Number.isInteger==="function"?(r)=>Number.isInteger(r):(r)=>typeof r==="number"&&Number.isFinite(r)&&Math.floor(r)===r;function a(r,s=" | "){return r.map((A)=>typeof A==="string"?`'${A}'`:A).join(s)}e.joinValues=a,e.jsonStringifyReplacer=(r,s)=>{if(typeof s==="bigint")return s.toString();return s}})(jn||(jn={}));(function(e){e.mergeShapes=(n,t)=>{return{...n,...t}}})(lv||(lv={}));xe=jn.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"])});var Ce,Epe=(e)=>{return JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:")},er;var NB=h(()=>{_b();Ce=jn.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"]);er=class er extends Error{get errors(){return this.issues}constructor(e){super();this.issues=[],this.addIssue=(t)=>{this.issues=[...this.issues,t]},this.addIssues=(t=[])=>{this.issues=[...this.issues,...t]};let n=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,n);else this.__proto__=n;this.name="ZodError",this.issues=e}format(e){let n=e||function(r){return r.message},t={_errors:[]},a=(r)=>{for(let s of r.issues)if(s.code==="invalid_union")s.unionErrors.map(a);else if(s.code==="invalid_return_type")a(s.returnTypeError);else if(s.code==="invalid_arguments")a(s.argumentsError);else if(s.path.length===0)t._errors.push(n(s));else{let A=t,l=0;while(l<s.path.length){let u=s.path[l];if(l!==s.path.length-1)A[u]=A[u]||{_errors:[]};else A[u]=A[u]||{_errors:[]},A[u]._errors.push(n(s));A=A[u],l++}}};return a(this),t}static assert(e){if(!(e instanceof er))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,jn.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=(n)=>n.message){let n={},t=[];for(let a of this.issues)if(a.path.length>0){let r=a.path[0];n[r]=n[r]||[],n[r].push(e(a))}else t.push(e(a));return{formErrors:t,fieldErrors:n}}get formErrors(){return this.flatten()}};er.create=(e)=>{return new er(e)}});var Qpe=(e,n)=>{let t;switch(e.code){case Ce.invalid_type:if(e.received===xe.undefined)t="Required";else t=`Expected ${e.expected}, received ${e.received}`;break;case Ce.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(e.expected,jn.jsonStringifyReplacer)}`;break;case Ce.unrecognized_keys:t=`Unrecognized key(s) in object: ${jn.joinValues(e.keys,", ")}`;break;case Ce.invalid_union:t="Invalid input";break;case Ce.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${jn.joinValues(e.options)}`;break;case Ce.invalid_enum_value:t=`Invalid enum value. Expected ${jn.joinValues(e.options)}, received '${e.received}'`;break;case Ce.invalid_arguments:t="Invalid function arguments";break;case Ce.invalid_return_type:t="Invalid function return type";break;case Ce.invalid_date:t="Invalid date";break;case Ce.invalid_string:if(typeof e.validation==="object")if("includes"in e.validation){if(t=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==="number")t=`${t} at one or more positions greater than or equal to ${e.validation.position}`}else if("startsWith"in e.validation)t=`Invalid input: must start with "${e.validation.startsWith}"`;else if("endsWith"in e.validation)t=`Invalid input: must end with "${e.validation.endsWith}"`;else jn.assertNever(e.validation);else if(e.validation!=="regex")t=`Invalid ${e.validation}`;else t="Invalid";break;case Ce.too_small:if(e.type==="array")t=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`;else if(e.type==="string")t=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`;else if(e.type==="number")t=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`;else if(e.type==="bigint")t=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`;else if(e.type==="date")t=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`;else t="Invalid input";break;case Ce.too_big:if(e.type==="array")t=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`;else if(e.type==="string")t=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`;else if(e.type==="number")t=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`;else if(e.type==="bigint")t=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`;else if(e.type==="date")t=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`;else t="Invalid input";break;case Ce.custom:t="Invalid input";break;case Ce.invalid_intersection_types:t="Intersection results could not be merged";break;case Ce.not_multiple_of:t=`Number must be a multiple of ${e.multipleOf}`;break;case Ce.not_finite:t="Number must be finite";break;default:t=n.defaultError,jn.assertNever(e)}return{message:t}},yc;var dv=h(()=>{NB();_b();yc=Qpe});function Ipe(e){KL=e}function wp(){return KL}var KL;var jB=h(()=>{dv();KL=yc});function $e(e,n){let t=wp(),a=Eb({issueData:n,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,t,t===yc?void 0:yc].filter((r)=>!!r)});e.common.issues.push(a)}class Ai{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray(e,n){let t=[];for(let a of n){if(a.status==="aborted")return tn;if(a.status==="dirty")e.dirty();t.push(a.value)}return{status:e.value,value:t}}static async mergeObjectAsync(e,n){let t=[];for(let a of n){let r=await a.key,s=await a.value;t.push({key:r,value:s})}return Ai.mergeObjectSync(e,t)}static mergeObjectSync(e,n){let t={};for(let a of n){let{key:r,value:s}=a;if(r.status==="aborted")return tn;if(s.status==="aborted")return tn;if(r.status==="dirty")e.dirty();if(s.status==="dirty")e.dirty();if(r.value!=="__proto__"&&(typeof s.value<"u"||a.alwaysSet))t[r.value]=s.value}return{status:e.value,value:t}}}var Eb=(e)=>{let{data:n,path:t,errorMaps:a,issueData:r}=e,s=[...t,...r.path||[]],A={...r,path:s};if(r.message!==void 0)return{...r,path:s,message:r.message};let l="",u=a.filter((m)=>!!m).slice().reverse();for(let m of u)l=m(A,{data:n,defaultError:l}).message;return{...r,path:s,message:l}},vpe,tn,rd=(e)=>({status:"dirty",value:e}),Qi=(e)=>({status:"valid",value:e}),LB=(e)=>e.status==="aborted",MB=(e)=>e.status==="dirty",jA=(e)=>e.status==="valid",Bp=(e)=>typeof Promise<"u"&&e instanceof Promise;var uv=h(()=>{jB();dv();vpe=[];tn=Object.freeze({status:"aborted"})});var ZL=()=>{};var Te;var JL=h(()=>{(function(e){e.errToObj=(n)=>typeof n==="string"?{message:n}:n||{},e.toString=(n)=>typeof n==="string"?n:n?.message})(Te||(Te={}))});class Fo{constructor(e,n,t,a){this._cachedPath=[],this.parent=e,this.data=n,this._path=t,this._key=a}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}function _n(e){if(!e)return{};let{errorMap:n,invalid_type_error:t,required_error:a,description:r}=e;if(n&&(t||a))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(n)return{errorMap:n,description:r};return{errorMap:(A,l)=>{let{message:u}=e;if(A.code==="invalid_enum_value")return{message:u??l.defaultError};if(typeof l.data>"u")return{message:u??a??l.defaultError};if(A.code!=="invalid_type")return{message:l.defaultError};return{message:u??t??l.defaultError}},description:r}}class vn{get description(){return this._def.description}_getType(e){return bs(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:bs(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ai,ctx:{common:e.parent.common,data:e.data,parsedType:bs(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(Bp(n))throw Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let t=this.safeParse(e,n);if(t.success)return t.data;throw t.error}safeParse(e,n){let t={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:bs(e)},a=this._parseSync({data:e,path:t.path,parent:t});return WL(t,a)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:bs(e)};if(!this["~standard"].async)try{let t=this._parseSync({data:e,path:[],parent:n});return jA(t)?{value:t.value}:{issues:n.common.issues}}catch(t){if(t?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then((t)=>jA(t)?{value:t.value}:{issues:n.common.issues})}async parseAsync(e,n){let t=await this.safeParseAsync(e,n);if(t.success)return t.data;throw t.error}async safeParseAsync(e,n){let t={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:bs(e)},a=this._parse({data:e,path:t.path,parent:t}),r=await(Bp(a)?a:Promise.resolve(a));return WL(t,r)}refine(e,n){let t=(a)=>{if(typeof n==="string"||typeof n>"u")return{message:n};else if(typeof n==="function")return n(a);else return n};return this._refinement((a,r)=>{let s=e(a),A=()=>r.addIssue({code:Ce.custom,...t(a)});if(typeof Promise<"u"&&s instanceof Promise)return s.then((l)=>{if(!l)return A(),!1;else return!0});if(!s)return A(),!1;else return!0})}refinement(e,n){return this._refinement((t,a)=>{if(!e(t))return a.addIssue(typeof n==="function"?n(t,a):n),!1;else return!0})}_refinement(e){return new So({schema:this,typeName:on.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:(n)=>this["~validate"](n)}}optional(){return Do.create(this,this._def)}nullable(){return Bc.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return xo.create(this)}promise(){return Ad.create(this,this._def)}or(e){return Ip.create([this,e],this._def)}and(e){return vp.create(this,e,this._def)}transform(e){return new So({..._n(this._def),schema:this,typeName:on.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e==="function"?e:()=>e;return new Sp({..._n(this._def),innerType:this,defaultValue:n,typeName:on.ZodDefault})}brand(){return new qB({typeName:on.ZodBranded,type:this,..._n(this._def)})}catch(e){let n=typeof e==="function"?e:()=>e;return new $p({..._n(this._def),innerType:this,catchValue:n,typeName:on.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return Fb.create(this,e)}readonly(){return Np.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}function eM(e){let n="[0-5]\\d";if(e.precision)n=`${n}\\.\\d{${e.precision}}`;else if(e.precision==null)n=`${n}(\\.\\d+)?`;let t=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${n})${t}`}function Tpe(e){return new RegExp(`^${eM(e)}$`)}function nM(e){let n=`${XL}T${eM(e)}`,t=[];if(t.push(e.local?"Z?":"Z"),e.offset)t.push("([+-]\\d{2}:?\\d{2})");return n=`${n}(${t.join("|")})`,new RegExp(`^${n}$`)}function Ope(e,n){if((n==="v4"||!n)&&Gpe.test(e))return!0;if((n==="v6"||!n)&&Rpe.test(e))return!0;return!1}function Ype(e,n){if(!Npe.test(e))return!1;try{let[t]=e.split(".");if(!t)return!1;let a=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),r=JSON.parse(atob(a));if(typeof r!=="object"||r===null)return!1;if("typ"in r&&r?.typ!=="JWT")return!1;if(!r.alg)return!1;if(n&&r.alg!==n)return!1;return!0}catch{return!1}}function Kpe(e,n){if((n==="v4"||!n)&&qpe.test(e))return!0;if((n==="v6"||!n)&&zpe.test(e))return!0;return!1}function Zpe(e,n){let t=(e.toString().split(".")[1]||"").length,a=(n.toString().split(".")[1]||"").length,r=t>a?t:a,s=Number.parseInt(e.toFixed(r).replace(".","")),A=Number.parseInt(n.toFixed(r).replace(".",""));return s%A/10**r}function kp(e){if(e instanceof Xt){let n={};for(let t in e.shape){let a=e.shape[t];n[t]=Do.create(kp(a))}return new Xt({...e._def,shape:()=>n})}else if(e instanceof xo)return new xo({...e._def,type:kp(e.element)});else if(e instanceof Do)return Do.create(kp(e.unwrap()));else if(e instanceof Bc)return Bc.create(kp(e.unwrap()));else if(e instanceof hs)return hs.create(e.items.map((n)=>kp(n)));else return e}function mv(e,n){let t=bs(e),a=bs(n);if(e===n)return{valid:!0,data:e};else if(t===xe.object&&a===xe.object){let r=jn.objectKeys(n),s=jn.objectKeys(e).filter((l)=>r.indexOf(l)!==-1),A={...e,...n};for(let l of s){let u=mv(e[l],n[l]);if(!u.valid)return{valid:!1};A[l]=u.data}return{valid:!0,data:A}}else if(t===xe.array&&a===xe.array){if(e.length!==n.length)return{valid:!1};let r=[];for(let s=0;s<e.length;s++){let A=e[s],l=n[s],u=mv(A,l);if(!u.valid)return{valid:!1};r.push(u.data)}return{valid:!0,data:r}}else if(t===xe.date&&a===xe.date&&+e===+n)return{valid:!0,data:e};else return{valid:!1}}function tM(e,n){return new qA({values:e,typeName:on.ZodEnum,..._n(n)})}function VL(e,n){let t=typeof e==="function"?e(n):typeof e==="string"?{message:e}:e;return typeof t==="string"?{message:t}:t}function aM(e,n={},t){if(e)return sd.create().superRefine((a,r)=>{let s=e(a);if(s instanceof Promise)return s.then((A)=>{if(!A){let l=VL(n,a),u=l.fatal??t??!0;r.addIssue({code:"custom",...l,fatal:u})}});if(!s){let A=VL(n,a),l=A.fatal??t??!0;r.addIssue({code:"custom",...A,fatal:l})}return});return sd.create()}var WL=(e,n)=>{if(jA(n))return{success:!0,data:n.value};else{if(!e.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new er(e.common.issues);return this._error=t,this._error}}}},xpe,Dpe,Fpe,Spe,$pe,Npe,jpe,Lpe,Mpe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",pv,Gpe,qpe,Rpe,zpe,Hpe,Ppe,XL="((\\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])))",Upe,vo,MA,GA,_p,od,Qb,Ep,Qp,sd,LA,fs,Ib,xo,Xt,Ip,wc=(e)=>{if(e instanceof xp)return wc(e.schema);else if(e instanceof So)return wc(e.innerType());else if(e instanceof Dp)return[e.value];else if(e instanceof qA)return e.options;else if(e instanceof Fp)return jn.objectValues(e.enum);else if(e instanceof Sp)return wc(e._def.innerType);else if(e instanceof Ep)return[void 0];else if(e instanceof Qp)return[null];else if(e instanceof Do)return[void 0,...wc(e.unwrap())];else if(e instanceof Bc)return[null,...wc(e.unwrap())];else if(e instanceof qB)return wc(e.unwrap());else if(e instanceof Np)return wc(e.unwrap());else if(e instanceof $p)return wc(e._def.innerType);else return[]},GB,vp,hs,vb,xb,cd,Cp,xp,Dp,qA,Fp,Ad,So,Do,Bc,Sp,$p,Db,Jpe,qB,Fb,Np,Wpe,on,Vpe=(e,n={message:`Input not instance of ${e.name}`})=>aM((t)=>t instanceof e,n),iM,rM,Xpe,eme,oM,nme,tme,ame,ime,rme,ome,sme,cme,Ame,lme,dme,ume,pme,mme,gme,bme,fme,hme,yme,wme,Bme,kme,Cme,_me,Eme,Qme,Ime,vme,xme,Dme=()=>iM().optional(),Fme=()=>rM().optional(),Sme=()=>oM().optional(),$me,Nme;var sM=h(()=>{NB();jB();JL();uv();_b();xpe=/^c[^\s-]{8,}$/i,Dpe=/^[0-9a-z]+$/,Fpe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Spe=/^[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,$pe=/^[a-z0-9_-]{21}$/i,Npe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,jpe=/^[-+]?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)?)??$/,Lpe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Gpe=/^(?:(?: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])$/,qpe=/^(?:(?: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])$/,Rpe=/^(([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]))$/,zpe=/^(([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])$/,Hpe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ppe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Upe=new RegExp(`^${XL}$`);vo=class vo extends vn{_parse(e){if(this._def.coerce)e.data=String(e.data);if(this._getType(e)!==xe.string){let r=this._getOrReturnCtx(e);return $e(r,{code:Ce.invalid_type,expected:xe.string,received:r.parsedType}),tn}let t=new Ai,a=void 0;for(let r of this._def.checks)if(r.kind==="min"){if(e.data.length<r.value)a=this._getOrReturnCtx(e,a),$e(a,{code:Ce.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty()}else if(r.kind==="max"){if(e.data.length>r.value)a=this._getOrReturnCtx(e,a),$e(a,{code:Ce.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty()}else if(r.kind==="length"){let s=e.data.length>r.value,A=e.data.length<r.value;if(s||A){if(a=this._getOrReturnCtx(e,a),s)$e(a,{code:Ce.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message});else if(A)$e(a,{code:Ce.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message});t.dirty()}}else if(r.kind==="email"){if(!Lpe.test(e.data))a=this._getOrReturnCtx(e,a),$e(a,{validation:"email",code:Ce.invalid_string,message:r.message}),t.dirty()}else if(r.kind==="emoji"){if(!pv)pv=new RegExp(Mpe,"u");if(!pv.test(e.data))a=this._getOrReturnCtx(e,a),$e(a,{validation:"emoji",code:Ce.invalid_string,message:r.message}),t.dirty()}else if(r.kind==="uuid"){if(!Spe.test(e.data))a=this._getOrReturnCtx(e,a),$e(a,{validation:"uuid",code:Ce.invalid_string,message:r.message}),t.dirty()}else if(r.kind==="nanoid"){if(!$pe.test(e.data))a=this._getOrReturnCtx(e,a),$e(a,{validation:"nanoid",code:Ce.invalid_string,message:r.message}),t.dirty()}else if(r.kind==="cuid"){if(!xpe.test(e.data))a=this._getOrReturnCtx(e,a),$e(a,{validation:"cuid",code:Ce.invalid_string,message:r.message}),t.dirty()}else if(r.kind==="cuid2"){if(!Dpe.test(e.data))a=this._getOrReturnCtx(e,a),$e(a,{validation:"cuid2",code:Ce.invalid_string,message:r.message}),t.dirty()}else if(r.kind==="ulid"){if(!Fpe.test(e.data))a=this._getOrReturnCtx(e,a),$e(a,{validation:"ulid",code:Ce.invalid_string,message:r.message}),t.dirty()}else if(r.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),$e(a,{validation:"url",code:Ce.invalid_string,message:r.message}),t.dirty()}else if(r.kind==="regex"){if(r.regex.lastIndex=0,!r.regex.test(e.data))a=this._getOrReturnCtx(e,a),$e(a,{validation:"regex",code:Ce.invalid_string,message:r.message}),t.dirty()}else if(r.kind==="trim")e.data=e.data.trim();else if(r.kind==="includes"){if(!e.data.includes(r.value,r.position))a=this._getOrReturnCtx(e,a),$e(a,{code:Ce.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()}else if(r.kind==="toLowerCase")e.data=e.data.toLowerCase();else if(r.kind==="toUpperCase")e.data=e.data.toUpperCase();else if(r.kind==="startsWith"){if(!e.data.startsWith(r.value))a=this._getOrReturnCtx(e,a),$e(a,{code:Ce.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()}else if(r.kind==="endsWith"){if(!e.data.endsWith(r.value))a=this._getOrReturnCtx(e,a),$e(a,{code:Ce.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()}else if(r.kind==="datetime"){if(!nM(r).test(e.data))a=this._getOrReturnCtx(e,a),$e(a,{code:Ce.invalid_string,validation:"datetime",message:r.message}),t.dirty()}else if(r.kind==="date"){if(!Upe.test(e.data))a=this._getOrReturnCtx(e,a),$e(a,{code:Ce.invalid_string,validation:"date",message:r.message}),t.dirty()}else if(r.kind==="time"){if(!Tpe(r).test(e.data))a=this._getOrReturnCtx(e,a),$e(a,{code:Ce.invalid_string,validation:"time",message:r.message}),t.dirty()}else if(r.kind==="duration"){if(!jpe.test(e.data))a=this._getOrReturnCtx(e,a),$e(a,{validation:"duration",code:Ce.invalid_string,message:r.message}),t.dirty()}else if(r.kind==="ip"){if(!Ope(e.data,r.version))a=this._getOrReturnCtx(e,a),$e(a,{validation:"ip",code:Ce.invalid_string,message:r.message}),t.dirty()}else if(r.kind==="jwt"){if(!Ype(e.data,r.alg))a=this._getOrReturnCtx(e,a),$e(a,{validation:"jwt",code:Ce.invalid_string,message:r.message}),t.dirty()}else if(r.kind==="cidr"){if(!Kpe(e.data,r.version))a=this._getOrReturnCtx(e,a),$e(a,{validation:"cidr",code:Ce.invalid_string,message:r.message}),t.dirty()}else if(r.kind==="base64"){if(!Hpe.test(e.data))a=this._getOrReturnCtx(e,a),$e(a,{validation:"base64",code:Ce.invalid_string,message:r.message}),t.dirty()}else if(r.kind==="base64url"){if(!Ppe.test(e.data))a=this._getOrReturnCtx(e,a),$e(a,{validation:"base64url",code:Ce.invalid_string,message:r.message}),t.dirty()}else jn.assertNever(r);return{status:t.value,value:e.data}}_regex(e,n,t){return this.refinement((a)=>e.test(a),{validation:n,code:Ce.invalid_string,...Te.errToObj(t)})}_addCheck(e){return new vo({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Te.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Te.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Te.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Te.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Te.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Te.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Te.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Te.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Te.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Te.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Te.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Te.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Te.errToObj(e)})}datetime(e){if(typeof e==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e});return this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...Te.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){if(typeof e==="string")return this._addCheck({kind:"time",precision:null,message:e});return this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...Te.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...Te.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...Te.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...Te.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...Te.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...Te.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...Te.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...Te.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...Te.errToObj(n)})}nonempty(e){return this.min(1,Te.errToObj(e))}trim(){return new vo({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new vo({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new vo({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((e)=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find((e)=>e.kind==="date")}get isTime(){return!!this._def.checks.find((e)=>e.kind==="time")}get isDuration(){return!!this._def.checks.find((e)=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find((e)=>e.kind==="email")}get isURL(){return!!this._def.checks.find((e)=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find((e)=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find((e)=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find((e)=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find((e)=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find((e)=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find((e)=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find((e)=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find((e)=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find((e)=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find((e)=>e.kind==="base64url")}get minLength(){let e=null;for(let n of this._def.checks)if(n.kind==="min"){if(e===null||n.value>e)e=n.value}return e}get maxLength(){let e=null;for(let n of this._def.checks)if(n.kind==="max"){if(e===null||n.value<e)e=n.value}return e}};vo.create=(e)=>{return new vo({checks:[],typeName:on.ZodString,coerce:e?.coerce??!1,..._n(e)})};MA=class MA extends vn{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);if(this._getType(e)!==xe.number){let r=this._getOrReturnCtx(e);return $e(r,{code:Ce.invalid_type,expected:xe.number,received:r.parsedType}),tn}let t=void 0,a=new Ai;for(let r of this._def.checks)if(r.kind==="int"){if(!jn.isInteger(e.data))t=this._getOrReturnCtx(e,t),$e(t,{code:Ce.invalid_type,expected:"integer",received:"float",message:r.message}),a.dirty()}else if(r.kind==="min"){if(r.inclusive?e.data<r.value:e.data<=r.value)t=this._getOrReturnCtx(e,t),$e(t,{code:Ce.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()}else if(r.kind==="max"){if(r.inclusive?e.data>r.value:e.data>=r.value)t=this._getOrReturnCtx(e,t),$e(t,{code:Ce.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()}else if(r.kind==="multipleOf"){if(Zpe(e.data,r.value)!==0)t=this._getOrReturnCtx(e,t),$e(t,{code:Ce.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()}else if(r.kind==="finite"){if(!Number.isFinite(e.data))t=this._getOrReturnCtx(e,t),$e(t,{code:Ce.not_finite,message:r.message}),a.dirty()}else jn.assertNever(r);return{status:a.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,Te.toString(n))}gt(e,n){return this.setLimit("min",e,!1,Te.toString(n))}lte(e,n){return this.setLimit("max",e,!0,Te.toString(n))}lt(e,n){return this.setLimit("max",e,!1,Te.toString(n))}setLimit(e,n,t,a){return new MA({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:t,message:Te.toString(a)}]})}_addCheck(e){return new MA({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Te.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Te.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Te.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Te.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Te.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:Te.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:Te.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Te.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Te.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)if(n.kind==="min"){if(e===null||n.value>e)e=n.value}return e}get maxValue(){let e=null;for(let n of this._def.checks)if(n.kind==="max"){if(e===null||n.value<e)e=n.value}return e}get isInt(){return!!this._def.checks.find((e)=>e.kind==="int"||e.kind==="multipleOf"&&jn.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let t of this._def.checks)if(t.kind==="finite"||t.kind==="int"||t.kind==="multipleOf")return!0;else if(t.kind==="min"){if(n===null||t.value>n)n=t.value}else if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return Number.isFinite(n)&&Number.isFinite(e)}};MA.create=(e)=>{return new MA({checks:[],typeName:on.ZodNumber,coerce:e?.coerce||!1,..._n(e)})};GA=class GA extends vn{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)!==xe.bigint)return this._getInvalidInput(e);let t=void 0,a=new Ai;for(let r of this._def.checks)if(r.kind==="min"){if(r.inclusive?e.data<r.value:e.data<=r.value)t=this._getOrReturnCtx(e,t),$e(t,{code:Ce.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()}else if(r.kind==="max"){if(r.inclusive?e.data>r.value:e.data>=r.value)t=this._getOrReturnCtx(e,t),$e(t,{code:Ce.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()}else if(r.kind==="multipleOf"){if(e.data%r.value!==BigInt(0))t=this._getOrReturnCtx(e,t),$e(t,{code:Ce.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()}else jn.assertNever(r);return{status:a.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return $e(n,{code:Ce.invalid_type,expected:xe.bigint,received:n.parsedType}),tn}gte(e,n){return this.setLimit("min",e,!0,Te.toString(n))}gt(e,n){return this.setLimit("min",e,!1,Te.toString(n))}lte(e,n){return this.setLimit("max",e,!0,Te.toString(n))}lt(e,n){return this.setLimit("max",e,!1,Te.toString(n))}setLimit(e,n,t,a){return new GA({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:t,message:Te.toString(a)}]})}_addCheck(e){return new GA({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Te.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Te.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Te.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Te.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:Te.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)if(n.kind==="min"){if(e===null||n.value>e)e=n.value}return e}get maxValue(){let e=null;for(let n of this._def.checks)if(n.kind==="max"){if(e===null||n.value<e)e=n.value}return e}};GA.create=(e)=>{return new GA({checks:[],typeName:on.ZodBigInt,coerce:e?.coerce??!1,..._n(e)})};_p=class _p extends vn{_parse(e){if(this._def.coerce)e.data=Boolean(e.data);if(this._getType(e)!==xe.boolean){let t=this._getOrReturnCtx(e);return $e(t,{code:Ce.invalid_type,expected:xe.boolean,received:t.parsedType}),tn}return Qi(e.data)}};_p.create=(e)=>{return new _p({typeName:on.ZodBoolean,coerce:e?.coerce||!1,..._n(e)})};od=class od extends vn{_parse(e){if(this._def.coerce)e.data=new Date(e.data);if(this._getType(e)!==xe.date){let r=this._getOrReturnCtx(e);return $e(r,{code:Ce.invalid_type,expected:xe.date,received:r.parsedType}),tn}if(Number.isNaN(e.data.getTime())){let r=this._getOrReturnCtx(e);return $e(r,{code:Ce.invalid_date}),tn}let t=new Ai,a=void 0;for(let r of this._def.checks)if(r.kind==="min"){if(e.data.getTime()<r.value)a=this._getOrReturnCtx(e,a),$e(a,{code:Ce.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),t.dirty()}else if(r.kind==="max"){if(e.data.getTime()>r.value)a=this._getOrReturnCtx(e,a),$e(a,{code:Ce.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),t.dirty()}else jn.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new od({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:Te.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:Te.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)if(n.kind==="min"){if(e===null||n.value>e)e=n.value}return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)if(n.kind==="max"){if(e===null||n.value<e)e=n.value}return e!=null?new Date(e):null}};od.create=(e)=>{return new od({checks:[],coerce:e?.coerce||!1,typeName:on.ZodDate,..._n(e)})};Qb=class Qb extends vn{_parse(e){if(this._getType(e)!==xe.symbol){let t=this._getOrReturnCtx(e);return $e(t,{code:Ce.invalid_type,expected:xe.symbol,received:t.parsedType}),tn}return Qi(e.data)}};Qb.create=(e)=>{return new Qb({typeName:on.ZodSymbol,..._n(e)})};Ep=class Ep extends vn{_parse(e){if(this._getType(e)!==xe.undefined){let t=this._getOrReturnCtx(e);return $e(t,{code:Ce.invalid_type,expected:xe.undefined,received:t.parsedType}),tn}return Qi(e.data)}};Ep.create=(e)=>{return new Ep({typeName:on.ZodUndefined,..._n(e)})};Qp=class Qp extends vn{_parse(e){if(this._getType(e)!==xe.null){let t=this._getOrReturnCtx(e);return $e(t,{code:Ce.invalid_type,expected:xe.null,received:t.parsedType}),tn}return Qi(e.data)}};Qp.create=(e)=>{return new Qp({typeName:on.ZodNull,..._n(e)})};sd=class sd extends vn{constructor(){super(...arguments);this._any=!0}_parse(e){return Qi(e.data)}};sd.create=(e)=>{return new sd({typeName:on.ZodAny,..._n(e)})};LA=class LA extends vn{constructor(){super(...arguments);this._unknown=!0}_parse(e){return Qi(e.data)}};LA.create=(e)=>{return new LA({typeName:on.ZodUnknown,..._n(e)})};fs=class fs extends vn{_parse(e){let n=this._getOrReturnCtx(e);return $e(n,{code:Ce.invalid_type,expected:xe.never,received:n.parsedType}),tn}};fs.create=(e)=>{return new fs({typeName:on.ZodNever,..._n(e)})};Ib=class Ib extends vn{_parse(e){if(this._getType(e)!==xe.undefined){let t=this._getOrReturnCtx(e);return $e(t,{code:Ce.invalid_type,expected:xe.void,received:t.parsedType}),tn}return Qi(e.data)}};Ib.create=(e)=>{return new Ib({typeName:on.ZodVoid,..._n(e)})};xo=class xo extends vn{_parse(e){let{ctx:n,status:t}=this._processInputParams(e),a=this._def;if(n.parsedType!==xe.array)return $e(n,{code:Ce.invalid_type,expected:xe.array,received:n.parsedType}),tn;if(a.exactLength!==null){let s=n.data.length>a.exactLength.value,A=n.data.length<a.exactLength.value;if(s||A)$e(n,{code:s?Ce.too_big:Ce.too_small,minimum:A?a.exactLength.value:void 0,maximum:s?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),t.dirty()}if(a.minLength!==null){if(n.data.length<a.minLength.value)$e(n,{code:Ce.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),t.dirty()}if(a.maxLength!==null){if(n.data.length>a.maxLength.value)$e(n,{code:Ce.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),t.dirty()}if(n.common.async)return Promise.all([...n.data].map((s,A)=>{return a.type._parseAsync(new Fo(n,s,n.path,A))})).then((s)=>{return Ai.mergeArray(t,s)});let r=[...n.data].map((s,A)=>{return a.type._parseSync(new Fo(n,s,n.path,A))});return Ai.mergeArray(t,r)}get element(){return this._def.type}min(e,n){return new xo({...this._def,minLength:{value:e,message:Te.toString(n)}})}max(e,n){return new xo({...this._def,maxLength:{value:e,message:Te.toString(n)}})}length(e,n){return new xo({...this._def,exactLength:{value:e,message:Te.toString(n)}})}nonempty(e){return this.min(1,e)}};xo.create=(e,n)=>{return new xo({type:e,minLength:null,maxLength:null,exactLength:null,typeName:on.ZodArray,..._n(n)})};Xt=class Xt extends vn{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),n=jn.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==xe.object){let u=this._getOrReturnCtx(e);return $e(u,{code:Ce.invalid_type,expected:xe.object,received:u.parsedType}),tn}let{status:t,ctx:a}=this._processInputParams(e),{shape:r,keys:s}=this._getCached(),A=[];if(!(this._def.catchall instanceof fs&&this._def.unknownKeys==="strip")){for(let u in a.data)if(!s.includes(u))A.push(u)}let l=[];for(let u of s){let m=r[u],b=a.data[u];l.push({key:{status:"valid",value:u},value:m._parse(new Fo(a,b,a.path,u)),alwaysSet:u in a.data})}if(this._def.catchall instanceof fs){let u=this._def.unknownKeys;if(u==="passthrough")for(let m of A)l.push({key:{status:"valid",value:m},value:{status:"valid",value:a.data[m]}});else if(u==="strict"){if(A.length>0)$e(a,{code:Ce.unrecognized_keys,keys:A}),t.dirty()}else if(u==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let m of A){let b=a.data[m];l.push({key:{status:"valid",value:m},value:u._parse(new Fo(a,b,a.path,m)),alwaysSet:m in a.data})}}if(a.common.async)return Promise.resolve().then(async()=>{let u=[];for(let m of l){let b=await m.key,f=await m.value;u.push({key:b,value:f,alwaysSet:m.alwaysSet})}return u}).then((u)=>{return Ai.mergeObjectSync(t,u)});else return Ai.mergeObjectSync(t,l)}get shape(){return this._def.shape()}strict(e){return Te.errToObj,new Xt({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,t)=>{let a=this._def.errorMap?.(n,t).message??t.defaultError;if(n.code==="unrecognized_keys")return{message:Te.errToObj(e).message??a};return{message:a}}}:{}})}strip(){return new Xt({...this._def,unknownKeys:"strip"})}passthrough(){return new Xt({...this._def,unknownKeys:"passthrough"})}extend(e){return new Xt({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Xt({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:on.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new Xt({...this._def,catchall:e})}pick(e){let n={};for(let t of jn.objectKeys(e))if(e[t]&&this.shape[t])n[t]=this.shape[t];return new Xt({...this._def,shape:()=>n})}omit(e){let n={};for(let t of jn.objectKeys(this.shape))if(!e[t])n[t]=this.shape[t];return new Xt({...this._def,shape:()=>n})}deepPartial(){return kp(this)}partial(e){let n={};for(let t of jn.objectKeys(this.shape)){let a=this.shape[t];if(e&&!e[t])n[t]=a;else n[t]=a.optional()}return new Xt({...this._def,shape:()=>n})}required(e){let n={};for(let t of jn.objectKeys(this.shape))if(e&&!e[t])n[t]=this.shape[t];else{let r=this.shape[t];while(r instanceof Do)r=r._def.innerType;n[t]=r}return new Xt({...this._def,shape:()=>n})}keyof(){return tM(jn.objectKeys(this.shape))}};Xt.create=(e,n)=>{return new Xt({shape:()=>e,unknownKeys:"strip",catchall:fs.create(),typeName:on.ZodObject,..._n(n)})};Xt.strictCreate=(e,n)=>{return new Xt({shape:()=>e,unknownKeys:"strict",catchall:fs.create(),typeName:on.ZodObject,..._n(n)})};Xt.lazycreate=(e,n)=>{return new Xt({shape:e,unknownKeys:"strip",catchall:fs.create(),typeName:on.ZodObject,..._n(n)})};Ip=class Ip extends vn{_parse(e){let{ctx:n}=this._processInputParams(e),t=this._def.options;function a(r){for(let A of r)if(A.result.status==="valid")return A.result;for(let A of r)if(A.result.status==="dirty")return n.common.issues.push(...A.ctx.common.issues),A.result;let s=r.map((A)=>new er(A.ctx.common.issues));return $e(n,{code:Ce.invalid_union,unionErrors:s}),tn}if(n.common.async)return Promise.all(t.map(async(r)=>{let s={...n,common:{...n.common,issues:[]},parent:null};return{result:await r._parseAsync({data:n.data,path:n.path,parent:s}),ctx:s}})).then(a);else{let r=void 0,s=[];for(let l of t){let u={...n,common:{...n.common,issues:[]},parent:null},m=l._parseSync({data:n.data,path:n.path,parent:u});if(m.status==="valid")return m;else if(m.status==="dirty"&&!r)r={result:m,ctx:u};if(u.common.issues.length)s.push(u.common.issues)}if(r)return n.common.issues.push(...r.ctx.common.issues),r.result;let A=s.map((l)=>new er(l));return $e(n,{code:Ce.invalid_union,unionErrors:A}),tn}}get options(){return this._def.options}};Ip.create=(e,n)=>{return new Ip({options:e,typeName:on.ZodUnion,..._n(n)})};GB=class GB extends vn{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==xe.object)return $e(n,{code:Ce.invalid_type,expected:xe.object,received:n.parsedType}),tn;let t=this.discriminator,a=n.data[t],r=this.optionsMap.get(a);if(!r)return $e(n,{code:Ce.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[t]}),tn;if(n.common.async)return r._parseAsync({data:n.data,path:n.path,parent:n});else return r._parseSync({data:n.data,path:n.path,parent:n})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,t){let a=new Map;for(let r of n){let s=wc(r.shape[e]);if(!s.length)throw Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let A of s){if(a.has(A))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(A)}`);a.set(A,r)}}return new GB({typeName:on.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:a,..._n(t)})}};vp=class vp extends vn{_parse(e){let{status:n,ctx:t}=this._processInputParams(e),a=(r,s)=>{if(LB(r)||LB(s))return tn;let A=mv(r.value,s.value);if(!A.valid)return $e(t,{code:Ce.invalid_intersection_types}),tn;if(MB(r)||MB(s))n.dirty();return{status:n.value,value:A.data}};if(t.common.async)return Promise.all([this._def.left._parseAsync({data:t.data,path:t.path,parent:t}),this._def.right._parseAsync({data:t.data,path:t.path,parent:t})]).then(([r,s])=>a(r,s));else return a(this._def.left._parseSync({data:t.data,path:t.path,parent:t}),this._def.right._parseSync({data:t.data,path:t.path,parent:t}))}};vp.create=(e,n,t)=>{return new vp({left:e,right:n,typeName:on.ZodIntersection,..._n(t)})};hs=class hs extends vn{_parse(e){let{status:n,ctx:t}=this._processInputParams(e);if(t.parsedType!==xe.array)return $e(t,{code:Ce.invalid_type,expected:xe.array,received:t.parsedType}),tn;if(t.data.length<this._def.items.length)return $e(t,{code:Ce.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),tn;if(!this._def.rest&&t.data.length>this._def.items.length)$e(t,{code:Ce.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty();let r=[...t.data].map((s,A)=>{let l=this._def.items[A]||this._def.rest;if(!l)return null;return l._parse(new Fo(t,s,t.path,A))}).filter((s)=>!!s);if(t.common.async)return Promise.all(r).then((s)=>{return Ai.mergeArray(n,s)});else return Ai.mergeArray(n,r)}get items(){return this._def.items}rest(e){return new hs({...this._def,rest:e})}};hs.create=(e,n)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new hs({items:e,typeName:on.ZodTuple,rest:null,..._n(n)})};vb=class vb extends vn{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:t}=this._processInputParams(e);if(t.parsedType!==xe.object)return $e(t,{code:Ce.invalid_type,expected:xe.object,received:t.parsedType}),tn;let a=[],r=this._def.keyType,s=this._def.valueType;for(let A in t.data)a.push({key:r._parse(new Fo(t,A,t.path,A)),value:s._parse(new Fo(t,t.data[A],t.path,A)),alwaysSet:A in t.data});if(t.common.async)return Ai.mergeObjectAsync(n,a);else return Ai.mergeObjectSync(n,a)}get element(){return this._def.valueType}static create(e,n,t){if(n instanceof vn)return new vb({keyType:e,valueType:n,typeName:on.ZodRecord,..._n(t)});return new vb({keyType:vo.create(),valueType:e,typeName:on.ZodRecord,..._n(n)})}};xb=class xb extends vn{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:t}=this._processInputParams(e);if(t.parsedType!==xe.map)return $e(t,{code:Ce.invalid_type,expected:xe.map,received:t.parsedType}),tn;let a=this._def.keyType,r=this._def.valueType,s=[...t.data.entries()].map(([A,l],u)=>{return{key:a._parse(new Fo(t,A,t.path,[u,"key"])),value:r._parse(new Fo(t,l,t.path,[u,"value"]))}});if(t.common.async){let A=new Map;return Promise.resolve().then(async()=>{for(let l of s){let u=await l.key,m=await l.value;if(u.status==="aborted"||m.status==="aborted")return tn;if(u.status==="dirty"||m.status==="dirty")n.dirty();A.set(u.value,m.value)}return{status:n.value,value:A}})}else{let A=new Map;for(let l of s){let{key:u,value:m}=l;if(u.status==="aborted"||m.status==="aborted")return tn;if(u.status==="dirty"||m.status==="dirty")n.dirty();A.set(u.value,m.value)}return{status:n.value,value:A}}}};xb.create=(e,n,t)=>{return new xb({valueType:n,keyType:e,typeName:on.ZodMap,..._n(t)})};cd=class cd extends vn{_parse(e){let{status:n,ctx:t}=this._processInputParams(e);if(t.parsedType!==xe.set)return $e(t,{code:Ce.invalid_type,expected:xe.set,received:t.parsedType}),tn;let a=this._def;if(a.minSize!==null){if(t.data.size<a.minSize.value)$e(t,{code:Ce.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),n.dirty()}if(a.maxSize!==null){if(t.data.size>a.maxSize.value)$e(t,{code:Ce.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),n.dirty()}let r=this._def.valueType;function s(l){let u=new Set;for(let m of l){if(m.status==="aborted")return tn;if(m.status==="dirty")n.dirty();u.add(m.value)}return{status:n.value,value:u}}let A=[...t.data.values()].map((l,u)=>r._parse(new Fo(t,l,t.path,u)));if(t.common.async)return Promise.all(A).then((l)=>s(l));else return s(A)}min(e,n){return new cd({...this._def,minSize:{value:e,message:Te.toString(n)}})}max(e,n){return new cd({...this._def,maxSize:{value:e,message:Te.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};cd.create=(e,n)=>{return new cd({valueType:e,minSize:null,maxSize:null,typeName:on.ZodSet,..._n(n)})};Cp=class Cp extends vn{constructor(){super(...arguments);this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==xe.function)return $e(n,{code:Ce.invalid_type,expected:xe.function,received:n.parsedType}),tn;function t(A,l){return Eb({data:A,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,wp(),yc].filter((u)=>!!u),issueData:{code:Ce.invalid_arguments,argumentsError:l}})}function a(A,l){return Eb({data:A,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,wp(),yc].filter((u)=>!!u),issueData:{code:Ce.invalid_return_type,returnTypeError:l}})}let r={errorMap:n.common.contextualErrorMap},s=n.data;if(this._def.returns instanceof Ad){let A=this;return Qi(async function(...l){let u=new er([]),m=await A._def.args.parseAsync(l,r).catch((y)=>{throw u.addIssue(t(l,y)),u}),b=await Reflect.apply(s,this,m);return await A._def.returns._def.type.parseAsync(b,r).catch((y)=>{throw u.addIssue(a(b,y)),u})})}else{let A=this;return Qi(function(...l){let u=A._def.args.safeParse(l,r);if(!u.success)throw new er([t(l,u.error)]);let m=Reflect.apply(s,this,u.data),b=A._def.returns.safeParse(m,r);if(!b.success)throw new er([a(m,b.error)]);return b.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Cp({...this._def,args:hs.create(e).rest(LA.create())})}returns(e){return new Cp({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,t){return new Cp({args:e?e:hs.create([]).rest(LA.create()),returns:n||LA.create(),typeName:on.ZodFunction,..._n(t)})}};xp=class xp extends vn{get schema(){return this._def.getter()}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};xp.create=(e,n)=>{return new xp({getter:e,typeName:on.ZodLazy,..._n(n)})};Dp=class Dp extends vn{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return $e(n,{received:n.data,code:Ce.invalid_literal,expected:this._def.value}),tn}return{status:"valid",value:e.data}}get value(){return this._def.value}};Dp.create=(e,n)=>{return new Dp({value:e,typeName:on.ZodLiteral,..._n(n)})};qA=class qA extends vn{_parse(e){if(typeof e.data!=="string"){let n=this._getOrReturnCtx(e),t=this._def.values;return $e(n,{expected:jn.joinValues(t),received:n.parsedType,code:Ce.invalid_type}),tn}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),t=this._def.values;return $e(n,{received:n.data,code:Ce.invalid_enum_value,options:t}),tn}return Qi(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return qA.create(e,{...this._def,...n})}exclude(e,n=this._def){return qA.create(this.options.filter((t)=>!e.includes(t)),{...this._def,...n})}};qA.create=tM;Fp=class Fp extends vn{_parse(e){let n=jn.getValidEnumValues(this._def.values),t=this._getOrReturnCtx(e);if(t.parsedType!==xe.string&&t.parsedType!==xe.number){let a=jn.objectValues(n);return $e(t,{expected:jn.joinValues(a),received:t.parsedType,code:Ce.invalid_type}),tn}if(!this._cache)this._cache=new Set(jn.getValidEnumValues(this._def.values));if(!this._cache.has(e.data)){let a=jn.objectValues(n);return $e(t,{received:t.data,code:Ce.invalid_enum_value,options:a}),tn}return Qi(e.data)}get enum(){return this._def.values}};Fp.create=(e,n)=>{return new Fp({values:e,typeName:on.ZodNativeEnum,..._n(n)})};Ad=class Ad extends vn{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==xe.promise&&n.common.async===!1)return $e(n,{code:Ce.invalid_type,expected:xe.promise,received:n.parsedType}),tn;let t=n.parsedType===xe.promise?n.data:Promise.resolve(n.data);return Qi(t.then((a)=>{return this._def.type.parseAsync(a,{path:n.path,errorMap:n.common.contextualErrorMap})}))}};Ad.create=(e,n)=>{return new Ad({type:e,typeName:on.ZodPromise,..._n(n)})};So=class So extends vn{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===on.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:t}=this._processInputParams(e),a=this._def.effect||null,r={addIssue:(s)=>{if($e(t,s),s.fatal)n.abort();else n.dirty()},get path(){return t.path}};if(r.addIssue=r.addIssue.bind(r),a.type==="preprocess"){let s=a.transform(t.data,r);if(t.common.async)return Promise.resolve(s).then(async(A)=>{if(n.value==="aborted")return tn;let l=await this._def.schema._parseAsync({data:A,path:t.path,parent:t});if(l.status==="aborted")return tn;if(l.status==="dirty")return rd(l.value);if(n.value==="dirty")return rd(l.value);return l});else{if(n.value==="aborted")return tn;let A=this._def.schema._parseSync({data:s,path:t.path,parent:t});if(A.status==="aborted")return tn;if(A.status==="dirty")return rd(A.value);if(n.value==="dirty")return rd(A.value);return A}}if(a.type==="refinement"){let s=(A)=>{let l=a.refinement(A,r);if(t.common.async)return Promise.resolve(l);if(l instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return A};if(t.common.async===!1){let A=this._def.schema._parseSync({data:t.data,path:t.path,parent:t});if(A.status==="aborted")return tn;if(A.status==="dirty")n.dirty();return s(A.value),{status:n.value,value:A.value}}else return this._def.schema._parseAsync({data:t.data,path:t.path,parent:t}).then((A)=>{if(A.status==="aborted")return tn;if(A.status==="dirty")n.dirty();return s(A.value).then(()=>{return{status:n.value,value:A.value}})})}if(a.type==="transform")if(t.common.async===!1){let s=this._def.schema._parseSync({data:t.data,path:t.path,parent:t});if(!jA(s))return tn;let A=a.transform(s.value,r);if(A instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:A}}else return this._def.schema._parseAsync({data:t.data,path:t.path,parent:t}).then((s)=>{if(!jA(s))return tn;return Promise.resolve(a.transform(s.value,r)).then((A)=>({status:n.value,value:A}))});jn.assertNever(a)}};So.create=(e,n,t)=>{return new So({schema:e,typeName:on.ZodEffects,effect:n,..._n(t)})};So.createWithPreprocess=(e,n,t)=>{return new So({schema:n,effect:{type:"preprocess",transform:e},typeName:on.ZodEffects,..._n(t)})};Do=class Do extends vn{_parse(e){if(this._getType(e)===xe.undefined)return Qi(void 0);return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Do.create=(e,n)=>{return new Do({innerType:e,typeName:on.ZodOptional,..._n(n)})};Bc=class Bc extends vn{_parse(e){if(this._getType(e)===xe.null)return Qi(null);return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Bc.create=(e,n)=>{return new Bc({innerType:e,typeName:on.ZodNullable,..._n(n)})};Sp=class Sp extends vn{_parse(e){let{ctx:n}=this._processInputParams(e),t=n.data;if(n.parsedType===xe.undefined)t=this._def.defaultValue();return this._def.innerType._parse({data:t,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};Sp.create=(e,n)=>{return new Sp({innerType:e,typeName:on.ZodDefault,defaultValue:typeof n.default==="function"?n.default:()=>n.default,..._n(n)})};$p=class $p extends vn{_parse(e){let{ctx:n}=this._processInputParams(e),t={...n,common:{...n.common,issues:[]}},a=this._def.innerType._parse({data:t.data,path:t.path,parent:{...t}});if(Bp(a))return a.then((r)=>{return{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new er(t.common.issues)},input:t.data})}});else return{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new er(t.common.issues)},input:t.data})}}removeCatch(){return this._def.innerType}};$p.create=(e,n)=>{return new $p({innerType:e,typeName:on.ZodCatch,catchValue:typeof n.catch==="function"?n.catch:()=>n.catch,..._n(n)})};Db=class Db extends vn{_parse(e){if(this._getType(e)!==xe.nan){let t=this._getOrReturnCtx(e);return $e(t,{code:Ce.invalid_type,expected:xe.nan,received:t.parsedType}),tn}return{status:"valid",value:e.data}}};Db.create=(e)=>{return new Db({typeName:on.ZodNaN,..._n(e)})};Jpe=Symbol("zod_brand");qB=class qB extends vn{_parse(e){let{ctx:n}=this._processInputParams(e),t=n.data;return this._def.type._parse({data:t,path:n.path,parent:n})}unwrap(){return this._def.type}};Fb=class Fb extends vn{_parse(e){let{status:n,ctx:t}=this._processInputParams(e);if(t.common.async)return(async()=>{let r=await this._def.in._parseAsync({data:t.data,path:t.path,parent:t});if(r.status==="aborted")return tn;if(r.status==="dirty")return n.dirty(),rd(r.value);else return this._def.out._parseAsync({data:r.value,path:t.path,parent:t})})();else{let a=this._def.in._parseSync({data:t.data,path:t.path,parent:t});if(a.status==="aborted")return tn;if(a.status==="dirty")return n.dirty(),{status:"dirty",value:a.value};else return this._def.out._parseSync({data:a.value,path:t.path,parent:t})}}static create(e,n){return new Fb({in:e,out:n,typeName:on.ZodPipeline})}};Np=class Np extends vn{_parse(e){let n=this._def.innerType._parse(e),t=(a)=>{if(jA(a))a.value=Object.freeze(a.value);return a};return Bp(n)?n.then((a)=>t(a)):t(n)}unwrap(){return this._def.innerType}};Np.create=(e,n)=>{return new Np({innerType:e,typeName:on.ZodReadonly,..._n(n)})};Wpe={object:Xt.lazycreate};(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(on||(on={}));iM=vo.create,rM=MA.create,Xpe=Db.create,eme=GA.create,oM=_p.create,nme=od.create,tme=Qb.create,ame=Ep.create,ime=Qp.create,rme=sd.create,ome=LA.create,sme=fs.create,cme=Ib.create,Ame=xo.create,lme=Xt.create,dme=Xt.strictCreate,ume=Ip.create,pme=GB.create,mme=vp.create,gme=hs.create,bme=vb.create,fme=xb.create,hme=cd.create,yme=Cp.create,wme=xp.create,Bme=Dp.create,kme=qA.create,Cme=Fp.create,_me=Ad.create,Eme=So.create,Qme=Do.create,Ime=Bc.create,vme=So.createWithPreprocess,xme=Fb.create,$me={string:(e)=>vo.create({...e,coerce:!0}),number:(e)=>MA.create({...e,coerce:!0}),boolean:(e)=>_p.create({...e,coerce:!0}),bigint:(e)=>GA.create({...e,coerce:!0}),date:(e)=>od.create({...e,coerce:!0})},Nme=tn});var $={};S($,{void:()=>cme,util:()=>jn,unknown:()=>ome,union:()=>ume,undefined:()=>ame,tuple:()=>gme,transformer:()=>Eme,symbol:()=>tme,string:()=>iM,strictObject:()=>dme,setErrorMap:()=>Ipe,set:()=>hme,record:()=>bme,quotelessJson:()=>Epe,promise:()=>_me,preprocess:()=>vme,pipeline:()=>xme,ostring:()=>Dme,optional:()=>Qme,onumber:()=>Fme,oboolean:()=>Sme,objectUtil:()=>lv,object:()=>lme,number:()=>rM,nullable:()=>Ime,null:()=>ime,never:()=>sme,nativeEnum:()=>Cme,nan:()=>Xpe,map:()=>fme,makeIssue:()=>Eb,literal:()=>Bme,lazy:()=>wme,late:()=>Wpe,isValid:()=>jA,isDirty:()=>MB,isAsync:()=>Bp,isAborted:()=>LB,intersection:()=>mme,instanceof:()=>Vpe,getParsedType:()=>bs,getErrorMap:()=>wp,function:()=>yme,enum:()=>kme,effect:()=>Eme,discriminatedUnion:()=>pme,defaultErrorMap:()=>yc,datetimeRegex:()=>nM,date:()=>nme,custom:()=>aM,coerce:()=>$me,boolean:()=>oM,bigint:()=>eme,array:()=>Ame,any:()=>rme,addIssueToContext:()=>$e,ZodVoid:()=>Ib,ZodUnknown:()=>LA,ZodUnion:()=>Ip,ZodUndefined:()=>Ep,ZodType:()=>vn,ZodTuple:()=>hs,ZodTransformer:()=>So,ZodSymbol:()=>Qb,ZodString:()=>vo,ZodSet:()=>cd,ZodSchema:()=>vn,ZodRecord:()=>vb,ZodReadonly:()=>Np,ZodPromise:()=>Ad,ZodPipeline:()=>Fb,ZodParsedType:()=>xe,ZodOptional:()=>Do,ZodObject:()=>Xt,ZodNumber:()=>MA,ZodNullable:()=>Bc,ZodNull:()=>Qp,ZodNever:()=>fs,ZodNativeEnum:()=>Fp,ZodNaN:()=>Db,ZodMap:()=>xb,ZodLiteral:()=>Dp,ZodLazy:()=>xp,ZodIssueCode:()=>Ce,ZodIntersection:()=>vp,ZodFunction:()=>Cp,ZodFirstPartyTypeKind:()=>on,ZodError:()=>er,ZodEnum:()=>qA,ZodEffects:()=>So,ZodDiscriminatedUnion:()=>GB,ZodDefault:()=>Sp,ZodDate:()=>od,ZodCatch:()=>$p,ZodBranded:()=>qB,ZodBoolean:()=>_p,ZodBigInt:()=>GA,ZodArray:()=>xo,ZodAny:()=>sd,Schema:()=>vn,ParseStatus:()=>Ai,OK:()=>Qi,NEVER:()=>Nme,INVALID:()=>tn,EMPTY_PATH:()=>vpe,DIRTY:()=>rd,BRAND:()=>Jpe});var gv=h(()=>{jB();uv();ZL();_b();sM();NB()});var sa=h(()=>{gv();gv()});function ye(e){return e instanceof Error?e.message:String(e)}function Ii(e){let n=e?.code;return typeof n==="string"?n:void 0}import{randomBytes as jme}from"node:crypto";import{chmod as cM,mkdir as Lme,readFile as Mme,rename as Gme,rm as lM,writeFile as qme}from"node:fs/promises";import{homedir as Rme}from"node:os";import{isAbsolute as AM,join as RB}from"node:path";function Ti(){let e=process.env.HOME,n=e&&AM(e)?e:Rme();if(!AM(n))throw new jp("cannot resolve an absolute home directory; set $HOME to an absolute path","resolve-path");return RB(n,".greptile")}function jt(){return vt.fromThrowable(()=>RB(Ti(),"auth.json"),(e)=>new jp(`could not resolve credentials path: ${ye(e)}`,"resolve-path",{cause:e}))().asyncAndThen((e)=>ma(async function*(){let n=yield*Hn.fromPromise(Ume(e),(r)=>bv(r,"read","could not read credentials"));if(n===null)return me(null);let t=yield*vt.fromThrowable(()=>JSON.parse(n),(r)=>new kc(`credential file corrupt: ${ye(r)}`))(),a=Pme.safeParse(t);if(!a.success)return ie(new kc("credential file missing required fields"));return me(a.data)}))}function Sb(e){let n=async()=>{let t=Ti();await Lme(t,{recursive:!0,mode:448}),await cM(t,448);let a=RB(t,"auth.json"),r=`${a}.${process.pid}.${jme(4).toString("hex")}.tmp`;try{await qme(r,JSON.stringify(e,null,2),{mode:384}),await Gme(r,a),await cM(a,384)}catch(s){throw await lM(r,{force:!0}),s}};return Hn.fromPromise(n(),(t)=>bv(t,"write","could not write credentials"))}function $b(){return vt.fromThrowable(()=>RB(Ti(),"auth.json"),(e)=>new jp(`could not resolve credentials path: ${ye(e)}`,"resolve-path",{cause:e}))().asyncAndThen((e)=>Hn.fromPromise(lM(e,{force:!0}),(n)=>bv(n,"delete","could not delete credentials")))}async function Ume(e){try{return await Mme(e,"utf8")}catch(n){if(Ii(n)==="ENOENT")return null;throw n}}function bv(e,n,t){if(e instanceof jp)return e;return new jp(`${t}: ${ye(e)}`,n,{cause:e})}var kc,jp,zme,Hme,Pme;var nr=h(()=>{Vt();sa();kc=class kc extends Error{kind="corrupt-credentials";constructor(e){super(e);this.name="CorruptCredentialsError"}};jp=class jp extends Error{operation;kind="credential-store";constructor(e,n,t={}){super(e,t);this.operation=n;this.name="CredentialStoreError"}};zme=$.object({method:$.literal("oauth"),issuer:$.string().default("https://auth.greptile.com"),accessToken:$.string(),refreshToken:$.string(),expiresAt:$.number().finite(),scope:$.string().optional(),subject:$.string().nullable().optional(),email:$.string().nullable().optional(),apiBaseUrl:$.string().optional()}),Hme=$.object({method:$.literal("apikey"),apiKey:$.string().min(1),subject:$.string().nullable().optional(),email:$.string().nullable().optional(),apiBaseUrl:$.string().optional()}),Pme=$.preprocess((e)=>{if(!e||typeof e!=="object"||Array.isArray(e))return e;let n=e;if(n.method==null)return{...n,method:"oauth"};return n},$.discriminatedUnion("method",[zme,Hme]))});var ga;var ys=h(()=>{ga={name:"greptile",version:"3.5.1",type:"module",description:"Greptile code review from your terminal",bin:"dist/greptile.js",scripts:{test:"bun test",build:"bun scripts/bundle.ts",postbuild:"bun scripts/link-dev.ts",dev:"bun run src/main.ts","generate:schema":"bun scripts/generate-settings-schema.ts",lint:"oxlint --type-aware --format agent src --ignore-pattern '**/__tests__/**' --ignore-pattern '**/*.test.ts' --ignore-pattern '**/*.test.tsx'",format:"oxfmt src package.json tsconfig.json",prepack:"bun scripts/bundle.ts",prepublishOnly:"bun run typecheck && bun scripts/bundle.ts",typecheck:"tsc --noEmit"},devDependencies:{"@inkjs/ui":"^2.0.0","@pierre/theme":"^1.0.3","@types/bun":"^1.3.11","@types/picomatch":"^4.0.3","@types/react":"^19.2.14","cli-truncate":"^6.0.0",commander:"^15.0.0",dotenv:"16.6.1",ink:"^7.0.3",neverthrow:"^8.2.0",picocolors:"^1.1.1",picomatch:"^4.0.4",react:"^19.2.6",shiki:"^4.1.0","ssh-config":"^5.1.0","string-width":"^8.2.1","strip-ansi":"^7.2.0","terminal-link":"^5.0.0",typescript:"^6.0.3","wrap-ansi":"^9.0.2",zod:"^3.25.76","zod-to-json-schema":"^3.25.2"},files:["dist/greptile.js","settings-schema.json","README.md","CHANGELOG.md"],engines:{node:">=22.0.0"},keywords:["greptile","code-review","cli","claude-code","codex"],license:"MIT",homepage:"https://greptile.com",repository:{type:"git",url:"git+https://github.com/greptileai/cli.git"},bugs:{url:"https://github.com/greptileai/cli/issues"},publishConfig:{access:"public"},overrides:{react:"^19.2.6","react-dom":"^19.2.6"}}});function dM(e,n){let t=Ii(e);if(t&&Ome.has(t)){let a=ye(e);return Error(`TLS certificate verification failed for ${n} (${a}). For a private certificate authority, point NODE_EXTRA_CA_CERTS at your CA bundle.`,{cause:e})}return e}var Ome;var uM=h(()=>{Ome=new Set(["SELF_SIGNED_CERT_IN_CHAIN","DEPTH_ZERO_SELF_SIGNED_CERT","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","UNABLE_TO_VERIFY_LEAF_SIGNATURE","CERT_HAS_EXPIRED","ERR_TLS_CERT_ALTNAME_INVALID"])});var fv={};S(fv,{request:()=>hr,USER_AGENT:()=>pM,HttpError:()=>ws,DEFAULT_MAX_RESPONSE_BYTES:()=>mM});import Yme from"node:http";import Kme from"node:https";function Zme(e,n){let t=n.toLowerCase();for(let a of Object.keys(e))if(a.toLowerCase()===t)return!0;return!1}function hr(e){return Hn.fromPromise(Wme(e),(n)=>Jme(n,e.hostname,e.path))}function Jme(e,n,t){if(e instanceof ws)return e;return new ws(ye(e),"network",n,t,{cause:e})}function Wme({method:e,hostname:n,path:t,headers:a={},body:r,port:s,scheme:A="https",timeoutMs:l=30000,maxResponseBytes:u=mM,detached:m=!1,signal:b}){let f=A==="http"?Yme:Kme,y=s??(A==="http"?80:443),B={...a};if(!Zme(B,"user-agent"))B["user-agent"]=pM;if(r!==void 0){for(let k of Object.keys(B))if(k.toLowerCase()==="content-length")delete B[k];B["content-length"]=String(Buffer.byteLength(r))}return new Promise((k,E)=>{if(b?.aborted){E(new ws(`request to ${n}${t} was aborted`,"aborted",n,t));return}let _=f.request({method:e,hostname:n,path:t,port:y,headers:B},(F)=>{let M=[],J=0;F.on("data",(ee)=>{let pe=Buffer.isBuffer(ee)?ee:Buffer.from(ee);if(J+=pe.byteLength,J>u){let ae=new ws(`response from ${n}${t} exceeded ${u} bytes`,"response-too-large",n,t);F.destroy(ae),_.destroy(ae);return}M.push(pe)}),F.on("end",()=>{k({status:F.statusCode??0,headers:F.headers,body:Buffer.concat(M)})}),F.on("error",E)});_.on("error",(F)=>{if(F instanceof ws){E(F);return}let M=dM(F,n);E(new ws(ye(M),M===F?"network":"tls",n,t,{cause:F}))});let x=setTimeout(()=>{let F=new ws(`request to ${n}${t} timed out after ${l}ms`,"timeout",n,t);E(F),_.destroy(F)},l),Q=()=>{let F=new ws(`request to ${n}${t} was aborted`,"aborted",n,t);E(F),_.destroy(F)};if(b?.addEventListener("abort",Q,{once:!0}),_.on("close",()=>{clearTimeout(x),b?.removeEventListener("abort",Q)}),m)x.unref(),_.on("socket",(F)=>F.unref());if(r!==void 0)_.write(r);_.end()})}var ws,pM,mM=10485760;var ld=h(()=>{Vt();ys();uM();ws=class ws extends Error{reason;hostname;path;kind="http";constructor(e,n,t,a,r={}){super(e,r);this.reason=n;this.hostname=t;this.path=a;this.name="HttpError"}};pM=`greptile-cli/${ga.version}`});function ea(e){let n=e.trim();if(!n)return null;try{return new URL(n)}catch{return null}}function RA(e,n){let t=ea(e),a=ea(n);if(!t||!a)return!1;return t.origin===a.origin}function ba(e){if(e.protocol!=="https:")return!1;return e.hostname==="greptile.com"||e.hostname.endsWith(".greptile.com")}function Nb(e){return Vme.has(e)}function Lp(e){return e.pathname!=="/"||e.search!==""||e.hash!==""}var Vme;var Bs=h(()=>{Vme=new Set(["localhost","127.0.0.1","[::1]","::1"])});import{createHash as Xme,randomBytes as gM}from"node:crypto";function fM(e=process.env){let n=e.GREPTILE_AUTH_BASE_URL?.trim();return n?n.replace(/\/+$/,""):zB}function hM(e){return`${e}/cli/callback`}function dd(e){return e.replace(/\/+$/,"")}function BM(){let e=gM(32).toString("base64url"),n=Xme("sha256").update(e).digest("base64url");return{verifier:e,challenge:n}}function kM(){return gM(24).toString("base64url")}function tge(e){let n=dd(e),t=new URL(n),a=t.pathname==="/"?"":t.pathname,r=[`${t.origin}/.well-known/oauth-authorization-server${a}`,`${t.origin}/.well-known/openid-configuration${a}`,`${n}/.well-known/openid-configuration`];return[...new Set(r)]}function Lb(e){try{if(ba(new URL(e)))return{}}catch{return{}}return{expectIssuer:e}}function zA(e=zB,n={}){let t=n.getJson??Mb;return ma(async function*(){let a=yield*vt.fromThrowable(()=>tge(e),(u)=>Bv(u,"metadata",`Could not read the sign-in server URL: ${ye(u)}`))(),r=0,s,A=!1;for(let u of a){let m=yield*t(u);if(r=m.status,m.status===200){s=m.body,A=!0;break}}if(!A)return ie(new vi(`Could not reach Greptile sign-in (HTTP ${r})`,"metadata"));let l=yield*age(s);if(n.expectIssuer!==void 0){let u=dd(n.expectIssuer),m=typeof l.issuer==="string"?dd(l.issuer):void 0;if(m===void 0)return ie(new vi(`The authorization server at ${u} did not include an issuer field in its metadata `+"(required by RFC 8414 §2). Fix the server metadata, or use `greptile login --api-key`.","metadata"));if(m!==u)return ie(new vi(`The sign-in server's metadata names a different issuer (${l.issuer}) than expected (${u}). `+"This can indicate a misconfigured or spoofed authorization server — not proceeding.","metadata"))}return me(l)})}function age(e){let n=ege.safeParse(e);if(n.success)return me(n.data);let t=n.error.issues[0]?.path[0];if(t==="token_endpoint")return ie(new vi("Greptile sign-in is not available right now","metadata"));if(t==="revocation_endpoint")return ie(new vi("Greptile sign-out is not available right now","metadata"));if(t==="code_challenge_methods_supported")return ie(new vi("Greptile sign-in is not available right now","metadata"));return ie(new vi("Greptile sign-in is not available right now","metadata"))}function CM(e,{redirectUri:n,challenge:t,state:a,audience:r}){let s=new URLSearchParams({client_id:HB,response_type:"code",scope:jb,redirect_uri:n,code_challenge:t,code_challenge_method:"S256",state:a});if(r!==void 0)s.set("audience",r);return`${e.authorization_endpoint}?${s.toString()}`}function _M(e,{code:n,verifier:t,redirectUri:a}){return wv(e.token_endpoint,{grant_type:"authorization_code",code:n,redirect_uri:a,client_id:HB,code_verifier:t}).andThen((r)=>{if(r.status!==200){let A=yM.safeParse(r.body).data?.error;return ie(new vi(`Greptile could not finish sign-in: ${A??`http ${r.status}`}`,"token-exchange",A??"http_error"))}let s=nge.safeParse(r.body);if(!s.success)return ie(new vi("Greptile could not finish sign-in","token-exchange"));return me(s.data)})}function EM(e,{refreshToken:n}){return wv(e.token_endpoint,{grant_type:"refresh_token",refresh_token:n,client_id:HB}).andThen((t)=>{if(t.status!==200){let r=yM.safeParse(t.body).data?.error;return ie(new vi(`refresh failed: ${r??`http ${t.status}`}`,"token-refresh",r??"http_error"))}let a=wM.safeParse(t.body);if(!a.success)return ie(new vi("Could not refresh your Greptile sign-in","token-refresh"));return me(a.data)})}function yv(e,{refreshToken:n}){if(!e.revocation_endpoint)return Nt({ok:!1});return wv(e.revocation_endpoint,{token:n,token_type_hint:"refresh_token",client_id:HB}).map((t)=>({ok:t.status>=200&&t.status<300}))}function QM(e){let n=new URL(e),t=n.protocol==="http:"?"http":"https",a=n.port?Number(n.port):t==="https"?443:80;return{hostname:n.hostname,path:n.pathname+(n.search||""),port:a,scheme:t}}function IM(e){let n=e.body.toString("utf8");if(n.length===0)return{status:e.status,headers:e.headers,body:null};try{return{status:e.status,headers:e.headers,body:JSON.parse(n)}}catch{return{status:e.status,headers:e.headers,body:n}}}function Mb(e,n={}){return vt.fromThrowable(()=>QM(e),(t)=>Bv(t,"request-url",ye(t)))().asyncAndThen(({hostname:t,path:a,port:r,scheme:s})=>hr({method:"GET",hostname:t,path:a,port:r,scheme:s,headers:{accept:"application/json",...n}})).map(IM)}function wv(e,n){return vt.fromThrowable(()=>QM(e),(t)=>Bv(t,"request-url",ye(t)))().asyncAndThen(({hostname:t,path:a,port:r,scheme:s})=>hr({method:"POST",hostname:t,path:a,port:r,scheme:s,headers:{"content-type":"application/x-www-form-urlencoded",accept:"application/json"},body:new URLSearchParams(n).toString()})).map(IM)}function Bv(e,n,t){if(e instanceof vi)return e;return new vi(t,n,void 0,{cause:e})}var zB="https://auth.greptile.com",bM="https://app.greptile.com",HB="greptile-cli",jb="read write openid offline_access",vi,hv,ege,yM,wM,nge;var Gb=h(()=>{Vt();ld();Bs();sa();vi=class vi extends Error{operation;code;kind="oauth";constructor(e,n,t,a={}){super(e,a);this.operation=n;this.code=t;this.name="OAuthError"}};hv=$.string().url().refine((e)=>{try{return new URL(e).protocol==="https:"}catch{return!1}},{message:"must be https"}),ege=$.object({issuer:$.string().optional(),authorization_endpoint:hv,token_endpoint:hv,revocation_endpoint:hv.optional(),code_challenge_methods_supported:$.array($.string()).refine((e)=>e.includes("S256"),{message:"must include S256"})}).passthrough(),yM=$.object({error:$.string().optional()}).passthrough(),wM=$.object({access_token:$.string(),refresh_token:$.string().optional(),expires_in:$.union([$.number(),$.string()]).optional(),id_token:$.string().optional(),scope:$.string().optional()}).passthrough(),nge=wM.extend({refresh_token:$.string()})});function vM(e){return $.string().transform((n)=>n.trim().replace(/\/+$/,"")).superRefine((n,t)=>{let a=ea(n);if(!a){t.addIssue({code:$.ZodIssueCode.custom,message:`${e} must be a valid URL.`});return}let r=a.protocol==="http:"&&Nb(a.hostname);if(a.protocol!=="https:"&&!r)t.addIssue({code:$.ZodIssueCode.custom,message:`${e} must use https.`});if(Lp(a))t.addIssue({code:$.ZodIssueCode.custom,message:`${e} must be an origin with no path.`})})}function xM(e){return e.map((n)=>({display:n,value:n}))}function Mp(e){return e in Ln}function qb(e){if(e==="true")return!0;if(e==="false")return!1;let n=e.trim();if(n!==""&&Number.isInteger(Number(n)))return Number(n);return e}function DM(e){return Ln[e].interactive!==!1}var kv,Cv,ige,Ln,HA,FM,SM;var ud=h(()=>{sa();ys();Bs();kv=["auto","text","json"],Cv=["comments","diff"],ige=[{display:"On",value:!0},{display:"Off",value:!1}];Ln={color:{schema:$.boolean(),label:"Color output",description:"Color output. Set to false for the same effect as always passing --no-color.",hint:"Use true or false.",expected:"true or false",fixValues:[!0,!1],defaultValue:!0,defaultLabel:"true",choices:ige},telemetry:{schema:$.boolean(),label:"Usage data sharing",description:"Anonymous usage data sharing. Overrides the first-run consent choice; never includes code or repo contents.",hint:"Use true or false.",expected:"true or false",fixValues:[!0,!1],defaultValue:void 0,defaultLabel:"first-run consent choice",interactive:!1},apiBaseUrl:{schema:vM("apiBaseUrl"),label:"API base URL",description:"API base URL for a self-hosted Greptile deployment. Origin only — serve the API at an origin root or dedicated hostname.",hint:"Use an HTTPS origin with no path, e.g. https://greptile-api.acme.internal.",expected:"an HTTPS origin with no path",fixValues:["https://greptile-api.acme.internal"],defaultValue:void 0,defaultLabel:"https://api.greptile.com"},webBaseUrl:{schema:vM("webBaseUrl"),label:"Web base URL",description:"Web dashboard URL for a self-hosted Greptile deployment. Origin only, no path.",hint:"Use an HTTPS origin with no path, e.g. https://greptile.acme.internal.",expected:"an HTTPS origin with no path",fixValues:["https://greptile.acme.internal"],defaultValue:void 0,defaultLabel:"https://app.greptile.com"},"review.output":{schema:$.enum(kv),label:"Review output",description:"Default review output: auto (rich on a terminal, text when piped), text, or json.",hint:"Use auto, text, or json.",expected:'"auto", "text", or "json"',fixValues:kv,defaultValue:"auto",defaultLabel:"auto",choices:xM(kv)},"review.layout":{schema:$.enum(Cv),label:"Review layout",description:"Default review layout: comments, or diff to show findings beside the changed code.",hint:"Use comments or diff.",expected:'"comments" or "diff"',fixValues:Cv,defaultValue:"comments",defaultLabel:"comments",choices:xM(Cv)},"review.context":{schema:$.number().int().min(0).max(60),label:"Review context lines",description:"Lines of nearby code shown around findings, the same as passing --context.",hint:"Use a number from 0 to 60.",expected:"an integer from 0 to 60",fixValues:[15],defaultValue:15,defaultLabel:"15"},"review.width":{schema:$.number().int().min(40).max(240),label:"Review width",description:"Review output width in columns, the same as passing --width.",hint:"Use a number from 40 to 240.",expected:"an integer from 40 to 240",fixValues:[80],defaultValue:void 0,defaultLabel:"terminal width"}},HA=Object.keys(Ln);FM=`https://cdn.jsdelivr.net/npm/greptile@${ga.version.split(".")[0]}/settings-schema.json`,SM=$.object({version:$.number().optional().describe("Settings file format version, written by the CLI."),color:Ln.color.schema.optional().describe(Ln.color.description),telemetry:Ln.telemetry.schema.optional().describe(Ln.telemetry.description),apiBaseUrl:Ln.apiBaseUrl.schema.optional().describe(Ln.apiBaseUrl.description),webBaseUrl:Ln.webBaseUrl.schema.optional().describe(Ln.webBaseUrl.description),review:$.object({output:Ln["review.output"].schema.optional().describe(Ln["review.output"].description),layout:Ln["review.layout"].schema.optional().describe(Ln["review.layout"].description),context:Ln["review.context"].schema.optional().describe(Ln["review.context"].description),width:Ln["review.width"].schema.optional().describe(Ln["review.width"].description)}).passthrough().optional().describe("Settings for greptile review.")}).passthrough()});import{randomBytes as rge}from"node:crypto";import{mkdir as oge,readFile as sge,rename as cge,rm as Age,writeFile as lge}from"node:fs/promises";import{homedir as dge}from"node:os";import{dirname as uge,isAbsolute as _v,join as Rb}from"node:path";function Cc(e=process.env){let n=e.XDG_CONFIG_HOME;if(n&&_v(n))return Rb(n,"greptile");let t=e.HOME,a=t&&_v(t)?t:dge();if(!_v(a))throw Error("cannot resolve an absolute home directory; set $HOME to an absolute path");return Rb(a,".config","greptile")}function Qv(e=process.env){return Cs(e).andThen((n)=>{let t=SM.safeParse(n);if(t.success)return me({raw:n,settings:t.data});let a=new Map;for(let l of t.error.issues){let u=l.path.join(".");if(a.has(u))continue;let m=ks(n,u),b=Mp(u)?Ln[u]:void 0;a.set(u,{key:u,value:m,expected:b?.expected??l.message,commands:b?.fixValues.map((f)=>`greptile settings set ${u} ${typeof f==="string"?JSON.stringify(f):f}`)??[]})}let r=Rb(Cc(e),"settings.json"),s=[...a.values()],A=Ln["review.width"].schema.safeParse(ks(n,"review.width"));return ie(new Gp(`${r} has invalid settings:
296
+ `)r.name="enter";else if(e==="\t")r.name="tab";else if(e==="\b"||e==="\x1B\b")r.name="backspace",r.meta=e.charAt(0)==="\x1B";else if(e===""||e==="\x1B")r.name="backspace",r.meta=e.charAt(0)==="\x1B";else if(e==="\x1B"||e==="\x1B\x1B")r.name="escape",r.meta=e.length===2;else if(e===" "||e==="\x1B ")r.name="space",r.meta=e.length===2;else if(e.length===1&&e<="\x1A")r.name=String.fromCharCode(e.charCodeAt(0)+97-1),r.ctrl=!0;else if(e.length===1&&e>="0"&&e<="9")r.name="number";else if(e.length===1&&e>="a"&&e<="z")r.name=e;else if(e.length===1&&e>="A"&&e<="Z")r.name=e.toLowerCase(),r.shift=!0;else if(n=Zue.exec(e))r.name=n[1].toLowerCase(),r.meta=!0,r.shift=/^[A-Z]$/.test(n[1]);else if(n=Jue.exec(e)){let s=[...e];if(s[0]==="\x1B"&&s[1]==="\x1B")r.meta=!0;let A=[n[1],n[2],n[4],n[6]].filter(Boolean).join(""),l=(n[3]||n[5]||1)-1;r.ctrl=!!(l&4),r.meta=r.meta||!!(l&10),r.shift=!!(l&1),r.code=A,r.name=pL[A]??"",r.shift=Wue(A)||r.shift,r.ctrl=Vue(A)||r.ctrl}return r},yL;var wL=h(()=>{EB();dL=new TextDecoder,Zue=/^(?:\x1b)([a-zA-Z0-9])$/,Jue=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,pL={OP:"f1",OQ:"f2",OR:"f3",OS:"f4","[P":"f1","[Q":"f2","[R":"f3","[S":"f4","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[A":"up","[B":"down","[C":"right","[D":"left","[E":"clear","[F":"end","[H":"home",OA:"up",OB:"down",OC:"right",OD:"left",OE:"clear",OF:"end",OH:"home","[1~":"home","[2~":"insert","[3~":"delete","[4~":"end","[5~":"pageup","[6~":"pagedown","[[5~":"pageup","[[6~":"pagedown","[7~":"home","[8~":"end","[a":"up","[b":"down","[c":"right","[d":"left","[e":"clear","[2$":"insert","[3$":"delete","[5$":"pageup","[6$":"pagedown","[7$":"home","[8$":"end",Oa:"up",Ob:"down",Oc:"right",Od:"left",Oe:"clear","[2^":"insert","[3^":"delete","[5^":"pageup","[6^":"pagedown","[7^":"home","[8^":"end","[Z":"tab"},mL=[...Object.values(pL),"backspace"],gL=/^\x1b\[(\d+)(?:;(\d+)(?::(\d+))?(?:;([\d:]+))?)?u$/,Xue=/^\x1b\[(\d+);(\d+):(\d+)([A-Za-z~])$/,epe={A:"up",B:"down",C:"right",D:"left",E:"clear",F:"end",H:"home",P:"f1",Q:"f2",R:"f3",S:"f4"},npe={2:"insert",3:"delete",5:"pageup",6:"pagedown",7:"home",8:"end",11:"f1",12:"f2",13:"f3",14:"f4",15:"f5",17:"f6",18:"f7",19:"f8",20:"f9",21:"f10",23:"f11",24:"f12"},uL={27:"escape",9:"tab",127:"backspace",8:"backspace",57358:"capslock",57359:"scrolllock",57360:"numlock",57361:"printscreen",57362:"pause",57363:"menu",57376:"f13",57377:"f14",57378:"f15",57379:"f16",57380:"f17",57381:"f18",57382:"f19",57383:"f20",57384:"f21",57385:"f22",57386:"f23",57387:"f24",57388:"f25",57389:"f26",57390:"f27",57391:"f28",57392:"f29",57393:"f30",57394:"f31",57395:"f32",57396:"f33",57397:"f34",57398:"f35",57399:"kp0",57400:"kp1",57401:"kp2",57402:"kp3",57403:"kp4",57404:"kp5",57405:"kp6",57406:"kp7",57407:"kp8",57408:"kp9",57409:"kpdecimal",57410:"kpdivide",57411:"kpmultiply",57412:"kpsubtract",57413:"kpadd",57414:"kpenter",57415:"kpequal",57416:"kpseparator",57417:"kpleft",57418:"kpright",57419:"kpup",57420:"kpdown",57421:"kppageup",57422:"kppagedown",57423:"kphome",57424:"kpend",57425:"kpinsert",57426:"kpdelete",57427:"kpbegin",57428:"mediaplay",57429:"mediapause",57430:"mediaplaypause",57431:"mediareverse",57432:"mediastop",57433:"mediafastforward",57434:"mediarewind",57435:"mediatracknext",57436:"mediatrackprevious",57437:"mediarecord",57438:"lowervolume",57439:"raisevolume",57440:"mutevolume",57441:"leftshift",57442:"leftcontrol",57443:"leftalt",57444:"leftsuper",57445:"lefthyper",57446:"leftmeta",57447:"rightshift",57448:"rightcontrol",57449:"rightalt",57450:"rightsuper",57451:"righthyper",57452:"rightmeta",57453:"isoLevel3Shift",57454:"isoLevel5Shift"};yL=ipe});var BL,sv=()=>BL.useContext(bB);var wb=h(()=>{UI();BL=re(Be(),1)});var Bb,rpe=(e,n={})=>{let{setRawMode:t,internal_exitOnCtrlC:a,internal_eventEmitter:r}=sv();Bb.useEffect(()=>{if(n.isActive===!1)return;return t(!0),()=>{t(!1)}},[n.isActive,t]);let s=Bb.useEffectEvent((A)=>{let l=yL(A),u={upArrow:l.name==="up",downArrow:l.name==="down",leftArrow:l.name==="left",rightArrow:l.name==="right",pageDown:l.name==="pagedown",pageUp:l.name==="pageup",home:l.name==="home",end:l.name==="end",return:l.name==="return",escape:l.name==="escape",ctrl:l.ctrl,shift:l.shift,tab:l.name==="tab",backspace:l.name==="backspace",delete:l.name==="delete",meta:l.meta,super:l.super??!1,hyper:l.hyper??!1,capsLock:l.capsLock??!1,numLock:l.numLock??!1,eventType:l.eventType},m;if(l.isKittyProtocol)if(l.isPrintable)m=l.text??l.name;else if(l.ctrl&&l.name.length===1)m=l.name;else m="";else if(l.ctrl)m=l.name??"";else m=l.sequence;if(!l.isKittyProtocol&&mL.includes(l.name))m="";if(m.startsWith("\x1B"))m=m.slice(1);if(m.length===1&&/[A-Z]/.test(m))u.shift=!0;if(m==="c"&&u.ctrl&&a)return;pa.discreteUpdates(()=>{e(m,u)})});Bb.useEffect(()=>{if(n.isActive===!1)return;return r.on("input",s),()=>{r.removeListener("input",s)}},[n.isActive,r,s])},rt;var kL=h(async()=>{wL();wb();await sb();Bb=re(Be(),1),rt=rpe});var CL;var _L=h(async()=>{wb();await sb();CL=re(Be(),1)});var EL,ope=()=>EL.useContext(gB),Qo;var QL=h(()=>{PI();EL=re(Be(),1),Qo=ope});var IL,spe=()=>IL.useContext(fB),bc;var FB=h(()=>{TI();IL=re(Be(),1),bc=spe});var cpe;var vL=h(()=>{YI();cpe=re(Be(),1)});var cv;var xL=h(()=>{yB();wb();cv=re(Be(),1)});var lpe;var DL=h(()=>{yB();lpe=re(Be(),1)});var dpe;var FL=h(()=>{yp();dpe=re(Be(),1)});var SB;var SL=h(()=>{WI();SB=re(Be(),1)});var kb;var $L=h(()=>{ZI();kb=re(Be(),1)});var NL;var jL=h(()=>{L0();FB();NL=re(Be(),1)});var $B;var LL=h(async()=>{FB();await Wg();$B=re(Be(),1)});var ML=()=>{};var nn=h(async()=>{BB();ev();oL();cL();AL();lL();QL();wb();FB();vL();xL();DL();FL();SL();$L();jL();ML();EB();await Kn([aL(),rL(),kL(),_L(),LL()])});var Bt="#28E99F",qL;var fc=h(()=>{qL=[" .##."," .######+"," -######## .+"," .######### .####+."," .######## ########. "," -######## ########. "," ########+. +######## ","#+. ########. .######### .#","####. ################ +###","######. ############ .######"," ######. ######## .####### "," ######. ### -#######"," ######+ .#######"," ##### ######"," ### ####"," # #"]});function id(e,n,t,a){function r(s){return s instanceof t?s:new t(function(A){A(s)})}return new(t||(t=Promise))(function(s,A){function l(b){try{m(a.next(b))}catch(f){A(f)}}function u(b){try{m(a.throw(b))}catch(f){A(f)}}function m(b){b.done?s(b.value):r(b.value).then(l,u)}m((a=a.apply(e,n||[])).next())})}function PL(e){var n=typeof Symbol==="function"&&Symbol.iterator,t=n&&e[n],a=0;if(t)return t.call(e);if(e&&typeof e.length==="number")return{next:function(){if(e&&a>=e.length)e=void 0;return{value:e&&e[a++],done:!e}}};throw TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function gs(e){return this instanceof gs?(this.v=e,this):new gs(e)}function UL(e,n,t){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var a=t.apply(e,n||[]),r,s=[];return r=Object.create((typeof AsyncIterator==="function"?AsyncIterator:Object).prototype),l("next"),l("throw"),l("return",A),r[Symbol.asyncIterator]=function(){return this},r;function A(B){return function(k){return Promise.resolve(k).then(B,f)}}function l(B,k){if(a[B]){if(r[B]=function(E){return new Promise(function(_,x){s.push([B,E,_,x])>1||u(B,E)})},k)r[B]=k(r[B])}}function u(B,k){try{m(a[B](k))}catch(E){y(s[0][3],E)}}function m(B){B.value instanceof gs?Promise.resolve(B.value.v).then(b,f):y(s[0][2],B)}function b(B){u("next",B)}function f(B){u("throw",B)}function y(B,k){if(B(k),s.shift(),s.length)u(s[0][0],s[0][1])}}function ype(e){var n,t;return n={},a("next"),a("throw",function(r){throw r}),a("return"),n[Symbol.iterator]=function(){return this},n;function a(r,s){n[r]=e[r]?function(A){return(t=!t)?{value:gs(e[r](A)),done:!1}:s?s(A):A}:s}}function wpe(e){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var n=e[Symbol.asyncIterator],t;return n?n.call(e):(e=typeof PL==="function"?PL(e):e[Symbol.iterator](),t={},a("next"),a("throw"),a("return"),t[Symbol.asyncIterator]=function(){return this},t);function a(s){t[s]=e[s]&&function(A){return new Promise(function(l,u){A=e[s](A),r(l,u,A.done,A.value)})}}function r(s,A,l,u){Promise.resolve(u).then(function(m){s({value:m,done:l})},A)}}function Bpe(e){return new oa(Promise.resolve(new Ur(e)))}function Cb(e){return new oa(Promise.resolve(new Tr(e)))}function hc(e){return new Ur(e)}function Io(e){return new Tr(e)}function _pe(e){let n=e().next();if(n instanceof Promise)return new oa(n.then((t)=>t.value));return n.value}var hpe,TL=(e,n,t=hpe)=>{let a=n.isOk()?{type:"Ok",value:n.value}:{type:"Err",value:n.error},r=t.withStackTrace?Error().stack:void 0;return{data:a,message:e,stack:r}},oa,zZe,HZe,PZe,OL=(e)=>{let n=hc([]);for(let t of e)if(t.isErr()){n=Io(t.error);break}else n.map((a)=>a.push(t.value));return n},kpe=(e)=>oa.fromSafePromise(Promise.all(e)).andThen(OL),YL=(e)=>{let n=hc([]);for(let t of e)if(t.isErr()&&n.isErr())n.error.push(t.error);else if(t.isErr()&&n.isOk())n=Io([t.error]);else if(t.isOk()&&n.isOk())n.value.push(t.value);return n},Cpe=(e)=>oa.fromSafePromise(Promise.all(e)).andThen(YL),vt=void 0,Ur,Tr,UZe,Hn,ie,Av,me,Nt,ma;var Vt=h(()=>{hpe={withStackTrace:!1};oa=class oa{constructor(e){this._promise=e}static fromSafePromise(e){let n=e.then((t)=>new Ur(t));return new oa(n)}static fromPromise(e,n){let t=e.then((a)=>new Ur(a)).catch((a)=>new Tr(n(a)));return new oa(t)}static fromThrowable(e,n){return(...t)=>{return new oa((()=>id(this,void 0,void 0,function*(){try{return new Ur(yield e(...t))}catch(a){return new Tr(n?n(a):a)}}))())}}static combine(e){return kpe(e)}static combineWithAllErrors(e){return Cpe(e)}map(e){return new oa(this._promise.then((n)=>id(this,void 0,void 0,function*(){if(n.isErr())return new Tr(n.error);return new Ur(yield e(n.value))})))}andThrough(e){return new oa(this._promise.then((n)=>id(this,void 0,void 0,function*(){if(n.isErr())return new Tr(n.error);let t=yield e(n.value);if(t.isErr())return new Tr(t.error);return new Ur(n.value)})))}andTee(e){return new oa(this._promise.then((n)=>id(this,void 0,void 0,function*(){if(n.isErr())return new Tr(n.error);try{yield e(n.value)}catch(t){}return new Ur(n.value)})))}orTee(e){return new oa(this._promise.then((n)=>id(this,void 0,void 0,function*(){if(n.isOk())return new Ur(n.value);try{yield e(n.error)}catch(t){}return new Tr(n.error)})))}mapErr(e){return new oa(this._promise.then((n)=>id(this,void 0,void 0,function*(){if(n.isOk())return new Ur(n.value);return new Tr(yield e(n.error))})))}andThen(e){return new oa(this._promise.then((n)=>{if(n.isErr())return new Tr(n.error);let t=e(n.value);return t instanceof oa?t._promise:t}))}orElse(e){return new oa(this._promise.then((n)=>id(this,void 0,void 0,function*(){if(n.isErr())return e(n.error);return new Ur(n.value)})))}match(e,n){return this._promise.then((t)=>t.match(e,n))}unwrapOr(e){return this._promise.then((n)=>n.unwrapOr(e))}safeUnwrap(){return UL(this,arguments,function*(){return yield gs(yield gs(yield*ype(wpe(yield gs(this._promise.then((n)=>n.safeUnwrap()))))))})}then(e,n){return this._promise.then(e,n)}[Symbol.asyncIterator](){return UL(this,arguments,function*(){let n=yield gs(this._promise);if(n.isErr())yield yield gs(Cb(n.error));return yield gs(n.value)})}};zZe=oa.fromPromise,HZe=oa.fromSafePromise,PZe=oa.fromThrowable;(function(e){function n(r,s){return(...A)=>{try{let l=r(...A);return hc(l)}catch(l){return Io(s?s(l):l)}}}e.fromThrowable=n;function t(r){return OL(r)}e.combine=t;function a(r){return YL(r)}e.combineWithAllErrors=a})(vt||(vt={}));Ur=class Ur{constructor(e){this.value=e}isOk(){return!0}isErr(){return!this.isOk()}map(e){return hc(e(this.value))}mapErr(e){return hc(this.value)}andThen(e){return e(this.value)}andThrough(e){return e(this.value).map((n)=>this.value)}andTee(e){try{e(this.value)}catch(n){}return hc(this.value)}orTee(e){return hc(this.value)}orElse(e){return hc(this.value)}asyncAndThen(e){return e(this.value)}asyncAndThrough(e){return e(this.value).map(()=>this.value)}asyncMap(e){return oa.fromSafePromise(e(this.value))}unwrapOr(e){return this.value}match(e,n){return e(this.value)}safeUnwrap(){let e=this.value;return function*(){return e}()}_unsafeUnwrap(e){return this.value}_unsafeUnwrapErr(e){throw TL("Called `_unsafeUnwrapErr` on an Ok",this,e)}*[Symbol.iterator](){return this.value}};Tr=class Tr{constructor(e){this.error=e}isOk(){return!1}isErr(){return!this.isOk()}map(e){return Io(this.error)}mapErr(e){return Io(e(this.error))}andThrough(e){return Io(this.error)}andTee(e){return Io(this.error)}orTee(e){try{e(this.error)}catch(n){}return Io(this.error)}andThen(e){return Io(this.error)}orElse(e){return e(this.error)}asyncAndThen(e){return Cb(this.error)}asyncAndThrough(e){return Cb(this.error)}asyncMap(e){return Cb(this.error)}unwrapOr(e){return e}match(e,n){return n(this.error)}safeUnwrap(){let e=this.error;return function*(){throw yield Io(e),Error("Do not use this generator out of `safeTry`")}()}_unsafeUnwrap(e){throw TL("Called `_unsafeUnwrap` on an Err",this,e)}_unsafeUnwrapErr(e){return this.error}*[Symbol.iterator](){let e=this;return yield e,e}};UZe=vt.fromThrowable;Hn=oa,ie=Io,Av=Cb,me=hc,Nt=Bpe,ma=_pe});var jn,lv,xe,bs=(e)=>{switch(typeof e){case"undefined":return xe.undefined;case"string":return xe.string;case"number":return Number.isNaN(e)?xe.nan:xe.number;case"boolean":return xe.boolean;case"function":return xe.function;case"bigint":return xe.bigint;case"symbol":return xe.symbol;case"object":if(Array.isArray(e))return xe.array;if(e===null)return xe.null;if(e.then&&typeof e.then==="function"&&e.catch&&typeof e.catch==="function")return xe.promise;if(typeof Map<"u"&&e instanceof Map)return xe.map;if(typeof Set<"u"&&e instanceof Set)return xe.set;if(typeof Date<"u"&&e instanceof Date)return xe.date;return xe.object;default:return xe.unknown}};var _b=h(()=>{(function(e){e.assertEqual=(r)=>{};function n(r){}e.assertIs=n;function t(r){throw Error()}e.assertNever=t,e.arrayToEnum=(r)=>{let s={};for(let A of r)s[A]=A;return s},e.getValidEnumValues=(r)=>{let s=e.objectKeys(r).filter((l)=>typeof r[r[l]]!=="number"),A={};for(let l of s)A[l]=r[l];return e.objectValues(A)},e.objectValues=(r)=>{return e.objectKeys(r).map(function(s){return r[s]})},e.objectKeys=typeof Object.keys==="function"?(r)=>Object.keys(r):(r)=>{let s=[];for(let A in r)if(Object.prototype.hasOwnProperty.call(r,A))s.push(A);return s},e.find=(r,s)=>{for(let A of r)if(s(A))return A;return},e.isInteger=typeof Number.isInteger==="function"?(r)=>Number.isInteger(r):(r)=>typeof r==="number"&&Number.isFinite(r)&&Math.floor(r)===r;function a(r,s=" | "){return r.map((A)=>typeof A==="string"?`'${A}'`:A).join(s)}e.joinValues=a,e.jsonStringifyReplacer=(r,s)=>{if(typeof s==="bigint")return s.toString();return s}})(jn||(jn={}));(function(e){e.mergeShapes=(n,t)=>{return{...n,...t}}})(lv||(lv={}));xe=jn.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"])});var Ce,Epe=(e)=>{return JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:")},er;var NB=h(()=>{_b();Ce=jn.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"]);er=class er extends Error{get errors(){return this.issues}constructor(e){super();this.issues=[],this.addIssue=(t)=>{this.issues=[...this.issues,t]},this.addIssues=(t=[])=>{this.issues=[...this.issues,...t]};let n=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,n);else this.__proto__=n;this.name="ZodError",this.issues=e}format(e){let n=e||function(r){return r.message},t={_errors:[]},a=(r)=>{for(let s of r.issues)if(s.code==="invalid_union")s.unionErrors.map(a);else if(s.code==="invalid_return_type")a(s.returnTypeError);else if(s.code==="invalid_arguments")a(s.argumentsError);else if(s.path.length===0)t._errors.push(n(s));else{let A=t,l=0;while(l<s.path.length){let u=s.path[l];if(l!==s.path.length-1)A[u]=A[u]||{_errors:[]};else A[u]=A[u]||{_errors:[]},A[u]._errors.push(n(s));A=A[u],l++}}};return a(this),t}static assert(e){if(!(e instanceof er))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,jn.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=(n)=>n.message){let n={},t=[];for(let a of this.issues)if(a.path.length>0){let r=a.path[0];n[r]=n[r]||[],n[r].push(e(a))}else t.push(e(a));return{formErrors:t,fieldErrors:n}}get formErrors(){return this.flatten()}};er.create=(e)=>{return new er(e)}});var Qpe=(e,n)=>{let t;switch(e.code){case Ce.invalid_type:if(e.received===xe.undefined)t="Required";else t=`Expected ${e.expected}, received ${e.received}`;break;case Ce.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(e.expected,jn.jsonStringifyReplacer)}`;break;case Ce.unrecognized_keys:t=`Unrecognized key(s) in object: ${jn.joinValues(e.keys,", ")}`;break;case Ce.invalid_union:t="Invalid input";break;case Ce.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${jn.joinValues(e.options)}`;break;case Ce.invalid_enum_value:t=`Invalid enum value. Expected ${jn.joinValues(e.options)}, received '${e.received}'`;break;case Ce.invalid_arguments:t="Invalid function arguments";break;case Ce.invalid_return_type:t="Invalid function return type";break;case Ce.invalid_date:t="Invalid date";break;case Ce.invalid_string:if(typeof e.validation==="object")if("includes"in e.validation){if(t=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==="number")t=`${t} at one or more positions greater than or equal to ${e.validation.position}`}else if("startsWith"in e.validation)t=`Invalid input: must start with "${e.validation.startsWith}"`;else if("endsWith"in e.validation)t=`Invalid input: must end with "${e.validation.endsWith}"`;else jn.assertNever(e.validation);else if(e.validation!=="regex")t=`Invalid ${e.validation}`;else t="Invalid";break;case Ce.too_small:if(e.type==="array")t=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`;else if(e.type==="string")t=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`;else if(e.type==="number")t=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`;else if(e.type==="bigint")t=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`;else if(e.type==="date")t=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`;else t="Invalid input";break;case Ce.too_big:if(e.type==="array")t=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`;else if(e.type==="string")t=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`;else if(e.type==="number")t=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`;else if(e.type==="bigint")t=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`;else if(e.type==="date")t=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`;else t="Invalid input";break;case Ce.custom:t="Invalid input";break;case Ce.invalid_intersection_types:t="Intersection results could not be merged";break;case Ce.not_multiple_of:t=`Number must be a multiple of ${e.multipleOf}`;break;case Ce.not_finite:t="Number must be finite";break;default:t=n.defaultError,jn.assertNever(e)}return{message:t}},yc;var dv=h(()=>{NB();_b();yc=Qpe});function Ipe(e){KL=e}function wp(){return KL}var KL;var jB=h(()=>{dv();KL=yc});function $e(e,n){let t=wp(),a=Eb({issueData:n,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,t,t===yc?void 0:yc].filter((r)=>!!r)});e.common.issues.push(a)}class Ai{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray(e,n){let t=[];for(let a of n){if(a.status==="aborted")return tn;if(a.status==="dirty")e.dirty();t.push(a.value)}return{status:e.value,value:t}}static async mergeObjectAsync(e,n){let t=[];for(let a of n){let r=await a.key,s=await a.value;t.push({key:r,value:s})}return Ai.mergeObjectSync(e,t)}static mergeObjectSync(e,n){let t={};for(let a of n){let{key:r,value:s}=a;if(r.status==="aborted")return tn;if(s.status==="aborted")return tn;if(r.status==="dirty")e.dirty();if(s.status==="dirty")e.dirty();if(r.value!=="__proto__"&&(typeof s.value<"u"||a.alwaysSet))t[r.value]=s.value}return{status:e.value,value:t}}}var Eb=(e)=>{let{data:n,path:t,errorMaps:a,issueData:r}=e,s=[...t,...r.path||[]],A={...r,path:s};if(r.message!==void 0)return{...r,path:s,message:r.message};let l="",u=a.filter((m)=>!!m).slice().reverse();for(let m of u)l=m(A,{data:n,defaultError:l}).message;return{...r,path:s,message:l}},vpe,tn,rd=(e)=>({status:"dirty",value:e}),Qi=(e)=>({status:"valid",value:e}),LB=(e)=>e.status==="aborted",MB=(e)=>e.status==="dirty",jA=(e)=>e.status==="valid",Bp=(e)=>typeof Promise<"u"&&e instanceof Promise;var uv=h(()=>{jB();dv();vpe=[];tn=Object.freeze({status:"aborted"})});var ZL=()=>{};var Te;var JL=h(()=>{(function(e){e.errToObj=(n)=>typeof n==="string"?{message:n}:n||{},e.toString=(n)=>typeof n==="string"?n:n?.message})(Te||(Te={}))});class Fo{constructor(e,n,t,a){this._cachedPath=[],this.parent=e,this.data=n,this._path=t,this._key=a}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}function _n(e){if(!e)return{};let{errorMap:n,invalid_type_error:t,required_error:a,description:r}=e;if(n&&(t||a))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(n)return{errorMap:n,description:r};return{errorMap:(A,l)=>{let{message:u}=e;if(A.code==="invalid_enum_value")return{message:u??l.defaultError};if(typeof l.data>"u")return{message:u??a??l.defaultError};if(A.code!=="invalid_type")return{message:l.defaultError};return{message:u??t??l.defaultError}},description:r}}class vn{get description(){return this._def.description}_getType(e){return bs(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:bs(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ai,ctx:{common:e.parent.common,data:e.data,parsedType:bs(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(Bp(n))throw Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let t=this.safeParse(e,n);if(t.success)return t.data;throw t.error}safeParse(e,n){let t={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:bs(e)},a=this._parseSync({data:e,path:t.path,parent:t});return WL(t,a)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:bs(e)};if(!this["~standard"].async)try{let t=this._parseSync({data:e,path:[],parent:n});return jA(t)?{value:t.value}:{issues:n.common.issues}}catch(t){if(t?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then((t)=>jA(t)?{value:t.value}:{issues:n.common.issues})}async parseAsync(e,n){let t=await this.safeParseAsync(e,n);if(t.success)return t.data;throw t.error}async safeParseAsync(e,n){let t={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:bs(e)},a=this._parse({data:e,path:t.path,parent:t}),r=await(Bp(a)?a:Promise.resolve(a));return WL(t,r)}refine(e,n){let t=(a)=>{if(typeof n==="string"||typeof n>"u")return{message:n};else if(typeof n==="function")return n(a);else return n};return this._refinement((a,r)=>{let s=e(a),A=()=>r.addIssue({code:Ce.custom,...t(a)});if(typeof Promise<"u"&&s instanceof Promise)return s.then((l)=>{if(!l)return A(),!1;else return!0});if(!s)return A(),!1;else return!0})}refinement(e,n){return this._refinement((t,a)=>{if(!e(t))return a.addIssue(typeof n==="function"?n(t,a):n),!1;else return!0})}_refinement(e){return new So({schema:this,typeName:on.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:(n)=>this["~validate"](n)}}optional(){return Do.create(this,this._def)}nullable(){return Bc.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return xo.create(this)}promise(){return Ad.create(this,this._def)}or(e){return Ip.create([this,e],this._def)}and(e){return vp.create(this,e,this._def)}transform(e){return new So({..._n(this._def),schema:this,typeName:on.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e==="function"?e:()=>e;return new Sp({..._n(this._def),innerType:this,defaultValue:n,typeName:on.ZodDefault})}brand(){return new qB({typeName:on.ZodBranded,type:this,..._n(this._def)})}catch(e){let n=typeof e==="function"?e:()=>e;return new $p({..._n(this._def),innerType:this,catchValue:n,typeName:on.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return Fb.create(this,e)}readonly(){return Np.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}function eM(e){let n="[0-5]\\d";if(e.precision)n=`${n}\\.\\d{${e.precision}}`;else if(e.precision==null)n=`${n}(\\.\\d+)?`;let t=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${n})${t}`}function Tpe(e){return new RegExp(`^${eM(e)}$`)}function nM(e){let n=`${XL}T${eM(e)}`,t=[];if(t.push(e.local?"Z?":"Z"),e.offset)t.push("([+-]\\d{2}:?\\d{2})");return n=`${n}(${t.join("|")})`,new RegExp(`^${n}$`)}function Ope(e,n){if((n==="v4"||!n)&&Gpe.test(e))return!0;if((n==="v6"||!n)&&Rpe.test(e))return!0;return!1}function Ype(e,n){if(!Npe.test(e))return!1;try{let[t]=e.split(".");if(!t)return!1;let a=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),r=JSON.parse(atob(a));if(typeof r!=="object"||r===null)return!1;if("typ"in r&&r?.typ!=="JWT")return!1;if(!r.alg)return!1;if(n&&r.alg!==n)return!1;return!0}catch{return!1}}function Kpe(e,n){if((n==="v4"||!n)&&qpe.test(e))return!0;if((n==="v6"||!n)&&zpe.test(e))return!0;return!1}function Zpe(e,n){let t=(e.toString().split(".")[1]||"").length,a=(n.toString().split(".")[1]||"").length,r=t>a?t:a,s=Number.parseInt(e.toFixed(r).replace(".","")),A=Number.parseInt(n.toFixed(r).replace(".",""));return s%A/10**r}function kp(e){if(e instanceof Xt){let n={};for(let t in e.shape){let a=e.shape[t];n[t]=Do.create(kp(a))}return new Xt({...e._def,shape:()=>n})}else if(e instanceof xo)return new xo({...e._def,type:kp(e.element)});else if(e instanceof Do)return Do.create(kp(e.unwrap()));else if(e instanceof Bc)return Bc.create(kp(e.unwrap()));else if(e instanceof hs)return hs.create(e.items.map((n)=>kp(n)));else return e}function mv(e,n){let t=bs(e),a=bs(n);if(e===n)return{valid:!0,data:e};else if(t===xe.object&&a===xe.object){let r=jn.objectKeys(n),s=jn.objectKeys(e).filter((l)=>r.indexOf(l)!==-1),A={...e,...n};for(let l of s){let u=mv(e[l],n[l]);if(!u.valid)return{valid:!1};A[l]=u.data}return{valid:!0,data:A}}else if(t===xe.array&&a===xe.array){if(e.length!==n.length)return{valid:!1};let r=[];for(let s=0;s<e.length;s++){let A=e[s],l=n[s],u=mv(A,l);if(!u.valid)return{valid:!1};r.push(u.data)}return{valid:!0,data:r}}else if(t===xe.date&&a===xe.date&&+e===+n)return{valid:!0,data:e};else return{valid:!1}}function tM(e,n){return new qA({values:e,typeName:on.ZodEnum,..._n(n)})}function VL(e,n){let t=typeof e==="function"?e(n):typeof e==="string"?{message:e}:e;return typeof t==="string"?{message:t}:t}function aM(e,n={},t){if(e)return sd.create().superRefine((a,r)=>{let s=e(a);if(s instanceof Promise)return s.then((A)=>{if(!A){let l=VL(n,a),u=l.fatal??t??!0;r.addIssue({code:"custom",...l,fatal:u})}});if(!s){let A=VL(n,a),l=A.fatal??t??!0;r.addIssue({code:"custom",...A,fatal:l})}return});return sd.create()}var WL=(e,n)=>{if(jA(n))return{success:!0,data:n.value};else{if(!e.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new er(e.common.issues);return this._error=t,this._error}}}},xpe,Dpe,Fpe,Spe,$pe,Npe,jpe,Lpe,Mpe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",pv,Gpe,qpe,Rpe,zpe,Hpe,Ppe,XL="((\\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])))",Upe,vo,MA,GA,_p,od,Qb,Ep,Qp,sd,LA,fs,Ib,xo,Xt,Ip,wc=(e)=>{if(e instanceof xp)return wc(e.schema);else if(e instanceof So)return wc(e.innerType());else if(e instanceof Dp)return[e.value];else if(e instanceof qA)return e.options;else if(e instanceof Fp)return jn.objectValues(e.enum);else if(e instanceof Sp)return wc(e._def.innerType);else if(e instanceof Ep)return[void 0];else if(e instanceof Qp)return[null];else if(e instanceof Do)return[void 0,...wc(e.unwrap())];else if(e instanceof Bc)return[null,...wc(e.unwrap())];else if(e instanceof qB)return wc(e.unwrap());else if(e instanceof Np)return wc(e.unwrap());else if(e instanceof $p)return wc(e._def.innerType);else return[]},GB,vp,hs,vb,xb,cd,Cp,xp,Dp,qA,Fp,Ad,So,Do,Bc,Sp,$p,Db,Jpe,qB,Fb,Np,Wpe,on,Vpe=(e,n={message:`Input not instance of ${e.name}`})=>aM((t)=>t instanceof e,n),iM,rM,Xpe,eme,oM,nme,tme,ame,ime,rme,ome,sme,cme,Ame,lme,dme,ume,pme,mme,gme,bme,fme,hme,yme,wme,Bme,kme,Cme,_me,Eme,Qme,Ime,vme,xme,Dme=()=>iM().optional(),Fme=()=>rM().optional(),Sme=()=>oM().optional(),$me,Nme;var sM=h(()=>{NB();jB();JL();uv();_b();xpe=/^c[^\s-]{8,}$/i,Dpe=/^[0-9a-z]+$/,Fpe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Spe=/^[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,$pe=/^[a-z0-9_-]{21}$/i,Npe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,jpe=/^[-+]?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)?)??$/,Lpe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Gpe=/^(?:(?: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])$/,qpe=/^(?:(?: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])$/,Rpe=/^(([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]))$/,zpe=/^(([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])$/,Hpe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ppe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Upe=new RegExp(`^${XL}$`);vo=class vo extends vn{_parse(e){if(this._def.coerce)e.data=String(e.data);if(this._getType(e)!==xe.string){let r=this._getOrReturnCtx(e);return $e(r,{code:Ce.invalid_type,expected:xe.string,received:r.parsedType}),tn}let t=new Ai,a=void 0;for(let r of this._def.checks)if(r.kind==="min"){if(e.data.length<r.value)a=this._getOrReturnCtx(e,a),$e(a,{code:Ce.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty()}else if(r.kind==="max"){if(e.data.length>r.value)a=this._getOrReturnCtx(e,a),$e(a,{code:Ce.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty()}else if(r.kind==="length"){let s=e.data.length>r.value,A=e.data.length<r.value;if(s||A){if(a=this._getOrReturnCtx(e,a),s)$e(a,{code:Ce.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message});else if(A)$e(a,{code:Ce.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message});t.dirty()}}else if(r.kind==="email"){if(!Lpe.test(e.data))a=this._getOrReturnCtx(e,a),$e(a,{validation:"email",code:Ce.invalid_string,message:r.message}),t.dirty()}else if(r.kind==="emoji"){if(!pv)pv=new RegExp(Mpe,"u");if(!pv.test(e.data))a=this._getOrReturnCtx(e,a),$e(a,{validation:"emoji",code:Ce.invalid_string,message:r.message}),t.dirty()}else if(r.kind==="uuid"){if(!Spe.test(e.data))a=this._getOrReturnCtx(e,a),$e(a,{validation:"uuid",code:Ce.invalid_string,message:r.message}),t.dirty()}else if(r.kind==="nanoid"){if(!$pe.test(e.data))a=this._getOrReturnCtx(e,a),$e(a,{validation:"nanoid",code:Ce.invalid_string,message:r.message}),t.dirty()}else if(r.kind==="cuid"){if(!xpe.test(e.data))a=this._getOrReturnCtx(e,a),$e(a,{validation:"cuid",code:Ce.invalid_string,message:r.message}),t.dirty()}else if(r.kind==="cuid2"){if(!Dpe.test(e.data))a=this._getOrReturnCtx(e,a),$e(a,{validation:"cuid2",code:Ce.invalid_string,message:r.message}),t.dirty()}else if(r.kind==="ulid"){if(!Fpe.test(e.data))a=this._getOrReturnCtx(e,a),$e(a,{validation:"ulid",code:Ce.invalid_string,message:r.message}),t.dirty()}else if(r.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),$e(a,{validation:"url",code:Ce.invalid_string,message:r.message}),t.dirty()}else if(r.kind==="regex"){if(r.regex.lastIndex=0,!r.regex.test(e.data))a=this._getOrReturnCtx(e,a),$e(a,{validation:"regex",code:Ce.invalid_string,message:r.message}),t.dirty()}else if(r.kind==="trim")e.data=e.data.trim();else if(r.kind==="includes"){if(!e.data.includes(r.value,r.position))a=this._getOrReturnCtx(e,a),$e(a,{code:Ce.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()}else if(r.kind==="toLowerCase")e.data=e.data.toLowerCase();else if(r.kind==="toUpperCase")e.data=e.data.toUpperCase();else if(r.kind==="startsWith"){if(!e.data.startsWith(r.value))a=this._getOrReturnCtx(e,a),$e(a,{code:Ce.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()}else if(r.kind==="endsWith"){if(!e.data.endsWith(r.value))a=this._getOrReturnCtx(e,a),$e(a,{code:Ce.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()}else if(r.kind==="datetime"){if(!nM(r).test(e.data))a=this._getOrReturnCtx(e,a),$e(a,{code:Ce.invalid_string,validation:"datetime",message:r.message}),t.dirty()}else if(r.kind==="date"){if(!Upe.test(e.data))a=this._getOrReturnCtx(e,a),$e(a,{code:Ce.invalid_string,validation:"date",message:r.message}),t.dirty()}else if(r.kind==="time"){if(!Tpe(r).test(e.data))a=this._getOrReturnCtx(e,a),$e(a,{code:Ce.invalid_string,validation:"time",message:r.message}),t.dirty()}else if(r.kind==="duration"){if(!jpe.test(e.data))a=this._getOrReturnCtx(e,a),$e(a,{validation:"duration",code:Ce.invalid_string,message:r.message}),t.dirty()}else if(r.kind==="ip"){if(!Ope(e.data,r.version))a=this._getOrReturnCtx(e,a),$e(a,{validation:"ip",code:Ce.invalid_string,message:r.message}),t.dirty()}else if(r.kind==="jwt"){if(!Ype(e.data,r.alg))a=this._getOrReturnCtx(e,a),$e(a,{validation:"jwt",code:Ce.invalid_string,message:r.message}),t.dirty()}else if(r.kind==="cidr"){if(!Kpe(e.data,r.version))a=this._getOrReturnCtx(e,a),$e(a,{validation:"cidr",code:Ce.invalid_string,message:r.message}),t.dirty()}else if(r.kind==="base64"){if(!Hpe.test(e.data))a=this._getOrReturnCtx(e,a),$e(a,{validation:"base64",code:Ce.invalid_string,message:r.message}),t.dirty()}else if(r.kind==="base64url"){if(!Ppe.test(e.data))a=this._getOrReturnCtx(e,a),$e(a,{validation:"base64url",code:Ce.invalid_string,message:r.message}),t.dirty()}else jn.assertNever(r);return{status:t.value,value:e.data}}_regex(e,n,t){return this.refinement((a)=>e.test(a),{validation:n,code:Ce.invalid_string,...Te.errToObj(t)})}_addCheck(e){return new vo({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Te.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Te.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Te.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Te.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Te.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Te.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Te.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Te.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Te.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Te.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Te.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Te.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Te.errToObj(e)})}datetime(e){if(typeof e==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e});return this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...Te.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){if(typeof e==="string")return this._addCheck({kind:"time",precision:null,message:e});return this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...Te.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...Te.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...Te.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...Te.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...Te.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...Te.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...Te.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...Te.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...Te.errToObj(n)})}nonempty(e){return this.min(1,Te.errToObj(e))}trim(){return new vo({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new vo({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new vo({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((e)=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find((e)=>e.kind==="date")}get isTime(){return!!this._def.checks.find((e)=>e.kind==="time")}get isDuration(){return!!this._def.checks.find((e)=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find((e)=>e.kind==="email")}get isURL(){return!!this._def.checks.find((e)=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find((e)=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find((e)=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find((e)=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find((e)=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find((e)=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find((e)=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find((e)=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find((e)=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find((e)=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find((e)=>e.kind==="base64url")}get minLength(){let e=null;for(let n of this._def.checks)if(n.kind==="min"){if(e===null||n.value>e)e=n.value}return e}get maxLength(){let e=null;for(let n of this._def.checks)if(n.kind==="max"){if(e===null||n.value<e)e=n.value}return e}};vo.create=(e)=>{return new vo({checks:[],typeName:on.ZodString,coerce:e?.coerce??!1,..._n(e)})};MA=class MA extends vn{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);if(this._getType(e)!==xe.number){let r=this._getOrReturnCtx(e);return $e(r,{code:Ce.invalid_type,expected:xe.number,received:r.parsedType}),tn}let t=void 0,a=new Ai;for(let r of this._def.checks)if(r.kind==="int"){if(!jn.isInteger(e.data))t=this._getOrReturnCtx(e,t),$e(t,{code:Ce.invalid_type,expected:"integer",received:"float",message:r.message}),a.dirty()}else if(r.kind==="min"){if(r.inclusive?e.data<r.value:e.data<=r.value)t=this._getOrReturnCtx(e,t),$e(t,{code:Ce.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()}else if(r.kind==="max"){if(r.inclusive?e.data>r.value:e.data>=r.value)t=this._getOrReturnCtx(e,t),$e(t,{code:Ce.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()}else if(r.kind==="multipleOf"){if(Zpe(e.data,r.value)!==0)t=this._getOrReturnCtx(e,t),$e(t,{code:Ce.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()}else if(r.kind==="finite"){if(!Number.isFinite(e.data))t=this._getOrReturnCtx(e,t),$e(t,{code:Ce.not_finite,message:r.message}),a.dirty()}else jn.assertNever(r);return{status:a.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,Te.toString(n))}gt(e,n){return this.setLimit("min",e,!1,Te.toString(n))}lte(e,n){return this.setLimit("max",e,!0,Te.toString(n))}lt(e,n){return this.setLimit("max",e,!1,Te.toString(n))}setLimit(e,n,t,a){return new MA({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:t,message:Te.toString(a)}]})}_addCheck(e){return new MA({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Te.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Te.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Te.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Te.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Te.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:Te.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:Te.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Te.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Te.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)if(n.kind==="min"){if(e===null||n.value>e)e=n.value}return e}get maxValue(){let e=null;for(let n of this._def.checks)if(n.kind==="max"){if(e===null||n.value<e)e=n.value}return e}get isInt(){return!!this._def.checks.find((e)=>e.kind==="int"||e.kind==="multipleOf"&&jn.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let t of this._def.checks)if(t.kind==="finite"||t.kind==="int"||t.kind==="multipleOf")return!0;else if(t.kind==="min"){if(n===null||t.value>n)n=t.value}else if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return Number.isFinite(n)&&Number.isFinite(e)}};MA.create=(e)=>{return new MA({checks:[],typeName:on.ZodNumber,coerce:e?.coerce||!1,..._n(e)})};GA=class GA extends vn{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)!==xe.bigint)return this._getInvalidInput(e);let t=void 0,a=new Ai;for(let r of this._def.checks)if(r.kind==="min"){if(r.inclusive?e.data<r.value:e.data<=r.value)t=this._getOrReturnCtx(e,t),$e(t,{code:Ce.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()}else if(r.kind==="max"){if(r.inclusive?e.data>r.value:e.data>=r.value)t=this._getOrReturnCtx(e,t),$e(t,{code:Ce.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()}else if(r.kind==="multipleOf"){if(e.data%r.value!==BigInt(0))t=this._getOrReturnCtx(e,t),$e(t,{code:Ce.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()}else jn.assertNever(r);return{status:a.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return $e(n,{code:Ce.invalid_type,expected:xe.bigint,received:n.parsedType}),tn}gte(e,n){return this.setLimit("min",e,!0,Te.toString(n))}gt(e,n){return this.setLimit("min",e,!1,Te.toString(n))}lte(e,n){return this.setLimit("max",e,!0,Te.toString(n))}lt(e,n){return this.setLimit("max",e,!1,Te.toString(n))}setLimit(e,n,t,a){return new GA({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:t,message:Te.toString(a)}]})}_addCheck(e){return new GA({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Te.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Te.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Te.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Te.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:Te.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)if(n.kind==="min"){if(e===null||n.value>e)e=n.value}return e}get maxValue(){let e=null;for(let n of this._def.checks)if(n.kind==="max"){if(e===null||n.value<e)e=n.value}return e}};GA.create=(e)=>{return new GA({checks:[],typeName:on.ZodBigInt,coerce:e?.coerce??!1,..._n(e)})};_p=class _p extends vn{_parse(e){if(this._def.coerce)e.data=Boolean(e.data);if(this._getType(e)!==xe.boolean){let t=this._getOrReturnCtx(e);return $e(t,{code:Ce.invalid_type,expected:xe.boolean,received:t.parsedType}),tn}return Qi(e.data)}};_p.create=(e)=>{return new _p({typeName:on.ZodBoolean,coerce:e?.coerce||!1,..._n(e)})};od=class od extends vn{_parse(e){if(this._def.coerce)e.data=new Date(e.data);if(this._getType(e)!==xe.date){let r=this._getOrReturnCtx(e);return $e(r,{code:Ce.invalid_type,expected:xe.date,received:r.parsedType}),tn}if(Number.isNaN(e.data.getTime())){let r=this._getOrReturnCtx(e);return $e(r,{code:Ce.invalid_date}),tn}let t=new Ai,a=void 0;for(let r of this._def.checks)if(r.kind==="min"){if(e.data.getTime()<r.value)a=this._getOrReturnCtx(e,a),$e(a,{code:Ce.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),t.dirty()}else if(r.kind==="max"){if(e.data.getTime()>r.value)a=this._getOrReturnCtx(e,a),$e(a,{code:Ce.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),t.dirty()}else jn.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new od({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:Te.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:Te.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)if(n.kind==="min"){if(e===null||n.value>e)e=n.value}return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)if(n.kind==="max"){if(e===null||n.value<e)e=n.value}return e!=null?new Date(e):null}};od.create=(e)=>{return new od({checks:[],coerce:e?.coerce||!1,typeName:on.ZodDate,..._n(e)})};Qb=class Qb extends vn{_parse(e){if(this._getType(e)!==xe.symbol){let t=this._getOrReturnCtx(e);return $e(t,{code:Ce.invalid_type,expected:xe.symbol,received:t.parsedType}),tn}return Qi(e.data)}};Qb.create=(e)=>{return new Qb({typeName:on.ZodSymbol,..._n(e)})};Ep=class Ep extends vn{_parse(e){if(this._getType(e)!==xe.undefined){let t=this._getOrReturnCtx(e);return $e(t,{code:Ce.invalid_type,expected:xe.undefined,received:t.parsedType}),tn}return Qi(e.data)}};Ep.create=(e)=>{return new Ep({typeName:on.ZodUndefined,..._n(e)})};Qp=class Qp extends vn{_parse(e){if(this._getType(e)!==xe.null){let t=this._getOrReturnCtx(e);return $e(t,{code:Ce.invalid_type,expected:xe.null,received:t.parsedType}),tn}return Qi(e.data)}};Qp.create=(e)=>{return new Qp({typeName:on.ZodNull,..._n(e)})};sd=class sd extends vn{constructor(){super(...arguments);this._any=!0}_parse(e){return Qi(e.data)}};sd.create=(e)=>{return new sd({typeName:on.ZodAny,..._n(e)})};LA=class LA extends vn{constructor(){super(...arguments);this._unknown=!0}_parse(e){return Qi(e.data)}};LA.create=(e)=>{return new LA({typeName:on.ZodUnknown,..._n(e)})};fs=class fs extends vn{_parse(e){let n=this._getOrReturnCtx(e);return $e(n,{code:Ce.invalid_type,expected:xe.never,received:n.parsedType}),tn}};fs.create=(e)=>{return new fs({typeName:on.ZodNever,..._n(e)})};Ib=class Ib extends vn{_parse(e){if(this._getType(e)!==xe.undefined){let t=this._getOrReturnCtx(e);return $e(t,{code:Ce.invalid_type,expected:xe.void,received:t.parsedType}),tn}return Qi(e.data)}};Ib.create=(e)=>{return new Ib({typeName:on.ZodVoid,..._n(e)})};xo=class xo extends vn{_parse(e){let{ctx:n,status:t}=this._processInputParams(e),a=this._def;if(n.parsedType!==xe.array)return $e(n,{code:Ce.invalid_type,expected:xe.array,received:n.parsedType}),tn;if(a.exactLength!==null){let s=n.data.length>a.exactLength.value,A=n.data.length<a.exactLength.value;if(s||A)$e(n,{code:s?Ce.too_big:Ce.too_small,minimum:A?a.exactLength.value:void 0,maximum:s?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),t.dirty()}if(a.minLength!==null){if(n.data.length<a.minLength.value)$e(n,{code:Ce.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),t.dirty()}if(a.maxLength!==null){if(n.data.length>a.maxLength.value)$e(n,{code:Ce.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),t.dirty()}if(n.common.async)return Promise.all([...n.data].map((s,A)=>{return a.type._parseAsync(new Fo(n,s,n.path,A))})).then((s)=>{return Ai.mergeArray(t,s)});let r=[...n.data].map((s,A)=>{return a.type._parseSync(new Fo(n,s,n.path,A))});return Ai.mergeArray(t,r)}get element(){return this._def.type}min(e,n){return new xo({...this._def,minLength:{value:e,message:Te.toString(n)}})}max(e,n){return new xo({...this._def,maxLength:{value:e,message:Te.toString(n)}})}length(e,n){return new xo({...this._def,exactLength:{value:e,message:Te.toString(n)}})}nonempty(e){return this.min(1,e)}};xo.create=(e,n)=>{return new xo({type:e,minLength:null,maxLength:null,exactLength:null,typeName:on.ZodArray,..._n(n)})};Xt=class Xt extends vn{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),n=jn.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==xe.object){let u=this._getOrReturnCtx(e);return $e(u,{code:Ce.invalid_type,expected:xe.object,received:u.parsedType}),tn}let{status:t,ctx:a}=this._processInputParams(e),{shape:r,keys:s}=this._getCached(),A=[];if(!(this._def.catchall instanceof fs&&this._def.unknownKeys==="strip")){for(let u in a.data)if(!s.includes(u))A.push(u)}let l=[];for(let u of s){let m=r[u],b=a.data[u];l.push({key:{status:"valid",value:u},value:m._parse(new Fo(a,b,a.path,u)),alwaysSet:u in a.data})}if(this._def.catchall instanceof fs){let u=this._def.unknownKeys;if(u==="passthrough")for(let m of A)l.push({key:{status:"valid",value:m},value:{status:"valid",value:a.data[m]}});else if(u==="strict"){if(A.length>0)$e(a,{code:Ce.unrecognized_keys,keys:A}),t.dirty()}else if(u==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let m of A){let b=a.data[m];l.push({key:{status:"valid",value:m},value:u._parse(new Fo(a,b,a.path,m)),alwaysSet:m in a.data})}}if(a.common.async)return Promise.resolve().then(async()=>{let u=[];for(let m of l){let b=await m.key,f=await m.value;u.push({key:b,value:f,alwaysSet:m.alwaysSet})}return u}).then((u)=>{return Ai.mergeObjectSync(t,u)});else return Ai.mergeObjectSync(t,l)}get shape(){return this._def.shape()}strict(e){return Te.errToObj,new Xt({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,t)=>{let a=this._def.errorMap?.(n,t).message??t.defaultError;if(n.code==="unrecognized_keys")return{message:Te.errToObj(e).message??a};return{message:a}}}:{}})}strip(){return new Xt({...this._def,unknownKeys:"strip"})}passthrough(){return new Xt({...this._def,unknownKeys:"passthrough"})}extend(e){return new Xt({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Xt({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:on.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new Xt({...this._def,catchall:e})}pick(e){let n={};for(let t of jn.objectKeys(e))if(e[t]&&this.shape[t])n[t]=this.shape[t];return new Xt({...this._def,shape:()=>n})}omit(e){let n={};for(let t of jn.objectKeys(this.shape))if(!e[t])n[t]=this.shape[t];return new Xt({...this._def,shape:()=>n})}deepPartial(){return kp(this)}partial(e){let n={};for(let t of jn.objectKeys(this.shape)){let a=this.shape[t];if(e&&!e[t])n[t]=a;else n[t]=a.optional()}return new Xt({...this._def,shape:()=>n})}required(e){let n={};for(let t of jn.objectKeys(this.shape))if(e&&!e[t])n[t]=this.shape[t];else{let r=this.shape[t];while(r instanceof Do)r=r._def.innerType;n[t]=r}return new Xt({...this._def,shape:()=>n})}keyof(){return tM(jn.objectKeys(this.shape))}};Xt.create=(e,n)=>{return new Xt({shape:()=>e,unknownKeys:"strip",catchall:fs.create(),typeName:on.ZodObject,..._n(n)})};Xt.strictCreate=(e,n)=>{return new Xt({shape:()=>e,unknownKeys:"strict",catchall:fs.create(),typeName:on.ZodObject,..._n(n)})};Xt.lazycreate=(e,n)=>{return new Xt({shape:e,unknownKeys:"strip",catchall:fs.create(),typeName:on.ZodObject,..._n(n)})};Ip=class Ip extends vn{_parse(e){let{ctx:n}=this._processInputParams(e),t=this._def.options;function a(r){for(let A of r)if(A.result.status==="valid")return A.result;for(let A of r)if(A.result.status==="dirty")return n.common.issues.push(...A.ctx.common.issues),A.result;let s=r.map((A)=>new er(A.ctx.common.issues));return $e(n,{code:Ce.invalid_union,unionErrors:s}),tn}if(n.common.async)return Promise.all(t.map(async(r)=>{let s={...n,common:{...n.common,issues:[]},parent:null};return{result:await r._parseAsync({data:n.data,path:n.path,parent:s}),ctx:s}})).then(a);else{let r=void 0,s=[];for(let l of t){let u={...n,common:{...n.common,issues:[]},parent:null},m=l._parseSync({data:n.data,path:n.path,parent:u});if(m.status==="valid")return m;else if(m.status==="dirty"&&!r)r={result:m,ctx:u};if(u.common.issues.length)s.push(u.common.issues)}if(r)return n.common.issues.push(...r.ctx.common.issues),r.result;let A=s.map((l)=>new er(l));return $e(n,{code:Ce.invalid_union,unionErrors:A}),tn}}get options(){return this._def.options}};Ip.create=(e,n)=>{return new Ip({options:e,typeName:on.ZodUnion,..._n(n)})};GB=class GB extends vn{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==xe.object)return $e(n,{code:Ce.invalid_type,expected:xe.object,received:n.parsedType}),tn;let t=this.discriminator,a=n.data[t],r=this.optionsMap.get(a);if(!r)return $e(n,{code:Ce.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[t]}),tn;if(n.common.async)return r._parseAsync({data:n.data,path:n.path,parent:n});else return r._parseSync({data:n.data,path:n.path,parent:n})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,t){let a=new Map;for(let r of n){let s=wc(r.shape[e]);if(!s.length)throw Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let A of s){if(a.has(A))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(A)}`);a.set(A,r)}}return new GB({typeName:on.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:a,..._n(t)})}};vp=class vp extends vn{_parse(e){let{status:n,ctx:t}=this._processInputParams(e),a=(r,s)=>{if(LB(r)||LB(s))return tn;let A=mv(r.value,s.value);if(!A.valid)return $e(t,{code:Ce.invalid_intersection_types}),tn;if(MB(r)||MB(s))n.dirty();return{status:n.value,value:A.data}};if(t.common.async)return Promise.all([this._def.left._parseAsync({data:t.data,path:t.path,parent:t}),this._def.right._parseAsync({data:t.data,path:t.path,parent:t})]).then(([r,s])=>a(r,s));else return a(this._def.left._parseSync({data:t.data,path:t.path,parent:t}),this._def.right._parseSync({data:t.data,path:t.path,parent:t}))}};vp.create=(e,n,t)=>{return new vp({left:e,right:n,typeName:on.ZodIntersection,..._n(t)})};hs=class hs extends vn{_parse(e){let{status:n,ctx:t}=this._processInputParams(e);if(t.parsedType!==xe.array)return $e(t,{code:Ce.invalid_type,expected:xe.array,received:t.parsedType}),tn;if(t.data.length<this._def.items.length)return $e(t,{code:Ce.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),tn;if(!this._def.rest&&t.data.length>this._def.items.length)$e(t,{code:Ce.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty();let r=[...t.data].map((s,A)=>{let l=this._def.items[A]||this._def.rest;if(!l)return null;return l._parse(new Fo(t,s,t.path,A))}).filter((s)=>!!s);if(t.common.async)return Promise.all(r).then((s)=>{return Ai.mergeArray(n,s)});else return Ai.mergeArray(n,r)}get items(){return this._def.items}rest(e){return new hs({...this._def,rest:e})}};hs.create=(e,n)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new hs({items:e,typeName:on.ZodTuple,rest:null,..._n(n)})};vb=class vb extends vn{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:t}=this._processInputParams(e);if(t.parsedType!==xe.object)return $e(t,{code:Ce.invalid_type,expected:xe.object,received:t.parsedType}),tn;let a=[],r=this._def.keyType,s=this._def.valueType;for(let A in t.data)a.push({key:r._parse(new Fo(t,A,t.path,A)),value:s._parse(new Fo(t,t.data[A],t.path,A)),alwaysSet:A in t.data});if(t.common.async)return Ai.mergeObjectAsync(n,a);else return Ai.mergeObjectSync(n,a)}get element(){return this._def.valueType}static create(e,n,t){if(n instanceof vn)return new vb({keyType:e,valueType:n,typeName:on.ZodRecord,..._n(t)});return new vb({keyType:vo.create(),valueType:e,typeName:on.ZodRecord,..._n(n)})}};xb=class xb extends vn{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:t}=this._processInputParams(e);if(t.parsedType!==xe.map)return $e(t,{code:Ce.invalid_type,expected:xe.map,received:t.parsedType}),tn;let a=this._def.keyType,r=this._def.valueType,s=[...t.data.entries()].map(([A,l],u)=>{return{key:a._parse(new Fo(t,A,t.path,[u,"key"])),value:r._parse(new Fo(t,l,t.path,[u,"value"]))}});if(t.common.async){let A=new Map;return Promise.resolve().then(async()=>{for(let l of s){let u=await l.key,m=await l.value;if(u.status==="aborted"||m.status==="aborted")return tn;if(u.status==="dirty"||m.status==="dirty")n.dirty();A.set(u.value,m.value)}return{status:n.value,value:A}})}else{let A=new Map;for(let l of s){let{key:u,value:m}=l;if(u.status==="aborted"||m.status==="aborted")return tn;if(u.status==="dirty"||m.status==="dirty")n.dirty();A.set(u.value,m.value)}return{status:n.value,value:A}}}};xb.create=(e,n,t)=>{return new xb({valueType:n,keyType:e,typeName:on.ZodMap,..._n(t)})};cd=class cd extends vn{_parse(e){let{status:n,ctx:t}=this._processInputParams(e);if(t.parsedType!==xe.set)return $e(t,{code:Ce.invalid_type,expected:xe.set,received:t.parsedType}),tn;let a=this._def;if(a.minSize!==null){if(t.data.size<a.minSize.value)$e(t,{code:Ce.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),n.dirty()}if(a.maxSize!==null){if(t.data.size>a.maxSize.value)$e(t,{code:Ce.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),n.dirty()}let r=this._def.valueType;function s(l){let u=new Set;for(let m of l){if(m.status==="aborted")return tn;if(m.status==="dirty")n.dirty();u.add(m.value)}return{status:n.value,value:u}}let A=[...t.data.values()].map((l,u)=>r._parse(new Fo(t,l,t.path,u)));if(t.common.async)return Promise.all(A).then((l)=>s(l));else return s(A)}min(e,n){return new cd({...this._def,minSize:{value:e,message:Te.toString(n)}})}max(e,n){return new cd({...this._def,maxSize:{value:e,message:Te.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};cd.create=(e,n)=>{return new cd({valueType:e,minSize:null,maxSize:null,typeName:on.ZodSet,..._n(n)})};Cp=class Cp extends vn{constructor(){super(...arguments);this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==xe.function)return $e(n,{code:Ce.invalid_type,expected:xe.function,received:n.parsedType}),tn;function t(A,l){return Eb({data:A,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,wp(),yc].filter((u)=>!!u),issueData:{code:Ce.invalid_arguments,argumentsError:l}})}function a(A,l){return Eb({data:A,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,wp(),yc].filter((u)=>!!u),issueData:{code:Ce.invalid_return_type,returnTypeError:l}})}let r={errorMap:n.common.contextualErrorMap},s=n.data;if(this._def.returns instanceof Ad){let A=this;return Qi(async function(...l){let u=new er([]),m=await A._def.args.parseAsync(l,r).catch((y)=>{throw u.addIssue(t(l,y)),u}),b=await Reflect.apply(s,this,m);return await A._def.returns._def.type.parseAsync(b,r).catch((y)=>{throw u.addIssue(a(b,y)),u})})}else{let A=this;return Qi(function(...l){let u=A._def.args.safeParse(l,r);if(!u.success)throw new er([t(l,u.error)]);let m=Reflect.apply(s,this,u.data),b=A._def.returns.safeParse(m,r);if(!b.success)throw new er([a(m,b.error)]);return b.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Cp({...this._def,args:hs.create(e).rest(LA.create())})}returns(e){return new Cp({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,t){return new Cp({args:e?e:hs.create([]).rest(LA.create()),returns:n||LA.create(),typeName:on.ZodFunction,..._n(t)})}};xp=class xp extends vn{get schema(){return this._def.getter()}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};xp.create=(e,n)=>{return new xp({getter:e,typeName:on.ZodLazy,..._n(n)})};Dp=class Dp extends vn{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return $e(n,{received:n.data,code:Ce.invalid_literal,expected:this._def.value}),tn}return{status:"valid",value:e.data}}get value(){return this._def.value}};Dp.create=(e,n)=>{return new Dp({value:e,typeName:on.ZodLiteral,..._n(n)})};qA=class qA extends vn{_parse(e){if(typeof e.data!=="string"){let n=this._getOrReturnCtx(e),t=this._def.values;return $e(n,{expected:jn.joinValues(t),received:n.parsedType,code:Ce.invalid_type}),tn}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),t=this._def.values;return $e(n,{received:n.data,code:Ce.invalid_enum_value,options:t}),tn}return Qi(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return qA.create(e,{...this._def,...n})}exclude(e,n=this._def){return qA.create(this.options.filter((t)=>!e.includes(t)),{...this._def,...n})}};qA.create=tM;Fp=class Fp extends vn{_parse(e){let n=jn.getValidEnumValues(this._def.values),t=this._getOrReturnCtx(e);if(t.parsedType!==xe.string&&t.parsedType!==xe.number){let a=jn.objectValues(n);return $e(t,{expected:jn.joinValues(a),received:t.parsedType,code:Ce.invalid_type}),tn}if(!this._cache)this._cache=new Set(jn.getValidEnumValues(this._def.values));if(!this._cache.has(e.data)){let a=jn.objectValues(n);return $e(t,{received:t.data,code:Ce.invalid_enum_value,options:a}),tn}return Qi(e.data)}get enum(){return this._def.values}};Fp.create=(e,n)=>{return new Fp({values:e,typeName:on.ZodNativeEnum,..._n(n)})};Ad=class Ad extends vn{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==xe.promise&&n.common.async===!1)return $e(n,{code:Ce.invalid_type,expected:xe.promise,received:n.parsedType}),tn;let t=n.parsedType===xe.promise?n.data:Promise.resolve(n.data);return Qi(t.then((a)=>{return this._def.type.parseAsync(a,{path:n.path,errorMap:n.common.contextualErrorMap})}))}};Ad.create=(e,n)=>{return new Ad({type:e,typeName:on.ZodPromise,..._n(n)})};So=class So extends vn{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===on.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:t}=this._processInputParams(e),a=this._def.effect||null,r={addIssue:(s)=>{if($e(t,s),s.fatal)n.abort();else n.dirty()},get path(){return t.path}};if(r.addIssue=r.addIssue.bind(r),a.type==="preprocess"){let s=a.transform(t.data,r);if(t.common.async)return Promise.resolve(s).then(async(A)=>{if(n.value==="aborted")return tn;let l=await this._def.schema._parseAsync({data:A,path:t.path,parent:t});if(l.status==="aborted")return tn;if(l.status==="dirty")return rd(l.value);if(n.value==="dirty")return rd(l.value);return l});else{if(n.value==="aborted")return tn;let A=this._def.schema._parseSync({data:s,path:t.path,parent:t});if(A.status==="aborted")return tn;if(A.status==="dirty")return rd(A.value);if(n.value==="dirty")return rd(A.value);return A}}if(a.type==="refinement"){let s=(A)=>{let l=a.refinement(A,r);if(t.common.async)return Promise.resolve(l);if(l instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return A};if(t.common.async===!1){let A=this._def.schema._parseSync({data:t.data,path:t.path,parent:t});if(A.status==="aborted")return tn;if(A.status==="dirty")n.dirty();return s(A.value),{status:n.value,value:A.value}}else return this._def.schema._parseAsync({data:t.data,path:t.path,parent:t}).then((A)=>{if(A.status==="aborted")return tn;if(A.status==="dirty")n.dirty();return s(A.value).then(()=>{return{status:n.value,value:A.value}})})}if(a.type==="transform")if(t.common.async===!1){let s=this._def.schema._parseSync({data:t.data,path:t.path,parent:t});if(!jA(s))return tn;let A=a.transform(s.value,r);if(A instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:A}}else return this._def.schema._parseAsync({data:t.data,path:t.path,parent:t}).then((s)=>{if(!jA(s))return tn;return Promise.resolve(a.transform(s.value,r)).then((A)=>({status:n.value,value:A}))});jn.assertNever(a)}};So.create=(e,n,t)=>{return new So({schema:e,typeName:on.ZodEffects,effect:n,..._n(t)})};So.createWithPreprocess=(e,n,t)=>{return new So({schema:n,effect:{type:"preprocess",transform:e},typeName:on.ZodEffects,..._n(t)})};Do=class Do extends vn{_parse(e){if(this._getType(e)===xe.undefined)return Qi(void 0);return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Do.create=(e,n)=>{return new Do({innerType:e,typeName:on.ZodOptional,..._n(n)})};Bc=class Bc extends vn{_parse(e){if(this._getType(e)===xe.null)return Qi(null);return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Bc.create=(e,n)=>{return new Bc({innerType:e,typeName:on.ZodNullable,..._n(n)})};Sp=class Sp extends vn{_parse(e){let{ctx:n}=this._processInputParams(e),t=n.data;if(n.parsedType===xe.undefined)t=this._def.defaultValue();return this._def.innerType._parse({data:t,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};Sp.create=(e,n)=>{return new Sp({innerType:e,typeName:on.ZodDefault,defaultValue:typeof n.default==="function"?n.default:()=>n.default,..._n(n)})};$p=class $p extends vn{_parse(e){let{ctx:n}=this._processInputParams(e),t={...n,common:{...n.common,issues:[]}},a=this._def.innerType._parse({data:t.data,path:t.path,parent:{...t}});if(Bp(a))return a.then((r)=>{return{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new er(t.common.issues)},input:t.data})}});else return{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new er(t.common.issues)},input:t.data})}}removeCatch(){return this._def.innerType}};$p.create=(e,n)=>{return new $p({innerType:e,typeName:on.ZodCatch,catchValue:typeof n.catch==="function"?n.catch:()=>n.catch,..._n(n)})};Db=class Db extends vn{_parse(e){if(this._getType(e)!==xe.nan){let t=this._getOrReturnCtx(e);return $e(t,{code:Ce.invalid_type,expected:xe.nan,received:t.parsedType}),tn}return{status:"valid",value:e.data}}};Db.create=(e)=>{return new Db({typeName:on.ZodNaN,..._n(e)})};Jpe=Symbol("zod_brand");qB=class qB extends vn{_parse(e){let{ctx:n}=this._processInputParams(e),t=n.data;return this._def.type._parse({data:t,path:n.path,parent:n})}unwrap(){return this._def.type}};Fb=class Fb extends vn{_parse(e){let{status:n,ctx:t}=this._processInputParams(e);if(t.common.async)return(async()=>{let r=await this._def.in._parseAsync({data:t.data,path:t.path,parent:t});if(r.status==="aborted")return tn;if(r.status==="dirty")return n.dirty(),rd(r.value);else return this._def.out._parseAsync({data:r.value,path:t.path,parent:t})})();else{let a=this._def.in._parseSync({data:t.data,path:t.path,parent:t});if(a.status==="aborted")return tn;if(a.status==="dirty")return n.dirty(),{status:"dirty",value:a.value};else return this._def.out._parseSync({data:a.value,path:t.path,parent:t})}}static create(e,n){return new Fb({in:e,out:n,typeName:on.ZodPipeline})}};Np=class Np extends vn{_parse(e){let n=this._def.innerType._parse(e),t=(a)=>{if(jA(a))a.value=Object.freeze(a.value);return a};return Bp(n)?n.then((a)=>t(a)):t(n)}unwrap(){return this._def.innerType}};Np.create=(e,n)=>{return new Np({innerType:e,typeName:on.ZodReadonly,..._n(n)})};Wpe={object:Xt.lazycreate};(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(on||(on={}));iM=vo.create,rM=MA.create,Xpe=Db.create,eme=GA.create,oM=_p.create,nme=od.create,tme=Qb.create,ame=Ep.create,ime=Qp.create,rme=sd.create,ome=LA.create,sme=fs.create,cme=Ib.create,Ame=xo.create,lme=Xt.create,dme=Xt.strictCreate,ume=Ip.create,pme=GB.create,mme=vp.create,gme=hs.create,bme=vb.create,fme=xb.create,hme=cd.create,yme=Cp.create,wme=xp.create,Bme=Dp.create,kme=qA.create,Cme=Fp.create,_me=Ad.create,Eme=So.create,Qme=Do.create,Ime=Bc.create,vme=So.createWithPreprocess,xme=Fb.create,$me={string:(e)=>vo.create({...e,coerce:!0}),number:(e)=>MA.create({...e,coerce:!0}),boolean:(e)=>_p.create({...e,coerce:!0}),bigint:(e)=>GA.create({...e,coerce:!0}),date:(e)=>od.create({...e,coerce:!0})},Nme=tn});var $={};S($,{void:()=>cme,util:()=>jn,unknown:()=>ome,union:()=>ume,undefined:()=>ame,tuple:()=>gme,transformer:()=>Eme,symbol:()=>tme,string:()=>iM,strictObject:()=>dme,setErrorMap:()=>Ipe,set:()=>hme,record:()=>bme,quotelessJson:()=>Epe,promise:()=>_me,preprocess:()=>vme,pipeline:()=>xme,ostring:()=>Dme,optional:()=>Qme,onumber:()=>Fme,oboolean:()=>Sme,objectUtil:()=>lv,object:()=>lme,number:()=>rM,nullable:()=>Ime,null:()=>ime,never:()=>sme,nativeEnum:()=>Cme,nan:()=>Xpe,map:()=>fme,makeIssue:()=>Eb,literal:()=>Bme,lazy:()=>wme,late:()=>Wpe,isValid:()=>jA,isDirty:()=>MB,isAsync:()=>Bp,isAborted:()=>LB,intersection:()=>mme,instanceof:()=>Vpe,getParsedType:()=>bs,getErrorMap:()=>wp,function:()=>yme,enum:()=>kme,effect:()=>Eme,discriminatedUnion:()=>pme,defaultErrorMap:()=>yc,datetimeRegex:()=>nM,date:()=>nme,custom:()=>aM,coerce:()=>$me,boolean:()=>oM,bigint:()=>eme,array:()=>Ame,any:()=>rme,addIssueToContext:()=>$e,ZodVoid:()=>Ib,ZodUnknown:()=>LA,ZodUnion:()=>Ip,ZodUndefined:()=>Ep,ZodType:()=>vn,ZodTuple:()=>hs,ZodTransformer:()=>So,ZodSymbol:()=>Qb,ZodString:()=>vo,ZodSet:()=>cd,ZodSchema:()=>vn,ZodRecord:()=>vb,ZodReadonly:()=>Np,ZodPromise:()=>Ad,ZodPipeline:()=>Fb,ZodParsedType:()=>xe,ZodOptional:()=>Do,ZodObject:()=>Xt,ZodNumber:()=>MA,ZodNullable:()=>Bc,ZodNull:()=>Qp,ZodNever:()=>fs,ZodNativeEnum:()=>Fp,ZodNaN:()=>Db,ZodMap:()=>xb,ZodLiteral:()=>Dp,ZodLazy:()=>xp,ZodIssueCode:()=>Ce,ZodIntersection:()=>vp,ZodFunction:()=>Cp,ZodFirstPartyTypeKind:()=>on,ZodError:()=>er,ZodEnum:()=>qA,ZodEffects:()=>So,ZodDiscriminatedUnion:()=>GB,ZodDefault:()=>Sp,ZodDate:()=>od,ZodCatch:()=>$p,ZodBranded:()=>qB,ZodBoolean:()=>_p,ZodBigInt:()=>GA,ZodArray:()=>xo,ZodAny:()=>sd,Schema:()=>vn,ParseStatus:()=>Ai,OK:()=>Qi,NEVER:()=>Nme,INVALID:()=>tn,EMPTY_PATH:()=>vpe,DIRTY:()=>rd,BRAND:()=>Jpe});var gv=h(()=>{jB();uv();ZL();_b();sM();NB()});var sa=h(()=>{gv();gv()});function ye(e){return e instanceof Error?e.message:String(e)}function Ii(e){let n=e?.code;return typeof n==="string"?n:void 0}import{randomBytes as jme}from"node:crypto";import{chmod as cM,mkdir as Lme,readFile as Mme,rename as Gme,rm as lM,writeFile as qme}from"node:fs/promises";import{homedir as Rme}from"node:os";import{isAbsolute as AM,join as RB}from"node:path";function Ti(){let e=process.env.HOME,n=e&&AM(e)?e:Rme();if(!AM(n))throw new jp("cannot resolve an absolute home directory; set $HOME to an absolute path","resolve-path");return RB(n,".greptile")}function jt(){return vt.fromThrowable(()=>RB(Ti(),"auth.json"),(e)=>new jp(`could not resolve credentials path: ${ye(e)}`,"resolve-path",{cause:e}))().asyncAndThen((e)=>ma(async function*(){let n=yield*Hn.fromPromise(Ume(e),(r)=>bv(r,"read","could not read credentials"));if(n===null)return me(null);let t=yield*vt.fromThrowable(()=>JSON.parse(n),(r)=>new kc(`credential file corrupt: ${ye(r)}`))(),a=Pme.safeParse(t);if(!a.success)return ie(new kc("credential file missing required fields"));return me(a.data)}))}function Sb(e){let n=async()=>{let t=Ti();await Lme(t,{recursive:!0,mode:448}),await cM(t,448);let a=RB(t,"auth.json"),r=`${a}.${process.pid}.${jme(4).toString("hex")}.tmp`;try{await qme(r,JSON.stringify(e,null,2),{mode:384}),await Gme(r,a),await cM(a,384)}catch(s){throw await lM(r,{force:!0}),s}};return Hn.fromPromise(n(),(t)=>bv(t,"write","could not write credentials"))}function $b(){return vt.fromThrowable(()=>RB(Ti(),"auth.json"),(e)=>new jp(`could not resolve credentials path: ${ye(e)}`,"resolve-path",{cause:e}))().asyncAndThen((e)=>Hn.fromPromise(lM(e,{force:!0}),(n)=>bv(n,"delete","could not delete credentials")))}async function Ume(e){try{return await Mme(e,"utf8")}catch(n){if(Ii(n)==="ENOENT")return null;throw n}}function bv(e,n,t){if(e instanceof jp)return e;return new jp(`${t}: ${ye(e)}`,n,{cause:e})}var kc,jp,zme,Hme,Pme;var nr=h(()=>{Vt();sa();kc=class kc extends Error{kind="corrupt-credentials";constructor(e){super(e);this.name="CorruptCredentialsError"}};jp=class jp extends Error{operation;kind="credential-store";constructor(e,n,t={}){super(e,t);this.operation=n;this.name="CredentialStoreError"}};zme=$.object({method:$.literal("oauth"),issuer:$.string().default("https://auth.greptile.com"),accessToken:$.string(),refreshToken:$.string(),expiresAt:$.number().finite(),scope:$.string().optional(),subject:$.string().nullable().optional(),email:$.string().nullable().optional(),apiBaseUrl:$.string().optional()}),Hme=$.object({method:$.literal("apikey"),apiKey:$.string().min(1),subject:$.string().nullable().optional(),email:$.string().nullable().optional(),apiBaseUrl:$.string().optional()}),Pme=$.preprocess((e)=>{if(!e||typeof e!=="object"||Array.isArray(e))return e;let n=e;if(n.method==null)return{...n,method:"oauth"};return n},$.discriminatedUnion("method",[zme,Hme]))});var ga;var ys=h(()=>{ga={name:"greptile",version:"3.5.2",type:"module",description:"Greptile code review from your terminal",bin:"dist/greptile.js",scripts:{test:"bun test",build:"bun scripts/bundle.ts",postbuild:"bun scripts/link-dev.ts",dev:"bun run src/main.ts","generate:schema":"bun scripts/generate-settings-schema.ts",lint:"oxlint --type-aware --format agent src --ignore-pattern '**/__tests__/**' --ignore-pattern '**/*.test.ts' --ignore-pattern '**/*.test.tsx'",format:"oxfmt src package.json tsconfig.json",prepack:"bun scripts/bundle.ts",prepublishOnly:"bun run typecheck && bun scripts/bundle.ts",typecheck:"tsc --noEmit"},devDependencies:{"@inkjs/ui":"^2.0.0","@pierre/theme":"^1.0.3","@types/bun":"^1.3.11","@types/picomatch":"^4.0.3","@types/react":"^19.2.14","cli-truncate":"^6.0.0",commander:"^15.0.0",dotenv:"16.6.1",ink:"^7.0.3",neverthrow:"^8.2.0",picocolors:"^1.1.1",picomatch:"^4.0.4",react:"^19.2.6",shiki:"^4.1.0","ssh-config":"^5.1.0","string-width":"^8.2.1","strip-ansi":"^7.2.0","terminal-link":"^5.0.0",typescript:"^6.0.3","wrap-ansi":"^9.0.2",zod:"^3.25.76","zod-to-json-schema":"^3.25.2"},files:["dist/greptile.js","settings-schema.json","README.md","CHANGELOG.md"],engines:{node:">=22.0.0"},keywords:["greptile","code-review","cli","claude-code","codex"],license:"MIT",homepage:"https://greptile.com",repository:{type:"git",url:"git+https://github.com/greptileai/cli.git"},bugs:{url:"https://github.com/greptileai/cli/issues"},publishConfig:{access:"public"},overrides:{react:"^19.2.6","react-dom":"^19.2.6"}}});function dM(e,n){let t=Ii(e);if(t&&Ome.has(t)){let a=ye(e);return Error(`TLS certificate verification failed for ${n} (${a}). For a private certificate authority, point NODE_EXTRA_CA_CERTS at your CA bundle.`,{cause:e})}return e}var Ome;var uM=h(()=>{Ome=new Set(["SELF_SIGNED_CERT_IN_CHAIN","DEPTH_ZERO_SELF_SIGNED_CERT","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","UNABLE_TO_VERIFY_LEAF_SIGNATURE","CERT_HAS_EXPIRED","ERR_TLS_CERT_ALTNAME_INVALID"])});var fv={};S(fv,{request:()=>hr,USER_AGENT:()=>pM,HttpError:()=>ws,DEFAULT_MAX_RESPONSE_BYTES:()=>mM});import Yme from"node:http";import Kme from"node:https";function Zme(e,n){let t=n.toLowerCase();for(let a of Object.keys(e))if(a.toLowerCase()===t)return!0;return!1}function hr(e){return Hn.fromPromise(Wme(e),(n)=>Jme(n,e.hostname,e.path))}function Jme(e,n,t){if(e instanceof ws)return e;return new ws(ye(e),"network",n,t,{cause:e})}function Wme({method:e,hostname:n,path:t,headers:a={},body:r,port:s,scheme:A="https",timeoutMs:l=30000,maxResponseBytes:u=mM,detached:m=!1,signal:b}){let f=A==="http"?Yme:Kme,y=s??(A==="http"?80:443),B={...a};if(!Zme(B,"user-agent"))B["user-agent"]=pM;if(r!==void 0){for(let k of Object.keys(B))if(k.toLowerCase()==="content-length")delete B[k];B["content-length"]=String(Buffer.byteLength(r))}return new Promise((k,E)=>{if(b?.aborted){E(new ws(`request to ${n}${t} was aborted`,"aborted",n,t));return}let _=f.request({method:e,hostname:n,path:t,port:y,headers:B},(F)=>{let M=[],J=0;F.on("data",(ee)=>{let pe=Buffer.isBuffer(ee)?ee:Buffer.from(ee);if(J+=pe.byteLength,J>u){let ae=new ws(`response from ${n}${t} exceeded ${u} bytes`,"response-too-large",n,t);F.destroy(ae),_.destroy(ae);return}M.push(pe)}),F.on("end",()=>{k({status:F.statusCode??0,headers:F.headers,body:Buffer.concat(M)})}),F.on("error",E)});_.on("error",(F)=>{if(F instanceof ws){E(F);return}let M=dM(F,n);E(new ws(ye(M),M===F?"network":"tls",n,t,{cause:F}))});let x=setTimeout(()=>{let F=new ws(`request to ${n}${t} timed out after ${l}ms`,"timeout",n,t);E(F),_.destroy(F)},l),Q=()=>{let F=new ws(`request to ${n}${t} was aborted`,"aborted",n,t);E(F),_.destroy(F)};if(b?.addEventListener("abort",Q,{once:!0}),_.on("close",()=>{clearTimeout(x),b?.removeEventListener("abort",Q)}),m)x.unref(),_.on("socket",(F)=>F.unref());if(r!==void 0)_.write(r);_.end()})}var ws,pM,mM=10485760;var ld=h(()=>{Vt();ys();uM();ws=class ws extends Error{reason;hostname;path;kind="http";constructor(e,n,t,a,r={}){super(e,r);this.reason=n;this.hostname=t;this.path=a;this.name="HttpError"}};pM=`greptile-cli/${ga.version}`});function ea(e){let n=e.trim();if(!n)return null;try{return new URL(n)}catch{return null}}function RA(e,n){let t=ea(e),a=ea(n);if(!t||!a)return!1;return t.origin===a.origin}function ba(e){if(e.protocol!=="https:")return!1;return e.hostname==="greptile.com"||e.hostname.endsWith(".greptile.com")}function Nb(e){return Vme.has(e)}function Lp(e){return e.pathname!=="/"||e.search!==""||e.hash!==""}var Vme;var Bs=h(()=>{Vme=new Set(["localhost","127.0.0.1","[::1]","::1"])});import{createHash as Xme,randomBytes as gM}from"node:crypto";function fM(e=process.env){let n=e.GREPTILE_AUTH_BASE_URL?.trim();return n?n.replace(/\/+$/,""):zB}function hM(e){return`${e}/cli/callback`}function dd(e){return e.replace(/\/+$/,"")}function BM(){let e=gM(32).toString("base64url"),n=Xme("sha256").update(e).digest("base64url");return{verifier:e,challenge:n}}function kM(){return gM(24).toString("base64url")}function tge(e){let n=dd(e),t=new URL(n),a=t.pathname==="/"?"":t.pathname,r=[`${t.origin}/.well-known/oauth-authorization-server${a}`,`${t.origin}/.well-known/openid-configuration${a}`,`${n}/.well-known/openid-configuration`];return[...new Set(r)]}function Lb(e){try{if(ba(new URL(e)))return{}}catch{return{}}return{expectIssuer:e}}function zA(e=zB,n={}){let t=n.getJson??Mb;return ma(async function*(){let a=yield*vt.fromThrowable(()=>tge(e),(u)=>Bv(u,"metadata",`Could not read the sign-in server URL: ${ye(u)}`))(),r=0,s,A=!1;for(let u of a){let m=yield*t(u);if(r=m.status,m.status===200){s=m.body,A=!0;break}}if(!A)return ie(new vi(`Could not reach Greptile sign-in (HTTP ${r})`,"metadata"));let l=yield*age(s);if(n.expectIssuer!==void 0){let u=dd(n.expectIssuer),m=typeof l.issuer==="string"?dd(l.issuer):void 0;if(m===void 0)return ie(new vi(`The authorization server at ${u} did not include an issuer field in its metadata `+"(required by RFC 8414 §2). Fix the server metadata, or use `greptile login --api-key`.","metadata"));if(m!==u)return ie(new vi(`The sign-in server's metadata names a different issuer (${l.issuer}) than expected (${u}). `+"This can indicate a misconfigured or spoofed authorization server — not proceeding.","metadata"))}return me(l)})}function age(e){let n=ege.safeParse(e);if(n.success)return me(n.data);let t=n.error.issues[0]?.path[0];if(t==="token_endpoint")return ie(new vi("Greptile sign-in is not available right now","metadata"));if(t==="revocation_endpoint")return ie(new vi("Greptile sign-out is not available right now","metadata"));if(t==="code_challenge_methods_supported")return ie(new vi("Greptile sign-in is not available right now","metadata"));return ie(new vi("Greptile sign-in is not available right now","metadata"))}function CM(e,{redirectUri:n,challenge:t,state:a,audience:r}){let s=new URLSearchParams({client_id:HB,response_type:"code",scope:jb,redirect_uri:n,code_challenge:t,code_challenge_method:"S256",state:a});if(r!==void 0)s.set("audience",r);return`${e.authorization_endpoint}?${s.toString()}`}function _M(e,{code:n,verifier:t,redirectUri:a}){return wv(e.token_endpoint,{grant_type:"authorization_code",code:n,redirect_uri:a,client_id:HB,code_verifier:t}).andThen((r)=>{if(r.status!==200){let A=yM.safeParse(r.body).data?.error;return ie(new vi(`Greptile could not finish sign-in: ${A??`http ${r.status}`}`,"token-exchange",A??"http_error"))}let s=nge.safeParse(r.body);if(!s.success)return ie(new vi("Greptile could not finish sign-in","token-exchange"));return me(s.data)})}function EM(e,{refreshToken:n}){return wv(e.token_endpoint,{grant_type:"refresh_token",refresh_token:n,client_id:HB}).andThen((t)=>{if(t.status!==200){let r=yM.safeParse(t.body).data?.error;return ie(new vi(`refresh failed: ${r??`http ${t.status}`}`,"token-refresh",r??"http_error"))}let a=wM.safeParse(t.body);if(!a.success)return ie(new vi("Could not refresh your Greptile sign-in","token-refresh"));return me(a.data)})}function yv(e,{refreshToken:n}){if(!e.revocation_endpoint)return Nt({ok:!1});return wv(e.revocation_endpoint,{token:n,token_type_hint:"refresh_token",client_id:HB}).map((t)=>({ok:t.status>=200&&t.status<300}))}function QM(e){let n=new URL(e),t=n.protocol==="http:"?"http":"https",a=n.port?Number(n.port):t==="https"?443:80;return{hostname:n.hostname,path:n.pathname+(n.search||""),port:a,scheme:t}}function IM(e){let n=e.body.toString("utf8");if(n.length===0)return{status:e.status,headers:e.headers,body:null};try{return{status:e.status,headers:e.headers,body:JSON.parse(n)}}catch{return{status:e.status,headers:e.headers,body:n}}}function Mb(e,n={}){return vt.fromThrowable(()=>QM(e),(t)=>Bv(t,"request-url",ye(t)))().asyncAndThen(({hostname:t,path:a,port:r,scheme:s})=>hr({method:"GET",hostname:t,path:a,port:r,scheme:s,headers:{accept:"application/json",...n}})).map(IM)}function wv(e,n){return vt.fromThrowable(()=>QM(e),(t)=>Bv(t,"request-url",ye(t)))().asyncAndThen(({hostname:t,path:a,port:r,scheme:s})=>hr({method:"POST",hostname:t,path:a,port:r,scheme:s,headers:{"content-type":"application/x-www-form-urlencoded",accept:"application/json"},body:new URLSearchParams(n).toString()})).map(IM)}function Bv(e,n,t){if(e instanceof vi)return e;return new vi(t,n,void 0,{cause:e})}var zB="https://auth.greptile.com",bM="https://app.greptile.com",HB="greptile-cli",jb="read write openid offline_access",vi,hv,ege,yM,wM,nge;var Gb=h(()=>{Vt();ld();Bs();sa();vi=class vi extends Error{operation;code;kind="oauth";constructor(e,n,t,a={}){super(e,a);this.operation=n;this.code=t;this.name="OAuthError"}};hv=$.string().url().refine((e)=>{try{return new URL(e).protocol==="https:"}catch{return!1}},{message:"must be https"}),ege=$.object({issuer:$.string().optional(),authorization_endpoint:hv,token_endpoint:hv,revocation_endpoint:hv.optional(),code_challenge_methods_supported:$.array($.string()).refine((e)=>e.includes("S256"),{message:"must include S256"})}).passthrough(),yM=$.object({error:$.string().optional()}).passthrough(),wM=$.object({access_token:$.string(),refresh_token:$.string().optional(),expires_in:$.union([$.number(),$.string()]).optional(),id_token:$.string().optional(),scope:$.string().optional()}).passthrough(),nge=wM.extend({refresh_token:$.string()})});function vM(e){return $.string().transform((n)=>n.trim().replace(/\/+$/,"")).superRefine((n,t)=>{let a=ea(n);if(!a){t.addIssue({code:$.ZodIssueCode.custom,message:`${e} must be a valid URL.`});return}let r=a.protocol==="http:"&&Nb(a.hostname);if(a.protocol!=="https:"&&!r)t.addIssue({code:$.ZodIssueCode.custom,message:`${e} must use https.`});if(Lp(a))t.addIssue({code:$.ZodIssueCode.custom,message:`${e} must be an origin with no path.`})})}function xM(e){return e.map((n)=>({display:n,value:n}))}function Mp(e){return e in Ln}function qb(e){if(e==="true")return!0;if(e==="false")return!1;let n=e.trim();if(n!==""&&Number.isInteger(Number(n)))return Number(n);return e}function DM(e){return Ln[e].interactive!==!1}var kv,Cv,ige,Ln,HA,FM,SM;var ud=h(()=>{sa();ys();Bs();kv=["auto","text","json"],Cv=["comments","diff"],ige=[{display:"On",value:!0},{display:"Off",value:!1}];Ln={color:{schema:$.boolean(),label:"Color output",description:"Color output. Set to false for the same effect as always passing --no-color.",hint:"Use true or false.",expected:"true or false",fixValues:[!0,!1],defaultValue:!0,defaultLabel:"true",choices:ige},telemetry:{schema:$.boolean(),label:"Usage data sharing",description:"Anonymous usage data sharing. Overrides the first-run consent choice; never includes code or repo contents.",hint:"Use true or false.",expected:"true or false",fixValues:[!0,!1],defaultValue:void 0,defaultLabel:"first-run consent choice",interactive:!1},apiBaseUrl:{schema:vM("apiBaseUrl"),label:"API base URL",description:"API base URL for a self-hosted Greptile deployment. Origin only — serve the API at an origin root or dedicated hostname.",hint:"Use an HTTPS origin with no path, e.g. https://greptile-api.acme.internal.",expected:"an HTTPS origin with no path",fixValues:["https://greptile-api.acme.internal"],defaultValue:void 0,defaultLabel:"https://api.greptile.com"},webBaseUrl:{schema:vM("webBaseUrl"),label:"Web base URL",description:"Web dashboard URL for a self-hosted Greptile deployment. Origin only, no path.",hint:"Use an HTTPS origin with no path, e.g. https://greptile.acme.internal.",expected:"an HTTPS origin with no path",fixValues:["https://greptile.acme.internal"],defaultValue:void 0,defaultLabel:"https://app.greptile.com"},"review.output":{schema:$.enum(kv),label:"Review output",description:"Default review output: auto (rich on a terminal, text when piped), text, or json.",hint:"Use auto, text, or json.",expected:'"auto", "text", or "json"',fixValues:kv,defaultValue:"auto",defaultLabel:"auto",choices:xM(kv)},"review.layout":{schema:$.enum(Cv),label:"Review layout",description:"Default review layout: comments, or diff to show findings beside the changed code.",hint:"Use comments or diff.",expected:'"comments" or "diff"',fixValues:Cv,defaultValue:"comments",defaultLabel:"comments",choices:xM(Cv)},"review.context":{schema:$.number().int().min(0).max(60),label:"Review context lines",description:"Lines of nearby code shown around findings, the same as passing --context.",hint:"Use a number from 0 to 60.",expected:"an integer from 0 to 60",fixValues:[15],defaultValue:15,defaultLabel:"15"},"review.width":{schema:$.number().int().min(40).max(240),label:"Review width",description:"Review output width in columns, the same as passing --width.",hint:"Use a number from 40 to 240.",expected:"an integer from 40 to 240",fixValues:[80],defaultValue:void 0,defaultLabel:"terminal width"}},HA=Object.keys(Ln);FM=`https://cdn.jsdelivr.net/npm/greptile@${ga.version.split(".")[0]}/settings-schema.json`,SM=$.object({version:$.number().optional().describe("Settings file format version, written by the CLI."),color:Ln.color.schema.optional().describe(Ln.color.description),telemetry:Ln.telemetry.schema.optional().describe(Ln.telemetry.description),apiBaseUrl:Ln.apiBaseUrl.schema.optional().describe(Ln.apiBaseUrl.description),webBaseUrl:Ln.webBaseUrl.schema.optional().describe(Ln.webBaseUrl.description),review:$.object({output:Ln["review.output"].schema.optional().describe(Ln["review.output"].description),layout:Ln["review.layout"].schema.optional().describe(Ln["review.layout"].description),context:Ln["review.context"].schema.optional().describe(Ln["review.context"].description),width:Ln["review.width"].schema.optional().describe(Ln["review.width"].description)}).passthrough().optional().describe("Settings for greptile review.")}).passthrough()});import{randomBytes as rge}from"node:crypto";import{mkdir as oge,readFile as sge,rename as cge,rm as Age,writeFile as lge}from"node:fs/promises";import{homedir as dge}from"node:os";import{dirname as uge,isAbsolute as _v,join as Rb}from"node:path";function Cc(e=process.env){let n=e.XDG_CONFIG_HOME;if(n&&_v(n))return Rb(n,"greptile");let t=e.HOME,a=t&&_v(t)?t:dge();if(!_v(a))throw Error("cannot resolve an absolute home directory; set $HOME to an absolute path");return Rb(a,".config","greptile")}function Qv(e=process.env){return Cs(e).andThen((n)=>{let t=SM.safeParse(n);if(t.success)return me({raw:n,settings:t.data});let a=new Map;for(let l of t.error.issues){let u=l.path.join(".");if(a.has(u))continue;let m=ks(n,u),b=Mp(u)?Ln[u]:void 0;a.set(u,{key:u,value:m,expected:b?.expected??l.message,commands:b?.fixValues.map((f)=>`greptile settings set ${u} ${typeof f==="string"?JSON.stringify(f):f}`)??[]})}let r=Rb(Cc(e),"settings.json"),s=[...a.values()],A=Ln["review.width"].schema.safeParse(ks(n,"review.width"));return ie(new Gp(`${r} has invalid settings:
297
297
  ${s.map(({key:l,value:u,expected:m})=>` ${l} is ${JSON.stringify(u)??"undefined"}. Expected ${m}.`).join(`
298
298
  `)}
299
299
  Fix each key with \`greptile settings set <key> <value>\`, or delete the file to start over.`,r,s,A.success?A.data:void 0))})}function zb(e=process.env){return Qv(e).map(({settings:n})=>n)}function Cs(e=process.env,n){let t=n??Rb(Cc(e),"settings.json");return ma(async function*(){let a=yield*Hn.fromPromise(sge(t,"utf8"),(A)=>A).orElse((A)=>Ii(A)==="ENOENT"?Nt(null):Av(new Gp(`could not read ${t}: ${ye(A)}`)));if(a===null)return me({});let r=yield*vt.fromThrowable(()=>JSON.parse(a),(A)=>new Gp(`${t} is not valid JSON (${ye(A)}). Fix it or delete it to start over.`))(),s=Ev.safeParse(r);if(!s.success)return ie(new Gp(`${t} is not a JSON object. Fix it or delete it to start over.`));return me(s.data)})}function PA(e,n=process.env,t){let a=t??Rb(Cc(n),"settings.json"),r=async()=>{await oge(uge(a),{recursive:!0});let s=`${a}.${process.pid}.${rge(4).toString("hex")}.tmp`,A={...e};delete A.$schema,delete A.version;let l={$schema:FM,version:1,...A};try{await lge(s,`${JSON.stringify(l,null,2)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "greptile",
3
- "version": "3.5.1",
3
+ "version": "3.5.2",
4
4
  "type": "module",
5
5
  "description": "Greptile code review from your terminal",
6
6
  "bin": "dist/greptile.js",