@polagram/core 0.0.3 → 0.1.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.
Files changed (99) hide show
  1. package/dist/index.d.ts +172 -85
  2. package/dist/polagram-core.js +2721 -2061
  3. package/dist/polagram-core.umd.cjs +20 -14
  4. package/package.json +11 -9
  5. package/dist/src/api.d.ts +0 -75
  6. package/dist/src/api.js +0 -160
  7. package/dist/src/ast/ast.test.d.ts +0 -1
  8. package/dist/src/ast/ast.test.js +0 -146
  9. package/dist/src/ast/index.d.ts +0 -119
  10. package/dist/src/ast/index.js +0 -2
  11. package/dist/src/config/index.d.ts +0 -1
  12. package/dist/src/config/index.js +0 -1
  13. package/dist/src/config/schema.d.ts +0 -182
  14. package/dist/src/config/schema.js +0 -78
  15. package/dist/src/config/schema.test.d.ts +0 -1
  16. package/dist/src/config/schema.test.js +0 -94
  17. package/dist/src/generator/base/walker.d.ts +0 -19
  18. package/dist/src/generator/base/walker.js +0 -56
  19. package/dist/src/generator/base/walker.test.d.ts +0 -1
  20. package/dist/src/generator/base/walker.test.js +0 -49
  21. package/dist/src/generator/generators/mermaid.d.ts +0 -24
  22. package/dist/src/generator/generators/mermaid.js +0 -140
  23. package/dist/src/generator/generators/mermaid.test.d.ts +0 -1
  24. package/dist/src/generator/generators/mermaid.test.js +0 -70
  25. package/dist/src/generator/interface.d.ts +0 -17
  26. package/dist/src/generator/interface.js +0 -1
  27. package/dist/src/index.d.ts +0 -9
  28. package/dist/src/index.js +0 -17
  29. package/dist/src/parser/base/lexer.d.ts +0 -18
  30. package/dist/src/parser/base/lexer.js +0 -95
  31. package/dist/src/parser/base/lexer.test.d.ts +0 -1
  32. package/dist/src/parser/base/lexer.test.js +0 -53
  33. package/dist/src/parser/base/parser.d.ts +0 -14
  34. package/dist/src/parser/base/parser.js +0 -43
  35. package/dist/src/parser/base/parser.test.d.ts +0 -1
  36. package/dist/src/parser/base/parser.test.js +0 -90
  37. package/dist/src/parser/index.d.ts +0 -10
  38. package/dist/src/parser/index.js +0 -29
  39. package/dist/src/parser/index.test.d.ts +0 -1
  40. package/dist/src/parser/index.test.js +0 -23
  41. package/dist/src/parser/interface.d.ts +0 -8
  42. package/dist/src/parser/interface.js +0 -1
  43. package/dist/src/parser/languages/mermaid/constants.d.ts +0 -7
  44. package/dist/src/parser/languages/mermaid/constants.js +0 -20
  45. package/dist/src/parser/languages/mermaid/index.d.ts +0 -4
  46. package/dist/src/parser/languages/mermaid/index.js +0 -11
  47. package/dist/src/parser/languages/mermaid/lexer.d.ts +0 -14
  48. package/dist/src/parser/languages/mermaid/lexer.js +0 -152
  49. package/dist/src/parser/languages/mermaid/lexer.test.d.ts +0 -1
  50. package/dist/src/parser/languages/mermaid/lexer.test.js +0 -58
  51. package/dist/src/parser/languages/mermaid/parser.d.ts +0 -21
  52. package/dist/src/parser/languages/mermaid/parser.js +0 -340
  53. package/dist/src/parser/languages/mermaid/parser.test.d.ts +0 -1
  54. package/dist/src/parser/languages/mermaid/parser.test.js +0 -252
  55. package/dist/src/parser/languages/mermaid/tokens.d.ts +0 -9
  56. package/dist/src/parser/languages/mermaid/tokens.js +0 -1
  57. package/dist/src/transformer/cleaners/prune-empty.d.ts +0 -9
  58. package/dist/src/transformer/cleaners/prune-empty.js +0 -27
  59. package/dist/src/transformer/cleaners/prune-empty.test.d.ts +0 -1
  60. package/dist/src/transformer/cleaners/prune-empty.test.js +0 -69
  61. package/dist/src/transformer/cleaners/prune-unused.d.ts +0 -5
  62. package/dist/src/transformer/cleaners/prune-unused.js +0 -48
  63. package/dist/src/transformer/cleaners/prune-unused.test.d.ts +0 -1
  64. package/dist/src/transformer/cleaners/prune-unused.test.js +0 -71
  65. package/dist/src/transformer/filters/focus.d.ts +0 -13
  66. package/dist/src/transformer/filters/focus.js +0 -71
  67. package/dist/src/transformer/filters/focus.test.d.ts +0 -1
  68. package/dist/src/transformer/filters/focus.test.js +0 -50
  69. package/dist/src/transformer/filters/remove.d.ts +0 -12
  70. package/dist/src/transformer/filters/remove.js +0 -82
  71. package/dist/src/transformer/filters/remove.test.d.ts +0 -1
  72. package/dist/src/transformer/filters/remove.test.js +0 -38
  73. package/dist/src/transformer/filters/resolve.d.ts +0 -9
  74. package/dist/src/transformer/filters/resolve.js +0 -32
  75. package/dist/src/transformer/filters/resolve.test.d.ts +0 -1
  76. package/dist/src/transformer/filters/resolve.test.js +0 -48
  77. package/dist/src/transformer/index.d.ts +0 -10
  78. package/dist/src/transformer/index.js +0 -10
  79. package/dist/src/transformer/lens.d.ts +0 -12
  80. package/dist/src/transformer/lens.js +0 -58
  81. package/dist/src/transformer/lens.test.d.ts +0 -1
  82. package/dist/src/transformer/lens.test.js +0 -60
  83. package/dist/src/transformer/orchestration/engine.d.ts +0 -5
  84. package/dist/src/transformer/orchestration/engine.js +0 -24
  85. package/dist/src/transformer/orchestration/engine.test.d.ts +0 -1
  86. package/dist/src/transformer/orchestration/engine.test.js +0 -41
  87. package/dist/src/transformer/orchestration/registry.d.ts +0 -10
  88. package/dist/src/transformer/orchestration/registry.js +0 -27
  89. package/dist/src/transformer/selector/matcher.d.ts +0 -9
  90. package/dist/src/transformer/selector/matcher.js +0 -62
  91. package/dist/src/transformer/selector/matcher.test.d.ts +0 -1
  92. package/dist/src/transformer/selector/matcher.test.js +0 -53
  93. package/dist/src/transformer/traverse/walker.d.ts +0 -14
  94. package/dist/src/transformer/traverse/walker.js +0 -67
  95. package/dist/src/transformer/traverse/walker.test.d.ts +0 -1
  96. package/dist/src/transformer/traverse/walker.test.js +0 -48
  97. package/dist/src/transformer/types.d.ts +0 -47
  98. package/dist/src/transformer/types.js +0 -1
  99. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -1,28 +1,34 @@
1
- (function(m,T){typeof exports=="object"&&typeof module<"u"?T(exports):typeof define=="function"&&define.amd?define(["exports"],T):(m=typeof globalThis<"u"?globalThis:m||self,T(m.PolagramCore={}))})(this,(function(m){"use strict";var Rs=Object.defineProperty;var Cs=(m,T,F)=>T in m?Rs(m,T,{enumerable:!0,configurable:!0,writable:!0,value:F}):m[T]=F;var Ct=(m,T,F)=>Cs(m,typeof T!="symbol"?T+"":T,F);class T{constructor(t){this.input=t,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===`
2
- `&&(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(t){const n=this.position;for(;t(this.ch);)this.readChar();return this.input.slice(n,this.position)}isLetter(t){return"a"<=t&&t<="z"||"A"<=t&&t<="Z"||t==="_"?!0:t.charCodeAt(0)>127?!/[\s\d]/.test(t):!1}isDigit(t){return"0"<=t&&t<="9"}}class F extends T{constructor(t){super(t)}nextToken(){this.skipWhitespace();const t=this.position,n=this.column;let r;switch(this.ch){case":":r=this.newToken("COLON",this.ch,t,n);break;case",":r=this.newToken("COMMA",this.ch,t,n);break;case"+":r=this.newToken("PLUS",this.ch,t,n);break;case"-":if(this.isArrowStart()){const i=this.readArrow();return r=this.newToken("ARROW",i,t,n),r}else r=this.newToken("MINUS",this.ch,t,n);break;case'"':const o=this.readString();return r=this.newToken("STRING",o,t,n),r;case`
3
- `:r=this.newToken("NEWLINE",this.ch,t,n);break;case"":r=this.newToken("EOF","",t,n);break;default:if(this.isLetter(this.ch)){const i=this.readIdentifier(),s=this.lookupIdent(i);return this.newToken(s,i,t,n)}else if(this.isDigit(this.ch)){const i=this.readNumber();return this.newToken("IDENTIFIER",i,t,n)}else r=this.newToken("UNKNOWN",this.ch,t,n)}return this.readChar(),r}newToken(t,n,r,o){return{type:t,literal:n,line:this.line,column:o,start:r,end:this.position>r?this.position:r+n.length}}readIdentifier(){const t=this.position;for(;this.isLetter(this.ch)||this.isDigit(this.ch);)this.readChar();return this.input.slice(t,this.position)}readNumber(){const t=this.position;for(;this.isDigit(this.ch);)this.readChar();return this.input.slice(t,this.position)}readString(){const t=this.position+1;for(this.readChar();this.ch!=='"'&&this.ch!==""&&this.ch!==`
4
- `;)this.readChar();const n=this.input.slice(t,this.position);return this.ch,this.readChar(),n}isArrowStart(){if(this.ch!=="-")return!1;const t=this.peekChar();return t===">"||t==="-"||t===")"||t==="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(t){for(let n=0;n<t;n++)this.readChar()}lookupIdent(t){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"}[t]||"IDENTIFIER"}}class jt{constructor(t){this.lexer=t,this.advance(),this.advance()}currToken;peekToken;advance(){this.currToken=this.peekToken,this.peekToken=this.lexer.nextToken()}curTokenIs(t){return this.currToken.type===t}peekTokenIs(t){return this.peekToken.type===t}expectPeek(t){return this.peekTokenIs(t)?(this.advance(),!0):!1}}const $e={"->":{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"}}},xt=Object.entries($e).reduce((e,[t,n])=>{const r=JSON.stringify({type:n.type,style:n.style});return e[r]=t,e},{});function Dt(e,t){const n=JSON.stringify({type:e,style:t});return xt[n]||"->>"}class Ft extends jt{currentGroup=null;idCounters={evt:0,frag:0,br:0,note:0,group:0};constructor(t){super(t)}parse(){const t={kind:"root",meta:{version:"1.0.0",source:"unknown"},participants:[],groups:[],events:[]};return t.events=this.parseBlock(t),t}parseBlock(t,n=[]){const r=[];for(;this.currToken.type!=="EOF";){const o=this.currToken.type;if(n.includes(o))return r;if(o==="NEWLINE"){this.advance();continue}if(o==="SEQUENCE_DIAGRAM"){t.meta.source="mermaid",this.advance();continue}if(o==="TITLE"){this.advance(),t.meta.title=this.readRestOfLine();continue}if(o==="BOX"){const i=this.parseGroup(t);r.push(...i);continue}if(o==="PARTICIPANT"||o==="ACTOR"){this.parseParticipant(t);continue}if(o==="LOOP"||o==="ALT"||o==="OPT"){r.push(this.parseFragment(t));continue}if(o==="NOTE"){r.push(this.parseNote(t));continue}if(o==="ACTIVATE"||o==="DEACTIVATE"){r.push(this.parseActivation(t));continue}if(this.isParticipantToken(this.currToken)){const i=this.parseMessage(t);if(i){r.push(i);continue}}this.advance()}return r}isParticipantToken(t){return t.type==="IDENTIFIER"||t.type==="STRING"}parseGroup(t){this.advance();const n=this.readRestOfLine().trim();let r=n,o;const i=n.split(/\s+/);if(i.length>0){const l=i[0];(l.startsWith("#")||["rgb","rgba","transparent","aqua","grey","gray","purple","red","blue","green"].includes(l.toLowerCase()))&&(o=l,r=i.slice(1).join(" "))}r||(r=`Group ${this.idCounters.group+1}`);const s={kind:"group",id:this.generateId("group"),name:r,type:"box",participantIds:[],style:o?{backgroundColor:o}:void 0};t.groups.push(s);const a=this.currentGroup;this.currentGroup=s;const u=this.parseBlock(t,["END"]);return this.currentGroup=a,this.currToken.type==="END"&&this.advance(),u}parseFragment(t){const n=this.currToken.type;let r="loop";n==="ALT"&&(r="alt"),n==="OPT"&&(r="opt"),this.advance();const o=this.readRestOfLine(),i=[],s=this.parseBlock(t,["END","ELSE"]);for(i.push({id:this.generateId("br"),condition:o,events:s});this.currToken.type==="ELSE";){this.advance();const a=this.readRestOfLine(),u=this.parseBlock(t,["END","ELSE"]);i.push({id:this.generateId("br"),condition:a,events:u})}return this.currToken.type==="END"&&this.advance(),{kind:"fragment",id:this.generateId("frag"),operator:r,branches:i}}parseParticipant(t){const n=this.currToken.type==="ACTOR";this.advance();let r="",o="";if(this.isParticipantToken(this.currToken)&&(r=this.currToken.literal,o=r,this.advance()),this.currToken.type==="AS"){this.advance();const s=this.readRestOfLine().trim();s&&(o=s)}const i=t.participants.find(s=>s.id===r);i?(o!==r&&(i.name=o),n&&(i.type="actor")):t.participants.push({id:r,name:o,type:n?"actor":"participant"}),this.currentGroup&&(this.currentGroup.participantIds.includes(r)||this.currentGroup.participantIds.push(r))}parseNote(t){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(t,this.currToken.literal),this.advance(),this.currToken.type==="COMMA");)this.advance();let o="";return this.currToken.type==="COLON"&&(this.advance(),o=this.readRestOfLine()),{kind:"note",id:this.generateId("note"),position:n,participantIds:r,text:o}}parseActivation(t){const n=this.currToken.type==="ACTIVATE"?"activate":"deactivate";this.advance();let r="";return this.isParticipantToken(this.currToken)&&(r=this.currToken.literal,this.ensureParticipant(t,r),this.advance()),{kind:"activation",participantId:r,action:n}}parseMessage(t){if(this.peekToken.type!=="ARROW")return null;const n=this.currToken.literal;if(this.ensureParticipant(t,n),this.advance(),this.currToken.type!=="ARROW")return null;const r=this.currToken.literal;this.advance();let o=!1,i=!1;if(this.currToken.type==="PLUS"&&(o=!0,this.advance()),this.currToken.type==="MINUS"&&(i=!0,this.advance()),!this.isParticipantToken(this.currToken))return null;const s=this.currToken.literal;this.ensureParticipant(t,s),this.advance();let a="";this.currToken.type==="COLON"&&(this.advance(),a=this.readRestOfLine());const{type:u,style:l}=this.resolveArrow(r);return{kind:"message",id:this.generateId("evt"),from:n,to:s,text:a,type:u,style:l,lifecycle:o||i?{activateTarget:o,deactivateSource:i}:void 0}}resolveArrow(t){const n=$e[t];return n||{type:"sync",style:{line:"solid",head:"arrow"}}}generateId(t){return this.idCounters[t]++,`${t}_${this.idCounters[t]}`}readRestOfLine(){if(this.currToken.type==="NEWLINE"||this.currToken.type==="EOF")return"";const t=this.currToken.start;let n=this.currToken.end;for(;this.currToken.type!=="NEWLINE"&&this.currToken.type!=="EOF";)n=this.currToken.end,this.advance();return this.lexer.getInput().slice(t,n)}ensureParticipant(t,n){t.participants.find(r=>r.id===n)||t.participants.push({id:n,name:n,type:"participant"})}}const Lt={parse:e=>{const t=new F(e);return new Ft(t).parse()}},le=class le{static register(t,n){this.parsers.set(t,n)}static getParser(t){const n=this.parsers.get(t);if(!n)throw new Error(`Parser for language '${t}' not found.`);return n}};Ct(le,"parsers",new Map),le.register("mermaid",Lt);let q=le;class Te{constructor(t){this.visitor=t}traverse(t){this.visitor.visitRoot(t)}dispatchEvent(t){switch(t.kind){case"message":this.visitor.visitMessage(t);break;case"fragment":this.visitor.visitFragment(t);break;case"note":this.visitor.visitNote(t);break;case"activation":this.visitor.visitActivation(t);break;case"divider":this.visitor.visitDivider(t);break;case"spacer":this.visitor.visitSpacer(t);break;case"ref":this.visitor.visitReference(t);break}}dispatchEvents(t){for(const n of t)this.dispatchEvent(n)}}class Ze{lines=[];indentLevel=0;traverser;constructor(){this.traverser=new Te(this)}generate(t){return this.lines=[],this.indentLevel=0,this.traverser.traverse(t),this.lines.join(`
5
- `)}visitRoot(t){this.lines.push("sequenceDiagram"),this.indentLevel++,t.meta?.title&&this.add(`title ${t.meta.title}`);for(const n of t.participants)this.visitParticipant(n);this.traverser.dispatchEvents(t.events)}visitParticipant(t){const n=t.type==="actor"?"actor":"participant",r=t.name;t.id===t.name?this.add(`${n} ${t.id}`):this.add(`${n} ${t.id} as ${r}`)}visitParticipantGroup(t){let n="box";t.style?.backgroundColor&&(n+=` ${t.style.backgroundColor}`),t.name&&(n+=` ${t.name}`),this.add(n)}visitMessage(t){const n=t.from??"[*]",r=t.to??"[*]",o=Dt(t.type,t.style);let i="";t.lifecycle?.activateTarget&&(i+="+"),t.lifecycle?.deactivateSource&&(i+="-"),this.add(`${n}${o}${i}${r}: ${t.text}`)}visitFragment(t){if(t.branches.length===0)return;const n=t.branches[0],r=n.condition?` ${n.condition}`:"";this.add(`${t.operator}${r}`),this.indent(()=>{this.traverser.dispatchEvents(n.events)});for(let o=1;o<t.branches.length;o++){const i=t.branches[o],s=i.condition?` ${i.condition}`:"";this.add(`else${s}`),this.indent(()=>{this.traverser.dispatchEvents(i.events)})}this.add("end")}visitNote(t){const n=t.position;let r="";t.participantIds.length>0&&(r=t.participantIds.join(","),n!=="over"?r=` of ${r}`:r=` ${r}`),this.add(`note ${n}${r}: ${t.text}`)}visitActivation(t){this.add(`${t.action} ${t.participantId}`)}visitDivider(t){this.add(`%% == ${t.text||""} ==`)}visitSpacer(t){this.add(`...${t.text||""}...`)}visitReference(t){this.add(`%% ref: ${t.text}`)}add(t){const n=" ".repeat(this.indentLevel);this.lines.push(`${n}${t}`)}indent(t){this.indentLevel++,t(),this.indentLevel--}}class X{transform(t){const n=this.mapEvents(t.events);return{...t,events:n}}mapEvents(t){return t.flatMap(n=>this.visitEvent(n))}visitEvent(t){return t.kind==="fragment"?this.visitFragment(t):[t]}visitFragment(t){const n=t.branches.map(r=>this.visitBranch(r));return[{...t,branches:n}]}visitBranch(t){return{...t,events:this.mapEvents(t.events)}}}class Ie extends X{visitFragment(t){const n=super.visitFragment(t);if(n.length===0)return[];const r=n[0],o=r.branches.filter(i=>i.events.length>0);return o.length===0?[]:[{...r,branches:o}]}}class Ee{transform(t){const n=this.collectUsedParticipants(t.events),r=t.participants.filter(i=>n.has(i.id)),o=t.groups.map(i=>({...i,participantIds:i.participantIds.filter(s=>n.has(s))})).filter(i=>i.participantIds.length>0);return{...t,participants:r,groups:o}}collectUsedParticipants(t){const n=new Set;function r(o){for(const i of o)switch(i.kind){case"message":i.from&&n.add(i.from),i.to&&n.add(i.to);break;case"fragment":for(const s of i.branches)r(s.events);break;case"activation":n.add(i.participantId);break;case"note":i.participantIds.forEach(s=>n.add(s));break;case"ref":i.participantIds.forEach(s=>n.add(s));break}}return r(t),n}}class Y{matchBranch(t,n,r){return!(n.operator&&!(Array.isArray(n.operator)?n.operator:[n.operator]).includes(r)||n.condition&&(!t.condition||!this.matchText(t.condition,n.condition)))}matchParticipant(t,n){return!(n.id&&!this.matchText(t.id,n.id)||n.name&&!this.matchText(t.name,n.name)||n.stereotype&&t.stereotype&&!this.matchText(t.stereotype,n.stereotype))}matchMessage(t,n){return!(n.text&&!this.matchText(t.text,n.text)||n.from&&t.from&&!this.matchText(t.from,n.from)||n.to&&t.to&&!this.matchText(t.to,n.to))}matchGroup(t,n){return!(n.name&&t.name&&!this.matchText(t.name,n.name))}matchText(t,n){if(typeof n=="string")return t===n;if(n instanceof RegExp)return n.test(t);if(typeof n=="object"&&n.pattern){const r=n.flags||"";return new RegExp(n.pattern,r).test(t)}return!1}}class Se extends X{constructor(t){super(),this.layer=t}matcher=new Y;targetParticipantIds=new Set;transform(t){return this.resolveTargetParticipants(t),super.transform(t)}resolveTargetParticipants(t){this.targetParticipantIds.clear();const n=this.layer.selector;t.participants.forEach(r=>{this.matcher.matchParticipant(r,n)&&this.targetParticipantIds.add(r.id)})}visitEvent(t){if(t.kind==="message"){const n=t;if(!this.isRelatedToParticipant(n))return[]}if(t.kind==="note"&&!t.participantIds.some(o=>this.targetParticipantIds.has(o)))return[];if(t.kind==="activation"){const n=t;if(!this.targetParticipantIds.has(n.participantId))return[]}return super.visitEvent(t)}isRelatedToParticipant(t){return!!(t.from&&this.targetParticipantIds.has(t.from)||t.to&&this.targetParticipantIds.has(t.to))}}class Oe extends X{constructor(t){super(),this.layer=t}matcher=new Y;removedParticipantIds=new Set;transform(t){const n=this.layer.selector;return n.kind==="participant"&&(t.participants.forEach(r=>{this.matcher.matchParticipant(r,n)&&this.removedParticipantIds.add(r.id)}),t.participants=t.participants.filter(r=>!this.removedParticipantIds.has(r.id))),n.kind==="group"&&(t.groups=t.groups.filter(r=>!this.matcher.matchGroup(r,n))),super.transform(t)}visitEvent(t){const n=this.layer.selector;if(n.kind==="message"&&t.kind==="message"&&this.matcher.matchMessage(t,n))return[];if(n.kind==="participant"){if(t.kind==="message"){const r=t;if(this.isRelatedToRemovedParticipant(r))return[]}if(t.kind==="note"&&t.participantIds.some(i=>this.removedParticipantIds.has(i)))return[];if(t.kind==="activation"){const r=t;if(this.removedParticipantIds.has(r.participantId))return[]}}return super.visitEvent(t)}isRelatedToRemovedParticipant(t){return!!(t.from&&this.removedParticipantIds.has(t.from)||t.to&&this.removedParticipantIds.has(t.to))}}class Pe extends X{constructor(t){super(),this.layer=t}matcher=new Y;visitFragment(t){const n=t.branches.find(r=>this.matcher.matchBranch(r,this.layer.selector,t.operator));return n?this.mapEvents(n.events):super.visitFragment(t)}}class Mt{factories=new Map;constructor(){this.register("resolve",t=>new Pe(t)),this.register("focus",t=>new Se(t)),this.register("remove",t=>new Oe(t))}register(t,n){this.factories.set(t,n)}get(t){const n=this.factories.get(t.action);return n?n(t):null}}const Ne=new Mt;class H{transform(t,n){let r=t;for(const o of n){const i=Ne.get(o);i?r=i.transform(r):console.warn(`Unknown action: ${o.action}`)}return r=new Ie().transform(r),r=new Ee().transform(r),r}}function Ut(e){if(typeof e!="object"||e===null)return!1;const t=e;if(Reflect.has(t,"name")&&typeof t.name!="string"||!Array.isArray(t.layers))return!1;for(const n of t.layers)if(!Jt(n))return!1;return!0}function Jt(e){if(typeof e!="object"||e===null)return!1;const t=e;return!(typeof t.action!="string"||!["focus","remove","resolve"].includes(t.action)||typeof t.selector!="object"||t.selector===null||typeof t.selector.kind!="string")}function Vt(e,t){return new H().transform(e,t.layers)}class Gt{constructor(){}static init(t,n="mermaid"){const o=q.getParser(n).parse(t);return new Ae(o)}}class Ae{ast;layers=[];constructor(t){this.ast=t}focusParticipant(t){return this.layers.push({action:"focus",selector:this.normalizeParticipantSelector(t)}),this}removeParticipant(t){return this.layers.push({action:"remove",selector:this.normalizeParticipantSelector(t)}),this}removeMessage(t){return this.layers.push({action:"remove",selector:this.normalizeMessageSelector(t)}),this}removeGroup(t){return this.layers.push({action:"remove",selector:this.normalizeGroupSelector(t)}),this}resolveFragment(t){return this.layers.push({action:"resolve",selector:this.normalizeFragmentSelector(t)}),this}applyLens(t){return this.layers.push(...t.layers),this}toMermaid(){const n=new H().transform(this.ast,this.layers);return new Ze().generate(n)}toAST(){return new H().transform(this.ast,this.layers)}normalizeParticipantSelector(t){return this.isTextMatcher(t)?{kind:"participant",name:t}:{kind:"participant",...t}}normalizeMessageSelector(t){return this.isTextMatcher(t)?{kind:"message",text:t}:{kind:"message",...t}}normalizeGroupSelector(t){return this.isTextMatcher(t)?{kind:"group",name:t}:{kind:"group",...t}}normalizeFragmentSelector(t){return this.isTextMatcher(t)?{kind:"fragment",condition:t}:{kind:"fragment",...t}}isTextMatcher(t){return typeof t=="string"||t instanceof RegExp||typeof t=="object"&&t!==null&&"pattern"in t&&!("kind"in t)}}function c(e,t,n){function r(a,u){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:u,constr:s,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,u);const l=s.prototype,f=Object.keys(l);for(let p=0;p<f.length;p++){const d=f[p];d in a||(a[d]=l[d].bind(a))}}const o=n?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function s(a){var u;const l=n?.Parent?new i:this;r(l,a),(u=l._zod).deferred??(u.deferred=[]);for(const f of l._zod.deferred)f();return l}return Object.defineProperty(s,"init",{value:r}),Object.defineProperty(s,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}class L extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Re extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Ce={};function R(e){return Ce}function je(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function fe(e,t){return typeof t=="bigint"?t.toString():t}function Q(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function he(e){return e==null}function pe(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Wt(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let o=(r.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(r)){const u=r.match(/\d?e-(\d?)/);u?.[1]&&(o=Number.parseInt(u[1]))}const i=n>o?n:o,s=Number.parseInt(e.toFixed(i).replace(".","")),a=Number.parseInt(t.toFixed(i).replace(".",""));return s%a/10**i}const xe=Symbol("evaluating");function g(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==xe)return r===void 0&&(r=xe,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function C(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function j(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function De(e){return JSON.stringify(e)}function Bt(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Fe="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function V(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Kt=Q(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function G(e){if(V(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(V(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Le(e){return G(e)?{...e}:Array.isArray(e)?[...e]:e}const qt=new Set(["string","number","symbol"]);function M(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function N(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function h(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Xt(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Yt={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 Ht(e,t){const n=e._zod.def,r=j(e._zod.def,{get shape(){const o={};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(o[i]=n.shape[i])}return C(this,"shape",o),o},checks:[]});return N(e,r)}function Qt(e,t){const n=e._zod.def,r=j(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete o[i]}return C(this,"shape",o),o},checks:[]});return N(e,r)}function en(e,t){if(!G(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const o=j(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return C(this,"shape",i),i},checks:[]});return N(e,o)}function tn(e,t){if(!G(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n={...e._zod.def,get shape(){const r={...e._zod.def.shape,...t};return C(this,"shape",r),r},checks:e._zod.def.checks};return N(e,n)}function nn(e,t){const n=j(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return C(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return N(e,n)}function rn(e,t,n){const r=j(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(n)for(const s in n){if(!(s in o))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(i[s]=e?new e({type:"optional",innerType:o[s]}):o[s])}else for(const s in o)i[s]=e?new e({type:"optional",innerType:o[s]}):o[s];return C(this,"shape",i),i},checks:[]});return N(t,r)}function on(e,t,n){const r=j(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(n)for(const s in n){if(!(s in i))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(i[s]=new e({type:"nonoptional",innerType:o[s]}))}else for(const s in o)i[s]=new e({type:"nonoptional",innerType:o[s]});return C(this,"shape",i),i},checks:[]});return N(t,r)}function U(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Me(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function ee(e){return typeof e=="string"?e:e?.message}function x(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const o=ee(e.inst?._zod.def?.error?.(e))??ee(t?.error?.(e))??ee(n.customError?.(e))??ee(n.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function de(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function W(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const Ue=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,fe,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Je=c("$ZodError",Ue),Ve=c("$ZodError",Ue,{Parent:Error});function sn(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function an(e,t=n=>n.message){const n={_errors:[]},r=o=>{for(const i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(s=>r({issues:s}));else if(i.code==="invalid_key")r({issues:i.issues});else if(i.code==="invalid_element")r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let s=n,a=0;for(;a<i.path.length;){const u=i.path[a];a===i.path.length-1?(s[u]=s[u]||{_errors:[]},s[u]._errors.push(t(i))):s[u]=s[u]||{_errors:[]},s=s[u],a++}}};return r(e),n}const me=e=>(t,n,r,o)=>{const i=r?Object.assign(r,{async:!1}):{async:!1},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new L;if(s.issues.length){const a=new(o?.Err??e)(s.issues.map(u=>x(u,i,R())));throw Fe(a,o?.callee),a}return s.value},ge=e=>async(t,n,r,o)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){const a=new(o?.Err??e)(s.issues.map(u=>x(u,i,R())));throw Fe(a,o?.callee),a}return s.value},te=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new L;return i.issues.length?{success:!1,error:new(e??Je)(i.issues.map(s=>x(s,o,R())))}:{success:!0,data:i.value}},cn=te(Ve),ne=e=>async(t,n,r)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>x(s,o,R())))}:{success:!0,data:i.value}},un=ne(Ve),ln=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return me(e)(t,n,o)},fn=e=>(t,n,r)=>me(e)(t,n,r),hn=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ge(e)(t,n,o)},pn=e=>async(t,n,r)=>ge(e)(t,n,r),dn=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return te(e)(t,n,o)},mn=e=>(t,n,r)=>te(e)(t,n,r),gn=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ne(e)(t,n,o)},vn=e=>async(t,n,r)=>ne(e)(t,n,r),_n=/^[cC][^\s-]{8,}$/,yn=/^[0-9a-z]+$/,kn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,wn=/^[0-9a-vA-V]{20}$/,bn=/^[A-Za-z0-9]{27}$/,zn=/^[a-zA-Z0-9_-]{21}$/,$n=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Tn=/^([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})$/,Ge=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[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)$/,Zn=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,In="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function En(){return new RegExp(In,"u")}const Sn=/^(?:(?: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])$/,On=/^(([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}|:))$/,Pn=/^((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])$/,Nn=/^(([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])$/,An=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,We=/^[A-Za-z0-9_-]*$/,Rn=/^\+(?:[0-9]){6,14}[0-9]$/,Be="(?:(?:\\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])))",Cn=new RegExp(`^${Be}$`);function Ke(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function jn(e){return new RegExp(`^${Ke(e)}$`)}function xn(e){const t=Ke({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${Be}T(?:${r})$`)}const Dn=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Fn=/^-?\d+$/,Ln=/^-?\d+(?:\.\d+)?/,Mn=/^[^A-Z]*$/,Un=/^[^a-z]*$/,$=c("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),qe={number:"number",bigint:"bigint",object:"date"},Xe=c("$ZodCheckLessThan",(e,t)=>{$.init(e,t);const n=qe[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,i=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ye=c("$ZodCheckGreaterThan",(e,t)=>{$.init(e,t);const n=qe[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Jn=c("$ZodCheckMultipleOf",(e,t)=>{$.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):Wt(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Vn=c("$ZodCheckNumberFormat",(e,t)=>{$.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,i]=Yt[t.format];e._zod.onattach.push(s=>{const a=s._zod.bag;a.format=t.format,a.minimum=o,a.maximum=i,n&&(a.pattern=Fn)}),e._zod.check=s=>{const a=s.value;if(n){if(!Number.isInteger(a)){s.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort});return}}a<o&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>i&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inst:e})}}),Gn=c("$ZodCheckMaxLength",(e,t)=>{var n;$.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!he(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=t.maximum)return;const s=de(o);r.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Wn=c("$ZodCheckMinLength",(e,t)=>{var n;$.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!he(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=t.minimum)return;const s=de(o);r.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Bn=c("$ZodCheckLengthEquals",(e,t)=>{var n;$.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!he(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,i=o.length;if(i===t.length)return;const s=de(o),a=i>t.length;r.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),re=c("$ZodCheckStringFormat",(e,t)=>{var n,r;$.init(e,t),e._zod.onattach.push(o=>{const i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Kn=c("$ZodCheckRegex",(e,t)=>{re.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),qn=c("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Mn),re.init(e,t)}),Xn=c("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Un),re.init(e,t)}),Yn=c("$ZodCheckIncludes",(e,t)=>{$.init(e,t);const n=M(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Hn=c("$ZodCheckStartsWith",(e,t)=>{$.init(e,t);const n=new RegExp(`^${M(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Qn=c("$ZodCheckEndsWith",(e,t)=>{$.init(e,t);const n=new RegExp(`.*${M(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),er=c("$ZodCheckOverwrite",(e,t)=>{$.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class tr{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
6
- `).filter(s=>s),o=Math.min(...r.map(s=>s.length-s.trimStart().length)),i=r.map(s=>s.slice(o)).map(s=>" ".repeat(this.indent*2)+s);for(const s of i)this.content.push(s)}compile(){const t=Function,n=this?.args,o=[...(this?.content??[""]).map(i=>` ${i}`)];return new t(...n,o.join(`
7
- `))}}const nr={major:4,minor:2,patch:1},k=c("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=nr;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const i of o._zod.onattach)i(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(s,a,u)=>{let l=U(s),f;for(const p of a){if(p._zod.def.when){if(!p._zod.def.when(s))continue}else if(l)continue;const d=s.issues.length,y=p._zod.check(s);if(y instanceof Promise&&u?.async===!1)throw new L;if(f||y instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await y,s.issues.length!==d&&(l||(l=U(s,d)))});else{if(s.issues.length===d)continue;l||(l=U(s,d))}}return f?f.then(()=>s):s},i=(s,a,u)=>{if(U(s))return s.aborted=!0,s;const l=o(a,r,u);if(l instanceof Promise){if(u.async===!1)throw new L;return l.then(f=>e._zod.parse(f,u))}return e._zod.parse(l,u)};e._zod.run=(s,a)=>{if(a.skipChecks)return e._zod.parse(s,a);if(a.direction==="backward"){const l=e._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});return l instanceof Promise?l.then(f=>i(f,s,a)):i(l,s,a)}const u=e._zod.parse(s,a);if(u instanceof Promise){if(a.async===!1)throw new L;return u.then(l=>o(l,r,a))}return o(u,r,a)}}e["~standard"]={validate:o=>{try{const i=cn(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return un(e,o).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}}),ve=c("$ZodString",(e,t)=>{k.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Dn(e._zod.bag),e._zod.parse=(n,r)=>{if(t.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:e}),n}}),v=c("$ZodStringFormat",(e,t)=>{re.init(e,t),ve.init(e,t)}),rr=c("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Tn),v.init(e,t)}),or=c("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Ge(r))}else t.pattern??(t.pattern=Ge());v.init(e,t)}),ir=c("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Zn),v.init(e,t)}),sr=c("$ZodURL",(e,t)=>{v.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=o.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),ar=c("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=En()),v.init(e,t)}),cr=c("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=zn),v.init(e,t)}),ur=c("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=_n),v.init(e,t)}),lr=c("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=yn),v.init(e,t)}),fr=c("$ZodULID",(e,t)=>{t.pattern??(t.pattern=kn),v.init(e,t)}),hr=c("$ZodXID",(e,t)=>{t.pattern??(t.pattern=wn),v.init(e,t)}),pr=c("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=bn),v.init(e,t)}),dr=c("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=xn(t)),v.init(e,t)}),mr=c("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Cn),v.init(e,t)}),gr=c("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=jn(t)),v.init(e,t)}),vr=c("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=$n),v.init(e,t)}),_r=c("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Sn),v.init(e,t),e._zod.bag.format="ipv4"}),yr=c("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=On),v.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),kr=c("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Pn),v.init(e,t)}),wr=c("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Nn),v.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[o,i]=r;if(!i)throw new Error;const s=Number(i);if(`${s}`!==i)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${o}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function He(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const br=c("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=An),v.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{He(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function zr(e){if(!We.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return He(n)}const $r=c("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=We),v.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{zr(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Tr=c("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Rn),v.init(e,t)});function Zr(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const Ir=c("$ZodJWT",(e,t)=>{v.init(e,t),e._zod.check=n=>{Zr(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Qe=c("$ZodNumber",(e,t)=>{k.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ln,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),n}}),Er=c("$ZodNumberFormat",(e,t)=>{Vn.init(e,t),Qe.init(e,t)}),Sr=c("$ZodUnknown",(e,t)=>{k.init(e,t),e._zod.parse=n=>n}),Or=c("$ZodNever",(e,t)=>{k.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function et(e,t,n){e.issues.length&&t.issues.push(...Me(n,e.issues)),t.value[n]=e.value}const Pr=c("$ZodArray",(e,t)=>{k.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const i=[];for(let s=0;s<o.length;s++){const a=o[s],u=t.element._zod.run({value:a,issues:[]},r);u instanceof Promise?i.push(u.then(l=>et(l,n,s))):et(u,n,s)}return i.length?Promise.all(i).then(()=>n):n}});function oe(e,t,n,r){e.issues.length&&t.issues.push(...Me(n,e.issues)),e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function tt(e){const t=Object.keys(e.shape);for(const r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const n=Xt(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function nt(e,t,n,r,o,i){const s=[],a=o.keySet,u=o.catchall._zod,l=u.def.type;for(const f in t){if(a.has(f))continue;if(l==="never"){s.push(f);continue}const p=u.run({value:t[f],issues:[]},r);p instanceof Promise?e.push(p.then(d=>oe(d,n,f,t))):oe(p,n,f,t)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}const Nr=c("$ZodObject",(e,t)=>{if(k.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const a=t.shape;Object.defineProperty(t,"shape",{get:()=>{const u={...a};return Object.defineProperty(t,"shape",{value:u}),u}})}const r=Q(()=>tt(t));g(e._zod,"propValues",()=>{const a=t.shape,u={};for(const l in a){const f=a[l]._zod;if(f.values){u[l]??(u[l]=new Set);for(const p of f.values)u[l].add(p)}}return u});const o=V,i=t.catchall;let s;e._zod.parse=(a,u)=>{s??(s=r.value);const l=a.value;if(!o(l))return a.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),a;a.value={};const f=[],p=s.shape;for(const d of s.keys){const Z=p[d]._zod.run({value:l[d],issues:[]},u);Z instanceof Promise?f.push(Z.then(ze=>oe(ze,a,d,l))):oe(Z,a,d,l)}return i?nt(f,l,a,u,r.value,e):f.length?Promise.all(f).then(()=>a):a}}),Ar=c("$ZodObjectJIT",(e,t)=>{Nr.init(e,t);const n=e._zod.parse,r=Q(()=>tt(t)),o=d=>{const y=new tr(["shape","payload","ctx"]),Z=r.value,ze=P=>{const S=De(P);return`shape[${S}]._zod.run({ value: input[${S}], issues: [] }, ctx)`};y.write("const input = payload.value;");const Rt=Object.create(null);let Ns=0;for(const P of Z.keys)Rt[P]=`key_${Ns++}`;y.write("const newResult = {};");for(const P of Z.keys){const S=Rt[P],K=De(P);y.write(`const ${S} = ${ze(P)};`),y.write(`
8
- if (${S}.issues.length) {
9
- payload.issues = payload.issues.concat(${S}.issues.map(iss => ({
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(", "),i=n==="left"||n==="right"?`${n} of`:n;this.add(`note ${i} ${r}: ${e.text}`)}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===`
4
+ `&&(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!==`
5
+ `;)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
+ `: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!==`
7
+ `;)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!==`
8
+ `&&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
+ `: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!==`
10
+ `;)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]!==`
11
+ `&&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
+ `).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(`
13
+ `))}}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(`
14
+ if (${O}.issues.length) {
15
+ payload.issues = payload.issues.concat(${O}.issues.map(iss => ({
10
16
  ...iss,
11
17
  path: iss.path ? [${K}, ...iss.path] : [${K}]
12
18
  })));
13
19
  }
14
20
 
15
21
 
16
- if (${S}.value === undefined) {
22
+ if (${O}.value === undefined) {
17
23
  if (${K} in input) {
18
24
  newResult[${K}] = undefined;
19
25
  }
20
26
  } else {
21
- newResult[${K}] = ${S}.value;
27
+ newResult[${K}] = ${O}.value;
22
28
  }
23
29
 
24
- `)}y.write("payload.value = newResult;"),y.write("return payload;");const As=y.compile();return(P,S)=>As(d,P,S)};let i;const s=V,a=!Ce.jitless,l=a&&Kt.value,f=t.catchall;let p;e._zod.parse=(d,y)=>{p??(p=r.value);const Z=d.value;return s(Z)?a&&l&&y?.async===!1&&y.jitless!==!0?(i||(i=o(t.shape)),d=i(d,y),f?nt([],Z,d,y,p,e):d):n(d,y):(d.issues.push({expected:"object",code:"invalid_type",input:Z,inst:e}),d)}});function rt(e,t,n,r){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const o=e.filter(i=>!U(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(s=>x(s,r,R())))}),t)}const ot=c("$ZodUnion",(e,t)=>{k.init(e,t),g(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),g(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),g(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),g(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>pe(i.source)).join("|")})$`)}});const n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(o,i)=>{if(n)return r(o,i);let s=!1;const a=[];for(const u of t.options){const l=u._zod.run({value:o.value,issues:[]},i);if(l instanceof Promise)a.push(l),s=!0;else{if(l.issues.length===0)return l;a.push(l)}}return s?Promise.all(a).then(u=>rt(u,o,e,i)):rt(a,o,e,i)}}),Rr=c("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,ot.init(e,t);const n=e._zod.parse;g(e._zod,"propValues",()=>{const o={};for(const i of t.options){const s=i._zod.propValues;if(!s||Object.keys(s).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const[a,u]of Object.entries(s)){o[a]||(o[a]=new Set);for(const l of u)o[a].add(l)}}return o});const r=Q(()=>{const o=t.options,i=new Map;for(const s of o){const a=s._zod.propValues?.[t.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const u of a){if(i.has(u))throw new Error(`Duplicate discriminator value "${String(u)}"`);i.set(u,s)}}return i});e._zod.parse=(o,i)=>{const s=o.value;if(!V(s))return o.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),o;const a=r.value.get(s?.[t.discriminator]);return a?a._zod.run(o,i):t.unionFallback?n(o,i):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:s,path:[t.discriminator],inst:e}),o)}}),Cr=c("$ZodIntersection",(e,t)=>{k.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,i=t.left._zod.run({value:o,issues:[]},r),s=t.right._zod.run({value:o,issues:[]},r);return i instanceof Promise||s instanceof Promise?Promise.all([i,s]).then(([u,l])=>it(n,u,l)):it(n,i,s)}});function _e(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(G(e)&&G(t)){const n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};for(const i of r){const s=_e(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],i=t[r],s=_e(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function it(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),U(e))return e;const r=_e(t.value,n.value);if(!r.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const jr=c("$ZodEnum",(e,t)=>{k.init(e,t);const n=je(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>qt.has(typeof o)).map(o=>typeof o=="string"?M(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{const s=o.value;return r.has(s)||o.issues.push({code:"invalid_value",values:n,input:s,inst:e}),o}}),xr=c("$ZodLiteral",(e,t)=>{if(k.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?M(r):r?M(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,o)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}}),Dr=c("$ZodTransform",(e,t)=>{k.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Re(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(s=>(n.value=s,n));if(o instanceof Promise)throw new L;return n.value=o,n}});function st(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Fr=c("$ZodOptional",(e,t)=>{k.init(e,t),e._zod.optin="optional",e._zod.optout="optional",g(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),g(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${pe(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>st(i,n.value)):st(o,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),Lr=c("$ZodNullable",(e,t)=>{k.init(e,t),g(e._zod,"optin",()=>t.innerType._zod.optin),g(e._zod,"optout",()=>t.innerType._zod.optout),g(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${pe(n.source)}|null)$`):void 0}),g(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),Mr=c("$ZodDefault",(e,t)=>{k.init(e,t),e._zod.optin="optional",g(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>at(i,t)):at(o,t)}});function at(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Ur=c("$ZodPrefault",(e,t)=>{k.init(e,t),e._zod.optin="optional",g(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),Jr=c("$ZodNonOptional",(e,t)=>{k.init(e,t),g(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>ct(i,e)):ct(o,e)}});function ct(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Vr=c("$ZodCatch",(e,t)=>{k.init(e,t),g(e._zod,"optin",()=>t.innerType._zod.optin),g(e._zod,"optout",()=>t.innerType._zod.optout),g(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(s=>x(s,r,R()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(i=>x(i,r,R()))},input:n.value}),n.issues=[]),n)}}),Gr=c("$ZodPipe",(e,t)=>{k.init(e,t),g(e._zod,"values",()=>t.in._zod.values),g(e._zod,"optin",()=>t.in._zod.optin),g(e._zod,"optout",()=>t.out._zod.optout),g(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=t.out._zod.run(n,r);return i instanceof Promise?i.then(s=>ie(s,t.in,r)):ie(i,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(i=>ie(i,t.out,r)):ie(o,t.out,r)}});function ie(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Wr=c("$ZodReadonly",(e,t)=>{k.init(e,t),g(e._zod,"propValues",()=>t.innerType._zod.propValues),g(e._zod,"values",()=>t.innerType._zod.values),g(e._zod,"optin",()=>t.innerType?._zod?.optin),g(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(ut):ut(o)}});function ut(e){return e.value=Object.freeze(e.value),e}const Br=c("$ZodCustom",(e,t)=>{$.init(e,t),k.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(i=>lt(i,n,r,e));lt(o,n,r,e)}});function lt(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(W(o))}}var ft;class Kr{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];if(this._map.set(t,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,t)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const o={...r,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function qr(){return new Kr}(ft=globalThis).__zod_globalRegistry??(ft.__zod_globalRegistry=qr());const B=globalThis.__zod_globalRegistry;function Xr(e,t){return new e({type:"string",...h(t)})}function Yr(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...h(t)})}function ht(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...h(t)})}function Hr(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...h(t)})}function Qr(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...h(t)})}function eo(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...h(t)})}function to(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...h(t)})}function no(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...h(t)})}function ro(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...h(t)})}function oo(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...h(t)})}function io(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...h(t)})}function so(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...h(t)})}function ao(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...h(t)})}function co(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...h(t)})}function uo(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...h(t)})}function lo(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...h(t)})}function fo(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...h(t)})}function ho(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...h(t)})}function po(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...h(t)})}function mo(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...h(t)})}function go(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...h(t)})}function vo(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...h(t)})}function _o(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...h(t)})}function yo(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...h(t)})}function ko(e,t){return new e({type:"string",format:"date",check:"string_format",...h(t)})}function wo(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...h(t)})}function bo(e,t){return new e({type:"string",format:"duration",check:"string_format",...h(t)})}function zo(e,t){return new e({type:"number",checks:[],...h(t)})}function $o(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...h(t)})}function To(e){return new e({type:"unknown"})}function Zo(e,t){return new e({type:"never",...h(t)})}function pt(e,t){return new Xe({check:"less_than",...h(t),value:e,inclusive:!1})}function ye(e,t){return new Xe({check:"less_than",...h(t),value:e,inclusive:!0})}function dt(e,t){return new Ye({check:"greater_than",...h(t),value:e,inclusive:!1})}function ke(e,t){return new Ye({check:"greater_than",...h(t),value:e,inclusive:!0})}function mt(e,t){return new Jn({check:"multiple_of",...h(t),value:e})}function gt(e,t){return new Gn({check:"max_length",...h(t),maximum:e})}function se(e,t){return new Wn({check:"min_length",...h(t),minimum:e})}function vt(e,t){return new Bn({check:"length_equals",...h(t),length:e})}function Io(e,t){return new Kn({check:"string_format",format:"regex",...h(t),pattern:e})}function Eo(e){return new qn({check:"string_format",format:"lowercase",...h(e)})}function So(e){return new Xn({check:"string_format",format:"uppercase",...h(e)})}function Oo(e,t){return new Yn({check:"string_format",format:"includes",...h(t),includes:e})}function Po(e,t){return new Hn({check:"string_format",format:"starts_with",...h(t),prefix:e})}function No(e,t){return new Qn({check:"string_format",format:"ends_with",...h(t),suffix:e})}function J(e){return new er({check:"overwrite",tx:e})}function Ao(e){return J(t=>t.normalize(e))}function Ro(){return J(e=>e.trim())}function Co(){return J(e=>e.toLowerCase())}function jo(){return J(e=>e.toUpperCase())}function xo(){return J(e=>Bt(e))}function Do(e,t,n){return new e({type:"array",element:t,...h(n)})}function Fo(e,t,n){return new e({type:"custom",check:"custom",fn:t,...h(n)})}function Lo(e){const t=Mo(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(W(r,n.value,t._zod.def));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),n.issues.push(W(o))}},e(n.value,n)));return t}function Mo(e,t){const n=new $({check:"custom",...h(t)});return n._zod.check=e,n}function _t(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??B,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function b(e,t,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s);const a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{const f={...n,schemaPath:[...n.schemaPath,e],path:n.path},p=e._zod.parent;if(p)s.ref=p,b(p,t,f),t.seen.get(p).isParent=!0;else if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,f);else{const d=s.schema,y=t.processors[o.type];if(!y)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);y(e,t,d,f)}}const u=t.metadataRegistry.get(e);return u&&Object.assign(s.schema,u),t.io==="input"&&z(e)&&(delete s.schema.examples,delete s.schema.default),t.io==="input"&&s.schema._prefault&&((r=s.schema).default??(r.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function yt(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=i=>{const s=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const f=e.external.registry.get(i[0])?.id,p=e.external.uri??(y=>y);if(f)return{ref:p(f)};const d=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=d,{defId:d,ref:`${p("__shared")}#/${s}/${d}`}}if(i[1]===n)return{ref:"#"};const u=`#/${s}/`,l=i[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+l}},o=i=>{if(i[1].schema.$ref)return;const s=i[1],{ref:a,defId:u}=r(i);s.def={...s.schema},u&&(s.defId=u);const l=s.schema;for(const f in l)delete l[f];l.$ref=a};if(e.cycles==="throw")for(const i of e.seen.entries()){const s=i[1];if(s.cycle)throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
30
+ `)}_.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>
25
31
 
26
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const i of e.seen.entries()){const s=i[1];if(t===i[0]){o(i);continue}if(e.external){const u=e.external.registry.get(i[0])?.id;if(t!==i[0]&&u){o(i);continue}}if(e.metadataRegistry.get(i[0])?.id){o(i);continue}if(s.cycle){o(i);continue}if(s.count>1&&e.reused==="ref"){o(i);continue}}}function kt(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=s=>{const a=e.seen.get(s),u=a.def??a.schema,l={...u};if(a.ref===null)return;const f=a.ref;if(a.ref=null,f){r(f);const p=e.seen.get(f).schema;p.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(p)):(Object.assign(u,p),Object.assign(u,l))}a.isParent||e.override({zodSchema:s,jsonSchema:u,path:a.path??[]})};for(const s of[...e.seen.entries()].reverse())r(s[0]);const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const s=e.external.registry.get(t)?.id;if(!s)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(s)}Object.assign(o,n.def??n.schema);const i=e.external?.defs??{};for(const s of e.seen.entries()){const a=s[1];a.def&&a.defId&&(i[a.defId]=a.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{const s=JSON.parse(JSON.stringify(o));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:ae(t,"input"),output:ae(t,"output")}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function z(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return z(r.element,n);if(r.type==="set")return z(r.valueType,n);if(r.type==="lazy")return z(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 z(r.innerType,n);if(r.type==="intersection")return z(r.left,n)||z(r.right,n);if(r.type==="record"||r.type==="map")return z(r.keyType,n)||z(r.valueType,n);if(r.type==="pipe")return z(r.in,n)||z(r.out,n);if(r.type==="object"){for(const o in r.shape)if(z(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(z(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(z(o,n))return!0;return!!(r.rest&&z(r.rest,n))}return!1}const Uo=(e,t={})=>n=>{const r=_t({...n,processors:t});return b(e,r),yt(r,e),kt(r,e)},ae=(e,t)=>n=>{const{libraryOptions:r,target:o}=n??{},i=_t({...r??{},target:o,io:t,processors:{}});return b(e,i),yt(i,e),kt(i,e)},Jo={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Vo=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:i,maximum:s,format:a,patterns:u,contentEncoding:l}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof s=="number"&&(o.maxLength=s),a&&(o.format=Jo[a]??a,o.format===""&&delete o.format),l&&(o.contentEncoding=l),u&&u.size>0){const f=[...u];f.length===1?o.pattern=f[0].source:f.length>1&&(o.allOf=[...f.map(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},Go=(e,t,n,r)=>{const o=n,{minimum:i,maximum:s,format:a,multipleOf:u,exclusiveMaximum:l,exclusiveMinimum:f}=e._zod.bag;typeof a=="string"&&a.includes("int")?o.type="integer":o.type="number",typeof f=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.minimum=f,o.exclusiveMinimum=!0):o.exclusiveMinimum=f),typeof i=="number"&&(o.minimum=i,typeof f=="number"&&t.target!=="draft-04"&&(f>=i?delete o.minimum:delete o.exclusiveMinimum)),typeof l=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.maximum=l,o.exclusiveMaximum=!0):o.exclusiveMaximum=l),typeof s=="number"&&(o.maximum=s,typeof l=="number"&&t.target!=="draft-04"&&(l<=s?delete o.maximum:delete o.exclusiveMaximum)),typeof u=="number"&&(o.multipleOf=u)},Wo=(e,t,n,r)=>{n.not={}},Bo=(e,t,n,r)=>{},Ko=(e,t,n,r)=>{const o=e._zod.def,i=je(o.entries);i.every(s=>typeof s=="number")&&(n.type="number"),i.every(s=>typeof s=="string")&&(n.type="string"),n.enum=i},qo=(e,t,n,r)=>{const o=e._zod.def,i=[];for(const s of o.values)if(s===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof s=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(s))}else i.push(s);if(i.length!==0)if(i.length===1){const s=i[0];n.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[s]:n.const=s}else i.every(s=>typeof s=="number")&&(n.type="number"),i.every(s=>typeof s=="string")&&(n.type="string"),i.every(s=>typeof s=="boolean")&&(n.type="boolean"),i.every(s=>s===null)&&(n.type="null"),n.enum=i},Xo=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Yo=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Ho=(e,t,n,r)=>{const o=n,i=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;typeof s=="number"&&(o.minItems=s),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=b(i.element,t,{...r,path:[...r.path,"items"]})},Qo=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object",o.properties={};const s=i.shape;for(const l in s)o.properties[l]=b(s[l],t,{...r,path:[...r.path,"properties",l]});const a=new Set(Object.keys(s)),u=new Set([...a].filter(l=>{const f=i.shape[l]._zod;return t.io==="input"?f.optin===void 0:f.optout===void 0}));u.size>0&&(o.required=Array.from(u)),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=b(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},ei=(e,t,n,r)=>{const o=e._zod.def,i=o.inclusive===!1,s=o.options.map((a,u)=>b(a,t,{...r,path:[...r.path,i?"oneOf":"anyOf",u]}));i?n.oneOf=s:n.anyOf=s},ti=(e,t,n,r)=>{const o=e._zod.def,i=b(o.left,t,{...r,path:[...r.path,"allOf",0]}),s=b(o.right,t,{...r,path:[...r.path,"allOf",1]}),a=l=>"allOf"in l&&Object.keys(l).length===1,u=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];n.allOf=u},ni=(e,t,n,r)=>{const o=e._zod.def,i=b(o.innerType,t,r),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},ri=(e,t,n,r)=>{const o=e._zod.def;b(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},oi=(e,t,n,r)=>{const o=e._zod.def;b(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},ii=(e,t,n,r)=>{const o=e._zod.def;b(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},si=(e,t,n,r)=>{const o=e._zod.def;b(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=s},ai=(e,t,n,r)=>{const o=e._zod.def,i=t.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;b(i,t,r);const s=t.seen.get(e);s.ref=i},ci=(e,t,n,r)=>{const o=e._zod.def;b(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},ui=(e,t,n,r)=>{const o=e._zod.def;b(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},li=c("ZodISODateTime",(e,t)=>{dr.init(e,t),_.init(e,t)});function fi(e){return yo(li,e)}const hi=c("ZodISODate",(e,t)=>{mr.init(e,t),_.init(e,t)});function pi(e){return ko(hi,e)}const di=c("ZodISOTime",(e,t)=>{gr.init(e,t),_.init(e,t)});function mi(e){return wo(di,e)}const gi=c("ZodISODuration",(e,t)=>{vr.init(e,t),_.init(e,t)});function vi(e){return bo(gi,e)}const I=c("ZodError",(e,t)=>{Je.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>an(e,n)},flatten:{value:n=>sn(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,fe,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,fe,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),_i=me(I),yi=ge(I),ki=te(I),wi=ne(I),bi=ln(I),zi=fn(I),$i=hn(I),Ti=pn(I),Zi=dn(I),Ii=mn(I),Ei=gn(I),Si=vn(I),w=c("ZodType",(e,t)=>(k.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:ae(e,"input"),output:ae(e,"output")}}),e.toJSONSchema=Uo(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(j(t,{checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]})),e.clone=(n,r)=>N(e,n,r),e.brand=()=>e,e.register=((n,r)=>(n.add(e,r),e)),e.parse=(n,r)=>_i(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>ki(e,n,r),e.parseAsync=async(n,r)=>yi(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>wi(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>bi(e,n,r),e.decode=(n,r)=>zi(e,n,r),e.encodeAsync=async(n,r)=>$i(e,n,r),e.decodeAsync=async(n,r)=>Ti(e,n,r),e.safeEncode=(n,r)=>Zi(e,n,r),e.safeDecode=(n,r)=>Ii(e,n,r),e.safeEncodeAsync=async(n,r)=>Ei(e,n,r),e.safeDecodeAsync=async(n,r)=>Si(e,n,r),e.refine=(n,r)=>e.check(ks(n,r)),e.superRefine=n=>e.check(ws(n)),e.overwrite=n=>e.check(J(n)),e.optional=()=>St(e),e.nullable=()=>Ot(e),e.nullish=()=>St(Ot(e)),e.nonoptional=n=>ps(e,n),e.array=()=>D(e),e.or=n=>we([e,n]),e.and=n=>os(e,n),e.transform=n=>Nt(e,as(n)),e.default=n=>ls(e,n),e.prefault=n=>hs(e,n),e.catch=n=>ms(e,n),e.pipe=n=>Nt(e,n),e.readonly=()=>_s(e),e.describe=n=>{const r=e.clone();return B.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){return B.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return B.get(e);const r=e.clone();return B.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),wt=c("_ZodString",(e,t)=>{ve.init(e,t),w.init(e,t),e._zod.processJSONSchema=(r,o,i)=>Vo(e,r,o);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...r)=>e.check(Io(...r)),e.includes=(...r)=>e.check(Oo(...r)),e.startsWith=(...r)=>e.check(Po(...r)),e.endsWith=(...r)=>e.check(No(...r)),e.min=(...r)=>e.check(se(...r)),e.max=(...r)=>e.check(gt(...r)),e.length=(...r)=>e.check(vt(...r)),e.nonempty=(...r)=>e.check(se(1,...r)),e.lowercase=r=>e.check(Eo(r)),e.uppercase=r=>e.check(So(r)),e.trim=()=>e.check(Ro()),e.normalize=(...r)=>e.check(Ao(...r)),e.toLowerCase=()=>e.check(Co()),e.toUpperCase=()=>e.check(jo()),e.slugify=()=>e.check(xo())}),Oi=c("ZodString",(e,t)=>{ve.init(e,t),wt.init(e,t),e.email=n=>e.check(Yr(Pi,n)),e.url=n=>e.check(no(Ni,n)),e.jwt=n=>e.check(_o(Bi,n)),e.emoji=n=>e.check(ro(Ai,n)),e.guid=n=>e.check(ht(bt,n)),e.uuid=n=>e.check(Hr(ce,n)),e.uuidv4=n=>e.check(Qr(ce,n)),e.uuidv6=n=>e.check(eo(ce,n)),e.uuidv7=n=>e.check(to(ce,n)),e.nanoid=n=>e.check(oo(Ri,n)),e.guid=n=>e.check(ht(bt,n)),e.cuid=n=>e.check(io(Ci,n)),e.cuid2=n=>e.check(so(ji,n)),e.ulid=n=>e.check(ao(xi,n)),e.base64=n=>e.check(mo(Vi,n)),e.base64url=n=>e.check(go(Gi,n)),e.xid=n=>e.check(co(Di,n)),e.ksuid=n=>e.check(uo(Fi,n)),e.ipv4=n=>e.check(lo(Li,n)),e.ipv6=n=>e.check(fo(Mi,n)),e.cidrv4=n=>e.check(ho(Ui,n)),e.cidrv6=n=>e.check(po(Ji,n)),e.e164=n=>e.check(vo(Wi,n)),e.datetime=n=>e.check(fi(n)),e.date=n=>e.check(pi(n)),e.time=n=>e.check(mi(n)),e.duration=n=>e.check(vi(n))});function E(e){return Xr(Oi,e)}const _=c("ZodStringFormat",(e,t)=>{v.init(e,t),wt.init(e,t)}),Pi=c("ZodEmail",(e,t)=>{ir.init(e,t),_.init(e,t)}),bt=c("ZodGUID",(e,t)=>{rr.init(e,t),_.init(e,t)}),ce=c("ZodUUID",(e,t)=>{or.init(e,t),_.init(e,t)}),Ni=c("ZodURL",(e,t)=>{sr.init(e,t),_.init(e,t)}),Ai=c("ZodEmoji",(e,t)=>{ar.init(e,t),_.init(e,t)}),Ri=c("ZodNanoID",(e,t)=>{cr.init(e,t),_.init(e,t)}),Ci=c("ZodCUID",(e,t)=>{ur.init(e,t),_.init(e,t)}),ji=c("ZodCUID2",(e,t)=>{lr.init(e,t),_.init(e,t)}),xi=c("ZodULID",(e,t)=>{fr.init(e,t),_.init(e,t)}),Di=c("ZodXID",(e,t)=>{hr.init(e,t),_.init(e,t)}),Fi=c("ZodKSUID",(e,t)=>{pr.init(e,t),_.init(e,t)}),Li=c("ZodIPv4",(e,t)=>{_r.init(e,t),_.init(e,t)}),Mi=c("ZodIPv6",(e,t)=>{yr.init(e,t),_.init(e,t)}),Ui=c("ZodCIDRv4",(e,t)=>{kr.init(e,t),_.init(e,t)}),Ji=c("ZodCIDRv6",(e,t)=>{wr.init(e,t),_.init(e,t)}),Vi=c("ZodBase64",(e,t)=>{br.init(e,t),_.init(e,t)}),Gi=c("ZodBase64URL",(e,t)=>{$r.init(e,t),_.init(e,t)}),Wi=c("ZodE164",(e,t)=>{Tr.init(e,t),_.init(e,t)}),Bi=c("ZodJWT",(e,t)=>{Ir.init(e,t),_.init(e,t)}),zt=c("ZodNumber",(e,t)=>{Qe.init(e,t),w.init(e,t),e._zod.processJSONSchema=(r,o,i)=>Go(e,r,o),e.gt=(r,o)=>e.check(dt(r,o)),e.gte=(r,o)=>e.check(ke(r,o)),e.min=(r,o)=>e.check(ke(r,o)),e.lt=(r,o)=>e.check(pt(r,o)),e.lte=(r,o)=>e.check(ye(r,o)),e.max=(r,o)=>e.check(ye(r,o)),e.int=r=>e.check($t(r)),e.safe=r=>e.check($t(r)),e.positive=r=>e.check(dt(0,r)),e.nonnegative=r=>e.check(ke(0,r)),e.negative=r=>e.check(pt(0,r)),e.nonpositive=r=>e.check(ye(0,r)),e.multipleOf=(r,o)=>e.check(mt(r,o)),e.step=(r,o)=>e.check(mt(r,o)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Ki(e){return zo(zt,e)}const qi=c("ZodNumberFormat",(e,t)=>{Er.init(e,t),zt.init(e,t)});function $t(e){return $o(qi,e)}const Xi=c("ZodUnknown",(e,t)=>{Sr.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Bo()});function Tt(){return To(Xi)}const Yi=c("ZodNever",(e,t)=>{Or.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Wo(e,n,r)});function Hi(e){return Zo(Yi,e)}const Qi=c("ZodArray",(e,t)=>{Pr.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ho(e,n,r,o),e.element=t.element,e.min=(n,r)=>e.check(se(n,r)),e.nonempty=n=>e.check(se(1,n)),e.max=(n,r)=>e.check(gt(n,r)),e.length=(n,r)=>e.check(vt(n,r)),e.unwrap=()=>e.element});function D(e,t){return Do(Qi,e,t)}const es=c("ZodObject",(e,t)=>{Ar.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Qo(e,n,r,o),g(e,"shape",()=>t.shape),e.keyof=()=>It(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Tt()}),e.loose=()=>e.clone({...e._zod.def,catchall:Tt()}),e.strict=()=>e.clone({...e._zod.def,catchall:Hi()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>en(e,n),e.safeExtend=n=>tn(e,n),e.merge=n=>nn(e,n),e.pick=n=>Ht(e,n),e.omit=n=>Qt(e,n),e.partial=(...n)=>rn(Et,e,n[0]),e.required=(...n)=>on(Pt,e,n[0])});function O(e,t){const n={type:"object",shape:e??{},...h(t)};return new es(n)}const Zt=c("ZodUnion",(e,t)=>{ot.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ei(e,n,r,o),e.options=t.options});function we(e,t){return new Zt({type:"union",options:e,...h(t)})}const ts=c("ZodDiscriminatedUnion",(e,t)=>{Zt.init(e,t),Rr.init(e,t)});function ns(e,t,n){return new ts({type:"union",options:t,discriminator:e,...h(n)})}const rs=c("ZodIntersection",(e,t)=>{Cr.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ti(e,n,r,o)});function os(e,t){return new rs({type:"intersection",left:e,right:t})}const be=c("ZodEnum",(e,t)=>{jr.init(e,t),w.init(e,t),e._zod.processJSONSchema=(r,o,i)=>Ko(e,r,o),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const i={};for(const s of r)if(n.has(s))i[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new be({...t,checks:[],...h(o),entries:i})},e.exclude=(r,o)=>{const i={...t.entries};for(const s of r)if(n.has(s))delete i[s];else throw new Error(`Key ${s} not found in enum`);return new be({...t,checks:[],...h(o),entries:i})}});function It(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new be({type:"enum",entries:n,...h(t)})}const is=c("ZodLiteral",(e,t)=>{xr.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>qo(e,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function ue(e,t){return new is({type:"literal",values:Array.isArray(e)?e:[e],...h(t)})}const ss=c("ZodTransform",(e,t)=>{Dr.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Yo(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Re(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(W(i,n.value,t));else{const s=i;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=e),n.issues.push(W(s))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n)):(n.value=o,n)}});function as(e){return new ss({type:"transform",transform:e})}const Et=c("ZodOptional",(e,t)=>{Fr.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ui(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function St(e){return new Et({type:"optional",innerType:e})}const cs=c("ZodNullable",(e,t)=>{Lr.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ni(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Ot(e){return new cs({type:"nullable",innerType:e})}const us=c("ZodDefault",(e,t)=>{Mr.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>oi(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ls(e,t){return new us({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Le(t)}})}const fs=c("ZodPrefault",(e,t)=>{Ur.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ii(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function hs(e,t){return new fs({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Le(t)}})}const Pt=c("ZodNonOptional",(e,t)=>{Jr.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ri(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function ps(e,t){return new Pt({type:"nonoptional",innerType:e,...h(t)})}const ds=c("ZodCatch",(e,t)=>{Vr.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>si(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ms(e,t){return new ds({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const gs=c("ZodPipe",(e,t)=>{Gr.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ai(e,n,r,o),e.in=t.in,e.out=t.out});function Nt(e,t){return new gs({type:"pipe",in:e,out:t})}const vs=c("ZodReadonly",(e,t)=>{Wr.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ci(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function _s(e){return new vs({type:"readonly",innerType:e})}const ys=c("ZodCustom",(e,t)=>{Br.init(e,t),w.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Xo(e,n)});function ks(e,t={}){return Fo(ys,e,t)}function ws(e){return Lo(e)}const A=we([E(),O({pattern:E(),flags:E().optional()})]),bs=O({kind:ue("fragment"),condition:A.optional(),operator:we([E(),D(E())]).optional()}),zs=O({kind:ue("participant"),name:A.optional(),id:A.optional(),stereotype:A.optional()}),$s=O({kind:ue("message"),text:A.optional(),from:A.optional(),to:A.optional()}),Ts=O({kind:ue("group"),name:A.optional()}),Zs=ns("kind",[bs,zs,$s,Ts]),Is=It(["focus","remove","resolve"]),Es=O({action:Is,selector:Zs}),Ss=O({name:E(),suffix:E().optional(),layers:D(Es)}),Os=O({input:D(E()),outputDir:E(),ignore:D(E()).optional(),lenses:D(Ss)}),At=O({version:Ki(),targets:D(Os)});function Ps(e){const t=At.safeParse(e);if(!t.success){const n=t.error.issues.map(r=>`[${r.path.join(".")}]: ${r.message}`).join(`
32
+ 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(`
27
33
  `);throw new Error(`Invalid Polagram Configuration:
28
- ${n}`)}return t.data}m.FocusFilter=Se,m.Matcher=Y,m.MermaidGeneratorVisitor=Ze,m.ParserFactory=q,m.Polagram=Gt,m.PolagramBuilder=Ae,m.PolagramConfigSchema=At,m.RemoveFilter=Oe,m.ResolveFilter=Pe,m.StructureCleaner=Ie,m.TransformationEngine=H,m.Traverser=Te,m.UnusedCleaner=Ee,m.applyLens=Vt,m.transformerRegistry=Ne,m.validateConfig=Ps,m.validateLens=Ut,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})}));
34
+ ${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"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polagram/core",
3
- "version": "0.0.3",
3
+ "version": "0.1.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -29,8 +29,17 @@
29
29
  "files": [
30
30
  "dist"
31
31
  ],
32
+ "scripts": {
33
+ "dev": "vite build --watch",
34
+ "build": "tsc && vite build",
35
+ "test": "vitest run",
36
+ "test:watch": "vitest",
37
+ "lint": "biome lint .",
38
+ "gen:docs": "node ../cli/dist/index.js generate -c docs/sequence/polagram.yml"
39
+ },
32
40
  "devDependencies": {
33
41
  "@types/js-yaml": "^4.0.9",
42
+ "@vitest/coverage-v8": "^4.0.16",
34
43
  "js-yaml": "^4.1.1",
35
44
  "typescript": "^5.9.3",
36
45
  "vite": "^7.3.0",
@@ -38,12 +47,5 @@
38
47
  },
39
48
  "dependencies": {
40
49
  "zod": "^4.2.1"
41
- },
42
- "scripts": {
43
- "dev": "vite build --watch",
44
- "build": "tsc && vite build",
45
- "test": "vitest run",
46
- "test:watch": "vitest",
47
- "gen:docs": "node ../cli/dist/index.js run -c docs/sequence/polagram.yml"
48
50
  }
49
- }
51
+ }