@fern-api/java-dynamic-snippets 3.29.2 → 3.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -12,20 +12,20 @@ ${o}`);this.isAtStartOfLine()&&(u=o+u),r&&(u+=`
|
|
|
12
12
|
`)}writeSemicolonIfLastCharacterIsNot(){this.lastCharacterIsSemicolon||this.writeInternal(";")}writeNewLineIfLastLineNot(){this.lastCharacterIsNewline||this.writeInternal(`
|
|
13
13
|
`)}indent(){this.indentLevel++}dedent(){this.indentLevel--}delimit({nodes:e,delimiter:t,writeFunction:r}){if(e.length>0){let a=e[0];a!=null&&r(a);for(let o=1;o<e.length;o++){this.write(t);let u=e[o];u!=null&&r(u)}}}toString(){return this.buffer}writeInternal(e){if(e.length===0)return;let t=!this.lastCharacterIsNewline;this.hasWrittenAnything=!0,this.lastCharacterIsNewline=e.endsWith(`
|
|
14
14
|
`),this.lastCharacterIsSemicolon=e.endsWith(";");let r=e.split(`
|
|
15
|
-
`),a=ge&&!this.shouldSkipTracking(r)&&this.lastCharacterIsNewline;t&&(this.lastLine=`${this.lastLine}${r.shift()||""}`),this.lastCharacterIsNewline&&r.pop(),this.lineBuffer.push(...r),a&&this.appendTrackingComment()}set lastLine(e){this.lineBuffer.length>0?this.lineBuffer[this.lineBuffer.length-1]=e:this.lineBuffer.push(e)}get lastLine(){return this.lineBuffer[this.lineBuffer.length-1]||""}shouldSkipTracking(e){return!1}formatStack(e,t=""){return e.map(r=>`${t?`(${t}) `:""} ${r.fn} - ${r.path} : ${r.position}`)}filterStack(e){return e.filter(t=>!t.fn.startsWith(`${this.constructor.name}.`))}appendTrackingComment(){let e=[...this.formatStack(this.filterStack(Ht({maxFrames:15,skip:3}))),...this.formatStack(this.filterStack(this.nodeStackFrames),"node")];switch(this.nodeStackFrames.length=0,vr){case"single":return this.singleLineTrackingComment(e);case"multiline":return this.multiLineTrackingComment(e);case"box":return this.boxTrackingComment(e)}}singleLineTrackingComment(e){this.lastLine=`${this.lastLine} // ${e.join(" ")}`}multiLineTrackingComment(e){this.lineBuffer.push(...e.map(t=>` // ${t}`))}boxTrackingComment(e){this.lineBuffer.push("/*",...e.map(t=>` ${t}`),"*/")}isAtStartOfLine(){return this.lastCharacterIsNewline||!this.hasWrittenAnything}getIndentString(){return" ".repeat(this.indentLevel*this.getTabSize())}getTabSize(){return Wo}};m();y();h();function Tr(n){return n?.name!=null&&n?.assignment!=null}m();y();h();m();y();h();m();y();h();var At=class{constructor(){_(this,"reporter");_(this,"snippet");_(this,"err");this.snippet=void 0,this.reporter=void 0,this.err=void 0}update({context:e,snippet:t}){this.shouldUpdate({snippet:t,reporter:e.errors})&&(this.reporter=e.errors.clone(),this.snippet=t)}getResponseOrThrow({endpoint:e}){if(this.snippet!=null&&this.reporter!=null)return{snippet:this.snippet,errors:this.reporter.toDynamicSnippetErrors()};throw this.err??new Error(`Failed to generate snippet for endpoint "${e.method} ${e.path}"`)}shouldUpdate({snippet:e,reporter:t}){return this.reporter==null||this.reporter.size()>0&&t.size()===0?!0:e.length>(this.snippet?.length??0)}};var St=class{constructor(e){_(this,"context");this.context=e}async generate(e,t={}){let r=this.context.resolveEndpointLocationOrThrow(e.endpoint);if(r.length===0)throw new Error(`No endpoints found that match "${e.endpoint.method} ${e.endpoint.path}"`);let a=new At;for(let o of r){let u=this.context.clone(),p=this.createSnippetGenerator(u);try{let g=await p.generateSnippet({endpoint:o,request:e,options:t});if(u.errors.empty())return{snippet:g,errors:void 0};a.update({context:u,snippet:g})}catch(g){a.err==null&&(a.err=g)}}return a.getResponseOrThrow({endpoint:e.endpoint})}async generateSnippetAst(e,t={}){let r=this.context.resolveEndpointLocationOrThrow(e.endpoint);if(r.length===0)throw new Error(`No endpoints found that match "${e.endpoint.method} ${e.endpoint.path}"`);let a;for(let o of r){let u=this.context.clone(),p=this.createSnippetGenerator(u);try{return await p.generateSnippetAst({endpoint:o,request:e,options:t})}catch(g){a=g}}throw a??new Error(`Failed to generate snippet AST for endpoint: ${e.endpoint.method} ${e.endpoint.path}`)}generateSync(e,t={}){let r=this.context.resolveEndpointLocationOrThrow(e.endpoint);if(r.length===0)throw new Error(`No endpoints found that match "${e.endpoint.method} ${e.endpoint.path}"`);let a=new At;for(let o of r){let u=this.context.clone(),p=this.createSnippetGenerator(u);try{let g=p.generateSnippetSync({endpoint:o,request:e,options:t});if(u.errors.empty())return{snippet:g,errors:void 0};a.update({context:u,snippet:g})}catch(g){a.err==null&&(a.err=g)}}return a.getResponseOrThrow({endpoint:e.endpoint})}};m();y();h();m();y();h();m();y();h();var Ct=class{constructor(){_(this,"REFERENCE_REGEX",/^(GET|POST|PUT|DELETE|PATCH|HEAD)\s(\/\S*)$/)}validate(e){return this.REFERENCE_REGEX.test(e)?{type:"valid"}:{type:"invalid"}}tryParse(e){if(this.validate(e).type==="invalid")return;let r=e.match(this.REFERENCE_REGEX);if(!(r==null||r[1]==null||r[2]==null))return{method:r[1],path:r[2]}}};m();y();h();var $={Critical:"CRITICAL",Warning:"WARNING"},Lt=class n{constructor(){_(this,"errors");_(this,"path");this.errors=[],this.path=[]}add(e){this.errors.push({...e,path:[...this.path]})}scope(e){this.path.push(e)}unscope(){this.path.pop()}getBySeverity(e){return this.errors.filter(t=>t.severity===e)}empty(){return this.errors.length===0}size(){return this.errors.length}clone(){let e=new n;return e.errors=[...this.errors],e.path=[...this.path],e}reset(){this.errors=[],this.path=[]}toDynamicSnippetErrors(){return this.errors.map(e=>({severity:e.severity,path:e.path!=null?this.pathToStringArray(e.path):void 0,message:e.message}))}pathToStringArray(e){let t=[];for(let r of e){if(typeof r=="string"){t.push(r);continue}t[t.length-1]+=`[${r.index}]`}return t}};var Bt=class{constructor({ir:e,config:t,options:r={}}){_(this,"config");_(this,"options");_(this,"errors");_(this,"_ir");_(this,"httpEndpointReferenceParser");this._ir=e,this.config=t,this.options=r,this.errors=new Lt,this.httpEndpointReferenceParser=new Ct}associateQueryParametersByWireValue({parameters:e,values:t}){let r=[];for(let[a,o]of Object.entries(t))if(o!==void 0){this.errors.scope(a);try{let u=e.find(g=>g.name.wireValue===a);if(u==null)throw this.newParameterNotRecognizedError(a);let p=this.isListTypeReference(u.typeReference)&&!Array.isArray(o)?[o]:o;r.push({name:u.name,typeReference:u.typeReference,value:p})}finally{this.errors.unscope()}}return r}associateByWireValueOrDefault({parameters:e,values:t}){let r=[];for(let a of e){this.errors.scope(a.name.wireValue);try{let o=t[a.name.wireValue];if(o==null)if(a.typeReference.type==="primitive"&&a.typeReference.value==="STRING")o=`<${a.name.wireValue}>`;else{this.errors.add({severity:$.Critical,message:this.newParameterNotRecognizedError(a.name.wireValue).message});continue}r.push({name:a.name,typeReference:a.typeReference,value:o})}finally{this.errors.unscope()}}return r}associateByWireValue({parameters:e,values:t,ignoreMissingParameters:r}){let a=[];for(let[o,u]of Object.entries(t))if(u!==void 0){this.errors.scope(o);try{let p=e.find(g=>g.name.wireValue===o);if(p==null){if(r)continue;this.errors.add({severity:$.Critical,message:this.newParameterNotRecognizedError(o).message});continue}a.push({name:p.name,typeReference:p.typeReference,value:u})}finally{this.errors.unscope()}}return a}getExampleObjectProperties({parameters:e,snippetObject:t}){let r=typeof t=="object"&&t!==null&&!Array.isArray(t)?t:{},a=[];for(let o of e){let u=r[o.name.wireValue];u==null?o.typeReference.type==="nullable"&&a.push({name:o.name,typeReference:o.typeReference,value:null}):a.push({name:o.name,typeReference:o.typeReference,value:u})}return a}getSingleFileValue({property:e,record:t}){let r=t[e.wireValue];if(r!=null){if(typeof r!="string"){this.errors.add({severity:$.Critical,message:`Expected file value to be a string, got ${typeof r}`});return}return r}}getFileArrayValues({property:e,record:t}){let r=t[e.wireValue];if(r==null)return;if(!Array.isArray(r)){this.errors.add({severity:$.Critical,message:`Expected file array value to be an array of strings, got ${typeof r}`});return}let a=[];for(let o of r){if(typeof o!="string"){this.errors.add({severity:$.Critical,message:`Expected file array value to be an array of strings, got ${typeof o}`});return}a.push(o)}return a}getRecord(e){if(typeof e!="object"||Array.isArray(e)){this.errors.add({severity:$.Critical,message:`Expected object with key, value pairs but got: ${Array.isArray(e)?"array":typeof e}`});return}return e??{}}resolveNamedType({typeId:e}){let t=this._ir.types[e];if(t==null){this.errors.add({severity:$.Critical,message:`Type identified by "${e}" could not be found`});return}return t}resolveDiscriminatedUnionTypeInstance({discriminatedUnion:e,value:t}){let r=this.getRecord(t);if(r==null)return;let a=e.discriminant.wireValue,o=r[a];if(o==null){this.errors.add({severity:$.Critical,message:this.newParameterNotRecognizedError(a).message});return}if(typeof o!="string"){this.errors.add({severity:$.Critical,message:`Expected discriminant value to be a string but got: ${typeof o}`});return}let u=e.types[o];if(u==null){this.errors.add({severity:$.Critical,message:`No type found for discriminant value "${o}"`});return}let{[a]:p,...g}=r;return{singleDiscriminatedUnionType:u,discriminantValue:u.discriminantValue,value:g}}resolveEndpointOrThrow(e){let t=this.httpEndpointReferenceParser.tryParse(e);if(t==null)throw new Error(`Failed to parse endpoint reference "${e}"`);return this.resolveEndpointLocationOrThrow(t)}resolveEndpointLocation(e){let t=[];for(let r of Object.values(this._ir.endpoints))this.parsedEndpointMatches({endpoint:r,parsedEndpoint:e})&&t.push(r);return t}resolveEndpointLocationOrThrow(e){let t=this.resolveEndpointLocation(e);if(t.length===0)throw new Error(`Failed to find endpoint identified by "${e.method} ${e.path}"`);return t}resolveEndpointById(e){return this._ir.endpoints[e]}resolveEndpointByIdOrThrow(e){let t=this.resolveEndpointById(e);if(t==null)throw new Error(`Failed to find endpoint with ID "${e}"`);return t}needsRequestParameter({request:e,inlinePathParameters:t,inlineFileProperties:r}){return this.includePathParametersInWrappedRequest({request:e,inlinePathParameters:t})||e.queryParameters!=null&&e.queryParameters.length>0||e.headers!=null&&e.headers.length>0?!0:e.body!=null?this.includeRequestBodyInWrappedRequest({body:e.body,inlineFileProperties:r}):!e.metadata?.onlyPathParameters}includePathParametersInWrappedRequest({request:e,inlinePathParameters:t}){return t&&(e.metadata?.includePathParameters??!1)}isFileUploadRequestBody(e){switch(e.type){case"fileUpload":return!0;case"properties":case"referenced":return!1;default:M(e)}}resolveEnvironmentName(e){if(this._ir.environments==null)return;let t=this._ir.environments.environments;switch(t.type){case"singleBaseUrl":{let r=t.environments.find(a=>a.id===e);return r?.name}case"multipleBaseUrls":{let r=t.environments.find(a=>a.id===e);return r?.name}default:M(t)}}isSingleEnvironmentID(e){return typeof e=="string"}isMultiEnvironmentValues(e){return typeof e=="object"}validateMultiEnvironmentUrlValues(e){if(this._ir.environments==null)return this.errors.add({severity:$.Critical,message:"Multiple environments are not supported for single base URL environments; use the baseUrl option instead"}),!1;let t=this._ir.environments.environments;switch(t.type){case"singleBaseUrl":return this.errors.add({severity:$.Critical,message:"Multiple environments are not supported for single base URL environments; use the baseUrl option instead"}),!1;case"multipleBaseUrls":{let r=t.environments[0];if(r==null)return this.errors.add({severity:$.Critical,message:"Multiple environments are not supported; use the baseUrl option instead"}),!1;let a=new Set(Nt(r.urls));for(let o of Nt(e))a.has(o)&&a.delete(o);return a.size>0?(this.errors.add({severity:$.Critical,message:`The provided environments are invalid; got: [${Object.keys(e).join(", ")}], expected: [${Nt(r.urls).join(", ")}]`}),!1):!0}}}getValueAsNumber({value:e}){if(typeof e!="number"){this.errors.add({severity:$.Critical,message:this.newTypeMismatchError({expected:"number",value:e}).message});return}return e}getValueAsBoolean({value:e}){if(typeof e!="boolean"){this.errors.add({severity:$.Critical,message:this.newTypeMismatchError({expected:"boolean",value:e}).message});return}return e}getValueAsString({value:e}){if(typeof e!="string"){this.errors.add({severity:$.Critical,message:this.newTypeMismatchError({expected:"string",value:e}).message});return}return e}isOptional(e){switch(e.type){case"nullable":return this.isOptional(e.value);case"optional":return!0;case"named":{let t=this.resolveNamedType({typeId:e.value});return t==null?!1:t.type==="alias"?this.isNullable(t.typeReference):!1}}return!1}isNullable(e){switch(e.type){case"nullable":return!0;case"optional":return this.isNullable(e.value);case"named":{let t=this.resolveNamedType({typeId:e.value});return t==null?!1:t.type==="alias"?this.isNullable(t.typeReference):!1}}return!1}newAuthMismatchError({auth:e,values:t}){return new Error(`Expected auth type ${e.type}, got ${t.type}`)}newParameterNotRecognizedError(e){return new Error(`"${e}" is not a recognized parameter for this endpoint`)}newTypeMismatchError({expected:e,value:t}){return new Error(`Expected ${e}, got ${typeof t}`)}includeRequestBodyInWrappedRequest({body:e,inlineFileProperties:t}){switch(e.type){case"properties":case"referenced":return!0;case"fileUpload":return this.includeFileUploadBodyInWrappedRequest({fileUpload:e,inlineFileProperties:t});default:M(e)}}includeFileUploadBodyInWrappedRequest({fileUpload:e,inlineFileProperties:t}){return this.fileUploadHasBodyProperties({fileUpload:e})||t&&this.fileUploadHasFileProperties({fileUpload:e})}fileUploadHasBodyProperties({fileUpload:e}){return e.properties.some(t=>{switch(t.type){case"file":case"fileArray":return!1;case"bodyProperty":return!0;default:M(t)}})}fileUploadHasFileProperties({fileUpload:e}){return e.properties.some(t=>{switch(t.type){case"file":case"fileArray":return!0;case"bodyProperty":return!1;default:M(t)}})}isListTypeReference(e){return e.type==="optional"?this.isListTypeReference(e.value):e.type==="list"||e.type==="set"}parsedEndpointMatches({endpoint:e,parsedEndpoint:t}){return e.location.method===t.method&&e.location.path===t.path}};m();y();h();var Me;(function(n){n.Concise="concise",n.Full="full"})(Me||(Me={}));m();y();h();var se={PathParameters:"pathParameters",QueryParameters:"queryParameters",Headers:"headers",RequestBody:"requestBody"};m();y();h();m();y();h();m();y();h();m();y();h();var $e=class extends Et{constructor({packageName:t,customConfig:r,formatter:a}){super();_(this,"packageName");_(this,"customConfig");_(this,"formatter");_(this,"imports",new Set);this.packageName=t,this.customConfig=r,this.formatter=a??new It}addImport(t){this.imports.add(t)}getImports(){return new Set(this.imports)}};var Pt=class extends $e{constructor({packageName:e,customConfig:t,formatter:r}){super({packageName:e,customConfig:t,formatter:r})}async toStringAsync(){let e=this.getContent();if(this.formatter!=null)try{return this.formatter.format(e)}catch(t){throw new Error(`Failed to format Java file: ${t}
|
|
15
|
+
`),a=ge&&!this.shouldSkipTracking(r)&&this.lastCharacterIsNewline;t&&(this.lastLine=`${this.lastLine}${r.shift()||""}`),this.lastCharacterIsNewline&&r.pop(),this.lineBuffer.push(...r),a&&this.appendTrackingComment()}set lastLine(e){this.lineBuffer.length>0?this.lineBuffer[this.lineBuffer.length-1]=e:this.lineBuffer.push(e)}get lastLine(){return this.lineBuffer[this.lineBuffer.length-1]||""}shouldSkipTracking(e){return!1}formatStack(e,t=""){return e.map(r=>`${t?`(${t}) `:""} ${r.fn} - ${r.path} : ${r.position}`)}filterStack(e){return e.filter(t=>!t.fn.startsWith(`${this.constructor.name}.`))}appendTrackingComment(){let e=[...this.formatStack(this.filterStack(Ht({maxFrames:15,skip:3}))),...this.formatStack(this.filterStack(this.nodeStackFrames),"node")];switch(this.nodeStackFrames.length=0,vr){case"single":return this.singleLineTrackingComment(e);case"multiline":return this.multiLineTrackingComment(e);case"box":return this.boxTrackingComment(e)}}singleLineTrackingComment(e){this.lastLine=`${this.lastLine} // ${e.join(" ")}`}multiLineTrackingComment(e){this.lineBuffer.push(...e.map(t=>` // ${t}`))}boxTrackingComment(e){this.lineBuffer.push("/*",...e.map(t=>` ${t}`),"*/")}isAtStartOfLine(){return this.lastCharacterIsNewline||!this.hasWrittenAnything}getIndentString(){return" ".repeat(this.indentLevel*this.getTabSize())}getTabSize(){return Wo}};m();y();h();function Tr(n){return n?.name!=null&&n?.assignment!=null}m();y();h();m();y();h();m();y();h();var At=class{constructor(){_(this,"reporter");_(this,"snippet");_(this,"err");this.snippet=void 0,this.reporter=void 0,this.err=void 0}update({context:e,snippet:t}){this.shouldUpdate({snippet:t,reporter:e.errors})&&(this.reporter=e.errors.clone(),this.snippet=t)}getResponseOrThrow({endpoint:e}){if(this.snippet!=null&&this.reporter!=null)return{snippet:this.snippet,errors:this.reporter.toDynamicSnippetErrors()};throw this.err??new Error(`Failed to generate snippet for endpoint "${e.method} ${e.path}"`)}shouldUpdate({snippet:e,reporter:t}){return this.reporter==null||this.reporter.size()>0&&t.size()===0?!0:e.length>(this.snippet?.length??0)}};var St=class{constructor(e){_(this,"context");this.context=e}async generate(e,t={}){let r=this.context.resolveEndpointLocationOrThrow(e.endpoint);if(r.length===0)throw new Error(`No endpoints found that match "${e.endpoint.method} ${e.endpoint.path}"`);let a=new At;for(let o of r){let u=this.context.clone(),p=this.createSnippetGenerator(u);try{let g=await p.generateSnippet({endpoint:o,request:e,options:t});if(u.errors.empty())return{snippet:g,errors:void 0};a.update({context:u,snippet:g})}catch(g){a.err==null&&(a.err=g)}}return a.getResponseOrThrow({endpoint:e.endpoint})}async generateSnippetAst(e,t={}){let r=this.context.resolveEndpointLocationOrThrow(e.endpoint);if(r.length===0)throw new Error(`No endpoints found that match "${e.endpoint.method} ${e.endpoint.path}"`);let a;for(let o of r){let u=this.context.clone(),p=this.createSnippetGenerator(u);try{return await p.generateSnippetAst({endpoint:o,request:e,options:t})}catch(g){a=g}}throw a??new Error(`Failed to generate snippet AST for endpoint: ${e.endpoint.method} ${e.endpoint.path}`)}generateSync(e,t={}){let r=this.context.resolveEndpointLocationOrThrow(e.endpoint);if(r.length===0)throw new Error(`No endpoints found that match "${e.endpoint.method} ${e.endpoint.path}"`);let a=new At;for(let o of r){let u=this.context.clone(),p=this.createSnippetGenerator(u);try{let g=p.generateSnippetSync({endpoint:o,request:e,options:t});if(u.errors.empty())return{snippet:g,errors:void 0};a.update({context:u,snippet:g})}catch(g){a.err==null&&(a.err=g)}}return a.getResponseOrThrow({endpoint:e.endpoint})}};m();y();h();m();y();h();m();y();h();var Ct=class{constructor(){_(this,"REFERENCE_REGEX",/^(GET|POST|PUT|DELETE|PATCH|HEAD)\s(\/\S*)$/)}validate(e){return this.REFERENCE_REGEX.test(e)?{type:"valid"}:{type:"invalid"}}tryParse(e){if(this.validate(e).type==="invalid")return;let r=e.match(this.REFERENCE_REGEX);if(!(r==null||r[1]==null||r[2]==null))return{method:r[1],path:r[2]}}};m();y();h();var D={Critical:"CRITICAL",Warning:"WARNING"},Lt=class n{constructor(){_(this,"errors");_(this,"path");this.errors=[],this.path=[]}add(e){this.errors.push({...e,path:[...this.path]})}scope(e){this.path.push(e)}unscope(){this.path.pop()}getBySeverity(e){return this.errors.filter(t=>t.severity===e)}empty(){return this.errors.length===0}size(){return this.errors.length}clone(){let e=new n;return e.errors=[...this.errors],e.path=[...this.path],e}reset(){this.errors=[],this.path=[]}toDynamicSnippetErrors(){return this.errors.map(e=>({severity:e.severity,path:e.path!=null?this.pathToStringArray(e.path):void 0,message:e.message}))}pathToStringArray(e){let t=[];for(let r of e){if(typeof r=="string"){t.push(r);continue}t[t.length-1]+=`[${r.index}]`}return t}};var Bt=class{constructor({ir:e,config:t,options:r={}}){_(this,"config");_(this,"options");_(this,"errors");_(this,"_ir");_(this,"httpEndpointReferenceParser");this._ir=e,this.config=t,this.options=r,this.errors=new Lt,this.httpEndpointReferenceParser=new Ct}associateQueryParametersByWireValue({parameters:e,values:t}){let r=[];for(let[a,o]of Object.entries(t))if(o!==void 0){this.errors.scope(a);try{let u=e.find(g=>g.name.wireValue===a);if(u==null)throw this.newParameterNotRecognizedError(a);let p=this.isListTypeReference(u.typeReference)&&!Array.isArray(o)?[o]:o;r.push({name:u.name,typeReference:u.typeReference,value:p})}finally{this.errors.unscope()}}return r}associateByWireValueOrDefault({parameters:e,values:t}){let r=[];for(let a of e){this.errors.scope(a.name.wireValue);try{let o=t[a.name.wireValue];if(o==null)if(a.typeReference.type==="primitive"&&a.typeReference.value==="STRING")o=`<${a.name.wireValue}>`;else{this.errors.add({severity:D.Critical,message:this.newParameterNotRecognizedError(a.name.wireValue).message});continue}r.push({name:a.name,typeReference:a.typeReference,value:o})}finally{this.errors.unscope()}}return r}associateByWireValue({parameters:e,values:t,ignoreMissingParameters:r}){let a=[];for(let[o,u]of Object.entries(t))if(u!==void 0){this.errors.scope(o);try{let p=e.find(g=>g.name.wireValue===o);if(p==null){if(r)continue;this.errors.add({severity:D.Critical,message:this.newParameterNotRecognizedError(o).message});continue}a.push({name:p.name,typeReference:p.typeReference,value:u})}finally{this.errors.unscope()}}return a}getExampleObjectProperties({parameters:e,snippetObject:t}){let r=typeof t=="object"&&t!==null&&!Array.isArray(t)?t:{},a=[];for(let o of e){let u=r[o.name.wireValue];u==null?o.typeReference.type==="nullable"&&a.push({name:o.name,typeReference:o.typeReference,value:null}):a.push({name:o.name,typeReference:o.typeReference,value:u})}return a}getSingleFileValue({property:e,record:t}){let r=t[e.wireValue];if(r!=null){if(typeof r!="string"){this.errors.add({severity:D.Critical,message:`Expected file value to be a string, got ${typeof r}`});return}return r}}getFileArrayValues({property:e,record:t}){let r=t[e.wireValue];if(r==null)return;if(!Array.isArray(r)){this.errors.add({severity:D.Critical,message:`Expected file array value to be an array of strings, got ${typeof r}`});return}let a=[];for(let o of r){if(typeof o!="string"){this.errors.add({severity:D.Critical,message:`Expected file array value to be an array of strings, got ${typeof o}`});return}a.push(o)}return a}getRecord(e){if(typeof e!="object"||Array.isArray(e)){this.errors.add({severity:D.Critical,message:`Expected object with key, value pairs but got: ${Array.isArray(e)?"array":typeof e}`});return}return e??{}}resolveNamedType({typeId:e}){let t=this._ir.types[e];if(t==null){this.errors.add({severity:D.Critical,message:`Type identified by "${e}" could not be found`});return}return t}resolveDiscriminatedUnionTypeInstance({discriminatedUnion:e,value:t}){let r=this.getRecord(t);if(r==null)return;let a=e.discriminant.wireValue,o=r[a];if(o==null){this.errors.add({severity:D.Critical,message:this.newParameterNotRecognizedError(a).message});return}if(typeof o!="string"){this.errors.add({severity:D.Critical,message:`Expected discriminant value to be a string but got: ${typeof o}`});return}let u=e.types[o];if(u==null){this.errors.add({severity:D.Critical,message:`No type found for discriminant value "${o}"`});return}let{[a]:p,...g}=r;return{singleDiscriminatedUnionType:u,discriminantValue:u.discriminantValue,value:g}}resolveEndpointOrThrow(e){let t=this.httpEndpointReferenceParser.tryParse(e);if(t==null)throw new Error(`Failed to parse endpoint reference "${e}"`);return this.resolveEndpointLocationOrThrow(t)}resolveEndpointLocation(e){let t=[];for(let r of Object.values(this._ir.endpoints))this.parsedEndpointMatches({endpoint:r,parsedEndpoint:e})&&t.push(r);return t}resolveEndpointLocationOrThrow(e){let t=this.resolveEndpointLocation(e);if(t.length===0)throw new Error(`Failed to find endpoint identified by "${e.method} ${e.path}"`);return t}resolveEndpointById(e){return this._ir.endpoints[e]}resolveEndpointByIdOrThrow(e){let t=this.resolveEndpointById(e);if(t==null)throw new Error(`Failed to find endpoint with ID "${e}"`);return t}needsRequestParameter({request:e,inlinePathParameters:t,inlineFileProperties:r}){return this.includePathParametersInWrappedRequest({request:e,inlinePathParameters:t})||e.queryParameters!=null&&e.queryParameters.length>0||e.headers!=null&&e.headers.length>0?!0:e.body!=null?this.includeRequestBodyInWrappedRequest({body:e.body,inlineFileProperties:r}):!e.metadata?.onlyPathParameters}includePathParametersInWrappedRequest({request:e,inlinePathParameters:t}){return t&&(e.metadata?.includePathParameters??!1)}isFileUploadRequestBody(e){switch(e.type){case"fileUpload":return!0;case"properties":case"referenced":return!1;default:M(e)}}resolveEnvironmentName(e){if(this._ir.environments==null)return;let t=this._ir.environments.environments;switch(t.type){case"singleBaseUrl":{let r=t.environments.find(a=>a.id===e);return r?.name}case"multipleBaseUrls":{let r=t.environments.find(a=>a.id===e);return r?.name}default:M(t)}}isSingleEnvironmentID(e){return typeof e=="string"}isMultiEnvironmentValues(e){return typeof e=="object"}validateMultiEnvironmentUrlValues(e){if(this._ir.environments==null)return this.errors.add({severity:D.Critical,message:"Multiple environments are not supported for single base URL environments; use the baseUrl option instead"}),!1;let t=this._ir.environments.environments;switch(t.type){case"singleBaseUrl":return this.errors.add({severity:D.Critical,message:"Multiple environments are not supported for single base URL environments; use the baseUrl option instead"}),!1;case"multipleBaseUrls":{let r=t.environments[0];if(r==null)return this.errors.add({severity:D.Critical,message:"Multiple environments are not supported; use the baseUrl option instead"}),!1;let a=new Set(Nt(r.urls));for(let o of Nt(e))a.has(o)&&a.delete(o);return a.size>0?(this.errors.add({severity:D.Critical,message:`The provided environments are invalid; got: [${Object.keys(e).join(", ")}], expected: [${Nt(r.urls).join(", ")}]`}),!1):!0}}}getValueAsNumber({value:e}){if(typeof e!="number"){this.errors.add({severity:D.Critical,message:this.newTypeMismatchError({expected:"number",value:e}).message});return}return e}getValueAsBoolean({value:e}){if(typeof e!="boolean"){this.errors.add({severity:D.Critical,message:this.newTypeMismatchError({expected:"boolean",value:e}).message});return}return e}getValueAsString({value:e}){if(typeof e!="string"){this.errors.add({severity:D.Critical,message:this.newTypeMismatchError({expected:"string",value:e}).message});return}return e}isOptional(e){switch(e.type){case"nullable":return this.isOptional(e.value);case"optional":return!0;case"named":{let t=this.resolveNamedType({typeId:e.value});return t==null?!1:t.type==="alias"?this.isNullable(t.typeReference):!1}}return!1}isNullable(e){switch(e.type){case"nullable":return!0;case"optional":return this.isNullable(e.value);case"named":{let t=this.resolveNamedType({typeId:e.value});return t==null?!1:t.type==="alias"?this.isNullable(t.typeReference):!1}}return!1}newAuthMismatchError({auth:e,values:t}){return new Error(`Expected auth type ${e.type}, got ${t.type}`)}newParameterNotRecognizedError(e){return new Error(`"${e}" is not a recognized parameter for this endpoint`)}newTypeMismatchError({expected:e,value:t}){return new Error(`Expected ${e}, got ${typeof t}`)}includeRequestBodyInWrappedRequest({body:e,inlineFileProperties:t}){switch(e.type){case"properties":case"referenced":return!0;case"fileUpload":return this.includeFileUploadBodyInWrappedRequest({fileUpload:e,inlineFileProperties:t});default:M(e)}}includeFileUploadBodyInWrappedRequest({fileUpload:e,inlineFileProperties:t}){return this.fileUploadHasBodyProperties({fileUpload:e})||t&&this.fileUploadHasFileProperties({fileUpload:e})}fileUploadHasBodyProperties({fileUpload:e}){return e.properties.some(t=>{switch(t.type){case"file":case"fileArray":return!1;case"bodyProperty":return!0;default:M(t)}})}fileUploadHasFileProperties({fileUpload:e}){return e.properties.some(t=>{switch(t.type){case"file":case"fileArray":return!0;case"bodyProperty":return!1;default:M(t)}})}isListTypeReference(e){return e.type==="optional"?this.isListTypeReference(e.value):e.type==="list"||e.type==="set"}parsedEndpointMatches({endpoint:e,parsedEndpoint:t}){return e.location.method===t.method&&e.location.path===t.path}};m();y();h();var Me;(function(n){n.Concise="concise",n.Full="full"})(Me||(Me={}));m();y();h();var se={PathParameters:"pathParameters",QueryParameters:"queryParameters",Headers:"headers",RequestBody:"requestBody"};m();y();h();m();y();h();m();y();h();m();y();h();var $e=class extends Et{constructor({packageName:t,customConfig:r,formatter:a}){super();_(this,"packageName");_(this,"customConfig");_(this,"formatter");_(this,"imports",new Set);this.packageName=t,this.customConfig=r,this.formatter=a??new It}addImport(t){this.imports.add(t)}getImports(){return new Set(this.imports)}};var Pt=class extends $e{constructor({packageName:e,customConfig:t,formatter:r}){super({packageName:e,customConfig:t,formatter:r})}async toStringAsync(){let e=this.getContent();if(this.formatter!=null)try{return this.formatter.format(e)}catch(t){throw new Error(`Failed to format Java file: ${t}
|
|
16
16
|
${e}`)}return e}toString(){let e=this.getContent();if(this.formatter!=null)try{return this.formatter.formatSync(e)}catch(t){throw new Error(`Failed to format Java file: ${t}
|
|
17
17
|
${e}`)}return e}getContent(){let e=`package ${this.packageName};
|
|
18
18
|
|
|
19
19
|
`,t=this.stringifyImports();return t.length>0?`${e}${t}
|
|
20
20
|
|
|
21
21
|
${this.buffer}`:e+this.buffer}stringifyImports(){return Array.from(this.imports).filter(e=>e!==this.packageName).map(e=>`import ${e};`).sort().join(`
|
|
22
|
-
`)}};m();y();h();m();y();h();var D={};Dt(D,{BRAND:()=>yu,DIRTY:()=>De,EMPTY_PATH:()=>Ho,INVALID:()=>L,NEVER:()=>el,OK:()=>te,ParseStatus:()=>X,Schema:()=>O,ZodAny:()=>Be,ZodArray:()=>Ie,ZodBigInt:()=>qe,ZodBoolean:()=>We,ZodBranded:()=>Ot,ZodCatch:()=>tt,ZodDate:()=>ze,ZodDefault:()=>et,ZodDiscriminatedUnion:()=>Qt,ZodEffects:()=>fe,ZodEnum:()=>Qe,ZodError:()=>oe,ZodFirstPartyTypeKind:()=>B,ZodFunction:()=>er,ZodIntersection:()=>Je,ZodIssueCode:()=>b,ZodLazy:()=>Ye,ZodLiteral:()=>Ke,ZodMap:()=>vt,ZodNaN:()=>bt,ZodNativeEnum:()=>Xe,ZodNever:()=>he,ZodNull:()=>Ge,ZodNullable:()=>we,ZodNumber:()=>Ve,ZodObject:()=>ue,ZodOptional:()=>pe,ZodParsedType:()=>I,ZodPipeline:()=>Ut,ZodPromise:()=>Pe,ZodReadonly:()=>rt,ZodRecord:()=>Xt,ZodSchema:()=>O,ZodSet:()=>wt,ZodString:()=>Le,ZodSymbol:()=>gt,ZodTransformer:()=>fe,ZodTuple:()=>ve,ZodType:()=>O,ZodUndefined:()=>Ze,ZodUnion:()=>He,ZodUnknown:()=>Re,ZodVoid:()=>xt,addIssueToContext:()=>R,any:()=>Nu,array:()=>Au,bigint:()=>wu,boolean:()=>ki,coerce:()=>Xu,custom:()=>bi,date:()=>bu,datetimeRegex:()=>vi,defaultErrorMap:()=>ke,discriminatedUnion:()=>Bu,effect:()=>zu,enum:()=>Vu,function:()=>Mu,getErrorMap:()=>mt,getParsedType:()=>xe,instanceof:()=>xu,intersection:()=>Pu,isAborted:()=>Yt,isAsync:()=>ht,isDirty:()=>Kt,isValid:()=>Ce,late:()=>gu,lazy:()=>$u,literal:()=>Du,makeIssue:()=>Ft,map:()=>Uu,nan:()=>vu,nativeEnum:()=>qu,never:()=>Iu,null:()=>ku,nullable:()=>Gu,number:()=>_i,object:()=>Su,objectUtil:()=>_r,oboolean:()=>Qu,onumber:()=>Ku,optional:()=>Zu,ostring:()=>Yu,pipeline:()=>Ju,preprocess:()=>Hu,promise:()=>Wu,quotelessJson:()=>zo,record:()=>Ou,set:()=>ju,setErrorMap:()=>Go,strictObject:()=>Cu,string:()=>Ti,symbol:()=>Tu,transformer:()=>zu,tuple:()=>Fu,undefined:()=>_u,union:()=>Lu,unknown:()=>Ru,util:()=>j,void:()=>Eu});m();y();h();m();y();h();m();y();h();m();y();h();m();y();h();var j;(function(n){n.assertEqual=a=>{};function e(a){}n.assertIs=e;function t(a){throw new Error}n.assertNever=t,n.arrayToEnum=a=>{let o={};for(let u of a)o[u]=u;return o},n.getValidEnumValues=a=>{let o=n.objectKeys(a).filter(p=>typeof a[a[p]]!="number"),u={};for(let p of o)u[p]=a[p];return n.objectValues(u)},n.objectValues=a=>n.objectKeys(a).map(function(o){return a[o]}),n.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{let o=[];for(let u in a)Object.prototype.hasOwnProperty.call(a,u)&&o.push(u);return o},n.find=(a,o)=>{for(let u of a)if(o(u))return u},n.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function r(a,o=" | "){return a.map(u=>typeof u=="string"?`'${u}'`:u).join(o)}n.joinValues=r,n.jsonStringifyReplacer=(a,o)=>typeof o=="bigint"?o.toString():o})(j||(j={}));var _r;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(_r||(_r={}));var I=j.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),xe=n=>{switch(typeof n){case"undefined":return I.undefined;case"string":return I.string;case"number":return Number.isNaN(n)?I.nan:I.number;case"boolean":return I.boolean;case"function":return I.function;case"bigint":return I.bigint;case"symbol":return I.symbol;case"object":return Array.isArray(n)?I.array:n===null?I.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?I.promise:typeof Map<"u"&&n instanceof Map?I.map:typeof Set<"u"&&n instanceof Set?I.set:typeof Date<"u"&&n instanceof Date?I.date:I.object;default:return I.unknown}};var b=j.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"]),zo=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:"),oe=class n extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(o){return o.message},r={_errors:[]},a=o=>{for(let u of o.issues)if(u.code==="invalid_union")u.unionErrors.map(a);else if(u.code==="invalid_return_type")a(u.returnTypeError);else if(u.code==="invalid_arguments")a(u.argumentsError);else if(u.path.length===0)r._errors.push(t(u));else{let p=r,g=0;for(;g<u.path.length;){let w=u.path[g];g===u.path.length-1?(p[w]=p[w]||{_errors:[]},p[w]._errors.push(t(u))):p[w]=p[w]||{_errors:[]},p=p[w],g++}}};return a(this),r}static assert(e){if(!(e instanceof n))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,j.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},r=[];for(let a of this.issues)if(a.path.length>0){let o=a.path[0];t[o]=t[o]||[],t[o].push(e(a))}else r.push(e(a));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}};oe.create=n=>new oe(n);var Zo=(n,e)=>{let t;switch(n.code){case b.invalid_type:n.received===I.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case b.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,j.jsonStringifyReplacer)}`;break;case b.unrecognized_keys:t=`Unrecognized key(s) in object: ${j.joinValues(n.keys,", ")}`;break;case b.invalid_union:t="Invalid input";break;case b.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${j.joinValues(n.options)}`;break;case b.invalid_enum_value:t=`Invalid enum value. Expected ${j.joinValues(n.options)}, received '${n.received}'`;break;case b.invalid_arguments:t="Invalid function arguments";break;case b.invalid_return_type:t="Invalid function return type";break;case b.invalid_date:t="Invalid date";break;case b.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:j.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case b.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="bigint"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case b.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case b.custom:t="Invalid input";break;case b.invalid_intersection_types:t="Intersection results could not be merged";break;case b.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case b.not_finite:t="Number must be finite";break;default:t=e.defaultError,j.assertNever(n)}return{message:t}},ke=Zo;var mi=ke;function Go(n){mi=n}function mt(){return mi}m();y();h();var Ft=n=>{let{data:e,path:t,errorMaps:r,issueData:a}=n,o=[...t,...a.path||[]],u={...a,path:o};if(a.message!==void 0)return{...a,path:o,message:a.message};let p="",g=r.filter(w=>!!w).slice().reverse();for(let w of g)p=w(u,{data:e,defaultError:p}).message;return{...a,path:o,message:p}},Ho=[];function R(n,e){let t=mt(),r=Ft({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===ke?void 0:ke].filter(a=>!!a)});n.common.issues.push(r)}var X=class n{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let r=[];for(let a of t){if(a.status==="aborted")return L;a.status==="dirty"&&e.dirty(),r.push(a.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){let r=[];for(let a of t){let o=await a.key,u=await a.value;r.push({key:o,value:u})}return n.mergeObjectSync(e,r)}static mergeObjectSync(e,t){let r={};for(let a of t){let{key:o,value:u}=a;if(o.status==="aborted"||u.status==="aborted")return L;o.status==="dirty"&&e.dirty(),u.status==="dirty"&&e.dirty(),o.value!=="__proto__"&&(typeof u.value<"u"||a.alwaysSet)&&(r[o.value]=u.value)}return{status:e.value,value:r}}},L=Object.freeze({status:"aborted"}),De=n=>({status:"dirty",value:n}),te=n=>({status:"valid",value:n}),Yt=n=>n.status==="aborted",Kt=n=>n.status==="dirty",Ce=n=>n.status==="valid",ht=n=>typeof Promise<"u"&&n instanceof Promise;m();y();h();m();y();h();var A;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e?.message})(A||(A={}));var de=class{constructor(e,t,r,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=a}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}},hi=(n,e)=>{if(Ce(e))return{success:!0,data:e.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new oe(n.common.issues);return this._error=t,this._error}}};function P(n){if(!n)return{};let{errorMap:e,invalid_type_error:t,required_error:r,description:a}=n;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:a}:{errorMap:(u,p)=>{let{message:g}=n;return u.code==="invalid_enum_value"?{message:g??p.defaultError}:typeof p.data>"u"?{message:g??r??p.defaultError}:u.code!=="invalid_type"?{message:p.defaultError}:{message:g??t??p.defaultError}},description:a}}var O=class{get description(){return this._def.description}_getType(e){return xe(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:xe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new X,ctx:{common:e.parent.common,data:e.data,parsedType:xe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(ht(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){let r={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:xe(e)},a=this._parseSync({data:e,path:r.path,parent:r});return hi(r,a)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:xe(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:t});return Ce(r)?{value:r.value}:{issues:t.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(r=>Ce(r)?{value:r.value}:{issues:t.common.issues})}async parseAsync(e,t){let r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){let r={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:xe(e)},a=this._parse({data:e,path:r.path,parent:r}),o=await(ht(a)?a:Promise.resolve(a));return hi(r,o)}refine(e,t){let r=a=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(a):t;return this._refinement((a,o)=>{let u=e(a),p=()=>o.addIssue({code:b.custom,...r(a)});return typeof Promise<"u"&&u instanceof Promise?u.then(g=>g?!0:(p(),!1)):u?!0:(p(),!1)})}refinement(e,t){return this._refinement((r,a)=>e(r)?!0:(a.addIssue(typeof t=="function"?t(r,a):t),!1))}_refinement(e){return new fe({schema:this,typeName:B.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return pe.create(this,this._def)}nullable(){return we.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ie.create(this)}promise(){return Pe.create(this,this._def)}or(e){return He.create([this,e],this._def)}and(e){return Je.create(this,e,this._def)}transform(e){return new fe({...P(this._def),schema:this,typeName:B.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new et({...P(this._def),innerType:this,defaultValue:t,typeName:B.ZodDefault})}brand(){return new Ot({typeName:B.ZodBranded,type:this,...P(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new tt({...P(this._def),innerType:this,catchValue:t,typeName:B.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ut.create(this,e)}readonly(){return rt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Jo=/^c[^\s-]{8,}$/i,Yo=/^[0-9a-z]+$/,Ko=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Qo=/^[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,Xo=/^[a-z0-9_-]{21}$/i,eu=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,tu=/^[-+]?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)?)??$/,ru=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,nu="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",kr,au=/^(?:(?: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])$/,iu=/^(?:(?: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])$/,su=/^(([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]))$/,ou=/^(([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])$/,uu=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,lu=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,gi="((\\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])))",cu=new RegExp(`^${gi}$`);function xi(n){let e="[0-5]\\d";n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`);let t=n.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function pu(n){return new RegExp(`^${xi(n)}$`)}function vi(n){let e=`${gi}T${xi(n)}`,t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function du(n,e){return!!((e==="v4"||!e)&&au.test(n)||(e==="v6"||!e)&&su.test(n))}function fu(n,e){if(!eu.test(n))return!1;try{let[t]=n.split(".");if(!t)return!1;let r=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),a=JSON.parse(atob(r));return!(typeof a!="object"||a===null||"typ"in a&&a?.typ!=="JWT"||!a.alg||e&&a.alg!==e)}catch{return!1}}function mu(n,e){return!!((e==="v4"||!e)&&iu.test(n)||(e==="v6"||!e)&&ou.test(n))}var Le=class n extends O{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==I.string){let o=this._getOrReturnCtx(e);return R(o,{code:b.invalid_type,expected:I.string,received:o.parsedType}),L}let r=new X,a;for(let o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(a=this._getOrReturnCtx(e,a),R(a,{code:b.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty());else if(o.kind==="max")e.data.length>o.value&&(a=this._getOrReturnCtx(e,a),R(a,{code:b.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty());else if(o.kind==="length"){let u=e.data.length>o.value,p=e.data.length<o.value;(u||p)&&(a=this._getOrReturnCtx(e,a),u?R(a,{code:b.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):p&&R(a,{code:b.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),r.dirty())}else if(o.kind==="email")ru.test(e.data)||(a=this._getOrReturnCtx(e,a),R(a,{validation:"email",code:b.invalid_string,message:o.message}),r.dirty());else if(o.kind==="emoji")kr||(kr=new RegExp(nu,"u")),kr.test(e.data)||(a=this._getOrReturnCtx(e,a),R(a,{validation:"emoji",code:b.invalid_string,message:o.message}),r.dirty());else if(o.kind==="uuid")Qo.test(e.data)||(a=this._getOrReturnCtx(e,a),R(a,{validation:"uuid",code:b.invalid_string,message:o.message}),r.dirty());else if(o.kind==="nanoid")Xo.test(e.data)||(a=this._getOrReturnCtx(e,a),R(a,{validation:"nanoid",code:b.invalid_string,message:o.message}),r.dirty());else if(o.kind==="cuid")Jo.test(e.data)||(a=this._getOrReturnCtx(e,a),R(a,{validation:"cuid",code:b.invalid_string,message:o.message}),r.dirty());else if(o.kind==="cuid2")Yo.test(e.data)||(a=this._getOrReturnCtx(e,a),R(a,{validation:"cuid2",code:b.invalid_string,message:o.message}),r.dirty());else if(o.kind==="ulid")Ko.test(e.data)||(a=this._getOrReturnCtx(e,a),R(a,{validation:"ulid",code:b.invalid_string,message:o.message}),r.dirty());else if(o.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),R(a,{validation:"url",code:b.invalid_string,message:o.message}),r.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),R(a,{validation:"regex",code:b.invalid_string,message:o.message}),r.dirty())):o.kind==="trim"?e.data=e.data.trim():o.kind==="includes"?e.data.includes(o.value,o.position)||(a=this._getOrReturnCtx(e,a),R(a,{code:b.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),r.dirty()):o.kind==="toLowerCase"?e.data=e.data.toLowerCase():o.kind==="toUpperCase"?e.data=e.data.toUpperCase():o.kind==="startsWith"?e.data.startsWith(o.value)||(a=this._getOrReturnCtx(e,a),R(a,{code:b.invalid_string,validation:{startsWith:o.value},message:o.message}),r.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(a=this._getOrReturnCtx(e,a),R(a,{code:b.invalid_string,validation:{endsWith:o.value},message:o.message}),r.dirty()):o.kind==="datetime"?vi(o).test(e.data)||(a=this._getOrReturnCtx(e,a),R(a,{code:b.invalid_string,validation:"datetime",message:o.message}),r.dirty()):o.kind==="date"?cu.test(e.data)||(a=this._getOrReturnCtx(e,a),R(a,{code:b.invalid_string,validation:"date",message:o.message}),r.dirty()):o.kind==="time"?pu(o).test(e.data)||(a=this._getOrReturnCtx(e,a),R(a,{code:b.invalid_string,validation:"time",message:o.message}),r.dirty()):o.kind==="duration"?tu.test(e.data)||(a=this._getOrReturnCtx(e,a),R(a,{validation:"duration",code:b.invalid_string,message:o.message}),r.dirty()):o.kind==="ip"?du(e.data,o.version)||(a=this._getOrReturnCtx(e,a),R(a,{validation:"ip",code:b.invalid_string,message:o.message}),r.dirty()):o.kind==="jwt"?fu(e.data,o.alg)||(a=this._getOrReturnCtx(e,a),R(a,{validation:"jwt",code:b.invalid_string,message:o.message}),r.dirty()):o.kind==="cidr"?mu(e.data,o.version)||(a=this._getOrReturnCtx(e,a),R(a,{validation:"cidr",code:b.invalid_string,message:o.message}),r.dirty()):o.kind==="base64"?uu.test(e.data)||(a=this._getOrReturnCtx(e,a),R(a,{validation:"base64",code:b.invalid_string,message:o.message}),r.dirty()):o.kind==="base64url"?lu.test(e.data)||(a=this._getOrReturnCtx(e,a),R(a,{validation:"base64url",code:b.invalid_string,message:o.message}),r.dirty()):j.assertNever(o);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement(a=>e.test(a),{validation:t,code:b.invalid_string,...A.errToObj(r)})}_addCheck(e){return new n({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...A.errToObj(e)})}url(e){return this._addCheck({kind:"url",...A.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...A.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...A.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...A.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...A.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...A.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...A.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...A.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...A.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...A.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...A.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...A.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...A.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...A.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...A.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...A.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...A.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...A.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...A.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...A.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...A.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...A.errToObj(t)})}nonempty(e){return this.min(1,A.errToObj(e))}trim(){return new n({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new n({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new n({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};Le.create=n=>new Le({checks:[],typeName:B.ZodString,coerce:n?.coerce??!1,...P(n)});function hu(n,e){let t=(n.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,a=t>r?t:r,o=Number.parseInt(n.toFixed(a).replace(".","")),u=Number.parseInt(e.toFixed(a).replace(".",""));return o%u/10**a}var Ve=class n extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==I.number){let o=this._getOrReturnCtx(e);return R(o,{code:b.invalid_type,expected:I.number,received:o.parsedType}),L}let r,a=new X;for(let o of this._def.checks)o.kind==="int"?j.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),R(r,{code:b.invalid_type,expected:"integer",received:"float",message:o.message}),a.dirty()):o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(r=this._getOrReturnCtx(e,r),R(r,{code:b.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),a.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(r=this._getOrReturnCtx(e,r),R(r,{code:b.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),a.dirty()):o.kind==="multipleOf"?hu(e.data,o.value)!==0&&(r=this._getOrReturnCtx(e,r),R(r,{code:b.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),R(r,{code:b.not_finite,message:o.message}),a.dirty()):j.assertNever(o);return{status:a.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,A.toString(t))}gt(e,t){return this.setLimit("min",e,!1,A.toString(t))}lte(e,t){return this.setLimit("max",e,!0,A.toString(t))}lt(e,t){return this.setLimit("max",e,!1,A.toString(t))}setLimit(e,t,r,a){return new n({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:A.toString(a)}]})}_addCheck(e){return new n({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:A.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:A.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:A.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:A.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:A.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:A.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:A.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:A.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:A.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&j.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}};Ve.create=n=>new Ve({checks:[],typeName:B.ZodNumber,coerce:n?.coerce||!1,...P(n)});var qe=class n extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==I.bigint)return this._getInvalidInput(e);let r,a=new X;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(r=this._getOrReturnCtx(e,r),R(r,{code:b.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),a.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(r=this._getOrReturnCtx(e,r),R(r,{code:b.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),a.dirty()):o.kind==="multipleOf"?e.data%o.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),R(r,{code:b.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):j.assertNever(o);return{status:a.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return R(t,{code:b.invalid_type,expected:I.bigint,received:t.parsedType}),L}gte(e,t){return this.setLimit("min",e,!0,A.toString(t))}gt(e,t){return this.setLimit("min",e,!1,A.toString(t))}lte(e,t){return this.setLimit("max",e,!0,A.toString(t))}lt(e,t){return this.setLimit("max",e,!1,A.toString(t))}setLimit(e,t,r,a){return new n({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:A.toString(a)}]})}_addCheck(e){return new n({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:A.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:A.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:A.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:A.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:A.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};qe.create=n=>new qe({checks:[],typeName:B.ZodBigInt,coerce:n?.coerce??!1,...P(n)});var We=class extends O{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==I.boolean){let r=this._getOrReturnCtx(e);return R(r,{code:b.invalid_type,expected:I.boolean,received:r.parsedType}),L}return te(e.data)}};We.create=n=>new We({typeName:B.ZodBoolean,coerce:n?.coerce||!1,...P(n)});var ze=class n extends O{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==I.date){let o=this._getOrReturnCtx(e);return R(o,{code:b.invalid_type,expected:I.date,received:o.parsedType}),L}if(Number.isNaN(e.data.getTime())){let o=this._getOrReturnCtx(e);return R(o,{code:b.invalid_date}),L}let r=new X,a;for(let o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(a=this._getOrReturnCtx(e,a),R(a,{code:b.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),r.dirty()):o.kind==="max"?e.data.getTime()>o.value&&(a=this._getOrReturnCtx(e,a),R(a,{code:b.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),r.dirty()):j.assertNever(o);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new n({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:A.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:A.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};ze.create=n=>new ze({checks:[],coerce:n?.coerce||!1,typeName:B.ZodDate,...P(n)});var gt=class extends O{_parse(e){if(this._getType(e)!==I.symbol){let r=this._getOrReturnCtx(e);return R(r,{code:b.invalid_type,expected:I.symbol,received:r.parsedType}),L}return te(e.data)}};gt.create=n=>new gt({typeName:B.ZodSymbol,...P(n)});var Ze=class extends O{_parse(e){if(this._getType(e)!==I.undefined){let r=this._getOrReturnCtx(e);return R(r,{code:b.invalid_type,expected:I.undefined,received:r.parsedType}),L}return te(e.data)}};Ze.create=n=>new Ze({typeName:B.ZodUndefined,...P(n)});var Ge=class extends O{_parse(e){if(this._getType(e)!==I.null){let r=this._getOrReturnCtx(e);return R(r,{code:b.invalid_type,expected:I.null,received:r.parsedType}),L}return te(e.data)}};Ge.create=n=>new Ge({typeName:B.ZodNull,...P(n)});var Be=class extends O{constructor(){super(...arguments),this._any=!0}_parse(e){return te(e.data)}};Be.create=n=>new Be({typeName:B.ZodAny,...P(n)});var Re=class extends O{constructor(){super(...arguments),this._unknown=!0}_parse(e){return te(e.data)}};Re.create=n=>new Re({typeName:B.ZodUnknown,...P(n)});var he=class extends O{_parse(e){let t=this._getOrReturnCtx(e);return R(t,{code:b.invalid_type,expected:I.never,received:t.parsedType}),L}};he.create=n=>new he({typeName:B.ZodNever,...P(n)});var xt=class extends O{_parse(e){if(this._getType(e)!==I.undefined){let r=this._getOrReturnCtx(e);return R(r,{code:b.invalid_type,expected:I.void,received:r.parsedType}),L}return te(e.data)}};xt.create=n=>new xt({typeName:B.ZodVoid,...P(n)});var Ie=class n extends O{_parse(e){let{ctx:t,status:r}=this._processInputParams(e),a=this._def;if(t.parsedType!==I.array)return R(t,{code:b.invalid_type,expected:I.array,received:t.parsedType}),L;if(a.exactLength!==null){let u=t.data.length>a.exactLength.value,p=t.data.length<a.exactLength.value;(u||p)&&(R(t,{code:u?b.too_big:b.too_small,minimum:p?a.exactLength.value:void 0,maximum:u?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),r.dirty())}if(a.minLength!==null&&t.data.length<a.minLength.value&&(R(t,{code:b.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),r.dirty()),a.maxLength!==null&&t.data.length>a.maxLength.value&&(R(t,{code:b.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((u,p)=>a.type._parseAsync(new de(t,u,t.path,p)))).then(u=>X.mergeArray(r,u));let o=[...t.data].map((u,p)=>a.type._parseSync(new de(t,u,t.path,p)));return X.mergeArray(r,o)}get element(){return this._def.type}min(e,t){return new n({...this._def,minLength:{value:e,message:A.toString(t)}})}max(e,t){return new n({...this._def,maxLength:{value:e,message:A.toString(t)}})}length(e,t){return new n({...this._def,exactLength:{value:e,message:A.toString(t)}})}nonempty(e){return this.min(1,e)}};Ie.create=(n,e)=>new Ie({type:n,minLength:null,maxLength:null,exactLength:null,typeName:B.ZodArray,...P(e)});function yt(n){if(n instanceof ue){let e={};for(let t in n.shape){let r=n.shape[t];e[t]=pe.create(yt(r))}return new ue({...n._def,shape:()=>e})}else return n instanceof Ie?new Ie({...n._def,type:yt(n.element)}):n instanceof pe?pe.create(yt(n.unwrap())):n instanceof we?we.create(yt(n.unwrap())):n instanceof ve?ve.create(n.items.map(e=>yt(e))):n}var ue=class n extends O{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=j.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==I.object){let w=this._getOrReturnCtx(e);return R(w,{code:b.invalid_type,expected:I.object,received:w.parsedType}),L}let{status:r,ctx:a}=this._processInputParams(e),{shape:o,keys:u}=this._getCached(),p=[];if(!(this._def.catchall instanceof he&&this._def.unknownKeys==="strip"))for(let w in a.data)u.includes(w)||p.push(w);let g=[];for(let w of u){let E=o[w],F=a.data[w];g.push({key:{status:"valid",value:w},value:E._parse(new de(a,F,a.path,w)),alwaysSet:w in a.data})}if(this._def.catchall instanceof he){let w=this._def.unknownKeys;if(w==="passthrough")for(let E of p)g.push({key:{status:"valid",value:E},value:{status:"valid",value:a.data[E]}});else if(w==="strict")p.length>0&&(R(a,{code:b.unrecognized_keys,keys:p}),r.dirty());else if(w!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let w=this._def.catchall;for(let E of p){let F=a.data[E];g.push({key:{status:"valid",value:E},value:w._parse(new de(a,F,a.path,E)),alwaysSet:E in a.data})}}return a.common.async?Promise.resolve().then(async()=>{let w=[];for(let E of g){let F=await E.key,J=await E.value;w.push({key:F,value:J,alwaysSet:E.alwaysSet})}return w}).then(w=>X.mergeObjectSync(r,w)):X.mergeObjectSync(r,g)}get shape(){return this._def.shape()}strict(e){return A.errToObj,new n({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{let a=this._def.errorMap?.(t,r).message??r.defaultError;return t.code==="unrecognized_keys"?{message:A.errToObj(e).message??a}:{message:a}}}:{}})}strip(){return new n({...this._def,unknownKeys:"strip"})}passthrough(){return new n({...this._def,unknownKeys:"passthrough"})}extend(e){return new n({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new n({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:B.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new n({...this._def,catchall:e})}pick(e){let t={};for(let r of j.objectKeys(e))e[r]&&this.shape[r]&&(t[r]=this.shape[r]);return new n({...this._def,shape:()=>t})}omit(e){let t={};for(let r of j.objectKeys(this.shape))e[r]||(t[r]=this.shape[r]);return new n({...this._def,shape:()=>t})}deepPartial(){return yt(this)}partial(e){let t={};for(let r of j.objectKeys(this.shape)){let a=this.shape[r];e&&!e[r]?t[r]=a:t[r]=a.optional()}return new n({...this._def,shape:()=>t})}required(e){let t={};for(let r of j.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let o=this.shape[r];for(;o instanceof pe;)o=o._def.innerType;t[r]=o}return new n({...this._def,shape:()=>t})}keyof(){return wi(j.objectKeys(this.shape))}};ue.create=(n,e)=>new ue({shape:()=>n,unknownKeys:"strip",catchall:he.create(),typeName:B.ZodObject,...P(e)});ue.strictCreate=(n,e)=>new ue({shape:()=>n,unknownKeys:"strict",catchall:he.create(),typeName:B.ZodObject,...P(e)});ue.lazycreate=(n,e)=>new ue({shape:n,unknownKeys:"strip",catchall:he.create(),typeName:B.ZodObject,...P(e)});var He=class extends O{_parse(e){let{ctx:t}=this._processInputParams(e),r=this._def.options;function a(o){for(let p of o)if(p.result.status==="valid")return p.result;for(let p of o)if(p.result.status==="dirty")return t.common.issues.push(...p.ctx.common.issues),p.result;let u=o.map(p=>new oe(p.ctx.common.issues));return R(t,{code:b.invalid_union,unionErrors:u}),L}if(t.common.async)return Promise.all(r.map(async o=>{let u={...t,common:{...t.common,issues:[]},parent:null};return{result:await o._parseAsync({data:t.data,path:t.path,parent:u}),ctx:u}})).then(a);{let o,u=[];for(let g of r){let w={...t,common:{...t.common,issues:[]},parent:null},E=g._parseSync({data:t.data,path:t.path,parent:w});if(E.status==="valid")return E;E.status==="dirty"&&!o&&(o={result:E,ctx:w}),w.common.issues.length&&u.push(w.common.issues)}if(o)return t.common.issues.push(...o.ctx.common.issues),o.result;let p=u.map(g=>new oe(g));return R(t,{code:b.invalid_union,unionErrors:p}),L}}get options(){return this._def.options}};He.create=(n,e)=>new He({options:n,typeName:B.ZodUnion,...P(e)});var Ne=n=>n instanceof Ye?Ne(n.schema):n instanceof fe?Ne(n.innerType()):n instanceof Ke?[n.value]:n instanceof Qe?n.options:n instanceof Xe?j.objectValues(n.enum):n instanceof et?Ne(n._def.innerType):n instanceof Ze?[void 0]:n instanceof Ge?[null]:n instanceof pe?[void 0,...Ne(n.unwrap())]:n instanceof we?[null,...Ne(n.unwrap())]:n instanceof Ot||n instanceof rt?Ne(n.unwrap()):n instanceof tt?Ne(n._def.innerType):[],Qt=class n extends O{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==I.object)return R(t,{code:b.invalid_type,expected:I.object,received:t.parsedType}),L;let r=this.discriminator,a=t.data[r],o=this.optionsMap.get(a);return o?t.common.async?o._parseAsync({data:t.data,path:t.path,parent:t}):o._parseSync({data:t.data,path:t.path,parent:t}):(R(t,{code:b.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),L)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){let a=new Map;for(let o of t){let u=Ne(o.shape[e]);if(!u.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let p of u){if(a.has(p))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(p)}`);a.set(p,o)}}return new n({typeName:B.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,...P(r)})}};function Nr(n,e){let t=xe(n),r=xe(e);if(n===e)return{valid:!0,data:n};if(t===I.object&&r===I.object){let a=j.objectKeys(e),o=j.objectKeys(n).filter(p=>a.indexOf(p)!==-1),u={...n,...e};for(let p of o){let g=Nr(n[p],e[p]);if(!g.valid)return{valid:!1};u[p]=g.data}return{valid:!0,data:u}}else if(t===I.array&&r===I.array){if(n.length!==e.length)return{valid:!1};let a=[];for(let o=0;o<n.length;o++){let u=n[o],p=e[o],g=Nr(u,p);if(!g.valid)return{valid:!1};a.push(g.data)}return{valid:!0,data:a}}else return t===I.date&&r===I.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}var Je=class extends O{_parse(e){let{status:t,ctx:r}=this._processInputParams(e),a=(o,u)=>{if(Yt(o)||Yt(u))return L;let p=Nr(o.value,u.value);return p.valid?((Kt(o)||Kt(u))&&t.dirty(),{status:t.value,value:p.data}):(R(r,{code:b.invalid_intersection_types}),L)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([o,u])=>a(o,u)):a(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};Je.create=(n,e,t)=>new Je({left:n,right:e,typeName:B.ZodIntersection,...P(t)});var ve=class n extends O{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==I.array)return R(r,{code:b.invalid_type,expected:I.array,received:r.parsedType}),L;if(r.data.length<this._def.items.length)return R(r,{code:b.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),L;!this._def.rest&&r.data.length>this._def.items.length&&(R(r,{code:b.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let o=[...r.data].map((u,p)=>{let g=this._def.items[p]||this._def.rest;return g?g._parse(new de(r,u,r.path,p)):null}).filter(u=>!!u);return r.common.async?Promise.all(o).then(u=>X.mergeArray(t,u)):X.mergeArray(t,o)}get items(){return this._def.items}rest(e){return new n({...this._def,rest:e})}};ve.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ve({items:n,typeName:B.ZodTuple,rest:null,...P(e)})};var Xt=class n extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==I.object)return R(r,{code:b.invalid_type,expected:I.object,received:r.parsedType}),L;let a=[],o=this._def.keyType,u=this._def.valueType;for(let p in r.data)a.push({key:o._parse(new de(r,p,r.path,p)),value:u._parse(new de(r,r.data[p],r.path,p)),alwaysSet:p in r.data});return r.common.async?X.mergeObjectAsync(t,a):X.mergeObjectSync(t,a)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof O?new n({keyType:e,valueType:t,typeName:B.ZodRecord,...P(r)}):new n({keyType:Le.create(),valueType:e,typeName:B.ZodRecord,...P(t)})}},vt=class extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==I.map)return R(r,{code:b.invalid_type,expected:I.map,received:r.parsedType}),L;let a=this._def.keyType,o=this._def.valueType,u=[...r.data.entries()].map(([p,g],w)=>({key:a._parse(new de(r,p,r.path,[w,"key"])),value:o._parse(new de(r,g,r.path,[w,"value"]))}));if(r.common.async){let p=new Map;return Promise.resolve().then(async()=>{for(let g of u){let w=await g.key,E=await g.value;if(w.status==="aborted"||E.status==="aborted")return L;(w.status==="dirty"||E.status==="dirty")&&t.dirty(),p.set(w.value,E.value)}return{status:t.value,value:p}})}else{let p=new Map;for(let g of u){let w=g.key,E=g.value;if(w.status==="aborted"||E.status==="aborted")return L;(w.status==="dirty"||E.status==="dirty")&&t.dirty(),p.set(w.value,E.value)}return{status:t.value,value:p}}}};vt.create=(n,e,t)=>new vt({valueType:e,keyType:n,typeName:B.ZodMap,...P(t)});var wt=class n extends O{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==I.set)return R(r,{code:b.invalid_type,expected:I.set,received:r.parsedType}),L;let a=this._def;a.minSize!==null&&r.data.size<a.minSize.value&&(R(r,{code:b.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),t.dirty()),a.maxSize!==null&&r.data.size>a.maxSize.value&&(R(r,{code:b.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),t.dirty());let o=this._def.valueType;function u(g){let w=new Set;for(let E of g){if(E.status==="aborted")return L;E.status==="dirty"&&t.dirty(),w.add(E.value)}return{status:t.value,value:w}}let p=[...r.data.values()].map((g,w)=>o._parse(new de(r,g,r.path,w)));return r.common.async?Promise.all(p).then(g=>u(g)):u(p)}min(e,t){return new n({...this._def,minSize:{value:e,message:A.toString(t)}})}max(e,t){return new n({...this._def,maxSize:{value:e,message:A.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};wt.create=(n,e)=>new wt({valueType:n,minSize:null,maxSize:null,typeName:B.ZodSet,...P(e)});var er=class n extends O{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==I.function)return R(t,{code:b.invalid_type,expected:I.function,received:t.parsedType}),L;function r(p,g){return Ft({data:p,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,mt(),ke].filter(w=>!!w),issueData:{code:b.invalid_arguments,argumentsError:g}})}function a(p,g){return Ft({data:p,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,mt(),ke].filter(w=>!!w),issueData:{code:b.invalid_return_type,returnTypeError:g}})}let o={errorMap:t.common.contextualErrorMap},u=t.data;if(this._def.returns instanceof Pe){let p=this;return te(async function(...g){let w=new oe([]),E=await p._def.args.parseAsync(g,o).catch(S=>{throw w.addIssue(r(g,S)),w}),F=await Reflect.apply(u,this,E);return await p._def.returns._def.type.parseAsync(F,o).catch(S=>{throw w.addIssue(a(F,S)),w})})}else{let p=this;return te(function(...g){let w=p._def.args.safeParse(g,o);if(!w.success)throw new oe([r(g,w.error)]);let E=Reflect.apply(u,this,w.data),F=p._def.returns.safeParse(E,o);if(!F.success)throw new oe([a(E,F.error)]);return F.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new n({...this._def,args:ve.create(e).rest(Re.create())})}returns(e){return new n({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new n({args:e||ve.create([]).rest(Re.create()),returns:t||Re.create(),typeName:B.ZodFunction,...P(r)})}},Ye=class extends O{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};Ye.create=(n,e)=>new Ye({getter:n,typeName:B.ZodLazy,...P(e)});var Ke=class extends O{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return R(t,{received:t.data,code:b.invalid_literal,expected:this._def.value}),L}return{status:"valid",value:e.data}}get value(){return this._def.value}};Ke.create=(n,e)=>new Ke({value:n,typeName:B.ZodLiteral,...P(e)});function wi(n,e){return new Qe({values:n,typeName:B.ZodEnum,...P(e)})}var Qe=class n extends O{_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),r=this._def.values;return R(t,{expected:j.joinValues(r),received:t.parsedType,code:b.invalid_type}),L}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),r=this._def.values;return R(t,{received:t.data,code:b.invalid_enum_value,options:r}),L}return te(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return n.create(e,{...this._def,...t})}exclude(e,t=this._def){return n.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}};Qe.create=wi;var Xe=class extends O{_parse(e){let t=j.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==I.string&&r.parsedType!==I.number){let a=j.objectValues(t);return R(r,{expected:j.joinValues(a),received:r.parsedType,code:b.invalid_type}),L}if(this._cache||(this._cache=new Set(j.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let a=j.objectValues(t);return R(r,{received:r.data,code:b.invalid_enum_value,options:a}),L}return te(e.data)}get enum(){return this._def.values}};Xe.create=(n,e)=>new Xe({values:n,typeName:B.ZodNativeEnum,...P(e)});var Pe=class extends O{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==I.promise&&t.common.async===!1)return R(t,{code:b.invalid_type,expected:I.promise,received:t.parsedType}),L;let r=t.parsedType===I.promise?t.data:Promise.resolve(t.data);return te(r.then(a=>this._def.type.parseAsync(a,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Pe.create=(n,e)=>new Pe({type:n,typeName:B.ZodPromise,...P(e)});var fe=class extends O{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===B.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:r}=this._processInputParams(e),a=this._def.effect||null,o={addIssue:u=>{R(r,u),u.fatal?t.abort():t.dirty()},get path(){return r.path}};if(o.addIssue=o.addIssue.bind(o),a.type==="preprocess"){let u=a.transform(r.data,o);if(r.common.async)return Promise.resolve(u).then(async p=>{if(t.value==="aborted")return L;let g=await this._def.schema._parseAsync({data:p,path:r.path,parent:r});return g.status==="aborted"?L:g.status==="dirty"?De(g.value):t.value==="dirty"?De(g.value):g});{if(t.value==="aborted")return L;let p=this._def.schema._parseSync({data:u,path:r.path,parent:r});return p.status==="aborted"?L:p.status==="dirty"?De(p.value):t.value==="dirty"?De(p.value):p}}if(a.type==="refinement"){let u=p=>{let g=a.refinement(p,o);if(r.common.async)return Promise.resolve(g);if(g instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return p};if(r.common.async===!1){let p=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return p.status==="aborted"?L:(p.status==="dirty"&&t.dirty(),u(p.value),{status:t.value,value:p.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(p=>p.status==="aborted"?L:(p.status==="dirty"&&t.dirty(),u(p.value).then(()=>({status:t.value,value:p.value}))))}if(a.type==="transform")if(r.common.async===!1){let u=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Ce(u))return L;let p=a.transform(u.value,o);if(p instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:p}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(u=>Ce(u)?Promise.resolve(a.transform(u.value,o)).then(p=>({status:t.value,value:p})):L);j.assertNever(a)}};fe.create=(n,e,t)=>new fe({schema:n,typeName:B.ZodEffects,effect:e,...P(t)});fe.createWithPreprocess=(n,e,t)=>new fe({schema:e,effect:{type:"preprocess",transform:n},typeName:B.ZodEffects,...P(t)});var pe=class extends O{_parse(e){return this._getType(e)===I.undefined?te(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};pe.create=(n,e)=>new pe({innerType:n,typeName:B.ZodOptional,...P(e)});var we=class extends O{_parse(e){return this._getType(e)===I.null?te(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};we.create=(n,e)=>new we({innerType:n,typeName:B.ZodNullable,...P(e)});var et=class extends O{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return t.parsedType===I.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};et.create=(n,e)=>new et({innerType:n,typeName:B.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...P(e)});var tt=class extends O{_parse(e){let{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return ht(a)?a.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new oe(r.common.issues)},input:r.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new oe(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};tt.create=(n,e)=>new tt({innerType:n,typeName:B.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...P(e)});var bt=class extends O{_parse(e){if(this._getType(e)!==I.nan){let r=this._getOrReturnCtx(e);return R(r,{code:b.invalid_type,expected:I.nan,received:r.parsedType}),L}return{status:"valid",value:e.data}}};bt.create=n=>new bt({typeName:B.ZodNaN,...P(n)});var yu=Symbol("zod_brand"),Ot=class extends O{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}},Ut=class n extends O{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let o=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?L:o.status==="dirty"?(t.dirty(),De(o.value)):this._def.out._parseAsync({data:o.value,path:r.path,parent:r})})();{let a=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?L:a.status==="dirty"?(t.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:r.path,parent:r})}}static create(e,t){return new n({in:e,out:t,typeName:B.ZodPipeline})}},rt=class extends O{_parse(e){let t=this._def.innerType._parse(e),r=a=>(Ce(a)&&(a.value=Object.freeze(a.value)),a);return ht(t)?t.then(a=>r(a)):r(t)}unwrap(){return this._def.innerType}};rt.create=(n,e)=>new rt({innerType:n,typeName:B.ZodReadonly,...P(e)});function yi(n,e){let t=typeof n=="function"?n(e):typeof n=="string"?{message:n}:n;return typeof t=="string"?{message:t}:t}function bi(n,e={},t){return n?Be.create().superRefine((r,a)=>{let o=n(r);if(o instanceof Promise)return o.then(u=>{if(!u){let p=yi(e,r),g=p.fatal??t??!0;a.addIssue({code:"custom",...p,fatal:g})}});if(!o){let u=yi(e,r),p=u.fatal??t??!0;a.addIssue({code:"custom",...u,fatal:p})}}):Be.create()}var gu={object:ue.lazycreate},B;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(B||(B={}));var xu=(n,e={message:`Input not instance of ${n.name}`})=>bi(t=>t instanceof n,e),Ti=Le.create,_i=Ve.create,vu=bt.create,wu=qe.create,ki=We.create,bu=ze.create,Tu=gt.create,_u=Ze.create,ku=Ge.create,Nu=Be.create,Ru=Re.create,Iu=he.create,Eu=xt.create,Au=Ie.create,Su=ue.create,Cu=ue.strictCreate,Lu=He.create,Bu=Qt.create,Pu=Je.create,Fu=ve.create,Ou=Xt.create,Uu=vt.create,ju=wt.create,Mu=er.create,$u=Ye.create,Du=Ke.create,Vu=Qe.create,qu=Xe.create,Wu=Pe.create,zu=fe.create,Zu=pe.create,Gu=we.create,Hu=fe.createWithPreprocess,Ju=Ut.create,Yu=()=>Ti().optional(),Ku=()=>_i().optional(),Qu=()=>ki().optional(),Xu={string:(n=>Le.create({...n,coerce:!0})),number:(n=>Ve.create({...n,coerce:!0})),boolean:(n=>We.create({...n,coerce:!0})),bigint:(n=>qe.create({...n,coerce:!0})),date:(n=>ze.create({...n,coerce:!0}))};var el=L;m();y();h();var Ni=D.strictObject({title:D.string(),content:D.string()});var Rr=D.object({"base-api-exception-class-name":D.string().optional(),"base-exception-class-name":D.string().optional(),"client-class-name":D.string().optional(),"inline-file-properties":D.boolean().optional(),"inline-path-parameters":D.boolean().optional(),"package-layout":D.enum(["flat","nested"]).optional(),"package-prefix":D.string().optional(),"use-local-date-for-dates":D.boolean().optional(),"custom-dependencies":D.array(D.string()).optional(),"disable-required-property-builder-checks":D.boolean().optional(),"enable-forward-compatible-enums":D.boolean().optional(),"enable-inline-types":D.boolean().optional(),"enable-public-constructors":D.boolean().optional(),"generate-unknown-as-json-node":D.boolean().optional(),"json-include":D.enum(["non-absent","non-empty"]).optional(),"enable-extensible-builders":D.boolean().optional(),"use-default-request-parameter-values":D.boolean().optional(),"enable-wire-tests":D.boolean().default(!1),"collapse-optional-nullable":D.boolean().optional(),"custom-readme-sections":D.array(Ni).optional(),"custom-pager-name":D.string().optional(),"default-timeout-in-seconds":D.number().optional(),"gradle-distribution-url":D.string().optional(),"gradle-plugin-management":D.string().optional(),"gradle-central-dependency-management":D.boolean().optional(),"wrapped-aliases":D.boolean().optional()});var d={};Dt(d,{Access:()=>Ir,AstNode:()=>Z,Class:()=>nt,ClassInstantiation:()=>at,ClassReference:()=>V,CodeBlock:()=>it,Method:()=>st,MethodInvocation:()=>ot,Parameter:()=>ut,Type:()=>jt,TypeLiteral:()=>le,Writer:()=>$e,classReference:()=>Tl,class_:()=>bl,codeblock:()=>wl,instantiateClass:()=>_l,invokeMethod:()=>kl,method:()=>Nl,parameter:()=>Rl});m();y();h();m();y();h();m();y();h();var Ir={Public:"public",Protected:"protected",Private:"private"};m();y();h();m();y();h();var Z=class extends je{async toStringAsync({packageName:e,customConfig:t,formatter:r}){let a=new Pt({packageName:e,customConfig:t,formatter:r});return this.write(a),a.toStringAsync()}toString({packageName:e,customConfig:t,formatter:r}){let a=new Pt({packageName:e,customConfig:t,formatter:r});return this.write(a),a.toString()}};var nt=class extends Z{constructor({name:t,access:r}){super();_(this,"name");_(this,"access");_(this,"methods",[]);this.name=t,this.access=r}write(t){if(t.write(`${this.access} class ${this.name}`),this.isEmpty()){t.writeLine(" {}");return}t.writeLine(" {"),t.indent();for(let r of this.methods)t.writeNode(r),t.newLine();t.dedent(),t.write("}")}addMethod(t){this.methods.push(t)}isEmpty(){return this.methods.length===0}};m();y();h();m();y();h();m();y();h();m();y();h();var V=class extends Z{constructor({name:t,packageName:r,fullyQualified:a}){super();_(this,"name");_(this,"packageName");_(this,"fullyQualified");this.name=t,this.packageName=r,this.fullyQualified=a??!1}write(t){if(t.addImport(`${this.packageName}.${this.name}`),this.fullyQualified){t.write(`${this.packageName}.${this.name}`);return}t.write(this.name)}};m();y();h();var jt=class extends Z{constructor(t){super();_(this,"internalType");this.internalType=t}write(t){switch(this.internalType.type){case"array":t.writeNode(this.internalType.value),t.write("[]");break;case"bigInteger":t.writeNode(tl);break;case"boolean":t.write("Boolean");break;case"bytes":t.write("byte[]");break;case"date":t.write("String");break;case"dateTime":t.writeNode(al);break;case"double":t.write("Double");break;case"float":t.write("Float");break;case"generic":t.writeNode(this.internalType.value),t.write("<");for(let[r,a]of this.internalType.parameters.entries())t.writeNode(a),r<this.internalType.parameters.length-1&&t.write(", ");t.write(">");break;case"inputStream":t.writeNode(ol);break;case"integer":t.write("Integer");break;case"iterable":this.writeIterable({writer:t,iterable:this.internalType});break;case"list":{this.writeList({writer:t,list:this.internalType});break}case"long":{t.write("Long");break}case"map":{this.writeMap({writer:t,map:this.internalType});break}case"object":{t.write("Object");break}case"optional":{this.writeOptional({writer:t,optional:this.internalType});break}case"reference":t.writeNode(this.internalType.value);break;case"set":{this.writeSet({writer:t,set:this.internalType});break}case"string":t.write("String");break;case"uuid":t.writeNode(sl);break;case"void":t.write("Void");break;default:M(this.internalType)}}isOptional(){return this.internalType.type==="optional"}static array(t){return new this({type:"array",value:t})}static bigInteger(){return new this({type:"bigInteger"})}static boolean(){return new this({type:"boolean"})}static bytes(){return new this({type:"bytes"})}static date(){return new this({type:"date"})}static dateTime(){return new this({type:"dateTime"})}static double(){return new this({type:"double"})}static float(){return new this({type:"float"})}static integer(){return new this({type:"integer"})}static list(t){return new this({type:"list",value:t})}static long(){return new this({type:"long"})}static map(t,r){return new this({type:"map",keyType:t,valueType:r})}static object(){return new this({type:"object"})}static optional(t){return this.isAlreadyOptional(t)?t:new this({type:"optional",value:t})}static reference(t){return new this({type:"reference",value:t})}static generic(t,r){return new this({type:"generic",value:t,parameters:r})}static set(t){return new this({type:"set",value:t})}static string(){return new this({type:"string"})}static uuid(){return new this({type:"uuid"})}static void(){return new this({type:"void"})}static iterable(t){return new this({type:"iterable",value:t})}static inputStream(){return new this({type:"inputStream"})}writeList({writer:t,list:r}){t.writeNode(rl),t.write("<"),r.value.write(t),t.write(">")}writeMap({writer:t,map:r}){t.writeNode(nl),t.write("<"),r.keyType.write(t),t.write(", "),r.valueType.write(t),t.write(">")}writeOptional({writer:t,optional:r}){t.writeNode(Er),t.write("<"),r.value.write(t),t.write(">")}writeIterable({writer:t,iterable:r}){t.writeNode(ul),t.write("<"),r.value.write(t),t.write(">")}writeSet({writer:t,set:r}){t.writeNode(il),t.write("<"),r.value.write(t),t.write(">")}static isAlreadyOptional(t){return t.internalType.type==="optional"}},tr=new V({name:"Arrays",packageName:"java.util"}),tl=new V({name:"BigInteger",packageName:"java.math"}),mg=new V({name:"HashMap",packageName:"java.util"}),rl=new V({name:"List",packageName:"java.util"}),nl=new V({name:"Map",packageName:"java.util"}),al=new V({name:"OffsetDateTime",packageName:"java.time"}),Er=new V({name:"Optional",packageName:"java.util"}),il=new V({name:"Set",packageName:"java.util"}),sl=new V({name:"UUID",packageName:"java.util"}),ol=new V({name:"InputStream",packageName:"java.io"}),ul=new V({name:"Iterable",packageName:"java.lang"});var le=class n extends Z{constructor(t){super();_(this,"internalType");this.internalType=t}write(t){switch(this.internalType.type){case"bigInteger":this.writeBigInteger({writer:t,bigInteger:this.internalType});break;case"boolean":t.write(this.internalType.value.toString());break;case"builder":this.writeBuilder({writer:t,builder:this.internalType});break;case"bytes":t.write(`"${this.internalType.value}".getBytes()`);break;case"class":{this.writeClass({writer:t,class_:this.internalType});break}case"date":this.writeDate({writer:t,date:this.internalType});break;case"dateTime":this.writeDateTime({writer:t,dateTime:this.internalType});break;case"double":{let r=this.internalType.value.toString();!r.includes(".")&&!r.includes("e")&&!r.includes("E")?t.write(`${r}.0`):t.write(r);break}case"enum":this.writeEnum({writer:t,enum_:this.internalType});break;case"float":t.write(`${this.internalType.value}f`);break;case"integer":t.write(Math.floor(this.internalType.value).toString());break;case"list":{this.writeList({writer:t,list:this.internalType});break}case"long":{t.write(`${Math.floor(this.internalType.value)}L`);break}case"map":{this.writeMap({writer:t,map:this.internalType});break}case"optional":{this.writeOptional({writer:t,optional:this.internalType});break}case"raw":{this.internalType.value instanceof Z?t.writeNode(this.internalType.value):t.write(this.internalType.value);break}case"reference":t.writeNode(this.internalType.value);break;case"set":{this.writeSet({writer:t,set:this.internalType});break}case"string":t.write(`"${this.escapeString(this.internalType.value)}"`);break;case"unknown":this.writeUnknown({writer:t,value:this.internalType.value});break;case"uuid":this.writeUUID({writer:t,uuid:this.internalType});break;case"nop":break;default:M(this.internalType)}}isOptional(){return this.internalType.type==="optional"}static bigInteger(t){return new this({type:"bigInteger",value:t})}static boolean(t){return new this({type:"boolean",value:t})}static builder({classReference:t,parameters:r}){return new this({type:"builder",classReference:t,parameters:r})}static bytes(t){return new this({type:"bytes",value:t})}static class_({reference:t,parameters:r}){return new this({type:"class",reference:t,parameters:r})}static date(t){return new this({type:"date",value:t})}static dateTime(t){return new this({type:"dateTime",value:t})}static double(t){return new this({type:"double",value:t})}static enum_({classReference:t,value:r}){return new this({type:"enum",classReference:t,value:r})}static float(t){return new this({type:"float",value:t})}static integer(t){return new this({type:"integer",value:t})}static list({valueType:t,values:r,isParameter:a}){return new this({type:"list",valueType:t,values:r,isParameter:a})}static long(t){return new this({type:"long",value:t})}static map({keyType:t,valueType:r,entries:a}){return new this({type:"map",keyType:t,valueType:r,entries:a})}static optional({value:t,useOf:r}){return this.isAlreadyOptional(t)?t:new this({type:"optional",value:t,useOf:r})}static raw(t){return new this({type:"raw",value:t})}static reference(t){return new this({type:"reference",value:t})}static set({valueType:t,values:r}){return new this({type:"set",valueType:t,values:r})}static string(t){return new this({type:"string",value:t})}static unknown(t){return new this({type:"unknown",value:t})}static uuid(t){return new this({type:"uuid",value:t})}static nop(){return new this({type:"nop"})}static isNop(t){return t.internalType.type==="nop"}shouldWriteInLine(){switch(this.internalType.type){case"bigInteger":case"boolean":case"bytes":case"date":case"dateTime":case"double":case"enum":case"float":case"integer":case"long":case"nop":case"raw":case"string":case"unknown":case"uuid":return!0;case"optional":return this.internalType.value.shouldWriteInLine();case"builder":case"class":case"list":case"map":case"reference":case"set":return!1;default:M(this.internalType)}}writeBigInteger({writer:t,bigInteger:r}){t.write("new "),t.writeNode(d.instantiateClass({classReference:ll,arguments_:[n.string(r.value)]}))}writeBuilder({writer:t,builder:r}){t.writeNode(r.classReference),t.writeNewLineIfLastLineNot(),t.indent(),this.writeBuilderParameters({writer:t,parameters:this.orderBuilderParameters(hl({parameters:r.parameters}))}),t.dedent()}writeBuilderParameters({writer:t,parameters:r}){t.writeLine(".builder()");for(let a of r)t.write(`.${a.name}(`),a.value.shouldWriteInLine()||t.newLine(),t.indent(),t.writeNode(a.value),t.dedent(),a.value.shouldWriteInLine()||t.newLine(),t.writeLine(")");t.writeNewLineIfLastLineNot(),t.write(".build()")}orderBuilderParameters(t){return t.some(a=>!a.value.isOptional()&&!this.isCollection(a.value))?t.sort((a,o)=>{let u=this.isNonRequired(a.value),p=this.isNonRequired(o.value);return u&&!p?1:!u&&p?-1:0}):t.sort((a,o)=>{let u=a.value.isOptional(),p=o.value.isOptional();return u&&!p?1:!u&&p?-1:0})}isCollection(t){let r=t.internalType.type;return r==="list"||r==="set"||r==="map"}isNonRequired(t){return t.isOptional()||this.isCollection(t)}writeClass({writer:t,class_:r}){let a=ml({parameters:r.parameters});t.writeNode(d.instantiateClass({classReference:r.reference,arguments_:a.map(o=>o.value)}))}writeDate({writer:t,date:r}){t.writeNode(d.invokeMethod({on:pl,method:"parse",arguments_:[n.string(r.value)]}))}writeDateTime({writer:t,dateTime:r}){t.writeNode(d.invokeMethod({on:dl,method:"parse",arguments_:[n.string(r.value)]}))}writeEnum({writer:t,enum_:r}){t.writeNode(r.classReference),t.write("."+r.value)}writeList({writer:t,list:r}){this.writeIterable({writer:t,iterable:r})}writeMap({writer:t,map:r}){let a=yl({entries:r.entries});if(a.length===0){t.write("new "),t.writeNode(rr),t.write("<"),t.writeNode(r.keyType),t.write(", "),t.writeNode(r.valueType),t.write(">()");return}t.write("new "),t.writeNode(rr),t.write("<"),t.writeNode(r.keyType),t.write(", "),t.writeNode(r.valueType),t.writeLine(">() {{"),t.indent();for(let o of a)t.write("put("),t.writeNode(o.key),t.write(", "),t.writeNode(o.value),t.writeLine(");");t.dedent(),t.write("}}")}writeOptional({writer:t,optional:r}){if(!r.useOf){t.writeNode(r.value);return}t.writeNode(d.invokeMethod({on:Er,method:"of",arguments_:[r.value]}))}writeSet({writer:t,set:r}){this.writeIterable({writer:t,iterable:r})}writeIterable({writer:t,iterable:r}){let a=r.type==="list"?Ar:cl,o=gl({values:r.values});if(r.type==="list"&&r.isParameter&&o.length>0){t.writeNode(d.invokeMethod({on:tr,method:"asList",arguments_:o}));return}if(o.length===0){t.write("new "),t.writeNode(a),t.write("<"),t.writeNode(r.valueType),t.write(">()");return}t.write("new "),t.writeNode(a),t.write("<"),t.writeNode(r.valueType),t.writeLine(">("),t.indent(),t.writeNode(d.invokeMethod({on:tr,method:"asList",arguments_:o})),t.writeNewLineIfLastLineNot(),t.dedent(),t.write(")")}writeUnknown({writer:t,value:r}){switch(typeof r){case"boolean":t.write(r.toString());return;case"string":t.write(`"${this.escapeString(r)}"`);return;case"number":t.write(r.toString());return;case"object":if(r==null){t.write("null");return}if(Array.isArray(r)){this.writeUnknownArray({writer:t,value:r});return}this.writeUnknownMap({writer:t,value:r});return;default:throw new Error(`Internal error; unsupported unknown type: ${typeof r}`)}}writeUnknownArray({writer:t,value:r}){if(r.length===0){t.write("new "),t.writeNode(Ar),t.write("<Object>()");return}t.write("new "),t.writeNode(Ar),t.write("<Object>("),t.writeNode(d.invokeMethod({on:tr,method:"asList",arguments_:r.map(a=>n.unknown(a))})),t.write(")")}writeUnknownMap({writer:t,value:r}){let a=Object.entries(r);if(a.length===0){t.write("new "),t.writeNode(rr),t.write("<String, Object>()");return}t.writeLine("new "),t.writeNode(rr),t.write("<String, Object>() {{"),t.indent();for(let[o,u]of a)t.write(`put("${o}", `),t.writeNode(n.unknown(u)),t.writeLine(");");t.dedent(),t.write("}}")}writeUUID({writer:t,uuid:r}){t.writeNode(d.invokeMethod({on:fl,method:"fromString",arguments_:[n.string(r.value)]}))}escapeString(t){return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}static isAlreadyOptional(t){return t.internalType.type==="optional"}},Ar=new V({name:"ArrayList",packageName:"java.util"}),ll=new V({name:"BigInteger",packageName:"java.math"}),rr=new V({name:"HashMap",packageName:"java.util"}),cl=new V({name:"HashSet",packageName:"java.util"}),Ng=new V({name:"List",packageName:"java.util"}),pl=new V({name:"LocalDate",packageName:"java.time"}),Rg=new V({name:"Map",packageName:"java.util"}),dl=new V({name:"OffsetDateTime",packageName:"java.time"}),Ig=new V({name:"Set",packageName:"java.util"}),fl=new V({name:"UUID",packageName:"java.util"});function ml({parameters:n}){return n.filter(e=>!le.isNop(e.value))}function hl({parameters:n}){return n.filter(e=>!le.isNop(e.value))}function yl({entries:n}){return n.filter(e=>!le.isNop(e.key)&&!le.isNop(e.value))}function gl({values:n}){return n.filter(e=>!le.isNop(e))}function nr({writer:n,arguments_:e}){let t=vl(e);if(t.length===0){n.write("()");return}if(t.some(a=>a instanceof le&&!a.shouldWriteInLine())){xl({writer:n,arguments_:t});return}n.write("("),t.forEach((a,o)=>{o>0&&n.write(", "),Ri({writer:n,argument:a})}),n.write(")")}function xl({writer:n,arguments_:e}){n.writeLine("("),n.indent(),e.forEach((t,r)=>{r>0&&n.writeLine(","),Ri({writer:n,argument:t})}),n.dedent(),e.length>0&&n.newLine(),n.write(")")}function Ri({writer:n,argument:e}){Tr(e)?n.writeNodeOrString(e.assignment):e.write(n)}function vl(n){return n.filter(e=>!(e instanceof le&&le.isNop(e)))}var at=class extends Z{constructor({classReference:t,arguments_:r}){super();_(this,"classReference");_(this,"arguments_");this.classReference=t,this.arguments_=r}write(t){t.writeNode(this.classReference),nr({writer:t,arguments_:this.arguments_})}};m();y();h();var it=class extends Z{constructor(t){super();_(this,"arg");this.arg=t}write(t){return new me(this.arg).write(t)}};m();y();h();var st=class extends Z{constructor({name:t,access:r,parameters:a,body:o,static_:u,return_:p}){super();_(this,"name");_(this,"access");_(this,"parameters");_(this,"body");_(this,"return_");_(this,"static_");this.name=t,this.access=r,this.parameters=a,this.body=o,this.return_=p,this.static_=u??!1}write(t){if(t.write(`${this.access} `),this.static_&&t.write("static "),this.return_!=null?t.writeNode(this.return_):t.write("void"),t.write(` ${this.name}`),this.parameters.length===0)t.write("()");else if(this.parameters.length===1){if(t.write("("),this.parameters[0]==null)throw new Error("Cannot render parameter "+this.parameters[0]);t.writeNode(this.parameters[0]),t.write(")")}else t.writeLine("("),t.indent(),this.parameters.forEach((r,a)=>{a>0&&t.writeLine(", "),t.writeNode(r)}),t.dedent(),t.write(")");if(this.body==null){t.write(";");return}t.writeLine(" {"),t.indent(),t.writeNode(this.body),t.writeNewLineIfLastLineNot(),t.dedent(),t.write("}")}};m();y();h();var ot=class extends Z{constructor({method:t,arguments_:r,on:a}){super();_(this,"on");_(this,"method");_(this,"arguments_");this.on=a,this.method=t,this.arguments_=r}write(t){this.on.write(t),t.write("."),t.write(this.method),nr({writer:t,arguments_:this.arguments_})}};m();y();h();var ut=class extends Z{constructor({name:t,type:r}){super();_(this,"name");_(this,"type");this.name=t,this.type=r}write(t){t.writeNode(this.type),t.write(` ${this.name}`)}};function wl(n){return new it(n)}function bl(n){return new nt(n)}function Tl(n){return new V(n)}function _l(n){return new at(n)}function kl(n){return new ot(n)}function Nl(n){return new st(n)}function Rl(n){return new ut(n)}m();y();h();var ar=class{constructor({context:e}){_(this,"context");this.context=e}isNopTypeLiteral(e){return e.internalType?.type==="nop"}usesOptionalNullable(){return this.context.customConfig?.["collapse-optional-nullable"]===!0}wrapInOptionalIfNotNop(e,t=!1){return this.isNopTypeLiteral(e)?e:this.usesOptionalNullable()?this.context.getOptionalNullableOf(e):d.TypeLiteral.optional({value:e,useOf:t})}convert(e){if(e.value===null)return this.context.isNullable(e.typeReference)?this.context.getNullableOfNull():(this.context.errors.add({severity:$.Critical,message:"Expected non-null value, but got null"}),d.TypeLiteral.nop());if(e.value===void 0)return d.TypeLiteral.nop();switch(e.typeReference.type){case"list":return this.convertList({list:e.typeReference.value,value:e.value,as:e.as});case"literal":return this.convertLiteral({literal:e.typeReference.value,value:e.value});case"map":return this.convertMap({map:e.typeReference,value:e.value,as:e.as});case"named":{let t=this.context.resolveNamedType({typeId:e.typeReference.value});return t==null?d.TypeLiteral.nop():this.convertNamed({named:t,value:e.value,as:e.as,inUndiscriminatedUnion:e.inUndiscriminatedUnion})}case"nullable":case"optional":{if(e.value===void 0||typeof e.value=="object"&&e.value!==null&&Object.keys(e.value).length===0&&e.typeReference.value.type==="named")return this.usesOptionalNullable()?this.context.getOptionalNullableAbsent():d.TypeLiteral.reference(d.invokeMethod({on:d.classReference({name:"Optional",packageName:"java.util"}),method:"empty",arguments_:[]}));if(e.typeReference.value.type==="list"){let a=this.convertList({list:e.typeReference.value.value,value:e.value});return this.wrapInOptionalIfNotNop(a,!0)}if(this.usesOptionalNullable()&&(e.typeReference.value.type==="optional"||e.typeReference.value.type==="nullable"))return this.convert({typeReference:e.typeReference.value,value:e.value,as:e.as,inUndiscriminatedUnion:e.inUndiscriminatedUnion});let t=this.convert({typeReference:e.typeReference.value,value:e.value,as:e.as,inUndiscriminatedUnion:e.inUndiscriminatedUnion}),r=e.as==="mapValue"||e.inUndiscriminatedUnion===!0;return this.wrapInOptionalIfNotNop(t,r)}case"primitive":return this.convertPrimitive({primitive:e.typeReference.value,value:e.value,as:e.as});case"set":return this.convertSet({set:e.typeReference.value,value:e.value,as:e.as});case"unknown":return this.convertUnknown({value:e.value});default:M(e.typeReference)}}convertList({list:e,value:t,as:r}){if(!Array.isArray(t))return this.context.errors.add({severity:$.Critical,message:`Expected array but got: ${typeof t}`}),d.TypeLiteral.nop();let a=e.type==="optional"||e.type==="nullable";return d.TypeLiteral.list({valueType:this.context.dynamicTypeMapper.convert({typeReference:e}),values:t.map((o,u)=>{this.context.errors.scope({index:u});try{if(a){let p=this.convert({typeReference:e.value,value:o,as:r});return this.wrapInOptionalIfNotNop(p,!0)}return this.convert({typeReference:e,value:o,as:r})}finally{this.context.errors.unscope()}}),isParameter:!0})}convertLiteral({literal:e,value:t}){switch(e.type){case"boolean":{let r=this.context.getValueAsBoolean({value:t});return r==null?d.TypeLiteral.nop():d.TypeLiteral.boolean(r)}case"string":{let r=this.context.getValueAsString({value:t});return r==null?d.TypeLiteral.nop():d.TypeLiteral.string(r)}default:M(e)}}convertSet({set:e,value:t,as:r}){return Array.isArray(t)?d.TypeLiteral.set({valueType:this.context.dynamicTypeMapper.convert({typeReference:e}),values:t.map((a,o)=>{this.context.errors.scope({index:o});try{return this.convert({typeReference:e,value:a,as:r})}finally{this.context.errors.unscope()}})}):(this.context.errors.add({severity:$.Critical,message:`Expected array but got: ${typeof t}`}),d.TypeLiteral.nop())}convertMap({map:e,value:t,as:r}){return typeof t!="object"||t==null?(this.context.errors.add({severity:$.Critical,message:`Expected object but got: ${t==null?"null":typeof t}`}),d.TypeLiteral.nop()):d.TypeLiteral.map({keyType:this.context.dynamicTypeMapper.convert({typeReference:e.key}),valueType:this.context.dynamicTypeMapper.convert({typeReference:e.value}),entries:Object.entries(t).map(([a,o])=>{this.context.errors.scope(a);try{return{key:this.convert({typeReference:e.key,value:a,as:"mapKey"}),value:this.convert({typeReference:e.value,value:o,as:"mapValue"})}}finally{this.context.errors.unscope()}})})}convertNamed({named:e,value:t,as:r,inUndiscriminatedUnion:a}){switch(e.type){case"alias":return this.convert({typeReference:e.typeReference,value:t,as:r,inUndiscriminatedUnion:a});case"discriminatedUnion":return this.convertDiscriminatedUnion({discriminatedUnion:e,value:t});case"enum":return this.convertEnum({enum_:e,value:t});case"object":return this.convertObject({object_:e,value:t,as:r});case"undiscriminatedUnion":return this.convertUndiscriminatedUnion({undiscriminatedUnion:e,value:t});default:M(e)}}convertDiscriminatedUnion({discriminatedUnion:e,value:t}){let r=this.context.getJavaClassReferenceFromDeclaration({declaration:e.declaration}),a=this.context.resolveDiscriminatedUnionTypeInstance({discriminatedUnion:e,value:t});if(a==null)return d.TypeLiteral.nop();let o=a.singleDiscriminatedUnionType;switch(o.type){case"samePropertiesAsObject":{let u=this.context.resolveNamedType({typeId:o.typeId});return u==null?d.TypeLiteral.nop():d.TypeLiteral.reference(d.invokeMethod({on:r,method:this.context.getPropertyName(o.discriminantValue.name),arguments_:[this.convertNamed({named:u,value:a.value})]}))}case"singleProperty":{let u=this.context.getRecord(a.value);if(u==null)return d.TypeLiteral.nop();try{return this.context.errors.scope(o.discriminantValue.wireValue),d.TypeLiteral.reference(d.invokeMethod({on:r,method:this.context.getPropertyName(o.discriminantValue.name),arguments_:[this.convert({typeReference:o.typeReference,value:u["value"]})]}))}finally{this.context.errors.unscope()}}case"noProperties":return d.TypeLiteral.reference(d.invokeMethod({on:r,method:this.context.getPropertyName(o.discriminantValue.name),arguments_:[]}));default:M(o)}}convertObject({object_:e,value:t,as:r}){let a=this.context.associateByWireValue({parameters:e.properties,values:this.context.getRecord(t)??{}}),o=r==="request"?a.filter(u=>!this.context.isDirectLiteral(u.typeReference)):a;return d.TypeLiteral.builder({classReference:this.context.getJavaClassReferenceFromDeclaration({declaration:e.declaration}),parameters:o.map(u=>{this.context.errors.scope(u.name.wireValue);try{return{name:this.context.getMethodName(u.name.name),value:this.convert({typeReference:u.typeReference,value:u.value,as:r})}}finally{this.context.errors.unscope()}})})}convertEnum({enum_:e,value:t}){let r=this.getEnumValueName({enum_:e,value:t});return r==null?d.TypeLiteral.nop():d.TypeLiteral.enum_({classReference:this.context.getJavaClassReferenceFromDeclaration({declaration:e.declaration}),value:r})}getEnumValueName({enum_:e,value:t}){if(typeof t!="string"){this.context.errors.add({severity:$.Critical,message:`Expected enum value string, got: ${typeof t}`});return}let r=e.values.find(a=>a.wireValue===t);if(r==null){this.context.errors.add({severity:$.Critical,message:`An enum value named "${t}" does not exist in this context`});return}return this.context.getEnumName(r.name)}convertUndiscriminatedUnion({undiscriminatedUnion:e,value:t}){let r=this.findMatchingUndiscriminatedUnionType({undiscriminatedUnion:e,value:t});return r==null?d.TypeLiteral.nop():this.context.isPrimitive(r.valueTypeReference)?d.TypeLiteral.reference(d.invokeMethod({on:this.context.getJavaClassReferenceFromDeclaration({declaration:e.declaration}),method:"of",arguments_:[r.typeInstantiation]})):d.TypeLiteral.reference(d.invokeMethod({on:this.context.getJavaClassReferenceFromDeclaration({declaration:e.declaration}),method:"of",arguments_:[r.typeInstantiation]}))}findMatchingUndiscriminatedUnionType({undiscriminatedUnion:e,value:t}){let r=[],a=[];for(let p of e.types)try{r.push(JSON.stringify(p));let g=this.convert({typeReference:p,value:t,inUndiscriminatedUnion:!0});return{valueTypeReference:p,typeInstantiation:g}}catch(g){a.push(`Type ${JSON.stringify(p)}: ${g instanceof Error?g.message:String(g)}`);continue}this.context.errors.add({severity:$.Critical,message:`None of the types in the undiscriminated union matched the given "${typeof t}" value. Tried ${r.length} variants. Errors: ${a.join("; ")}`});let o=e.declaration.name??"UnknownUnion",u=a.map((p,g)=>` ${g+1}. ${p}`).join(`
|
|
22
|
+
`)}};m();y();h();m();y();h();var $={};Dt($,{BRAND:()=>yu,DIRTY:()=>De,EMPTY_PATH:()=>Ho,INVALID:()=>L,NEVER:()=>el,OK:()=>te,ParseStatus:()=>X,Schema:()=>O,ZodAny:()=>Be,ZodArray:()=>Ie,ZodBigInt:()=>qe,ZodBoolean:()=>We,ZodBranded:()=>Ot,ZodCatch:()=>tt,ZodDate:()=>ze,ZodDefault:()=>et,ZodDiscriminatedUnion:()=>Qt,ZodEffects:()=>fe,ZodEnum:()=>Qe,ZodError:()=>oe,ZodFirstPartyTypeKind:()=>B,ZodFunction:()=>er,ZodIntersection:()=>Je,ZodIssueCode:()=>b,ZodLazy:()=>Ye,ZodLiteral:()=>Ke,ZodMap:()=>vt,ZodNaN:()=>bt,ZodNativeEnum:()=>Xe,ZodNever:()=>he,ZodNull:()=>Ge,ZodNullable:()=>we,ZodNumber:()=>Ve,ZodObject:()=>ue,ZodOptional:()=>pe,ZodParsedType:()=>I,ZodPipeline:()=>Ut,ZodPromise:()=>Pe,ZodReadonly:()=>rt,ZodRecord:()=>Xt,ZodSchema:()=>O,ZodSet:()=>wt,ZodString:()=>Le,ZodSymbol:()=>gt,ZodTransformer:()=>fe,ZodTuple:()=>ve,ZodType:()=>O,ZodUndefined:()=>Ze,ZodUnion:()=>He,ZodUnknown:()=>Re,ZodVoid:()=>xt,addIssueToContext:()=>R,any:()=>Nu,array:()=>Au,bigint:()=>wu,boolean:()=>ki,coerce:()=>Xu,custom:()=>bi,date:()=>bu,datetimeRegex:()=>vi,defaultErrorMap:()=>ke,discriminatedUnion:()=>Bu,effect:()=>zu,enum:()=>Vu,function:()=>Mu,getErrorMap:()=>mt,getParsedType:()=>xe,instanceof:()=>xu,intersection:()=>Pu,isAborted:()=>Yt,isAsync:()=>ht,isDirty:()=>Kt,isValid:()=>Ce,late:()=>gu,lazy:()=>$u,literal:()=>Du,makeIssue:()=>Ft,map:()=>Uu,nan:()=>vu,nativeEnum:()=>qu,never:()=>Iu,null:()=>ku,nullable:()=>Gu,number:()=>_i,object:()=>Su,objectUtil:()=>_r,oboolean:()=>Qu,onumber:()=>Ku,optional:()=>Zu,ostring:()=>Yu,pipeline:()=>Ju,preprocess:()=>Hu,promise:()=>Wu,quotelessJson:()=>zo,record:()=>Ou,set:()=>ju,setErrorMap:()=>Go,strictObject:()=>Cu,string:()=>Ti,symbol:()=>Tu,transformer:()=>zu,tuple:()=>Fu,undefined:()=>_u,union:()=>Lu,unknown:()=>Ru,util:()=>j,void:()=>Eu});m();y();h();m();y();h();m();y();h();m();y();h();m();y();h();var j;(function(n){n.assertEqual=a=>{};function e(a){}n.assertIs=e;function t(a){throw new Error}n.assertNever=t,n.arrayToEnum=a=>{let o={};for(let u of a)o[u]=u;return o},n.getValidEnumValues=a=>{let o=n.objectKeys(a).filter(p=>typeof a[a[p]]!="number"),u={};for(let p of o)u[p]=a[p];return n.objectValues(u)},n.objectValues=a=>n.objectKeys(a).map(function(o){return a[o]}),n.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{let o=[];for(let u in a)Object.prototype.hasOwnProperty.call(a,u)&&o.push(u);return o},n.find=(a,o)=>{for(let u of a)if(o(u))return u},n.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function r(a,o=" | "){return a.map(u=>typeof u=="string"?`'${u}'`:u).join(o)}n.joinValues=r,n.jsonStringifyReplacer=(a,o)=>typeof o=="bigint"?o.toString():o})(j||(j={}));var _r;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(_r||(_r={}));var I=j.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),xe=n=>{switch(typeof n){case"undefined":return I.undefined;case"string":return I.string;case"number":return Number.isNaN(n)?I.nan:I.number;case"boolean":return I.boolean;case"function":return I.function;case"bigint":return I.bigint;case"symbol":return I.symbol;case"object":return Array.isArray(n)?I.array:n===null?I.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?I.promise:typeof Map<"u"&&n instanceof Map?I.map:typeof Set<"u"&&n instanceof Set?I.set:typeof Date<"u"&&n instanceof Date?I.date:I.object;default:return I.unknown}};var b=j.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"]),zo=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:"),oe=class n extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(o){return o.message},r={_errors:[]},a=o=>{for(let u of o.issues)if(u.code==="invalid_union")u.unionErrors.map(a);else if(u.code==="invalid_return_type")a(u.returnTypeError);else if(u.code==="invalid_arguments")a(u.argumentsError);else if(u.path.length===0)r._errors.push(t(u));else{let p=r,g=0;for(;g<u.path.length;){let w=u.path[g];g===u.path.length-1?(p[w]=p[w]||{_errors:[]},p[w]._errors.push(t(u))):p[w]=p[w]||{_errors:[]},p=p[w],g++}}};return a(this),r}static assert(e){if(!(e instanceof n))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,j.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},r=[];for(let a of this.issues)if(a.path.length>0){let o=a.path[0];t[o]=t[o]||[],t[o].push(e(a))}else r.push(e(a));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}};oe.create=n=>new oe(n);var Zo=(n,e)=>{let t;switch(n.code){case b.invalid_type:n.received===I.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case b.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,j.jsonStringifyReplacer)}`;break;case b.unrecognized_keys:t=`Unrecognized key(s) in object: ${j.joinValues(n.keys,", ")}`;break;case b.invalid_union:t="Invalid input";break;case b.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${j.joinValues(n.options)}`;break;case b.invalid_enum_value:t=`Invalid enum value. Expected ${j.joinValues(n.options)}, received '${n.received}'`;break;case b.invalid_arguments:t="Invalid function arguments";break;case b.invalid_return_type:t="Invalid function return type";break;case b.invalid_date:t="Invalid date";break;case b.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:j.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case b.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="bigint"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case b.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case b.custom:t="Invalid input";break;case b.invalid_intersection_types:t="Intersection results could not be merged";break;case b.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case b.not_finite:t="Number must be finite";break;default:t=e.defaultError,j.assertNever(n)}return{message:t}},ke=Zo;var mi=ke;function Go(n){mi=n}function mt(){return mi}m();y();h();var Ft=n=>{let{data:e,path:t,errorMaps:r,issueData:a}=n,o=[...t,...a.path||[]],u={...a,path:o};if(a.message!==void 0)return{...a,path:o,message:a.message};let p="",g=r.filter(w=>!!w).slice().reverse();for(let w of g)p=w(u,{data:e,defaultError:p}).message;return{...a,path:o,message:p}},Ho=[];function R(n,e){let t=mt(),r=Ft({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===ke?void 0:ke].filter(a=>!!a)});n.common.issues.push(r)}var X=class n{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let r=[];for(let a of t){if(a.status==="aborted")return L;a.status==="dirty"&&e.dirty(),r.push(a.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){let r=[];for(let a of t){let o=await a.key,u=await a.value;r.push({key:o,value:u})}return n.mergeObjectSync(e,r)}static mergeObjectSync(e,t){let r={};for(let a of t){let{key:o,value:u}=a;if(o.status==="aborted"||u.status==="aborted")return L;o.status==="dirty"&&e.dirty(),u.status==="dirty"&&e.dirty(),o.value!=="__proto__"&&(typeof u.value<"u"||a.alwaysSet)&&(r[o.value]=u.value)}return{status:e.value,value:r}}},L=Object.freeze({status:"aborted"}),De=n=>({status:"dirty",value:n}),te=n=>({status:"valid",value:n}),Yt=n=>n.status==="aborted",Kt=n=>n.status==="dirty",Ce=n=>n.status==="valid",ht=n=>typeof Promise<"u"&&n instanceof Promise;m();y();h();m();y();h();var A;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e?.message})(A||(A={}));var de=class{constructor(e,t,r,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=a}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}},hi=(n,e)=>{if(Ce(e))return{success:!0,data:e.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new oe(n.common.issues);return this._error=t,this._error}}};function P(n){if(!n)return{};let{errorMap:e,invalid_type_error:t,required_error:r,description:a}=n;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:a}:{errorMap:(u,p)=>{let{message:g}=n;return u.code==="invalid_enum_value"?{message:g??p.defaultError}:typeof p.data>"u"?{message:g??r??p.defaultError}:u.code!=="invalid_type"?{message:p.defaultError}:{message:g??t??p.defaultError}},description:a}}var O=class{get description(){return this._def.description}_getType(e){return xe(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:xe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new X,ctx:{common:e.parent.common,data:e.data,parsedType:xe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(ht(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){let r={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:xe(e)},a=this._parseSync({data:e,path:r.path,parent:r});return hi(r,a)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:xe(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:t});return Ce(r)?{value:r.value}:{issues:t.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(r=>Ce(r)?{value:r.value}:{issues:t.common.issues})}async parseAsync(e,t){let r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){let r={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:xe(e)},a=this._parse({data:e,path:r.path,parent:r}),o=await(ht(a)?a:Promise.resolve(a));return hi(r,o)}refine(e,t){let r=a=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(a):t;return this._refinement((a,o)=>{let u=e(a),p=()=>o.addIssue({code:b.custom,...r(a)});return typeof Promise<"u"&&u instanceof Promise?u.then(g=>g?!0:(p(),!1)):u?!0:(p(),!1)})}refinement(e,t){return this._refinement((r,a)=>e(r)?!0:(a.addIssue(typeof t=="function"?t(r,a):t),!1))}_refinement(e){return new fe({schema:this,typeName:B.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return pe.create(this,this._def)}nullable(){return we.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ie.create(this)}promise(){return Pe.create(this,this._def)}or(e){return He.create([this,e],this._def)}and(e){return Je.create(this,e,this._def)}transform(e){return new fe({...P(this._def),schema:this,typeName:B.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new et({...P(this._def),innerType:this,defaultValue:t,typeName:B.ZodDefault})}brand(){return new Ot({typeName:B.ZodBranded,type:this,...P(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new tt({...P(this._def),innerType:this,catchValue:t,typeName:B.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ut.create(this,e)}readonly(){return rt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Jo=/^c[^\s-]{8,}$/i,Yo=/^[0-9a-z]+$/,Ko=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Qo=/^[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,Xo=/^[a-z0-9_-]{21}$/i,eu=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,tu=/^[-+]?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)?)??$/,ru=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,nu="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",kr,au=/^(?:(?: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])$/,iu=/^(?:(?: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])$/,su=/^(([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]))$/,ou=/^(([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])$/,uu=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,lu=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,gi="((\\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])))",cu=new RegExp(`^${gi}$`);function xi(n){let e="[0-5]\\d";n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`);let t=n.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function pu(n){return new RegExp(`^${xi(n)}$`)}function vi(n){let e=`${gi}T${xi(n)}`,t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function du(n,e){return!!((e==="v4"||!e)&&au.test(n)||(e==="v6"||!e)&&su.test(n))}function fu(n,e){if(!eu.test(n))return!1;try{let[t]=n.split(".");if(!t)return!1;let r=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),a=JSON.parse(atob(r));return!(typeof a!="object"||a===null||"typ"in a&&a?.typ!=="JWT"||!a.alg||e&&a.alg!==e)}catch{return!1}}function mu(n,e){return!!((e==="v4"||!e)&&iu.test(n)||(e==="v6"||!e)&&ou.test(n))}var Le=class n extends O{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==I.string){let o=this._getOrReturnCtx(e);return R(o,{code:b.invalid_type,expected:I.string,received:o.parsedType}),L}let r=new X,a;for(let o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(a=this._getOrReturnCtx(e,a),R(a,{code:b.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty());else if(o.kind==="max")e.data.length>o.value&&(a=this._getOrReturnCtx(e,a),R(a,{code:b.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty());else if(o.kind==="length"){let u=e.data.length>o.value,p=e.data.length<o.value;(u||p)&&(a=this._getOrReturnCtx(e,a),u?R(a,{code:b.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):p&&R(a,{code:b.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),r.dirty())}else if(o.kind==="email")ru.test(e.data)||(a=this._getOrReturnCtx(e,a),R(a,{validation:"email",code:b.invalid_string,message:o.message}),r.dirty());else if(o.kind==="emoji")kr||(kr=new RegExp(nu,"u")),kr.test(e.data)||(a=this._getOrReturnCtx(e,a),R(a,{validation:"emoji",code:b.invalid_string,message:o.message}),r.dirty());else if(o.kind==="uuid")Qo.test(e.data)||(a=this._getOrReturnCtx(e,a),R(a,{validation:"uuid",code:b.invalid_string,message:o.message}),r.dirty());else if(o.kind==="nanoid")Xo.test(e.data)||(a=this._getOrReturnCtx(e,a),R(a,{validation:"nanoid",code:b.invalid_string,message:o.message}),r.dirty());else if(o.kind==="cuid")Jo.test(e.data)||(a=this._getOrReturnCtx(e,a),R(a,{validation:"cuid",code:b.invalid_string,message:o.message}),r.dirty());else if(o.kind==="cuid2")Yo.test(e.data)||(a=this._getOrReturnCtx(e,a),R(a,{validation:"cuid2",code:b.invalid_string,message:o.message}),r.dirty());else if(o.kind==="ulid")Ko.test(e.data)||(a=this._getOrReturnCtx(e,a),R(a,{validation:"ulid",code:b.invalid_string,message:o.message}),r.dirty());else if(o.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),R(a,{validation:"url",code:b.invalid_string,message:o.message}),r.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),R(a,{validation:"regex",code:b.invalid_string,message:o.message}),r.dirty())):o.kind==="trim"?e.data=e.data.trim():o.kind==="includes"?e.data.includes(o.value,o.position)||(a=this._getOrReturnCtx(e,a),R(a,{code:b.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),r.dirty()):o.kind==="toLowerCase"?e.data=e.data.toLowerCase():o.kind==="toUpperCase"?e.data=e.data.toUpperCase():o.kind==="startsWith"?e.data.startsWith(o.value)||(a=this._getOrReturnCtx(e,a),R(a,{code:b.invalid_string,validation:{startsWith:o.value},message:o.message}),r.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(a=this._getOrReturnCtx(e,a),R(a,{code:b.invalid_string,validation:{endsWith:o.value},message:o.message}),r.dirty()):o.kind==="datetime"?vi(o).test(e.data)||(a=this._getOrReturnCtx(e,a),R(a,{code:b.invalid_string,validation:"datetime",message:o.message}),r.dirty()):o.kind==="date"?cu.test(e.data)||(a=this._getOrReturnCtx(e,a),R(a,{code:b.invalid_string,validation:"date",message:o.message}),r.dirty()):o.kind==="time"?pu(o).test(e.data)||(a=this._getOrReturnCtx(e,a),R(a,{code:b.invalid_string,validation:"time",message:o.message}),r.dirty()):o.kind==="duration"?tu.test(e.data)||(a=this._getOrReturnCtx(e,a),R(a,{validation:"duration",code:b.invalid_string,message:o.message}),r.dirty()):o.kind==="ip"?du(e.data,o.version)||(a=this._getOrReturnCtx(e,a),R(a,{validation:"ip",code:b.invalid_string,message:o.message}),r.dirty()):o.kind==="jwt"?fu(e.data,o.alg)||(a=this._getOrReturnCtx(e,a),R(a,{validation:"jwt",code:b.invalid_string,message:o.message}),r.dirty()):o.kind==="cidr"?mu(e.data,o.version)||(a=this._getOrReturnCtx(e,a),R(a,{validation:"cidr",code:b.invalid_string,message:o.message}),r.dirty()):o.kind==="base64"?uu.test(e.data)||(a=this._getOrReturnCtx(e,a),R(a,{validation:"base64",code:b.invalid_string,message:o.message}),r.dirty()):o.kind==="base64url"?lu.test(e.data)||(a=this._getOrReturnCtx(e,a),R(a,{validation:"base64url",code:b.invalid_string,message:o.message}),r.dirty()):j.assertNever(o);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement(a=>e.test(a),{validation:t,code:b.invalid_string,...A.errToObj(r)})}_addCheck(e){return new n({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...A.errToObj(e)})}url(e){return this._addCheck({kind:"url",...A.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...A.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...A.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...A.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...A.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...A.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...A.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...A.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...A.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...A.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...A.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...A.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...A.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...A.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...A.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...A.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...A.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...A.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...A.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...A.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...A.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...A.errToObj(t)})}nonempty(e){return this.min(1,A.errToObj(e))}trim(){return new n({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new n({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new n({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};Le.create=n=>new Le({checks:[],typeName:B.ZodString,coerce:n?.coerce??!1,...P(n)});function hu(n,e){let t=(n.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,a=t>r?t:r,o=Number.parseInt(n.toFixed(a).replace(".","")),u=Number.parseInt(e.toFixed(a).replace(".",""));return o%u/10**a}var Ve=class n extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==I.number){let o=this._getOrReturnCtx(e);return R(o,{code:b.invalid_type,expected:I.number,received:o.parsedType}),L}let r,a=new X;for(let o of this._def.checks)o.kind==="int"?j.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),R(r,{code:b.invalid_type,expected:"integer",received:"float",message:o.message}),a.dirty()):o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(r=this._getOrReturnCtx(e,r),R(r,{code:b.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),a.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(r=this._getOrReturnCtx(e,r),R(r,{code:b.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),a.dirty()):o.kind==="multipleOf"?hu(e.data,o.value)!==0&&(r=this._getOrReturnCtx(e,r),R(r,{code:b.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),R(r,{code:b.not_finite,message:o.message}),a.dirty()):j.assertNever(o);return{status:a.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,A.toString(t))}gt(e,t){return this.setLimit("min",e,!1,A.toString(t))}lte(e,t){return this.setLimit("max",e,!0,A.toString(t))}lt(e,t){return this.setLimit("max",e,!1,A.toString(t))}setLimit(e,t,r,a){return new n({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:A.toString(a)}]})}_addCheck(e){return new n({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:A.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:A.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:A.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:A.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:A.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:A.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:A.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:A.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:A.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&j.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}};Ve.create=n=>new Ve({checks:[],typeName:B.ZodNumber,coerce:n?.coerce||!1,...P(n)});var qe=class n extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==I.bigint)return this._getInvalidInput(e);let r,a=new X;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(r=this._getOrReturnCtx(e,r),R(r,{code:b.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),a.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(r=this._getOrReturnCtx(e,r),R(r,{code:b.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),a.dirty()):o.kind==="multipleOf"?e.data%o.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),R(r,{code:b.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):j.assertNever(o);return{status:a.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return R(t,{code:b.invalid_type,expected:I.bigint,received:t.parsedType}),L}gte(e,t){return this.setLimit("min",e,!0,A.toString(t))}gt(e,t){return this.setLimit("min",e,!1,A.toString(t))}lte(e,t){return this.setLimit("max",e,!0,A.toString(t))}lt(e,t){return this.setLimit("max",e,!1,A.toString(t))}setLimit(e,t,r,a){return new n({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:A.toString(a)}]})}_addCheck(e){return new n({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:A.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:A.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:A.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:A.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:A.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};qe.create=n=>new qe({checks:[],typeName:B.ZodBigInt,coerce:n?.coerce??!1,...P(n)});var We=class extends O{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==I.boolean){let r=this._getOrReturnCtx(e);return R(r,{code:b.invalid_type,expected:I.boolean,received:r.parsedType}),L}return te(e.data)}};We.create=n=>new We({typeName:B.ZodBoolean,coerce:n?.coerce||!1,...P(n)});var ze=class n extends O{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==I.date){let o=this._getOrReturnCtx(e);return R(o,{code:b.invalid_type,expected:I.date,received:o.parsedType}),L}if(Number.isNaN(e.data.getTime())){let o=this._getOrReturnCtx(e);return R(o,{code:b.invalid_date}),L}let r=new X,a;for(let o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(a=this._getOrReturnCtx(e,a),R(a,{code:b.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),r.dirty()):o.kind==="max"?e.data.getTime()>o.value&&(a=this._getOrReturnCtx(e,a),R(a,{code:b.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),r.dirty()):j.assertNever(o);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new n({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:A.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:A.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};ze.create=n=>new ze({checks:[],coerce:n?.coerce||!1,typeName:B.ZodDate,...P(n)});var gt=class extends O{_parse(e){if(this._getType(e)!==I.symbol){let r=this._getOrReturnCtx(e);return R(r,{code:b.invalid_type,expected:I.symbol,received:r.parsedType}),L}return te(e.data)}};gt.create=n=>new gt({typeName:B.ZodSymbol,...P(n)});var Ze=class extends O{_parse(e){if(this._getType(e)!==I.undefined){let r=this._getOrReturnCtx(e);return R(r,{code:b.invalid_type,expected:I.undefined,received:r.parsedType}),L}return te(e.data)}};Ze.create=n=>new Ze({typeName:B.ZodUndefined,...P(n)});var Ge=class extends O{_parse(e){if(this._getType(e)!==I.null){let r=this._getOrReturnCtx(e);return R(r,{code:b.invalid_type,expected:I.null,received:r.parsedType}),L}return te(e.data)}};Ge.create=n=>new Ge({typeName:B.ZodNull,...P(n)});var Be=class extends O{constructor(){super(...arguments),this._any=!0}_parse(e){return te(e.data)}};Be.create=n=>new Be({typeName:B.ZodAny,...P(n)});var Re=class extends O{constructor(){super(...arguments),this._unknown=!0}_parse(e){return te(e.data)}};Re.create=n=>new Re({typeName:B.ZodUnknown,...P(n)});var he=class extends O{_parse(e){let t=this._getOrReturnCtx(e);return R(t,{code:b.invalid_type,expected:I.never,received:t.parsedType}),L}};he.create=n=>new he({typeName:B.ZodNever,...P(n)});var xt=class extends O{_parse(e){if(this._getType(e)!==I.undefined){let r=this._getOrReturnCtx(e);return R(r,{code:b.invalid_type,expected:I.void,received:r.parsedType}),L}return te(e.data)}};xt.create=n=>new xt({typeName:B.ZodVoid,...P(n)});var Ie=class n extends O{_parse(e){let{ctx:t,status:r}=this._processInputParams(e),a=this._def;if(t.parsedType!==I.array)return R(t,{code:b.invalid_type,expected:I.array,received:t.parsedType}),L;if(a.exactLength!==null){let u=t.data.length>a.exactLength.value,p=t.data.length<a.exactLength.value;(u||p)&&(R(t,{code:u?b.too_big:b.too_small,minimum:p?a.exactLength.value:void 0,maximum:u?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),r.dirty())}if(a.minLength!==null&&t.data.length<a.minLength.value&&(R(t,{code:b.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),r.dirty()),a.maxLength!==null&&t.data.length>a.maxLength.value&&(R(t,{code:b.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((u,p)=>a.type._parseAsync(new de(t,u,t.path,p)))).then(u=>X.mergeArray(r,u));let o=[...t.data].map((u,p)=>a.type._parseSync(new de(t,u,t.path,p)));return X.mergeArray(r,o)}get element(){return this._def.type}min(e,t){return new n({...this._def,minLength:{value:e,message:A.toString(t)}})}max(e,t){return new n({...this._def,maxLength:{value:e,message:A.toString(t)}})}length(e,t){return new n({...this._def,exactLength:{value:e,message:A.toString(t)}})}nonempty(e){return this.min(1,e)}};Ie.create=(n,e)=>new Ie({type:n,minLength:null,maxLength:null,exactLength:null,typeName:B.ZodArray,...P(e)});function yt(n){if(n instanceof ue){let e={};for(let t in n.shape){let r=n.shape[t];e[t]=pe.create(yt(r))}return new ue({...n._def,shape:()=>e})}else return n instanceof Ie?new Ie({...n._def,type:yt(n.element)}):n instanceof pe?pe.create(yt(n.unwrap())):n instanceof we?we.create(yt(n.unwrap())):n instanceof ve?ve.create(n.items.map(e=>yt(e))):n}var ue=class n extends O{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=j.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==I.object){let w=this._getOrReturnCtx(e);return R(w,{code:b.invalid_type,expected:I.object,received:w.parsedType}),L}let{status:r,ctx:a}=this._processInputParams(e),{shape:o,keys:u}=this._getCached(),p=[];if(!(this._def.catchall instanceof he&&this._def.unknownKeys==="strip"))for(let w in a.data)u.includes(w)||p.push(w);let g=[];for(let w of u){let E=o[w],F=a.data[w];g.push({key:{status:"valid",value:w},value:E._parse(new de(a,F,a.path,w)),alwaysSet:w in a.data})}if(this._def.catchall instanceof he){let w=this._def.unknownKeys;if(w==="passthrough")for(let E of p)g.push({key:{status:"valid",value:E},value:{status:"valid",value:a.data[E]}});else if(w==="strict")p.length>0&&(R(a,{code:b.unrecognized_keys,keys:p}),r.dirty());else if(w!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let w=this._def.catchall;for(let E of p){let F=a.data[E];g.push({key:{status:"valid",value:E},value:w._parse(new de(a,F,a.path,E)),alwaysSet:E in a.data})}}return a.common.async?Promise.resolve().then(async()=>{let w=[];for(let E of g){let F=await E.key,J=await E.value;w.push({key:F,value:J,alwaysSet:E.alwaysSet})}return w}).then(w=>X.mergeObjectSync(r,w)):X.mergeObjectSync(r,g)}get shape(){return this._def.shape()}strict(e){return A.errToObj,new n({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{let a=this._def.errorMap?.(t,r).message??r.defaultError;return t.code==="unrecognized_keys"?{message:A.errToObj(e).message??a}:{message:a}}}:{}})}strip(){return new n({...this._def,unknownKeys:"strip"})}passthrough(){return new n({...this._def,unknownKeys:"passthrough"})}extend(e){return new n({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new n({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:B.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new n({...this._def,catchall:e})}pick(e){let t={};for(let r of j.objectKeys(e))e[r]&&this.shape[r]&&(t[r]=this.shape[r]);return new n({...this._def,shape:()=>t})}omit(e){let t={};for(let r of j.objectKeys(this.shape))e[r]||(t[r]=this.shape[r]);return new n({...this._def,shape:()=>t})}deepPartial(){return yt(this)}partial(e){let t={};for(let r of j.objectKeys(this.shape)){let a=this.shape[r];e&&!e[r]?t[r]=a:t[r]=a.optional()}return new n({...this._def,shape:()=>t})}required(e){let t={};for(let r of j.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let o=this.shape[r];for(;o instanceof pe;)o=o._def.innerType;t[r]=o}return new n({...this._def,shape:()=>t})}keyof(){return wi(j.objectKeys(this.shape))}};ue.create=(n,e)=>new ue({shape:()=>n,unknownKeys:"strip",catchall:he.create(),typeName:B.ZodObject,...P(e)});ue.strictCreate=(n,e)=>new ue({shape:()=>n,unknownKeys:"strict",catchall:he.create(),typeName:B.ZodObject,...P(e)});ue.lazycreate=(n,e)=>new ue({shape:n,unknownKeys:"strip",catchall:he.create(),typeName:B.ZodObject,...P(e)});var He=class extends O{_parse(e){let{ctx:t}=this._processInputParams(e),r=this._def.options;function a(o){for(let p of o)if(p.result.status==="valid")return p.result;for(let p of o)if(p.result.status==="dirty")return t.common.issues.push(...p.ctx.common.issues),p.result;let u=o.map(p=>new oe(p.ctx.common.issues));return R(t,{code:b.invalid_union,unionErrors:u}),L}if(t.common.async)return Promise.all(r.map(async o=>{let u={...t,common:{...t.common,issues:[]},parent:null};return{result:await o._parseAsync({data:t.data,path:t.path,parent:u}),ctx:u}})).then(a);{let o,u=[];for(let g of r){let w={...t,common:{...t.common,issues:[]},parent:null},E=g._parseSync({data:t.data,path:t.path,parent:w});if(E.status==="valid")return E;E.status==="dirty"&&!o&&(o={result:E,ctx:w}),w.common.issues.length&&u.push(w.common.issues)}if(o)return t.common.issues.push(...o.ctx.common.issues),o.result;let p=u.map(g=>new oe(g));return R(t,{code:b.invalid_union,unionErrors:p}),L}}get options(){return this._def.options}};He.create=(n,e)=>new He({options:n,typeName:B.ZodUnion,...P(e)});var Ne=n=>n instanceof Ye?Ne(n.schema):n instanceof fe?Ne(n.innerType()):n instanceof Ke?[n.value]:n instanceof Qe?n.options:n instanceof Xe?j.objectValues(n.enum):n instanceof et?Ne(n._def.innerType):n instanceof Ze?[void 0]:n instanceof Ge?[null]:n instanceof pe?[void 0,...Ne(n.unwrap())]:n instanceof we?[null,...Ne(n.unwrap())]:n instanceof Ot||n instanceof rt?Ne(n.unwrap()):n instanceof tt?Ne(n._def.innerType):[],Qt=class n extends O{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==I.object)return R(t,{code:b.invalid_type,expected:I.object,received:t.parsedType}),L;let r=this.discriminator,a=t.data[r],o=this.optionsMap.get(a);return o?t.common.async?o._parseAsync({data:t.data,path:t.path,parent:t}):o._parseSync({data:t.data,path:t.path,parent:t}):(R(t,{code:b.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),L)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){let a=new Map;for(let o of t){let u=Ne(o.shape[e]);if(!u.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let p of u){if(a.has(p))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(p)}`);a.set(p,o)}}return new n({typeName:B.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,...P(r)})}};function Nr(n,e){let t=xe(n),r=xe(e);if(n===e)return{valid:!0,data:n};if(t===I.object&&r===I.object){let a=j.objectKeys(e),o=j.objectKeys(n).filter(p=>a.indexOf(p)!==-1),u={...n,...e};for(let p of o){let g=Nr(n[p],e[p]);if(!g.valid)return{valid:!1};u[p]=g.data}return{valid:!0,data:u}}else if(t===I.array&&r===I.array){if(n.length!==e.length)return{valid:!1};let a=[];for(let o=0;o<n.length;o++){let u=n[o],p=e[o],g=Nr(u,p);if(!g.valid)return{valid:!1};a.push(g.data)}return{valid:!0,data:a}}else return t===I.date&&r===I.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}var Je=class extends O{_parse(e){let{status:t,ctx:r}=this._processInputParams(e),a=(o,u)=>{if(Yt(o)||Yt(u))return L;let p=Nr(o.value,u.value);return p.valid?((Kt(o)||Kt(u))&&t.dirty(),{status:t.value,value:p.data}):(R(r,{code:b.invalid_intersection_types}),L)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([o,u])=>a(o,u)):a(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};Je.create=(n,e,t)=>new Je({left:n,right:e,typeName:B.ZodIntersection,...P(t)});var ve=class n extends O{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==I.array)return R(r,{code:b.invalid_type,expected:I.array,received:r.parsedType}),L;if(r.data.length<this._def.items.length)return R(r,{code:b.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),L;!this._def.rest&&r.data.length>this._def.items.length&&(R(r,{code:b.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let o=[...r.data].map((u,p)=>{let g=this._def.items[p]||this._def.rest;return g?g._parse(new de(r,u,r.path,p)):null}).filter(u=>!!u);return r.common.async?Promise.all(o).then(u=>X.mergeArray(t,u)):X.mergeArray(t,o)}get items(){return this._def.items}rest(e){return new n({...this._def,rest:e})}};ve.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ve({items:n,typeName:B.ZodTuple,rest:null,...P(e)})};var Xt=class n extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==I.object)return R(r,{code:b.invalid_type,expected:I.object,received:r.parsedType}),L;let a=[],o=this._def.keyType,u=this._def.valueType;for(let p in r.data)a.push({key:o._parse(new de(r,p,r.path,p)),value:u._parse(new de(r,r.data[p],r.path,p)),alwaysSet:p in r.data});return r.common.async?X.mergeObjectAsync(t,a):X.mergeObjectSync(t,a)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof O?new n({keyType:e,valueType:t,typeName:B.ZodRecord,...P(r)}):new n({keyType:Le.create(),valueType:e,typeName:B.ZodRecord,...P(t)})}},vt=class extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==I.map)return R(r,{code:b.invalid_type,expected:I.map,received:r.parsedType}),L;let a=this._def.keyType,o=this._def.valueType,u=[...r.data.entries()].map(([p,g],w)=>({key:a._parse(new de(r,p,r.path,[w,"key"])),value:o._parse(new de(r,g,r.path,[w,"value"]))}));if(r.common.async){let p=new Map;return Promise.resolve().then(async()=>{for(let g of u){let w=await g.key,E=await g.value;if(w.status==="aborted"||E.status==="aborted")return L;(w.status==="dirty"||E.status==="dirty")&&t.dirty(),p.set(w.value,E.value)}return{status:t.value,value:p}})}else{let p=new Map;for(let g of u){let w=g.key,E=g.value;if(w.status==="aborted"||E.status==="aborted")return L;(w.status==="dirty"||E.status==="dirty")&&t.dirty(),p.set(w.value,E.value)}return{status:t.value,value:p}}}};vt.create=(n,e,t)=>new vt({valueType:e,keyType:n,typeName:B.ZodMap,...P(t)});var wt=class n extends O{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==I.set)return R(r,{code:b.invalid_type,expected:I.set,received:r.parsedType}),L;let a=this._def;a.minSize!==null&&r.data.size<a.minSize.value&&(R(r,{code:b.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),t.dirty()),a.maxSize!==null&&r.data.size>a.maxSize.value&&(R(r,{code:b.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),t.dirty());let o=this._def.valueType;function u(g){let w=new Set;for(let E of g){if(E.status==="aborted")return L;E.status==="dirty"&&t.dirty(),w.add(E.value)}return{status:t.value,value:w}}let p=[...r.data.values()].map((g,w)=>o._parse(new de(r,g,r.path,w)));return r.common.async?Promise.all(p).then(g=>u(g)):u(p)}min(e,t){return new n({...this._def,minSize:{value:e,message:A.toString(t)}})}max(e,t){return new n({...this._def,maxSize:{value:e,message:A.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};wt.create=(n,e)=>new wt({valueType:n,minSize:null,maxSize:null,typeName:B.ZodSet,...P(e)});var er=class n extends O{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==I.function)return R(t,{code:b.invalid_type,expected:I.function,received:t.parsedType}),L;function r(p,g){return Ft({data:p,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,mt(),ke].filter(w=>!!w),issueData:{code:b.invalid_arguments,argumentsError:g}})}function a(p,g){return Ft({data:p,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,mt(),ke].filter(w=>!!w),issueData:{code:b.invalid_return_type,returnTypeError:g}})}let o={errorMap:t.common.contextualErrorMap},u=t.data;if(this._def.returns instanceof Pe){let p=this;return te(async function(...g){let w=new oe([]),E=await p._def.args.parseAsync(g,o).catch(S=>{throw w.addIssue(r(g,S)),w}),F=await Reflect.apply(u,this,E);return await p._def.returns._def.type.parseAsync(F,o).catch(S=>{throw w.addIssue(a(F,S)),w})})}else{let p=this;return te(function(...g){let w=p._def.args.safeParse(g,o);if(!w.success)throw new oe([r(g,w.error)]);let E=Reflect.apply(u,this,w.data),F=p._def.returns.safeParse(E,o);if(!F.success)throw new oe([a(E,F.error)]);return F.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new n({...this._def,args:ve.create(e).rest(Re.create())})}returns(e){return new n({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new n({args:e||ve.create([]).rest(Re.create()),returns:t||Re.create(),typeName:B.ZodFunction,...P(r)})}},Ye=class extends O{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};Ye.create=(n,e)=>new Ye({getter:n,typeName:B.ZodLazy,...P(e)});var Ke=class extends O{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return R(t,{received:t.data,code:b.invalid_literal,expected:this._def.value}),L}return{status:"valid",value:e.data}}get value(){return this._def.value}};Ke.create=(n,e)=>new Ke({value:n,typeName:B.ZodLiteral,...P(e)});function wi(n,e){return new Qe({values:n,typeName:B.ZodEnum,...P(e)})}var Qe=class n extends O{_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),r=this._def.values;return R(t,{expected:j.joinValues(r),received:t.parsedType,code:b.invalid_type}),L}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),r=this._def.values;return R(t,{received:t.data,code:b.invalid_enum_value,options:r}),L}return te(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return n.create(e,{...this._def,...t})}exclude(e,t=this._def){return n.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}};Qe.create=wi;var Xe=class extends O{_parse(e){let t=j.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==I.string&&r.parsedType!==I.number){let a=j.objectValues(t);return R(r,{expected:j.joinValues(a),received:r.parsedType,code:b.invalid_type}),L}if(this._cache||(this._cache=new Set(j.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let a=j.objectValues(t);return R(r,{received:r.data,code:b.invalid_enum_value,options:a}),L}return te(e.data)}get enum(){return this._def.values}};Xe.create=(n,e)=>new Xe({values:n,typeName:B.ZodNativeEnum,...P(e)});var Pe=class extends O{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==I.promise&&t.common.async===!1)return R(t,{code:b.invalid_type,expected:I.promise,received:t.parsedType}),L;let r=t.parsedType===I.promise?t.data:Promise.resolve(t.data);return te(r.then(a=>this._def.type.parseAsync(a,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Pe.create=(n,e)=>new Pe({type:n,typeName:B.ZodPromise,...P(e)});var fe=class extends O{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===B.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:r}=this._processInputParams(e),a=this._def.effect||null,o={addIssue:u=>{R(r,u),u.fatal?t.abort():t.dirty()},get path(){return r.path}};if(o.addIssue=o.addIssue.bind(o),a.type==="preprocess"){let u=a.transform(r.data,o);if(r.common.async)return Promise.resolve(u).then(async p=>{if(t.value==="aborted")return L;let g=await this._def.schema._parseAsync({data:p,path:r.path,parent:r});return g.status==="aborted"?L:g.status==="dirty"?De(g.value):t.value==="dirty"?De(g.value):g});{if(t.value==="aborted")return L;let p=this._def.schema._parseSync({data:u,path:r.path,parent:r});return p.status==="aborted"?L:p.status==="dirty"?De(p.value):t.value==="dirty"?De(p.value):p}}if(a.type==="refinement"){let u=p=>{let g=a.refinement(p,o);if(r.common.async)return Promise.resolve(g);if(g instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return p};if(r.common.async===!1){let p=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return p.status==="aborted"?L:(p.status==="dirty"&&t.dirty(),u(p.value),{status:t.value,value:p.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(p=>p.status==="aborted"?L:(p.status==="dirty"&&t.dirty(),u(p.value).then(()=>({status:t.value,value:p.value}))))}if(a.type==="transform")if(r.common.async===!1){let u=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Ce(u))return L;let p=a.transform(u.value,o);if(p instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:p}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(u=>Ce(u)?Promise.resolve(a.transform(u.value,o)).then(p=>({status:t.value,value:p})):L);j.assertNever(a)}};fe.create=(n,e,t)=>new fe({schema:n,typeName:B.ZodEffects,effect:e,...P(t)});fe.createWithPreprocess=(n,e,t)=>new fe({schema:e,effect:{type:"preprocess",transform:n},typeName:B.ZodEffects,...P(t)});var pe=class extends O{_parse(e){return this._getType(e)===I.undefined?te(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};pe.create=(n,e)=>new pe({innerType:n,typeName:B.ZodOptional,...P(e)});var we=class extends O{_parse(e){return this._getType(e)===I.null?te(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};we.create=(n,e)=>new we({innerType:n,typeName:B.ZodNullable,...P(e)});var et=class extends O{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return t.parsedType===I.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};et.create=(n,e)=>new et({innerType:n,typeName:B.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...P(e)});var tt=class extends O{_parse(e){let{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return ht(a)?a.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new oe(r.common.issues)},input:r.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new oe(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};tt.create=(n,e)=>new tt({innerType:n,typeName:B.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...P(e)});var bt=class extends O{_parse(e){if(this._getType(e)!==I.nan){let r=this._getOrReturnCtx(e);return R(r,{code:b.invalid_type,expected:I.nan,received:r.parsedType}),L}return{status:"valid",value:e.data}}};bt.create=n=>new bt({typeName:B.ZodNaN,...P(n)});var yu=Symbol("zod_brand"),Ot=class extends O{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}},Ut=class n extends O{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let o=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?L:o.status==="dirty"?(t.dirty(),De(o.value)):this._def.out._parseAsync({data:o.value,path:r.path,parent:r})})();{let a=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?L:a.status==="dirty"?(t.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:r.path,parent:r})}}static create(e,t){return new n({in:e,out:t,typeName:B.ZodPipeline})}},rt=class extends O{_parse(e){let t=this._def.innerType._parse(e),r=a=>(Ce(a)&&(a.value=Object.freeze(a.value)),a);return ht(t)?t.then(a=>r(a)):r(t)}unwrap(){return this._def.innerType}};rt.create=(n,e)=>new rt({innerType:n,typeName:B.ZodReadonly,...P(e)});function yi(n,e){let t=typeof n=="function"?n(e):typeof n=="string"?{message:n}:n;return typeof t=="string"?{message:t}:t}function bi(n,e={},t){return n?Be.create().superRefine((r,a)=>{let o=n(r);if(o instanceof Promise)return o.then(u=>{if(!u){let p=yi(e,r),g=p.fatal??t??!0;a.addIssue({code:"custom",...p,fatal:g})}});if(!o){let u=yi(e,r),p=u.fatal??t??!0;a.addIssue({code:"custom",...u,fatal:p})}}):Be.create()}var gu={object:ue.lazycreate},B;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(B||(B={}));var xu=(n,e={message:`Input not instance of ${n.name}`})=>bi(t=>t instanceof n,e),Ti=Le.create,_i=Ve.create,vu=bt.create,wu=qe.create,ki=We.create,bu=ze.create,Tu=gt.create,_u=Ze.create,ku=Ge.create,Nu=Be.create,Ru=Re.create,Iu=he.create,Eu=xt.create,Au=Ie.create,Su=ue.create,Cu=ue.strictCreate,Lu=He.create,Bu=Qt.create,Pu=Je.create,Fu=ve.create,Ou=Xt.create,Uu=vt.create,ju=wt.create,Mu=er.create,$u=Ye.create,Du=Ke.create,Vu=Qe.create,qu=Xe.create,Wu=Pe.create,zu=fe.create,Zu=pe.create,Gu=we.create,Hu=fe.createWithPreprocess,Ju=Ut.create,Yu=()=>Ti().optional(),Ku=()=>_i().optional(),Qu=()=>ki().optional(),Xu={string:(n=>Le.create({...n,coerce:!0})),number:(n=>Ve.create({...n,coerce:!0})),boolean:(n=>We.create({...n,coerce:!0})),bigint:(n=>qe.create({...n,coerce:!0})),date:(n=>ze.create({...n,coerce:!0}))};var el=L;m();y();h();var Ni=$.strictObject({title:$.string(),content:$.string()});var Rr=$.object({"base-api-exception-class-name":$.string().optional(),"base-exception-class-name":$.string().optional(),"client-class-name":$.string().optional(),"inline-file-properties":$.boolean().optional(),"inline-path-parameters":$.boolean().optional(),"package-layout":$.enum(["flat","nested"]).optional(),"package-prefix":$.string().optional(),"use-local-date-for-dates":$.boolean().optional(),"custom-dependencies":$.array($.string()).optional(),"disable-required-property-builder-checks":$.boolean().optional(),"enable-forward-compatible-enums":$.boolean().optional(),"enable-inline-types":$.boolean().optional(),"enable-public-constructors":$.boolean().optional(),"generate-unknown-as-json-node":$.boolean().optional(),"json-include":$.enum(["non-absent","non-empty"]).optional(),"enable-extensible-builders":$.boolean().optional(),"use-default-request-parameter-values":$.boolean().optional(),"enable-wire-tests":$.boolean().default(!1),"collapse-optional-nullable":$.boolean().optional(),"custom-readme-sections":$.array(Ni).optional(),"custom-pager-name":$.string().optional(),"default-timeout-in-seconds":$.number().optional(),"gradle-distribution-url":$.string().optional(),"gradle-plugin-management":$.string().optional(),"gradle-central-dependency-management":$.boolean().optional(),"enable-gradle-profiling":$.boolean().optional(),"wrapped-aliases":$.boolean().optional()});var d={};Dt(d,{Access:()=>Ir,AstNode:()=>Z,Class:()=>nt,ClassInstantiation:()=>at,ClassReference:()=>V,CodeBlock:()=>it,Method:()=>st,MethodInvocation:()=>ot,Parameter:()=>ut,Type:()=>jt,TypeLiteral:()=>le,Writer:()=>$e,classReference:()=>Tl,class_:()=>bl,codeblock:()=>wl,instantiateClass:()=>_l,invokeMethod:()=>kl,method:()=>Nl,parameter:()=>Rl});m();y();h();m();y();h();m();y();h();var Ir={Public:"public",Protected:"protected",Private:"private"};m();y();h();m();y();h();var Z=class extends je{async toStringAsync({packageName:e,customConfig:t,formatter:r}){let a=new Pt({packageName:e,customConfig:t,formatter:r});return this.write(a),a.toStringAsync()}toString({packageName:e,customConfig:t,formatter:r}){let a=new Pt({packageName:e,customConfig:t,formatter:r});return this.write(a),a.toString()}};var nt=class extends Z{constructor({name:t,access:r}){super();_(this,"name");_(this,"access");_(this,"methods",[]);this.name=t,this.access=r}write(t){if(t.write(`${this.access} class ${this.name}`),this.isEmpty()){t.writeLine(" {}");return}t.writeLine(" {"),t.indent();for(let r of this.methods)t.writeNode(r),t.newLine();t.dedent(),t.write("}")}addMethod(t){this.methods.push(t)}isEmpty(){return this.methods.length===0}};m();y();h();m();y();h();m();y();h();m();y();h();var V=class extends Z{constructor({name:t,packageName:r,fullyQualified:a}){super();_(this,"name");_(this,"packageName");_(this,"fullyQualified");this.name=t,this.packageName=r,this.fullyQualified=a??!1}write(t){if(t.addImport(`${this.packageName}.${this.name}`),this.fullyQualified){t.write(`${this.packageName}.${this.name}`);return}t.write(this.name)}};m();y();h();var jt=class extends Z{constructor(t){super();_(this,"internalType");this.internalType=t}write(t){switch(this.internalType.type){case"array":t.writeNode(this.internalType.value),t.write("[]");break;case"bigInteger":t.writeNode(tl);break;case"boolean":t.write("Boolean");break;case"bytes":t.write("byte[]");break;case"date":t.write("String");break;case"dateTime":t.writeNode(al);break;case"double":t.write("Double");break;case"float":t.write("Float");break;case"generic":t.writeNode(this.internalType.value),t.write("<");for(let[r,a]of this.internalType.parameters.entries())t.writeNode(a),r<this.internalType.parameters.length-1&&t.write(", ");t.write(">");break;case"inputStream":t.writeNode(ol);break;case"integer":t.write("Integer");break;case"iterable":this.writeIterable({writer:t,iterable:this.internalType});break;case"list":{this.writeList({writer:t,list:this.internalType});break}case"long":{t.write("Long");break}case"map":{this.writeMap({writer:t,map:this.internalType});break}case"object":{t.write("Object");break}case"optional":{this.writeOptional({writer:t,optional:this.internalType});break}case"reference":t.writeNode(this.internalType.value);break;case"set":{this.writeSet({writer:t,set:this.internalType});break}case"string":t.write("String");break;case"uuid":t.writeNode(sl);break;case"void":t.write("Void");break;default:M(this.internalType)}}isOptional(){return this.internalType.type==="optional"}static array(t){return new this({type:"array",value:t})}static bigInteger(){return new this({type:"bigInteger"})}static boolean(){return new this({type:"boolean"})}static bytes(){return new this({type:"bytes"})}static date(){return new this({type:"date"})}static dateTime(){return new this({type:"dateTime"})}static double(){return new this({type:"double"})}static float(){return new this({type:"float"})}static integer(){return new this({type:"integer"})}static list(t){return new this({type:"list",value:t})}static long(){return new this({type:"long"})}static map(t,r){return new this({type:"map",keyType:t,valueType:r})}static object(){return new this({type:"object"})}static optional(t){return this.isAlreadyOptional(t)?t:new this({type:"optional",value:t})}static reference(t){return new this({type:"reference",value:t})}static generic(t,r){return new this({type:"generic",value:t,parameters:r})}static set(t){return new this({type:"set",value:t})}static string(){return new this({type:"string"})}static uuid(){return new this({type:"uuid"})}static void(){return new this({type:"void"})}static iterable(t){return new this({type:"iterable",value:t})}static inputStream(){return new this({type:"inputStream"})}writeList({writer:t,list:r}){t.writeNode(rl),t.write("<"),r.value.write(t),t.write(">")}writeMap({writer:t,map:r}){t.writeNode(nl),t.write("<"),r.keyType.write(t),t.write(", "),r.valueType.write(t),t.write(">")}writeOptional({writer:t,optional:r}){t.writeNode(Er),t.write("<"),r.value.write(t),t.write(">")}writeIterable({writer:t,iterable:r}){t.writeNode(ul),t.write("<"),r.value.write(t),t.write(">")}writeSet({writer:t,set:r}){t.writeNode(il),t.write("<"),r.value.write(t),t.write(">")}static isAlreadyOptional(t){return t.internalType.type==="optional"}},tr=new V({name:"Arrays",packageName:"java.util"}),tl=new V({name:"BigInteger",packageName:"java.math"}),mg=new V({name:"HashMap",packageName:"java.util"}),rl=new V({name:"List",packageName:"java.util"}),nl=new V({name:"Map",packageName:"java.util"}),al=new V({name:"OffsetDateTime",packageName:"java.time"}),Er=new V({name:"Optional",packageName:"java.util"}),il=new V({name:"Set",packageName:"java.util"}),sl=new V({name:"UUID",packageName:"java.util"}),ol=new V({name:"InputStream",packageName:"java.io"}),ul=new V({name:"Iterable",packageName:"java.lang"});var le=class n extends Z{constructor(t){super();_(this,"internalType");this.internalType=t}write(t){switch(this.internalType.type){case"bigInteger":this.writeBigInteger({writer:t,bigInteger:this.internalType});break;case"boolean":t.write(this.internalType.value.toString());break;case"builder":this.writeBuilder({writer:t,builder:this.internalType});break;case"bytes":t.write(`"${this.internalType.value}".getBytes()`);break;case"class":{this.writeClass({writer:t,class_:this.internalType});break}case"date":this.writeDate({writer:t,date:this.internalType});break;case"dateTime":this.writeDateTime({writer:t,dateTime:this.internalType});break;case"double":{let r=this.internalType.value.toString();!r.includes(".")&&!r.includes("e")&&!r.includes("E")?t.write(`${r}.0`):t.write(r);break}case"enum":this.writeEnum({writer:t,enum_:this.internalType});break;case"float":t.write(`${this.internalType.value}f`);break;case"integer":t.write(Math.floor(this.internalType.value).toString());break;case"list":{this.writeList({writer:t,list:this.internalType});break}case"long":{t.write(`${Math.floor(this.internalType.value)}L`);break}case"map":{this.writeMap({writer:t,map:this.internalType});break}case"optional":{this.writeOptional({writer:t,optional:this.internalType});break}case"raw":{this.internalType.value instanceof Z?t.writeNode(this.internalType.value):t.write(this.internalType.value);break}case"reference":t.writeNode(this.internalType.value);break;case"set":{this.writeSet({writer:t,set:this.internalType});break}case"string":t.write(`"${this.escapeString(this.internalType.value)}"`);break;case"unknown":this.writeUnknown({writer:t,value:this.internalType.value});break;case"uuid":this.writeUUID({writer:t,uuid:this.internalType});break;case"nop":break;default:M(this.internalType)}}isOptional(){return this.internalType.type==="optional"}static bigInteger(t){return new this({type:"bigInteger",value:t})}static boolean(t){return new this({type:"boolean",value:t})}static builder({classReference:t,parameters:r}){return new this({type:"builder",classReference:t,parameters:r})}static bytes(t){return new this({type:"bytes",value:t})}static class_({reference:t,parameters:r}){return new this({type:"class",reference:t,parameters:r})}static date(t){return new this({type:"date",value:t})}static dateTime(t){return new this({type:"dateTime",value:t})}static double(t){return new this({type:"double",value:t})}static enum_({classReference:t,value:r}){return new this({type:"enum",classReference:t,value:r})}static float(t){return new this({type:"float",value:t})}static integer(t){return new this({type:"integer",value:t})}static list({valueType:t,values:r,isParameter:a}){return new this({type:"list",valueType:t,values:r,isParameter:a})}static long(t){return new this({type:"long",value:t})}static map({keyType:t,valueType:r,entries:a}){return new this({type:"map",keyType:t,valueType:r,entries:a})}static optional({value:t,useOf:r}){return this.isAlreadyOptional(t)?t:new this({type:"optional",value:t,useOf:r})}static raw(t){return new this({type:"raw",value:t})}static reference(t){return new this({type:"reference",value:t})}static set({valueType:t,values:r}){return new this({type:"set",valueType:t,values:r})}static string(t){return new this({type:"string",value:t})}static unknown(t){return new this({type:"unknown",value:t})}static uuid(t){return new this({type:"uuid",value:t})}static nop(){return new this({type:"nop"})}static isNop(t){return t.internalType.type==="nop"}shouldWriteInLine(){switch(this.internalType.type){case"bigInteger":case"boolean":case"bytes":case"date":case"dateTime":case"double":case"enum":case"float":case"integer":case"long":case"nop":case"raw":case"string":case"unknown":case"uuid":return!0;case"optional":return this.internalType.value.shouldWriteInLine();case"builder":case"class":case"list":case"map":case"reference":case"set":return!1;default:M(this.internalType)}}writeBigInteger({writer:t,bigInteger:r}){t.write("new "),t.writeNode(d.instantiateClass({classReference:ll,arguments_:[n.string(r.value)]}))}writeBuilder({writer:t,builder:r}){t.writeNode(r.classReference),t.writeNewLineIfLastLineNot(),t.indent(),this.writeBuilderParameters({writer:t,parameters:this.orderBuilderParameters(hl({parameters:r.parameters}))}),t.dedent()}writeBuilderParameters({writer:t,parameters:r}){t.writeLine(".builder()");for(let a of r)t.write(`.${a.name}(`),a.value.shouldWriteInLine()||t.newLine(),t.indent(),t.writeNode(a.value),t.dedent(),a.value.shouldWriteInLine()||t.newLine(),t.writeLine(")");t.writeNewLineIfLastLineNot(),t.write(".build()")}orderBuilderParameters(t){return t.some(a=>!a.value.isOptional()&&!this.isCollection(a.value))?t.sort((a,o)=>{let u=this.isNonRequired(a.value),p=this.isNonRequired(o.value);return u&&!p?1:!u&&p?-1:0}):t.sort((a,o)=>{let u=a.value.isOptional(),p=o.value.isOptional();return u&&!p?1:!u&&p?-1:0})}isCollection(t){let r=t.internalType.type;return r==="list"||r==="set"||r==="map"}isNonRequired(t){return t.isOptional()||this.isCollection(t)}writeClass({writer:t,class_:r}){let a=ml({parameters:r.parameters});t.writeNode(d.instantiateClass({classReference:r.reference,arguments_:a.map(o=>o.value)}))}writeDate({writer:t,date:r}){t.writeNode(d.invokeMethod({on:pl,method:"parse",arguments_:[n.string(r.value)]}))}writeDateTime({writer:t,dateTime:r}){t.writeNode(d.invokeMethod({on:dl,method:"parse",arguments_:[n.string(r.value)]}))}writeEnum({writer:t,enum_:r}){t.writeNode(r.classReference),t.write("."+r.value)}writeList({writer:t,list:r}){this.writeIterable({writer:t,iterable:r})}writeMap({writer:t,map:r}){let a=yl({entries:r.entries});if(a.length===0){t.write("new "),t.writeNode(rr),t.write("<"),t.writeNode(r.keyType),t.write(", "),t.writeNode(r.valueType),t.write(">()");return}t.write("new "),t.writeNode(rr),t.write("<"),t.writeNode(r.keyType),t.write(", "),t.writeNode(r.valueType),t.writeLine(">() {{"),t.indent();for(let o of a)t.write("put("),t.writeNode(o.key),t.write(", "),t.writeNode(o.value),t.writeLine(");");t.dedent(),t.write("}}")}writeOptional({writer:t,optional:r}){if(!r.useOf){t.writeNode(r.value);return}t.writeNode(d.invokeMethod({on:Er,method:"of",arguments_:[r.value]}))}writeSet({writer:t,set:r}){this.writeIterable({writer:t,iterable:r})}writeIterable({writer:t,iterable:r}){let a=r.type==="list"?Ar:cl,o=gl({values:r.values});if(r.type==="list"&&r.isParameter&&o.length>0){t.writeNode(d.invokeMethod({on:tr,method:"asList",arguments_:o}));return}if(o.length===0){t.write("new "),t.writeNode(a),t.write("<"),t.writeNode(r.valueType),t.write(">()");return}t.write("new "),t.writeNode(a),t.write("<"),t.writeNode(r.valueType),t.writeLine(">("),t.indent(),t.writeNode(d.invokeMethod({on:tr,method:"asList",arguments_:o})),t.writeNewLineIfLastLineNot(),t.dedent(),t.write(")")}writeUnknown({writer:t,value:r}){switch(typeof r){case"boolean":t.write(r.toString());return;case"string":t.write(`"${this.escapeString(r)}"`);return;case"number":t.write(r.toString());return;case"object":if(r==null){t.write("null");return}if(Array.isArray(r)){this.writeUnknownArray({writer:t,value:r});return}this.writeUnknownMap({writer:t,value:r});return;default:throw new Error(`Internal error; unsupported unknown type: ${typeof r}`)}}writeUnknownArray({writer:t,value:r}){if(r.length===0){t.write("new "),t.writeNode(Ar),t.write("<Object>()");return}t.write("new "),t.writeNode(Ar),t.write("<Object>("),t.writeNode(d.invokeMethod({on:tr,method:"asList",arguments_:r.map(a=>n.unknown(a))})),t.write(")")}writeUnknownMap({writer:t,value:r}){let a=Object.entries(r);if(a.length===0){t.write("new "),t.writeNode(rr),t.write("<String, Object>()");return}t.writeLine("new "),t.writeNode(rr),t.write("<String, Object>() {{"),t.indent();for(let[o,u]of a)t.write(`put("${o}", `),t.writeNode(n.unknown(u)),t.writeLine(");");t.dedent(),t.write("}}")}writeUUID({writer:t,uuid:r}){t.writeNode(d.invokeMethod({on:fl,method:"fromString",arguments_:[n.string(r.value)]}))}escapeString(t){return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}static isAlreadyOptional(t){return t.internalType.type==="optional"}},Ar=new V({name:"ArrayList",packageName:"java.util"}),ll=new V({name:"BigInteger",packageName:"java.math"}),rr=new V({name:"HashMap",packageName:"java.util"}),cl=new V({name:"HashSet",packageName:"java.util"}),Ng=new V({name:"List",packageName:"java.util"}),pl=new V({name:"LocalDate",packageName:"java.time"}),Rg=new V({name:"Map",packageName:"java.util"}),dl=new V({name:"OffsetDateTime",packageName:"java.time"}),Ig=new V({name:"Set",packageName:"java.util"}),fl=new V({name:"UUID",packageName:"java.util"});function ml({parameters:n}){return n.filter(e=>!le.isNop(e.value))}function hl({parameters:n}){return n.filter(e=>!le.isNop(e.value))}function yl({entries:n}){return n.filter(e=>!le.isNop(e.key)&&!le.isNop(e.value))}function gl({values:n}){return n.filter(e=>!le.isNop(e))}function nr({writer:n,arguments_:e}){let t=vl(e);if(t.length===0){n.write("()");return}if(t.some(a=>a instanceof le&&!a.shouldWriteInLine())){xl({writer:n,arguments_:t});return}n.write("("),t.forEach((a,o)=>{o>0&&n.write(", "),Ri({writer:n,argument:a})}),n.write(")")}function xl({writer:n,arguments_:e}){n.writeLine("("),n.indent(),e.forEach((t,r)=>{r>0&&n.writeLine(","),Ri({writer:n,argument:t})}),n.dedent(),e.length>0&&n.newLine(),n.write(")")}function Ri({writer:n,argument:e}){Tr(e)?n.writeNodeOrString(e.assignment):e.write(n)}function vl(n){return n.filter(e=>!(e instanceof le&&le.isNop(e)))}var at=class extends Z{constructor({classReference:t,arguments_:r}){super();_(this,"classReference");_(this,"arguments_");this.classReference=t,this.arguments_=r}write(t){t.writeNode(this.classReference),nr({writer:t,arguments_:this.arguments_})}};m();y();h();var it=class extends Z{constructor(t){super();_(this,"arg");this.arg=t}write(t){return new me(this.arg).write(t)}};m();y();h();var st=class extends Z{constructor({name:t,access:r,parameters:a,body:o,static_:u,return_:p}){super();_(this,"name");_(this,"access");_(this,"parameters");_(this,"body");_(this,"return_");_(this,"static_");this.name=t,this.access=r,this.parameters=a,this.body=o,this.return_=p,this.static_=u??!1}write(t){if(t.write(`${this.access} `),this.static_&&t.write("static "),this.return_!=null?t.writeNode(this.return_):t.write("void"),t.write(` ${this.name}`),this.parameters.length===0)t.write("()");else if(this.parameters.length===1){if(t.write("("),this.parameters[0]==null)throw new Error("Cannot render parameter "+this.parameters[0]);t.writeNode(this.parameters[0]),t.write(")")}else t.writeLine("("),t.indent(),this.parameters.forEach((r,a)=>{a>0&&t.writeLine(", "),t.writeNode(r)}),t.dedent(),t.write(")");if(this.body==null){t.write(";");return}t.writeLine(" {"),t.indent(),t.writeNode(this.body),t.writeNewLineIfLastLineNot(),t.dedent(),t.write("}")}};m();y();h();var ot=class extends Z{constructor({method:t,arguments_:r,on:a}){super();_(this,"on");_(this,"method");_(this,"arguments_");this.on=a,this.method=t,this.arguments_=r}write(t){this.on.write(t),t.write("."),t.write(this.method),nr({writer:t,arguments_:this.arguments_})}};m();y();h();var ut=class extends Z{constructor({name:t,type:r}){super();_(this,"name");_(this,"type");this.name=t,this.type=r}write(t){t.writeNode(this.type),t.write(` ${this.name}`)}};function wl(n){return new it(n)}function bl(n){return new nt(n)}function Tl(n){return new V(n)}function _l(n){return new at(n)}function kl(n){return new ot(n)}function Nl(n){return new st(n)}function Rl(n){return new ut(n)}m();y();h();var ar=class{constructor({context:e}){_(this,"context");this.context=e}isNopTypeLiteral(e){return e.internalType?.type==="nop"}usesOptionalNullable(){return this.context.customConfig?.["collapse-optional-nullable"]===!0}wrapInOptionalIfNotNop(e,t=!1){return this.isNopTypeLiteral(e)?e:this.usesOptionalNullable()?this.context.getOptionalNullableOf(e):d.TypeLiteral.optional({value:e,useOf:t})}convert(e){if(e.value===null)return this.context.isNullable(e.typeReference)?this.context.getNullableOfNull():(this.context.errors.add({severity:D.Critical,message:"Expected non-null value, but got null"}),d.TypeLiteral.nop());if(e.value===void 0)return d.TypeLiteral.nop();switch(e.typeReference.type){case"list":return this.convertList({list:e.typeReference.value,value:e.value,as:e.as});case"literal":return this.convertLiteral({literal:e.typeReference.value,value:e.value});case"map":return this.convertMap({map:e.typeReference,value:e.value,as:e.as});case"named":{let t=this.context.resolveNamedType({typeId:e.typeReference.value});return t==null?d.TypeLiteral.nop():this.convertNamed({named:t,value:e.value,as:e.as,inUndiscriminatedUnion:e.inUndiscriminatedUnion})}case"nullable":case"optional":{if(e.value===void 0||typeof e.value=="object"&&e.value!==null&&Object.keys(e.value).length===0&&e.typeReference.value.type==="named")return this.usesOptionalNullable()?this.context.getOptionalNullableAbsent():d.TypeLiteral.reference(d.invokeMethod({on:d.classReference({name:"Optional",packageName:"java.util"}),method:"empty",arguments_:[]}));if(e.typeReference.value.type==="list"){let a=this.convertList({list:e.typeReference.value.value,value:e.value});return this.wrapInOptionalIfNotNop(a,!0)}if(this.usesOptionalNullable()&&(e.typeReference.value.type==="optional"||e.typeReference.value.type==="nullable"))return this.convert({typeReference:e.typeReference.value,value:e.value,as:e.as,inUndiscriminatedUnion:e.inUndiscriminatedUnion});let t=this.convert({typeReference:e.typeReference.value,value:e.value,as:e.as,inUndiscriminatedUnion:e.inUndiscriminatedUnion}),r=e.as==="mapValue"||e.inUndiscriminatedUnion===!0;return this.wrapInOptionalIfNotNop(t,r)}case"primitive":return this.convertPrimitive({primitive:e.typeReference.value,value:e.value,as:e.as});case"set":return this.convertSet({set:e.typeReference.value,value:e.value,as:e.as});case"unknown":return this.convertUnknown({value:e.value});default:M(e.typeReference)}}convertList({list:e,value:t,as:r}){if(!Array.isArray(t))return this.context.errors.add({severity:D.Critical,message:`Expected array but got: ${typeof t}`}),d.TypeLiteral.nop();let a=e.type==="optional"||e.type==="nullable";return d.TypeLiteral.list({valueType:this.context.dynamicTypeMapper.convert({typeReference:e}),values:t.map((o,u)=>{this.context.errors.scope({index:u});try{if(a){let p=this.convert({typeReference:e.value,value:o,as:r});return this.wrapInOptionalIfNotNop(p,!0)}return this.convert({typeReference:e,value:o,as:r})}finally{this.context.errors.unscope()}}),isParameter:!0})}convertLiteral({literal:e,value:t}){switch(e.type){case"boolean":{let r=this.context.getValueAsBoolean({value:t});return r==null?d.TypeLiteral.nop():d.TypeLiteral.boolean(r)}case"string":{let r=this.context.getValueAsString({value:t});return r==null?d.TypeLiteral.nop():d.TypeLiteral.string(r)}default:M(e)}}convertSet({set:e,value:t,as:r}){return Array.isArray(t)?d.TypeLiteral.set({valueType:this.context.dynamicTypeMapper.convert({typeReference:e}),values:t.map((a,o)=>{this.context.errors.scope({index:o});try{return this.convert({typeReference:e,value:a,as:r})}finally{this.context.errors.unscope()}})}):(this.context.errors.add({severity:D.Critical,message:`Expected array but got: ${typeof t}`}),d.TypeLiteral.nop())}convertMap({map:e,value:t,as:r}){return typeof t!="object"||t==null?(this.context.errors.add({severity:D.Critical,message:`Expected object but got: ${t==null?"null":typeof t}`}),d.TypeLiteral.nop()):d.TypeLiteral.map({keyType:this.context.dynamicTypeMapper.convert({typeReference:e.key}),valueType:this.context.dynamicTypeMapper.convert({typeReference:e.value}),entries:Object.entries(t).map(([a,o])=>{this.context.errors.scope(a);try{return{key:this.convert({typeReference:e.key,value:a,as:"mapKey"}),value:this.convert({typeReference:e.value,value:o,as:"mapValue"})}}finally{this.context.errors.unscope()}})})}convertNamed({named:e,value:t,as:r,inUndiscriminatedUnion:a}){switch(e.type){case"alias":return this.convert({typeReference:e.typeReference,value:t,as:r,inUndiscriminatedUnion:a});case"discriminatedUnion":return this.convertDiscriminatedUnion({discriminatedUnion:e,value:t});case"enum":return this.convertEnum({enum_:e,value:t});case"object":return this.convertObject({object_:e,value:t,as:r});case"undiscriminatedUnion":return this.convertUndiscriminatedUnion({undiscriminatedUnion:e,value:t});default:M(e)}}convertDiscriminatedUnion({discriminatedUnion:e,value:t}){let r=this.context.getJavaClassReferenceFromDeclaration({declaration:e.declaration}),a=this.context.resolveDiscriminatedUnionTypeInstance({discriminatedUnion:e,value:t});if(a==null)return d.TypeLiteral.nop();let o=a.singleDiscriminatedUnionType;switch(o.type){case"samePropertiesAsObject":{let u=this.context.resolveNamedType({typeId:o.typeId});return u==null?d.TypeLiteral.nop():d.TypeLiteral.reference(d.invokeMethod({on:r,method:this.context.getPropertyName(o.discriminantValue.name),arguments_:[this.convertNamed({named:u,value:a.value})]}))}case"singleProperty":{let u=this.context.getRecord(a.value);if(u==null)return d.TypeLiteral.nop();try{return this.context.errors.scope(o.discriminantValue.wireValue),d.TypeLiteral.reference(d.invokeMethod({on:r,method:this.context.getPropertyName(o.discriminantValue.name),arguments_:[this.convert({typeReference:o.typeReference,value:u["value"]})]}))}finally{this.context.errors.unscope()}}case"noProperties":return d.TypeLiteral.reference(d.invokeMethod({on:r,method:this.context.getPropertyName(o.discriminantValue.name),arguments_:[]}));default:M(o)}}convertObject({object_:e,value:t,as:r}){let a=this.context.associateByWireValue({parameters:e.properties,values:this.context.getRecord(t)??{}}),o=r==="request"?a.filter(u=>!this.context.isDirectLiteral(u.typeReference)):a;return d.TypeLiteral.builder({classReference:this.context.getJavaClassReferenceFromDeclaration({declaration:e.declaration}),parameters:o.map(u=>{this.context.errors.scope(u.name.wireValue);try{return{name:this.context.getMethodName(u.name.name),value:this.convert({typeReference:u.typeReference,value:u.value,as:r})}}finally{this.context.errors.unscope()}})})}convertEnum({enum_:e,value:t}){let r=this.getEnumValueName({enum_:e,value:t});return r==null?d.TypeLiteral.nop():d.TypeLiteral.enum_({classReference:this.context.getJavaClassReferenceFromDeclaration({declaration:e.declaration}),value:r})}getEnumValueName({enum_:e,value:t}){if(typeof t!="string"){this.context.errors.add({severity:D.Critical,message:`Expected enum value string, got: ${typeof t}`});return}let r=e.values.find(a=>a.wireValue===t);if(r==null){this.context.errors.add({severity:D.Critical,message:`An enum value named "${t}" does not exist in this context`});return}return this.context.getEnumName(r.name)}convertUndiscriminatedUnion({undiscriminatedUnion:e,value:t}){let r=this.findMatchingUndiscriminatedUnionType({undiscriminatedUnion:e,value:t});return r==null?d.TypeLiteral.nop():this.context.isPrimitive(r.valueTypeReference)?d.TypeLiteral.reference(d.invokeMethod({on:this.context.getJavaClassReferenceFromDeclaration({declaration:e.declaration}),method:"of",arguments_:[r.typeInstantiation]})):d.TypeLiteral.reference(d.invokeMethod({on:this.context.getJavaClassReferenceFromDeclaration({declaration:e.declaration}),method:"of",arguments_:[r.typeInstantiation]}))}findMatchingUndiscriminatedUnionType({undiscriminatedUnion:e,value:t}){let r=[],a=[];for(let p of e.types)try{r.push(JSON.stringify(p));let g=this.convert({typeReference:p,value:t,inUndiscriminatedUnion:!0});return{valueTypeReference:p,typeInstantiation:g}}catch(g){a.push(`Type ${JSON.stringify(p)}: ${g instanceof Error?g.message:String(g)}`);continue}this.context.errors.add({severity:D.Critical,message:`None of the types in the undiscriminated union matched the given "${typeof t}" value. Tried ${r.length} variants. Errors: ${a.join("; ")}`});let o=e.declaration.name??"UnknownUnion",u=a.map((p,g)=>` ${g+1}. ${p}`).join(`
|
|
23
23
|
`);throw new Error(`Failed to match undiscriminated union "${o}" for ${typeof t} value.
|
|
24
24
|
Value: ${JSON.stringify(t)}
|
|
25
25
|
Attempted ${r.length} variants:
|
|
26
26
|
${u}
|
|
27
27
|
|
|
28
|
-
This prevents invalid snippet code generation that would cause formatter errors.`)}getUndiscriminatedUnionFieldName({typeReference:e}){switch(e.type){case"list":return this.getUndiscriminatedUnionFieldNameForList({list:e});case"literal":return this.getUndiscriminatedUnionFieldNameForLiteral({literal:e.value});case"map":return this.getUndiscriminatedUnionFieldNameForMap({map:e});case"named":{let t=this.context.resolveNamedType({typeId:e.value});return t==null?void 0:this.context.getClassName(t.declaration.name)}case"optional":return this.getUndiscriminatedUnionFieldNameForOptional({typeReference:e});case"nullable":return this.getUndiscriminatedUnionFieldNameForNullable({typeReference:e});case"primitive":return this.getUndiscriminatedUnionFieldNameForPrimitive({primitive:e.value});case"set":return this.getUndiscriminatedUnionFieldNameForSet({set:e});case"unknown":return"Unknown";default:M(e)}}getUndiscriminatedUnionFieldNameForList({list:e}){let t=this.getUndiscriminatedUnionFieldName({typeReference:e});if(t!=null)return`ListOf${t}`}getUndiscriminatedUnionFieldNameForMap({map:e}){let t=this.getUndiscriminatedUnionFieldName({typeReference:e.key});if(t==null)return;let r=this.getUndiscriminatedUnionFieldName({typeReference:e.value});if(r!=null)return`MapOf${t}To${r}`}getUndiscriminatedUnionFieldNameForOptional({typeReference:e}){let t=this.getUndiscriminatedUnionFieldName({typeReference:e});if(t!=null)return`Optional${t}`}getUndiscriminatedUnionFieldNameForNullable({typeReference:e}){let t=this.getUndiscriminatedUnionFieldName({typeReference:e});if(t!=null)return`Nullable${t}`}getUndiscriminatedUnionFieldNameForSet({set:e}){let t=this.getUndiscriminatedUnionFieldName({typeReference:e});if(t!=null)return`SetOf${t}`}getUndiscriminatedUnionFieldNameForLiteral({literal:e}){}getUndiscriminatedUnionFieldNameForPrimitive({primitive:e}){switch(e){case"INTEGER":case"UINT":return"Integer";case"LONG":case"UINT_64":return"Long";case"FLOAT":return"Float";case"DOUBLE":return"Double";case"BOOLEAN":return"Boolean";case"BIG_INTEGER":return"BigInteger";case"STRING":return"String";case"UUID":return"Uuid";case"DATE":return"Date";case"DATE_TIME":return"DateTime";case"BASE_64":return"Base64";default:M(e)}}convertUnknown({value:e}){return this.context.customConfig?.["generate-unknown-as-json-node"]===!0?this.convertToJsonNode({value:e}):d.TypeLiteral.unknown(e)}convertToJsonNode({value:e}){let t=d.classReference({name:"ObjectMappers",packageName:this.context.getCorePackageName()});return typeof e=="string"?d.TypeLiteral.reference(d.invokeMethod({on:d.codeblock(r=>{r.writeNode(t),r.write(".JSON_MAPPER")}),method:"valueToTree",arguments_:[d.TypeLiteral.string(e)]})):typeof e=="number"?d.TypeLiteral.reference(d.invokeMethod({on:d.codeblock(r=>{r.writeNode(t),r.write(".JSON_MAPPER")}),method:"valueToTree",arguments_:[d.TypeLiteral.integer(e)]})):typeof e=="boolean"?d.TypeLiteral.reference(d.invokeMethod({on:d.codeblock(r=>{r.writeNode(t),r.write(".JSON_MAPPER")}),method:"valueToTree",arguments_:[d.TypeLiteral.boolean(e)]})):e===null?d.TypeLiteral.reference(d.invokeMethod({on:d.codeblock(r=>{r.writeNode(t),r.write(".JSON_MAPPER")}),method:"valueToTree",arguments_:[d.TypeLiteral.raw(d.codeblock("null"))]})):Array.isArray(e)?d.TypeLiteral.reference(d.invokeMethod({on:d.codeblock(r=>{r.writeNode(t),r.write(".JSON_MAPPER")}),method:"valueToTree",arguments_:[d.TypeLiteral.list({valueType:d.Type.object(),values:e.map(r=>d.TypeLiteral.unknown(r)),isParameter:!0})]})):typeof e=="object"&&e!==null?d.TypeLiteral.reference(d.invokeMethod({on:d.codeblock(r=>{r.writeNode(t),r.write(".JSON_MAPPER")}),method:"valueToTree",arguments_:[d.TypeLiteral.unknown(e)]})):d.TypeLiteral.unknown(e)}convertPrimitive({primitive:e,value:t,as:r}){switch(e){case"INTEGER":case"UINT":{let a=this.getValueAsNumber({value:t,as:r});return a==null?d.TypeLiteral.nop():d.TypeLiteral.integer(a)}case"LONG":case"UINT_64":{let a=this.getValueAsNumber({value:t,as:r});return a==null?d.TypeLiteral.nop():d.TypeLiteral.long(a)}case"FLOAT":{let a=this.getValueAsNumber({value:t,as:r});return a==null?d.TypeLiteral.nop():d.TypeLiteral.float(a)}case"DOUBLE":{let a=this.getValueAsNumber({value:t,as:r});return a==null?d.TypeLiteral.nop():d.TypeLiteral.double(a)}case"BOOLEAN":{let a=this.getValueAsBoolean({value:t,as:r});return a==null?d.TypeLiteral.nop():d.TypeLiteral.boolean(a)}case"STRING":{let a=this.context.getValueAsString({value:t});return a==null?d.TypeLiteral.nop():d.TypeLiteral.string(a)}case"DATE":{let a=this.context.getValueAsString({value:t});return a==null?d.TypeLiteral.nop():this.context.customConfig?.["use-local-date-for-dates"]===!0?d.TypeLiteral.date(a):d.TypeLiteral.string(a)}case"DATE_TIME":{let a=this.context.getValueAsString({value:t});return a==null?d.TypeLiteral.nop():d.TypeLiteral.dateTime(a)}case"UUID":{let a=this.context.getValueAsString({value:t});return a==null?d.TypeLiteral.nop():d.TypeLiteral.uuid(a)}case"BASE_64":{let a=this.context.getValueAsString({value:t});return a==null?d.TypeLiteral.nop():d.TypeLiteral.bytes(a)}case"BIG_INTEGER":{let a=this.context.getValueAsString({value:t});return a==null?d.TypeLiteral.nop():d.TypeLiteral.bigInteger(a)}default:M(e)}}getValueAsNumber({value:e,as:t}){let r=t==="mapKey"&&typeof e=="string"?Number(e):e;return this.context.getValueAsNumber({value:r})}getValueAsBoolean({value:e,as:t}){let r=t==="mapKey"?typeof e=="string"?e==="true":e==="false"?!1:e:e;return this.context.getValueAsBoolean({value:r})}};m();y();h();var ir=class{constructor({context:e}){_(this,"context");this.context=e}convert(e){switch(e.typeReference.type){case"list":return d.Type.list(this.convert({typeReference:e.typeReference}));case"literal":return this.convertLiteral({literal:e.typeReference.value});case"map":return d.Type.map(this.convert({typeReference:e.typeReference.key}),this.convert({typeReference:e.typeReference.value}));case"named":{let t=this.context.resolveNamedType({typeId:e.typeReference.value});return t==null?this.convertUnknown():this.convertNamed({named:t})}case"optional":case"nullable":return d.Type.optional(this.convert({typeReference:e.typeReference.value}));case"primitive":return this.convertPrimitive({primitive:e.typeReference.value});case"set":return d.Type.set(this.convert({typeReference:e.typeReference}));case"unknown":return this.convertUnknown();default:M(e.typeReference)}}convertNamed({named:e}){switch(e.type){case"alias":return this.convert({typeReference:e.typeReference});case"enum":case"discriminatedUnion":case"object":case"undiscriminatedUnion":return d.Type.reference(d.classReference({name:this.context.getClassName(e.declaration.name),packageName:this.context.getTypesPackageName(e.declaration.fernFilepath)}));default:M(e)}}convertLiteral({literal:e}){switch(e.type){case"boolean":return d.Type.boolean();case"string":return d.Type.string()}}convertUnknown(){return this.context.customConfig?.["generate-unknown-as-json-node"]===!0?d.Type.reference(d.classReference({name:"JsonNode",packageName:"com.fasterxml.jackson.databind"})):d.Type.object()}convertPrimitive({primitive:e}){switch(e){case"INTEGER":return d.Type.integer();case"UINT":return d.Type.integer();case"LONG":return d.Type.long();case"UINT_64":return d.Type.long();case"FLOAT":return d.Type.float();case"DOUBLE":return d.Type.double();case"BOOLEAN":return d.Type.boolean();case"STRING":return d.Type.string();case"DATE":return d.Type.date();case"DATE_TIME":return d.Type.dateTime();case"UUID":return d.Type.uuid();case"BASE_64":return d.Type.bytes();case"BIG_INTEGER":return d.Type.bigInteger();default:M(e)}}};m();y();h();var sr=class{constructor({context:e}){_(this,"context");this.context=e}getFilePropertyInfo({body:e,value:t}){let r={fileFields:[],bodyPropertyFields:[]},a=this.context.getRecord(t)??{};for(let o of e.properties)switch(o.type){case"file":r.fileFields.push({name:this.context.getMethodName(o.name),value:this.getSingleFileProperty({property:o,record:a})});break;case"fileArray":r.fileFields.push({name:this.context.getMethodName(o.name),value:this.getArrayFileProperty({property:o,record:a})});break;case"bodyProperty":r.bodyPropertyFields.push({name:this.context.getMethodName(o.name.name),value:this.getBodyProperty({property:o,record:a})});break;default:M(o)}return r}getSingleFileProperty({property:e,record:t}){let r=this.context.getSingleFileValue({property:e,record:t});return r==null?d.TypeLiteral.nop():d.TypeLiteral.reference(this.context.getFileStreamFromString(r))}getArrayFileProperty({property:e,record:t}){let r=this.context.getFileArrayValues({property:e,record:t});if(r==null)return d.TypeLiteral.nop();for(let a of r)return d.TypeLiteral.reference(this.context.getFileStreamFromString(a));return d.TypeLiteral.nop()}getBodyProperty({property:e,record:t}){let r=t[e.name.wireValue];return r==null?d.TypeLiteral.nop():this.context.dynamicTypeLiteralMapper.convert({typeReference:e.typeReference,value:r})}};var Il=new Set(["enum","extends","package","void","short","class","abstract","return","import","for","assert","switch"]),El=new Set(["getClass","notify","notifyAll","wait"]),or=class n extends Bt{constructor({ir:t,config:r,options:a}){super({ir:t,config:r,options:a});_(this,"ir");_(this,"customConfig");_(this,"dynamicTypeMapper");_(this,"dynamicTypeLiteralMapper");_(this,"filePropertyMapper");this.ir=t,this.customConfig=Rr.parse(r.customConfig??{}),this.dynamicTypeMapper=new ir({context:this}),this.dynamicTypeLiteralMapper=new ar({context:this}),this.filePropertyMapper=new sr({context:this})}clone(){return new n({ir:this.ir,config:this.config,options:this.options})}getClassName(t){return this.getName(t.pascalCase.safeName)}getEnumName(t){return this.getName(t.screamingSnakeCase.safeName)}getPropertyName(t){return this.getName(t.camelCase.safeName)}getMethodName(t){let r=t.camelCase.safeName;return this.isReservedMethodName(r)?r+"_":this.getName(r)}getRootClientClassReference(){return d.classReference({name:this.getRootClientClassName(),packageName:this.getRootPackageName()})}getRootClientClassName(){return this.customConfig?.["client-class-name"]??`${this.getBaseNamePrefix()}Client`}getEnvironmentClassName(){return"Environment"}getEnvironmentTypeReferenceFromID(t){let r=this.resolveEnvironmentName(t);if(r!=null)return d.codeblock(a=>{a.writeNode(this.getEnvironmentClassReference()),a.write("."),a.write(this.getEnumName(r))})}getEnvironmentClassReference(){return d.classReference({name:this.getEnvironmentClassName(),packageName:this.getCorePackageName()})}getJavaClassReferenceFromDeclaration({declaration:t}){return d.classReference({name:t.name.pascalCase.unsafeName,packageName:this.getTypesPackageName(t.fernFilepath)})}getNullableClassReference(){return d.classReference({name:"Nullable",packageName:this.getCorePackageName()})}getNullableOfNull(){return d.TypeLiteral.reference(d.invokeMethod({on:this.getNullableClassReference(),method:"ofNull",arguments_:[]}))}getOptionalNullableClassReference(){return d.classReference({name:"OptionalNullable",packageName:this.getCorePackageName()})}getOptionalNullableAbsent(){return d.TypeLiteral.reference(d.invokeMethod({on:this.getOptionalNullableClassReference(),method:"absent",arguments_:[]}))}getOptionalNullableOf(t){return d.TypeLiteral.reference(d.invokeMethod({on:this.getOptionalNullableClassReference(),method:"of",arguments_:[t]}))}getFileStreamFromString(t){return d.TypeLiteral.reference(d.codeblock(r=>{r.write("new "),r.writeNode(this.getFileStreamClassReference()),r.write("("),r.writeNode(this.getByteArrayInputStreamClassReference()),r.write("("),r.writeNode(d.TypeLiteral.string(t)),r.write(".getBytes("),r.writeNode(this.getStandardCharsetsClassReference()),r.write(".UTF_8)))")}))}getFileStreamClassReference(){return d.classReference({name:"FileStream",packageName:this.getCorePackageName()})}getByteArrayInputStreamClassReference(){return d.classReference({name:"ByteArrayInputStream",packageName:"java.io"})}getStandardCharsetsClassReference(){return d.classReference({name:"StandardCharsets",packageName:"java.nio.charset"})}isPrimitive(t){switch(t.type){case"primitive":return!0;case"optional":case"nullable":return this.isPrimitive(t.value);case"named":{let r=this.resolveNamedType({typeId:t.value});if(r==null)return!1;switch(r.type){case"alias":return this.isPrimitive(r.typeReference);case"discriminatedUnion":case"undiscriminatedUnion":case"object":case"enum":return!1;default:M(r)}break}case"list":case"set":case"map":case"literal":case"unknown":return!1;default:M(t)}}isDirectLiteral(t){return t.type==="literal"}sortTypeInstancesByRequiredFirst(t,r){let a=new Map;r.forEach((p,g)=>{a.set(p.name.wireValue,g)});let o=[],u=[];for(let p of t)this.isOptional(p.typeReference)?u.push(p):o.push(p);return o.sort((p,g)=>(a.get(p.name.wireValue)??0)-(a.get(g.name.wireValue)??0)),[...o,...u]}associateByWireValue({parameters:t,values:r,ignoreMissingParameters:a}){let o=super.associateByWireValue({parameters:t,values:r,ignoreMissingParameters:a}),u=new Map;for(let g of o)u.set(g.name.wireValue,g);let p=[];for(let g of t){let w=u.get(g.name.wireValue);w!=null&&p.push(w)}return p}getRootPackageName(){let t=this.getPackagePrefixTokens();return this.joinPackageTokens(t)}getCorePackageName(){let t=this.getPackagePrefixTokens();return t.push("core"),this.joinPackageTokens(t)}getTypesPackageName(t){return this.getResourcesPackage(t,"types")}getRequestsPackageName(t){return this.getPackageLayout()==="flat"?this.getTypesPackageName(t):this.getResourcesPackage(t,"requests")}getResourcesPackage(t,r){let a=this.getPackagePrefixTokens();switch(this.getPackageLayout()){case"flat":t!=null&&a.push(...t.packagePath.map(o=>this.getPackageNameSegment(o)));break;case"nested":default:t!=null&&t.allParts.length>0&&a.push("resources"),t!=null&&a.push(...t.allParts.map(o=>this.getPackageNameSegment(o)))}return r!=null&&a.push(r),this.joinPackageTokens(a)}getPackageName(t,r){let a=this.getPackageNameSegments(t);return a=r!=null?[...a,r]:a,[...this.getPackagePrefixTokens(),...a].join(".")}getPackageLayout(){return this.customConfig?.["package-layout"]??"nested"}shouldInlinePathParameters(){return this.customConfig?.["inline-path-parameters"]??!1}shouldInlineFileProperties(){return this.customConfig?.["inline-file-properties"]??!1}getPackageNameSegments(t){return t.packagePath.map(r=>this.getPackageNameSegment(r))}getPackageNameSegment(t){return t.camelCase.safeName.toLowerCase()}getPackagePrefixTokens(){if(this.customConfig?.["package-prefix"]!=null)return this.customConfig["package-prefix"].split(".");let t=[];return t.push("com"),t.push(...this.splitOnNonAlphaNumericChar(this.config.organization)),t.push(...this.splitOnNonAlphaNumericChar(this.getApiName())),t}getBaseNamePrefix(){return this.convertKebabCaseToUpperCamelCase(this.config.organization)+this.convertKebabCaseToUpperCamelCase(this.getApiName())}getApiName(){return xr(this.config.workspaceName)}startsWithNumber(t){return/^\d/.test(t)}splitOnNonAlphaNumericChar(t){return t.split(/[^a-zA-Z0-9]/)}convertKebabCaseToUpperCamelCase(t){return t.replace(/-([a-z])/g,(r,a)=>a.toUpperCase()).replace(/^[a-z]/,r=>r.toUpperCase())}joinPackageTokens(t){return t.map(a=>this.startsWithNumber(a)?"_"+a:a).join(".")}getName(t){return this.isReservedName(t)?"_"+t:t}isReservedName(t){return Il.has(t)}isReservedMethodName(t){return El.has(t)}};m();y();h();var Ii="com.example.usage",Al="Example",Sl="main",Cl="args",Ei="client",Ll={type:"primitive",value:"STRING"};function Bl(n){if(n.type==="optional"&&n.value.type==="list"){let t=n.value.value;if(t.type==="optional")return{type:"optional",value:{type:"list",value:t.value}}}if(n.type==="list"){let e=n.value;if(e.type==="optional")return{type:"list",value:e.value}}return n}var ur=class{constructor({context:e,formatter:t}){_(this,"context");_(this,"formatter");this.context=e,this.formatter=t}async generateSnippet({endpoint:e,request:t,options:r}){let a=this.getConfig(r);return await this.buildCodeBlock({endpoint:e,snippet:t,options:r}).toStringAsync({packageName:a.fullStylePackageName??Ii,customConfig:this.context.customConfig,formatter:this.formatter})}generateSnippetSync({endpoint:e,request:t,options:r}){let a=this.getConfig(r);return this.buildCodeBlock({endpoint:e,snippet:t,options:r}).toString({packageName:a.fullStylePackageName??Ii,customConfig:this.context.customConfig,formatter:this.formatter})}async generateSnippetAst({endpoint:e,request:t,options:r}){throw new Error("Unsupported")}buildCodeBlock({endpoint:e,snippet:t,options:r}){let a=d.codeblock(u=>{u.writeNodeStatement(this.constructClient({endpoint:e,snippet:t})),u.newLine(),u.writeNodeStatement(this.callMethod({endpoint:e,snippet:t}))}),o=this.getStyle(r);switch(o){case Me.Concise:return a;case Me.Full:return this.buildFullCodeBlock({body:a,options:r});default:M(o)}}constructClient({endpoint:e,snippet:t}){let r=e.auth?.type==="oauth";return d.codeblock(a=>{if(a.writeNode(this.context.getRootClientClassReference()),a.write(` ${Ei} = `),r&&t.auth?.type==="oauth"){let o=t.auth;a.writeNode(this.context.getRootClientClassReference()),a.write(`.withCredentials("${o.clientId}", "${o.clientSecret}")`),a.writeNewLineIfLastLineNot(),a.indent();let u=this.getRootClientBuilderArgsExcludingAuth({endpoint:e,snippet:t});for(let p of u)a.write(`.${p.name}(`),p.value.shouldWriteInLine()||a.newLine(),a.writeNode(p.value),p.value.shouldWriteInLine()||a.newLine(),a.writeLine(")");a.writeLine(".build()"),a.dedent()}else a.writeNode(d.TypeLiteral.builder({classReference:this.context.getRootClientClassReference(),parameters:this.getRootClientBuilderArgs({endpoint:e,snippet:t})}))})}getRootClientBuilderArgsExcludingAuth({endpoint:e,snippet:t}){let r=[],a=this.getRootClientBaseUrlArg({baseUrl:t.baseURL,environment:t.environment});a!=null&&r.push(a),this.context.errors.scope(se.Headers),this.context.ir.headers!=null&&t.headers!=null&&r.push(...this.getRootClientHeaderArgs({headers:this.context.ir.headers,values:t.headers})),this.context.errors.unscope();let o=new Set;if([...this.context.ir.pathParameters??[],...e.request.pathParameters??[]].forEach(p=>{p.variable!=null&&o.add(p.variable)}),this.context.ir.variables!=null&&this.context.ir.variables.length>0){for(let p of this.context.ir.variables)if(o.has(p.id)){let g=p.name.camelCase.unsafeName;r.push({name:g,value:d.TypeLiteral.string(`YOUR_${p.name.screamingSnakeCase.unsafeName}`)})}}if(this.context.errors.scope(se.PathParameters),this.context.ir.pathParameters!=null&&this.context.ir.pathParameters.length>0){let p=this.context.ir.pathParameters.filter(g=>g.variable==null);p.length>0&&r.push(...this.getPathParameters({namedParameters:p,snippet:t}))}return this.context.errors.unscope(),r}buildFullCodeBlock({body:e,options:t}){let r=this.getConfig(t),a=d.class_({name:r.fullStyleClassName??Al,access:d.Access.Public}),o=d.parameter({name:Cl,type:d.Type.array(d.Type.string())});return a.addMethod(d.method({name:Sl,access:d.Access.Public,static_:!0,parameters:[o],body:e})),a}getRootClientBuilderArgs({endpoint:e,snippet:t}){let r=[];e.auth!=null&&(t.auth!=null?r.push(...this.getRootClientAuthArgs({auth:e.auth,values:t.auth})):this.context.errors.add({severity:$.Warning,message:`Auth with ${e.auth.type} configuration is required for this endpoint`}));let a=this.getRootClientBaseUrlArg({baseUrl:t.baseURL,environment:t.environment});a!=null&&r.push(a),this.context.errors.scope(se.Headers),this.context.ir.headers!=null&&t.headers!=null&&r.push(...this.getRootClientHeaderArgs({headers:this.context.ir.headers,values:t.headers})),this.context.errors.unscope();let o=new Set;if([...this.context.ir.pathParameters??[],...e.request.pathParameters??[]].forEach(p=>{p.variable!=null&&o.add(p.variable)}),this.context.ir.variables!=null&&this.context.ir.variables.length>0){for(let p of this.context.ir.variables)if(o.has(p.id)){let g=p.name.camelCase.unsafeName;r.push({name:g,value:d.TypeLiteral.string(`YOUR_${p.name.screamingSnakeCase.unsafeName}`)})}}if(this.context.errors.scope(se.PathParameters),this.context.ir.pathParameters!=null&&this.context.ir.pathParameters.length>0){let p=this.context.ir.pathParameters.filter(g=>g.variable==null);p.length>0&&r.push(...this.getPathParameters({namedParameters:p,snippet:t}))}return this.context.errors.unscope(),r}getRootClientBaseUrlArg({baseUrl:e,environment:t}){if(e!=null&&t!=null){this.context.errors.add({severity:$.Critical,message:"Cannot specify both baseUrl and environment options"});return}if(e!=null){if(this.context.ir.environments?.environments.type==="multipleBaseUrls"){this.context.errors.add({severity:$.Critical,message:"The Java SDK doesn't support a baseUrl when multiple URL environments are configured"});return}return{name:"url",value:d.TypeLiteral.string(e)}}if(t!=null){if(this.context.isSingleEnvironmentID(t)){let r=this.context.getEnvironmentTypeReferenceFromID(t);if(r==null){this.context.errors.add({severity:$.Warning,message:`Environment ${JSON.stringify(t)} was not found`});return}return{name:"environment",value:d.TypeLiteral.reference(r)}}if(this.context.isMultiEnvironmentValues(t))return this.context.validateMultiEnvironmentUrlValues(t)?{name:"environment",value:d.TypeLiteral.reference(d.instantiateClass({classReference:this.context.getEnvironmentClassReference(),arguments_:Object.values(t).map(r=>this.context.dynamicTypeLiteralMapper.convert({typeReference:Ll,value:r}))}))}:void 0}}getRootClientAuthArgs({auth:e,values:t}){if(t.type!==e.type)return this.addError(this.context.newAuthMismatchError({auth:e,values:t}).message),[];switch(e.type){case"basic":return t.type==="basic"?this.getRootClientBasicAuthArgs({auth:e,values:t}):[];case"bearer":return t.type==="bearer"?this.getRootClientBearerAuthArgs({auth:e,values:t}):[];case"header":return t.type==="header"?this.getRootClientHeaderAuthArgs({auth:e,values:t}):[];case"oauth":return t.type==="oauth"?this.getRootClientOAuthArgs({auth:e,values:t}):[];case"inferred":return this.addWarning("The Java SDK Generator does not support Inferred auth scheme yet"),[];default:M(e)}}addError(e){this.context.errors.add({severity:$.Critical,message:e})}addWarning(e){this.context.errors.add({severity:$.Warning,message:e})}getRootClientBasicAuthArgs({auth:e,values:t}){return[{name:"credentials",value:d.TypeLiteral.raw(`"${t.username}", "${t.password}"`)}]}getRootClientBearerAuthArgs({auth:e,values:t}){return[{name:this.context.getMethodName(e.token),value:d.TypeLiteral.string(t.token)}]}getRootClientHeaderAuthArgs({auth:e,values:t}){return[{name:this.context.getMethodName(e.header.name.name),value:this.context.dynamicTypeLiteralMapper.convert({typeReference:e.header.typeReference,value:t.value})}]}getRootClientOAuthArgs({auth:e,values:t}){return[{name:this.context.getMethodName(e.clientId),value:d.TypeLiteral.string(t.clientId)},{name:this.context.getMethodName(e.clientSecret),value:d.TypeLiteral.string(t.clientSecret)}]}getRootClientHeaderArgs({headers:e,values:t}){let r=[];for(let a of e){let o=this.getRootClientHeaderArg({header:a,value:t.value});o!=null&&r.push({name:this.context.getMethodName(a.name.name),value:o})}return r}getRootClientHeaderArg({header:e,value:t}){let r=this.context.dynamicTypeLiteralMapper.convert({typeReference:e.typeReference,value:t});if(!d.TypeLiteral.isNop(r))return r}callMethod({endpoint:e,snippet:t}){return d.invokeMethod({on:d.codeblock(Ei),method:this.getMethod({endpoint:e}),arguments_:this.getMethodArgs({endpoint:e,snippet:t})})}getMethodArgs({endpoint:e,snippet:t}){switch(e.request.type){case"inlined":return this.getMethodArgsForInlinedRequest({request:e.request,snippet:t});case"body":return this.getMethodArgsForBodyRequest({request:e.request,snippet:t});default:M(e.request)}}getMethodArgsForBodyRequest({request:e,snippet:t}){let r=[];this.context.errors.scope(se.PathParameters);let a=(e.pathParameters??[]).filter(u=>u.variable==null);a.length>0&&r.push(...this.getPathParameters({namedParameters:a,snippet:t}).map(u=>u.value)),this.context.errors.unscope(),this.context.errors.scope(se.RequestBody),e.body!=null&&r.push(this.getBodyRequestArg({body:e.body,value:t.requestBody})),this.context.errors.unscope();let o=this.getRequestOptionsArg({request:e,snippet:t});return o!=null&&r.push(o),r}usesOptionalNullable(){return this.context.customConfig?.["collapse-optional-nullable"]===!0}getBodyRequestArg({body:e,value:t}){switch(e.type){case"bytes":return this.getBytesBodyRequestArg({value:t});case"typeReference":{if(e.value.type==="optional"){if(t==null)return this.usesOptionalNullable()?this.context.getOptionalNullableAbsent():d.TypeLiteral.reference(d.invokeMethod({on:d.classReference({name:"Optional",packageName:"java.util"}),method:"empty",arguments_:[]}));let r=this.context.dynamicTypeLiteralMapper.convert({typeReference:e.value.value,value:t,as:"request"}),a=r.toString({packageName:"com.example",customConfig:this.context.customConfig});return a.includes("Optional.empty()")||a.includes("OptionalNullable.absent()")?r:this.usesOptionalNullable()?this.context.getOptionalNullableOf(r):d.TypeLiteral.optional({value:r,useOf:!0})}return this.context.dynamicTypeLiteralMapper.convert({typeReference:e.value,value:t,as:"request"})}default:M(e)}}getBytesBodyRequestArg({value:e}){return e==null?d.TypeLiteral.bytes(""):typeof e!="string"?(this.context.errors.add({severity:$.Critical,message:`Expected bytes value to be a string, got ${typeof e}`}),d.TypeLiteral.nop()):d.TypeLiteral.bytes(e)}getMethodArgsForInlinedRequest({request:e,snippet:t}){let r=[],{inlinePathParameters:a,inlineFileProperties:o}={inlinePathParameters:this.context.shouldInlinePathParameters(),inlineFileProperties:this.context.shouldInlineFileProperties()};this.context.errors.scope(se.PathParameters);let u=[],p=(e.pathParameters??[]).filter(w=>w.variable==null);p.length>0&&u.push(...this.getPathParameters({namedParameters:p,snippet:t})),this.context.errors.unscope(),this.context.errors.scope(se.RequestBody);let g=this.getFilePropertyInfo({request:e,snippet:t});return this.context.errors.unscope(),this.context.includePathParametersInWrappedRequest({request:e,inlinePathParameters:a})||r.push(...u.map(w=>w.value)),o||r.push(...g.fileFields.map(w=>w.value)),r.push(this.getInlinedRequestArg({request:e,snippet:t,pathParameterFields:this.context.includePathParametersInWrappedRequest({request:e,inlinePathParameters:a})?u:[],filePropertyInfo:g})),r}getFilePropertyInfo({request:e,snippet:t}){return e.body==null||!this.context.isFileUploadRequestBody(e.body)?{fileFields:[],bodyPropertyFields:[]}:this.context.filePropertyMapper.getFilePropertyInfo({body:e.body,value:t.requestBody})}getInlinedRequestArg({request:e,snippet:t,pathParameterFields:r,filePropertyInfo:a}){this.context.errors.scope(se.QueryParameters);let u=this.context.associateQueryParametersByWireValue({parameters:e.queryParameters??[],values:t.queryParameters??{}}).filter(C=>!this.context.isDirectLiteral(C.typeReference)),g=this.context.sortTypeInstancesByRequiredFirst(u,e.queryParameters??[]).map(C=>({name:this.context.getMethodName(C.name.name),value:this.context.dynamicTypeLiteralMapper.convert({typeReference:Bl(C.typeReference),value:C.value,as:"request"})}));this.context.errors.unscope(),this.context.errors.scope(se.Headers);let E=this.context.associateByWireValue({parameters:e.headers??[],values:t.headers??{}}).filter(C=>!this.context.isDirectLiteral(C.typeReference)),J=this.context.sortTypeInstancesByRequiredFirst(E,e.headers??[]).map(C=>({name:this.context.getMethodName(C.name.name),value:this.context.dynamicTypeLiteralMapper.convert({typeReference:C.typeReference,value:C.value,as:"request"})}));this.context.errors.unscope(),this.context.errors.scope(se.RequestBody);let S=e.body!=null?this.getInlinedRequestBodyBuilderParameters({body:e.body,value:t.requestBody,filePropertyInfo:a}):[];return this.context.errors.unscope(),d.TypeLiteral.builder({classReference:d.classReference({name:this.context.getClassName(e.declaration.name),packageName:this.context.getRequestsPackageName(e.declaration.fernFilepath)}),parameters:[...r,...J,...g,...S]})}getRequestOptionsArg({request:e,snippet:t}){let r="headers"in e?e.headers??[]:[];if(r.length===0||Object.keys(t.headers??{}).length===0)return;this.context.errors.scope(se.Headers);let a=this.context.associateByWireValue({parameters:r,values:t.headers??{}});if(this.context.errors.unscope(),a.length===0)return;let o=d.classReference({name:"RequestOptions",packageName:this.context.getCorePackageName()}),u=d.invokeMethod({on:o,method:"builder",arguments_:[]});for(let g of a)u=d.invokeMethod({on:u,method:"addHeader",arguments_:[d.TypeLiteral.string(g.name.wireValue),this.context.dynamicTypeLiteralMapper.convert(g)]});let p=d.invokeMethod({on:u,method:"build",arguments_:[]});return d.TypeLiteral.reference(p)}getInlinedRequestBodyBuilderParameters({body:e,value:t,filePropertyInfo:r}){switch(e.type){case"properties":return this.getInlinedRequestBodyPropertyBuilderParameters({parameters:e.value,value:t});case"referenced":return[this.getReferencedRequestBodyPropertyBuilderParameter({body:e,value:t})];case"fileUpload":return this.getFileUploadRequestBodyBuilderParameters({filePropertyInfo:r});default:M(e)}}getFileUploadRequestBodyBuilderParameters({filePropertyInfo:e}){return this.context.shouldInlineFileProperties()?[...e.fileFields,...e.bodyPropertyFields]:e.bodyPropertyFields}getReferencedRequestBodyPropertyBuilderParameter({body:e,value:t}){return{name:this.context.getMethodName(e.bodyKey),value:this.getReferencedRequestBodyPropertyTypeLiteral({body:e.bodyType,value:t})}}getReferencedRequestBodyPropertyTypeLiteral({body:e,value:t}){switch(e.type){case"bytes":return this.getBytesBodyRequestArg({value:t});case"typeReference":return this.context.dynamicTypeLiteralMapper.convert({typeReference:e.value,value:t,as:"request"});default:M(e)}}getInlinedRequestBodyPropertyBuilderParameters({parameters:e,value:t}){let a=this.context.associateByWireValue({parameters:e,values:this.context.getRecord(t)??{}}).filter(u=>!this.context.isDirectLiteral(u.typeReference));return this.context.sortTypeInstancesByRequiredFirst(a,e).map(u=>({name:this.context.getMethodName(u.name.name),value:this.context.dynamicTypeLiteralMapper.convert({typeReference:u.typeReference,value:u.value,as:"request"})}))}getPathParameters({namedParameters:e,snippet:t}){let r=[],a=this.context.associateByWireValue({parameters:e,values:t.pathParameters??{}});for(let o of a)r.push({name:this.context.getMethodName(o.name.name),value:this.context.dynamicTypeLiteralMapper.convert(o)});return r}getMethod({endpoint:e}){return e.declaration.fernFilepath.allParts.length>0?`${e.declaration.fernFilepath.allParts.map(t=>`${this.context.getMethodName(t)}()`).join(".")}.${this.context.getMethodName(e.declaration.name)}`:this.context.getMethodName(e.declaration.name)}getStyle(e){return e.style??this.context.options.style??Me.Full}getConfig(e){return e.config??this.context.options.config??{}}};var lr=class extends St{constructor({ir:t,config:r,options:a={}}){super(new or({ir:t,config:r,options:a}));_(this,"formatter")}async generate(t,r={}){return super.generate(t,r)}generateSync(t,r={}){return super.generateSync(t,r)}async generateSnippetAst(t){return super.generateSnippetAst(t)}createSnippetGenerator(t){return new ur({context:t})}};0&&(module.exports={DynamicSnippetsGenerator});
|
|
28
|
+
This prevents invalid snippet code generation that would cause formatter errors.`)}getUndiscriminatedUnionFieldName({typeReference:e}){switch(e.type){case"list":return this.getUndiscriminatedUnionFieldNameForList({list:e});case"literal":return this.getUndiscriminatedUnionFieldNameForLiteral({literal:e.value});case"map":return this.getUndiscriminatedUnionFieldNameForMap({map:e});case"named":{let t=this.context.resolveNamedType({typeId:e.value});return t==null?void 0:this.context.getClassName(t.declaration.name)}case"optional":return this.getUndiscriminatedUnionFieldNameForOptional({typeReference:e});case"nullable":return this.getUndiscriminatedUnionFieldNameForNullable({typeReference:e});case"primitive":return this.getUndiscriminatedUnionFieldNameForPrimitive({primitive:e.value});case"set":return this.getUndiscriminatedUnionFieldNameForSet({set:e});case"unknown":return"Unknown";default:M(e)}}getUndiscriminatedUnionFieldNameForList({list:e}){let t=this.getUndiscriminatedUnionFieldName({typeReference:e});if(t!=null)return`ListOf${t}`}getUndiscriminatedUnionFieldNameForMap({map:e}){let t=this.getUndiscriminatedUnionFieldName({typeReference:e.key});if(t==null)return;let r=this.getUndiscriminatedUnionFieldName({typeReference:e.value});if(r!=null)return`MapOf${t}To${r}`}getUndiscriminatedUnionFieldNameForOptional({typeReference:e}){let t=this.getUndiscriminatedUnionFieldName({typeReference:e});if(t!=null)return`Optional${t}`}getUndiscriminatedUnionFieldNameForNullable({typeReference:e}){let t=this.getUndiscriminatedUnionFieldName({typeReference:e});if(t!=null)return`Nullable${t}`}getUndiscriminatedUnionFieldNameForSet({set:e}){let t=this.getUndiscriminatedUnionFieldName({typeReference:e});if(t!=null)return`SetOf${t}`}getUndiscriminatedUnionFieldNameForLiteral({literal:e}){}getUndiscriminatedUnionFieldNameForPrimitive({primitive:e}){switch(e){case"INTEGER":case"UINT":return"Integer";case"LONG":case"UINT_64":return"Long";case"FLOAT":return"Float";case"DOUBLE":return"Double";case"BOOLEAN":return"Boolean";case"BIG_INTEGER":return"BigInteger";case"STRING":return"String";case"UUID":return"Uuid";case"DATE":return"Date";case"DATE_TIME":return"DateTime";case"BASE_64":return"Base64";default:M(e)}}convertUnknown({value:e}){return this.context.customConfig?.["generate-unknown-as-json-node"]===!0?this.convertToJsonNode({value:e}):d.TypeLiteral.unknown(e)}convertToJsonNode({value:e}){let t=d.classReference({name:"ObjectMappers",packageName:this.context.getCorePackageName()});return typeof e=="string"?d.TypeLiteral.reference(d.invokeMethod({on:d.codeblock(r=>{r.writeNode(t),r.write(".JSON_MAPPER")}),method:"valueToTree",arguments_:[d.TypeLiteral.string(e)]})):typeof e=="number"?d.TypeLiteral.reference(d.invokeMethod({on:d.codeblock(r=>{r.writeNode(t),r.write(".JSON_MAPPER")}),method:"valueToTree",arguments_:[d.TypeLiteral.integer(e)]})):typeof e=="boolean"?d.TypeLiteral.reference(d.invokeMethod({on:d.codeblock(r=>{r.writeNode(t),r.write(".JSON_MAPPER")}),method:"valueToTree",arguments_:[d.TypeLiteral.boolean(e)]})):e===null?d.TypeLiteral.reference(d.invokeMethod({on:d.codeblock(r=>{r.writeNode(t),r.write(".JSON_MAPPER")}),method:"valueToTree",arguments_:[d.TypeLiteral.raw(d.codeblock("null"))]})):Array.isArray(e)?d.TypeLiteral.reference(d.invokeMethod({on:d.codeblock(r=>{r.writeNode(t),r.write(".JSON_MAPPER")}),method:"valueToTree",arguments_:[d.TypeLiteral.list({valueType:d.Type.object(),values:e.map(r=>d.TypeLiteral.unknown(r)),isParameter:!0})]})):typeof e=="object"&&e!==null?d.TypeLiteral.reference(d.invokeMethod({on:d.codeblock(r=>{r.writeNode(t),r.write(".JSON_MAPPER")}),method:"valueToTree",arguments_:[d.TypeLiteral.unknown(e)]})):d.TypeLiteral.unknown(e)}convertPrimitive({primitive:e,value:t,as:r}){switch(e){case"INTEGER":case"UINT":{let a=this.getValueAsNumber({value:t,as:r});return a==null?d.TypeLiteral.nop():d.TypeLiteral.integer(a)}case"LONG":case"UINT_64":{let a=this.getValueAsNumber({value:t,as:r});return a==null?d.TypeLiteral.nop():d.TypeLiteral.long(a)}case"FLOAT":{let a=this.getValueAsNumber({value:t,as:r});return a==null?d.TypeLiteral.nop():d.TypeLiteral.float(a)}case"DOUBLE":{let a=this.getValueAsNumber({value:t,as:r});return a==null?d.TypeLiteral.nop():d.TypeLiteral.double(a)}case"BOOLEAN":{let a=this.getValueAsBoolean({value:t,as:r});return a==null?d.TypeLiteral.nop():d.TypeLiteral.boolean(a)}case"STRING":{let a=this.context.getValueAsString({value:t});return a==null?d.TypeLiteral.nop():d.TypeLiteral.string(a)}case"DATE":{let a=this.context.getValueAsString({value:t});return a==null?d.TypeLiteral.nop():this.context.customConfig?.["use-local-date-for-dates"]===!0?d.TypeLiteral.date(a):d.TypeLiteral.string(a)}case"DATE_TIME":{let a=this.context.getValueAsString({value:t});return a==null?d.TypeLiteral.nop():d.TypeLiteral.dateTime(a)}case"UUID":{let a=this.context.getValueAsString({value:t});return a==null?d.TypeLiteral.nop():d.TypeLiteral.uuid(a)}case"BASE_64":{let a=this.context.getValueAsString({value:t});return a==null?d.TypeLiteral.nop():d.TypeLiteral.bytes(a)}case"BIG_INTEGER":{let a=this.context.getValueAsString({value:t});return a==null?d.TypeLiteral.nop():d.TypeLiteral.bigInteger(a)}default:M(e)}}getValueAsNumber({value:e,as:t}){let r=t==="mapKey"&&typeof e=="string"?Number(e):e;return this.context.getValueAsNumber({value:r})}getValueAsBoolean({value:e,as:t}){let r=t==="mapKey"?typeof e=="string"?e==="true":e==="false"?!1:e:e;return this.context.getValueAsBoolean({value:r})}};m();y();h();var ir=class{constructor({context:e}){_(this,"context");this.context=e}convert(e){switch(e.typeReference.type){case"list":return d.Type.list(this.convert({typeReference:e.typeReference}));case"literal":return this.convertLiteral({literal:e.typeReference.value});case"map":return d.Type.map(this.convert({typeReference:e.typeReference.key}),this.convert({typeReference:e.typeReference.value}));case"named":{let t=this.context.resolveNamedType({typeId:e.typeReference.value});return t==null?this.convertUnknown():this.convertNamed({named:t})}case"optional":case"nullable":return d.Type.optional(this.convert({typeReference:e.typeReference.value}));case"primitive":return this.convertPrimitive({primitive:e.typeReference.value});case"set":return d.Type.set(this.convert({typeReference:e.typeReference}));case"unknown":return this.convertUnknown();default:M(e.typeReference)}}convertNamed({named:e}){switch(e.type){case"alias":return this.convert({typeReference:e.typeReference});case"enum":case"discriminatedUnion":case"object":case"undiscriminatedUnion":return d.Type.reference(d.classReference({name:this.context.getClassName(e.declaration.name),packageName:this.context.getTypesPackageName(e.declaration.fernFilepath)}));default:M(e)}}convertLiteral({literal:e}){switch(e.type){case"boolean":return d.Type.boolean();case"string":return d.Type.string()}}convertUnknown(){return this.context.customConfig?.["generate-unknown-as-json-node"]===!0?d.Type.reference(d.classReference({name:"JsonNode",packageName:"com.fasterxml.jackson.databind"})):d.Type.object()}convertPrimitive({primitive:e}){switch(e){case"INTEGER":return d.Type.integer();case"UINT":return d.Type.integer();case"LONG":return d.Type.long();case"UINT_64":return d.Type.long();case"FLOAT":return d.Type.float();case"DOUBLE":return d.Type.double();case"BOOLEAN":return d.Type.boolean();case"STRING":return d.Type.string();case"DATE":return d.Type.date();case"DATE_TIME":return d.Type.dateTime();case"UUID":return d.Type.uuid();case"BASE_64":return d.Type.bytes();case"BIG_INTEGER":return d.Type.bigInteger();default:M(e)}}};m();y();h();var sr=class{constructor({context:e}){_(this,"context");this.context=e}getFilePropertyInfo({body:e,value:t}){let r={fileFields:[],bodyPropertyFields:[]},a=this.context.getRecord(t)??{};for(let o of e.properties)switch(o.type){case"file":r.fileFields.push({name:this.context.getMethodName(o.name),value:this.getSingleFileProperty({property:o,record:a})});break;case"fileArray":r.fileFields.push({name:this.context.getMethodName(o.name),value:this.getArrayFileProperty({property:o,record:a})});break;case"bodyProperty":r.bodyPropertyFields.push({name:this.context.getMethodName(o.name.name),value:this.getBodyProperty({property:o,record:a})});break;default:M(o)}return r}getSingleFileProperty({property:e,record:t}){let r=this.context.getSingleFileValue({property:e,record:t});return r==null?d.TypeLiteral.nop():d.TypeLiteral.reference(this.context.getFileStreamFromString(r))}getArrayFileProperty({property:e,record:t}){let r=this.context.getFileArrayValues({property:e,record:t});if(r==null)return d.TypeLiteral.nop();for(let a of r)return d.TypeLiteral.reference(this.context.getFileStreamFromString(a));return d.TypeLiteral.nop()}getBodyProperty({property:e,record:t}){let r=t[e.name.wireValue];return r==null?d.TypeLiteral.nop():this.context.dynamicTypeLiteralMapper.convert({typeReference:e.typeReference,value:r})}};var Il=new Set(["enum","extends","package","void","short","class","abstract","return","import","for","assert","switch"]),El=new Set(["getClass","notify","notifyAll","wait"]),or=class n extends Bt{constructor({ir:t,config:r,options:a}){super({ir:t,config:r,options:a});_(this,"ir");_(this,"customConfig");_(this,"dynamicTypeMapper");_(this,"dynamicTypeLiteralMapper");_(this,"filePropertyMapper");this.ir=t,this.customConfig=Rr.parse(r.customConfig??{}),this.dynamicTypeMapper=new ir({context:this}),this.dynamicTypeLiteralMapper=new ar({context:this}),this.filePropertyMapper=new sr({context:this})}clone(){return new n({ir:this.ir,config:this.config,options:this.options})}getClassName(t){return this.getName(t.pascalCase.safeName)}getEnumName(t){return this.getName(t.screamingSnakeCase.safeName)}getPropertyName(t){return this.getName(t.camelCase.safeName)}getMethodName(t){let r=t.camelCase.safeName;return this.isReservedMethodName(r)?r+"_":this.getName(r)}getRootClientClassReference(){return d.classReference({name:this.getRootClientClassName(),packageName:this.getRootPackageName()})}getRootClientClassName(){return this.customConfig?.["client-class-name"]??`${this.getBaseNamePrefix()}Client`}getEnvironmentClassName(){return"Environment"}getEnvironmentTypeReferenceFromID(t){let r=this.resolveEnvironmentName(t);if(r!=null)return d.codeblock(a=>{a.writeNode(this.getEnvironmentClassReference()),a.write("."),a.write(this.getEnumName(r))})}getEnvironmentClassReference(){return d.classReference({name:this.getEnvironmentClassName(),packageName:this.getCorePackageName()})}getJavaClassReferenceFromDeclaration({declaration:t}){return d.classReference({name:t.name.pascalCase.unsafeName,packageName:this.getTypesPackageName(t.fernFilepath)})}getNullableClassReference(){return d.classReference({name:"Nullable",packageName:this.getCorePackageName()})}getNullableOfNull(){return d.TypeLiteral.reference(d.invokeMethod({on:this.getNullableClassReference(),method:"ofNull",arguments_:[]}))}getOptionalNullableClassReference(){return d.classReference({name:"OptionalNullable",packageName:this.getCorePackageName()})}getOptionalNullableAbsent(){return d.TypeLiteral.reference(d.invokeMethod({on:this.getOptionalNullableClassReference(),method:"absent",arguments_:[]}))}getOptionalNullableOf(t){return d.TypeLiteral.reference(d.invokeMethod({on:this.getOptionalNullableClassReference(),method:"of",arguments_:[t]}))}getFileStreamFromString(t){return d.TypeLiteral.reference(d.codeblock(r=>{r.write("new "),r.writeNode(this.getFileStreamClassReference()),r.write("("),r.writeNode(this.getByteArrayInputStreamClassReference()),r.write("("),r.writeNode(d.TypeLiteral.string(t)),r.write(".getBytes("),r.writeNode(this.getStandardCharsetsClassReference()),r.write(".UTF_8)))")}))}getFileStreamClassReference(){return d.classReference({name:"FileStream",packageName:this.getCorePackageName()})}getByteArrayInputStreamClassReference(){return d.classReference({name:"ByteArrayInputStream",packageName:"java.io"})}getStandardCharsetsClassReference(){return d.classReference({name:"StandardCharsets",packageName:"java.nio.charset"})}isPrimitive(t){switch(t.type){case"primitive":return!0;case"optional":case"nullable":return this.isPrimitive(t.value);case"named":{let r=this.resolveNamedType({typeId:t.value});if(r==null)return!1;switch(r.type){case"alias":return this.isPrimitive(r.typeReference);case"discriminatedUnion":case"undiscriminatedUnion":case"object":case"enum":return!1;default:M(r)}break}case"list":case"set":case"map":case"literal":case"unknown":return!1;default:M(t)}}isDirectLiteral(t){return t.type==="literal"}sortTypeInstancesByRequiredFirst(t,r){let a=new Map;r.forEach((p,g)=>{a.set(p.name.wireValue,g)});let o=[],u=[];for(let p of t)this.isOptional(p.typeReference)?u.push(p):o.push(p);return o.sort((p,g)=>(a.get(p.name.wireValue)??0)-(a.get(g.name.wireValue)??0)),[...o,...u]}associateByWireValue({parameters:t,values:r,ignoreMissingParameters:a}){let o=super.associateByWireValue({parameters:t,values:r,ignoreMissingParameters:a}),u=new Map;for(let g of o)u.set(g.name.wireValue,g);let p=[];for(let g of t){let w=u.get(g.name.wireValue);w!=null&&p.push(w)}return p}getRootPackageName(){let t=this.getPackagePrefixTokens();return this.joinPackageTokens(t)}getCorePackageName(){let t=this.getPackagePrefixTokens();return t.push("core"),this.joinPackageTokens(t)}getTypesPackageName(t){return this.getResourcesPackage(t,"types")}getRequestsPackageName(t){return this.getPackageLayout()==="flat"?this.getTypesPackageName(t):this.getResourcesPackage(t,"requests")}getResourcesPackage(t,r){let a=this.getPackagePrefixTokens();switch(this.getPackageLayout()){case"flat":t!=null&&a.push(...t.packagePath.map(o=>this.getPackageNameSegment(o)));break;case"nested":default:t!=null&&t.allParts.length>0&&a.push("resources"),t!=null&&a.push(...t.allParts.map(o=>this.getPackageNameSegment(o)))}return r!=null&&a.push(r),this.joinPackageTokens(a)}getPackageName(t,r){let a=this.getPackageNameSegments(t);return a=r!=null?[...a,r]:a,[...this.getPackagePrefixTokens(),...a].join(".")}getPackageLayout(){return this.customConfig?.["package-layout"]??"nested"}shouldInlinePathParameters(){return this.customConfig?.["inline-path-parameters"]??!1}shouldInlineFileProperties(){return this.customConfig?.["inline-file-properties"]??!1}getPackageNameSegments(t){return t.packagePath.map(r=>this.getPackageNameSegment(r))}getPackageNameSegment(t){return t.camelCase.safeName.toLowerCase()}getPackagePrefixTokens(){if(this.customConfig?.["package-prefix"]!=null)return this.customConfig["package-prefix"].split(".");let t=[];return t.push("com"),t.push(...this.splitOnNonAlphaNumericChar(this.config.organization)),t.push(...this.splitOnNonAlphaNumericChar(this.getApiName())),t}getBaseNamePrefix(){return this.convertKebabCaseToUpperCamelCase(this.config.organization)+this.convertKebabCaseToUpperCamelCase(this.getApiName())}getApiName(){return xr(this.config.workspaceName)}startsWithNumber(t){return/^\d/.test(t)}splitOnNonAlphaNumericChar(t){return t.split(/[^a-zA-Z0-9]/)}convertKebabCaseToUpperCamelCase(t){return t.replace(/-([a-z])/g,(r,a)=>a.toUpperCase()).replace(/^[a-z]/,r=>r.toUpperCase())}joinPackageTokens(t){return t.map(a=>this.startsWithNumber(a)?"_"+a:a).join(".")}getName(t){return this.isReservedName(t)?"_"+t:t}isReservedName(t){return Il.has(t)}isReservedMethodName(t){return El.has(t)}};m();y();h();var Ii="com.example.usage",Al="Example",Sl="main",Cl="args",Ei="client",Ll={type:"primitive",value:"STRING"};function Bl(n){if(n.type==="optional"&&n.value.type==="list"){let t=n.value.value;if(t.type==="optional")return{type:"optional",value:{type:"list",value:t.value}}}if(n.type==="list"){let e=n.value;if(e.type==="optional")return{type:"list",value:e.value}}return n}var ur=class{constructor({context:e,formatter:t}){_(this,"context");_(this,"formatter");this.context=e,this.formatter=t}async generateSnippet({endpoint:e,request:t,options:r}){let a=this.getConfig(r);return await this.buildCodeBlock({endpoint:e,snippet:t,options:r}).toStringAsync({packageName:a.fullStylePackageName??Ii,customConfig:this.context.customConfig,formatter:this.formatter})}generateSnippetSync({endpoint:e,request:t,options:r}){let a=this.getConfig(r);return this.buildCodeBlock({endpoint:e,snippet:t,options:r}).toString({packageName:a.fullStylePackageName??Ii,customConfig:this.context.customConfig,formatter:this.formatter})}async generateSnippetAst({endpoint:e,request:t,options:r}){throw new Error("Unsupported")}buildCodeBlock({endpoint:e,snippet:t,options:r}){let a=d.codeblock(u=>{u.writeNodeStatement(this.constructClient({endpoint:e,snippet:t})),u.newLine(),u.writeNodeStatement(this.callMethod({endpoint:e,snippet:t}))}),o=this.getStyle(r);switch(o){case Me.Concise:return a;case Me.Full:return this.buildFullCodeBlock({body:a,options:r});default:M(o)}}constructClient({endpoint:e,snippet:t}){let r=e.auth?.type==="oauth";return d.codeblock(a=>{if(a.writeNode(this.context.getRootClientClassReference()),a.write(` ${Ei} = `),r&&t.auth?.type==="oauth"){let o=t.auth;a.writeNode(this.context.getRootClientClassReference()),a.write(`.withCredentials("${o.clientId}", "${o.clientSecret}")`),a.writeNewLineIfLastLineNot(),a.indent();let u=this.getRootClientBuilderArgsExcludingAuth({endpoint:e,snippet:t});for(let p of u)a.write(`.${p.name}(`),p.value.shouldWriteInLine()||a.newLine(),a.writeNode(p.value),p.value.shouldWriteInLine()||a.newLine(),a.writeLine(")");a.writeLine(".build()"),a.dedent()}else a.writeNode(d.TypeLiteral.builder({classReference:this.context.getRootClientClassReference(),parameters:this.getRootClientBuilderArgs({endpoint:e,snippet:t})}))})}getRootClientBuilderArgsExcludingAuth({endpoint:e,snippet:t}){let r=[],a=this.getRootClientBaseUrlArg({baseUrl:t.baseURL,environment:t.environment});a!=null&&r.push(a),this.context.errors.scope(se.Headers),this.context.ir.headers!=null&&t.headers!=null&&r.push(...this.getRootClientHeaderArgs({headers:this.context.ir.headers,values:t.headers})),this.context.errors.unscope();let o=new Set;if([...this.context.ir.pathParameters??[],...e.request.pathParameters??[]].forEach(p=>{p.variable!=null&&o.add(p.variable)}),this.context.ir.variables!=null&&this.context.ir.variables.length>0){for(let p of this.context.ir.variables)if(o.has(p.id)){let g=p.name.camelCase.unsafeName;r.push({name:g,value:d.TypeLiteral.string(`YOUR_${p.name.screamingSnakeCase.unsafeName}`)})}}if(this.context.errors.scope(se.PathParameters),this.context.ir.pathParameters!=null&&this.context.ir.pathParameters.length>0){let p=this.context.ir.pathParameters.filter(g=>g.variable==null);p.length>0&&r.push(...this.getPathParameters({namedParameters:p,snippet:t}))}return this.context.errors.unscope(),r}buildFullCodeBlock({body:e,options:t}){let r=this.getConfig(t),a=d.class_({name:r.fullStyleClassName??Al,access:d.Access.Public}),o=d.parameter({name:Cl,type:d.Type.array(d.Type.string())});return a.addMethod(d.method({name:Sl,access:d.Access.Public,static_:!0,parameters:[o],body:e})),a}getRootClientBuilderArgs({endpoint:e,snippet:t}){let r=[];e.auth!=null&&(t.auth!=null?r.push(...this.getRootClientAuthArgs({auth:e.auth,values:t.auth})):this.context.errors.add({severity:D.Warning,message:`Auth with ${e.auth.type} configuration is required for this endpoint`}));let a=this.getRootClientBaseUrlArg({baseUrl:t.baseURL,environment:t.environment});a!=null&&r.push(a),this.context.errors.scope(se.Headers),this.context.ir.headers!=null&&t.headers!=null&&r.push(...this.getRootClientHeaderArgs({headers:this.context.ir.headers,values:t.headers})),this.context.errors.unscope();let o=new Set;if([...this.context.ir.pathParameters??[],...e.request.pathParameters??[]].forEach(p=>{p.variable!=null&&o.add(p.variable)}),this.context.ir.variables!=null&&this.context.ir.variables.length>0){for(let p of this.context.ir.variables)if(o.has(p.id)){let g=p.name.camelCase.unsafeName;r.push({name:g,value:d.TypeLiteral.string(`YOUR_${p.name.screamingSnakeCase.unsafeName}`)})}}if(this.context.errors.scope(se.PathParameters),this.context.ir.pathParameters!=null&&this.context.ir.pathParameters.length>0){let p=this.context.ir.pathParameters.filter(g=>g.variable==null);p.length>0&&r.push(...this.getPathParameters({namedParameters:p,snippet:t}))}return this.context.errors.unscope(),r}getRootClientBaseUrlArg({baseUrl:e,environment:t}){if(e!=null&&t!=null){this.context.errors.add({severity:D.Critical,message:"Cannot specify both baseUrl and environment options"});return}if(e!=null){if(this.context.ir.environments?.environments.type==="multipleBaseUrls"){this.context.errors.add({severity:D.Critical,message:"The Java SDK doesn't support a baseUrl when multiple URL environments are configured"});return}return{name:"url",value:d.TypeLiteral.string(e)}}if(t!=null){if(this.context.isSingleEnvironmentID(t)){let r=this.context.getEnvironmentTypeReferenceFromID(t);if(r==null){this.context.errors.add({severity:D.Warning,message:`Environment ${JSON.stringify(t)} was not found`});return}return{name:"environment",value:d.TypeLiteral.reference(r)}}if(this.context.isMultiEnvironmentValues(t))return this.context.validateMultiEnvironmentUrlValues(t)?{name:"environment",value:d.TypeLiteral.reference(d.instantiateClass({classReference:this.context.getEnvironmentClassReference(),arguments_:Object.values(t).map(r=>this.context.dynamicTypeLiteralMapper.convert({typeReference:Ll,value:r}))}))}:void 0}}getRootClientAuthArgs({auth:e,values:t}){if(t.type!==e.type)return this.addError(this.context.newAuthMismatchError({auth:e,values:t}).message),[];switch(e.type){case"basic":return t.type==="basic"?this.getRootClientBasicAuthArgs({auth:e,values:t}):[];case"bearer":return t.type==="bearer"?this.getRootClientBearerAuthArgs({auth:e,values:t}):[];case"header":return t.type==="header"?this.getRootClientHeaderAuthArgs({auth:e,values:t}):[];case"oauth":return t.type==="oauth"?this.getRootClientOAuthArgs({auth:e,values:t}):[];case"inferred":return this.addWarning("The Java SDK Generator does not support Inferred auth scheme yet"),[];default:M(e)}}addError(e){this.context.errors.add({severity:D.Critical,message:e})}addWarning(e){this.context.errors.add({severity:D.Warning,message:e})}getRootClientBasicAuthArgs({auth:e,values:t}){return[{name:"credentials",value:d.TypeLiteral.raw(`"${t.username}", "${t.password}"`)}]}getRootClientBearerAuthArgs({auth:e,values:t}){return[{name:this.context.getMethodName(e.token),value:d.TypeLiteral.string(t.token)}]}getRootClientHeaderAuthArgs({auth:e,values:t}){return[{name:this.context.getMethodName(e.header.name.name),value:this.context.dynamicTypeLiteralMapper.convert({typeReference:e.header.typeReference,value:t.value})}]}getRootClientOAuthArgs({auth:e,values:t}){return[{name:this.context.getMethodName(e.clientId),value:d.TypeLiteral.string(t.clientId)},{name:this.context.getMethodName(e.clientSecret),value:d.TypeLiteral.string(t.clientSecret)}]}getRootClientHeaderArgs({headers:e,values:t}){let r=[];for(let a of e){let o=this.getRootClientHeaderArg({header:a,value:t.value});o!=null&&r.push({name:this.context.getMethodName(a.name.name),value:o})}return r}getRootClientHeaderArg({header:e,value:t}){let r=this.context.dynamicTypeLiteralMapper.convert({typeReference:e.typeReference,value:t});if(!d.TypeLiteral.isNop(r))return r}callMethod({endpoint:e,snippet:t}){return d.invokeMethod({on:d.codeblock(Ei),method:this.getMethod({endpoint:e}),arguments_:this.getMethodArgs({endpoint:e,snippet:t})})}getMethodArgs({endpoint:e,snippet:t}){switch(e.request.type){case"inlined":return this.getMethodArgsForInlinedRequest({request:e.request,snippet:t});case"body":return this.getMethodArgsForBodyRequest({request:e.request,snippet:t});default:M(e.request)}}getMethodArgsForBodyRequest({request:e,snippet:t}){let r=[];this.context.errors.scope(se.PathParameters);let a=(e.pathParameters??[]).filter(u=>u.variable==null);a.length>0&&r.push(...this.getPathParameters({namedParameters:a,snippet:t}).map(u=>u.value)),this.context.errors.unscope(),this.context.errors.scope(se.RequestBody),e.body!=null&&r.push(this.getBodyRequestArg({body:e.body,value:t.requestBody})),this.context.errors.unscope();let o=this.getRequestOptionsArg({request:e,snippet:t});return o!=null&&r.push(o),r}usesOptionalNullable(){return this.context.customConfig?.["collapse-optional-nullable"]===!0}getBodyRequestArg({body:e,value:t}){switch(e.type){case"bytes":return this.getBytesBodyRequestArg({value:t});case"typeReference":{if(e.value.type==="optional"){if(t==null)return this.usesOptionalNullable()?this.context.getOptionalNullableAbsent():d.TypeLiteral.reference(d.invokeMethod({on:d.classReference({name:"Optional",packageName:"java.util"}),method:"empty",arguments_:[]}));let r=this.context.dynamicTypeLiteralMapper.convert({typeReference:e.value.value,value:t,as:"request"}),a=r.toString({packageName:"com.example",customConfig:this.context.customConfig});return a.includes("Optional.empty()")||a.includes("OptionalNullable.absent()")?r:this.usesOptionalNullable()?this.context.getOptionalNullableOf(r):d.TypeLiteral.optional({value:r,useOf:!0})}return this.context.dynamicTypeLiteralMapper.convert({typeReference:e.value,value:t,as:"request"})}default:M(e)}}getBytesBodyRequestArg({value:e}){return e==null?d.TypeLiteral.bytes(""):typeof e!="string"?(this.context.errors.add({severity:D.Critical,message:`Expected bytes value to be a string, got ${typeof e}`}),d.TypeLiteral.nop()):d.TypeLiteral.bytes(e)}getMethodArgsForInlinedRequest({request:e,snippet:t}){let r=[],{inlinePathParameters:a,inlineFileProperties:o}={inlinePathParameters:this.context.shouldInlinePathParameters(),inlineFileProperties:this.context.shouldInlineFileProperties()};this.context.errors.scope(se.PathParameters);let u=[],p=(e.pathParameters??[]).filter(w=>w.variable==null);p.length>0&&u.push(...this.getPathParameters({namedParameters:p,snippet:t})),this.context.errors.unscope(),this.context.errors.scope(se.RequestBody);let g=this.getFilePropertyInfo({request:e,snippet:t});return this.context.errors.unscope(),this.context.includePathParametersInWrappedRequest({request:e,inlinePathParameters:a})||r.push(...u.map(w=>w.value)),o||r.push(...g.fileFields.map(w=>w.value)),r.push(this.getInlinedRequestArg({request:e,snippet:t,pathParameterFields:this.context.includePathParametersInWrappedRequest({request:e,inlinePathParameters:a})?u:[],filePropertyInfo:g})),r}getFilePropertyInfo({request:e,snippet:t}){return e.body==null||!this.context.isFileUploadRequestBody(e.body)?{fileFields:[],bodyPropertyFields:[]}:this.context.filePropertyMapper.getFilePropertyInfo({body:e.body,value:t.requestBody})}getInlinedRequestArg({request:e,snippet:t,pathParameterFields:r,filePropertyInfo:a}){this.context.errors.scope(se.QueryParameters);let u=this.context.associateQueryParametersByWireValue({parameters:e.queryParameters??[],values:t.queryParameters??{}}).filter(C=>!this.context.isDirectLiteral(C.typeReference)),g=this.context.sortTypeInstancesByRequiredFirst(u,e.queryParameters??[]).map(C=>({name:this.context.getMethodName(C.name.name),value:this.context.dynamicTypeLiteralMapper.convert({typeReference:Bl(C.typeReference),value:C.value,as:"request"})}));this.context.errors.unscope(),this.context.errors.scope(se.Headers);let E=this.context.associateByWireValue({parameters:e.headers??[],values:t.headers??{}}).filter(C=>!this.context.isDirectLiteral(C.typeReference)),J=this.context.sortTypeInstancesByRequiredFirst(E,e.headers??[]).map(C=>({name:this.context.getMethodName(C.name.name),value:this.context.dynamicTypeLiteralMapper.convert({typeReference:C.typeReference,value:C.value,as:"request"})}));this.context.errors.unscope(),this.context.errors.scope(se.RequestBody);let S=e.body!=null?this.getInlinedRequestBodyBuilderParameters({body:e.body,value:t.requestBody,filePropertyInfo:a}):[];return this.context.errors.unscope(),d.TypeLiteral.builder({classReference:d.classReference({name:this.context.getClassName(e.declaration.name),packageName:this.context.getRequestsPackageName(e.declaration.fernFilepath)}),parameters:[...r,...J,...g,...S]})}getRequestOptionsArg({request:e,snippet:t}){let r="headers"in e?e.headers??[]:[];if(r.length===0||Object.keys(t.headers??{}).length===0)return;this.context.errors.scope(se.Headers);let a=this.context.associateByWireValue({parameters:r,values:t.headers??{}});if(this.context.errors.unscope(),a.length===0)return;let o=d.classReference({name:"RequestOptions",packageName:this.context.getCorePackageName()}),u=d.invokeMethod({on:o,method:"builder",arguments_:[]});for(let g of a)u=d.invokeMethod({on:u,method:"addHeader",arguments_:[d.TypeLiteral.string(g.name.wireValue),this.context.dynamicTypeLiteralMapper.convert(g)]});let p=d.invokeMethod({on:u,method:"build",arguments_:[]});return d.TypeLiteral.reference(p)}getInlinedRequestBodyBuilderParameters({body:e,value:t,filePropertyInfo:r}){switch(e.type){case"properties":return this.getInlinedRequestBodyPropertyBuilderParameters({parameters:e.value,value:t});case"referenced":return[this.getReferencedRequestBodyPropertyBuilderParameter({body:e,value:t})];case"fileUpload":return this.getFileUploadRequestBodyBuilderParameters({filePropertyInfo:r});default:M(e)}}getFileUploadRequestBodyBuilderParameters({filePropertyInfo:e}){return this.context.shouldInlineFileProperties()?[...e.fileFields,...e.bodyPropertyFields]:e.bodyPropertyFields}getReferencedRequestBodyPropertyBuilderParameter({body:e,value:t}){return{name:this.context.getMethodName(e.bodyKey),value:this.getReferencedRequestBodyPropertyTypeLiteral({body:e.bodyType,value:t})}}getReferencedRequestBodyPropertyTypeLiteral({body:e,value:t}){switch(e.type){case"bytes":return this.getBytesBodyRequestArg({value:t});case"typeReference":return this.context.dynamicTypeLiteralMapper.convert({typeReference:e.value,value:t,as:"request"});default:M(e)}}getInlinedRequestBodyPropertyBuilderParameters({parameters:e,value:t}){let a=this.context.associateByWireValue({parameters:e,values:this.context.getRecord(t)??{}}).filter(u=>!this.context.isDirectLiteral(u.typeReference));return this.context.sortTypeInstancesByRequiredFirst(a,e).map(u=>({name:this.context.getMethodName(u.name.name),value:this.context.dynamicTypeLiteralMapper.convert({typeReference:u.typeReference,value:u.value,as:"request"})}))}getPathParameters({namedParameters:e,snippet:t}){let r=[],a=this.context.associateByWireValue({parameters:e,values:t.pathParameters??{}});for(let o of a)r.push({name:this.context.getMethodName(o.name.name),value:this.context.dynamicTypeLiteralMapper.convert(o)});return r}getMethod({endpoint:e}){return e.declaration.fernFilepath.allParts.length>0?`${e.declaration.fernFilepath.allParts.map(t=>`${this.context.getMethodName(t)}()`).join(".")}.${this.context.getMethodName(e.declaration.name)}`:this.context.getMethodName(e.declaration.name)}getStyle(e){return e.style??this.context.options.style??Me.Full}getConfig(e){return e.config??this.context.options.config??{}}};var lr=class extends St{constructor({ir:t,config:r,options:a={}}){super(new or({ir:t,config:r,options:a}));_(this,"formatter")}async generate(t,r={}){return super.generate(t,r)}generateSync(t,r={}){return super.generateSync(t,r)}async generateSnippetAst(t){return super.generateSnippetAst(t)}createSnippetGenerator(t){return new ur({context:t})}};0&&(module.exports={DynamicSnippetsGenerator});
|
|
29
29
|
/*! Bundled license information:
|
|
30
30
|
|
|
31
31
|
@jspm/core/nodelibs/browser/chunk-DtuTasat.js:
|