@polagram/core 0.1.1 → 0.2.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.
@@ -1,35 +1,35 @@
1
- (function(T,x){typeof exports=="object"&&typeof module<"u"?x(exports):typeof define=="function"&&define.amd?define(["exports"],x):(T=typeof globalThis<"u"?globalThis:T||self,x(T.PolagramCore={}))})(this,(function(T){"use strict";const x={"->":{type:"sync",style:{line:"solid",head:"open"}},"->>":{type:"sync",style:{line:"solid",head:"arrow"}},"-->":{type:"reply",style:{line:"dotted",head:"open"}},"-->>":{type:"reply",style:{line:"dotted",head:"arrow"}},"-)":{type:"async",style:{line:"solid",head:"async"}},"--)":{type:"async",style:{line:"dotted",head:"async"}},"-x":{type:"destroy",style:{line:"solid",head:"cross"}},"--x":{type:"destroy",style:{line:"dotted",head:"cross"}}},Ct=Object.entries(x).reduce((t,[e,n])=>{const r=JSON.stringify({type:n.type,style:n.style});return t[r]=e,t},{});function Rt(t,e){const n=JSON.stringify({type:t,style:e});return Ct[n]||"->>"}class ue{constructor(e){this.visitor=e}traverse(e){this.visitor.visitRoot(e)}dispatchEvent(e){switch(e.kind){case"message":this.visitor.visitMessage(e);break;case"fragment":this.visitor.visitFragment(e);break;case"note":this.visitor.visitNote(e);break;case"activation":this.visitor.visitActivation(e);break;case"divider":this.visitor.visitDivider(e);break;case"spacer":this.visitor.visitSpacer(e);break;case"ref":this.visitor.visitReference(e);break}}dispatchEvents(e){for(const n of e)this.dispatchEvent(n)}}class he{lines=[];indentLevel=0;traverser;constructor(){this.traverser=new ue(this)}generate(e){return this.lines=[],this.indentLevel=0,this.traverser.traverse(e),this.lines.join(`
2
- `)}visitRoot(e){this.lines.push("sequenceDiagram"),this.indentLevel++,e.meta?.title&&this.add(`title ${e.meta.title}`);for(const n of e.participants)this.visitParticipant(n);this.traverser.dispatchEvents(e.events)}visitParticipant(e){const n=e.type==="actor"?"actor":"participant",r=e.name;e.id===e.name?this.add(`${n} ${e.id}`):this.add(`${n} ${e.id} as ${r}`)}visitParticipantGroup(e){let n="box";e.style?.backgroundColor&&(n+=` ${e.style.backgroundColor}`),e.name&&(n+=` ${e.name}`),this.add(n)}visitMessage(e){const n=e.from??"[*]",r=e.to??"[*]",i=Rt(e.type,e.style);let s="";e.lifecycle?.activateTarget&&(s+="+"),e.lifecycle?.deactivateSource&&(s+="-"),this.add(`${n}${i}${s}${r}: ${e.text}`)}visitFragment(e){if(e.branches.length===0)return;const n=e.branches[0],r=n.condition?` ${n.condition}`:"";this.add(`${e.operator}${r}`),this.indent(()=>{this.traverser.dispatchEvents(n.events)});let i="else";e.operator==="par"?i="and":e.operator==="critical"&&(i="option");for(let s=1;s<e.branches.length;s++){const o=e.branches[s],a=o.condition?` ${o.condition}`:"";this.add(`${i}${a}`),this.indent(()=>{this.traverser.dispatchEvents(o.events)})}this.add("end")}visitNote(e){const n=e.position;let r="";e.participantIds.length>0&&(r=e.participantIds.join(","),n!=="over"?r=` of ${r}`:r=` ${r}`),this.add(`note ${n}${r}: ${e.text}`)}visitActivation(e){this.add(`${e.action} ${e.participantId}`)}visitDivider(e){this.add(`%% == ${e.text||""} ==`)}visitSpacer(e){this.add(`...${e.text||""}...`)}visitReference(e){this.add(`%% ref: ${e.text}`)}add(e){const n=" ".repeat(this.indentLevel);this.lines.push(`${n}${e}`)}indent(e){this.indentLevel++,e(),this.indentLevel--}}class le{lines=[];traverser;constructor(){this.traverser=new ue(this)}generate(e){return this.lines=[],this.traverser.traverse(e),this.lines.join(`
3
- `)}visitRoot(e){this.add("@startuml"),e.meta.title&&this.add(`title ${e.meta.title}`);const n=new Map(e.participants.map(i=>[i.id,i])),r=new Set;for(const i of e.groups)this.visitGroup(i,n),i.participantIds.forEach(s=>{r.add(s)});for(const i of e.participants)r.has(i.id)||this.visitParticipant(i);this.traverser.dispatchEvents(e.events),this.add("@enduml")}visitParticipant(e){e.name===e.id?this.add(`${e.type} ${e.id}`):this.add(`${e.type} "${e.name}" as ${e.id}`)}visitParticipantGroup(e){}visitGroup(e,n){const r=e.style?.backgroundColor?` ${e.style.backgroundColor}`:"",i=e.name?` "${e.name}"`:"";this.add(`box${i}${r}`);for(const s of e.participantIds){const o=n.get(s);o&&this.visitParticipant(o)}this.add("end box")}visitMessage(e){const n=e.from||"[*]",r=e.to||"[*]";let i="->";e.type==="reply"?i="-->":e.type==="async"&&(i="->>"),this.add(`${n} ${i} ${r}: ${e.text}`)}visitFragment(e){const n=e.operator;e.branches.forEach((r,i)=>{i===0?this.add(`${n} ${r.condition||""}`.trim()):this.add(`else ${r.condition||""}`.trim()),this.traverser.dispatchEvents(r.events)}),this.add("end")}visitNote(e){const n=e.position||"over",r=e.participantIds.join(", ");let i="";e.participantIds.length>0?n==="over"?i=`note over ${r}`:i=`note ${n} of ${r}`:i=`note ${n}`,this.add(i),e.text.split(`
1
+ (function(T,F){typeof exports=="object"&&typeof module<"u"?F(exports):typeof define=="function"&&define.amd?define(["exports"],F):(T=typeof globalThis<"u"?globalThis:T||self,F(T.PolagramCore={}))})(this,(function(T){"use strict";const F={"->":{type:"sync",style:{line:"solid",head:"open"}},"->>":{type:"sync",style:{line:"solid",head:"arrow"}},"-->":{type:"reply",style:{line:"dotted",head:"open"}},"-->>":{type:"reply",style:{line:"dotted",head:"arrow"}},"-)":{type:"async",style:{line:"solid",head:"async"}},"--)":{type:"async",style:{line:"dotted",head:"async"}},"-x":{type:"destroy",style:{line:"solid",head:"cross"}},"--x":{type:"destroy",style:{line:"dotted",head:"cross"}}},Rt=Object.entries(F).reduce((t,[e,n])=>{const r=JSON.stringify({type:n.type,style:n.style});return t[r]=e,t},{});function Lt(t,e){const n=JSON.stringify({type:t,style:e});return Rt[n]||"->>"}class pe{constructor(e){this.visitor=e}traverse(e){this.visitor.visitRoot(e)}dispatchEvent(e){switch(e.kind){case"message":this.visitor.visitMessage(e);break;case"fragment":this.visitor.visitFragment(e);break;case"note":this.visitor.visitNote(e);break;case"activation":this.visitor.visitActivation(e);break;case"divider":this.visitor.visitDivider(e);break;case"spacer":this.visitor.visitSpacer(e);break;case"ref":this.visitor.visitReference(e);break}}dispatchEvents(e){for(const n of e)this.dispatchEvent(n)}}class le{lines=[];indentLevel=0;traverser;constructor(){this.traverser=new pe(this)}visitParticipantGroup(e){}generate(e){return this.lines=[],this.indentLevel=0,this.traverser.traverse(e),this.lines.join(`
2
+ `)}visitRoot(e){this.lines.push("sequenceDiagram"),this.indentLevel++,e.meta?.title&&this.add(`title ${e.meta.title}`);const n=new Map;for(const i of e.participants)n.set(i.id,[]);for(const i of e.groups)for(const s of i.participantIds){const o=n.get(s);o&&o.push(i)}const r=[];for(const i of e.participants){const s=n.get(i.id)||[];let o=0;const a=Math.min(r.length,s.length);for(let c=0;c<a&&r[c]===s[c];c++)o++;for(;r.length>o;)this.indentLevel--,this.add("end"),r.pop();for(let c=o;c<s.length;c++){const h=s[c];let p="box";h.style?.backgroundColor&&(p+=` ${h.style.backgroundColor}`),h.name&&(p+=` ${h.name}`),this.add(p),this.indentLevel++,r.push(h)}this.visitParticipant(i)}for(;r.length>0;)this.indentLevel--,this.add("end"),r.pop();this.traverser.dispatchEvents(e.events)}visitParticipant(e){const n=e.type==="actor"?"actor":"participant",r=e.name;e.id===e.name?this.add(`${n} ${e.id}`):this.add(`${n} ${e.id} as ${r}`)}visitMessage(e){const n=e.from??"[*]",r=e.to??"[*]",i=Lt(e.type,e.style);let s="";e.lifecycle?.activateTarget&&(s+="+"),e.lifecycle?.deactivateSource&&(s+="-"),this.add(`${n}${i}${s}${r}: ${e.text}`)}visitFragment(e){if(e.branches.length===0)return;const n=e.branches[0],r=n.condition?` ${n.condition}`:"";this.add(`${e.operator}${r}`),this.indent(()=>{this.traverser.dispatchEvents(n.events)});let i="else";e.operator==="par"?i="and":e.operator==="critical"&&(i="option");for(let s=1;s<e.branches.length;s++){const o=e.branches[s],a=o.condition?` ${o.condition}`:"";this.add(`${i}${a}`),this.indent(()=>{this.traverser.dispatchEvents(o.events)})}this.add("end")}visitNote(e){const n=e.position;let r="";e.participantIds.length>0&&(r=e.participantIds.join(","),n!=="over"?r=` of ${r}`:r=` ${r}`),this.add(`note ${n}${r}: ${e.text}`)}visitActivation(e){this.add(`${e.action} ${e.participantId}`)}visitDivider(e){this.add(`%% == ${e.text||""} ==`)}visitSpacer(e){this.add(`...${e.text||""}...`)}visitReference(e){this.add(`%% ref: ${e.text}`)}add(e){const n=" ".repeat(this.indentLevel);this.lines.push(`${n}${e}`)}indent(e){this.indentLevel++,e(),this.indentLevel--}}class de{lines=[];traverser;constructor(){this.traverser=new pe(this)}generate(e){return this.lines=[],this.traverser.traverse(e),this.lines.join(`
3
+ `)}visitRoot(e){this.add("@startuml"),e.meta.title&&this.add(`title ${e.meta.title}`);const n=new Map;for(const i of e.participants)n.set(i.id,[]);for(const i of e.groups)for(const s of i.participantIds){const o=n.get(s);o&&o.push(i)}const r=[];for(const i of e.participants){const s=n.get(i.id)||[];let o=0;const a=Math.min(r.length,s.length);for(let c=0;c<a&&r[c]===s[c];c++)o++;for(;r.length>o;)this.add("end box"),r.pop();for(let c=o;c<s.length;c++){const h=s[c],p=h.style?.backgroundColor?` ${h.style.backgroundColor}`:"",d=h.name?` "${h.name}"`:"";this.add(`box${d}${p}`),r.push(h)}this.visitParticipant(i)}for(;r.length>0;)this.add("end box"),r.pop();this.traverser.dispatchEvents(e.events),this.add("@enduml")}visitParticipant(e){e.name===e.id?this.add(`${e.type} ${e.id}`):this.add(`${e.type} "${e.name}" as ${e.id}`)}visitParticipantGroup(e){}visitMessage(e){const n=e.from||"[*]",r=e.to||"[*]";let i="->";e.type==="reply"?i="-->":e.type==="async"&&(i="->>"),this.add(`${n} ${i} ${r}: ${e.text}`)}visitFragment(e){const n=e.operator;e.branches.forEach((r,i)=>{i===0?this.add(`${n} ${r.condition||""}`.trim()):this.add(`else ${r.condition||""}`.trim()),this.traverser.dispatchEvents(r.events)}),this.add("end")}visitNote(e){const n=e.position||"over",r=e.participantIds.join(", ");let i="";e.participantIds.length>0?n==="over"?i=`note over ${r}`:i=`note ${n} of ${r}`:i=`note ${n}`,this.add(i),e.text.split(`
4
4
  `).forEach(s=>{this.add(` ${s}`)}),this.add("end note")}visitActivation(e){this.add(`${e.action} ${e.participantId}`)}visitDivider(e){e.text?this.add(`== ${e.text} ==`):this.add("====")}visitSpacer(e){this.add("|||")}visitReference(e){const n=e.participantIds.join(", ");this.add(`ref over ${n}: ${e.text}`)}add(e){this.lines.push(e)}}class Oe{constructor(e){this.input=e,this.readChar()}position=0;readPosition=0;ch="";line=1;column=0;getInput(){return this.input}readChar(){this.readPosition>=this.input.length?this.ch="":this.ch=this.input[this.readPosition],this.position=this.readPosition,this.readPosition+=1,this.column+=1,this.ch===`
5
5
  `&&(this.line+=1,this.column=0)}peekChar(){return this.readPosition>=this.input.length?"":this.input[this.readPosition]}skipWhitespace(){for(;this.ch===" "||this.ch===" "||this.ch==="\r";)this.readChar()}readWhile(e){const n=this.position;for(;e(this.ch);)this.readChar();return this.input.slice(n,this.position)}isLetter(e){return"a"<=e&&e<="z"||"A"<=e&&e<="Z"||e==="_"?!0:e.charCodeAt(0)>127?!/[\s\d]/.test(e):!1}isDigit(e){return"0"<=e&&e<="9"}readIdentifier(){const e=this.position;for(;this.isLetter(this.ch)||this.isDigit(this.ch);)this.readChar();return this.input.slice(e,this.position)}readQuotedString(){const e=this.position+1;for(this.readChar();this.ch!=='"'&&this.ch!==""&&this.ch!==`
6
- `;)this.readChar();const n=this.input.slice(e,this.position);return this.readChar(),n}createToken(e,n,r,i){return{type:e,literal:n,line:this.line,column:i,start:r,end:this.position>r?this.position:r+n.length}}}let Lt=class extends Oe{nextToken(){if(this.skipWhitespace(),this.ch==="%"&&this.peekChar()==="%")return this.skipComment(),this.nextToken();const e=this.position,n=this.column;let r;switch(this.ch){case":":r=this.newToken("COLON",this.ch,e,n);break;case",":r=this.newToken("COMMA",this.ch,e,n);break;case"+":r=this.newToken("PLUS",this.ch,e,n);break;case"-":if(this.isArrowStart()){const i=this.readArrow();return r=this.newToken("ARROW",i,e,n),r}else r=this.newToken("MINUS",this.ch,e,n);break;case'"':{const i=this.readString();return r=this.newToken("STRING",i,e,n),r}case`
6
+ `;)this.readChar();const n=this.input.slice(e,this.position);return this.readChar(),n}createToken(e,n,r,i){return{type:e,literal:n,line:this.line,column:i,start:r,end:this.position>r?this.position:r+n.length}}}let Dt=class extends Oe{nextToken(){if(this.skipWhitespace(),this.ch==="%"&&this.peekChar()==="%")return this.skipComment(),this.nextToken();const e=this.position,n=this.column;let r;switch(this.ch){case":":r=this.newToken("COLON",this.ch,e,n);break;case",":r=this.newToken("COMMA",this.ch,e,n);break;case"+":r=this.newToken("PLUS",this.ch,e,n);break;case"-":if(this.isArrowStart()){const i=this.readArrow();return r=this.newToken("ARROW",i,e,n),r}else r=this.newToken("MINUS",this.ch,e,n);break;case'"':{const i=this.readString();return r=this.newToken("STRING",i,e,n),r}case`
7
7
  `:r=this.newToken("NEWLINE",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 if(this.isDigit(this.ch)){const i=this.readNumber();return this.newToken("IDENTIFIER",i,e,n)}else r=this.newToken("UNKNOWN",this.ch,e,n)}return this.readChar(),r}newToken(e,n,r,i){return{type:e,literal:n,line:this.line,column:i,start:r,end:this.position>r?this.position:r+n.length}}readNumber(){const e=this.position;for(;this.isDigit(this.ch);)this.readChar();return this.input.slice(e,this.position)}readString(){const e=this.position+1;for(this.readChar();this.ch!=='"'&&this.ch!==""&&this.ch!==`
8
8
  `;)this.readChar();const n=this.input.slice(e,this.position);return this.ch,this.readChar(),n}isArrowStart(){if(this.ch!=="-")return!1;const e=this.peekChar();return e===">"||e==="-"||e===")"||e==="x"}readArrow(){if(this.input.slice(this.position,this.position+4)==="-->>")return this.readMulti(4),"-->>";const n=this.input.slice(this.position,this.position+3);if(n==="-->"||n==="--)"||n==="->>"||n==="--x")return this.readMulti(3),n;const r=this.input.slice(this.position,this.position+2);return r==="->"||r==="-)"||r==="-x"?(this.readMulti(2),r):"-"}readMulti(e){for(let n=0;n<e;n++)this.readChar()}skipComment(){for(;this.ch!==`
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 Se{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 Dt=class extends Se{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 u=this.parseBlock(e,["END"]);return this.currentGroup=a,this.isCurrentToken("END")&&this.advance(),u}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 u=this.readRestOfLine(),h=this.parseBlock(e,["END","AND"]);s.push({id:this.generateId("br"),condition:u,events:h})}for(;this.isCurrentToken("OPTION");){this.advance();const u=this.readRestOfLine(),h=this.parseBlock(e,["END","OPTION"]);s.push({id:this.generateId("br"),condition:u,events:h})}for(;this.isCurrentToken("ELSE");){this.advance();const u=this.readRestOfLine(),h=this.parseBlock(e,["END","ELSE"]);s.push({id:this.generateId("br"),condition:u,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:u,style:h}=this.resolveArrow(r);return{kind:"message",id:this.generateId("evt"),from:n,to:o,text:a,type:u,style:h,lifecycle:i||s?{activateTarget:i,deactivateSource:s}:void 0}}resolveArrow(e){const n=x[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 xt={parse:t=>{const e=new Lt(t);return new Dt(e).parse()}};class Ft extends Oe{nextToken(){this.skipWhitespace();const e=this.position,n=this.column;let r;switch(this.ch){case`
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 jt extends Se{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 u=this.parseStatement(e);u&&o.push(u)}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 Mt={parse:t=>{const e=new Ft(t);return new jt(e).parse()}},Ut={".puml":"plantuml",".plantuml":"plantuml",".pu":"plantuml",".mmd":"mermaid",".mermaid":"mermaid"},Gt=[{pattern:/^\s*@startuml/m,format:"plantuml"},{pattern:/^\s*sequenceDiagram/m,format:"mermaid"}],pe={detect(t,e){const n=pe.detectByExtension(t);return n||pe.detectByContent(e)},detectByExtension(t){const e=t.toLowerCase().match(/\.[^.]+$/)?.[0];return e&&Ut[e]||null},detectByContent(t){for(const{pattern:e,format:n}of Gt)if(e.test(t))return n;return null},getDefaultExtension(t){switch(t){case"plantuml":return".puml";case"mermaid":return".mmd"}}},Y=new Map;Y.set("mermaid",xt),Y.set("plantuml",Mt);const Pe={register(t,e){Y.set(t,e)},getParser(t){const e=Y.get(t);if(!e)throw new Error(`Parser for language '${t}' not found.`);return e}};class X{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 Vt extends X{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 Bt{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 de{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 Jt extends X{constructor(e){super(),this.layer=e}matcher=new de;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 Wt extends X{constructor(e){super(),this.layer=e}matcher=new de;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 Kt extends X{constructor(e){super(),this.layer=e}matcher=new de;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 Yt{factories=new Map;constructor(){this.registerTyped("resolve",e=>new Kt(e)),this.registerTyped("focus",e=>new Jt(e)),this.registerTyped("remove",e=>new Wt(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 Yt;class q{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 Vt().transform(r),r=new Bt().transform(r),r}}class Xt{constructor(){}static init(e,n="mermaid"){const i=Pe.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 q().transform(this.ast,this.layers);return new he().generate(n)}toPlantUML(){const n=new q().transform(this.ast,this.layers);return new le().generate(n)}toAST(){return new q().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 F=new Map;F.set("mermaid",()=>new he),F.set("plantuml",()=>new le);const qt={register(t,e){F.set(t,e)},getGenerator(t){const e=F.get(t);if(!e)throw new Error(`Generator for language '${t}' not found.`);return e()},hasGenerator(t){return F.has(t)},getLanguages(){return Array.from(F.keys())}};function c(t,e,n){function r(a,u){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:u,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(t))return;a._zod.traits.add(t),e(a,u);const h=o.prototype,l=Object.keys(h);for(let d=0;d<l.length;d++){const f=l[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 u;const h=n?.Parent?new s:this;r(h,a),(u=h._zod).deferred??(u.deferred=[]);for(const l of h._zod.deferred)l();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 j 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 Z(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 fe(t,e){return typeof e=="bigint"?e.toString():e}function Q(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function me(t){return t==null}function ge(t){const e=t.startsWith("^")?1:0,n=t.endsWith("$")?t.length-1:t.length;return t.slice(e,n)}function Qt(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 u=r.match(/\d?e-(\d?)/);u?.[1]&&(i=Number.parseInt(u[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 C(t,e,n){Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0})}function R(...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 Ht(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const xe="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function V(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const en=Q(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function B(t){if(V(t)===!1)return!1;const e=t.constructor;if(e===void 0||typeof e!="function")return!0;const n=e.prototype;return!(V(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Fe(t){return B(t)?{...t}:Array.isArray(t)?[...t]:t}const tn=new Set(["string","number","symbol"]);function M(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 p(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 nn(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}const rn={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 sn(t,e){const n=t._zod.def,r=R(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 C(this,"shape",i),i},checks:[]});return N(t,r)}function on(t,e){const n=t._zod.def,r=R(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 C(this,"shape",i),i},checks:[]});return N(t,r)}function an(t,e){if(!B(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=R(t._zod.def,{get shape(){const s={...t._zod.def.shape,...e};return C(this,"shape",s),s},checks:[]});return N(t,i)}function cn(t,e){if(!B(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 C(this,"shape",r),r},checks:t._zod.def.checks};return N(t,n)}function un(t,e){const n=R(t._zod.def,{get shape(){const r={...t._zod.def.shape,...e._zod.def.shape};return C(this,"shape",r),r},get catchall(){return e._zod.def.catchall},checks:[]});return N(t,n)}function hn(t,e,n){const r=R(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 C(this,"shape",s),s},checks:[]});return N(e,r)}function ln(t,e,n){const r=R(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 C(this,"shape",s),s},checks:[]});return N(e,r)}function U(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 H(t){return typeof t=="string"?t:t?.message}function L(t,e,n){const r={...t,path:t.path??[]};if(!t.message){const i=H(t.inst?._zod.def?.error?.(t))??H(e?.error?.(t))??H(n.customError?.(t))??H(n.localeError?.(t))??"Invalid input";r.message=i}return delete r.inst,delete r.continue,e?.reportInput||delete r.input,r}function ve(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function J(...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,fe,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},Ue=c("$ZodError",Me),Ge=c("$ZodError",Me,{Parent:Error});function pn(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 dn(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 u=s.path[a];a===s.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(e(s))):o[u]=o[u]||{_errors:[]},o=o[u],a++}}};return r(t),n}const _e=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 j;if(o.issues.length){const a=new(i?.Err??t)(o.issues.map(u=>L(u,s,Z())));throw xe(a,i?.callee),a}return o.value},ke=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(u=>L(u,s,Z())));throw xe(a,i?.callee),a}return o.value},ee=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 j;return s.issues.length?{success:!1,error:new(t??Ue)(s.issues.map(o=>L(o,i,Z())))}:{success:!0,data:s.value}},fn=ee(Ge),te=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=>L(o,i,Z())))}:{success:!0,data:s.value}},mn=te(Ge),gn=t=>(e,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return _e(t)(e,n,i)},vn=t=>(e,n,r)=>_e(t)(e,n,r),_n=t=>async(e,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ke(t)(e,n,i)},kn=t=>async(e,n,r)=>ke(t)(e,n,r),yn=t=>(e,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ee(t)(e,n,i)},Tn=t=>(e,n,r)=>ee(t)(e,n,r),wn=t=>async(e,n,r)=>{const i=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return te(t)(e,n,i)},bn=t=>async(e,n,r)=>te(t)(e,n,r),En=/^[cC][^\s-]{8,}$/,zn=/^[0-9a-z]+$/,In=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,$n=/^[0-9a-vA-V]{20}$/,On=/^[A-Za-z0-9]{27}$/,Sn=/^[a-zA-Z0-9_-]{21}$/,Pn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Nn=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,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)$/,An=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Zn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Cn(){return new RegExp(Zn,"u")}const Rn=/^(?:(?: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])$/,Ln=/^(([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}|:))$/,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])\/([0-9]|[1-2][0-9]|3[0-2])$/,xn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Fn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Be=/^[A-Za-z0-9_-]*$/,jn=/^\+(?:[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])))",Mn=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 Un(t){return new RegExp(`^${We(t)}$`)}function Gn(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 Vn=t=>{const e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},Bn=/^-?\d+$/,Jn=/^-?\d+(?:\.\d+)?/,Wn=/^[^A-Z]*$/,Kn=/^[^a-z]*$/,E=c("$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=c("$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})}}),Xe=c("$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})}}),Yn=c("$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):Qt(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})}}),Xn=c("$ZodCheckNumberFormat",(t,e)=>{E.init(t,e),e.format=e.format||"float64";const n=e.format?.includes("int"),r=n?"int":"number",[i,s]=rn[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=Bn)}),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})}}),qn=c("$ZodCheckMaxLength",(t,e)=>{var n;E.init(t,e),(n=t._zod.def).when??(n.when=r=>{const i=r.value;return!me(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=ve(i);r.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:i,inst:t,continue:!e.abort})}}),Qn=c("$ZodCheckMinLength",(t,e)=>{var n;E.init(t,e),(n=t._zod.def).when??(n.when=r=>{const i=r.value;return!me(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=ve(i);r.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:i,inst:t,continue:!e.abort})}}),Hn=c("$ZodCheckLengthEquals",(t,e)=>{var n;E.init(t,e),(n=t._zod.def).when??(n.when=r=>{const i=r.value;return!me(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=ve(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})}}),ne=c("$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=()=>{})}),er=c("$ZodCheckRegex",(t,e)=>{ne.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})}}),tr=c("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=Wn),ne.init(t,e)}),nr=c("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=Kn),ne.init(t,e)}),rr=c("$ZodCheckIncludes",(t,e)=>{E.init(t,e);const n=M(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})}}),ir=c("$ZodCheckStartsWith",(t,e)=>{E.init(t,e);const n=new RegExp(`^${M(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})}}),sr=c("$ZodCheckEndsWith",(t,e)=>{E.init(t,e);const n=new RegExp(`.*${M(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})}}),or=c("$ZodCheckOverwrite",(t,e)=>{E.init(t,e),t._zod.check=n=>{n.value=e.tx(n.value)}});class ar{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,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(`
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 cr={major:4,minor:2,patch:1},k=c("$ZodType",(t,e)=>{var n;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=cr;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,u)=>{let h=U(o),l;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&&u?.async===!1)throw new j;if(l||_ instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await _,o.issues.length!==f&&(h||(h=U(o,f)))});else{if(o.issues.length===f)continue;h||(h=U(o,f))}}return l?l.then(()=>o):o},s=(o,a,u)=>{if(U(o))return o.aborted=!0,o;const h=i(a,r,u);if(h instanceof Promise){if(u.async===!1)throw new j;return h.then(l=>t._zod.parse(l,u))}return t._zod.parse(h,u)};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(l=>s(l,o,a)):s(h,o,a)}const u=t._zod.parse(o,a);if(u instanceof Promise){if(a.async===!1)throw new j;return u.then(h=>i(h,r,a))}return i(u,r,a)}}t["~standard"]={validate:i=>{try{const s=fn(t,i);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return mn(t,i).then(o=>o.success?{value:o.data}:{issues:o.error?.issues})}},vendor:"zod",version:1}}),ye=c("$ZodString",(t,e)=>{k.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??Vn(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=c("$ZodStringFormat",(t,e)=>{ne.init(t,e),ye.init(t,e)}),ur=c("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=Nn),g.init(t,e)}),hr=c("$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)}),lr=c("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=An),g.init(t,e)}),pr=c("$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})}}}),dr=c("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=Cn()),g.init(t,e)}),fr=c("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=Sn),g.init(t,e)}),mr=c("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=En),g.init(t,e)}),gr=c("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=zn),g.init(t,e)}),vr=c("$ZodULID",(t,e)=>{e.pattern??(e.pattern=In),g.init(t,e)}),_r=c("$ZodXID",(t,e)=>{e.pattern??(e.pattern=$n),g.init(t,e)}),kr=c("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=On),g.init(t,e)}),yr=c("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=Gn(e)),g.init(t,e)}),Tr=c("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=Mn),g.init(t,e)}),wr=c("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=Un(e)),g.init(t,e)}),br=c("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=Pn),g.init(t,e)}),Er=c("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=Rn),g.init(t,e),t._zod.bag.format="ipv4"}),zr=c("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=Ln),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})}}}),Ir=c("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=Dn),g.init(t,e)}),$r=c("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=xn),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 qe(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}const Or=c("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=Fn),g.init(t,e),t._zod.bag.contentEncoding="base64",t._zod.check=n=>{qe(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:t,continue:!e.abort})}});function Sr(t){if(!Be.test(t))return!1;const e=t.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=e.padEnd(Math.ceil(e.length/4)*4,"=");return qe(n)}const Pr=c("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=Be),g.init(t,e),t._zod.bag.contentEncoding="base64url",t._zod.check=n=>{Sr(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:t,continue:!e.abort})}}),Nr=c("$ZodE164",(t,e)=>{e.pattern??(e.pattern=jn),g.init(t,e)});function Ar(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 Zr=c("$ZodJWT",(t,e)=>{g.init(t,e),t._zod.check=n=>{Ar(n.value,e.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:t,continue:!e.abort})}}),Qe=c("$ZodNumber",(t,e)=>{k.init(t,e),t._zod.pattern=t._zod.bag.pattern??Jn,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}}),Cr=c("$ZodNumberFormat",(t,e)=>{Xn.init(t,e),Qe.init(t,e)}),Rr=c("$ZodUnknown",(t,e)=>{k.init(t,e),t._zod.parse=n=>n}),Lr=c("$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 Dr=c("$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],u=e.element._zod.run({value:a,issues:[]},r);u instanceof Promise?s.push(u.then(h=>He(h,n,o))):He(u,n,o)}return s.length?Promise.all(s).then(()=>n):n}});function re(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=nn(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,u=i.catchall._zod,h=u.def.type;for(const l in e){if(a.has(l))continue;if(h==="never"){o.push(l);continue}const d=u.run({value:e[l],issues:[]},r);d instanceof Promise?t.push(d.then(f=>re(f,n,l,e))):re(d,n,l,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 xr=c("$ZodObject",(t,e)=>{if(k.init(t,e),!Object.getOwnPropertyDescriptor(e,"shape")?.get){const a=e.shape;Object.defineProperty(e,"shape",{get:()=>{const u={...a};return Object.defineProperty(e,"shape",{value:u}),u}})}const r=Q(()=>et(e));m(t._zod,"propValues",()=>{const a=e.shape,u={};for(const h in a){const l=a[h]._zod;if(l.values){u[h]??(u[h]=new Set);for(const d of l.values)u[h].add(d)}}return u});const i=V,s=e.catchall;let o;t._zod.parse=(a,u)=>{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 l=[],d=o.shape;for(const f of o.keys){const z=d[f]._zod.run({value:h[f],issues:[]},u);z instanceof Promise?l.push(z.then($e=>re($e,a,f,h))):re(z,a,f,h)}return s?tt(l,h,a,u,r.value,t):l.length?Promise.all(l).then(()=>a):a}}),Fr=c("$ZodObjectJIT",(t,e)=>{xr.init(t,e);const n=t._zod.parse,r=Q(()=>et(e)),i=f=>{const _=new ar(["shape","payload","ctx"]),z=r.value,$e=P=>{const O=De(P);return`shape[${O}]._zod.run({ value: input[${O}], issues: [] }, ctx)`};_.write("const input = payload.value;");const Zt=Object.create(null);let xo=0;for(const P of z.keys)Zt[P]=`key_${xo++}`;_.write("const newResult = {};");for(const P of z.keys){const O=Zt[P],K=De(P);_.write(`const ${O} = ${$e(P)};`),_.write(`
15
- if (${O}.issues.length) {
16
- payload.issues = payload.issues.concat(${O}.issues.map(iss => ({
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 I=d[f]._zod.run({value:h[f],issues:[]},c);I instanceof Promise?p.push(I.then($e=>se($e,a,f,h))):se(I,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"]),I=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 I.keys)Ct[S]=`key_${Mo++}`;_.write("const newResult = {};");for(const S of I.keys){const P=Ct[S],q=De(S);_.write(`const ${P} = ${$e(S)};`),_.write(`
15
+ if (${P}.issues.length) {
16
+ payload.issues = payload.issues.concat(${P}.issues.map(iss => ({
17
17
  ...iss,
18
- path: iss.path ? [${K}, ...iss.path] : [${K}]
18
+ path: iss.path ? [${q}, ...iss.path] : [${q}]
19
19
  })));
20
20
  }
21
21
 
22
22
 
23
- if (${O}.value === undefined) {
24
- if (${K} in input) {
25
- newResult[${K}] = undefined;
23
+ if (${P}.value === undefined) {
24
+ if (${q} in input) {
25
+ newResult[${q}] = undefined;
26
26
  }
27
27
  } else {
28
- newResult[${K}] = ${O}.value;
28
+ newResult[${q}] = ${P}.value;
29
29
  }
30
30
 
31
- `)}_.write("payload.value = newResult;"),_.write("return payload;");const Fo=_.compile();return(P,O)=>Fo(f,P,O)};let s;const o=V,a=!Ce.jitless,h=a&&en.value,l=e.catchall;let d;t._zod.parse=(f,_)=>{d??(d=r.value);const z=f.value;return o(z)?a&&h&&_?.async===!1&&_.jitless!==!0?(s||(s=i(e.shape)),f=s(f,_),l?tt([],z,f,_,d,t):f):n(f,_):(f.issues.push({expected:"object",code:"invalid_type",input:z,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=>!U(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=>L(o,r,Z())))}),e)}const rt=c("$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=>ge(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 u of e.options){const h=u._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(u=>nt(u,i,t,s)):nt(a,i,t,s)}}),jr=c("$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,u]of Object.entries(o)){i[a]||(i[a]=new Set);for(const h of u)i[a].add(h)}}return i});const r=Q(()=>{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 u of a){if(s.has(u))throw new Error(`Duplicate discriminator value "${String(u)}"`);s.set(u,o)}}return s});t._zod.parse=(i,s)=>{const o=i.value;if(!V(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)}}),Mr=c("$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(([u,h])=>it(n,u,h)):it(n,s,o)}});function Te(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(B(t)&&B(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=Te(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=Te(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),U(t))return t;const r=Te(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 Ur=c("$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=>tn.has(typeof i)).map(i=>typeof i=="string"?M(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}}),Gr=c("$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"?M(r):r?M(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}}),Vr=c("$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 j;return n.value=i,n}});function st(t,e){return t.issues.length&&e===void 0?{issues:[],value:void 0}:t}const Br=c("$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(`^(${ge(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)}}),Jr=c("$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(`^(${ge(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)}),Wr=c("$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 Kr=c("$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))}),Yr=c("$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 Xr=c("$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=>L(o,r,Z()))},input:n.value}),n.issues=[]),n)):(n.value=i.value,i.issues.length&&(n.value=e.catchValue({...n,error:{issues:i.issues.map(s=>L(s,r,Z()))},input:n.value}),n.issues=[]),n)}}),qr=c("$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=>ie(o,e.in,r)):ie(s,e.in,r)}const i=e.in._zod.run(n,r);return i instanceof Promise?i.then(s=>ie(s,e.out,r)):ie(i,e.out,r)}});function ie(t,e,n){return t.issues.length?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues},n)}const Qr=c("$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 Hr=c("$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(J(i))}}var ht;class ei{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 ti(){return new ei}(ht=globalThis).__zod_globalRegistry??(ht.__zod_globalRegistry=ti());const W=globalThis.__zod_globalRegistry;function ni(t,e){return new t({type:"string",...p(e)})}function ri(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...p(e)})}function lt(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...p(e)})}function ii(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...p(e)})}function si(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...p(e)})}function oi(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...p(e)})}function ai(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...p(e)})}function ci(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...p(e)})}function ui(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...p(e)})}function hi(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...p(e)})}function li(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...p(e)})}function pi(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...p(e)})}function di(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...p(e)})}function fi(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...p(e)})}function mi(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...p(e)})}function gi(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...p(e)})}function vi(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...p(e)})}function _i(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...p(e)})}function ki(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...p(e)})}function yi(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...p(e)})}function Ti(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...p(e)})}function wi(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...p(e)})}function bi(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...p(e)})}function Ei(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...p(e)})}function zi(t,e){return new t({type:"string",format:"date",check:"string_format",...p(e)})}function Ii(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...p(e)})}function $i(t,e){return new t({type:"string",format:"duration",check:"string_format",...p(e)})}function Oi(t,e){return new t({type:"number",checks:[],...p(e)})}function Si(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...p(e)})}function Pi(t){return new t({type:"unknown"})}function Ni(t,e){return new t({type:"never",...p(e)})}function pt(t,e){return new Ye({check:"less_than",...p(e),value:t,inclusive:!1})}function we(t,e){return new Ye({check:"less_than",...p(e),value:t,inclusive:!0})}function dt(t,e){return new Xe({check:"greater_than",...p(e),value:t,inclusive:!1})}function be(t,e){return new Xe({check:"greater_than",...p(e),value:t,inclusive:!0})}function ft(t,e){return new Yn({check:"multiple_of",...p(e),value:t})}function mt(t,e){return new qn({check:"max_length",...p(e),maximum:t})}function se(t,e){return new Qn({check:"min_length",...p(e),minimum:t})}function gt(t,e){return new Hn({check:"length_equals",...p(e),length:t})}function Ai(t,e){return new er({check:"string_format",format:"regex",...p(e),pattern:t})}function Zi(t){return new tr({check:"string_format",format:"lowercase",...p(t)})}function Ci(t){return new nr({check:"string_format",format:"uppercase",...p(t)})}function Ri(t,e){return new rr({check:"string_format",format:"includes",...p(e),includes:t})}function Li(t,e){return new ir({check:"string_format",format:"starts_with",...p(e),prefix:t})}function Di(t,e){return new sr({check:"string_format",format:"ends_with",...p(e),suffix:t})}function G(t){return new or({check:"overwrite",tx:t})}function xi(t){return G(e=>e.normalize(t))}function Fi(){return G(t=>t.trim())}function ji(){return G(t=>t.toLowerCase())}function Mi(){return G(t=>t.toUpperCase())}function Ui(){return G(t=>Ht(t))}function Gi(t,e,n){return new t({type:"array",element:e,...p(n)})}function Vi(t,e,n){return new t({type:"custom",check:"custom",fn:e,...p(n)})}function Bi(t){const e=Ji(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(J(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(J(i))}},t(n.value,n)));return e}function Ji(t,e){const n=new E({check:"custom",...p(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??W,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 l={...n,schemaPath:[...n.schemaPath,t],path:n.path},d=t._zod.parent;if(d)o.ref=d,w(d,e,l),e.seen.get(d).isParent=!0;else if(t._zod.processJSONSchema)t._zod.processJSONSchema(e,o.schema,l);else{const f=o.schema,_=e.processors[i.type];if(!_)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);_(t,e,f,l)}}const u=e.metadataRegistry.get(t);return u&&Object.assign(o.schema,u),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 l=t.external.registry.get(s[0])?.id,d=t.external.uri??(_=>_);if(l)return{ref:d(l)};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 u=`#/${o}/`,h=s[1].schema.id??`__schema${t.counter++}`;return{defId:h,ref:u+h}},i=s=>{if(s[1].schema.$ref)return;const o=s[1],{ref:a,defId:u}=r(s);o.def={...o.schema},u&&(o.defId=u);const h=o.schema;for(const l in h)delete h[l];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 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>
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 u=t.external.registry.get(s[0])?.id;if(e!==s[0]&&u){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),u=a.def??a.schema,h={...u};if(a.ref===null)return;const l=a.ref;if(a.ref=null,l){r(l);const d=t.seen.get(l).schema;d.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(d)):(Object.assign(u,d),Object.assign(u,h))}a.isParent||t.override({zodSchema:o,jsonSchema:u,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:oe(e,"input"),output:oe(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 Wi=(t,e={})=>n=>{const r=vt({...n,processors:e});return w(t,r),_t(r,t),kt(r,t)},oe=(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)},Ki={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Yi=(t,e,n,r)=>{const i=n;i.type="string";const{minimum:s,maximum:o,format:a,patterns:u,contentEncoding:h}=t._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof o=="number"&&(i.maxLength=o),a&&(i.format=Ki[a]??a,i.format===""&&delete i.format),h&&(i.contentEncoding=h),u&&u.size>0){const l=[...u];l.length===1?i.pattern=l[0].source:l.length>1&&(i.allOf=[...l.map(d=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},Xi=(t,e,n,r)=>{const i=n,{minimum:s,maximum:o,format:a,multipleOf:u,exclusiveMaximum:h,exclusiveMinimum:l}=t._zod.bag;typeof a=="string"&&a.includes("int")?i.type="integer":i.type="number",typeof l=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l),typeof s=="number"&&(i.minimum=s,typeof l=="number"&&e.target!=="draft-04"&&(l>=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 u=="number"&&(i.multipleOf=u)},qi=(t,e,n,r)=>{n.not={}},Qi=(t,e,n,r)=>{},Hi=(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},es=(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},ts=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},ns=(t,e,n,r)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},rs=(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"]})},is=(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)),u=new Set([...a].filter(h=>{const l=s.shape[h]._zod;return e.io==="input"?l.optin===void 0:l.optout===void 0}));u.size>0&&(i.required=Array.from(u)),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)},ss=(t,e,n,r)=>{const i=t._zod.def,s=i.inclusive===!1,o=i.options.map((a,u)=>w(a,e,{...r,path:[...r.path,s?"oneOf":"anyOf",u]}));s?n.oneOf=o:n.anyOf=o},os=(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,u=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];n.allOf=u},as=(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"}]},cs=(t,e,n,r)=>{const i=t._zod.def;w(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType},us=(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))},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,e.io==="input"&&(n._prefault=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;let o;try{o=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=o},ps=(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},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,n.readOnly=!0},fs=(t,e,n,r)=>{const i=t._zod.def;w(i.innerType,e,r);const s=e.seen.get(t);s.ref=i.innerType},ms=c("ZodISODateTime",(t,e)=>{yr.init(t,e),v.init(t,e)});function gs(t){return Ei(ms,t)}const vs=c("ZodISODate",(t,e)=>{Tr.init(t,e),v.init(t,e)});function _s(t){return zi(vs,t)}const ks=c("ZodISOTime",(t,e)=>{wr.init(t,e),v.init(t,e)});function ys(t){return Ii(ks,t)}const Ts=c("ZodISODuration",(t,e)=>{br.init(t,e),v.init(t,e)});function ws(t){return $i(Ts,t)}const I=c("ZodError",(t,e)=>{Ue.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:n=>dn(t,n)},flatten:{value:n=>pn(t,n)},addIssue:{value:n=>{t.issues.push(n),t.message=JSON.stringify(t.issues,fe,2)}},addIssues:{value:n=>{t.issues.push(...n),t.message=JSON.stringify(t.issues,fe,2)}},isEmpty:{get(){return t.issues.length===0}}})},{Parent:Error}),bs=_e(I),Es=ke(I),zs=ee(I),Is=te(I),$s=gn(I),Os=vn(I),Ss=_n(I),Ps=kn(I),Ns=yn(I),As=Tn(I),Zs=wn(I),Cs=bn(I),y=c("ZodType",(t,e)=>(k.init(t,e),Object.assign(t["~standard"],{jsonSchema:{input:oe(t,"input"),output:oe(t,"output")}}),t.toJSONSchema=Wi(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.check=(...n)=>t.clone(R(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)=>bs(t,n,r,{callee:t.parse}),t.safeParse=(n,r)=>zs(t,n,r),t.parseAsync=async(n,r)=>Es(t,n,r,{callee:t.parseAsync}),t.safeParseAsync=async(n,r)=>Is(t,n,r),t.spa=t.safeParseAsync,t.encode=(n,r)=>$s(t,n,r),t.decode=(n,r)=>Os(t,n,r),t.encodeAsync=async(n,r)=>Ss(t,n,r),t.decodeAsync=async(n,r)=>Ps(t,n,r),t.safeEncode=(n,r)=>Ns(t,n,r),t.safeDecode=(n,r)=>As(t,n,r),t.safeEncodeAsync=async(n,r)=>Zs(t,n,r),t.safeDecodeAsync=async(n,r)=>Cs(t,n,r),t.refine=(n,r)=>t.check(Io(n,r)),t.superRefine=n=>t.check($o(n)),t.overwrite=n=>t.check(G(n)),t.optional=()=>$t(t),t.nullable=()=>Ot(t),t.nullish=()=>$t(Ot(t)),t.nonoptional=n=>ko(t,n),t.array=()=>D(t),t.or=n=>Ee([t,n]),t.and=n=>uo(t,n),t.transform=n=>Pt(t,po(n)),t.default=n=>go(t,n),t.prefault=n=>_o(t,n),t.catch=n=>To(t,n),t.pipe=n=>Pt(t,n),t.readonly=()=>Eo(t),t.describe=n=>{const r=t.clone();return W.add(r,{description:n}),r},Object.defineProperty(t,"description",{get(){return W.get(t)?.description},configurable:!0}),t.meta=(...n)=>{if(n.length===0)return W.get(t);const r=t.clone();return W.add(r,n[0]),r},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t)),yt=c("_ZodString",(t,e)=>{ye.init(t,e),y.init(t,e),t._zod.processJSONSchema=(r,i,s)=>Yi(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(Ai(...r)),t.includes=(...r)=>t.check(Ri(...r)),t.startsWith=(...r)=>t.check(Li(...r)),t.endsWith=(...r)=>t.check(Di(...r)),t.min=(...r)=>t.check(se(...r)),t.max=(...r)=>t.check(mt(...r)),t.length=(...r)=>t.check(gt(...r)),t.nonempty=(...r)=>t.check(se(1,...r)),t.lowercase=r=>t.check(Zi(r)),t.uppercase=r=>t.check(Ci(r)),t.trim=()=>t.check(Fi()),t.normalize=(...r)=>t.check(xi(...r)),t.toLowerCase=()=>t.check(ji()),t.toUpperCase=()=>t.check(Mi()),t.slugify=()=>t.check(Ui())}),Rs=c("ZodString",(t,e)=>{ye.init(t,e),yt.init(t,e),t.email=n=>t.check(ri(Ls,n)),t.url=n=>t.check(ci(Ds,n)),t.jwt=n=>t.check(bi(Qs,n)),t.emoji=n=>t.check(ui(xs,n)),t.guid=n=>t.check(lt(Tt,n)),t.uuid=n=>t.check(ii(ae,n)),t.uuidv4=n=>t.check(si(ae,n)),t.uuidv6=n=>t.check(oi(ae,n)),t.uuidv7=n=>t.check(ai(ae,n)),t.nanoid=n=>t.check(hi(Fs,n)),t.guid=n=>t.check(lt(Tt,n)),t.cuid=n=>t.check(li(js,n)),t.cuid2=n=>t.check(pi(Ms,n)),t.ulid=n=>t.check(di(Us,n)),t.base64=n=>t.check(yi(Ys,n)),t.base64url=n=>t.check(Ti(Xs,n)),t.xid=n=>t.check(fi(Gs,n)),t.ksuid=n=>t.check(mi(Vs,n)),t.ipv4=n=>t.check(gi(Bs,n)),t.ipv6=n=>t.check(vi(Js,n)),t.cidrv4=n=>t.check(_i(Ws,n)),t.cidrv6=n=>t.check(ki(Ks,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))});function $(t){return ni(Rs,t)}const v=c("ZodStringFormat",(t,e)=>{g.init(t,e),yt.init(t,e)}),Ls=c("ZodEmail",(t,e)=>{lr.init(t,e),v.init(t,e)}),Tt=c("ZodGUID",(t,e)=>{ur.init(t,e),v.init(t,e)}),ae=c("ZodUUID",(t,e)=>{hr.init(t,e),v.init(t,e)}),Ds=c("ZodURL",(t,e)=>{pr.init(t,e),v.init(t,e)}),xs=c("ZodEmoji",(t,e)=>{dr.init(t,e),v.init(t,e)}),Fs=c("ZodNanoID",(t,e)=>{fr.init(t,e),v.init(t,e)}),js=c("ZodCUID",(t,e)=>{mr.init(t,e),v.init(t,e)}),Ms=c("ZodCUID2",(t,e)=>{gr.init(t,e),v.init(t,e)}),Us=c("ZodULID",(t,e)=>{vr.init(t,e),v.init(t,e)}),Gs=c("ZodXID",(t,e)=>{_r.init(t,e),v.init(t,e)}),Vs=c("ZodKSUID",(t,e)=>{kr.init(t,e),v.init(t,e)}),Bs=c("ZodIPv4",(t,e)=>{Er.init(t,e),v.init(t,e)}),Js=c("ZodIPv6",(t,e)=>{zr.init(t,e),v.init(t,e)}),Ws=c("ZodCIDRv4",(t,e)=>{Ir.init(t,e),v.init(t,e)}),Ks=c("ZodCIDRv6",(t,e)=>{$r.init(t,e),v.init(t,e)}),Ys=c("ZodBase64",(t,e)=>{Or.init(t,e),v.init(t,e)}),Xs=c("ZodBase64URL",(t,e)=>{Pr.init(t,e),v.init(t,e)}),qs=c("ZodE164",(t,e)=>{Nr.init(t,e),v.init(t,e)}),Qs=c("ZodJWT",(t,e)=>{Zr.init(t,e),v.init(t,e)}),wt=c("ZodNumber",(t,e)=>{Qe.init(t,e),y.init(t,e),t._zod.processJSONSchema=(r,i,s)=>Xi(t,r,i),t.gt=(r,i)=>t.check(dt(r,i)),t.gte=(r,i)=>t.check(be(r,i)),t.min=(r,i)=>t.check(be(r,i)),t.lt=(r,i)=>t.check(pt(r,i)),t.lte=(r,i)=>t.check(we(r,i)),t.max=(r,i)=>t.check(we(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(be(0,r)),t.negative=r=>t.check(pt(0,r)),t.nonpositive=r=>t.check(we(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 Hs(t){return Oi(wt,t)}const eo=c("ZodNumberFormat",(t,e)=>{Cr.init(t,e),wt.init(t,e)});function bt(t){return Si(eo,t)}const to=c("ZodUnknown",(t,e)=>{Rr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>Qi()});function Et(){return Pi(to)}const no=c("ZodNever",(t,e)=>{Lr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>qi(t,n,r)});function ro(t){return Ni(no,t)}const io=c("ZodArray",(t,e)=>{Dr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>rs(t,n,r,i),t.element=e.element,t.min=(n,r)=>t.check(se(n,r)),t.nonempty=n=>t.check(se(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 D(t,e){return Gi(io,t,e)}const so=c("ZodObject",(t,e)=>{Fr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>is(t,n,r,i),m(t,"shape",()=>e.shape),t.keyof=()=>Ie(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:ro()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=n=>an(t,n),t.safeExtend=n=>cn(t,n),t.merge=n=>un(t,n),t.pick=n=>sn(t,n),t.omit=n=>on(t,n),t.partial=(...n)=>hn(It,t,n[0]),t.required=(...n)=>ln(St,t,n[0])});function S(t,e){const n={type:"object",shape:t??{},...p(e)};return new so(n)}const zt=c("ZodUnion",(t,e)=>{rt.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>ss(t,n,r,i),t.options=e.options});function Ee(t,e){return new zt({type:"union",options:t,...p(e)})}const oo=c("ZodDiscriminatedUnion",(t,e)=>{zt.init(t,e),jr.init(t,e)});function ao(t,e,n){return new oo({type:"union",options:e,discriminator:t,...p(n)})}const co=c("ZodIntersection",(t,e)=>{Mr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>os(t,n,r,i)});function uo(t,e){return new co({type:"intersection",left:t,right:e})}const ze=c("ZodEnum",(t,e)=>{Ur.init(t,e),y.init(t,e),t._zod.processJSONSchema=(r,i,s)=>Hi(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 ze({...e,checks:[],...p(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 ze({...e,checks:[],...p(i),entries:s})}});function Ie(t,e){const n=Array.isArray(t)?Object.fromEntries(t.map(r=>[r,r])):t;return new ze({type:"enum",entries:n,...p(e)})}const ho=c("ZodLiteral",(t,e)=>{Gr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>es(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 ce(t,e){return new ho({type:"literal",values:Array.isArray(t)?t:[t],...p(e)})}const lo=c("ZodTransform",(t,e)=>{Vr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>ns(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(J(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(J(o))}};const i=e.transform(n.value,n);return i instanceof Promise?i.then(s=>(n.value=s,n)):(n.value=i,n)}});function po(t){return new lo({type:"transform",transform:t})}const It=c("ZodOptional",(t,e)=>{Br.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>fs(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function $t(t){return new It({type:"optional",innerType:t})}const fo=c("ZodNullable",(t,e)=>{Jr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>as(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function Ot(t){return new fo({type:"nullable",innerType:t})}const mo=c("ZodDefault",(t,e)=>{Wr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>us(t,n,r,i),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function go(t,e){return new mo({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():Fe(e)}})}const vo=c("ZodPrefault",(t,e)=>{Kr.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 _o(t,e){return new vo({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():Fe(e)}})}const St=c("ZodNonOptional",(t,e)=>{Yr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>cs(t,n,r,i),t.unwrap=()=>t._zod.def.innerType});function ko(t,e){return new St({type:"nonoptional",innerType:t,...p(e)})}const yo=c("ZodCatch",(t,e)=>{Xr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>ls(t,n,r,i),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function To(t,e){return new yo({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}const wo=c("ZodPipe",(t,e)=>{qr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>ps(t,n,r,i),t.in=e.in,t.out=e.out});function Pt(t,e){return new wo({type:"pipe",in:t,out:e})}const bo=c("ZodReadonly",(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});function Eo(t){return new bo({type:"readonly",innerType:t})}const zo=c("ZodCustom",(t,e)=>{Hr.init(t,e),y.init(t,e),t._zod.processJSONSchema=(n,r,i)=>ts(t,n)});function Io(t,e={}){return Vi(zo,t,e)}function $o(t){return Bi(t)}const A=Ee([$(),S({pattern:$(),flags:$().optional()})]),Oo=S({kind:ce("fragment"),condition:A.optional(),operator:Ee([$(),D($())]).optional()}),So=S({kind:ce("participant"),name:A.optional(),id:A.optional(),stereotype:A.optional()}),Po=S({kind:ce("message"),text:A.optional(),from:A.optional(),to:A.optional()}),No=S({kind:ce("group"),name:A.optional()}),Ao=ao("kind",[Oo,So,Po,No]),Zo=Ie(["focus","remove","resolve"]),Co=S({action:Zo,selector:Ao}),Ro=S({name:$(),suffix:$().optional(),layers:D(Co)}),Nt=Ie(["mermaid","plantuml"]),Lo=S({input:D($()),outputDir:$(),ignore:D($()).optional(),lenses:D(Ro),format:Nt.optional(),outputFormat:Nt.optional()}),At=S({version:Hs(),targets:D(Lo)});function Do(t){const e=At.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 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(`
34
34
  `);throw new Error(`Invalid Polagram Configuration:
35
- ${n}`)}return e.data}T.FormatDetector=pe,T.GeneratorFactory=qt,T.MermaidGeneratorVisitor=he,T.ParserFactory=Pe,T.PlantUMLGeneratorVisitor=le,T.Polagram=Xt,T.PolagramBuilder=Ae,T.PolagramConfigSchema=At,T.TransformationEngine=q,T.Traverser=ue,T.transformerRegistry=Ne,T.validateConfig=Do,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})}));
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"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polagram/core",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"