clone

a browser-first diagram editor with live svg previews, local drafts and encrypted, accountless sharing

migrate DBML into GraphViz Worker family

Dami committed fd6940d
commit
fd6940deead10cd06e32f6706adbd2357f29266f
parent
95f27d7b1900823fb46d88e542d90d12bad7a530
author
Dami <dami.etoile@gmail.com>
24 files changed, +379 -20
Mdiagramzip-render/README.md13+++---
Mdiagramzip-render/package-lock.json30+++++++++++++
Mdiagramzip-render/package.json2+
Adiagramzip-render/scripts/build-dbml.mjs53+++++++++++++++++++++++
Mdiagramzip-render/scripts/deploy-compatibility-units.mjs2+-
Mdiagramzip-render/scripts/smoke-units.mjs4+-
Mdiagramzip-render/src/adapters/edge.ts2+
Adiagramzip-render/src/adapters/edge/dbml.ts50++++++++++++++++++++++
Mdiagramzip-render/src/adapters/edge/types.ts2+-
Mdiagramzip-render/src/catalog.ts12++++-
Mdiagramzip-render/src/units/graphviz-family.ts12+++++
Adiagramzip-render/src/vendor/dbml-backend.d.ts1+
Adiagramzip-render/src/vendor/dbml-backend.js51++++++++++++++++++++++
Adiagramzip-render/src/vendor/dbml-entry.ts5++
Adiagramzip-render/src/vendor/dbml-provenance.md29+++++++++++++
Mdiagramzip-render/test/adapters.test.ts1+
Mdiagramzip-render/test/catalog.test.ts6+-
Adiagramzip-render/test/dbml.test.ts69++++++++++++++++++++++++++++++
Mdiagramzip-render/test/gateway.test.ts2+-
Adiagramzip-render/vendor-licenses/dbml-renderer-NOTICE45++++++++++++++++++++
Ddiagramzip-render/wrangler.compatibility/dbml.jsonc1-
Mdiagramzip-render/wrangler.units/graphviz-family.jsonc3+-
Mdiagramzip/src/renderer-units.js2+-
Mdiagramzip/test/renderer-units.test.js2+-
M diagramzip-render/README.md +7 -6
@@ -42,7 +42,7 @@ bundles, CSPs, deployments, and subdomains.
4242 4343 A unit may expose multiple catalog hostnames when those engines share the same4444 dependency stack. BlockDiag, SeqDiag, ActDiag, NwDiag, PacketDiag, and RackDiag45-share `blockdiag-family`; GraphViz and the ERD-to-DOT translator share45+share `blockdiag-family`; GraphViz, DBML, and the ERD-to-DOT translator share4646 `graphviz-family`; PlantUML and C4 PlantUML share `plantuml-family`; Vega and4747 Vega-Lite share `vega-family`. Requests are still selected only by a dedicated4848 hostname, so a caller cannot choose an unrelated engine in the body.
@@ -60,14 +60,15 @@ catalog engine.
6060 | --- | --- |6161 | Worker JavaScript | Bytefield, Nomnoml, Vega family (Vega and Vega-Lite → Vega), WaveDrom |6262 | Worker Python | BlockDiag family (BlockDiag, SeqDiag, ActDiag, NwDiag, PacketDiag, RackDiag); WireViz → DOT → GraphViz |63-| Worker WebAssembly | GraphViz family (GraphViz and ERD → DOT → GraphViz); Pikchr; Svgbob |63+| Worker WebAssembly | GraphViz family (GraphViz, DBML → DOT → GraphViz, and ERD → DOT → GraphViz); Pikchr; Svgbob |6464 | Sandboxed browser unit | Mermaid, BPMN, Excalidraw |65-| Compatibility unit | 10 dependency units covering the remaining 11 engines |65+| Compatibility unit | 9 dependency units covering the remaining 10 engines |6666 67-The current split is 19/30 engines off Fly and 11/30 still dependent on it.67+The current split is 20/30 engines off Fly and 10/30 still dependent on it.6868 Compatibility units are extraction seams, not final runtimes or fallbacks for69-an engine after cutover. DBML70-currently proxies because its published package mixes module formats. GraphViz69+an engine after cutover. DBML retains the upstream parser/checker/DOT model in70+an explicitly rebuilt Worker bundle, then shares the GraphViz-Wasm runtime.71+GraphViz7172 uses a precompiled Worker module; ERD lowers its upstream-compatible source7273 language to DOT and reuses the same in-process GraphViz runtime. WireViz runs7374 its vendored upstream parser and DOT composer in a separate Python Worker, then
M diagramzip-render/package-lock.json +30 -0
@@ -8,6 +8,7 @@
88 "name": "diagramzip-render",99 "version": "0.2.1",1010 "dependencies": {11+ "@softwaretechnik/dbml-renderer": "1.0.31",1112 "@viz-js/viz": "3.29.0",1213 "bytefield-svg": "1.11.0",1314 "json5": "2.2.3",
@@ -31,6 +32,12 @@
3132 "node": ">=24"3233 }3334 },35+ "node_modules/@aduh95/viz.js": {36+ "version": "3.4.0",37+ "resolved": "https://registry.npmjs.org/@aduh95/viz.js/-/viz.js-3.4.0.tgz",38+ "integrity": "sha512-KI2nVf9JdwWCXqK6RVf+9/096G7VWN4Z84mnynlyZKao2xQENW8WNEjLmvdlxS5X8PNWXFC1zqwm7tveOXw/4A==",39+ "license": "MIT"40+ },3441 "node_modules/@cloudflare/kv-asset-handler": {3542 "version": "0.5.0",3643 "resolved": "https://registry.npmjs.org/@cloudflare/kv-asset-handler/-/kv-asset-handler-0.5.0.tgz",
@@ -1552,6 +1559,29 @@
15521559 "url": "https://github.com/sindresorhus/is?sponsor=1"15531560 }15541561 },1562+ "node_modules/@softwaretechnik/dbml-renderer": {1563+ "version": "1.0.31",1564+ "resolved": "https://registry.npmjs.org/@softwaretechnik/dbml-renderer/-/dbml-renderer-1.0.31.tgz",1565+ "integrity": "sha512-ThoBDBc2/ODuCtvrHKLaZNHvBhSMdgTXae7z1hOgXn+i5Qdqp1tq5nK1rrkm7THfnAIXuZ3WxAeos1iRZSKeOw==",1566+ "license": "ISC",1567+ "dependencies": {1568+ "@aduh95/viz.js": "3.4.0",1569+ "yargs": "^17.7.2",1570+ "zod": "^3.25.67"1571+ },1572+ "bin": {1573+ "dbml-renderer": "lib/index.js"1574+ }1575+ },1576+ "node_modules/@softwaretechnik/dbml-renderer/node_modules/zod": {1577+ "version": "3.25.76",1578+ "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz",1579+ "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==",1580+ "license": "MIT",1581+ "funding": {1582+ "url": "https://github.com/sponsors/colinhacks"1583+ }1584+ },15551585 "node_modules/@speed-highlight/core": {15561586 "version": "1.2.24",15571587 "resolved": "https://registry.npmjs.org/@speed-highlight/core/-/core-1.2.24.tgz",
M diagramzip-render/package.json +2 -0
A diagramzip-render/scripts/build-dbml.mjs +53 -0
@@ -0,0 +1,53 @@
1+import { readdir, readFile } from 'node:fs/promises'2+import { build } from 'esbuild'3+4+const rendererPath = new URL('../node_modules/@softwaretechnik/dbml-renderer/lib/renderer.js', import.meta.url)5+const upstreamRenderer = await readFile(rendererPath, 'utf8')6+const rendererPattern = /const render = \(input, format\) => \{[\s\S]*?\n\};/7+if (!rendererPattern.test(upstreamRenderer)) {8+ throw new Error('DBML renderer layout changed; review the Viz-free repack before rebuilding.')9+}10+const dotOnlyRenderer = upstreamRenderer.replace(rendererPattern, `const render = (input, format) => {11+ if (format !== "dot") throw new Error("The edge DBML bundle only supports DOT lowering.");12+ return dot(input);13+};`)14+const parserPath = new URL('../node_modules/@softwaretechnik/dbml-renderer/lib/parser.js', import.meta.url)15+const upstreamParser = await readFile(parserPath, 'utf8')16+if (!upstreamParser.includes('console.debug(peggyErr);')) {17+ throw new Error('DBML parser layout changed; review the debug suppression before rebuilding.')18+}19+const quietParser = upstreamParser.replace(' console.debug(peggyErr);\n', '')20+21+await build({22+ entryPoints: ['src/vendor/dbml-entry.ts'],23+ bundle: true,24+ format: 'esm',25+ platform: 'node',26+ minify: true,27+ outfile: 'src/vendor/dbml-backend.js',28+ plugins: [{29+ name: 'dbml-dot-only',30+ setup(plugin) {31+ plugin.onLoad({ filter: /[\\/]@softwaretechnik[\\/]dbml-renderer[\\/]lib[\\/]renderer\.js$/ }, () => ({32+ contents: dotOnlyRenderer,33+ loader: 'js',34+ }))35+ plugin.onLoad({ filter: /[\\/]@softwaretechnik[\\/]dbml-renderer[\\/]lib[\\/]parser\.js$/ }, () => ({36+ contents: quietParser,37+ loader: 'js',38+ }))39+ },40+ }],41+})42+43+const { dbmlToDot } = await import(new URL(`../src/vendor/dbml-backend.js?build=${Date.now()}`, import.meta.url))44+const examplesPath = new URL('../node_modules/@softwaretechnik/dbml-renderer/examples/', import.meta.url)45+const examples = (await readdir(examplesPath)).filter(filename => filename.endsWith('.dbml')).sort()46+if (examples.length < 20) throw new Error('DBML upstream example corpus is incomplete.')47+for (const filename of examples) {48+ const source = await readFile(new URL(filename, examplesPath), 'utf8')49+ const expectedDot = await readFile(new URL(`${filename}.dot`, examplesPath), 'utf8')50+ if (dbmlToDot(source) !== expectedDot) {51+ throw new Error(`DBML edge bundle differs from upstream expected DOT for ${filename}.`)52+ }53+}
M diagramzip-render/scripts/deploy-compatibility-units.mjs +1 -1
M diagramzip-render/scripts/smoke-units.mjs +3 -1
M diagramzip-render/src/adapters/edge.ts +2 -0
A diagramzip-render/src/adapters/edge/dbml.ts +50 -0
@@ -0,0 +1,50 @@
1+import { RenderError } from '../../errors'2+import { dbmlToDot } from '../../vendor/dbml-backend.js'3+import type { RendererAdapter } from '../../types'4+import { edgeResult } from './types'5+import { renderGraphvizSource } from './graphviz'6+7+const VERSION = 'dbml@1.0.31+graphviz@15.1.1'8+const MAX_SOURCE_BYTES = 262_1449+const MAX_DECLARATIONS = 2_00010+const MAX_REFERENCES = 10_00011+const MAX_DOT_BYTES = 4_194_30412+13+function preflight(source: string): void {14+ if (new TextEncoder().encode(source).byteLength > MAX_SOURCE_BYTES) {15+ throw new RenderError(413, 'request_too_large', 'DBML source is too large for the edge renderer.')16+ }17+ const declarations = source.match(/^\s*(?:Table|TableGroup|Enum)\b/gm)?.length ?? 018+ if (declarations > MAX_DECLARATIONS) {19+ throw new RenderError(413, 'request_too_large', 'DBML contains too many declarations for the edge renderer.')20+ }21+ const references = source.match(/^\s*Ref\b/gm)?.length ?? 022+ if (references > MAX_REFERENCES) {23+ throw new RenderError(413, 'request_too_large', 'DBML contains too many references for the edge renderer.')24+ }25+}26+27+export const dbmlAdapter: RendererAdapter = {28+ id: 'dbml',29+ runtime: 'edge-wasm',30+ version: VERSION,31+ async render(request, signal) {32+ if (signal.aborted) throw signal.reason33+ if (Object.keys(request.options).length > 0) {34+ throw new RenderError(400, 'invalid_options', 'DBML does not accept renderer options.')35+ }36+ try {37+ preflight(request.source)38+ const dot = dbmlToDot(request.source)39+ if (new TextEncoder().encode(dot).byteLength > MAX_DOT_BYTES) {40+ throw new RenderError(413, 'output_too_large', 'DBML produced too large a GraphViz model.')41+ }42+ if (signal.aborted) throw signal.reason43+ return edgeResult('dbml', VERSION, await renderGraphvizSource(dot), 'edge-wasm')44+ } catch (error) {45+ if (error instanceof RenderError) throw error46+ const message = error instanceof Error ? error.message : String(error)47+ throw new RenderError(422, 'render_failed', message.slice(0, 500) || 'DBML could not render this source.')48+ }49+ },50+}
M diagramzip-render/src/adapters/edge/types.ts +1 -1
M diagramzip-render/src/catalog.ts +9 -3
@@ -23,7 +23,7 @@ const targetRuntime: Record<EngineId, EngineRuntime> = {
2323 rackdiag: 'edge-python',2424 bpmn: 'client',2525 bytefield: 'edge-js',26- dbml: 'edge-js',26+ dbml: 'edge-wasm',2727 diagramsnet: 'client',2828 ditaa: 'origin',2929 erd: 'edge-wasm',
@@ -58,6 +58,7 @@ const activeRuntime: Partial<Record<EngineId, EngineRuntime>> = {
5858 packetdiag: 'edge-python',5959 rackdiag: 'edge-python',6060 graphviz: 'edge-wasm',61+ dbml: 'edge-wasm',6162 pikchr: 'edge-wasm',6263 svgbob: 'edge-wasm',6364 erd: 'edge-wasm',
@@ -79,7 +80,8 @@ const versions: Partial<Record<EngineId, string>> = {
7980 nwdiag: 'nwdiag@3.0.0/python-worker-1',8081 packetdiag: 'packetdiag@3.0.0/python-worker-1',8182 rackdiag: 'rackdiag@3.0.0/python-worker-1',82- graphviz: 'graphviz@15.1.1/edge-wasm-1',83+ graphviz: 'graphviz@15.1.1/edge-wasm-2',84+ dbml: 'dbml@1.0.31+graphviz@15.1.1/edge-wasm-2',8385 pikchr: 'pikchr@85e65b9686/edge-wasm-1',8486 svgbob: 'svgbob@0.7.6/edge-wasm-1',8587 erd: 'erd@0.2.1.0+graphviz@15.1.1/edge-wasm-1',
@@ -106,7 +108,11 @@ const losses: Partial<Record<EngineId, readonly string[]>> = {
106108 'The edge build is compiled from upstream svgbob 0.7.6 at pinned commit 04a9d85c4b1879051f205e9e434e058864c3d36f.',107109 ],108110 bytefield: ['Only SVG is in the v2 rendering contract.'],109- dbml: ['The upstream package mixes ESM files into a CommonJS package and remains on the origin until it can be safely repackaged.'],111+ dbml: [112+ 'Only SVG is supported.',113+ 'DBML URLs are lowered to GraphViz HREFs, then external links are removed by SVG sanitization.',114+ 'The translated graph uses GraphViz 15.1.1 versus the compatibility DBML image Viz.js/GraphViz 2.47.0; output differences are possible.',115+ ],110116 excalidraw: [111117 'External resources are blocked; image data must be embedded in the scene.',112118 'Font subsetting is disabled by the sandbox policy, so exports embed the complete self-hosted font.',
M diagramzip-render/src/units/graphviz-family.ts +12 -0
A diagramzip-render/src/vendor/dbml-backend.d.ts +1 -0
A diagramzip-render/src/vendor/dbml-backend.js +51 -0
@@ -0,0 +1,51 @@
1+var vi=Object.create;var xr=Object.defineProperty;var yi=Object.getOwnPropertyDescriptor;var _i=Object.getOwnPropertyNames;var bi=Object.getPrototypeOf,Ti=Object.prototype.hasOwnProperty;var B=(s,t)=>()=>{try{return t||s((t={exports:{}}).exports,t),t.exports}catch(e){throw t=0,e}};var xi=(s,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of _i(t))!Ti.call(s,u)&&u!==e&&xr(s,u,{get:()=>t[u],enumerable:!(i=yi(t,u))||i.enumerable});return s};var Ci=(s,t,e)=>(e=s!=null?vi(bi(s)):{},xi(t||!s||!s.__esModule?xr(e,"default",{value:s,enumerable:!0}):e,s));var as=B($t=>{"use strict";Object.defineProperty($t,"__esModule",{value:!0});$t.fullName=void 0;var Ii=s=>s.schema?`${s.schema}.${s.name}`:s.name;$t.fullName=Ii});var Ir=B((gu,Cr)=>{"use strict";function $i(s,t){function e(){this.constructor=s}e.prototype=t.prototype,s.prototype=new e}function me(s,t,e,i){var u=Error.call(this,s);return Object.setPrototypeOf&&Object.setPrototypeOf(u,me.prototype),u.expected=t,u.found=e,u.location=i,u.name="SyntaxError",u}$i(me,Error);function ns(s,t,e){return e=e||" ",s.length>t?s:(t-=s.length,e+=e.repeat(t),s+e.slice(0,t))}me.prototype.format=function(s){var t="Error: "+this.message;if(this.location){var e=null,i;for(i=0;i<s.length;i++)if(s[i].source===this.location.source){e=s[i].text.split(/\r\n|\n|\r/g);break}var u=this.location.start,l=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(u):u,g=this.location.source+":"+l.line+":"+l.column;if(e){var m=this.location.end,x=ns("",l.line.toString().length," "),b=e[u.line-1],Z=u.line===m.line?m.column:b.length+1,L=Z-u.column||1;t+=`2+ --> `+g+`3+`+x+` |4+`+l.line+" | "+b+`5+`+x+" | "+ns("",u.column-1," ")+ns("",L,"^")}else t+=`6+ at `+g}return t};me.buildMessage=function(s,t){var e={literal:function(b){return'"'+u(b.text)+'"'},class:function(b){var Z=b.parts.map(function(L){return Array.isArray(L)?l(L[0])+"-"+l(L[1]):l(L)});return"["+(b.inverted?"^":"")+Z.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(b){return b.description}};function i(b){return b.charCodeAt(0).toString(16).toUpperCase()}function u(b){return b.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(Z){return"\\x0"+i(Z)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(Z){return"\\x"+i(Z)})}function l(b){return b.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(Z){return"\\x0"+i(Z)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(Z){return"\\x"+i(Z)})}function g(b){return e[b.type](b)}function m(b){var Z=b.map(g),L,ee;if(Z.sort(),Z.length>0){for(L=1,ee=1;L<Z.length;L++)Z[L-1]!==Z[L]&&(Z[ee]=Z[L],ee++);Z.length=ee}switch(Z.length){case 1:return Z[0];case 2:return Z[0]+" or "+Z[1];default:return Z.slice(0,-1).join(", ")+", or "+Z[Z.length-1]}}function x(b){return b?'"'+u(b)+'"':"end of input"}return"Expected "+m(s)+" but "+x(t)+" found."};function Zi(s,t){t=t!==void 0?t:{};var e={},i=t.grammarSource,u={File:hr},l=hr,g="project",m="{",x="}",b="note",Z="table",L="as",ee="[",Te="]",ut=".",Lt="(",ce=",",Vt=")",na="indexes",ia="tablegroup",oa="ref",Mt=":",ua="-",$s="<>",la="enum",lt='"',re="'''",Zs="'",dt="\\'",ct='\\"',ws="//",As="/*",fe="*/",ks="`",Os=`7+`,da="\r",Ue=/^[a-zA-Z0-9_,]/,ca=/^[<>]/,Ns=/^[a-zA-Z0-9_]/,Es=/^[^"\n\r]/,ft=/^[^'\\]/,pt=/^[\\]/,ht=/^[^"\\]/,js=/^[^\n\r]/,Ps=/^[^,\]:]/,Rs=/^[^,\]]/,Ss=/^[^`]/,Ds=/^[ \t]/,Ls=/^[ \t\n\r]/,fa=S("Project",!0),xe=S("{",!1),Ce=S("}",!1),pa=S("Note",!0),ha=S("Table",!0),ma=S("as",!1),Ut=S("[",!1),Fe=W([["a","z"],["A","Z"],["0","9"],"_",","],!1,!1),Ft=S("]",!1),mt=S(".",!1),Bt=S("(",!1),pe=S(",",!1),zt=S(")",!1),ga=S("Indexes",!0),va=S("TableGroup",!0),ya=S("Ref",!0),qt=S(":",!1),_a=S("-",!1),ba=S("<>",!1),Ta=W(["<",">"],!1,!1),xa=S("Enum",!0),Vs=W([["a","z"],["A","Z"],["0","9"],"_"],!1,!1),gt=S('"',!1),Ms=W(['"',`8+`,"\r"],!0,!1),Qe=S("'''",!1),Ie=Rn(),Us=S("'",!1),vt=W(["'","\\"],!0,!1),Fs=S("\\'",!1),yt=W(["\\"],!1,!1),_t=W(['"',"\\"],!0,!1),Bs=S('\\"',!1),Ca=S("//",!1),Ia=S("/*",!1),bt=S("*/",!1),zs=W([`9+`,"\r"],!0,!1),qs=W([",","]",":"],!0,!1),Gs=W([",","]"],!0,!1),Ws=S("`",!1),Ks=W(["`"],!0,!1),$a=Ct("space"),Ys=W([" "," "],!1,!1),Za=Ct("whitespace"),wa=Ct("pure whitespace"),Js=W([" "," ",`10+`,"\r"],!1,!1),Hs=S(`11+`,!1),Aa=S("\r",!1),ka=function(r){return r.filter(n=>n)},Oa=function(){},Na=function(r){return r},Ea=function(r,n){return{type:"project",name:r,options:n}},ja=function(r,n){return{type:"note",name:r,note:n}},Pa=function(r,n,d,o){return{type:"table",...r,alias:n,items:o,settings:d}},Ra=function(r){return r},Qs=function(r,n){return n},Sa=function(r,n){return[r,...n]},Da=function(r){return{type:"option",option:r}},La=function(r,n,d){return{type:"column",name:r,data:n,settings:d}},Xs=function(r,n){return`[${n}]`},Va=function(r,n){return r+n.join("")},Ma=function(r,n){return r+"."+n},er=function(r,n,d){return d},Ua=function(r,n,d){return[n,...d]},Fa=function(r,n){return`${r}(${n.join(",")})`},Ba=function(r){return{type:"indices",indices:r}},tr=function(r,n){return n},za=function(r,n){return[r,...n]},qa=function(r){return[r]},Ga=function(r){return[r]},Wa=function(r,n){return{columns:r,settings:n}},sr=function(r,n){return n},Ka=function(r,n){return[r,...n]},Ya=function(r){return r},Ja=function(r,n,d){return{type:"group",name:r,items:d,settings:n}},rr=function(r,n){return n},Ha=function(r,n){return[r,...n]},Qa=function(r){return{type:"option",option:r}},Xa=function(r){return{type:"table",...r}},en=function(r,n,d,o,f){return{type:"ref",cardinality:d,from:n,to:o,settings:f}},tn=function(r){return r},sn=function(r){return r},rn=function(r,n){return{...r,columns:n}},an=function(r){return[r]},ar=function(r,n){return n},nn=function(r,n){return[r,...n]},on=function(r){return r},un=function(r,n){return{type:"enum",...r,items:n}},nr=function(r,n){return n},ln=function(r,n){return[r,...n].filter(d=>d)},dn=function(r,n){return{type:"value",name:r,settings:n}},cn=function(r,n){return{schema:r,name:n}},fn=function(r){return{schema:null,name:r}},pn=function(r){return r},hn=function(){return""},mn=function(r){return r},ir=function(r,n){return n},gn=function(r,n){return[r,...n].join("")},or=function(){return"'"},vn=function(r){return r.join("")},ur=function(){return'"'},yn=function(r){return r.join("")},_n=function(r){return{type:"comment",comment:r}},bn=function(r){return r},Tn=function(){return""},xn=function(r){return r},lr=function(r,n){return n},Cn=function(r,n){return[r,...n].join("")},In=function(r){return r},dr=function(r,n){return n},$n=function(r,n){return[r,...n].reduce((d,o)=>Object.assign(d,o),{})},Zn=function(r,n){return n},wn=function(r,n){return{[r]:n}},An=function(){return xt().trim().toLowerCase()},kn=function(){return xt().trim()},On=function(){return xt()},cr=function(r,n){return n},Nn=function(r,n){return[r,...n].reduce((d,o)=>Object.assign(d,o),{})},En=function(r,n){return{[r]:n}},jn=function(r,n){return{[r]:n}},Pn=function(){return xt().trim().toLowerCase()},a=t.peg$currPos|0,T=a,Be=[{line:1,column:1}],te=a,Tt=t.peg$maxFailExpected||[],v=t.peg$silentFails|0,Xe;if(t.startRule){if(!(t.startRule in u))throw new Error(`Can't start parsing from rule "`+t.startRule+'".');l=u[t.startRule]}function xt(){return s.substring(T,a)}function lu(){return T}function du(){return{source:i,start:T,end:a}}function cu(){return et(T,a)}function fu(r,n){throw n=n!==void 0?n:et(T,a),pr([Ct(r)],s.substring(T,a),n)}function pu(r,n){throw n=n!==void 0?n:et(T,a),Dn(r,n)}function S(r,n){return{type:"literal",text:r,ignoreCase:n}}function W(r,n,d){return{type:"class",parts:r,inverted:n,ignoreCase:d}}function Rn(){return{type:"any"}}function Sn(){return{type:"end"}}function Ct(r){return{type:"other",description:r}}function fr(r){var n=Be[r],d;if(n)return n;if(r>=Be.length)d=Be.length-1;else for(d=r;!Be[--d];);for(n=Be[d],n={line:n.line,column:n.column};d<r;)s.charCodeAt(d)===10?(n.line++,n.column=1):n.column++,d++;return Be[r]=n,n}function et(r,n,d){var o=fr(r),f=fr(n),c={source:i,start:{offset:r,line:o.line,column:o.column},end:{offset:n,line:f.line,column:f.column}};return d&&i&&typeof i.offset=="function"&&(c.start=i.offset(c.start),c.end=i.offset(c.end)),c}function y(r){a<te||(a>te&&(te=a,Tt=[]),Tt.push(r))}function Dn(r,n){return new me(r,null,null,n)}function pr(r,n,d){return new me(me.buildMessage(r,n),r,n,d)}function hr(){var r,n,d;if(r=a,n=[],d=mr(),d!==e)for(;d!==e;)n.push(d),d=mr();else n=e;return n!==e&&(T=r,n=ka(n)),r=n,r}function mr(){var r,n,d,o;return r=a,n=k(),d=It(),d===e&&(d=Ln(),d===e&&(d=Vn(),d===e&&(d=Mn(),d===e&&(d=Yn(),d===e&&(d=Hn(),d===e&&(d=ti(),d===e&&(d=a,o=rs(),o!==e&&(T=d,o=Oa()),d=o))))))),d!==e?(T=r,r=Na(d)):(a=r,r=e),r}function Ln(){var r,n,d,o,f,c,_,N,w,R;return r=a,n=s.substr(a,7),n.toLowerCase()===g?a+=7:(n=e,v===0&&y(fa)),n!==e?(d=k(),o=F(),o===e&&(o=null),f=D(),s.charCodeAt(a)===123?(c=m,a++):(c=e,v===0&&y(xe)),c!==e?(_=D(),N=mi(),w=D(),s.charCodeAt(a)===125?(R=x,a++):(R=e,v===0&&y(Ce)),R!==e?(T=r,r=Ea(o,N)):(a=r,r=e)):(a=r,r=e)):(a=r,r=e),r}function Vn(){var r,n,d,o,f,c,_,N,w,R;return r=a,n=s.substr(a,4),n.toLowerCase()===b?a+=4:(n=e,v===0&&y(pa)),n!==e?(d=k(),o=F(),o!==e?(f=D(),s.charCodeAt(a)===123?(c=m,a++):(c=e,v===0&&y(xe)),c!==e?(_=D(),N=tt(),N!==e?(w=D(),s.charCodeAt(a)===125?(R=x,a++):(R=e,v===0&&y(Ce)),R!==e?(T=r,r=ja(o,N)):(a=r,r=e)):(a=r,r=e)):(a=r,r=e)):(a=r,r=e)):(a=r,r=e),r}function Mn(){var r,n,d,o,f,c,_,N,w,R,M,K,ne,he;return r=a,n=s.substr(a,5),n.toLowerCase()===Z?a+=5:(n=e,v===0&&y(ha)),n!==e?(d=k(),o=Xt(),o!==e?(f=k(),c=Un(),c===e&&(c=null),_=k(),N=ze(),N===e&&(N=null),w=D(),s.charCodeAt(a)===123?(R=m,a++):(R=e,v===0&&y(xe)),R!==e?(M=D(),K=Fn(),ne=D(),s.charCodeAt(a)===125?(he=x,a++):(he=e,v===0&&y(Ce)),he!==e?(T=r,r=Pa(o,c,N,K)):(a=r,r=e)):(a=r,r=e)):(a=r,r=e)):(a=r,r=e),r}function Un(){var r,n,d,o;return r=a,s.substr(a,2)===L?(n=L,a+=2):(n=e,v===0&&y(ma)),n!==e?(d=k(),o=F(),o!==e?(T=r,r=Ra(o)):(a=r,r=e)):(a=r,r=e),r}function Fn(){var r,n,d,o,f,c,_;if(r=a,n=Gt(),n!==e){for(d=[],o=a,f=ae(),f!==e?(c=D(),_=Gt(),_!==e?(T=o,o=Qs(n,_)):(a=o,o=e)):(a=o,o=e);o!==e;)d.push(o),o=a,f=ae(),f!==e?(c=D(),_=Gt(),_!==e?(T=o,o=Qs(n,_)):(a=o,o=e)):(a=o,o=e);T=r,r=Sa(n,d)}else a=r,r=e;return r===e&&(r=null),r}function Gt(){var r,n;return r=Bn(),r===e&&(r=Gn(),r===e&&(r=a,n=st(),n!==e&&(T=r,n=Da(n)),r=n)),r}function Bn(){var r,n,d,o,f,c;return r=a,n=F(),n!==e?(d=k(),o=gr(),o!==e?(f=k(),c=ze(),c===e&&(c=null),T=r,r=La(n,o,c)):(a=r,r=e)):(a=r,r=e),r}function gr(){var r,n,d,o,f,c,_,N,w;if(r=a,n=qn(),n===e&&(n=zn(),n===e&&(n=Wt())),n!==e){if(d=[],o=a,s.charCodeAt(a)===91?(f=ee,a++):(f=e,v===0&&y(Ut)),f!==e){for(c=k(),_=a,N=[],w=s.charAt(a),Ue.test(w)?a++:(w=e,v===0&&y(Fe));w!==e;)N.push(w),w=s.charAt(a),Ue.test(w)?a++:(w=e,v===0&&y(Fe));_=s.substring(_,a),N=k(),s.charCodeAt(a)===93?(w=Te,a++):(w=e,v===0&&y(Ft)),w!==e?(T=o,o=Xs(n,_)):(a=o,o=e)}else a=o,o=e;for(;o!==e;)if(d.push(o),o=a,s.charCodeAt(a)===91?(f=ee,a++):(f=e,v===0&&y(Ut)),f!==e){for(c=k(),_=a,N=[],w=s.charAt(a),Ue.test(w)?a++:(w=e,v===0&&y(Fe));w!==e;)N.push(w),w=s.charAt(a),Ue.test(w)?a++:(w=e,v===0&&y(Fe));_=s.substring(_,a),N=k(),s.charCodeAt(a)===93?(w=Te,a++):(w=e,v===0&&y(Ft)),w!==e?(T=o,o=Xs(n,_)):(a=o,o=e)}else a=o,o=e;T=r,r=Va(n,d)}else a=r,r=e;return r}function zn(){var r,n,d,o,f,c;return r=a,n=F(),n!==e?(d=k(),s.charCodeAt(a)===46?(o=ut,a++):(o=e,v===0&&y(mt)),o!==e?(f=k(),c=Wt(),c!==e?(T=r,r=Ma(n,c)):(a=r,r=e)):(a=r,r=e)):(a=r,r=e),r}function Wt(){var r,n,d;if(r=br(),r===e){if(r=a,n=[],d=s.charAt(a),Ue.test(d)?a++:(d=e,v===0&&y(Fe)),d!==e)for(;d!==e;)n.push(d),d=s.charAt(a),Ue.test(d)?a++:(d=e,v===0&&y(Fe));else n=e;n!==e?r=s.substring(r,a):r=n}return r}function qn(){var r,n,d,o,f,c,_,N,w,R,M,K,ne;if(r=a,n=Wt(),n!==e)if(d=k(),s.charCodeAt(a)===40?(o=Lt,a++):(o=e,v===0&&y(Bt)),o!==e){if(f=k(),c=a,_=Kt(),_!==e){for(N=[],w=a,R=k(),s.charCodeAt(a)===44?(M=ce,a++):(M=e,v===0&&y(pe)),M!==e?(K=k(),ne=Kt(),ne!==e?(T=w,w=er(n,_,ne)):(a=w,w=e)):(a=w,w=e);w!==e;)N.push(w),w=a,R=k(),s.charCodeAt(a)===44?(M=ce,a++):(M=e,v===0&&y(pe)),M!==e?(K=k(),ne=Kt(),ne!==e?(T=w,w=er(n,_,ne)):(a=w,w=e)):(a=w,w=e);T=c,c=Ua(n,_,N)}else a=c,c=e;c===e&&(c=null),_=k(),s.charCodeAt(a)===41?(N=Vt,a++):(N=e,v===0&&y(zt)),N!==e?(T=r,r=Fa(n,c)):(a=r,r=e)}else a=r,r=e;else a=r,r=e;return r}function Kt(){var r;return r=gr(),r===e&&(r=tt()),r}function Gn(){var r,n,d,o,f,c,_,N;return r=a,n=s.substr(a,7),n.toLowerCase()===na?a+=7:(n=e,v===0&&y(ga)),n!==e?(d=D(),s.charCodeAt(a)===123?(o=m,a++):(o=e,v===0&&y(xe)),o!==e?(f=D(),c=Wn(),_=D(),s.charCodeAt(a)===125?(N=x,a++):(N=e,v===0&&y(Ce)),N!==e?(T=r,r=Ba(c)):(a=r,r=e)):(a=r,r=e)):(a=r,r=e),r}function Wn(){var r,n,d,o,f,c,_;if(r=a,n=Yt(),n!==e){for(d=[],o=a,f=ae(),f!==e?(c=D(),_=Yt(),_!==e?(T=o,o=tr(n,_)):(a=o,o=e)):(a=o,o=e);o!==e;)d.push(o),o=a,f=ae(),f!==e?(c=D(),_=Yt(),_!==e?(T=o,o=tr(n,_)):(a=o,o=e)):(a=o,o=e);T=r,r=za(n,d)}else a=r,r=e;return r===e&&(r=null),r}function Yt(){var r,n,d,o;return r=a,n=a,d=ts(),d!==e&&(T=n,d=qa(d)),n=d,n===e&&(n=a,d=F(),d!==e&&(T=n,d=Ga(d)),n=d,n===e&&(n=Kn())),n!==e?(d=k(),o=ze(),o===e&&(o=null),T=r,r=Wa(n,o)):(a=r,r=e),r}function Kn(){var r,n,d,o,f,c,_,N,w,R,M;if(r=a,s.charCodeAt(a)===40?(n=Lt,a++):(n=e,v===0&&y(Bt)),n!==e){if(d=k(),o=a,f=Jt(),f!==e){for(c=[],_=a,N=k(),s.charCodeAt(a)===44?(w=ce,a++):(w=e,v===0&&y(pe)),w!==e?(R=k(),M=Jt(),M!==e?(T=_,_=sr(f,M)):(a=_,_=e)):(a=_,_=e);_!==e;)c.push(_),_=a,N=k(),s.charCodeAt(a)===44?(w=ce,a++):(w=e,v===0&&y(pe)),w!==e?(R=k(),M=Jt(),M!==e?(T=_,_=sr(f,M)):(a=_,_=e)):(a=_,_=e);T=o,o=Ka(f,c)}else a=o,o=e;o===e&&(o=null),f=k(),s.charCodeAt(a)===41?(c=Vt,a++):(c=e,v===0&&y(zt)),c!==e?(T=r,r=Ya(o)):(a=r,r=e)}else a=r,r=e;return r}function Jt(){var r;return r=F(),r===e&&(r=ts()),r}function Yn(){var r,n,d,o,f,c,_,N,w,R,M,K;return r=a,n=s.substr(a,10),n.toLowerCase()===ia?a+=10:(n=e,v===0&&y(va)),n!==e?(d=k(),o=F(),o!==e?(f=k(),c=ze(),c===e&&(c=null),_=D(),s.charCodeAt(a)===123?(N=m,a++):(N=e,v===0&&y(xe)),N!==e?(w=D(),R=Jn(),M=D(),s.charCodeAt(a)===125?(K=x,a++):(K=e,v===0&&y(Ce)),K!==e?(T=r,r=Ja(o,c,R)):(a=r,r=e)):(a=r,r=e)):(a=r,r=e)):(a=r,r=e),r}function Jn(){var r,n,d,o,f,c,_;if(r=a,n=Ht(),n!==e){for(d=[],o=a,f=ae(),f!==e?(c=D(),_=Ht(),_!==e?(T=o,o=rr(n,_)):(a=o,o=e)):(a=o,o=e);o!==e;)d.push(o),o=a,f=ae(),f!==e?(c=D(),_=Ht(),_!==e?(T=o,o=rr(n,_)):(a=o,o=e)):(a=o,o=e);T=r,r=Ha(n,d)}else a=r,r=e;return r===e&&(r=null),r}function Ht(){var r,n;return r=a,n=st(),n!==e&&(T=r,n=Qa(n)),r=n,r===e&&(r=a,n=Xt(),n!==e&&(T=r,n=Xa(n)),r=n),r}function Hn(){var r,n,d,o,f,c,_,N,w,R,M,K,ne,he;return r=a,n=s.substr(a,3),n.toLowerCase()===oa?a+=3:(n=e,v===0&&y(ya)),n!==e?(d=k(),o=F(),o===e&&(o=null),f=k(),s.charCodeAt(a)===58?(c=Mt,a++):(c=e,v===0&&y(qt)),c!==e?(_=k(),N=vr(),N!==e?(w=k(),R=Xn(),R!==e?(M=k(),K=vr(),K!==e?(ne=k(),he=ze(),he===e&&(he=null),T=r,r=en(o,N,R,K,he)):(a=r,r=e)):(a=r,r=e)):(a=r,r=e)):(a=r,r=e)):(a=r,r=e),r}function vr(){var r,n,d,o,f;return r=a,n=a,d=yr(),d!==e?(o=k(),s.charCodeAt(a)===46?(f=ut,a++):(f=e,v===0&&y(mt)),f!==e?(T=n,n=tn(d)):(a=n,n=e)):(a=n,n=e),n===e&&(n=a,d=_r(),d!==e?(o=k(),s.charCodeAt(a)===46?(f=ut,a++):(f=e,v===0&&y(mt)),f!==e?(T=n,n=sn(d)):(a=n,n=e)):(a=n,n=e)),n!==e?(d=k(),o=Qn(),o!==e?(T=r,r=rn(n,o)):(a=r,r=e)):(a=r,r=e),r}function Qn(){var r,n;return r=a,n=F(),n!==e&&(T=r,n=an(n)),r=n,r===e&&(r=ei()),r}function Xn(){var r;return s.charCodeAt(a)===45?(r=ua,a++):(r=e,v===0&&y(_a)),r===e&&(s.substr(a,2)===$s?(r=$s,a+=2):(r=e,v===0&&y(ba)),r===e&&(r=s.charAt(a),ca.test(r)?a++:(r=e,v===0&&y(Ta)))),r}function ei(){var r,n,d,o,f,c,_,N,w,R,M;if(r=a,s.charCodeAt(a)===40?(n=Lt,a++):(n=e,v===0&&y(Bt)),n!==e){if(d=k(),o=a,f=F(),f!==e){for(c=[],_=a,N=k(),s.charCodeAt(a)===44?(w=ce,a++):(w=e,v===0&&y(pe)),w!==e?(R=k(),M=F(),M!==e?(T=_,_=ar(f,M)):(a=_,_=e)):(a=_,_=e);_!==e;)c.push(_),_=a,N=k(),s.charCodeAt(a)===44?(w=ce,a++):(w=e,v===0&&y(pe)),w!==e?(R=k(),M=F(),M!==e?(T=_,_=ar(f,M)):(a=_,_=e)):(a=_,_=e);T=o,o=nn(f,c)}else a=o,o=e;o===e&&(o=null),f=k(),s.charCodeAt(a)===41?(c=Vt,a++):(c=e,v===0&&y(zt)),c!==e?(T=r,r=on(o)):(a=r,r=e)}else a=r,r=e;return r}function ti(){var r,n,d,o,f,c,_,N,w,R;return r=a,n=s.substr(a,4),n.toLowerCase()===la?a+=4:(n=e,v===0&&y(xa)),n!==e?(d=k(),o=Xt(),o!==e?(f=D(),s.charCodeAt(a)===123?(c=m,a++):(c=e,v===0&&y(xe)),c!==e?(_=D(),N=si(),w=D(),s.charCodeAt(a)===125?(R=x,a++):(R=e,v===0&&y(Ce)),R!==e?(T=r,r=un(o,N)):(a=r,r=e)):(a=r,r=e)):(a=r,r=e)):(a=r,r=e),r}function si(){var r,n,d,o,f,c,_;if(r=a,n=Qt(),n!==e){for(d=[],o=a,f=ae(),f!==e?(c=D(),_=Qt(),_!==e?(T=o,o=nr(n,_)):(a=o,o=e)):(a=o,o=e);o!==e;)d.push(o),o=a,f=ae(),f!==e?(c=D(),_=Qt(),_!==e?(T=o,o=nr(n,_)):(a=o,o=e)):(a=o,o=e);T=r,r=ln(n,d)}else a=r,r=e;return r===e&&(r=null),r}function Qt(){var r,n,d,o;return r=a,n=F(),n!==e?(d=k(),o=ze(),o===e&&(o=null),T=r,r=dn(n,o)):(a=r,r=e),r}function Xt(){var r;return r=yr(),r===e&&(r=_r()),r}function yr(){var r,n,d,o,f,c;return r=a,n=F(),n!==e?(d=k(),s.charCodeAt(a)===46?(o=ut,a++):(o=e,v===0&&y(mt)),o!==e?(f=k(),c=F(),c!==e?(T=r,r=cn(n,c)):(a=r,r=e)):(a=r,r=e)):(a=r,r=e),r}function _r(){var r,n;return r=a,n=F(),n!==e&&(T=r,n=fn(n)),r=n,r}function F(){var r;return r=ri(),r===e&&(r=br()),r}function ri(){var r,n,d;if(r=a,n=[],d=s.charAt(a),Ns.test(d)?a++:(d=e,v===0&&y(Vs)),d!==e)for(;d!==e;)n.push(d),d=s.charAt(a),Ns.test(d)?a++:(d=e,v===0&&y(Vs));else n=e;return n!==e?r=s.substring(r,a):r=n,r}function br(){var r,n,d,o,f;if(r=a,s.charCodeAt(a)===34?(n=lt,a++):(n=e,v===0&&y(gt)),n!==e){for(d=a,o=[],f=s.charAt(a),Es.test(f)?a++:(f=e,v===0&&y(Ms));f!==e;)o.push(f),f=s.charAt(a),Es.test(f)?a++:(f=e,v===0&&y(Ms));d=s.substring(d,a),s.charCodeAt(a)===34?(o=lt,a++):(o=e,v===0&&y(gt)),o!==e?(T=r,r=pn(d)):(a=r,r=e)}else a=r,r=e;return r}function tt(){var r;return r=ai(),r===e&&(r=ii(),r===e&&(r=oi())),r}function ai(){var r,n,d,o;return r=a,s.substr(a,3)===re?(n=re,a+=3):(n=e,v===0&&y(Qe)),n!==e?(d=a,s.substr(a,3)===re?(o=re,a+=3):(o=e,v===0&&y(Qe)),o!==e&&(T=d,o=hn()),d=o,d===e&&(d=ni()),d!==e?(T=r,r=mn(d)):(a=r,r=e)):(a=r,r=e),r}function ni(){var r,n,d,o,f,c;if(r=a,s.length>a?(n=s.charAt(a),a++):(n=e,v===0&&y(Ie)),n!==e){for(d=[],o=a,f=a,v++,s.substr(a,3)===re?(c=re,a+=3):(c=e,v===0&&y(Qe)),v--,c===e?f=void 0:(a=f,f=e),f!==e?(s.length>a?(c=s.charAt(a),a++):(c=e,v===0&&y(Ie)),c!==e?(T=o,o=ir(n,c)):(a=o,o=e)):(a=o,o=e);o!==e;)d.push(o),o=a,f=a,v++,s.substr(a,3)===re?(c=re,a+=3):(c=e,v===0&&y(Qe)),v--,c===e?f=void 0:(a=f,f=e),f!==e?(s.length>a?(c=s.charAt(a),a++):(c=e,v===0&&y(Ie)),c!==e?(T=o,o=ir(n,c)):(a=o,o=e)):(a=o,o=e);s.substr(a,3)===re?(o=re,a+=3):(o=e,v===0&&y(Qe)),o!==e?(T=r,r=gn(n,d)):(a=r,r=e)}else a=r,r=e;return r}function ii(){var r,n,d,o,f,c;if(r=a,s.charCodeAt(a)===39?(n=Zs,a++):(n=e,v===0&&y(Us)),n!==e){if(d=[],o=a,f=[],c=s.charAt(a),ft.test(c)?a++:(c=e,v===0&&y(vt)),c!==e)for(;c!==e;)f.push(c),c=s.charAt(a),ft.test(c)?a++:(c=e,v===0&&y(vt));else f=e;for(f!==e?o=s.substring(o,a):o=f,o===e&&(o=a,s.substr(a,2)===dt?(f=dt,a+=2):(f=e,v===0&&y(Fs)),f!==e&&(T=o,f=or()),o=f,o===e&&(o=s.charAt(a),pt.test(o)?a++:(o=e,v===0&&y(yt))));o!==e;){if(d.push(o),o=a,f=[],c=s.charAt(a),ft.test(c)?a++:(c=e,v===0&&y(vt)),c!==e)for(;c!==e;)f.push(c),c=s.charAt(a),ft.test(c)?a++:(c=e,v===0&&y(vt));else f=e;f!==e?o=s.substring(o,a):o=f,o===e&&(o=a,s.substr(a,2)===dt?(f=dt,a+=2):(f=e,v===0&&y(Fs)),f!==e&&(T=o,f=or()),o=f,o===e&&(o=s.charAt(a),pt.test(o)?a++:(o=e,v===0&&y(yt))))}s.charCodeAt(a)===39?(o=Zs,a++):(o=e,v===0&&y(Us)),o!==e?(T=r,r=vn(d)):(a=r,r=e)}else a=r,r=e;return r}function oi(){var r,n,d,o,f,c;if(r=a,s.charCodeAt(a)===34?(n=lt,a++):(n=e,v===0&&y(gt)),n!==e){if(d=[],o=a,f=[],c=s.charAt(a),ht.test(c)?a++:(c=e,v===0&&y(_t)),c!==e)for(;c!==e;)f.push(c),c=s.charAt(a),ht.test(c)?a++:(c=e,v===0&&y(_t));else f=e;for(f!==e?o=s.substring(o,a):o=f,o===e&&(o=a,s.substr(a,2)===ct?(f=ct,a+=2):(f=e,v===0&&y(Bs)),f!==e&&(T=o,f=ur()),o=f,o===e&&(o=s.charAt(a),pt.test(o)?a++:(o=e,v===0&&y(yt))));o!==e;){if(d.push(o),o=a,f=[],c=s.charAt(a),ht.test(c)?a++:(c=e,v===0&&y(_t)),c!==e)for(;c!==e;)f.push(c),c=s.charAt(a),ht.test(c)?a++:(c=e,v===0&&y(_t));else f=e;f!==e?o=s.substring(o,a):o=f,o===e&&(o=a,s.substr(a,2)===ct?(f=ct,a+=2):(f=e,v===0&&y(Bs)),f!==e&&(T=o,f=ur()),o=f,o===e&&(o=s.charAt(a),pt.test(o)?a++:(o=e,v===0&&y(yt))))}s.charCodeAt(a)===34?(o=lt,a++):(o=e,v===0&&y(gt)),o!==e?(T=r,r=yn(d)):(a=r,r=e)}else a=r,r=e;return r}function It(){var r,n;return r=a,n=ui(),n===e&&(n=li()),n!==e&&(T=r,n=_n(n)),r=n,r}function ui(){var r,n,d,o,f;return r=a,n=k(),s.substr(a,2)===ws?(d=ws,a+=2):(d=e,v===0&&y(Ca)),d!==e?(o=k(),f=ci(),T=r,r=bn(f)):(a=r,r=e),r}function li(){var r,n,d,o;return r=a,s.substr(a,2)===As?(n=As,a+=2):(n=e,v===0&&y(Ia)),n!==e?(d=a,s.substr(a,2)===fe?(o=fe,a+=2):(o=e,v===0&&y(bt)),o!==e&&(T=d,o=Tn()),d=o,d===e&&(d=di()),d!==e?(T=r,r=xn(d)):(a=r,r=e)):(a=r,r=e),r}function di(){var r,n,d,o,f,c;if(r=a,s.length>a?(n=s.charAt(a),a++):(n=e,v===0&&y(Ie)),n!==e){for(d=[],o=a,f=a,v++,s.substr(a,2)===fe?(c=fe,a+=2):(c=e,v===0&&y(bt)),v--,c===e?f=void 0:(a=f,f=e),f!==e?(s.length>a?(c=s.charAt(a),a++):(c=e,v===0&&y(Ie)),c!==e?(T=o,o=lr(n,c)):(a=o,o=e)):(a=o,o=e);o!==e;)d.push(o),o=a,f=a,v++,s.substr(a,2)===fe?(c=fe,a+=2):(c=e,v===0&&y(bt)),v--,c===e?f=void 0:(a=f,f=e),f!==e?(s.length>a?(c=s.charAt(a),a++):(c=e,v===0&&y(Ie)),c!==e?(T=o,o=lr(n,c)):(a=o,o=e)):(a=o,o=e);s.substr(a,2)===fe?(o=fe,a+=2):(o=e,v===0&&y(bt)),o!==e?(T=r,r=Cn(n,d)):(a=r,r=e)}else a=r,r=e;return r}function ci(){var r,n,d;for(r=a,n=[],d=s.charAt(a),js.test(d)?a++:(d=e,v===0&&y(zs));d!==e;)n.push(d),d=s.charAt(a),js.test(d)?a++:(d=e,v===0&&y(zs));return r=s.substring(r,a),r}function ze(){var r,n,d,o;return r=a,s.charCodeAt(a)===91?(n=ee,a++):(n=e,v===0&&y(Ut)),n!==e?(d=fi(),s.charCodeAt(a)===93?(o=Te,a++):(o=e,v===0&&y(Ft)),o!==e?(T=r,r=In(d)):(a=r,r=e)):(a=r,r=e),r}function fi(){var r,n,d,o,f,c,_,N,w;if(r=a,n=es(),n!==e){for(d=[],o=a,f=k(),s.charCodeAt(a)===44?(c=ce,a++):(c=e,v===0&&y(pe)),c!==e?(_=k(),N=es(),N!==e?(w=k(),T=o,o=dr(n,N)):(a=o,o=e)):(a=o,o=e);o!==e;)d.push(o),o=a,f=k(),s.charCodeAt(a)===44?(c=ce,a++):(c=e,v===0&&y(pe)),c!==e?(_=k(),N=es(),N!==e?(w=k(),T=o,o=dr(n,N)):(a=o,o=e)):(a=o,o=e);T=r,r=$n(n,d)}else a=r,r=e;return r===e&&(r=null),r}function es(){var r,n,d,o,f,c,_;return r=a,n=pi(),n!==e?(d=k(),o=a,s.charCodeAt(a)===58?(f=Mt,a++):(f=e,v===0&&y(qt)),f!==e?(c=k(),_=hi(),_!==e?(T=o,o=Zn(n,_)):(a=o,o=e)):(a=o,o=e),o===e&&(o=null),T=r,r=wn(n,o)):(a=r,r=e),r}function pi(){var r,n,d;if(r=a,n=[],d=s.charAt(a),Ps.test(d)?a++:(d=e,v===0&&y(qs)),d!==e)for(;d!==e;)n.push(d),d=s.charAt(a),Ps.test(d)?a++:(d=e,v===0&&y(qs));else n=e;return n!==e&&(T=r,n=An()),r=n,r}function hi(){var r,n,d;if(r=tt(),r===e&&(r=ts(),r===e)){if(r=a,n=[],d=s.charAt(a),Rs.test(d)?a++:(d=e,v===0&&y(Gs)),d!==e)for(;d!==e;)n.push(d),d=s.charAt(a),Rs.test(d)?a++:(d=e,v===0&&y(Gs));else n=e;n!==e&&(T=r,n=kn()),r=n}return r}function ts(){var r,n,d,o;if(r=a,s.charCodeAt(a)===96?(n=ks,a++):(n=e,v===0&&y(Ws)),n!==e){for(d=[],o=s.charAt(a),Ss.test(o)?a++:(o=e,v===0&&y(Ks));o!==e;)d.push(o),o=s.charAt(a),Ss.test(o)?a++:(o=e,v===0&&y(Ks));s.charCodeAt(a)===96?(o=ks,a++):(o=e,v===0&&y(Ws)),o!==e?(T=r,r=On()):(a=r,r=e)}else a=r,r=e;return r}function mi(){var r,n,d,o,f,c,_;if(r=a,n=st(),n!==e){for(d=[],o=a,f=ae(),f!==e?(c=D(),_=st(),_!==e?(T=o,o=cr(n,_)):(a=o,o=e)):(a=o,o=e);o!==e;)d.push(o),o=a,f=ae(),f!==e?(c=D(),_=st(),_!==e?(T=o,o=cr(n,_)):(a=o,o=e)):(a=o,o=e);T=r,r=Nn(n,d)}else a=r,r=e;return r===e&&(r=null),r}function st(){var r,n,d,o,f,c,_,N;return r=a,n=Tr(),n!==e?(d=k(),s.charCodeAt(a)===58?(o=Mt,a++):(o=e,v===0&&y(qt)),o!==e?(f=k(),c=tt(),c!==e?(T=r,r=En(n,c)):(a=r,r=e)):(a=r,r=e)):(a=r,r=e),r===e&&(r=a,n=Tr(),n!==e?(d=k(),s.charCodeAt(a)===123?(o=m,a++):(o=e,v===0&&y(xe)),o!==e?(f=D(),c=tt(),c!==e?(_=D(),s.charCodeAt(a)===125?(N=x,a++):(N=e,v===0&&y(Ce)),N!==e?(T=r,r=jn(n,c)):(a=r,r=e)):(a=r,r=e)):(a=r,r=e)):(a=r,r=e)),r}function Tr(){var r,n;return r=a,n=F(),n!==e&&(T=r,n=Pn()),r=n,r}function k(){var r,n;for(v++,r=[],n=s.charAt(a),Ds.test(n)?a++:(n=e,v===0&&y(Ys));n!==e;)r.push(n),n=s.charAt(a),Ds.test(n)?a++:(n=e,v===0&&y(Ys));return v--,n=e,v===0&&y($a),r}function D(){var r,n,d,o,f,c;for(v++,r=a,n=ss(),d=[],o=a,f=It(),f!==e?(c=ss(),f=[f,c],o=f):(a=o,o=e);o!==e;)d.push(o),o=a,f=It(),f!==e?(c=ss(),f=[f,c],o=f):(a=o,o=e);return n=[n,d],r=n,v--,n=e,v===0&&y(Za),r}function ss(){var r,n;for(v++,r=[],n=s.charAt(a),Ls.test(n)?a++:(n=e,v===0&&y(Js));n!==e;)r.push(n),n=s.charAt(a),Ls.test(n)?a++:(n=e,v===0&&y(Js));return v--,n=e,v===0&&y(wa),r}function ae(){var r,n,d;return r=a,n=k(),d=rs(),d!==e?(n=[n,d],r=n):(a=r,r=e),r===e&&(r=a,n=It(),n!==e?(d=rs(),d!==e?(n=[n,d],r=n):(a=r,r=e)):(a=r,r=e),r===e&&(r=gi())),r}function rs(){var r,n,d;return s.charCodeAt(a)===10?(r=Os,a++):(r=e,v===0&&y(Hs)),r===e&&(r=a,s.charCodeAt(a)===13?(n=da,a++):(n=e,v===0&&y(Aa)),n!==e?(s.charCodeAt(a)===10?(d=Os,a++):(d=e,v===0&&y(Hs)),d!==e?(n=[n,d],r=n):(a=r,r=e)):(a=r,r=e)),r}function gi(){var r,n;return r=a,v++,s.length>a?(n=s.charAt(a),a++):(n=e,v===0&&y(Ie)),v--,n===e?r=void 0:(a=r,r=e),r}if(Xe=l(),t.peg$library)return{peg$result:Xe,peg$currPos:a,peg$FAILED:e,peg$maxFailExpected:Tt,peg$maxFailPos:te};if(Xe!==e&&a===s.length)return Xe;throw Xe!==e&&a<s.length&&y(Sn()),pr(Tt,te<s.length?s.charAt(te):null,te<s.length?et(te,te+1):et(te,te))}Cr.exports={StartRules:["File"],SyntaxError:me,parse:Zi}});var rt=B(U=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});U.getParsedType=U.ZodParsedType=U.objectUtil=U.util=void 0;var is;(function(s){s.assertEqual=u=>{};function t(u){}s.assertIs=t;function e(u){throw new Error}s.assertNever=e,s.arrayToEnum=u=>{let l={};for(let g of u)l[g]=g;return l},s.getValidEnumValues=u=>{let l=s.objectKeys(u).filter(m=>typeof u[u[m]]!="number"),g={};for(let m of l)g[m]=u[m];return s.objectValues(g)},s.objectValues=u=>s.objectKeys(u).map(function(l){return u[l]}),s.objectKeys=typeof Object.keys=="function"?u=>Object.keys(u):u=>{let l=[];for(let g in u)Object.prototype.hasOwnProperty.call(u,g)&&l.push(g);return l},s.find=(u,l)=>{for(let g of u)if(l(g))return g},s.isInteger=typeof Number.isInteger=="function"?u=>Number.isInteger(u):u=>typeof u=="number"&&Number.isFinite(u)&&Math.floor(u)===u;function i(u,l=" | "){return u.map(g=>typeof g=="string"?`'${g}'`:g).join(l)}s.joinValues=i,s.jsonStringifyReplacer=(u,l)=>typeof l=="bigint"?l.toString():l})(is||(U.util=is={}));var $r;(function(s){s.mergeShapes=(t,e)=>({...t,...e})})($r||(U.objectUtil=$r={}));U.ZodParsedType=is.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);var wi=s=>{switch(typeof s){case"undefined":return U.ZodParsedType.undefined;case"string":return U.ZodParsedType.string;case"number":return Number.isNaN(s)?U.ZodParsedType.nan:U.ZodParsedType.number;case"boolean":return U.ZodParsedType.boolean;case"function":return U.ZodParsedType.function;case"bigint":return U.ZodParsedType.bigint;case"symbol":return U.ZodParsedType.symbol;case"object":return Array.isArray(s)?U.ZodParsedType.array:s===null?U.ZodParsedType.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?U.ZodParsedType.promise:typeof Map<"u"&&s instanceof Map?U.ZodParsedType.map:typeof Set<"u"&&s instanceof Set?U.ZodParsedType.set:typeof Date<"u"&&s instanceof Date?U.ZodParsedType.date:U.ZodParsedType.object;default:return U.ZodParsedType.unknown}};U.getParsedType=wi});var Zt=B(ge=>{"use strict";Object.defineProperty(ge,"__esModule",{value:!0});ge.ZodError=ge.quotelessJson=ge.ZodIssueCode=void 0;var Zr=rt();ge.ZodIssueCode=Zr.util.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);var Ai=s=>JSON.stringify(s,null,2).replace(/"([^"]+)":/g,"$1:");ge.quotelessJson=Ai;var at=class s extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=i=>{this.issues=[...this.issues,i]},this.addIssues=(i=[])=>{this.issues=[...this.issues,...i]};let e=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,e):this.__proto__=e,this.name="ZodError",this.issues=t}format(t){let e=t||function(l){return l.message},i={_errors:[]},u=l=>{for(let g of l.issues)if(g.code==="invalid_union")g.unionErrors.map(u);else if(g.code==="invalid_return_type")u(g.returnTypeError);else if(g.code==="invalid_arguments")u(g.argumentsError);else if(g.path.length===0)i._errors.push(e(g));else{let m=i,x=0;for(;x<g.path.length;){let b=g.path[x];x===g.path.length-1?(m[b]=m[b]||{_errors:[]},m[b]._errors.push(e(g))):m[b]=m[b]||{_errors:[]},m=m[b],x++}}};return u(this),i}static assert(t){if(!(t instanceof s))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Zr.util.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=e=>e.message){let e={},i=[];for(let u of this.issues)if(u.path.length>0){let l=u.path[0];e[l]=e[l]||[],e[l].push(t(u))}else i.push(t(u));return{formErrors:i,fieldErrors:e}}get formErrors(){return this.flatten()}};ge.ZodError=at;at.create=s=>new at(s)});var us=B(os=>{"use strict";Object.defineProperty(os,"__esModule",{value:!0});var z=Zt(),$e=rt(),ki=(s,t)=>{let e;switch(s.code){case z.ZodIssueCode.invalid_type:s.received===$e.ZodParsedType.undefined?e="Required":e=`Expected ${s.expected}, received ${s.received}`;break;case z.ZodIssueCode.invalid_literal:e=`Invalid literal value, expected ${JSON.stringify(s.expected,$e.util.jsonStringifyReplacer)}`;break;case z.ZodIssueCode.unrecognized_keys:e=`Unrecognized key(s) in object: ${$e.util.joinValues(s.keys,", ")}`;break;case z.ZodIssueCode.invalid_union:e="Invalid input";break;case z.ZodIssueCode.invalid_union_discriminator:e=`Invalid discriminator value. Expected ${$e.util.joinValues(s.options)}`;break;case z.ZodIssueCode.invalid_enum_value:e=`Invalid enum value. Expected ${$e.util.joinValues(s.options)}, received '${s.received}'`;break;case z.ZodIssueCode.invalid_arguments:e="Invalid function arguments";break;case z.ZodIssueCode.invalid_return_type:e="Invalid function return type";break;case z.ZodIssueCode.invalid_date:e="Invalid date";break;case z.ZodIssueCode.invalid_string:typeof s.validation=="object"?"includes"in s.validation?(e=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(e=`${e} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?e=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?e=`Invalid input: must end with "${s.validation.endsWith}"`:$e.util.assertNever(s.validation):s.validation!=="regex"?e=`Invalid ${s.validation}`:e="Invalid";break;case z.ZodIssueCode.too_small:s.type==="array"?e=`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?e=`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?e=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="bigint"?e=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?e=`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:e="Invalid input";break;case z.ZodIssueCode.too_big:s.type==="array"?e=`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?e=`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?e=`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?e=`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?e=`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.maximum))}`:e="Invalid input";break;case z.ZodIssueCode.custom:e="Invalid input";break;case z.ZodIssueCode.invalid_intersection_types:e="Intersection results could not be merged";break;case z.ZodIssueCode.not_multiple_of:e=`Number must be a multiple of ${s.multipleOf}`;break;case z.ZodIssueCode.not_finite:e="Number must be finite";break;default:e=t.defaultError,$e.util.assertNever(s)}return{message:e}};os.default=ki});var wt=B(ve=>{"use strict";var Oi=ve&&ve.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(ve,"__esModule",{value:!0});ve.defaultErrorMap=void 0;ve.setErrorMap=Ni;ve.getErrorMap=Ei;var wr=Oi(us());ve.defaultErrorMap=wr.default;var Ar=wr.default;function Ni(s){Ar=s}function Ei(){return Ar}});var ds=B(V=>{"use strict";var ji=V&&V.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(V,"__esModule",{value:!0});V.isAsync=V.isValid=V.isDirty=V.isAborted=V.OK=V.DIRTY=V.INVALID=V.ParseStatus=V.EMPTY_PATH=V.makeIssue=void 0;V.addIssueToContext=Si;var Pi=wt(),kr=ji(us()),Ri=s=>{let{data:t,path:e,errorMaps:i,issueData:u}=s,l=[...e,...u.path||[]],g={...u,path:l};if(u.message!==void 0)return{...u,path:l,message:u.message};let m="",x=i.filter(b=>!!b).slice().reverse();for(let b of x)m=b(g,{data:t,defaultError:m}).message;return{...u,path:l,message:m}};V.makeIssue=Ri;V.EMPTY_PATH=[];function Si(s,t){let e=(0,Pi.getErrorMap)(),i=(0,V.makeIssue)({issueData:t,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,e,e===kr.default?void 0:kr.default].filter(u=>!!u)});s.common.issues.push(i)}var ls=class s{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,e){let i=[];for(let u of e){if(u.status==="aborted")return V.INVALID;u.status==="dirty"&&t.dirty(),i.push(u.value)}return{status:t.value,value:i}}static async mergeObjectAsync(t,e){let i=[];for(let u of e){let l=await u.key,g=await u.value;i.push({key:l,value:g})}return s.mergeObjectSync(t,i)}static mergeObjectSync(t,e){let i={};for(let u of e){let{key:l,value:g}=u;if(l.status==="aborted"||g.status==="aborted")return V.INVALID;l.status==="dirty"&&t.dirty(),g.status==="dirty"&&t.dirty(),l.value!=="__proto__"&&(typeof g.value<"u"||u.alwaysSet)&&(i[l.value]=g.value)}return{status:t.value,value:i}}};V.ParseStatus=ls;V.INVALID=Object.freeze({status:"aborted"});var Di=s=>({status:"dirty",value:s});V.DIRTY=Di;var Li=s=>({status:"valid",value:s});V.OK=Li;var Vi=s=>s.status==="aborted";V.isAborted=Vi;var Mi=s=>s.status==="dirty";V.isDirty=Mi;var Ui=s=>s.status==="valid";V.isValid=Ui;var Fi=s=>typeof Promise<"u"&&s instanceof Promise;V.isAsync=Fi});var Nr=B(Or=>{"use strict";Object.defineProperty(Or,"__esModule",{value:!0})});var jr=B(At=>{"use strict";Object.defineProperty(At,"__esModule",{value:!0});At.errorUtil=void 0;var Er;(function(s){s.errToObj=t=>typeof t=="string"?{message:t}:t||{},s.toString=t=>typeof t=="string"?t:t?.message})(Er||(At.errorUtil=Er={}))});var qr=B(p=>{"use strict";Object.defineProperty(p,"__esModule",{value:!0});p.discriminatedUnion=p.date=p.boolean=p.bigint=p.array=p.any=p.coerce=p.ZodFirstPartyTypeKind=p.late=p.ZodSchema=p.Schema=p.ZodReadonly=p.ZodPipeline=p.ZodBranded=p.BRAND=p.ZodNaN=p.ZodCatch=p.ZodDefault=p.ZodNullable=p.ZodOptional=p.ZodTransformer=p.ZodEffects=p.ZodPromise=p.ZodNativeEnum=p.ZodEnum=p.ZodLiteral=p.ZodLazy=p.ZodFunction=p.ZodSet=p.ZodMap=p.ZodRecord=p.ZodTuple=p.ZodIntersection=p.ZodDiscriminatedUnion=p.ZodUnion=p.ZodObject=p.ZodArray=p.ZodVoid=p.ZodNever=p.ZodUnknown=p.ZodAny=p.ZodNull=p.ZodUndefined=p.ZodSymbol=p.ZodDate=p.ZodBoolean=p.ZodBigInt=p.ZodNumber=p.ZodString=p.ZodType=void 0;p.NEVER=p.void=p.unknown=p.union=p.undefined=p.tuple=p.transformer=p.symbol=p.string=p.strictObject=p.set=p.record=p.promise=p.preprocess=p.pipeline=p.ostring=p.optional=p.onumber=p.oboolean=p.object=p.number=p.nullable=p.null=p.never=p.nativeEnum=p.nan=p.map=p.literal=p.lazy=p.intersection=p.instanceof=p.function=p.enum=p.effect=void 0;p.datetimeRegex=Lr;p.custom=Mr;var C=Zt(),kt=wt(),O=jr(),h=ds(),I=rt(),H=class{constructor(t,e,i,u){this._cachedPath=[],this.parent=t,this.data=e,this._path=i,this._key=u}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Pr=(s,t)=>{if((0,h.isValid)(t))return{success:!0,data:t.value};if(!s.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let e=new C.ZodError(s.common.issues);return this._error=e,this._error}}};function j(s){if(!s)return{};let{errorMap:t,invalid_type_error:e,required_error:i,description:u}=s;if(t&&(e||i))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:u}:{errorMap:(g,m)=>{let{message:x}=s;return g.code==="invalid_enum_value"?{message:x??m.defaultError}:typeof m.data>"u"?{message:x??i??m.defaultError}:g.code!=="invalid_type"?{message:m.defaultError}:{message:x??e??m.defaultError}},description:u}}var P=class{get description(){return this._def.description}_getType(t){return(0,I.getParsedType)(t.data)}_getOrReturnCtx(t,e){return e||{common:t.parent.common,data:t.data,parsedType:(0,I.getParsedType)(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new h.ParseStatus,ctx:{common:t.parent.common,data:t.data,parsedType:(0,I.getParsedType)(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let e=this._parse(t);if((0,h.isAsync)(e))throw new Error("Synchronous parse encountered promise.");return e}_parseAsync(t){let e=this._parse(t);return Promise.resolve(e)}parse(t,e){let i=this.safeParse(t,e);if(i.success)return i.data;throw i.error}safeParse(t,e){let i={common:{issues:[],async:e?.async??!1,contextualErrorMap:e?.errorMap},path:e?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:(0,I.getParsedType)(t)},u=this._parseSync({data:t,path:i.path,parent:i});return Pr(i,u)}"~validate"(t){let e={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:(0,I.getParsedType)(t)};if(!this["~standard"].async)try{let i=this._parseSync({data:t,path:[],parent:e});return(0,h.isValid)(i)?{value:i.value}:{issues:e.common.issues}}catch(i){i?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),e.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:e}).then(i=>(0,h.isValid)(i)?{value:i.value}:{issues:e.common.issues})}async parseAsync(t,e){let i=await this.safeParseAsync(t,e);if(i.success)return i.data;throw i.error}async safeParseAsync(t,e){let i={common:{issues:[],contextualErrorMap:e?.errorMap,async:!0},path:e?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:(0,I.getParsedType)(t)},u=this._parse({data:t,path:i.path,parent:i}),l=await((0,h.isAsync)(u)?u:Promise.resolve(u));return Pr(i,l)}refine(t,e){let i=u=>typeof e=="string"||typeof e>"u"?{message:e}:typeof e=="function"?e(u):e;return this._refinement((u,l)=>{let g=t(u),m=()=>l.addIssue({code:C.ZodIssueCode.custom,...i(u)});return typeof Promise<"u"&&g instanceof Promise?g.then(x=>x?!0:(m(),!1)):g?!0:(m(),!1)})}refinement(t,e){return this._refinement((i,u)=>t(i)?!0:(u.addIssue(typeof e=="function"?e(i,u):e),!1))}_refinement(t){return new Y({schema:this,typeName:E.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return J.create(this,this._def)}nullable(){return oe.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return de.create(this)}promise(){return be.create(this,this._def)}or(t){return Ee.create([this,t],this._def)}and(t){return je.create(this,t,this._def)}transform(t){return new Y({...j(this._def),schema:this,typeName:E.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let e=typeof t=="function"?t:()=>t;return new Le({...j(this._def),innerType:this,defaultValue:e,typeName:E.ZodDefault})}brand(){return new nt({typeName:E.ZodBranded,type:this,...j(this._def)})}catch(t){let e=typeof t=="function"?t:()=>t;return new Ve({...j(this._def),innerType:this,catchValue:e,typeName:E.ZodCatch})}describe(t){let e=this.constructor;return new e({...this._def,description:t})}pipe(t){return it.create(this,t)}readonly(){return Me.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};p.ZodType=P;p.Schema=P;p.ZodSchema=P;var Bi=/^c[^\s-]{8,}$/i,zi=/^[0-9a-z]+$/,qi=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Gi=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Wi=/^[a-z0-9_-]{21}$/i,Ki=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Yi=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Ji=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Hi="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",cs,Qi=/^(?:(?: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])$/,Xi=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,eo=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,to=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,so=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ro=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Sr="((\\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])))",ao=new RegExp(`^${Sr}$`);function Dr(s){let t="[0-5]\\d";s.precision?t=`${t}\\.\\d{${s.precision}}`:s.precision==null&&(t=`${t}(\\.\\d+)?`);let e=s.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${e}`}function no(s){return new RegExp(`^${Dr(s)}$`)}function Lr(s){let t=`${Sr}T${Dr(s)}`,e=[];return e.push(s.local?"Z?":"Z"),s.offset&&e.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${e.join("|")})`,new RegExp(`^${t}$`)}function io(s,t){return!!((t==="v4"||!t)&&Qi.test(s)||(t==="v6"||!t)&&eo.test(s))}function oo(s,t){if(!Ki.test(s))return!1;try{let[e]=s.split(".");if(!e)return!1;let i=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(4-e.length%4)%4,"="),u=JSON.parse(atob(i));return!(typeof u!="object"||u===null||"typ"in u&&u?.typ!=="JWT"||!u.alg||t&&u.alg!==t)}catch{return!1}}function uo(s,t){return!!((t==="v4"||!t)&&Xi.test(s)||(t==="v6"||!t)&&to.test(s))}var ye=class s extends P{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==I.ZodParsedType.string){let l=this._getOrReturnCtx(t);return(0,h.addIssueToContext)(l,{code:C.ZodIssueCode.invalid_type,expected:I.ZodParsedType.string,received:l.parsedType}),h.INVALID}let i=new h.ParseStatus,u;for(let l of this._def.checks)if(l.kind==="min")t.data.length<l.value&&(u=this._getOrReturnCtx(t,u),(0,h.addIssueToContext)(u,{code:C.ZodIssueCode.too_small,minimum:l.value,type:"string",inclusive:!0,exact:!1,message:l.message}),i.dirty());else if(l.kind==="max")t.data.length>l.value&&(u=this._getOrReturnCtx(t,u),(0,h.addIssueToContext)(u,{code:C.ZodIssueCode.too_big,maximum:l.value,type:"string",inclusive:!0,exact:!1,message:l.message}),i.dirty());else if(l.kind==="length"){let g=t.data.length>l.value,m=t.data.length<l.value;(g||m)&&(u=this._getOrReturnCtx(t,u),g?(0,h.addIssueToContext)(u,{code:C.ZodIssueCode.too_big,maximum:l.value,type:"string",inclusive:!0,exact:!0,message:l.message}):m&&(0,h.addIssueToContext)(u,{code:C.ZodIssueCode.too_small,minimum:l.value,type:"string",inclusive:!0,exact:!0,message:l.message}),i.dirty())}else if(l.kind==="email")Ji.test(t.data)||(u=this._getOrReturnCtx(t,u),(0,h.addIssueToContext)(u,{validation:"email",code:C.ZodIssueCode.invalid_string,message:l.message}),i.dirty());else if(l.kind==="emoji")cs||(cs=new RegExp(Hi,"u")),cs.test(t.data)||(u=this._getOrReturnCtx(t,u),(0,h.addIssueToContext)(u,{validation:"emoji",code:C.ZodIssueCode.invalid_string,message:l.message}),i.dirty());else if(l.kind==="uuid")Gi.test(t.data)||(u=this._getOrReturnCtx(t,u),(0,h.addIssueToContext)(u,{validation:"uuid",code:C.ZodIssueCode.invalid_string,message:l.message}),i.dirty());else if(l.kind==="nanoid")Wi.test(t.data)||(u=this._getOrReturnCtx(t,u),(0,h.addIssueToContext)(u,{validation:"nanoid",code:C.ZodIssueCode.invalid_string,message:l.message}),i.dirty());else if(l.kind==="cuid")Bi.test(t.data)||(u=this._getOrReturnCtx(t,u),(0,h.addIssueToContext)(u,{validation:"cuid",code:C.ZodIssueCode.invalid_string,message:l.message}),i.dirty());else if(l.kind==="cuid2")zi.test(t.data)||(u=this._getOrReturnCtx(t,u),(0,h.addIssueToContext)(u,{validation:"cuid2",code:C.ZodIssueCode.invalid_string,message:l.message}),i.dirty());else if(l.kind==="ulid")qi.test(t.data)||(u=this._getOrReturnCtx(t,u),(0,h.addIssueToContext)(u,{validation:"ulid",code:C.ZodIssueCode.invalid_string,message:l.message}),i.dirty());else if(l.kind==="url")try{new URL(t.data)}catch{u=this._getOrReturnCtx(t,u),(0,h.addIssueToContext)(u,{validation:"url",code:C.ZodIssueCode.invalid_string,message:l.message}),i.dirty()}else l.kind==="regex"?(l.regex.lastIndex=0,l.regex.test(t.data)||(u=this._getOrReturnCtx(t,u),(0,h.addIssueToContext)(u,{validation:"regex",code:C.ZodIssueCode.invalid_string,message:l.message}),i.dirty())):l.kind==="trim"?t.data=t.data.trim():l.kind==="includes"?t.data.includes(l.value,l.position)||(u=this._getOrReturnCtx(t,u),(0,h.addIssueToContext)(u,{code:C.ZodIssueCode.invalid_string,validation:{includes:l.value,position:l.position},message:l.message}),i.dirty()):l.kind==="toLowerCase"?t.data=t.data.toLowerCase():l.kind==="toUpperCase"?t.data=t.data.toUpperCase():l.kind==="startsWith"?t.data.startsWith(l.value)||(u=this._getOrReturnCtx(t,u),(0,h.addIssueToContext)(u,{code:C.ZodIssueCode.invalid_string,validation:{startsWith:l.value},message:l.message}),i.dirty()):l.kind==="endsWith"?t.data.endsWith(l.value)||(u=this._getOrReturnCtx(t,u),(0,h.addIssueToContext)(u,{code:C.ZodIssueCode.invalid_string,validation:{endsWith:l.value},message:l.message}),i.dirty()):l.kind==="datetime"?Lr(l).test(t.data)||(u=this._getOrReturnCtx(t,u),(0,h.addIssueToContext)(u,{code:C.ZodIssueCode.invalid_string,validation:"datetime",message:l.message}),i.dirty()):l.kind==="date"?ao.test(t.data)||(u=this._getOrReturnCtx(t,u),(0,h.addIssueToContext)(u,{code:C.ZodIssueCode.invalid_string,validation:"date",message:l.message}),i.dirty()):l.kind==="time"?no(l).test(t.data)||(u=this._getOrReturnCtx(t,u),(0,h.addIssueToContext)(u,{code:C.ZodIssueCode.invalid_string,validation:"time",message:l.message}),i.dirty()):l.kind==="duration"?Yi.test(t.data)||(u=this._getOrReturnCtx(t,u),(0,h.addIssueToContext)(u,{validation:"duration",code:C.ZodIssueCode.invalid_string,message:l.message}),i.dirty()):l.kind==="ip"?io(t.data,l.version)||(u=this._getOrReturnCtx(t,u),(0,h.addIssueToContext)(u,{validation:"ip",code:C.ZodIssueCode.invalid_string,message:l.message}),i.dirty()):l.kind==="jwt"?oo(t.data,l.alg)||(u=this._getOrReturnCtx(t,u),(0,h.addIssueToContext)(u,{validation:"jwt",code:C.ZodIssueCode.invalid_string,message:l.message}),i.dirty()):l.kind==="cidr"?uo(t.data,l.version)||(u=this._getOrReturnCtx(t,u),(0,h.addIssueToContext)(u,{validation:"cidr",code:C.ZodIssueCode.invalid_string,message:l.message}),i.dirty()):l.kind==="base64"?so.test(t.data)||(u=this._getOrReturnCtx(t,u),(0,h.addIssueToContext)(u,{validation:"base64",code:C.ZodIssueCode.invalid_string,message:l.message}),i.dirty()):l.kind==="base64url"?ro.test(t.data)||(u=this._getOrReturnCtx(t,u),(0,h.addIssueToContext)(u,{validation:"base64url",code:C.ZodIssueCode.invalid_string,message:l.message}),i.dirty()):I.util.assertNever(l);return{status:i.value,value:t.data}}_regex(t,e,i){return this.refinement(u=>t.test(u),{validation:e,code:C.ZodIssueCode.invalid_string,...O.errorUtil.errToObj(i)})}_addCheck(t){return new s({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...O.errorUtil.errToObj(t)})}url(t){return this._addCheck({kind:"url",...O.errorUtil.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...O.errorUtil.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...O.errorUtil.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...O.errorUtil.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...O.errorUtil.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...O.errorUtil.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...O.errorUtil.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...O.errorUtil.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...O.errorUtil.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...O.errorUtil.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...O.errorUtil.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...O.errorUtil.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...O.errorUtil.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...O.errorUtil.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...O.errorUtil.errToObj(t)})}regex(t,e){return this._addCheck({kind:"regex",regex:t,...O.errorUtil.errToObj(e)})}includes(t,e){return this._addCheck({kind:"includes",value:t,position:e?.position,...O.errorUtil.errToObj(e?.message)})}startsWith(t,e){return this._addCheck({kind:"startsWith",value:t,...O.errorUtil.errToObj(e)})}endsWith(t,e){return this._addCheck({kind:"endsWith",value:t,...O.errorUtil.errToObj(e)})}min(t,e){return this._addCheck({kind:"min",value:t,...O.errorUtil.errToObj(e)})}max(t,e){return this._addCheck({kind:"max",value:t,...O.errorUtil.errToObj(e)})}length(t,e){return this._addCheck({kind:"length",value:t,...O.errorUtil.errToObj(e)})}nonempty(t){return this.min(1,O.errorUtil.errToObj(t))}trim(){return new s({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new s({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new s({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(let e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxLength(){let t=null;for(let e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}};p.ZodString=ye;ye.create=s=>new ye({checks:[],typeName:E.ZodString,coerce:s?.coerce??!1,...j(s)});function lo(s,t){let e=(s.toString().split(".")[1]||"").length,i=(t.toString().split(".")[1]||"").length,u=e>i?e:i,l=Number.parseInt(s.toFixed(u).replace(".","")),g=Number.parseInt(t.toFixed(u).replace(".",""));return l%g/10**u}var Ze=class s extends P{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==I.ZodParsedType.number){let l=this._getOrReturnCtx(t);return(0,h.addIssueToContext)(l,{code:C.ZodIssueCode.invalid_type,expected:I.ZodParsedType.number,received:l.parsedType}),h.INVALID}let i,u=new h.ParseStatus;for(let l of this._def.checks)l.kind==="int"?I.util.isInteger(t.data)||(i=this._getOrReturnCtx(t,i),(0,h.addIssueToContext)(i,{code:C.ZodIssueCode.invalid_type,expected:"integer",received:"float",message:l.message}),u.dirty()):l.kind==="min"?(l.inclusive?t.data<l.value:t.data<=l.value)&&(i=this._getOrReturnCtx(t,i),(0,h.addIssueToContext)(i,{code:C.ZodIssueCode.too_small,minimum:l.value,type:"number",inclusive:l.inclusive,exact:!1,message:l.message}),u.dirty()):l.kind==="max"?(l.inclusive?t.data>l.value:t.data>=l.value)&&(i=this._getOrReturnCtx(t,i),(0,h.addIssueToContext)(i,{code:C.ZodIssueCode.too_big,maximum:l.value,type:"number",inclusive:l.inclusive,exact:!1,message:l.message}),u.dirty()):l.kind==="multipleOf"?lo(t.data,l.value)!==0&&(i=this._getOrReturnCtx(t,i),(0,h.addIssueToContext)(i,{code:C.ZodIssueCode.not_multiple_of,multipleOf:l.value,message:l.message}),u.dirty()):l.kind==="finite"?Number.isFinite(t.data)||(i=this._getOrReturnCtx(t,i),(0,h.addIssueToContext)(i,{code:C.ZodIssueCode.not_finite,message:l.message}),u.dirty()):I.util.assertNever(l);return{status:u.value,value:t.data}}gte(t,e){return this.setLimit("min",t,!0,O.errorUtil.toString(e))}gt(t,e){return this.setLimit("min",t,!1,O.errorUtil.toString(e))}lte(t,e){return this.setLimit("max",t,!0,O.errorUtil.toString(e))}lt(t,e){return this.setLimit("max",t,!1,O.errorUtil.toString(e))}setLimit(t,e,i,u){return new s({...this._def,checks:[...this._def.checks,{kind:t,value:e,inclusive:i,message:O.errorUtil.toString(u)}]})}_addCheck(t){return new s({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:O.errorUtil.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:O.errorUtil.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:O.errorUtil.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:O.errorUtil.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:O.errorUtil.toString(t)})}multipleOf(t,e){return this._addCheck({kind:"multipleOf",value:t,message:O.errorUtil.toString(e)})}finite(t){return this._addCheck({kind:"finite",message:O.errorUtil.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:O.errorUtil.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:O.errorUtil.toString(t)})}get minValue(){let t=null;for(let e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxValue(){let t=null;for(let e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&I.util.isInteger(t.value))}get isFinite(){let t=null,e=null;for(let i of this._def.checks){if(i.kind==="finite"||i.kind==="int"||i.kind==="multipleOf")return!0;i.kind==="min"?(e===null||i.value>e)&&(e=i.value):i.kind==="max"&&(t===null||i.value<t)&&(t=i.value)}return Number.isFinite(e)&&Number.isFinite(t)}};p.ZodNumber=Ze;Ze.create=s=>new Ze({checks:[],typeName:E.ZodNumber,coerce:s?.coerce||!1,...j(s)});var we=class s extends P{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==I.ZodParsedType.bigint)return this._getInvalidInput(t);let i,u=new h.ParseStatus;for(let l of this._def.checks)l.kind==="min"?(l.inclusive?t.data<l.value:t.data<=l.value)&&(i=this._getOrReturnCtx(t,i),(0,h.addIssueToContext)(i,{code:C.ZodIssueCode.too_small,type:"bigint",minimum:l.value,inclusive:l.inclusive,message:l.message}),u.dirty()):l.kind==="max"?(l.inclusive?t.data>l.value:t.data>=l.value)&&(i=this._getOrReturnCtx(t,i),(0,h.addIssueToContext)(i,{code:C.ZodIssueCode.too_big,type:"bigint",maximum:l.value,inclusive:l.inclusive,message:l.message}),u.dirty()):l.kind==="multipleOf"?t.data%l.value!==BigInt(0)&&(i=this._getOrReturnCtx(t,i),(0,h.addIssueToContext)(i,{code:C.ZodIssueCode.not_multiple_of,multipleOf:l.value,message:l.message}),u.dirty()):I.util.assertNever(l);return{status:u.value,value:t.data}}_getInvalidInput(t){let e=this._getOrReturnCtx(t);return(0,h.addIssueToContext)(e,{code:C.ZodIssueCode.invalid_type,expected:I.ZodParsedType.bigint,received:e.parsedType}),h.INVALID}gte(t,e){return this.setLimit("min",t,!0,O.errorUtil.toString(e))}gt(t,e){return this.setLimit("min",t,!1,O.errorUtil.toString(e))}lte(t,e){return this.setLimit("max",t,!0,O.errorUtil.toString(e))}lt(t,e){return this.setLimit("max",t,!1,O.errorUtil.toString(e))}setLimit(t,e,i,u){return new s({...this._def,checks:[...this._def.checks,{kind:t,value:e,inclusive:i,message:O.errorUtil.toString(u)}]})}_addCheck(t){return new s({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:O.errorUtil.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:O.errorUtil.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:O.errorUtil.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:O.errorUtil.toString(t)})}multipleOf(t,e){return this._addCheck({kind:"multipleOf",value:t,message:O.errorUtil.toString(e)})}get minValue(){let t=null;for(let e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxValue(){let t=null;for(let e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}};p.ZodBigInt=we;we.create=s=>new we({checks:[],typeName:E.ZodBigInt,coerce:s?.coerce??!1,...j(s)});var Ae=class extends P{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==I.ZodParsedType.boolean){let i=this._getOrReturnCtx(t);return(0,h.addIssueToContext)(i,{code:C.ZodIssueCode.invalid_type,expected:I.ZodParsedType.boolean,received:i.parsedType}),h.INVALID}return(0,h.OK)(t.data)}};p.ZodBoolean=Ae;Ae.create=s=>new Ae({typeName:E.ZodBoolean,coerce:s?.coerce||!1,...j(s)});var ke=class s extends P{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==I.ZodParsedType.date){let l=this._getOrReturnCtx(t);return(0,h.addIssueToContext)(l,{code:C.ZodIssueCode.invalid_type,expected:I.ZodParsedType.date,received:l.parsedType}),h.INVALID}if(Number.isNaN(t.data.getTime())){let l=this._getOrReturnCtx(t);return(0,h.addIssueToContext)(l,{code:C.ZodIssueCode.invalid_date}),h.INVALID}let i=new h.ParseStatus,u;for(let l of this._def.checks)l.kind==="min"?t.data.getTime()<l.value&&(u=this._getOrReturnCtx(t,u),(0,h.addIssueToContext)(u,{code:C.ZodIssueCode.too_small,message:l.message,inclusive:!0,exact:!1,minimum:l.value,type:"date"}),i.dirty()):l.kind==="max"?t.data.getTime()>l.value&&(u=this._getOrReturnCtx(t,u),(0,h.addIssueToContext)(u,{code:C.ZodIssueCode.too_big,message:l.message,inclusive:!0,exact:!1,maximum:l.value,type:"date"}),i.dirty()):I.util.assertNever(l);return{status:i.value,value:new Date(t.data.getTime())}}_addCheck(t){return new s({...this._def,checks:[...this._def.checks,t]})}min(t,e){return this._addCheck({kind:"min",value:t.getTime(),message:O.errorUtil.toString(e)})}max(t,e){return this._addCheck({kind:"max",value:t.getTime(),message:O.errorUtil.toString(e)})}get minDate(){let t=null;for(let e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t!=null?new Date(t):null}};p.ZodDate=ke;ke.create=s=>new ke({checks:[],coerce:s?.coerce||!1,typeName:E.ZodDate,...j(s)});var Ge=class extends P{_parse(t){if(this._getType(t)!==I.ZodParsedType.symbol){let i=this._getOrReturnCtx(t);return(0,h.addIssueToContext)(i,{code:C.ZodIssueCode.invalid_type,expected:I.ZodParsedType.symbol,received:i.parsedType}),h.INVALID}return(0,h.OK)(t.data)}};p.ZodSymbol=Ge;Ge.create=s=>new Ge({typeName:E.ZodSymbol,...j(s)});var Oe=class extends P{_parse(t){if(this._getType(t)!==I.ZodParsedType.undefined){let i=this._getOrReturnCtx(t);return(0,h.addIssueToContext)(i,{code:C.ZodIssueCode.invalid_type,expected:I.ZodParsedType.undefined,received:i.parsedType}),h.INVALID}return(0,h.OK)(t.data)}};p.ZodUndefined=Oe;Oe.create=s=>new Oe({typeName:E.ZodUndefined,...j(s)});var Ne=class extends P{_parse(t){if(this._getType(t)!==I.ZodParsedType.null){let i=this._getOrReturnCtx(t);return(0,h.addIssueToContext)(i,{code:C.ZodIssueCode.invalid_type,expected:I.ZodParsedType.null,received:i.parsedType}),h.INVALID}return(0,h.OK)(t.data)}};p.ZodNull=Ne;Ne.create=s=>new Ne({typeName:E.ZodNull,...j(s)});var _e=class extends P{constructor(){super(...arguments),this._any=!0}_parse(t){return(0,h.OK)(t.data)}};p.ZodAny=_e;_e.create=s=>new _e({typeName:E.ZodAny,...j(s)});var le=class extends P{constructor(){super(...arguments),this._unknown=!0}_parse(t){return(0,h.OK)(t.data)}};p.ZodUnknown=le;le.create=s=>new le({typeName:E.ZodUnknown,...j(s)});var se=class extends P{_parse(t){let e=this._getOrReturnCtx(t);return(0,h.addIssueToContext)(e,{code:C.ZodIssueCode.invalid_type,expected:I.ZodParsedType.never,received:e.parsedType}),h.INVALID}};p.ZodNever=se;se.create=s=>new se({typeName:E.ZodNever,...j(s)});var We=class extends P{_parse(t){if(this._getType(t)!==I.ZodParsedType.undefined){let i=this._getOrReturnCtx(t);return(0,h.addIssueToContext)(i,{code:C.ZodIssueCode.invalid_type,expected:I.ZodParsedType.void,received:i.parsedType}),h.INVALID}return(0,h.OK)(t.data)}};p.ZodVoid=We;We.create=s=>new We({typeName:E.ZodVoid,...j(s)});var de=class s extends P{_parse(t){let{ctx:e,status:i}=this._processInputParams(t),u=this._def;if(e.parsedType!==I.ZodParsedType.array)return(0,h.addIssueToContext)(e,{code:C.ZodIssueCode.invalid_type,expected:I.ZodParsedType.array,received:e.parsedType}),h.INVALID;if(u.exactLength!==null){let g=e.data.length>u.exactLength.value,m=e.data.length<u.exactLength.value;(g||m)&&((0,h.addIssueToContext)(e,{code:g?C.ZodIssueCode.too_big:C.ZodIssueCode.too_small,minimum:m?u.exactLength.value:void 0,maximum:g?u.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:u.exactLength.message}),i.dirty())}if(u.minLength!==null&&e.data.length<u.minLength.value&&((0,h.addIssueToContext)(e,{code:C.ZodIssueCode.too_small,minimum:u.minLength.value,type:"array",inclusive:!0,exact:!1,message:u.minLength.message}),i.dirty()),u.maxLength!==null&&e.data.length>u.maxLength.value&&((0,h.addIssueToContext)(e,{code:C.ZodIssueCode.too_big,maximum:u.maxLength.value,type:"array",inclusive:!0,exact:!1,message:u.maxLength.message}),i.dirty()),e.common.async)return Promise.all([...e.data].map((g,m)=>u.type._parseAsync(new H(e,g,e.path,m)))).then(g=>h.ParseStatus.mergeArray(i,g));let l=[...e.data].map((g,m)=>u.type._parseSync(new H(e,g,e.path,m)));return h.ParseStatus.mergeArray(i,l)}get element(){return this._def.type}min(t,e){return new s({...this._def,minLength:{value:t,message:O.errorUtil.toString(e)}})}max(t,e){return new s({...this._def,maxLength:{value:t,message:O.errorUtil.toString(e)}})}length(t,e){return new s({...this._def,exactLength:{value:t,message:O.errorUtil.toString(e)}})}nonempty(t){return this.min(1,t)}};p.ZodArray=de;de.create=(s,t)=>new de({type:s,minLength:null,maxLength:null,exactLength:null,typeName:E.ZodArray,...j(t)});function qe(s){if(s instanceof q){let t={};for(let e in s.shape){let i=s.shape[e];t[e]=J.create(qe(i))}return new q({...s._def,shape:()=>t})}else return s instanceof de?new de({...s._def,type:qe(s.element)}):s instanceof J?J.create(qe(s.unwrap())):s instanceof oe?oe.create(qe(s.unwrap())):s instanceof ie?ie.create(s.items.map(t=>qe(t))):s}var q=class s extends P{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),e=I.util.objectKeys(t);return this._cached={shape:t,keys:e},this._cached}_parse(t){if(this._getType(t)!==I.ZodParsedType.object){let b=this._getOrReturnCtx(t);return(0,h.addIssueToContext)(b,{code:C.ZodIssueCode.invalid_type,expected:I.ZodParsedType.object,received:b.parsedType}),h.INVALID}let{status:i,ctx:u}=this._processInputParams(t),{shape:l,keys:g}=this._getCached(),m=[];if(!(this._def.catchall instanceof se&&this._def.unknownKeys==="strip"))for(let b in u.data)g.includes(b)||m.push(b);let x=[];for(let b of g){let Z=l[b],L=u.data[b];x.push({key:{status:"valid",value:b},value:Z._parse(new H(u,L,u.path,b)),alwaysSet:b in u.data})}if(this._def.catchall instanceof se){let b=this._def.unknownKeys;if(b==="passthrough")for(let Z of m)x.push({key:{status:"valid",value:Z},value:{status:"valid",value:u.data[Z]}});else if(b==="strict")m.length>0&&((0,h.addIssueToContext)(u,{code:C.ZodIssueCode.unrecognized_keys,keys:m}),i.dirty());else if(b!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let b=this._def.catchall;for(let Z of m){let L=u.data[Z];x.push({key:{status:"valid",value:Z},value:b._parse(new H(u,L,u.path,Z)),alwaysSet:Z in u.data})}}return u.common.async?Promise.resolve().then(async()=>{let b=[];for(let Z of x){let L=await Z.key,ee=await Z.value;b.push({key:L,value:ee,alwaysSet:Z.alwaysSet})}return b}).then(b=>h.ParseStatus.mergeObjectSync(i,b)):h.ParseStatus.mergeObjectSync(i,x)}get shape(){return this._def.shape()}strict(t){return O.errorUtil.errToObj,new s({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(e,i)=>{let u=this._def.errorMap?.(e,i).message??i.defaultError;return e.code==="unrecognized_keys"?{message:O.errorUtil.errToObj(t).message??u}:{message:u}}}:{}})}strip(){return new s({...this._def,unknownKeys:"strip"})}passthrough(){return new s({...this._def,unknownKeys:"passthrough"})}extend(t){return new s({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new s({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:E.ZodObject})}setKey(t,e){return this.augment({[t]:e})}catchall(t){return new s({...this._def,catchall:t})}pick(t){let e={};for(let i of I.util.objectKeys(t))t[i]&&this.shape[i]&&(e[i]=this.shape[i]);return new s({...this._def,shape:()=>e})}omit(t){let e={};for(let i of I.util.objectKeys(this.shape))t[i]||(e[i]=this.shape[i]);return new s({...this._def,shape:()=>e})}deepPartial(){return qe(this)}partial(t){let e={};for(let i of I.util.objectKeys(this.shape)){let u=this.shape[i];t&&!t[i]?e[i]=u:e[i]=u.optional()}return new s({...this._def,shape:()=>e})}required(t){let e={};for(let i of I.util.objectKeys(this.shape))if(t&&!t[i])e[i]=this.shape[i];else{let l=this.shape[i];for(;l instanceof J;)l=l._def.innerType;e[i]=l}return new s({...this._def,shape:()=>e})}keyof(){return Vr(I.util.objectKeys(this.shape))}};p.ZodObject=q;q.create=(s,t)=>new q({shape:()=>s,unknownKeys:"strip",catchall:se.create(),typeName:E.ZodObject,...j(t)});q.strictCreate=(s,t)=>new q({shape:()=>s,unknownKeys:"strict",catchall:se.create(),typeName:E.ZodObject,...j(t)});q.lazycreate=(s,t)=>new q({shape:s,unknownKeys:"strip",catchall:se.create(),typeName:E.ZodObject,...j(t)});var Ee=class extends P{_parse(t){let{ctx:e}=this._processInputParams(t),i=this._def.options;function u(l){for(let m of l)if(m.result.status==="valid")return m.result;for(let m of l)if(m.result.status==="dirty")return e.common.issues.push(...m.ctx.common.issues),m.result;let g=l.map(m=>new C.ZodError(m.ctx.common.issues));return(0,h.addIssueToContext)(e,{code:C.ZodIssueCode.invalid_union,unionErrors:g}),h.INVALID}if(e.common.async)return Promise.all(i.map(async l=>{let g={...e,common:{...e.common,issues:[]},parent:null};return{result:await l._parseAsync({data:e.data,path:e.path,parent:g}),ctx:g}})).then(u);{let l,g=[];for(let x of i){let b={...e,common:{...e.common,issues:[]},parent:null},Z=x._parseSync({data:e.data,path:e.path,parent:b});if(Z.status==="valid")return Z;Z.status==="dirty"&&!l&&(l={result:Z,ctx:b}),b.common.issues.length&&g.push(b.common.issues)}if(l)return e.common.issues.push(...l.ctx.common.issues),l.result;let m=g.map(x=>new C.ZodError(x));return(0,h.addIssueToContext)(e,{code:C.ZodIssueCode.invalid_union,unionErrors:m}),h.INVALID}}get options(){return this._def.options}};p.ZodUnion=Ee;Ee.create=(s,t)=>new Ee({options:s,typeName:E.ZodUnion,...j(t)});var ue=s=>s instanceof Pe?ue(s.schema):s instanceof Y?ue(s.innerType()):s instanceof Re?[s.value]:s instanceof Se?s.options:s instanceof De?I.util.objectValues(s.enum):s instanceof Le?ue(s._def.innerType):s instanceof Oe?[void 0]:s instanceof Ne?[null]:s instanceof J?[void 0,...ue(s.unwrap())]:s instanceof oe?[null,...ue(s.unwrap())]:s instanceof nt||s instanceof Me?ue(s.unwrap()):s instanceof Ve?ue(s._def.innerType):[],Ot=class s extends P{_parse(t){let{ctx:e}=this._processInputParams(t);if(e.parsedType!==I.ZodParsedType.object)return(0,h.addIssueToContext)(e,{code:C.ZodIssueCode.invalid_type,expected:I.ZodParsedType.object,received:e.parsedType}),h.INVALID;let i=this.discriminator,u=e.data[i],l=this.optionsMap.get(u);return l?e.common.async?l._parseAsync({data:e.data,path:e.path,parent:e}):l._parseSync({data:e.data,path:e.path,parent:e}):((0,h.addIssueToContext)(e,{code:C.ZodIssueCode.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[i]}),h.INVALID)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,e,i){let u=new Map;for(let l of e){let g=ue(l.shape[t]);if(!g.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let m of g){if(u.has(m))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(m)}`);u.set(m,l)}}return new s({typeName:E.ZodDiscriminatedUnion,discriminator:t,options:e,optionsMap:u,...j(i)})}};p.ZodDiscriminatedUnion=Ot;function fs(s,t){let e=(0,I.getParsedType)(s),i=(0,I.getParsedType)(t);if(s===t)return{valid:!0,data:s};if(e===I.ZodParsedType.object&&i===I.ZodParsedType.object){let u=I.util.objectKeys(t),l=I.util.objectKeys(s).filter(m=>u.indexOf(m)!==-1),g={...s,...t};for(let m of l){let x=fs(s[m],t[m]);if(!x.valid)return{valid:!1};g[m]=x.data}return{valid:!0,data:g}}else if(e===I.ZodParsedType.array&&i===I.ZodParsedType.array){if(s.length!==t.length)return{valid:!1};let u=[];for(let l=0;l<s.length;l++){let g=s[l],m=t[l],x=fs(g,m);if(!x.valid)return{valid:!1};u.push(x.data)}return{valid:!0,data:u}}else return e===I.ZodParsedType.date&&i===I.ZodParsedType.date&&+s==+t?{valid:!0,data:s}:{valid:!1}}var je=class extends P{_parse(t){let{status:e,ctx:i}=this._processInputParams(t),u=(l,g)=>{if((0,h.isAborted)(l)||(0,h.isAborted)(g))return h.INVALID;let m=fs(l.value,g.value);return m.valid?(((0,h.isDirty)(l)||(0,h.isDirty)(g))&&e.dirty(),{status:e.value,value:m.data}):((0,h.addIssueToContext)(i,{code:C.ZodIssueCode.invalid_intersection_types}),h.INVALID)};return i.common.async?Promise.all([this._def.left._parseAsync({data:i.data,path:i.path,parent:i}),this._def.right._parseAsync({data:i.data,path:i.path,parent:i})]).then(([l,g])=>u(l,g)):u(this._def.left._parseSync({data:i.data,path:i.path,parent:i}),this._def.right._parseSync({data:i.data,path:i.path,parent:i}))}};p.ZodIntersection=je;je.create=(s,t,e)=>new je({left:s,right:t,typeName:E.ZodIntersection,...j(e)});var ie=class s extends P{_parse(t){let{status:e,ctx:i}=this._processInputParams(t);if(i.parsedType!==I.ZodParsedType.array)return(0,h.addIssueToContext)(i,{code:C.ZodIssueCode.invalid_type,expected:I.ZodParsedType.array,received:i.parsedType}),h.INVALID;if(i.data.length<this._def.items.length)return(0,h.addIssueToContext)(i,{code:C.ZodIssueCode.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),h.INVALID;!this._def.rest&&i.data.length>this._def.items.length&&((0,h.addIssueToContext)(i,{code:C.ZodIssueCode.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),e.dirty());let l=[...i.data].map((g,m)=>{let x=this._def.items[m]||this._def.rest;return x?x._parse(new H(i,g,i.path,m)):null}).filter(g=>!!g);return i.common.async?Promise.all(l).then(g=>h.ParseStatus.mergeArray(e,g)):h.ParseStatus.mergeArray(e,l)}get items(){return this._def.items}rest(t){return new s({...this._def,rest:t})}};p.ZodTuple=ie;ie.create=(s,t)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ie({items:s,typeName:E.ZodTuple,rest:null,...j(t)})};var Nt=class s extends P{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:e,ctx:i}=this._processInputParams(t);if(i.parsedType!==I.ZodParsedType.object)return(0,h.addIssueToContext)(i,{code:C.ZodIssueCode.invalid_type,expected:I.ZodParsedType.object,received:i.parsedType}),h.INVALID;let u=[],l=this._def.keyType,g=this._def.valueType;for(let m in i.data)u.push({key:l._parse(new H(i,m,i.path,m)),value:g._parse(new H(i,i.data[m],i.path,m)),alwaysSet:m in i.data});return i.common.async?h.ParseStatus.mergeObjectAsync(e,u):h.ParseStatus.mergeObjectSync(e,u)}get element(){return this._def.valueType}static create(t,e,i){return e instanceof P?new s({keyType:t,valueType:e,typeName:E.ZodRecord,...j(i)}):new s({keyType:ye.create(),valueType:t,typeName:E.ZodRecord,...j(e)})}};p.ZodRecord=Nt;var Ke=class extends P{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:e,ctx:i}=this._processInputParams(t);if(i.parsedType!==I.ZodParsedType.map)return(0,h.addIssueToContext)(i,{code:C.ZodIssueCode.invalid_type,expected:I.ZodParsedType.map,received:i.parsedType}),h.INVALID;let u=this._def.keyType,l=this._def.valueType,g=[...i.data.entries()].map(([m,x],b)=>({key:u._parse(new H(i,m,i.path,[b,"key"])),value:l._parse(new H(i,x,i.path,[b,"value"]))}));if(i.common.async){let m=new Map;return Promise.resolve().then(async()=>{for(let x of g){let b=await x.key,Z=await x.value;if(b.status==="aborted"||Z.status==="aborted")return h.INVALID;(b.status==="dirty"||Z.status==="dirty")&&e.dirty(),m.set(b.value,Z.value)}return{status:e.value,value:m}})}else{let m=new Map;for(let x of g){let b=x.key,Z=x.value;if(b.status==="aborted"||Z.status==="aborted")return h.INVALID;(b.status==="dirty"||Z.status==="dirty")&&e.dirty(),m.set(b.value,Z.value)}return{status:e.value,value:m}}}};p.ZodMap=Ke;Ke.create=(s,t,e)=>new Ke({valueType:t,keyType:s,typeName:E.ZodMap,...j(e)});var Ye=class s extends P{_parse(t){let{status:e,ctx:i}=this._processInputParams(t);if(i.parsedType!==I.ZodParsedType.set)return(0,h.addIssueToContext)(i,{code:C.ZodIssueCode.invalid_type,expected:I.ZodParsedType.set,received:i.parsedType}),h.INVALID;let u=this._def;u.minSize!==null&&i.data.size<u.minSize.value&&((0,h.addIssueToContext)(i,{code:C.ZodIssueCode.too_small,minimum:u.minSize.value,type:"set",inclusive:!0,exact:!1,message:u.minSize.message}),e.dirty()),u.maxSize!==null&&i.data.size>u.maxSize.value&&((0,h.addIssueToContext)(i,{code:C.ZodIssueCode.too_big,maximum:u.maxSize.value,type:"set",inclusive:!0,exact:!1,message:u.maxSize.message}),e.dirty());let l=this._def.valueType;function g(x){let b=new Set;for(let Z of x){if(Z.status==="aborted")return h.INVALID;Z.status==="dirty"&&e.dirty(),b.add(Z.value)}return{status:e.value,value:b}}let m=[...i.data.values()].map((x,b)=>l._parse(new H(i,x,i.path,b)));return i.common.async?Promise.all(m).then(x=>g(x)):g(m)}min(t,e){return new s({...this._def,minSize:{value:t,message:O.errorUtil.toString(e)}})}max(t,e){return new s({...this._def,maxSize:{value:t,message:O.errorUtil.toString(e)}})}size(t,e){return this.min(t,e).max(t,e)}nonempty(t){return this.min(1,t)}};p.ZodSet=Ye;Ye.create=(s,t)=>new Ye({valueType:s,minSize:null,maxSize:null,typeName:E.ZodSet,...j(t)});var Et=class s extends P{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:e}=this._processInputParams(t);if(e.parsedType!==I.ZodParsedType.function)return(0,h.addIssueToContext)(e,{code:C.ZodIssueCode.invalid_type,expected:I.ZodParsedType.function,received:e.parsedType}),h.INVALID;function i(m,x){return(0,h.makeIssue)({data:m,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,(0,kt.getErrorMap)(),kt.defaultErrorMap].filter(b=>!!b),issueData:{code:C.ZodIssueCode.invalid_arguments,argumentsError:x}})}function u(m,x){return(0,h.makeIssue)({data:m,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,(0,kt.getErrorMap)(),kt.defaultErrorMap].filter(b=>!!b),issueData:{code:C.ZodIssueCode.invalid_return_type,returnTypeError:x}})}let l={errorMap:e.common.contextualErrorMap},g=e.data;if(this._def.returns instanceof be){let m=this;return(0,h.OK)(async function(...x){let b=new C.ZodError([]),Z=await m._def.args.parseAsync(x,l).catch(Te=>{throw b.addIssue(i(x,Te)),b}),L=await Reflect.apply(g,this,Z);return await m._def.returns._def.type.parseAsync(L,l).catch(Te=>{throw b.addIssue(u(L,Te)),b})})}else{let m=this;return(0,h.OK)(function(...x){let b=m._def.args.safeParse(x,l);if(!b.success)throw new C.ZodError([i(x,b.error)]);let Z=Reflect.apply(g,this,b.data),L=m._def.returns.safeParse(Z,l);if(!L.success)throw new C.ZodError([u(Z,L.error)]);return L.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new s({...this._def,args:ie.create(t).rest(le.create())})}returns(t){return new s({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,e,i){return new s({args:t||ie.create([]).rest(le.create()),returns:e||le.create(),typeName:E.ZodFunction,...j(i)})}};p.ZodFunction=Et;var Pe=class extends P{get schema(){return this._def.getter()}_parse(t){let{ctx:e}=this._processInputParams(t);return this._def.getter()._parse({data:e.data,path:e.path,parent:e})}};p.ZodLazy=Pe;Pe.create=(s,t)=>new Pe({getter:s,typeName:E.ZodLazy,...j(t)});var Re=class extends P{_parse(t){if(t.data!==this._def.value){let e=this._getOrReturnCtx(t);return(0,h.addIssueToContext)(e,{received:e.data,code:C.ZodIssueCode.invalid_literal,expected:this._def.value}),h.INVALID}return{status:"valid",value:t.data}}get value(){return this._def.value}};p.ZodLiteral=Re;Re.create=(s,t)=>new Re({value:s,typeName:E.ZodLiteral,...j(t)});function Vr(s,t){return new Se({values:s,typeName:E.ZodEnum,...j(t)})}var Se=class s extends P{_parse(t){if(typeof t.data!="string"){let e=this._getOrReturnCtx(t),i=this._def.values;return(0,h.addIssueToContext)(e,{expected:I.util.joinValues(i),received:e.parsedType,code:C.ZodIssueCode.invalid_type}),h.INVALID}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let e=this._getOrReturnCtx(t),i=this._def.values;return(0,h.addIssueToContext)(e,{received:e.data,code:C.ZodIssueCode.invalid_enum_value,options:i}),h.INVALID}return(0,h.OK)(t.data)}get options(){return this._def.values}get enum(){let t={};for(let e of this._def.values)t[e]=e;return t}get Values(){let t={};for(let e of this._def.values)t[e]=e;return t}get Enum(){let t={};for(let e of this._def.values)t[e]=e;return t}extract(t,e=this._def){return s.create(t,{...this._def,...e})}exclude(t,e=this._def){return s.create(this.options.filter(i=>!t.includes(i)),{...this._def,...e})}};p.ZodEnum=Se;Se.create=Vr;var De=class extends P{_parse(t){let e=I.util.getValidEnumValues(this._def.values),i=this._getOrReturnCtx(t);if(i.parsedType!==I.ZodParsedType.string&&i.parsedType!==I.ZodParsedType.number){let u=I.util.objectValues(e);return(0,h.addIssueToContext)(i,{expected:I.util.joinValues(u),received:i.parsedType,code:C.ZodIssueCode.invalid_type}),h.INVALID}if(this._cache||(this._cache=new Set(I.util.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let u=I.util.objectValues(e);return(0,h.addIssueToContext)(i,{received:i.data,code:C.ZodIssueCode.invalid_enum_value,options:u}),h.INVALID}return(0,h.OK)(t.data)}get enum(){return this._def.values}};p.ZodNativeEnum=De;De.create=(s,t)=>new De({values:s,typeName:E.ZodNativeEnum,...j(t)});var be=class extends P{unwrap(){return this._def.type}_parse(t){let{ctx:e}=this._processInputParams(t);if(e.parsedType!==I.ZodParsedType.promise&&e.common.async===!1)return(0,h.addIssueToContext)(e,{code:C.ZodIssueCode.invalid_type,expected:I.ZodParsedType.promise,received:e.parsedType}),h.INVALID;let i=e.parsedType===I.ZodParsedType.promise?e.data:Promise.resolve(e.data);return(0,h.OK)(i.then(u=>this._def.type.parseAsync(u,{path:e.path,errorMap:e.common.contextualErrorMap})))}};p.ZodPromise=be;be.create=(s,t)=>new be({type:s,typeName:E.ZodPromise,...j(t)});var Y=class extends P{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===E.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:e,ctx:i}=this._processInputParams(t),u=this._def.effect||null,l={addIssue:g=>{(0,h.addIssueToContext)(i,g),g.fatal?e.abort():e.dirty()},get path(){return i.path}};if(l.addIssue=l.addIssue.bind(l),u.type==="preprocess"){let g=u.transform(i.data,l);if(i.common.async)return Promise.resolve(g).then(async m=>{if(e.value==="aborted")return h.INVALID;let x=await this._def.schema._parseAsync({data:m,path:i.path,parent:i});return x.status==="aborted"?h.INVALID:x.status==="dirty"||e.value==="dirty"?(0,h.DIRTY)(x.value):x});{if(e.value==="aborted")return h.INVALID;let m=this._def.schema._parseSync({data:g,path:i.path,parent:i});return m.status==="aborted"?h.INVALID:m.status==="dirty"||e.value==="dirty"?(0,h.DIRTY)(m.value):m}}if(u.type==="refinement"){let g=m=>{let x=u.refinement(m,l);if(i.common.async)return Promise.resolve(x);if(x instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return m};if(i.common.async===!1){let m=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});return m.status==="aborted"?h.INVALID:(m.status==="dirty"&&e.dirty(),g(m.value),{status:e.value,value:m.value})}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(m=>m.status==="aborted"?h.INVALID:(m.status==="dirty"&&e.dirty(),g(m.value).then(()=>({status:e.value,value:m.value}))))}if(u.type==="transform")if(i.common.async===!1){let g=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});if(!(0,h.isValid)(g))return h.INVALID;let m=u.transform(g.value,l);if(m instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:e.value,value:m}}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(g=>(0,h.isValid)(g)?Promise.resolve(u.transform(g.value,l)).then(m=>({status:e.value,value:m})):h.INVALID);I.util.assertNever(u)}};p.ZodEffects=Y;p.ZodTransformer=Y;Y.create=(s,t,e)=>new Y({schema:s,typeName:E.ZodEffects,effect:t,...j(e)});Y.createWithPreprocess=(s,t,e)=>new Y({schema:t,effect:{type:"preprocess",transform:s},typeName:E.ZodEffects,...j(e)});var J=class extends P{_parse(t){return this._getType(t)===I.ZodParsedType.undefined?(0,h.OK)(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};p.ZodOptional=J;J.create=(s,t)=>new J({innerType:s,typeName:E.ZodOptional,...j(t)});var oe=class extends P{_parse(t){return this._getType(t)===I.ZodParsedType.null?(0,h.OK)(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};p.ZodNullable=oe;oe.create=(s,t)=>new oe({innerType:s,typeName:E.ZodNullable,...j(t)});var Le=class extends P{_parse(t){let{ctx:e}=this._processInputParams(t),i=e.data;return e.parsedType===I.ZodParsedType.undefined&&(i=this._def.defaultValue()),this._def.innerType._parse({data:i,path:e.path,parent:e})}removeDefault(){return this._def.innerType}};p.ZodDefault=Le;Le.create=(s,t)=>new Le({innerType:s,typeName:E.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...j(t)});var Ve=class extends P{_parse(t){let{ctx:e}=this._processInputParams(t),i={...e,common:{...e.common,issues:[]}},u=this._def.innerType._parse({data:i.data,path:i.path,parent:{...i}});return(0,h.isAsync)(u)?u.then(l=>({status:"valid",value:l.status==="valid"?l.value:this._def.catchValue({get error(){return new C.ZodError(i.common.issues)},input:i.data})})):{status:"valid",value:u.status==="valid"?u.value:this._def.catchValue({get error(){return new C.ZodError(i.common.issues)},input:i.data})}}removeCatch(){return this._def.innerType}};p.ZodCatch=Ve;Ve.create=(s,t)=>new Ve({innerType:s,typeName:E.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...j(t)});var Je=class extends P{_parse(t){if(this._getType(t)!==I.ZodParsedType.nan){let i=this._getOrReturnCtx(t);return(0,h.addIssueToContext)(i,{code:C.ZodIssueCode.invalid_type,expected:I.ZodParsedType.nan,received:i.parsedType}),h.INVALID}return{status:"valid",value:t.data}}};p.ZodNaN=Je;Je.create=s=>new Je({typeName:E.ZodNaN,...j(s)});p.BRAND=Symbol("zod_brand");var nt=class extends P{_parse(t){let{ctx:e}=this._processInputParams(t),i=e.data;return this._def.type._parse({data:i,path:e.path,parent:e})}unwrap(){return this._def.type}};p.ZodBranded=nt;var it=class s extends P{_parse(t){let{status:e,ctx:i}=this._processInputParams(t);if(i.common.async)return(async()=>{let l=await this._def.in._parseAsync({data:i.data,path:i.path,parent:i});return l.status==="aborted"?h.INVALID:l.status==="dirty"?(e.dirty(),(0,h.DIRTY)(l.value)):this._def.out._parseAsync({data:l.value,path:i.path,parent:i})})();{let u=this._def.in._parseSync({data:i.data,path:i.path,parent:i});return u.status==="aborted"?h.INVALID:u.status==="dirty"?(e.dirty(),{status:"dirty",value:u.value}):this._def.out._parseSync({data:u.value,path:i.path,parent:i})}}static create(t,e){return new s({in:t,out:e,typeName:E.ZodPipeline})}};p.ZodPipeline=it;var Me=class extends P{_parse(t){let e=this._def.innerType._parse(t),i=u=>((0,h.isValid)(u)&&(u.value=Object.freeze(u.value)),u);return(0,h.isAsync)(e)?e.then(u=>i(u)):i(e)}unwrap(){return this._def.innerType}};p.ZodReadonly=Me;Me.create=(s,t)=>new Me({innerType:s,typeName:E.ZodReadonly,...j(t)});function Rr(s,t){let e=typeof s=="function"?s(t):typeof s=="string"?{message:s}:s;return typeof e=="string"?{message:e}:e}function Mr(s,t={},e){return s?_e.create().superRefine((i,u)=>{let l=s(i);if(l instanceof Promise)return l.then(g=>{if(!g){let m=Rr(t,i),x=m.fatal??e??!0;u.addIssue({code:"custom",...m,fatal:x})}});if(!l){let g=Rr(t,i),m=g.fatal??e??!0;u.addIssue({code:"custom",...g,fatal:m})}}):_e.create()}p.late={object:q.lazycreate};var E;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline",s.ZodReadonly="ZodReadonly"})(E||(p.ZodFirstPartyTypeKind=E={}));var co=(s,t={message:`Input not instance of ${s.name}`})=>Mr(e=>e instanceof s,t);p.instanceof=co;var Ur=ye.create;p.string=Ur;var Fr=Ze.create;p.number=Fr;var fo=Je.create;p.nan=fo;var po=we.create;p.bigint=po;var Br=Ae.create;p.boolean=Br;var ho=ke.create;p.date=ho;var mo=Ge.create;p.symbol=mo;var go=Oe.create;p.undefined=go;var vo=Ne.create;p.null=vo;var yo=_e.create;p.any=yo;var _o=le.create;p.unknown=_o;var bo=se.create;p.never=bo;var To=We.create;p.void=To;var xo=de.create;p.array=xo;var Co=q.create;p.object=Co;var Io=q.strictCreate;p.strictObject=Io;var $o=Ee.create;p.union=$o;var Zo=Ot.create;p.discriminatedUnion=Zo;var wo=je.create;p.intersection=wo;var Ao=ie.create;p.tuple=Ao;var ko=Nt.create;p.record=ko;var Oo=Ke.create;p.map=Oo;var No=Ye.create;p.set=No;var Eo=Et.create;p.function=Eo;var jo=Pe.create;p.lazy=jo;var Po=Re.create;p.literal=Po;var Ro=Se.create;p.enum=Ro;var So=De.create;p.nativeEnum=So;var Do=be.create;p.promise=Do;var zr=Y.create;p.effect=zr;p.transformer=zr;var Lo=J.create;p.optional=Lo;var Vo=oe.create;p.nullable=Vo;var Mo=Y.createWithPreprocess;p.preprocess=Mo;var Uo=it.create;p.pipeline=Uo;var Fo=()=>Ur().optional();p.ostring=Fo;var Bo=()=>Fr().optional();p.onumber=Bo;var zo=()=>Br().optional();p.oboolean=zo;p.coerce={string:(s=>ye.create({...s,coerce:!0})),number:(s=>Ze.create({...s,coerce:!0})),boolean:(s=>Ae.create({...s,coerce:!0})),bigint:(s=>we.create({...s,coerce:!0})),date:(s=>ke.create({...s,coerce:!0}))};p.NEVER=h.INVALID});var ps=B(Q=>{"use strict";var qo=Q&&Q.__createBinding||(Object.create?(function(s,t,e,i){i===void 0&&(i=e);var u=Object.getOwnPropertyDescriptor(t,e);(!u||("get"in u?!t.__esModule:u.writable||u.configurable))&&(u={enumerable:!0,get:function(){return t[e]}}),Object.defineProperty(s,i,u)}):(function(s,t,e,i){i===void 0&&(i=e),s[i]=t[e]})),He=Q&&Q.__exportStar||function(s,t){for(var e in s)e!=="default"&&!Object.prototype.hasOwnProperty.call(t,e)&&qo(t,s,e)};Object.defineProperty(Q,"__esModule",{value:!0});He(wt(),Q);He(ds(),Q);He(Nr(),Q);He(rt(),Q);He(qr(),Q);He(Zt(),Q)});var hs=B(G=>{"use strict";var Gr=G&&G.__createBinding||(Object.create?(function(s,t,e,i){i===void 0&&(i=e);var u=Object.getOwnPropertyDescriptor(t,e);(!u||("get"in u?!t.__esModule:u.writable||u.configurable))&&(u={enumerable:!0,get:function(){return t[e]}}),Object.defineProperty(s,i,u)}):(function(s,t,e,i){i===void 0&&(i=e),s[i]=t[e]})),Go=G&&G.__setModuleDefault||(Object.create?(function(s,t){Object.defineProperty(s,"default",{enumerable:!0,value:t})}):function(s,t){s.default=t}),Wo=G&&G.__importStar||function(s){if(s&&s.__esModule)return s;var t={};if(s!=null)for(var e in s)e!=="default"&&Object.prototype.hasOwnProperty.call(s,e)&&Gr(t,s,e);return Go(t,s),t},Ko=G&&G.__exportStar||function(s,t){for(var e in s)e!=="default"&&!Object.prototype.hasOwnProperty.call(t,e)&&Gr(t,s,e)};Object.defineProperty(G,"__esModule",{value:!0});G.z=void 0;var Wr=Wo(ps());G.z=Wr;Ko(ps(),G);G.default=Wr});var Yr=B(A=>{"use strict";var Yo=A&&A.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(A,"__esModule",{value:!0});A.Output=A.Entity=A.Ref=A.Cardinality=A.Enum=A.EnumValue=A.TableGroup=A.TableGroupOption=A.TableRef=A.Table=A.TableIndices=A.TableOption=A.Column=A.StickyNote=A.Project=A.Options=A.Settings=A.Comment=void 0;var $=Yo(hs());A.Comment=$.default.object({type:$.default.literal("comment"),comment:$.default.string()});A.Settings=$.default.record($.default.string().nullable());A.Options=$.default.record($.default.string());A.Project=$.default.object({type:$.default.literal("project"),name:$.default.string().nullable(),options:A.Options.nullable().transform(s=>s||{})});A.StickyNote=$.default.object({type:$.default.literal("note"),name:$.default.string(),note:$.default.string()});A.Column=$.default.object({type:$.default.literal("column"),name:$.default.string(),data:$.default.string(),settings:A.Settings.nullable().transform(s=>s||{})});A.TableOption=$.default.object({type:$.default.literal("option"),option:$.default.record($.default.string())});A.TableIndices=$.default.object({type:$.default.literal("indices"),indices:$.default.array($.default.object({columns:$.default.array($.default.string()),settings:A.Settings.nullable().transform(s=>s||{})}))});A.Table=$.default.object({type:$.default.literal("table"),schema:$.default.string().nullable(),name:$.default.string(),alias:$.default.string().nullable(),items:$.default.array($.default.union([A.Comment,A.Column,A.TableOption,A.TableIndices])),settings:A.Settings.nullable().transform(s=>s||{})});A.TableRef=$.default.object({type:$.default.literal("table"),schema:$.default.string().nullable(),name:$.default.string()});A.TableGroupOption=$.default.object({type:$.default.literal("option"),option:$.default.record($.default.string())});A.TableGroup=$.default.object({type:$.default.literal("group"),name:$.default.string().nullable(),items:$.default.array($.default.union([A.Comment,A.TableRef,A.TableGroupOption])),settings:A.Settings.nullable().transform(s=>s||{})});A.EnumValue=$.default.object({type:$.default.literal("value"),name:$.default.string(),settings:A.Settings.nullable().transform(s=>s||{})});A.Enum=$.default.object({type:$.default.literal("enum"),schema:$.default.string().nullable(),name:$.default.string(),items:$.default.array($.default.union([A.Comment,A.EnumValue]))});A.Cardinality=$.default.union([$.default.literal("<>"),$.default.literal(">"),$.default.literal("<"),$.default.literal("-")]);var Kr=$.default.object({schema:$.default.string().nullable(),name:$.default.string(),columns:$.default.array($.default.string())});A.Ref=$.default.object({type:$.default.literal("ref"),cardinality:A.Cardinality,from:Kr,to:Kr,settings:A.Settings.nullable().transform(s=>s||{})});A.Entity=$.default.union([A.Comment,A.Project,A.StickyNote,A.Table,A.TableGroup,A.Enum,A.Ref]);A.Output=$.default.array(A.Entity)});var gs=B(jt=>{"use strict";Object.defineProperty(jt,"__esModule",{value:!0});jt.parse=void 0;var Jo=Ir(),Ho=Yr(),Qo=hs(),Xo=s=>{try{return Ho.Output.parse((0,Jo.parse)(s))}catch(t){throw new ms(t)}};jt.parse=Xo;var ms=class extends Error{constructor(t){t instanceof Qo.ZodError?super("Zod Error"):super(`Could not parse input at line ${t.location.start.line}:${t.location.start.column}. ${t.message}`),this.name="SyntaxError"}}});var Qr=B(Pt=>{"use strict";Object.defineProperty(Pt,"__esModule",{value:!0});Pt.check=void 0;var ot=as(),eu=gs(),tu=s=>{let t=X("table",s).map(m=>({actual:m,columns:X("column",m.items),indices:X("indices",m.items)[0],options:X("option",m.items).reduce((x,b)=>({...x,...b.option}),{})})),e=t.flatMap(m=>m.columns.flatMap(x=>{let b=x.settings.ref;if(!b)return[];let Z=`Ref: ${(0,ot.fullName)(m.actual)}.${x.name} ${b}`;return X("ref",(0,eu.parse)(Z))})),i=new Set,u=X("group",s).map(m=>({actual:m,tables:X("table",m.items).map(x=>{let b=Hr(x,t),Z=(0,ot.fullName)(b.actual);if(!i.add(Z))throw new Error(`Table ${x.name} belongs to multiple groups`);return b}),options:X("option",m.items).reduce((x,b)=>({...x,...b.option}),{})})),l=t.filter(m=>!i.has((0,ot.fullName)(m.actual))),g=X("ref",s).concat(e).map(m=>({actual:m,from:Jr(m.from,t),to:Jr(m.to,t)}));return{project:X("project",s)[0],ungroupedTables:l,groups:u,refs:g,enums:X("enum",s).map(m=>({actual:m,values:X("value",m.items).map(x=>x.name)}))}};Pt.check=tu;var Hr=(s,t)=>{let e=t.find(i=>s.schema===i.actual.schema&&(s.name===i.actual.name||s.name===i.actual.alias));if(!e)throw new Error(`Table ${(0,ot.fullName)(s)} does not exist`);return e},X=(s,t)=>t.filter(e=>e.type===s),Jr=(s,t)=>{let e=Hr(s,t);return{table:e,columns:s.columns.map(i=>{let u=e.columns.find(l=>l.name===i);if(!u)throw new Error(`Column ${i} does not exist in table ${(0,ot.fullName)(e.actual)}`);return u})}}});var sa=B(St=>{"use strict";Object.defineProperty(St,"__esModule",{value:!0});St.render=void 0;var ea=as(),su=(s,t)=>{if(t!=="dot")throw new Error("The edge DBML bundle only supports DOT lowering.");return ru(s)};St.render=su;var ru=s=>new Is(s).toDot(),vs=class{constructor(t,e){this.name="__TABLE__",this.port="f0",this.table=t,this.displayName=e}toDot(){let t=this.table.settings?.headercolor?this.table.settings.headercolor:"#1d71b8",e="#ffffff";if(t.startsWith("#")&&t.length==7){let l=parseInt(t.substring(1,3),16),g=parseInt(t.substring(3,5),16),m=parseInt(t.substring(5,7),16);l*.299+g*.587+m*.114>186&&(e="#000000")}let[i,u]=this.table.settings?.url?[` HREF="${this.table.settings.url}"`," \u{1F517}"]:["",""];return`<TR><TD PORT="${this.port}" BGCOLOR="${t}"${i}><FONT COLOR="${e}"><B> ${this.displayName}${u} </B></FONT></TD></TR>`}},ys=class{constructor(t,e,i){this.actual=e,this.name=e.name,this.port=t,this.indices=i.items.find(u=>u.type==="indices")||{type:"indices",indices:[]}}dataType(){return this.actual.data}toDot(){let t=this.indices.indices.filter(g=>g.columns.includes(this.actual.name)).map(g=>g.settings),e=g=>"pk"in g||"primary key"in g,i=this.actual.name,u=this.actual.settings||{};(e(u)||t.some(e))&&(i=`<B>${i}</B>`);let l=`<I>${this.dataType()}</I>`;return"not null"in u&&(l=l+" <B>(!)</B>"),`<TR><TD ALIGN="LEFT" PORT="${this.port}" BGCOLOR="#e7e2dd">12+ <TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0">13+ <TR>14+ <TD ALIGN="LEFT">${i} </TD>15+ <TD ALIGN="RIGHT"><FONT>${l}</FONT></TD>16+ </TR>17+ </TABLE>18+ </TD></TR>`}},_s=class{constructor(t,e,i){this.columns=i,this.port=t,this.name=e}toDot(){return`<TR><TD PORT="${this.port}" BGCOLOR="#e7e2dd"><FONT COLOR="#1d71b8"><I> ${this.columns.join(", ")} </I></FONT></TD></TR>`}},Rt=class{constructor(t){this.table=t,this.columns=[],t.columns.forEach((e,i)=>{this.columns.push(new ys(`f${i+1}`,e,t.actual))}),this.renderers=[new vs(t.actual,this.displayName()),...this.columns]}selfRef(){return`"${this.displayName()}":${this.renderers[0].port}`}ref(t){let e=this.findColumn(t);if(!e)throw new Error(`Unknown column ${this.displayName()}.${e}`);return`"${this.displayName()}":${e.port}`}findColumn(t){return this.renderers.find(e=>e.name===t)}refAll(t){let e={};t.forEach(l=>e[l]=this.renderers.findIndex(g=>g.name===l)+1||Number.MAX_SAFE_INTEGER);let i=t.sort((l,g)=>e[l]-e[g]).join(",");return this.findColumn(i)||this.renderers.push(new _s(`f${this.renderers.length}`,i,t)),this.ref(i)}displayName(){return(0,ea.fullName)(this.table.actual)}toDot(){let t=this.table.options.note||this.table.actual.settings?.note,e=t?`tooltip="${this.displayName()}\\n${ta(t)}";`:"";return`"${this.displayName()}" [id="${this.displayName()}";${e}label=<<TABLE BORDER="2" COLOR="#29235c" CELLBORDER="1" CELLSPACING="0" CELLPADDING="10">19+ ${this.renderers.map(i=>i.toDot()).join(`20+`)}21+ </TABLE>>];`}},bs=class{constructor(t){this.note=t.options.note||t.actual.settings?.note,this.color=t.actual.settings?.color?t.actual.settings.color:"#dddddd",this.name=t.actual.name||"-unnamed-",this.tables=t.tables.map(e=>new Rt(e))}toDot(){let t=this.note?`22+ tooltip="${this.name}\\n${ta(this.note)}"`:"";return`subgraph cluster_${this.name} {${t}23+ label="${this.name}"24+ style=filled;25+ color="${this.color}";26+27+ ${this.tables.map(e=>e.toDot()).join(`28+`)}29+ }`}},au={"<>":["*","*"],">":["*","1"],"<":["1","*"],"-":["1","1"]},Ts=class{constructor(t,e){this.ref=t.actual.cardinality!=="<"?t:{actual:{type:"ref",cardinality:t.actual.cardinality,from:t.actual.to,to:t.actual.from,settings:t.actual.settings},from:t.to,to:t.from},this.fromTable=e.find(i=>i.table===t.from.table),this.toTable=e.find(i=>i.table===t.to.table),this.fromRef=this.findRef(this.fromTable,t.actual.from.columns),this.toRef=this.findRef(this.toTable,t.actual.to.columns)}findRef(t,e){return e.length===1?t.ref(e[0]):t.refAll(e)}toDot(){let[t,e]=au[this.ref.actual.cardinality];return`${this.fromTable.selfRef()} -> ${this.toTable.selfRef()} [style=invis, weight=100, color=red]30+ ${this.fromRef}:e -> ${this.toRef}:w [dir=${this.ref.actual.cardinality=="<>"?"both":"forward"}, penwidth=3, color="#29235c", headlabel="${e}", taillabel="${t}"]`}},xs=class{constructor(t){this.enumType=t}name(){return(0,ea.fullName)(this.enumType.actual)}selfRef(){return`"${this.name()}":f0`}toDot(){return`"${this.name()}" [id="${this.name()}";label=<<TABLE BORDER="2" COLOR="#29235c" CELLBORDER="1" CELLSPACING="0" CELLPADDING="10">31+ <TR><TD PORT="f0" BGCOLOR="#29235c"><FONT COLOR="#ffffff"><B> ${this.name()} </B></FONT></TD></TR>32+ ${this.enumType.values.map((t,e)=>this.valueDot(t,e)).join(`33+`)}34+ </TABLE>>];`}valueDot(t,e){return`<TR><TD PORT="f${e}" BGCOLOR="#e7e2dd"><FONT COLOR="#1d71b8"><I> ${t} </I></FONT></TD></TR>`}},Cs=class{constructor(t,e){this.columnRef=t,this.enumRef=e}toDot(){return`${this.columnRef}:e -> ${this.enumRef}:w [penwidth=3, color="#29235c", arrowhead="none", arrowtail="none"]`}},Is=class{constructor(t){this.groups=t.groups.map(i=>new bs(i)),this.ungroupedTables=t.ungroupedTables.map(i=>new Rt(i));let e=this.groups.flatMap(i=>i.tables).concat(this.ungroupedTables);this.refs=t.refs.map(i=>new Ts(i,e)),this.enums=t.enums.map(i=>new xs(i)),this.enumRefs=this.groups.flatMap(i=>Xr(i.tables,this.enums)).concat(Xr(this.ungroupedTables,this.enums))}toDot(){return`digraph dbml {35+ rankdir=LR;36+ graph [fontname="helvetica", fontsize=32, fontcolor="#29235c", bgcolor="transparent"];37+ node [penwidth=0, margin=0, fontname="helvetica", fontsize=32, fontcolor="#29235c"];38+ edge [fontname="helvetica", fontsize=32, fontcolor="#29235c", color="#29235c"];39+40+ ${this.enums.map(t=>t.toDot()).join(`41+`)}42+ ${this.groups.map(t=>t.toDot()).join(`43+`)}44+ ${this.ungroupedTables.map(t=>t.toDot()).join(`45+`)}46+ ${this.refs.map(t=>t.toDot()).join(`47+`)}48+ ${this.enumRefs.map(t=>t.toDot()).join(`49+`)}50+ }51+`}},Xr=(s,t)=>s.flatMap(e=>e.columns.flatMap(i=>{let u=t.find(m=>m.name()===i.dataType());if(!u)return[];let l=e.ref(i.name),g=u.selfRef();return new Cs(l,g)})),ta=s=>(s=JSON.stringify(s),s.substring(1,s.length-1))});var ra=B(Dt=>{"use strict";Object.defineProperty(Dt,"__esModule",{value:!0});Dt.run=void 0;var nu=Qr(),iu=gs(),ou=sa(),uu=(s,t)=>(0,ou.render)((0,nu.check)((0,iu.parse)(s)),t);Dt.run=uu});var aa=Ci(ra(),1);function Eu(s){return(0,aa.run)(s,"dot")}export{Eu as dbmlToDot};
A diagramzip-render/src/vendor/dbml-entry.ts +5 -0
A diagramzip-render/src/vendor/dbml-provenance.md +29 -0
@@ -0,0 +1,29 @@
1+# DBML renderer provenance2+3+The edge DBML adapter retains the parser, checker, and DOT renderer from4+`@softwaretechnik/dbml-renderer` 1.0.31. The package is published as5+CommonJS but its source/dependency graph includes mixed module formats, so the6+Worker artifact is rebuilt explicitly with the repository's pinned esbuild:7+8+```sh9+npm ci10+npm run build:dbml11+```12+13+The build bundles `src/vendor/dbml-entry.ts` as an ESM artifact after a14+fail-closed build-time transform removes the unused SVG/Viz branch and the15+upstream parser's `console.debug` of Zod errors. DBML requests call the16+upstream `run(source, "dot")` path, then the shared GraphViz-Wasm runtime17+renders SVG. No parser grammar was rewritten and no filesystem/network access18+is available at runtime. Every rebuild must reproduce the expected DOT output19+for the package's complete published example corpus before the script exits.20+21+- Package: https://www.npmjs.com/package/@softwaretechnik/dbml-renderer/v/1.0.3122+- Source: https://github.com/softwaretechnik-berlin/dbml-renderer23+- npm tarball SHA-512: `ThoBDBc2/ODuCtvrHKLaZNHvBhSMdgTXae7z1hOgXn+i5Qdqp1tq5nK1rrkm7THfnAIXuZ3WxAeos1iRZSKeOw==`24+- License: ISC (package metadata)25+- Generated bundle SHA-256: `2d46e13b33834dd1174d947c2ada68b357ba29b5c94a07a217e22a00225bee35`26+27+The original compatibility image used GraphViz 2.47.0. The edge family uses28+GraphViz 15.1.1, so layout and SVG details can differ while DBML language29+coverage remains provided by the upstream parser.
M diagramzip-render/test/adapters.test.ts +1 -0
M diagramzip-render/test/catalog.test.ts +3 -3
A diagramzip-render/test/dbml.test.ts +69 -0
@@ -0,0 +1,69 @@
1+import { describe, expect, it } from 'vitest'2+import { dbmlAdapter } from '../src/adapters/edge/dbml'3+import { sanitizeAndDecorateSvg } from '../src/svg'4+import type { RenderRequest } from '../src/types'5+import { dbmlToDot } from '../src/vendor/dbml-backend.js'6+7+function request(source: string, options: Record<string, string> = {}): RenderRequest {8+ return {9+ engine: 'dbml',10+ source,11+ format: 'svg',12+ options,13+ metadata: { title: '', description: '' },14+ presentation: { background: '', padding: 0, frame: false },15+ }16+}17+18+describe('DBML upstream lowering', () => {19+ it('retains tables, fields, indexes, and refs in the DOT model', () => {20+ const dot = dbmlToDot(`21+ Project app { database_type: 'PostgreSQL' }22+ Table users {23+ id int [pk]24+ email varchar [unique, not null]25+ indexes { (email) [name: 'users_email'] }26+ }27+ Table posts {28+ id int [pk]29+ user_id int30+ }31+ Ref: posts.user_id > users.id32+ `.trim() + '\n')33+ expect(dot).toContain('"users"')34+ expect(dot).toContain('"posts"')35+ expect(dot).toContain('email')36+ expect(dot).toContain('( ! )'.replaceAll(' ', ''))37+ expect(dot).toMatch(/posts.*users|users.*posts/s)38+ })39+40+ it('preserves useful parser locations for malformed input', () => {41+ expect(() => dbmlToDot('Table users { id integer')).toThrow(/line 1:25|Expected/)42+ })43+44+ it('renders through the shared GraphViz-Wasm backend', async () => {45+ const result = await dbmlAdapter.render(request('Table users { id integer [primary key] }'), new AbortController().signal)46+ expect(result.runtime).toBe('edge-wasm')47+ expect(result.engineVersion).toBe('dbml@1.0.31+graphviz@15.1.1')48+ expect(result.body).toMatch(/<svg[\s>]/i)49+ expect(result.body).toContain('users')50+ })51+52+ it('rejects renderer options and oversized or overly complex source', async () => {53+ const signal = new AbortController().signal54+ await expect(dbmlAdapter.render(request('Table users { id integer }', { layout: 'neato' }), signal))55+ .rejects.toMatchObject({ status: 400, code: 'invalid_options' })56+ await expect(dbmlAdapter.render(request('x'.repeat(262_145)), signal))57+ .rejects.toMatchObject({ status: 413, code: 'request_too_large' })58+ await expect(dbmlAdapter.render(request(Array.from({ length: 2_001 }, (_, index) => `Table t${index} { id int }`).join('\n')), signal))59+ .rejects.toMatchObject({ status: 413, code: 'request_too_large' })60+ })61+62+ it('removes external DBML table links from the final SVG', async () => {63+ const result = await dbmlAdapter.render(request("Table users [url: 'https://example.com/private'] { id integer }"), new AbortController().signal)64+ expect(result.body).toContain('https://example.com/private')65+ const sanitized = sanitizeAndDecorateSvg(result.body, request('').metadata, request('').presentation, 'dbml')66+ expect(sanitized).not.toContain('https://example.com/private')67+ expect(sanitized).toContain('users')68+ })69+})
M diagramzip-render/test/gateway.test.ts +1 -1
A diagramzip-render/vendor-licenses/dbml-renderer-NOTICE +45 -0
@@ -0,0 +1,45 @@
1+@softwaretechnik/dbml-renderer 1.0.312+https://github.com/softwaretechnik-berlin/dbml-renderer3+4+The GraphViz-family Worker bundles the upstream DBML parser, semantic checker,5+and DOT composer. The npm package declares the ISC license but does not ship a6+LICENSE file or a named copyright notice. The Worker bundle also includes Zod7+3.25.76 under the MIT license.8+9+DBML renderer ISC License10+11+Copyright (c) the @softwaretechnik/dbml-renderer contributors12+13+Permission to use, copy, modify, and/or distribute this software for any14+purpose with or without fee is hereby granted, provided that the above15+copyright notice and this permission notice appear in all copies.16+17+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH18+REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY19+AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,20+INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM21+LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR22+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR23+PERFORMANCE OF THIS SOFTWARE.24+25+Zod MIT License26+27+Copyright (c) 2025 Colin McDonnell28+29+Permission is hereby granted, free of charge, to any person obtaining a copy30+of this software and associated documentation files (the "Software"), to deal31+in the Software without restriction, including without limitation the rights32+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell33+copies of the Software, and to permit persons to whom the Software is34+furnished to do so, subject to the following conditions:35+36+The above copyright notice and this permission notice shall be included in all37+copies or substantial portions of the Software.38+39+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR40+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,41+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE42+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER43+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,44+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE45+SOFTWARE.
D diagramzip-render/wrangler.compatibility/dbml.jsonc +0 -1
M diagramzip-render/wrangler.units/graphviz-family.jsonc +2 -1
M diagramzip/src/renderer-units.js +1 -1
M diagramzip/test/renderer-units.test.js +1 -1