@polagram/core 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +20 -4
- package/dist/polagram-core.js +48 -33
- package/dist/polagram-core.umd.cjs +4 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -230,7 +230,11 @@ declare const LensSchema: z.ZodObject<{
|
|
|
230
230
|
}, z.core.$strip>]>;
|
|
231
231
|
}, z.core.$strip>, z.ZodObject<{
|
|
232
232
|
action: z.ZodLiteral<"merge">;
|
|
233
|
-
|
|
233
|
+
into: z.ZodOptional<z.ZodObject<{
|
|
234
|
+
name: z.ZodOptional<z.ZodString>;
|
|
235
|
+
id: z.ZodOptional<z.ZodString>;
|
|
236
|
+
stereotype: z.ZodOptional<z.ZodString>;
|
|
237
|
+
}, z.core.$strip>>;
|
|
234
238
|
selector: z.ZodObject<{
|
|
235
239
|
kind: z.ZodLiteral<"participant">;
|
|
236
240
|
name: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
@@ -251,7 +255,11 @@ declare const LensSchema: z.ZodObject<{
|
|
|
251
255
|
|
|
252
256
|
export declare interface MergeLayer {
|
|
253
257
|
action: 'merge';
|
|
254
|
-
|
|
258
|
+
into?: {
|
|
259
|
+
name?: string;
|
|
260
|
+
id?: string;
|
|
261
|
+
stereotype?: string;
|
|
262
|
+
};
|
|
255
263
|
selector: ParticipantSelector;
|
|
256
264
|
}
|
|
257
265
|
|
|
@@ -544,7 +552,11 @@ export declare const PolagramConfigSchema: z.ZodObject<{
|
|
|
544
552
|
}, z.core.$strip>]>;
|
|
545
553
|
}, z.core.$strip>, z.ZodObject<{
|
|
546
554
|
action: z.ZodLiteral<"merge">;
|
|
547
|
-
|
|
555
|
+
into: z.ZodOptional<z.ZodObject<{
|
|
556
|
+
name: z.ZodOptional<z.ZodString>;
|
|
557
|
+
id: z.ZodOptional<z.ZodString>;
|
|
558
|
+
stereotype: z.ZodOptional<z.ZodString>;
|
|
559
|
+
}, z.core.$strip>>;
|
|
548
560
|
selector: z.ZodObject<{
|
|
549
561
|
kind: z.ZodLiteral<"participant">;
|
|
550
562
|
name: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
@@ -717,7 +729,11 @@ declare const TargetConfigSchema: z.ZodObject<{
|
|
|
717
729
|
}, z.core.$strip>]>;
|
|
718
730
|
}, z.core.$strip>, z.ZodObject<{
|
|
719
731
|
action: z.ZodLiteral<"merge">;
|
|
720
|
-
|
|
732
|
+
into: z.ZodOptional<z.ZodObject<{
|
|
733
|
+
name: z.ZodOptional<z.ZodString>;
|
|
734
|
+
id: z.ZodOptional<z.ZodString>;
|
|
735
|
+
stereotype: z.ZodOptional<z.ZodString>;
|
|
736
|
+
}, z.core.$strip>>;
|
|
721
737
|
selector: z.ZodObject<{
|
|
722
738
|
kind: z.ZodLiteral<"participant">;
|
|
723
739
|
name: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
package/dist/polagram-core.js
CHANGED
|
@@ -1324,30 +1324,41 @@ class Bt extends K {
|
|
|
1324
1324
|
}
|
|
1325
1325
|
class Jt extends K {
|
|
1326
1326
|
constructor(e) {
|
|
1327
|
-
super(), this.layer = e
|
|
1327
|
+
super(), this.layer = e;
|
|
1328
1328
|
}
|
|
1329
1329
|
matcher = new ne();
|
|
1330
1330
|
mergedParticipantIds = /* @__PURE__ */ new Set();
|
|
1331
|
-
|
|
1331
|
+
targetParticipantId = "";
|
|
1332
1332
|
transform(e) {
|
|
1333
|
-
const n = this.layer.selector;
|
|
1334
|
-
if (e.participants.forEach((
|
|
1335
|
-
this.matcher.matchParticipant(
|
|
1336
|
-
}),
|
|
1333
|
+
const n = this.layer.selector, r = [];
|
|
1334
|
+
if (e.participants.forEach((d) => {
|
|
1335
|
+
this.matcher.matchParticipant(d, n) && r.push(d);
|
|
1336
|
+
}), r.length === 0)
|
|
1337
1337
|
return e;
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1338
|
+
this.mergedParticipantIds = new Set(r.map((d) => d.id));
|
|
1339
|
+
const i = this.layer.into || {};
|
|
1340
|
+
let s = i.id, o = i.name;
|
|
1341
|
+
s || (o ? s = o.replace(/[^a-zA-Z0-9-_]/g, "_") : s = r.map((d) => d.id).join("_")), o || (o = s), this.targetParticipantId = s;
|
|
1342
|
+
const a = [], h = !e.participants.some(
|
|
1343
|
+
(d) => d.id === s && !this.mergedParticipantIds.has(d.id)
|
|
1344
|
+
);
|
|
1345
|
+
let p = !1;
|
|
1346
|
+
for (const d of e.participants) {
|
|
1347
|
+
if (this.mergedParticipantIds.has(d.id)) {
|
|
1348
|
+
if (h && !p) {
|
|
1349
|
+
const f = {
|
|
1350
|
+
id: s || "",
|
|
1351
|
+
name: o || "",
|
|
1352
|
+
type: "participant"
|
|
1353
|
+
// Todo: map stereotype?
|
|
1354
|
+
};
|
|
1355
|
+
a.push(f), p = !0;
|
|
1356
|
+
}
|
|
1357
|
+
continue;
|
|
1358
|
+
}
|
|
1359
|
+
d.id, a.push(d);
|
|
1347
1360
|
}
|
|
1348
|
-
return e.participants =
|
|
1349
|
-
(i) => !this.mergedParticipantIds.has(i.id)
|
|
1350
|
-
), super.transform(e);
|
|
1361
|
+
return e.participants = a, super.transform(e);
|
|
1351
1362
|
}
|
|
1352
1363
|
visitEvent(e) {
|
|
1353
1364
|
if (e.kind === "message")
|
|
@@ -1366,7 +1377,7 @@ class Jt extends K {
|
|
|
1366
1377
|
}
|
|
1367
1378
|
transformMessage(e) {
|
|
1368
1379
|
let n = e.from, r = e.to;
|
|
1369
|
-
return n && this.mergedParticipantIds.has(n) && (n = this.
|
|
1380
|
+
return n && this.mergedParticipantIds.has(n) && (n = this.targetParticipantId), r && this.mergedParticipantIds.has(r) && (r = this.targetParticipantId), n === this.targetParticipantId && r === this.targetParticipantId ? [] : [
|
|
1370
1381
|
{
|
|
1371
1382
|
...e,
|
|
1372
1383
|
from: n,
|
|
@@ -1378,7 +1389,7 @@ class Jt extends K {
|
|
|
1378
1389
|
const n = /* @__PURE__ */ new Set();
|
|
1379
1390
|
let r = !1;
|
|
1380
1391
|
for (const o of e.participantIds)
|
|
1381
|
-
this.mergedParticipantIds.has(o) ? (n.add(this.
|
|
1392
|
+
this.mergedParticipantIds.has(o) ? (n.add(this.targetParticipantId), r = !0) : n.add(o);
|
|
1382
1393
|
if (!r)
|
|
1383
1394
|
return [e];
|
|
1384
1395
|
const i = Array.from(n);
|
|
@@ -4026,9 +4037,9 @@ const bs = (t, e) => {
|
|
|
4026
4037
|
// enumerable: false,
|
|
4027
4038
|
}
|
|
4028
4039
|
});
|
|
4029
|
-
},
|
|
4040
|
+
}, $ = u("ZodError", bs, {
|
|
4030
4041
|
Parent: Error
|
|
4031
|
-
}), Es = /* @__PURE__ */ _e(
|
|
4042
|
+
}), Es = /* @__PURE__ */ _e($), Is = /* @__PURE__ */ ke($), zs = /* @__PURE__ */ ie($), $s = /* @__PURE__ */ se($), Os = /* @__PURE__ */ gn($), Ps = /* @__PURE__ */ vn($), Ss = /* @__PURE__ */ _n($), Ns = /* @__PURE__ */ kn($), As = /* @__PURE__ */ yn($), Zs = /* @__PURE__ */ Tn($), Cs = /* @__PURE__ */ wn($), Rs = /* @__PURE__ */ bn($), y = /* @__PURE__ */ u("ZodType", (t, e) => (k.init(t, e), Object.assign(t["~standard"], {
|
|
4032
4043
|
jsonSchema: {
|
|
4033
4044
|
input: te(t, "input"),
|
|
4034
4045
|
output: te(t, "output")
|
|
@@ -4058,7 +4069,7 @@ const bs = (t, e) => {
|
|
|
4058
4069
|
}), Ls = /* @__PURE__ */ u("ZodString", (t, e) => {
|
|
4059
4070
|
ye.init(t, e), Et.init(t, e), t.email = (n) => t.check(ri(xs, n)), t.url = (n) => t.check(ci(Ds, n)), t.jwt = (n) => t.check(bi(Hs, n)), t.emoji = (n) => t.check(ui(Fs, n)), t.guid = (n) => t.check(Le(je, n)), t.uuid = (n) => t.check(ii(X, n)), t.uuidv4 = (n) => t.check(si(X, n)), t.uuidv6 = (n) => t.check(oi(X, n)), t.uuidv7 = (n) => t.check(ai(X, n)), t.nanoid = (n) => t.check(hi(js, n)), t.guid = (n) => t.check(Le(je, n)), t.cuid = (n) => t.check(pi(Ms, n)), t.cuid2 = (n) => t.check(li(Us, n)), t.ulid = (n) => t.check(di(Gs, n)), t.base64 = (n) => t.check(yi(qs, n)), t.base64url = (n) => t.check(Ti(Xs, n)), t.xid = (n) => t.check(fi(Vs, n)), t.ksuid = (n) => t.check(mi(Bs, n)), t.ipv4 = (n) => t.check(gi(Js, n)), t.ipv6 = (n) => t.check(vi(Ws, n)), t.cidrv4 = (n) => t.check(_i(Ks, n)), t.cidrv6 = (n) => t.check(ki(Ys, n)), t.e164 = (n) => t.check(wi(Qs, n)), t.datetime = (n) => t.check(gs(n)), t.date = (n) => t.check(_s(n)), t.time = (n) => t.check(ys(n)), t.duration = (n) => t.check(ws(n));
|
|
4060
4071
|
});
|
|
4061
|
-
function
|
|
4072
|
+
function I(t) {
|
|
4062
4073
|
return ni(Ls, t);
|
|
4063
4074
|
}
|
|
4064
4075
|
const _ = /* @__PURE__ */ u("ZodStringFormat", (t, e) => {
|
|
@@ -4344,15 +4355,15 @@ function Oo(t) {
|
|
|
4344
4355
|
return Bi(t);
|
|
4345
4356
|
}
|
|
4346
4357
|
const S = ae([
|
|
4347
|
-
|
|
4358
|
+
I(),
|
|
4348
4359
|
z({
|
|
4349
|
-
pattern:
|
|
4350
|
-
flags:
|
|
4360
|
+
pattern: I(),
|
|
4361
|
+
flags: I().optional()
|
|
4351
4362
|
})
|
|
4352
4363
|
]), Po = z({
|
|
4353
4364
|
kind: A("fragment"),
|
|
4354
4365
|
condition: S.optional(),
|
|
4355
|
-
operator: ae([
|
|
4366
|
+
operator: ae([I(), Z(I())]).optional()
|
|
4356
4367
|
// Note: Operator types might need to be refined if we want strict enum validation,
|
|
4357
4368
|
// but string is flexible for now.
|
|
4358
4369
|
}), Te = z({
|
|
@@ -4383,7 +4394,11 @@ const S = ae([
|
|
|
4383
4394
|
])
|
|
4384
4395
|
}), Ro = z({
|
|
4385
4396
|
action: A("merge"),
|
|
4386
|
-
|
|
4397
|
+
into: z({
|
|
4398
|
+
name: I().optional(),
|
|
4399
|
+
id: I().optional(),
|
|
4400
|
+
stereotype: I().optional()
|
|
4401
|
+
}).optional(),
|
|
4387
4402
|
selector: Te
|
|
4388
4403
|
}), Lo = co("action", [
|
|
4389
4404
|
Ao,
|
|
@@ -4391,14 +4406,14 @@ const S = ae([
|
|
|
4391
4406
|
Co,
|
|
4392
4407
|
Ro
|
|
4393
4408
|
]), xo = z({
|
|
4394
|
-
name:
|
|
4395
|
-
suffix:
|
|
4409
|
+
name: I(),
|
|
4410
|
+
suffix: I().optional(),
|
|
4396
4411
|
// Defaults to .name in logic
|
|
4397
4412
|
layers: Z(Lo)
|
|
4398
4413
|
}), Je = $t(["mermaid", "plantuml"]), Do = z({
|
|
4399
|
-
input: Z(
|
|
4400
|
-
outputDir:
|
|
4401
|
-
ignore: Z(
|
|
4414
|
+
input: Z(I()),
|
|
4415
|
+
outputDir: I(),
|
|
4416
|
+
ignore: Z(I()).optional(),
|
|
4402
4417
|
lenses: Z(xo),
|
|
4403
4418
|
format: Je.optional(),
|
|
4404
4419
|
// Input format (auto-detected if omitted)
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
`&&this.ch!=="";)this.readChar()}lookupIdent(e){return{sequencediagram:"SEQUENCE_DIAGRAM",participant:"PARTICIPANT",actor:"ACTOR",loop:"LOOP",alt:"ALT",opt:"OPT",end:"END",else:"ELSE",note:"NOTE",left:"LEFT",right:"RIGHT",over:"OVER",of:"OF",as:"AS",title:"TITLE",activate:"ACTIVATE",deactivate:"DEACTIVATE",box:"BOX",par:"PAR",and:"AND",break:"BREAK",critical:"CRITICAL",option:"OPTION",rect:"RECT"}[e.toLowerCase()]||"IDENTIFIER"}};class Pe{constructor(e){this.lexer=e,this.advance(),this.advance()}currToken;peekToken;advance(){this.currToken=this.peekToken,this.peekToken=this.lexer.nextToken()}curTokenIs(e){return this.currToken.type===e}peekTokenIs(e){return this.peekToken.type===e}expectPeek(e){return this.peekTokenIs(e)?(this.advance(),!0):!1}isCurrentToken(e){return this.currToken.type===e}isCurrentTokenOneOf(e){return e.includes(this.currToken.type)}getCurrentTokenType(){return this.currToken.type}}let xt=class extends Pe{currentGroup=null;idCounters={evt:0,frag:0,br:0,note:0,group:0};parse(){const e={kind:"root",meta:{version:"1.0.0",source:"unknown"},participants:[],groups:[],events:[]};return e.events=this.parseBlock(e),e}parseBlock(e,n=[]){const r=[];for(;!this.isCurrentToken("EOF");){const i=this.getCurrentTokenType();if(n.includes(i))return r;if(i==="NEWLINE"){this.advance();continue}if(i==="SEQUENCE_DIAGRAM"){e.meta.source="mermaid",this.advance();continue}if(i==="TITLE"){this.advance(),e.meta.title=this.readRestOfLine();continue}if(i==="BOX"){const s=this.parseGroup(e);r.push(...s);continue}if(i==="PARTICIPANT"||i==="ACTOR"){this.parseParticipant(e);continue}if(i==="LOOP"||i==="ALT"||i==="OPT"||i==="PAR"||i==="BREAK"||i==="CRITICAL"||i==="RECT"){r.push(this.parseFragment(e));continue}if(i==="NOTE"){r.push(this.parseNote(e));continue}if(i==="ACTIVATE"||i==="DEACTIVATE"){r.push(this.parseActivation(e));continue}if(this.isParticipantToken(this.currToken)){const s=this.parseMessage(e);if(s){r.push(s);continue}}this.advance()}return r}isParticipantToken(e){return e.type==="IDENTIFIER"||e.type==="STRING"}parseGroup(e){this.advance();const n=this.readRestOfLine().trim();let r=n,i;const s=n.split(/\s+/);if(s.length>0){const h=s[0];(h.startsWith("#")||["rgb","rgba","transparent","aqua","grey","gray","purple","red","blue","green"].includes(h.toLowerCase()))&&(i=h,r=s.slice(1).join(" "))}r||(r=`Group ${this.idCounters.group+1}`);const o={kind:"group",id:this.generateId("group"),name:r,type:"box",participantIds:[],style:i?{backgroundColor:i}:void 0};e.groups.push(o);const a=this.currentGroup;this.currentGroup=o;const c=this.parseBlock(e,["END"]);return this.currentGroup=a,this.isCurrentToken("END")&&this.advance(),c}parseFragment(e){const n=this.getCurrentTokenType();let r="loop";n==="ALT"&&(r="alt"),n==="OPT"&&(r="opt"),n==="PAR"&&(r="par"),n==="BREAK"&&(r="break"),n==="CRITICAL"&&(r="critical"),n==="RECT"&&(r="rect"),this.advance();const i=this.readRestOfLine(),s=[];let o;r==="par"?o=["END","ELSE","AND"]:r==="critical"?o=["END","OPTION"]:o=["END","ELSE"];const a=this.parseBlock(e,o);for(s.push({id:this.generateId("br"),condition:i,events:a});this.isCurrentToken("AND");){this.advance();const c=this.readRestOfLine(),h=this.parseBlock(e,["END","AND"]);s.push({id:this.generateId("br"),condition:c,events:h})}for(;this.isCurrentToken("OPTION");){this.advance();const c=this.readRestOfLine(),h=this.parseBlock(e,["END","OPTION"]);s.push({id:this.generateId("br"),condition:c,events:h})}for(;this.isCurrentToken("ELSE");){this.advance();const c=this.readRestOfLine(),h=this.parseBlock(e,["END","ELSE"]);s.push({id:this.generateId("br"),condition:c,events:h})}return this.isCurrentToken("END")&&this.advance(),{kind:"fragment",id:this.generateId("frag"),operator:r,branches:s}}parseParticipant(e){const n=this.currToken.type==="ACTOR";this.advance();let r="",i="";if(this.isParticipantToken(this.currToken)&&(r=this.currToken.literal,i=r,this.advance()),this.currToken.type==="AS"){this.advance();const o=this.readRestOfLine().trim();o&&(i=o)}const s=e.participants.find(o=>o.id===r);s?(i!==r&&(s.name=i),n&&(s.type="actor")):e.participants.push({id:r,name:i,type:n?"actor":"participant"}),this.currentGroup&&(this.currentGroup.participantIds.includes(r)||this.currentGroup.participantIds.push(r))}parseNote(e){this.advance();let n="over";this.currToken.type==="LEFT"?(n="left",this.advance()):this.currToken.type==="RIGHT"?(n="right",this.advance()):this.currToken.type==="OVER"&&(n="over",this.advance()),this.currToken.type==="OF"&&this.advance();const r=[];for(;this.isParticipantToken(this.currToken)&&(r.push(this.currToken.literal),this.ensureParticipant(e,this.currToken.literal),this.advance(),this.currToken.type==="COMMA");)this.advance();let i="";return this.currToken.type==="COLON"&&(this.advance(),i=this.readRestOfLine()),{kind:"note",id:this.generateId("note"),position:n,participantIds:r,text:i}}parseActivation(e){const n=this.currToken.type==="ACTIVATE"?"activate":"deactivate";this.advance();let r="";return this.isParticipantToken(this.currToken)&&(r=this.currToken.literal,this.ensureParticipant(e,r),this.advance()),{kind:"activation",participantId:r,action:n}}parseMessage(e){if(this.peekToken.type!=="ARROW")return null;const n=this.currToken.literal;if(this.ensureParticipant(e,n),this.advance(),this.currToken.type!=="ARROW")return null;const r=this.currToken.literal;this.advance();let i=!1,s=!1;if(this.isCurrentToken("PLUS")&&(i=!0,this.advance()),this.isCurrentToken("MINUS")&&(s=!0,this.advance()),!this.isParticipantToken(this.currToken))return null;const o=this.currToken.literal;this.ensureParticipant(e,o),this.advance();let a="";this.isCurrentToken("COLON")&&(this.advance(),a=this.readRestOfLine());const{type:c,style:h}=this.resolveArrow(r);return{kind:"message",id:this.generateId("evt"),from:n,to:o,text:a,type:c,style:h,lifecycle:i||s?{activateTarget:i,deactivateSource:s}:void 0}}resolveArrow(e){const n=F[e];return n||{type:"sync",style:{line:"solid",head:"arrow"}}}generateId(e){return this.idCounters[e]++,`${e}_${this.idCounters[e]}`}readRestOfLine(){if(this.isCurrentToken("NEWLINE")||this.isCurrentToken("EOF"))return"";const e=this.currToken.start;let n=this.currToken.end;for(;!this.isCurrentToken("NEWLINE")&&!this.isCurrentToken("EOF");)n=this.currToken.end,this.advance();return this.lexer.getInput().slice(e,n)}ensureParticipant(e,n){e.participants.find(r=>r.id===n)||e.participants.push({id:n,name:n,type:"participant"})}};const Ft={parse:t=>{const e=new Dt(t);return new xt(e).parse()}};class jt extends Oe{nextToken(){this.skipWhitespace();const e=this.position,n=this.column;let r;switch(this.ch){case`
|
|
10
10
|
`:r=this.newToken("NEWLINE",this.ch,e,n);break;case"@":this.peekString("startuml")?(this.readMulti(9),r=this.newToken("START_UML","@startuml",e,n)):this.peekString("enduml")?(this.readMulti(7),r=this.newToken("END_UML","@enduml",e,n)):r=this.newToken("UNKNOWN",this.ch,e,n);break;case",":r=this.newToken("COMMA",",",e,n);break;case'"':{const i=this.readString();return this.newToken("STRING",i,e,n)}case":":r=this.newToken("COLON",":",e,n);break;case"-":{const i=this.readArrow();i?r=this.newToken("ARROW",i,e,n):r=this.newToken("UNKNOWN",this.ch,e,n);break}case"=":{if(this.peekExact("=")){const i=this.readDivider();return this.newToken("DIVIDER",i,e,n)}r=this.newToken("UNKNOWN",this.ch,e,n);break}case"":r=this.newToken("EOF","",e,n);break;default:if(this.isLetter(this.ch)){const i=this.readIdentifier(),s=this.lookupIdent(i);return this.newToken(s,i,e,n)}else r=this.newToken("UNKNOWN",this.ch,e,n)}return this.readChar(),r}newToken(e,n,r,i){const s=this.position===r?r+n.length:this.position;return{type:e,literal:n,line:this.line,column:i,start:r,end:s}}readString(){const e=this.position+1;for(this.readChar();this.ch!=='"'&&this.ch!==""&&this.ch!==`
|
|
11
11
|
`;)this.readChar();const n=this.input.slice(e,this.position);return this.readChar(),n}lookupIdent(e){return{title:"TITLE",participant:"PARTICIPANT",actor:"ACTOR",database:"DATABASE",as:"AS",activate:"ACTIVATE",deactivate:"DEACTIVATE",note:"NOTE",left:"LEFT",right:"RIGHT",over:"OVER",of:"OF",alt:"ALT",opt:"OPT",loop:"LOOP",else:"ELSE",end:"END",box:"BOX",boundary:"BOUNDARY",control:"CONTROL",entity:"ENTITY",collections:"COLLECTIONS",queue:"QUEUE","@startuml":"START_UML","@enduml":"END_UML"}[e]||"IDENTIFIER"}readArrow(){return this.peekString("->")?(this.readMulti(2),"-->"):this.peekExact(">")?(this.readMulti(1),"->"):null}peekExact(e){return this.input[this.position+1]===e}peekString(e){for(let n=0;n<e.length;n++)if(this.input[this.position+1+n]!==e[n])return!1;return!0}readRestOfLine(){const e=this.position;for(;this.input[this.position]!==`
|
|
12
|
-
`&&this.input[this.position]!==""&&this.position<this.input.length;)this.readChar();return this.input.slice(e,this.position).trim()}readMulti(e){for(let n=0;n<e;n++)this.readChar()}readDivider(){const n=this.readRestOfLine().match(/^==\s*(.*?)\s*==$/);return n?n[1]:""}}class Mt extends Pe{isTokenType(e){return this.currToken.type===e}parse(){const e={kind:"root",meta:{version:"1.0.0",source:"plantuml"},participants:[],groups:[],events:[]};for(;this.currToken.type!=="EOF";){if(this.currToken.type==="START_UML"){this.advance();continue}if(this.currToken.type==="END_UML"){this.advance();continue}if(this.currToken.type==="TITLE"){this.advance(),e.meta.title=this.readRestOfLine().trim();continue}if(["PARTICIPANT","ACTOR","DATABASE","BOUNDARY","CONTROL","ENTITY","COLLECTIONS","QUEUE"].includes(this.currToken.type)){this.parseParticipant(e);continue}if(this.currToken.type==="DIVIDER"){const n={kind:"divider",id:`div_${e.events.length+1}`,text:this.currToken.literal||void 0};e.events.push(n),this.advance();continue}if(this.isParticipantToken(this.currToken)){const n=this.parseMessage(e);if(n){e.events.push(n);continue}}if(this.currToken.type==="ACTIVATE"||this.currToken.type==="DEACTIVATE"){const n=this.parseActivation(e);n&&e.events.push(n);continue}if(this.currToken.type==="NOTE"){const n=this.parseNote(e);n&&e.events.push(n);continue}if(["ALT","OPT","LOOP"].includes(this.currToken.type)){const n=this.parseFragment(e);n&&e.events.push(n);continue}if(this.currToken.type==="END")return e;if(this.currToken.type==="BOX"){const n=this.parseGroup(e);n&&e.groups.push(n);continue}this.advance()}return e}parseGroup(e){this.advance();let n="",r;this.currToken.type==="STRING"&&(n=this.currToken.literal,this.advance()),this.currToken.type==="UNKNOWN"&&this.currToken.literal==="#"&&(this.advance(),this.isTokenType("IDENTIFIER")&&(r=`#${this.currToken.literal}`,this.advance()));const i=[];for(;this.currToken.type!=="EOF";){if(this.currToken.type==="END"){this.advance(),this.isTokenType("BOX")&&this.advance();break}if(["PARTICIPANT","ACTOR","DATABASE","BOUNDARY","CONTROL","ENTITY","COLLECTIONS","QUEUE"].includes(this.currToken.type)){const s=e.participants.length;this.parseParticipant(e);const o=e.participants.length;o>s&&i.push(e.participants[o-1].id);continue}if(this.currToken.type==="IDENTIFIER"){this.advance();continue}this.advance()}return{kind:"group",id:`group_${e.groups.length+1}`,name:n,type:"box",participantIds:i,style:r?{backgroundColor:r}:void 0}}parseFragment(e){const n="fragment",r=this.currToken.literal.toLowerCase();this.advance();const i=this.readRestOfLine().trim(),s=[];let o=[];const a={id:`br_${s.length+1}`,condition:i,events:o};for(s.push(a);this.currToken.type!=="EOF";){if(this.currToken.type==="END"){this.advance();break}if(this.currToken.type==="ELSE"){this.advance();const h=this.readRestOfLine().trim();o=[],s.push({id:`br_${s.length+1}`,condition:h,events:o});continue}if(this.currToken.type==="NEWLINE"){this.advance();continue}const c=this.parseStatement(e);c&&o.push(c)}return{kind:n,id:`frag_${e.events.length+1}`,operator:r,branches:s}}parseStatement(e){if(["PARTICIPANT","ACTOR","DATABASE","BOUNDARY","CONTROL","ENTITY","COLLECTIONS","QUEUE"].includes(this.currToken.type))return this.parseParticipant(e),null;if(this.isParticipantToken(this.currToken)){const n=this.parseMessage(e);if(n)return n}return this.currToken.type==="ACTIVATE"||this.currToken.type==="DEACTIVATE"?this.parseActivation(e):this.currToken.type==="NOTE"?this.parseNote(e):["ALT","OPT","LOOP"].includes(this.currToken.type)?this.parseFragment(e):(this.advance(),null)}parseNote(e){this.advance();let n="over";this.currToken.type==="LEFT"?(n="left",this.advance()):this.currToken.type==="RIGHT"?(n="right",this.advance()):this.currToken.type==="OVER"&&(n="over",this.advance()),this.currToken.type==="OF"&&this.advance();const r=[];for(;this.isParticipantToken(this.currToken)&&(r.push(this.currToken.literal),this.ensureParticipant(e,this.currToken.literal),this.advance(),this.currToken.type==="COMMA");)this.advance();let i="";if(this.currToken.type==="COLON")this.advance(),i=this.readRestOfLine().trim();else{this.currToken.type==="NEWLINE"&&this.advance();const s=this.currToken.start;let o=s;for(;this.currToken.type!=="EOF";){if(this.currToken.type==="END"&&this.peekToken.type==="NOTE"){o=this.currToken.start,this.advance(),this.advance();break}this.advance()}i=this.lexer.getInput().slice(s,o).trim()}return{kind:"note",id:`note_${e.events.length+1}`,position:n,participantIds:r,text:i}}parseActivation(e){const n=this.currToken.type==="ACTIVATE"?"activate":"deactivate";this.advance();let r="";if(this.isParticipantToken(this.currToken))r=this.currToken.literal,this.ensureParticipant(e,r),this.advance();else return null;return{kind:"activation",participantId:r,action:n}}isParticipantToken(e){return e.type==="IDENTIFIER"||e.type==="STRING"}parseMessage(e){if(this.peekToken.type!=="ARROW")return null;const n=this.currToken.literal;this.ensureParticipant(e,n),this.advance();const r=this.currToken.literal;if(this.advance(),!this.isParticipantToken(this.currToken))return null;const i=this.currToken.literal;this.ensureParticipant(e,i),this.advance();let s="";this.currToken.type==="COLON"&&(this.advance(),s=this.readRestOfLine().trim());let o="sync",a={line:"solid",head:"arrow"};return r==="-->"?(o="reply",a={line:"dotted",head:"arrow"}):r==="->"&&(o="sync",a={line:"solid",head:"arrow"}),{kind:"message",id:`msg_${e.events.length+1}`,from:n,to:i,text:s,type:o,style:a}}ensureParticipant(e,n){e.participants.find(r=>r.id===n)||e.participants.push({id:n,name:n,type:"participant"})}parseParticipant(e){const n=this.currToken.type;let r="participant";n==="ACTOR"&&(r="actor"),n==="DATABASE"&&(r="database"),n==="BOUNDARY"&&(r="boundary"),n==="CONTROL"&&(r="control"),n==="ENTITY"&&(r="entity"),n==="COLLECTIONS"&&(r="collections"),n==="QUEUE"&&(r="queue"),this.advance();let i="",s="";(this.currToken.type==="STRING"||this.currToken.type==="IDENTIFIER")&&(i=this.currToken.literal,s=i,this.advance()),this.currToken.type==="AS"&&(this.advance(),this.isTokenType("IDENTIFIER")&&(s=this.currToken.literal,this.advance())),e.participants.push({id:s,name:i,type:r})}readRestOfLine(){if(this.currToken.type==="NEWLINE"||this.currToken.type==="EOF")return"";const e=this.currToken.start;let n=this.currToken.end;for(;!this.isTokenType("NEWLINE")&&!this.isTokenType("EOF");)n=this.currToken.end,this.advance();return this.lexer.getInput().slice(e,n).trim()}}const Ut={parse:t=>{const e=new jt(t);return new Mt(e).parse()}},Gt={".puml":"plantuml",".plantuml":"plantuml",".pu":"plantuml",".mmd":"mermaid",".mermaid":"mermaid"},Vt=[{pattern:/^\s*@startuml/m,format:"plantuml"},{pattern:/^\s*sequenceDiagram/m,format:"mermaid"}],fe={detect(t,e){const n=fe.detectByExtension(t);return n||fe.detectByContent(e)},detectByExtension(t){const e=t.toLowerCase().match(/\.[^.]+$/)?.[0];return e&&Gt[e]||null},detectByContent(t){for(const{pattern:e,format:n}of Vt)if(e.test(t))return n;return null},getDefaultExtension(t){switch(t){case"plantuml":return".puml";case"mermaid":return".mmd"}}},X=new Map;X.set("mermaid",Ft),X.set("plantuml",Ut);const Se={register(t,e){X.set(t,e)},getParser(t){const e=X.get(t);if(!e)throw new Error(`Parser for language '${t}' not found.`);return e}};class B{transform(e){const n=this.mapEvents(e.events);return{...e,events:n}}mapEvents(e){return e.flatMap(n=>this.visitEvent(n))}visitEvent(e){return e.kind==="fragment"?this.visitFragment(e):[e]}visitFragment(e){const n=e.branches.map(r=>this.visitBranch(r));return[{...e,branches:n}]}visitBranch(e){return{...e,events:this.mapEvents(e.events)}}}class Bt extends B{visitFragment(e){const n=super.visitFragment(e);if(n.length===0)return[];const r=n[0],i=r.branches.filter(s=>s.events.length>0);return i.length===0?[]:[{...r,branches:i}]}}class Jt{transform(e){const n=this.collectUsedParticipants(e.events),r=e.participants.filter(s=>n.has(s.id)),i=e.groups.map(s=>({...s,participantIds:s.participantIds.filter(o=>n.has(o))})).filter(s=>s.participantIds.length>0);return{...e,participants:r,groups:i}}collectUsedParticipants(e){const n=new Set;function r(i){for(const s of i)switch(s.kind){case"message":s.from&&n.add(s.from),s.to&&n.add(s.to);break;case"fragment":for(const o of s.branches)r(o.events);break;case"activation":n.add(s.participantId);break;case"note":s.participantIds.forEach(o=>{n.add(o)});break;case"ref":s.participantIds.forEach(o=>{n.add(o)});break}}return r(e),n}}class Q{matchBranch(e,n,r){return!(n.operator&&!(Array.isArray(n.operator)?n.operator:[n.operator]).includes(r)||n.condition&&(!e.condition||!this.matchText(e.condition,n.condition)))}matchParticipant(e,n){return!(n.id&&!this.matchText(e.id,n.id)||n.name&&!this.matchText(e.name,n.name)||n.stereotype&&e.stereotype&&!this.matchText(e.stereotype,n.stereotype))}matchMessage(e,n){return!(n.text&&!this.matchText(e.text,n.text)||n.from&&e.from&&!this.matchText(e.from,n.from)||n.to&&e.to&&!this.matchText(e.to,n.to))}matchGroup(e,n){return!(n.name&&e.name&&!this.matchText(e.name,n.name))}matchText(e,n){if(typeof n=="string")return e===n;if(n instanceof RegExp)return n.test(e);if(typeof n=="object"&&n.pattern){const r=n.flags||"";return new RegExp(n.pattern,r).test(e)}return!1}}class Wt extends B{constructor(e){super(),this.layer=e}matcher=new Q;targetParticipantIds=new Set;transform(e){return this.resolveTargetParticipants(e),super.transform(e)}resolveTargetParticipants(e){this.targetParticipantIds.clear();const n=this.layer.selector;e.participants.forEach(r=>{this.matcher.matchParticipant(r,n)&&this.targetParticipantIds.add(r.id)})}visitEvent(e){if(e.kind==="message"){const n=e;if(!this.isRelatedToParticipant(n))return[]}if(e.kind==="note"&&!e.participantIds.some(i=>this.targetParticipantIds.has(i)))return[];if(e.kind==="activation"){const n=e;if(!this.targetParticipantIds.has(n.participantId))return[]}return super.visitEvent(e)}isRelatedToParticipant(e){return!!(e.from&&this.targetParticipantIds.has(e.from)||e.to&&this.targetParticipantIds.has(e.to))}}class Kt extends B{constructor(e){super(),this.layer=e,this.newParticipantId=e.newName}matcher=new Q;mergedParticipantIds=new Set;newParticipantId;transform(e){const n=this.layer.selector;if(e.participants.forEach(i=>{this.matcher.matchParticipant(i,n)&&this.mergedParticipantIds.add(i.id)}),this.mergedParticipantIds.size===0)return e;if(!e.participants.some(i=>i.id===this.newParticipantId)){const i={id:this.newParticipantId,name:this.layer.newName,type:"participant"};e.participants.push(i)}return e.participants=e.participants.filter(i=>!this.mergedParticipantIds.has(i.id)),super.transform(e)}visitEvent(e){if(e.kind==="message")return this.transformMessage(e);if(e.kind==="note")return this.transformNote(e);if(e.kind==="activation")return this.transformActivation(e);if(e.kind==="fragment"){const n=super.visitEvent(e);return n.length>0&&n[0].kind==="fragment"&&n[0].branches.every(s=>s.events.length===0)?[]:n}return super.visitEvent(e)}transformMessage(e){let n=e.from,r=e.to;return n&&this.mergedParticipantIds.has(n)&&(n=this.newParticipantId),r&&this.mergedParticipantIds.has(r)&&(r=this.newParticipantId),n===this.newParticipantId&&r===this.newParticipantId?[]:[{...e,from:n,to:r}]}transformNote(e){const n=new Set;let r=!1;for(const o of e.participantIds)this.mergedParticipantIds.has(o)?(n.add(this.newParticipantId),r=!0):n.add(o);if(!r)return[e];const i=Array.from(n);return e.participantIds.every(o=>this.mergedParticipantIds.has(o))?[]:[{...e,participantIds:i}]}transformActivation(e){return this.mergedParticipantIds.has(e.participantId)?[]:[e]}}class Yt extends B{constructor(e){super(),this.layer=e}matcher=new Q;removedParticipantIds=new Set;transform(e){const n=this.layer.selector;return n.kind==="participant"&&(e.participants.forEach(r=>{this.matcher.matchParticipant(r,n)&&this.removedParticipantIds.add(r.id)}),e.participants=e.participants.filter(r=>!this.removedParticipantIds.has(r.id))),n.kind==="group"&&(e.groups=e.groups.filter(r=>!this.matcher.matchGroup(r,n))),super.transform(e)}visitEvent(e){const n=this.layer.selector;if(n.kind==="message"&&e.kind==="message"&&this.matcher.matchMessage(e,n))return[];if(n.kind==="participant"){if(e.kind==="message"){const r=e;if(this.isRelatedToRemovedParticipant(r))return[]}if(e.kind==="note"&&e.participantIds.some(s=>this.removedParticipantIds.has(s)))return[];if(e.kind==="activation"){const r=e;if(this.removedParticipantIds.has(r.participantId))return[]}}return super.visitEvent(e)}isRelatedToRemovedParticipant(e){return!!(e.from&&this.removedParticipantIds.has(e.from)||e.to&&this.removedParticipantIds.has(e.to))}}class qt extends B{constructor(e){super(),this.layer=e}matcher=new Q;visitFragment(e){const n=e.branches.find(r=>this.matcher.matchBranch(r,this.layer.selector,e.operator));return n?this.mapEvents(n.events):super.visitFragment(e)}}class Xt{factories=new Map;constructor(){this.registerTyped("resolve",e=>new qt(e)),this.registerTyped("focus",e=>new Wt(e)),this.registerTyped("remove",e=>new Yt(e)),this.registerTyped("merge",e=>new Kt(e))}registerTyped(e,n){this.factories.set(e,n)}register(e,n){this.factories.set(e,n)}get(e){const n=this.factories.get(e.action);return n?n(e):null}has(e){return this.factories.has(e)}}const Ne=new Xt;class H{transform(e,n){let r=e;for(const i of n){const s=Ne.get(i);s?r=s.transform(r):console.warn(`Unknown action: ${i.action}`)}return r=new Bt().transform(r),r=new Jt().transform(r),r}}class Qt{constructor(){}static init(e,n="mermaid"){const i=Se.getParser(n).parse(e);return new Ae(i,n)}}class Ae{ast;layers=[];sourceFormat;constructor(e,n="mermaid"){this.ast=e,this.sourceFormat=n}focusParticipant(e){return this.layers.push({action:"focus",selector:this.normalizeParticipantSelector(e)}),this}removeParticipant(e){return this.layers.push({action:"remove",selector:this.normalizeParticipantSelector(e)}),this}removeMessage(e){return this.layers.push({action:"remove",selector:this.normalizeMessageSelector(e)}),this}removeGroup(e){return this.layers.push({action:"remove",selector:this.normalizeGroupSelector(e)}),this}resolveFragment(e){return this.layers.push({action:"resolve",selector:this.normalizeFragmentSelector(e)}),this}applyLens(e){return this.layers.push(...e.layers),this}toMermaid(){const n=new H().transform(this.ast,this.layers);return new le().generate(n)}toPlantUML(){const n=new H().transform(this.ast,this.layers);return new de().generate(n)}toAST(){return new H().transform(this.ast,this.layers)}getSourceFormat(){return this.sourceFormat}normalizeParticipantSelector(e){return this.isTextMatcher(e)?{kind:"participant",name:e}:{kind:"participant",...e}}normalizeMessageSelector(e){return this.isTextMatcher(e)?{kind:"message",text:e}:{kind:"message",...e}}normalizeGroupSelector(e){return this.isTextMatcher(e)?{kind:"group",name:e}:{kind:"group",...e}}normalizeFragmentSelector(e){return this.isTextMatcher(e)?{kind:"fragment",condition:e}:{kind:"fragment",...e}}isTextMatcher(e){return typeof e=="string"||e instanceof RegExp||typeof e=="object"&&e!==null&&"pattern"in e&&!("kind"in e)}}const j=new Map;j.set("mermaid",()=>new le),j.set("plantuml",()=>new de);const Ht={register(t,e){j.set(t,e)},getGenerator(t){const e=j.get(t);if(!e)throw new Error(`Generator for language '${t}' not found.`);return e()},hasGenerator(t){return j.has(t)},getLanguages(){return Array.from(j.keys())}};function u(t,e,n){function r(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(t))return;a._zod.traits.add(t),e(a,c);const h=o.prototype,p=Object.keys(h);for(let d=0;d<p.length;d++){const f=p[d];f in a||(a[f]=h[f].bind(a))}}const i=n?.Parent??Object;class s extends i{}Object.defineProperty(s,"name",{value:t});function o(a){var c;const h=n?.Parent?new s:this;r(h,a),(c=h._zod).deferred??(c.deferred=[]);for(const p of h._zod.deferred)p();return h}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(t)}),Object.defineProperty(o,"name",{value:t}),o}class M extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Ze extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const Ce={};function C(t){return Ce}function Re(t){const e=Object.values(t).filter(r=>typeof r=="number");return Object.entries(t).filter(([r,i])=>e.indexOf(+r)===-1).map(([r,i])=>i)}function me(t,e){return typeof e=="bigint"?e.toString():e}function ee(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function ge(t){return t==null}function ve(t){const e=t.startsWith("^")?1:0,n=t.endsWith("$")?t.length-1:t.length;return t.slice(e,n)}function en(t,e){const n=(t.toString().split(".")[1]||"").length,r=e.toString();let i=(r.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(r)){const c=r.match(/\d?e-(\d?)/);c?.[1]&&(i=Number.parseInt(c[1]))}const s=n>i?n:i,o=Number.parseInt(t.toFixed(s).replace(".","")),a=Number.parseInt(e.toFixed(s).replace(".",""));return o%a/10**s}const Le=Symbol("evaluating");function m(t,e,n){let r;Object.defineProperty(t,e,{get(){if(r!==Le)return r===void 0&&(r=Le,r=n()),r},set(i){Object.defineProperty(t,e,{value:i})},configurable:!0})}function R(t,e,n){Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0})}function L(...t){const e={};for(const n of t){const r=Object.getOwnPropertyDescriptors(n);Object.assign(e,r)}return Object.defineProperties({},e)}function De(t){return JSON.stringify(t)}function tn(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const xe="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function J(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const nn=ee(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function W(t){if(J(t)===!1)return!1;const e=t.constructor;if(e===void 0||typeof e!="function")return!0;const n=e.prototype;return!(J(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Fe(t){return W(t)?{...t}:Array.isArray(t)?[...t]:t}const rn=new Set(["string","number","symbol"]);function U(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function N(t,e,n){const r=new t._zod.constr(e??t._zod.def);return(!e||n?.parent)&&(r._zod.parent=t),r}function l(t){const e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function sn(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}const on={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function an(t,e){const n=t._zod.def,r=L(t._zod.def,{get shape(){const i={};for(const s in e){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);e[s]&&(i[s]=n.shape[s])}return R(this,"shape",i),i},checks:[]});return N(t,r)}function cn(t,e){const n=t._zod.def,r=L(t._zod.def,{get shape(){const i={...t._zod.def.shape};for(const s in e){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);e[s]&&delete i[s]}return R(this,"shape",i),i},checks:[]});return N(t,r)}function un(t,e){if(!W(e))throw new Error("Invalid input to extend: expected a plain object");const n=t._zod.def.checks;if(n&&n.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const i=L(t._zod.def,{get shape(){const s={...t._zod.def.shape,...e};return R(this,"shape",s),s},checks:[]});return N(t,i)}function hn(t,e){if(!W(e))throw new Error("Invalid input to safeExtend: expected a plain object");const n={...t._zod.def,get shape(){const r={...t._zod.def.shape,...e};return R(this,"shape",r),r},checks:t._zod.def.checks};return N(t,n)}function pn(t,e){const n=L(t._zod.def,{get shape(){const r={...t._zod.def.shape,...e._zod.def.shape};return R(this,"shape",r),r},get catchall(){return e._zod.def.catchall},checks:[]});return N(t,n)}function ln(t,e,n){const r=L(e._zod.def,{get shape(){const i=e._zod.def.shape,s={...i};if(n)for(const o in n){if(!(o in i))throw new Error(`Unrecognized key: "${o}"`);n[o]&&(s[o]=t?new t({type:"optional",innerType:i[o]}):i[o])}else for(const o in i)s[o]=t?new t({type:"optional",innerType:i[o]}):i[o];return R(this,"shape",s),s},checks:[]});return N(e,r)}function dn(t,e,n){const r=L(e._zod.def,{get shape(){const i=e._zod.def.shape,s={...i};if(n)for(const o in n){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);n[o]&&(s[o]=new t({type:"nonoptional",innerType:i[o]}))}else for(const o in i)s[o]=new t({type:"nonoptional",innerType:i[o]});return R(this,"shape",s),s},checks:[]});return N(e,r)}function G(t,e=0){if(t.aborted===!0)return!0;for(let n=e;n<t.issues.length;n++)if(t.issues[n]?.continue!==!0)return!0;return!1}function je(t,e){return e.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(t),n})}function te(t){return typeof t=="string"?t:t?.message}function D(t,e,n){const r={...t,path:t.path??[]};if(!t.message){const i=te(t.inst?._zod.def?.error?.(t))??te(e?.error?.(t))??te(n.customError?.(t))??te(n.localeError?.(t))??"Invalid input";r.message=i}return delete r.inst,delete r.continue,e?.reportInput||delete r.input,r}function _e(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function K(...t){const[e,n,r]=t;return typeof e=="string"?{message:e,code:"custom",input:n,inst:r}:{...e}}const Me=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),t.message=JSON.stringify(e,me,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},Ue=u("$ZodError",Me),Ge=u("$ZodError",Me,{Parent:Error});function fn(t,e=n=>n.message){const n={},r=[];for(const i of t.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(e(i))):r.push(e(i));return{formErrors:r,fieldErrors:n}}function mn(t,e=n=>n.message){const n={_errors:[]},r=i=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(o=>r({issues:o}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)n._errors.push(e(s));else{let o=n,a=0;for(;a<s.path.length;){const c=s.path[a];a===s.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(e(s))):o[c]=o[c]||{_errors:[]},o=o[c],a++}}};return r(t),n}const ke=t=>(e,n,r,i)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},o=e._zod.run({value:n,issues:[]},s);if(o instanceof Promise)throw new M;if(o.issues.length){const a=new(i?.Err??t)(o.issues.map(c=>D(c,s,C())));throw xe(a,i?.callee),a}return o.value},ye=t=>async(e,n,r,i)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let o=e._zod.run({value:n,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new(i?.Err??t)(o.issues.map(c=>D(c,s,C())));throw xe(a,i?.callee),a}return o.value},ne=t=>(e,n,r)=>{const i=r?{...r,async:!1}:{async:!1},s=e._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new M;return s.issues.length?{success:!1,error:new(t??Ue)(s.issues.map(o=>D(o,i,C())))}:{success:!0,data:s.value}},gn=ne(Ge),re=t=>async(e,n,r)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let s=e._zod.run({value:n,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new t(s.issues.map(o=>D(o,i,C())))}:{success:!0,data:s.value}},vn=re(Ge),_n=t=>(e,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ke(t)(e,n,i)},kn=t=>(e,n,r)=>ke(t)(e,n,r),yn=t=>async(e,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ye(t)(e,n,i)},Tn=t=>async(e,n,r)=>ye(t)(e,n,r),wn=t=>(e,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ne(t)(e,n,i)},bn=t=>(e,n,r)=>ne(t)(e,n,r),En=t=>async(e,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return re(t)(e,n,i)},In=t=>async(e,n,r)=>re(t)(e,n,r),zn=/^[cC][^\s-]{8,}$/,$n=/^[0-9a-z]+$/,On=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Pn=/^[0-9a-vA-V]{20}$/,Sn=/^[A-Za-z0-9]{27}$/,Nn=/^[a-zA-Z0-9_-]{21}$/,An=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Zn=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Ve=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Cn=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Rn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Ln(){return new RegExp(Rn,"u")}const Dn=/^(?:(?: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])$/,xn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Fn=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,jn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Mn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Be=/^[A-Za-z0-9_-]*$/,Un=/^\+(?:[0-9]){6,14}[0-9]$/,Je="(?:(?:\\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])))",Gn=new RegExp(`^${Je}$`);function We(t){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Vn(t){return new RegExp(`^${We(t)}$`)}function Bn(t){const e=We({precision:t.precision}),n=["Z"];t.local&&n.push(""),t.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${e}(?:${n.join("|")})`;return new RegExp(`^${Je}T(?:${r})$`)}const Jn=t=>{const e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},Wn=/^-?\d+$/,Kn=/^-?\d+(?:\.\d+)?/,Yn=/^[^A-Z]*$/,qn=/^[^a-z]*$/,E=u("$ZodCheck",(t,e)=>{var n;t._zod??(t._zod={}),t._zod.def=e,(n=t._zod).onattach??(n.onattach=[])}),Ke={number:"number",bigint:"bigint",object:"date"},Ye=u("$ZodCheckLessThan",(t,e)=>{E.init(t,e);const n=Ke[typeof e.value];t._zod.onattach.push(r=>{const i=r._zod.bag,s=(e.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<s&&(e.inclusive?i.maximum=e.value:i.exclusiveMaximum=e.value)}),t._zod.check=r=>{(e.inclusive?r.value<=e.value:r.value<e.value)||r.issues.push({origin:n,code:"too_big",maximum:e.value,input:r.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),qe=u("$ZodCheckGreaterThan",(t,e)=>{E.init(t,e);const n=Ke[typeof e.value];t._zod.onattach.push(r=>{const i=r._zod.bag,s=(e.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>s&&(e.inclusive?i.minimum=e.value:i.exclusiveMinimum=e.value)}),t._zod.check=r=>{(e.inclusive?r.value>=e.value:r.value>e.value)||r.issues.push({origin:n,code:"too_small",minimum:e.value,input:r.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),Xn=u("$ZodCheckMultipleOf",(t,e)=>{E.init(t,e),t._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=e.value)}),t._zod.check=n=>{if(typeof n.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%e.value===BigInt(0):en(n.value,e.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:e.value,input:n.value,inst:t,continue:!e.abort})}}),Qn=u("$ZodCheckNumberFormat",(t,e)=>{E.init(t,e),e.format=e.format||"float64";const n=e.format?.includes("int"),r=n?"int":"number",[i,s]=on[e.format];t._zod.onattach.push(o=>{const a=o._zod.bag;a.format=e.format,a.minimum=i,a.maximum=s,n&&(a.pattern=Wn)}),t._zod.check=o=>{const a=o.value;if(n){if(!Number.isInteger(a)){o.issues.push({expected:r,format:e.format,code:"invalid_type",continue:!1,input:a,inst:t});return}if(!Number.isSafeInteger(a)){a>0?o.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:r,continue:!e.abort}):o.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:r,continue:!e.abort});return}}a<i&&o.issues.push({origin:"number",input:a,code:"too_small",minimum:i,inclusive:!0,inst:t,continue:!e.abort}),a>s&&o.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inst:t})}}),Hn=u("$ZodCheckMaxLength",(t,e)=>{var n;E.init(t,e),(n=t._zod.def).when??(n.when=r=>{const i=r.value;return!ge(i)&&i.length!==void 0}),t._zod.onattach.push(r=>{const i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<i&&(r._zod.bag.maximum=e.maximum)}),t._zod.check=r=>{const i=r.value;if(i.length<=e.maximum)return;const o=_e(i);r.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:i,inst:t,continue:!e.abort})}}),er=u("$ZodCheckMinLength",(t,e)=>{var n;E.init(t,e),(n=t._zod.def).when??(n.when=r=>{const i=r.value;return!ge(i)&&i.length!==void 0}),t._zod.onattach.push(r=>{const i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>i&&(r._zod.bag.minimum=e.minimum)}),t._zod.check=r=>{const i=r.value;if(i.length>=e.minimum)return;const o=_e(i);r.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:i,inst:t,continue:!e.abort})}}),tr=u("$ZodCheckLengthEquals",(t,e)=>{var n;E.init(t,e),(n=t._zod.def).when??(n.when=r=>{const i=r.value;return!ge(i)&&i.length!==void 0}),t._zod.onattach.push(r=>{const i=r._zod.bag;i.minimum=e.length,i.maximum=e.length,i.length=e.length}),t._zod.check=r=>{const i=r.value,s=i.length;if(s===e.length)return;const o=_e(i),a=s>e.length;r.issues.push({origin:o,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:r.value,inst:t,continue:!e.abort})}}),ie=u("$ZodCheckStringFormat",(t,e)=>{var n,r;E.init(t,e),t._zod.onattach.push(i=>{const s=i._zod.bag;s.format=e.format,e.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(e.pattern))}),e.pattern?(n=t._zod).check??(n.check=i=>{e.pattern.lastIndex=0,!e.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:e.format,input:i.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(r=t._zod).check??(r.check=()=>{})}),nr=u("$ZodCheckRegex",(t,e)=>{ie.init(t,e),t._zod.check=n=>{e.pattern.lastIndex=0,!e.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),rr=u("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=Yn),ie.init(t,e)}),ir=u("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=qn),ie.init(t,e)}),sr=u("$ZodCheckIncludes",(t,e)=>{E.init(t,e);const n=U(e.includes),r=new RegExp(typeof e.position=="number"?`^.{${e.position}}${n}`:n);e.pattern=r,t._zod.onattach.push(i=>{const s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),t._zod.check=i=>{i.value.includes(e.includes,e.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:i.value,inst:t,continue:!e.abort})}}),or=u("$ZodCheckStartsWith",(t,e)=>{E.init(t,e);const n=new RegExp(`^${U(e.prefix)}.*`);e.pattern??(e.pattern=n),t._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),t._zod.check=r=>{r.value.startsWith(e.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:r.value,inst:t,continue:!e.abort})}}),ar=u("$ZodCheckEndsWith",(t,e)=>{E.init(t,e);const n=new RegExp(`.*${U(e.suffix)}$`);e.pattern??(e.pattern=n),t._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),t._zod.check=r=>{r.value.endsWith(e.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:r.value,inst:t,continue:!e.abort})}}),cr=u("$ZodCheckOverwrite",(t,e)=>{E.init(t,e),t._zod.check=n=>{n.value=e.tx(n.value)}});class ur{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const r=e.split(`
|
|
12
|
+
`&&this.input[this.position]!==""&&this.position<this.input.length;)this.readChar();return this.input.slice(e,this.position).trim()}readMulti(e){for(let n=0;n<e;n++)this.readChar()}readDivider(){const n=this.readRestOfLine().match(/^==\s*(.*?)\s*==$/);return n?n[1]:""}}class Mt extends Pe{isTokenType(e){return this.currToken.type===e}parse(){const e={kind:"root",meta:{version:"1.0.0",source:"plantuml"},participants:[],groups:[],events:[]};for(;this.currToken.type!=="EOF";){if(this.currToken.type==="START_UML"){this.advance();continue}if(this.currToken.type==="END_UML"){this.advance();continue}if(this.currToken.type==="TITLE"){this.advance(),e.meta.title=this.readRestOfLine().trim();continue}if(["PARTICIPANT","ACTOR","DATABASE","BOUNDARY","CONTROL","ENTITY","COLLECTIONS","QUEUE"].includes(this.currToken.type)){this.parseParticipant(e);continue}if(this.currToken.type==="DIVIDER"){const n={kind:"divider",id:`div_${e.events.length+1}`,text:this.currToken.literal||void 0};e.events.push(n),this.advance();continue}if(this.isParticipantToken(this.currToken)){const n=this.parseMessage(e);if(n){e.events.push(n);continue}}if(this.currToken.type==="ACTIVATE"||this.currToken.type==="DEACTIVATE"){const n=this.parseActivation(e);n&&e.events.push(n);continue}if(this.currToken.type==="NOTE"){const n=this.parseNote(e);n&&e.events.push(n);continue}if(["ALT","OPT","LOOP"].includes(this.currToken.type)){const n=this.parseFragment(e);n&&e.events.push(n);continue}if(this.currToken.type==="END")return e;if(this.currToken.type==="BOX"){const n=this.parseGroup(e);n&&e.groups.push(n);continue}this.advance()}return e}parseGroup(e){this.advance();let n="",r;this.currToken.type==="STRING"&&(n=this.currToken.literal,this.advance()),this.currToken.type==="UNKNOWN"&&this.currToken.literal==="#"&&(this.advance(),this.isTokenType("IDENTIFIER")&&(r=`#${this.currToken.literal}`,this.advance()));const i=[];for(;this.currToken.type!=="EOF";){if(this.currToken.type==="END"){this.advance(),this.isTokenType("BOX")&&this.advance();break}if(["PARTICIPANT","ACTOR","DATABASE","BOUNDARY","CONTROL","ENTITY","COLLECTIONS","QUEUE"].includes(this.currToken.type)){const s=e.participants.length;this.parseParticipant(e);const o=e.participants.length;o>s&&i.push(e.participants[o-1].id);continue}if(this.currToken.type==="IDENTIFIER"){this.advance();continue}this.advance()}return{kind:"group",id:`group_${e.groups.length+1}`,name:n,type:"box",participantIds:i,style:r?{backgroundColor:r}:void 0}}parseFragment(e){const n="fragment",r=this.currToken.literal.toLowerCase();this.advance();const i=this.readRestOfLine().trim(),s=[];let o=[];const a={id:`br_${s.length+1}`,condition:i,events:o};for(s.push(a);this.currToken.type!=="EOF";){if(this.currToken.type==="END"){this.advance();break}if(this.currToken.type==="ELSE"){this.advance();const h=this.readRestOfLine().trim();o=[],s.push({id:`br_${s.length+1}`,condition:h,events:o});continue}if(this.currToken.type==="NEWLINE"){this.advance();continue}const c=this.parseStatement(e);c&&o.push(c)}return{kind:n,id:`frag_${e.events.length+1}`,operator:r,branches:s}}parseStatement(e){if(["PARTICIPANT","ACTOR","DATABASE","BOUNDARY","CONTROL","ENTITY","COLLECTIONS","QUEUE"].includes(this.currToken.type))return this.parseParticipant(e),null;if(this.isParticipantToken(this.currToken)){const n=this.parseMessage(e);if(n)return n}return this.currToken.type==="ACTIVATE"||this.currToken.type==="DEACTIVATE"?this.parseActivation(e):this.currToken.type==="NOTE"?this.parseNote(e):["ALT","OPT","LOOP"].includes(this.currToken.type)?this.parseFragment(e):(this.advance(),null)}parseNote(e){this.advance();let n="over";this.currToken.type==="LEFT"?(n="left",this.advance()):this.currToken.type==="RIGHT"?(n="right",this.advance()):this.currToken.type==="OVER"&&(n="over",this.advance()),this.currToken.type==="OF"&&this.advance();const r=[];for(;this.isParticipantToken(this.currToken)&&(r.push(this.currToken.literal),this.ensureParticipant(e,this.currToken.literal),this.advance(),this.currToken.type==="COMMA");)this.advance();let i="";if(this.currToken.type==="COLON")this.advance(),i=this.readRestOfLine().trim();else{this.currToken.type==="NEWLINE"&&this.advance();const s=this.currToken.start;let o=s;for(;this.currToken.type!=="EOF";){if(this.currToken.type==="END"&&this.peekToken.type==="NOTE"){o=this.currToken.start,this.advance(),this.advance();break}this.advance()}i=this.lexer.getInput().slice(s,o).trim()}return{kind:"note",id:`note_${e.events.length+1}`,position:n,participantIds:r,text:i}}parseActivation(e){const n=this.currToken.type==="ACTIVATE"?"activate":"deactivate";this.advance();let r="";if(this.isParticipantToken(this.currToken))r=this.currToken.literal,this.ensureParticipant(e,r),this.advance();else return null;return{kind:"activation",participantId:r,action:n}}isParticipantToken(e){return e.type==="IDENTIFIER"||e.type==="STRING"}parseMessage(e){if(this.peekToken.type!=="ARROW")return null;const n=this.currToken.literal;this.ensureParticipant(e,n),this.advance();const r=this.currToken.literal;if(this.advance(),!this.isParticipantToken(this.currToken))return null;const i=this.currToken.literal;this.ensureParticipant(e,i),this.advance();let s="";this.currToken.type==="COLON"&&(this.advance(),s=this.readRestOfLine().trim());let o="sync",a={line:"solid",head:"arrow"};return r==="-->"?(o="reply",a={line:"dotted",head:"arrow"}):r==="->"&&(o="sync",a={line:"solid",head:"arrow"}),{kind:"message",id:`msg_${e.events.length+1}`,from:n,to:i,text:s,type:o,style:a}}ensureParticipant(e,n){e.participants.find(r=>r.id===n)||e.participants.push({id:n,name:n,type:"participant"})}parseParticipant(e){const n=this.currToken.type;let r="participant";n==="ACTOR"&&(r="actor"),n==="DATABASE"&&(r="database"),n==="BOUNDARY"&&(r="boundary"),n==="CONTROL"&&(r="control"),n==="ENTITY"&&(r="entity"),n==="COLLECTIONS"&&(r="collections"),n==="QUEUE"&&(r="queue"),this.advance();let i="",s="";(this.currToken.type==="STRING"||this.currToken.type==="IDENTIFIER")&&(i=this.currToken.literal,s=i,this.advance()),this.currToken.type==="AS"&&(this.advance(),this.isTokenType("IDENTIFIER")&&(s=this.currToken.literal,this.advance())),e.participants.push({id:s,name:i,type:r})}readRestOfLine(){if(this.currToken.type==="NEWLINE"||this.currToken.type==="EOF")return"";const e=this.currToken.start;let n=this.currToken.end;for(;!this.isTokenType("NEWLINE")&&!this.isTokenType("EOF");)n=this.currToken.end,this.advance();return this.lexer.getInput().slice(e,n).trim()}}const Ut={parse:t=>{const e=new jt(t);return new Mt(e).parse()}},Gt={".puml":"plantuml",".plantuml":"plantuml",".pu":"plantuml",".mmd":"mermaid",".mermaid":"mermaid"},Vt=[{pattern:/^\s*@startuml/m,format:"plantuml"},{pattern:/^\s*sequenceDiagram/m,format:"mermaid"}],fe={detect(t,e){const n=fe.detectByExtension(t);return n||fe.detectByContent(e)},detectByExtension(t){const e=t.toLowerCase().match(/\.[^.]+$/)?.[0];return e&&Gt[e]||null},detectByContent(t){for(const{pattern:e,format:n}of Vt)if(e.test(t))return n;return null},getDefaultExtension(t){switch(t){case"plantuml":return".puml";case"mermaid":return".mmd"}}},X=new Map;X.set("mermaid",Ft),X.set("plantuml",Ut);const Se={register(t,e){X.set(t,e)},getParser(t){const e=X.get(t);if(!e)throw new Error(`Parser for language '${t}' not found.`);return e}};class B{transform(e){const n=this.mapEvents(e.events);return{...e,events:n}}mapEvents(e){return e.flatMap(n=>this.visitEvent(n))}visitEvent(e){return e.kind==="fragment"?this.visitFragment(e):[e]}visitFragment(e){const n=e.branches.map(r=>this.visitBranch(r));return[{...e,branches:n}]}visitBranch(e){return{...e,events:this.mapEvents(e.events)}}}class Bt extends B{visitFragment(e){const n=super.visitFragment(e);if(n.length===0)return[];const r=n[0],i=r.branches.filter(s=>s.events.length>0);return i.length===0?[]:[{...r,branches:i}]}}class Jt{transform(e){const n=this.collectUsedParticipants(e.events),r=e.participants.filter(s=>n.has(s.id)),i=e.groups.map(s=>({...s,participantIds:s.participantIds.filter(o=>n.has(o))})).filter(s=>s.participantIds.length>0);return{...e,participants:r,groups:i}}collectUsedParticipants(e){const n=new Set;function r(i){for(const s of i)switch(s.kind){case"message":s.from&&n.add(s.from),s.to&&n.add(s.to);break;case"fragment":for(const o of s.branches)r(o.events);break;case"activation":n.add(s.participantId);break;case"note":s.participantIds.forEach(o=>{n.add(o)});break;case"ref":s.participantIds.forEach(o=>{n.add(o)});break}}return r(e),n}}class Q{matchBranch(e,n,r){return!(n.operator&&!(Array.isArray(n.operator)?n.operator:[n.operator]).includes(r)||n.condition&&(!e.condition||!this.matchText(e.condition,n.condition)))}matchParticipant(e,n){return!(n.id&&!this.matchText(e.id,n.id)||n.name&&!this.matchText(e.name,n.name)||n.stereotype&&e.stereotype&&!this.matchText(e.stereotype,n.stereotype))}matchMessage(e,n){return!(n.text&&!this.matchText(e.text,n.text)||n.from&&e.from&&!this.matchText(e.from,n.from)||n.to&&e.to&&!this.matchText(e.to,n.to))}matchGroup(e,n){return!(n.name&&e.name&&!this.matchText(e.name,n.name))}matchText(e,n){if(typeof n=="string")return e===n;if(n instanceof RegExp)return n.test(e);if(typeof n=="object"&&n.pattern){const r=n.flags||"";return new RegExp(n.pattern,r).test(e)}return!1}}class Wt extends B{constructor(e){super(),this.layer=e}matcher=new Q;targetParticipantIds=new Set;transform(e){return this.resolveTargetParticipants(e),super.transform(e)}resolveTargetParticipants(e){this.targetParticipantIds.clear();const n=this.layer.selector;e.participants.forEach(r=>{this.matcher.matchParticipant(r,n)&&this.targetParticipantIds.add(r.id)})}visitEvent(e){if(e.kind==="message"){const n=e;if(!this.isRelatedToParticipant(n))return[]}if(e.kind==="note"&&!e.participantIds.some(i=>this.targetParticipantIds.has(i)))return[];if(e.kind==="activation"){const n=e;if(!this.targetParticipantIds.has(n.participantId))return[]}return super.visitEvent(e)}isRelatedToParticipant(e){return!!(e.from&&this.targetParticipantIds.has(e.from)||e.to&&this.targetParticipantIds.has(e.to))}}class Kt extends B{constructor(e){super(),this.layer=e}matcher=new Q;mergedParticipantIds=new Set;targetParticipantId="";transform(e){const n=this.layer.selector,r=[];if(e.participants.forEach(d=>{this.matcher.matchParticipant(d,n)&&r.push(d)}),r.length===0)return e;this.mergedParticipantIds=new Set(r.map(d=>d.id));const i=this.layer.into||{};let s=i.id,o=i.name;s||(o?s=o.replace(/[^a-zA-Z0-9-_]/g,"_"):s=r.map(d=>d.id).join("_")),o||(o=s),this.targetParticipantId=s;const a=[],h=!e.participants.some(d=>d.id===s&&!this.mergedParticipantIds.has(d.id));let p=!1;for(const d of e.participants){if(this.mergedParticipantIds.has(d.id)){if(h&&!p){const f={id:s||"",name:o||"",type:"participant"};a.push(f),p=!0}continue}d.id,a.push(d)}return e.participants=a,super.transform(e)}visitEvent(e){if(e.kind==="message")return this.transformMessage(e);if(e.kind==="note")return this.transformNote(e);if(e.kind==="activation")return this.transformActivation(e);if(e.kind==="fragment"){const n=super.visitEvent(e);return n.length>0&&n[0].kind==="fragment"&&n[0].branches.every(s=>s.events.length===0)?[]:n}return super.visitEvent(e)}transformMessage(e){let n=e.from,r=e.to;return n&&this.mergedParticipantIds.has(n)&&(n=this.targetParticipantId),r&&this.mergedParticipantIds.has(r)&&(r=this.targetParticipantId),n===this.targetParticipantId&&r===this.targetParticipantId?[]:[{...e,from:n,to:r}]}transformNote(e){const n=new Set;let r=!1;for(const o of e.participantIds)this.mergedParticipantIds.has(o)?(n.add(this.targetParticipantId),r=!0):n.add(o);if(!r)return[e];const i=Array.from(n);return e.participantIds.every(o=>this.mergedParticipantIds.has(o))?[]:[{...e,participantIds:i}]}transformActivation(e){return this.mergedParticipantIds.has(e.participantId)?[]:[e]}}class Yt extends B{constructor(e){super(),this.layer=e}matcher=new Q;removedParticipantIds=new Set;transform(e){const n=this.layer.selector;return n.kind==="participant"&&(e.participants.forEach(r=>{this.matcher.matchParticipant(r,n)&&this.removedParticipantIds.add(r.id)}),e.participants=e.participants.filter(r=>!this.removedParticipantIds.has(r.id))),n.kind==="group"&&(e.groups=e.groups.filter(r=>!this.matcher.matchGroup(r,n))),super.transform(e)}visitEvent(e){const n=this.layer.selector;if(n.kind==="message"&&e.kind==="message"&&this.matcher.matchMessage(e,n))return[];if(n.kind==="participant"){if(e.kind==="message"){const r=e;if(this.isRelatedToRemovedParticipant(r))return[]}if(e.kind==="note"&&e.participantIds.some(s=>this.removedParticipantIds.has(s)))return[];if(e.kind==="activation"){const r=e;if(this.removedParticipantIds.has(r.participantId))return[]}}return super.visitEvent(e)}isRelatedToRemovedParticipant(e){return!!(e.from&&this.removedParticipantIds.has(e.from)||e.to&&this.removedParticipantIds.has(e.to))}}class qt extends B{constructor(e){super(),this.layer=e}matcher=new Q;visitFragment(e){const n=e.branches.find(r=>this.matcher.matchBranch(r,this.layer.selector,e.operator));return n?this.mapEvents(n.events):super.visitFragment(e)}}class Xt{factories=new Map;constructor(){this.registerTyped("resolve",e=>new qt(e)),this.registerTyped("focus",e=>new Wt(e)),this.registerTyped("remove",e=>new Yt(e)),this.registerTyped("merge",e=>new Kt(e))}registerTyped(e,n){this.factories.set(e,n)}register(e,n){this.factories.set(e,n)}get(e){const n=this.factories.get(e.action);return n?n(e):null}has(e){return this.factories.has(e)}}const Ne=new Xt;class H{transform(e,n){let r=e;for(const i of n){const s=Ne.get(i);s?r=s.transform(r):console.warn(`Unknown action: ${i.action}`)}return r=new Bt().transform(r),r=new Jt().transform(r),r}}class Qt{constructor(){}static init(e,n="mermaid"){const i=Se.getParser(n).parse(e);return new Ae(i,n)}}class Ae{ast;layers=[];sourceFormat;constructor(e,n="mermaid"){this.ast=e,this.sourceFormat=n}focusParticipant(e){return this.layers.push({action:"focus",selector:this.normalizeParticipantSelector(e)}),this}removeParticipant(e){return this.layers.push({action:"remove",selector:this.normalizeParticipantSelector(e)}),this}removeMessage(e){return this.layers.push({action:"remove",selector:this.normalizeMessageSelector(e)}),this}removeGroup(e){return this.layers.push({action:"remove",selector:this.normalizeGroupSelector(e)}),this}resolveFragment(e){return this.layers.push({action:"resolve",selector:this.normalizeFragmentSelector(e)}),this}applyLens(e){return this.layers.push(...e.layers),this}toMermaid(){const n=new H().transform(this.ast,this.layers);return new le().generate(n)}toPlantUML(){const n=new H().transform(this.ast,this.layers);return new de().generate(n)}toAST(){return new H().transform(this.ast,this.layers)}getSourceFormat(){return this.sourceFormat}normalizeParticipantSelector(e){return this.isTextMatcher(e)?{kind:"participant",name:e}:{kind:"participant",...e}}normalizeMessageSelector(e){return this.isTextMatcher(e)?{kind:"message",text:e}:{kind:"message",...e}}normalizeGroupSelector(e){return this.isTextMatcher(e)?{kind:"group",name:e}:{kind:"group",...e}}normalizeFragmentSelector(e){return this.isTextMatcher(e)?{kind:"fragment",condition:e}:{kind:"fragment",...e}}isTextMatcher(e){return typeof e=="string"||e instanceof RegExp||typeof e=="object"&&e!==null&&"pattern"in e&&!("kind"in e)}}const j=new Map;j.set("mermaid",()=>new le),j.set("plantuml",()=>new de);const Ht={register(t,e){j.set(t,e)},getGenerator(t){const e=j.get(t);if(!e)throw new Error(`Generator for language '${t}' not found.`);return e()},hasGenerator(t){return j.has(t)},getLanguages(){return Array.from(j.keys())}};function u(t,e,n){function r(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(t))return;a._zod.traits.add(t),e(a,c);const h=o.prototype,p=Object.keys(h);for(let d=0;d<p.length;d++){const f=p[d];f in a||(a[f]=h[f].bind(a))}}const i=n?.Parent??Object;class s extends i{}Object.defineProperty(s,"name",{value:t});function o(a){var c;const h=n?.Parent?new s:this;r(h,a),(c=h._zod).deferred??(c.deferred=[]);for(const p of h._zod.deferred)p();return h}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(t)}),Object.defineProperty(o,"name",{value:t}),o}class M extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Ze extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const Ce={};function C(t){return Ce}function Re(t){const e=Object.values(t).filter(r=>typeof r=="number");return Object.entries(t).filter(([r,i])=>e.indexOf(+r)===-1).map(([r,i])=>i)}function me(t,e){return typeof e=="bigint"?e.toString():e}function ee(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function ge(t){return t==null}function ve(t){const e=t.startsWith("^")?1:0,n=t.endsWith("$")?t.length-1:t.length;return t.slice(e,n)}function en(t,e){const n=(t.toString().split(".")[1]||"").length,r=e.toString();let i=(r.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(r)){const c=r.match(/\d?e-(\d?)/);c?.[1]&&(i=Number.parseInt(c[1]))}const s=n>i?n:i,o=Number.parseInt(t.toFixed(s).replace(".","")),a=Number.parseInt(e.toFixed(s).replace(".",""));return o%a/10**s}const Le=Symbol("evaluating");function m(t,e,n){let r;Object.defineProperty(t,e,{get(){if(r!==Le)return r===void 0&&(r=Le,r=n()),r},set(i){Object.defineProperty(t,e,{value:i})},configurable:!0})}function R(t,e,n){Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0})}function L(...t){const e={};for(const n of t){const r=Object.getOwnPropertyDescriptors(n);Object.assign(e,r)}return Object.defineProperties({},e)}function De(t){return JSON.stringify(t)}function tn(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const xe="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function J(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const nn=ee(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function W(t){if(J(t)===!1)return!1;const e=t.constructor;if(e===void 0||typeof e!="function")return!0;const n=e.prototype;return!(J(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Fe(t){return W(t)?{...t}:Array.isArray(t)?[...t]:t}const rn=new Set(["string","number","symbol"]);function U(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function N(t,e,n){const r=new t._zod.constr(e??t._zod.def);return(!e||n?.parent)&&(r._zod.parent=t),r}function l(t){const e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function sn(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}const on={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function an(t,e){const n=t._zod.def,r=L(t._zod.def,{get shape(){const i={};for(const s in e){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);e[s]&&(i[s]=n.shape[s])}return R(this,"shape",i),i},checks:[]});return N(t,r)}function cn(t,e){const n=t._zod.def,r=L(t._zod.def,{get shape(){const i={...t._zod.def.shape};for(const s in e){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);e[s]&&delete i[s]}return R(this,"shape",i),i},checks:[]});return N(t,r)}function un(t,e){if(!W(e))throw new Error("Invalid input to extend: expected a plain object");const n=t._zod.def.checks;if(n&&n.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const i=L(t._zod.def,{get shape(){const s={...t._zod.def.shape,...e};return R(this,"shape",s),s},checks:[]});return N(t,i)}function hn(t,e){if(!W(e))throw new Error("Invalid input to safeExtend: expected a plain object");const n={...t._zod.def,get shape(){const r={...t._zod.def.shape,...e};return R(this,"shape",r),r},checks:t._zod.def.checks};return N(t,n)}function pn(t,e){const n=L(t._zod.def,{get shape(){const r={...t._zod.def.shape,...e._zod.def.shape};return R(this,"shape",r),r},get catchall(){return e._zod.def.catchall},checks:[]});return N(t,n)}function ln(t,e,n){const r=L(e._zod.def,{get shape(){const i=e._zod.def.shape,s={...i};if(n)for(const o in n){if(!(o in i))throw new Error(`Unrecognized key: "${o}"`);n[o]&&(s[o]=t?new t({type:"optional",innerType:i[o]}):i[o])}else for(const o in i)s[o]=t?new t({type:"optional",innerType:i[o]}):i[o];return R(this,"shape",s),s},checks:[]});return N(e,r)}function dn(t,e,n){const r=L(e._zod.def,{get shape(){const i=e._zod.def.shape,s={...i};if(n)for(const o in n){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);n[o]&&(s[o]=new t({type:"nonoptional",innerType:i[o]}))}else for(const o in i)s[o]=new t({type:"nonoptional",innerType:i[o]});return R(this,"shape",s),s},checks:[]});return N(e,r)}function G(t,e=0){if(t.aborted===!0)return!0;for(let n=e;n<t.issues.length;n++)if(t.issues[n]?.continue!==!0)return!0;return!1}function je(t,e){return e.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(t),n})}function te(t){return typeof t=="string"?t:t?.message}function D(t,e,n){const r={...t,path:t.path??[]};if(!t.message){const i=te(t.inst?._zod.def?.error?.(t))??te(e?.error?.(t))??te(n.customError?.(t))??te(n.localeError?.(t))??"Invalid input";r.message=i}return delete r.inst,delete r.continue,e?.reportInput||delete r.input,r}function _e(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function K(...t){const[e,n,r]=t;return typeof e=="string"?{message:e,code:"custom",input:n,inst:r}:{...e}}const Me=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),t.message=JSON.stringify(e,me,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},Ue=u("$ZodError",Me),Ge=u("$ZodError",Me,{Parent:Error});function fn(t,e=n=>n.message){const n={},r=[];for(const i of t.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(e(i))):r.push(e(i));return{formErrors:r,fieldErrors:n}}function mn(t,e=n=>n.message){const n={_errors:[]},r=i=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(o=>r({issues:o}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)n._errors.push(e(s));else{let o=n,a=0;for(;a<s.path.length;){const c=s.path[a];a===s.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(e(s))):o[c]=o[c]||{_errors:[]},o=o[c],a++}}};return r(t),n}const ke=t=>(e,n,r,i)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},o=e._zod.run({value:n,issues:[]},s);if(o instanceof Promise)throw new M;if(o.issues.length){const a=new(i?.Err??t)(o.issues.map(c=>D(c,s,C())));throw xe(a,i?.callee),a}return o.value},ye=t=>async(e,n,r,i)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let o=e._zod.run({value:n,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){const a=new(i?.Err??t)(o.issues.map(c=>D(c,s,C())));throw xe(a,i?.callee),a}return o.value},ne=t=>(e,n,r)=>{const i=r?{...r,async:!1}:{async:!1},s=e._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new M;return s.issues.length?{success:!1,error:new(t??Ue)(s.issues.map(o=>D(o,i,C())))}:{success:!0,data:s.value}},gn=ne(Ge),re=t=>async(e,n,r)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let s=e._zod.run({value:n,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new t(s.issues.map(o=>D(o,i,C())))}:{success:!0,data:s.value}},vn=re(Ge),_n=t=>(e,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ke(t)(e,n,i)},kn=t=>(e,n,r)=>ke(t)(e,n,r),yn=t=>async(e,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ye(t)(e,n,i)},Tn=t=>async(e,n,r)=>ye(t)(e,n,r),wn=t=>(e,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ne(t)(e,n,i)},bn=t=>(e,n,r)=>ne(t)(e,n,r),En=t=>async(e,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return re(t)(e,n,i)},In=t=>async(e,n,r)=>re(t)(e,n,r),zn=/^[cC][^\s-]{8,}$/,$n=/^[0-9a-z]+$/,On=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Pn=/^[0-9a-vA-V]{20}$/,Sn=/^[A-Za-z0-9]{27}$/,Nn=/^[a-zA-Z0-9_-]{21}$/,An=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Zn=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Ve=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Cn=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Rn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Ln(){return new RegExp(Rn,"u")}const Dn=/^(?:(?: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])$/,xn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Fn=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,jn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Mn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Be=/^[A-Za-z0-9_-]*$/,Un=/^\+(?:[0-9]){6,14}[0-9]$/,Je="(?:(?:\\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])))",Gn=new RegExp(`^${Je}$`);function We(t){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Vn(t){return new RegExp(`^${We(t)}$`)}function Bn(t){const e=We({precision:t.precision}),n=["Z"];t.local&&n.push(""),t.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${e}(?:${n.join("|")})`;return new RegExp(`^${Je}T(?:${r})$`)}const Jn=t=>{const e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},Wn=/^-?\d+$/,Kn=/^-?\d+(?:\.\d+)?/,Yn=/^[^A-Z]*$/,qn=/^[^a-z]*$/,E=u("$ZodCheck",(t,e)=>{var n;t._zod??(t._zod={}),t._zod.def=e,(n=t._zod).onattach??(n.onattach=[])}),Ke={number:"number",bigint:"bigint",object:"date"},Ye=u("$ZodCheckLessThan",(t,e)=>{E.init(t,e);const n=Ke[typeof e.value];t._zod.onattach.push(r=>{const i=r._zod.bag,s=(e.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<s&&(e.inclusive?i.maximum=e.value:i.exclusiveMaximum=e.value)}),t._zod.check=r=>{(e.inclusive?r.value<=e.value:r.value<e.value)||r.issues.push({origin:n,code:"too_big",maximum:e.value,input:r.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),qe=u("$ZodCheckGreaterThan",(t,e)=>{E.init(t,e);const n=Ke[typeof e.value];t._zod.onattach.push(r=>{const i=r._zod.bag,s=(e.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>s&&(e.inclusive?i.minimum=e.value:i.exclusiveMinimum=e.value)}),t._zod.check=r=>{(e.inclusive?r.value>=e.value:r.value>e.value)||r.issues.push({origin:n,code:"too_small",minimum:e.value,input:r.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),Xn=u("$ZodCheckMultipleOf",(t,e)=>{E.init(t,e),t._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=e.value)}),t._zod.check=n=>{if(typeof n.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%e.value===BigInt(0):en(n.value,e.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:e.value,input:n.value,inst:t,continue:!e.abort})}}),Qn=u("$ZodCheckNumberFormat",(t,e)=>{E.init(t,e),e.format=e.format||"float64";const n=e.format?.includes("int"),r=n?"int":"number",[i,s]=on[e.format];t._zod.onattach.push(o=>{const a=o._zod.bag;a.format=e.format,a.minimum=i,a.maximum=s,n&&(a.pattern=Wn)}),t._zod.check=o=>{const a=o.value;if(n){if(!Number.isInteger(a)){o.issues.push({expected:r,format:e.format,code:"invalid_type",continue:!1,input:a,inst:t});return}if(!Number.isSafeInteger(a)){a>0?o.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:r,continue:!e.abort}):o.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:r,continue:!e.abort});return}}a<i&&o.issues.push({origin:"number",input:a,code:"too_small",minimum:i,inclusive:!0,inst:t,continue:!e.abort}),a>s&&o.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inst:t})}}),Hn=u("$ZodCheckMaxLength",(t,e)=>{var n;E.init(t,e),(n=t._zod.def).when??(n.when=r=>{const i=r.value;return!ge(i)&&i.length!==void 0}),t._zod.onattach.push(r=>{const i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<i&&(r._zod.bag.maximum=e.maximum)}),t._zod.check=r=>{const i=r.value;if(i.length<=e.maximum)return;const o=_e(i);r.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:i,inst:t,continue:!e.abort})}}),er=u("$ZodCheckMinLength",(t,e)=>{var n;E.init(t,e),(n=t._zod.def).when??(n.when=r=>{const i=r.value;return!ge(i)&&i.length!==void 0}),t._zod.onattach.push(r=>{const i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>i&&(r._zod.bag.minimum=e.minimum)}),t._zod.check=r=>{const i=r.value;if(i.length>=e.minimum)return;const o=_e(i);r.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:i,inst:t,continue:!e.abort})}}),tr=u("$ZodCheckLengthEquals",(t,e)=>{var n;E.init(t,e),(n=t._zod.def).when??(n.when=r=>{const i=r.value;return!ge(i)&&i.length!==void 0}),t._zod.onattach.push(r=>{const i=r._zod.bag;i.minimum=e.length,i.maximum=e.length,i.length=e.length}),t._zod.check=r=>{const i=r.value,s=i.length;if(s===e.length)return;const o=_e(i),a=s>e.length;r.issues.push({origin:o,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:r.value,inst:t,continue:!e.abort})}}),ie=u("$ZodCheckStringFormat",(t,e)=>{var n,r;E.init(t,e),t._zod.onattach.push(i=>{const s=i._zod.bag;s.format=e.format,e.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(e.pattern))}),e.pattern?(n=t._zod).check??(n.check=i=>{e.pattern.lastIndex=0,!e.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:e.format,input:i.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(r=t._zod).check??(r.check=()=>{})}),nr=u("$ZodCheckRegex",(t,e)=>{ie.init(t,e),t._zod.check=n=>{e.pattern.lastIndex=0,!e.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),rr=u("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=Yn),ie.init(t,e)}),ir=u("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=qn),ie.init(t,e)}),sr=u("$ZodCheckIncludes",(t,e)=>{E.init(t,e);const n=U(e.includes),r=new RegExp(typeof e.position=="number"?`^.{${e.position}}${n}`:n);e.pattern=r,t._zod.onattach.push(i=>{const s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),t._zod.check=i=>{i.value.includes(e.includes,e.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:i.value,inst:t,continue:!e.abort})}}),or=u("$ZodCheckStartsWith",(t,e)=>{E.init(t,e);const n=new RegExp(`^${U(e.prefix)}.*`);e.pattern??(e.pattern=n),t._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),t._zod.check=r=>{r.value.startsWith(e.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:r.value,inst:t,continue:!e.abort})}}),ar=u("$ZodCheckEndsWith",(t,e)=>{E.init(t,e);const n=new RegExp(`.*${U(e.suffix)}$`);e.pattern??(e.pattern=n),t._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),t._zod.check=r=>{r.value.endsWith(e.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:r.value,inst:t,continue:!e.abort})}}),cr=u("$ZodCheckOverwrite",(t,e)=>{E.init(t,e),t._zod.check=n=>{n.value=e.tx(n.value)}});class ur{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const r=e.split(`
|
|
13
13
|
`).filter(o=>o),i=Math.min(...r.map(o=>o.length-o.trimStart().length)),s=r.map(o=>o.slice(i)).map(o=>" ".repeat(this.indent*2)+o);for(const o of s)this.content.push(o)}compile(){const e=Function,n=this?.args,i=[...(this?.content??[""]).map(s=>` ${s}`)];return new e(...n,i.join(`
|
|
14
|
-
`))}}const hr={major:4,minor:2,patch:1},k=u("$ZodType",(t,e)=>{var n;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=hr;const r=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&r.unshift(t);for(const i of r)for(const s of i._zod.onattach)s(t);if(r.length===0)(n=t._zod).deferred??(n.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{const i=(o,a,c)=>{let h=G(o),p;for(const d of a){if(d._zod.def.when){if(!d._zod.def.when(o))continue}else if(h)continue;const f=o.issues.length,_=d._zod.check(o);if(_ instanceof Promise&&c?.async===!1)throw new M;if(p||_ instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await _,o.issues.length!==f&&(h||(h=G(o,f)))});else{if(o.issues.length===f)continue;h||(h=G(o,f))}}return p?p.then(()=>o):o},s=(o,a,c)=>{if(G(o))return o.aborted=!0,o;const h=i(a,r,c);if(h instanceof Promise){if(c.async===!1)throw new M;return h.then(p=>t._zod.parse(p,c))}return t._zod.parse(h,c)};t._zod.run=(o,a)=>{if(a.skipChecks)return t._zod.parse(o,a);if(a.direction==="backward"){const h=t._zod.parse({value:o.value,issues:[]},{...a,skipChecks:!0});return h instanceof Promise?h.then(p=>s(p,o,a)):s(h,o,a)}const c=t._zod.parse(o,a);if(c instanceof Promise){if(a.async===!1)throw new M;return c.then(h=>i(h,r,a))}return i(c,r,a)}}t["~standard"]={validate:i=>{try{const s=gn(t,i);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return vn(t,i).then(o=>o.success?{value:o.data}:{issues:o.error?.issues})}},vendor:"zod",version:1}}),Te=u("$ZodString",(t,e)=>{k.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??Jn(t._zod.bag),t._zod.parse=(n,r)=>{if(e.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:t}),n}}),g=u("$ZodStringFormat",(t,e)=>{ie.init(t,e),Te.init(t,e)}),pr=u("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=Zn),g.init(t,e)}),lr=u("$ZodUUID",(t,e)=>{if(e.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(r===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=Ve(r))}else e.pattern??(e.pattern=Ve());g.init(t,e)}),dr=u("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=Cn),g.init(t,e)}),fr=u("$ZodURL",(t,e)=>{g.init(t,e),t._zod.check=n=>{try{const r=n.value.trim(),i=new URL(r);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(i.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:n.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:n.value,inst:t,continue:!e.abort})),e.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:t,continue:!e.abort})}}}),mr=u("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=Ln()),g.init(t,e)}),gr=u("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=Nn),g.init(t,e)}),vr=u("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=zn),g.init(t,e)}),_r=u("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=$n),g.init(t,e)}),kr=u("$ZodULID",(t,e)=>{e.pattern??(e.pattern=On),g.init(t,e)}),yr=u("$ZodXID",(t,e)=>{e.pattern??(e.pattern=Pn),g.init(t,e)}),Tr=u("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=Sn),g.init(t,e)}),wr=u("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=Bn(e)),g.init(t,e)}),br=u("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=Gn),g.init(t,e)}),Er=u("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=Vn(e)),g.init(t,e)}),Ir=u("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=An),g.init(t,e)}),zr=u("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=Dn),g.init(t,e),t._zod.bag.format="ipv4"}),$r=u("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=xn),g.init(t,e),t._zod.bag.format="ipv6",t._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:t,continue:!e.abort})}}}),Or=u("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=Fn),g.init(t,e)}),Pr=u("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=jn),g.init(t,e),t._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[i,s]=r;if(!s)throw new Error;const o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${i}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:t,continue:!e.abort})}}});function Xe(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}const Sr=u("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=Mn),g.init(t,e),t._zod.bag.contentEncoding="base64",t._zod.check=n=>{Xe(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:t,continue:!e.abort})}});function Nr(t){if(!Be.test(t))return!1;const e=t.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=e.padEnd(Math.ceil(e.length/4)*4,"=");return Xe(n)}const Ar=u("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=Be),g.init(t,e),t._zod.bag.contentEncoding="base64url",t._zod.check=n=>{Nr(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:t,continue:!e.abort})}}),Zr=u("$ZodE164",(t,e)=>{e.pattern??(e.pattern=Un),g.init(t,e)});function Cr(t,e=null){try{const n=t.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const i=JSON.parse(atob(r));return!("typ"in i&&i?.typ!=="JWT"||!i.alg||e&&(!("alg"in i)||i.alg!==e))}catch{return!1}}const Rr=u("$ZodJWT",(t,e)=>{g.init(t,e),t._zod.check=n=>{Cr(n.value,e.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:t,continue:!e.abort})}}),Qe=u("$ZodNumber",(t,e)=>{k.init(t,e),t._zod.pattern=t._zod.bag.pattern??Kn,t._zod.parse=(n,r)=>{if(e.coerce)try{n.value=Number(n.value)}catch{}const i=n.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return n;const s=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:t,...s?{received:s}:{}}),n}}),Lr=u("$ZodNumberFormat",(t,e)=>{Qn.init(t,e),Qe.init(t,e)}),Dr=u("$ZodUnknown",(t,e)=>{k.init(t,e),t._zod.parse=n=>n}),xr=u("$ZodNever",(t,e)=>{k.init(t,e),t._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:t}),n)});function He(t,e,n){t.issues.length&&e.issues.push(...je(n,t.issues)),e.value[n]=t.value}const Fr=u("$ZodArray",(t,e)=>{k.init(t,e),t._zod.parse=(n,r)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:t}),n;n.value=Array(i.length);const s=[];for(let o=0;o<i.length;o++){const a=i[o],c=e.element._zod.run({value:a,issues:[]},r);c instanceof Promise?s.push(c.then(h=>He(h,n,o))):He(c,n,o)}return s.length?Promise.all(s).then(()=>n):n}});function se(t,e,n,r){t.issues.length&&e.issues.push(...je(n,t.issues)),t.value===void 0?n in r&&(e.value[n]=void 0):e.value[n]=t.value}function et(t){const e=Object.keys(t.shape);for(const r of e)if(!t.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const n=sn(t.shape);return{...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}}function tt(t,e,n,r,i,s){const o=[],a=i.keySet,c=i.catchall._zod,h=c.def.type;for(const p in e){if(a.has(p))continue;if(h==="never"){o.push(p);continue}const d=c.run({value:e[p],issues:[]},r);d instanceof Promise?t.push(d.then(f=>se(f,n,p,e))):se(d,n,p,e)}return o.length&&n.issues.push({code:"unrecognized_keys",keys:o,input:e,inst:s}),t.length?Promise.all(t).then(()=>n):n}const jr=u("$ZodObject",(t,e)=>{if(k.init(t,e),!Object.getOwnPropertyDescriptor(e,"shape")?.get){const a=e.shape;Object.defineProperty(e,"shape",{get:()=>{const c={...a};return Object.defineProperty(e,"shape",{value:c}),c}})}const r=ee(()=>et(e));m(t._zod,"propValues",()=>{const a=e.shape,c={};for(const h in a){const p=a[h]._zod;if(p.values){c[h]??(c[h]=new Set);for(const d of p.values)c[h].add(d)}}return c});const i=J,s=e.catchall;let o;t._zod.parse=(a,c)=>{o??(o=r.value);const h=a.value;if(!i(h))return a.issues.push({expected:"object",code:"invalid_type",input:h,inst:t}),a;a.value={};const p=[],d=o.shape;for(const f of o.keys){const
|
|
14
|
+
`))}}const hr={major:4,minor:2,patch:1},k=u("$ZodType",(t,e)=>{var n;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=hr;const r=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&r.unshift(t);for(const i of r)for(const s of i._zod.onattach)s(t);if(r.length===0)(n=t._zod).deferred??(n.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{const i=(o,a,c)=>{let h=G(o),p;for(const d of a){if(d._zod.def.when){if(!d._zod.def.when(o))continue}else if(h)continue;const f=o.issues.length,_=d._zod.check(o);if(_ instanceof Promise&&c?.async===!1)throw new M;if(p||_ instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await _,o.issues.length!==f&&(h||(h=G(o,f)))});else{if(o.issues.length===f)continue;h||(h=G(o,f))}}return p?p.then(()=>o):o},s=(o,a,c)=>{if(G(o))return o.aborted=!0,o;const h=i(a,r,c);if(h instanceof Promise){if(c.async===!1)throw new M;return h.then(p=>t._zod.parse(p,c))}return t._zod.parse(h,c)};t._zod.run=(o,a)=>{if(a.skipChecks)return t._zod.parse(o,a);if(a.direction==="backward"){const h=t._zod.parse({value:o.value,issues:[]},{...a,skipChecks:!0});return h instanceof Promise?h.then(p=>s(p,o,a)):s(h,o,a)}const c=t._zod.parse(o,a);if(c instanceof Promise){if(a.async===!1)throw new M;return c.then(h=>i(h,r,a))}return i(c,r,a)}}t["~standard"]={validate:i=>{try{const s=gn(t,i);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return vn(t,i).then(o=>o.success?{value:o.data}:{issues:o.error?.issues})}},vendor:"zod",version:1}}),Te=u("$ZodString",(t,e)=>{k.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??Jn(t._zod.bag),t._zod.parse=(n,r)=>{if(e.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:t}),n}}),g=u("$ZodStringFormat",(t,e)=>{ie.init(t,e),Te.init(t,e)}),pr=u("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=Zn),g.init(t,e)}),lr=u("$ZodUUID",(t,e)=>{if(e.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(r===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=Ve(r))}else e.pattern??(e.pattern=Ve());g.init(t,e)}),dr=u("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=Cn),g.init(t,e)}),fr=u("$ZodURL",(t,e)=>{g.init(t,e),t._zod.check=n=>{try{const r=n.value.trim(),i=new URL(r);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(i.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:n.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:n.value,inst:t,continue:!e.abort})),e.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:t,continue:!e.abort})}}}),mr=u("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=Ln()),g.init(t,e)}),gr=u("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=Nn),g.init(t,e)}),vr=u("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=zn),g.init(t,e)}),_r=u("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=$n),g.init(t,e)}),kr=u("$ZodULID",(t,e)=>{e.pattern??(e.pattern=On),g.init(t,e)}),yr=u("$ZodXID",(t,e)=>{e.pattern??(e.pattern=Pn),g.init(t,e)}),Tr=u("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=Sn),g.init(t,e)}),wr=u("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=Bn(e)),g.init(t,e)}),br=u("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=Gn),g.init(t,e)}),Er=u("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=Vn(e)),g.init(t,e)}),Ir=u("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=An),g.init(t,e)}),zr=u("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=Dn),g.init(t,e),t._zod.bag.format="ipv4"}),$r=u("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=xn),g.init(t,e),t._zod.bag.format="ipv6",t._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:t,continue:!e.abort})}}}),Or=u("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=Fn),g.init(t,e)}),Pr=u("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=jn),g.init(t,e),t._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[i,s]=r;if(!s)throw new Error;const o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${i}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:t,continue:!e.abort})}}});function Xe(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}const Sr=u("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=Mn),g.init(t,e),t._zod.bag.contentEncoding="base64",t._zod.check=n=>{Xe(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:t,continue:!e.abort})}});function Nr(t){if(!Be.test(t))return!1;const e=t.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=e.padEnd(Math.ceil(e.length/4)*4,"=");return Xe(n)}const Ar=u("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=Be),g.init(t,e),t._zod.bag.contentEncoding="base64url",t._zod.check=n=>{Nr(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:t,continue:!e.abort})}}),Zr=u("$ZodE164",(t,e)=>{e.pattern??(e.pattern=Un),g.init(t,e)});function Cr(t,e=null){try{const n=t.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const i=JSON.parse(atob(r));return!("typ"in i&&i?.typ!=="JWT"||!i.alg||e&&(!("alg"in i)||i.alg!==e))}catch{return!1}}const Rr=u("$ZodJWT",(t,e)=>{g.init(t,e),t._zod.check=n=>{Cr(n.value,e.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:t,continue:!e.abort})}}),Qe=u("$ZodNumber",(t,e)=>{k.init(t,e),t._zod.pattern=t._zod.bag.pattern??Kn,t._zod.parse=(n,r)=>{if(e.coerce)try{n.value=Number(n.value)}catch{}const i=n.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return n;const s=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:t,...s?{received:s}:{}}),n}}),Lr=u("$ZodNumberFormat",(t,e)=>{Qn.init(t,e),Qe.init(t,e)}),Dr=u("$ZodUnknown",(t,e)=>{k.init(t,e),t._zod.parse=n=>n}),xr=u("$ZodNever",(t,e)=>{k.init(t,e),t._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:t}),n)});function He(t,e,n){t.issues.length&&e.issues.push(...je(n,t.issues)),e.value[n]=t.value}const Fr=u("$ZodArray",(t,e)=>{k.init(t,e),t._zod.parse=(n,r)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:t}),n;n.value=Array(i.length);const s=[];for(let o=0;o<i.length;o++){const a=i[o],c=e.element._zod.run({value:a,issues:[]},r);c instanceof Promise?s.push(c.then(h=>He(h,n,o))):He(c,n,o)}return s.length?Promise.all(s).then(()=>n):n}});function se(t,e,n,r){t.issues.length&&e.issues.push(...je(n,t.issues)),t.value===void 0?n in r&&(e.value[n]=void 0):e.value[n]=t.value}function et(t){const e=Object.keys(t.shape);for(const r of e)if(!t.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const n=sn(t.shape);return{...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}}function tt(t,e,n,r,i,s){const o=[],a=i.keySet,c=i.catchall._zod,h=c.def.type;for(const p in e){if(a.has(p))continue;if(h==="never"){o.push(p);continue}const d=c.run({value:e[p],issues:[]},r);d instanceof Promise?t.push(d.then(f=>se(f,n,p,e))):se(d,n,p,e)}return o.length&&n.issues.push({code:"unrecognized_keys",keys:o,input:e,inst:s}),t.length?Promise.all(t).then(()=>n):n}const jr=u("$ZodObject",(t,e)=>{if(k.init(t,e),!Object.getOwnPropertyDescriptor(e,"shape")?.get){const a=e.shape;Object.defineProperty(e,"shape",{get:()=>{const c={...a};return Object.defineProperty(e,"shape",{value:c}),c}})}const r=ee(()=>et(e));m(t._zod,"propValues",()=>{const a=e.shape,c={};for(const h in a){const p=a[h]._zod;if(p.values){c[h]??(c[h]=new Set);for(const d of p.values)c[h].add(d)}}return c});const i=J,s=e.catchall;let o;t._zod.parse=(a,c)=>{o??(o=r.value);const h=a.value;if(!i(h))return a.issues.push({expected:"object",code:"invalid_type",input:h,inst:t}),a;a.value={};const p=[],d=o.shape;for(const f of o.keys){const $=d[f]._zod.run({value:h[f],issues:[]},c);$ instanceof Promise?p.push($.then($e=>se($e,a,f,h))):se($,a,f,h)}return s?tt(p,h,a,c,r.value,t):p.length?Promise.all(p).then(()=>a):a}}),Mr=u("$ZodObjectJIT",(t,e)=>{jr.init(t,e);const n=t._zod.parse,r=ee(()=>et(e)),i=f=>{const _=new ur(["shape","payload","ctx"]),$=r.value,$e=S=>{const P=De(S);return`shape[${P}]._zod.run({ value: input[${P}], issues: [] }, ctx)`};_.write("const input = payload.value;");const Ct=Object.create(null);let Mo=0;for(const S of $.keys)Ct[S]=`key_${Mo++}`;_.write("const newResult = {};");for(const S of $.keys){const P=Ct[S],q=De(S);_.write(`const ${P} = ${$e(S)};`),_.write(`
|
|
15
15
|
if (${P}.issues.length) {
|
|
16
16
|
payload.issues = payload.issues.concat(${P}.issues.map(iss => ({
|
|
17
17
|
...iss,
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
newResult[${q}] = ${P}.value;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
`)}_.write("payload.value = newResult;"),_.write("return payload;");const Uo=_.compile();return(S,P)=>Uo(f,S,P)};let s;const o=J,a=!Ce.jitless,h=a&&nn.value,p=e.catchall;let d;t._zod.parse=(f,_)=>{d??(d=r.value);const I=f.value;return o(I)?a&&h&&_?.async===!1&&_.jitless!==!0?(s||(s=i(e.shape)),f=s(f,_),p?tt([],I,f,_,d,t):f):n(f,_):(f.issues.push({expected:"object",code:"invalid_type",input:I,inst:t}),f)}});function nt(t,e,n,r){for(const s of t)if(s.issues.length===0)return e.value=s.value,e;const i=t.filter(s=>!G(s));return i.length===1?(e.value=i[0].value,i[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:n,errors:t.map(s=>s.issues.map(o=>D(o,r,C())))}),e)}const rt=u("$ZodUnion",(t,e)=>{k.init(t,e),m(t._zod,"optin",()=>e.options.some(i=>i._zod.optin==="optional")?"optional":void 0),m(t._zod,"optout",()=>e.options.some(i=>i._zod.optout==="optional")?"optional":void 0),m(t._zod,"values",()=>{if(e.options.every(i=>i._zod.values))return new Set(e.options.flatMap(i=>Array.from(i._zod.values)))}),m(t._zod,"pattern",()=>{if(e.options.every(i=>i._zod.pattern)){const i=e.options.map(s=>s._zod.pattern);return new RegExp(`^(${i.map(s=>ve(s.source)).join("|")})$`)}});const n=e.options.length===1,r=e.options[0]._zod.run;t._zod.parse=(i,s)=>{if(n)return r(i,s);let o=!1;const a=[];for(const c of e.options){const h=c._zod.run({value:i.value,issues:[]},s);if(h instanceof Promise)a.push(h),o=!0;else{if(h.issues.length===0)return h;a.push(h)}}return o?Promise.all(a).then(c=>nt(c,i,t,s)):nt(a,i,t,s)}}),Ur=u("$ZodDiscriminatedUnion",(t,e)=>{e.inclusive=!1,rt.init(t,e);const n=t._zod.parse;m(t._zod,"propValues",()=>{const i={};for(const s of e.options){const o=s._zod.propValues;if(!o||Object.keys(o).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(s)}"`);for(const[a,c]of Object.entries(o)){i[a]||(i[a]=new Set);for(const h of c)i[a].add(h)}}return i});const r=ee(()=>{const i=e.options,s=new Map;for(const o of i){const a=o._zod.propValues?.[e.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(o)}"`);for(const c of a){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,o)}}return s});t._zod.parse=(i,s)=>{const o=i.value;if(!J(o))return i.issues.push({code:"invalid_type",expected:"object",input:o,inst:t}),i;const a=r.value.get(o?.[e.discriminator]);return a?a._zod.run(i,s):e.unionFallback?n(i,s):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:e.discriminator,input:o,path:[e.discriminator],inst:t}),i)}}),Gr=u("$ZodIntersection",(t,e)=>{k.init(t,e),t._zod.parse=(n,r)=>{const i=n.value,s=e.left._zod.run({value:i,issues:[]},r),o=e.right._zod.run({value:i,issues:[]},r);return s instanceof Promise||o instanceof Promise?Promise.all([s,o]).then(([c,h])=>it(n,c,h)):it(n,s,o)}});function we(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(W(t)&&W(e)){const n=Object.keys(e),r=Object.keys(t).filter(s=>n.indexOf(s)!==-1),i={...t,...e};for(const s of r){const o=we(t[s],e[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};i[s]=o.data}return{valid:!0,data:i}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<t.length;r++){const i=t[r],s=e[r],o=we(i,s);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function it(t,e,n){if(e.issues.length&&t.issues.push(...e.issues),n.issues.length&&t.issues.push(...n.issues),G(t))return t;const r=we(e.value,n.value);if(!r.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return t.value=r.data,t}const Vr=u("$ZodEnum",(t,e)=>{k.init(t,e);const n=Re(e.entries),r=new Set(n);t._zod.values=r,t._zod.pattern=new RegExp(`^(${n.filter(i=>rn.has(typeof i)).map(i=>typeof i=="string"?U(i):i.toString()).join("|")})$`),t._zod.parse=(i,s)=>{const o=i.value;return r.has(o)||i.issues.push({code:"invalid_value",values:n,input:o,inst:t}),i}}),Br=u("$ZodLiteral",(t,e)=>{if(k.init(t,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(e.values);t._zod.values=n,t._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?U(r):r?U(r.toString()):String(r)).join("|")})$`),t._zod.parse=(r,i)=>{const s=r.value;return n.has(s)||r.issues.push({code:"invalid_value",values:e.values,input:s,inst:t}),r}}),Jr=u("$ZodTransform",(t,e)=>{k.init(t,e),t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Ze(t.constructor.name);const i=e.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(o=>(n.value=o,n));if(i instanceof Promise)throw new M;return n.value=i,n}});function st(t,e){return t.issues.length&&e===void 0?{issues:[],value:void 0}:t}const Wr=u("$ZodOptional",(t,e)=>{k.init(t,e),t._zod.optin="optional",t._zod.optout="optional",m(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),m(t._zod,"pattern",()=>{const n=e.innerType._zod.pattern;return n?new RegExp(`^(${ve(n.source)})?$`):void 0}),t._zod.parse=(n,r)=>{if(e.innerType._zod.optin==="optional"){const i=e.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>st(s,n.value)):st(i,n.value)}return n.value===void 0?n:e.innerType._zod.run(n,r)}}),Kr=u("$ZodNullable",(t,e)=>{k.init(t,e),m(t._zod,"optin",()=>e.innerType._zod.optin),m(t._zod,"optout",()=>e.innerType._zod.optout),m(t._zod,"pattern",()=>{const n=e.innerType._zod.pattern;return n?new RegExp(`^(${ve(n.source)}|null)$`):void 0}),m(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(n,r)=>n.value===null?n:e.innerType._zod.run(n,r)}),Yr=u("$ZodDefault",(t,e)=>{k.init(t,e),t._zod.optin="optional",m(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>{if(r.direction==="backward")return e.innerType._zod.run(n,r);if(n.value===void 0)return n.value=e.defaultValue,n;const i=e.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>ot(s,e)):ot(i,e)}});function ot(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}const qr=u("$ZodPrefault",(t,e)=>{k.init(t,e),t._zod.optin="optional",m(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=e.defaultValue),e.innerType._zod.run(n,r))}),Xr=u("$ZodNonOptional",(t,e)=>{k.init(t,e),m(t._zod,"values",()=>{const n=e.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),t._zod.parse=(n,r)=>{const i=e.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>at(s,t)):at(i,t)}});function at(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}const Qr=u("$ZodCatch",(t,e)=>{k.init(t,e),m(t._zod,"optin",()=>e.innerType._zod.optin),m(t._zod,"optout",()=>e.innerType._zod.optout),m(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>{if(r.direction==="backward")return e.innerType._zod.run(n,r);const i=e.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>(n.value=s.value,s.issues.length&&(n.value=e.catchValue({...n,error:{issues:s.issues.map(o=>D(o,r,C()))},input:n.value}),n.issues=[]),n)):(n.value=i.value,i.issues.length&&(n.value=e.catchValue({...n,error:{issues:i.issues.map(s=>D(s,r,C()))},input:n.value}),n.issues=[]),n)}}),Hr=u("$ZodPipe",(t,e)=>{k.init(t,e),m(t._zod,"values",()=>e.in._zod.values),m(t._zod,"optin",()=>e.in._zod.optin),m(t._zod,"optout",()=>e.out._zod.optout),m(t._zod,"propValues",()=>e.in._zod.propValues),t._zod.parse=(n,r)=>{if(r.direction==="backward"){const s=e.out._zod.run(n,r);return s instanceof Promise?s.then(o=>oe(o,e.in,r)):oe(s,e.in,r)}const i=e.in._zod.run(n,r);return i instanceof Promise?i.then(s=>oe(s,e.out,r)):oe(i,e.out,r)}});function oe(t,e,n){return t.issues.length?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues},n)}const ei=u("$ZodReadonly",(t,e)=>{k.init(t,e),m(t._zod,"propValues",()=>e.innerType._zod.propValues),m(t._zod,"values",()=>e.innerType._zod.values),m(t._zod,"optin",()=>e.innerType?._zod?.optin),m(t._zod,"optout",()=>e.innerType?._zod?.optout),t._zod.parse=(n,r)=>{if(r.direction==="backward")return e.innerType._zod.run(n,r);const i=e.innerType._zod.run(n,r);return i instanceof Promise?i.then(ct):ct(i)}});function ct(t){return t.value=Object.freeze(t.value),t}const ti=u("$ZodCustom",(t,e)=>{E.init(t,e),k.init(t,e),t._zod.parse=(n,r)=>n,t._zod.check=n=>{const r=n.value,i=e.fn(r);if(i instanceof Promise)return i.then(s=>ut(s,n,r,t));ut(i,n,r,t)}});function ut(t,e,n,r){if(!t){const i={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),e.issues.push(K(i))}}var ht;class ni{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...n){const r=n[0];if(this._map.set(e,r),r&&typeof r=="object"&&"id"in r){if(this._idmap.has(r.id))throw new Error(`ID ${r.id} already exists in the registry`);this._idmap.set(r.id,e)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const n=this._map.get(e);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(e),this}get(e){const n=e._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const i={...r,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function ri(){return new ni}(ht=globalThis).__zod_globalRegistry??(ht.__zod_globalRegistry=ri());const Y=globalThis.__zod_globalRegistry;function ii(t,e){return new t({type:"string",...l(e)})}function si(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...l(e)})}function pt(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...l(e)})}function oi(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...l(e)})}function ai(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...l(e)})}function ci(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...l(e)})}function ui(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...l(e)})}function hi(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...l(e)})}function pi(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...l(e)})}function li(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...l(e)})}function di(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...l(e)})}function fi(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...l(e)})}function mi(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...l(e)})}function gi(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...l(e)})}function vi(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...l(e)})}function _i(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...l(e)})}function ki(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...l(e)})}function yi(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...l(e)})}function Ti(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...l(e)})}function wi(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...l(e)})}function bi(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...l(e)})}function Ei(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...l(e)})}function Ii(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...l(e)})}function zi(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...l(e)})}function $i(t,e){return new t({type:"string",format:"date",check:"string_format",...l(e)})}function Oi(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...l(e)})}function Pi(t,e){return new t({type:"string",format:"duration",check:"string_format",...l(e)})}function Si(t,e){return new t({type:"number",checks:[],...l(e)})}function Ni(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...l(e)})}function Ai(t){return new t({type:"unknown"})}function Zi(t,e){return new t({type:"never",...l(e)})}function lt(t,e){return new Ye({check:"less_than",...l(e),value:t,inclusive:!1})}function be(t,e){return new Ye({check:"less_than",...l(e),value:t,inclusive:!0})}function dt(t,e){return new qe({check:"greater_than",...l(e),value:t,inclusive:!1})}function Ee(t,e){return new qe({check:"greater_than",...l(e),value:t,inclusive:!0})}function ft(t,e){return new Xn({check:"multiple_of",...l(e),value:t})}function mt(t,e){return new Hn({check:"max_length",...l(e),maximum:t})}function ae(t,e){return new er({check:"min_length",...l(e),minimum:t})}function gt(t,e){return new tr({check:"length_equals",...l(e),length:t})}function Ci(t,e){return new nr({check:"string_format",format:"regex",...l(e),pattern:t})}function Ri(t){return new rr({check:"string_format",format:"lowercase",...l(t)})}function Li(t){return new ir({check:"string_format",format:"uppercase",...l(t)})}function Di(t,e){return new sr({check:"string_format",format:"includes",...l(e),includes:t})}function xi(t,e){return new or({check:"string_format",format:"starts_with",...l(e),prefix:t})}function Fi(t,e){return new ar({check:"string_format",format:"ends_with",...l(e),suffix:t})}function V(t){return new cr({check:"overwrite",tx:t})}function ji(t){return V(e=>e.normalize(t))}function Mi(){return V(t=>t.trim())}function Ui(){return V(t=>t.toLowerCase())}function Gi(){return V(t=>t.toUpperCase())}function Vi(){return V(t=>tn(t))}function Bi(t,e,n){return new t({type:"array",element:e,...l(n)})}function Ji(t,e,n){return new t({type:"custom",check:"custom",fn:e,...l(n)})}function Wi(t){const e=Ki(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(K(r,n.value,e._zod.def));else{const i=r;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),i.continue??(i.continue=!e._zod.def.abort),n.issues.push(K(i))}},t(n.value,n)));return e}function Ki(t,e){const n=new E({check:"custom",...l(e)});return n._zod.check=t,n}function vt(t){let e=t?.target??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:t.processors??{},metadataRegistry:t?.metadata??Y,target:e,unrepresentable:t?.unrepresentable??"throw",override:t?.override??(()=>{}),io:t?.io??"output",counter:0,seen:new Map,cycles:t?.cycles??"ref",reused:t?.reused??"inline",external:t?.external??void 0}}function w(t,e,n={path:[],schemaPath:[]}){var r;const i=t._zod.def,s=e.seen.get(t);if(s)return s.count++,n.schemaPath.includes(t)&&(s.cycle=n.path),s.schema;const o={schema:{},count:1,cycle:void 0,path:n.path};e.seen.set(t,o);const a=t._zod.toJSONSchema?.();if(a)o.schema=a;else{const p={...n,schemaPath:[...n.schemaPath,t],path:n.path},d=t._zod.parent;if(d)o.ref=d,w(d,e,p),e.seen.get(d).isParent=!0;else if(t._zod.processJSONSchema)t._zod.processJSONSchema(e,o.schema,p);else{const f=o.schema,_=e.processors[i.type];if(!_)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);_(t,e,f,p)}}const c=e.metadataRegistry.get(t);return c&&Object.assign(o.schema,c),e.io==="input"&&b(t)&&(delete o.schema.examples,delete o.schema.default),e.io==="input"&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,e.seen.get(t).schema}function _t(t,e){const n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=s=>{const o=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){const p=t.external.registry.get(s[0])?.id,d=t.external.uri??(_=>_);if(p)return{ref:d(p)};const f=s[1].defId??s[1].schema.id??`schema${t.counter++}`;return s[1].defId=f,{defId:f,ref:`${d("__shared")}#/${o}/${f}`}}if(s[1]===n)return{ref:"#"};const c=`#/${o}/`,h=s[1].schema.id??`__schema${t.counter++}`;return{defId:h,ref:c+h}},i=s=>{if(s[1].schema.$ref)return;const o=s[1],{ref:a,defId:c}=r(s);o.def={...o.schema},c&&(o.defId=c);const h=o.schema;for(const p in h)delete h[p];h.$ref=a};if(t.cycles==="throw")for(const s of t.seen.entries()){const o=s[1];if(o.cycle)throw new Error(`Cycle detected: #/${o.cycle?.join("/")}/<root>
|
|
31
|
+
`)}_.write("payload.value = newResult;"),_.write("return payload;");const Uo=_.compile();return(S,P)=>Uo(f,S,P)};let s;const o=J,a=!Ce.jitless,h=a&&nn.value,p=e.catchall;let d;t._zod.parse=(f,_)=>{d??(d=r.value);const $=f.value;return o($)?a&&h&&_?.async===!1&&_.jitless!==!0?(s||(s=i(e.shape)),f=s(f,_),p?tt([],$,f,_,d,t):f):n(f,_):(f.issues.push({expected:"object",code:"invalid_type",input:$,inst:t}),f)}});function nt(t,e,n,r){for(const s of t)if(s.issues.length===0)return e.value=s.value,e;const i=t.filter(s=>!G(s));return i.length===1?(e.value=i[0].value,i[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:n,errors:t.map(s=>s.issues.map(o=>D(o,r,C())))}),e)}const rt=u("$ZodUnion",(t,e)=>{k.init(t,e),m(t._zod,"optin",()=>e.options.some(i=>i._zod.optin==="optional")?"optional":void 0),m(t._zod,"optout",()=>e.options.some(i=>i._zod.optout==="optional")?"optional":void 0),m(t._zod,"values",()=>{if(e.options.every(i=>i._zod.values))return new Set(e.options.flatMap(i=>Array.from(i._zod.values)))}),m(t._zod,"pattern",()=>{if(e.options.every(i=>i._zod.pattern)){const i=e.options.map(s=>s._zod.pattern);return new RegExp(`^(${i.map(s=>ve(s.source)).join("|")})$`)}});const n=e.options.length===1,r=e.options[0]._zod.run;t._zod.parse=(i,s)=>{if(n)return r(i,s);let o=!1;const a=[];for(const c of e.options){const h=c._zod.run({value:i.value,issues:[]},s);if(h instanceof Promise)a.push(h),o=!0;else{if(h.issues.length===0)return h;a.push(h)}}return o?Promise.all(a).then(c=>nt(c,i,t,s)):nt(a,i,t,s)}}),Ur=u("$ZodDiscriminatedUnion",(t,e)=>{e.inclusive=!1,rt.init(t,e);const n=t._zod.parse;m(t._zod,"propValues",()=>{const i={};for(const s of e.options){const o=s._zod.propValues;if(!o||Object.keys(o).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(s)}"`);for(const[a,c]of Object.entries(o)){i[a]||(i[a]=new Set);for(const h of c)i[a].add(h)}}return i});const r=ee(()=>{const i=e.options,s=new Map;for(const o of i){const a=o._zod.propValues?.[e.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(o)}"`);for(const c of a){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,o)}}return s});t._zod.parse=(i,s)=>{const o=i.value;if(!J(o))return i.issues.push({code:"invalid_type",expected:"object",input:o,inst:t}),i;const a=r.value.get(o?.[e.discriminator]);return a?a._zod.run(i,s):e.unionFallback?n(i,s):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:e.discriminator,input:o,path:[e.discriminator],inst:t}),i)}}),Gr=u("$ZodIntersection",(t,e)=>{k.init(t,e),t._zod.parse=(n,r)=>{const i=n.value,s=e.left._zod.run({value:i,issues:[]},r),o=e.right._zod.run({value:i,issues:[]},r);return s instanceof Promise||o instanceof Promise?Promise.all([s,o]).then(([c,h])=>it(n,c,h)):it(n,s,o)}});function we(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(W(t)&&W(e)){const n=Object.keys(e),r=Object.keys(t).filter(s=>n.indexOf(s)!==-1),i={...t,...e};for(const s of r){const o=we(t[s],e[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};i[s]=o.data}return{valid:!0,data:i}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<t.length;r++){const i=t[r],s=e[r],o=we(i,s);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function it(t,e,n){if(e.issues.length&&t.issues.push(...e.issues),n.issues.length&&t.issues.push(...n.issues),G(t))return t;const r=we(e.value,n.value);if(!r.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return t.value=r.data,t}const Vr=u("$ZodEnum",(t,e)=>{k.init(t,e);const n=Re(e.entries),r=new Set(n);t._zod.values=r,t._zod.pattern=new RegExp(`^(${n.filter(i=>rn.has(typeof i)).map(i=>typeof i=="string"?U(i):i.toString()).join("|")})$`),t._zod.parse=(i,s)=>{const o=i.value;return r.has(o)||i.issues.push({code:"invalid_value",values:n,input:o,inst:t}),i}}),Br=u("$ZodLiteral",(t,e)=>{if(k.init(t,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(e.values);t._zod.values=n,t._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?U(r):r?U(r.toString()):String(r)).join("|")})$`),t._zod.parse=(r,i)=>{const s=r.value;return n.has(s)||r.issues.push({code:"invalid_value",values:e.values,input:s,inst:t}),r}}),Jr=u("$ZodTransform",(t,e)=>{k.init(t,e),t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Ze(t.constructor.name);const i=e.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(o=>(n.value=o,n));if(i instanceof Promise)throw new M;return n.value=i,n}});function st(t,e){return t.issues.length&&e===void 0?{issues:[],value:void 0}:t}const Wr=u("$ZodOptional",(t,e)=>{k.init(t,e),t._zod.optin="optional",t._zod.optout="optional",m(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),m(t._zod,"pattern",()=>{const n=e.innerType._zod.pattern;return n?new RegExp(`^(${ve(n.source)})?$`):void 0}),t._zod.parse=(n,r)=>{if(e.innerType._zod.optin==="optional"){const i=e.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>st(s,n.value)):st(i,n.value)}return n.value===void 0?n:e.innerType._zod.run(n,r)}}),Kr=u("$ZodNullable",(t,e)=>{k.init(t,e),m(t._zod,"optin",()=>e.innerType._zod.optin),m(t._zod,"optout",()=>e.innerType._zod.optout),m(t._zod,"pattern",()=>{const n=e.innerType._zod.pattern;return n?new RegExp(`^(${ve(n.source)}|null)$`):void 0}),m(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(n,r)=>n.value===null?n:e.innerType._zod.run(n,r)}),Yr=u("$ZodDefault",(t,e)=>{k.init(t,e),t._zod.optin="optional",m(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>{if(r.direction==="backward")return e.innerType._zod.run(n,r);if(n.value===void 0)return n.value=e.defaultValue,n;const i=e.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>ot(s,e)):ot(i,e)}});function ot(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}const qr=u("$ZodPrefault",(t,e)=>{k.init(t,e),t._zod.optin="optional",m(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=e.defaultValue),e.innerType._zod.run(n,r))}),Xr=u("$ZodNonOptional",(t,e)=>{k.init(t,e),m(t._zod,"values",()=>{const n=e.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),t._zod.parse=(n,r)=>{const i=e.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>at(s,t)):at(i,t)}});function at(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}const Qr=u("$ZodCatch",(t,e)=>{k.init(t,e),m(t._zod,"optin",()=>e.innerType._zod.optin),m(t._zod,"optout",()=>e.innerType._zod.optout),m(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,r)=>{if(r.direction==="backward")return e.innerType._zod.run(n,r);const i=e.innerType._zod.run(n,r);return i instanceof Promise?i.then(s=>(n.value=s.value,s.issues.length&&(n.value=e.catchValue({...n,error:{issues:s.issues.map(o=>D(o,r,C()))},input:n.value}),n.issues=[]),n)):(n.value=i.value,i.issues.length&&(n.value=e.catchValue({...n,error:{issues:i.issues.map(s=>D(s,r,C()))},input:n.value}),n.issues=[]),n)}}),Hr=u("$ZodPipe",(t,e)=>{k.init(t,e),m(t._zod,"values",()=>e.in._zod.values),m(t._zod,"optin",()=>e.in._zod.optin),m(t._zod,"optout",()=>e.out._zod.optout),m(t._zod,"propValues",()=>e.in._zod.propValues),t._zod.parse=(n,r)=>{if(r.direction==="backward"){const s=e.out._zod.run(n,r);return s instanceof Promise?s.then(o=>oe(o,e.in,r)):oe(s,e.in,r)}const i=e.in._zod.run(n,r);return i instanceof Promise?i.then(s=>oe(s,e.out,r)):oe(i,e.out,r)}});function oe(t,e,n){return t.issues.length?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues},n)}const ei=u("$ZodReadonly",(t,e)=>{k.init(t,e),m(t._zod,"propValues",()=>e.innerType._zod.propValues),m(t._zod,"values",()=>e.innerType._zod.values),m(t._zod,"optin",()=>e.innerType?._zod?.optin),m(t._zod,"optout",()=>e.innerType?._zod?.optout),t._zod.parse=(n,r)=>{if(r.direction==="backward")return e.innerType._zod.run(n,r);const i=e.innerType._zod.run(n,r);return i instanceof Promise?i.then(ct):ct(i)}});function ct(t){return t.value=Object.freeze(t.value),t}const ti=u("$ZodCustom",(t,e)=>{E.init(t,e),k.init(t,e),t._zod.parse=(n,r)=>n,t._zod.check=n=>{const r=n.value,i=e.fn(r);if(i instanceof Promise)return i.then(s=>ut(s,n,r,t));ut(i,n,r,t)}});function ut(t,e,n,r){if(!t){const i={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),e.issues.push(K(i))}}var ht;class ni{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...n){const r=n[0];if(this._map.set(e,r),r&&typeof r=="object"&&"id"in r){if(this._idmap.has(r.id))throw new Error(`ID ${r.id} already exists in the registry`);this._idmap.set(r.id,e)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const n=this._map.get(e);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(e),this}get(e){const n=e._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const i={...r,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function ri(){return new ni}(ht=globalThis).__zod_globalRegistry??(ht.__zod_globalRegistry=ri());const Y=globalThis.__zod_globalRegistry;function ii(t,e){return new t({type:"string",...l(e)})}function si(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...l(e)})}function pt(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...l(e)})}function oi(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...l(e)})}function ai(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...l(e)})}function ci(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...l(e)})}function ui(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...l(e)})}function hi(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...l(e)})}function pi(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...l(e)})}function li(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...l(e)})}function di(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...l(e)})}function fi(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...l(e)})}function mi(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...l(e)})}function gi(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...l(e)})}function vi(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...l(e)})}function _i(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...l(e)})}function ki(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...l(e)})}function yi(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...l(e)})}function Ti(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...l(e)})}function wi(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...l(e)})}function bi(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...l(e)})}function Ei(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...l(e)})}function Ii(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...l(e)})}function zi(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...l(e)})}function $i(t,e){return new t({type:"string",format:"date",check:"string_format",...l(e)})}function Oi(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...l(e)})}function Pi(t,e){return new t({type:"string",format:"duration",check:"string_format",...l(e)})}function Si(t,e){return new t({type:"number",checks:[],...l(e)})}function Ni(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...l(e)})}function Ai(t){return new t({type:"unknown"})}function Zi(t,e){return new t({type:"never",...l(e)})}function lt(t,e){return new Ye({check:"less_than",...l(e),value:t,inclusive:!1})}function be(t,e){return new Ye({check:"less_than",...l(e),value:t,inclusive:!0})}function dt(t,e){return new qe({check:"greater_than",...l(e),value:t,inclusive:!1})}function Ee(t,e){return new qe({check:"greater_than",...l(e),value:t,inclusive:!0})}function ft(t,e){return new Xn({check:"multiple_of",...l(e),value:t})}function mt(t,e){return new Hn({check:"max_length",...l(e),maximum:t})}function ae(t,e){return new er({check:"min_length",...l(e),minimum:t})}function gt(t,e){return new tr({check:"length_equals",...l(e),length:t})}function Ci(t,e){return new nr({check:"string_format",format:"regex",...l(e),pattern:t})}function Ri(t){return new rr({check:"string_format",format:"lowercase",...l(t)})}function Li(t){return new ir({check:"string_format",format:"uppercase",...l(t)})}function Di(t,e){return new sr({check:"string_format",format:"includes",...l(e),includes:t})}function xi(t,e){return new or({check:"string_format",format:"starts_with",...l(e),prefix:t})}function Fi(t,e){return new ar({check:"string_format",format:"ends_with",...l(e),suffix:t})}function V(t){return new cr({check:"overwrite",tx:t})}function ji(t){return V(e=>e.normalize(t))}function Mi(){return V(t=>t.trim())}function Ui(){return V(t=>t.toLowerCase())}function Gi(){return V(t=>t.toUpperCase())}function Vi(){return V(t=>tn(t))}function Bi(t,e,n){return new t({type:"array",element:e,...l(n)})}function Ji(t,e,n){return new t({type:"custom",check:"custom",fn:e,...l(n)})}function Wi(t){const e=Ki(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(K(r,n.value,e._zod.def));else{const i=r;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),i.continue??(i.continue=!e._zod.def.abort),n.issues.push(K(i))}},t(n.value,n)));return e}function Ki(t,e){const n=new E({check:"custom",...l(e)});return n._zod.check=t,n}function vt(t){let e=t?.target??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:t.processors??{},metadataRegistry:t?.metadata??Y,target:e,unrepresentable:t?.unrepresentable??"throw",override:t?.override??(()=>{}),io:t?.io??"output",counter:0,seen:new Map,cycles:t?.cycles??"ref",reused:t?.reused??"inline",external:t?.external??void 0}}function w(t,e,n={path:[],schemaPath:[]}){var r;const i=t._zod.def,s=e.seen.get(t);if(s)return s.count++,n.schemaPath.includes(t)&&(s.cycle=n.path),s.schema;const o={schema:{},count:1,cycle:void 0,path:n.path};e.seen.set(t,o);const a=t._zod.toJSONSchema?.();if(a)o.schema=a;else{const p={...n,schemaPath:[...n.schemaPath,t],path:n.path},d=t._zod.parent;if(d)o.ref=d,w(d,e,p),e.seen.get(d).isParent=!0;else if(t._zod.processJSONSchema)t._zod.processJSONSchema(e,o.schema,p);else{const f=o.schema,_=e.processors[i.type];if(!_)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);_(t,e,f,p)}}const c=e.metadataRegistry.get(t);return c&&Object.assign(o.schema,c),e.io==="input"&&b(t)&&(delete o.schema.examples,delete o.schema.default),e.io==="input"&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,e.seen.get(t).schema}function _t(t,e){const n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=s=>{const o=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){const p=t.external.registry.get(s[0])?.id,d=t.external.uri??(_=>_);if(p)return{ref:d(p)};const f=s[1].defId??s[1].schema.id??`schema${t.counter++}`;return s[1].defId=f,{defId:f,ref:`${d("__shared")}#/${o}/${f}`}}if(s[1]===n)return{ref:"#"};const c=`#/${o}/`,h=s[1].schema.id??`__schema${t.counter++}`;return{defId:h,ref:c+h}},i=s=>{if(s[1].schema.$ref)return;const o=s[1],{ref:a,defId:c}=r(s);o.def={...o.schema},c&&(o.defId=c);const h=o.schema;for(const p in h)delete h[p];h.$ref=a};if(t.cycles==="throw")for(const s of t.seen.entries()){const o=s[1];if(o.cycle)throw new Error(`Cycle detected: #/${o.cycle?.join("/")}/<root>
|
|
32
32
|
|
|
33
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const s of t.seen.entries()){const o=s[1];if(e===s[0]){i(s);continue}if(t.external){const c=t.external.registry.get(s[0])?.id;if(e!==s[0]&&c){i(s);continue}}if(t.metadataRegistry.get(s[0])?.id){i(s);continue}if(o.cycle){i(s);continue}if(o.count>1&&t.reused==="ref"){i(s);continue}}}function kt(t,e){const n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=o=>{const a=t.seen.get(o),c=a.def??a.schema,h={...c};if(a.ref===null)return;const p=a.ref;if(a.ref=null,p){r(p);const d=t.seen.get(p).schema;d.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(d)):(Object.assign(c,d),Object.assign(c,h))}a.isParent||t.override({zodSchema:o,jsonSchema:c,path:a.path??[]})};for(const o of[...t.seen.entries()].reverse())r(o[0]);const i={};if(t.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":t.target,t.external?.uri){const o=t.external.registry.get(e)?.id;if(!o)throw new Error("Schema is missing an `id` property");i.$id=t.external.uri(o)}Object.assign(i,n.def??n.schema);const s=t.external?.defs??{};for(const o of t.seen.entries()){const a=o[1];a.def&&a.defId&&(s[a.defId]=a.def)}t.external||Object.keys(s).length>0&&(t.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const o=JSON.parse(JSON.stringify(i));return Object.defineProperty(o,"~standard",{value:{...e["~standard"],jsonSchema:{input:ce(e,"input"),output:ce(e,"output")}},enumerable:!1,writable:!1}),o}catch{throw new Error("Error converting schema to JSON.")}}function b(t,e){const n=e??{seen:new Set};if(n.seen.has(t))return!1;n.seen.add(t);const r=t._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return b(r.element,n);if(r.type==="set")return b(r.valueType,n);if(r.type==="lazy")return b(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return b(r.innerType,n);if(r.type==="intersection")return b(r.left,n)||b(r.right,n);if(r.type==="record"||r.type==="map")return b(r.keyType,n)||b(r.valueType,n);if(r.type==="pipe")return b(r.in,n)||b(r.out,n);if(r.type==="object"){for(const i in r.shape)if(b(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(b(i,n))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(b(i,n))return!0;return!!(r.rest&&b(r.rest,n))}return!1}const Yi=(t,e={})=>n=>{const r=vt({...n,processors:e});return w(t,r),_t(r,t),kt(r,t)},ce=(t,e)=>n=>{const{libraryOptions:r,target:i}=n??{},s=vt({...r??{},target:i,io:e,processors:{}});return w(t,s),_t(s,t),kt(s,t)},qi={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Xi=(t,e,n,r)=>{const i=n;i.type="string";const{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:h}=t._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof o=="number"&&(i.maxLength=o),a&&(i.format=qi[a]??a,i.format===""&&delete i.format),h&&(i.contentEncoding=h),c&&c.size>0){const p=[...c];p.length===1?i.pattern=p[0].source:p.length>1&&(i.allOf=[...p.map(d=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},Qi=(t,e,n,r)=>{const i=n,{minimum:s,maximum:o,format:a,multipleOf:c,exclusiveMaximum:h,exclusiveMinimum:p}=t._zod.bag;typeof a=="string"&&a.includes("int")?i.type="integer":i.type="number",typeof p=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(i.minimum=p,i.exclusiveMinimum=!0):i.exclusiveMinimum=p),typeof s=="number"&&(i.minimum=s,typeof p=="number"&&e.target!=="draft-04"&&(p>=s?delete i.minimum:delete i.exclusiveMinimum)),typeof h=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(i.maximum=h,i.exclusiveMaximum=!0):i.exclusiveMaximum=h),typeof o=="number"&&(i.maximum=o,typeof h=="number"&&e.target!=="draft-04"&&(h<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c=="number"&&(i.multipleOf=c)},Hi=(t,e,n,r)=>{n.not={}},es=(t,e,n,r)=>{},ts=(t,e,n,r)=>{const i=t._zod.def,s=Re(i.entries);s.every(o=>typeof o=="number")&&(n.type="number"),s.every(o=>typeof o=="string")&&(n.type="string"),n.enum=s},ns=(t,e,n,r)=>{const i=t._zod.def,s=[];for(const o of i.values)if(o===void 0){if(e.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(e.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(o))}else s.push(o);if(s.length!==0)if(s.length===1){const o=s[0];n.type=o===null?"null":typeof o,e.target==="draft-04"||e.target==="openapi-3.0"?n.enum=[o]:n.const=o}else s.every(o=>typeof o=="number")&&(n.type="number"),s.every(o=>typeof o=="string")&&(n.type="string"),s.every(o=>typeof o=="boolean")&&(n.type="boolean"),s.every(o=>o===null)&&(n.type="null"),n.enum=s},rs=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},is=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},ss=(t,e,n,r)=>{const i=n,s=t._zod.def,{minimum:o,maximum:a}=t._zod.bag;typeof o=="number"&&(i.minItems=o),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=w(s.element,e,{...r,path:[...r.path,"items"]})},os=(t,e,n,r)=>{const i=n,s=t._zod.def;i.type="object",i.properties={};const o=s.shape;for(const h in o)i.properties[h]=w(o[h],e,{...r,path:[...r.path,"properties",h]});const a=new Set(Object.keys(o)),c=new Set([...a].filter(h=>{const p=s.shape[h]._zod;return e.io==="input"?p.optin===void 0:p.optout===void 0}));c.size>0&&(i.required=Array.from(c)),s.catchall?._zod.def.type==="never"?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=w(s.catchall,e,{...r,path:[...r.path,"additionalProperties"]})):e.io==="output"&&(i.additionalProperties=!1)},as=(t,e,n,r)=>{const i=t._zod.def,s=i.inclusive===!1,o=i.options.map((a,c)=>w(a,e,{...r,path:[...r.path,s?"oneOf":"anyOf",c]}));s?n.oneOf=o:n.anyOf=o},cs=(t,e,n,r)=>{const i=t._zod.def,s=w(i.left,e,{...r,path:[...r.path,"allOf",0]}),o=w(i.right,e,{...r,path:[...r.path,"allOf",1]}),a=h=>"allOf"in h&&Object.keys(h).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];n.allOf=c},us=(t,e,n,r)=>{const i=t._zod.def,s=w(i.innerType,e,r),o=e.seen.get(t);e.target==="openapi-3.0"?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},hs=(t,e,n,r)=>{const i=t._zod.def;w(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType},ps=(t,e,n,r)=>{const i=t._zod.def;w(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},ls=(t,e,n,r)=>{const i=t._zod.def;w(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType,e.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},ds=(t,e,n,r)=>{const i=t._zod.def;w(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=o},fs=(t,e,n,r)=>{const i=t._zod.def,s=e.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;w(s,e,r);const o=e.seen.get(t);o.ref=s},ms=(t,e,n,r)=>{const i=t._zod.def;w(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType,n.readOnly=!0},gs=(t,e,n,r)=>{const i=t._zod.def;w(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType},vs=u("ZodISODateTime",(t,e)=>{wr.init(t,e),v.init(t,e)});function _s(t){return zi(vs,t)}const ks=u("ZodISODate",(t,e)=>{br.init(t,e),v.init(t,e)});function ys(t){return $i(ks,t)}const Ts=u("ZodISOTime",(t,e)=>{Er.init(t,e),v.init(t,e)});function ws(t){return Oi(Ts,t)}const bs=u("ZodISODuration",(t,e)=>{Ir.init(t,e),v.init(t,e)});function Es(t){return Pi(bs,t)}const z=u("ZodError",(t,e)=>{Ue.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:n=>mn(t,n)},flatten:{value:n=>fn(t,n)},addIssue:{value:n=>{t.issues.push(n),t.message=JSON.stringify(t.issues,me,2)}},addIssues:{value:n=>{t.issues.push(...n),t.message=JSON.stringify(t.issues,me,2)}},isEmpty:{get(){return t.issues.length===0}}})},{Parent:Error}),Is=ke(z),zs=ye(z),$s=ne(z),Os=re(z),Ps=_n(z),Ss=kn(z),Ns=yn(z),As=Tn(z),Zs=wn(z),Cs=bn(z),Rs=En(z),Ls=In(z),y=u("ZodType",(t,e)=>(k.init(t,e),Object.assign(t["~standard"],{jsonSchema:{input:ce(t,"input"),output:ce(t,"output")}}),t.toJSONSchema=Yi(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.check=(...n)=>t.clone(L(e,{checks:[...e.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]})),t.clone=(n,r)=>N(t,n,r),t.brand=()=>t,t.register=((n,r)=>(n.add(t,r),t)),t.parse=(n,r)=>Is(t,n,r,{callee:t.parse}),t.safeParse=(n,r)=>$s(t,n,r),t.parseAsync=async(n,r)=>zs(t,n,r,{callee:t.parseAsync}),t.safeParseAsync=async(n,r)=>Os(t,n,r),t.spa=t.safeParseAsync,t.encode=(n,r)=>Ps(t,n,r),t.decode=(n,r)=>Ss(t,n,r),t.encodeAsync=async(n,r)=>Ns(t,n,r),t.decodeAsync=async(n,r)=>As(t,n,r),t.safeEncode=(n,r)=>Zs(t,n,r),t.safeDecode=(n,r)=>Cs(t,n,r),t.safeEncodeAsync=async(n,r)=>Rs(t,n,r),t.safeDecodeAsync=async(n,r)=>Ls(t,n,r),t.refine=(n,r)=>t.check(Oo(n,r)),t.superRefine=n=>t.check(Po(n)),t.overwrite=n=>t.check(V(n)),t.optional=()=>Ot(t),t.nullable=()=>Pt(t),t.nullish=()=>Ot(Pt(t)),t.nonoptional=n=>To(t,n),t.array=()=>x(t),t.or=n=>he([t,n]),t.and=n=>po(t,n),t.transform=n=>Nt(t,mo(n)),t.default=n=>_o(t,n),t.prefault=n=>yo(t,n),t.catch=n=>bo(t,n),t.pipe=n=>Nt(t,n),t.readonly=()=>zo(t),t.describe=n=>{const r=t.clone();return Y.add(r,{description:n}),r},Object.defineProperty(t,"description",{get(){return Y.get(t)?.description},configurable:!0}),t.meta=(...n)=>{if(n.length===0)return Y.get(t);const r=t.clone();return Y.add(r,n[0]),r},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t)),yt=u("_ZodString",(t,e)=>{Te.init(t,e),y.init(t,e),t._zod.processJSONSchema=(r,i,s)=>Xi(t,r,i);const n=t._zod.bag;t.format=n.format??null,t.minLength=n.minimum??null,t.maxLength=n.maximum??null,t.regex=(...r)=>t.check(Ci(...r)),t.includes=(...r)=>t.check(Di(...r)),t.startsWith=(...r)=>t.check(xi(...r)),t.endsWith=(...r)=>t.check(Fi(...r)),t.min=(...r)=>t.check(ae(...r)),t.max=(...r)=>t.check(mt(...r)),t.length=(...r)=>t.check(gt(...r)),t.nonempty=(...r)=>t.check(ae(1,...r)),t.lowercase=r=>t.check(Ri(r)),t.uppercase=r=>t.check(Li(r)),t.trim=()=>t.check(Mi()),t.normalize=(...r)=>t.check(ji(...r)),t.toLowerCase=()=>t.check(Ui()),t.toUpperCase=()=>t.check(Gi()),t.slugify=()=>t.check(Vi())}),Ds=u("ZodString",(t,e)=>{Te.init(t,e),yt.init(t,e),t.email=n=>t.check(si(xs,n)),t.url=n=>t.check(hi(Fs,n)),t.jwt=n=>t.check(Ii(eo,n)),t.emoji=n=>t.check(pi(js,n)),t.guid=n=>t.check(pt(Tt,n)),t.uuid=n=>t.check(oi(ue,n)),t.uuidv4=n=>t.check(ai(ue,n)),t.uuidv6=n=>t.check(ci(ue,n)),t.uuidv7=n=>t.check(ui(ue,n)),t.nanoid=n=>t.check(li(Ms,n)),t.guid=n=>t.check(pt(Tt,n)),t.cuid=n=>t.check(di(Us,n)),t.cuid2=n=>t.check(fi(Gs,n)),t.ulid=n=>t.check(mi(Vs,n)),t.base64=n=>t.check(wi(Xs,n)),t.base64url=n=>t.check(bi(Qs,n)),t.xid=n=>t.check(gi(Bs,n)),t.ksuid=n=>t.check(vi(Js,n)),t.ipv4=n=>t.check(_i(Ws,n)),t.ipv6=n=>t.check(ki(Ks,n)),t.cidrv4=n=>t.check(yi(Ys,n)),t.cidrv6=n=>t.check(Ti(qs,n)),t.e164=n=>t.check(Ei(Hs,n)),t.datetime=n=>t.check(_s(n)),t.date=n=>t.check(ys(n)),t.time=n=>t.check(ws(n)),t.duration=n=>t.check(Es(n))});function O(t){return ii(Ds,t)}const v=u("ZodStringFormat",(t,e)=>{g.init(t,e),yt.init(t,e)}),xs=u("ZodEmail",(t,e)=>{dr.init(t,e),v.init(t,e)}),Tt=u("ZodGUID",(t,e)=>{pr.init(t,e),v.init(t,e)}),ue=u("ZodUUID",(t,e)=>{lr.init(t,e),v.init(t,e)}),Fs=u("ZodURL",(t,e)=>{fr.init(t,e),v.init(t,e)}),js=u("ZodEmoji",(t,e)=>{mr.init(t,e),v.init(t,e)}),Ms=u("ZodNanoID",(t,e)=>{gr.init(t,e),v.init(t,e)}),Us=u("ZodCUID",(t,e)=>{vr.init(t,e),v.init(t,e)}),Gs=u("ZodCUID2",(t,e)=>{_r.init(t,e),v.init(t,e)}),Vs=u("ZodULID",(t,e)=>{kr.init(t,e),v.init(t,e)}),Bs=u("ZodXID",(t,e)=>{yr.init(t,e),v.init(t,e)}),Js=u("ZodKSUID",(t,e)=>{Tr.init(t,e),v.init(t,e)}),Ws=u("ZodIPv4",(t,e)=>{zr.init(t,e),v.init(t,e)}),Ks=u("ZodIPv6",(t,e)=>{$r.init(t,e),v.init(t,e)}),Ys=u("ZodCIDRv4",(t,e)=>{Or.init(t,e),v.init(t,e)}),qs=u("ZodCIDRv6",(t,e)=>{Pr.init(t,e),v.init(t,e)}),Xs=u("ZodBase64",(t,e)=>{Sr.init(t,e),v.init(t,e)}),Qs=u("ZodBase64URL",(t,e)=>{Ar.init(t,e),v.init(t,e)}),Hs=u("ZodE164",(t,e)=>{Zr.init(t,e),v.init(t,e)}),eo=u("ZodJWT",(t,e)=>{Rr.init(t,e),v.init(t,e)}),wt=u("ZodNumber",(t,e)=>{Qe.init(t,e),y.init(t,e),t._zod.processJSONSchema=(r,i,s)=>Qi(t,r,i),t.gt=(r,i)=>t.check(dt(r,i)),t.gte=(r,i)=>t.check(Ee(r,i)),t.min=(r,i)=>t.check(Ee(r,i)),t.lt=(r,i)=>t.check(lt(r,i)),t.lte=(r,i)=>t.check(be(r,i)),t.max=(r,i)=>t.check(be(r,i)),t.int=r=>t.check(bt(r)),t.safe=r=>t.check(bt(r)),t.positive=r=>t.check(dt(0,r)),t.nonnegative=r=>t.check(Ee(0,r)),t.negative=r=>t.check(lt(0,r)),t.nonpositive=r=>t.check(be(0,r)),t.multipleOf=(r,i)=>t.check(ft(r,i)),t.step=(r,i)=>t.check(ft(r,i)),t.finite=()=>t;const n=t._zod.bag;t.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),t.isFinite=!0,t.format=n.format??null});function to(t){return Si(wt,t)}const no=u("ZodNumberFormat",(t,e)=>{Lr.init(t,e),wt.init(t,e)});function bt(t){return Ni(no,t)}const ro=u("ZodUnknown",(t,e)=>{Dr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>es()});function Et(){return Ai(ro)}const io=u("ZodNever",(t,e)=>{xr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>Hi(t,n,r)});function so(t){return Zi(io,t)}const oo=u("ZodArray",(t,e)=>{Fr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>ss(t,n,r,i),t.element=e.element,t.min=(n,r)=>t.check(ae(n,r)),t.nonempty=n=>t.check(ae(1,n)),t.max=(n,r)=>t.check(mt(n,r)),t.length=(n,r)=>t.check(gt(n,r)),t.unwrap=()=>t.element});function x(t,e){return Bi(oo,t,e)}const ao=u("ZodObject",(t,e)=>{Mr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>os(t,n,r,i),m(t,"shape",()=>e.shape),t.keyof=()=>zt(Object.keys(t._zod.def.shape)),t.catchall=n=>t.clone({...t._zod.def,catchall:n}),t.passthrough=()=>t.clone({...t._zod.def,catchall:Et()}),t.loose=()=>t.clone({...t._zod.def,catchall:Et()}),t.strict=()=>t.clone({...t._zod.def,catchall:so()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=n=>un(t,n),t.safeExtend=n=>hn(t,n),t.merge=n=>pn(t,n),t.pick=n=>an(t,n),t.omit=n=>cn(t,n),t.partial=(...n)=>ln($t,t,n[0]),t.required=(...n)=>dn(St,t,n[0])});function $(t,e){const n={type:"object",shape:t??{},...l(e)};return new ao(n)}const It=u("ZodUnion",(t,e)=>{rt.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>as(t,n,r,i),t.options=e.options});function he(t,e){return new It({type:"union",options:t,...l(e)})}const co=u("ZodDiscriminatedUnion",(t,e)=>{It.init(t,e),Ur.init(t,e)});function uo(t,e,n){return new co({type:"union",options:e,discriminator:t,...l(n)})}const ho=u("ZodIntersection",(t,e)=>{Gr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>cs(t,n,r,i)});function po(t,e){return new ho({type:"intersection",left:t,right:e})}const Ie=u("ZodEnum",(t,e)=>{Vr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(r,i,s)=>ts(t,r,i),t.enum=e.entries,t.options=Object.values(e.entries);const n=new Set(Object.keys(e.entries));t.extract=(r,i)=>{const s={};for(const o of r)if(n.has(o))s[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new Ie({...e,checks:[],...l(i),entries:s})},t.exclude=(r,i)=>{const s={...e.entries};for(const o of r)if(n.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new Ie({...e,checks:[],...l(i),entries:s})}});function zt(t,e){const n=Array.isArray(t)?Object.fromEntries(t.map(r=>[r,r])):t;return new Ie({type:"enum",entries:n,...l(e)})}const lo=u("ZodLiteral",(t,e)=>{Br.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>ns(t,n,r),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function A(t,e){return new lo({type:"literal",values:Array.isArray(t)?t:[t],...l(e)})}const fo=u("ZodTransform",(t,e)=>{Jr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>is(t,n),t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Ze(t.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(K(s,n.value,e));else{const o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),n.issues.push(K(o))}};const i=e.transform(n.value,n);return i instanceof Promise?i.then(s=>(n.value=s,n)):(n.value=i,n)}});function mo(t){return new fo({type:"transform",transform:t})}const $t=u("ZodOptional",(t,e)=>{Wr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>gs(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function Ot(t){return new $t({type:"optional",innerType:t})}const go=u("ZodNullable",(t,e)=>{Kr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>us(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function Pt(t){return new go({type:"nullable",innerType:t})}const vo=u("ZodDefault",(t,e)=>{Yr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>ps(t,n,r,i),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function _o(t,e){return new vo({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():Fe(e)}})}const ko=u("ZodPrefault",(t,e)=>{qr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>ls(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function yo(t,e){return new ko({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():Fe(e)}})}const St=u("ZodNonOptional",(t,e)=>{Xr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>hs(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function To(t,e){return new St({type:"nonoptional",innerType:t,...l(e)})}const wo=u("ZodCatch",(t,e)=>{Qr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>ds(t,n,r,i),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function bo(t,e){return new wo({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}const Eo=u("ZodPipe",(t,e)=>{Hr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>fs(t,n,r,i),t.in=e.in,t.out=e.out});function Nt(t,e){return new Eo({type:"pipe",in:t,out:e})}const Io=u("ZodReadonly",(t,e)=>{ei.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>ms(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function zo(t){return new Io({type:"readonly",innerType:t})}const $o=u("ZodCustom",(t,e)=>{ti.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>rs(t,n)});function Oo(t,e={}){return Ji($o,t,e)}function Po(t){return Wi(t)}const Z=he([O(),$({pattern:O(),flags:O().optional()})]),So=$({kind:A("fragment"),condition:Z.optional(),operator:he([O(),x(O())]).optional()}),ze=$({kind:A("participant"),name:Z.optional(),id:Z.optional(),stereotype:Z.optional()}),No=$({kind:A("message"),text:Z.optional(),from:Z.optional(),to:Z.optional()}),Ao=$({kind:A("group"),name:Z.optional()}),Zo=$({action:A("resolve"),selector:So}),Co=$({action:A("focus"),selector:ze}),Ro=$({action:A("remove"),selector:he([ze,No,Ao])}),Lo=$({action:A("merge"),newName:O(),selector:ze}),Do=uo("action",[Zo,Co,Ro,Lo]),xo=$({name:O(),suffix:O().optional(),layers:x(Do)}),At=zt(["mermaid","plantuml"]),Fo=$({input:x(O()),outputDir:O(),ignore:x(O()).optional(),lenses:x(xo),format:At.optional(),outputFormat:At.optional()}),Zt=$({version:to(),targets:x(Fo)});function jo(t){const e=Zt.safeParse(t);if(!e.success){const n=e.error.issues.map(r=>`[${r.path.join(".")}]: ${r.message}`).join(`
|
|
33
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const s of t.seen.entries()){const o=s[1];if(e===s[0]){i(s);continue}if(t.external){const c=t.external.registry.get(s[0])?.id;if(e!==s[0]&&c){i(s);continue}}if(t.metadataRegistry.get(s[0])?.id){i(s);continue}if(o.cycle){i(s);continue}if(o.count>1&&t.reused==="ref"){i(s);continue}}}function kt(t,e){const n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=o=>{const a=t.seen.get(o),c=a.def??a.schema,h={...c};if(a.ref===null)return;const p=a.ref;if(a.ref=null,p){r(p);const d=t.seen.get(p).schema;d.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(d)):(Object.assign(c,d),Object.assign(c,h))}a.isParent||t.override({zodSchema:o,jsonSchema:c,path:a.path??[]})};for(const o of[...t.seen.entries()].reverse())r(o[0]);const i={};if(t.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":t.target,t.external?.uri){const o=t.external.registry.get(e)?.id;if(!o)throw new Error("Schema is missing an `id` property");i.$id=t.external.uri(o)}Object.assign(i,n.def??n.schema);const s=t.external?.defs??{};for(const o of t.seen.entries()){const a=o[1];a.def&&a.defId&&(s[a.defId]=a.def)}t.external||Object.keys(s).length>0&&(t.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const o=JSON.parse(JSON.stringify(i));return Object.defineProperty(o,"~standard",{value:{...e["~standard"],jsonSchema:{input:ce(e,"input"),output:ce(e,"output")}},enumerable:!1,writable:!1}),o}catch{throw new Error("Error converting schema to JSON.")}}function b(t,e){const n=e??{seen:new Set};if(n.seen.has(t))return!1;n.seen.add(t);const r=t._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return b(r.element,n);if(r.type==="set")return b(r.valueType,n);if(r.type==="lazy")return b(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return b(r.innerType,n);if(r.type==="intersection")return b(r.left,n)||b(r.right,n);if(r.type==="record"||r.type==="map")return b(r.keyType,n)||b(r.valueType,n);if(r.type==="pipe")return b(r.in,n)||b(r.out,n);if(r.type==="object"){for(const i in r.shape)if(b(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(b(i,n))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(b(i,n))return!0;return!!(r.rest&&b(r.rest,n))}return!1}const Yi=(t,e={})=>n=>{const r=vt({...n,processors:e});return w(t,r),_t(r,t),kt(r,t)},ce=(t,e)=>n=>{const{libraryOptions:r,target:i}=n??{},s=vt({...r??{},target:i,io:e,processors:{}});return w(t,s),_t(s,t),kt(s,t)},qi={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Xi=(t,e,n,r)=>{const i=n;i.type="string";const{minimum:s,maximum:o,format:a,patterns:c,contentEncoding:h}=t._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof o=="number"&&(i.maxLength=o),a&&(i.format=qi[a]??a,i.format===""&&delete i.format),h&&(i.contentEncoding=h),c&&c.size>0){const p=[...c];p.length===1?i.pattern=p[0].source:p.length>1&&(i.allOf=[...p.map(d=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},Qi=(t,e,n,r)=>{const i=n,{minimum:s,maximum:o,format:a,multipleOf:c,exclusiveMaximum:h,exclusiveMinimum:p}=t._zod.bag;typeof a=="string"&&a.includes("int")?i.type="integer":i.type="number",typeof p=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(i.minimum=p,i.exclusiveMinimum=!0):i.exclusiveMinimum=p),typeof s=="number"&&(i.minimum=s,typeof p=="number"&&e.target!=="draft-04"&&(p>=s?delete i.minimum:delete i.exclusiveMinimum)),typeof h=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(i.maximum=h,i.exclusiveMaximum=!0):i.exclusiveMaximum=h),typeof o=="number"&&(i.maximum=o,typeof h=="number"&&e.target!=="draft-04"&&(h<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c=="number"&&(i.multipleOf=c)},Hi=(t,e,n,r)=>{n.not={}},es=(t,e,n,r)=>{},ts=(t,e,n,r)=>{const i=t._zod.def,s=Re(i.entries);s.every(o=>typeof o=="number")&&(n.type="number"),s.every(o=>typeof o=="string")&&(n.type="string"),n.enum=s},ns=(t,e,n,r)=>{const i=t._zod.def,s=[];for(const o of i.values)if(o===void 0){if(e.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(e.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(o))}else s.push(o);if(s.length!==0)if(s.length===1){const o=s[0];n.type=o===null?"null":typeof o,e.target==="draft-04"||e.target==="openapi-3.0"?n.enum=[o]:n.const=o}else s.every(o=>typeof o=="number")&&(n.type="number"),s.every(o=>typeof o=="string")&&(n.type="string"),s.every(o=>typeof o=="boolean")&&(n.type="boolean"),s.every(o=>o===null)&&(n.type="null"),n.enum=s},rs=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},is=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},ss=(t,e,n,r)=>{const i=n,s=t._zod.def,{minimum:o,maximum:a}=t._zod.bag;typeof o=="number"&&(i.minItems=o),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=w(s.element,e,{...r,path:[...r.path,"items"]})},os=(t,e,n,r)=>{const i=n,s=t._zod.def;i.type="object",i.properties={};const o=s.shape;for(const h in o)i.properties[h]=w(o[h],e,{...r,path:[...r.path,"properties",h]});const a=new Set(Object.keys(o)),c=new Set([...a].filter(h=>{const p=s.shape[h]._zod;return e.io==="input"?p.optin===void 0:p.optout===void 0}));c.size>0&&(i.required=Array.from(c)),s.catchall?._zod.def.type==="never"?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=w(s.catchall,e,{...r,path:[...r.path,"additionalProperties"]})):e.io==="output"&&(i.additionalProperties=!1)},as=(t,e,n,r)=>{const i=t._zod.def,s=i.inclusive===!1,o=i.options.map((a,c)=>w(a,e,{...r,path:[...r.path,s?"oneOf":"anyOf",c]}));s?n.oneOf=o:n.anyOf=o},cs=(t,e,n,r)=>{const i=t._zod.def,s=w(i.left,e,{...r,path:[...r.path,"allOf",0]}),o=w(i.right,e,{...r,path:[...r.path,"allOf",1]}),a=h=>"allOf"in h&&Object.keys(h).length===1,c=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];n.allOf=c},us=(t,e,n,r)=>{const i=t._zod.def,s=w(i.innerType,e,r),o=e.seen.get(t);e.target==="openapi-3.0"?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},hs=(t,e,n,r)=>{const i=t._zod.def;w(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType},ps=(t,e,n,r)=>{const i=t._zod.def;w(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},ls=(t,e,n,r)=>{const i=t._zod.def;w(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType,e.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},ds=(t,e,n,r)=>{const i=t._zod.def;w(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=o},fs=(t,e,n,r)=>{const i=t._zod.def,s=e.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;w(s,e,r);const o=e.seen.get(t);o.ref=s},ms=(t,e,n,r)=>{const i=t._zod.def;w(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType,n.readOnly=!0},gs=(t,e,n,r)=>{const i=t._zod.def;w(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType},vs=u("ZodISODateTime",(t,e)=>{wr.init(t,e),v.init(t,e)});function _s(t){return zi(vs,t)}const ks=u("ZodISODate",(t,e)=>{br.init(t,e),v.init(t,e)});function ys(t){return $i(ks,t)}const Ts=u("ZodISOTime",(t,e)=>{Er.init(t,e),v.init(t,e)});function ws(t){return Oi(Ts,t)}const bs=u("ZodISODuration",(t,e)=>{Ir.init(t,e),v.init(t,e)});function Es(t){return Pi(bs,t)}const O=u("ZodError",(t,e)=>{Ue.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:n=>mn(t,n)},flatten:{value:n=>fn(t,n)},addIssue:{value:n=>{t.issues.push(n),t.message=JSON.stringify(t.issues,me,2)}},addIssues:{value:n=>{t.issues.push(...n),t.message=JSON.stringify(t.issues,me,2)}},isEmpty:{get(){return t.issues.length===0}}})},{Parent:Error}),Is=ke(O),zs=ye(O),$s=ne(O),Os=re(O),Ps=_n(O),Ss=kn(O),Ns=yn(O),As=Tn(O),Zs=wn(O),Cs=bn(O),Rs=En(O),Ls=In(O),y=u("ZodType",(t,e)=>(k.init(t,e),Object.assign(t["~standard"],{jsonSchema:{input:ce(t,"input"),output:ce(t,"output")}}),t.toJSONSchema=Yi(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.check=(...n)=>t.clone(L(e,{checks:[...e.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]})),t.clone=(n,r)=>N(t,n,r),t.brand=()=>t,t.register=((n,r)=>(n.add(t,r),t)),t.parse=(n,r)=>Is(t,n,r,{callee:t.parse}),t.safeParse=(n,r)=>$s(t,n,r),t.parseAsync=async(n,r)=>zs(t,n,r,{callee:t.parseAsync}),t.safeParseAsync=async(n,r)=>Os(t,n,r),t.spa=t.safeParseAsync,t.encode=(n,r)=>Ps(t,n,r),t.decode=(n,r)=>Ss(t,n,r),t.encodeAsync=async(n,r)=>Ns(t,n,r),t.decodeAsync=async(n,r)=>As(t,n,r),t.safeEncode=(n,r)=>Zs(t,n,r),t.safeDecode=(n,r)=>Cs(t,n,r),t.safeEncodeAsync=async(n,r)=>Rs(t,n,r),t.safeDecodeAsync=async(n,r)=>Ls(t,n,r),t.refine=(n,r)=>t.check(Oo(n,r)),t.superRefine=n=>t.check(Po(n)),t.overwrite=n=>t.check(V(n)),t.optional=()=>Ot(t),t.nullable=()=>Pt(t),t.nullish=()=>Ot(Pt(t)),t.nonoptional=n=>To(t,n),t.array=()=>x(t),t.or=n=>he([t,n]),t.and=n=>po(t,n),t.transform=n=>Nt(t,mo(n)),t.default=n=>_o(t,n),t.prefault=n=>yo(t,n),t.catch=n=>bo(t,n),t.pipe=n=>Nt(t,n),t.readonly=()=>zo(t),t.describe=n=>{const r=t.clone();return Y.add(r,{description:n}),r},Object.defineProperty(t,"description",{get(){return Y.get(t)?.description},configurable:!0}),t.meta=(...n)=>{if(n.length===0)return Y.get(t);const r=t.clone();return Y.add(r,n[0]),r},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t)),yt=u("_ZodString",(t,e)=>{Te.init(t,e),y.init(t,e),t._zod.processJSONSchema=(r,i,s)=>Xi(t,r,i);const n=t._zod.bag;t.format=n.format??null,t.minLength=n.minimum??null,t.maxLength=n.maximum??null,t.regex=(...r)=>t.check(Ci(...r)),t.includes=(...r)=>t.check(Di(...r)),t.startsWith=(...r)=>t.check(xi(...r)),t.endsWith=(...r)=>t.check(Fi(...r)),t.min=(...r)=>t.check(ae(...r)),t.max=(...r)=>t.check(mt(...r)),t.length=(...r)=>t.check(gt(...r)),t.nonempty=(...r)=>t.check(ae(1,...r)),t.lowercase=r=>t.check(Ri(r)),t.uppercase=r=>t.check(Li(r)),t.trim=()=>t.check(Mi()),t.normalize=(...r)=>t.check(ji(...r)),t.toLowerCase=()=>t.check(Ui()),t.toUpperCase=()=>t.check(Gi()),t.slugify=()=>t.check(Vi())}),Ds=u("ZodString",(t,e)=>{Te.init(t,e),yt.init(t,e),t.email=n=>t.check(si(xs,n)),t.url=n=>t.check(hi(Fs,n)),t.jwt=n=>t.check(Ii(eo,n)),t.emoji=n=>t.check(pi(js,n)),t.guid=n=>t.check(pt(Tt,n)),t.uuid=n=>t.check(oi(ue,n)),t.uuidv4=n=>t.check(ai(ue,n)),t.uuidv6=n=>t.check(ci(ue,n)),t.uuidv7=n=>t.check(ui(ue,n)),t.nanoid=n=>t.check(li(Ms,n)),t.guid=n=>t.check(pt(Tt,n)),t.cuid=n=>t.check(di(Us,n)),t.cuid2=n=>t.check(fi(Gs,n)),t.ulid=n=>t.check(mi(Vs,n)),t.base64=n=>t.check(wi(Xs,n)),t.base64url=n=>t.check(bi(Qs,n)),t.xid=n=>t.check(gi(Bs,n)),t.ksuid=n=>t.check(vi(Js,n)),t.ipv4=n=>t.check(_i(Ws,n)),t.ipv6=n=>t.check(ki(Ks,n)),t.cidrv4=n=>t.check(yi(Ys,n)),t.cidrv6=n=>t.check(Ti(qs,n)),t.e164=n=>t.check(Ei(Hs,n)),t.datetime=n=>t.check(_s(n)),t.date=n=>t.check(ys(n)),t.time=n=>t.check(ws(n)),t.duration=n=>t.check(Es(n))});function I(t){return ii(Ds,t)}const v=u("ZodStringFormat",(t,e)=>{g.init(t,e),yt.init(t,e)}),xs=u("ZodEmail",(t,e)=>{dr.init(t,e),v.init(t,e)}),Tt=u("ZodGUID",(t,e)=>{pr.init(t,e),v.init(t,e)}),ue=u("ZodUUID",(t,e)=>{lr.init(t,e),v.init(t,e)}),Fs=u("ZodURL",(t,e)=>{fr.init(t,e),v.init(t,e)}),js=u("ZodEmoji",(t,e)=>{mr.init(t,e),v.init(t,e)}),Ms=u("ZodNanoID",(t,e)=>{gr.init(t,e),v.init(t,e)}),Us=u("ZodCUID",(t,e)=>{vr.init(t,e),v.init(t,e)}),Gs=u("ZodCUID2",(t,e)=>{_r.init(t,e),v.init(t,e)}),Vs=u("ZodULID",(t,e)=>{kr.init(t,e),v.init(t,e)}),Bs=u("ZodXID",(t,e)=>{yr.init(t,e),v.init(t,e)}),Js=u("ZodKSUID",(t,e)=>{Tr.init(t,e),v.init(t,e)}),Ws=u("ZodIPv4",(t,e)=>{zr.init(t,e),v.init(t,e)}),Ks=u("ZodIPv6",(t,e)=>{$r.init(t,e),v.init(t,e)}),Ys=u("ZodCIDRv4",(t,e)=>{Or.init(t,e),v.init(t,e)}),qs=u("ZodCIDRv6",(t,e)=>{Pr.init(t,e),v.init(t,e)}),Xs=u("ZodBase64",(t,e)=>{Sr.init(t,e),v.init(t,e)}),Qs=u("ZodBase64URL",(t,e)=>{Ar.init(t,e),v.init(t,e)}),Hs=u("ZodE164",(t,e)=>{Zr.init(t,e),v.init(t,e)}),eo=u("ZodJWT",(t,e)=>{Rr.init(t,e),v.init(t,e)}),wt=u("ZodNumber",(t,e)=>{Qe.init(t,e),y.init(t,e),t._zod.processJSONSchema=(r,i,s)=>Qi(t,r,i),t.gt=(r,i)=>t.check(dt(r,i)),t.gte=(r,i)=>t.check(Ee(r,i)),t.min=(r,i)=>t.check(Ee(r,i)),t.lt=(r,i)=>t.check(lt(r,i)),t.lte=(r,i)=>t.check(be(r,i)),t.max=(r,i)=>t.check(be(r,i)),t.int=r=>t.check(bt(r)),t.safe=r=>t.check(bt(r)),t.positive=r=>t.check(dt(0,r)),t.nonnegative=r=>t.check(Ee(0,r)),t.negative=r=>t.check(lt(0,r)),t.nonpositive=r=>t.check(be(0,r)),t.multipleOf=(r,i)=>t.check(ft(r,i)),t.step=(r,i)=>t.check(ft(r,i)),t.finite=()=>t;const n=t._zod.bag;t.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),t.isFinite=!0,t.format=n.format??null});function to(t){return Si(wt,t)}const no=u("ZodNumberFormat",(t,e)=>{Lr.init(t,e),wt.init(t,e)});function bt(t){return Ni(no,t)}const ro=u("ZodUnknown",(t,e)=>{Dr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>es()});function Et(){return Ai(ro)}const io=u("ZodNever",(t,e)=>{xr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>Hi(t,n,r)});function so(t){return Zi(io,t)}const oo=u("ZodArray",(t,e)=>{Fr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>ss(t,n,r,i),t.element=e.element,t.min=(n,r)=>t.check(ae(n,r)),t.nonempty=n=>t.check(ae(1,n)),t.max=(n,r)=>t.check(mt(n,r)),t.length=(n,r)=>t.check(gt(n,r)),t.unwrap=()=>t.element});function x(t,e){return Bi(oo,t,e)}const ao=u("ZodObject",(t,e)=>{Mr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>os(t,n,r,i),m(t,"shape",()=>e.shape),t.keyof=()=>zt(Object.keys(t._zod.def.shape)),t.catchall=n=>t.clone({...t._zod.def,catchall:n}),t.passthrough=()=>t.clone({...t._zod.def,catchall:Et()}),t.loose=()=>t.clone({...t._zod.def,catchall:Et()}),t.strict=()=>t.clone({...t._zod.def,catchall:so()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=n=>un(t,n),t.safeExtend=n=>hn(t,n),t.merge=n=>pn(t,n),t.pick=n=>an(t,n),t.omit=n=>cn(t,n),t.partial=(...n)=>ln($t,t,n[0]),t.required=(...n)=>dn(St,t,n[0])});function z(t,e){const n={type:"object",shape:t??{},...l(e)};return new ao(n)}const It=u("ZodUnion",(t,e)=>{rt.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>as(t,n,r,i),t.options=e.options});function he(t,e){return new It({type:"union",options:t,...l(e)})}const co=u("ZodDiscriminatedUnion",(t,e)=>{It.init(t,e),Ur.init(t,e)});function uo(t,e,n){return new co({type:"union",options:e,discriminator:t,...l(n)})}const ho=u("ZodIntersection",(t,e)=>{Gr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>cs(t,n,r,i)});function po(t,e){return new ho({type:"intersection",left:t,right:e})}const Ie=u("ZodEnum",(t,e)=>{Vr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(r,i,s)=>ts(t,r,i),t.enum=e.entries,t.options=Object.values(e.entries);const n=new Set(Object.keys(e.entries));t.extract=(r,i)=>{const s={};for(const o of r)if(n.has(o))s[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new Ie({...e,checks:[],...l(i),entries:s})},t.exclude=(r,i)=>{const s={...e.entries};for(const o of r)if(n.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new Ie({...e,checks:[],...l(i),entries:s})}});function zt(t,e){const n=Array.isArray(t)?Object.fromEntries(t.map(r=>[r,r])):t;return new Ie({type:"enum",entries:n,...l(e)})}const lo=u("ZodLiteral",(t,e)=>{Br.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>ns(t,n,r),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function A(t,e){return new lo({type:"literal",values:Array.isArray(t)?t:[t],...l(e)})}const fo=u("ZodTransform",(t,e)=>{Jr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>is(t,n),t._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Ze(t.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(K(s,n.value,e));else{const o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),n.issues.push(K(o))}};const i=e.transform(n.value,n);return i instanceof Promise?i.then(s=>(n.value=s,n)):(n.value=i,n)}});function mo(t){return new fo({type:"transform",transform:t})}const $t=u("ZodOptional",(t,e)=>{Wr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>gs(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function Ot(t){return new $t({type:"optional",innerType:t})}const go=u("ZodNullable",(t,e)=>{Kr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>us(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function Pt(t){return new go({type:"nullable",innerType:t})}const vo=u("ZodDefault",(t,e)=>{Yr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>ps(t,n,r,i),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function _o(t,e){return new vo({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():Fe(e)}})}const ko=u("ZodPrefault",(t,e)=>{qr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>ls(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function yo(t,e){return new ko({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():Fe(e)}})}const St=u("ZodNonOptional",(t,e)=>{Xr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>hs(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function To(t,e){return new St({type:"nonoptional",innerType:t,...l(e)})}const wo=u("ZodCatch",(t,e)=>{Qr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>ds(t,n,r,i),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function bo(t,e){return new wo({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}const Eo=u("ZodPipe",(t,e)=>{Hr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>fs(t,n,r,i),t.in=e.in,t.out=e.out});function Nt(t,e){return new Eo({type:"pipe",in:t,out:e})}const Io=u("ZodReadonly",(t,e)=>{ei.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>ms(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function zo(t){return new Io({type:"readonly",innerType:t})}const $o=u("ZodCustom",(t,e)=>{ti.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>rs(t,n)});function Oo(t,e={}){return Ji($o,t,e)}function Po(t){return Wi(t)}const Z=he([I(),z({pattern:I(),flags:I().optional()})]),So=z({kind:A("fragment"),condition:Z.optional(),operator:he([I(),x(I())]).optional()}),ze=z({kind:A("participant"),name:Z.optional(),id:Z.optional(),stereotype:Z.optional()}),No=z({kind:A("message"),text:Z.optional(),from:Z.optional(),to:Z.optional()}),Ao=z({kind:A("group"),name:Z.optional()}),Zo=z({action:A("resolve"),selector:So}),Co=z({action:A("focus"),selector:ze}),Ro=z({action:A("remove"),selector:he([ze,No,Ao])}),Lo=z({action:A("merge"),into:z({name:I().optional(),id:I().optional(),stereotype:I().optional()}).optional(),selector:ze}),Do=uo("action",[Zo,Co,Ro,Lo]),xo=z({name:I(),suffix:I().optional(),layers:x(Do)}),At=zt(["mermaid","plantuml"]),Fo=z({input:x(I()),outputDir:I(),ignore:x(I()).optional(),lenses:x(xo),format:At.optional(),outputFormat:At.optional()}),Zt=z({version:to(),targets:x(Fo)});function jo(t){const e=Zt.safeParse(t);if(!e.success){const n=e.error.issues.map(r=>`[${r.path.join(".")}]: ${r.message}`).join(`
|
|
34
34
|
`);throw new Error(`Invalid Polagram Configuration:
|
|
35
35
|
${n}`)}return e.data}T.FormatDetector=fe,T.GeneratorFactory=Ht,T.MermaidGeneratorVisitor=le,T.ParserFactory=Se,T.PlantUMLGeneratorVisitor=de,T.Polagram=Qt,T.PolagramBuilder=Ae,T.PolagramConfigSchema=Zt,T.TransformationEngine=H,T.Traverser=pe,T.transformerRegistry=Ne,T.validateConfig=jo,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})}));
|