@hey-api/openapi-ts 0.86.6 → 0.86.8
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/{getSpec-x2GCg2gS.js → getSpec-CXDbow97.js} +2 -2
- package/dist/{getSpec-x2GCg2gS.js.map → getSpec-CXDbow97.js.map} +1 -1
- package/dist/{getSpec-dCAz_woE.cjs → getSpec-dCba3-3n.cjs} +2 -2
- package/dist/{getSpec-dCAz_woE.cjs.map → getSpec-dCba3-3n.cjs.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/internal.cjs +1 -1
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +1 -1
- package/dist/run.cjs +1 -1
- package/dist/run.cjs.map +1 -1
- package/dist/run.js +1 -1
- package/dist/run.js.map +1 -1
- package/dist/{src-uVOc7K-o.js → src-Be7tT6MZ.js} +2 -2
- package/dist/{src-uVOc7K-o.js.map → src-Be7tT6MZ.js.map} +1 -1
- package/dist/{src-ZtEOUDGN.cjs → src-CrH8890n.cjs} +2 -2
- package/dist/{src-ZtEOUDGN.cjs.map → src-CrH8890n.cjs.map} +1 -1
- package/dist/{types-ComCm5zo.d.cts → types-CHvu8B2X.d.cts} +2 -2
- package/dist/{types-7_tn_FD9.d.ts → types-CxjjO0D6.d.ts} +2 -2
- package/package.json +1 -1
|
@@ -20,5 +20,5 @@ ${r}`,o.writeFileSync(e,r,`utf8`)},pl=({meta:t,outputPath:n,plugin:r,project:i})
|
|
|
20
20
|
`,t=null){if(this.isEmpty()){this.remove({force:!0});return}let n=this._path;if(typeof this._path==`string`){let e=this._path.split(s.sep);n=e.slice(0,e.length-1).join(s.sep)}v(n),o.writeFileSync(this._path,this._toString(e,t))}};const Kl=e=>{let t=e.match(/\.[0-9a-z]+$/i),n=t?t[0].slice(1):``;return{extension:n,name:e.slice(0,e.length-(n?n.length+1:0))}},ql=(e,t)=>{let n=b();if(Array.isArray(e))return e.map(e=>ql(e));if(typeof e!=`object`||!e)return e;let r={...e};return Object.entries(r).forEach(([e,i])=>{if(n.plugins[`@hey-api/schemas`]?.config.type===`form`&&[`description`,`x-enum-descriptions`,`x-enum-varnames`,`x-enumNames`,`title`].includes(e)&&t!==`properties`){delete r[e];return}e===`$ref`&&typeof i==`string`&&(r[e]=decodeURIComponent(i)),i&&typeof i==`object`&&(r[e]=ql(i,e))}),r},Jl=(e,t)=>{let n=b(),r=fr(e),i=n.plugins[`@hey-api/schemas`];return i?.config.nameBuilder?typeof i.config.nameBuilder==`function`?i.config.nameBuilder(r,t):i.config.nameBuilder.replace(`{{name}}`,r):`${r}Schema`},Yl={api:new Fl({name:`@hey-api/schemas`}),config:{exportFromIndex:!1,nameBuilder:e=>`${e}Schema`,type:`json`},handler:Wl,handlerLegacy:({files:e,openApi:t,plugin:n})=>{e.schemas=new Gl({dir:b().output.path,exportFromIndex:n.config.exportFromIndex,id:`schemas`,name:`schemas.ts`});let r=(t,n)=>{let r=ql(n),i=P.objectExpression({obj:r}),a=P.constVariable({assertion:`const`,exportConst:!0,expression:i,name:Jl(t,n)});e.schemas.add(a)};`swagger`in t&&Object.entries(t.definitions??{}).forEach(([e,t])=>{r(e,t)}),`openapi`in t&&Object.entries(t.components?.schemas??{}).forEach(([e,t])=>{r(e,t)})},name:`@hey-api/schemas`};var Xl=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const Zl=({plugin:e})=>{let t=P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:P.this(),name:`_client`}),operator:`=`,right:P.propertyAccessExpression({expression:P.identifier({text:`args`}),name:`client`})})}),n=e.referenceSymbol(e.api.selector(`Client`)),r=y(e.context.config),i=r.api&&`selector`in r.api?e.getSymbol(r.api.selector(`client`)):void 0;return[P.propertyDeclaration({initializer:i?P.identifier({text:i.placeholder}):void 0,modifier:`protected`,name:`_client`,type:P.typeReferenceNode({typeName:n.placeholder})}),P.identifier({text:`
|
|
21
21
|
`}),P.constructorDeclaration({multiLine:!0,parameters:[{isRequired:!e.config.client,name:`args`,type:P.typeInterfaceNode({properties:[{isRequired:!e.config.client,name:`client`,type:n.placeholder}],useLegacyResolution:!1})}],statements:[e.config.client?P.ifStatement({expression:P.propertyAccessExpression({expression:P.identifier({text:`args`}),isOptional:!0,name:`client`}),thenStatement:P.block({statements:[t]})}):t]})]},Ql=({plugin:e})=>{let t=y(e.context.config),n=t.name===`@hey-api/client-angular`,r=t.name===`@hey-api/client-nuxt`,i=new Map,a=new Set,o=e.config.instance?Zl({plugin:e}):[];e.forEach(`operation`,({operation:a})=>{let o=Uc({context:e.context,operation:a}),s=e.getPluginOrThrow(`@hey-api/typescript`),c=r?e.getSymbol(s.api.selector(`response`,a.id)):void 0,l=Lc({context:e.context,operation:a,plugin:e});for(let s of l.values())s.path.forEach((l,u)=>{let d=e.referenceSymbol(e.api.selector(`class`,l));i.has(d.id)||i.set(d.id,{className:l,classes:new Set,id:d.id,methods:new Set,nodes:[],root:!u});let f=s.path[u-1];if(f){let t=e.referenceSymbol(e.api.selector(`class`,f));if(t.placeholder!==d.placeholder){let e=i.get(t.id);e.classes.add(d.id),i.set(t.id,e)}}if(s.path.length!==u+1)return;let p=i.get(d.id);if(p.methods.has(s.methodName))return;let m=zc({isRequiredOptions:o,operation:a,plugin:e}),h=Vc({isRequiredOptions:o,opParameters:m,operation:a,plugin:e}),g=P.methodDeclaration({accessLevel:`public`,comment:Hc({operation:a}),isStatic:n?!1:!e.config.instance,name:s.methodName,parameters:m.parameters,returnType:void 0,statements:h,types:r?[{default:P.ots.string(`$fetch`),extends:P.typeNode(e.referenceSymbol(e.api.selector(`Composable`)).placeholder),name:Ac},{default:c?P.typeReferenceNode({typeName:c.placeholder}):P.typeNode(`undefined`),extends:c?P.typeReferenceNode({typeName:c.placeholder}):void 0,name:jc}]:[{default:(`throwOnError`in t.config?t.config.throwOnError:!1)??!1,extends:`boolean`,name:`ThrowOnError`}]});p.nodes.length?p.nodes.push(P.identifier({text:`
|
|
22
22
|
`}),g):p.nodes.push(g),p.methods.add(s.methodName),i.set(d.id,p)})},{order:`declarations`});let s=e.registerSymbol({exported:!1,meta:{path:[]},name:`_HeyApiClient`}),c=t=>{if(a.has(t.id))return;if(t.classes.size)for(let n of t.classes){let r=i.get(n);c(r),t.nodes.push(P.propertyDeclaration({initializer:e.config.instance?P.newExpression({argumentsArray:e.config.instance?[P.objectExpression({multiLine:!1,obj:[{key:`client`,value:P.propertyAccessExpression({expression:P.this(),name:`_client`})}]})]:[],expression:P.identifier({text:e.referenceSymbol(r.id).placeholder})}):P.identifier({text:e.referenceSymbol(r.id).placeholder}),modifier:e.config.instance?void 0:`static`,name:C({case:`camelCase`,value:r.className})}))}let r=e.registerSymbol({exported:!0,meta:{path:[]},name:t.className,selector:e.api.selector(`class`,t.className)}),o=P.classDeclaration({decorator:t.root&&n?{args:[{providedIn:`root`}],name:e.referenceSymbol(e.api.selector(`Injectable`)).placeholder}:void 0,exportClass:r.exported,extendedClasses:e.config.instance?[s.placeholder]:void 0,name:r.placeholder,nodes:t.nodes});e.setSymbolValue(r,o),a.add(r.id)};if(o.length){let t=P.classDeclaration({exportClass:s.exported,name:s.placeholder,nodes:o});e.setSymbolValue(s,t)}for(let e of i.values())c(e)},$l=({meta:e,onImport:t,...n})=>{if(!e)return{created:!1,name:``};let{created:r,name:i}=Ms({meta:e,...n});return i&&t(i),{created:r,name:i}},eu=e=>`${e}ModelResponseTransformer`,tu=e=>`${C({case:`PascalCase`,value:e})}Data`,nu=e=>`${C({case:`PascalCase`,value:e})}Error`,ru=e=>`${e}Transformer`,iu=e=>`${C({case:`PascalCase`,value:e})}Response`,au=({importedType:e,throwOnError:t})=>{let n=`OptionsLegacyParser`;return t?`${n}<${e||`unknown`}, ${t}>`:e?`${n}<${e}>`:n},ou=(e,t)=>{let n=b(),{name:r}=Ms({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:tu}),i=Is(t.parameters);if(!x(n))return[{isRequired:i,name:`options`,type:au({importedType:r,throwOnError:`ThrowOnError`})}];if(!t.parameters.length)return[];let a=e=>{if(e.default!==void 0)return JSON.stringify(e.default,null,4)};return n.useOptions?[{default:i?void 0:{},name:`data`,type:r}]:t.parameters.map(e=>{let t=`${r}['${e.name}']`;return{default:e?.default,isRequired:(!e.isRequired&&!a(e)?`?`:``)==``,name:e.name,type:t}})},su=(e,t)=>{let n=b(),r=P.typeNode(`void`);if(t.responses.filter(e=>e.responseTypes.includes(`success`)).length){let{name:n}=Ms({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:iu});r=P.typeUnionNode({types:[n]})}return n.useOptions&&n.plugins[`@hey-api/sdk`]?.config.response===`response`&&(r=P.typeNode(`ApiResult`,[r])),r=y(n).name===`legacy/angular`?P.typeNode(`Observable`,[r]):P.typeNode(`CancelablePromise`,[r]),r},cu=e=>{let t=b();if(!x(t))return[e.deprecated&&`@deprecated`,e.summary&&k(e.summary),e.description&&k(e.description)];let n=[];e.parameters.length&&(n=t.useOptions?[`@param data The data for the request.`,...e.parameters.map(e=>`@param data.${e.name} ${e.description?k(e.description):``}`)]:e.parameters.map(e=>`@param ${e.name} ${e.description?k(e.description):``}`));let r=e.responses.filter(e=>e.responseTypes.includes(`success`));return[e.deprecated&&`@deprecated`,e.summary&&k(e.summary),e.description&&k(e.description),...n,...r.map(e=>`@returns ${e.type} ${e.description?k(e.description):``}`),`@throws ApiError`]},lu=({client:e,onClientImport:t,onImport:n,operation:r})=>{let i=b(),a=iu(r.name),{name:o}=Ms({client:e,meta:{$ref:`transformers/${a}`,name:a},nameTransformer:ru});if(o&&n(o),!x(i)){let e=[{spread:`options`}],n=r.parameters.filter(e=>e.in===`body`||e.in===`formData`).map(e=>e.mediaType||(e.in===`formData`?`multipart/form-data`:void 0)).filter(Boolean).filter(ns);return n.length===1&&(n[0]===`multipart/form-data`&&(e=[...e,{spread:`formDataBodySerializer`},{key:`headers`,value:[{key:`Content-Type`,value:null},{spread:`options?.headers`}]}],t?.(`formDataBodySerializer`)),n[0]===`application/x-www-form-urlencoded`&&(e=[...e,{spread:`urlSearchParamsBodySerializer`},{key:`headers`,value:[{key:`Content-Type`,value:n[0]},{spread:`options?.headers`}]}],t?.(`urlSearchParamsBodySerializer`))),e=[...e,{key:`url`,value:r.path}],o&&(e=[...e,{key:`responseTransformer`,value:o}]),P.objectExpression({identifiers:[`responseTransformer`],obj:e})}let s=e=>e.reduce((e,t)=>{let n=t.prop,r=i.useOptions?`data.${t.name}`:t.name;return n===r?e[n]=n:bt(n)===n?e[n]=r:e[`'${n}'`]=r,e},{}),c={method:r.method,url:r.path};r.parametersPath.length&&(c.path=s(r.parametersPath)),r.parametersCookie.length&&(c.cookies=s(r.parametersCookie)),r.parametersHeader.length&&(c.headers=s(r.parametersHeader)),r.parametersQuery.length&&(c.query=s(r.parametersQuery)),r.parametersForm.length&&(c.formData=s(r.parametersForm)),r.parametersBody&&(r.parametersBody.in===`formData`&&(i.useOptions?c.formData=`data.${r.parametersBody.name}`:c.formData=r.parametersBody.name),r.parametersBody.in===`body`&&(i.useOptions?c.body=`data.${r.parametersBody.name}`:c.body=r.parametersBody.name)),r.parametersBody?.mediaType&&(c.mediaType=r.parametersBody?.mediaType),r.responseHeader&&(c.responseHeader=r.responseHeader),o&&(c.responseTransformer=o);let l=r.responses.filter(e=>e.responseTypes.includes(`error`));if(l.length>0){let e={};l.forEach(t=>{e[t.code]=t.description??``}),c.errors=e}return P.objectExpression({identifiers:[`body`,`cookies`,`formData`,`headers`,`path`,`query`,`responseTransformer`],obj:c,shorthand:!0})},uu=({config:e,handleIllegal:t,id:n,operation:r})=>e.plugins[`@hey-api/sdk`]?.config.methodNameBuilder?e.plugins[`@hey-api/sdk`].config.methodNameBuilder(r):t&&n.match(mt)?`${n}_`:n,du=({client:e,onClientImport:t,onImport:n,operation:r})=>{let i=b(),a=lu({client:e,onClientImport:t,onImport:n,operation:r});if(!x(i)){let t=Ms({client:e,meta:{$ref:r.name,name:r.name},nameTransformer:nu}).name,n=r.responses.filter(e=>e.responseTypes.includes(`success`)).length?Ms({client:e,meta:{$ref:r.name,name:r.name},nameTransformer:iu}).name:`void`;return[P.returnFunctionCall({args:[a],name:`(options?.client ?? client).${r.method.toLocaleLowerCase()}`,types:t&&n?[n,t,`ThrowOnError`]:t?[`unknown`,t,`ThrowOnError`]:n?[n,`unknown`,`ThrowOnError`]:[]})]}return he(i)?[P.returnFunctionCall({args:[a],name:`this.httpRequest.request`})]:y(i).name===`legacy/angular`?[P.returnFunctionCall({args:[`OpenAPI`,`this.http`,a],name:`__request`})]:[P.returnFunctionCall({args:[`OpenAPI`,a],name:`__request`})]},fu=({client:e,onClientImport:t,onImport:n,onNode:r,service:i})=>{let a=b(),o=y(a),s=x(a);for(let t of i.operations)t.parameters.length&&$l({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:tu,onImport:n}),s||$l({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:nu,onImport:n}),t.responses.filter(e=>e.responseTypes.includes(`success`)).length&&$l({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:iu,onImport:n});let c={default:(`throwOnError`in o.config?o.config.throwOnError:!1)??!1,extends:`boolean`,name:`ThrowOnError`};if(!a.plugins[`@hey-api/sdk`]?.config.asClass&&!he(a)){for(let l of i.operations){let i={parameters:ou(e,l),returnType:s?su(e,l):void 0,statements:du({client:e,onClientImport:t,onImport:n,operation:l}),types:s?void 0:[c]},u=o.name===`legacy/angular`?P.anonymousFunction(i):P.arrowFunction(i);r(P.constVariable({comment:cu(l),exportConst:!0,expression:u,name:uu({config:a,handleIllegal:!0,id:l.name,operation:l})}))}return}let l=i.operations.map(r=>P.methodDeclaration({accessLevel:`public`,comment:cu(r),isStatic:he(a)===void 0&&o.name!==`legacy/angular`,name:uu({config:a,id:r.name,operation:r}),parameters:ou(e,r),returnType:s?su(e,r):void 0,statements:du({client:e,onClientImport:t,onImport:n,operation:r}),types:s?void 0:[c]}));if(!l.length)return;he(a)?l=[P.constructorDeclaration({multiLine:!1,parameters:[{accessLevel:`public`,isReadOnly:!0,name:`httpRequest`,type:`BaseHttpRequest`}]}),...l]:o.name===`legacy/angular`&&(l=[P.constructorDeclaration({multiLine:!1,parameters:[{accessLevel:`public`,isReadOnly:!0,name:`http`,type:`HttpClient`}]}),...l]);let u=[];l.forEach((e,t)=>{t&&u.push(P.identifier({text:`
|
|
23
|
-
`})),u.push(e)}),r(P.classDeclaration({decorator:o.name===`legacy/angular`?{args:[{providedIn:`root`}],name:`Injectable`}:void 0,exportClass:!0,name:Xo({config:a,name:i.name}),nodes:u}))},pu=({client:e,files:t,plugin:n})=>{let r=b(),i=x(r);if(t.sdk=new Gl({dir:r.output.path,exportFromIndex:n.config.exportFromIndex,id:`sdk`,name:`sdk.ts`}),!i)t.sdk.import({module:cl({config:r,sourceOutput:`sdk`}),name:`createClient`}),t.sdk.import({module:cl({config:r,sourceOutput:`sdk`}),name:`createConfig`}),t.sdk.import({asType:!0,module:cl({config:r,sourceOutput:`sdk`}),name:`OptionsLegacyParser`});else if(y(r).name===`legacy/angular`?(t.sdk.import({module:`@angular/core`,name:`Injectable`}),he(r)||t.sdk.import({module:`@angular/common/http`,name:`HttpClient`}),t.sdk.import({asType:!0,module:`rxjs`,name:`Observable`})):t.sdk.import({asType:!0,module:`./core/CancelablePromise`,name:`CancelablePromise`}),r.plugins[`@hey-api/sdk`]?.config.response===`response`&&t.sdk.import({asType:!0,module:`./core/ApiResult`,name:`ApiResult`}),he(r)){let e=y(r);t.sdk.import({asType:e.name!==`legacy/angular`,module:`./core/BaseHttpRequest`,name:`BaseHttpRequest`})}else t.sdk.import({module:`./core/OpenAPI`,name:`OpenAPI`}),t.sdk.import({alias:`__request`,module:`./core/request`,name:`request`});if(!i){let e=y(r),n=P.constVariable({exportConst:!0,expression:P.callExpression({functionName:`createClient`,parameters:[P.callExpression({functionName:`createConfig`,parameters:[`throwOnError`in e&&e.throwOnError?P.objectExpression({obj:[{key:`throwOnError`,value:!0}]}):void 0]})]}),name:`client`});t.sdk.add(n)}for(let n of e.services)fu({client:e,onClientImport:e=>{t.sdk.import({module:cl({config:r,sourceOutput:`sdk`}),name:e})},onImport:e=>{t.sdk.import({asType:!e.endsWith(`Transformer`),module:`./${t.types.nameWithoutExtension()}`,name:e})},onNode:e=>{t.sdk.add(e)},service:n})},mu=({plugin:e})=>{let t=y(e.context.config),n=t.name===`@hey-api/client-nuxt`;e.forEach(`operation`,r=>{let{operation:i}=r,a=Uc({context:e.context,operation:i}),o=e.getPluginOrThrow(`@hey-api/typescript`),s=n?e.getSymbol(o.api.selector(`response`,i.id)):void 0,c=zc({isRequiredOptions:a,operation:i,plugin:e}),l=Vc({isRequiredOptions:a,opParameters:c,operation:i,plugin:e}),u=e.registerSymbol({meta:{path:r._path,tags:r.tags},name:uu({config:e.context.config,handleIllegal:!0,id:i.id,operation:i}),selector:e.api.selector(`function`,i.id)}),d=P.constVariable({comment:Hc({operation:i}),exportConst:!0,expression:P.arrowFunction({parameters:c.parameters,returnType:void 0,statements:l,types:n?[{default:P.ots.string(`$fetch`),extends:P.typeNode(e.referenceSymbol(e.api.selector(`Composable`)).placeholder),name:Ac},{default:s?P.typeReferenceNode({typeName:s.placeholder}):P.typeNode(`undefined`),extends:s?P.typeReferenceNode({typeName:s.placeholder}):void 0,name:jc}]:[{default:(`throwOnError`in t.config?t.config.throwOnError:!1)??!1,extends:`boolean`,name:`ThrowOnError`}]}),name:u.placeholder});e.setSymbolValue(u,d)},{order:`declarations`})},hu=({plugin:e})=>{let t=ll(e.context.config),n=y(e.context.config).name===`@hey-api/client-nuxt`,r=e.registerSymbol({external:t,meta:{kind:`type`,path:[]},name:`TDataShape`}),i=e.registerSymbol({external:t,meta:{kind:`type`,path:[]},name:`Client`,selector:e.api.selector(`Client`)}),a=e.registerSymbol({external:t,meta:{kind:`type`,path:[]},name:`Options`}),o=e.registerSymbol({exported:!0,meta:{kind:`type`,path:[]},name:`Options`,selector:e.api.selector(`Options`)}),s=P.typeAliasDeclaration({exportType:o.exported,name:o.placeholder,type:P.typeIntersectionNode({types:[P.typeReferenceNode({typeArguments:n?[P.typeReferenceNode({typeName:`TComposable`}),P.typeReferenceNode({typeName:`TData`}),P.typeReferenceNode({typeName:Mc}),P.typeReferenceNode({typeName:jc})]:[P.typeReferenceNode({typeName:`TData`}),P.typeReferenceNode({typeName:`ThrowOnError`})],typeName:a.placeholder}),P.typeInterfaceNode({properties:[{comment:["You can provide a client instance returned by `createClient()` instead of",`individual options. This might be also useful if you want to implement a`,`custom client.`],isRequired:!e.config.client,name:`client`,type:P.typeReferenceNode({typeName:i.placeholder})},{comment:["You can pass arbitrary values through the `meta` object. This can be",`used to access values that aren't defined as part of the SDK function.`],isRequired:!1,name:`meta`,type:P.typeReferenceNode({typeArguments:[P.keywordTypeNode({keyword:`string`}),P.keywordTypeNode({keyword:`unknown`})],typeName:`Record`})}],useLegacyResolution:!1})]}),typeParameters:n?[P.typeParameterDeclaration({constraint:P.typeReferenceNode({typeName:e.referenceSymbol(e.api.selector(`Composable`)).placeholder}),defaultType:P.typeNode(`'$fetch'`),name:`TComposable`}),P.typeParameterDeclaration({constraint:P.typeReferenceNode({typeName:r.placeholder}),defaultType:P.typeReferenceNode({typeName:r.placeholder}),name:`TData`}),P.typeParameterDeclaration({defaultType:P.keywordTypeNode({keyword:`unknown`}),name:Mc}),P.typeParameterDeclaration({defaultType:P.keywordTypeNode({keyword:`undefined`}),name:jc})]:[P.typeParameterDeclaration({constraint:P.typeReferenceNode({typeName:r.placeholder}),defaultType:P.typeReferenceNode({typeName:r.placeholder}),name:`TData`}),P.typeParameterDeclaration({constraint:P.keywordTypeNode({keyword:`boolean`}),defaultType:P.keywordTypeNode({keyword:`boolean`}),name:`ThrowOnError`})]});e.setSymbolValue(o,s)},gu=({plugin:e})=>{let t=ll(e.context.config);e.registerSymbol({external:t,name:`formDataBodySerializer`,selector:e.api.selector(`formDataBodySerializer`)}),e.registerSymbol({external:t,name:`urlSearchParamsBodySerializer`,selector:e.api.selector(`urlSearchParamsBodySerializer`)}),e.registerSymbol({external:t,name:`buildClientParams`,selector:e.api.selector(`buildClientParams`)});let n=y(e.context.config),r=n.name===`@hey-api/client-angular`;n.name===`@hey-api/client-nuxt`&&e.registerSymbol({external:t,meta:{kind:`type`},name:`Composable`,selector:e.api.selector(`Composable`)}),r&&e.config.asClass&&e.registerSymbol({external:`@angular/core`,name:`Injectable`,selector:e.api.selector(`Injectable`)}),hu({plugin:e}),e.config.asClass?Ql({plugin:e}):mu({plugin:e})},_u={api:new Xl({name:`@hey-api/sdk`}),config:{asClass:!1,auth:!0,classNameBuilder:`{{name}}`,classStructure:`auto`,client:!0,exportFromIndex:!0,instance:!1,operationId:!0,params_EXPERIMENTAL:`default`,response:`body`,responseStyle:`fields`,transformer:!1,validator:!1},dependencies:[`@hey-api/typescript`],handler:e=>gu(e),handlerLegacy:pu,name:`@hey-api/sdk`,resolveConfig:(e,t)=>{e.config.client?(typeof e.config.client==`boolean`&&(e.config.client=t.pluginByTag(`client`,{defaultPlugin:`@hey-api/client-fetch`})),e.dependencies.add(e.config.client)):e.config.client=!1,e.config.transformer?(typeof e.config.transformer==`boolean`&&(e.config.transformer=t.pluginByTag(`transformer`)),e.dependencies.add(e.config.transformer)):e.config.transformer=!1,typeof e.config.validator!=`object`&&(e.config.validator={request:e.config.validator,response:e.config.validator}),e.config.validator.request?(typeof e.config.validator.request==`boolean`&&(e.config.validator.request=t.pluginByTag(`validator`)),e.dependencies.add(e.config.validator.request)):e.config.validator.request=!1,e.config.validator.response?(typeof e.config.validator.response==`boolean`&&(e.config.validator.response=t.pluginByTag(`validator`)),e.dependencies.add(e.config.validator.response)):e.config.validator.response=!1,e.config.instance?(typeof e.config.instance!=`string`&&(e.config.instance=`Sdk`),e.config.asClass=!0):e.config.instance=!1,e.config.classNameBuilder===`{{name}}`&&e.config.client===`@hey-api/client-angular`&&(e.config.classNameBuilder=`{{name}}Service`)}};var vu=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const yu=({dataExpression:e,schema:t})=>{if(t.type!==`integer`||t.format!==`int64`)return;let n=e===void 0?void 0:P.callExpression({functionName:`BigInt`,parameters:[P.callExpression({functionName:P.propertyAccessExpression({expression:e,name:`toString`})})]});if(n){if(typeof e==`string`)return[n];if(e)return[P.assignment({left:e,right:n})]}},bu=({dataExpression:e,schema:t})=>{if(t.type!==`string`||!(t.format===`date`||t.format===`date-time`))return;let n=P.identifier({text:`Date`});if(typeof e==`string`)return[P.newExpression({argumentsArray:[P.identifier({text:e})],expression:n})];if(e)return[P.assignment({left:e,right:P.newExpression({argumentsArray:[e],expression:n})})]},xu=`data`,Su=e=>e.map(e=>l.isStatement(e)?e:P.expressionToStatement({expression:e})),Cu=({node:e})=>e.kind===l.SyntaxKind.ReturnStatement,wu=({plugin:e,schema:t})=>{let n=P.identifier({text:xu}),r=Tu({dataExpression:n,plugin:e,schema:t});return r.length&&!Cu({node:r[r.length-1]})&&r.push(P.returnStatement({expression:n})),r},Tu=({dataExpression:e,plugin:t,schema:n})=>{if(n.$ref){let r=t.api.selector(`response-ref`,n.$ref);if(!t.getSymbol(r)){let e=t.registerSymbol({name:w({config:{case:`camelCase`,name:`{{name}}SchemaResponseTransformer`},name:F(n.$ref)}),selector:r}),i=wu({plugin:t,schema:t.context.resolveIrRef(n.$ref)});if(i.length){let n=P.constVariable({expression:P.arrowFunction({async:!1,multiLine:!0,parameters:[{name:xu,type:P.keywordTypeNode({keyword:`any`})}],statements:Su(i)}),name:e.placeholder});t.setSymbolValue(e,n)}}if(t.isSymbolRegistered(r)){let n=t.referenceSymbol(r),i=P.callExpression({functionName:n.placeholder,parameters:[e]});if(e)return typeof e==`string`&&e===`item`?[P.returnStatement({expression:i})]:[typeof e==`string`?i:P.assignment({left:e,right:i})]}return[]}if(n.type===`array`){if(!e||typeof e==`string`)return[];let r=n.items?Tu({dataExpression:`item`,plugin:t,schema:n.items?.[0]?n.items[0]:{...n,type:void 0}}):[];if(!r.length)return[];let i=Su(r);return i.some(e=>Cu({node:e}))||i.push(P.returnStatement({expression:P.identifier({text:`item`})})),[P.assignment({left:e,right:P.callExpression({functionName:P.propertyAccessExpression({expression:e,name:`map`}),parameters:[P.arrowFunction({multiLine:!0,parameters:[{name:`item`,type:`any`}],statements:i})]})})]}if(n.type===`object`){let r=[],i=n.required??[];for(let a in n.properties){let o=n.properties[a],s=P.propertyAccessExpression({expression:e||xu,name:a}),c=Tu({dataExpression:s,plugin:t,schema:o});if(!c.length)continue;let l=!o.items?.find(e=>e.type===`null`);i.includes(a)&&l?r=r.concat(c):r.push(P.ifStatement({expression:s,thenStatement:P.block({statements:Su(c)})}))}return r}if(n.items){if(n.items.length===1)return Tu({dataExpression:`item`,plugin:t,schema:n.items[0]});let r=[];if(n.logicalOperator===`and`||n.items.length===2&&n.items.find(e=>e.type===`null`||e.type===`void`)){for(let i of n.items){let n=Tu({dataExpression:e||`item`,plugin:t,schema:i});if(n.length)if(e)r=r.concat(n);else{let e=P.identifier({text:`item`});r.push(P.ifStatement({expression:e,thenStatement:P.block({statements:Su(n)})}),P.returnStatement({expression:e}))}}return r}n.type!==`enum`&&((n.items??[]).every(e=>[`boolean`,`integer`,`null`,`number`,`string`].includes(e.type))||console.warn(`❗️ Transformers warning: schema ${JSON.stringify(n)} is too complex and won't be currently processed. This will likely produce an incomplete transformer which is not what you want. Please open an issue if you'd like this improved https://github.com/hey-api/openapi-ts/issues`))}for(let r of t.config.transformers){let i=r({config:t.config,dataExpression:e,schema:n});if(i)return i}return[]},Eu=({plugin:e})=>{e.forEach(`operation`,({operation:t})=>{let{response:n}=ct(t);if(!n)return;if(n.items&&n.items.length>1){e.context.config.logs.level===`debug`&&console.warn(`❗️ Transformers warning: route ${D(t)} has ${n.items.length} non-void success responses. This is currently not handled and we will not generate a response transformer. Please open an issue if you'd like this feature https://github.com/hey-api/openapi-ts/issues`);return}let r=e.getPluginOrThrow(`@hey-api/typescript`),i=e.getSymbol(r.api.selector(`response`,t.id));if(!i)return;let a=wu({plugin:e,schema:n});if(!a.length)return;let o=e.registerSymbol({exported:!0,name:w({config:{case:`camelCase`,name:`{{name}}ResponseTransformer`},name:t.id}),selector:e.api.selector(`response`,t.id)}),s=P.constVariable({exportConst:o.exported,expression:P.arrowFunction({async:!0,multiLine:!0,parameters:[{name:xu,type:P.keywordTypeNode({keyword:`any`})}],returnType:P.typeReferenceNode({typeArguments:[P.typeReferenceNode({typeName:i.placeholder})],typeName:`Promise`}),statements:Su(a)}),name:o.placeholder});e.setSymbolValue(o,s)},{order:`declarations`})},G={$refs:[],base:``,description:null,enum:[],enums:[],export:`interface`,imports:[],in:``,isDefinition:!1,isNullable:!1,isReadOnly:!1,isRequired:!1,link:null,name:``,properties:[],template:null,type:``},Du=({comments:e,leadingComment:t,meta:n,obj:r,onNode:i,...a})=>{if(!n)return;let{created:o,name:s}=Ms({create:!0,meta:n,...a});if(o){let n=b().plugins[`@hey-api/typescript`];i(P.enumDeclaration({asConst:typeof n?.config.enums==`object`&&n.config.enums.mode===`typescript-const`,comments:e,leadingComment:t,name:s,obj:r}))}},Ou=({comment:e,meta:t,onCreated:n,onNode:r,type:i,...a})=>{if(!t)return{created:!1,name:``};let o=Ms({create:!0,meta:t,...a}),{created:s,name:c}=o;return s&&(r(P.typeAliasDeclaration({comment:e,exportType:!0,name:c,type:i})),n?.(c)),o},ku=e=>{let t=[];Mu(e),e.model.enums.forEach(n=>ju({...e,model:n,onNode:e=>{t.push(e)}})),t.length&&e.onNode(P.namespaceDeclaration({name:e.model.name,statements:t}))},Au=({client:e,model:t,onNode:n})=>{let r=b(),i={},a={};t.enum.forEach(e=>{let{key:t,value:n}=ys(e);i[t]=n;let r=e.customDescription||e.description;r&&(a[t]=[k(r)])});let o=[t.description&&k(t.description),t.deprecated&&`@deprecated`],s=r.plugins[`@hey-api/typescript`];if(s?.config&&typeof s.config.enums==`object`&&s.config.enums.enabled&&(s.config.enums.mode===`typescript`||s.config.enums.mode===`typescript-const`)){Du({asConst:s.config.enums.mode===`typescript-const`,client:e,comments:a,leadingComment:o,meta:t.meta,obj:i,onNode:n});return}Ou({client:e,comment:o,meta:t.meta,onCreated:e=>{let t=r.plugins[`@hey-api/typescript`];if(t?.config&&typeof t.config.enums==`object`&&t.config.enums.enabled&&t.config.enums.mode===`javascript`){let t=P.objectExpression({multiLine:!0,obj:Object.entries(i).map(([e,t])=>({comments:a[e],key:e,value:t})),unescape:!0});n(P.constVariable({assertion:`const`,comment:o,exportConst:!0,expression:t,name:e}))}},onNode:n,type:_s(t.enum)})},ju=({model:e,onNode:t})=>{let n={},r={};e.enum.forEach(e=>{let{key:t,value:i}=ys(e);n[t]=i;let a=e.customDescription||e.description;a&&(r[t]=[k(a)])});let i=b().plugins[`@hey-api/typescript`];t(P.enumDeclaration({asConst:typeof i?.config.enums==`object`&&i.config.enums.mode===`typescript-const`,comments:r,leadingComment:[e.description&&k(e.description),e.deprecated&&`@deprecated`],name:e.meta?.name||e.name,obj:n}))},Mu=({client:e,model:t,onNode:n})=>{Ou({client:e,comment:[t.description&&k(t.description),t.deprecated&&`@deprecated`],meta:t.meta,onNode:n,type:js(t)})},Nu=e=>{switch(e.model.export){case`all-of`:case`any-of`:case`one-of`:case`interface`:return ku(e);case`enum`:return Au(e);default:return Mu(e)}},Pu=({client:e,onNode:t})=>{let n={},r=b();if(!r.plugins[`@hey-api/sdk`]&&!r.plugins[`@hey-api/typescript`]?.config.tree)return;let i=x(r);for(let r of e.services)for(let a of r.operations){if(!a.parameters.length&&!a.responses.length)continue;n[a.path]||(n[a.path]={});let r=n[a.path];r[a.method]||(r[a.method]={});let o=r[a.method];if(o.$ref=a.name,a.responses.length>0){if(o.res||={},Array.isArray(o.res))continue;a.responses.forEach(e=>{o.res[e.code]=e})}if(a.parameters.length>0){let n={mediaType:null,...G,in:`body`,name:`body`,prop:`body`},r=a.parameters.filter(e=>e.in===`body`);r.length||(r=a.parameters.filter(e=>e.in===`formData`)),r.length===1?n={...G,...r[0],in:`body`,isRequired:r[0].isRequired,name:`body`,prop:`body`}:r.length>1&&(n={...G,in:`body`,isRequired:r.some(e=>e.isRequired),mediaType:`multipart/form-data`,name:`body`,prop:`body`,properties:r});let s={...G,in:`header`,isRequired:Is(a.parameters.filter(e=>e.in===`header`)),mediaType:null,name:i?`header`:`headers`,prop:i?`header`:`headers`,properties:a.parameters.filter(e=>e.in===`header`).sort(ms)},c={...G,in:`path`,isRequired:Is(a.parameters.filter(e=>e.in===`path`)),mediaType:null,name:`path`,prop:`path`,properties:a.parameters.filter(e=>e.in===`path`).sort(ms)},l={...G,in:`query`,isRequired:Is(a.parameters.filter(e=>e.in===`query`)),mediaType:null,name:`query`,prop:`query`,properties:a.parameters.filter(e=>e.in===`query`).sort(ms)},u=i?hs([...a.parameters]):[n,s,c,l].filter(e=>e.properties.length||e.$refs.length||e.mediaType);o.req=u,Ou({client:e,meta:{$ref:a.name,name:a.name},nameTransformer:tu,onNode:t,type:js({...G,isRequired:!0,properties:u})})}let s=a.responses.filter(e=>e.responseTypes.includes(`success`));if(s.length>0){Ou({client:e,meta:{$ref:a.name,name:a.name},nameTransformer:iu,onNode:t,type:js({...G,export:`any-of`,isRequired:!0,properties:s})});let n=a.responses.filter(e=>e.responseTypes.includes(`error`));i||Ou({client:e,meta:{$ref:a.name,name:a.name},nameTransformer:nu,onNode:t,type:js(n.length?{...G,export:`one-of`,isRequired:!0,properties:n}:{...G,base:`unknown`,isRequired:!0,type:`unknown`})})}}let a=Object.entries(n).map(([t,n])=>{let r=Object.entries(n).map(([t,n])=>{let r=t,i=[];if(n.req){let t=n.$ref,{name:r}=Ms({client:e,meta:{$ref:t,name:t},nameTransformer:tu}),a={...G,base:r,export:`reference`,isRequired:!0,name:`req`,properties:[],type:r};i=[...i,a]}if(n.res){let e=Object.entries(n.res).map(([e,t])=>({...G,...t,isRequired:!0,name:String(e)})),t={...G,isRequired:!0,name:`res`,properties:e};i=[...i,t]}return{...G,isRequired:!0,name:r.toLocaleLowerCase(),properties:i}}).filter(Boolean);return{...G,isRequired:!0,name:`'${t}'`,properties:r}});r.plugins[`@hey-api/typescript`]?.config.tree&&Ou({client:e,meta:{$ref:`@hey-api/openapi-ts`,name:`$OpenApiTs`},onNode:t,type:js({...G,properties:a})})},Fu=({client:e,files:t,plugin:n})=>{t.types=new Gl({dir:b().output.path,exportFromIndex:n.config.exportFromIndex,id:`types`,name:`types.ts`});let r=e=>{t.types?.add(e)};for(let t of e.models)Nu({client:e,model:t,onNode:r});Pu({client:e,onNode:r})},Iu=`data`,Lu=e=>e.base===`unknown`&&e.export===`generic`&&e.type===`unknown`,Ru=({client:e,model:t})=>t.$refs.map(t=>{let n=e.models.find(e=>e.meta?.$ref===t);if(!n)throw Error(`Ref ${t} could not be found. Transformers cannot be generated without having access to all refs.`);return n}),zu=e=>{let t=e.model.meta.name,{name:n}=Ou({...e,meta:{$ref:`transformers/${t}`,name:t},nameTransformer:eu,onCreated:n=>{let r=Hu({...e,meta:{$ref:`transformers/${t}`,name:n},path:[Iu]});Uu({...e,async:!1,name:n,statements:r})},type:`(${Iu}: any) => ${t}`});return{created:!!e.client.types[n],name:n}},Bu=e=>{let{model:t}=e,n=Ru(e);if(n.length===1){let{created:t,name:r}=zu({...e,model:n[0]});return t?[P.transformArrayMutation({path:e.path,transformerName:r})]:[]}return Cs(t)||t.link&&!Array.isArray(t.link)&&t.link.export===`any-of`&&t.link.properties.find(e=>Cs(e))?[P.transformArrayMap({path:e.path,transformExpression:P.conditionalExpression({condition:P.identifier({text:`item`}),whenFalse:P.identifier({text:`item`}),whenTrue:P.transformNewDate({parameterName:`item`})})})]:[]},Vu=e=>{let{model:t}=e,n=[...e.path,t.name];return t.type===`string`&&t.export!==`array`&&Cs(t)?[P.transformDateMutation({path:n})]:Hu({...e,model:t,path:n})},Hu=e=>{let{model:t}=e;switch(t.export){case`array`:return Bu(e);case`interface`:return t.properties.flatMap(t=>Vu({...e,model:t}));case`reference`:{if(t.$refs.length!==1)return[];let n=Ru(e),{created:r,name:i}=zu({...e,model:n[0]});return r?t.in===`response`?[P.expressionToStatement({expression:P.callExpression({functionName:i,parameters:[Iu]})})]:P.transformFunctionMutation({path:e.path,transformerName:i}):[]}default:return[]}},Uu=({async:e,client:t,name:n,onNode:r,onRemoveNode:i,statements:a})=>{let o={created:!1,name:n};if(!a.length)return Ns({client:t,name:n}),i?.(),o;let s=P.arrowFunction({async:e,multiLine:!0,parameters:[{name:Iu}],statements:[...a,P.returnVariable({expression:Iu})]});return r(P.constVariable({exportConst:!0,expression:s,name:n,typeName:n})),{created:!0,name:n}},Wu={api:new vu({name:`@hey-api/transformers`}),config:{bigInt:!0,dates:!0,exportFromIndex:!1,transformers:[],typeTransformers:[]},dependencies:[`@hey-api/typescript`],handler:Eu,handlerLegacy:({client:e,files:t})=>{let n=b(),r=e=>{t.types?.add(e)},i=()=>{t.types?.removeNode_LEGACY()};for(let t of e.services)for(let a of t.operations){let t=a.responses.filter(e=>e.responseTypes.includes(`success`));if(!t.length)continue;let o=t.filter(e=>!Lu(e));if(!o.length)continue;if(o.length>1){n.logs.level===`debug`&&console.warn(`❗️ Transformers warning: route ${D(a)} has ${o.length} non-void success responses. This is currently not handled and we will not generate a response transformer. Please open an issue if you'd like this feature https://github.com/hey-api/openapi-ts/issues`);continue}let s=iu(a.name);Ou({client:e,meta:{$ref:`transformers/${s}`,name:s},nameTransformer:ru,onCreated:n=>{Uu({async:!0,client:e,name:n,onNode:r,onRemoveNode:i,statements:t.length>1?t.flatMap(t=>{let n=Hu({client:e,meta:{$ref:`transformers/${s}`,name:s},model:t,onNode:r,onRemoveNode:i,path:[Iu]});return n.length?[P.ifStatement({expression:P.safeAccessExpression([`data`]),thenStatement:P.block({statements:n})})]:[]}):Hu({client:e,meta:{$ref:`transformers/${s}`,name:s},model:t[0],onNode:r,onRemoveNode:i,path:[Iu]})})},onNode:r,type:`(${Iu}: any) => Promise<${s}>`})}},name:`@hey-api/transformers`,resolveConfig:e=>{e.config.transformers||(e.config.transformers=[]),e.config.dates&&(e.config.transformers=[...e.config.transformers,bu]),e.config.bigInt&&(e.config.transformers=[...e.config.transformers,yu])},tags:[`transformer`]},K=e=>({value:e}),q=e=>{let t={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=K(e[n]));return t},Gu=P.keywordTypeNode({keyword:`string`}),Ku=({server:e})=>{let t=ua(e.url);return t.protocol&&t.host?P.literalTypeNode({literal:P.stringLiteral({text:e.url})}):P.templateLiteralType({value:[t.protocol||Gu,`://`,t.host||Gu,t.port?`:${t.port}`:``,t.path||``]})},qu=({plugin:e,servers:t,symbolClientOptions:n})=>{let r=y(e.context.config),i=t.map(e=>Ku({server:e}));t.length?`strictBaseUrl`in r.config&&r.config.strictBaseUrl||i.push(P.typeIntersectionNode({types:[Gu,l.factory.createTypeLiteralNode([])]})):i.push(Gu);let a=P.typeInterfaceNode({properties:[{name:fe(e.context.config),type:P.typeUnionNode({types:i})}],useLegacyResolution:!1}),o=P.typeAliasDeclaration({exportType:n.exported,name:n.placeholder,type:a});e.setSymbolValue(n,o)},Ju=({schema:e})=>{let t=[];return e.title&&t.push(k(e.title)),e.description&&(t.length&&t.push(``),t.push(k(e.description))),e.deprecated&&(t.length&&t.push(``),t.push(`@deprecated`)),t.length?t:void 0},Yu=({plugin:e,schema:t})=>{let n=[];return{obj:(t.items??[]).map((t,r)=>{let i=typeof t.const;n.includes(i)||n.push(i);let a;return a=t.title?t.title:i===`number`||i===`string`?`${t.const}`:i===`boolean`?t.const?`true`:`false`:t.const===null?`null`:`${r}`,a&&(a=C({case:e.config.enums.case,stripLeadingSeparators:!1,value:a}),O.lastIndex=0,O.test(a)&&e.config.enums.enabled&&(e.config.enums.mode===`typescript`||e.config.enums.mode===`typescript-const`)&&(a=`_${a}`)),{comments:Ju({schema:t}),key:a,value:t.const}}),typeofItems:n}},Xu=({plugin:e,schema:t,symbol:n,type:r})=>{if(t.type===`enum`&&e.config.enums.enabled){let r=Yu({plugin:e,schema:t});if(e.config.enums.mode===`javascript`){e.config.enums.constantsIgnoreNull&&r.typeofItems.includes(`object`)&&(r.obj=r.obj.filter(e=>e.value!==null));let i=P.constVariable({assertion:`const`,comment:Ju({schema:t}),exportConst:!0,expression:P.objectExpression({multiLine:!0,obj:r.obj}),name:n.placeholder}),a=P.typeOfExpression({text:n.placeholder}),o=P.typeAliasDeclaration({comment:Ju({schema:t}),exportType:!0,name:n.placeholder,type:P.indexedAccessTypeNode({indexType:P.typeOperatorNode({operator:`keyof`,type:a}),objectType:a})});e.setSymbolValue(n,[i,o]);return}else if((e.config.enums.mode===`typescript`||e.config.enums.mode===`typescript-const`)&&!r.typeofItems.some(e=>e!==`number`&&e!==`string`)){let i=P.enumDeclaration({asConst:e.config.enums.mode===`typescript-const`,leadingComment:Ju({schema:t}),name:n.placeholder,obj:r.obj});e.setSymbolValue(n,i);return}}let i=P.typeAliasDeclaration({comment:Ju({schema:t}),exportType:n.exported,name:n.placeholder,type:r});e.setSymbolValue(n,i)},Zu=({parameters:e})=>{let t={type:`object`};if(e){let n={},r=[];for(let t in e){let i=e[t];n[i.name]=T({detectFormat:!1,schema:i.schema}),i.required&&r.push(i.name)}t.properties=n,r.length&&(t.required=r)}return t},Qu=({operation:e,plugin:t,state:n})=>{let r={type:`object`},i=[];r.properties||={},e.body?(r.properties.body=e.body.schema,e.body.required&&i.push(`body`)):r.properties.body={type:`never`},e.parameters?.header&&(r.properties.headers=Zu({parameters:e.parameters.header}),r.properties.headers.required&&i.push(`headers`)),e.parameters?.path?(r.properties.path=Zu({parameters:e.parameters.path}),r.properties.path.required&&i.push(`path`)):r.properties.path={type:`never`},e.parameters?.query?(r.properties.query=Zu({parameters:e.parameters.query}),r.properties.query.required&&i.push(`query`)):r.properties.query={type:`never`},r.properties.url={const:e.path,type:`string`},i.push(`url`),r.required=i;let a=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:w({config:t.config.requests,name:e.id}),selector:t.api.selector(`data`,e.id)}),o=J({plugin:t,schema:r,state:n}),s=P.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:o});t.setSymbolValue(a,s)},$u=({operation:e,plugin:t,state:n})=>{Qu({operation:e,plugin:t,state:n});let{error:r,errors:i,response:a,responses:o}=ct(e);if(i){let a=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:w({config:t.config.errors,name:e.id}),selector:t.api.selector(`errors`,e.id)}),o=J({plugin:t,schema:i,state:n}),s=P.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:o});if(t.setSymbolValue(a,s),r){let r=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:w({config:{case:t.config.errors.case,name:t.config.errors.error},name:e.id}),selector:t.api.selector(`error`,e.id)}),i=P.indexedAccessTypeNode({indexType:P.typeOperatorNode({operator:`keyof`,type:P.typeReferenceNode({typeName:a.placeholder})}),objectType:P.typeReferenceNode({typeName:a.placeholder})}),o=P.typeAliasDeclaration({exportType:r.exported,name:r.placeholder,type:i});t.setSymbolValue(r,o)}}if(o){let r=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:w({config:t.config.responses,name:e.id}),selector:t.api.selector(`responses`,e.id)}),i=J({plugin:t,schema:o,state:n}),s=P.typeAliasDeclaration({exportType:r.exported,name:r.placeholder,type:i});if(t.setSymbolValue(r,s),a){let i=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:w({config:{case:t.config.responses.case,name:t.config.responses.response},name:e.id}),selector:t.api.selector(`response`,e.id)}),a=P.indexedAccessTypeNode({indexType:P.typeOperatorNode({operator:`keyof`,type:P.typeReferenceNode({typeName:r.placeholder})}),objectType:P.typeReferenceNode({typeName:r.placeholder})}),o=P.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:a});t.setSymbolValue(i,o)}}},ed=({operation:e,plugin:t,state:n})=>{let r={type:`object`},i=[];if(r.properties||={},e.body){let a=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:w({config:{case:t.config.webhooks.case,name:t.config.webhooks.payload},name:e.id}),selector:t.api.selector(`webhook-payload`,e.id)}),o=J({plugin:t,schema:e.body.schema,state:n}),s=P.typeAliasDeclaration({comment:Ju({schema:e.body.schema}),exportType:a.exported,name:a.placeholder,type:o});t.setSymbolValue(a,s),t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:a.name,placeholder:a.placeholder,selector:t.api.selector(`ref`,a.placeholder)}),r.properties.body={$ref:a.placeholder},i.push(`body`)}else r.properties.body={type:`never`};r.properties.key={const:e.path,type:`string`},i.push(`key`),r.properties.path={type:`never`},r.properties.query={type:`never`},r.required=i;let a=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:w({config:t.config.webhooks,name:e.id}),selector:t.api.selector(`webhook-request`,e.id)}),o=J({plugin:t,schema:r,state:n}),s=P.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:o});return t.setSymbolValue(a,s),a.placeholder},td=({operation:e,plugin:t,state:n})=>ed({operation:e,plugin:t,state:n}),nd=({plugin:e,symbolWebhooks:t,webhookNames:n})=>{if(!n.length)return;let r=P.typeUnionNode({types:n.map(e=>P.typeReferenceNode({typeName:e}))}),i=P.typeAliasDeclaration({exportType:t.exported,name:t.placeholder,type:r});e.setSymbolValue(t,i)},rd=({plugin:e,schema:t,state:n})=>{if(!t.items)return P.typeArrayNode(P.keywordTypeNode({keyword:e.config.topType}));t=T({detectFormat:!0,schema:t});let r=[];return t.items&&t.items.forEach((t,i)=>{let a=J({plugin:e,schema:t,state:{...n,path:K([...n.path.value,`items`,i])}});r.push(a)}),r.length===1?P.typeArrayNode(r[0]):t.logicalOperator===`and`?P.typeArrayNode(P.typeIntersectionNode({types:r})):P.typeArrayNode(P.typeUnionNode({types:r}))},id=({schema:e})=>e.const===void 0?P.keywordTypeNode({keyword:`boolean`}):P.literalTypeNode({literal:P.ots.boolean(e.const)}),ad=({plugin:e,schema:t,state:n})=>J({plugin:e,schema:{...t,type:void 0},state:n}),od=e=>P.keywordTypeNode({keyword:`never`}),sd=e=>P.literalTypeNode({literal:P.null()}),cd=({plugin:e,schema:t})=>t.const===void 0?t.type===`integer`&&t.format===`int64`&&e.getPlugin(`@hey-api/transformers`)?.config.bigInt?P.typeReferenceNode({typeName:`bigint`}):P.keywordTypeNode({keyword:`number`}):P.literalTypeNode({literal:P.ots.number(t.const)}),ld=({context:e,name:t})=>(O.lastIndex=0,O.test(t)?t.startsWith(`-`)?l.factory.createStringLiteral(t):l.factory.createNumericLiteral(t):C({case:e.config.output.case,value:t})),ud=({plugin:e,schema:t,state:n})=>{let r,i,a=[],o=[],s=t.required??[],c=!1;for(let r in t.properties){let i=t.properties[r],l=J({plugin:e,schema:i,state:{...n,path:K([...n.path.value,`properties`,r])}}),u=s.includes(r);a.push({comment:Ju({schema:i}),isReadOnly:i.accessScope===`read`,isRequired:u,name:ld({context:e.context,name:r}),type:l}),o.push(i),u||(c=!0)}if(t.patternProperties)for(let e in t.patternProperties){let n=t.patternProperties[e];o.unshift(n)}let l=!!t.patternProperties&&Object.keys(t.patternProperties).length>0,u=t.additionalProperties,d=u!==!1&&u?u:void 0;if(l||d&&(d.type!==`never`||!o.length)){let a=d;a&&a.type!==`never`?o.unshift(a):!l&&!o.length&&a&&a.type===`never`&&(o=[a]),c&&o.push({type:`undefined`}),i={isRequired:!t.propertyNames,name:`key`,type:o.length===1?J({plugin:e,schema:o[0],state:n}):J({plugin:e,schema:{items:o,logicalOperator:`or`},state:n})},t.propertyNames?.$ref&&(r=J({plugin:e,schema:{$ref:t.propertyNames.$ref},state:n}))}return P.typeInterfaceNode({indexKey:r,indexProperty:i,properties:a,useLegacyResolution:!1})},dd=({plugin:e,schema:t})=>{if(t.const!==void 0)return P.literalTypeNode({literal:P.stringLiteral({text:t.const})});if(t.format){if(t.format===`binary`)return P.typeUnionNode({types:[P.typeReferenceNode({typeName:`Blob`}),P.typeReferenceNode({typeName:`File`})]});if((t.format===`date-time`||t.format===`date`)&&e.getPlugin(`@hey-api/transformers`)?.config.dates)return P.typeReferenceNode({typeName:`Date`});if(t.format===`typeid`&&typeof t.example==`string`){let n=String(t.example).split(`_`);n.pop();let r=n.join(`_`),i=e.api.selector(`TypeID`,r);if(!e.getSymbol(i)){let t=e.api.selector(`TypeID`);if(!e.getSymbol(t)){let n=e.registerSymbol({exported:!0,meta:{kind:`type`,path:[]},name:`TypeID`,selector:t}),r=P.typeAliasDeclaration({exportType:n.exported,name:n.placeholder,type:P.templateLiteralType({value:[P.typeReferenceNode({typeName:`T`}),`_`,P.keywordTypeNode({keyword:`string`})]}),typeParameters:[P.typeParameterDeclaration({constraint:P.keywordTypeNode({keyword:`string`}),name:`T`})]});e.setSymbolValue(n,r)}let n=e.referenceSymbol(t),a=e.registerSymbol({exported:!0,meta:{kind:`type`,path:[]},name:C({case:e.config.case,value:`${r}_id`}),selector:i}),o=P.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:P.typeReferenceNode({typeArguments:[P.literalTypeNode({literal:P.stringLiteral({text:r})})],typeName:n.placeholder})});e.setSymbolValue(a,o)}let a=e.referenceSymbol(i);return P.typeReferenceNode({typeName:a.placeholder})}}return P.keywordTypeNode({keyword:`string`})},fd=({plugin:e,schema:t,state:n})=>{let r=[];return t.const&&Array.isArray(t.const)?r=t.const.map(t=>P.valueToExpression({value:t})??P.identifier({text:e.config.topType})):t.items&&t.items.forEach((t,i)=>{let a=J({plugin:e,schema:t,state:{...n,path:K([...n.path.value,`items`,i])}});r.push(a)}),P.typeTupleNode({types:r})},pd=e=>P.keywordTypeNode({keyword:`undefined`}),md=({plugin:e})=>P.keywordTypeNode({keyword:e.config.topType}),hd=e=>P.keywordTypeNode({keyword:`void`}),gd=({schema:e,...t})=>{let n=t.plugin.getPlugin(`@hey-api/transformers`);if(n?.config.typeTransformers)for(let t of n.config.typeTransformers){let n=t({schema:e});if(n)return n}switch(e.type){case`array`:return rd({...t,schema:e});case`boolean`:return id({...t,schema:e});case`enum`:return ad({...t,schema:e});case`integer`:case`number`:return cd({...t,schema:e});case`never`:return od({...t,schema:e});case`null`:return sd({...t,schema:e});case`object`:return ud({...t,schema:e});case`string`:return dd({...t,schema:e});case`tuple`:return fd({...t,schema:e});case`undefined`:return pd({...t,schema:e});case`unknown`:return md({...t,schema:e});case`void`:return hd({...t,schema:e})}},J=({plugin:e,schema:t,state:n})=>{if(t.$ref){let n=e.referenceSymbol(e.api.selector(`ref`,t.$ref));return P.typeReferenceNode({typeName:n.placeholder})}if(t.type)return gd({plugin:e,schema:t,state:n});if(t.items){if(t=T({detectFormat:!1,schema:t}),t.items){let r=[];for(let i of t.items){let t=J({plugin:e,schema:i,state:n});r.push(t)}return t.logicalOperator===`and`?P.typeIntersectionNode({types:r}):P.typeUnionNode({types:r})}return J({plugin:e,schema:t,state:n})}return gd({plugin:e,schema:{type:`unknown`},state:n})},_d=({plugin:e,schema:t,state:n})=>{let r=J({plugin:e,schema:t,state:n}),i=t.type===`enum`&&e.config.enums.enabled,a=or(n.path.value);Xu({plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{kind:i?void 0:`type`,path:n.path.value,tags:n.tags?.value},name:w({config:e.config.definitions,name:F(a)}),selector:e.api.selector(`ref`,a)}),type:r})},vd=({plugin:e})=>{let t=e.registerSymbol({exported:!0,meta:{kind:`type`,path:[]},name:w({config:{case:e.config.case},name:`ClientOptions`}),selector:e.api.selector(`ClientOptions`)}),n=e.registerSymbol({exported:!0,meta:{kind:`type`,path:[]},name:w({config:{case:e.config.case},name:`Webhooks`}),selector:e.api.selector(`Webhooks`)}),r=[],i=[];e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`server`,`webhook`,t=>{let n=q({path:t._path,tags:t.tags});switch(t.type){case`operation`:$u({operation:t.operation,plugin:e,state:n});break;case`parameter`:_d({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:_d({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:_d({plugin:e,schema:t.schema,state:n});break;case`server`:r.push(t.server);break;case`webhook`:i.push(td({operation:t.operation,plugin:e,state:n}));break}},{order:`declarations`}),qu({plugin:e,servers:r,symbolClientOptions:t}),nd({plugin:e,symbolWebhooks:n,webhookNames:i})},yd={api:new class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}schemaToType(e){return J(e)}}({name:`@hey-api/typescript`}),config:{case:`PascalCase`,exportFromIndex:!0,style:`preserve`,topType:`unknown`,tree:!1},handler:e=>vd(e),handlerLegacy:Fu,name:`@hey-api/typescript`,resolveConfig:(e,t)=>{e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,name:`{{name}}`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.config.definitions}),e.config.enums=t.valueToObject({defaultValue:{case:`SCREAMING_SNAKE_CASE`,constantsIgnoreNull:!1,enabled:!!e.config.enums,mode:`javascript`},mappers:{boolean:e=>({enabled:e}),string:e=>({mode:e})},value:e.config.enums}),e.config.errors=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,error:`{{name}}Error`,name:`{{name}}Errors`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.config.errors}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,name:`{{name}}Data`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,name:`{{name}}Responses`,response:`{{name}}Response`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.config.responses}),e.config.webhooks=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,name:`{{name}}WebhookRequest`,payload:`{{name}}WebhookPayload`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.config.webhooks})}};var bd=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const xd=(e,t,n)=>{let r=e.config[n].meta;if(!r)return;let i=r(t);if(Object.keys(i).length)return P.valueToExpression({value:i})},Sd=({operation:e,plugin:t})=>Rc({operation:e,plugin:t.getPluginOrThrow(`@hey-api/sdk`)}),Cd=({operation:e,plugin:t})=>{let n=y(t.context.config),r=t.getPluginOrThrow(`@hey-api/typescript`),i=t.getSymbol(r.api.selector(`error`,e.id))?.placeholder;return i||=`Error`,n.name===`@hey-api/client-axios`&&(i=`${t.referenceSymbol(t.api.selector(`AxiosError`)).placeholder}<${i}>`),i},wd=({operation:e,plugin:t})=>{let n=t.getPluginOrThrow(`@hey-api/typescript`);return t.getSymbol(n.api.selector(`response`,e.id))?.placeholder||`unknown`},Td=({plugin:e,typeData:t})=>{let n=y(e.context.config).name===`@hey-api/client-nuxt`;return{isNuxtClient:n,strippedTypeData:n?`Omit<${t}, 'composable'>`:t}},Ed=({operation:e,plugin:t,queryFn:n})=>{let r=t.referenceSymbol(t.api.selector(`UseMutationOptions`)),i=Sd({operation:e,plugin:t}),a=Cd({operation:e,plugin:t}),o=wd({operation:e,plugin:t}),{isNuxtClient:s,strippedTypeData:c}=Td({plugin:t,typeData:i}),l=s?`${r.placeholder}<${o}, ${c}, ${a}>`:`${r.placeholder}<${o}, ${i}, ${a}>`,u=`fnOptions`,d=P.awaitExpression({expression:P.callExpression({functionName:n,parameters:[P.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:u},{key:`throwOnError`,value:!0}]})]})}),f=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?f.push(P.returnVariable({expression:d})):f.push(P.constVariable({destructure:!0,expression:d,name:`data`}),P.returnVariable({expression:`data`}));let p=[{key:`mutation`,value:P.arrowFunction({async:!0,multiLine:!0,parameters:[s?{name:u,type:`Partial<${c}>`}:{name:u}],statements:f})}],m=xd(t,e,`mutationOptions`);m&&p.push({key:`meta`,value:m});let h=t.registerSymbol({exported:!0,name:w({config:t.config.mutationOptions,name:e.id})}),g=P.constVariable({comment:t.config.comments?Hc({operation:e}):void 0,exportConst:h.exported,expression:P.arrowFunction({parameters:[{isRequired:!1,name:`options`,type:`Partial<${c}>`}],returnType:l,statements:[P.returnStatement({expression:P.objectExpression({obj:p})})]}),name:h.placeholder});t.setSymbolValue(h,g)},Dd=`TOptions`,Od=P.identifier({text:`options`}),kd=({plugin:e})=>{let t=e.registerSymbol({name:w({config:{case:e.config.case},name:`createQueryKey`}),selector:e.api.selector(`createQueryKey`)}),n=e.referenceSymbol(e.api.selector(`QueryKey`)),r=e.referenceSymbol(e.api.selector(`_JSONValue`)),i=P.indexedAccessTypeNode({indexType:P.literalTypeNode({literal:P.ots.number(0)}),objectType:P.typeReferenceNode({typeArguments:[P.typeReferenceNode({typeName:Dd})],typeName:n.placeholder})}),a=fe(e.context.config),o=e.getPluginOrThrow(`@hey-api/sdk`),s=e.referenceSymbol(o.api.selector(`Options`)),c=y(e.context.config),l=c.api&&`selector`in c.api?e.getSymbol(c.api.selector(`client`)):void 0,u=ll(e.context.config),d=e.registerSymbol({external:u,name:`serializeQueryKeyValue`}),f=P.constVariable({expression:P.arrowFunction({multiLine:!0,parameters:[{name:`id`,type:P.typeReferenceNode({typeName:`string`})},{isRequired:!1,name:`options`,type:P.typeReferenceNode({typeName:Dd})},{isRequired:!1,name:`tags`,type:P.typeReferenceNode({typeName:`ReadonlyArray<string>`})}],returnType:P.typeTupleNode({types:[i]}),statements:[P.constVariable({assertion:i,expression:P.objectExpression({multiLine:!1,obj:[{key:`_id`,value:P.identifier({text:`id`})},{key:a,value:P.identifier({text:`options?.${a} || (options?.client ?? ${l?.placeholder}).getConfig().${a}`})}]}),name:`params`,typeName:i}),P.ifStatement({expression:P.identifier({text:`tags`}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`tags`}),right:P.asExpression({expression:P.asExpression({expression:P.identifier({text:`tags`}),type:P.keywordTypeNode({keyword:`unknown`})}),type:P.typeReferenceNode({typeName:r.placeholder})})})})]})}),P.ifStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:Od,isOptional:!0,name:P.identifier({text:`body`})}),operator:`!==`,right:`undefined`}),thenStatement:P.block({statements:[P.constVariable({expression:P.callExpression({functionName:d.placeholder,parameters:[P.propertyAccessExpression({expression:`options`,name:`body`})]}),name:`normalizedBody`}),P.ifStatement({expression:P.binaryExpression({left:P.identifier({text:`normalizedBody`}),operator:`!==`,right:`undefined`}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`body`}),right:P.identifier({text:`normalizedBody`})})})]})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:Od,isOptional:!0,name:P.identifier({text:`path`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`path`}),right:P.propertyAccessExpression({expression:`options`,name:`path`})})})]})}),P.ifStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:Od,isOptional:!0,name:P.identifier({text:`query`})}),operator:`!==`,right:`undefined`}),thenStatement:P.block({statements:[P.constVariable({expression:P.callExpression({functionName:d.placeholder,parameters:[P.propertyAccessExpression({expression:`options`,name:`query`})]}),name:`normalizedQuery`}),P.ifStatement({expression:P.binaryExpression({left:P.identifier({text:`normalizedQuery`}),operator:`!==`,right:`undefined`}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`query`}),right:P.identifier({text:`normalizedQuery`})})})]})})]})}),P.returnStatement({expression:P.arrayLiteralExpression({elements:[P.identifier({text:`params`})]})})],types:[{extends:P.typeReferenceNode({typeName:P.identifier({text:s.placeholder})}),name:Dd}]}),name:t.placeholder});e.setSymbolValue(t,f)},Ad=({id:e,operation:t,plugin:n})=>{let r=n.config.queryKeys,i;r.tags&&t.tags&&t.tags.length>0&&(i=P.arrayLiteralExpression({elements:t.tags.map(e=>P.stringLiteral({text:e}))}));let a=n.referenceSymbol(n.api.selector(`createQueryKey`));return P.callExpression({functionName:a.placeholder,parameters:[P.ots.string(e),`options`,i]})},jd=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`_JSONValue`)),n=[{name:`_id`,type:P.keywordTypeNode({keyword:`string`})},{isRequired:!1,name:fe(e.context.config),type:P.typeReferenceNode({typeName:t.placeholder})},{isRequired:!1,name:`body`,type:P.typeReferenceNode({typeName:t.placeholder})},{isRequired:!1,name:`query`,type:P.typeReferenceNode({typeName:t.placeholder})},{isRequired:!1,name:`tags`,type:P.typeReferenceNode({typeName:t.placeholder})}],r=e.getPluginOrThrow(`@hey-api/sdk`),i=e.referenceSymbol(r.api.selector(`Options`)),a=e.registerSymbol({exported:!0,meta:{kind:`type`},name:`QueryKey`,selector:e.api.selector(`QueryKey`)}),o=P.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:P.typeTupleNode({types:[P.typeIntersectionNode({types:[P.typeReferenceNode({typeName:`Pick<${Dd}, 'path'>`}),P.typeInterfaceNode({properties:n,useLegacyResolution:!0})]})]}),typeParameters:[{extends:P.typeReferenceNode({typeName:P.identifier({text:i.placeholder})}),name:Dd}]});e.setSymbolValue(a,o)},Md=({operation:e,plugin:t,symbol:n})=>{let{strippedTypeData:r}=Td({plugin:t,typeData:Sd({operation:e,plugin:t})});return P.constVariable({exportConst:n.exported,expression:P.arrowFunction({parameters:[{isRequired:at(e),name:`options`,type:r}],statements:Ad({id:e.id,operation:e,plugin:t})}),name:n.placeholder})},Nd=`options`,Pd=`context`,Fd=({operation:e,plugin:t,queryFn:n})=>{if(Wc({operation:e}))return;let r=Uc({context:t.context,operation:e});t.getSymbol(t.api.selector(`createQueryKey`))||(jd({plugin:t}),kd({plugin:t}));let i;if(t.config.queryKeys.enabled){let n=t.registerSymbol({exported:!0,name:w({config:t.config.queryKeys,name:e.id})}),r=Md({operation:e,plugin:t,symbol:n});t.setSymbolValue(n,r),i=P.callExpression({functionName:n.placeholder,parameters:[Nd]})}else{let n=t.referenceSymbol(t.api.selector(`createQueryKey`)),r;t.config.queryKeys.tags&&e.tags&&e.tags.length>0&&(r=P.arrayLiteralExpression({elements:e.tags.map(e=>P.stringLiteral({text:e}))})),i=P.callExpression({functionName:n.placeholder,parameters:[P.ots.string(e.id),Nd,r]})}let{strippedTypeData:a}=Td({plugin:t,typeData:Sd({operation:e,plugin:t})}),o=P.awaitExpression({expression:P.callExpression({functionName:n,parameters:[P.objectExpression({multiLine:!0,obj:[{spread:Nd},{spread:Pd},{key:`throwOnError`,value:!0}]})]})}),s=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?s.push(P.returnVariable({expression:o})):s.push(P.constVariable({destructure:!0,expression:o,name:`data`}),P.returnVariable({expression:`data`}));let c=[{key:`key`,value:i},{key:`query`,value:P.arrowFunction({async:!0,multiLine:!0,parameters:[{name:Pd}],statements:s})}],l=xd(t,e,`queryOptions`);l&&c.push({key:`meta`,value:l});let u=t.registerSymbol({exported:!0,name:w({config:t.config.queryOptions,name:e.id}),selector:t.api.selector(`queryOptionsFn`,e.id)}),d=t.registerSymbol({external:t.name,name:`defineQueryOptions`,selector:t.api.selector(`defineQueryOptions`)}),f=P.constVariable({comment:t.config.comments?Hc({operation:e}):void 0,exportConst:u.exported,expression:P.callExpression({functionName:d.placeholder,parameters:[P.arrowFunction({parameters:[{isRequired:r,name:Nd,type:a}],statements:P.objectExpression({obj:c})})]}),name:u.placeholder});t.setSymbolValue(u,f)},Id={api:new bd({name:`@pinia/colada`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/typescript`,`@hey-api/sdk`],handler:({plugin:e})=>{e.registerSymbol({external:e.name,meta:{kind:`type`},name:`UseMutationOptions`,selector:e.api.selector(`UseMutationOptions`)}),e.registerSymbol({external:e.name,meta:{kind:`type`},name:`UseQueryOptions`,selector:e.api.selector(`UseQueryOptions`)}),e.registerSymbol({external:e.name,meta:{kind:`type`},name:`_JSONValue`,selector:e.api.selector(`_JSONValue`)}),e.registerSymbol({external:`axios`,meta:{kind:`type`},name:`AxiosError`,selector:e.api.selector(`AxiosError`)});let t=e.getPluginOrThrow(`@hey-api/sdk`);e.forEach(`operation`,({operation:n})=>{let r=t.config.asClass?Lc({context:e.context,operation:n,plugin:t}):void 0,i=r?r.values().next().value:void 0,a=i?[e.referenceSymbol(t.api.selector(`class`,i.path[0])).placeholder,...i.path.slice(1).map(e=>C({case:`camelCase`,value:e})),i.methodName].filter(Boolean).join(`.`):e.referenceSymbol(t.api.selector(`function`,n.id)).placeholder;e.hooks.operation.isQuery(n)&&e.config.queryOptions.enabled&&Fd({operation:n,plugin:e,queryFn:a}),e.hooks.operation.isMutation(n)&&e.config.mutationOptions.enabled&&Ed({operation:n,plugin:e,queryFn:a})},{order:`declarations`})},name:`@pinia/colada`,resolveConfig:(e,t)=>{e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Query`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions})}},Ld=(e,t,n)=>{let r=e.config[n].meta;if(!r)return;let i=r(t);if(Object.keys(i).length)return P.valueToExpression({value:i})},Rd=({operation:e,plugin:t})=>Rc({operation:e,plugin:t.getPluginOrThrow(`@hey-api/sdk`)}),zd=({operation:e,plugin:t})=>{let n=y(t.context.config),r=t.getPluginOrThrow(`@hey-api/typescript`),i=t.getSymbol(r.api.selector(`error`,e.id))?.placeholder;return i||=t.referenceSymbol(t.api.selector(`DefaultError`)).placeholder,n.name===`@hey-api/client-axios`&&(i=`${t.referenceSymbol(t.api.selector(`AxiosError`)).placeholder}<${i}>`),i},Bd=({operation:e,plugin:t})=>{let n=t.getPluginOrThrow(`@hey-api/typescript`);return t.getSymbol(n.api.selector(`response`,e.id))?.placeholder||`unknown`},Vd=`TOptions`,Hd=P.identifier({text:`infinite`}),Ud=P.identifier({text:`options`}),Wd=({plugin:e})=>{let t=e.registerSymbol({name:w({config:{case:e.config.case},name:`createQueryKey`}),selector:e.api.selector(`createQueryKey`)}),n=e.referenceSymbol(e.api.selector(`QueryKey`)),r=P.indexedAccessTypeNode({indexType:P.literalTypeNode({literal:P.ots.number(0)}),objectType:P.typeReferenceNode({typeArguments:[P.typeReferenceNode({typeName:Vd})],typeName:n.placeholder})}),i=fe(e.context.config),a=y(e.context.config),o=a.api&&`selector`in a.api?e.getSymbol(a.api.selector(`client`)):void 0,s=e.getPluginOrThrow(`@hey-api/sdk`),c=e.referenceSymbol(s.api.selector(`Options`)),l=P.constVariable({expression:P.arrowFunction({multiLine:!0,parameters:[{name:`id`,type:P.typeReferenceNode({typeName:`string`})},{isRequired:!1,name:`options`,type:P.typeReferenceNode({typeName:Vd})},{isRequired:!1,name:`infinite`,type:P.typeReferenceNode({typeName:`boolean`})},{isRequired:!1,name:`tags`,type:P.typeReferenceNode({typeName:`ReadonlyArray<string>`})}],returnType:P.typeTupleNode({types:[r]}),statements:[P.constVariable({assertion:r,expression:P.objectExpression({multiLine:!1,obj:[{key:`_id`,value:P.identifier({text:`id`})},{key:i,value:P.identifier({text:`options?.${i} || (options?.client ?? ${o?.placeholder}).getConfig().${i}`})}]}),name:`params`,typeName:r}),P.ifStatement({expression:Hd,thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`_infinite`}),right:Hd})})]})}),P.ifStatement({expression:P.identifier({text:`tags`}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`tags`}),right:P.identifier({text:`tags`})})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:Ud,isOptional:!0,name:P.identifier({text:`body`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`body`}),right:P.propertyAccessExpression({expression:`options`,name:`body`})})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:Ud,isOptional:!0,name:P.identifier({text:`headers`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`headers`}),right:P.propertyAccessExpression({expression:`options`,name:`headers`})})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:Ud,isOptional:!0,name:P.identifier({text:`path`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`path`}),right:P.propertyAccessExpression({expression:`options`,name:`path`})})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:Ud,isOptional:!0,name:P.identifier({text:`query`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`query`}),right:P.propertyAccessExpression({expression:`options`,name:`query`})})})]})}),P.returnStatement({expression:P.arrayLiteralExpression({elements:[P.identifier({text:`params`})]})})],types:[{extends:P.typeReferenceNode({typeName:P.identifier({text:c.placeholder})}),name:Vd}]}),name:t.placeholder});e.setSymbolValue(t,l)},Gd=({id:e,isInfinite:t,operation:n,plugin:r})=>{let i=t?r.config.infiniteQueryKeys:r.config.queryKeys,a;i.tags&&n.tags&&n.tags.length>0&&(a=P.arrayLiteralExpression({elements:n.tags.map(e=>P.stringLiteral({text:e}))}));let o=r.referenceSymbol(r.api.selector(`createQueryKey`));return P.callExpression({functionName:o.placeholder,parameters:[P.ots.string(e),`options`,t||a?P.ots.boolean(!!t):void 0,a]})},Kd=({plugin:e})=>{let t=[{name:`_id`,type:P.keywordTypeNode({keyword:`string`})},{isRequired:!1,name:`_infinite`,type:P.keywordTypeNode({keyword:`boolean`})},{isRequired:!1,name:`tags`,type:P.typeReferenceNode({typeName:`ReadonlyArray<string>`})}],n=e.getPluginOrThrow(`@hey-api/sdk`),r=e.referenceSymbol(n.api.selector(`Options`)),i=e.registerSymbol({exported:!0,meta:{kind:`type`},name:`QueryKey`,selector:e.api.selector(`QueryKey`)}),a=P.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:P.typeTupleNode({types:[P.typeIntersectionNode({types:[P.typeReferenceNode({typeName:`Pick<${Vd}, '${fe(e.context.config)}' | 'body' | 'headers' | 'path' | 'query'>`}),P.typeInterfaceNode({properties:t,useLegacyResolution:!0})]})]}),typeParameters:[{extends:P.typeReferenceNode({typeName:P.identifier({text:r.placeholder})}),name:Vd}]});e.setSymbolValue(i,a)},qd=({isInfinite:e,operation:t,plugin:n,symbol:r,typeQueryKey:i})=>{let a=Rd({operation:t,plugin:n});return P.constVariable({exportConst:r.exported,expression:P.arrowFunction({parameters:[{isRequired:at(t),name:`options`,type:a}],returnType:e?i:void 0,statements:Gd({id:t.id,isInfinite:e,operation:t,plugin:n})}),name:r.placeholder})},Jd=({plugin:e})=>{let t=e.registerSymbol({name:w({config:{case:e.config.case},name:`createInfiniteParams`}),selector:e.api.selector(`createInfiniteParams`)}),n=P.constVariable({expression:P.arrowFunction({multiLine:!0,parameters:[{name:`queryKey`,type:P.typeReferenceNode({typeName:`QueryKey<Options>`})},{name:`page`,type:P.typeReferenceNode({typeName:`K`})}],statements:[P.constVariable({expression:P.objectExpression({obj:[{spread:P.propertyAccessExpression({expression:`queryKey`,name:0})}]}),name:`params`}),P.ifStatement({expression:P.propertyAccessExpression({expression:P.identifier({text:`page`}),name:P.identifier({text:`body`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`body`}),right:P.objectExpression({multiLine:!0,obj:[{assertion:`any`,spread:`queryKey[0].body`},{assertion:`any`,spread:`page.body`}]})})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:P.identifier({text:`page`}),name:P.identifier({text:`headers`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`headers`}),right:P.objectExpression({multiLine:!0,obj:[{spread:`queryKey[0].headers`},{spread:`page.headers`}]})})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:P.identifier({text:`page`}),name:P.identifier({text:`path`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`path`}),right:P.objectExpression({multiLine:!0,obj:[{assertion:`any`,spread:`queryKey[0].path`},{assertion:`any`,spread:`page.path`}]})})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:P.identifier({text:`page`}),name:P.identifier({text:`query`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`query`}),right:P.objectExpression({multiLine:!0,obj:[{assertion:`any`,spread:`queryKey[0].query`},{assertion:`any`,spread:`page.query`}]})})})]})}),P.returnVariable({expression:P.asExpression({expression:P.asExpression({expression:P.identifier({text:`params`}),type:P.keywordTypeNode({keyword:`unknown`})}),type:l.factory.createTypeQueryNode(P.identifier({text:`page`}))})})],types:[{extends:P.typeReferenceNode({typeName:P.identifier({text:`Pick<QueryKey<Options>[0], 'body' | 'headers' | 'path' | 'query'>`})}),name:`K`}]}),name:t.placeholder});e.setSymbolValue(t,n)},Yd=({operation:e,plugin:t,queryFn:n})=>{let r=ot({context:t.context,operation:e});if(!r)return;let i=Uc({context:t.context,operation:e});t.getSymbol(t.api.selector(`createQueryKey`))||(Kd({plugin:t}),Wd({plugin:t})),t.getSymbol(t.api.selector(`createInfiniteParams`))||Jd({plugin:t});let a=t.referenceSymbol(t.api.selector(`infiniteQueryOptions`)),o=t.referenceSymbol(t.api.selector(`InfiniteData`)),s=Rd({operation:e,plugin:t}),c=zd({operation:e,plugin:t}),l=Bd({operation:e,plugin:t}),u=`${t.referenceSymbol(t.api.selector(`QueryKey`)).placeholder}<${s}>`,d=`Pick<${u}[0], 'body' | 'headers' | 'path' | 'query'>`,f=t.getPluginOrThrow(`@hey-api/typescript`),p=`${Tt({node:f.api.schemaToType({plugin:f,schema:r.schema,state:{path:{value:[]}}}),unescape:!0})} | ${d}`,m=t.registerSymbol({exported:!0,name:w({config:t.config.infiniteQueryKeys,name:e.id})}),h=qd({isInfinite:!0,operation:e,plugin:t,symbol:m,typeQueryKey:u});t.setSymbolValue(m,h);let g=P.awaitExpression({expression:P.callExpression({functionName:n,parameters:[P.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:`params`},{key:`signal`,shorthand:!0,value:P.identifier({text:`signal`})},{key:`throwOnError`,value:!0}]})]})}),ee=t.referenceSymbol(t.api.selector(`createInfiniteParams`)),_=[P.constVariable({comment:[{jsdoc:!1,lines:[`@ts-ignore`]}],expression:P.conditionalExpression({condition:P.binaryExpression({left:P.typeOfExpression({text:`pageParam`}),operator:`===`,right:P.ots.string(`object`)}),whenFalse:P.objectExpression({multiLine:!0,obj:[{key:r.in,value:P.objectExpression({multiLine:!0,obj:[{key:r.name,value:P.identifier({text:`pageParam`})}]})}]}),whenTrue:P.identifier({text:`pageParam`})}),name:`page`,typeName:d}),P.constVariable({expression:P.callExpression({functionName:ee.placeholder,parameters:[`queryKey`,`page`]}),name:`params`})];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?_.push(P.returnVariable({expression:g})):_.push(P.constVariable({destructure:!0,expression:g,name:`data`}),P.returnVariable({expression:`data`}));let te=[{key:`queryFn`,value:P.arrowFunction({async:!0,multiLine:!0,parameters:[{destructure:[{name:`pageParam`},{name:`queryKey`},{name:`signal`}]}],statements:_})},{key:`queryKey`,value:P.callExpression({functionName:m.placeholder,parameters:[`options`]})}],v=Ld(t,e,`infiniteQueryOptions`);v&&te.push({key:`meta`,value:v});let ne=t.registerSymbol({exported:!0,name:w({config:t.config.infiniteQueryOptions,name:e.id})}),re=P.constVariable({comment:t.config.comments?Hc({operation:e}):void 0,exportConst:ne.exported,expression:P.arrowFunction({parameters:[{isRequired:i,name:`options`,type:s}],statements:[P.returnFunctionCall({args:[P.objectExpression({comments:[{jsdoc:!1,lines:[`@ts-ignore`]}],obj:te})],name:a.placeholder,types:[l,c||`unknown`,`${o.placeholder}<${l}>`,u,p]})]}),name:ne.placeholder});t.setSymbolValue(ne,re)},Xd=({operation:e,plugin:t,queryFn:n})=>{let r=t.referenceSymbol(t.api.selector(`MutationOptions`)),i=Rd({operation:e,plugin:t}),a=zd({operation:e,plugin:t}),o=Bd({operation:e,plugin:t}),s=`${r.placeholder}<${o}, ${a}, ${i}>`,c=`fnOptions`,l=P.awaitExpression({expression:P.callExpression({functionName:n,parameters:[P.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:c},{key:`throwOnError`,value:!0}]})]})}),u=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?u.push(P.returnVariable({expression:l})):u.push(P.constVariable({destructure:!0,expression:l,name:`data`}),P.returnVariable({expression:`data`}));let d=[{key:`mutationFn`,value:P.arrowFunction({async:!0,multiLine:!0,parameters:[{name:c}],statements:u})}],f=Ld(t,e,`mutationOptions`);f&&d.push({key:`meta`,value:f});let p=`mutationOptions`,m=P.arrowFunction({parameters:[{isRequired:!1,name:`options`,type:`Partial<${i}>`}],returnType:s,statements:[P.constVariable({expression:P.objectExpression({obj:d}),name:p,typeName:s}),P.returnVariable({expression:p})]}),h=t.registerSymbol({exported:!0,name:w({config:t.config.mutationOptions,name:e.id})}),g=P.constVariable({comment:t.config.comments?Hc({operation:e}):void 0,exportConst:h.exported,expression:m,name:h.placeholder});t.setSymbolValue(h,g)},Zd=`options`,Qd=({operation:e,plugin:t,queryFn:n})=>{if(Wc({operation:e}))return;let r=Uc({context:t.context,operation:e});t.getSymbol(t.api.selector(`createQueryKey`))||(Kd({plugin:t}),Wd({plugin:t}));let i=t.referenceSymbol(t.api.selector(`queryOptions`)),a=t.registerSymbol({exported:!0,name:w({config:t.config.queryKeys,name:e.id})}),o=qd({isInfinite:!1,operation:e,plugin:t,symbol:a});t.setSymbolValue(a,o);let s=Rd({operation:e,plugin:t}),c=P.awaitExpression({expression:P.callExpression({functionName:n,parameters:[P.objectExpression({multiLine:!0,obj:[{spread:Zd},{spread:`queryKey[0]`},{key:`signal`,shorthand:!0,value:P.identifier({text:`signal`})},{key:`throwOnError`,value:!0}]})]})}),l=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?l.push(P.returnVariable({expression:c})):l.push(P.constVariable({destructure:!0,expression:c,name:`data`}),P.returnVariable({expression:`data`}));let u=[{key:`queryFn`,value:P.arrowFunction({async:!0,multiLine:!0,parameters:[{destructure:[{name:`queryKey`},{name:`signal`}]}],statements:l})},{key:`queryKey`,value:P.callExpression({functionName:a.placeholder,parameters:[Zd]})}],d=Ld(t,e,`queryOptions`);d&&u.push({key:`meta`,value:d});let f=t.registerSymbol({exported:t.config.queryOptions.exported,name:w({config:t.config.queryOptions,name:e.id}),selector:t.api.selector(`queryOptionsFn`,e.id)}),p=P.constVariable({comment:t.config.comments?Hc({operation:e}):void 0,exportConst:f.exported,expression:P.arrowFunction({parameters:[{isRequired:r,name:Zd,type:s}],statements:[P.returnFunctionCall({args:[P.objectExpression({obj:u})],name:i.placeholder})]}),name:f.placeholder});t.setSymbolValue(f,p)},$d=`options`,ef=({operation:e,plugin:t})=>{if(Wc({operation:e})||!(`useQuery`in t.config))return;let n=t.registerSymbol({exported:!0,name:w({config:t.config.useQuery,name:e.id})}),r=t.referenceSymbol(t.api.selector(`useQuery`)),i=Uc({context:t.context,operation:e}),a=Rd({operation:e,plugin:t}),o=t.referenceSymbol(t.api.selector(`queryOptionsFn`,e.id)),s=P.constVariable({comment:t.config.comments?Hc({operation:e}):void 0,exportConst:n.exported,expression:P.arrowFunction({parameters:[{isRequired:i,name:$d,type:a}],statements:[P.returnStatement({expression:P.callExpression({functionName:r.placeholder,parameters:[P.callExpression({functionName:o.placeholder,parameters:[$d]})]})})]}),name:n.placeholder});t.setSymbolValue(n,s)},tf=({plugin:e})=>{e.registerSymbol({external:e.name,meta:{kind:`type`},name:`DefaultError`,selector:e.api.selector(`DefaultError`)}),e.registerSymbol({external:e.name,meta:{kind:`type`},name:`InfiniteData`,selector:e.api.selector(`InfiniteData`)});let t=e.name===`@tanstack/angular-query-experimental`||e.name===`@tanstack/svelte-query`||e.name===`@tanstack/solid-query`?`MutationOptions`:`UseMutationOptions`;e.registerSymbol({external:e.name,meta:{kind:`type`},name:t,selector:e.api.selector(`MutationOptions`)}),e.registerSymbol({external:e.name,name:`infiniteQueryOptions`,selector:e.api.selector(`infiniteQueryOptions`)}),e.registerSymbol({external:e.name,name:`queryOptions`,selector:e.api.selector(`queryOptions`)}),e.registerSymbol({external:e.name,name:`useQuery`,selector:e.api.selector(`useQuery`)}),e.registerSymbol({external:`axios`,meta:{kind:`type`},name:`AxiosError`,selector:e.api.selector(`AxiosError`)});let n=e.getPluginOrThrow(`@hey-api/sdk`);e.forEach(`operation`,({operation:t})=>{let r=n.config.asClass?Lc({context:e.context,operation:t,plugin:n}):void 0,i=r?r.values().next().value:void 0,a=i?[e.referenceSymbol(n.api.selector(`class`,i.path[0])).placeholder,...i.path.slice(1).map(e=>C({case:`camelCase`,value:e})),i.methodName].filter(Boolean).join(`.`):e.referenceSymbol(n.api.selector(`function`,t.id)).placeholder;e.hooks.operation.isQuery(t)&&(e.config.queryOptions.enabled&&Qd({operation:t,plugin:e,queryFn:a}),e.config.infiniteQueryOptions.enabled&&Yd({operation:t,plugin:e,queryFn:a}),`useQuery`in e.config&&e.config.useQuery.enabled&&ef({operation:t,plugin:e})),e.hooks.operation.isMutation(t)&&e.config.mutationOptions.enabled&&Xd({operation:t,plugin:e,queryFn:a})},{order:`declarations`})},nf=e=>`${uu({config:b(),id:e.name,operation:e})}InfiniteOptions`,rf=e=>`${uu({config:b(),id:e.name,operation:e})}Mutation`,af=({config:e,id:t,operation:n})=>`${uu({config:e,id:t,operation:n})}Options`,of=({config:e,id:t,isInfinite:n,operation:r})=>`${uu({config:e,id:t,operation:r})}${n?`Infinite`:``}QueryKey`,sf=e=>{switch(e.in){case`formData`:return`body`;case`header`:return`headers`;default:return e.in}},cf=`createQueryKey`,lf=`infiniteQueryOptions`,uf=`mutationOptions`,df=`QueryKey`,ff=`queryOptions`,pf=`TOptions`,mf=({file:e})=>{let t=P.constVariable({expression:P.arrowFunction({multiLine:!0,parameters:[{name:`queryKey`,type:P.typeNode(`QueryKey<OptionsLegacyParser>`)},{name:`page`,type:P.typeNode(`K`)}],statements:[P.constVariable({expression:P.identifier({text:`queryKey[0]`}),name:`params`}),P.ifStatement({expression:P.propertyAccessExpression({expression:P.identifier({text:`page`}),name:P.identifier({text:`body`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`body`}),right:P.objectExpression({multiLine:!0,obj:[{assertion:`any`,spread:`queryKey[0].body`},{assertion:`any`,spread:`page.body`}]})})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:P.identifier({text:`page`}),name:P.identifier({text:`headers`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`headers`}),right:P.objectExpression({multiLine:!0,obj:[{spread:`queryKey[0].headers`},{spread:`page.headers`}]})})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:P.identifier({text:`page`}),name:P.identifier({text:`path`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`path`}),right:P.objectExpression({multiLine:!0,obj:[{spread:`queryKey[0].path`},{spread:`page.path`}]})})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:P.identifier({text:`page`}),name:P.identifier({text:`query`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`query`}),right:P.objectExpression({multiLine:!0,obj:[{spread:`queryKey[0].query`},{spread:`page.query`}]})})})]})}),P.returnVariable({expression:l.factory.createAsExpression(l.factory.createAsExpression(P.identifier({text:`params`}),l.factory.createKeywordTypeNode(l.SyntaxKind.UnknownKeyword)),l.factory.createTypeQueryNode(P.identifier({text:`page`})))})],types:[{extends:P.typeReferenceNode({typeName:P.identifier({text:`Pick<QueryKey<OptionsLegacyParser>[0], 'body' | 'headers' | 'path' | 'query'>`})}),name:`K`}]}),name:`createInfiniteParams`});e.add(t)},hf=({file:e})=>{let t=P.indexedAccessTypeNode({indexType:P.typeNode(0),objectType:P.typeNode(df,[P.typeNode(pf)])}),n=P.identifier({text:`infinite`}),r=fe(b()),i=P.constVariable({expression:P.arrowFunction({multiLine:!0,parameters:[{name:`id`,type:P.typeNode(`string`)},{isRequired:!1,name:`options`,type:P.typeNode(pf)},{isRequired:!1,name:`infinite`,type:P.typeNode(`boolean`)}],returnType:t,statements:[P.constVariable({assertion:t,expression:P.objectExpression({multiLine:!1,obj:[{key:`_id`,value:P.identifier({text:`id`})},{key:r,value:P.identifier({text:`options?.${r} || (options?.client ?? _heyApiClient).getConfig().${r}`})}]}),name:`params`,typeName:t}),P.ifStatement({expression:n,thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`_infinite`}),right:n})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:P.identifier({text:`options`}),isOptional:!0,name:P.identifier({text:`body`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`body`}),right:P.propertyAccessExpression({expression:`options`,name:`body`})})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:P.identifier({text:`options`}),isOptional:!0,name:P.identifier({text:`headers`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`headers`}),right:P.propertyAccessExpression({expression:`options`,name:`headers`})})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:P.identifier({text:`options`}),isOptional:!0,name:P.identifier({text:`path`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`path`}),right:P.propertyAccessExpression({expression:`options`,name:`path`})})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:P.identifier({text:`options`}),isOptional:!0,name:P.identifier({text:`query`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`query`}),right:P.propertyAccessExpression({expression:`options`,name:`query`})})})]})}),P.returnVariable({expression:`params`})],types:[{extends:P.typeReferenceNode({typeName:P.identifier({text:`OptionsLegacyParser`})}),name:pf}]}),name:cf});e.add(i)},gf=({file:e})=>{let t=[{name:`_id`,type:P.keywordTypeNode({keyword:`string`})},{isRequired:!1,name:`_infinite`,type:P.keywordTypeNode({keyword:`boolean`})}],n=P.typeAliasDeclaration({name:df,type:P.typeTupleNode({types:[P.typeIntersectionNode({types:[P.typeReferenceNode({typeName:`Pick<${pf}, '${fe(b())}' | 'body' | 'headers' | 'path' | 'query'>`}),P.typeInterfaceNode({properties:t,useLegacyResolution:!0})]})]}),typeParameters:[{extends:P.typeReferenceNode({typeName:P.identifier({text:`OptionsLegacyParser`})}),name:pf}]});e.add(n)},_f=({client:e,file:t,operation:n,typesModulePath:r})=>{let{name:i}=$l({client:e,meta:n.parameters.length?{$ref:n.name,name:n.name}:void 0,nameTransformer:tu,onImport:e=>{t.import({asType:!0,module:r,name:e})}});return{typeData:au({importedType:i})}},vf=({client:e,file:t,operation:n,pluginName:r,typesModulePath:i})=>{let a=b(),{name:o}=$l({client:e,meta:{$ref:n.name,name:n.name},nameTransformer:nu,onImport:e=>{t.import({asType:!0,module:i,name:e})}}),s={asType:!0,name:o};if(s.name||(s=t.import({asType:!0,module:r,name:`DefaultError`})),y(a).name===`@hey-api/client-axios`){let e=t.import({asType:!0,module:`axios`,name:`AxiosError`});s={...e,name:`${e.name}<${s.name}>`}}return{typeError:s}},yf=({client:e,file:t,operation:n,typesModulePath:r})=>{let{name:i}=$l({client:e,meta:{$ref:n.name,name:n.name},nameTransformer:iu,onImport:e=>{t.import({asType:!0,module:r,name:e})}});return{typeResponse:i||`void`}},bf=({id:e,isInfinite:t})=>P.arrayLiteralExpression({elements:[P.callExpression({functionName:cf,parameters:[P.ots.string(e),`options`,t?P.ots.boolean(!0):void 0]})],multiLine:!1}),xf=({client:e,files:t,plugin:n})=>{let r=b();if(x(r))throw Error(`TanStack Query plugin does not support legacy clients`);let i=t[n.name];i.import({asType:!0,module:cl({config:r,sourceOutput:n.output}),name:`OptionsLegacyParser`});let a=re({moduleOutput:t.types.nameWithoutExtension(),sourceOutput:n.output}),o=n.name===`@tanstack/angular-query-experimental`||n.name===`@tanstack/svelte-query`||n.name===`@tanstack/solid-query`?`MutationOptions`:`UseMutationOptions`,s,c=!1,l=!1,u=!1,d=!1,f=!1,p=new Map;for(let m of e.services)for(let h of m.operations){let g=D(h);if(p.has(g))continue;p.set(g,!0);let ee=[r.plugins[`@hey-api/sdk`]?.config.asClass&&Xo({config:r,name:m.name}),uu({config:r,handleIllegal:!r.plugins[`@hey-api/sdk`]?.config.asClass,id:h.name,operation:h})].filter(Boolean).join(`.`),_=!1;if(n.config.queryOptions.enabled&&[`GET`,`POST`].includes(h.method)){f||(f=!0,l||=(gf({file:i}),hf({file:i}),!0),i.import({module:n.name,name:ff})),_=!0;let{typeData:t}=_f({client:e,file:i,operation:h,typesModulePath:a}),o=Is(h.parameters),s=P.constVariable({exportConst:!0,expression:P.arrowFunction({parameters:[{isRequired:o,name:`options`,type:t}],statements:bf({id:h.name})}),name:of({config:r,id:h.name,operation:h})});i.add(s);let c=P.constVariable({comment:[],exportConst:!0,expression:P.arrowFunction({parameters:[{isRequired:o,name:`options`,type:t}],statements:[P.returnFunctionCall({args:[P.objectExpression({obj:[{key:`queryFn`,value:P.arrowFunction({async:!0,multiLine:!0,parameters:[{destructure:[{name:`queryKey`},{name:`signal`}]}],statements:[P.constVariable({destructure:!0,expression:P.awaitExpression({expression:P.callExpression({functionName:ee,parameters:[P.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:`queryKey[0]`},{key:`signal`,shorthand:!0,value:P.identifier({text:`signal`})},{key:`throwOnError`,value:!0}]})]})}),name:`data`}),P.returnVariable({expression:`data`})]})},{key:`queryKey`,value:P.callExpression({functionName:of({config:r,id:h.name,operation:h}),parameters:[`options`]})}]})],name:ff})]}),name:af({config:r,id:h.name,operation:h})});i.add(c)}if(n.config.infiniteQueryOptions&&[`GET`,`POST`].includes(h.method)){let t,o=h.parameters.find(n=>{if(Ni(r.parser.pagination).test(n.name))return t=n,!0;if(n.in===`body`){if(n.export===`reference`){let i=n.$refs[0];return e.models.find(e=>e.meta?.$ref===i)?.properties.find(e=>{if(Ni(r.parser.pagination).test(e.name))return t=e,!0})}return n.properties.find(e=>{if(Ni(r.parser.pagination).test(e.name))return t=e,!0})}});if(o&&t){u||(u=!0,l||=(gf({file:i}),hf({file:i}),!0),c||=(mf({file:i}),!0),i.import({module:n.name,name:lf}),s=i.import({asType:!0,module:n.name,name:`InfiniteData`})),_=!0;let{typeData:d}=_f({client:e,file:i,operation:h,typesModulePath:a}),{typeError:f}=vf({client:e,file:i,operation:h,pluginName:n.name,typesModulePath:a}),{typeResponse:p}=yf({client:e,file:i,operation:h,typesModulePath:a}),m=Is(h.parameters),g=`${df}<${d}>`,te=`Pick<${g}[0], 'body' | 'headers' | 'path' | 'query'>`,v=`${t.base} | ${te}`,ne=P.constVariable({exportConst:!0,expression:P.arrowFunction({parameters:[{isRequired:m,name:`options`,type:d}],returnType:g,statements:bf({id:h.name,isInfinite:!0})}),name:of({config:r,id:h.name,isInfinite:!0,operation:h})});i.add(ne);let re=P.constVariable({comment:[],exportConst:!0,expression:P.arrowFunction({parameters:[{isRequired:m,name:`options`,type:d}],statements:[P.returnFunctionCall({args:[P.objectExpression({comments:[{jsdoc:!1,lines:[`@ts-ignore`]}],obj:[{key:`queryFn`,value:P.arrowFunction({async:!0,multiLine:!0,parameters:[{destructure:[{name:`pageParam`},{name:`queryKey`},{name:`signal`}]}],statements:[P.constVariable({comment:[{jsdoc:!1,lines:[`@ts-ignore`]}],expression:P.conditionalExpression({condition:P.binaryExpression({left:P.typeOfExpression({text:`pageParam`}),operator:`===`,right:P.ots.string(`object`)}),whenFalse:P.objectExpression({multiLine:!0,obj:[{key:sf(o),value:P.objectExpression({multiLine:!0,obj:[{key:t.name,value:P.identifier({text:`pageParam`})}]})}]}),whenTrue:P.identifier({text:`pageParam`})}),name:`page`,typeName:te}),P.constVariable({expression:P.callExpression({functionName:`createInfiniteParams`,parameters:[`queryKey`,`page`]}),name:`params`}),P.constVariable({destructure:!0,expression:P.awaitExpression({expression:P.callExpression({functionName:ee,parameters:[P.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:`params`},{key:`signal`,shorthand:!0,value:P.identifier({text:`signal`})},{key:`throwOnError`,value:!0}]})]})}),name:`data`}),P.returnVariable({expression:`data`})]})},{key:`queryKey`,value:P.callExpression({functionName:of({config:r,id:h.name,isInfinite:!0,operation:h}),parameters:[`options`]})}]})],name:lf,types:[p,f.name,`${typeof s==`string`?s:s.name}<${p}>`,g,v]})]}),name:nf(h)});i.add(re)}}if(n.config.mutationOptions&&[`DELETE`,`PATCH`,`POST`,`PUT`].includes(h.method)){d||(d=!0,i.import({asType:!0,module:n.name,name:o})),_=!0;let{typeData:t}=_f({client:e,file:i,operation:h,typesModulePath:a}),{typeError:r}=vf({client:e,file:i,operation:h,pluginName:n.name,typesModulePath:a}),{typeResponse:s}=yf({client:e,file:i,operation:h,typesModulePath:a}),c=`fnOptions`,l=P.arrowFunction({parameters:[{isRequired:!1,name:`options`,type:`Partial<${t}>`}],statements:[P.constVariable({expression:P.objectExpression({obj:[{key:`mutationFn`,value:P.arrowFunction({async:!0,multiLine:!0,parameters:[{name:c}],statements:[P.constVariable({destructure:!0,expression:P.awaitExpression({expression:P.callExpression({functionName:ee,parameters:[P.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:c},{key:`throwOnError`,value:!0}]})]})}),name:`data`}),P.returnVariable({expression:`data`})]})}]}),name:uf,typeName:`${o}<${s}, ${r.name}, ${t}>`}),P.returnVariable({expression:uf})]}),u=P.constVariable({comment:[],exportConst:!0,expression:l,name:rf(h)});i.add(u)}(f||u)&&i.import({alias:`_heyApiClient`,module:re({moduleOutput:t.client.nameWithoutExtension(),sourceOutput:n.output}),name:`client`}),_&&i.import({module:re({moduleOutput:t.sdk.nameWithoutExtension(),sourceOutput:n.output}),name:ee.split(`.`)[0]})}},Sf={api:new class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}}({name:`@tanstack/angular-query-experimental`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:tf,handlerLegacy:xf,name:`@tanstack/angular-query-experimental`,output:`@tanstack/angular-query-experimental`,resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteQueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteOptions`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,exported:!0,name:`{{name}}Options`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions})}},Cf={api:new class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}}({name:`@tanstack/react-query`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:tf,handlerLegacy:xf,name:`@tanstack/react-query`,output:`@tanstack/react-query`,resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteQueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteOptions`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,exported:!0,name:`{{name}}Options`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions}),e.config.useQuery=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!1,name:`use{{name}}Query`},mappers:{boolean:e=>({enabled:e}),function:e=>({enabled:!0,name:e}),object:e=>({enabled:!0,...e}),string:e=>({enabled:!0,name:e})},value:e.config.useQuery}),e.config.useQuery.enabled&&(e.config.queryOptions.enabled||(e.config.queryOptions.enabled=!0,e.config.queryOptions.exported=!1))}},wf={api:new class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}}({name:`@tanstack/solid-query`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:tf,handlerLegacy:xf,name:`@tanstack/solid-query`,output:`@tanstack/solid-query`,resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteQueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteOptions`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,exported:!0,name:`{{name}}Options`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions})}},Tf={api:new class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}}({name:`@tanstack/svelte-query`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:tf,handlerLegacy:xf,name:`@tanstack/svelte-query`,output:`@tanstack/svelte-query`,resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteQueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteOptions`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,exported:!0,name:`{{name}}Options`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions})}},Ef={api:new class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}}({name:`@tanstack/vue-query`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:tf,handlerLegacy:xf,name:`@tanstack/vue-query`,output:`@tanstack/vue-query`,resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteQueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteOptions`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,exported:!0,name:`{{name}}Options`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions})}},Df=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`data`,e.id));if(!n)return;let r=`data`;return P.arrowFunction({async:!0,parameters:[{name:r}],statements:[P.returnStatement({expression:P.awaitExpression({expression:P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:`parseAsync`}),parameters:[P.identifier({text:r})]})})})]})},Of=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`responses`,e.id));if(!n)return;let r=`data`;return P.arrowFunction({async:!0,parameters:[{name:r}],statements:[P.returnStatement({expression:P.awaitExpression({expression:P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:`parseAsync`}),parameters:[P.identifier({text:r})]})})})]})};var kf=class{constructor(e){this.meta=e}createRequestValidator(e){return Df(e)}createResponseValidator(e){return Of(e)}selector(...e){return[this.meta.name,...e]}};const Y={keywords:{false:P.identifier({text:`false`}),true:P.identifier({text:`true`})},number:{Infinity:P.identifier({text:`Infinity`}),NaN:P.identifier({text:`NaN`}),NegativeInfinity:P.identifier({text:`NegativeInfinity`}),epoch:P.identifier({text:`epoch`}),integer:P.identifier({text:`integer`}),safe:P.identifier({text:`safe`})},primitives:{bigint:P.identifier({text:`bigint`}),boolean:P.identifier({text:`boolean`}),keywords:P.identifier({text:`keywords`}),null:`null`,number:P.identifier({text:`number`}),string:`string`,symbol:P.identifier({text:`symbol`}),undefined:P.identifier({text:`undefined`}),unit:P.identifier({text:`unit`})},string:{NFC:P.identifier({text:`NFC`}),NFD:P.identifier({text:`NFD`}),NFKC:P.identifier({text:`NFKC`}),NFKD:P.identifier({text:`NFKD`}),alpha:P.identifier({text:`alpha`}),alphanumeric:P.identifier({text:`alphanumeric`}),base64:P.identifier({text:`base64`}),capitalize:P.identifier({text:`capitalize`}),creditCard:P.identifier({text:`creditCard`}),date:`date`,digits:P.identifier({text:`digits`}),email:`email`,epoch:P.identifier({text:`epoch`}),hex:P.identifier({text:`hex`}),integer:P.identifier({text:`integer`}),ip:`ip`,iso:`iso`,json:P.identifier({text:`json`}),lower:P.identifier({text:`lower`}),normalize:P.identifier({text:`normalize`}),numeric:P.identifier({text:`numeric`}),parse:P.identifier({text:`parse`}),preformatted:P.identifier({text:`preformatted`}),regex:P.identifier({text:`regex`}),semver:P.identifier({text:`semver`}),trim:P.identifier({text:`trim`}),upper:P.identifier({text:`upper`}),url:`url`,uuid:`uuid`,v1:`v1`,v2:`v2`,v3:`v3`,v4:`v4`,v5:`v5`,v6:`v6`,v7:`v7`,v8:`v8`},type:{$:P.identifier({text:`$`}),allows:P.identifier({text:`allows`}),and:P.identifier({text:`and`}),array:P.identifier({text:`array`}),as:P.identifier({text:`as`}),assert:P.identifier({text:`assert`}),brand:P.identifier({text:`brand`}),configure:P.identifier({text:`configure`}),default:P.identifier({text:`default`}),describe:P.identifier({text:`describe`}),description:P.identifier({text:`description`}),equals:P.identifier({text:`equals`}),exclude:P.identifier({text:`exclude`}),expression:P.identifier({text:`expression`}),extends:P.identifier({text:`extends`}),extract:P.identifier({text:`extract`}),filter:P.identifier({text:`filter`}),from:P.identifier({text:`from`}),ifEquals:P.identifier({text:`ifEquals`}),ifExtends:P.identifier({text:`ifExtends`}),infer:P.identifier({text:`infer`}),inferIn:P.identifier({text:`inferIn`}),intersect:P.identifier({text:`intersect`}),json:P.identifier({text:`json`}),meta:P.identifier({text:`meta`}),narrow:P.identifier({text:`narrow`}),onDeepUndeclaredKey:P.identifier({text:`onDeepUndeclaredKey`}),onUndeclaredKey:P.identifier({text:`onUndeclaredKey`}),optional:P.identifier({text:`optional`}),or:P.identifier({text:`or`}),overlaps:P.identifier({text:`overlaps`}),pipe:P.identifier({text:`pipe`}),select:P.identifier({text:`select`}),to:P.identifier({text:`to`}),toJsonSchema:P.identifier({text:`toJsonSchema`})}},Af=({ast:e,plugin:t,schema:n,symbol:r,typeInferSymbol:i})=>{let a=t.referenceSymbol(t.api.selector(`external`,`arktype.type`)),o=P.constVariable({comment:t.config.comments?Ju({schema:n}):void 0,exportConst:r.exported,expression:P.callExpression({functionName:a.placeholder,parameters:[e.def?P.stringLiteral({text:e.def}):e.expression]}),name:r.placeholder});if(t.setSymbolValue(r,o),i){let e=P.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:l.factory.createTypeQueryNode(l.factory.createQualifiedName(l.factory.createIdentifier(r.placeholder),Y.type.infer))});t.setSymbolValue(i,e)}},jf=e=>{let t={};return t.def=Y.primitives.null,t},Mf=({plugin:e,schema:t,state:n})=>{let r={},i=[],a=t.required??[];for(let o in t.properties){let s=t.properties[o],c=a.includes(o),u=Ff({optional:!c,plugin:e,schema:s,state:{...n,path:K([...n.path.value,`properties`,o])}});u.hasLazyExpression&&(r.hasLazyExpression=!0);let d=c?o:`${o}?`;d.endsWith(`?`)?d=l.factory.createComputedPropertyName(P.stringLiteral({text:d})):((d.match(/^[0-9]/)&&d.match(/\D+/g)||d.match(/\W/g))&&!d.startsWith(`'`)&&!d.endsWith(`'`)&&(d=`'${d}'`),O.lastIndex=0,d=O.test(d)?d.startsWith(`-`)?P.stringLiteral({text:o}):l.factory.createNumericLiteral(o):o),i.push(P.propertyAssignment({initializer:u.expression,name:d}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=Ff({plugin:e,schema:t.additionalProperties,state:{...n,path:K([...n.path.value,`additionalProperties`])}});return r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:`TODO`,name:`record`}),parameters:[P.callExpression({functionName:P.propertyAccessExpression({expression:`TODO`,name:`string`}),parameters:[]}),i.expression]}),i.hasLazyExpression&&(r.hasLazyExpression=!0),r.hasLazyExpression?{...r,typeName:`TODO`}:r}return r.expression=l.factory.createObjectLiteralExpression(i,!0),r.hasLazyExpression?{...r,typeName:`TODO`}:r},Nf=({schema:e})=>{let t={};if(typeof e.const==`string`)return t.def=e.const,t;let n=Y.primitives.string;if(e.format)switch(e.format){case`date`:case`date-time`:case`time`:n=`${n}.${Y.string.date}.${Y.string.iso}`;break;case`email`:n=`${n}.${Y.string.email}`;break;case`ipv4`:n=`${n}.${Y.string.ip}.${Y.string.v4}`;break;case`ipv6`:n=`${n}.${Y.string.ip}.${Y.string.v6}`;break;case`uri`:n=`${n}.${Y.string.url}`;break;case`uuid`:n=`${n}.${Y.string.uuid}`;break}return e.minLength===e.maxLength&&e.minLength!==void 0?n=`${e.minLength} <= ${n} <= ${e.maxLength}`:e.maxLength===void 0?e.minLength!==void 0&&(n=`${n} >= ${e.minLength}`):(n=`${n} <= ${e.maxLength}`,e.minLength!==void 0&&(n=`${e.minLength} <= ${n}`)),e.pattern&&(n=`/${e.pattern}/`),t.def=n,t},Pf=({schema:e,...t})=>{switch(e.type){case`null`:return jf({...t,schema:e});case`object`:return Mf({...t,schema:e});case`string`:return Nf({...t,schema:e})}let n=t.plugin.referenceSymbol(t.plugin.api.selector(`external`,`arktype.type`));return{def:``,expression:l.factory.createCallExpression(l.factory.createIdentifier(n.placeholder),void 0,[l.factory.createObjectLiteralExpression([l.factory.createPropertyAssignment(`name`,l.factory.createStringLiteral(`string`)),l.factory.createPropertyAssignment(`platform`,l.factory.createStringLiteral(`'android' | 'ios'`)),l.factory.createPropertyAssignment(l.factory.createComputedPropertyName(l.factory.createStringLiteral(`versions?`)),l.factory.createStringLiteral(`(number | string)[]`))],!0)]),hasLazyExpression:!1}},Ff=({plugin:e,schema:t,state:n})=>{let r={};if(t.$ref){let i=e.api.selector(`ref`,t.$ref),a=e.referenceSymbol(i);e.isSymbolRegistered(i)?r.expression=P.identifier({text:a.placeholder}):(r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:`TODO`,name:`TODO`}),parameters:[P.arrowFunction({returnType:P.keywordTypeNode({keyword:`any`}),statements:[P.returnStatement({expression:P.identifier({text:a.placeholder})})]})]}),r.hasLazyExpression=!0,n.hasLazyExpression.value=!0)}else if(t.type){let i=Pf({plugin:e,schema:t,state:n});r.def=i.def,r.expression=i.expression,r.hasLazyExpression=i.hasLazyExpression,e.config.metadata&&t.description}else if(t.items)t=T({schema:t}),t.items||(r=Ff({plugin:e,schema:t,state:n}));else{let t=Pf({plugin:e,schema:{type:`unknown`},state:n});r.def=t.def,r.expression=t.expression}return r.expression||=Pf({plugin:e,schema:{type:`unknown`},state:n}).expression,r},If=({plugin:e,schema:t,state:n})=>{let r=or(n.path.value),i=Ff({plugin:e,schema:t,state:n}),a=F(r);Af({ast:i,plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{path:n.path.value},name:w({config:e.config.definitions,name:a}),selector:e.api.selector(`ref`,r)}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value},name:w({config:e.config.definitions.types.infer,name:a}),selector:e.api.selector(`type-infer-ref`,r)}):void 0})},Lf=({plugin:e})=>{e.registerSymbol({external:`arktype`,name:`type`,selector:e.api.selector(`external`,`arktype.type`)}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=q({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`parameter`:If({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:If({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:If({plugin:e,schema:t.schema,state:n});break}})},Rf={api:new kf({name:`arktype`}),config:{case:`PascalCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:e=>Lf(e),name:`arktype`,resolveConfig:(e,t)=>{e.config.types=t.valueToObject({defaultValue:{infer:{case:`PascalCase`,enabled:!1}},mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:S,value:e.infer})})},value:e.config.types}),e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,enabled:!0,name:`{{name}}`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}`}}},mappers:{...S,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:S,value:e.infer})})},value:e.types})})},value:e.config.definitions}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,enabled:!0,name:`{{name}}Data`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}Data`}}},mappers:{...S,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:S,value:e.infer})})},value:e.types})})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,enabled:!0,name:`{{name}}Response`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}Response`}}},mappers:{...S,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:S,value:e.infer})})},value:e.types})})},value:e.config.responses}),e.config.webhooks=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,enabled:!0,name:`{{name}}WebhookRequest`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}WebhookRequest`}}},mappers:{...S,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:S,value:e.infer})})},value:e.types})})},value:e.config.webhooks})},tags:[`validator`]};var zf=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const Bf=({operation:e,plugin:t})=>{let n=[],r=t.getPluginOrThrow(`@hey-api/typescript`),i=t.getSymbol(r.api.selector(`data`,e.id));i&&(e.body&&n.push({isRequired:e.body.required,name:`Body`,type:`${i.placeholder}['body']`}),e.parameters&&(e.parameters.header&&n.push({isRequired:nt(e.parameters.header),name:`Headers`,type:`${i.placeholder}['headers']`}),e.parameters.path&&n.push({isRequired:nt(e.parameters.path),name:`Params`,type:`${i.placeholder}['path']`}),e.parameters.query&&n.push({isRequired:nt(e.parameters.query),name:`Querystring`,type:`${i.placeholder}['query']`})));let{errors:a,responses:o}=ct(e),s,c=t.getSymbol(r.api.selector(`errors`,e.id));if(c&&a&&a.properties){let e=Object.keys(a.properties);if(e.length){if(!e.includes(`default`))s=P.typeReferenceNode({typeName:c.placeholder});else if(e.length>1){let e=P.typeReferenceNode({typeName:c.placeholder}),t=P.literalTypeNode({literal:P.stringLiteral({text:`default`})});s=P.typeReferenceNode({typeArguments:[e,t],typeName:`Omit`})}}}let l,u=t.getSymbol(r.api.selector(`responses`,e.id));if(u&&o&&o.properties){let e=Object.keys(o.properties);if(e.length){if(!e.includes(`default`))l=P.typeReferenceNode({typeName:u.placeholder});else if(e.length>1){let e=P.typeReferenceNode({typeName:u.placeholder}),t=P.literalTypeNode({literal:P.stringLiteral({text:`default`})});l=P.typeReferenceNode({typeArguments:[e,t],typeName:`Omit`})}}}let d=[s,l].filter(Boolean);if(d.length&&n.push({name:`Reply`,type:P.typeIntersectionNode({types:d})}),!n.length)return;let f=t.referenceSymbol(t.api.selector(`RouteHandler`));return{name:e.id,type:P.typeReferenceNode({typeArguments:[P.typeInterfaceNode({properties:n,useLegacyResolution:!1})],typeName:f.placeholder})}},Vf={api:new zf({name:`fastify`}),config:{exportFromIndex:!1},dependencies:[`@hey-api/typescript`],handler:({plugin:e})=>{e.registerSymbol({external:`fastify`,meta:{kind:`type`},name:`RouteHandler`,selector:e.api.selector(`RouteHandler`)});let t=e.registerSymbol({exported:!0,meta:{kind:`type`},name:`RouteHandlers`}),n=[];e.forEach(`operation`,({operation:t})=>{let r=Bf({operation:t,plugin:e});r&&n.push(r)},{order:`declarations`});let r=P.typeAliasDeclaration({exportType:t.exported,name:t.placeholder,type:P.typeInterfaceNode({properties:n,useLegacyResolution:!1})});e.setSymbolValue(t,r)},name:`fastify`},X={actions:{args:P.identifier({text:`args`}),base64:P.identifier({text:`base64`}),bic:P.identifier({text:`bic`}),brand:P.identifier({text:`brand`}),bytes:P.identifier({text:`bytes`}),check:P.identifier({text:`check`}),checkItems:P.identifier({text:`checkItems`}),creditCard:P.identifier({text:`creditCard`}),cuid2:P.identifier({text:`cuid2`}),decimal:P.identifier({text:`decimal`}),description:P.identifier({text:`description`}),digits:P.identifier({text:`digits`}),email:P.identifier({text:`email`}),emoji:P.identifier({text:`emoji`}),empty:P.identifier({text:`empty`}),endsWith:P.identifier({text:`endsWith`}),entries:P.identifier({text:`entries`}),everyItem:P.identifier({text:`everyItem`}),excludes:P.identifier({text:`excludes`}),filterItems:P.identifier({text:`filterItems`}),findItem:P.identifier({text:`findItem`}),finite:P.identifier({text:`finite`}),flavor:P.identifier({text:`flavor`}),graphemes:P.identifier({text:`graphemes`}),gtValue:P.identifier({text:`gtValue`}),hash:P.identifier({text:`hash`}),hexColor:P.identifier({text:`hexColor`}),hexadecimal:P.identifier({text:`hexadecimal`}),imei:P.identifier({text:`imei`}),includes:P.identifier({text:`includes`}),integer:P.identifier({text:`integer`}),ip:P.identifier({text:`ip`}),ipv4:P.identifier({text:`ipv4`}),ipv6:P.identifier({text:`ipv6`}),isoDate:P.identifier({text:`isoDate`}),isoDateTime:P.identifier({text:`isoDateTime`}),isoTime:P.identifier({text:`isoTime`}),isoTimeSecond:P.identifier({text:`isoTimeSecond`}),isoTimestamp:P.identifier({text:`isoTimestamp`}),isoWeek:P.identifier({text:`isoWeek`}),length:P.identifier({text:`length`}),ltValue:P.identifier({text:`ltValue`}),mac:P.identifier({text:`mac`}),mac48:P.identifier({text:`mac48`}),mac64:P.identifier({text:`mac64`}),mapItems:P.identifier({text:`mapItems`}),maxBytes:P.identifier({text:`maxBytes`}),maxEntries:P.identifier({text:`maxEntries`}),maxGraphemes:P.identifier({text:`maxGraphemes`}),maxLength:P.identifier({text:`maxLength`}),maxSize:P.identifier({text:`maxSize`}),maxValue:P.identifier({text:`maxValue`}),maxWords:P.identifier({text:`maxWords`}),metadata:P.identifier({text:`metadata`}),mimeType:P.identifier({text:`mimeType`}),minBytes:P.identifier({text:`minBytes`}),minEntries:P.identifier({text:`minEntries`}),minGraphemes:P.identifier({text:`minGraphemes`}),minLength:P.identifier({text:`minLength`}),minSize:P.identifier({text:`minSize`}),minValue:P.identifier({text:`minValue`}),minWords:P.identifier({text:`minWords`}),multipleOf:P.identifier({text:`multipleOf`}),nanoid:P.identifier({text:`nanoid`}),nonEmpty:P.identifier({text:`nonEmpty`}),normalize:P.identifier({text:`normalize`}),notBytes:P.identifier({text:`notBytes`}),notEntries:P.identifier({text:`notEntries`}),notGraphemes:P.identifier({text:`notGraphemes`}),notLength:P.identifier({text:`notLength`}),notSize:P.identifier({text:`notSize`}),notValue:P.identifier({text:`notValue`}),notValues:P.identifier({text:`notValues`}),notWords:P.identifier({text:`notWords`}),octal:P.identifier({text:`octal`}),parseJson:P.identifier({text:`parseJson`}),partialCheck:P.identifier({text:`partialCheck`}),rawCheck:P.identifier({text:`rawCheck`}),rawTransform:P.identifier({text:`rawTransform`}),readonly:P.identifier({text:`readonly`}),reduceItems:P.identifier({text:`reduceItems`}),regex:P.identifier({text:`regex`}),returns:P.identifier({text:`returns`}),rfcEmail:P.identifier({text:`rfcEmail`}),safeInteger:P.identifier({text:`safeInteger`}),size:P.identifier({text:`size`}),slug:P.identifier({text:`slug`}),someItem:P.identifier({text:`someItem`}),sortItems:P.identifier({text:`sortItems`}),startsWith:P.identifier({text:`startsWith`}),stringifyJson:P.identifier({text:`stringifyJson`}),title:P.identifier({text:`title`}),toLowerCase:P.identifier({text:`toLowerCase`}),toMaxValue:P.identifier({text:`toMaxValue`}),toMinValue:P.identifier({text:`toMinValue`}),toUpperCase:P.identifier({text:`toUpperCase`}),transform:P.identifier({text:`transform`}),trim:P.identifier({text:`trim`}),trimEnd:P.identifier({text:`trimEnd`}),trimStart:P.identifier({text:`trimStart`}),ulid:P.identifier({text:`ulid`}),url:P.identifier({text:`url`}),uuid:P.identifier({text:`uuid`}),value:P.identifier({text:`value`}),values:P.identifier({text:`values`}),words:P.identifier({text:`words`})},async:{argsAsync:P.identifier({text:`argsAsync`}),arrayAsync:P.identifier({text:`arrayAsync`}),awaitAsync:P.identifier({text:`awaitAsync`}),checkAsync:P.identifier({text:`checkAsync`}),checkItemsAsync:P.identifier({text:`checkItemsAsync`}),customAsync:P.identifier({text:`customAsync`}),exactOptionalAsync:P.identifier({text:`exactOptionalAsync`}),fallbackAsync:P.identifier({text:`fallbackAsync`}),forwardAsync:P.identifier({text:`forwardAsync`}),getDefaultsAsync:P.identifier({text:`getDefaultsAsync`}),getFallbacksAsync:P.identifier({text:`getFallbacksAsync`}),intersectAsync:P.identifier({text:`intersectAsync`}),lazyAsync:P.identifier({text:`lazyAsync`}),looseObjectAsync:P.identifier({text:`looseObjectAsync`}),looseTupleAsync:P.identifier({text:`looseTupleAsync`}),mapAsync:P.identifier({text:`mapAsync`}),nonNullableAsync:P.identifier({text:`nonNullableAsync`}),nonNullishAsync:P.identifier({text:`nonNullishAsync`}),nonOptionalAsync:P.identifier({text:`nonOptionalAsync`}),nullableAsync:P.identifier({text:`nullableAsync`}),nullishAsync:P.identifier({text:`nullishAsync`}),objectAsync:P.identifier({text:`objectAsync`}),objectWithRestAsync:P.identifier({text:`objectWithRestAsync`}),optionalAsync:P.identifier({text:`optionalAsync`}),parseAsync:P.identifier({text:`parseAsync`}),parserAsync:P.identifier({text:`parserAsync`}),partialAsync:P.identifier({text:`partialAsync`}),partialCheckAsync:P.identifier({text:`partialCheckAsync`}),pipeAsync:P.identifier({text:`pipeAsync`}),rawCheckAsync:P.identifier({text:`rawCheckAsync`}),rawTransformAsync:P.identifier({text:`rawTransformAsync`}),recordAsync:P.identifier({text:`recordAsync`}),requiredAsync:P.identifier({text:`requiredAsync`}),returnsAsync:P.identifier({text:`returnsAsync`}),safeParseAsync:P.identifier({text:`safeParseAsync`}),safeParserAsync:P.identifier({text:`safeParserAsync`}),setAsync:P.identifier({text:`setAsync`}),strictObjectAsync:P.identifier({text:`strictObjectAsync`}),strictTupleAsync:P.identifier({text:`strictTupleAsync`}),transformAsync:P.identifier({text:`transformAsync`}),tupleAsync:P.identifier({text:`tupleAsync`}),tupleWithRestAsync:P.identifier({text:`tupleWithRestAsync`}),undefinedableAsync:P.identifier({text:`undefinedableAsync`}),unionAsync:P.identifier({text:`unionAsync`}),variantAsync:P.identifier({text:`variantAsync`})},methods:{assert:P.identifier({text:`assert`}),config:P.identifier({text:`config`}),fallback:P.identifier({text:`fallback`}),flatten:P.identifier({text:`flatten`}),forward:P.identifier({text:`forward`}),getDefault:P.identifier({text:`getDefault`}),getDefaults:P.identifier({text:`getDefaults`}),getDescription:P.identifier({text:`getDescription`}),getFallback:P.identifier({text:`getFallback`}),getFallbacks:P.identifier({text:`getFallbacks`}),getMetadata:P.identifier({text:`getMetadata`}),getTitle:P.identifier({text:`getTitle`}),is:P.identifier({text:`is`}),keyof:P.identifier({text:`keyof`}),message:P.identifier({text:`message`}),omit:P.identifier({text:`omit`}),parse:P.identifier({text:`parse`}),parser:P.identifier({text:`parser`}),partial:P.identifier({text:`partial`}),pick:P.identifier({text:`pick`}),pipe:P.identifier({text:`pipe`}),required:P.identifier({text:`required`}),safeParse:P.identifier({text:`safeParse`}),safeParser:P.identifier({text:`safeParser`}),summarize:P.identifier({text:`summarize`}),unwrap:P.identifier({text:`unwrap`})},schemas:{any:P.identifier({text:`any`}),array:P.identifier({text:`array`}),bigInt:P.identifier({text:`bigint`}),blob:P.identifier({text:`blob`}),boolean:P.identifier({text:`boolean`}),custom:P.identifier({text:`custom`}),date:P.identifier({text:`date`}),enum:P.identifier({text:`enum`}),exactOptional:P.identifier({text:`exactOptional`}),file:P.identifier({text:`file`}),function:P.identifier({text:`function`}),instance:P.identifier({text:`instance`}),intersect:P.identifier({text:`intersect`}),lazy:P.identifier({text:`lazy`}),literal:P.identifier({text:`literal`}),looseObject:P.identifier({text:`looseObject`}),looseTuple:P.identifier({text:`looseTuple`}),map:P.identifier({text:`map`}),nan:P.identifier({text:`nan`}),never:P.identifier({text:`never`}),nonNullable:P.identifier({text:`nonNullable`}),nonNullish:P.identifier({text:`nonNullish`}),nonOptional:P.identifier({text:`nonOptional`}),null:P.identifier({text:`null`}),nullable:P.identifier({text:`nullable`}),nullish:P.identifier({text:`nullish`}),number:P.identifier({text:`number`}),object:P.identifier({text:`object`}),objectWithRest:P.identifier({text:`objectWithRest`}),optional:P.identifier({text:`optional`}),picklist:P.identifier({text:`picklist`}),promise:P.identifier({text:`promise`}),record:P.identifier({text:`record`}),set:P.identifier({text:`set`}),strictObject:P.identifier({text:`strictObject`}),strictTuple:P.identifier({text:`strictTuple`}),string:P.identifier({text:`string`}),symbol:P.identifier({text:`symbol`}),tuple:P.identifier({text:`tuple`}),tupleWithRest:P.identifier({text:`tupleWithRest`}),undefined:P.identifier({text:`undefined`}),undefinedable:P.identifier({text:`undefinedable`}),union:P.identifier({text:`union`}),unknown:P.identifier({text:`unknown`}),variant:P.identifier({text:`variant`}),void:P.identifier({text:`void`})},storages:{},types:{GenericSchema:P.identifier({text:`GenericSchema`})},utils:{}},Hf=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`data`,e.id));if(!n)return;let r=t.referenceSymbol(t.api.selector(`external`,`valibot.v`)),i=`data`;return P.arrowFunction({async:!0,parameters:[{name:i}],statements:[P.returnStatement({expression:P.awaitExpression({expression:P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:X.async.parseAsync}),parameters:[P.identifier({text:n.placeholder}),P.identifier({text:i})]})})})]})},Uf=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`responses`,e.id));if(!n)return;let r=t.referenceSymbol(t.api.selector(`external`,`valibot.v`)),i=`data`;return P.arrowFunction({async:!0,parameters:[{name:i}],statements:[P.returnStatement({expression:P.awaitExpression({expression:P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:X.async.parseAsync}),parameters:[P.identifier({text:n.placeholder}),P.identifier({text:i})]})})})]})};var Wf=class{constructor(e){this.meta=e}createRequestValidator(e){return Hf(e)}createResponseValidator(e){return Uf(e)}selector(...e){return[this.meta.name,...e]}};const Z=({pipes:e,plugin:t})=>{if(e.length===1)return e[0];let n=t.referenceSymbol(t.api.selector(`external`,`valibot.v`));return P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:X.methods.pipe}),parameters:e})},Gf=({ast:e,plugin:t,schema:n,state:r,symbol:i})=>{let a=t.referenceSymbol(t.api.selector(`external`,`valibot.v`)),o=P.constVariable({comment:t.config.comments?Ju({schema:n}):void 0,exportConst:i.exported,expression:Z({pipes:e.pipes,plugin:t}),name:i.placeholder,typeName:r.hasLazyExpression.value?P.propertyAccessExpression({expression:a.placeholder,name:e.typeName||X.types.GenericSchema.text}):void 0});t.setSymbolValue(i,o)},Kf={int16:{max:32767,maxError:`Invalid value: Expected int16 to be <= 2^15-1`,min:-32768,minError:`Invalid value: Expected int16 to be >= -2^15`,needsBigInt:!1},int32:{max:2147483647,maxError:`Invalid value: Expected int32 to be <= 2^31-1`,min:-2147483648,minError:`Invalid value: Expected int32 to be >= -2^31`,needsBigInt:!1},int64:{max:`9223372036854775807`,maxError:`Invalid value: Expected int64 to be <= 2^63-1`,min:`-9223372036854775808`,minError:`Invalid value: Expected int64 to be >= -2^63`,needsBigInt:!0},int8:{max:127,maxError:`Invalid value: Expected int8 to be <= 2^7-1`,min:-128,minError:`Invalid value: Expected int8 to be >= -2^7`,needsBigInt:!1},uint16:{max:65535,maxError:`Invalid value: Expected uint16 to be <= 2^16-1`,min:0,minError:`Invalid value: Expected uint16 to be >= 0`,needsBigInt:!1},uint32:{max:4294967295,maxError:`Invalid value: Expected uint32 to be <= 2^32-1`,min:0,minError:`Invalid value: Expected uint32 to be >= 0`,needsBigInt:!1},uint64:{max:`18446744073709551615`,maxError:`Invalid value: Expected uint64 to be <= 2^64-1`,min:`0`,minError:`Invalid value: Expected uint64 to be >= 0`,needsBigInt:!0},uint8:{max:255,maxError:`Invalid value: Expected uint8 to be <= 2^8-1`,min:0,minError:`Invalid value: Expected uint8 to be >= 0`,needsBigInt:!1}},qf=e=>e!==void 0&&e in Kf,Jf=e=>qf(e)&&Kf[e].needsBigInt,Yf=({isBigInt:e,value:t})=>{let n=P.valueToExpression({value:t});return e&&(typeof t==`bigint`||typeof t==`number`||typeof t==`string`||typeof t==`boolean`)?P.callExpression({functionName:`BigInt`,parameters:[n]}):n},Xf=({getAst:e,operation:t,plugin:n,state:r})=>{if(n.config.requests.enabled){let i=new Set,a={properties:{body:{type:`never`},path:{type:`never`},query:{type:`never`}},type:`object`};if(t.parameters){if(t.parameters.header){let e={},n=[];for(let r in t.parameters.header){let a=t.parameters.header[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`headers`))}Object.keys(e).length&&(a.properties.headers={properties:e,required:n,type:`object`})}if(t.parameters.path){let e={},n=[];for(let r in t.parameters.path){let a=t.parameters.path[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`path`))}Object.keys(e).length&&(a.properties.path={properties:e,required:n,type:`object`})}if(t.parameters.query){let e={},n=[];for(let r in t.parameters.query){let a=t.parameters.query[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`query`))}Object.keys(e).length&&(a.properties.query={properties:e,required:n,type:`object`})}}t.body&&(a.properties.body=t.body.schema,t.body.required&&i.add(`body`)),a.required=[...i],Gf({ast:e(a,r.path.value),plugin:n,schema:a,state:r,symbol:n.registerSymbol({exported:!0,meta:{path:r.path.value,tags:r.tags?.value},name:w({config:n.config.requests,name:t.id}),selector:n.api.selector(`data`,t.id)})})}if(n.config.responses.enabled&&t.responses){let{response:i}=ct(t);if(i){let a=[...r.path.value,`responses`];Gf({ast:e(i,a),plugin:n,schema:i,state:r,symbol:n.registerSymbol({exported:!0,meta:{path:a,tags:r.tags?.value},name:w({config:n.config.responses,name:t.id}),selector:n.api.selector(`responses`,t.id)})})}}},Zf=({getAst:e,operation:t,plugin:n,state:r})=>{if(n.config.webhooks.enabled){let i=new Set,a={properties:{body:{type:`never`},path:{type:`never`},query:{type:`never`}},type:`object`};if(t.parameters){if(t.parameters.header){let e={},n=[];for(let r in t.parameters.header){let a=t.parameters.header[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`headers`))}Object.keys(e).length&&(a.properties.headers={properties:e,required:n,type:`object`})}if(t.parameters.path){let e={},n=[];for(let r in t.parameters.path){let a=t.parameters.path[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`path`))}Object.keys(e).length&&(a.properties.path={properties:e,required:n,type:`object`})}if(t.parameters.query){let e={},n=[];for(let r in t.parameters.query){let a=t.parameters.query[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`query`))}Object.keys(e).length&&(a.properties.query={properties:e,required:n,type:`object`})}}t.body&&(a.properties.body=t.body.schema,t.body.required&&i.add(`body`)),a.required=[...i],Gf({ast:e(a,r.path.value),plugin:n,schema:a,state:r,symbol:n.registerSymbol({exported:!0,meta:{path:r.path.value,tags:r.tags?.value},name:w({config:n.config.webhooks,name:t.id}),selector:n.api.selector(`webhook-request`,t.id)})})}},Qf=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:X.schemas.unknown})})},$f=({plugin:e,schema:t,state:n})=>{let r={pipes:[]},i=e.referenceSymbol(e.api.selector(`external`,`valibot.v`)),a=P.propertyAccessExpression({expression:i.placeholder,name:X.schemas.array});if(t.items){t=T({schema:t});let i=t.items.map((t,i)=>{let a=dp({plugin:e,schema:t,state:{...n,path:K([...n.path.value,`items`,i])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),Z({pipes:a.pipes,plugin:e})});if(i.length===1){let e=P.callExpression({functionName:a,parameters:i});r.pipes.push(e)}else{t.logicalOperator;let i=P.callExpression({functionName:a,parameters:[Qf({plugin:e,schema:{type:`unknown`},state:n})]});r.pipes.push(i)}}else{let t=P.callExpression({functionName:a,parameters:[Qf({plugin:e,schema:{type:`unknown`},state:n})]});r.pipes.push(t)}if(t.minItems===t.maxItems&&t.minItems!==void 0){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:X.actions.length}),parameters:[P.valueToExpression({value:t.minItems})]});r.pipes.push(e)}else{if(t.minItems!==void 0){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:X.actions.minLength}),parameters:[P.valueToExpression({value:t.minItems})]});r.pipes.push(e)}if(t.maxItems!==void 0){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:X.actions.maxLength}),parameters:[P.valueToExpression({value:t.maxItems})]});r.pipes.push(e)}}return r},ep=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return typeof t.const==`boolean`?P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:X.schemas.literal}),parameters:[P.ots.boolean(t.const)]}):P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:X.schemas.boolean})})},tp=({plugin:e,schema:t,state:n})=>{let r=[],i=!1;for(let e of t.items??[])e.type===`string`&&typeof e.const==`string`?r.push(P.stringLiteral({text:e.const})):(e.type===`null`||e.const===null)&&(i=!0);if(!r.length)return Qf({plugin:e,schema:{type:`unknown`},state:n});let a=e.referenceSymbol(e.api.selector(`external`,`valibot.v`)),o=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:X.schemas.picklist}),parameters:[P.arrayLiteralExpression({elements:r,multiLine:!1})]});return i&&(o=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:X.schemas.nullable}),parameters:[o]})),o},np=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:X.schemas.never})})},rp=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:X.schemas.null})})},ip=({plugin:e,schema:t})=>{let n=t.format,r=t.type===`integer`,i=Jf(n),a=qf(n)?Kf[n]:null,o=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));if(t.const!==void 0&&t.const!==null){let e=t.const,r;if(typeof e==`number`&&!n)r=P.ots.number(e);else if(typeof e==`number`&&n)r=i?P.callExpression({functionName:`BigInt`,parameters:[P.ots.string(e.toString())]}):P.ots.number(e);else if(typeof e==`string`&&i){let t=e.endsWith(`n`)?e.slice(0,-1):e;r=P.callExpression({functionName:`BigInt`,parameters:[P.ots.string(t)]})}else if(typeof e==`bigint`){let t=e.toString(),n=t.endsWith(`n`)?t.slice(0,-1):t;r=P.callExpression({functionName:`BigInt`,parameters:[P.ots.string(n)]})}else r=P.valueToExpression({value:e});return P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.schemas.literal}),parameters:[r]})}let s=[];if(i){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.schemas.union}),parameters:[P.arrayLiteralExpression({elements:[P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.schemas.number})}),P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.schemas.string})}),P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.schemas.bigInt})})],multiLine:!1})]});s.push(e);let t=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.actions.transform}),parameters:[P.arrowFunction({parameters:[{name:`x`}],statements:P.callExpression({functionName:`BigInt`,parameters:[P.identifier({text:`x`})]})})]});s.push(t)}else{let e=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.schemas.number})});s.push(e)}if(!i&&r){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.actions.integer})});s.push(e)}if(a){let e=a.min,t=a.max,n=a.minError,r=a.maxError,c=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.actions.minValue}),parameters:[i?P.callExpression({functionName:`BigInt`,parameters:[P.ots.string(e.toString())]}):P.ots.number(e),P.ots.string(n)]});s.push(c);let l=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.actions.maxValue}),parameters:[i?P.callExpression({functionName:`BigInt`,parameters:[P.ots.string(t.toString())]}):P.ots.number(t),P.ots.string(r)]});s.push(l)}if(t.exclusiveMinimum!==void 0){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.actions.gtValue}),parameters:[Yf({isBigInt:i,value:t.exclusiveMinimum})]});s.push(e)}else if(t.minimum!==void 0){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.actions.minValue}),parameters:[Yf({isBigInt:i,value:t.minimum})]});s.push(e)}if(t.exclusiveMaximum!==void 0){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.actions.ltValue}),parameters:[Yf({isBigInt:i,value:t.exclusiveMaximum})]});s.push(e)}else if(t.maximum!==void 0){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.actions.maxValue}),parameters:[Yf({isBigInt:i,value:t.maximum})]});s.push(e)}return Z({pipes:s,plugin:e})},ap=({plugin:e,schema:t,state:n})=>{let r={},i=[],a=t.required??[];for(let o in t.properties){let s=t.properties[o],c=dp({optional:!a.includes(o),plugin:e,schema:s,state:{...n,path:K([...n.path.value,`properties`,o])}});c.hasLazyExpression&&(r.hasLazyExpression=!0),O.lastIndex=0;let u;u=O.test(o)?o.startsWith(`-`)?l.factory.createStringLiteral(o):l.factory.createNumericLiteral(o):o,(o.match(/^[0-9]/)&&o.match(/\D+/g)||o.match(/\W/g))&&!o.startsWith(`'`)&&!o.endsWith(`'`)&&(u=`'${o}'`),i.push(P.propertyAssignment({initializer:Z({pipes:c.pipes,plugin:e}),name:u}))}let o=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));if(t.additionalProperties&&t.additionalProperties.type===`object`&&!Object.keys(i).length){let i=dp({plugin:e,schema:t.additionalProperties,state:{...n,path:K([...n.path.value,`additionalProperties`])}});return i.hasLazyExpression&&(r.hasLazyExpression=!0),r.pipes=[P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.schemas.record}),parameters:[P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.schemas.string}),parameters:[]}),Z({pipes:i.pipes,plugin:e})]})],r}return r.pipes=[P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.schemas.object}),parameters:[l.factory.createObjectLiteralExpression(i,!0)]})],r},op=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));if(typeof t.const==`string`)return P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:X.schemas.literal}),parameters:[P.ots.string(t.const)]});let r=[],i=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:X.schemas.string})});if(r.push(i),t.format)switch(t.format){case`date`:r.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:X.actions.isoDate})}));break;case`date-time`:r.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:X.actions.isoTimestamp})}));break;case`ipv4`:case`ipv6`:r.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:X.actions.ip})}));break;case`uri`:r.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:X.actions.url})}));break;case`email`:case`time`:case`uuid`:r.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:P.identifier({text:t.format})})}));break}if(t.minLength===t.maxLength&&t.minLength!==void 0){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:X.actions.length}),parameters:[P.valueToExpression({value:t.minLength})]});r.push(e)}else{if(t.minLength!==void 0){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:X.actions.minLength}),parameters:[P.valueToExpression({value:t.minLength})]});r.push(e)}if(t.maxLength!==void 0){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:X.actions.maxLength}),parameters:[P.valueToExpression({value:t.maxLength})]});r.push(e)}}if(t.pattern){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:X.actions.regex}),parameters:[P.regularExpressionLiteral({text:t.pattern})]});r.push(e)}return Z({pipes:r,plugin:e})},sp=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:X.schemas.literal}),parameters:[P.valueToExpression({value:e})]}));return r.pipes=[P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:X.schemas.tuple}),parameters:[P.arrayLiteralExpression({elements:e})]})],r}if(t.items){let a=t.items.map((t,i)=>{let a=dp({plugin:e,schema:t,state:{...n,path:K([...n.path.value,`items`,i])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),Z({pipes:a.pipes,plugin:e})});return r.pipes=[P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:X.schemas.tuple}),parameters:[P.arrayLiteralExpression({elements:a})]})],r}return{pipes:[Qf({plugin:e,schema:{type:`unknown`},state:n})]}},cp=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:X.schemas.undefined})})},lp=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:X.schemas.void})})},up=({schema:e,...t})=>{switch(e.type){case`array`:return{expression:Z({pipes:$f({...t,schema:e}).pipes,plugin:t.plugin})};case`boolean`:return{expression:ep({...t,schema:e})};case`enum`:return{expression:tp({...t,schema:e})};case`integer`:case`number`:return{expression:ip({...t,schema:e})};case`never`:return{expression:np({...t,schema:e})};case`null`:return{expression:rp({...t,schema:e})};case`object`:return{expression:Z({pipes:ap({...t,schema:e}).pipes,plugin:t.plugin})};case`string`:return e.format===`int64`||e.format===`uint64`?{expression:ip({...t,schema:e})}:{expression:op({...t,schema:e})};case`tuple`:return{expression:Z({pipes:sp({...t,schema:e}).pipes,plugin:t.plugin})};case`undefined`:return{expression:cp({...t,schema:e})};case`unknown`:return{expression:Qf({...t,schema:e})};case`void`:return{expression:lp({...t,schema:e})}}},dp=({optional:e,plugin:t,schema:n,state:r})=>{let i={pipes:[]},a=t.referenceSymbol(t.api.selector(`external`,`valibot.v`));if(n.$ref){let e=t.api.selector(`ref`,n.$ref),o=t.referenceSymbol(e);if(t.isSymbolRegistered(e)){let e=P.identifier({text:o.placeholder});i.pipes.push(e)}else{let e=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:X.schemas.lazy}),parameters:[P.arrowFunction({statements:[P.returnStatement({expression:P.identifier({text:o.placeholder})})]})]});i.pipes.push(e),r.hasLazyExpression.value=!0}}else if(n.type){let e=up({plugin:t,schema:n,state:r});if(i.typeName=e.anyType,i.pipes.push(e.expression),t.config.metadata&&n.description){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:X.actions.metadata}),parameters:[P.objectExpression({obj:[{key:`description`,value:P.stringLiteral({text:n.description})}]})]});i.pipes.push(e)}}else if(n.items)if(n=T({schema:n}),n.items){let e=n.items.map((e,n)=>Z({pipes:dp({plugin:t,schema:e,state:{...r,path:K([...r.path.value,`items`,n])}}).pipes,plugin:t}));if(n.logicalOperator===`and`){let t=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:X.schemas.intersect}),parameters:[P.arrayLiteralExpression({elements:e})]});i.pipes.push(t)}else{let t=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:X.schemas.union}),parameters:[P.arrayLiteralExpression({elements:e})]});i.pipes.push(t)}}else{let e=dp({plugin:t,schema:n,state:r});i.pipes.push(...e.pipes)}else{let e=up({plugin:t,schema:{type:`unknown`},state:r});i.typeName=e.anyType,i.pipes.push(e.expression)}if(i.pipes.length){if(n.accessScope===`read`){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:X.actions.readonly})});i.pipes.push(e)}let r;n.default!==void 0&&(r=Yf({isBigInt:n.type===`integer`&&n.format===`int64`,value:n.default}),r&&(i.pipes=[P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:X.schemas.optional}),parameters:[Z({pipes:i.pipes,plugin:t}),r]})])),e&&!r&&(i.pipes=[P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:X.schemas.optional}),parameters:[Z({pipes:i.pipes,plugin:t})]})])}return i},fp=({plugin:e,schema:t,state:n})=>{let r=or(n.path.value),i=dp({plugin:e,schema:t,state:n}),a=F(r);Gf({ast:i,plugin:e,schema:t,state:n,symbol:e.registerSymbol({exported:!0,meta:{path:n.path.value,tags:n.tags?.value},name:w({config:e.config.definitions,name:a}),selector:e.api.selector(`ref`,r)})})},pp=({plugin:e})=>{e.registerSymbol({external:`valibot`,meta:{importKind:`namespace`},name:`v`,selector:e.api.selector(`external`,`valibot.v`)}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=q({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:Xf({getAst:(n,r)=>dp({plugin:e,schema:n,state:q({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:fp({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:fp({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:fp({plugin:e,schema:t.schema,state:n});break;case`webhook`:Zf({getAst:(n,r)=>dp({plugin:e,schema:n,state:q({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},mp={api:new Wf({name:`valibot`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:e=>pp(e),name:`valibot`,resolveConfig:(e,t)=>{e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`v{{name}}`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.definitions}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`v{{name}}Data`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`v{{name}}Response`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.responses}),e.config.webhooks=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`v{{name}}WebhookRequest`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.webhooks})},tags:[`validator`]},Q={ZodMiniOptional:P.identifier({text:`ZodMiniOptional`}),ZodOptional:P.identifier({text:`ZodOptional`}),_default:P.identifier({text:`_default`}),and:P.identifier({text:`and`}),array:P.identifier({text:`array`}),bigint:P.identifier({text:`bigint`}),boolean:P.identifier({text:`boolean`}),check:P.identifier({text:`check`}),coerce:P.identifier({text:`coerce`}),date:P.identifier({text:`date`}),datetime:P.identifier({text:`datetime`}),default:P.identifier({text:`default`}),describe:P.identifier({text:`describe`}),email:P.identifier({text:`email`}),enum:P.identifier({text:`enum`}),globalRegistry:P.identifier({text:`globalRegistry`}),gt:P.identifier({text:`gt`}),gte:P.identifier({text:`gte`}),infer:P.identifier({text:`infer`}),int:P.identifier({text:`int`}),intersection:P.identifier({text:`intersection`}),ip:P.identifier({text:`ip`}),ipv4:P.identifier({text:`ipv4`}),ipv6:P.identifier({text:`ipv6`}),iso:P.identifier({text:`iso`}),lazy:P.identifier({text:`lazy`}),length:P.identifier({text:`length`}),literal:P.identifier({text:`literal`}),lt:P.identifier({text:`lt`}),lte:P.identifier({text:`lte`}),max:P.identifier({text:`max`}),maxLength:P.identifier({text:`maxLength`}),min:P.identifier({text:`min`}),minLength:P.identifier({text:`minLength`}),never:P.identifier({text:`never`}),null:P.identifier({text:`null`}),nullable:P.identifier({text:`nullable`}),number:P.identifier({text:`number`}),object:P.identifier({text:`object`}),optional:P.identifier({text:`optional`}),parseAsync:P.identifier({text:`parseAsync`}),readonly:P.identifier({text:`readonly`}),record:P.identifier({text:`record`}),regex:P.identifier({text:`regex`}),register:P.identifier({text:`register`}),string:P.identifier({text:`string`}),time:P.identifier({text:`time`}),tuple:P.identifier({text:`tuple`}),undefined:P.identifier({text:`undefined`}),union:P.identifier({text:`union`}),unknown:P.identifier({text:`unknown`}),url:P.identifier({text:`url`}),uuid:P.identifier({text:`uuid`}),void:P.identifier({text:`void`})},hp=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`data`,e.id));if(!n)return;let r=`data`;return P.arrowFunction({async:!0,parameters:[{name:r}],statements:[P.returnStatement({expression:P.awaitExpression({expression:P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[P.identifier({text:r})]})})})]})},gp=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`responses`,e.id));if(!n)return;let r=`data`;return P.arrowFunction({async:!0,parameters:[{name:r}],statements:[P.returnStatement({expression:P.awaitExpression({expression:P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[P.identifier({text:r})]})})})]})},_p=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`data`,e.id));if(!n)return;let r=`data`;return P.arrowFunction({async:!0,parameters:[{name:r}],statements:[P.returnStatement({expression:P.awaitExpression({expression:P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[P.identifier({text:r})]})})})]})},vp=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`responses`,e.id));if(!n)return;let r=`data`;return P.arrowFunction({async:!0,parameters:[{name:r}],statements:[P.returnStatement({expression:P.awaitExpression({expression:P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[P.identifier({text:r})]})})})]})},yp=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`data`,e.id));if(!n)return;let r=`data`;return P.arrowFunction({async:!0,parameters:[{name:r}],statements:[P.returnStatement({expression:P.awaitExpression({expression:P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[P.identifier({text:r})]})})})]})},bp=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`responses`,e.id));if(!n)return;let r=`data`;return P.arrowFunction({async:!0,parameters:[{name:r}],statements:[P.returnStatement({expression:P.awaitExpression({expression:P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[P.identifier({text:r})]})})})]})};var xp=class{constructor(e){this.meta=e}createRequestValidator(e){let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return _p(e);case`mini`:return hp(e);case 4:default:return yp(e)}}createResponseValidator(e){let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return vp(e);case`mini`:return gp(e);case 4:default:return bp(e)}}selector(...e){return[this.meta.name,...e]}};const Sp=({ast:e,plugin:t,schema:n,symbol:r,typeInferSymbol:i})=>{let a=t.referenceSymbol(t.api.selector(`external`,`zod.z`)),o=P.constVariable({comment:t.config.comments?Ju({schema:n}):void 0,exportConst:r.exported,expression:e.expression,name:r.placeholder,typeName:e.typeName?P.propertyAccessExpression({expression:a.placeholder,name:e.typeName}):void 0});if(t.setSymbolValue(r,o),i){let e=P.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:P.typeReferenceNode({typeArguments:[P.typeOfExpression({text:r.placeholder})],typeName:P.propertyAccessExpression({expression:a.placeholder,name:Q.infer})})});t.setSymbolValue(i,e)}},Cp=({plugin:e})=>{let t=e.package.getVersion(`zod`);if(t&&e.package.satisfies(t,`<4.0.0`))switch(e.config.compatibilityVersion){case 3:default:return`zod`;case 4:return`zod/v4`;case`mini`:return`zod/v4-mini`}switch(e.config.compatibilityVersion){case 3:return`zod/v3`;case 4:default:return`zod`;case`mini`:return`zod/mini`}},$=({isBigInt:e,value:t})=>{let n=P.valueToExpression({value:t});return e&&(typeof t==`bigint`||typeof t==`number`||typeof t==`string`||typeof t==`boolean`)?P.callExpression({functionName:`BigInt`,parameters:[n]}):n},wp=({getAst:e,operation:t,plugin:n,state:r})=>{if(n.config.requests.enabled){let i=new Set,a={properties:{body:{type:`never`},path:{type:`never`},query:{type:`never`}},type:`object`};if(t.parameters){if(t.parameters.header){let e={},n=[];for(let r in t.parameters.header){let a=t.parameters.header[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`headers`))}Object.keys(e).length&&(a.properties.headers={properties:e,required:n,type:`object`})}if(t.parameters.path){let e={},n=[];for(let r in t.parameters.path){let a=t.parameters.path[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`path`))}Object.keys(e).length&&(a.properties.path={properties:e,required:n,type:`object`})}if(t.parameters.query){let e={},n=[];for(let r in t.parameters.query){let a=t.parameters.query[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`query`))}Object.keys(e).length&&(a.properties.query={properties:e,required:n,type:`object`})}}t.body&&(a.properties.body=t.body.schema,t.body.required&&i.add(`body`)),a.required=[...i],Sp({ast:e(a,r.path.value),plugin:n,schema:a,symbol:n.registerSymbol({exported:!0,meta:{path:r.path.value,tags:r.tags?.value},name:w({config:n.config.requests,name:t.id}),selector:n.api.selector(`data`,t.id)}),typeInferSymbol:n.config.requests.types.infer.enabled?n.registerSymbol({exported:!0,meta:{kind:`type`,path:r.path.value,tags:r.tags?.value},name:w({config:n.config.requests.types.infer,name:t.id}),selector:n.api.selector(`type-infer-data`,t.id)}):void 0})}if(n.config.responses.enabled&&t.responses){let{response:i}=ct(t);if(i){let a=[...r.path.value,`responses`];Sp({ast:e(i,a),plugin:n,schema:i,symbol:n.registerSymbol({exported:!0,meta:{path:a,tags:r.tags?.value},name:w({config:n.config.responses,name:t.id}),selector:n.api.selector(`responses`,t.id)}),typeInferSymbol:n.config.responses.types.infer.enabled?n.registerSymbol({exported:!0,meta:{kind:`type`,path:a,tags:r.tags?.value},name:w({config:n.config.responses.types.infer,name:t.id}),selector:n.api.selector(`type-infer-responses`,t.id)}):void 0})}}},Tp=({getAst:e,operation:t,plugin:n,state:r})=>{if(n.config.webhooks.enabled){let i=new Set,a={properties:{body:{type:`never`},path:{type:`never`},query:{type:`never`}},type:`object`};if(t.parameters){if(t.parameters.header){let e={},n=[];for(let r in t.parameters.header){let a=t.parameters.header[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`headers`))}Object.keys(e).length&&(a.properties.headers={properties:e,required:n,type:`object`})}if(t.parameters.path){let e={},n=[];for(let r in t.parameters.path){let a=t.parameters.path[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`path`))}Object.keys(e).length&&(a.properties.path={properties:e,required:n,type:`object`})}if(t.parameters.query){let e={},n=[];for(let r in t.parameters.query){let a=t.parameters.query[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`query`))}Object.keys(e).length&&(a.properties.query={properties:e,required:n,type:`object`})}}t.body&&(a.properties.body=t.body.schema,t.body.required&&i.add(`body`)),a.required=[...i],Sp({ast:e(a,r.path.value),plugin:n,schema:a,symbol:n.registerSymbol({exported:!0,meta:{path:r.path.value,tags:r.tags?.value},name:w({config:n.config.webhooks,name:t.id}),selector:n.api.selector(`webhook-request`,t.id)}),typeInferSymbol:n.config.webhooks.types.infer.enabled?n.registerSymbol({exported:!0,meta:{kind:`type`,path:r.path.value,tags:r.tags?.value},name:w({config:n.config.webhooks.types.infer,name:t.id}),selector:n.api.selector(`type-infer-webhook-request`,t.id)}):void 0})}},Ep=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),n={};return n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:Q.unknown})}),n},Dp=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i={},a=P.propertyAccessExpression({expression:r.placeholder,name:Q.array});if(!t.items)i.expression=P.callExpression({functionName:a,parameters:[Ep({plugin:e,schema:{type:`unknown`},state:n}).expression]});else{t=T({schema:t});let o=t.items.map((t,r)=>{let a=zp({plugin:e,schema:t,state:{...n,path:K([...n.path.value,`items`,r])}});return a.hasLazyExpression&&(i.hasLazyExpression=!0),a.expression});if(o.length===1)i.expression=P.callExpression({functionName:a,parameters:o});else if(t.logicalOperator===`and`){let e=t.items[0],n;if(e.logicalOperator===`or`||e.type&&e.type!==`object`)n=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.intersection}),parameters:o});else{n=o[0];for(let e=1;e<o.length;e++)n=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.intersection}),parameters:[n,o[e]]})}i.expression=P.callExpression({functionName:a,parameters:[n]})}else i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.array}),parameters:[P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.union}),parameters:[P.arrayLiteralExpression({elements:o})]})]})}let o=[];return t.minItems===t.maxItems&&t.minItems!==void 0?o.push(P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.length}),parameters:[P.valueToExpression({value:t.minItems})]})):(t.minItems!==void 0&&o.push(P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.minLength}),parameters:[P.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&o.push(P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.maxLength}),parameters:[P.valueToExpression({value:t.maxItems})]}))),o.length&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.expression,name:Q.check}),parameters:o})),i},Op=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),r={};return typeof t.const==`boolean`?(r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[P.ots.boolean(t.const)]}),r):(r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.boolean})}),r)},kp=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i={},a=[],o=[],s=!1,c=!0;for(let e of t.items??[])if(e.type===`string`&&typeof e.const==`string`){let t=P.stringLiteral({text:e.const});a.push(t),o.push(P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[t]}))}else if((e.type===`number`||e.type===`integer`)&&typeof e.const==`number`){c=!1;let t=P.ots.number(e.const);o.push(P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[t]}))}else if(e.type===`boolean`&&typeof e.const==`boolean`){c=!1;let t=P.ots.boolean(e.const);o.push(P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[t]}))}else (e.type===`null`||e.const===null)&&(s=!0);return o.length?(c&&a.length>0?i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.enum}),parameters:[P.arrayLiteralExpression({elements:a,multiLine:!1})]}):o.length===1?i.expression=o[0]:i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.union}),parameters:[P.arrayLiteralExpression({elements:o,multiLine:o.length>3})]}),s&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.nullable}),parameters:[i.expression]})),i):Ep({plugin:e,schema:{type:`unknown`},state:n})},Ap=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),n={};return n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:Q.never})}),n},jp=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),n={};return n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:Q.null})}),n},Mp=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),r={},i=t.type===`integer`&&t.format===`int64`;if(typeof t.const==`number`)return r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[P.ots.number(t.const)]}),r;r.expression=P.callExpression({functionName:i?P.propertyAccessExpression({expression:P.propertyAccessExpression({expression:n.placeholder,name:Q.coerce}),name:Q.bigint}):P.propertyAccessExpression({expression:n.placeholder,name:Q.number})}),!i&&t.type===`integer`&&(r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.int})}));let a=[];return t.exclusiveMinimum===void 0?t.minimum!==void 0&&a.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.gte}),parameters:[$({isBigInt:i,value:t.minimum})]})):a.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.gt}),parameters:[$({isBigInt:i,value:t.exclusiveMinimum})]})),t.exclusiveMaximum===void 0?t.maximum!==void 0&&a.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.lte}),parameters:[$({isBigInt:i,value:t.maximum})]})):a.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.lt}),parameters:[$({isBigInt:i,value:t.exclusiveMaximum})]})),a.length&&(r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.expression,name:Q.check}),parameters:a})),r},Np=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i={},a=[],o=t.required??[];for(let r in t.properties){let s=t.properties[r],c=zp({optional:!o.includes(r),plugin:e,schema:s,state:{...n,path:K([...n.path.value,`properties`,r])}});c.hasLazyExpression&&(i.hasLazyExpression=!0),O.lastIndex=0;let u;u=O.test(r)?r.startsWith(`-`)?l.factory.createStringLiteral(r):l.factory.createNumericLiteral(r):r,(r.match(/^[0-9]/)&&r.match(/\D+/g)||r.match(/\W/g))&&!r.startsWith(`'`)&&!r.endsWith(`'`)&&(u=`'${r}'`),c.hasLazyExpression?a.push(P.getAccessorDeclaration({name:u,statements:[P.returnStatement({expression:c.expression})]})):a.push(P.propertyAssignment({initializer:c.expression,name:u}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let a=zp({plugin:e,schema:t.additionalProperties,state:{...n,path:K([...n.path.value,`additionalProperties`])}});return i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.record}),parameters:[P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.string}),parameters:[]}),a.expression]}),a.hasLazyExpression&&(i.hasLazyExpression=!0),i}return i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.object}),parameters:[l.factory.createObjectLiteralExpression(a,!0)]}),i},Pp=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),r={};if(typeof t.const==`string`)return r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[P.ots.string(t.const)]}),r;r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.string})});let i=[];if(e.config.dates.offset&&i.push({key:`offset`,value:!0}),e.config.dates.local&&i.push({key:`local`,value:!0}),t.format)switch(t.format){case`date`:r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:P.propertyAccessExpression({expression:n.placeholder,name:Q.iso}),name:Q.date})});break;case`date-time`:r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:P.propertyAccessExpression({expression:n.placeholder,name:Q.iso}),name:Q.datetime}),parameters:i.length>0?[P.objectExpression({obj:i})]:[]});break;case`email`:r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.email})});break;case`ipv4`:r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.ipv4})});break;case`ipv6`:r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.ipv6})});break;case`time`:r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:P.propertyAccessExpression({expression:n.placeholder,name:Q.iso}),name:Q.time})});break;case`uri`:r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.url})});break;case`uuid`:r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.uuid})});break}let a=[];return t.minLength===t.maxLength&&t.minLength!==void 0?a.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.length}),parameters:[P.valueToExpression({value:t.minLength})]})):(t.minLength!==void 0&&a.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.minLength}),parameters:[P.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&a.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.maxLength}),parameters:[P.valueToExpression({value:t.maxLength})]}))),t.pattern&&a.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.regex}),parameters:[P.regularExpressionLiteral({text:t.pattern})]})),a.length&&(r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.expression,name:Q.check}),parameters:a})),r},Fp=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i={};if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[P.valueToExpression({value:e})]}));return i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.tuple}),parameters:[P.arrayLiteralExpression({elements:e})]}),i}let a=[];return t.items&&t.items.forEach((t,r)=>{let o=zp({plugin:e,schema:t,state:{...n,path:K([...n.path.value,`items`,r])}});a.push(o.expression),o.hasLazyExpression&&(i.hasLazyExpression=!0)}),i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.tuple}),parameters:[P.arrayLiteralExpression({elements:a})]}),i},Ip=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),n={};return n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:Q.undefined})}),n},Lp=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),n={};return n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:Q.void})}),n},Rp=({schema:e,...t})=>{switch(e.type){case`array`:return Dp({...t,schema:e});case`boolean`:return Op({...t,schema:e});case`enum`:return kp({...t,schema:e});case`integer`:case`number`:return Mp({...t,schema:e});case`never`:return Ap({...t,schema:e});case`null`:return jp({...t,schema:e});case`object`:return Np({...t,schema:e});case`string`:return Pp({...t,schema:e});case`tuple`:return Fp({...t,schema:e});case`undefined`:return Ip({...t,schema:e});case`unknown`:return Ep({...t,schema:e});case`void`:return Lp({...t,schema:e})}},zp=({optional:e,plugin:t,schema:n,state:r})=>{let i={},a=t.referenceSymbol(t.api.selector(`external`,`zod.z`));if(n.$ref){let e=t.api.selector(`ref`,n.$ref),o=t.referenceSymbol(e);t.isSymbolRegistered(e)?i.expression=P.identifier({text:o.placeholder}):(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:Q.lazy}),parameters:[P.arrowFunction({returnType:P.keywordTypeNode({keyword:`any`}),statements:[P.returnStatement({expression:P.identifier({text:o.placeholder})})]})]}),i.hasLazyExpression=!0,r.hasLazyExpression.value=!0)}else if(n.type){let e=Rp({plugin:t,schema:n,state:r});i.expression=e.expression,i.hasLazyExpression=e.hasLazyExpression,t.config.metadata&&n.description&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.expression,name:Q.register}),parameters:[P.propertyAccessExpression({expression:a.placeholder,name:Q.globalRegistry}),P.objectExpression({obj:[{key:`description`,value:P.stringLiteral({text:n.description})}]})]}))}else if(n.items)if(n=T({schema:n}),n.items){let e=n.items.map((e,n)=>zp({plugin:t,schema:e,state:{...r,path:K([...r.path.value,`items`,n])}}));if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:Q.intersection}),parameters:e.map(e=>e.expression)}):(i.expression=e[0].expression,e.slice(1).forEach(e=>{i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:Q.intersection}),parameters:[i.expression,e.hasLazyExpression?P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:Q.lazy}),parameters:[P.arrowFunction({statements:[P.returnStatement({expression:e.expression})]})]}):e.expression]})}))}else i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:Q.union}),parameters:[P.arrayLiteralExpression({elements:e.map(e=>e.expression)})]})}else i=zp({plugin:t,schema:n,state:r});else i.expression=Rp({plugin:t,schema:{type:`unknown`},state:r}).expression;if(i.expression&&(n.accessScope===`read`&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:Q.readonly}),parameters:[i.expression]})),e&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:Q.optional}),parameters:[i.expression]}),i.typeName=Q.ZodMiniOptional),n.default!==void 0)){let e=$({isBigInt:n.type===`integer`&&n.format===`int64`,value:n.default});e&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:Q._default}),parameters:[i.expression,e]}))}return i},Bp=({plugin:e,schema:t,state:n})=>{let r=or(n.path.value),i=zp({plugin:e,schema:t,state:n}),a=F(r);Sp({ast:i,plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{path:n.path.value,tags:n.tags?.value},name:w({config:e.config.definitions,name:a}),selector:e.api.selector(`ref`,r)}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:w({config:e.config.definitions.types.infer,name:a}),selector:e.api.selector(`type-infer-ref`,r)}):void 0})},Vp=({plugin:e})=>{e.registerSymbol({external:Cp({plugin:e}),meta:{importKind:`namespace`},name:`z`,selector:e.api.selector(`external`,`zod.z`)}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=q({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:wp({getAst:(n,r)=>zp({plugin:e,schema:n,state:q({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:Bp({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:Bp({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:Bp({plugin:e,schema:t.schema,state:n});break;case`webhook`:Tp({getAst:(n,r)=>zp({plugin:e,schema:n,state:q({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},Hp=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:Q.unknown})})},Up=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i=P.propertyAccessExpression({expression:r.placeholder,name:Q.array}),a,o=!1;if(!t.items)a=P.callExpression({functionName:i,parameters:[Hp({plugin:e,schema:{type:`unknown`},state:n})]});else{t=T({schema:t});let s=t.items.map((t,r)=>{let i=tm({plugin:e,schema:t,state:{...n,path:K([...n.path.value,`items`,r])}});return i.hasLazyExpression&&(o=!0),i.expression});if(s.length===1)a=P.callExpression({functionName:i,parameters:s});else if(t.logicalOperator===`and`){let e=t.items[0],n;if(e.logicalOperator===`or`||e.type&&e.type!==`object`)n=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.intersection}),parameters:s});else{n=s[0];for(let e=1;e<s.length;e++)n=P.callExpression({functionName:P.propertyAccessExpression({expression:n,name:Q.and}),parameters:[s[e]]})}a=P.callExpression({functionName:i,parameters:[n]})}else a=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.array}),parameters:[P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.union}),parameters:[P.arrayLiteralExpression({elements:s})]})]})}return t.minItems===t.maxItems&&t.minItems!==void 0?a=P.callExpression({functionName:P.propertyAccessExpression({expression:a,name:Q.length}),parameters:[P.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(a=P.callExpression({functionName:P.propertyAccessExpression({expression:a,name:Q.min}),parameters:[P.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(a=P.callExpression({functionName:P.propertyAccessExpression({expression:a,name:Q.max}),parameters:[P.valueToExpression({value:t.maxItems})]}))),{expression:a,hasLazyExpression:o}},Wp=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return typeof t.const==`boolean`?P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[P.ots.boolean(t.const)]}):P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.boolean})})},Gp=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i=[],a=[],o=!1,s=!0;for(let e of t.items??[])if(e.type===`string`&&typeof e.const==`string`){let t=P.stringLiteral({text:e.const});i.push(t),a.push(P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[t]}))}else if((e.type===`number`||e.type===`integer`)&&typeof e.const==`number`){s=!1;let t=P.ots.number(e.const);a.push(P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[t]}))}else if(e.type===`boolean`&&typeof e.const==`boolean`){s=!1;let t=P.ots.boolean(e.const);a.push(P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[t]}))}else (e.type===`null`||e.const===null)&&(o=!0);if(!a.length)return Hp({plugin:e,schema:{type:`unknown`},state:n});let c;return c=s&&i.length>0?P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.enum}),parameters:[P.arrayLiteralExpression({elements:i,multiLine:!1})]}):a.length===1?a[0]:P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.union}),parameters:[P.arrayLiteralExpression({elements:a,multiLine:a.length>3})]}),o&&(c=P.callExpression({functionName:P.propertyAccessExpression({expression:c,name:Q.nullable})})),c},Kp=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:Q.never})})},qp=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:Q.null})})},Jp=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),r=t.type===`integer`&&t.format===`int64`;if(typeof t.const==`number`)return P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[P.ots.number(t.const)]});let i=P.callExpression({functionName:r?P.propertyAccessExpression({expression:P.propertyAccessExpression({expression:n.placeholder,name:Q.coerce}),name:Q.bigint}):P.propertyAccessExpression({expression:n.placeholder,name:Q.number})});return!r&&t.type===`integer`&&(i=P.callExpression({functionName:P.propertyAccessExpression({expression:i,name:Q.int})})),t.exclusiveMinimum===void 0?t.minimum!==void 0&&(i=P.callExpression({functionName:P.propertyAccessExpression({expression:i,name:Q.gte}),parameters:[$({isBigInt:r,value:t.minimum})]})):i=P.callExpression({functionName:P.propertyAccessExpression({expression:i,name:Q.gt}),parameters:[$({isBigInt:r,value:t.exclusiveMinimum})]}),t.exclusiveMaximum===void 0?t.maximum!==void 0&&(i=P.callExpression({functionName:P.propertyAccessExpression({expression:i,name:Q.lte}),parameters:[$({isBigInt:r,value:t.maximum})]})):i=P.callExpression({functionName:P.propertyAccessExpression({expression:i,name:Q.lt}),parameters:[$({isBigInt:r,value:t.exclusiveMaximum})]}),i},Yp=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i=!1,a=[],o=t.required??[];for(let r in t.properties){let s=t.properties[r],c=tm({optional:!o.includes(r),plugin:e,schema:s,state:{...n,path:K([...n.path.value,`properties`,r])}});c.hasLazyExpression&&(i=!0),O.lastIndex=0;let u;u=O.test(r)?r.startsWith(`-`)?l.factory.createStringLiteral(r):l.factory.createNumericLiteral(r):r,(r.match(/^[0-9]/)&&r.match(/\D+/g)||r.match(/\W/g))&&!r.startsWith(`'`)&&!r.endsWith(`'`)&&(u=`'${r}'`),a.push(P.propertyAssignment({initializer:c.expression,name:u}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=tm({plugin:e,schema:t.additionalProperties,state:{...n,path:K([...n.path.value,`additionalProperties`])}});return{anyType:`AnyZodObject`,expression:P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.record}),parameters:[i.expression]}),hasLazyExpression:i.hasLazyExpression}}return{anyType:`AnyZodObject`,expression:P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.object}),parameters:[l.factory.createObjectLiteralExpression(a,!0)]}),hasLazyExpression:i}},Xp=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));if(typeof t.const==`string`)return P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[P.ots.string(t.const)]});let r=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.string})}),i=[];if(e.config.dates.offset&&i.push({key:`offset`,value:!0}),e.config.dates.local&&i.push({key:`local`,value:!0}),t.format)switch(t.format){case`date`:r=P.callExpression({functionName:P.propertyAccessExpression({expression:r,name:Q.date})});break;case`date-time`:r=P.callExpression({functionName:P.propertyAccessExpression({expression:r,name:Q.datetime}),parameters:i.length>0?[P.objectExpression({obj:i})]:[]});break;case`email`:r=P.callExpression({functionName:P.propertyAccessExpression({expression:r,name:Q.email})});break;case`ipv4`:case`ipv6`:r=P.callExpression({functionName:P.propertyAccessExpression({expression:r,name:Q.ip})});break;case`time`:r=P.callExpression({functionName:P.propertyAccessExpression({expression:r,name:Q.time})});break;case`uri`:r=P.callExpression({functionName:P.propertyAccessExpression({expression:r,name:Q.url})});break;case`uuid`:r=P.callExpression({functionName:P.propertyAccessExpression({expression:r,name:Q.uuid})});break}return t.minLength===t.maxLength&&t.minLength!==void 0?r=P.callExpression({functionName:P.propertyAccessExpression({expression:r,name:Q.length}),parameters:[P.valueToExpression({value:t.minLength})]}):(t.minLength!==void 0&&(r=P.callExpression({functionName:P.propertyAccessExpression({expression:r,name:Q.min}),parameters:[P.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&(r=P.callExpression({functionName:P.propertyAccessExpression({expression:r,name:Q.max}),parameters:[P.valueToExpression({value:t.maxLength})]}))),t.pattern&&(r=P.callExpression({functionName:P.propertyAccessExpression({expression:r,name:Q.regex}),parameters:[P.regularExpressionLiteral({text:t.pattern})]})),r},Zp=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i=!1;if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[P.valueToExpression({value:e})]}));return{expression:P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.tuple}),parameters:[P.arrayLiteralExpression({elements:e})]}),hasLazyExpression:i}}let a=[];return t.items&&t.items.forEach((t,r)=>{let o=tm({plugin:e,schema:t,state:{...n,path:K([...n.path.value,`items`,r])}});a.push(o.expression),o.hasLazyExpression&&(i=!0)}),{expression:P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.tuple}),parameters:[P.arrayLiteralExpression({elements:a})]}),hasLazyExpression:i}},Qp=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:Q.undefined})})},$p=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:Q.void})})},em=({schema:e,...t})=>{switch(e.type){case`array`:return Up({...t,schema:e});case`boolean`:return{expression:Wp({...t,schema:e})};case`enum`:return{expression:Gp({...t,schema:e})};case`integer`:case`number`:return{expression:Jp({...t,schema:e})};case`never`:return{expression:Kp({...t,schema:e})};case`null`:return{expression:qp({...t,schema:e})};case`object`:return Yp({...t,schema:e});case`string`:return{expression:Xp({...t,schema:e})};case`tuple`:return Zp({...t,schema:e});case`undefined`:return{expression:Qp({...t,schema:e})};case`unknown`:return{expression:Hp({...t,schema:e})};case`void`:return{expression:$p({...t,schema:e})}}},tm=({optional:e,plugin:t,schema:n,state:r})=>{let i={},a=t.referenceSymbol(t.api.selector(`external`,`zod.z`));if(n.$ref){let e=t.api.selector(`ref`,n.$ref),o=t.referenceSymbol(e);t.isSymbolRegistered(e)?i.expression=P.identifier({text:o.placeholder}):(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:Q.lazy}),parameters:[P.arrowFunction({statements:[P.returnStatement({expression:P.identifier({text:o.placeholder})})]})]}),i.hasLazyExpression=!0,r.hasLazyExpression.value=!0)}else if(n.type){let e=em({plugin:t,schema:n,state:r});i.expression=e.expression,i.typeName=e.anyType,t.config.metadata&&n.description&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.expression,name:Q.describe}),parameters:[P.stringLiteral({text:n.description})]}))}else if(n.items)if(n=T({schema:n}),n.items){let e=n.items.map((e,n)=>tm({plugin:t,schema:e,state:{...r,path:K([...r.path.value,`items`,n])}}).expression);if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:Q.intersection}),parameters:e}):(i.expression=e[0],e.slice(1).forEach(e=>{i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.expression,name:Q.and}),parameters:[e]})}))}else i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:Q.union}),parameters:[P.arrayLiteralExpression({elements:e})]})}else i=tm({plugin:t,schema:n,state:r});else{let e=em({plugin:t,schema:{type:`unknown`},state:r});i.expression=e.expression,i.typeName=e.anyType}if(i.expression&&(n.accessScope===`read`&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.expression,name:Q.readonly})})),e&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.expression,name:Q.optional})})),n.default!==void 0)){let e=$({isBigInt:n.type===`integer`&&n.format===`int64`,value:n.default});e&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.expression,name:Q.default}),parameters:[e]}))}return r.hasLazyExpression.value?i.typeName||=`ZodTypeAny`:i.typeName&&=void 0,i},nm=({plugin:e,schema:t,state:n})=>{let r=or(n.path.value),i=tm({plugin:e,schema:t,state:n}),a=F(r);Sp({ast:i,plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{path:n.path.value,tags:n.tags?.value},name:w({config:e.config.definitions,name:a}),selector:e.api.selector(`ref`,r)}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:w({config:e.config.definitions.types.infer,name:a}),selector:e.api.selector(`type-infer-ref`,r)}):void 0})},rm=({plugin:e})=>{e.registerSymbol({external:Cp({plugin:e}),name:`z`,selector:e.api.selector(`external`,`zod.z`)}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=q({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:wp({getAst:(n,r)=>tm({plugin:e,schema:n,state:q({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:nm({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:nm({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:nm({plugin:e,schema:t.schema,state:n});break;case`webhook`:Tp({getAst:(n,r)=>tm({plugin:e,schema:n,state:q({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},im=({plugin:e})=>{let t={},n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return t.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.unknown})}),t},am=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),a=P.propertyAccessExpression({expression:i.placeholder,name:Q.array});if(!t.items)r.expression=P.callExpression({functionName:a,parameters:[im({plugin:e,schema:{type:`unknown`},state:n}).expression]});else{t=T({schema:t});let o=t.items.map((t,i)=>{let a=_m({plugin:e,schema:t,state:{...n,path:K([...n.path.value,`items`,i])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),a.expression});if(o.length===1)r.expression=P.callExpression({functionName:a,parameters:o});else if(t.logicalOperator===`and`){let e=t.items[0],n;if(e.logicalOperator===`or`||e.type&&e.type!==`object`)n=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:Q.intersection}),parameters:o});else{n=o[0];for(let e=1;e<o.length;e++)n=P.callExpression({functionName:P.propertyAccessExpression({expression:n,name:Q.and}),parameters:[o[e]]})}r.expression=P.callExpression({functionName:a,parameters:[n]})}else r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:Q.array}),parameters:[P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:Q.union}),parameters:[P.arrayLiteralExpression({elements:o})]})]})}return t.minItems===t.maxItems&&t.minItems!==void 0?r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.expression,name:Q.length}),parameters:[P.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.expression,name:Q.min}),parameters:[P.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.expression,name:Q.max}),parameters:[P.valueToExpression({value:t.maxItems})]}))),r},om=({plugin:e,schema:t})=>{let n={},r=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return typeof t.const==`boolean`?(n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[P.ots.boolean(t.const)]}),n):(n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.boolean})}),n)},sm=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),a=[],o=[],s=!1,c=!0;for(let e of t.items??[])if(e.type===`string`&&typeof e.const==`string`){let t=P.stringLiteral({text:e.const});a.push(t),o.push(P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:Q.literal}),parameters:[t]}))}else if((e.type===`number`||e.type===`integer`)&&typeof e.const==`number`){c=!1;let t=P.ots.number(e.const);o.push(P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:Q.literal}),parameters:[t]}))}else if(e.type===`boolean`&&typeof e.const==`boolean`){c=!1;let t=P.ots.boolean(e.const);o.push(P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:Q.literal}),parameters:[t]}))}else (e.type===`null`||e.const===null)&&(s=!0);return o.length?(c&&a.length>0?r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:Q.enum}),parameters:[P.arrayLiteralExpression({elements:a,multiLine:!1})]}):o.length===1?r.expression=o[0]:r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:Q.union}),parameters:[P.arrayLiteralExpression({elements:o,multiLine:o.length>3})]}),s&&(r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:Q.nullable}),parameters:[r.expression]})),r):im({plugin:e,schema:{type:`unknown`},state:n})},cm=({plugin:e})=>{let t={},n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return t.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.never})}),t},lm=({plugin:e})=>{let t={},n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return t.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.null})}),t},um=({plugin:e,schema:t})=>{let n={},r=t.type===`integer`&&t.format===`int64`,i=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return typeof t.const==`number`?(n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:Q.literal}),parameters:[P.ots.number(t.const)]}),n):(n.expression=P.callExpression({functionName:r?P.propertyAccessExpression({expression:P.propertyAccessExpression({expression:i.placeholder,name:Q.coerce}),name:Q.bigint}):P.propertyAccessExpression({expression:i.placeholder,name:Q.number})}),!r&&t.type===`integer`&&(n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:Q.int})})),t.exclusiveMinimum===void 0?t.minimum!==void 0&&(n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.expression,name:Q.gte}),parameters:[$({isBigInt:r,value:t.minimum})]})):n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.expression,name:Q.gt}),parameters:[$({isBigInt:r,value:t.exclusiveMinimum})]}),t.exclusiveMaximum===void 0?t.maximum!==void 0&&(n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.expression,name:Q.lte}),parameters:[$({isBigInt:r,value:t.maximum})]})):n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.expression,name:Q.lt}),parameters:[$({isBigInt:r,value:t.exclusiveMaximum})]}),n)},dm=({plugin:e,schema:t,state:n})=>{let r={},i=[],a=t.required??[],o=e.referenceSymbol(e.api.selector(`external`,`zod.z`));for(let o in t.properties){let s=t.properties[o],c=_m({optional:!a.includes(o),plugin:e,schema:s,state:{...n,path:K([...n.path.value,`properties`,o])}});c.hasLazyExpression&&(r.hasLazyExpression=!0),O.lastIndex=0;let u;u=O.test(o)?o.startsWith(`-`)?l.factory.createStringLiteral(o):l.factory.createNumericLiteral(o):o,(o.match(/^[0-9]/)&&o.match(/\D+/g)||o.match(/\W/g))&&!o.startsWith(`'`)&&!o.endsWith(`'`)&&(u=`'${o}'`),c.hasLazyExpression?i.push(P.getAccessorDeclaration({name:u,statements:[P.returnStatement({expression:c.expression})]})):i.push(P.propertyAssignment({initializer:c.expression,name:u}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=_m({plugin:e,schema:t.additionalProperties,state:{...n,path:K([...n.path.value,`additionalProperties`])}});return r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:Q.record}),parameters:[P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:Q.string}),parameters:[]}),i.expression]}),i.hasLazyExpression&&(r.hasLazyExpression=!0),r.hasLazyExpression?{...r,typeName:`ZodType`}:r}return r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:Q.object}),parameters:[l.factory.createObjectLiteralExpression(i,!0)]}),r.hasLazyExpression?{...r,typeName:`ZodType`}:r},fm=({plugin:e,schema:t})=>{let n={},r=e.referenceSymbol(e.api.selector(`external`,`zod.z`));if(typeof t.const==`string`)return n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[P.ots.string(t.const)]}),n;n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.string})});let i=[];if(e.config.dates.offset&&i.push({key:`offset`,value:!0}),e.config.dates.local&&i.push({key:`local`,value:!0}),t.format)switch(t.format){case`date`:n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:P.propertyAccessExpression({expression:r.placeholder,name:Q.iso}),name:Q.date})});break;case`date-time`:n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:P.propertyAccessExpression({expression:r.placeholder,name:Q.iso}),name:Q.datetime}),parameters:i.length>0?[P.objectExpression({obj:i})]:[]});break;case`email`:n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.email})});break;case`ipv4`:n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.ipv4})});break;case`ipv6`:n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.ipv6})});break;case`time`:n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:P.propertyAccessExpression({expression:r.placeholder,name:Q.iso}),name:Q.time})});break;case`uri`:n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.url})});break;case`uuid`:n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.uuid})});break}return t.minLength===t.maxLength&&t.minLength!==void 0?n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.expression,name:Q.length}),parameters:[P.valueToExpression({value:t.minLength})]}):(t.minLength!==void 0&&(n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.expression,name:Q.min}),parameters:[P.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&(n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.expression,name:Q.max}),parameters:[P.valueToExpression({value:t.maxLength})]}))),t.pattern&&(n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.expression,name:Q.regex}),parameters:[P.regularExpressionLiteral({text:t.pattern})]})),n},pm=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol(e.api.selector(`external`,`zod.z`));if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:Q.literal}),parameters:[P.valueToExpression({value:e})]}));return r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:Q.tuple}),parameters:[P.arrayLiteralExpression({elements:e})]}),r}let a=[];return t.items&&t.items.forEach((t,i)=>{let o=_m({plugin:e,schema:t,state:{...n,path:K([...n.path.value,`items`,i])}});a.push(o.expression),o.hasLazyExpression&&(r.hasLazyExpression=!0)}),r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:Q.tuple}),parameters:[P.arrayLiteralExpression({elements:a})]}),r},mm=({plugin:e})=>{let t={},n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return t.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.undefined})}),t},hm=({plugin:e})=>{let t={},n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return t.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.void})}),t},gm=({schema:e,...t})=>{switch(e.type){case`array`:return am({...t,schema:e});case`boolean`:return om({...t,schema:e});case`enum`:return sm({...t,schema:e});case`integer`:case`number`:return um({...t,schema:e});case`never`:return cm({...t,schema:e});case`null`:return lm({...t,schema:e});case`object`:return dm({...t,schema:e});case`string`:return fm({...t,schema:e});case`tuple`:return pm({...t,schema:e});case`undefined`:return mm({...t,schema:e});case`unknown`:return im({...t,schema:e});case`void`:return hm({...t,schema:e})}},_m=({optional:e,plugin:t,schema:n,state:r})=>{let i={},a=t.referenceSymbol(t.api.selector(`external`,`zod.z`));if(n.$ref){let e=t.api.selector(`ref`,n.$ref),o=t.referenceSymbol(e);t.isSymbolRegistered(e)?i.expression=P.identifier({text:o.placeholder}):(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:Q.lazy}),parameters:[P.arrowFunction({returnType:P.keywordTypeNode({keyword:`any`}),statements:[P.returnStatement({expression:P.identifier({text:o.placeholder})})]})]}),i.hasLazyExpression=!0,r.hasLazyExpression.value=!0)}else if(n.type){let e=gm({plugin:t,schema:n,state:r});i.expression=e.expression,i.hasLazyExpression=e.hasLazyExpression,t.config.metadata&&n.description&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.expression,name:Q.register}),parameters:[P.propertyAccessExpression({expression:a.placeholder,name:Q.globalRegistry}),P.objectExpression({obj:[{key:`description`,value:P.stringLiteral({text:n.description})}]})]}))}else if(n.items)if(n=T({schema:n}),n.items){let e=n.items.map((e,n)=>_m({plugin:t,schema:e,state:{...r,path:K([...r.path.value,`items`,n])}}));if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:Q.intersection}),parameters:e.map(e=>e.expression)}):(i.expression=e[0].expression,e.slice(1).forEach(e=>{i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.expression,name:Q.and}),parameters:[e.hasLazyExpression?P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:Q.lazy}),parameters:[P.arrowFunction({statements:[P.returnStatement({expression:e.expression})]})]}):e.expression]})}))}else i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:Q.union}),parameters:[P.arrayLiteralExpression({elements:e.map(e=>e.expression)})]})}else i=_m({plugin:t,schema:n,state:r});else i.expression=gm({plugin:t,schema:{type:`unknown`},state:r}).expression;if(i.expression&&(n.accessScope===`read`&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.expression,name:Q.readonly})})),e&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:Q.optional}),parameters:[i.expression]}),i.typeName=Q.ZodOptional),n.default!==void 0)){let e=$({isBigInt:n.type===`integer`&&n.format===`int64`,value:n.default});e&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.expression,name:Q.default}),parameters:[e]}))}return i},vm=({plugin:e,schema:t,state:n})=>{let r=or(n.path.value),i=_m({plugin:e,schema:t,state:n}),a=F(r);Sp({ast:i,plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{path:n.path.value,tags:n.tags?.value},name:w({config:e.config.definitions,name:a}),selector:e.api.selector(`ref`,r)}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:w({config:e.config.definitions.types.infer,name:a}),selector:e.api.selector(`type-infer-ref`,r)}):void 0})},ym=({plugin:e})=>{e.registerSymbol({external:Cp({plugin:e}),name:`z`,selector:e.api.selector(`external`,`zod.z`)}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=q({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:wp({getAst:(n,r)=>_m({plugin:e,schema:n,state:q({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:vm({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:vm({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:vm({plugin:e,schema:t.schema,state:n});break;case`webhook`:Tp({getAst:(n,r)=>_m({plugin:e,schema:n,state:q({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},bm={api:new xp({name:`zod`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:e=>{let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return rm(e);case`mini`:return Vp(e);case 4:default:return ym(e)}},name:`zod`,resolveConfig:(e,t)=>{let n=t.package.getVersion(`zod`),r=()=>n&&(n.major===4||n.major===3)?n.major:4,i=e=>{if(!e)return r();if(!n)return e;if((e===4||e===3||e===`mini`)&&!t.package.satisfies(n,`>=3.25.0 <5.0.0`)){let t=r();return console.warn(`🔌 ${a.yellow(`Warning:`)} Installed ${a.cyan(`zod`)} ${a.cyan(`v${n.version}`)} does not support compatibility version ${a.yellow(String(e))}, using ${a.yellow(String(t))}.`),t}return e};e.config.compatibilityVersion=i(e.config.compatibilityVersion),e.config.dates=t.valueToObject({defaultValue:{local:!1,offset:!1},value:e.config.dates}),e.config.types=t.valueToObject({defaultValue:{infer:{case:`PascalCase`,enabled:!1}},mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:S,value:e.infer})})},value:e.config.types}),e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`z{{name}}`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}ZodType`}}},mappers:{...S,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:S,value:e.infer})})},value:e.types})})},value:e.config.definitions}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`z{{name}}Data`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}DataZodType`}}},mappers:{...S,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:S,value:e.infer})})},value:e.types})})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`z{{name}}Response`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}ResponseZodType`}}},mappers:{...S,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:S,value:e.infer})})},value:e.types})})},value:e.config.responses}),e.config.webhooks=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`z{{name}}WebhookRequest`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}WebhookRequestZodType`}}},mappers:{...S,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:S,value:e.infer})})},value:e.types})})},value:e.config.webhooks})},tags:[`validator`]},xm={"@angular/common":rl,"@hey-api/client-angular":yl,"@hey-api/client-axios":xl,"@hey-api/client-fetch":Cl,"@hey-api/client-next":Tl,"@hey-api/client-nuxt":Dl,"@hey-api/client-ofetch":kl,"@hey-api/schemas":Yl,"@hey-api/sdk":_u,"@hey-api/transformers":Wu,"@hey-api/typescript":yd,"@pinia/colada":Id,"@tanstack/angular-query-experimental":Sf,"@tanstack/react-query":Cf,"@tanstack/solid-query":wf,"@tanstack/svelte-query":Tf,"@tanstack/vue-query":Ef,arktype:Rf,fastify:Vf,"legacy/angular":Al,"legacy/axios":jl,"legacy/fetch":Ml,"legacy/node":Nl,"legacy/xhr":Pl,valibot:mp,zod:bm},Sm=[`@hey-api/typescript`,`@hey-api/sdk`],Cm=({dependencies:e,userPlugins:t,userPluginsConfig:n})=>{let r=new Set,i=new Set,a={},o=s=>{if(r.has(s))throw Error(`Circular reference detected at '${s}'`);if(i.has(s))return;r.add(s);let c=xm[s],l=n[s];if(!c&&!l)throw Error(`unknown plugin dependency "${s}" - do you need to register a custom plugin with this name?`);let u={...c,...l,config:{...c?.config,...l?.config},dependencies:new Set([...c?.dependencies||[],...l?.dependencies||[]])};if(u.resolveConfig){let r={package:ut(e),pluginByTag:(e,r={})=>{let{defaultPlugin:i,errorMessage:a}=r;for(let r of t){let t=xm[r]||n[r];if(t&&t.tags?.includes(e)&&r!==s)return r}if(i){let t=xm[i]||n[i];if(t&&t.tags?.includes(e)&&i!==s)return i}throw Error(a||`missing plugin - no plugin with tag "${e}" found`)},valueToObject:Be};u.resolveConfig(u,r)}for(let e of u.dependencies)o(e);r.delete(s),i.add(s),a[s]=u};for(let e of t)o(e);return{pluginOrder:Array.from(i),plugins:a}},wm=e=>typeof e==`string`?e.startsWith(`@hey-api/client`)||e.startsWith(`legacy/`):e.name.startsWith(`@hey-api/client`)||e.name.startsWith(`legacy/`)||e.tags&&e.tags.includes(`client`),Tm=({dependencies:e,userConfig:t})=>{let n={},r=Sm;return t.plugins&&(t.plugins=t.plugins.filter(e=>typeof e==`string`&&e||typeof e!=`string`&&e.name),r=t.plugins.length===1&&wm(t.plugins[0])?[...Sm,...t.plugins]:t.plugins),Cm({dependencies:e,userPlugins:r.map(e=>{if(typeof e==`string`)return e;let t=e.name;return t&&(e.handler?n[t]=e:(n[t]={config:{...e}},delete n[t].config.name)),t}).filter(Boolean),userPluginsConfig:n})},Em=()=>!!(process.stdin.isTTY&&process.stdout.isTTY&&!process.env.CI&&!process.env.NO_INTERACTIVE&&!process.env.NO_INTERACTION),Dm=async({logger:e,userConfigs:t})=>{let n=[],r={},i=e.timeEvent(`load`);for(let i of t){let t;if(i?.configFile){let e=i.configFile.split(`.`);t=e.slice(0,e.length-1).join(`.`)}let o=e.timeEvent(`c12`),{loadConfig:s}=await import(`c12`),{config:c,configFile:l}=await s({configFile:t,name:`openapi-ts`});o.timeEnd(),Object.keys(r).length||(r=He(Object.keys(c).length?l:void 0));let u=c instanceof Array?c.map(e=>Le(e,i)):[Le(c,i)];for(let e of u){let t=Pe(e);if(e.output instanceof Array){let r=t.length,i=e.output.length;if(i>1)if(r!==i){console.warn(`⚙️ ${a.yellow(`Warning:`)} You provided ${a.cyan(String(r))} ${a.cyan(r===1?`input`:`inputs`)} and ${a.yellow(String(i))} ${a.yellow(`outputs`)}. This is probably not what you want as it will produce identical output in multiple locations. You most likely want to provide a single output or the same number of outputs as inputs.`);for(let r of e.output)n.push({...e,input:t,output:r})}else e.output.forEach((r,i)=>{n.push({...e,input:t[i],output:r})});else n.push({...e,input:t,output:e.output[0]??``})}else n.push({...e,input:t})}}i.timeEnd();let o=[],c=e.timeEvent(`build`);for(let e of n){let{base:t,configFile:n=``,dryRun:i=!1,experimentalParser:c=!0,exportCore:l=!0,name:u,request:d,useOptions:f=!0}=e,p=e.interactive===void 0?Em():e.interactive,m=Fe(e),h=Pe(e),g=Ve(e),ee=We(e),_=[];h.length||_.push(new ie(`missing input - which OpenAPI specification should we use to generate your output?`)),g.path||_.push(new ie(`missing output - where should we generate your output?`)),!f&&m.level!==`silent`&&console.warn(`❗️ Deprecation warning: useOptions set to false. This setting will be removed in future versions. Please migrate useOptions to true https://heyapi.dev/openapi-ts/migrating.html#v0-27-38`),g.path=s.resolve(process.cwd(),g.path);let te;try{te=Tm({dependencies:r,userConfig:e})}catch(e){_.push(e),te={pluginOrder:[],plugins:{}}}let v=me({...te,base:t,configFile:n,dryRun:i,experimentalParser:c,exportCore:!1,input:h,interactive:p,logs:m,name:u,output:g,parser:ee,request:d,useOptions:f});v.exportCore=x(v)?l:!1;let ne=o.length;if(m.level===`debug`){let e=a.gray(`[Job ${ne+1}] `);console.warn(`${e}${a.cyan(`config:`)}`,v)}o.push({config:v,errors:_,jobIndex:ne})}return c.timeEnd(),{dependencies:r,results:o}};Object.entries({$body_:`body`,$headers_:`headers`,$path_:`path`,$query_:`query`});const Om=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},km=e=>{switch(e){case`form`:return`,`;case`pipeDelimited`:return`|`;case`spaceDelimited`:return`%20`;default:return`,`}},Am=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},jm=({allowReserved:e,explode:t,name:n,style:r,value:i})=>{if(!t){let t=(e?i:i.map(e=>encodeURIComponent(e))).join(km(r));switch(r){case`label`:return`.${t}`;case`matrix`:return`;${n}=${t}`;case`simple`:return t;default:return`${n}=${t}`}}let a=Om(r),o=i.map(t=>r===`label`||r===`simple`?e?t:encodeURIComponent(t):Mm({allowReserved:e,name:n,value:t})).join(a);return r===`label`||r===`matrix`?a+o:o},Mm=({allowReserved:e,name:t,value:n})=>{if(n==null)return``;if(typeof n==`object`)throw Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?n:encodeURIComponent(n)}`},Nm=({allowReserved:e,explode:t,name:n,style:r,value:i,valueOnly:a})=>{if(i instanceof Date)return a?i.toISOString():`${n}=${i.toISOString()}`;if(r!==`deepObject`&&!t){let t=[];Object.entries(i).forEach(([n,r])=>{t=[...t,n,e?r:encodeURIComponent(r)]});let a=t.join(`,`);switch(r){case`form`:return`${n}=${a}`;case`label`:return`.${a}`;case`matrix`:return`;${n}=${a}`;default:return a}}let o=Am(r),s=Object.entries(i).map(([t,i])=>Mm({allowReserved:e,name:r===`deepObject`?`${n}[${t}]`:t,value:i})).join(o);return r===`label`||r===`matrix`?o+s:s},Pm=({parameters:e={},...t}={})=>n=>{let r=[];if(n&&typeof n==`object`)for(let i in n){let a=n[i];if(a==null)continue;let o=e[i]||t;if(Array.isArray(a)){let e=jm({allowReserved:o.allowReserved,explode:!0,name:i,style:`form`,value:a,...o.array});e&&r.push(e)}else if(typeof a==`object`){let e=Nm({allowReserved:o.allowReserved,explode:!0,name:i,style:`deepObject`,value:a,...o.object});e&&r.push(e)}else{let e=Mm({allowReserved:o.allowReserved,name:i,value:a});e&&r.push(e)}}return r.join(`&`)},Fm=e=>{let t=[];return e.forEach((e,n)=>{t.push([n,e])}),t},Im=(...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let e=n instanceof Headers?Fm(n):Object.entries(n);for(let[n,r]of e)if(r===null)t.delete(n);else if(Array.isArray(r))for(let e of r)t.append(n,e);else r!==void 0&&t.set(n,typeof r==`object`?JSON.stringify(r):r)}return t};Pm({allowReserved:!1,array:{explode:!0,style:`form`},object:{explode:!0,style:`deepObject`}});const Lm=async({fetchOptions:e,inputPath:t,timeout:n,watch:r})=>{let i=f({pathOrUrlOrSchema:t}),a,o,s;if(i.type===`url`){if(r.lastValue&&r.isHeadMethodSupported!==!1){try{let t=await p({fetchOptions:{method:`HEAD`,...e,headers:Im(e?.headers,r.headers)},timeout:n,url:i.path});if(t.response.status>=300)return{error:`not-ok`,response:t.response};s=t.response}catch(e){return{error:`not-ok`,response:new Response(e.message)}}if(!s.ok&&r.isHeadMethodSupported)return{error:`not-ok`,response:s};if(r.isHeadMethodSupported===void 0&&(r.isHeadMethodSupported=s.ok),s.status===304)return{error:`not-modified`,response:s};if(o===void 0){let e=s.headers.get(`ETag`);e&&(o=e!==r.headers.get(`If-None-Match`),o&&r.headers.set(`If-None-Match`,e))}if(o===void 0){let e=s.headers.get(`Last-Modified`);e&&(o=e!==r.headers.get(`If-Modified-Since`),o&&r.headers.set(`If-Modified-Since`,e))}if(o===!1)return{error:`not-modified`,response:s}}try{let t=await p({fetchOptions:{method:`GET`,...e},timeout:n,url:i.path});if(t.response.status>=300)return{error:`not-ok`,response:t.response};s=t.response}catch(e){return{error:`not-ok`,response:new Response(e.message)}}if(!s.ok)return{error:`not-ok`,response:s};if(a=s.body?await s.arrayBuffer():new ArrayBuffer(0),o===void 0){let e=new TextDecoder().decode(a);o=e!==r.lastValue,r.lastValue=e}}else r.lastValue?o=!1:r.lastValue=i.type;return o===!1?{error:`not-modified`,response:s}:{arrayBuffer:a,resolvedInput:i}};export{ce as A,b as C,ie as D,y as E,ne as F,ee as I,ue as M,de as N,ae as O,v as P,Fe as S,he as T,Un as _,_l as a,Ge as b,al as c,ps as d,hs as f,pr as g,oi as h,Gl as i,le as j,oe as k,Ec as l,Xo as m,Dm as n,pl as o,ns as p,Sm as r,il as s,Lm as t,Dc as u,P as v,x as w,Ue as x,C as y};
|
|
24
|
-
//# sourceMappingURL=getSpec-
|
|
23
|
+
`})),u.push(e)}),r(P.classDeclaration({decorator:o.name===`legacy/angular`?{args:[{providedIn:`root`}],name:`Injectable`}:void 0,exportClass:!0,name:Xo({config:a,name:i.name}),nodes:u}))},pu=({client:e,files:t,plugin:n})=>{let r=b(),i=x(r);if(t.sdk=new Gl({dir:r.output.path,exportFromIndex:n.config.exportFromIndex,id:`sdk`,name:`sdk.ts`}),!i)t.sdk.import({module:cl({config:r,sourceOutput:`sdk`}),name:`createClient`}),t.sdk.import({module:cl({config:r,sourceOutput:`sdk`}),name:`createConfig`}),t.sdk.import({asType:!0,module:cl({config:r,sourceOutput:`sdk`}),name:`OptionsLegacyParser`});else if(y(r).name===`legacy/angular`?(t.sdk.import({module:`@angular/core`,name:`Injectable`}),he(r)||t.sdk.import({module:`@angular/common/http`,name:`HttpClient`}),t.sdk.import({asType:!0,module:`rxjs`,name:`Observable`})):t.sdk.import({asType:!0,module:`./core/CancelablePromise`,name:`CancelablePromise`}),r.plugins[`@hey-api/sdk`]?.config.response===`response`&&t.sdk.import({asType:!0,module:`./core/ApiResult`,name:`ApiResult`}),he(r)){let e=y(r);t.sdk.import({asType:e.name!==`legacy/angular`,module:`./core/BaseHttpRequest`,name:`BaseHttpRequest`})}else t.sdk.import({module:`./core/OpenAPI`,name:`OpenAPI`}),t.sdk.import({alias:`__request`,module:`./core/request`,name:`request`});if(!i){let e=y(r),n=P.constVariable({exportConst:!0,expression:P.callExpression({functionName:`createClient`,parameters:[P.callExpression({functionName:`createConfig`,parameters:[`throwOnError`in e&&e.throwOnError?P.objectExpression({obj:[{key:`throwOnError`,value:!0}]}):void 0]})]}),name:`client`});t.sdk.add(n)}for(let n of e.services)fu({client:e,onClientImport:e=>{t.sdk.import({module:cl({config:r,sourceOutput:`sdk`}),name:e})},onImport:e=>{t.sdk.import({asType:!e.endsWith(`Transformer`),module:`./${t.types.nameWithoutExtension()}`,name:e})},onNode:e=>{t.sdk.add(e)},service:n})},mu=({plugin:e})=>{let t=y(e.context.config),n=t.name===`@hey-api/client-nuxt`;e.forEach(`operation`,r=>{let{operation:i}=r,a=Uc({context:e.context,operation:i}),o=e.getPluginOrThrow(`@hey-api/typescript`),s=n?e.getSymbol(o.api.selector(`response`,i.id)):void 0,c=zc({isRequiredOptions:a,operation:i,plugin:e}),l=Vc({isRequiredOptions:a,opParameters:c,operation:i,plugin:e}),u=e.registerSymbol({meta:{path:r._path,tags:r.tags},name:uu({config:e.context.config,handleIllegal:!0,id:i.id,operation:i}),selector:e.api.selector(`function`,i.id)}),d=P.constVariable({comment:Hc({operation:i}),exportConst:!0,expression:P.arrowFunction({parameters:c.parameters,returnType:void 0,statements:l,types:n?[{default:P.ots.string(`$fetch`),extends:P.typeNode(e.referenceSymbol(e.api.selector(`Composable`)).placeholder),name:Ac},{default:s?P.typeReferenceNode({typeName:s.placeholder}):P.typeNode(`undefined`),extends:s?P.typeReferenceNode({typeName:s.placeholder}):void 0,name:jc}]:[{default:(`throwOnError`in t.config?t.config.throwOnError:!1)??!1,extends:`boolean`,name:`ThrowOnError`}]}),name:u.placeholder});e.setSymbolValue(u,d)},{order:`declarations`})},hu=({plugin:e})=>{let t=ll(e.context.config),n=y(e.context.config).name===`@hey-api/client-nuxt`,r=e.registerSymbol({external:t,meta:{kind:`type`,path:[]},name:`TDataShape`}),i=e.registerSymbol({external:t,meta:{kind:`type`,path:[]},name:`Client`,selector:e.api.selector(`Client`)}),a=e.registerSymbol({external:t,meta:{kind:`type`,path:[]},name:`Options`}),o=e.registerSymbol({exported:!0,meta:{kind:`type`,path:[]},name:`Options`,selector:e.api.selector(`Options`)}),s=P.typeAliasDeclaration({exportType:o.exported,name:o.placeholder,type:P.typeIntersectionNode({types:[P.typeReferenceNode({typeArguments:n?[P.typeReferenceNode({typeName:`TComposable`}),P.typeReferenceNode({typeName:`TData`}),P.typeReferenceNode({typeName:Mc}),P.typeReferenceNode({typeName:jc})]:[P.typeReferenceNode({typeName:`TData`}),P.typeReferenceNode({typeName:`ThrowOnError`})],typeName:a.placeholder}),P.typeInterfaceNode({properties:[{comment:["You can provide a client instance returned by `createClient()` instead of",`individual options. This might be also useful if you want to implement a`,`custom client.`],isRequired:!e.config.client,name:`client`,type:P.typeReferenceNode({typeName:i.placeholder})},{comment:["You can pass arbitrary values through the `meta` object. This can be",`used to access values that aren't defined as part of the SDK function.`],isRequired:!1,name:`meta`,type:P.typeReferenceNode({typeArguments:[P.keywordTypeNode({keyword:`string`}),P.keywordTypeNode({keyword:`unknown`})],typeName:`Record`})}],useLegacyResolution:!1})]}),typeParameters:n?[P.typeParameterDeclaration({constraint:P.typeReferenceNode({typeName:e.referenceSymbol(e.api.selector(`Composable`)).placeholder}),defaultType:P.typeNode(`'$fetch'`),name:`TComposable`}),P.typeParameterDeclaration({constraint:P.typeReferenceNode({typeName:r.placeholder}),defaultType:P.typeReferenceNode({typeName:r.placeholder}),name:`TData`}),P.typeParameterDeclaration({defaultType:P.keywordTypeNode({keyword:`unknown`}),name:Mc}),P.typeParameterDeclaration({defaultType:P.keywordTypeNode({keyword:`undefined`}),name:jc})]:[P.typeParameterDeclaration({constraint:P.typeReferenceNode({typeName:r.placeholder}),defaultType:P.typeReferenceNode({typeName:r.placeholder}),name:`TData`}),P.typeParameterDeclaration({constraint:P.keywordTypeNode({keyword:`boolean`}),defaultType:P.keywordTypeNode({keyword:`boolean`}),name:`ThrowOnError`})]});e.setSymbolValue(o,s)},gu=({plugin:e})=>{let t=ll(e.context.config);e.registerSymbol({external:t,name:`formDataBodySerializer`,selector:e.api.selector(`formDataBodySerializer`)}),e.registerSymbol({external:t,name:`urlSearchParamsBodySerializer`,selector:e.api.selector(`urlSearchParamsBodySerializer`)}),e.registerSymbol({external:t,name:`buildClientParams`,selector:e.api.selector(`buildClientParams`)});let n=y(e.context.config),r=n.name===`@hey-api/client-angular`;n.name===`@hey-api/client-nuxt`&&e.registerSymbol({external:t,meta:{kind:`type`},name:`Composable`,selector:e.api.selector(`Composable`)}),r&&e.config.asClass&&e.registerSymbol({external:`@angular/core`,name:`Injectable`,selector:e.api.selector(`Injectable`)}),hu({plugin:e}),e.config.asClass?Ql({plugin:e}):mu({plugin:e})},_u={api:new Xl({name:`@hey-api/sdk`}),config:{asClass:!1,auth:!0,classNameBuilder:`{{name}}`,classStructure:`auto`,client:!0,exportFromIndex:!0,instance:!1,operationId:!0,params_EXPERIMENTAL:`default`,response:`body`,responseStyle:`fields`,transformer:!1,validator:!1},dependencies:[`@hey-api/typescript`],handler:e=>gu(e),handlerLegacy:pu,name:`@hey-api/sdk`,resolveConfig:(e,t)=>{e.config.client?(typeof e.config.client==`boolean`&&(e.config.client=t.pluginByTag(`client`,{defaultPlugin:`@hey-api/client-fetch`})),e.dependencies.add(e.config.client)):e.config.client=!1,e.config.transformer?(typeof e.config.transformer==`boolean`&&(e.config.transformer=t.pluginByTag(`transformer`)),e.dependencies.add(e.config.transformer)):e.config.transformer=!1,typeof e.config.validator!=`object`&&(e.config.validator={request:e.config.validator,response:e.config.validator}),e.config.validator.request?(typeof e.config.validator.request==`boolean`&&(e.config.validator.request=t.pluginByTag(`validator`)),e.dependencies.add(e.config.validator.request)):e.config.validator.request=!1,e.config.validator.response?(typeof e.config.validator.response==`boolean`&&(e.config.validator.response=t.pluginByTag(`validator`)),e.dependencies.add(e.config.validator.response)):e.config.validator.response=!1,e.config.instance?(typeof e.config.instance!=`string`&&(e.config.instance=`Sdk`),e.config.asClass=!0):e.config.instance=!1,e.config.classNameBuilder===`{{name}}`&&e.config.client===`@hey-api/client-angular`&&(e.config.classNameBuilder=`{{name}}Service`)}};var vu=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const yu=({dataExpression:e,schema:t})=>{if(t.type!==`integer`||t.format!==`int64`)return;let n=e===void 0?void 0:P.callExpression({functionName:`BigInt`,parameters:[P.callExpression({functionName:P.propertyAccessExpression({expression:e,name:`toString`})})]});if(n){if(typeof e==`string`)return[n];if(e)return[P.assignment({left:e,right:n})]}},bu=({dataExpression:e,schema:t})=>{if(t.type!==`string`||!(t.format===`date`||t.format===`date-time`))return;let n=P.identifier({text:`Date`});if(typeof e==`string`)return[P.newExpression({argumentsArray:[P.identifier({text:e})],expression:n})];if(e)return[P.assignment({left:e,right:P.newExpression({argumentsArray:[e],expression:n})})]},xu=`data`,Su=e=>e.map(e=>l.isStatement(e)?e:P.expressionToStatement({expression:e})),Cu=({node:e})=>e.kind===l.SyntaxKind.ReturnStatement,wu=({plugin:e,schema:t})=>{let n=P.identifier({text:xu}),r=Tu({dataExpression:n,plugin:e,schema:t});return r.length&&!Cu({node:r[r.length-1]})&&r.push(P.returnStatement({expression:n})),r},Tu=({dataExpression:e,plugin:t,schema:n})=>{if(n.$ref){let r=t.api.selector(`response-ref`,n.$ref);if(!t.getSymbol(r)){let e=t.registerSymbol({name:w({config:{case:`camelCase`,name:`{{name}}SchemaResponseTransformer`},name:F(n.$ref)}),selector:r}),i=wu({plugin:t,schema:t.context.resolveIrRef(n.$ref)});if(i.length){let n=P.constVariable({expression:P.arrowFunction({async:!1,multiLine:!0,parameters:[{name:xu,type:P.keywordTypeNode({keyword:`any`})}],statements:Su(i)}),name:e.placeholder});t.setSymbolValue(e,n)}}if(t.isSymbolRegistered(r)){let n=t.referenceSymbol(r),i=P.callExpression({functionName:n.placeholder,parameters:[e]});if(e)return typeof e==`string`&&e===`item`?[P.returnStatement({expression:i})]:[typeof e==`string`?i:P.assignment({left:e,right:i})]}return[]}if(n.type===`array`){if(!e||typeof e==`string`)return[];let r=n.items?Tu({dataExpression:`item`,plugin:t,schema:n.items?.[0]?n.items[0]:{...n,type:void 0}}):[];if(!r.length)return[];let i=Su(r);return i.some(e=>Cu({node:e}))||i.push(P.returnStatement({expression:P.identifier({text:`item`})})),[P.assignment({left:e,right:P.callExpression({functionName:P.propertyAccessExpression({expression:e,name:`map`}),parameters:[P.arrowFunction({multiLine:!0,parameters:[{name:`item`,type:`any`}],statements:i})]})})]}if(n.type===`object`){let r=[],i=n.required??[];for(let a in n.properties){let o=n.properties[a],s=P.propertyAccessExpression({expression:e||xu,name:a}),c=Tu({dataExpression:s,plugin:t,schema:o});if(!c.length)continue;let l=!o.items?.find(e=>e.type===`null`);i.includes(a)&&l?r=r.concat(c):r.push(P.ifStatement({expression:s,thenStatement:P.block({statements:Su(c)})}))}return r}if(n.items){if(n.items.length===1)return Tu({dataExpression:`item`,plugin:t,schema:n.items[0]});let r=[];if(n.logicalOperator===`and`||n.items.length===2&&n.items.find(e=>e.type===`null`||e.type===`void`)){for(let i of n.items){let n=Tu({dataExpression:e||`item`,plugin:t,schema:i});if(n.length)if(e)r=r.concat(n);else{let e=P.identifier({text:`item`});r.push(P.ifStatement({expression:e,thenStatement:P.block({statements:Su(n)})}),P.returnStatement({expression:e}))}}return r}n.type!==`enum`&&((n.items??[]).every(e=>[`boolean`,`integer`,`null`,`number`,`string`].includes(e.type))||console.warn(`❗️ Transformers warning: schema ${JSON.stringify(n)} is too complex and won't be currently processed. This will likely produce an incomplete transformer which is not what you want. Please open an issue if you'd like this improved https://github.com/hey-api/openapi-ts/issues`))}for(let r of t.config.transformers){let i=r({config:t.config,dataExpression:e,schema:n});if(i)return i}return[]},Eu=({plugin:e})=>{e.forEach(`operation`,({operation:t})=>{let{response:n}=ct(t);if(!n)return;if(n.items&&n.items.length>1){e.context.config.logs.level===`debug`&&console.warn(`❗️ Transformers warning: route ${D(t)} has ${n.items.length} non-void success responses. This is currently not handled and we will not generate a response transformer. Please open an issue if you'd like this feature https://github.com/hey-api/openapi-ts/issues`);return}let r=e.getPluginOrThrow(`@hey-api/typescript`),i=e.getSymbol(r.api.selector(`response`,t.id));if(!i)return;let a=wu({plugin:e,schema:n});if(!a.length)return;let o=e.registerSymbol({exported:!0,name:w({config:{case:`camelCase`,name:`{{name}}ResponseTransformer`},name:t.id}),selector:e.api.selector(`response`,t.id)}),s=P.constVariable({exportConst:o.exported,expression:P.arrowFunction({async:!0,multiLine:!0,parameters:[{name:xu,type:P.keywordTypeNode({keyword:`any`})}],returnType:P.typeReferenceNode({typeArguments:[P.typeReferenceNode({typeName:i.placeholder})],typeName:`Promise`}),statements:Su(a)}),name:o.placeholder});e.setSymbolValue(o,s)},{order:`declarations`})},G={$refs:[],base:``,description:null,enum:[],enums:[],export:`interface`,imports:[],in:``,isDefinition:!1,isNullable:!1,isReadOnly:!1,isRequired:!1,link:null,name:``,properties:[],template:null,type:``},Du=({comments:e,leadingComment:t,meta:n,obj:r,onNode:i,...a})=>{if(!n)return;let{created:o,name:s}=Ms({create:!0,meta:n,...a});if(o){let n=b().plugins[`@hey-api/typescript`];i(P.enumDeclaration({asConst:typeof n?.config.enums==`object`&&n.config.enums.mode===`typescript-const`,comments:e,leadingComment:t,name:s,obj:r}))}},Ou=({comment:e,meta:t,onCreated:n,onNode:r,type:i,...a})=>{if(!t)return{created:!1,name:``};let o=Ms({create:!0,meta:t,...a}),{created:s,name:c}=o;return s&&(r(P.typeAliasDeclaration({comment:e,exportType:!0,name:c,type:i})),n?.(c)),o},ku=e=>{let t=[];Mu(e),e.model.enums.forEach(n=>ju({...e,model:n,onNode:e=>{t.push(e)}})),t.length&&e.onNode(P.namespaceDeclaration({name:e.model.name,statements:t}))},Au=({client:e,model:t,onNode:n})=>{let r=b(),i={},a={};t.enum.forEach(e=>{let{key:t,value:n}=ys(e);i[t]=n;let r=e.customDescription||e.description;r&&(a[t]=[k(r)])});let o=[t.description&&k(t.description),t.deprecated&&`@deprecated`],s=r.plugins[`@hey-api/typescript`];if(s?.config&&typeof s.config.enums==`object`&&s.config.enums.enabled&&(s.config.enums.mode===`typescript`||s.config.enums.mode===`typescript-const`)){Du({asConst:s.config.enums.mode===`typescript-const`,client:e,comments:a,leadingComment:o,meta:t.meta,obj:i,onNode:n});return}Ou({client:e,comment:o,meta:t.meta,onCreated:e=>{let t=r.plugins[`@hey-api/typescript`];if(t?.config&&typeof t.config.enums==`object`&&t.config.enums.enabled&&t.config.enums.mode===`javascript`){let t=P.objectExpression({multiLine:!0,obj:Object.entries(i).map(([e,t])=>({comments:a[e],key:e,value:t})),unescape:!0});n(P.constVariable({assertion:`const`,comment:o,exportConst:!0,expression:t,name:e}))}},onNode:n,type:_s(t.enum)})},ju=({model:e,onNode:t})=>{let n={},r={};e.enum.forEach(e=>{let{key:t,value:i}=ys(e);n[t]=i;let a=e.customDescription||e.description;a&&(r[t]=[k(a)])});let i=b().plugins[`@hey-api/typescript`];t(P.enumDeclaration({asConst:typeof i?.config.enums==`object`&&i.config.enums.mode===`typescript-const`,comments:r,leadingComment:[e.description&&k(e.description),e.deprecated&&`@deprecated`],name:e.meta?.name||e.name,obj:n}))},Mu=({client:e,model:t,onNode:n})=>{Ou({client:e,comment:[t.description&&k(t.description),t.deprecated&&`@deprecated`],meta:t.meta,onNode:n,type:js(t)})},Nu=e=>{switch(e.model.export){case`all-of`:case`any-of`:case`one-of`:case`interface`:return ku(e);case`enum`:return Au(e);default:return Mu(e)}},Pu=({client:e,onNode:t})=>{let n={},r=b();if(!r.plugins[`@hey-api/sdk`]&&!r.plugins[`@hey-api/typescript`]?.config.tree)return;let i=x(r);for(let r of e.services)for(let a of r.operations){if(!a.parameters.length&&!a.responses.length)continue;n[a.path]||(n[a.path]={});let r=n[a.path];r[a.method]||(r[a.method]={});let o=r[a.method];if(o.$ref=a.name,a.responses.length>0){if(o.res||={},Array.isArray(o.res))continue;a.responses.forEach(e=>{o.res[e.code]=e})}if(a.parameters.length>0){let n={mediaType:null,...G,in:`body`,name:`body`,prop:`body`},r=a.parameters.filter(e=>e.in===`body`);r.length||(r=a.parameters.filter(e=>e.in===`formData`)),r.length===1?n={...G,...r[0],in:`body`,isRequired:r[0].isRequired,name:`body`,prop:`body`}:r.length>1&&(n={...G,in:`body`,isRequired:r.some(e=>e.isRequired),mediaType:`multipart/form-data`,name:`body`,prop:`body`,properties:r});let s={...G,in:`header`,isRequired:Is(a.parameters.filter(e=>e.in===`header`)),mediaType:null,name:i?`header`:`headers`,prop:i?`header`:`headers`,properties:a.parameters.filter(e=>e.in===`header`).sort(ms)},c={...G,in:`path`,isRequired:Is(a.parameters.filter(e=>e.in===`path`)),mediaType:null,name:`path`,prop:`path`,properties:a.parameters.filter(e=>e.in===`path`).sort(ms)},l={...G,in:`query`,isRequired:Is(a.parameters.filter(e=>e.in===`query`)),mediaType:null,name:`query`,prop:`query`,properties:a.parameters.filter(e=>e.in===`query`).sort(ms)},u=i?hs([...a.parameters]):[n,s,c,l].filter(e=>e.properties.length||e.$refs.length||e.mediaType);o.req=u,Ou({client:e,meta:{$ref:a.name,name:a.name},nameTransformer:tu,onNode:t,type:js({...G,isRequired:!0,properties:u})})}let s=a.responses.filter(e=>e.responseTypes.includes(`success`));if(s.length>0){Ou({client:e,meta:{$ref:a.name,name:a.name},nameTransformer:iu,onNode:t,type:js({...G,export:`any-of`,isRequired:!0,properties:s})});let n=a.responses.filter(e=>e.responseTypes.includes(`error`));i||Ou({client:e,meta:{$ref:a.name,name:a.name},nameTransformer:nu,onNode:t,type:js(n.length?{...G,export:`one-of`,isRequired:!0,properties:n}:{...G,base:`unknown`,isRequired:!0,type:`unknown`})})}}let a=Object.entries(n).map(([t,n])=>{let r=Object.entries(n).map(([t,n])=>{let r=t,i=[];if(n.req){let t=n.$ref,{name:r}=Ms({client:e,meta:{$ref:t,name:t},nameTransformer:tu}),a={...G,base:r,export:`reference`,isRequired:!0,name:`req`,properties:[],type:r};i=[...i,a]}if(n.res){let e=Object.entries(n.res).map(([e,t])=>({...G,...t,isRequired:!0,name:String(e)})),t={...G,isRequired:!0,name:`res`,properties:e};i=[...i,t]}return{...G,isRequired:!0,name:r.toLocaleLowerCase(),properties:i}}).filter(Boolean);return{...G,isRequired:!0,name:`'${t}'`,properties:r}});r.plugins[`@hey-api/typescript`]?.config.tree&&Ou({client:e,meta:{$ref:`@hey-api/openapi-ts`,name:`$OpenApiTs`},onNode:t,type:js({...G,properties:a})})},Fu=({client:e,files:t,plugin:n})=>{t.types=new Gl({dir:b().output.path,exportFromIndex:n.config.exportFromIndex,id:`types`,name:`types.ts`});let r=e=>{t.types?.add(e)};for(let t of e.models)Nu({client:e,model:t,onNode:r});Pu({client:e,onNode:r})},Iu=`data`,Lu=e=>e.base===`unknown`&&e.export===`generic`&&e.type===`unknown`,Ru=({client:e,model:t})=>t.$refs.map(t=>{let n=e.models.find(e=>e.meta?.$ref===t);if(!n)throw Error(`Ref ${t} could not be found. Transformers cannot be generated without having access to all refs.`);return n}),zu=e=>{let t=e.model.meta.name,{name:n}=Ou({...e,meta:{$ref:`transformers/${t}`,name:t},nameTransformer:eu,onCreated:n=>{let r=Hu({...e,meta:{$ref:`transformers/${t}`,name:n},path:[Iu]});Uu({...e,async:!1,name:n,statements:r})},type:`(${Iu}: any) => ${t}`});return{created:!!e.client.types[n],name:n}},Bu=e=>{let{model:t}=e,n=Ru(e);if(n.length===1){let{created:t,name:r}=zu({...e,model:n[0]});return t?[P.transformArrayMutation({path:e.path,transformerName:r})]:[]}return Cs(t)||t.link&&!Array.isArray(t.link)&&t.link.export===`any-of`&&t.link.properties.find(e=>Cs(e))?[P.transformArrayMap({path:e.path,transformExpression:P.conditionalExpression({condition:P.identifier({text:`item`}),whenFalse:P.identifier({text:`item`}),whenTrue:P.transformNewDate({parameterName:`item`})})})]:[]},Vu=e=>{let{model:t}=e,n=[...e.path,t.name];return t.type===`string`&&t.export!==`array`&&Cs(t)?[P.transformDateMutation({path:n})]:Hu({...e,model:t,path:n})},Hu=e=>{let{model:t}=e;switch(t.export){case`array`:return Bu(e);case`interface`:return t.properties.flatMap(t=>Vu({...e,model:t}));case`reference`:{if(t.$refs.length!==1)return[];let n=Ru(e),{created:r,name:i}=zu({...e,model:n[0]});return r?t.in===`response`?[P.expressionToStatement({expression:P.callExpression({functionName:i,parameters:[Iu]})})]:P.transformFunctionMutation({path:e.path,transformerName:i}):[]}default:return[]}},Uu=({async:e,client:t,name:n,onNode:r,onRemoveNode:i,statements:a})=>{let o={created:!1,name:n};if(!a.length)return Ns({client:t,name:n}),i?.(),o;let s=P.arrowFunction({async:e,multiLine:!0,parameters:[{name:Iu}],statements:[...a,P.returnVariable({expression:Iu})]});return r(P.constVariable({exportConst:!0,expression:s,name:n,typeName:n})),{created:!0,name:n}},Wu={api:new vu({name:`@hey-api/transformers`}),config:{bigInt:!0,dates:!0,exportFromIndex:!1,transformers:[],typeTransformers:[]},dependencies:[`@hey-api/typescript`],handler:Eu,handlerLegacy:({client:e,files:t})=>{let n=b(),r=e=>{t.types?.add(e)},i=()=>{t.types?.removeNode_LEGACY()};for(let t of e.services)for(let a of t.operations){let t=a.responses.filter(e=>e.responseTypes.includes(`success`));if(!t.length)continue;let o=t.filter(e=>!Lu(e));if(!o.length)continue;if(o.length>1){n.logs.level===`debug`&&console.warn(`❗️ Transformers warning: route ${D(a)} has ${o.length} non-void success responses. This is currently not handled and we will not generate a response transformer. Please open an issue if you'd like this feature https://github.com/hey-api/openapi-ts/issues`);continue}let s=iu(a.name);Ou({client:e,meta:{$ref:`transformers/${s}`,name:s},nameTransformer:ru,onCreated:n=>{Uu({async:!0,client:e,name:n,onNode:r,onRemoveNode:i,statements:t.length>1?t.flatMap(t=>{let n=Hu({client:e,meta:{$ref:`transformers/${s}`,name:s},model:t,onNode:r,onRemoveNode:i,path:[Iu]});return n.length?[P.ifStatement({expression:P.safeAccessExpression([`data`]),thenStatement:P.block({statements:n})})]:[]}):Hu({client:e,meta:{$ref:`transformers/${s}`,name:s},model:t[0],onNode:r,onRemoveNode:i,path:[Iu]})})},onNode:r,type:`(${Iu}: any) => Promise<${s}>`})}},name:`@hey-api/transformers`,resolveConfig:e=>{e.config.transformers||(e.config.transformers=[]),e.config.dates&&(e.config.transformers=[...e.config.transformers,bu]),e.config.bigInt&&(e.config.transformers=[...e.config.transformers,yu])},tags:[`transformer`]},K=e=>({value:e}),q=e=>{let t={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=K(e[n]));return t},Gu=P.keywordTypeNode({keyword:`string`}),Ku=({server:e})=>{let t=ua(e.url);return t.protocol&&t.host?P.literalTypeNode({literal:P.stringLiteral({text:e.url})}):P.templateLiteralType({value:[t.protocol||Gu,`://`,t.host||Gu,t.port?`:${t.port}`:``,t.path||``]})},qu=({plugin:e,servers:t,symbolClientOptions:n})=>{let r=y(e.context.config),i=t.map(e=>Ku({server:e}));t.length?`strictBaseUrl`in r.config&&r.config.strictBaseUrl||i.push(P.typeIntersectionNode({types:[Gu,l.factory.createTypeLiteralNode([])]})):i.push(Gu);let a=P.typeInterfaceNode({properties:[{name:fe(e.context.config),type:P.typeUnionNode({types:i})}],useLegacyResolution:!1}),o=P.typeAliasDeclaration({exportType:n.exported,name:n.placeholder,type:a});e.setSymbolValue(n,o)},Ju=({schema:e})=>{let t=[];return e.title&&t.push(k(e.title)),e.description&&(t.length&&t.push(``),t.push(k(e.description))),e.deprecated&&(t.length&&t.push(``),t.push(`@deprecated`)),t.length?t:void 0},Yu=({plugin:e,schema:t})=>{let n=[];return{obj:(t.items??[]).map((t,r)=>{let i=typeof t.const;n.includes(i)||n.push(i);let a;return a=t.title?t.title:i===`number`||i===`string`?`${t.const}`:i===`boolean`?t.const?`true`:`false`:t.const===null?`null`:`${r}`,a&&(a=C({case:e.config.enums.case,stripLeadingSeparators:!1,value:a}),O.lastIndex=0,O.test(a)&&e.config.enums.enabled&&(e.config.enums.mode===`typescript`||e.config.enums.mode===`typescript-const`)&&(a=`_${a}`)),{comments:Ju({schema:t}),key:a,value:t.const}}),typeofItems:n}},Xu=({plugin:e,schema:t,symbol:n,type:r})=>{if(t.type===`enum`&&e.config.enums.enabled){let r=Yu({plugin:e,schema:t});if(e.config.enums.mode===`javascript`){e.config.enums.constantsIgnoreNull&&r.typeofItems.includes(`object`)&&(r.obj=r.obj.filter(e=>e.value!==null));let i=P.constVariable({assertion:`const`,comment:Ju({schema:t}),exportConst:!0,expression:P.objectExpression({multiLine:!0,obj:r.obj}),name:n.placeholder}),a=P.typeOfExpression({text:n.placeholder}),o=P.typeAliasDeclaration({comment:Ju({schema:t}),exportType:!0,name:n.placeholder,type:P.indexedAccessTypeNode({indexType:P.typeOperatorNode({operator:`keyof`,type:a}),objectType:a})});e.setSymbolValue(n,[i,o]);return}else if((e.config.enums.mode===`typescript`||e.config.enums.mode===`typescript-const`)&&!r.typeofItems.some(e=>e!==`number`&&e!==`string`)){let i=P.enumDeclaration({asConst:e.config.enums.mode===`typescript-const`,leadingComment:Ju({schema:t}),name:n.placeholder,obj:r.obj});e.setSymbolValue(n,i);return}}let i=P.typeAliasDeclaration({comment:Ju({schema:t}),exportType:n.exported,name:n.placeholder,type:r});e.setSymbolValue(n,i)},Zu=({parameters:e})=>{let t={type:`object`};if(e){let n={},r=[];for(let t in e){let i=e[t];n[i.name]=T({detectFormat:!1,schema:i.schema}),i.required&&r.push(i.name)}t.properties=n,r.length&&(t.required=r)}return t},Qu=({operation:e,plugin:t,state:n})=>{let r={type:`object`},i=[];r.properties||={},e.body?(r.properties.body=e.body.schema,e.body.required&&i.push(`body`)):r.properties.body={type:`never`},e.parameters?.header&&(r.properties.headers=Zu({parameters:e.parameters.header}),r.properties.headers.required&&i.push(`headers`)),e.parameters?.path?(r.properties.path=Zu({parameters:e.parameters.path}),r.properties.path.required&&i.push(`path`)):r.properties.path={type:`never`},e.parameters?.query?(r.properties.query=Zu({parameters:e.parameters.query}),r.properties.query.required&&i.push(`query`)):r.properties.query={type:`never`},r.properties.url={const:e.path,type:`string`},i.push(`url`),r.required=i;let a=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:w({config:t.config.requests,name:e.id}),selector:t.api.selector(`data`,e.id)}),o=J({plugin:t,schema:r,state:n}),s=P.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:o});t.setSymbolValue(a,s)},$u=({operation:e,plugin:t,state:n})=>{Qu({operation:e,plugin:t,state:n});let{error:r,errors:i,response:a,responses:o}=ct(e);if(i){let a=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:w({config:t.config.errors,name:e.id}),selector:t.api.selector(`errors`,e.id)}),o=J({plugin:t,schema:i,state:n}),s=P.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:o});if(t.setSymbolValue(a,s),r){let r=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:w({config:{case:t.config.errors.case,name:t.config.errors.error},name:e.id}),selector:t.api.selector(`error`,e.id)}),i=P.indexedAccessTypeNode({indexType:P.typeOperatorNode({operator:`keyof`,type:P.typeReferenceNode({typeName:a.placeholder})}),objectType:P.typeReferenceNode({typeName:a.placeholder})}),o=P.typeAliasDeclaration({exportType:r.exported,name:r.placeholder,type:i});t.setSymbolValue(r,o)}}if(o){let r=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:w({config:t.config.responses,name:e.id}),selector:t.api.selector(`responses`,e.id)}),i=J({plugin:t,schema:o,state:n}),s=P.typeAliasDeclaration({exportType:r.exported,name:r.placeholder,type:i});if(t.setSymbolValue(r,s),a){let i=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:w({config:{case:t.config.responses.case,name:t.config.responses.response},name:e.id}),selector:t.api.selector(`response`,e.id)}),a=P.indexedAccessTypeNode({indexType:P.typeOperatorNode({operator:`keyof`,type:P.typeReferenceNode({typeName:r.placeholder})}),objectType:P.typeReferenceNode({typeName:r.placeholder})}),o=P.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:a});t.setSymbolValue(i,o)}}},ed=({operation:e,plugin:t,state:n})=>{let r={type:`object`},i=[];if(r.properties||={},e.body){let a=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:w({config:{case:t.config.webhooks.case,name:t.config.webhooks.payload},name:e.id}),selector:t.api.selector(`webhook-payload`,e.id)}),o=J({plugin:t,schema:e.body.schema,state:n}),s=P.typeAliasDeclaration({comment:Ju({schema:e.body.schema}),exportType:a.exported,name:a.placeholder,type:o});t.setSymbolValue(a,s),t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:a.name,placeholder:a.placeholder,selector:t.api.selector(`ref`,a.placeholder)}),r.properties.body={$ref:a.placeholder},i.push(`body`)}else r.properties.body={type:`never`};r.properties.key={const:e.path,type:`string`},i.push(`key`),r.properties.path={type:`never`},r.properties.query={type:`never`},r.required=i;let a=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:w({config:t.config.webhooks,name:e.id}),selector:t.api.selector(`webhook-request`,e.id)}),o=J({plugin:t,schema:r,state:n}),s=P.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:o});return t.setSymbolValue(a,s),a.placeholder},td=({operation:e,plugin:t,state:n})=>ed({operation:e,plugin:t,state:n}),nd=({plugin:e,symbolWebhooks:t,webhookNames:n})=>{if(!n.length)return;let r=P.typeUnionNode({types:n.map(e=>P.typeReferenceNode({typeName:e}))}),i=P.typeAliasDeclaration({exportType:t.exported,name:t.placeholder,type:r});e.setSymbolValue(t,i)},rd=({plugin:e,schema:t,state:n})=>{if(!t.items)return P.typeArrayNode(P.keywordTypeNode({keyword:e.config.topType}));t=T({detectFormat:!0,schema:t});let r=[];return t.items&&t.items.forEach((t,i)=>{let a=J({plugin:e,schema:t,state:{...n,path:K([...n.path.value,`items`,i])}});r.push(a)}),r.length===1?P.typeArrayNode(r[0]):t.logicalOperator===`and`?P.typeArrayNode(P.typeIntersectionNode({types:r})):P.typeArrayNode(P.typeUnionNode({types:r}))},id=({schema:e})=>e.const===void 0?P.keywordTypeNode({keyword:`boolean`}):P.literalTypeNode({literal:P.ots.boolean(e.const)}),ad=({plugin:e,schema:t,state:n})=>J({plugin:e,schema:{...t,type:void 0},state:n}),od=e=>P.keywordTypeNode({keyword:`never`}),sd=e=>P.literalTypeNode({literal:P.null()}),cd=({plugin:e,schema:t})=>t.const===void 0?t.type===`integer`&&t.format===`int64`&&e.getPlugin(`@hey-api/transformers`)?.config.bigInt?P.typeReferenceNode({typeName:`bigint`}):P.keywordTypeNode({keyword:`number`}):P.literalTypeNode({literal:P.ots.number(t.const)}),ld=({context:e,name:t})=>(O.lastIndex=0,O.test(t)?t.startsWith(`-`)?l.factory.createStringLiteral(t):l.factory.createNumericLiteral(t):C({case:e.config.output.case,value:t})),ud=({plugin:e,schema:t,state:n})=>{let r,i,a=[],o=[],s=t.required??[],c=!1;for(let r in t.properties){let i=t.properties[r],l=J({plugin:e,schema:i,state:{...n,path:K([...n.path.value,`properties`,r])}}),u=s.includes(r);a.push({comment:Ju({schema:i}),isReadOnly:i.accessScope===`read`,isRequired:u,name:ld({context:e.context,name:r}),type:l}),o.push(i),u||(c=!0)}if(t.patternProperties)for(let e in t.patternProperties){let n=t.patternProperties[e];o.unshift(n)}let l=!!t.patternProperties&&Object.keys(t.patternProperties).length>0,u=t.additionalProperties,d=u!==!1&&u?u:void 0;if(l||d&&(d.type!==`never`||!o.length)){let a=d;a&&a.type!==`never`?o.unshift(a):!l&&!o.length&&a&&a.type===`never`&&(o=[a]),c&&o.push({type:`undefined`}),i={isRequired:!t.propertyNames,name:`key`,type:o.length===1?J({plugin:e,schema:o[0],state:n}):J({plugin:e,schema:{items:o,logicalOperator:`or`},state:n})},t.propertyNames?.$ref&&(r=J({plugin:e,schema:{$ref:t.propertyNames.$ref},state:n}))}return P.typeInterfaceNode({indexKey:r,indexProperty:i,properties:a,useLegacyResolution:!1})},dd=({plugin:e,schema:t})=>{if(t.const!==void 0)return P.literalTypeNode({literal:P.stringLiteral({text:t.const})});if(t.format){if(t.format===`binary`)return P.typeUnionNode({types:[P.typeReferenceNode({typeName:`Blob`}),P.typeReferenceNode({typeName:`File`})]});if((t.format===`date-time`||t.format===`date`)&&e.getPlugin(`@hey-api/transformers`)?.config.dates)return P.typeReferenceNode({typeName:`Date`});if(t.format===`typeid`&&typeof t.example==`string`){let n=String(t.example).split(`_`);n.pop();let r=n.join(`_`),i=e.api.selector(`TypeID`,r);if(!e.getSymbol(i)){let t=e.api.selector(`TypeID`);if(!e.getSymbol(t)){let n=e.registerSymbol({exported:!0,meta:{kind:`type`,path:[]},name:`TypeID`,selector:t}),r=P.typeAliasDeclaration({exportType:n.exported,name:n.placeholder,type:P.templateLiteralType({value:[P.typeReferenceNode({typeName:`T`}),`_`,P.keywordTypeNode({keyword:`string`})]}),typeParameters:[P.typeParameterDeclaration({constraint:P.keywordTypeNode({keyword:`string`}),name:`T`})]});e.setSymbolValue(n,r)}let n=e.referenceSymbol(t),a=e.registerSymbol({exported:!0,meta:{kind:`type`,path:[]},name:C({case:e.config.case,value:`${r}_id`}),selector:i}),o=P.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:P.typeReferenceNode({typeArguments:[P.literalTypeNode({literal:P.stringLiteral({text:r})})],typeName:n.placeholder})});e.setSymbolValue(a,o)}let a=e.referenceSymbol(i);return P.typeReferenceNode({typeName:a.placeholder})}}return P.keywordTypeNode({keyword:`string`})},fd=({plugin:e,schema:t,state:n})=>{let r=[];return t.const&&Array.isArray(t.const)?r=t.const.map(t=>P.valueToExpression({value:t})??P.identifier({text:e.config.topType})):t.items&&t.items.forEach((t,i)=>{let a=J({plugin:e,schema:t,state:{...n,path:K([...n.path.value,`items`,i])}});r.push(a)}),P.typeTupleNode({types:r})},pd=e=>P.keywordTypeNode({keyword:`undefined`}),md=({plugin:e})=>P.keywordTypeNode({keyword:e.config.topType}),hd=e=>P.keywordTypeNode({keyword:`void`}),gd=({schema:e,...t})=>{let n=t.plugin.getPlugin(`@hey-api/transformers`);if(n?.config.typeTransformers)for(let t of n.config.typeTransformers){let n=t({schema:e});if(n)return n}switch(e.type){case`array`:return rd({...t,schema:e});case`boolean`:return id({...t,schema:e});case`enum`:return ad({...t,schema:e});case`integer`:case`number`:return cd({...t,schema:e});case`never`:return od({...t,schema:e});case`null`:return sd({...t,schema:e});case`object`:return ud({...t,schema:e});case`string`:return dd({...t,schema:e});case`tuple`:return fd({...t,schema:e});case`undefined`:return pd({...t,schema:e});case`unknown`:return md({...t,schema:e});case`void`:return hd({...t,schema:e})}},J=({plugin:e,schema:t,state:n})=>{if(t.$ref){let n=e.referenceSymbol(e.api.selector(`ref`,t.$ref));return P.typeReferenceNode({typeName:n.placeholder})}if(t.type)return gd({plugin:e,schema:t,state:n});if(t.items){if(t=T({detectFormat:!1,schema:t}),t.items){let r=[];for(let i of t.items){let t=J({plugin:e,schema:i,state:n});r.push(t)}return t.logicalOperator===`and`?P.typeIntersectionNode({types:r}):P.typeUnionNode({types:r})}return J({plugin:e,schema:t,state:n})}return gd({plugin:e,schema:{type:`unknown`},state:n})},_d=({plugin:e,schema:t,state:n})=>{let r=J({plugin:e,schema:t,state:n}),i=t.type===`enum`&&e.config.enums.enabled,a=or(n.path.value);Xu({plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{kind:i?void 0:`type`,path:n.path.value,tags:n.tags?.value},name:w({config:e.config.definitions,name:F(a)}),selector:e.api.selector(`ref`,a)}),type:r})},vd=({plugin:e})=>{let t=e.registerSymbol({exported:!0,meta:{kind:`type`,path:[]},name:w({config:{case:e.config.case},name:`ClientOptions`}),selector:e.api.selector(`ClientOptions`)}),n=e.registerSymbol({exported:!0,meta:{kind:`type`,path:[]},name:w({config:{case:e.config.case},name:`Webhooks`}),selector:e.api.selector(`Webhooks`)}),r=[],i=[];e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`server`,`webhook`,t=>{let n=q({path:t._path,tags:t.tags});switch(t.type){case`operation`:$u({operation:t.operation,plugin:e,state:n});break;case`parameter`:_d({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:_d({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:_d({plugin:e,schema:t.schema,state:n});break;case`server`:r.push(t.server);break;case`webhook`:i.push(td({operation:t.operation,plugin:e,state:n}));break}},{order:`declarations`}),qu({plugin:e,servers:r,symbolClientOptions:t}),nd({plugin:e,symbolWebhooks:n,webhookNames:i})},yd={api:new class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}schemaToType(e){return J(e)}}({name:`@hey-api/typescript`}),config:{case:`PascalCase`,exportFromIndex:!0,style:`preserve`,topType:`unknown`,tree:!1},handler:e=>vd(e),handlerLegacy:Fu,name:`@hey-api/typescript`,resolveConfig:(e,t)=>{e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,name:`{{name}}`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.config.definitions}),e.config.enums=t.valueToObject({defaultValue:{case:`SCREAMING_SNAKE_CASE`,constantsIgnoreNull:!1,enabled:!!e.config.enums,mode:`javascript`},mappers:{boolean:e=>({enabled:e}),string:e=>({mode:e})},value:e.config.enums}),e.config.errors=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,error:`{{name}}Error`,name:`{{name}}Errors`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.config.errors}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,name:`{{name}}Data`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,name:`{{name}}Responses`,response:`{{name}}Response`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.config.responses}),e.config.webhooks=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,name:`{{name}}WebhookRequest`,payload:`{{name}}WebhookPayload`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.config.webhooks})}};var bd=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const xd=(e,t,n)=>{let r=e.config[n].meta;if(!r)return;let i=r(t);if(Object.keys(i).length)return P.valueToExpression({value:i})},Sd=({operation:e,plugin:t})=>Rc({operation:e,plugin:t.getPluginOrThrow(`@hey-api/sdk`)}),Cd=({operation:e,plugin:t})=>{let n=y(t.context.config),r=t.getPluginOrThrow(`@hey-api/typescript`),i=t.getSymbol(r.api.selector(`error`,e.id))?.placeholder;return i||=`Error`,n.name===`@hey-api/client-axios`&&(i=`${t.referenceSymbol(t.api.selector(`AxiosError`)).placeholder}<${i}>`),i},wd=({operation:e,plugin:t})=>{let n=t.getPluginOrThrow(`@hey-api/typescript`);return t.getSymbol(n.api.selector(`response`,e.id))?.placeholder||`unknown`},Td=({plugin:e,typeData:t})=>{let n=y(e.context.config).name===`@hey-api/client-nuxt`;return{isNuxtClient:n,strippedTypeData:n?`Omit<${t}, 'composable'>`:t}},Ed=({operation:e,plugin:t,queryFn:n})=>{let r=t.referenceSymbol(t.api.selector(`UseMutationOptions`)),i=Sd({operation:e,plugin:t}),a=Cd({operation:e,plugin:t}),o=wd({operation:e,plugin:t}),{isNuxtClient:s,strippedTypeData:c}=Td({plugin:t,typeData:i}),l=s?`${r.placeholder}<${o}, ${c}, ${a}>`:`${r.placeholder}<${o}, ${i}, ${a}>`,u=`fnOptions`,d=P.awaitExpression({expression:P.callExpression({functionName:n,parameters:[P.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:u},{key:`throwOnError`,value:!0}]})]})}),f=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?f.push(P.returnVariable({expression:d})):f.push(P.constVariable({destructure:!0,expression:d,name:`data`}),P.returnVariable({expression:`data`}));let p=[{key:`mutation`,value:P.arrowFunction({async:!0,multiLine:!0,parameters:[s?{name:u,type:`Partial<${c}>`}:{name:u}],statements:f})}],m=xd(t,e,`mutationOptions`);m&&p.push({key:`meta`,value:m});let h=t.registerSymbol({exported:!0,name:w({config:t.config.mutationOptions,name:e.id})}),g=P.constVariable({comment:t.config.comments?Hc({operation:e}):void 0,exportConst:h.exported,expression:P.arrowFunction({parameters:[{isRequired:!1,name:`options`,type:`Partial<${c}>`}],returnType:l,statements:[P.returnStatement({expression:P.objectExpression({obj:p})})]}),name:h.placeholder});t.setSymbolValue(h,g)},Dd=`TOptions`,Od=P.identifier({text:`options`}),kd=({plugin:e})=>{let t=e.registerSymbol({name:w({config:{case:e.config.case},name:`createQueryKey`}),selector:e.api.selector(`createQueryKey`)}),n=e.referenceSymbol(e.api.selector(`QueryKey`)),r=e.referenceSymbol(e.api.selector(`_JSONValue`)),i=P.indexedAccessTypeNode({indexType:P.literalTypeNode({literal:P.ots.number(0)}),objectType:P.typeReferenceNode({typeArguments:[P.typeReferenceNode({typeName:Dd})],typeName:n.placeholder})}),a=fe(e.context.config),o=e.getPluginOrThrow(`@hey-api/sdk`),s=e.referenceSymbol(o.api.selector(`Options`)),c=y(e.context.config),l=c.api&&`selector`in c.api?e.getSymbol(c.api.selector(`client`)):void 0,u=ll(e.context.config),d=e.registerSymbol({external:u,name:`serializeQueryKeyValue`}),f=P.constVariable({expression:P.arrowFunction({multiLine:!0,parameters:[{name:`id`,type:P.typeReferenceNode({typeName:`string`})},{isRequired:!1,name:`options`,type:P.typeReferenceNode({typeName:Dd})},{isRequired:!1,name:`tags`,type:P.typeReferenceNode({typeName:`ReadonlyArray<string>`})}],returnType:P.typeTupleNode({types:[i]}),statements:[P.constVariable({assertion:i,expression:P.objectExpression({multiLine:!1,obj:[{key:`_id`,value:P.identifier({text:`id`})},{key:a,value:P.identifier({text:`options?.${a} || (options?.client ?? ${l?.placeholder}).getConfig().${a}`})}]}),name:`params`,typeName:i}),P.ifStatement({expression:P.identifier({text:`tags`}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`tags`}),right:P.asExpression({expression:P.asExpression({expression:P.identifier({text:`tags`}),type:P.keywordTypeNode({keyword:`unknown`})}),type:P.typeReferenceNode({typeName:r.placeholder})})})})]})}),P.ifStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:Od,isOptional:!0,name:P.identifier({text:`body`})}),operator:`!==`,right:`undefined`}),thenStatement:P.block({statements:[P.constVariable({expression:P.callExpression({functionName:d.placeholder,parameters:[P.propertyAccessExpression({expression:`options`,name:`body`})]}),name:`normalizedBody`}),P.ifStatement({expression:P.binaryExpression({left:P.identifier({text:`normalizedBody`}),operator:`!==`,right:`undefined`}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`body`}),right:P.identifier({text:`normalizedBody`})})})]})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:Od,isOptional:!0,name:P.identifier({text:`path`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`path`}),right:P.propertyAccessExpression({expression:`options`,name:`path`})})})]})}),P.ifStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:Od,isOptional:!0,name:P.identifier({text:`query`})}),operator:`!==`,right:`undefined`}),thenStatement:P.block({statements:[P.constVariable({expression:P.callExpression({functionName:d.placeholder,parameters:[P.propertyAccessExpression({expression:`options`,name:`query`})]}),name:`normalizedQuery`}),P.ifStatement({expression:P.binaryExpression({left:P.identifier({text:`normalizedQuery`}),operator:`!==`,right:`undefined`}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`query`}),right:P.identifier({text:`normalizedQuery`})})})]})})]})}),P.returnStatement({expression:P.arrayLiteralExpression({elements:[P.identifier({text:`params`})]})})],types:[{extends:P.typeReferenceNode({typeName:P.identifier({text:s.placeholder})}),name:Dd}]}),name:t.placeholder});e.setSymbolValue(t,f)},Ad=({id:e,operation:t,plugin:n})=>{let r=n.config.queryKeys,i;r.tags&&t.tags&&t.tags.length>0&&(i=P.arrayLiteralExpression({elements:t.tags.map(e=>P.stringLiteral({text:e}))}));let a=n.referenceSymbol(n.api.selector(`createQueryKey`));return P.callExpression({functionName:a.placeholder,parameters:[P.ots.string(e),`options`,i]})},jd=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`_JSONValue`)),n=[{name:`_id`,type:P.keywordTypeNode({keyword:`string`})},{isRequired:!1,name:fe(e.context.config),type:P.typeReferenceNode({typeName:t.placeholder})},{isRequired:!1,name:`body`,type:P.typeReferenceNode({typeName:t.placeholder})},{isRequired:!1,name:`query`,type:P.typeReferenceNode({typeName:t.placeholder})},{isRequired:!1,name:`tags`,type:P.typeReferenceNode({typeName:t.placeholder})}],r=e.getPluginOrThrow(`@hey-api/sdk`),i=e.referenceSymbol(r.api.selector(`Options`)),a=e.registerSymbol({exported:!0,meta:{kind:`type`},name:`QueryKey`,selector:e.api.selector(`QueryKey`)}),o=P.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:P.typeTupleNode({types:[P.typeIntersectionNode({types:[P.typeReferenceNode({typeName:`Pick<${Dd}, 'path'>`}),P.typeInterfaceNode({properties:n,useLegacyResolution:!0})]})]}),typeParameters:[{extends:P.typeReferenceNode({typeName:P.identifier({text:i.placeholder})}),name:Dd}]});e.setSymbolValue(a,o)},Md=({operation:e,plugin:t,symbol:n})=>{let{strippedTypeData:r}=Td({plugin:t,typeData:Sd({operation:e,plugin:t})});return P.constVariable({exportConst:n.exported,expression:P.arrowFunction({parameters:[{isRequired:at(e),name:`options`,type:r}],statements:Ad({id:e.id,operation:e,plugin:t})}),name:n.placeholder})},Nd=`options`,Pd=`context`,Fd=({operation:e,plugin:t,queryFn:n})=>{if(Wc({operation:e}))return;let r=Uc({context:t.context,operation:e});t.getSymbol(t.api.selector(`createQueryKey`))||(jd({plugin:t}),kd({plugin:t}));let i;if(t.config.queryKeys.enabled){let n=t.registerSymbol({exported:!0,name:w({config:t.config.queryKeys,name:e.id})}),r=Md({operation:e,plugin:t,symbol:n});t.setSymbolValue(n,r),i=P.callExpression({functionName:n.placeholder,parameters:[Nd]})}else{let n=t.referenceSymbol(t.api.selector(`createQueryKey`)),r;t.config.queryKeys.tags&&e.tags&&e.tags.length>0&&(r=P.arrayLiteralExpression({elements:e.tags.map(e=>P.stringLiteral({text:e}))})),i=P.callExpression({functionName:n.placeholder,parameters:[P.ots.string(e.id),Nd,r]})}let{strippedTypeData:a}=Td({plugin:t,typeData:Sd({operation:e,plugin:t})}),o=P.awaitExpression({expression:P.callExpression({functionName:n,parameters:[P.objectExpression({multiLine:!0,obj:[{spread:Nd},{spread:Pd},{key:`throwOnError`,value:!0}]})]})}),s=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?s.push(P.returnVariable({expression:o})):s.push(P.constVariable({destructure:!0,expression:o,name:`data`}),P.returnVariable({expression:`data`}));let c=[{key:`key`,value:i},{key:`query`,value:P.arrowFunction({async:!0,multiLine:!0,parameters:[{name:Pd}],statements:s})}],l=xd(t,e,`queryOptions`);l&&c.push({key:`meta`,value:l});let u=t.registerSymbol({exported:!0,name:w({config:t.config.queryOptions,name:e.id}),selector:t.api.selector(`queryOptionsFn`,e.id)}),d=t.registerSymbol({external:t.name,name:`defineQueryOptions`,selector:t.api.selector(`defineQueryOptions`)}),f=P.constVariable({comment:t.config.comments?Hc({operation:e}):void 0,exportConst:u.exported,expression:P.callExpression({functionName:d.placeholder,parameters:[P.arrowFunction({parameters:[{isRequired:r,name:Nd,type:a}],statements:P.objectExpression({obj:c})})]}),name:u.placeholder});t.setSymbolValue(u,f)},Id={api:new bd({name:`@pinia/colada`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/typescript`,`@hey-api/sdk`],handler:({plugin:e})=>{e.registerSymbol({external:e.name,meta:{kind:`type`},name:`UseMutationOptions`,selector:e.api.selector(`UseMutationOptions`)}),e.registerSymbol({external:e.name,meta:{kind:`type`},name:`UseQueryOptions`,selector:e.api.selector(`UseQueryOptions`)}),e.registerSymbol({external:e.name,meta:{kind:`type`},name:`_JSONValue`,selector:e.api.selector(`_JSONValue`)}),e.registerSymbol({external:`axios`,meta:{kind:`type`},name:`AxiosError`,selector:e.api.selector(`AxiosError`)});let t=e.getPluginOrThrow(`@hey-api/sdk`);e.forEach(`operation`,({operation:n})=>{let r=t.config.asClass?Lc({context:e.context,operation:n,plugin:t}):void 0,i=r?r.values().next().value:void 0,a=i?[e.referenceSymbol(t.api.selector(`class`,i.path[0])).placeholder,...i.path.slice(1).map(e=>C({case:`camelCase`,value:e})),i.methodName].filter(Boolean).join(`.`):e.referenceSymbol(t.api.selector(`function`,n.id)).placeholder;e.hooks.operation.isQuery(n)&&e.config.queryOptions.enabled&&Fd({operation:n,plugin:e,queryFn:a}),e.hooks.operation.isMutation(n)&&e.config.mutationOptions.enabled&&Ed({operation:n,plugin:e,queryFn:a})},{order:`declarations`})},name:`@pinia/colada`,resolveConfig:(e,t)=>{e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Query`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions})}},Ld=(e,t,n)=>{let r=e.config[n].meta;if(!r)return;let i=r(t);if(Object.keys(i).length)return P.valueToExpression({value:i})},Rd=({operation:e,plugin:t})=>Rc({operation:e,plugin:t.getPluginOrThrow(`@hey-api/sdk`)}),zd=({operation:e,plugin:t})=>{let n=y(t.context.config),r=t.getPluginOrThrow(`@hey-api/typescript`),i=t.getSymbol(r.api.selector(`error`,e.id))?.placeholder;return i||=t.referenceSymbol(t.api.selector(`DefaultError`)).placeholder,n.name===`@hey-api/client-axios`&&(i=`${t.referenceSymbol(t.api.selector(`AxiosError`)).placeholder}<${i}>`),i},Bd=({operation:e,plugin:t})=>{let n=t.getPluginOrThrow(`@hey-api/typescript`);return t.getSymbol(n.api.selector(`response`,e.id))?.placeholder||`unknown`},Vd=`TOptions`,Hd=P.identifier({text:`infinite`}),Ud=P.identifier({text:`options`}),Wd=({plugin:e})=>{let t=e.registerSymbol({name:w({config:{case:e.config.case},name:`createQueryKey`}),selector:e.api.selector(`createQueryKey`)}),n=e.referenceSymbol(e.api.selector(`QueryKey`)),r=P.indexedAccessTypeNode({indexType:P.literalTypeNode({literal:P.ots.number(0)}),objectType:P.typeReferenceNode({typeArguments:[P.typeReferenceNode({typeName:Vd})],typeName:n.placeholder})}),i=fe(e.context.config),a=y(e.context.config),o=a.api&&`selector`in a.api?e.getSymbol(a.api.selector(`client`)):void 0,s=e.getPluginOrThrow(`@hey-api/sdk`),c=e.referenceSymbol(s.api.selector(`Options`)),l=P.constVariable({expression:P.arrowFunction({multiLine:!0,parameters:[{name:`id`,type:P.typeReferenceNode({typeName:`string`})},{isRequired:!1,name:`options`,type:P.typeReferenceNode({typeName:Vd})},{isRequired:!1,name:`infinite`,type:P.typeReferenceNode({typeName:`boolean`})},{isRequired:!1,name:`tags`,type:P.typeReferenceNode({typeName:`ReadonlyArray<string>`})}],returnType:P.typeTupleNode({types:[r]}),statements:[P.constVariable({assertion:r,expression:P.objectExpression({multiLine:!1,obj:[{key:`_id`,value:P.identifier({text:`id`})},{key:i,value:P.identifier({text:`options?.${i} || (options?.client ?? ${o?.placeholder}).getConfig().${i}`})}]}),name:`params`,typeName:r}),P.ifStatement({expression:Hd,thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`_infinite`}),right:Hd})})]})}),P.ifStatement({expression:P.identifier({text:`tags`}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`tags`}),right:P.identifier({text:`tags`})})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:Ud,isOptional:!0,name:P.identifier({text:`body`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`body`}),right:P.propertyAccessExpression({expression:`options`,name:`body`})})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:Ud,isOptional:!0,name:P.identifier({text:`headers`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`headers`}),right:P.propertyAccessExpression({expression:`options`,name:`headers`})})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:Ud,isOptional:!0,name:P.identifier({text:`path`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`path`}),right:P.propertyAccessExpression({expression:`options`,name:`path`})})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:Ud,isOptional:!0,name:P.identifier({text:`query`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`query`}),right:P.propertyAccessExpression({expression:`options`,name:`query`})})})]})}),P.returnStatement({expression:P.arrayLiteralExpression({elements:[P.identifier({text:`params`})]})})],types:[{extends:P.typeReferenceNode({typeName:P.identifier({text:c.placeholder})}),name:Vd}]}),name:t.placeholder});e.setSymbolValue(t,l)},Gd=({id:e,isInfinite:t,operation:n,plugin:r})=>{let i=t?r.config.infiniteQueryKeys:r.config.queryKeys,a;i.tags&&n.tags&&n.tags.length>0&&(a=P.arrayLiteralExpression({elements:n.tags.map(e=>P.stringLiteral({text:e}))}));let o=r.referenceSymbol(r.api.selector(`createQueryKey`));return P.callExpression({functionName:o.placeholder,parameters:[P.ots.string(e),`options`,t||a?P.ots.boolean(!!t):void 0,a]})},Kd=({plugin:e})=>{let t=[{name:`_id`,type:P.keywordTypeNode({keyword:`string`})},{isRequired:!1,name:`_infinite`,type:P.keywordTypeNode({keyword:`boolean`})},{isRequired:!1,name:`tags`,type:P.typeReferenceNode({typeName:`ReadonlyArray<string>`})}],n=e.getPluginOrThrow(`@hey-api/sdk`),r=e.referenceSymbol(n.api.selector(`Options`)),i=e.registerSymbol({exported:!0,meta:{kind:`type`},name:`QueryKey`,selector:e.api.selector(`QueryKey`)}),a=P.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:P.typeTupleNode({types:[P.typeIntersectionNode({types:[P.typeReferenceNode({typeName:`Pick<${Vd}, '${fe(e.context.config)}' | 'body' | 'headers' | 'path' | 'query'>`}),P.typeInterfaceNode({properties:t,useLegacyResolution:!0})]})]}),typeParameters:[{extends:P.typeReferenceNode({typeName:P.identifier({text:r.placeholder})}),name:Vd}]});e.setSymbolValue(i,a)},qd=({isInfinite:e,operation:t,plugin:n,symbol:r,typeQueryKey:i})=>{let a=Rd({operation:t,plugin:n});return P.constVariable({exportConst:r.exported,expression:P.arrowFunction({parameters:[{isRequired:at(t),name:`options`,type:a}],returnType:e?i:void 0,statements:Gd({id:t.id,isInfinite:e,operation:t,plugin:n})}),name:r.placeholder})},Jd=({plugin:e})=>{let t=e.registerSymbol({name:w({config:{case:e.config.case},name:`createInfiniteParams`}),selector:e.api.selector(`createInfiniteParams`)}),n=P.constVariable({expression:P.arrowFunction({multiLine:!0,parameters:[{name:`queryKey`,type:P.typeReferenceNode({typeName:`QueryKey<Options>`})},{name:`page`,type:P.typeReferenceNode({typeName:`K`})}],statements:[P.constVariable({expression:P.objectExpression({obj:[{spread:P.propertyAccessExpression({expression:`queryKey`,name:0})}]}),name:`params`}),P.ifStatement({expression:P.propertyAccessExpression({expression:P.identifier({text:`page`}),name:P.identifier({text:`body`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`body`}),right:P.objectExpression({multiLine:!0,obj:[{assertion:`any`,spread:`queryKey[0].body`},{assertion:`any`,spread:`page.body`}]})})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:P.identifier({text:`page`}),name:P.identifier({text:`headers`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`headers`}),right:P.objectExpression({multiLine:!0,obj:[{spread:`queryKey[0].headers`},{spread:`page.headers`}]})})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:P.identifier({text:`page`}),name:P.identifier({text:`path`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`path`}),right:P.objectExpression({multiLine:!0,obj:[{assertion:`any`,spread:`queryKey[0].path`},{assertion:`any`,spread:`page.path`}]})})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:P.identifier({text:`page`}),name:P.identifier({text:`query`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`query`}),right:P.objectExpression({multiLine:!0,obj:[{assertion:`any`,spread:`queryKey[0].query`},{assertion:`any`,spread:`page.query`}]})})})]})}),P.returnVariable({expression:P.asExpression({expression:P.asExpression({expression:P.identifier({text:`params`}),type:P.keywordTypeNode({keyword:`unknown`})}),type:l.factory.createTypeQueryNode(P.identifier({text:`page`}))})})],types:[{extends:P.typeReferenceNode({typeName:P.identifier({text:`Pick<QueryKey<Options>[0], 'body' | 'headers' | 'path' | 'query'>`})}),name:`K`}]}),name:t.placeholder});e.setSymbolValue(t,n)},Yd=({operation:e,plugin:t,queryFn:n})=>{let r=ot({context:t.context,operation:e});if(!r)return;let i=Uc({context:t.context,operation:e});t.getSymbol(t.api.selector(`createQueryKey`))||(Kd({plugin:t}),Wd({plugin:t})),t.getSymbol(t.api.selector(`createInfiniteParams`))||Jd({plugin:t});let a=t.referenceSymbol(t.api.selector(`infiniteQueryOptions`)),o=t.referenceSymbol(t.api.selector(`InfiniteData`)),s=Rd({operation:e,plugin:t}),c=zd({operation:e,plugin:t}),l=Bd({operation:e,plugin:t}),u=`${t.referenceSymbol(t.api.selector(`QueryKey`)).placeholder}<${s}>`,d=`Pick<${u}[0], 'body' | 'headers' | 'path' | 'query'>`,f=t.getPluginOrThrow(`@hey-api/typescript`),p=`${Tt({node:f.api.schemaToType({plugin:f,schema:r.schema,state:{path:{value:[]}}}),unescape:!0})} | ${d}`,m=t.registerSymbol({exported:!0,name:w({config:t.config.infiniteQueryKeys,name:e.id})}),h=qd({isInfinite:!0,operation:e,plugin:t,symbol:m,typeQueryKey:u});t.setSymbolValue(m,h);let g=P.awaitExpression({expression:P.callExpression({functionName:n,parameters:[P.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:`params`},{key:`signal`,shorthand:!0,value:P.identifier({text:`signal`})},{key:`throwOnError`,value:!0}]})]})}),ee=t.referenceSymbol(t.api.selector(`createInfiniteParams`)),_=[P.constVariable({comment:[{jsdoc:!1,lines:[`@ts-ignore`]}],expression:P.conditionalExpression({condition:P.binaryExpression({left:P.typeOfExpression({text:`pageParam`}),operator:`===`,right:P.ots.string(`object`)}),whenFalse:P.objectExpression({multiLine:!0,obj:[{key:r.in,value:P.objectExpression({multiLine:!0,obj:[{key:r.name,value:P.identifier({text:`pageParam`})}]})}]}),whenTrue:P.identifier({text:`pageParam`})}),name:`page`,typeName:d}),P.constVariable({expression:P.callExpression({functionName:ee.placeholder,parameters:[`queryKey`,`page`]}),name:`params`})];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?_.push(P.returnVariable({expression:g})):_.push(P.constVariable({destructure:!0,expression:g,name:`data`}),P.returnVariable({expression:`data`}));let te=[{key:`queryFn`,value:P.arrowFunction({async:!0,multiLine:!0,parameters:[{destructure:[{name:`pageParam`},{name:`queryKey`},{name:`signal`}]}],statements:_})},{key:`queryKey`,value:P.callExpression({functionName:m.placeholder,parameters:[`options`]})}],v=Ld(t,e,`infiniteQueryOptions`);v&&te.push({key:`meta`,value:v});let ne=t.registerSymbol({exported:!0,name:w({config:t.config.infiniteQueryOptions,name:e.id})}),re=P.constVariable({comment:t.config.comments?Hc({operation:e}):void 0,exportConst:ne.exported,expression:P.arrowFunction({parameters:[{isRequired:i,name:`options`,type:s}],statements:[P.returnFunctionCall({args:[P.objectExpression({comments:[{jsdoc:!1,lines:[`@ts-ignore`]}],obj:te})],name:a.placeholder,types:[l,c||`unknown`,`${o.placeholder}<${l}>`,u,p]})]}),name:ne.placeholder});t.setSymbolValue(ne,re)},Xd=({operation:e,plugin:t,queryFn:n})=>{let r=t.referenceSymbol(t.api.selector(`MutationOptions`)),i=Rd({operation:e,plugin:t}),a=zd({operation:e,plugin:t}),o=Bd({operation:e,plugin:t}),s=`${r.placeholder}<${o}, ${a}, ${i}>`,c=`fnOptions`,l=P.awaitExpression({expression:P.callExpression({functionName:n,parameters:[P.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:c},{key:`throwOnError`,value:!0}]})]})}),u=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?u.push(P.returnVariable({expression:l})):u.push(P.constVariable({destructure:!0,expression:l,name:`data`}),P.returnVariable({expression:`data`}));let d=[{key:`mutationFn`,value:P.arrowFunction({async:!0,multiLine:!0,parameters:[{name:c}],statements:u})}],f=Ld(t,e,`mutationOptions`);f&&d.push({key:`meta`,value:f});let p=`mutationOptions`,m=P.arrowFunction({parameters:[{isRequired:!1,name:`options`,type:`Partial<${i}>`}],returnType:s,statements:[P.constVariable({expression:P.objectExpression({obj:d}),name:p,typeName:s}),P.returnVariable({expression:p})]}),h=t.registerSymbol({exported:!0,name:w({config:t.config.mutationOptions,name:e.id})}),g=P.constVariable({comment:t.config.comments?Hc({operation:e}):void 0,exportConst:h.exported,expression:m,name:h.placeholder});t.setSymbolValue(h,g)},Zd=`options`,Qd=({operation:e,plugin:t,queryFn:n})=>{if(Wc({operation:e}))return;let r=Uc({context:t.context,operation:e});t.getSymbol(t.api.selector(`createQueryKey`))||(Kd({plugin:t}),Wd({plugin:t}));let i=t.referenceSymbol(t.api.selector(`queryOptions`)),a=t.registerSymbol({exported:!0,name:w({config:t.config.queryKeys,name:e.id})}),o=qd({isInfinite:!1,operation:e,plugin:t,symbol:a});t.setSymbolValue(a,o);let s=Rd({operation:e,plugin:t}),c=P.awaitExpression({expression:P.callExpression({functionName:n,parameters:[P.objectExpression({multiLine:!0,obj:[{spread:Zd},{spread:`queryKey[0]`},{key:`signal`,shorthand:!0,value:P.identifier({text:`signal`})},{key:`throwOnError`,value:!0}]})]})}),l=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?l.push(P.returnVariable({expression:c})):l.push(P.constVariable({destructure:!0,expression:c,name:`data`}),P.returnVariable({expression:`data`}));let u=[{key:`queryFn`,value:P.arrowFunction({async:!0,multiLine:!0,parameters:[{destructure:[{name:`queryKey`},{name:`signal`}]}],statements:l})},{key:`queryKey`,value:P.callExpression({functionName:a.placeholder,parameters:[Zd]})}],d=Ld(t,e,`queryOptions`);d&&u.push({key:`meta`,value:d});let f=t.registerSymbol({exported:t.config.queryOptions.exported,name:w({config:t.config.queryOptions,name:e.id}),selector:t.api.selector(`queryOptionsFn`,e.id)}),p=P.constVariable({comment:t.config.comments?Hc({operation:e}):void 0,exportConst:f.exported,expression:P.arrowFunction({parameters:[{isRequired:r,name:Zd,type:s}],statements:[P.returnFunctionCall({args:[P.objectExpression({obj:u})],name:i.placeholder})]}),name:f.placeholder});t.setSymbolValue(f,p)},$d=`options`,ef=({operation:e,plugin:t})=>{if(Wc({operation:e})||!(`useQuery`in t.config))return;let n=t.registerSymbol({exported:!0,name:w({config:t.config.useQuery,name:e.id})}),r=t.referenceSymbol(t.api.selector(`useQuery`)),i=Uc({context:t.context,operation:e}),a=Rd({operation:e,plugin:t}),o=t.referenceSymbol(t.api.selector(`queryOptionsFn`,e.id)),s=P.constVariable({comment:t.config.comments?Hc({operation:e}):void 0,exportConst:n.exported,expression:P.arrowFunction({parameters:[{isRequired:i,name:$d,type:a}],statements:[P.returnStatement({expression:P.callExpression({functionName:r.placeholder,parameters:[P.callExpression({functionName:o.placeholder,parameters:[$d]})]})})]}),name:n.placeholder});t.setSymbolValue(n,s)},tf=({plugin:e})=>{e.registerSymbol({external:e.name,meta:{kind:`type`},name:`DefaultError`,selector:e.api.selector(`DefaultError`)}),e.registerSymbol({external:e.name,meta:{kind:`type`},name:`InfiniteData`,selector:e.api.selector(`InfiniteData`)});let t=e.name===`@tanstack/angular-query-experimental`||e.name===`@tanstack/svelte-query`||e.name===`@tanstack/solid-query`?`MutationOptions`:`UseMutationOptions`;e.registerSymbol({external:e.name,meta:{kind:`type`},name:t,selector:e.api.selector(`MutationOptions`)}),e.registerSymbol({external:e.name,name:`infiniteQueryOptions`,selector:e.api.selector(`infiniteQueryOptions`)}),e.registerSymbol({external:e.name,name:`queryOptions`,selector:e.api.selector(`queryOptions`)}),e.registerSymbol({external:e.name,name:`useQuery`,selector:e.api.selector(`useQuery`)}),e.registerSymbol({external:`axios`,meta:{kind:`type`},name:`AxiosError`,selector:e.api.selector(`AxiosError`)});let n=e.getPluginOrThrow(`@hey-api/sdk`);e.forEach(`operation`,({operation:t})=>{let r=n.config.asClass?Lc({context:e.context,operation:t,plugin:n}):void 0,i=r?r.values().next().value:void 0,a=i?[e.referenceSymbol(n.api.selector(`class`,i.path[0])).placeholder,...i.path.slice(1).map(e=>C({case:`camelCase`,value:e})),i.methodName].filter(Boolean).join(`.`):e.referenceSymbol(n.api.selector(`function`,t.id)).placeholder;e.hooks.operation.isQuery(t)&&(e.config.queryOptions.enabled&&Qd({operation:t,plugin:e,queryFn:a}),e.config.infiniteQueryOptions.enabled&&Yd({operation:t,plugin:e,queryFn:a}),`useQuery`in e.config&&e.config.useQuery.enabled&&ef({operation:t,plugin:e})),e.hooks.operation.isMutation(t)&&e.config.mutationOptions.enabled&&Xd({operation:t,plugin:e,queryFn:a})},{order:`declarations`})},nf=e=>`${uu({config:b(),id:e.name,operation:e})}InfiniteOptions`,rf=e=>`${uu({config:b(),id:e.name,operation:e})}Mutation`,af=({config:e,id:t,operation:n})=>`${uu({config:e,id:t,operation:n})}Options`,of=({config:e,id:t,isInfinite:n,operation:r})=>`${uu({config:e,id:t,operation:r})}${n?`Infinite`:``}QueryKey`,sf=e=>{switch(e.in){case`formData`:return`body`;case`header`:return`headers`;default:return e.in}},cf=`createQueryKey`,lf=`infiniteQueryOptions`,uf=`mutationOptions`,df=`QueryKey`,ff=`queryOptions`,pf=`TOptions`,mf=({file:e})=>{let t=P.constVariable({expression:P.arrowFunction({multiLine:!0,parameters:[{name:`queryKey`,type:P.typeNode(`QueryKey<OptionsLegacyParser>`)},{name:`page`,type:P.typeNode(`K`)}],statements:[P.constVariable({expression:P.identifier({text:`queryKey[0]`}),name:`params`}),P.ifStatement({expression:P.propertyAccessExpression({expression:P.identifier({text:`page`}),name:P.identifier({text:`body`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`body`}),right:P.objectExpression({multiLine:!0,obj:[{assertion:`any`,spread:`queryKey[0].body`},{assertion:`any`,spread:`page.body`}]})})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:P.identifier({text:`page`}),name:P.identifier({text:`headers`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`headers`}),right:P.objectExpression({multiLine:!0,obj:[{spread:`queryKey[0].headers`},{spread:`page.headers`}]})})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:P.identifier({text:`page`}),name:P.identifier({text:`path`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`path`}),right:P.objectExpression({multiLine:!0,obj:[{spread:`queryKey[0].path`},{spread:`page.path`}]})})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:P.identifier({text:`page`}),name:P.identifier({text:`query`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`query`}),right:P.objectExpression({multiLine:!0,obj:[{spread:`queryKey[0].query`},{spread:`page.query`}]})})})]})}),P.returnVariable({expression:l.factory.createAsExpression(l.factory.createAsExpression(P.identifier({text:`params`}),l.factory.createKeywordTypeNode(l.SyntaxKind.UnknownKeyword)),l.factory.createTypeQueryNode(P.identifier({text:`page`})))})],types:[{extends:P.typeReferenceNode({typeName:P.identifier({text:`Pick<QueryKey<OptionsLegacyParser>[0], 'body' | 'headers' | 'path' | 'query'>`})}),name:`K`}]}),name:`createInfiniteParams`});e.add(t)},hf=({file:e})=>{let t=P.indexedAccessTypeNode({indexType:P.typeNode(0),objectType:P.typeNode(df,[P.typeNode(pf)])}),n=P.identifier({text:`infinite`}),r=fe(b()),i=P.constVariable({expression:P.arrowFunction({multiLine:!0,parameters:[{name:`id`,type:P.typeNode(`string`)},{isRequired:!1,name:`options`,type:P.typeNode(pf)},{isRequired:!1,name:`infinite`,type:P.typeNode(`boolean`)}],returnType:t,statements:[P.constVariable({assertion:t,expression:P.objectExpression({multiLine:!1,obj:[{key:`_id`,value:P.identifier({text:`id`})},{key:r,value:P.identifier({text:`options?.${r} || (options?.client ?? _heyApiClient).getConfig().${r}`})}]}),name:`params`,typeName:t}),P.ifStatement({expression:n,thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`_infinite`}),right:n})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:P.identifier({text:`options`}),isOptional:!0,name:P.identifier({text:`body`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`body`}),right:P.propertyAccessExpression({expression:`options`,name:`body`})})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:P.identifier({text:`options`}),isOptional:!0,name:P.identifier({text:`headers`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`headers`}),right:P.propertyAccessExpression({expression:`options`,name:`headers`})})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:P.identifier({text:`options`}),isOptional:!0,name:P.identifier({text:`path`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`path`}),right:P.propertyAccessExpression({expression:`options`,name:`path`})})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:P.identifier({text:`options`}),isOptional:!0,name:P.identifier({text:`query`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`query`}),right:P.propertyAccessExpression({expression:`options`,name:`query`})})})]})}),P.returnVariable({expression:`params`})],types:[{extends:P.typeReferenceNode({typeName:P.identifier({text:`OptionsLegacyParser`})}),name:pf}]}),name:cf});e.add(i)},gf=({file:e})=>{let t=[{name:`_id`,type:P.keywordTypeNode({keyword:`string`})},{isRequired:!1,name:`_infinite`,type:P.keywordTypeNode({keyword:`boolean`})}],n=P.typeAliasDeclaration({name:df,type:P.typeTupleNode({types:[P.typeIntersectionNode({types:[P.typeReferenceNode({typeName:`Pick<${pf}, '${fe(b())}' | 'body' | 'headers' | 'path' | 'query'>`}),P.typeInterfaceNode({properties:t,useLegacyResolution:!0})]})]}),typeParameters:[{extends:P.typeReferenceNode({typeName:P.identifier({text:`OptionsLegacyParser`})}),name:pf}]});e.add(n)},_f=({client:e,file:t,operation:n,typesModulePath:r})=>{let{name:i}=$l({client:e,meta:n.parameters.length?{$ref:n.name,name:n.name}:void 0,nameTransformer:tu,onImport:e=>{t.import({asType:!0,module:r,name:e})}});return{typeData:au({importedType:i})}},vf=({client:e,file:t,operation:n,pluginName:r,typesModulePath:i})=>{let a=b(),{name:o}=$l({client:e,meta:{$ref:n.name,name:n.name},nameTransformer:nu,onImport:e=>{t.import({asType:!0,module:i,name:e})}}),s={asType:!0,name:o};if(s.name||(s=t.import({asType:!0,module:r,name:`DefaultError`})),y(a).name===`@hey-api/client-axios`){let e=t.import({asType:!0,module:`axios`,name:`AxiosError`});s={...e,name:`${e.name}<${s.name}>`}}return{typeError:s}},yf=({client:e,file:t,operation:n,typesModulePath:r})=>{let{name:i}=$l({client:e,meta:{$ref:n.name,name:n.name},nameTransformer:iu,onImport:e=>{t.import({asType:!0,module:r,name:e})}});return{typeResponse:i||`void`}},bf=({id:e,isInfinite:t})=>P.arrayLiteralExpression({elements:[P.callExpression({functionName:cf,parameters:[P.ots.string(e),`options`,t?P.ots.boolean(!0):void 0]})],multiLine:!1}),xf=({client:e,files:t,plugin:n})=>{let r=b();if(x(r))throw Error(`TanStack Query plugin does not support legacy clients`);let i=t[n.name];i.import({asType:!0,module:cl({config:r,sourceOutput:n.output}),name:`OptionsLegacyParser`});let a=re({moduleOutput:t.types.nameWithoutExtension(),sourceOutput:n.output}),o=n.name===`@tanstack/angular-query-experimental`||n.name===`@tanstack/svelte-query`||n.name===`@tanstack/solid-query`?`MutationOptions`:`UseMutationOptions`,s,c=!1,l=!1,u=!1,d=!1,f=!1,p=new Map;for(let m of e.services)for(let h of m.operations){let g=D(h);if(p.has(g))continue;p.set(g,!0);let ee=[r.plugins[`@hey-api/sdk`]?.config.asClass&&Xo({config:r,name:m.name}),uu({config:r,handleIllegal:!r.plugins[`@hey-api/sdk`]?.config.asClass,id:h.name,operation:h})].filter(Boolean).join(`.`),_=!1;if(n.config.queryOptions.enabled&&[`GET`,`POST`].includes(h.method)){f||(f=!0,l||=(gf({file:i}),hf({file:i}),!0),i.import({module:n.name,name:ff})),_=!0;let{typeData:t}=_f({client:e,file:i,operation:h,typesModulePath:a}),o=Is(h.parameters),s=P.constVariable({exportConst:!0,expression:P.arrowFunction({parameters:[{isRequired:o,name:`options`,type:t}],statements:bf({id:h.name})}),name:of({config:r,id:h.name,operation:h})});i.add(s);let c=P.constVariable({comment:[],exportConst:!0,expression:P.arrowFunction({parameters:[{isRequired:o,name:`options`,type:t}],statements:[P.returnFunctionCall({args:[P.objectExpression({obj:[{key:`queryFn`,value:P.arrowFunction({async:!0,multiLine:!0,parameters:[{destructure:[{name:`queryKey`},{name:`signal`}]}],statements:[P.constVariable({destructure:!0,expression:P.awaitExpression({expression:P.callExpression({functionName:ee,parameters:[P.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:`queryKey[0]`},{key:`signal`,shorthand:!0,value:P.identifier({text:`signal`})},{key:`throwOnError`,value:!0}]})]})}),name:`data`}),P.returnVariable({expression:`data`})]})},{key:`queryKey`,value:P.callExpression({functionName:of({config:r,id:h.name,operation:h}),parameters:[`options`]})}]})],name:ff})]}),name:af({config:r,id:h.name,operation:h})});i.add(c)}if(n.config.infiniteQueryOptions&&[`GET`,`POST`].includes(h.method)){let t,o=h.parameters.find(n=>{if(Ni(r.parser.pagination).test(n.name))return t=n,!0;if(n.in===`body`){if(n.export===`reference`){let i=n.$refs[0];return e.models.find(e=>e.meta?.$ref===i)?.properties.find(e=>{if(Ni(r.parser.pagination).test(e.name))return t=e,!0})}return n.properties.find(e=>{if(Ni(r.parser.pagination).test(e.name))return t=e,!0})}});if(o&&t){u||(u=!0,l||=(gf({file:i}),hf({file:i}),!0),c||=(mf({file:i}),!0),i.import({module:n.name,name:lf}),s=i.import({asType:!0,module:n.name,name:`InfiniteData`})),_=!0;let{typeData:d}=_f({client:e,file:i,operation:h,typesModulePath:a}),{typeError:f}=vf({client:e,file:i,operation:h,pluginName:n.name,typesModulePath:a}),{typeResponse:p}=yf({client:e,file:i,operation:h,typesModulePath:a}),m=Is(h.parameters),g=`${df}<${d}>`,te=`Pick<${g}[0], 'body' | 'headers' | 'path' | 'query'>`,v=`${t.base} | ${te}`,ne=P.constVariable({exportConst:!0,expression:P.arrowFunction({parameters:[{isRequired:m,name:`options`,type:d}],returnType:g,statements:bf({id:h.name,isInfinite:!0})}),name:of({config:r,id:h.name,isInfinite:!0,operation:h})});i.add(ne);let re=P.constVariable({comment:[],exportConst:!0,expression:P.arrowFunction({parameters:[{isRequired:m,name:`options`,type:d}],statements:[P.returnFunctionCall({args:[P.objectExpression({comments:[{jsdoc:!1,lines:[`@ts-ignore`]}],obj:[{key:`queryFn`,value:P.arrowFunction({async:!0,multiLine:!0,parameters:[{destructure:[{name:`pageParam`},{name:`queryKey`},{name:`signal`}]}],statements:[P.constVariable({comment:[{jsdoc:!1,lines:[`@ts-ignore`]}],expression:P.conditionalExpression({condition:P.binaryExpression({left:P.typeOfExpression({text:`pageParam`}),operator:`===`,right:P.ots.string(`object`)}),whenFalse:P.objectExpression({multiLine:!0,obj:[{key:sf(o),value:P.objectExpression({multiLine:!0,obj:[{key:t.name,value:P.identifier({text:`pageParam`})}]})}]}),whenTrue:P.identifier({text:`pageParam`})}),name:`page`,typeName:te}),P.constVariable({expression:P.callExpression({functionName:`createInfiniteParams`,parameters:[`queryKey`,`page`]}),name:`params`}),P.constVariable({destructure:!0,expression:P.awaitExpression({expression:P.callExpression({functionName:ee,parameters:[P.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:`params`},{key:`signal`,shorthand:!0,value:P.identifier({text:`signal`})},{key:`throwOnError`,value:!0}]})]})}),name:`data`}),P.returnVariable({expression:`data`})]})},{key:`queryKey`,value:P.callExpression({functionName:of({config:r,id:h.name,isInfinite:!0,operation:h}),parameters:[`options`]})}]})],name:lf,types:[p,f.name,`${typeof s==`string`?s:s.name}<${p}>`,g,v]})]}),name:nf(h)});i.add(re)}}if(n.config.mutationOptions&&[`DELETE`,`PATCH`,`POST`,`PUT`].includes(h.method)){d||(d=!0,i.import({asType:!0,module:n.name,name:o})),_=!0;let{typeData:t}=_f({client:e,file:i,operation:h,typesModulePath:a}),{typeError:r}=vf({client:e,file:i,operation:h,pluginName:n.name,typesModulePath:a}),{typeResponse:s}=yf({client:e,file:i,operation:h,typesModulePath:a}),c=`fnOptions`,l=P.arrowFunction({parameters:[{isRequired:!1,name:`options`,type:`Partial<${t}>`}],statements:[P.constVariable({expression:P.objectExpression({obj:[{key:`mutationFn`,value:P.arrowFunction({async:!0,multiLine:!0,parameters:[{name:c}],statements:[P.constVariable({destructure:!0,expression:P.awaitExpression({expression:P.callExpression({functionName:ee,parameters:[P.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:c},{key:`throwOnError`,value:!0}]})]})}),name:`data`}),P.returnVariable({expression:`data`})]})}]}),name:uf,typeName:`${o}<${s}, ${r.name}, ${t}>`}),P.returnVariable({expression:uf})]}),u=P.constVariable({comment:[],exportConst:!0,expression:l,name:rf(h)});i.add(u)}(f||u)&&i.import({alias:`_heyApiClient`,module:re({moduleOutput:t.client.nameWithoutExtension(),sourceOutput:n.output}),name:`client`}),_&&i.import({module:re({moduleOutput:t.sdk.nameWithoutExtension(),sourceOutput:n.output}),name:ee.split(`.`)[0]})}},Sf={api:new class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}}({name:`@tanstack/angular-query-experimental`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:tf,handlerLegacy:xf,name:`@tanstack/angular-query-experimental`,output:`@tanstack/angular-query-experimental`,resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteQueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteOptions`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,exported:!0,name:`{{name}}Options`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions})}},Cf={api:new class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}}({name:`@tanstack/react-query`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:tf,handlerLegacy:xf,name:`@tanstack/react-query`,output:`@tanstack/react-query`,resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteQueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteOptions`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,exported:!0,name:`{{name}}Options`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions}),e.config.useQuery=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!1,name:`use{{name}}Query`},mappers:{boolean:e=>({enabled:e}),function:e=>({enabled:!0,name:e}),object:e=>({enabled:!0,...e}),string:e=>({enabled:!0,name:e})},value:e.config.useQuery}),e.config.useQuery.enabled&&(e.config.queryOptions.enabled||(e.config.queryOptions.enabled=!0,e.config.queryOptions.exported=!1))}},wf={api:new class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}}({name:`@tanstack/solid-query`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:tf,handlerLegacy:xf,name:`@tanstack/solid-query`,output:`@tanstack/solid-query`,resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteQueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteOptions`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,exported:!0,name:`{{name}}Options`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions})}},Tf={api:new class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}}({name:`@tanstack/svelte-query`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:tf,handlerLegacy:xf,name:`@tanstack/svelte-query`,output:`@tanstack/svelte-query`,resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteQueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteOptions`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,exported:!0,name:`{{name}}Options`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions})}},Ef={api:new class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}}({name:`@tanstack/vue-query`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:tf,handlerLegacy:xf,name:`@tanstack/vue-query`,output:`@tanstack/vue-query`,resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteQueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteOptions`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,exported:!0,name:`{{name}}Options`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions})}},Df=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`data`,e.id));if(!n)return;let r=`data`;return P.arrowFunction({async:!0,parameters:[{name:r}],statements:[P.returnStatement({expression:P.awaitExpression({expression:P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:`parseAsync`}),parameters:[P.identifier({text:r})]})})})]})},Of=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`responses`,e.id));if(!n)return;let r=`data`;return P.arrowFunction({async:!0,parameters:[{name:r}],statements:[P.returnStatement({expression:P.awaitExpression({expression:P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:`parseAsync`}),parameters:[P.identifier({text:r})]})})})]})};var kf=class{constructor(e){this.meta=e}createRequestValidator(e){return Df(e)}createResponseValidator(e){return Of(e)}selector(...e){return[this.meta.name,...e]}};const Y={keywords:{false:P.identifier({text:`false`}),true:P.identifier({text:`true`})},number:{Infinity:P.identifier({text:`Infinity`}),NaN:P.identifier({text:`NaN`}),NegativeInfinity:P.identifier({text:`NegativeInfinity`}),epoch:P.identifier({text:`epoch`}),integer:P.identifier({text:`integer`}),safe:P.identifier({text:`safe`})},primitives:{bigint:P.identifier({text:`bigint`}),boolean:P.identifier({text:`boolean`}),keywords:P.identifier({text:`keywords`}),null:`null`,number:P.identifier({text:`number`}),string:`string`,symbol:P.identifier({text:`symbol`}),undefined:P.identifier({text:`undefined`}),unit:P.identifier({text:`unit`})},string:{NFC:P.identifier({text:`NFC`}),NFD:P.identifier({text:`NFD`}),NFKC:P.identifier({text:`NFKC`}),NFKD:P.identifier({text:`NFKD`}),alpha:P.identifier({text:`alpha`}),alphanumeric:P.identifier({text:`alphanumeric`}),base64:P.identifier({text:`base64`}),capitalize:P.identifier({text:`capitalize`}),creditCard:P.identifier({text:`creditCard`}),date:`date`,digits:P.identifier({text:`digits`}),email:`email`,epoch:P.identifier({text:`epoch`}),hex:P.identifier({text:`hex`}),integer:P.identifier({text:`integer`}),ip:`ip`,iso:`iso`,json:P.identifier({text:`json`}),lower:P.identifier({text:`lower`}),normalize:P.identifier({text:`normalize`}),numeric:P.identifier({text:`numeric`}),parse:P.identifier({text:`parse`}),preformatted:P.identifier({text:`preformatted`}),regex:P.identifier({text:`regex`}),semver:P.identifier({text:`semver`}),trim:P.identifier({text:`trim`}),upper:P.identifier({text:`upper`}),url:`url`,uuid:`uuid`,v1:`v1`,v2:`v2`,v3:`v3`,v4:`v4`,v5:`v5`,v6:`v6`,v7:`v7`,v8:`v8`},type:{$:P.identifier({text:`$`}),allows:P.identifier({text:`allows`}),and:P.identifier({text:`and`}),array:P.identifier({text:`array`}),as:P.identifier({text:`as`}),assert:P.identifier({text:`assert`}),brand:P.identifier({text:`brand`}),configure:P.identifier({text:`configure`}),default:P.identifier({text:`default`}),describe:P.identifier({text:`describe`}),description:P.identifier({text:`description`}),equals:P.identifier({text:`equals`}),exclude:P.identifier({text:`exclude`}),expression:P.identifier({text:`expression`}),extends:P.identifier({text:`extends`}),extract:P.identifier({text:`extract`}),filter:P.identifier({text:`filter`}),from:P.identifier({text:`from`}),ifEquals:P.identifier({text:`ifEquals`}),ifExtends:P.identifier({text:`ifExtends`}),infer:P.identifier({text:`infer`}),inferIn:P.identifier({text:`inferIn`}),intersect:P.identifier({text:`intersect`}),json:P.identifier({text:`json`}),meta:P.identifier({text:`meta`}),narrow:P.identifier({text:`narrow`}),onDeepUndeclaredKey:P.identifier({text:`onDeepUndeclaredKey`}),onUndeclaredKey:P.identifier({text:`onUndeclaredKey`}),optional:P.identifier({text:`optional`}),or:P.identifier({text:`or`}),overlaps:P.identifier({text:`overlaps`}),pipe:P.identifier({text:`pipe`}),select:P.identifier({text:`select`}),to:P.identifier({text:`to`}),toJsonSchema:P.identifier({text:`toJsonSchema`})}},Af=({ast:e,plugin:t,schema:n,symbol:r,typeInferSymbol:i})=>{let a=t.referenceSymbol(t.api.selector(`external`,`arktype.type`)),o=P.constVariable({comment:t.config.comments?Ju({schema:n}):void 0,exportConst:r.exported,expression:P.callExpression({functionName:a.placeholder,parameters:[e.def?P.stringLiteral({text:e.def}):e.expression]}),name:r.placeholder});if(t.setSymbolValue(r,o),i){let e=P.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:l.factory.createTypeQueryNode(l.factory.createQualifiedName(l.factory.createIdentifier(r.placeholder),Y.type.infer))});t.setSymbolValue(i,e)}},jf=e=>{let t={};return t.def=Y.primitives.null,t},Mf=({plugin:e,schema:t,state:n})=>{let r={},i=[],a=t.required??[];for(let o in t.properties){let s=t.properties[o],c=a.includes(o),u=Ff({optional:!c,plugin:e,schema:s,state:{...n,path:K([...n.path.value,`properties`,o])}});u.hasLazyExpression&&(r.hasLazyExpression=!0);let d=c?o:`${o}?`;d.endsWith(`?`)?d=l.factory.createComputedPropertyName(P.stringLiteral({text:d})):((d.match(/^[0-9]/)&&d.match(/\D+/g)||d.match(/\W/g))&&!d.startsWith(`'`)&&!d.endsWith(`'`)&&(d=`'${d}'`),O.lastIndex=0,d=O.test(d)?d.startsWith(`-`)?P.stringLiteral({text:o}):l.factory.createNumericLiteral(o):o),i.push(P.propertyAssignment({initializer:u.expression,name:d}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=Ff({plugin:e,schema:t.additionalProperties,state:{...n,path:K([...n.path.value,`additionalProperties`])}});return r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:`TODO`,name:`record`}),parameters:[P.callExpression({functionName:P.propertyAccessExpression({expression:`TODO`,name:`string`}),parameters:[]}),i.expression]}),i.hasLazyExpression&&(r.hasLazyExpression=!0),r.hasLazyExpression?{...r,typeName:`TODO`}:r}return r.expression=l.factory.createObjectLiteralExpression(i,!0),r.hasLazyExpression?{...r,typeName:`TODO`}:r},Nf=({schema:e})=>{let t={};if(typeof e.const==`string`)return t.def=e.const,t;let n=Y.primitives.string;if(e.format)switch(e.format){case`date`:case`date-time`:case`time`:n=`${n}.${Y.string.date}.${Y.string.iso}`;break;case`email`:n=`${n}.${Y.string.email}`;break;case`ipv4`:n=`${n}.${Y.string.ip}.${Y.string.v4}`;break;case`ipv6`:n=`${n}.${Y.string.ip}.${Y.string.v6}`;break;case`uri`:n=`${n}.${Y.string.url}`;break;case`uuid`:n=`${n}.${Y.string.uuid}`;break}return e.minLength===e.maxLength&&e.minLength!==void 0?n=`${e.minLength} <= ${n} <= ${e.maxLength}`:e.maxLength===void 0?e.minLength!==void 0&&(n=`${n} >= ${e.minLength}`):(n=`${n} <= ${e.maxLength}`,e.minLength!==void 0&&(n=`${e.minLength} <= ${n}`)),e.pattern&&(n=`/${e.pattern}/`),t.def=n,t},Pf=({schema:e,...t})=>{switch(e.type){case`null`:return jf({...t,schema:e});case`object`:return Mf({...t,schema:e});case`string`:return Nf({...t,schema:e})}let n=t.plugin.referenceSymbol(t.plugin.api.selector(`external`,`arktype.type`));return{def:``,expression:l.factory.createCallExpression(l.factory.createIdentifier(n.placeholder),void 0,[l.factory.createObjectLiteralExpression([l.factory.createPropertyAssignment(`name`,l.factory.createStringLiteral(`string`)),l.factory.createPropertyAssignment(`platform`,l.factory.createStringLiteral(`'android' | 'ios'`)),l.factory.createPropertyAssignment(l.factory.createComputedPropertyName(l.factory.createStringLiteral(`versions?`)),l.factory.createStringLiteral(`(number | string)[]`))],!0)]),hasLazyExpression:!1}},Ff=({plugin:e,schema:t,state:n})=>{let r={};if(t.$ref){let i=e.api.selector(`ref`,t.$ref),a=e.referenceSymbol(i);e.isSymbolRegistered(i)?r.expression=P.identifier({text:a.placeholder}):(r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:`TODO`,name:`TODO`}),parameters:[P.arrowFunction({returnType:P.keywordTypeNode({keyword:`any`}),statements:[P.returnStatement({expression:P.identifier({text:a.placeholder})})]})]}),r.hasLazyExpression=!0,n.hasLazyExpression.value=!0)}else if(t.type){let i=Pf({plugin:e,schema:t,state:n});r.def=i.def,r.expression=i.expression,r.hasLazyExpression=i.hasLazyExpression,e.config.metadata&&t.description}else if(t.items)t=T({schema:t}),t.items||(r=Ff({plugin:e,schema:t,state:n}));else{let t=Pf({plugin:e,schema:{type:`unknown`},state:n});r.def=t.def,r.expression=t.expression}return r.expression||=Pf({plugin:e,schema:{type:`unknown`},state:n}).expression,r},If=({plugin:e,schema:t,state:n})=>{let r=or(n.path.value),i=Ff({plugin:e,schema:t,state:n}),a=F(r);Af({ast:i,plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{path:n.path.value},name:w({config:e.config.definitions,name:a}),selector:e.api.selector(`ref`,r)}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value},name:w({config:e.config.definitions.types.infer,name:a}),selector:e.api.selector(`type-infer-ref`,r)}):void 0})},Lf=({plugin:e})=>{e.registerSymbol({external:`arktype`,name:`type`,selector:e.api.selector(`external`,`arktype.type`)}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=q({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`parameter`:If({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:If({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:If({plugin:e,schema:t.schema,state:n});break}})},Rf={api:new kf({name:`arktype`}),config:{case:`PascalCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:e=>Lf(e),name:`arktype`,resolveConfig:(e,t)=>{e.config.types=t.valueToObject({defaultValue:{infer:{case:`PascalCase`,enabled:!1}},mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:S,value:e.infer})})},value:e.config.types}),e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,enabled:!0,name:`{{name}}`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}`}}},mappers:{...S,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:S,value:e.infer})})},value:e.types})})},value:e.config.definitions}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,enabled:!0,name:`{{name}}Data`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}Data`}}},mappers:{...S,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:S,value:e.infer})})},value:e.types})})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,enabled:!0,name:`{{name}}Response`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}Response`}}},mappers:{...S,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:S,value:e.infer})})},value:e.types})})},value:e.config.responses}),e.config.webhooks=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,enabled:!0,name:`{{name}}WebhookRequest`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}WebhookRequest`}}},mappers:{...S,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:S,value:e.infer})})},value:e.types})})},value:e.config.webhooks})},tags:[`validator`]};var zf=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const Bf=({operation:e,plugin:t})=>{let n=[],r=t.getPluginOrThrow(`@hey-api/typescript`),i=t.getSymbol(r.api.selector(`data`,e.id));i&&(e.body&&n.push({isRequired:e.body.required,name:`Body`,type:`${i.placeholder}['body']`}),e.parameters&&(e.parameters.header&&n.push({isRequired:nt(e.parameters.header),name:`Headers`,type:`${i.placeholder}['headers']`}),e.parameters.path&&n.push({isRequired:nt(e.parameters.path),name:`Params`,type:`${i.placeholder}['path']`}),e.parameters.query&&n.push({isRequired:nt(e.parameters.query),name:`Querystring`,type:`${i.placeholder}['query']`})));let{errors:a,responses:o}=ct(e),s,c=t.getSymbol(r.api.selector(`errors`,e.id));if(c&&a&&a.properties){let e=Object.keys(a.properties);if(e.length){if(!e.includes(`default`))s=P.typeReferenceNode({typeName:c.placeholder});else if(e.length>1){let e=P.typeReferenceNode({typeName:c.placeholder}),t=P.literalTypeNode({literal:P.stringLiteral({text:`default`})});s=P.typeReferenceNode({typeArguments:[e,t],typeName:`Omit`})}}}let l,u=t.getSymbol(r.api.selector(`responses`,e.id));if(u&&o&&o.properties){let e=Object.keys(o.properties);if(e.length){if(!e.includes(`default`))l=P.typeReferenceNode({typeName:u.placeholder});else if(e.length>1){let e=P.typeReferenceNode({typeName:u.placeholder}),t=P.literalTypeNode({literal:P.stringLiteral({text:`default`})});l=P.typeReferenceNode({typeArguments:[e,t],typeName:`Omit`})}}}let d=[s,l].filter(Boolean);if(d.length&&n.push({name:`Reply`,type:P.typeIntersectionNode({types:d})}),!n.length)return;let f=t.referenceSymbol(t.api.selector(`RouteHandler`));return{name:e.id,type:P.typeReferenceNode({typeArguments:[P.typeInterfaceNode({properties:n,useLegacyResolution:!1})],typeName:f.placeholder})}},Vf={api:new zf({name:`fastify`}),config:{exportFromIndex:!1},dependencies:[`@hey-api/typescript`],handler:({plugin:e})=>{e.registerSymbol({external:`fastify`,meta:{kind:`type`},name:`RouteHandler`,selector:e.api.selector(`RouteHandler`)});let t=e.registerSymbol({exported:!0,meta:{kind:`type`},name:`RouteHandlers`}),n=[];e.forEach(`operation`,({operation:t})=>{let r=Bf({operation:t,plugin:e});r&&n.push(r)},{order:`declarations`});let r=P.typeAliasDeclaration({exportType:t.exported,name:t.placeholder,type:P.typeInterfaceNode({properties:n,useLegacyResolution:!1})});e.setSymbolValue(t,r)},name:`fastify`},X={actions:{args:P.identifier({text:`args`}),base64:P.identifier({text:`base64`}),bic:P.identifier({text:`bic`}),brand:P.identifier({text:`brand`}),bytes:P.identifier({text:`bytes`}),check:P.identifier({text:`check`}),checkItems:P.identifier({text:`checkItems`}),creditCard:P.identifier({text:`creditCard`}),cuid2:P.identifier({text:`cuid2`}),decimal:P.identifier({text:`decimal`}),description:P.identifier({text:`description`}),digits:P.identifier({text:`digits`}),email:P.identifier({text:`email`}),emoji:P.identifier({text:`emoji`}),empty:P.identifier({text:`empty`}),endsWith:P.identifier({text:`endsWith`}),entries:P.identifier({text:`entries`}),everyItem:P.identifier({text:`everyItem`}),excludes:P.identifier({text:`excludes`}),filterItems:P.identifier({text:`filterItems`}),findItem:P.identifier({text:`findItem`}),finite:P.identifier({text:`finite`}),flavor:P.identifier({text:`flavor`}),graphemes:P.identifier({text:`graphemes`}),gtValue:P.identifier({text:`gtValue`}),hash:P.identifier({text:`hash`}),hexColor:P.identifier({text:`hexColor`}),hexadecimal:P.identifier({text:`hexadecimal`}),imei:P.identifier({text:`imei`}),includes:P.identifier({text:`includes`}),integer:P.identifier({text:`integer`}),ip:P.identifier({text:`ip`}),ipv4:P.identifier({text:`ipv4`}),ipv6:P.identifier({text:`ipv6`}),isoDate:P.identifier({text:`isoDate`}),isoDateTime:P.identifier({text:`isoDateTime`}),isoTime:P.identifier({text:`isoTime`}),isoTimeSecond:P.identifier({text:`isoTimeSecond`}),isoTimestamp:P.identifier({text:`isoTimestamp`}),isoWeek:P.identifier({text:`isoWeek`}),length:P.identifier({text:`length`}),ltValue:P.identifier({text:`ltValue`}),mac:P.identifier({text:`mac`}),mac48:P.identifier({text:`mac48`}),mac64:P.identifier({text:`mac64`}),mapItems:P.identifier({text:`mapItems`}),maxBytes:P.identifier({text:`maxBytes`}),maxEntries:P.identifier({text:`maxEntries`}),maxGraphemes:P.identifier({text:`maxGraphemes`}),maxLength:P.identifier({text:`maxLength`}),maxSize:P.identifier({text:`maxSize`}),maxValue:P.identifier({text:`maxValue`}),maxWords:P.identifier({text:`maxWords`}),metadata:P.identifier({text:`metadata`}),mimeType:P.identifier({text:`mimeType`}),minBytes:P.identifier({text:`minBytes`}),minEntries:P.identifier({text:`minEntries`}),minGraphemes:P.identifier({text:`minGraphemes`}),minLength:P.identifier({text:`minLength`}),minSize:P.identifier({text:`minSize`}),minValue:P.identifier({text:`minValue`}),minWords:P.identifier({text:`minWords`}),multipleOf:P.identifier({text:`multipleOf`}),nanoid:P.identifier({text:`nanoid`}),nonEmpty:P.identifier({text:`nonEmpty`}),normalize:P.identifier({text:`normalize`}),notBytes:P.identifier({text:`notBytes`}),notEntries:P.identifier({text:`notEntries`}),notGraphemes:P.identifier({text:`notGraphemes`}),notLength:P.identifier({text:`notLength`}),notSize:P.identifier({text:`notSize`}),notValue:P.identifier({text:`notValue`}),notValues:P.identifier({text:`notValues`}),notWords:P.identifier({text:`notWords`}),octal:P.identifier({text:`octal`}),parseJson:P.identifier({text:`parseJson`}),partialCheck:P.identifier({text:`partialCheck`}),rawCheck:P.identifier({text:`rawCheck`}),rawTransform:P.identifier({text:`rawTransform`}),readonly:P.identifier({text:`readonly`}),reduceItems:P.identifier({text:`reduceItems`}),regex:P.identifier({text:`regex`}),returns:P.identifier({text:`returns`}),rfcEmail:P.identifier({text:`rfcEmail`}),safeInteger:P.identifier({text:`safeInteger`}),size:P.identifier({text:`size`}),slug:P.identifier({text:`slug`}),someItem:P.identifier({text:`someItem`}),sortItems:P.identifier({text:`sortItems`}),startsWith:P.identifier({text:`startsWith`}),stringifyJson:P.identifier({text:`stringifyJson`}),title:P.identifier({text:`title`}),toLowerCase:P.identifier({text:`toLowerCase`}),toMaxValue:P.identifier({text:`toMaxValue`}),toMinValue:P.identifier({text:`toMinValue`}),toUpperCase:P.identifier({text:`toUpperCase`}),transform:P.identifier({text:`transform`}),trim:P.identifier({text:`trim`}),trimEnd:P.identifier({text:`trimEnd`}),trimStart:P.identifier({text:`trimStart`}),ulid:P.identifier({text:`ulid`}),url:P.identifier({text:`url`}),uuid:P.identifier({text:`uuid`}),value:P.identifier({text:`value`}),values:P.identifier({text:`values`}),words:P.identifier({text:`words`})},async:{argsAsync:P.identifier({text:`argsAsync`}),arrayAsync:P.identifier({text:`arrayAsync`}),awaitAsync:P.identifier({text:`awaitAsync`}),checkAsync:P.identifier({text:`checkAsync`}),checkItemsAsync:P.identifier({text:`checkItemsAsync`}),customAsync:P.identifier({text:`customAsync`}),exactOptionalAsync:P.identifier({text:`exactOptionalAsync`}),fallbackAsync:P.identifier({text:`fallbackAsync`}),forwardAsync:P.identifier({text:`forwardAsync`}),getDefaultsAsync:P.identifier({text:`getDefaultsAsync`}),getFallbacksAsync:P.identifier({text:`getFallbacksAsync`}),intersectAsync:P.identifier({text:`intersectAsync`}),lazyAsync:P.identifier({text:`lazyAsync`}),looseObjectAsync:P.identifier({text:`looseObjectAsync`}),looseTupleAsync:P.identifier({text:`looseTupleAsync`}),mapAsync:P.identifier({text:`mapAsync`}),nonNullableAsync:P.identifier({text:`nonNullableAsync`}),nonNullishAsync:P.identifier({text:`nonNullishAsync`}),nonOptionalAsync:P.identifier({text:`nonOptionalAsync`}),nullableAsync:P.identifier({text:`nullableAsync`}),nullishAsync:P.identifier({text:`nullishAsync`}),objectAsync:P.identifier({text:`objectAsync`}),objectWithRestAsync:P.identifier({text:`objectWithRestAsync`}),optionalAsync:P.identifier({text:`optionalAsync`}),parseAsync:P.identifier({text:`parseAsync`}),parserAsync:P.identifier({text:`parserAsync`}),partialAsync:P.identifier({text:`partialAsync`}),partialCheckAsync:P.identifier({text:`partialCheckAsync`}),pipeAsync:P.identifier({text:`pipeAsync`}),rawCheckAsync:P.identifier({text:`rawCheckAsync`}),rawTransformAsync:P.identifier({text:`rawTransformAsync`}),recordAsync:P.identifier({text:`recordAsync`}),requiredAsync:P.identifier({text:`requiredAsync`}),returnsAsync:P.identifier({text:`returnsAsync`}),safeParseAsync:P.identifier({text:`safeParseAsync`}),safeParserAsync:P.identifier({text:`safeParserAsync`}),setAsync:P.identifier({text:`setAsync`}),strictObjectAsync:P.identifier({text:`strictObjectAsync`}),strictTupleAsync:P.identifier({text:`strictTupleAsync`}),transformAsync:P.identifier({text:`transformAsync`}),tupleAsync:P.identifier({text:`tupleAsync`}),tupleWithRestAsync:P.identifier({text:`tupleWithRestAsync`}),undefinedableAsync:P.identifier({text:`undefinedableAsync`}),unionAsync:P.identifier({text:`unionAsync`}),variantAsync:P.identifier({text:`variantAsync`})},methods:{assert:P.identifier({text:`assert`}),config:P.identifier({text:`config`}),fallback:P.identifier({text:`fallback`}),flatten:P.identifier({text:`flatten`}),forward:P.identifier({text:`forward`}),getDefault:P.identifier({text:`getDefault`}),getDefaults:P.identifier({text:`getDefaults`}),getDescription:P.identifier({text:`getDescription`}),getFallback:P.identifier({text:`getFallback`}),getFallbacks:P.identifier({text:`getFallbacks`}),getMetadata:P.identifier({text:`getMetadata`}),getTitle:P.identifier({text:`getTitle`}),is:P.identifier({text:`is`}),keyof:P.identifier({text:`keyof`}),message:P.identifier({text:`message`}),omit:P.identifier({text:`omit`}),parse:P.identifier({text:`parse`}),parser:P.identifier({text:`parser`}),partial:P.identifier({text:`partial`}),pick:P.identifier({text:`pick`}),pipe:P.identifier({text:`pipe`}),required:P.identifier({text:`required`}),safeParse:P.identifier({text:`safeParse`}),safeParser:P.identifier({text:`safeParser`}),summarize:P.identifier({text:`summarize`}),unwrap:P.identifier({text:`unwrap`})},schemas:{any:P.identifier({text:`any`}),array:P.identifier({text:`array`}),bigInt:P.identifier({text:`bigint`}),blob:P.identifier({text:`blob`}),boolean:P.identifier({text:`boolean`}),custom:P.identifier({text:`custom`}),date:P.identifier({text:`date`}),enum:P.identifier({text:`enum`}),exactOptional:P.identifier({text:`exactOptional`}),file:P.identifier({text:`file`}),function:P.identifier({text:`function`}),instance:P.identifier({text:`instance`}),intersect:P.identifier({text:`intersect`}),lazy:P.identifier({text:`lazy`}),literal:P.identifier({text:`literal`}),looseObject:P.identifier({text:`looseObject`}),looseTuple:P.identifier({text:`looseTuple`}),map:P.identifier({text:`map`}),nan:P.identifier({text:`nan`}),never:P.identifier({text:`never`}),nonNullable:P.identifier({text:`nonNullable`}),nonNullish:P.identifier({text:`nonNullish`}),nonOptional:P.identifier({text:`nonOptional`}),null:P.identifier({text:`null`}),nullable:P.identifier({text:`nullable`}),nullish:P.identifier({text:`nullish`}),number:P.identifier({text:`number`}),object:P.identifier({text:`object`}),objectWithRest:P.identifier({text:`objectWithRest`}),optional:P.identifier({text:`optional`}),picklist:P.identifier({text:`picklist`}),promise:P.identifier({text:`promise`}),record:P.identifier({text:`record`}),set:P.identifier({text:`set`}),strictObject:P.identifier({text:`strictObject`}),strictTuple:P.identifier({text:`strictTuple`}),string:P.identifier({text:`string`}),symbol:P.identifier({text:`symbol`}),tuple:P.identifier({text:`tuple`}),tupleWithRest:P.identifier({text:`tupleWithRest`}),undefined:P.identifier({text:`undefined`}),undefinedable:P.identifier({text:`undefinedable`}),union:P.identifier({text:`union`}),unknown:P.identifier({text:`unknown`}),variant:P.identifier({text:`variant`}),void:P.identifier({text:`void`})},storages:{},types:{GenericSchema:P.identifier({text:`GenericSchema`})},utils:{}},Hf=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`data`,e.id));if(!n)return;let r=t.referenceSymbol(t.api.selector(`external`,`valibot.v`)),i=`data`;return P.arrowFunction({async:!0,parameters:[{name:i}],statements:[P.returnStatement({expression:P.awaitExpression({expression:P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:X.async.parseAsync}),parameters:[P.identifier({text:n.placeholder}),P.identifier({text:i})]})})})]})},Uf=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`responses`,e.id));if(!n)return;let r=t.referenceSymbol(t.api.selector(`external`,`valibot.v`)),i=`data`;return P.arrowFunction({async:!0,parameters:[{name:i}],statements:[P.returnStatement({expression:P.awaitExpression({expression:P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:X.async.parseAsync}),parameters:[P.identifier({text:n.placeholder}),P.identifier({text:i})]})})})]})};var Wf=class{constructor(e){this.meta=e}createRequestValidator(e){return Hf(e)}createResponseValidator(e){return Uf(e)}selector(...e){return[this.meta.name,...e]}};const Z=({pipes:e,plugin:t})=>{if(e.length===1)return e[0];let n=t.referenceSymbol(t.api.selector(`external`,`valibot.v`));return P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:X.methods.pipe}),parameters:e})},Gf=({ast:e,plugin:t,schema:n,state:r,symbol:i})=>{let a=t.referenceSymbol(t.api.selector(`external`,`valibot.v`)),o=P.constVariable({comment:t.config.comments?Ju({schema:n}):void 0,exportConst:i.exported,expression:Z({pipes:e.pipes,plugin:t}),name:i.placeholder,typeName:r.hasLazyExpression.value?P.propertyAccessExpression({expression:a.placeholder,name:e.typeName||X.types.GenericSchema.text}):void 0});t.setSymbolValue(i,o)},Kf={int16:{max:32767,maxError:`Invalid value: Expected int16 to be <= 2^15-1`,min:-32768,minError:`Invalid value: Expected int16 to be >= -2^15`,needsBigInt:!1},int32:{max:2147483647,maxError:`Invalid value: Expected int32 to be <= 2^31-1`,min:-2147483648,minError:`Invalid value: Expected int32 to be >= -2^31`,needsBigInt:!1},int64:{max:`9223372036854775807`,maxError:`Invalid value: Expected int64 to be <= 2^63-1`,min:`-9223372036854775808`,minError:`Invalid value: Expected int64 to be >= -2^63`,needsBigInt:!0},int8:{max:127,maxError:`Invalid value: Expected int8 to be <= 2^7-1`,min:-128,minError:`Invalid value: Expected int8 to be >= -2^7`,needsBigInt:!1},uint16:{max:65535,maxError:`Invalid value: Expected uint16 to be <= 2^16-1`,min:0,minError:`Invalid value: Expected uint16 to be >= 0`,needsBigInt:!1},uint32:{max:4294967295,maxError:`Invalid value: Expected uint32 to be <= 2^32-1`,min:0,minError:`Invalid value: Expected uint32 to be >= 0`,needsBigInt:!1},uint64:{max:`18446744073709551615`,maxError:`Invalid value: Expected uint64 to be <= 2^64-1`,min:`0`,minError:`Invalid value: Expected uint64 to be >= 0`,needsBigInt:!0},uint8:{max:255,maxError:`Invalid value: Expected uint8 to be <= 2^8-1`,min:0,minError:`Invalid value: Expected uint8 to be >= 0`,needsBigInt:!1}},qf=e=>e!==void 0&&e in Kf,Jf=e=>qf(e)&&Kf[e].needsBigInt,Yf=({isBigInt:e,value:t})=>{let n=P.valueToExpression({value:t});return e&&(typeof t==`bigint`||typeof t==`number`||typeof t==`string`||typeof t==`boolean`)?P.callExpression({functionName:`BigInt`,parameters:[n]}):n},Xf=({getAst:e,operation:t,plugin:n,state:r})=>{if(n.config.requests.enabled){let i=new Set,a={properties:{body:{type:`never`},path:{type:`never`},query:{type:`never`}},type:`object`};if(t.parameters){if(t.parameters.header){let e={},n=[];for(let r in t.parameters.header){let a=t.parameters.header[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`headers`))}Object.keys(e).length&&(a.properties.headers={properties:e,required:n,type:`object`})}if(t.parameters.path){let e={},n=[];for(let r in t.parameters.path){let a=t.parameters.path[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`path`))}Object.keys(e).length&&(a.properties.path={properties:e,required:n,type:`object`})}if(t.parameters.query){let e={},n=[];for(let r in t.parameters.query){let a=t.parameters.query[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`query`))}Object.keys(e).length&&(a.properties.query={properties:e,required:n,type:`object`})}}t.body&&(a.properties.body=t.body.schema,t.body.required&&i.add(`body`)),a.required=[...i],Gf({ast:e(a,r.path.value),plugin:n,schema:a,state:r,symbol:n.registerSymbol({exported:!0,meta:{path:r.path.value,tags:r.tags?.value},name:w({config:n.config.requests,name:t.id}),selector:n.api.selector(`data`,t.id)})})}if(n.config.responses.enabled&&t.responses){let{response:i}=ct(t);if(i){let a=[...r.path.value,`responses`];Gf({ast:e(i,a),plugin:n,schema:i,state:r,symbol:n.registerSymbol({exported:!0,meta:{path:a,tags:r.tags?.value},name:w({config:n.config.responses,name:t.id}),selector:n.api.selector(`responses`,t.id)})})}}},Zf=({getAst:e,operation:t,plugin:n,state:r})=>{if(n.config.webhooks.enabled){let i=new Set,a={properties:{body:{type:`never`},path:{type:`never`},query:{type:`never`}},type:`object`};if(t.parameters){if(t.parameters.header){let e={},n=[];for(let r in t.parameters.header){let a=t.parameters.header[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`headers`))}Object.keys(e).length&&(a.properties.headers={properties:e,required:n,type:`object`})}if(t.parameters.path){let e={},n=[];for(let r in t.parameters.path){let a=t.parameters.path[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`path`))}Object.keys(e).length&&(a.properties.path={properties:e,required:n,type:`object`})}if(t.parameters.query){let e={},n=[];for(let r in t.parameters.query){let a=t.parameters.query[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`query`))}Object.keys(e).length&&(a.properties.query={properties:e,required:n,type:`object`})}}t.body&&(a.properties.body=t.body.schema,t.body.required&&i.add(`body`)),a.required=[...i],Gf({ast:e(a,r.path.value),plugin:n,schema:a,state:r,symbol:n.registerSymbol({exported:!0,meta:{path:r.path.value,tags:r.tags?.value},name:w({config:n.config.webhooks,name:t.id}),selector:n.api.selector(`webhook-request`,t.id)})})}},Qf=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:X.schemas.unknown})})},$f=({plugin:e,schema:t,state:n})=>{let r={pipes:[]},i=e.referenceSymbol(e.api.selector(`external`,`valibot.v`)),a=P.propertyAccessExpression({expression:i.placeholder,name:X.schemas.array});if(t.items){t=T({schema:t});let i=t.items.map((t,i)=>{let a=dp({plugin:e,schema:t,state:{...n,path:K([...n.path.value,`items`,i])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),Z({pipes:a.pipes,plugin:e})});if(i.length===1){let e=P.callExpression({functionName:a,parameters:i});r.pipes.push(e)}else{t.logicalOperator;let i=P.callExpression({functionName:a,parameters:[Qf({plugin:e,schema:{type:`unknown`},state:n})]});r.pipes.push(i)}}else{let t=P.callExpression({functionName:a,parameters:[Qf({plugin:e,schema:{type:`unknown`},state:n})]});r.pipes.push(t)}if(t.minItems===t.maxItems&&t.minItems!==void 0){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:X.actions.length}),parameters:[P.valueToExpression({value:t.minItems})]});r.pipes.push(e)}else{if(t.minItems!==void 0){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:X.actions.minLength}),parameters:[P.valueToExpression({value:t.minItems})]});r.pipes.push(e)}if(t.maxItems!==void 0){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:X.actions.maxLength}),parameters:[P.valueToExpression({value:t.maxItems})]});r.pipes.push(e)}}return r},ep=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return typeof t.const==`boolean`?P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:X.schemas.literal}),parameters:[P.ots.boolean(t.const)]}):P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:X.schemas.boolean})})},tp=({plugin:e,schema:t,state:n})=>{let r=[],i=!1;for(let e of t.items??[])e.type===`string`&&typeof e.const==`string`?r.push(P.stringLiteral({text:e.const})):(e.type===`null`||e.const===null)&&(i=!0);if(!r.length)return Qf({plugin:e,schema:{type:`unknown`},state:n});let a=e.referenceSymbol(e.api.selector(`external`,`valibot.v`)),o=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:X.schemas.picklist}),parameters:[P.arrayLiteralExpression({elements:r,multiLine:!1})]});return i&&(o=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:X.schemas.nullable}),parameters:[o]})),o},np=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:X.schemas.never})})},rp=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:X.schemas.null})})},ip=({plugin:e,schema:t})=>{let n=t.format,r=t.type===`integer`,i=Jf(n),a=qf(n)?Kf[n]:null,o=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));if(t.const!==void 0&&t.const!==null){let e=t.const,r;if(typeof e==`number`&&!n)r=P.ots.number(e);else if(typeof e==`number`&&n)r=i?P.callExpression({functionName:`BigInt`,parameters:[P.ots.string(e.toString())]}):P.ots.number(e);else if(typeof e==`string`&&i){let t=e.endsWith(`n`)?e.slice(0,-1):e;r=P.callExpression({functionName:`BigInt`,parameters:[P.ots.string(t)]})}else if(typeof e==`bigint`){let t=e.toString(),n=t.endsWith(`n`)?t.slice(0,-1):t;r=P.callExpression({functionName:`BigInt`,parameters:[P.ots.string(n)]})}else r=P.valueToExpression({value:e});return P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.schemas.literal}),parameters:[r]})}let s=[];if(i){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.schemas.union}),parameters:[P.arrayLiteralExpression({elements:[P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.schemas.number})}),P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.schemas.string})}),P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.schemas.bigInt})})],multiLine:!1})]});s.push(e);let t=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.actions.transform}),parameters:[P.arrowFunction({parameters:[{name:`x`}],statements:P.callExpression({functionName:`BigInt`,parameters:[P.identifier({text:`x`})]})})]});s.push(t)}else{let e=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.schemas.number})});s.push(e)}if(!i&&r){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.actions.integer})});s.push(e)}if(a){let e=a.min,t=a.max,n=a.minError,r=a.maxError,c=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.actions.minValue}),parameters:[i?P.callExpression({functionName:`BigInt`,parameters:[P.ots.string(e.toString())]}):P.ots.number(e),P.ots.string(n)]});s.push(c);let l=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.actions.maxValue}),parameters:[i?P.callExpression({functionName:`BigInt`,parameters:[P.ots.string(t.toString())]}):P.ots.number(t),P.ots.string(r)]});s.push(l)}if(t.exclusiveMinimum!==void 0){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.actions.gtValue}),parameters:[Yf({isBigInt:i,value:t.exclusiveMinimum})]});s.push(e)}else if(t.minimum!==void 0){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.actions.minValue}),parameters:[Yf({isBigInt:i,value:t.minimum})]});s.push(e)}if(t.exclusiveMaximum!==void 0){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.actions.ltValue}),parameters:[Yf({isBigInt:i,value:t.exclusiveMaximum})]});s.push(e)}else if(t.maximum!==void 0){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.actions.maxValue}),parameters:[Yf({isBigInt:i,value:t.maximum})]});s.push(e)}return Z({pipes:s,plugin:e})},ap=({plugin:e,schema:t,state:n})=>{let r={},i=[],a=t.required??[];for(let o in t.properties){let s=t.properties[o],c=dp({optional:!a.includes(o),plugin:e,schema:s,state:{...n,path:K([...n.path.value,`properties`,o])}});c.hasLazyExpression&&(r.hasLazyExpression=!0),O.lastIndex=0;let u;u=O.test(o)?o.startsWith(`-`)?l.factory.createStringLiteral(o):l.factory.createNumericLiteral(o):o,(o.match(/^[0-9]/)&&o.match(/\D+/g)||o.match(/\W/g))&&!o.startsWith(`'`)&&!o.endsWith(`'`)&&(u=`'${o}'`),i.push(P.propertyAssignment({initializer:Z({pipes:c.pipes,plugin:e}),name:u}))}let o=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));if(t.additionalProperties&&typeof t.additionalProperties==`object`&&t.additionalProperties.type!==void 0){let a=dp({plugin:e,schema:t.additionalProperties,state:{...n,path:K([...n.path.value,`additionalProperties`])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),Object.keys(i).length?(r.pipes=[P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.schemas.objectWithRest}),parameters:[l.factory.createObjectLiteralExpression(i,!0),Z({pipes:a.pipes,plugin:e})]})],r):(r.pipes=[P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.schemas.record}),parameters:[P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.schemas.string}),parameters:[]}),Z({pipes:a.pipes,plugin:e})]})],r)}return r.pipes=[P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:X.schemas.object}),parameters:[l.factory.createObjectLiteralExpression(i,!0)]})],r},op=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));if(typeof t.const==`string`)return P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:X.schemas.literal}),parameters:[P.ots.string(t.const)]});let r=[],i=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:X.schemas.string})});if(r.push(i),t.format)switch(t.format){case`date`:r.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:X.actions.isoDate})}));break;case`date-time`:r.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:X.actions.isoTimestamp})}));break;case`ipv4`:case`ipv6`:r.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:X.actions.ip})}));break;case`uri`:r.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:X.actions.url})}));break;case`email`:case`time`:case`uuid`:r.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:P.identifier({text:t.format})})}));break}if(t.minLength===t.maxLength&&t.minLength!==void 0){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:X.actions.length}),parameters:[P.valueToExpression({value:t.minLength})]});r.push(e)}else{if(t.minLength!==void 0){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:X.actions.minLength}),parameters:[P.valueToExpression({value:t.minLength})]});r.push(e)}if(t.maxLength!==void 0){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:X.actions.maxLength}),parameters:[P.valueToExpression({value:t.maxLength})]});r.push(e)}}if(t.pattern){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:X.actions.regex}),parameters:[P.regularExpressionLiteral({text:t.pattern})]});r.push(e)}return Z({pipes:r,plugin:e})},sp=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:X.schemas.literal}),parameters:[P.valueToExpression({value:e})]}));return r.pipes=[P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:X.schemas.tuple}),parameters:[P.arrayLiteralExpression({elements:e})]})],r}if(t.items){let a=t.items.map((t,i)=>{let a=dp({plugin:e,schema:t,state:{...n,path:K([...n.path.value,`items`,i])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),Z({pipes:a.pipes,plugin:e})});return r.pipes=[P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:X.schemas.tuple}),parameters:[P.arrayLiteralExpression({elements:a})]})],r}return{pipes:[Qf({plugin:e,schema:{type:`unknown`},state:n})]}},cp=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:X.schemas.undefined})})},lp=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:X.schemas.void})})},up=({schema:e,...t})=>{switch(e.type){case`array`:return{expression:Z({pipes:$f({...t,schema:e}).pipes,plugin:t.plugin})};case`boolean`:return{expression:ep({...t,schema:e})};case`enum`:return{expression:tp({...t,schema:e})};case`integer`:case`number`:return{expression:ip({...t,schema:e})};case`never`:return{expression:np({...t,schema:e})};case`null`:return{expression:rp({...t,schema:e})};case`object`:return{expression:Z({pipes:ap({...t,schema:e}).pipes,plugin:t.plugin})};case`string`:return e.format===`int64`||e.format===`uint64`?{expression:ip({...t,schema:e})}:{expression:op({...t,schema:e})};case`tuple`:return{expression:Z({pipes:sp({...t,schema:e}).pipes,plugin:t.plugin})};case`undefined`:return{expression:cp({...t,schema:e})};case`unknown`:return{expression:Qf({...t,schema:e})};case`void`:return{expression:lp({...t,schema:e})}}},dp=({optional:e,plugin:t,schema:n,state:r})=>{let i={pipes:[]},a=t.referenceSymbol(t.api.selector(`external`,`valibot.v`));if(n.$ref){let e=t.api.selector(`ref`,n.$ref),o=t.referenceSymbol(e);if(t.isSymbolRegistered(e)){let e=P.identifier({text:o.placeholder});i.pipes.push(e)}else{let e=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:X.schemas.lazy}),parameters:[P.arrowFunction({statements:[P.returnStatement({expression:P.identifier({text:o.placeholder})})]})]});i.pipes.push(e),r.hasLazyExpression.value=!0}}else if(n.type){let e=up({plugin:t,schema:n,state:r});if(i.typeName=e.anyType,i.pipes.push(e.expression),t.config.metadata&&n.description){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:X.actions.metadata}),parameters:[P.objectExpression({obj:[{key:`description`,value:P.stringLiteral({text:n.description})}]})]});i.pipes.push(e)}}else if(n.items)if(n=T({schema:n}),n.items){let e=n.items.map((e,n)=>Z({pipes:dp({plugin:t,schema:e,state:{...r,path:K([...r.path.value,`items`,n])}}).pipes,plugin:t}));if(n.logicalOperator===`and`){let t=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:X.schemas.intersect}),parameters:[P.arrayLiteralExpression({elements:e})]});i.pipes.push(t)}else{let t=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:X.schemas.union}),parameters:[P.arrayLiteralExpression({elements:e})]});i.pipes.push(t)}}else{let e=dp({plugin:t,schema:n,state:r});i.pipes.push(...e.pipes)}else{let e=up({plugin:t,schema:{type:`unknown`},state:r});i.typeName=e.anyType,i.pipes.push(e.expression)}if(i.pipes.length){if(n.accessScope===`read`){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:X.actions.readonly})});i.pipes.push(e)}let r;n.default!==void 0&&(r=Yf({isBigInt:n.type===`integer`&&n.format===`int64`,value:n.default}),r&&(i.pipes=[P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:X.schemas.optional}),parameters:[Z({pipes:i.pipes,plugin:t}),r]})])),e&&!r&&(i.pipes=[P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:X.schemas.optional}),parameters:[Z({pipes:i.pipes,plugin:t})]})])}return i},fp=({plugin:e,schema:t,state:n})=>{let r=or(n.path.value),i=dp({plugin:e,schema:t,state:n}),a=F(r);Gf({ast:i,plugin:e,schema:t,state:n,symbol:e.registerSymbol({exported:!0,meta:{path:n.path.value,tags:n.tags?.value},name:w({config:e.config.definitions,name:a}),selector:e.api.selector(`ref`,r)})})},pp=({plugin:e})=>{e.registerSymbol({external:`valibot`,meta:{importKind:`namespace`},name:`v`,selector:e.api.selector(`external`,`valibot.v`)}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=q({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:Xf({getAst:(n,r)=>dp({plugin:e,schema:n,state:q({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:fp({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:fp({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:fp({plugin:e,schema:t.schema,state:n});break;case`webhook`:Zf({getAst:(n,r)=>dp({plugin:e,schema:n,state:q({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},mp={api:new Wf({name:`valibot`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:e=>pp(e),name:`valibot`,resolveConfig:(e,t)=>{e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`v{{name}}`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.definitions}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`v{{name}}Data`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`v{{name}}Response`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.responses}),e.config.webhooks=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`v{{name}}WebhookRequest`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.webhooks})},tags:[`validator`]},Q={ZodMiniOptional:P.identifier({text:`ZodMiniOptional`}),ZodOptional:P.identifier({text:`ZodOptional`}),_default:P.identifier({text:`_default`}),and:P.identifier({text:`and`}),array:P.identifier({text:`array`}),bigint:P.identifier({text:`bigint`}),boolean:P.identifier({text:`boolean`}),check:P.identifier({text:`check`}),coerce:P.identifier({text:`coerce`}),date:P.identifier({text:`date`}),datetime:P.identifier({text:`datetime`}),default:P.identifier({text:`default`}),describe:P.identifier({text:`describe`}),email:P.identifier({text:`email`}),enum:P.identifier({text:`enum`}),globalRegistry:P.identifier({text:`globalRegistry`}),gt:P.identifier({text:`gt`}),gte:P.identifier({text:`gte`}),infer:P.identifier({text:`infer`}),int:P.identifier({text:`int`}),intersection:P.identifier({text:`intersection`}),ip:P.identifier({text:`ip`}),ipv4:P.identifier({text:`ipv4`}),ipv6:P.identifier({text:`ipv6`}),iso:P.identifier({text:`iso`}),lazy:P.identifier({text:`lazy`}),length:P.identifier({text:`length`}),literal:P.identifier({text:`literal`}),lt:P.identifier({text:`lt`}),lte:P.identifier({text:`lte`}),max:P.identifier({text:`max`}),maxLength:P.identifier({text:`maxLength`}),min:P.identifier({text:`min`}),minLength:P.identifier({text:`minLength`}),never:P.identifier({text:`never`}),null:P.identifier({text:`null`}),nullable:P.identifier({text:`nullable`}),number:P.identifier({text:`number`}),object:P.identifier({text:`object`}),optional:P.identifier({text:`optional`}),parseAsync:P.identifier({text:`parseAsync`}),readonly:P.identifier({text:`readonly`}),record:P.identifier({text:`record`}),regex:P.identifier({text:`regex`}),register:P.identifier({text:`register`}),string:P.identifier({text:`string`}),time:P.identifier({text:`time`}),tuple:P.identifier({text:`tuple`}),undefined:P.identifier({text:`undefined`}),union:P.identifier({text:`union`}),unknown:P.identifier({text:`unknown`}),url:P.identifier({text:`url`}),uuid:P.identifier({text:`uuid`}),void:P.identifier({text:`void`})},hp=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`data`,e.id));if(!n)return;let r=`data`;return P.arrowFunction({async:!0,parameters:[{name:r}],statements:[P.returnStatement({expression:P.awaitExpression({expression:P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[P.identifier({text:r})]})})})]})},gp=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`responses`,e.id));if(!n)return;let r=`data`;return P.arrowFunction({async:!0,parameters:[{name:r}],statements:[P.returnStatement({expression:P.awaitExpression({expression:P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[P.identifier({text:r})]})})})]})},_p=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`data`,e.id));if(!n)return;let r=`data`;return P.arrowFunction({async:!0,parameters:[{name:r}],statements:[P.returnStatement({expression:P.awaitExpression({expression:P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[P.identifier({text:r})]})})})]})},vp=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`responses`,e.id));if(!n)return;let r=`data`;return P.arrowFunction({async:!0,parameters:[{name:r}],statements:[P.returnStatement({expression:P.awaitExpression({expression:P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[P.identifier({text:r})]})})})]})},yp=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`data`,e.id));if(!n)return;let r=`data`;return P.arrowFunction({async:!0,parameters:[{name:r}],statements:[P.returnStatement({expression:P.awaitExpression({expression:P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[P.identifier({text:r})]})})})]})},bp=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`responses`,e.id));if(!n)return;let r=`data`;return P.arrowFunction({async:!0,parameters:[{name:r}],statements:[P.returnStatement({expression:P.awaitExpression({expression:P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[P.identifier({text:r})]})})})]})};var xp=class{constructor(e){this.meta=e}createRequestValidator(e){let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return _p(e);case`mini`:return hp(e);case 4:default:return yp(e)}}createResponseValidator(e){let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return vp(e);case`mini`:return gp(e);case 4:default:return bp(e)}}selector(...e){return[this.meta.name,...e]}};const Sp=({ast:e,plugin:t,schema:n,symbol:r,typeInferSymbol:i})=>{let a=t.referenceSymbol(t.api.selector(`external`,`zod.z`)),o=P.constVariable({comment:t.config.comments?Ju({schema:n}):void 0,exportConst:r.exported,expression:e.expression,name:r.placeholder,typeName:e.typeName?P.propertyAccessExpression({expression:a.placeholder,name:e.typeName}):void 0});if(t.setSymbolValue(r,o),i){let e=P.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:P.typeReferenceNode({typeArguments:[P.typeOfExpression({text:r.placeholder})],typeName:P.propertyAccessExpression({expression:a.placeholder,name:Q.infer})})});t.setSymbolValue(i,e)}},Cp=({plugin:e})=>{let t=e.package.getVersion(`zod`);if(t&&e.package.satisfies(t,`<4.0.0`))switch(e.config.compatibilityVersion){case 3:default:return`zod`;case 4:return`zod/v4`;case`mini`:return`zod/v4-mini`}switch(e.config.compatibilityVersion){case 3:return`zod/v3`;case 4:default:return`zod`;case`mini`:return`zod/mini`}},$=({isBigInt:e,value:t})=>{let n=P.valueToExpression({value:t});return e&&(typeof t==`bigint`||typeof t==`number`||typeof t==`string`||typeof t==`boolean`)?P.callExpression({functionName:`BigInt`,parameters:[n]}):n},wp=({getAst:e,operation:t,plugin:n,state:r})=>{if(n.config.requests.enabled){let i=new Set,a={properties:{body:{type:`never`},path:{type:`never`},query:{type:`never`}},type:`object`};if(t.parameters){if(t.parameters.header){let e={},n=[];for(let r in t.parameters.header){let a=t.parameters.header[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`headers`))}Object.keys(e).length&&(a.properties.headers={properties:e,required:n,type:`object`})}if(t.parameters.path){let e={},n=[];for(let r in t.parameters.path){let a=t.parameters.path[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`path`))}Object.keys(e).length&&(a.properties.path={properties:e,required:n,type:`object`})}if(t.parameters.query){let e={},n=[];for(let r in t.parameters.query){let a=t.parameters.query[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`query`))}Object.keys(e).length&&(a.properties.query={properties:e,required:n,type:`object`})}}t.body&&(a.properties.body=t.body.schema,t.body.required&&i.add(`body`)),a.required=[...i],Sp({ast:e(a,r.path.value),plugin:n,schema:a,symbol:n.registerSymbol({exported:!0,meta:{path:r.path.value,tags:r.tags?.value},name:w({config:n.config.requests,name:t.id}),selector:n.api.selector(`data`,t.id)}),typeInferSymbol:n.config.requests.types.infer.enabled?n.registerSymbol({exported:!0,meta:{kind:`type`,path:r.path.value,tags:r.tags?.value},name:w({config:n.config.requests.types.infer,name:t.id}),selector:n.api.selector(`type-infer-data`,t.id)}):void 0})}if(n.config.responses.enabled&&t.responses){let{response:i}=ct(t);if(i){let a=[...r.path.value,`responses`];Sp({ast:e(i,a),plugin:n,schema:i,symbol:n.registerSymbol({exported:!0,meta:{path:a,tags:r.tags?.value},name:w({config:n.config.responses,name:t.id}),selector:n.api.selector(`responses`,t.id)}),typeInferSymbol:n.config.responses.types.infer.enabled?n.registerSymbol({exported:!0,meta:{kind:`type`,path:a,tags:r.tags?.value},name:w({config:n.config.responses.types.infer,name:t.id}),selector:n.api.selector(`type-infer-responses`,t.id)}):void 0})}}},Tp=({getAst:e,operation:t,plugin:n,state:r})=>{if(n.config.webhooks.enabled){let i=new Set,a={properties:{body:{type:`never`},path:{type:`never`},query:{type:`never`}},type:`object`};if(t.parameters){if(t.parameters.header){let e={},n=[];for(let r in t.parameters.header){let a=t.parameters.header[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`headers`))}Object.keys(e).length&&(a.properties.headers={properties:e,required:n,type:`object`})}if(t.parameters.path){let e={},n=[];for(let r in t.parameters.path){let a=t.parameters.path[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`path`))}Object.keys(e).length&&(a.properties.path={properties:e,required:n,type:`object`})}if(t.parameters.query){let e={},n=[];for(let r in t.parameters.query){let a=t.parameters.query[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`query`))}Object.keys(e).length&&(a.properties.query={properties:e,required:n,type:`object`})}}t.body&&(a.properties.body=t.body.schema,t.body.required&&i.add(`body`)),a.required=[...i],Sp({ast:e(a,r.path.value),plugin:n,schema:a,symbol:n.registerSymbol({exported:!0,meta:{path:r.path.value,tags:r.tags?.value},name:w({config:n.config.webhooks,name:t.id}),selector:n.api.selector(`webhook-request`,t.id)}),typeInferSymbol:n.config.webhooks.types.infer.enabled?n.registerSymbol({exported:!0,meta:{kind:`type`,path:r.path.value,tags:r.tags?.value},name:w({config:n.config.webhooks.types.infer,name:t.id}),selector:n.api.selector(`type-infer-webhook-request`,t.id)}):void 0})}},Ep=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),n={};return n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:Q.unknown})}),n},Dp=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i={},a=P.propertyAccessExpression({expression:r.placeholder,name:Q.array});if(!t.items)i.expression=P.callExpression({functionName:a,parameters:[Ep({plugin:e,schema:{type:`unknown`},state:n}).expression]});else{t=T({schema:t});let o=t.items.map((t,r)=>{let a=zp({plugin:e,schema:t,state:{...n,path:K([...n.path.value,`items`,r])}});return a.hasLazyExpression&&(i.hasLazyExpression=!0),a.expression});if(o.length===1)i.expression=P.callExpression({functionName:a,parameters:o});else if(t.logicalOperator===`and`){let e=t.items[0],n;if(e.logicalOperator===`or`||e.type&&e.type!==`object`)n=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.intersection}),parameters:o});else{n=o[0];for(let e=1;e<o.length;e++)n=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.intersection}),parameters:[n,o[e]]})}i.expression=P.callExpression({functionName:a,parameters:[n]})}else i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.array}),parameters:[P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.union}),parameters:[P.arrayLiteralExpression({elements:o})]})]})}let o=[];return t.minItems===t.maxItems&&t.minItems!==void 0?o.push(P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.length}),parameters:[P.valueToExpression({value:t.minItems})]})):(t.minItems!==void 0&&o.push(P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.minLength}),parameters:[P.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&o.push(P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.maxLength}),parameters:[P.valueToExpression({value:t.maxItems})]}))),o.length&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.expression,name:Q.check}),parameters:o})),i},Op=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),r={};return typeof t.const==`boolean`?(r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[P.ots.boolean(t.const)]}),r):(r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.boolean})}),r)},kp=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i={},a=[],o=[],s=!1,c=!0;for(let e of t.items??[])if(e.type===`string`&&typeof e.const==`string`){let t=P.stringLiteral({text:e.const});a.push(t),o.push(P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[t]}))}else if((e.type===`number`||e.type===`integer`)&&typeof e.const==`number`){c=!1;let t=P.ots.number(e.const);o.push(P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[t]}))}else if(e.type===`boolean`&&typeof e.const==`boolean`){c=!1;let t=P.ots.boolean(e.const);o.push(P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[t]}))}else (e.type===`null`||e.const===null)&&(s=!0);return o.length?(c&&a.length>0?i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.enum}),parameters:[P.arrayLiteralExpression({elements:a,multiLine:!1})]}):o.length===1?i.expression=o[0]:i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.union}),parameters:[P.arrayLiteralExpression({elements:o,multiLine:o.length>3})]}),s&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.nullable}),parameters:[i.expression]})),i):Ep({plugin:e,schema:{type:`unknown`},state:n})},Ap=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),n={};return n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:Q.never})}),n},jp=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),n={};return n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:Q.null})}),n},Mp=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),r={},i=t.type===`integer`&&t.format===`int64`;if(typeof t.const==`number`)return r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[P.ots.number(t.const)]}),r;r.expression=P.callExpression({functionName:i?P.propertyAccessExpression({expression:P.propertyAccessExpression({expression:n.placeholder,name:Q.coerce}),name:Q.bigint}):P.propertyAccessExpression({expression:n.placeholder,name:Q.number})}),!i&&t.type===`integer`&&(r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.int})}));let a=[];return t.exclusiveMinimum===void 0?t.minimum!==void 0&&a.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.gte}),parameters:[$({isBigInt:i,value:t.minimum})]})):a.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.gt}),parameters:[$({isBigInt:i,value:t.exclusiveMinimum})]})),t.exclusiveMaximum===void 0?t.maximum!==void 0&&a.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.lte}),parameters:[$({isBigInt:i,value:t.maximum})]})):a.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.lt}),parameters:[$({isBigInt:i,value:t.exclusiveMaximum})]})),a.length&&(r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.expression,name:Q.check}),parameters:a})),r},Np=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i={},a=[],o=t.required??[];for(let r in t.properties){let s=t.properties[r],c=zp({optional:!o.includes(r),plugin:e,schema:s,state:{...n,path:K([...n.path.value,`properties`,r])}});c.hasLazyExpression&&(i.hasLazyExpression=!0),O.lastIndex=0;let u;u=O.test(r)?r.startsWith(`-`)?l.factory.createStringLiteral(r):l.factory.createNumericLiteral(r):r,(r.match(/^[0-9]/)&&r.match(/\D+/g)||r.match(/\W/g))&&!r.startsWith(`'`)&&!r.endsWith(`'`)&&(u=`'${r}'`),c.hasLazyExpression?a.push(P.getAccessorDeclaration({name:u,statements:[P.returnStatement({expression:c.expression})]})):a.push(P.propertyAssignment({initializer:c.expression,name:u}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let a=zp({plugin:e,schema:t.additionalProperties,state:{...n,path:K([...n.path.value,`additionalProperties`])}});return i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.record}),parameters:[P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.string}),parameters:[]}),a.expression]}),a.hasLazyExpression&&(i.hasLazyExpression=!0),i}return i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.object}),parameters:[l.factory.createObjectLiteralExpression(a,!0)]}),i},Pp=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),r={};if(typeof t.const==`string`)return r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[P.ots.string(t.const)]}),r;r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.string})});let i=[];if(e.config.dates.offset&&i.push({key:`offset`,value:!0}),e.config.dates.local&&i.push({key:`local`,value:!0}),t.format)switch(t.format){case`date`:r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:P.propertyAccessExpression({expression:n.placeholder,name:Q.iso}),name:Q.date})});break;case`date-time`:r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:P.propertyAccessExpression({expression:n.placeholder,name:Q.iso}),name:Q.datetime}),parameters:i.length>0?[P.objectExpression({obj:i})]:[]});break;case`email`:r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.email})});break;case`ipv4`:r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.ipv4})});break;case`ipv6`:r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.ipv6})});break;case`time`:r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:P.propertyAccessExpression({expression:n.placeholder,name:Q.iso}),name:Q.time})});break;case`uri`:r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.url})});break;case`uuid`:r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.uuid})});break}let a=[];return t.minLength===t.maxLength&&t.minLength!==void 0?a.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.length}),parameters:[P.valueToExpression({value:t.minLength})]})):(t.minLength!==void 0&&a.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.minLength}),parameters:[P.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&a.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.maxLength}),parameters:[P.valueToExpression({value:t.maxLength})]}))),t.pattern&&a.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.regex}),parameters:[P.regularExpressionLiteral({text:t.pattern})]})),a.length&&(r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.expression,name:Q.check}),parameters:a})),r},Fp=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i={};if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[P.valueToExpression({value:e})]}));return i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.tuple}),parameters:[P.arrayLiteralExpression({elements:e})]}),i}let a=[];return t.items&&t.items.forEach((t,r)=>{let o=zp({plugin:e,schema:t,state:{...n,path:K([...n.path.value,`items`,r])}});a.push(o.expression),o.hasLazyExpression&&(i.hasLazyExpression=!0)}),i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.tuple}),parameters:[P.arrayLiteralExpression({elements:a})]}),i},Ip=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),n={};return n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:Q.undefined})}),n},Lp=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),n={};return n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:Q.void})}),n},Rp=({schema:e,...t})=>{switch(e.type){case`array`:return Dp({...t,schema:e});case`boolean`:return Op({...t,schema:e});case`enum`:return kp({...t,schema:e});case`integer`:case`number`:return Mp({...t,schema:e});case`never`:return Ap({...t,schema:e});case`null`:return jp({...t,schema:e});case`object`:return Np({...t,schema:e});case`string`:return Pp({...t,schema:e});case`tuple`:return Fp({...t,schema:e});case`undefined`:return Ip({...t,schema:e});case`unknown`:return Ep({...t,schema:e});case`void`:return Lp({...t,schema:e})}},zp=({optional:e,plugin:t,schema:n,state:r})=>{let i={},a=t.referenceSymbol(t.api.selector(`external`,`zod.z`));if(n.$ref){let e=t.api.selector(`ref`,n.$ref),o=t.referenceSymbol(e);t.isSymbolRegistered(e)?i.expression=P.identifier({text:o.placeholder}):(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:Q.lazy}),parameters:[P.arrowFunction({returnType:P.keywordTypeNode({keyword:`any`}),statements:[P.returnStatement({expression:P.identifier({text:o.placeholder})})]})]}),i.hasLazyExpression=!0,r.hasLazyExpression.value=!0)}else if(n.type){let e=Rp({plugin:t,schema:n,state:r});i.expression=e.expression,i.hasLazyExpression=e.hasLazyExpression,t.config.metadata&&n.description&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.expression,name:Q.register}),parameters:[P.propertyAccessExpression({expression:a.placeholder,name:Q.globalRegistry}),P.objectExpression({obj:[{key:`description`,value:P.stringLiteral({text:n.description})}]})]}))}else if(n.items)if(n=T({schema:n}),n.items){let e=n.items.map((e,n)=>zp({plugin:t,schema:e,state:{...r,path:K([...r.path.value,`items`,n])}}));if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:Q.intersection}),parameters:e.map(e=>e.expression)}):(i.expression=e[0].expression,e.slice(1).forEach(e=>{i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:Q.intersection}),parameters:[i.expression,e.hasLazyExpression?P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:Q.lazy}),parameters:[P.arrowFunction({statements:[P.returnStatement({expression:e.expression})]})]}):e.expression]})}))}else i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:Q.union}),parameters:[P.arrayLiteralExpression({elements:e.map(e=>e.expression)})]})}else i=zp({plugin:t,schema:n,state:r});else i.expression=Rp({plugin:t,schema:{type:`unknown`},state:r}).expression;if(i.expression&&(n.accessScope===`read`&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:Q.readonly}),parameters:[i.expression]})),e&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:Q.optional}),parameters:[i.expression]}),i.typeName=Q.ZodMiniOptional),n.default!==void 0)){let e=$({isBigInt:n.type===`integer`&&n.format===`int64`,value:n.default});e&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:Q._default}),parameters:[i.expression,e]}))}return i},Bp=({plugin:e,schema:t,state:n})=>{let r=or(n.path.value),i=zp({plugin:e,schema:t,state:n}),a=F(r);Sp({ast:i,plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{path:n.path.value,tags:n.tags?.value},name:w({config:e.config.definitions,name:a}),selector:e.api.selector(`ref`,r)}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:w({config:e.config.definitions.types.infer,name:a}),selector:e.api.selector(`type-infer-ref`,r)}):void 0})},Vp=({plugin:e})=>{e.registerSymbol({external:Cp({plugin:e}),meta:{importKind:`namespace`},name:`z`,selector:e.api.selector(`external`,`zod.z`)}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=q({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:wp({getAst:(n,r)=>zp({plugin:e,schema:n,state:q({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:Bp({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:Bp({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:Bp({plugin:e,schema:t.schema,state:n});break;case`webhook`:Tp({getAst:(n,r)=>zp({plugin:e,schema:n,state:q({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},Hp=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:Q.unknown})})},Up=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i=P.propertyAccessExpression({expression:r.placeholder,name:Q.array}),a,o=!1;if(!t.items)a=P.callExpression({functionName:i,parameters:[Hp({plugin:e,schema:{type:`unknown`},state:n})]});else{t=T({schema:t});let s=t.items.map((t,r)=>{let i=tm({plugin:e,schema:t,state:{...n,path:K([...n.path.value,`items`,r])}});return i.hasLazyExpression&&(o=!0),i.expression});if(s.length===1)a=P.callExpression({functionName:i,parameters:s});else if(t.logicalOperator===`and`){let e=t.items[0],n;if(e.logicalOperator===`or`||e.type&&e.type!==`object`)n=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.intersection}),parameters:s});else{n=s[0];for(let e=1;e<s.length;e++)n=P.callExpression({functionName:P.propertyAccessExpression({expression:n,name:Q.and}),parameters:[s[e]]})}a=P.callExpression({functionName:i,parameters:[n]})}else a=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.array}),parameters:[P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.union}),parameters:[P.arrayLiteralExpression({elements:s})]})]})}return t.minItems===t.maxItems&&t.minItems!==void 0?a=P.callExpression({functionName:P.propertyAccessExpression({expression:a,name:Q.length}),parameters:[P.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(a=P.callExpression({functionName:P.propertyAccessExpression({expression:a,name:Q.min}),parameters:[P.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(a=P.callExpression({functionName:P.propertyAccessExpression({expression:a,name:Q.max}),parameters:[P.valueToExpression({value:t.maxItems})]}))),{expression:a,hasLazyExpression:o}},Wp=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return typeof t.const==`boolean`?P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[P.ots.boolean(t.const)]}):P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.boolean})})},Gp=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i=[],a=[],o=!1,s=!0;for(let e of t.items??[])if(e.type===`string`&&typeof e.const==`string`){let t=P.stringLiteral({text:e.const});i.push(t),a.push(P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[t]}))}else if((e.type===`number`||e.type===`integer`)&&typeof e.const==`number`){s=!1;let t=P.ots.number(e.const);a.push(P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[t]}))}else if(e.type===`boolean`&&typeof e.const==`boolean`){s=!1;let t=P.ots.boolean(e.const);a.push(P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[t]}))}else (e.type===`null`||e.const===null)&&(o=!0);if(!a.length)return Hp({plugin:e,schema:{type:`unknown`},state:n});let c;return c=s&&i.length>0?P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.enum}),parameters:[P.arrayLiteralExpression({elements:i,multiLine:!1})]}):a.length===1?a[0]:P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.union}),parameters:[P.arrayLiteralExpression({elements:a,multiLine:a.length>3})]}),o&&(c=P.callExpression({functionName:P.propertyAccessExpression({expression:c,name:Q.nullable})})),c},Kp=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:Q.never})})},qp=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:Q.null})})},Jp=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),r=t.type===`integer`&&t.format===`int64`;if(typeof t.const==`number`)return P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[P.ots.number(t.const)]});let i=P.callExpression({functionName:r?P.propertyAccessExpression({expression:P.propertyAccessExpression({expression:n.placeholder,name:Q.coerce}),name:Q.bigint}):P.propertyAccessExpression({expression:n.placeholder,name:Q.number})});return!r&&t.type===`integer`&&(i=P.callExpression({functionName:P.propertyAccessExpression({expression:i,name:Q.int})})),t.exclusiveMinimum===void 0?t.minimum!==void 0&&(i=P.callExpression({functionName:P.propertyAccessExpression({expression:i,name:Q.gte}),parameters:[$({isBigInt:r,value:t.minimum})]})):i=P.callExpression({functionName:P.propertyAccessExpression({expression:i,name:Q.gt}),parameters:[$({isBigInt:r,value:t.exclusiveMinimum})]}),t.exclusiveMaximum===void 0?t.maximum!==void 0&&(i=P.callExpression({functionName:P.propertyAccessExpression({expression:i,name:Q.lte}),parameters:[$({isBigInt:r,value:t.maximum})]})):i=P.callExpression({functionName:P.propertyAccessExpression({expression:i,name:Q.lt}),parameters:[$({isBigInt:r,value:t.exclusiveMaximum})]}),i},Yp=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i=!1,a=[],o=t.required??[];for(let r in t.properties){let s=t.properties[r],c=tm({optional:!o.includes(r),plugin:e,schema:s,state:{...n,path:K([...n.path.value,`properties`,r])}});c.hasLazyExpression&&(i=!0),O.lastIndex=0;let u;u=O.test(r)?r.startsWith(`-`)?l.factory.createStringLiteral(r):l.factory.createNumericLiteral(r):r,(r.match(/^[0-9]/)&&r.match(/\D+/g)||r.match(/\W/g))&&!r.startsWith(`'`)&&!r.endsWith(`'`)&&(u=`'${r}'`),a.push(P.propertyAssignment({initializer:c.expression,name:u}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=tm({plugin:e,schema:t.additionalProperties,state:{...n,path:K([...n.path.value,`additionalProperties`])}});return{anyType:`AnyZodObject`,expression:P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.record}),parameters:[i.expression]}),hasLazyExpression:i.hasLazyExpression}}return{anyType:`AnyZodObject`,expression:P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.object}),parameters:[l.factory.createObjectLiteralExpression(a,!0)]}),hasLazyExpression:i}},Xp=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));if(typeof t.const==`string`)return P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[P.ots.string(t.const)]});let r=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.string})}),i=[];if(e.config.dates.offset&&i.push({key:`offset`,value:!0}),e.config.dates.local&&i.push({key:`local`,value:!0}),t.format)switch(t.format){case`date`:r=P.callExpression({functionName:P.propertyAccessExpression({expression:r,name:Q.date})});break;case`date-time`:r=P.callExpression({functionName:P.propertyAccessExpression({expression:r,name:Q.datetime}),parameters:i.length>0?[P.objectExpression({obj:i})]:[]});break;case`email`:r=P.callExpression({functionName:P.propertyAccessExpression({expression:r,name:Q.email})});break;case`ipv4`:case`ipv6`:r=P.callExpression({functionName:P.propertyAccessExpression({expression:r,name:Q.ip})});break;case`time`:r=P.callExpression({functionName:P.propertyAccessExpression({expression:r,name:Q.time})});break;case`uri`:r=P.callExpression({functionName:P.propertyAccessExpression({expression:r,name:Q.url})});break;case`uuid`:r=P.callExpression({functionName:P.propertyAccessExpression({expression:r,name:Q.uuid})});break}return t.minLength===t.maxLength&&t.minLength!==void 0?r=P.callExpression({functionName:P.propertyAccessExpression({expression:r,name:Q.length}),parameters:[P.valueToExpression({value:t.minLength})]}):(t.minLength!==void 0&&(r=P.callExpression({functionName:P.propertyAccessExpression({expression:r,name:Q.min}),parameters:[P.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&(r=P.callExpression({functionName:P.propertyAccessExpression({expression:r,name:Q.max}),parameters:[P.valueToExpression({value:t.maxLength})]}))),t.pattern&&(r=P.callExpression({functionName:P.propertyAccessExpression({expression:r,name:Q.regex}),parameters:[P.regularExpressionLiteral({text:t.pattern})]})),r},Zp=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i=!1;if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[P.valueToExpression({value:e})]}));return{expression:P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.tuple}),parameters:[P.arrayLiteralExpression({elements:e})]}),hasLazyExpression:i}}let a=[];return t.items&&t.items.forEach((t,r)=>{let o=tm({plugin:e,schema:t,state:{...n,path:K([...n.path.value,`items`,r])}});a.push(o.expression),o.hasLazyExpression&&(i=!0)}),{expression:P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.tuple}),parameters:[P.arrayLiteralExpression({elements:a})]}),hasLazyExpression:i}},Qp=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:Q.undefined})})},$p=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:Q.void})})},em=({schema:e,...t})=>{switch(e.type){case`array`:return Up({...t,schema:e});case`boolean`:return{expression:Wp({...t,schema:e})};case`enum`:return{expression:Gp({...t,schema:e})};case`integer`:case`number`:return{expression:Jp({...t,schema:e})};case`never`:return{expression:Kp({...t,schema:e})};case`null`:return{expression:qp({...t,schema:e})};case`object`:return Yp({...t,schema:e});case`string`:return{expression:Xp({...t,schema:e})};case`tuple`:return Zp({...t,schema:e});case`undefined`:return{expression:Qp({...t,schema:e})};case`unknown`:return{expression:Hp({...t,schema:e})};case`void`:return{expression:$p({...t,schema:e})}}},tm=({optional:e,plugin:t,schema:n,state:r})=>{let i={},a=t.referenceSymbol(t.api.selector(`external`,`zod.z`));if(n.$ref){let e=t.api.selector(`ref`,n.$ref),o=t.referenceSymbol(e);t.isSymbolRegistered(e)?i.expression=P.identifier({text:o.placeholder}):(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:Q.lazy}),parameters:[P.arrowFunction({statements:[P.returnStatement({expression:P.identifier({text:o.placeholder})})]})]}),i.hasLazyExpression=!0,r.hasLazyExpression.value=!0)}else if(n.type){let e=em({plugin:t,schema:n,state:r});i.expression=e.expression,i.typeName=e.anyType,t.config.metadata&&n.description&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.expression,name:Q.describe}),parameters:[P.stringLiteral({text:n.description})]}))}else if(n.items)if(n=T({schema:n}),n.items){let e=n.items.map((e,n)=>tm({plugin:t,schema:e,state:{...r,path:K([...r.path.value,`items`,n])}}).expression);if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:Q.intersection}),parameters:e}):(i.expression=e[0],e.slice(1).forEach(e=>{i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.expression,name:Q.and}),parameters:[e]})}))}else i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:Q.union}),parameters:[P.arrayLiteralExpression({elements:e})]})}else i=tm({plugin:t,schema:n,state:r});else{let e=em({plugin:t,schema:{type:`unknown`},state:r});i.expression=e.expression,i.typeName=e.anyType}if(i.expression&&(n.accessScope===`read`&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.expression,name:Q.readonly})})),e&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.expression,name:Q.optional})})),n.default!==void 0)){let e=$({isBigInt:n.type===`integer`&&n.format===`int64`,value:n.default});e&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.expression,name:Q.default}),parameters:[e]}))}return r.hasLazyExpression.value?i.typeName||=`ZodTypeAny`:i.typeName&&=void 0,i},nm=({plugin:e,schema:t,state:n})=>{let r=or(n.path.value),i=tm({plugin:e,schema:t,state:n}),a=F(r);Sp({ast:i,plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{path:n.path.value,tags:n.tags?.value},name:w({config:e.config.definitions,name:a}),selector:e.api.selector(`ref`,r)}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:w({config:e.config.definitions.types.infer,name:a}),selector:e.api.selector(`type-infer-ref`,r)}):void 0})},rm=({plugin:e})=>{e.registerSymbol({external:Cp({plugin:e}),name:`z`,selector:e.api.selector(`external`,`zod.z`)}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=q({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:wp({getAst:(n,r)=>tm({plugin:e,schema:n,state:q({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:nm({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:nm({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:nm({plugin:e,schema:t.schema,state:n});break;case`webhook`:Tp({getAst:(n,r)=>tm({plugin:e,schema:n,state:q({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},im=({plugin:e})=>{let t={},n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return t.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.unknown})}),t},am=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),a=P.propertyAccessExpression({expression:i.placeholder,name:Q.array});if(!t.items)r.expression=P.callExpression({functionName:a,parameters:[im({plugin:e,schema:{type:`unknown`},state:n}).expression]});else{t=T({schema:t});let o=t.items.map((t,i)=>{let a=_m({plugin:e,schema:t,state:{...n,path:K([...n.path.value,`items`,i])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),a.expression});if(o.length===1)r.expression=P.callExpression({functionName:a,parameters:o});else if(t.logicalOperator===`and`){let e=t.items[0],n;if(e.logicalOperator===`or`||e.type&&e.type!==`object`)n=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:Q.intersection}),parameters:o});else{n=o[0];for(let e=1;e<o.length;e++)n=P.callExpression({functionName:P.propertyAccessExpression({expression:n,name:Q.and}),parameters:[o[e]]})}r.expression=P.callExpression({functionName:a,parameters:[n]})}else r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:Q.array}),parameters:[P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:Q.union}),parameters:[P.arrayLiteralExpression({elements:o})]})]})}return t.minItems===t.maxItems&&t.minItems!==void 0?r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.expression,name:Q.length}),parameters:[P.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.expression,name:Q.min}),parameters:[P.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.expression,name:Q.max}),parameters:[P.valueToExpression({value:t.maxItems})]}))),r},om=({plugin:e,schema:t})=>{let n={},r=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return typeof t.const==`boolean`?(n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[P.ots.boolean(t.const)]}),n):(n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.boolean})}),n)},sm=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),a=[],o=[],s=!1,c=!0;for(let e of t.items??[])if(e.type===`string`&&typeof e.const==`string`){let t=P.stringLiteral({text:e.const});a.push(t),o.push(P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:Q.literal}),parameters:[t]}))}else if((e.type===`number`||e.type===`integer`)&&typeof e.const==`number`){c=!1;let t=P.ots.number(e.const);o.push(P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:Q.literal}),parameters:[t]}))}else if(e.type===`boolean`&&typeof e.const==`boolean`){c=!1;let t=P.ots.boolean(e.const);o.push(P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:Q.literal}),parameters:[t]}))}else (e.type===`null`||e.const===null)&&(s=!0);return o.length?(c&&a.length>0?r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:Q.enum}),parameters:[P.arrayLiteralExpression({elements:a,multiLine:!1})]}):o.length===1?r.expression=o[0]:r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:Q.union}),parameters:[P.arrayLiteralExpression({elements:o,multiLine:o.length>3})]}),s&&(r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:Q.nullable}),parameters:[r.expression]})),r):im({plugin:e,schema:{type:`unknown`},state:n})},cm=({plugin:e})=>{let t={},n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return t.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.never})}),t},lm=({plugin:e})=>{let t={},n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return t.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.null})}),t},um=({plugin:e,schema:t})=>{let n={},r=t.type===`integer`&&t.format===`int64`,i=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return typeof t.const==`number`?(n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:Q.literal}),parameters:[P.ots.number(t.const)]}),n):(n.expression=P.callExpression({functionName:r?P.propertyAccessExpression({expression:P.propertyAccessExpression({expression:i.placeholder,name:Q.coerce}),name:Q.bigint}):P.propertyAccessExpression({expression:i.placeholder,name:Q.number})}),!r&&t.type===`integer`&&(n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:Q.int})})),t.exclusiveMinimum===void 0?t.minimum!==void 0&&(n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.expression,name:Q.gte}),parameters:[$({isBigInt:r,value:t.minimum})]})):n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.expression,name:Q.gt}),parameters:[$({isBigInt:r,value:t.exclusiveMinimum})]}),t.exclusiveMaximum===void 0?t.maximum!==void 0&&(n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.expression,name:Q.lte}),parameters:[$({isBigInt:r,value:t.maximum})]})):n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.expression,name:Q.lt}),parameters:[$({isBigInt:r,value:t.exclusiveMaximum})]}),n)},dm=({plugin:e,schema:t,state:n})=>{let r={},i=[],a=t.required??[],o=e.referenceSymbol(e.api.selector(`external`,`zod.z`));for(let o in t.properties){let s=t.properties[o],c=_m({optional:!a.includes(o),plugin:e,schema:s,state:{...n,path:K([...n.path.value,`properties`,o])}});c.hasLazyExpression&&(r.hasLazyExpression=!0),O.lastIndex=0;let u;u=O.test(o)?o.startsWith(`-`)?l.factory.createStringLiteral(o):l.factory.createNumericLiteral(o):o,(o.match(/^[0-9]/)&&o.match(/\D+/g)||o.match(/\W/g))&&!o.startsWith(`'`)&&!o.endsWith(`'`)&&(u=`'${o}'`),c.hasLazyExpression?i.push(P.getAccessorDeclaration({name:u,statements:[P.returnStatement({expression:c.expression})]})):i.push(P.propertyAssignment({initializer:c.expression,name:u}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=_m({plugin:e,schema:t.additionalProperties,state:{...n,path:K([...n.path.value,`additionalProperties`])}});return r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:Q.record}),parameters:[P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:Q.string}),parameters:[]}),i.expression]}),i.hasLazyExpression&&(r.hasLazyExpression=!0),r.hasLazyExpression?{...r,typeName:`ZodType`}:r}return r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:Q.object}),parameters:[l.factory.createObjectLiteralExpression(i,!0)]}),r.hasLazyExpression?{...r,typeName:`ZodType`}:r},fm=({plugin:e,schema:t})=>{let n={},r=e.referenceSymbol(e.api.selector(`external`,`zod.z`));if(typeof t.const==`string`)return n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[P.ots.string(t.const)]}),n;n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.string})});let i=[];if(e.config.dates.offset&&i.push({key:`offset`,value:!0}),e.config.dates.local&&i.push({key:`local`,value:!0}),t.format)switch(t.format){case`date`:n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:P.propertyAccessExpression({expression:r.placeholder,name:Q.iso}),name:Q.date})});break;case`date-time`:n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:P.propertyAccessExpression({expression:r.placeholder,name:Q.iso}),name:Q.datetime}),parameters:i.length>0?[P.objectExpression({obj:i})]:[]});break;case`email`:n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.email})});break;case`ipv4`:n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.ipv4})});break;case`ipv6`:n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.ipv6})});break;case`time`:n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:P.propertyAccessExpression({expression:r.placeholder,name:Q.iso}),name:Q.time})});break;case`uri`:n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.url})});break;case`uuid`:n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:Q.uuid})});break}return t.minLength===t.maxLength&&t.minLength!==void 0?n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.expression,name:Q.length}),parameters:[P.valueToExpression({value:t.minLength})]}):(t.minLength!==void 0&&(n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.expression,name:Q.min}),parameters:[P.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&(n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.expression,name:Q.max}),parameters:[P.valueToExpression({value:t.maxLength})]}))),t.pattern&&(n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.expression,name:Q.regex}),parameters:[P.regularExpressionLiteral({text:t.pattern})]})),n},pm=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol(e.api.selector(`external`,`zod.z`));if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:Q.literal}),parameters:[P.valueToExpression({value:e})]}));return r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:Q.tuple}),parameters:[P.arrayLiteralExpression({elements:e})]}),r}let a=[];return t.items&&t.items.forEach((t,i)=>{let o=_m({plugin:e,schema:t,state:{...n,path:K([...n.path.value,`items`,i])}});a.push(o.expression),o.hasLazyExpression&&(r.hasLazyExpression=!0)}),r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:Q.tuple}),parameters:[P.arrayLiteralExpression({elements:a})]}),r},mm=({plugin:e})=>{let t={},n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return t.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.undefined})}),t},hm=({plugin:e})=>{let t={},n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return t.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:Q.void})}),t},gm=({schema:e,...t})=>{switch(e.type){case`array`:return am({...t,schema:e});case`boolean`:return om({...t,schema:e});case`enum`:return sm({...t,schema:e});case`integer`:case`number`:return um({...t,schema:e});case`never`:return cm({...t,schema:e});case`null`:return lm({...t,schema:e});case`object`:return dm({...t,schema:e});case`string`:return fm({...t,schema:e});case`tuple`:return pm({...t,schema:e});case`undefined`:return mm({...t,schema:e});case`unknown`:return im({...t,schema:e});case`void`:return hm({...t,schema:e})}},_m=({optional:e,plugin:t,schema:n,state:r})=>{let i={},a=t.referenceSymbol(t.api.selector(`external`,`zod.z`));if(n.$ref){let e=t.api.selector(`ref`,n.$ref),o=t.referenceSymbol(e);t.isSymbolRegistered(e)?i.expression=P.identifier({text:o.placeholder}):(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:Q.lazy}),parameters:[P.arrowFunction({returnType:P.keywordTypeNode({keyword:`any`}),statements:[P.returnStatement({expression:P.identifier({text:o.placeholder})})]})]}),i.hasLazyExpression=!0,r.hasLazyExpression.value=!0)}else if(n.type){let e=gm({plugin:t,schema:n,state:r});i.expression=e.expression,i.hasLazyExpression=e.hasLazyExpression,t.config.metadata&&n.description&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.expression,name:Q.register}),parameters:[P.propertyAccessExpression({expression:a.placeholder,name:Q.globalRegistry}),P.objectExpression({obj:[{key:`description`,value:P.stringLiteral({text:n.description})}]})]}))}else if(n.items)if(n=T({schema:n}),n.items){let e=n.items.map((e,n)=>_m({plugin:t,schema:e,state:{...r,path:K([...r.path.value,`items`,n])}}));if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:Q.intersection}),parameters:e.map(e=>e.expression)}):(i.expression=e[0].expression,e.slice(1).forEach(e=>{i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.expression,name:Q.and}),parameters:[e.hasLazyExpression?P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:Q.lazy}),parameters:[P.arrowFunction({statements:[P.returnStatement({expression:e.expression})]})]}):e.expression]})}))}else i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:Q.union}),parameters:[P.arrayLiteralExpression({elements:e.map(e=>e.expression)})]})}else i=_m({plugin:t,schema:n,state:r});else i.expression=gm({plugin:t,schema:{type:`unknown`},state:r}).expression;if(i.expression&&(n.accessScope===`read`&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.expression,name:Q.readonly})})),e&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:Q.optional}),parameters:[i.expression]}),i.typeName=Q.ZodOptional),n.default!==void 0)){let e=$({isBigInt:n.type===`integer`&&n.format===`int64`,value:n.default});e&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.expression,name:Q.default}),parameters:[e]}))}return i},vm=({plugin:e,schema:t,state:n})=>{let r=or(n.path.value),i=_m({plugin:e,schema:t,state:n}),a=F(r);Sp({ast:i,plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{path:n.path.value,tags:n.tags?.value},name:w({config:e.config.definitions,name:a}),selector:e.api.selector(`ref`,r)}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:w({config:e.config.definitions.types.infer,name:a}),selector:e.api.selector(`type-infer-ref`,r)}):void 0})},ym=({plugin:e})=>{e.registerSymbol({external:Cp({plugin:e}),name:`z`,selector:e.api.selector(`external`,`zod.z`)}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=q({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:wp({getAst:(n,r)=>_m({plugin:e,schema:n,state:q({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:vm({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:vm({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:vm({plugin:e,schema:t.schema,state:n});break;case`webhook`:Tp({getAst:(n,r)=>_m({plugin:e,schema:n,state:q({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},bm={api:new xp({name:`zod`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:e=>{let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return rm(e);case`mini`:return Vp(e);case 4:default:return ym(e)}},name:`zod`,resolveConfig:(e,t)=>{let n=t.package.getVersion(`zod`),r=()=>n&&(n.major===4||n.major===3)?n.major:4,i=e=>{if(!e)return r();if(!n)return e;if((e===4||e===3||e===`mini`)&&!t.package.satisfies(n,`>=3.25.0 <5.0.0`)){let t=r();return console.warn(`🔌 ${a.yellow(`Warning:`)} Installed ${a.cyan(`zod`)} ${a.cyan(`v${n.version}`)} does not support compatibility version ${a.yellow(String(e))}, using ${a.yellow(String(t))}.`),t}return e};e.config.compatibilityVersion=i(e.config.compatibilityVersion),e.config.dates=t.valueToObject({defaultValue:{local:!1,offset:!1},value:e.config.dates}),e.config.types=t.valueToObject({defaultValue:{infer:{case:`PascalCase`,enabled:!1}},mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:S,value:e.infer})})},value:e.config.types}),e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`z{{name}}`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}ZodType`}}},mappers:{...S,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:S,value:e.infer})})},value:e.types})})},value:e.config.definitions}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`z{{name}}Data`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}DataZodType`}}},mappers:{...S,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:S,value:e.infer})})},value:e.types})})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`z{{name}}Response`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}ResponseZodType`}}},mappers:{...S,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:S,value:e.infer})})},value:e.types})})},value:e.config.responses}),e.config.webhooks=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`z{{name}}WebhookRequest`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}WebhookRequestZodType`}}},mappers:{...S,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:S,value:e.infer})})},value:e.types})})},value:e.config.webhooks})},tags:[`validator`]},xm={"@angular/common":rl,"@hey-api/client-angular":yl,"@hey-api/client-axios":xl,"@hey-api/client-fetch":Cl,"@hey-api/client-next":Tl,"@hey-api/client-nuxt":Dl,"@hey-api/client-ofetch":kl,"@hey-api/schemas":Yl,"@hey-api/sdk":_u,"@hey-api/transformers":Wu,"@hey-api/typescript":yd,"@pinia/colada":Id,"@tanstack/angular-query-experimental":Sf,"@tanstack/react-query":Cf,"@tanstack/solid-query":wf,"@tanstack/svelte-query":Tf,"@tanstack/vue-query":Ef,arktype:Rf,fastify:Vf,"legacy/angular":Al,"legacy/axios":jl,"legacy/fetch":Ml,"legacy/node":Nl,"legacy/xhr":Pl,valibot:mp,zod:bm},Sm=[`@hey-api/typescript`,`@hey-api/sdk`],Cm=({dependencies:e,userPlugins:t,userPluginsConfig:n})=>{let r=new Set,i=new Set,a={},o=s=>{if(r.has(s))throw Error(`Circular reference detected at '${s}'`);if(i.has(s))return;r.add(s);let c=xm[s],l=n[s];if(!c&&!l)throw Error(`unknown plugin dependency "${s}" - do you need to register a custom plugin with this name?`);let u={...c,...l,config:{...c?.config,...l?.config},dependencies:new Set([...c?.dependencies||[],...l?.dependencies||[]])};if(u.resolveConfig){let r={package:ut(e),pluginByTag:(e,r={})=>{let{defaultPlugin:i,errorMessage:a}=r;for(let r of t){let t=xm[r]||n[r];if(t&&t.tags?.includes(e)&&r!==s)return r}if(i){let t=xm[i]||n[i];if(t&&t.tags?.includes(e)&&i!==s)return i}throw Error(a||`missing plugin - no plugin with tag "${e}" found`)},valueToObject:Be};u.resolveConfig(u,r)}for(let e of u.dependencies)o(e);r.delete(s),i.add(s),a[s]=u};for(let e of t)o(e);return{pluginOrder:Array.from(i),plugins:a}},wm=e=>typeof e==`string`?e.startsWith(`@hey-api/client`)||e.startsWith(`legacy/`):e.name.startsWith(`@hey-api/client`)||e.name.startsWith(`legacy/`)||e.tags&&e.tags.includes(`client`),Tm=({dependencies:e,userConfig:t})=>{let n={},r=Sm;return t.plugins&&(t.plugins=t.plugins.filter(e=>typeof e==`string`&&e||typeof e!=`string`&&e.name),r=t.plugins.length===1&&wm(t.plugins[0])?[...Sm,...t.plugins]:t.plugins),Cm({dependencies:e,userPlugins:r.map(e=>{if(typeof e==`string`)return e;let t=e.name;return t&&(e.handler?n[t]=e:(n[t]={config:{...e}},delete n[t].config.name)),t}).filter(Boolean),userPluginsConfig:n})},Em=()=>!!(process.stdin.isTTY&&process.stdout.isTTY&&!process.env.CI&&!process.env.NO_INTERACTIVE&&!process.env.NO_INTERACTION),Dm=async({logger:e,userConfigs:t})=>{let n=[],r={},i=e.timeEvent(`load`);for(let i of t){let t;if(i?.configFile){let e=i.configFile.split(`.`);t=e.slice(0,e.length-1).join(`.`)}let o=e.timeEvent(`c12`),{loadConfig:s}=await import(`c12`),{config:c,configFile:l}=await s({configFile:t,name:`openapi-ts`});o.timeEnd(),Object.keys(r).length||(r=He(Object.keys(c).length?l:void 0));let u=c instanceof Array?c.map(e=>Le(e,i)):[Le(c,i)];for(let e of u){let t=Pe(e);if(e.output instanceof Array){let r=t.length,i=e.output.length;if(i>1)if(r!==i){console.warn(`⚙️ ${a.yellow(`Warning:`)} You provided ${a.cyan(String(r))} ${a.cyan(r===1?`input`:`inputs`)} and ${a.yellow(String(i))} ${a.yellow(`outputs`)}. This is probably not what you want as it will produce identical output in multiple locations. You most likely want to provide a single output or the same number of outputs as inputs.`);for(let r of e.output)n.push({...e,input:t,output:r})}else e.output.forEach((r,i)=>{n.push({...e,input:t[i],output:r})});else n.push({...e,input:t,output:e.output[0]??``})}else n.push({...e,input:t})}}i.timeEnd();let o=[],c=e.timeEvent(`build`);for(let e of n){let{base:t,configFile:n=``,dryRun:i=!1,experimentalParser:c=!0,exportCore:l=!0,name:u,request:d,useOptions:f=!0}=e,p=e.interactive===void 0?Em():e.interactive,m=Fe(e),h=Pe(e),g=Ve(e),ee=We(e),_=[];h.length||_.push(new ie(`missing input - which OpenAPI specification should we use to generate your output?`)),g.path||_.push(new ie(`missing output - where should we generate your output?`)),!f&&m.level!==`silent`&&console.warn(`❗️ Deprecation warning: useOptions set to false. This setting will be removed in future versions. Please migrate useOptions to true https://heyapi.dev/openapi-ts/migrating.html#v0-27-38`),g.path=s.resolve(process.cwd(),g.path);let te;try{te=Tm({dependencies:r,userConfig:e})}catch(e){_.push(e),te={pluginOrder:[],plugins:{}}}let v=me({...te,base:t,configFile:n,dryRun:i,experimentalParser:c,exportCore:!1,input:h,interactive:p,logs:m,name:u,output:g,parser:ee,request:d,useOptions:f});v.exportCore=x(v)?l:!1;let ne=o.length;if(m.level===`debug`){let e=a.gray(`[Job ${ne+1}] `);console.warn(`${e}${a.cyan(`config:`)}`,v)}o.push({config:v,errors:_,jobIndex:ne})}return c.timeEnd(),{dependencies:r,results:o}};Object.entries({$body_:`body`,$headers_:`headers`,$path_:`path`,$query_:`query`});const Om=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},km=e=>{switch(e){case`form`:return`,`;case`pipeDelimited`:return`|`;case`spaceDelimited`:return`%20`;default:return`,`}},Am=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},jm=({allowReserved:e,explode:t,name:n,style:r,value:i})=>{if(!t){let t=(e?i:i.map(e=>encodeURIComponent(e))).join(km(r));switch(r){case`label`:return`.${t}`;case`matrix`:return`;${n}=${t}`;case`simple`:return t;default:return`${n}=${t}`}}let a=Om(r),o=i.map(t=>r===`label`||r===`simple`?e?t:encodeURIComponent(t):Mm({allowReserved:e,name:n,value:t})).join(a);return r===`label`||r===`matrix`?a+o:o},Mm=({allowReserved:e,name:t,value:n})=>{if(n==null)return``;if(typeof n==`object`)throw Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?n:encodeURIComponent(n)}`},Nm=({allowReserved:e,explode:t,name:n,style:r,value:i,valueOnly:a})=>{if(i instanceof Date)return a?i.toISOString():`${n}=${i.toISOString()}`;if(r!==`deepObject`&&!t){let t=[];Object.entries(i).forEach(([n,r])=>{t=[...t,n,e?r:encodeURIComponent(r)]});let a=t.join(`,`);switch(r){case`form`:return`${n}=${a}`;case`label`:return`.${a}`;case`matrix`:return`;${n}=${a}`;default:return a}}let o=Am(r),s=Object.entries(i).map(([t,i])=>Mm({allowReserved:e,name:r===`deepObject`?`${n}[${t}]`:t,value:i})).join(o);return r===`label`||r===`matrix`?o+s:s},Pm=({parameters:e={},...t}={})=>n=>{let r=[];if(n&&typeof n==`object`)for(let i in n){let a=n[i];if(a==null)continue;let o=e[i]||t;if(Array.isArray(a)){let e=jm({allowReserved:o.allowReserved,explode:!0,name:i,style:`form`,value:a,...o.array});e&&r.push(e)}else if(typeof a==`object`){let e=Nm({allowReserved:o.allowReserved,explode:!0,name:i,style:`deepObject`,value:a,...o.object});e&&r.push(e)}else{let e=Mm({allowReserved:o.allowReserved,name:i,value:a});e&&r.push(e)}}return r.join(`&`)},Fm=e=>{let t=[];return e.forEach((e,n)=>{t.push([n,e])}),t},Im=(...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let e=n instanceof Headers?Fm(n):Object.entries(n);for(let[n,r]of e)if(r===null)t.delete(n);else if(Array.isArray(r))for(let e of r)t.append(n,e);else r!==void 0&&t.set(n,typeof r==`object`?JSON.stringify(r):r)}return t};Pm({allowReserved:!1,array:{explode:!0,style:`form`},object:{explode:!0,style:`deepObject`}});const Lm=async({fetchOptions:e,inputPath:t,timeout:n,watch:r})=>{let i=f({pathOrUrlOrSchema:t}),a,o,s;if(i.type===`url`){if(r.lastValue&&r.isHeadMethodSupported!==!1){try{let t=await p({fetchOptions:{method:`HEAD`,...e,headers:Im(e?.headers,r.headers)},timeout:n,url:i.path});if(t.response.status>=300)return{error:`not-ok`,response:t.response};s=t.response}catch(e){return{error:`not-ok`,response:new Response(e.message)}}if(!s.ok&&r.isHeadMethodSupported)return{error:`not-ok`,response:s};if(r.isHeadMethodSupported===void 0&&(r.isHeadMethodSupported=s.ok),s.status===304)return{error:`not-modified`,response:s};if(o===void 0){let e=s.headers.get(`ETag`);e&&(o=e!==r.headers.get(`If-None-Match`),o&&r.headers.set(`If-None-Match`,e))}if(o===void 0){let e=s.headers.get(`Last-Modified`);e&&(o=e!==r.headers.get(`If-Modified-Since`),o&&r.headers.set(`If-Modified-Since`,e))}if(o===!1)return{error:`not-modified`,response:s}}try{let t=await p({fetchOptions:{method:`GET`,...e},timeout:n,url:i.path});if(t.response.status>=300)return{error:`not-ok`,response:t.response};s=t.response}catch(e){return{error:`not-ok`,response:new Response(e.message)}}if(!s.ok)return{error:`not-ok`,response:s};if(a=s.body?await s.arrayBuffer():new ArrayBuffer(0),o===void 0){let e=new TextDecoder().decode(a);o=e!==r.lastValue,r.lastValue=e}}else r.lastValue?o=!1:r.lastValue=i.type;return o===!1?{error:`not-modified`,response:s}:{arrayBuffer:a,resolvedInput:i}};export{ce as A,b as C,ie as D,y as E,ne as F,ee as I,ue as M,de as N,ae as O,v as P,Fe as S,he as T,Un as _,_l as a,Ge as b,al as c,ps as d,hs as f,pr as g,oi as h,Gl as i,le as j,oe as k,Ec as l,Xo as m,Dm as n,pl as o,ns as p,Sm as r,il as s,Lm as t,Dc as u,P as v,x as w,Ue as x,C as y};
|
|
24
|
+
//# sourceMappingURL=getSpec-CXDbow97.js.map
|