@skyramp/testbot-core 0.13.1 → 0.13.2-v3.479

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.
@@ -1696,6 +1696,8 @@ export interface RequirementReportRow {
1696
1696
  /** The requirement as the plan states it; absent for a Requirement reference. */
1697
1697
  statement?: string;
1698
1698
  clauses: RequirementClauseRow[];
1699
+ /** A run of several pull requests: the ones it belongs to, as `owner/repo#N` (SKYR-6078). Absent when none is known. */
1700
+ pullRequests?: string[];
1699
1701
  }
1700
1702
  /** The shipped report — the TestbotReport shape deliver renders into the PR. */
1701
1703
  export interface StagedTestbotReport {
@@ -1720,6 +1722,8 @@ export interface StagedTestbotReport {
1720
1722
  /** The test functions behind the case, as the runner names them (SKYR-5466): several cases can share one. Absent
1721
1723
  * when the run did not name them. */
1722
1724
  functions?: string[];
1725
+ /** A run of several pull requests: the ones whose requirements it covers, as `owner/repo#N` (SKYR-6078). */
1726
+ pullRequests?: string[];
1723
1727
  }[];
1724
1728
  testMaintenance?: {
1725
1729
  testType: string;
@@ -1771,6 +1775,8 @@ export interface StagedTestbotReport {
1771
1775
  findingId?: string;
1772
1776
  /** The plan's requirement or clause ids it violates. */
1773
1777
  requirementIds?: string[];
1778
+ /** A run of several pull requests: the ones it is against, as `owner/repo#N` (SKYR-6078). */
1779
+ pullRequests?: string[];
1774
1780
  }[];
1775
1781
  nextSteps: string[];
1776
1782
  /**
@@ -2171,6 +2177,8 @@ declare enum CaveatKind {
2171
2177
  SutNotRequired = "sut-not-required",
2172
2178
  /** The repo's own linter config doesn't reach this file — derived independently of CiNotCovered (whether the test RUNS at all), so the two can coexist: a file can be run but not linted, linted but not run, both, or neither. */
2173
2179
  LintNotCovered = "lint-not-covered",
2180
+ /** No linter checked the test files: the repo's linter could not start on them, or the run's lint proves nothing (SKYR-5827). The tests still ship. */
2181
+ LintNotRun = "lint-not-run",
2174
2182
  /** Analyze was salvaged: some of its claims went unconfirmed, and the plan was made from them as such. */
2175
2183
  AnalysisUnverified = "analysis-unverified",
2176
2184
  /** A shared environment: the browser ran under the data-safety guard, but plan probes and test runs only under prompt rules (SKYR-5127). */
@@ -2287,6 +2295,9 @@ declare enum AttemptState {
2287
2295
  * `RunnerProviderNotReady`: GitHub or Azure DevOps did not show the job as running while the runner waited for its token,
2288
2296
  * so the app runs the attempt again (SKYR-5429). `MergeConflict`: two revisions of one repository the run merges do not
2289
2297
  * merge cleanly, so the run stops before build or deploy for a person to resolve; it is no checkout failure (SKYR-5061).
2298
+ * `EnvironmentUnavailable`: the SUT did not come up because a package source, a registry or the network failed (an Ubuntu
2299
+ * mirror, Docker Hub, npm, PyPI), not the recipe: the setup check's `environment` cause. It is no `SetupFailed`, so the
2300
+ * app neither asks for a deployment review nor stops the Runtime Plan's reuse (SKYR-5971).
2290
2301
  */
2291
2302
  export declare enum NoReportCause {
2292
2303
  TimedOut = "timed_out",
@@ -2299,7 +2310,8 @@ export declare enum NoReportCause {
2299
2310
  ModelProviderDenied = "model_provider_denied",
2300
2311
  ModelProviderUnavailable = "model_provider_unavailable",
2301
2312
  RunnerProviderNotReady = "runner_provider_not_ready",
2302
- MergeConflict = "merge_conflict"
2313
+ MergeConflict = "merge_conflict",
2314
+ EnvironmentUnavailable = "environment_unavailable"
2303
2315
  }
2304
2316
  declare const SourceRefSchema: z.ZodDiscriminatedUnion<"provider", [
2305
2317
  z.ZodObject<{
@@ -4129,6 +4141,16 @@ declare const GeneratedTestDeliverySchema: z.ZodDiscriminatedUnion<"status", [
4129
4141
  commitSha?: string | undefined;
4130
4142
  }>, "many">;
4131
4143
  failures: z.ZodArray<z.ZodObject<{
4144
+ heldBack: z.ZodOptional<z.ZodArray<z.ZodObject<{
4145
+ file: z.ZodString;
4146
+ dependsOn: z.ZodArray<z.ZodString, "many">;
4147
+ }, "strict", z.ZodTypeAny, {
4148
+ file: string;
4149
+ dependsOn: string[];
4150
+ }, {
4151
+ file: string;
4152
+ dependsOn: string[];
4153
+ }>, "many">>;
4132
4154
  branch: z.ZodOptional<z.ZodString>;
4133
4155
  commitSha: z.ZodOptional<z.ZodString>;
4134
4156
  repository: z.ZodDiscriminatedUnion<"provider", [
@@ -4173,6 +4195,10 @@ declare const GeneratedTestDeliverySchema: z.ZodDiscriminatedUnion<"status", [
4173
4195
  };
4174
4196
  branch?: string | undefined;
4175
4197
  commitSha?: string | undefined;
4198
+ heldBack?: {
4199
+ file: string;
4200
+ dependsOn: string[];
4201
+ }[] | undefined;
4176
4202
  }, {
4177
4203
  message: string;
4178
4204
  repository: {
@@ -4186,6 +4212,10 @@ declare const GeneratedTestDeliverySchema: z.ZodDiscriminatedUnion<"status", [
4186
4212
  };
4187
4213
  branch?: string | undefined;
4188
4214
  commitSha?: string | undefined;
4215
+ heldBack?: {
4216
+ file: string;
4217
+ dependsOn: string[];
4218
+ }[] | undefined;
4189
4219
  }>, "many">;
4190
4220
  }, "strict", z.ZodTypeAny, {
4191
4221
  status: DeliveryStatus.Partial;
@@ -4215,6 +4245,10 @@ declare const GeneratedTestDeliverySchema: z.ZodDiscriminatedUnion<"status", [
4215
4245
  };
4216
4246
  branch?: string | undefined;
4217
4247
  commitSha?: string | undefined;
4248
+ heldBack?: {
4249
+ file: string;
4250
+ dependsOn: string[];
4251
+ }[] | undefined;
4218
4252
  }[];
4219
4253
  noTests?: {
4220
4254
  reason: string;
@@ -4256,6 +4290,10 @@ declare const GeneratedTestDeliverySchema: z.ZodDiscriminatedUnion<"status", [
4256
4290
  };
4257
4291
  branch?: string | undefined;
4258
4292
  commitSha?: string | undefined;
4293
+ heldBack?: {
4294
+ file: string;
4295
+ dependsOn: string[];
4296
+ }[] | undefined;
4259
4297
  }[];
4260
4298
  noTests?: {
4261
4299
  reason: string;
@@ -4327,6 +4365,16 @@ declare const GeneratedTestDeliverySchema: z.ZodDiscriminatedUnion<"status", [
4327
4365
  };
4328
4366
  }>, "many">>;
4329
4367
  failures: z.ZodOptional<z.ZodArray<z.ZodObject<{
4368
+ heldBack: z.ZodOptional<z.ZodArray<z.ZodObject<{
4369
+ file: z.ZodString;
4370
+ dependsOn: z.ZodArray<z.ZodString, "many">;
4371
+ }, "strict", z.ZodTypeAny, {
4372
+ file: string;
4373
+ dependsOn: string[];
4374
+ }, {
4375
+ file: string;
4376
+ dependsOn: string[];
4377
+ }>, "many">>;
4330
4378
  branch: z.ZodOptional<z.ZodString>;
4331
4379
  commitSha: z.ZodOptional<z.ZodString>;
4332
4380
  repository: z.ZodDiscriminatedUnion<"provider", [
@@ -4371,6 +4419,10 @@ declare const GeneratedTestDeliverySchema: z.ZodDiscriminatedUnion<"status", [
4371
4419
  };
4372
4420
  branch?: string | undefined;
4373
4421
  commitSha?: string | undefined;
4422
+ heldBack?: {
4423
+ file: string;
4424
+ dependsOn: string[];
4425
+ }[] | undefined;
4374
4426
  }, {
4375
4427
  message: string;
4376
4428
  repository: {
@@ -4384,6 +4436,10 @@ declare const GeneratedTestDeliverySchema: z.ZodDiscriminatedUnion<"status", [
4384
4436
  };
4385
4437
  branch?: string | undefined;
4386
4438
  commitSha?: string | undefined;
4439
+ heldBack?: {
4440
+ file: string;
4441
+ dependsOn: string[];
4442
+ }[] | undefined;
4387
4443
  }>, "many">>;
4388
4444
  }, "strict", z.ZodTypeAny, {
4389
4445
  message: string;
@@ -4413,6 +4469,10 @@ declare const GeneratedTestDeliverySchema: z.ZodDiscriminatedUnion<"status", [
4413
4469
  };
4414
4470
  branch?: string | undefined;
4415
4471
  commitSha?: string | undefined;
4472
+ heldBack?: {
4473
+ file: string;
4474
+ dependsOn: string[];
4475
+ }[] | undefined;
4416
4476
  }[] | undefined;
4417
4477
  }, {
4418
4478
  message: string;
@@ -4442,6 +4502,10 @@ declare const GeneratedTestDeliverySchema: z.ZodDiscriminatedUnion<"status", [
4442
4502
  };
4443
4503
  branch?: string | undefined;
4444
4504
  commitSha?: string | undefined;
4505
+ heldBack?: {
4506
+ file: string;
4507
+ dependsOn: string[];
4508
+ }[] | undefined;
4445
4509
  }[] | undefined;
4446
4510
  }>
4447
4511
  ]>;
@@ -4479,6 +4543,10 @@ export interface V3ReportDisplay {
4479
4543
  id: string;
4480
4544
  text: string;
4481
4545
  }[];
4546
+ requirements?: {
4547
+ id: string;
4548
+ statement: string;
4549
+ }[];
4482
4550
  issuesFound?: {
4483
4551
  description: string;
4484
4552
  }[];
@@ -4532,6 +4600,7 @@ declare const GitHubWriteSchema: z.ZodDiscriminatedUnion<"kind", [
4532
4600
  branch: z.ZodString;
4533
4601
  commit: z.ZodString;
4534
4602
  }, "strict", z.ZodTypeAny, {
4603
+ branch: string;
4535
4604
  kind: GitHubWriteKind.BranchPushed;
4536
4605
  repository: {
4537
4606
  provider: SourceProvider.GitHub;
@@ -4542,9 +4611,9 @@ declare const GitHubWriteSchema: z.ZodDiscriminatedUnion<"kind", [
4542
4611
  providerAccountId: string;
4543
4612
  providerRepositoryId: string;
4544
4613
  };
4545
- branch: string;
4546
4614
  commit: string;
4547
4615
  }, {
4616
+ branch: string;
4548
4617
  kind: GitHubWriteKind.BranchPushed;
4549
4618
  repository: {
4550
4619
  provider: SourceProvider.GitHub;
@@ -4555,7 +4624,6 @@ declare const GitHubWriteSchema: z.ZodDiscriminatedUnion<"kind", [
4555
4624
  providerAccountId: string;
4556
4625
  providerRepositoryId: string;
4557
4626
  };
4558
- branch: string;
4559
4627
  commit: string;
4560
4628
  }>,
4561
4629
  z.ZodObject<{
@@ -4595,6 +4663,7 @@ declare const GitHubWriteSchema: z.ZodDiscriminatedUnion<"kind", [
4595
4663
  branch: z.ZodString;
4596
4664
  }, "strict", z.ZodTypeAny, {
4597
4665
  number: string;
4666
+ branch: string;
4598
4667
  kind: GitHubWriteKind.PullRequestOpened | GitHubWriteKind.PullRequestEdited;
4599
4668
  repository: {
4600
4669
  provider: SourceProvider.GitHub;
@@ -4605,9 +4674,9 @@ declare const GitHubWriteSchema: z.ZodDiscriminatedUnion<"kind", [
4605
4674
  providerAccountId: string;
4606
4675
  providerRepositoryId: string;
4607
4676
  };
4608
- branch: string;
4609
4677
  }, {
4610
4678
  number: string;
4679
+ branch: string;
4611
4680
  kind: GitHubWriteKind.PullRequestOpened | GitHubWriteKind.PullRequestEdited;
4612
4681
  repository: {
4613
4682
  provider: SourceProvider.GitHub;
@@ -4618,7 +4687,6 @@ declare const GitHubWriteSchema: z.ZodDiscriminatedUnion<"kind", [
4618
4687
  providerAccountId: string;
4619
4688
  providerRepositoryId: string;
4620
4689
  };
4621
- branch: string;
4622
4690
  }>
4623
4691
  ]>;
4624
4692
  export type GitHubWrite = z.infer<typeof GitHubWriteSchema>;
@@ -4746,8 +4814,10 @@ declare enum PersistenceRefusal {
4746
4814
  /** The request is outside the environment's address. */
4747
4815
  OutOfScope = "out_of_scope"
4748
4816
  }
4817
+ /** An allowed decision carries the permission it read, so what the test leaves traces to it (SKYR-5207). */
4749
4818
  export type PersistenceDecision = {
4750
4819
  allowed: true;
4820
+ policy: PersistentDataPolicy;
4751
4821
  } | {
4752
4822
  allowed: false;
4753
4823
  refusal: PersistenceRefusal;
@@ -4900,6 +4970,10 @@ export declare class AppRefusal extends Error {
4900
4970
  /** The app did not answer on any try: a network error, a timeout, a 5xx or a 429. Trying again later may work. */
4901
4971
  export declare class AppUnreachable extends Error {
4902
4972
  }
4973
+ export interface EncodedAppBody {
4974
+ body: string | Uint8Array | undefined;
4975
+ gzip?: true;
4976
+ }
4903
4977
  /** One Execution attempt of a Validation Run, bound by the handshake. */
4904
4978
  export declare class V3Attempt {
4905
4979
  readonly attemptId: string;
@@ -4964,13 +5038,15 @@ export declare class V3Attempt {
4964
5038
  * The run's budget, from now: the time to the attempt deadline, less the post step's reserve. The app fixed the
4965
5039
  * deadline from the execution timeout it froze, so the `testbotTimeout` input has no say in a V3 run.
4966
5040
  */
4967
- budgetMs(now: Date): number;
5041
+ budgetMs(now: Date, executionTimeoutMinutes?: number): number;
4968
5042
  /** The run's page in the app (skyrampRunPageUrl). */
4969
5043
  get skyrampRunUrl(): string;
4970
5044
  /** One call to an attempt route of the app. */
4971
5045
  /** Writes one line to the job log. */
4972
5046
  log(line: string): void;
4973
5047
  send<T>(method: RunnerMethod, route: string, body: unknown, deadlineMs?: number): Promise<T>;
5048
+ /** Send the selected report using the bytes that passed the upload size checks. */
5049
+ sendReport(encoded: EncodedAppBody): Promise<void>;
4974
5050
  /** One read of an attempt route that answers bytes (callAppBytes). */
4975
5051
  readBytes(route: string, maxBytes: number): Promise<Buffer>;
4976
5052
  /** Every scoped token this attempt received, for scrubbing what it uploads. */
@@ -5034,6 +5110,8 @@ export declare function heartbeatV3Attempt(attempt: V3Attempt, deadlineMs?: numb
5034
5110
  export declare function closedV3Attempt(attempt: V3Attempt, now?: () => Date, deadlineMs?: number): Promise<AttemptClosure | null>;
5035
5111
  /** One frozen source, checked out for this attempt. */
5036
5112
  export interface CheckedOutSource {
5113
+ /** A merged source's actual checkout tree, captured before any agent starts; its report revision stays the frozen base. */
5114
+ checkoutRevision?: string;
5037
5115
  repository: SourceIdentity;
5038
5116
  /** What `git rev-parse HEAD` says after the checkout: the provenance the report sends. */
5039
5117
  revision: string;
@@ -5101,6 +5179,8 @@ export interface V3AttemptState {
5101
5179
  cause?: V3EndCause;
5102
5180
  /** What did not merge, when the cause is `merge_conflict` (SKYR-5061). */
5103
5181
  conflict?: MergeConflictV1;
5182
+ /** What the attempt wrote to GitHub, sent only when it ends without a report (SKYR-5996). */
5183
+ githubWrites?: GitHubWrite[];
5104
5184
  }
5105
5185
  /**
5106
5186
  * The attempt end, sent by the post step. The app derives the outcome from it and from the accepted report; the
@@ -0,0 +1 @@
1
+ "use strict";var i=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var a=(e,o)=>i(e,"name",{value:o,configurable:!0});var p=(e,o)=>{for(var n in o)i(e,n,{get:o[n],enumerable:!0})},m=(e,o,n,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of f(o))!b.call(e,t)&&t!==n&&i(e,t,{get:()=>o[t],enumerable:!(s=d(o,t))||s.enumerable});return e};var E=e=>m(i({},"__esModule",{value:!0}),e);var v={};p(v,{ENVIRONMENT_FAILURE:()=>l,FETCHES:()=>u,FETCH_FAILURE:()=>c,isEnvironmentFailureText:()=>g,isPackageSourceOutage:()=>h});module.exports=E(v);var l=/toomanyrequests|failed to resolve reference|pull access denied|manifest unknown|manifest for \S+ not found|error pulling image|could not resolve host|temporary failure in name resolution|no such host|getaddrinfo ENOTFOUND|EAI_AGAIN|no space left on device|Temporary failure resolving '|Could not resolve '[\w.-]+'|Could not connect to [\w.-]+:\d+ \(|Connection failed \[IP: |Unable to fetch some archives|Failed to fetch \S+\s+50\d\s.*\[IP: /i,c=/\b50[234]\b|Bad Gateway|Service Unavailable|Gateway Time-?out|i\/o timeout|TLS handshake timeout|connection reset by peer|ECONNRESET|ETIMEDOUT/i,u=/\b(?:pull|build|install|download)\b|--build\b|\bnpm ci\b|\bapk add\b/i;function g(e,o){return l.test(e)||o!==void 0&&u.test(o)&&c.test(e)}a(g,"isEnvironmentFailureText");function h(e){let o=/Temporary failure resolving '[\w.-]+'|Could not resolve '[\w.-]+'|Could not connect to [\w.-]+:\d+ \(|Connection failed \[IP: |Failed to fetch \S+\s+50\d\s.*\[IP: /i,n=/\btoomanyrequests\b/i,s=/(?:could not resolve host:?\s+|getaddrinfo (?:ENOTFOUND|EAI_AGAIN)\s+|lookup\s+(?=[^\r\n]*\bno such host\b))([\w.-]+)/gi;return o.test(e)||n.test(e)?!0:[...e.matchAll(s)].some(([,t])=>{let r=t.replace(/\.$/,"");return/^[a-z0-9-]+(?:\.[a-z0-9-]+)*\.[a-z]{2,}$/i.test(r)&&!/\.(?:local|localhost|internal|test|invalid|example|lan|corp|svc|cluster)$/i.test(r)})}a(h,"isPackageSourceOutage");
@@ -0,0 +1,32 @@
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ /**
4
+ * The text of a failure that is the environment's, not the recipe's: a registry, the network, the runner, or a package
5
+ * source failed (SKYR-5970). One source for the engine's setup check (setup-check.ts) and the Testbot web app's setup
6
+ * loop, which loads it as its own bundle, dist/setup-failure.cjs, in a Cloudflare Worker. So this file imports nothing.
7
+ */
8
+ /**
9
+ * A registry's, the network's or the runner's own failure, whatever command failed: a pull the registry refused or rate
10
+ * limited, a name that did not resolve, a full disk. apt's outage lines too, in apt's own words only: it names the
11
+ * mirror it could not resolve (`Temporary failure resolving '<host>'`, `Could not resolve '<host>'`) or reach
12
+ * (`Could not connect to <host>:<port> (<ip>)`, `Connection failed [IP: …]`), a mirror that answered 5xx
13
+ * (`Failed to fetch <url> 503 Service Unavailable [IP: …]`), and the archives it could not fetch. A check again may pass.
14
+ */
15
+ export declare const ENVIRONMENT_FAILURE: RegExp;
16
+ /**
17
+ * A gateway's or a socket's failure, which the SUT's own proxy and health check give too: the environment's only when the
18
+ * command that failed fetches (FETCHES), never when it is the recipe's own check that the SUT answers.
19
+ */
20
+ export declare const FETCH_FAILURE: RegExp;
21
+ /** A command that pulls, builds or installs, which fetches from a registry or a package index. */
22
+ export declare const FETCHES: RegExp;
23
+ /**
24
+ * Whether `text`, what a failed command printed, says the environment failed: ENVIRONMENT_FAILURE whatever the command,
25
+ * or FETCH_FAILURE when `command` is given and fetches. Without a command, a gateway or a socket error is never the
26
+ * environment's: it may be the SUT's own.
27
+ */
28
+ export declare function isEnvironmentFailureText(text: string, command?: string): boolean;
29
+ /** Evidence strong enough to withhold a Validation Run report and retry the attempt. */
30
+ export declare function isPackageSourceOutage(text: string): boolean;
31
+
32
+ export {};
@@ -0,0 +1,7 @@
1
+ "use strict";var He=Object.defineProperty;var Et=Object.getOwnPropertyDescriptor;var It=Object.getOwnPropertyNames;var Ct=Object.prototype.hasOwnProperty;var at=(r,e)=>{for(var t in e)He(r,t,{get:e[t],enumerable:!0})},jt=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of It(e))!Ct.call(r,n)&&n!==t&&He(r,n,{get:()=>e[n],enumerable:!(s=Et(e,n))||s.enumerable});return r};var Nt=r=>jt(He({},"__esModule",{value:!0}),r);var Qr={};at(Qr,{renderDeliveredSharedTest:()=>Ot,sharedEnvironmentTest:()=>Kr});module.exports=Nt(Qr);var Q=require("node:fs"),Rt=require("node:crypto"),Ee=require("node:path"),At=require("node:test"),Le=require("node:assert");var bt=require("node:crypto");var h={};at(h,{BRAND:()=>ar,DIRTY:()=>X,EMPTY_PATH:()=>Zt,INVALID:()=>y,NEVER:()=>qr,OK:()=>A,ParseStatus:()=>R,Schema:()=>_,ZodAny:()=>Y,ZodArray:()=>W,ZodBigInt:()=>te,ZodBoolean:()=>re,ZodBranded:()=>Ce,ZodCatch:()=>pe,ZodDate:()=>se,ZodDefault:()=>fe,ZodDiscriminatedUnion:()=>Ze,ZodEffects:()=>D,ZodEnum:()=>ue,ZodError:()=>C,ZodFirstPartyTypeKind:()=>g,ZodFunction:()=>Me,ZodIntersection:()=>oe,ZodIssueCode:()=>d,ZodLazy:()=>ce,ZodLiteral:()=>de,ZodMap:()=>Te,ZodNaN:()=>Oe,ZodNativeEnum:()=>le,ZodNever:()=>Z,ZodNull:()=>ae,ZodNullable:()=>V,ZodNumber:()=>ee,ZodObject:()=>j,ZodOptional:()=>P,ZodParsedType:()=>f,ZodPipeline:()=>je,ZodPromise:()=>K,ZodReadonly:()=>he,ZodRecord:()=>Ue,ZodSchema:()=>_,ZodSet:()=>Se,ZodString:()=>G,ZodSymbol:()=>ke,ZodTransformer:()=>D,ZodTuple:()=>z,ZodType:()=>_,ZodUndefined:()=>ne,ZodUnion:()=>ie,ZodUnknown:()=>B,ZodVoid:()=>we,addIssueToContext:()=>l,any:()=>hr,array:()=>vr,bigint:()=>dr,boolean:()=>yt,coerce:()=>Lr,custom:()=>pt,date:()=>ur,datetimeRegex:()=>lt,defaultErrorMap:()=>H,discriminatedUnion:()=>kr,effect:()=>Pr,enum:()=>Cr,function:()=>Ar,getErrorMap:()=>_e,getParsedType:()=>M,instanceof:()=>or,intersection:()=>wr,isAborted:()=>$e,isAsync:()=>xe,isDirty:()=>De,isValid:()=>J,late:()=>ir,lazy:()=>Er,literal:()=>Ir,makeIssue:()=>Ie,map:()=>Or,nan:()=>cr,nativeEnum:()=>jr,never:()=>yr,null:()=>pr,nullable:()=>Dr,number:()=>mt,object:()=>_r,objectUtil:()=>Fe,oboolean:()=>Vr,onumber:()=>zr,optional:()=>$r,ostring:()=>Mr,pipeline:()=>Ur,preprocess:()=>Zr,promise:()=>Nr,quotelessJson:()=>Pt,record:()=>Sr,set:()=>Rr,setErrorMap:()=>Dt,strictObject:()=>xr,string:()=>ht,symbol:()=>lr,transformer:()=>Pr,tuple:()=>Tr,undefined:()=>fr,union:()=>br,unknown:()=>mr,util:()=>x,void:()=>gr});var x;(function(r){r.assertEqual=n=>{};function e(n){}r.assertIs=e;function t(n){throw new Error}r.assertNever=t,r.arrayToEnum=n=>{let a={};for(let i of n)a[i]=i;return a},r.getValidEnumValues=n=>{let a=r.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),i={};for(let o of a)i[o]=n[o];return r.objectValues(i)},r.objectValues=n=>r.objectKeys(n).map(function(a){return n[a]}),r.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{let a=[];for(let i in n)Object.prototype.hasOwnProperty.call(n,i)&&a.push(i);return a},r.find=(n,a)=>{for(let i of n)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function s(n,a=" | "){return n.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=s,r.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(x||(x={}));var Fe;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Fe||(Fe={}));var f=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),M=r=>{switch(typeof r){case"undefined":return f.undefined;case"string":return f.string;case"number":return Number.isNaN(r)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(r)?f.array:r===null?f.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?f.promise:typeof Map<"u"&&r instanceof Map?f.map:typeof Set<"u"&&r instanceof Set?f.set:typeof Date<"u"&&r instanceof Date?f.date:f.object;default:return f.unknown}};var d=x.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"]),Pt=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),C=class r extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(a){return a.message},s={_errors:[]},n=a=>{for(let i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(n);else if(i.code==="invalid_return_type")n(i.returnTypeError);else if(i.code==="invalid_arguments")n(i.argumentsError);else if(i.path.length===0)s._errors.push(t(i));else{let o=s,c=0;for(;c<i.path.length;){let u=i.path[c],m=c===i.path.length-1;if(u==="_errors"){m&&o._errors.push(t(i)),c++;continue}Object.prototype.hasOwnProperty.call(o,u)||(u==="__proto__"?Object.defineProperty(o,u,{value:{_errors:[]},writable:!0,enumerable:!0,configurable:!0}):o[u]={_errors:[]}),o=o[u],m&&o._errors.push(t(i)),c++}}};return n(this),s}static assert(e){if(!(e instanceof r))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,x.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t=Object.create(null),s=[];for(let n of this.issues)if(n.path.length>0){let a=n.path[0];t[a]=t[a]||[],t[a].push(e(n))}else s.push(e(n));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}};C.create=r=>new C(r);var $t=(r,e)=>{let t;switch(r.code){case d.invalid_type:r.received===f.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case d.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,x.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:t=`Unrecognized key(s) in object: ${x.joinValues(r.keys,", ")}`;break;case d.invalid_union:t="Invalid input";break;case d.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${x.joinValues(r.options)}`;break;case d.invalid_enum_value:t=`Invalid enum value. Expected ${x.joinValues(r.options)}, received '${r.received}'`;break;case d.invalid_arguments:t="Invalid function arguments";break;case d.invalid_return_type:t="Invalid function return type";break;case d.invalid_date:t="Invalid date";break;case d.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:x.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case d.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="bigint"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case d.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case d.custom:t="Invalid input";break;case d.invalid_intersection_types:t="Intersection results could not be merged";break;case d.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case d.not_finite:t="Number must be finite";break;default:t=e.defaultError,x.assertNever(r)}return{message:t}},H=$t;var it=H;function Dt(r){it=r}function _e(){return it}var Ie=r=>{let{data:e,path:t,errorMaps:s,issueData:n}=r,a=[...t,...n.path||[]],i={...n,path:a};if(n.message!==void 0)return{...n,path:a,message:n.message};let o="",c=s.filter(u=>!!u).slice().reverse();for(let u of c)o=u(i,{data:e,defaultError:o}).message;return{...n,path:a,message:o}},Zt=[];function l(r,e){let t=_e(),s=Ie({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===H?void 0:H].filter(n=>!!n)});r.common.issues.push(s)}var R=class r{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let s=[];for(let n of t){if(n.status==="aborted")return y;n.status==="dirty"&&e.dirty(),s.push(n.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){let s=[];for(let n of t){let a=await n.key,i=await n.value;s.push({key:a,value:i})}return r.mergeObjectSync(e,s)}static mergeObjectSync(e,t){let s={};for(let n of t){let{key:a,value:i}=n;if(a.status==="aborted"||i.status==="aborted")return y;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||n.alwaysSet)&&(s[a.value]=i.value)}return{status:e.value,value:s}}},y=Object.freeze({status:"aborted"}),X=r=>({status:"dirty",value:r}),A=r=>({status:"valid",value:r}),$e=r=>r.status==="aborted",De=r=>r.status==="dirty",J=r=>r.status==="valid",xe=r=>typeof Promise<"u"&&r instanceof Promise;var p;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e?.message})(p||(p={}));var $=class{constructor(e,t,s,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=n}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},ot=(r,e)=>{if(J(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new C(r.common.issues);return this._error=t,this._error}}};function v(r){if(!r)return{};let{errorMap:e,invalid_type_error:t,required_error:s,description:n}=r;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(i,o)=>{let{message:c}=r;return i.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??s??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:c??t??o.defaultError}},description:n}}var _=class{get description(){return this._def.description}_getType(e){return M(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:M(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new R,ctx:{common:e.parent.common,data:e.data,parsedType:M(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(xe(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){let s={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:M(e)},n=this._parseSync({data:e,path:s.path,parent:s});return ot(s,n)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:M(e)};if(!this["~standard"].async)try{let s=this._parseSync({data:e,path:[],parent:t});return J(s)?{value:s.value}:{issues:t.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(s=>J(s)?{value:s.value}:{issues:t.common.issues})}async parseAsync(e,t){let s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){let s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:M(e)},n=this._parse({data:e,path:s.path,parent:s}),a=await(xe(n)?n:Promise.resolve(n));return ot(s,a)}refine(e,t){let s=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{let i=e(n),o=()=>a.addIssue({code:d.custom,...s(n)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((s,n)=>e(s)?!0:(n.addIssue(typeof t=="function"?t(s,n):t),!1))}_refinement(e){return new D({schema:this,typeName:g.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:t=>this["~validate"](t)}}optional(){return P.create(this,this._def)}nullable(){return V.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return W.create(this)}promise(){return K.create(this,this._def)}or(e){return ie.create([this,e],this._def)}and(e){return oe.create(this,e,this._def)}transform(e){return new D({...v(this._def),schema:this,typeName:g.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new fe({...v(this._def),innerType:this,defaultValue:t,typeName:g.ZodDefault})}brand(){return new Ce({typeName:g.ZodBranded,type:this,...v(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new pe({...v(this._def),innerType:this,catchValue:t,typeName:g.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return je.create(this,e)}readonly(){return he.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Ut=/^c[^\s-]{8,}$/i,Mt=/^[0-9a-z]+$/,zt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Vt=/^[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,Lt=/^[a-z0-9_-]{21}$/i,qt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Ht=/^[-+]?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)?)??$/,Ft=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Bt="^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$",Be,Wt=/^(?:(?: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])$/,Jt=/^(?:(?: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])$/,Gt=/^(([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]))$/,Yt=/^(([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])$/,Kt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Qt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,dt="((\\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])))",Xt=new RegExp(`^${dt}$`);function ut(r){let e="[0-5]\\d";r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`);let t=r.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function er(r){return new RegExp(`^${ut(r)}$`)}function lt(r){let e=`${dt}T${ut(r)}`,t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function tr(r,e){return!!((e==="v4"||!e)&&Wt.test(r)||(e==="v6"||!e)&&Gt.test(r))}function rr(r,e){if(!qt.test(r))return!1;try{let[t]=r.split(".");if(!t)return!1;let s=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),n=JSON.parse(atob(s));return!(typeof n!="object"||n===null||"typ"in n&&n?.typ!=="JWT"||!n.alg||e&&n.alg!==e)}catch{return!1}}function sr(r,e){return!!((e==="v4"||!e)&&Jt.test(r)||(e==="v6"||!e)&&Yt.test(r))}var G=class r extends _{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){let a=this._getOrReturnCtx(e);return l(a,{code:d.invalid_type,expected:f.string,received:a.parsedType}),y}let s=new R,n;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="max")e.data.length>a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="length"){let i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(n=this._getOrReturnCtx(e,n),i?l(n,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&l(n,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),s.dirty())}else if(a.kind==="email")Ft.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"email",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="emoji")Be||(Be=new RegExp(Bt,"u")),Be.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"emoji",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="uuid")Vt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"uuid",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="nanoid")Lt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"nanoid",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid")Ut.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"cuid",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid2")Mt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"cuid2",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="ulid")zt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"ulid",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),l(n,{validation:"url",code:d.invalid_string,message:a.message}),s.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"regex",code:d.invalid_string,message:a.message}),s.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(n=this._getOrReturnCtx(e,n),l(n,{code:d.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),s.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(n=this._getOrReturnCtx(e,n),l(n,{code:d.invalid_string,validation:{startsWith:a.value},message:a.message}),s.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(n=this._getOrReturnCtx(e,n),l(n,{code:d.invalid_string,validation:{endsWith:a.value},message:a.message}),s.dirty()):a.kind==="datetime"?lt(a).test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:d.invalid_string,validation:"datetime",message:a.message}),s.dirty()):a.kind==="date"?Xt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:d.invalid_string,validation:"date",message:a.message}),s.dirty()):a.kind==="time"?er(a).test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:d.invalid_string,validation:"time",message:a.message}),s.dirty()):a.kind==="duration"?Ht.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"duration",code:d.invalid_string,message:a.message}),s.dirty()):a.kind==="ip"?tr(e.data,a.version)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"ip",code:d.invalid_string,message:a.message}),s.dirty()):a.kind==="jwt"?rr(e.data,a.alg)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"jwt",code:d.invalid_string,message:a.message}),s.dirty()):a.kind==="cidr"?sr(e.data,a.version)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"cidr",code:d.invalid_string,message:a.message}),s.dirty()):a.kind==="base64"?Kt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"base64",code:d.invalid_string,message:a.message}),s.dirty()):a.kind==="base64url"?Qt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"base64url",code:d.invalid_string,message:a.message}),s.dirty()):x.assertNever(a);return{status:s.value,value:e.data}}_regex(e,t,s){return this.refinement(n=>e.test(n),{validation:t,code:d.invalid_string,...p.errToObj(s)})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...p.errToObj(e)})}url(e){return this._addCheck({kind:"url",...p.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...p.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...p.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...p.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...p.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...p.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...p.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...p.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...p.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...p.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...p.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...p.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...p.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...p.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...p.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...p.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...p.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...p.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...p.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...p.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...p.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...p.errToObj(t)})}nonempty(e){return this.min(1,p.errToObj(e))}trim(){return new r({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new r({...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 t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};G.create=r=>new G({checks:[],typeName:g.ZodString,coerce:r?.coerce??!1,...v(r)});function nr(r,e){let t=(r.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,n=t>s?t:s,a=Number.parseInt(r.toFixed(n).replace(".","")),i=Number.parseInt(e.toFixed(n).replace(".",""));return a%i/10**n}var ee=class r extends _{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==f.number){let a=this._getOrReturnCtx(e);return l(a,{code:d.invalid_type,expected:f.number,received:a.parsedType}),y}let s,n=new R;for(let a of this._def.checks)a.kind==="int"?x.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:d.invalid_type,expected:"integer",received:"float",message:a.message}),n.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="multipleOf"?nr(e.data,a.value)!==0&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:d.not_finite,message:a.message}),n.dirty()):x.assertNever(a);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,p.toString(t))}gt(e,t){return this.setLimit("min",e,!1,p.toString(t))}lte(e,t){return this.setLimit("max",e,!0,p.toString(t))}lt(e,t){return this.setLimit("max",e,!1,p.toString(t))}setLimit(e,t,s,n){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:p.toString(n)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:p.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:p.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:p.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:p.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:p.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&x.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}};ee.create=r=>new ee({checks:[],typeName:g.ZodNumber,coerce:r?.coerce||!1,...v(r)});var te=class r extends _{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)!==f.bigint)return this._getInvalidInput(e);let s,n=new R;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):x.assertNever(a);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return l(t,{code:d.invalid_type,expected:f.bigint,received:t.parsedType}),y}gte(e,t){return this.setLimit("min",e,!0,p.toString(t))}gt(e,t){return this.setLimit("min",e,!1,p.toString(t))}lte(e,t){return this.setLimit("max",e,!0,p.toString(t))}lt(e,t){return this.setLimit("max",e,!1,p.toString(t))}setLimit(e,t,s,n){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:p.toString(n)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:p.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};te.create=r=>new te({checks:[],typeName:g.ZodBigInt,coerce:r?.coerce??!1,...v(r)});var re=class extends _{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){let s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:f.boolean,received:s.parsedType}),y}return A(e.data)}};re.create=r=>new re({typeName:g.ZodBoolean,coerce:r?.coerce||!1,...v(r)});var se=class r extends _{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){let a=this._getOrReturnCtx(e);return l(a,{code:d.invalid_type,expected:f.date,received:a.parsedType}),y}if(Number.isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return l(a,{code:d.invalid_date}),y}let s=new R,n;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:d.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),s.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:d.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),s.dirty()):x.assertNever(a);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:p.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:p.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};se.create=r=>new se({checks:[],coerce:r?.coerce||!1,typeName:g.ZodDate,...v(r)});var ke=class extends _{_parse(e){if(this._getType(e)!==f.symbol){let s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:f.symbol,received:s.parsedType}),y}return A(e.data)}};ke.create=r=>new ke({typeName:g.ZodSymbol,...v(r)});var ne=class extends _{_parse(e){if(this._getType(e)!==f.undefined){let s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:f.undefined,received:s.parsedType}),y}return A(e.data)}};ne.create=r=>new ne({typeName:g.ZodUndefined,...v(r)});var ae=class extends _{_parse(e){if(this._getType(e)!==f.null){let s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:f.null,received:s.parsedType}),y}return A(e.data)}};ae.create=r=>new ae({typeName:g.ZodNull,...v(r)});var Y=class extends _{constructor(){super(...arguments),this._any=!0}_parse(e){return A(e.data)}};Y.create=r=>new Y({typeName:g.ZodAny,...v(r)});var B=class extends _{constructor(){super(...arguments),this._unknown=!0}_parse(e){return A(e.data)}};B.create=r=>new B({typeName:g.ZodUnknown,...v(r)});var Z=class extends _{_parse(e){let t=this._getOrReturnCtx(e);return l(t,{code:d.invalid_type,expected:f.never,received:t.parsedType}),y}};Z.create=r=>new Z({typeName:g.ZodNever,...v(r)});var we=class extends _{_parse(e){if(this._getType(e)!==f.undefined){let s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:f.void,received:s.parsedType}),y}return A(e.data)}};we.create=r=>new we({typeName:g.ZodVoid,...v(r)});var W=class r extends _{_parse(e){let{ctx:t,status:s}=this._processInputParams(e),n=this._def;if(t.parsedType!==f.array)return l(t,{code:d.invalid_type,expected:f.array,received:t.parsedType}),y;if(n.exactLength!==null){let i=t.data.length>n.exactLength.value,o=t.data.length<n.exactLength.value;(i||o)&&(l(t,{code:i?d.too_big:d.too_small,minimum:o?n.exactLength.value:void 0,maximum:i?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(l(t,{code:d.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(l(t,{code:d.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>n.type._parseAsync(new $(t,i,t.path,o)))).then(i=>R.mergeArray(s,i));let a=[...t.data].map((i,o)=>n.type._parseSync(new $(t,i,t.path,o)));return R.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new r({...this._def,minLength:{value:e,message:p.toString(t)}})}max(e,t){return new r({...this._def,maxLength:{value:e,message:p.toString(t)}})}length(e,t){return new r({...this._def,exactLength:{value:e,message:p.toString(t)}})}nonempty(e){return this.min(1,e)}};W.create=(r,e)=>new W({type:r,minLength:null,maxLength:null,exactLength:null,typeName:g.ZodArray,...v(e)});function be(r){if(r instanceof j){let e={};for(let t in r.shape){let s=r.shape[t];e[t]=P.create(be(s))}return new j({...r._def,shape:()=>e})}else return r instanceof W?new W({...r._def,type:be(r.element)}):r instanceof P?P.create(be(r.unwrap())):r instanceof V?V.create(be(r.unwrap())):r instanceof z?z.create(r.items.map(e=>be(e))):r}var j=class r extends _{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(),t=x.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==f.object){let u=this._getOrReturnCtx(e);return l(u,{code:d.invalid_type,expected:f.object,received:u.parsedType}),y}let{status:s,ctx:n}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof Z&&this._def.unknownKeys==="strip"))for(let u in n.data)i.includes(u)||o.push(u);let c=[];for(let u of i){let m=a[u],T=n.data[u];c.push({key:{status:"valid",value:u},value:m._parse(new $(n,T,n.path,u)),alwaysSet:u in n.data})}if(this._def.catchall instanceof Z){let u=this._def.unknownKeys;if(u==="passthrough")for(let m of o)c.push({key:{status:"valid",value:m},value:{status:"valid",value:n.data[m]}});else if(u==="strict")o.length>0&&(l(n,{code:d.unrecognized_keys,keys:o}),s.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let m of o){let T=n.data[m];c.push({key:{status:"valid",value:m},value:u._parse(new $(n,T,n.path,m)),alwaysSet:m in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let u=[];for(let m of c){let T=await m.key,U=await m.value;u.push({key:T,value:U,alwaysSet:m.alwaysSet})}return u}).then(u=>R.mergeObjectSync(s,u)):R.mergeObjectSync(s,c)}get shape(){return this._def.shape()}strict(e){return p.errToObj,new r({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{let n=this._def.errorMap?.(t,s).message??s.defaultError;return t.code==="unrecognized_keys"?{message:p.errToObj(e).message??n}:{message:n}}}:{}})}strip(){return new r({...this._def,unknownKeys:"strip"})}passthrough(){return new r({...this._def,unknownKeys:"passthrough"})}extend(e){return new r({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new r({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:g.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new r({...this._def,catchall:e})}pick(e){let t={};for(let s of x.objectKeys(e))e[s]&&this.shape[s]&&(t[s]=this.shape[s]);return new r({...this._def,shape:()=>t})}omit(e){let t={};for(let s of x.objectKeys(this.shape))e[s]||(t[s]=this.shape[s]);return new r({...this._def,shape:()=>t})}deepPartial(){return be(this)}partial(e){let t={};for(let s of x.objectKeys(this.shape)){let n=this.shape[s];e&&!e[s]?t[s]=n:t[s]=n.optional()}return new r({...this._def,shape:()=>t})}required(e){let t={};for(let s of x.objectKeys(this.shape))if(e&&!e[s])t[s]=this.shape[s];else{let a=this.shape[s];for(;a instanceof P;)a=a._def.innerType;t[s]=a}return new r({...this._def,shape:()=>t})}keyof(){return ft(x.objectKeys(this.shape))}};j.create=(r,e)=>new j({shape:()=>r,unknownKeys:"strip",catchall:Z.create(),typeName:g.ZodObject,...v(e)});j.strictCreate=(r,e)=>new j({shape:()=>r,unknownKeys:"strict",catchall:Z.create(),typeName:g.ZodObject,...v(e)});j.lazycreate=(r,e)=>new j({shape:r,unknownKeys:"strip",catchall:Z.create(),typeName:g.ZodObject,...v(e)});var ie=class extends _{_parse(e){let{ctx:t}=this._processInputParams(e),s=this._def.options;function n(a){for(let o of a)if(o.result.status==="valid")return o.result;for(let o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;let i=a.map(o=>new C(o.ctx.common.issues));return l(t,{code:d.invalid_union,unionErrors:i}),y}if(t.common.async)return Promise.all(s.map(async a=>{let i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(n);{let a,i=[];for(let c of s){let u={...t,common:{...t.common,issues:[]},parent:null},m=c._parseSync({data:t.data,path:t.path,parent:u});if(m.status==="valid")return m;m.status==="dirty"&&!a&&(a={result:m,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(c=>new C(c));return l(t,{code:d.invalid_union,unionErrors:o}),y}}get options(){return this._def.options}};ie.create=(r,e)=>new ie({options:r,typeName:g.ZodUnion,...v(e)});var F=r=>r instanceof ce?F(r.schema):r instanceof D?F(r.innerType()):r instanceof de?[r.value]:r instanceof ue?r.options:r instanceof le?x.objectValues(r.enum):r instanceof fe?F(r._def.innerType):r instanceof ne?[void 0]:r instanceof ae?[null]:r instanceof P?[void 0,...F(r.unwrap())]:r instanceof V?[null,...F(r.unwrap())]:r instanceof Ce||r instanceof he?F(r.unwrap()):r instanceof pe?F(r._def.innerType):[],Ze=class r extends _{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.object)return l(t,{code:d.invalid_type,expected:f.object,received:t.parsedType}),y;let s=this.discriminator,n=t.data[s],a=this.optionsMap.get(n);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(l(t,{code:d.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),y)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){let n=new Map;for(let a of t){let i=F(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of i){if(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,a)}}return new r({typeName:g.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...v(s)})}};function We(r,e){let t=M(r),s=M(e);if(r===e)return{valid:!0,data:r};if(t===f.object&&s===f.object){let n=x.objectKeys(e),a=x.objectKeys(r).filter(o=>n.indexOf(o)!==-1),i={...r,...e};Object.prototype.hasOwnProperty.call(i,"__proto__")&&delete i.__proto__;for(let o of a){if(o==="__proto__")continue;let c=We(r[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===f.array&&s===f.array){if(r.length!==e.length)return{valid:!1};let n=[];for(let a=0;a<r.length;a++){let i=r[a],o=e[a],c=We(i,o);if(!c.valid)return{valid:!1};n.push(c.data)}return{valid:!0,data:n}}else return t===f.date&&s===f.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}var oe=class extends _{_parse(e){let{status:t,ctx:s}=this._processInputParams(e),n=(a,i)=>{if($e(a)||$e(i))return y;let o=We(a.value,i.value);return o.valid?((De(a)||De(i))&&t.dirty(),{status:t.value,value:o.data}):(l(s,{code:d.invalid_intersection_types}),y)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,i])=>n(a,i)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}};oe.create=(r,e,t)=>new oe({left:r,right:e,typeName:g.ZodIntersection,...v(t)});var z=class r extends _{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.array)return l(s,{code:d.invalid_type,expected:f.array,received:s.parsedType}),y;if(s.data.length<this._def.items.length)return l(s,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),y;!this._def.rest&&s.data.length>this._def.items.length&&(l(s,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let a=[...s.data].map((i,o)=>{let c=this._def.items[o]||this._def.rest;return c?c._parse(new $(s,i,s.path,o)):null}).filter(i=>!!i);return s.common.async?Promise.all(a).then(i=>R.mergeArray(t,i)):R.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new r({...this._def,rest:e})}};z.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new z({items:r,typeName:g.ZodTuple,rest:null,...v(e)})};var Ue=class r extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.object)return l(s,{code:d.invalid_type,expected:f.object,received:s.parsedType}),y;let n=[],a=this._def.keyType,i=this._def.valueType;for(let o in s.data)n.push({key:a._parse(new $(s,o,s.path,o)),value:i._parse(new $(s,s.data[o],s.path,o)),alwaysSet:o in s.data});return s.common.async?R.mergeObjectAsync(t,n):R.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof _?new r({keyType:e,valueType:t,typeName:g.ZodRecord,...v(s)}):new r({keyType:G.create(),valueType:e,typeName:g.ZodRecord,...v(t)})}},Te=class extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.map)return l(s,{code:d.invalid_type,expected:f.map,received:s.parsedType}),y;let n=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([o,c],u)=>({key:n._parse(new $(s,o,s.path,[u,"key"])),value:a._parse(new $(s,c,s.path,[u,"value"]))}));if(s.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let c of i){let u=await c.key,m=await c.value;if(u.status==="aborted"||m.status==="aborted")return y;(u.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(u.value,m.value)}return{status:t.value,value:o}})}else{let o=new Map;for(let c of i){let u=c.key,m=c.value;if(u.status==="aborted"||m.status==="aborted")return y;(u.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(u.value,m.value)}return{status:t.value,value:o}}}};Te.create=(r,e,t)=>new Te({valueType:e,keyType:r,typeName:g.ZodMap,...v(t)});var Se=class r extends _{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.set)return l(s,{code:d.invalid_type,expected:f.set,received:s.parsedType}),y;let n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(l(s,{code:d.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&s.data.size>n.maxSize.value&&(l(s,{code:d.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());let a=this._def.valueType;function i(c){let u=new Set;for(let m of c){if(m.status==="aborted")return y;m.status==="dirty"&&t.dirty(),u.add(m.value)}return{status:t.value,value:u}}let o=[...s.data.values()].map((c,u)=>a._parse(new $(s,c,s.path,u)));return s.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new r({...this._def,minSize:{value:e,message:p.toString(t)}})}max(e,t){return new r({...this._def,maxSize:{value:e,message:p.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Se.create=(r,e)=>new Se({valueType:r,minSize:null,maxSize:null,typeName:g.ZodSet,...v(e)});var Me=class r extends _{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.function)return l(t,{code:d.invalid_type,expected:f.function,received:t.parsedType}),y;function s(o,c){return Ie({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,_e(),H].filter(u=>!!u),issueData:{code:d.invalid_arguments,argumentsError:c}})}function n(o,c){return Ie({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,_e(),H].filter(u=>!!u),issueData:{code:d.invalid_return_type,returnTypeError:c}})}let a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof K){let o=this;return A(async function(...c){let u=new C([]),m=await o._def.args.parseAsync(c,a).catch(ye=>{throw u.addIssue(s(c,ye)),u}),T=await Reflect.apply(i,this,m);return await o._def.returns._def.type.parseAsync(T,a).catch(ye=>{throw u.addIssue(n(T,ye)),u})})}else{let o=this;return A(function(...c){let u=o._def.args.safeParse(c,a);if(!u.success)throw new C([s(c,u.error)]);let m=Reflect.apply(i,this,u.data),T=o._def.returns.safeParse(m,a);if(!T.success)throw new C([n(m,T.error)]);return T.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new r({...this._def,args:z.create(e).rest(B.create())})}returns(e){return new r({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new r({args:e||z.create([]).rest(B.create()),returns:t||B.create(),typeName:g.ZodFunction,...v(s)})}},ce=class extends _{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};ce.create=(r,e)=>new ce({getter:r,typeName:g.ZodLazy,...v(e)});var de=class extends _{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return l(t,{received:t.data,code:d.invalid_literal,expected:this._def.value}),y}return{status:"valid",value:e.data}}get value(){return this._def.value}};de.create=(r,e)=>new de({value:r,typeName:g.ZodLiteral,...v(e)});function ft(r,e){return new ue({values:r,typeName:g.ZodEnum,...v(e)})}var ue=class r extends _{_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),s=this._def.values;return l(t,{expected:x.joinValues(s),received:t.parsedType,code:d.invalid_type}),y}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),s=this._def.values;return l(t,{received:t.data,code:d.invalid_enum_value,options:s}),y}return A(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return r.create(e,{...this._def,...t})}exclude(e,t=this._def){return r.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}};ue.create=ft;var le=class extends _{_parse(e){let t=x.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==f.string&&s.parsedType!==f.number){let n=x.objectValues(t);return l(s,{expected:x.joinValues(n),received:s.parsedType,code:d.invalid_type}),y}if(this._cache||(this._cache=new Set(x.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let n=x.objectValues(t);return l(s,{received:s.data,code:d.invalid_enum_value,options:n}),y}return A(e.data)}get enum(){return this._def.values}};le.create=(r,e)=>new le({values:r,typeName:g.ZodNativeEnum,...v(e)});var K=class extends _{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.promise&&t.common.async===!1)return l(t,{code:d.invalid_type,expected:f.promise,received:t.parsedType}),y;let s=t.parsedType===f.promise?t.data:Promise.resolve(t.data);return A(s.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}};K.create=(r,e)=>new K({type:r,typeName:g.ZodPromise,...v(e)});var D=class extends _{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===g.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:s}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:i=>{l(s,i),i.fatal?t.abort():t.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){let i=n.transform(s.data,a);if(s.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return y;let c=await this._def.schema._parseAsync({data:o,path:s.path,parent:s});return c.status==="aborted"?y:c.status==="dirty"?X(c.value):t.value==="dirty"?X(c.value):c});{if(t.value==="aborted")return y;let o=this._def.schema._parseSync({data:i,path:s.path,parent:s});return o.status==="aborted"?y:o.status==="dirty"?X(o.value):t.value==="dirty"?X(o.value):o}}if(n.type==="refinement"){let i=o=>{let c=n.refinement(o,a);if(s.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){let o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?y:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?y:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(n.type==="transform")if(s.common.async===!1){let i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!J(i))return y;let o=n.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>J(i)?Promise.resolve(n.transform(i.value,a)).then(o=>({status:t.value,value:o})):y);x.assertNever(n)}};D.create=(r,e,t)=>new D({schema:r,typeName:g.ZodEffects,effect:e,...v(t)});D.createWithPreprocess=(r,e,t)=>new D({schema:e,effect:{type:"preprocess",transform:r},typeName:g.ZodEffects,...v(t)});var P=class extends _{_parse(e){return this._getType(e)===f.undefined?A(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};P.create=(r,e)=>new P({innerType:r,typeName:g.ZodOptional,...v(e)});var V=class extends _{_parse(e){return this._getType(e)===f.null?A(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};V.create=(r,e)=>new V({innerType:r,typeName:g.ZodNullable,...v(e)});var fe=class extends _{_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return t.parsedType===f.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};fe.create=(r,e)=>new fe({innerType:r,typeName:g.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...v(e)});var pe=class extends _{_parse(e){let{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return xe(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new C(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new C(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}};pe.create=(r,e)=>new pe({innerType:r,typeName:g.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...v(e)});var Oe=class extends _{_parse(e){if(this._getType(e)!==f.nan){let s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:f.nan,received:s.parsedType}),y}return{status:"valid",value:e.data}}};Oe.create=r=>new Oe({typeName:g.ZodNaN,...v(r)});var ar=Symbol("zod_brand"),Ce=class extends _{_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}},je=class r extends _{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?y:a.status==="dirty"?(t.dirty(),X(a.value)):this._def.out._parseAsync({data:a.value,path:s.path,parent:s})})();{let n=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?y:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:s.path,parent:s})}}static create(e,t){return new r({in:e,out:t,typeName:g.ZodPipeline})}},he=class extends _{_parse(e){let t=this._def.innerType._parse(e),s=n=>(J(n)&&(n.value=Object.freeze(n.value)),n);return xe(t)?t.then(n=>s(n)):s(t)}unwrap(){return this._def.innerType}};he.create=(r,e)=>new he({innerType:r,typeName:g.ZodReadonly,...v(e)});function ct(r,e){let t=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof t=="string"?{message:t}:t}function pt(r,e={},t){return r?Y.create().superRefine((s,n)=>{let a=r(s);if(a instanceof Promise)return a.then(i=>{if(!i){let o=ct(e,s),c=o.fatal??t??!0;n.addIssue({code:"custom",...o,fatal:c})}});if(!a){let i=ct(e,s),o=i.fatal??t??!0;n.addIssue({code:"custom",...i,fatal:o})}}):Y.create()}var ir={object:j.lazycreate},g;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(g||(g={}));var or=(r,e={message:`Input not instance of ${r.name}`})=>pt(t=>t instanceof r,e),ht=G.create,mt=ee.create,cr=Oe.create,dr=te.create,yt=re.create,ur=se.create,lr=ke.create,fr=ne.create,pr=ae.create,hr=Y.create,mr=B.create,yr=Z.create,gr=we.create,vr=W.create,_r=j.create,xr=j.strictCreate,br=ie.create,kr=Ze.create,wr=oe.create,Tr=z.create,Sr=Ue.create,Or=Te.create,Rr=Se.create,Ar=Me.create,Er=ce.create,Ir=de.create,Cr=ue.create,jr=le.create,Nr=K.create,Pr=D.create,$r=P.create,Dr=V.create,Zr=D.createWithPreprocess,Ur=je.create,Mr=()=>ht().optional(),zr=()=>mt().optional(),Vr=()=>yt().optional(),Lr={string:(r=>G.create({...r,coerce:!0})),number:(r=>ee.create({...r,coerce:!0})),boolean:(r=>re.create({...r,coerce:!0})),bigint:(r=>te.create({...r,coerce:!0})),date:(r=>se.create({...r,coerce:!0}))};var qr=y;var Je=h.object({environmentId:h.string().uuid(),allowed:h.boolean(),revision:h.string().uuid(),updatedAt:h.string().datetime(),updatedBy:h.string().uuid()}).strict();function gt(r,e,t){let s=Je.safeParse(e);return!s.success||!s.data.allowed||!r.environmentId||s.data.environmentId!==r.environmentId||!r.environmentAddress||r.persistentDataPolicy&&r.persistentDataPolicy.revision!==s.data.revision?!1:Ge(r.environmentAddress,t)}function Ge(r,e){try{let t=new URL(e),s=new URL(r);if(s.search||s.hash)return!1;let n=/%(?:2f|5c|2e|25)/i;if(e.includes("\\")||r.includes("\\")||n.test(t.pathname)||n.test(s.pathname))return!1;let a=s.pathname.replace(/\/$/,"");return["https:","http:"].includes(s.protocol)&&t.origin===s.origin&&(t.pathname===a||t.pathname.startsWith(`${a}/`))}catch{return!1}}var Qe=(t=>(t.Patch="PATCH",t.Put="PUT",t))(Qe||{}),Re=class extends Error{constructor(t){super(`Safety gap: ${t.reason}`);this.incident=t}incident},Ae=class extends Error{constructor(t){super("The delivered test assertion or execution failed; its resource trace is retained in diagnostics");this.trace=t}trace},me=class extends Error{};function w(r){throw new me(`environment restriction: ${r}`)}function Xe(r){let e=new URL(r);return(!["https:","http:"].includes(e.protocol)||e.username||e.password||e.search||e.hash||/%(?:2f|5c|2e|25)/i.test(e.pathname)||r.includes("\\"))&&w("unsupported environment address"),e.href.replace(/\/$/,"")}function ze(r,e){let t=new URL(e,`${r}/`);return(!Ge(r,e.includes("://")?e:t.href)||t.username||t.password||t.hash)&&w("request leaves the selected environment"),t}function Hr(r){let e=r.map(t=>{(!t||t.includes("\\")||/[\[\]{}()]/.test(t))&&w("unsupported off-limits pattern");let s=n=>n.split("*").map(a=>a.replace(/[.+?^$|]/g,"\\$&")).join(".*");return new RegExp(t.endsWith("/**")?`^(?:${s(t)}|${s(t.slice(0,-3))})$`:`^${s(t)}$`,"i")});return t=>e.some(s=>s.test(t.href)||s.test(t.pathname))}async function Fr(r){let e=await r.text();if(e)try{return JSON.parse(e)}catch{throw new Error("Shared test response was not JSON")}}function Ke(r){let e=new URL(r);if(e.protocol!=="https:"||e.username||e.password||e.pathname!=="/"||e.search||e.hash)throw new Error("expected a bare HTTPS origin");return e.origin}function vt(r,e,t){let s=new URL(r),n=(e??"").split(",").map(a=>a.trim()).filter(Boolean);return(s.protocol!=="https:"||s.username||s.password||s.hash||!(s.port===""&&t(s.hostname))&&!n.some(a=>Ke(a)===s.origin))&&w("unsupported workflow identity endpoint"),s}function Ve(r,e){let t=r;for(let s of e){if(!t||typeof t!="object"||!Object.hasOwn(t,s))return;t=t[s]}return t}async function _t(r){let e=await r.text(),t;if(e)try{t=JSON.parse(e)}catch{t=e}return{status:r.status,headers:r.headers,body:t}}function Br(r,e){let t=r.bearerTokenEnv;if(!t)return;let s=process.env[t];if(!s?.trim())throw new Error(`required SUT credential ${t} is unavailable`);if(process.env.TESTBOT_SHARED_SUT_TOKEN_ENV!==t)throw new Error("declared SUT credential is not approved by TESTBOT_SHARED_SUT_TOKEN_ENV");let n=process.env.TESTBOT_SHARED_SUT_ADDRESS,a=!1;try{a=!!n&&Xe(n)===e}catch{}if(!a)throw new Error("SUT address does not match TESTBOT_SHARED_SUT_ADDRESS");return s}async function Wr(r){let e=process.env.ACTIONS_ID_TOKEN_REQUEST_URL,t=process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN,s=process.env.SYSTEM_OIDCREQUESTURI,n=process.env.SYSTEM_ACCESSTOKEN,a,i,o;if(e&&t)a=vt(e,process.env.TESTBOT_GITHUB_OIDC_ORIGINS,T=>T.endsWith(".actions.githubusercontent.com")),a.searchParams.set("audience",r),i=t,o="github";else if(s&&n)a=vt(s,process.env.TESTBOT_AZURE_OIDC_ORIGINS,T=>T==="dev.azure.com"||T.endsWith(".visualstudio.com")),a.searchParams.set("api-version","7.1-preview.1"),i=n,o="azure";else return w("fresh provider-signed workflow identity is unavailable");let c=await fetch(a,{method:o==="github"?"GET":"POST",headers:{Authorization:`Bearer ${i}`,...o==="azure"?{"Content-Type":"application/json",Accept:"application/json"}:{}},...o==="azure"?{body:"{}"}:{},redirect:"error",signal:AbortSignal.timeout(1e4)});if(!c.ok)return w("workflow identity request failed");let u=await c.json(),m=o==="github"?u.value:u.oidcToken;return typeof m=="string"&&m?m:w("workflow identity response is invalid")}async function Ye(r,e){try{r.targetId||w("current persistent-data policy is unavailable");let t=Ke(process.env.TESTBOT_POLICY_ORIGIN??"https://testbot.skyramp.dev");r.appOrigin&&Ke(r.appOrigin)!==t&&w("policy service origin does not match trusted CI configuration");let s=await Wr(t),n=`${t}/api/v1/runner/targets/${encodeURIComponent(r.targetId)}/test-environments/${encodeURIComponent(r.environmentId)}/persistent-data-policy`,a=await fetch(n,{headers:{Authorization:`Bearer ${s}`},cache:"no-store",redirect:"error",signal:AbortSignal.timeout(1e4)});a.ok||w("current persistent-data policy is unavailable");let i=await a.json(),o=Je.safeParse(i.persistentDataPolicy);(i.schemaVersion!==1||i.environmentId!==r.environmentId||typeof i.environmentAddress!="string"||Xe(i.environmentAddress)!==e||!o.success||!gt({environmentId:r.environmentId,environmentAddress:e},o.data,e))&&w("current policy does not authorize this environment")}catch(t){if(t instanceof me)throw t;w("current persistent-data policy is unavailable")}}function xt(r){return{status:"restricted",detail:r instanceof me?r.message:"environment restriction: unsupported shared-environment configuration"}}async function kt(r,e){let t,s;try{(!r||!r.environmentId||!Array.isArray(r.offLimits))&&w("shared-environment identity and off-limits rules are required"),t=Xe(r.environmentAddress),s=Hr(r.offLimits),r.route?.kind!=="persistence"&&w("delivered shared tests require the persistence route")}catch(b){return xt(b)}let n=Br(r,t);try{await Ye(r,t)}catch(b){return xt(b)}let a=`testbot-${(0,bt.randomUUID)()}`,i=new Set,o=[],c=async(b,O,k)=>{let N=ze(t,O);return s(N)&&w("the request is off limits"),["GET","HEAD","OPTIONS"].includes(b)||(ye=!0),await fetch(N,{method:b,headers:{...n?{Authorization:`Bearer ${n}`}:{},...k===void 0?{}:{"Content-Type":"application/json"}},redirect:"error",signal:AbortSignal.timeout(1e4),...k===void 0?{}:{body:JSON.stringify(k)}})},u=b=>{let O=ze(t,b).href;return i.has(O)||w("mutations and resource reads require a run-owned resource"),O},m=b=>new Ae({runId:a,route:r.route.kind,resources:o,retained:!0,outcome:"test-failed",...b===void 0?{}:{status:b}}),T=async(b,O)=>{let k=b.status;if(!(O===void 0?b.ok:O===k)||k<200||k>=300&&k<400||k>=500)throw await b.body?.cancel(),m(k);return _t(b)},U,ye=!1;try{await e({async create(b,O,k,N={}){(!k.trim()||!Object.hasOwn(O,k)||typeof O[k]!="string")&&w("creation needs a supported run-unique string field"),Object.keys(O).some(q=>/^(?:id|_id|uuid|pk)$/i.test(q))&&w("caller-selected resource IDs cannot establish a newly owned record");let I=ze(t,b);I.search&&w("create-only collections cannot use query actions"),s(I)&&w("the request is off limits");let ge=`${O[k]}-${a}`,ve=q=>new Re({runId:a,route:r.route.kind,resources:[...o,I.href],outcome:"failed-or-unknown",reason:q});await Ye(r,t);let E;try{E=await c("POST",I.href,{...O,[k]:ge})}catch(q){throw q instanceof me?q:ve("create response was unavailable; side effects are unknown")}if(E.status>=400&&E.status<500){if(E.status===N.expectedStatus)return _t(E);throw await E.body?.cancel(),m(E.status)}if(!E.ok)throw ve(`create did not establish new-resource provenance (${E.status})`);let Pe;try{Pe=await Fr(E)}catch{throw ve("create returned unreadable resource provenance")}if(Ve(Pe,N.responseUniqueFieldPath??[k])!==ge)throw ve("create did not confirm the run-unique value");let qe=Ve(Pe,N.responseIdPath??["id"]),rt=E.headers.get("location"),L;try{let q=rt?new URL(rt,I).href:typeof qe=="string"||typeof qe=="number"?`${I.href.replace(/\/$/,"")}/${encodeURIComponent(qe)}`:void 0;if(!q)throw new Error("no resource identity");L=ze(t,q)}catch{throw ve("create returned missing, invalid or out-of-scope resource provenance")}let st=I.pathname.replace(/\/$/,"")+"/",nt=L.pathname.slice(st.length);if(L.search||!L.pathname.startsWith(st)||!nt||nt.includes("/")||s(L)||i.has(L.href))throw ve("create returned unsupported resource provenance");if(i.add(L.href),o.push(L.href),E.status!==(N.expectedStatus??201))throw m(E.status);return{url:L.href,body:Pe,status:E.status,headers:E.headers}},async read(b,O={}){let k=new URL(u(b));for(let[I,ge]of Object.entries(O.query??{}))k.searchParams.append(I,ge);let N=await c("GET",k.href);return T(N,O.expectedStatus)},async update(b,O,k={}){let N=u(b),I=k.method??"PATCH";I!=="PATCH"&&I!=="PUT"&&w("unsupported resource update method"),await Ye(r,t);let ge=await c(I,N,O);return T(ge,k.expectedStatus)}})}catch(b){U=b}if(U instanceof me&&!ye)return{status:"restricted",detail:U.message};if(U instanceof Re||U instanceof Ae)throw U;if(U)throw m();return{status:"executed",runId:a,resources:o,retained:!0}}var Ne=h.lazy(()=>h.union([h.string(),h.number().finite(),h.boolean(),h.null(),h.array(Ne),h.record(Ne)])),S=h.string().trim().min(1),Tt=h.string().regex(/^[A-Za-z_]\w*$/).optional(),et=h.number().int().refine(r=>r>=200&&r<300||r>=400&&r<500,"Expected an explicit success or client rejection status").optional(),wt=h.array(S).min(1).max(20).optional(),Jr=h.object({environmentId:h.string().uuid(),environmentAddress:h.string().url(),targetId:S.optional(),appOrigin:h.string().url().optional(),offLimits:h.array(S),bearerTokenEnv:Tt,route:h.object({kind:h.literal("persistence")}).strict()}).strict(),St=h.array(h.discriminatedUnion("op",[h.object({op:h.literal("create"),collection:S,body:h.record(Ne),uniqueField:S,expectedStatus:et,responseIdPath:wt,responseUniqueFieldPath:wt,as:S}).strict(),h.object({op:h.literal("read"),resource:S,as:S,expectedStatus:et,query:h.record(h.string()).optional()}).strict(),h.object({op:h.literal("update"),resource:S,method:h.nativeEnum(Qe).optional(),expectedStatus:et,body:h.record(Ne),as:S}).strict(),h.object({op:h.literal("assert"),resource:S,path:h.array(S),equals:Ne}).strict(),h.object({op:h.literal("assertStatus"),resource:S,equals:h.number().int().min(200).max(499)}).strict(),h.object({op:h.literal("assertHeader"),resource:S,name:h.string().regex(/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/),equals:h.string().nullable()}).strict()])).min(1).refine(r=>r.some(e=>e.op==="assert"||e.op==="assertStatus"||e.op==="assertHeader"),"A runnable test must retain a planned assertion"),js=h.object({name:S,bearerTokenEnv:Tt,steps:St.describe("ordered objects with op: create (collection, body, uniqueField, as; optional expectedStatus, responseIdPath, responseUniqueFieldPath), read (resource, as; optional expectedStatus, query), update (resource, body, as; optional expectedStatus, method PUT or PATCH), assert (resource, path, equals), assertStatus (resource, equals), or assertHeader (resource, name, equals). Resource names an earlier request alias and paths are arrays of JSON keys")}).strict(),tt=h.union([h.object({name:S,definition:Jr,steps:St}).strict(),h.object({name:S,restriction:S,sourceAsset:h.object({path:S.regex(/^(?!\/)(?!.*(?:^|\/)\.\.?(?:\/|$))[^\\]+\.source$/),sha256:h.string().regex(/^[a-f0-9]{64}$/)}).strict()}).strict()]),Gr=`"use strict";
2
+ const spec = `,Yr=`;
3
+ let runtime;
4
+ try { runtime = require("@skyramp/testbot-core/dist/shared-environment-test.cjs"); } catch {}
5
+ if (runtime && typeof runtime.sharedEnvironmentTest === "function") runtime.sharedEnvironmentTest(spec, __filename);
6
+ else require("node:test").test(spec.name, () => { throw new Error("required shared-environment guard runtime is unavailable"); });
7
+ `;function Ot(r){return Gr+JSON.stringify(tt.parse(r),null,2)+Yr}function Kr(r,e){let t=tt.parse(r);return(0,At.test)(t.name,async s=>{if("restriction"in t){let a=(0,Q.realpathSync)((0,Ee.dirname)(e)),i=(0,Ee.resolve)(a,t.sourceAsset.path);if(!i.startsWith(a+Ee.sep)||!(0,Q.lstatSync)(i).isFile()||(0,Q.lstatSync)(i).isSymbolicLink()||(0,Q.realpathSync)(i)!==i||(0,Rt.createHash)("sha256").update((0,Q.readFileSync)(i)).digest("hex")!==t.sourceAsset.sha256)throw new Error("The restricted required test source asset is missing or changed");s.skip(`environment restriction: ${t.restriction}`);return}let n;try{n=await kt(t.definition,async a=>{let i=new Map,o=c=>{if(i.has(c))throw new Error("A delivered response alias cannot be reused")};for(let c of t.steps){if(c.op==="create"){o(c.as),i.set(c.as,await a.create(c.collection,c.body,c.uniqueField,c));continue}let u=i.get(c.resource);if(!u)throw new Error("A delivered step names no earlier response");if(c.op==="assert"){let m=Ve(u.body,c.path);if(m===void 0)throw new Error("The planned assertion field was absent");(0,Le.deepStrictEqual)(m,c.equals)}else if(c.op==="assertStatus")(0,Le.deepStrictEqual)(u.status,c.equals);else if(c.op==="assertHeader")(0,Le.deepStrictEqual)(u.headers.get(c.name),c.equals);else{if(!u.url)throw new Error("A delivered request names no run-owned resource");o(c.as);let m=c.op==="read"?await a.read(u.url,c):await a.update(u.url,c.body,c);i.set(c.as,{...m,url:u.url})}}})}catch(a){throw a instanceof Re&&s.diagnostic(JSON.stringify(a.incident)),a instanceof Ae&&s.diagnostic(JSON.stringify(a.trace)),a}n.status==="restricted"?s.skip(n.detail):s.diagnostic(JSON.stringify(n))})}0&&(module.exports={renderDeliveredSharedTest,sharedEnvironmentTest});