@hey-api/openapi-ts 0.87.1 → 0.87.3
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/README.md +2 -0
- package/dist/clients/fetch/client.ts +34 -1
- package/dist/clients/ky/client.ts +339 -0
- package/dist/clients/ky/index.ts +24 -0
- package/dist/clients/ky/types.ts +271 -0
- package/dist/clients/ky/utils.ts +328 -0
- package/dist/{config-PWeoedFF.d.cts → config-BI0uP8YS.d.cts} +1010 -27
- package/dist/{config-CNi83ZTD.d.ts → config-BpulPCv9.d.ts} +1010 -27
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +325 -325
- package/dist/index.d.ts +325 -325
- 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/openApi--TCWOigv.js +19 -0
- package/dist/openApi--TCWOigv.js.map +1 -0
- package/dist/openApi-hVsWZkpA.cjs +19 -0
- package/dist/openApi-hVsWZkpA.cjs.map +1 -0
- 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-CF9c-t93.js +11 -0
- package/dist/{src-CZCpIWy7.js.map → src-CF9c-t93.js.map} +1 -1
- package/dist/src-CVDS5cbw.cjs +19 -0
- package/dist/{src-Cvd6zAsc.cjs.map → src-CVDS5cbw.cjs.map} +1 -1
- package/package.json +5 -4
- package/dist/openApi-CCTdD3hW.cjs +0 -19
- package/dist/openApi-CCTdD3hW.cjs.map +0 -1
- package/dist/openApi-D7xrG_wR.js +0 -19
- package/dist/openApi-D7xrG_wR.js.map +0 -1
- package/dist/src-CZCpIWy7.js +0 -11
- package/dist/src-Cvd6zAsc.cjs +0 -19
package/dist/openApi-D7xrG_wR.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./chunk-C-EqMg7d.js";import{Project as t,createBinding as n,mergeBindings as r,renderIds as i}from"@hey-api/codegen-core";import a from"ansi-colors";import o from"node:fs";import s from"node:path";import{fileURLToPath as c}from"node:url";import l from"typescript";import{EOL as u}from"node:os";import*as d from"semver";import{getResolvedInput as f,sendRequest as p}from"@hey-api/json-schema-ref-parser";const m=c(import.meta.url),h=s.dirname(m),g=()=>{let e=h;for(;e!==s.dirname(e);){let t=o.readdirSync(e).filter(e=>e===`package.json`);if(t[0]){let n=s.join(e,t[0]);return JSON.parse(o.readFileSync(n,{encoding:`utf8`}))}e=s.dirname(e)}},ee=()=>{let e=g(),t={bugs:{url:``},name:``,version:``};return e&&typeof e==`object`&&(`name`in e&&typeof e.name==`string`&&(t.name=e.name),`version`in e&&typeof e.version==`string`&&(t.version=e.version),`bugs`in e&&e.bugs&&typeof e.bugs==`object`&&`url`in e.bugs&&typeof e.bugs.url==`string`&&(t.bugs.url=e.bugs.url,t.bugs.url&&!t.bugs.url.endsWith(`/`)&&(t.bugs.url+=`/`))),t},te=e=>{if(e===null)return null;if(e){let t=s.isAbsolute(e)?e:s.resolve(h,e);return o.existsSync(t)?t:null}let t=h;for(;t!==s.dirname(t);){let e=o.readdirSync(t).filter(e=>e.startsWith(`tsconfig`)&&e.endsWith(`.json`)).sort(e=>e===`tsconfig.json`?-1:1);if(e[0])return s.join(t,e[0]);t=s.dirname(t)}return null},ne=e=>{if(!e)return null;let t=l.readConfigFile(e,l.sys.readFile);if(t.error)throw Error(`Couldn't read tsconfig from path: ${e}`);return l.parseJsonConfigFileContent(t.config,l.sys,s.dirname(e))},_=e=>{o.existsSync(e)||o.mkdirSync(e,{recursive:!0})};var v=class extends Error{constructor(e){super(e),this.name=`ConfigError`}},re=class extends Error{errors;constructor(e){super(`Found ${e.length} configuration ${e.length===1?`error`:`errors`}.`),this.name=`ConfigValidationError`,this.errors=e}},ie=class extends Error{originalError;constructor(e,t){super(e),this.name=`JobError`,this.originalError=t}},ae=class extends Error{args;event;pluginName;constructor({args:e,error:t,event:n,name:r,pluginName:i}){let a=t instanceof Error?t.message:`Unknown error`;super(a),this.args=e,this.cause=t.cause,this.event=n,this.name=r||t.name,this.pluginName=i,this.stack=t.stack}};const oe=(e,t)=>{if(e instanceof v||e instanceof re)return;e instanceof ie&&(e=e.originalError.error);let n=`openapi-ts-error-${Date.now()}.log`,r=s.resolve(process.cwd(),t);_(r);let i=s.resolve(r,n),a=`[${new Date().toISOString()}] `;e instanceof ae&&(a+=`${e.name} during event "${e.event}"\n`,e.pluginName&&(a+=`Plugin: ${e.pluginName}\n`),a+=`Arguments: ${JSON.stringify(e.args,null,2)}\n\n`);let c=e instanceof Error?e.message:String(e),l=e instanceof Error?e.stack:void 0;return a+=`Error: ${c}\n`,l&&(a+=`Stack:\n${l}\n`),o.writeFileSync(i,a),i},se=async e=>{let t=ee();if(!t.bugs.url)return;e instanceof ie&&(e=e.originalError.error);let n=``;e instanceof ae&&(e.pluginName&&(n+=`**Plugin**: \`${e.pluginName}\`\n`),n+=`**Event**: \`${e.event}\`\n`,n+=`**Arguments**:\n\`\`\`ts\n${JSON.stringify(e.args,null,2)}\n\`\`\`\n\n`);let r=e instanceof Error?e.message:String(e),i=e instanceof Error?e.stack:void 0;n+=`**Error**: \`${r}\`\n`,i&&(n+=`\n**Stack Trace**:\n\`\`\`\n${i}\n\`\`\``);let a=new URLSearchParams({body:n,labels:`bug 🔥`,title:`Crash Report`}),o=`${t.bugs.url}new?${a.toString()}`,s=(await import(`open`)).default;await s(o)},ce=({error:e,logPath:t})=>{if(e instanceof re&&e.errors.length){let t=new Map;for(let{error:n,jobIndex:r}of e.errors)t.has(r)||t.set(r,[]),t.get(r).push(n);for(let[e,n]of t.entries()){let t=a.gray(`[Job ${e+1}] `),r=n.length,i=a.red(`Found ${r} configuration ${r===1?`error`:`errors`}:`);console.error(`${t}❗️ ${i}`),n.forEach((e,n)=>{let r=` [${n+1}] `,i=a.red(r);console.error(`${t}${i}${a.white(e.message)}`)})}}else{let t=a.gray(`[root] `);e instanceof ie&&(t=a.gray(`[Job ${e.originalError.jobIndex+1}] `),e=e.originalError.error);let n=a.red(`Failed with the message:`);console.error(`${t}❌ ${n}`);let r=a.red(` `);console.error(`${t}${r}${typeof e==`string`?e:e instanceof Error?e.message:`Unknown error`}`)}if(t){let e=a.gray(`[root] `);console.error(`${e}${a.cyan(`📄 Crash log saved to:`)} ${a.gray(t)}`)}},le=async({error:e,isInteractive:t})=>!t||e instanceof v||e instanceof re?!1:new Promise(e=>{let t=a.gray(`[root] `);console.log(`${t}${a.yellow(`📢 Open a GitHub issue with crash details? (y/N):`)}`),process.stdin.setEncoding(`utf8`),process.stdin.once(`data`,t=>{e(t.trim().toLowerCase()===`y`)})}),ue=/^([\w-]+)\/([\w-]+)(?:\?([\w=&.-]*))?$/,de=`https://get.heyapi.dev`,fe=(e,t,n)=>`${de}/${e}/${t}${n?`?${n}`:``}`,pe=e=>{let t=e.organization,n=e.project,r;if(e.path){let i=e.path.match(ue);if(!i)throw Error(`Invalid Hey API shorthand format. Expected "organization/project?queryParams" or "organization/project", received: ${e.path}`);t=i[1],n=i[2],r=i[3]}if(!t)throw Error(`The Hey API organization cannot be empty.`);if(!n)throw Error(`The Hey API project cannot be empty.`);return{organization:t,project:n,queryParams:r}},me=e=>{let t=pe(e);return{path:fe(t.organization,t.project,t.queryParams),registry:`hey-api`}},he=/^(@([\w-]+)\/([\w\-.]+)#)?([\w-]+)$/,ge=e=>`https://dash.readme.com/api/v1/api-registry/${e}`,_e=`readme`,ve=e=>{let t=e.match(he);if(!t)throw Error(`Invalid ReadMe shorthand format. Expected "${_e}:@organization/project#uuid" or "${_e}:uuid", received: ${_e}:${e}`);let[,,n,r,i]=t;if(!i)throw Error(`The ReadMe UUID cannot be empty.`);return{organization:n,project:r,uuid:i}},ye=e=>{let t=ve(e.slice(`${_e}:`.length));return{...t,path:ge(t.uuid),registry:`readme`}},be=/^(@[\w-]+)\/([\w.-]+)$/,xe=(e,t)=>`https://registry.scalar.com/${e}/apis/${t}/latest?format=json`,Se=`scalar`,Ce=e=>{let t=e.match(be);if(!t)throw Error(`Invalid Scalar shorthand format. Expected "${Se}:@organization/project", received: ${Se}:${e}`);let[,n,r]=t;if(!n)throw Error(`The Scalar organization cannot be empty.`);if(!r)throw Error(`The Scalar project cannot be empty.`);return{organization:n,project:r}},we=e=>{let t=Ce(e.slice(`${Se}:`.length));return{...t,path:xe(t.organization,t.project),registry:`scalar`}},Te=e=>{if(e.path.startsWith(`readme:`)){Object.assign(e,ye(e.path));return}if(e.path.startsWith(`scalar:`)){Object.assign(e,we(e.path));return}if(e.path.startsWith(`.`))return;if(e.path.startsWith(de)){e.path=e.path.slice(23),Object.assign(e,me(e));return}let t=e.path.split(`/`);if(t.length===2&&t.filter(Boolean).length===2){Object.assign(e,me(e));return}},Ee={enabled:!1,interval:1e3,timeout:6e4},De=e=>{let t={...Ee};return typeof e.path==`string`&&(typeof e.watch==`boolean`?t.enabled=e.watch:typeof e.watch==`number`?(t.enabled=!0,t.interval=e.watch):e.watch&&(t={...t,...e.watch})),t},Oe=e=>{let t=e.input instanceof Array?e.input:[e.input],n=[];for(let r of t){let t={path:``,watch:Ee};typeof r==`string`?t.path=r:r&&(r.path!==void 0||r.organization!==void 0)?(t={...t,path:de,...r},t.watch!==void 0&&(t.watch=De(t))):t={...t,path:r},typeof t.path==`string`&&Te(t),e.watch!==void 0&&t.watch.enabled===Ee.enabled&&t.watch.interval===Ee.interval&&t.watch.timeout===Ee.timeout&&(t.watch=De({path:t.path,watch:e.watch})),t.path&&n.push(t)}return n},ke=e=>{let t={file:!0,level:`info`,path:process.cwd()};return typeof e?.logs==`string`?t.path=e.logs:t={...t,...e?.logs},t},Ae=(e,t)=>{let n=e||{},r=t||{};return{...n,...r}},je=(e,t)=>{let n=e||{},r=t||{},i={...n,...r};return typeof i.logs==`object`&&(i.logs=Ae(n.logs,r.logs)),i},Me=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof e!=`function`,Ne=(e,t)=>{for(let[n,r]of Object.entries(t))r!==void 0&&r!==``&&(e[n]=r);return e},y=({defaultValue:e,mappers:t,value:n})=>{let r={...e};switch(typeof n){case`boolean`:if(t&&`boolean`in t){let e=t.boolean;r=Ne(r,e(n))}break;case`function`:if(t&&`function`in t){let e=t.function;r=Ne(r,e(n))}break;case`number`:if(t&&`number`in t){let e=t.number;r=Ne(r,e(n))}break;case`string`:if(t&&`string`in t){let e=t.string;r=Ne(r,e(n))}break;case`object`:if(Me(n))if(t&&`object`in t&&typeof t.object==`function`){let i=t.object;r=Ne(r,i(n,e))}else r=Ne(r,n);break}return r},Pe=e=>{if(e.output instanceof Array)throw Error(`Unexpected array of outputs in user configuration. This should have been expanded already.`);let t=y({defaultValue:{clean:!0,fileName:{case:`preserve`,name:`{{name}}`,suffix:`.gen`},format:null,indexFile:!0,lint:null,path:``},mappers:{object:(e,t)=>({...e,fileName:y({defaultValue:{...t.fileName},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.fileName})}),string:e=>({path:e})},value:e.output});return t.tsConfig=ne(te(t.tsConfigPath)),t.importFileExtension===void 0&&t.tsConfig?.options.moduleResolution===l.ModuleResolutionKind.NodeNext&&(t.importFileExtension=`.js`),t.importFileExtension&&!t.importFileExtension.startsWith(`.`)&&(t.importFileExtension=`.${t.importFileExtension}`),t},Fe=e=>{let t=e?s.dirname(e):process.cwd();for(;t!==s.dirname(t);){let e=s.join(t,`package.json`);if(o.existsSync(e))try{let t=JSON.parse(o.readFileSync(e,`utf8`));return{...t.dependencies,...t.devDependencies,...t.peerDependencies,...t.optionalDependencies}}catch{}let n=s.dirname(t);if(n===t)break;t=n}return{}},Ie=[`after`,`before`,`cursor`,`offset`,`page`,`start`],Le=e=>y({defaultValue:{hooks:{},pagination:{keywords:Ie},transforms:{enums:{case:`PascalCase`,enabled:!1,mode:`root`,name:`{{name}}Enum`},propertiesRequiredByDefault:!1,readWrite:{enabled:!0,requests:{case:`preserve`,name:`{{name}}Writable`},responses:{case:`preserve`,name:`{{name}}`}}},validate_EXPERIMENTAL:!1},mappers:{object:(e,t)=>({...e,pagination:y({defaultValue:{...t.pagination},value:e.pagination}),transforms:y({defaultValue:{...t.transforms},mappers:{object:(e,t)=>({...e,enums:y({defaultValue:{...t.enums,enabled:e.enums===void 0?t.enums.enabled:!!e.enums},mappers:{boolean:e=>({enabled:e}),string:e=>({mode:e})},value:e.enums}),propertiesRequiredByDefault:e.propertiesRequiredByDefault===void 0?t.propertiesRequiredByDefault:e.propertiesRequiredByDefault,readWrite:y({defaultValue:{...t.readWrite,enabled:e.readWrite===void 0?t.readWrite.enabled:!!e.readWrite},mappers:{boolean:e=>({enabled:e}),object:(e,t)=>({...e,requests:y({defaultValue:{...t.requests},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.requests}),responses:y({defaultValue:{...t.responses},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.responses})})},value:e.readWrite})})},value:e.transforms}),validate_EXPERIMENTAL:e.validate_EXPERIMENTAL===!0?`warn`:e.validate_EXPERIMENTAL})},value:e.parser}),Re=e=>t=>({...e,config:{...e.config,...t}}),b={boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},ze=/[\p{Lu}]/u,Be=/[\p{Ll}]/u,Ve=/([\p{Alpha}\p{N}_]|$)/u,He=/[_.\- `\\[\]{}\\/]+/,Ue=RegExp(`^${He.source}`),We=RegExp(`${He.source}${Ve.source}`,`gu`),Ge=RegExp(`\\d+${Ve.source}`,`gu`),Ke=({case:e,string:t})=>{let n=!1,r=!1,i=!1,a=!1,o=e===`snake_case`||e===`SCREAMING_SNAKE_CASE`?`_`:`-`;for(let e=0;e<t.length;e++){let s=t[e];a=e>2?t[e-3]===o:!0;let c=e+1,l=t[c];for(He.lastIndex=0;l&&He.test(l);)c+=1,l=t[c];let u=c!==e+1;if(Be.lastIndex=0,ze.lastIndex=0,ze.test(s)&&(n||l&&!u&&l!==`s`&&Be.test(l)))t=`${t.slice(0,e)}${o}${t.slice(e)}`,e++,i=r,n=!1,r=!0;else if(r&&i&&Be.test(s)&&!a&&!(s===`s`&&(!l||l.toLocaleLowerCase()!==l)))t=`${t.slice(0,e-1)}${o}${t.slice(e-1)}`,i=r,n=!0,r=!1;else{let e=s.toLocaleLowerCase(),t=s.toLocaleUpperCase();i=r,n=e===s&&t!==s,r=t===s&&e!==s}}return t},x=({case:e,stripLeadingSeparators:t=!0,value:n})=>{let r=n.trim();return r.length?!e||e===`preserve`?r:r.length===1?(He.lastIndex=0,He.test(r)?``:e===`PascalCase`||e===`SCREAMING_SNAKE_CASE`?r.toLocaleUpperCase():r.toLocaleLowerCase()):(r!==r.toLocaleLowerCase()&&(r=Ke({case:e,string:r})),(t||r[0]!==n[0])&&(r=r.replace(Ue,``)),r=e===`SCREAMING_SNAKE_CASE`?r.toLocaleUpperCase():r.toLocaleLowerCase(),e===`PascalCase`&&(r=`${r.charAt(0).toLocaleUpperCase()}${r.slice(1)}`),e===`snake_case`||e===`SCREAMING_SNAKE_CASE`?(r=r.replaceAll(We,(e,n,r)=>r===0&&!t?e:`_${n}`),r[r.length-1]===`_`&&(r=r.slice(0,r.length-1))):(We.lastIndex=0,Ge.lastIndex=0,r=r.replaceAll(Ge,(e,t,n)=>[`_`,`-`,`.`].includes(r.charAt(n+e.length))?e:e.toLocaleUpperCase()),r=r.replaceAll(We,(e,r,i)=>i===0&&!t&&e[0]&&n.startsWith(e[0])?e:r.toLocaleUpperCase())),r):``},S=({config:e,name:t})=>{if(typeof e.name==`function`)t=e.name(t);else if(e.name){let n=e.case===`preserve`?``:`-`;t=e.name.replace(`{{name}}`,`${n}${t}${n}`)}return x({case:e.case,value:t})},qe=({context:e,parameter:t})=>{if(!t.pagination)return;if(t.pagination===!0)return t.schema;let n=t.schema;return n.$ref&&(n=e.resolveIrRef(n.$ref)),n.properties[t.pagination]},Je=e=>{for(let t in e)if(e[t].required)return!0;return!1},Ye=e=>e?!!(Je(e.cookie)||Je(e.header)||Je(e.path)||Je(e.query)):!1,Xe=({context:e,parameters:t})=>{if(t){for(let n in t.cookie){let r=t.cookie[n];if(r.pagination)return{in:r.location,name:r.pagination===!0?r.name:`${r.name}.${r.pagination}`,schema:qe({context:e,parameter:r})}}for(let n in t.header){let r=t.header[n];if(r.pagination)return{in:r.location,name:r.pagination===!0?r.name:`${r.name}.${r.pagination}`,schema:qe({context:e,parameter:r})}}for(let n in t.path){let r=t.path[n];if(r.pagination)return{in:r.location,name:r.pagination===!0?r.name:`${r.name}.${r.pagination}`,schema:qe({context:e,parameter:r})}}for(let n in t.query){let r=t.query[n];if(r.pagination)return{in:r.location,name:r.pagination===!0?r.name:`${r.name}.${r.pagination}`,schema:qe({context:e,parameter:r})}}}},C=({detectFormat:e=!0,schema:t})=>{if(!t.items)return t;let n=[],r=[];for(let i of t.items){if(!i.type&&i.items||t.type===`tuple`){n.push(i);continue}if(!i.type||i.type===`boolean`||i.type===`integer`||i.type===`null`||i.type===`number`||i.type===`string`||i.type===`unknown`||i.type===`void`){let t=i.const===void 0?``:`const-${i.const}`,a=i.format!==void 0&&e?`format-${i.format}`:``,o=[i.minLength===void 0?``:`minLength-${i.minLength}`,i.maxLength===void 0?``:`maxLength-${i.maxLength}`,i.minimum===void 0?``:`minimum-${i.minimum}`,i.maximum===void 0?``:`maximum-${i.maximum}`,i.exclusiveMinimum===void 0?``:`exclusiveMinimum-${i.exclusiveMinimum}`,i.exclusiveMaximum===void 0?``:`exclusiveMaximum-${i.exclusiveMaximum}`,i.minItems===void 0?``:`minItems-${i.minItems}`,i.maxItems===void 0?``:`maxItems-${i.maxItems}`,i.pattern===void 0?``:`pattern-${i.pattern}`].join(``),s=`${i.$ref??``}${i.type??``}${t}${a}${o}`;r.includes(s)||(r.push(s),n.push(i));continue}n.push(i)}let i={...t};if(i.items=n,i.items.length<=1&&i.type!==`array`&&i.type!==`enum`&&i.type!==`tuple`){let e=i.items[0];delete i.logicalOperator,delete i.items,i={...i,...e}}return i.type===`unknown`?{}:i},w=({items:e,logicalOperator:t=`or`,mutateSchemaOneItem:n=!1,schema:r})=>e.length?r.type===`tuple`?(r.items=e,r):e.length===1?n?(r={...r,...e[0]},r):(r.items=e,r):(r.items=e,r.logicalOperator=t,r):r,Ze=e=>!!(Ye(e.parameters)||e.body?.required),T=({method:e,path:t})=>`${e.toUpperCase()} ${t}`,Qe=({context:e,operation:t})=>{let n=t.body;if(!n||!n.pagination)return Xe({context:e,parameters:t.parameters});if(n.pagination===!0)return{in:`body`,name:`body`,schema:n.schema};let r=n.schema,i=r.$ref?e.resolveIrRef(r.$ref):r,a=(`schema`in i?i.schema:i)?.properties?.[n.pagination];return a?{in:`body`,name:n.pagination,schema:a}:Xe({context:e,parameters:t.parameters})},$e=({statusCode:e})=>{switch(e){case`1XX`:return`1XX`;case`2XX`:return`2XX`;case`3XX`:return`3XX`;case`4XX`:return`4XX`;case`5XX`:return`5XX`;case`default`:return`default`;default:return`${e[0]}XX`}},et=e=>{let t={};if(!e.responses)return t;let n={properties:{},type:`object`},r={properties:{},type:`object`},i;for(let t in e.responses){let a=e.responses[t];switch($e({statusCode:t})){case`1XX`:case`3XX`:break;case`2XX`:r.properties[t]=a.schema;break;case`4XX`:case`5XX`:n.properties[t]=a.schema;break;case`default`:i=a;break}}if(i){let e=!1;Object.keys(r.properties).length||(r.properties.default=i.schema,e=!0);let t=(i.schema.description??``).toLocaleLowerCase(),a=(i.schema.$ref??``).toLocaleLowerCase();[`success`].some(e=>t.includes(e)||a.includes(e))&&(r.properties.default=i.schema,e=!0),[`error`,`problem`].some(e=>t.includes(e)||a.includes(e))&&(n.properties.default=i.schema,e=!0),e||(n.properties.default=i.schema)}let a=Object.keys(n.properties);if(a.length){n.required=a,t.errors=n;let e=w({items:Object.values(n.properties),mutateSchemaOneItem:!0,schema:{}});e=C({schema:e}),Object.keys(e).length&&e.type!==`unknown`&&(t.error=e)}let o=Object.keys(r.properties);if(o.length){r.required=o,t.responses=r;let e=w({items:Object.values(r.properties),mutateSchemaOneItem:!0,schema:{}});e=C({schema:e}),Object.keys(e).length&&e.type!==`unknown`&&(t.response=e)}return t},tt=e=>e.replace(/^[^\p{ID_Start}]+/u,``).replace(/[^$\u200c\u200d\p{ID_Continue}]/gu,`-`).replace(/[$+]/g,`-`),nt=e=>{let t=E(e);return t.name===`@hey-api/client-axios`||t.name===`@hey-api/client-nuxt`?`baseURL`:`baseUrl`},E=e=>{for(let t of e.pluginOrder){let n=e.plugins[t];if(n?.tags?.includes(`client`))return n}return{config:{name:``},name:``}},D=e=>({value:e}),O=e=>{let t={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=D(e[n]));return t},rt=/^[^$_\p{ID_Start}]+/u,k=/^-?\d+(\.\d+)?$/,it=/^(document|history|location|navigator|window)$/g,at=/^(console|Array|Date|Error|Function|JSON|Map|Math|Object|Promise|RegExp|Set|WeakMap|WeakSet)$/g,ot=/^(arguments|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|eval|export|extends|false|finally|for|from|function|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)$/g,st=/^(global|process|Buffer)$/g,ct=/^(any|as|bigint|boolean|namespace|never|null|number|string|symbol|type|undefined|unknown|void)$/g,lt=/^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u,ut=e=>(e||e===``)&&(lt.lastIndex=0,!lt.test(e))?`'${e}'`:e,dt=e=>e&&e.startsWith(`'`)&&e.endsWith(`'`)?e.slice(1,e.length-1):e,ft=e=>e.replace(/\*\//g,`*`).replace(/\/\*/g,`*`).replace(/\r?\n(.*)/g,(e,t)=>u+t.trim()),pt=l.createPrinter({newLine:l.NewLineKind.LineFeed,removeComments:!1}),mt=(e=>l.createSourceFile(``,e,l.ScriptTarget.ESNext,!1,l.ScriptKind.TS))(``),ht=e=>e.replace(/\\u([0-9a-fA-F]{4})/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16)));function gt({node:e,unescape:t=!1}){let n=pt.printNode(l.EmitHint.Unspecified,e,mt);if(!t)return n;try{return ht(n)}catch{return n}}const A=e=>l.factory.createIdentifier(typeof e==`string`?e:e.text),_t=e=>{switch(e){case`!`:return l.SyntaxKind.ExclamationToken;case`-`:return l.SyntaxKind.MinusToken}},vt=({expression:e,prefix:t})=>{let n=typeof e==`string`?A(e):e,r=typeof t==`string`?_t(t):t;return l.factory.createPrefixUnaryExpression(r,n)},yt=()=>l.factory.createThis(),j=({keyword:e})=>{let t=At({keyword:e});return l.factory.createModifier(t)},bt=({initializer:e,modifiers:t,name:n,type:r})=>{let i=Array.isArray(t)?t:[t];return l.factory.createPropertyDeclaration(t?i.map(e=>j({keyword:e})):void 0,n,void 0,r,e)},xt={boolean:e=>e?l.factory.createTrue():l.factory.createFalse(),export:({alias:e,asType:t=!1,name:n})=>{let r=A(n);if(e){let n=A(e);return l.factory.createExportSpecifier(t,r,n)}return l.factory.createExportSpecifier(t,void 0,r)},import:({alias:e,asType:t=!1,name:n})=>{let r=A(n);if(e){let n=A(e);return l.factory.createImportSpecifier(t,r,n)}return l.factory.createImportSpecifier(t,void 0,r)},number:e=>e<0?vt({expression:l.factory.createNumericLiteral(Math.abs(e)),prefix:`-`}):l.factory.createNumericLiteral(e),string:(e,t=!1)=>{let n=e;t&&(n=dt(n));let r=n.includes(`'`)&&n.includes(`"`),i=n.includes(`
|
|
2
|
-
`),a=n.startsWith("`"),o=n.startsWith("\\`")&&n.endsWith("\\`");return(i||r||a)&&!o&&(n=`\`${n.replace(/(?<!\\)`/g,"\\`").replace(/\${/g,"\\${")}\``),n.startsWith("`")?A(n):Jt({text:n})}},St=e=>typeof e==`object`&&!!e&&typeof e.kind==`number`&&typeof e.flags==`number`&&typeof e.pos==`number`&&typeof e.end==`number`,Ct=e=>e!==void 0,wt=({commentObject:e,node:t})=>{let n=e.lines.filter(e=>!!e||e===``);if(!n.length)return;if(!e.jsdoc){for(let e of n)l.addSyntheticLeadingComment(t,l.SyntaxKind.SingleLineCommentTrivia,` ${e}`,!0);return}let r=n.map((e,t)=>{let r=e;return t!==n.length&&(r=`${r}\n`),l.factory.createJSDocText(r)}),i=gt({node:l.factory.createJSDocComment(l.factory.createNodeArray(r),void 0),unescape:!0}).replace(`/*`,``).replace(`* */`,``);l.addSyntheticLeadingComment(t,l.SyntaxKind.MultiLineCommentTrivia,i,!0)},M=({comments:e=[],node:t})=>{let n=!!e.find(e=>typeof e==`object`&&e),r=e;n||(r=[{jsdoc:!0,lines:e}]);for(let e of r)wt({commentObject:e,node:t})},N=(e,t)=>l.isTypeNode(e)?e:typeof e==`number`?l.factory.createLiteralTypeNode(xt.number(e)):Qt({typeArguments:t?.map(e=>N(e)),typeName:l.isIdentifier(e)?e.text:e}),Tt=({expression:e,name:t})=>l.factory.createPropertyAccessChain(e,l.factory.createToken(l.SyntaxKind.QuestionDotToken),t),Et=({expression:e,isOptional:t,name:n})=>{let r=typeof e==`string`?A({text:e}):e;if(t&&typeof n!=`number`)return Tt({expression:r,name:n});if(typeof n==`string`){if(lt.lastIndex=0,!lt.test(n)){!n.startsWith(`'`)&&!n.endsWith(`'`)&&(n=`\'${n}\'`);let e=A({text:n});return l.factory.createElementAccessExpression(r,e)}let e=A({text:n});return l.factory.createPropertyAccessExpression(r,e)}if(typeof n==`number`){let e=l.factory.createNumericLiteral(n);return l.factory.createElementAccessExpression(r,e)}return l.factory.createPropertyAccessExpression(r,n)},Dt=()=>l.factory.createNull(),Ot=({identifiers:e=[],isValueAccess:t,shorthand:n,unescape:r,value:i})=>{if(i===null)return Dt();if(Array.isArray(i))return zt({elements:i});if(typeof i==`object`)return Ht({identifiers:e,obj:i,shorthand:n});if(typeof i==`number`)return xt.number(i);if(typeof i==`boolean`)return xt.boolean(i);if(typeof i==`string`){if(t){let e=i.split(`.`);return Et({expression:e[0],name:e[1]})}return xt.string(i,r)}},kt=e=>e.map(e=>{if(`destructure`in e)return en({name:l.factory.createObjectBindingPattern(e.destructure.map(e=>{if(!(`destructure`in e))return l.factory.createBindingElement(void 0,void 0,A({text:e.name}),void 0)}).filter(Boolean)),type:e.type===void 0?void 0:N(e.type)});let t=e.accessLevel?[j({keyword:e.accessLevel})]:[];return e.isReadOnly&&t.push(j({keyword:`readonly`})),en({initializer:e.default===void 0?void 0:Ot({value:e.default}),modifiers:t,name:A({text:e.name}),required:e.isRequired!==!1,type:e.type===void 0?void 0:N(e.type)})}),At=({keyword:e})=>{switch(e){case`any`:return l.SyntaxKind.AnyKeyword;case`async`:return l.SyntaxKind.AsyncKeyword;case`boolean`:return l.SyntaxKind.BooleanKeyword;case`export`:return l.SyntaxKind.ExportKeyword;case`never`:return l.SyntaxKind.NeverKeyword;case`number`:return l.SyntaxKind.NumberKeyword;case`private`:return l.SyntaxKind.PrivateKeyword;case`protected`:return l.SyntaxKind.ProtectedKeyword;case`public`:return l.SyntaxKind.PublicKeyword;case`readonly`:return l.SyntaxKind.ReadonlyKeyword;case`static`:return l.SyntaxKind.StaticKeyword;case`string`:return l.SyntaxKind.StringKeyword;case`undefined`:return l.SyntaxKind.UndefinedKeyword;case`unknown`:return l.SyntaxKind.UnknownKeyword;case`void`:return l.SyntaxKind.VoidKeyword;default:throw Error(`unsupported syntax kind keyword "${e}"`)}},jt=({keyword:e})=>{let t=At({keyword:e});return l.factory.createKeywordTypeNode(t)},Mt=e=>e.map(e=>l.isTypeParameterDeclaration(e)?e:Pt({constraint:e.extends?typeof e.extends==`string`?jt({keyword:`boolean`}):e.extends:void 0,defaultType:e.default===void 0?void 0:St(e.default)?e.default:l.factory.createLiteralTypeNode(e.default?l.factory.createTrue():l.factory.createFalse()),name:e.name})),Nt=({operator:e,type:t})=>{let n=e===`keyof`?l.SyntaxKind.KeyOfKeyword:e===`readonly`?l.SyntaxKind.ReadonlyKeyword:l.SyntaxKind.UniqueKeyword;return l.factory.createTypeOperatorNode(n,t)},Pt=({constraint:e,defaultType:t,modifiers:n,name:r})=>l.factory.createTypeParameterDeclaration(n,r,e,t),Ft=({members:e,nameType:t,questionToken:n,readonlyToken:r,type:i,typeParameter:a})=>l.factory.createMappedTypeNode(r,a,t,n,i,e),It=({literal:e})=>l.factory.createLiteralTypeNode(e),Lt=({async:e,comment:t,multiLine:n,parameters:r=[],returnType:i,statements:a=[],types:o=[]})=>{let s=l.factory.createArrowFunction(e?[j({keyword:`async`})]:void 0,o?Mt(o):void 0,kt(r),i?N(i):void 0,void 0,Array.isArray(a)?P({multiLine:n,statements:a}):a);return M({comments:t,node:s}),s},Rt=({async:e,comment:t,multiLine:n,parameters:r=[],returnType:i,statements:a=[],types:o=[]})=>{let s=l.factory.createFunctionExpression(e?[j({keyword:`async`})]:void 0,void 0,void 0,o?Mt(o):void 0,kt(r),i?N(i):void 0,P({multiLine:n,statements:a}));return M({comments:t,node:s}),s},zt=({elements:e,multiLine:t=!1})=>l.factory.createArrayLiteralExpression(e.map(e=>St(e)?e:Ot({value:e})).filter(Ct),t||!Array.isArray(e[0])&&typeof e[0]==`object`),Bt=({expression:e})=>l.factory.createAwaitExpression(e),Vt=({parameters:e=[],returnType:t,typeParameters:n})=>l.factory.createFunctionTypeNode(n,e,t),Ht=({comments:e,identifiers:t=[],multiLine:n=!0,obj:r,shorthand:i,unescape:a=!1})=>{let o=Array.isArray(r)?r.map(e=>{let r=!1;if(`key`in e){let{key:t}=e;r=t===e.value,(t.match(/^[0-9]/)&&t.match(/\D+/g)||t.match(/\W/g)||t===``)&&!t.startsWith(`'`)&&!t.endsWith(`'`)&&(e.key=`'${t}'`)}let o;if(`spread`in e){let t=St(e.spread)?e.spread:A({text:e.spread});o=l.factory.createSpreadAssignment(e.assertion?sn({expression:t,type:typeof e.assertion==`string`?jt({keyword:e.assertion}):e.assertion}):t)}else if(e.shorthand||i&&r)o=l.factory.createShorthandPropertyAssignment(e.value);else{let r=St(e.value)?e.value:Array.isArray(e.value)&&(!e.value.length||typeof e.value[0]==`object`)?Ht({multiLine:n,obj:e.value,shorthand:i,unescape:a}):Ot({identifiers:t.includes(e.key)?Object.keys(e.value):[],isValueAccess:e.isValueAccess,shorthand:i,unescape:a,value:e.value});if(!r)return;t.includes(e.key)&&!l.isObjectLiteralExpression(r)&&(r=A({text:e.value})),o=an({initializer:r,name:e.key})}return M({comments:e.comments,node:o}),o}).filter(Ct):Object.entries(r).map(([e,n])=>{let r=Ot({identifiers:t.includes(e)?Object.keys(n):[],shorthand:i,unescape:a,value:n});if(!r)return;t.includes(e)&&!l.isObjectLiteralExpression(r)&&(r=A({text:n}));let o=e===n;return e.match(/^[0-9]/)&&e.match(/\D+/g)&&!e.startsWith(`'`)&&!e.endsWith(`'`)&&(e=`'${e}'`),e.match(/\W/g)&&!e.startsWith(`'`)&&!e.endsWith(`'`)&&(e=`'${e}'`),i&&o?l.factory.createShorthandPropertyAssignment(n):an({initializer:r,name:e})}).filter(Ct),s=l.factory.createObjectLiteralExpression(o,n);return M({comments:e,node:s}),s},Ut=({asConst:e,comments:t={},leadingComment:n,name:r,obj:i})=>{let a=Array.isArray(i)?i.map(e=>{let t=Wt({initializer:Ot({value:e.value}),name:e.key});return M({comments:e.comments,node:t}),t}):Object.entries(i).map(([e,n])=>{let r=l.factory.createEnumMember(e,Ot({unescape:!0,value:n}));return M({comments:t[e],node:r}),r}),o=[j({keyword:`export`})],s=e?[l.factory.createToken(l.SyntaxKind.ConstKeyword)]:[],c=[...o,...s],u=l.factory.createEnumDeclaration(c,typeof r==`string`?A({text:r}):r,a);return M({comments:n,node:u}),u},Wt=({initializer:e,name:t})=>{let n=t;return typeof n==`string`&&(n=n.includes(`'`)?Jt({isSingleQuote:!1,text:n}):ut(n)),l.factory.createEnumMember(n,e)},Gt=({name:e,statements:t})=>l.factory.createModuleDeclaration([j({keyword:`export`})],A({text:e}),l.factory.createModuleBlock(t),l.NodeFlags.Namespace),Kt=({indexType:e,objectType:t})=>l.factory.createIndexedAccessTypeNode(t,e),qt=({modifiers:e,name:t,returnType:n,statements:r})=>{let i=Array.isArray(e)?e:[e];return l.factory.createGetAccessorDeclaration(e?i.map(e=>j({keyword:e})):void 0,t,[],n?Qt({typeName:n}):void 0,P({statements:r}))},Jt=({isSingleQuote:e,text:t})=>(e===void 0&&(e=!t.includes(`'`)),l.factory.createStringLiteral(t,e)),Yt=({condition:e,whenFalse:t,whenTrue:n})=>l.factory.createConditionalExpression(e,l.factory.createToken(l.SyntaxKind.QuestionToken),n,l.factory.createToken(l.SyntaxKind.ColonToken),t),Xt=({text:e})=>l.factory.createTypeOfExpression(typeof e==`string`?A({text:e}):e),Zt=({comment:e,exportType:t,name:n,type:r,typeParameters:i=[]})=>{let a=l.factory.createTypeAliasDeclaration(t?[j({keyword:`export`})]:void 0,typeof n==`string`?A({text:n}):n,Mt(i),N(r));return M({comments:e,node:a}),a},Qt=({typeArguments:e,typeName:t})=>l.factory.createTypeReferenceNode(t,e),$t=({type:e})=>l.factory.createParenthesizedType(e),en=({initializer:e,modifiers:t,name:n,required:r=!0,type:i})=>l.factory.createParameterDeclaration(t,void 0,n,r?void 0:l.factory.createToken(l.SyntaxKind.QuestionToken),i,e),tn=({argumentsArray:e,expression:t,typeArguments:n})=>l.factory.createNewExpression(t,n,e),nn=({awaitModifier:e,expression:t,initializer:n,statement:r})=>l.factory.createForOfStatement(e,n,t,r),rn=({left:e,right:t})=>l.factory.createAssignment(e,t),P=({multiLine:e=!0,statements:t})=>l.factory.createBlock(t,e),an=({initializer:e,name:t})=>l.factory.createPropertyAssignment(t,e),on=({flags:e=[],text:t})=>{let n=`/${(t.startsWith(`/`)&&t.endsWith(`/`)?t.slice(1,-1):t).replace(/(?<!\\)\//g,`\\/`)}/`;return l.factory.createRegularExpressionLiteral(`${n}${e.join(``)}`)},sn=({expression:e,type:t})=>l.factory.createAsExpression(e,t),cn=({value:e})=>{let t=[],n=``;for(let r of e.slice(0).reverse())if(typeof r==`string`)n=`${r}${n}`;else{let e=t.length?l.factory.createTemplateMiddle(n):l.factory.createTemplateTail(n),i=l.factory.createTemplateLiteralTypeSpan(r,e);t.push(i),n=``}return l.factory.createTemplateLiteralType(l.factory.createTemplateHead(n),t.reverse())},ln=({module:e,shouldAppendJs:t})=>l.factory.createExportDeclaration(void 0,!1,void 0,xt.string(t?`${e}.js`:e)),un=({functionName:e,parameters:t=[],types:n})=>{let r=typeof e==`string`?A({text:e}):e,i=t.filter(e=>e!==void 0).map(e=>typeof e==`string`?A({text:e}):e);return l.factory.createCallExpression(r,n,i)},dn=({exports:e,module:t})=>{let n=Array.isArray(e)?e:[e],r=n.some(e=>typeof e!=`object`||!e.asType),i=n.map(e=>{let t=typeof e==`string`?{name:e}:e;return xt.export({alias:t.alias,asType:r&&t.asType,name:t.name})}),a=l.factory.createNamedExports(i),o=xt.string(t);return l.factory.createExportDeclaration(void 0,!r,a,o)},fn=({assertion:e,comment:t,destructure:n,exportConst:r,expression:i,name:a,typeName:o})=>{let s=e?sn({expression:i,type:typeof e==`string`?Qt({typeName:e}):e}):i,c=typeof a==`string`?A({text:a}):a,u=l.factory.createVariableDeclaration(n?l.factory.createObjectBindingPattern([l.factory.createBindingElement(void 0,void 0,c,void 0)]):c,void 0,o?typeof o==`string`?Qt({typeName:o}):o:void 0,s),d=l.factory.createVariableStatement(r?[j({keyword:`export`})]:void 0,l.factory.createVariableDeclarationList([u],l.NodeFlags.Const));return M({comments:t,node:d}),d},pn=({imports:e,module:t})=>{let n=Array.isArray(e)?e:[e],r=n.some(e=>typeof e!=`object`||!e.asType),i,a=[];n.forEach(e=>{let t=typeof e==`string`?{name:e}:e;t.name===`*`&&t.alias?i=t:a.push(xt.import({alias:t.alias,asType:r&&t.asType,name:t.name}))});let o=i?l.factory.createNamespaceImport(A({text:i.alias})):l.factory.createNamedImports(a),s=l.factory.createImportClause(!r,void 0,o),c=xt.string(t);return l.factory.createImportDeclaration(void 0,s,c)},mn=({accessLevel:e,comment:t,multiLine:n=!0,parameters:r=[],statements:i=[]})=>{let a=e?[j({keyword:e})]:void 0,o=l.factory.createConstructorDeclaration(a,kt(r),P({multiLine:n,statements:i}));return M({comments:t,node:o}),o},hn=({accessLevel:e,comment:t,isStatic:n=!1,multiLine:r=!0,name:i,parameters:a=[],returnType:o,statements:s=[],types:c=[]})=>{let u=e?[j({keyword:e})]:[];n&&u.push(j({keyword:`static`}));let d=l.factory.createMethodDeclaration(u,void 0,A({text:i}),void 0,c?Mt(c):void 0,kt(a),o?N(o):void 0,P({multiLine:r,statements:s}));return M({comments:t,node:d}),d},gn=({decorator:e,exportClass:t,extendedClasses:n,name:r,nodes:i,typeParameters:a})=>{let o=[];t&&o.push(j({keyword:`export`})),e&&o.unshift(l.factory.createDecorator(un({functionName:e.name,parameters:e.args.map(e=>Ot({value:e})).filter(Ct)})));let s=[];if(n)for(let e of n)s.push(l.factory.createHeritageClause(l.SyntaxKind.ExtendsKeyword,[l.factory.createExpressionWithTypeArguments(A({text:e}),void 0)]));return l.factory.createClassDeclaration(o,A({text:r}),a,s,i)},_n=({expression:e})=>l.factory.createExpressionStatement(e),vn=({expression:e})=>l.factory.createReturnStatement(e),yn=({args:e=[],name:t,types:n=[]})=>{let r=n.map(e=>Qt({typeName:e}));return vn({expression:un({functionName:t,parameters:e.map(e=>l.isExpression(e)?e:A({text:e})).filter(Ct),types:r})})},bn=({expression:e})=>vn({expression:typeof e==`string`?A({text:e}):e}),xn=e=>e.slice(1).reduce((e,t)=>(lt.lastIndex=0,lt.test(t)?Tt({expression:e,name:t}):l.factory.createElementAccessChain(e,l.factory.createToken(l.SyntaxKind.QuestionDotToken),A({text:t}))),A({text:e[0]})),Sn=e=>e.slice(1).reduce((e,t)=>Et({expression:e,name:t}),A({text:e[0]})),Cn=({expressions:e})=>e.reduce((e,t)=>Et({expression:e,name:t})),wn=({left:e,operator:t=`=`,right:n})=>l.factory.createBinaryExpression(e,t===`=`?l.SyntaxKind.EqualsToken:t===`===`?l.SyntaxKind.EqualsEqualsEqualsToken:t===`!==`?l.SyntaxKind.ExclamationEqualsEqualsToken:t===`??`?l.SyntaxKind.QuestionQuestionToken:l.SyntaxKind.InKeyword,typeof n==`string`?A({text:n}):n),Tn=({elseStatement:e,expression:t,thenStatement:n})=>l.factory.createIfStatement(t,n,e),En=({path:e})=>{let t=xn(e),n=Sn(e);return Tn({expression:t,thenStatement:P({statements:[_n({expression:wn({left:n,right:tn({argumentsArray:[n],expression:A({text:`Date`})})})})]})})},Dn=({path:e,transformerName:t})=>[Tn({expression:xn(e),thenStatement:P({statements:[_n({expression:un({functionName:t,parameters:[Sn(e)]})})]})})],On=({path:e,transformerName:t})=>{let n=xn(e),r=Sn(e);return Tn({expression:un({functionName:Et({expression:`Array`,name:`isArray`}),parameters:[n]}),thenStatement:P({statements:[_n({expression:l.factory.createCallChain(Et({expression:r,name:`forEach`}),void 0,void 0,[A({text:t})])})]})})},kn=({parameterName:e})=>{let t=A({text:`Date`});return tn({argumentsArray:[A({text:e})],expression:t})},An=({path:e,transformExpression:t})=>{let n=xn(e),r=Sn(e);return Tn({expression:un({functionName:Et({expression:`Array`,name:`isArray`}),parameters:[n]}),thenStatement:P({statements:[_n({expression:wn({left:r,right:l.factory.createCallChain(Et({expression:r,name:`map`}),void 0,void 0,[Lt({parameters:[{name:`item`}],statements:t})])})})]})})},jn=Qt({typeName:`null`}),Mn=({isNullable:e,node:t})=>e?l.factory.createUnionTypeNode([t,jn]):t,Nn=({indexKey:e,indexProperty:t,isNullable:n,properties:r,useLegacyResolution:i})=>{let a=[],o=r.map(e=>{let t=e.isReadOnly?[j({keyword:`readonly`})]:void 0,n=e.isRequired===!1?l.factory.createToken(l.SyntaxKind.QuestionToken):void 0,r=N(e.type);a.push(r);let o=l.factory.createPropertySignature(t,i||typeof e.name==`string`&&e.name.match(lt)||typeof e.name!=`string`&&l.isPropertyName(e.name)?e.name:Jt({text:e.name}),n,r);return M({comments:e.comment,node:o}),o}),s=!1;if(t)if(!r.length&&e){let n=Ft({questionToken:l.factory.createToken(l.SyntaxKind.QuestionToken),type:t.type??jt({keyword:`string`}),typeParameter:Pt({constraint:e,name:A({text:String(t.name)})})});o.push(n),s=!0}else{let e=t.isReadOnly?[j({keyword:`readonly`})]:void 0,n=l.factory.createIndexSignature(e,[en({name:A({text:String(t.name)}),type:jt({keyword:`string`})})],N(t.type));o.push(n)}return Mn({isNullable:n,node:s?o[0]:l.factory.createTypeLiteralNode(o)})},Pn=({isNullable:e,types:t})=>{let n=[];for(let e of t){let t=N(e);l.isUnionTypeNode(t)?n.push(...t.types):n.push(t)}return Mn({isNullable:e,node:l.factory.createUnionTypeNode(n)})},F={anonymousFunction:Rt,arrayLiteralExpression:zt,arrowFunction:Lt,asExpression:sn,assignment:rn,awaitExpression:Bt,binaryExpression:wn,block:P,callExpression:un,classDeclaration:gn,conditionalExpression:Yt,constVariable:fn,constructorDeclaration:mn,enumDeclaration:Ut,exportAllDeclaration:ln,exportNamedDeclaration:dn,expressionToStatement:_n,forOfStatement:nn,functionTypeNode:Vt,getAccessorDeclaration:qt,identifier:A,ifStatement:Tn,indexedAccessTypeNode:Kt,isTsNode:St,keywordTypeNode:jt,literalTypeNode:It,mappedTypeNode:Ft,methodDeclaration:hn,namedImportDeclarations:pn,namespaceDeclaration:Gt,newExpression:tn,nodeToString:gt,null:Dt,objectExpression:Ht,ots:xt,parameterDeclaration:en,prefixUnaryExpression:vt,propertyAccessExpression:Et,propertyAccessExpressions:Cn,propertyAssignment:an,propertyDeclaration:bt,regularExpressionLiteral:on,returnFunctionCall:yn,returnStatement:vn,returnVariable:bn,safeAccessExpression:xn,stringLiteral:Jt,templateLiteralType:cn,this:yt,transformArrayMap:An,transformArrayMutation:On,transformDateMutation:En,transformFunctionMutation:Dn,transformNewDate:kn,typeAliasDeclaration:Zt,typeArrayNode:(e,t=!1)=>Mn({isNullable:t,node:Qt({typeArguments:[Array.isArray(e)?Pn({types:e}):e],typeName:`Array`})}),typeInterfaceNode:Nn,typeIntersectionNode:({isNullable:e,types:t})=>{let n=[];for(let e of t){let t=N(e);l.isIntersectionTypeNode(t)?n.push(...t.types):n.push(t)}return Mn({isNullable:e,node:l.factory.createIntersectionTypeNode(n)})},typeNode:N,typeOfExpression:Xt,typeOperatorNode:Nt,typeParameterDeclaration:Pt,typeParenthesizedNode:$t,typeRecordNode:(e,t,n=!1,r=!0)=>{let i=Pn({types:e}),a=Pn({types:t});return Mn({isNullable:n,node:Nn({properties:[{name:`[key: ${gt({node:i,unescape:!0})}]`,type:a}],useLegacyResolution:r})})},typeReferenceNode:Qt,typeTupleNode:({isNullable:e=!1,types:t})=>{let n=t.map(e=>N(e));return Mn({isNullable:e,node:l.factory.createTupleTypeNode(n)})},typeUnionNode:Pn,valueToExpression:Ot},Fn=F,In=({config:e,name:t})=>{let n=e.plugins[`@hey-api/sdk`];if(n?.config.classNameBuilder){let e=``;return e=typeof n.config.classNameBuilder==`function`?n.config.classNameBuilder(t):n.config.classNameBuilder.replace(`{{name}}`,t),e}return t},Ln=({securitySchemeObject:e})=>{if(e.type===`openIdConnect`)return{scheme:`bearer`,type:`http`};if(e.type===`oauth2`)return e.flows.password||e.flows.authorizationCode||e.flows.clientCredentials||e.flows.implicit?{scheme:`bearer`,type:`http`}:void 0;if(e.type===`apiKey`)return e.in===`header`?{name:e.name,type:`apiKey`}:e.in===`query`||e.in==`cookie`?{in:e.in,name:e.name,type:`apiKey`}:void 0;if(e.type===`http`){let t=e.scheme.toLowerCase();return t===`bearer`||t===`basic`?{scheme:t,type:`http`}:void 0}},Rn=({operation:e,plugin:t})=>{if(!e.security||!t.config.auth)return[];let n=[];for(let t of e.security){let e=Ln({securitySchemeObject:t});e?n.push(e):console.warn(`❗️ SDK warning: unsupported security scheme. Please open an issue if you'd like it added https://github.com/hey-api/openapi-ts/issues\n${JSON.stringify(t,null,2)}`)}return n},zn=`TComposable`,Bn=`DefaultT`,Vn=`ResT`,Hn=/~1/g,Un=/~0/g,I=e=>{let t=Gn(e),n=t[t.length-1];return decodeURI(n)},Wn=e=>String(e).replace(/~/g,`~0`).replace(/\//g,`~1`),Gn=e=>{let t=e.trim();return t.startsWith(`#`)&&(t=t.slice(1)),t.startsWith(`/`)&&(t=t.slice(1)),t?t.split(`/`).map(e=>e.replace(Hn,`/`).replace(Un,`~`)):[]},Kn=e=>{let t=e.trim();return t.startsWith(`#`)||(t=`#${t}`),t.length>1&&t.endsWith(`/`)&&(t=t.slice(0,-1)),t=t.replace(/\/+/g,`/`),t},qn=e=>{let t=e.map(Wn).join(`/`);return`#`+(t?`/${t}`:``)},Jn=({$ref:e,spec:t})=>{let n=Gn(decodeURI(e)),r=t;for(let t of n){let n=t;if(r[n]===void 0)throw Error(`Reference not found: ${e}`);r=r[n]}return r},Yn=({operation:e})=>{let t=[`header`,`path`,`query`],n={},r=(e,t)=>{n[e]||(n[e]=new Set),n[e].add(t)};for(let n of t){let t=e.parameters?.[n];if(t)for(let e in t){let i=t[e];r(i.name,n)}}if(e.body)if(!e.body.schema.logicalOperator&&e.body.schema.type===`object`&&e.body.schema.properties){let t=e.body.schema.properties;for(let e in t)r(e,`body`)}else e.body.schema.$ref?r(x({case:`camelCase`,value:I(e.body.schema.$ref)}),`body`):r(`body`,`body`);let i=new Set;for(let e in n)n[e].size>1&&i.add(e);let a={},o=[];for(let n of t){let t=e.parameters?.[n];if(t)for(let e in t){let r=t[e],s=r.name,c=i.has(s)?`${n}_${s}`:s,l={isRequired:r.required??!1,name:c,schema:r.schema};c!==s&&(l.originalName=s),a[c]=l,o.push({in:n===`header`?`headers`:n,key:c,...c===s?{}:{map:s}})}}if(e.body){let t=`body`;if(!e.body.schema.logicalOperator&&e.body.schema.type===`object`&&e.body.schema.properties){let n=e.body.schema.properties;for(let e in n){let r=n[e],s=i.has(e)?`${t}_${e}`:e,c={isRequired:r.required?.includes(e)??!1,name:s,schema:r};s!==e&&(c.originalName=e),a[s]=c,o.push({in:t,key:s,...s===e?{}:{map:e}})}}else if(e.body.schema.$ref){let n=x({case:`camelCase`,value:I(e.body.schema.$ref)}),r=i.has(n)?`${t}_${n}`:n,s={isRequired:e.body.required??!1,name:r,schema:e.body.schema};r!==n&&(s.originalName=n),a[r]=s,o.push({key:r,map:`body`})}else a.body={isRequired:e.body.required??!1,name:`body`,schema:e.body.schema},o.push({in:`body`})}if(Object.keys(a).length)return{fields:o,parameters:a}},Xn=({operation:e,plugin:t})=>{if(!t.config.validator.request)return;let n=t.getPluginOrThrow(t.config.validator.request);if(n.api.createRequestValidator)return n.api.createRequestValidator({operation:e,plugin:n})},Zn=({operation:e,plugin:t})=>{if(!t.config.validator.response)return;let n=t.getPluginOrThrow(t.config.validator.response);if(n.api.createResponseValidator)return n.api.createResponseValidator({operation:e,plugin:n})},Qn=({context:e,value:t})=>{let n=x({case:`PascalCase`,value:tt(t)});return In({config:e.config,name:n})},$n=({operation:e,plugin:t})=>t.config.methodNameBuilder?t.config.methodNameBuilder(e):!t.config.asClass&&e.id.match(ot)?`${e.id}_`:e.id,er=({context:e,operation:t,plugin:n})=>{let r=new Map,i,a,o=[];n.config.classStructure===`auto`&&t.operationId&&(o=t.operationId.split(/[./]/).filter(Boolean),o.length>1&&(a=x({case:`camelCase`,value:tt(o.pop())}),i=o.pop()));let s=n.config.instance?[n.config.instance]:t.tags??[`default`];for(let c of s){let s=Qn({context:e,value:i||c}),l=[c];i&&(l=o.includes(c)||c===i?[...o,i]:[c,...o,i]),r.set(c,{className:s,methodName:a||$n({operation:t,plugin:n}),path:l.map(t=>Qn({context:e,value:t}))})}return r},tr=({isDataAllowed:e=!0,operation:t,plugin:n,throwOnError:r})=>{let i=E(n.context.config).name===`@hey-api/client-nuxt`,a=e?n.querySymbol({category:`type`,resource:`operation`,resourceId:t.id,role:`data`,tool:`typescript`}):void 0,o=n.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`});if(i){let r=n.querySymbol({category:`type`,resource:`operation`,resourceId:t.id,role:`response`}),i=e?a?.placeholder||`unknown`:`never`,s=r?.placeholder||`unknown`;return`${o.placeholder}<${zn}, ${i}, ${s}, ${Bn}>`}if(r){let t=e?a?.placeholder||`unknown`:`never`;return`${o.placeholder}<${t}, ${r}>`}let s=e?a?.placeholder:`never`;return s?`${o.placeholder}<${s}>`:o.placeholder},nr=({isRequiredOptions:e,operation:t,plugin:n})=>{let r={argNames:[],fields:[],parameters:[]},i=n.getPluginOrThrow(`@hey-api/typescript`),a=E(n.context.config).name===`@hey-api/client-nuxt`;if(n.config.paramsStructure===`flat`){let e=Yn({operation:t,plugin:n}),a=[];if(e){let t=!1;for(let n in e.parameters){let r=e.parameters[n];r.isRequired&&(t=!0),a.push({isRequired:r.isRequired,name:r.name,type:i.api.schemaToType({plugin:i,schema:r.schema,state:O({path:[]})})})}r.argNames.push(`parameters`);for(let t of e.fields)r.fields.push(t);r.parameters.push({isRequired:t,name:`parameters`,type:F.typeInterfaceNode({properties:a,useLegacyResolution:!1})})}}return r.parameters.push({isRequired:e,name:`options`,type:tr({isDataAllowed:n.config.paramsStructure===`grouped`,operation:t,plugin:n,throwOnError:a?void 0:`ThrowOnError`})}),r},rr=e=>{if(!e)return;let t=e.split(`;`)[0]?.trim();if(t){if(t.startsWith(`application/json`)||t.endsWith(`+json`))return`json`;if([`application/`,`audio/`,`image/`,`video/`].some(e=>t.startsWith(e)))return`blob`;if(t.startsWith(`text/`))return`text`}},ir=({isRequiredOptions:e,opParameters:t,operation:n,plugin:r})=>{let i=E(r.context.config),a=i.name===`@hey-api/client-nuxt`,o=r.querySymbol({category:`type`,resource:`operation`,resourceId:n.id,role:a?`response`:`responses`})?.placeholder||`unknown`,s=r.querySymbol({category:`type`,resource:`operation`,resourceId:n.id,role:a?`error`:`errors`})?.placeholder||`unknown`,c=[];if(n.body)switch(n.body.type){case`form-data`:{let e=r.referenceSymbol({category:`external`,resource:`client.formDataBodySerializer`});c.push({spread:e.placeholder});break}case`json`:break;case`text`:case`octet-stream`:c.push({key:`bodySerializer`,value:null});break;case`url-search-params`:{let e=r.referenceSymbol({category:`external`,resource:`client.urlSearchParamsBodySerializer`});c.push({spread:e.placeholder});break}}let l=[];for(let e in n.parameters?.query){let t=n.parameters.query[e];t.schema.type===`array`||t.schema.type===`tuple`?(t.style!==`form`||!t.explode)&&l.push({key:t.name,value:[{key:`array`,value:[{key:`explode`,value:t.explode===!0?void 0:t.explode},{key:`style`,value:t.style===`form`?void 0:t.style}].filter(({value:e})=>e!==void 0)}]}):t.schema.type===`object`&&(t.style!==`deepObject`||!t.explode)&&l.push({key:t.name,value:[{key:`object`,value:[{key:`explode`,value:t.explode===!0?void 0:t.explode},{key:`style`,value:t.style===`deepObject`?void 0:t.style}].filter(({value:e})=>e!==void 0)}]})}l.length&&c.push({key:`querySerializer`,value:[{key:`parameters`,value:l}]});let u=Xn({operation:n,plugin:r});if(u&&c.push({key:`requestValidator`,value:u}),r.config.transformer){let e={category:`transform`,resource:`operation`,resourceId:n.id,role:`response`};if(r.isSymbolRegistered(e)){let t=r.referenceSymbol(e);c.push({key:`responseTransformer`,value:t.placeholder})}}let d=!1,f;for(let e in n.responses){let t=n.responses[e];!f&&i.name===`@hey-api/client-axios`&&$e({statusCode:e})===`2XX`&&(f=rr(t.mediaType),f&&c.push({key:`responseType`,value:f})),t.mediaType===`text/event-stream`&&(d=!0)}let p=Zn({operation:n,plugin:r});p&&c.push({key:`responseValidator`,value:p}),r.config.responseStyle===`data`&&c.push({key:`responseStyle`,value:r.config.responseStyle});let m=Rn({context:r.context,operation:n,plugin:r});m.length&&c.push({key:`security`,value:F.arrayLiteralExpression({elements:m})}),c.push({key:`url`,value:n.path}),c.push({spread:`options`});let h=[],g=t.argNames.length;if(g){let e=[],n=[];for(let n of t.argNames)e.push(F.identifier({text:n}));for(let e of t.fields){let t=[];`in`in e&&(t.push({key:`in`,value:e.in}),e.key&&t.push({key:`key`,value:e.key}),e.map&&t.push({key:`map`,value:e.map})),n.push(F.objectExpression({obj:t}))}let i=r.referenceSymbol({category:`external`,resource:`client.buildClientParams`});h.push(F.constVariable({expression:F.callExpression({functionName:i.placeholder,parameters:[F.arrayLiteralExpression({elements:e}),F.arrayLiteralExpression({elements:n})]}),name:`params`})),c.push({spread:`params`})}if(n.body){let t=n.parameters?.header?.[`content-type`];if(!t?.required){let r=[{key:t?.name??`Content-Type`,value:n.body.type===`form-data`?null:n.body.mediaType},{spread:F.propertyAccessExpression({expression:F.identifier({text:`options`}),isOptional:!e,name:`headers`})}];g&&r.push({spread:F.propertyAccessExpression({expression:F.identifier({text:`params`}),name:`headers`})}),c.push({key:`headers`,value:r})}}let ee=r.config.client?r.getSymbol({category:`client`}):void 0,te=F.propertyAccessExpression({expression:F.identifier({text:`options`}),isOptional:!e,name:`client`}),ne;ne=r.config.instance?F.binaryExpression({left:te,operator:`??`,right:F.propertyAccessExpression({expression:F.this(),name:`client`})}):ee?F.binaryExpression({left:te,operator:`??`,right:ee.placeholder}):te;let _=[];a?_.push(zn,`${o} | ${Bn}`,s,Bn):_.push(o,s,`ThrowOnError`),r.config.responseStyle===`data`&&_.push(F.stringLiteral({text:r.config.responseStyle}));let v=d?F.propertyAccessExpression({expression:ne,name:F.identifier({text:`sse`})}):ne;return v=F.propertyAccessExpression({expression:v,name:F.identifier({text:n.method})}),h.push(F.returnFunctionCall({args:[F.objectExpression({identifiers:[`responseTransformer`],obj:c})],name:v,types:_})),h},L=({operation:e})=>{let t=[];if(e.summary&&t.push(ft(e.summary)),e.description&&(t.length&&t.push(``),t.push(ft(e.description))),e.deprecated&&(t.length&&t.push(``),t.push(`@deprecated`)),t.length)return t},ar=({context:e,operation:t})=>{let n=E(e.config).name===`@hey-api/client-nuxt`,r=e.config.plugins[`@hey-api/sdk`];if(r){if(!r.config.client&&!r.config.instance)return!0;if(r.config.paramsStructure===`flat`)return!1}return n||Ze(t)},or=({operation:e})=>{for(let t in e.responses)if(e.responses[t].mediaType===`text/event-stream`)return!0;return!1},sr=({plugin:e})=>{let t=new Map,n=new Set,r=e.getPluginOrThrow(`@hey-api/sdk`);e.forEach(`operation`,({operation:n})=>{let i=ar({context:e.context,operation:n}),a=er({context:e.context,operation:n,plugin:r});for(let r of a.values())r.path.forEach((a,o)=>{t.has(a)||t.set(a,{className:a,classes:new Set,methods:new Set,nodes:[],root:!o});let s=r.path[o-1];if(s&&s!==a){let e=t.get(s);e.classes.add(a),t.set(s,e)}if(r.path.length!==o+1)return;let c=t.get(a),l=e.config.httpRequests.methodNameBuilder(n);if(c.methods.has(l))return;let u=ur({isRequiredOptions:i,methodName:l,operation:n,plugin:e});c.nodes.length?c.nodes.push(F.identifier({text:`
|
|
3
|
-
`}),u):c.nodes.push(u),c.methods.add(l),t.set(a,c)})},{order:`declarations`});let i=r=>{if(n.has(r.className))return;if(r.classes.size)for(let n of r.classes){let a=t.get(n);i(a),r.nodes.push(F.propertyDeclaration({initializer:F.newExpression({argumentsArray:[],expression:F.identifier({text:S({config:{case:`preserve`,name:e.config.httpRequests.classNameBuilder},name:a.className})})}),name:x({case:`camelCase`,value:a.className})}))}let a=e.referenceSymbol({category:`external`,resource:`@angular/core.Injectable`}),o=e.registerSymbol({exported:!0,meta:{category:`utility`,resource:`class`,resourceId:r.className,tool:`angular`},name:S({config:{case:`preserve`,name:e.config.httpRequests.classNameBuilder},name:r.className})}),s=F.classDeclaration({decorator:r.root?{args:[{providedIn:`root`}],name:a.placeholder}:void 0,exportClass:o.exported,name:o.placeholder,nodes:r.nodes});e.setSymbolValue(o,s),n.add(r.className)};for(let e of t.values())i(e)},cr=({plugin:e})=>{e.forEach(`operation`,({operation:t})=>{let n=ar({context:e.context,operation:t}),r=e.registerSymbol({exported:!0,meta:{category:`utility`,resource:`operation`,resourceId:t.id,role:`data`,tool:`angular`},name:e.config.httpRequests.methodNameBuilder(t)}),i=dr({isRequiredOptions:n,operation:t,plugin:e,symbol:r});e.setSymbolValue(r,i)},{order:`declarations`})},lr=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`client`}),r=F.propertyAccessExpression({expression:F.identifier({text:`options`}),isOptional:!0,name:`client`}),i;return i=n?F.binaryExpression({left:r,operator:`??`,right:n.placeholder}):r,F.callExpression({functionName:F.propertyAccessExpression({expression:i,name:`requestOptions`}),parameters:[F.objectExpression({obj:[{key:`responseStyle`,value:F.identifier({text:`'data'`})},{key:`method`,value:F.identifier({text:`'${e.method.toUpperCase()}'`})},{key:`url`,value:F.identifier({text:`'${e.path}'`})},{spread:`options`}]})]})},ur=({isRequiredOptions:e,methodName:t,operation:n,plugin:r})=>{let i=r.referenceSymbol({category:`external`,resource:`@angular/common/http.HttpRequest`}),a=r.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),o=r.querySymbol({category:`type`,resource:`operation`,resourceId:n.id,role:`data`,tool:`typescript`})?.placeholder||`unknown`;return F.methodDeclaration({accessLevel:`public`,comment:L({operation:n}),name:t,parameters:[{isRequired:e,name:`options`,type:`${a.placeholder}<${o}, ThrowOnError>`}],returnType:`${i.placeholder}<unknown>`,statements:[F.returnStatement({expression:lr({operation:n,plugin:r})})],types:[{default:!1,extends:`boolean`,name:`ThrowOnError`}]})},dr=({isRequiredOptions:e,operation:t,plugin:n,symbol:r})=>{let i=n.referenceSymbol({category:`external`,resource:`@angular/common/http.HttpRequest`}),a=n.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),o=n.querySymbol({category:`type`,resource:`operation`,resourceId:t.id,role:`data`,tool:`typescript`})?.placeholder||`unknown`;return F.constVariable({comment:L({operation:t}),exportConst:r.exported,expression:F.arrowFunction({parameters:[{isRequired:e,name:`options`,type:`${a.placeholder}<${o}, ThrowOnError>`}],returnType:`${i.placeholder}<unknown>`,statements:[F.returnStatement({expression:lr({operation:t,plugin:n})})],types:[{default:!1,extends:`boolean`,name:`ThrowOnError`}]}),name:r.placeholder})},fr=({plugin:e})=>{e.config.httpRequests.asClass?sr({plugin:e}):cr({plugin:e})},pr=({plugin:e})=>{let t=new Map,n=new Set,r=e.getPluginOrThrow(`@hey-api/sdk`);e.forEach(`operation`,({operation:n})=>{let i=ar({context:e.context,operation:n}),a=er({context:e.context,operation:n,plugin:r});for(let r of a.values())r.path.forEach((a,o)=>{t.has(a)||t.set(a,{className:a,classes:new Set,methods:new Set,nodes:[],root:!o});let s=r.path[o-1];if(s&&s!==a){let e=t.get(s);e.classes.add(a),t.set(s,e)}if(r.path.length!==o+1)return;let c=t.get(a),l=e.config.httpResources.methodNameBuilder(n);if(c.methods.has(l))return;let u=gr({isRequiredOptions:i,methodName:l,operation:n,plugin:e});c.nodes.length?c.nodes.push(F.identifier({text:`
|
|
4
|
-
`}),u):c.nodes.push(u),c.methods.add(l),t.set(a,c)})},{order:`declarations`});let i=r=>{if(n.has(r.className))return;if(r.classes.size)for(let n of r.classes){let a=t.get(n);i(a),r.nodes.push(F.propertyDeclaration({initializer:F.newExpression({argumentsArray:[],expression:F.identifier({text:S({config:{case:`preserve`,name:e.config.httpResources.classNameBuilder},name:a.className})})}),name:x({case:`camelCase`,value:a.className})}))}let a=e.referenceSymbol({category:`external`,resource:`@angular/core.Injectable`}),o=e.registerSymbol({exported:!0,name:S({config:{case:`preserve`,name:e.config.httpResources.classNameBuilder},name:r.className})}),s=F.classDeclaration({decorator:r.root?{args:[{providedIn:`root`}],name:a.placeholder}:void 0,exportClass:o.exported,name:o.placeholder,nodes:r.nodes});e.setSymbolValue(o,s),n.add(r.className)};for(let e of t.values())i(e)},mr=({plugin:e})=>{e.forEach(`operation`,({operation:t})=>{let n=ar({context:e.context,operation:t}),r=e.registerSymbol({exported:!0,name:e.config.httpResources.methodNameBuilder(t)}),i=_r({isRequiredOptions:n,operation:t,plugin:e,symbol:r});e.setSymbolValue(r,i)},{order:`declarations`})},hr=({operation:e,plugin:t})=>{let n=t.getPluginOrThrow(`@hey-api/sdk`),r=t.referenceSymbol({category:`external`,resource:`@angular/common/http.httpResource`}),i=t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`response`})?.placeholder||`unknown`;if(t.config.httpRequests.asClass){let a=er({context:t.context,operation:e,plugin:n}),o=Array.from(a.values())[0];if(o){let n=o.path[0],a=t.referenceSymbol({category:`utility`,resource:`class`,resourceId:n,tool:`angular`}),s=t.referenceSymbol({category:`external`,resource:`@angular/core.inject`}),c=F.callExpression({functionName:s.placeholder,parameters:[F.identifier({text:a.placeholder})]});for(let e=1;e<o.path.length;e++){let t=o.path[e];t&&(c=F.propertyAccessExpression({expression:c,name:x({case:`camelCase`,value:t})}))}return c=F.propertyAccessExpression({expression:c,name:t.config.httpRequests.methodNameBuilder(e)}),F.callExpression({functionName:r.placeholder,parameters:[F.arrowFunction({parameters:[],statements:[F.constVariable({expression:F.conditionalExpression({condition:F.identifier({text:`options`}),whenFalse:F.identifier({text:`undefined`}),whenTrue:F.callExpression({functionName:`options`,parameters:[]})}),name:`opts`}),F.returnStatement({expression:F.conditionalExpression({condition:F.identifier({text:`opts`}),whenFalse:F.identifier({text:`undefined`}),whenTrue:F.callExpression({functionName:c,parameters:[F.identifier({text:`opts`})]})})})]})],types:[F.typeNode(i)]})}}else{let n=t.referenceSymbol({category:`utility`,resource:`operation`,resourceId:e.id,role:`data`,tool:`angular`});return F.callExpression({functionName:r.placeholder,parameters:[F.arrowFunction({parameters:[],statements:[F.constVariable({expression:F.conditionalExpression({condition:F.identifier({text:`options`}),whenFalse:F.identifier({text:`undefined`}),whenTrue:F.callExpression({functionName:`options`,parameters:[]})}),name:`opts`}),F.returnStatement({expression:F.conditionalExpression({condition:F.identifier({text:`opts`}),whenFalse:F.identifier({text:`undefined`}),whenTrue:F.callExpression({functionName:n.placeholder,parameters:[F.identifier({text:`opts`})]})})})]})],types:[F.typeNode(i)]})}return F.callExpression({functionName:r.placeholder,parameters:[F.arrowFunction({parameters:[],statements:[F.returnStatement({expression:F.identifier({text:`undefined`})})]})],types:[F.typeNode(i)]})},gr=({isRequiredOptions:e,methodName:t,operation:n,plugin:r})=>{let i=r.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),a=r.querySymbol({category:`type`,resource:`operation`,resourceId:n.id,role:`data`,tool:`typescript`})?.placeholder||`unknown`;return F.methodDeclaration({accessLevel:`public`,comment:L({operation:n}),name:t,parameters:[{isRequired:e,name:`options`,type:`() => ${i.placeholder}<${a}, ThrowOnError> | undefined`}],returnType:void 0,statements:[F.returnStatement({expression:hr({operation:n,plugin:r})})],types:[{default:!1,extends:`boolean`,name:`ThrowOnError`}]})},_r=({isRequiredOptions:e,operation:t,plugin:n,symbol:r})=>{let i=n.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),a=n.querySymbol({category:`type`,resource:`operation`,resourceId:t.id,role:`data`,tool:`typescript`})?.placeholder||`unknown`;return F.constVariable({comment:L({operation:t}),exportConst:r.exported,expression:F.arrowFunction({parameters:[{isRequired:e,name:`options`,type:`() => ${i.placeholder}<${a}, ThrowOnError> | undefined`}],statements:[F.returnStatement({expression:hr({operation:t,plugin:n})})],types:[{default:!1,extends:`boolean`,name:`ThrowOnError`}]}),name:r.placeholder})},vr=({plugin:e})=>{e.config.httpResources.asClass?pr({plugin:e}):mr({plugin:e})},yr={config:{exportFromIndex:!1},dependencies:[`@hey-api/client-angular`,`@hey-api/sdk`],handler:({plugin:e})=>{e.registerSymbol({external:`@angular/common/http`,kind:`type`,meta:{category:`external`,resource:`@angular/common/http.HttpRequest`},name:`HttpRequest`}),e.registerSymbol({external:`@angular/core`,meta:{category:`external`,resource:`@angular/core.inject`},name:`inject`}),e.registerSymbol({external:`@angular/core`,meta:{category:`external`,resource:`@angular/core.Injectable`},name:`Injectable`}),e.registerSymbol({external:`@angular/common/http`,meta:{category:`external`,resource:`@angular/common/http.httpResource`},name:`httpResource`}),e.config.httpRequests.enabled&&fr({plugin:e}),e.config.httpResources.enabled&&vr({plugin:e})},name:`@angular/common`,resolveConfig:(e,t)=>{if(e.config.httpRequests=t.valueToObject({defaultValue:{asClass:!1,classNameBuilder:`{{name}}Requests`,enabled:!0},mappers:{boolean:e=>({enabled:e})},value:e.config.httpRequests}),!e.config.httpRequests.methodNameBuilder){let{asClass:t}=e.config.httpRequests;e.config.httpRequests.methodNameBuilder=e=>t?String(e.id):`${String(e.id)}Request`}if(e.config.httpResources=t.valueToObject({defaultValue:{asClass:!1,classNameBuilder:`{{name}}Resources`,enabled:!0},mappers:{boolean:e=>({enabled:e})},value:e.config.httpResources}),!e.config.httpResources.methodNameBuilder){let{asClass:t}=e.config.httpResources;e.config.httpResources.methodNameBuilder=e=>t?String(e.id):`${String(e.id)}Resource`}}},br={baseUrl:!0,bundle:!0,exportFromIndex:!1},xr={dependencies:[`@hey-api/typescript`],tags:[`client`]},Sr=c(import.meta.url),Cr=s.dirname(Sr),wr=e=>{let t=E(e);if(`bundle`in t.config&&t.config.bundle){let t=e._FRAGILE_CLIENT_BUNDLE_RENAMED;return s.resolve(e.output.path,`client`,`${t?.get(`index`)??`index`}.ts`)}return t.name},Tr=(e,t)=>{if(o.statSync(e).isDirectory()){o.existsSync(t)||o.mkdirSync(t,{recursive:!0});let n=o.readdirSync(e);for(let r of n)Tr(s.join(e,r),s.join(t,r))}else{let n=o.readFileSync(e);o.writeFileSync(t,n)}},Er=({filePath:e,project:t,renamed:n})=>{let r=s.extname(e),i=s.basename(e,r),a=t.fileName?.(i)||i;if(a!==i){let t=s.dirname(e);o.renameSync(e,s.resolve(t,`${a}${r}`)),n.set(i,a)}},Dr=({filePath:e,meta:t,renamed:n})=>{let r=o.readFileSync(e,`utf8`);r=r.replace(/from\s+['"](\.\.?\/[^'"]*?)['"]/g,(e,r)=>{let i=e.indexOf(r),a=s.extname(r),o=s.basename(r,a),c=s.dirname(r),l=(n.get(o)??o)+(t.importFileExtension?t.importFileExtension:a);return e.slice(0,i)+[c,l].filter(Boolean).join(`/`)+e.slice(i+r.length)}),r=`// This file is auto-generated by @hey-api/openapi-ts
|
|
5
|
-
|
|
6
|
-
${r}`,o.writeFileSync(e,r,`utf8`)},Or=({meta:t,outputPath:n,plugin:r,project:i})=>{let a=new Map;if(r.name.startsWith(`@hey-api/client-`)){let e=s.resolve(n,`core`);_(e),Tr(s.resolve(Cr,`clients`,`core`),e);let c=s.resolve(n,`client`);_(c);let l=r.name.slice(16);if(Tr(s.resolve(Cr,`clients`,l),c),i){let t=o.readdirSync(e);for(let n of t)Er({filePath:s.resolve(e,n),project:i,renamed:a});let n=o.readdirSync(c);for(let e of n)Er({filePath:s.resolve(c,e),project:i,renamed:a})}let u=o.readdirSync(e);for(let n of u)Dr({filePath:s.resolve(e,n),meta:t,renamed:a});let d=o.readdirSync(c);for(let e of d)Dr({filePath:s.resolve(c,e),meta:t,renamed:a});return a}let c=s.isAbsolute(r.name)?s.dirname(r.name):void 0;if(c){let e=s.resolve(n,`client`);_(e),Tr(c,e);return}let l=s.normalize(e.resolve(r.name)).split(s.sep),u=l.slice(0,l.indexOf(`dist`)+1).join(s.sep),d=[l[l.length-1],`index.d.ts`,`index.d.cts`],f=s.resolve(n,`client`);_(f);for(let e of d)o.copyFileSync(s.resolve(u,e),s.resolve(f,e))},kr=/^(([^:/?#]+):)?((\/\/)?([^:/?#]*)(:?([^/?#]*)))?([^?#]*)(\?([^#]*))?(#(.*))?/,Ar=e=>{let t={host:``,path:``,port:``,protocol:``};kr.lastIndex=0;let n=e.match(kr);if(!n)return t;let r=n[5]||``;if(r===`.`||r===`..`)return t;let i=n[8]||``,a=n[2]||``;return a.length===1?t:{host:r,path:i===`/`?``:i,port:n[7]||``,protocol:a}},jr=({plugin:e})=>{let{baseUrl:t}=e.config;if(t===!1)return;if(typeof t==`string`)return t;let{servers:n}=e.context.ir;if(n)return n[typeof t==`number`?t:0]?.url},Mr=({plugin:e})=>{let t=wr(e.context.config),n=e.registerSymbol({external:t,name:`createClient`}),r=e.registerSymbol({external:t,name:`createConfig`}),i=e.referenceSymbol({category:`type`,resource:`client`,role:`options`}),{runtimeConfigPath:a}=e.config,o=a?e.registerSymbol({external:a,name:`createClientConfig`}):void 0,s=[],c=jr({plugin:e});if(c){let t=Ar(c);if(t.protocol&&t.host&&!c.includes(`{`))s.push({key:nt(e.context.config),value:c});else if(c!==`/`&&c.startsWith(`/`)){let t=c.endsWith(`/`)?c.slice(0,-1):c;s.push({key:nt(e.context.config),value:t})}}`throwOnError`in e.config&&e.config.throwOnError&&s.push({key:`throwOnError`,value:!0});let l=[F.callExpression({functionName:r.placeholder,parameters:s.length?[F.objectExpression({obj:s})]:void 0,types:[F.typeReferenceNode({typeName:i.placeholder})]})],u=e.registerSymbol({meta:{category:`client`},name:`client`}),d=F.constVariable({exportConst:!0,expression:F.callExpression({functionName:n.placeholder,parameters:o?[F.callExpression({functionName:o.placeholder,parameters:l})]:l}),name:u.placeholder});e.setSymbolValue(u,d)},Nr=({plugin:e})=>{let t=wr(e.context.config),n=e.referenceSymbol({category:`type`,resource:`client`,role:`options`}),r=e.registerSymbol({external:t,kind:`type`,name:`Config`}),i=e.registerSymbol({external:t,kind:`type`,name:`ClientOptions`}),a=e.registerSymbol({exported:!0,kind:`type`,name:`CreateClientConfig`}),o=F.typeReferenceNode({typeName:i.placeholder}),s=F.typeReferenceNode({typeName:`T`}),c=F.typeAliasDeclaration({comment:["The `createClientConfig()` function will be called on client initialization",`and the returned object will become the client's initial configuration.`,``,`You may want to initialize your client this way instead of calling`,"`setConfig()`. This is useful for example if you're using Next.js",`to ensure your client always has the correct values.`],exportType:a.exported,name:a.placeholder,type:F.functionTypeNode({parameters:[F.parameterDeclaration({name:`override`,required:!1,type:F.typeReferenceNode({typeArguments:[F.typeIntersectionNode({types:[o,s]})],typeName:r.placeholder})})],returnType:F.typeReferenceNode({typeArguments:[F.typeIntersectionNode({types:[F.typeReferenceNode({typeArguments:[o],typeName:`Required`}),s]})],typeName:r.placeholder})}),typeParameters:[{default:F.typeReferenceNode({typeName:n.placeholder}),extends:o,name:`T`}]});e.setSymbolValue(a,c)},Pr=({plugin:e})=>{Nr({plugin:e}),Mr({plugin:e})},Fr={...xr,config:{...br,throwOnError:!1},handler:Pr,name:`@hey-api/client-angular`},Ir={...xr,config:{...br,throwOnError:!1},handler:Pr,name:`@hey-api/client-axios`},Lr={...xr,config:{...br,throwOnError:!1},handler:Pr,name:`@hey-api/client-fetch`},Rr={...xr,config:{...br,throwOnError:!1},handler:Pr,name:`@hey-api/client-next`},zr={...xr,config:br,handler:Pr,name:`@hey-api/client-nuxt`},Br={...xr,config:{...br,throwOnError:!1},handler:Pr,name:`@hey-api/client-ofetch`},Vr=(...e)=>d.satisfies(...e),Hr=e=>({getVersion:t=>{let n=e[t];if(n)try{let e=d.parse(n);if(e)return e;let t=d.minVersion(n);if(t)return t;if(e=d.coerce(n),e)return e}catch{}},isInstalled:t=>!!e[t],satisfies:(t,n,r)=>{let i=typeof t==`string`?e[t]:t;return i?Vr(i,n,r):!1}}),Ur=[ot,ct,at,st,it],Wr=e=>{let t=e.replace(/[^$\u200c\u200d\p{ID_Continue}]/gu,`_`);if(rt.lastIndex=0,rt.test(t))return`_${t}`;for(let e of Ur){if(t.startsWith(`_`))return t;t=t.replace(e,`_$1`)}return t},Gr=({plugin:e,schema:t})=>{e.config.type===`form`&&(t.description&&delete t.description,t[`x-enum-descriptions`]&&delete t[`x-enum-descriptions`],t[`x-enum-varnames`]&&delete t[`x-enum-varnames`],t[`x-enumNames`]&&delete t[`x-enumNames`],t.title&&delete t.title)},Kr=({context:e,plugin:t,schema:n})=>{if(Array.isArray(n))return n.map(n=>Kr({context:e,plugin:t,schema:n}));let r=structuredClone(n);if(r.$ref)return r.$ref=decodeURI(r.$ref),r;if(Gr({plugin:t,schema:r}),r.additionalProperties&&typeof r.additionalProperties!=`boolean`&&(r.additionalProperties=Kr({context:e,plugin:t,schema:r.additionalProperties})),r.allOf&&=r.allOf.map(n=>Kr({context:e,plugin:t,schema:n})),r.items&&=Kr({context:e,plugin:t,schema:r.items}),r.properties)for(let n in r.properties){let i=r.properties[n];typeof i!=`boolean`&&(r.properties[n]=Kr({context:e,plugin:t,schema:i}))}return r},qr=({context:e,plugin:t,schema:n})=>{if(Array.isArray(n))return n.map(n=>qr({context:e,plugin:t,schema:n}));let r=structuredClone(n);if(`$ref`in r)return r.$ref=decodeURI(r.$ref),r;if(Gr({plugin:t,schema:r}),r.additionalProperties&&typeof r.additionalProperties!=`boolean`&&(r.additionalProperties=qr({context:e,plugin:t,schema:r.additionalProperties})),r.allOf&&=r.allOf.map(n=>qr({context:e,plugin:t,schema:n})),r.anyOf&&=r.anyOf.map(n=>qr({context:e,plugin:t,schema:n})),r.items&&=qr({context:e,plugin:t,schema:r.items}),r.oneOf&&=r.oneOf.map(n=>qr({context:e,plugin:t,schema:n})),r.properties)for(let n in r.properties){let i=r.properties[n];typeof i!=`boolean`&&(r.properties[n]=qr({context:e,plugin:t,schema:i}))}return r},Jr=({context:e,plugin:t,schema:n})=>{if(Array.isArray(n))return n.map(n=>Jr({context:e,plugin:t,schema:n}));let r=structuredClone(n);if(Gr({plugin:t,schema:r}),r.$ref&&=decodeURI(r.$ref),r.additionalProperties&&typeof r.additionalProperties!=`boolean`&&(r.additionalProperties=Jr({context:e,plugin:t,schema:r.additionalProperties})),r.allOf&&=r.allOf.map(n=>Jr({context:e,plugin:t,schema:n})),r.anyOf&&=r.anyOf.map(n=>Jr({context:e,plugin:t,schema:n})),r.items&&=Jr({context:e,plugin:t,schema:r.items}),r.oneOf&&=r.oneOf.map(n=>Jr({context:e,plugin:t,schema:n})),r.prefixItems&&=r.prefixItems.map(n=>Jr({context:e,plugin:t,schema:n})),r.properties)for(let n in r.properties){let i=r.properties[n];typeof i!=`boolean`&&(r.properties[n]=Jr({context:e,plugin:t,schema:i}))}return r},Yr=({name:e,plugin:t,schema:n})=>{let r=``;return t.config.nameBuilder&&(r=typeof t.config.nameBuilder==`function`?t.config.nameBuilder(e,n):t.config.nameBuilder.replace(`{{name}}`,e)),r||=`${e}Schema`,Wr(r)},Xr=({context:e,plugin:t})=>{if(e.spec.definitions)for(let n in e.spec.definitions){let r=e.spec.definitions[n],i=t.registerSymbol({exported:!0,meta:{category:`schema`,resource:`definition`,resourceId:n,tool:`json-schema`},name:Yr({name:n,plugin:t,schema:r})}),a=Kr({context:e,plugin:t,schema:r}),o=F.constVariable({assertion:`const`,exportConst:i.exported,expression:F.objectExpression({obj:a}),name:i.placeholder});t.setSymbolValue(i,o)}},Zr=({context:e,plugin:t})=>{if(e.spec.components)for(let n in e.spec.components.schemas){let r=e.spec.components.schemas[n],i=t.registerSymbol({exported:!0,meta:{category:`schema`,resource:`definition`,resourceId:n,tool:`json-schema`},name:Yr({name:n,plugin:t,schema:r})}),a=qr({context:e,plugin:t,schema:r}),o=F.constVariable({assertion:`const`,exportConst:i.exported,expression:F.objectExpression({obj:a}),name:i.placeholder});t.setSymbolValue(i,o)}},Qr=({context:e,plugin:t})=>{if(e.spec.components)for(let n in e.spec.components.schemas){let r=e.spec.components.schemas[n],i=t.registerSymbol({exported:!0,meta:{category:`schema`,resource:`definition`,resourceId:n,tool:`json-schema`},name:Yr({name:n,plugin:t,schema:r})}),a=Jr({context:e,plugin:t,schema:r}),o=F.constVariable({assertion:`const`,exportConst:i.exported,expression:F.objectExpression({obj:a}),name:i.placeholder});t.setSymbolValue(i,o)}},$r={config:{exportFromIndex:!1,nameBuilder:e=>`${e}Schema`,type:`json`},handler:({plugin:e})=>{if(`swagger`in e.context.spec){Xr({context:e.context,plugin:e});return}if(Vr(e.context.spec.openapi,`>=3.0.0 <3.1.0`)){Zr({context:e.context,plugin:e});return}if(Vr(e.context.spec.openapi,`>=3.1.0`)){Qr({context:e.context,plugin:e});return}throw Error(`Unsupported OpenAPI specification`)},name:`@hey-api/schemas`};var R=class e{$expr(e){return typeof e==`string`?l.factory.createIdentifier(e):e}$if(e,t,n){return e?t(this,e)??this:n?n(this,e)??this:this}$node(e){if(e!==void 0)return typeof e==`string`?this.$expr(e):e instanceof Array?e.map(e=>this._render(e)):this._render(e)}$stmt(e){return(e instanceof Array?e:[e]).map(e=>{let t=typeof e==`string`?l.factory.createIdentifier(e):this._render(e);return l.isExpression(t)?l.factory.createExpressionStatement(t):t})}$type(e){if(e!==void 0){if(typeof e==`string`)return l.factory.createTypeReferenceNode(e);if(typeof e==`boolean`){let t=e?l.factory.createTrue():l.factory.createFalse();return l.factory.createLiteralTypeNode(t)}return this._render(e)}}_render(t){return t instanceof e?t.$render():t}},ei=class extends R{callee;callArgs=[];constructor(e,...t){super(),this.callee=e,t.length&&(this.callArgs=t)}args(...e){return this.callArgs=e,this}$render(){let e=this.$node(this.callee),t=this.$node(this.callArgs).map(e=>this.$expr(e));return l.factory.createCallExpression(e,void 0,t)}},ti=class{attr(e){return new ai(this,e)}call(...e){return new ei(this,...e)}};function z(e,...t){let n=e.prototype;for(let r of t){let[t,i]=r instanceof Array?r:[r],a=t;if(typeof t==`function`)try{let n=t(e);n?.prototype&&(a=n)}catch{}let o=a.prototype;if(o)for(let[e,t]of Object.entries(Object.getOwnPropertyDescriptors(o)))e!==`constructor`&&(e===`$render`&&!i?.overrideRender||Object.defineProperty(n,e,t))}}var B=class extends R{left;operator;right;constructor(e,t,n){super(),this.left=e,this.operator=t,this.right=n}$render(){let e=this.$node(this.left),t=this.$node(this.right),n=typeof this.operator==`string`?this.mapOperator(this.operator):this.operator;return l.factory.createBinaryExpression(e,n,t)}mapOperator(e){let t={"!=":l.SyntaxKind.ExclamationEqualsToken,"!==":l.SyntaxKind.ExclamationEqualsEqualsToken,"&&":l.SyntaxKind.AmpersandAmpersandToken,"*":l.SyntaxKind.AsteriskToken,"+":l.SyntaxKind.PlusToken,"-":l.SyntaxKind.MinusToken,"/":l.SyntaxKind.SlashToken,"<":l.SyntaxKind.LessThanToken,"<=":l.SyntaxKind.LessThanEqualsToken,"=":l.SyntaxKind.EqualsToken,"==":l.SyntaxKind.EqualsEqualsToken,"===":l.SyntaxKind.EqualsEqualsEqualsToken,">":l.SyntaxKind.GreaterThanToken,">=":l.SyntaxKind.GreaterThanEqualsToken,"??":l.SyntaxKind.QuestionQuestionToken,"||":l.SyntaxKind.BarBarToken}[e];if(!t)throw Error(`Unsupported operator: ${e}`);return t}},ni=class{assign(e){return new B(this,`=`,e)}},ri=class{and(e){return new B(this,`&&`,e)}coalesce(e){return new B(this,`??`,e)}div(e){return new B(this,`/`,e)}eq(e){return new B(this,`===`,e)}gt(e){return new B(this,`>`,e)}gte(e){return new B(this,`>=`,e)}looseEq(e){return new B(this,`==`,e)}looseNeq(e){return new B(this,`!=`,e)}lt(e){return new B(this,`<`,e)}lte(e){return new B(this,`<=`,e)}minus(e){return new B(this,`-`,e)}neq(e){return new B(this,`!==`,e)}or(e){return new B(this,`||`,e)}plus(e){return new B(this,`+`,e)}times(e){return new B(this,`*`,e)}},ii=class{isOptional;questionToken;optional(e=!0){return e&&(this.isOptional=!0,this.questionToken=l.factory.createToken(l.SyntaxKind.QuestionToken)),this}},ai=class extends R{left;right;constructor(e,t){super(),this.left=e,this.right=t}$render(){let e=this.$node(this.left);return this.isOptional?l.factory.createPropertyAccessChain(e,l.factory.createToken(l.SyntaxKind.QuestionDotToken),l.factory.createIdentifier(this.right)):l.factory.createPropertyAccessExpression(e,l.factory.createIdentifier(this.right))}};z(ai,ti,ni,ri,ii);var oi=class extends R{input;constructor(e){super(),this.input=e}$render(){return this.$node(this.input)}};z(oi,ti,ri);var si=class extends R{props=[];layout=3;constructor(e){super(),e&&e(this)}auto(e=3){return this.layout=e,this}inline(){return this.layout=!1,this}pretty(){return this.layout=!0,this}prop(e,t){let n=t(e=>new oi(e));return this.props.push({expr:n,name:e}),this}$render(){let e=this.props.map(({expr:e,name:t})=>l.factory.createPropertyAssignment(t,e.$render())),t=typeof this.layout==`number`?this.props.length>=this.layout:this.layout;return l.factory.createObjectLiteralExpression(e,t)}},ci=class extends R{decorators;decorator(e,t){if(!e)return this;let n=this.$expr(e),r=n;if(t){let e=new si(t);r=l.factory.createCallExpression(n,void 0,[e.$render()])}return(this.decorators??=[]).push(l.factory.createDecorator(r)),this}$render(){throw Error(`noop`)}},li=class extends R{_lines=[];constructor(e,t){super(),e&&(typeof e==`string`?this.add(e):this.add(...e)),t&&t(this)}add(...e){return this._lines.push(...e),this}apply(e){let t=this._lines.filter(e=>!!e||e===``);if(!t.length)return e;let n=t.map((e,n)=>{let r=e;return n!==t.length&&(r=`${r}\n`),l.factory.createJSDocText(r)}),r=l.factory.createJSDocComment(l.factory.createNodeArray(n),void 0),i=l.createPrinter().printNode(l.EmitHint.Unspecified,r,e.getSourceFile?.()??l.createSourceFile(``,``,l.ScriptTarget.Latest)).replace(`/*`,``).replace(`* */`,``);return l.addSyntheticLeadingComment(e,l.SyntaxKind.MultiLineCommentTrivia,i,!0),e}$render(){return l.factory.createIdentifier(``)}};function ui(e){let t=class extends e{_desc;describe(e,t){return this._desc=new li(e,t),this}},n=e.prototype.$render;return t.prototype.$render=function(...e){let t=n.apply(this,e);return this._desc?this._desc.apply(t):t},t}function di(e){let t=[];function n(n,r=!0){return r&&t.push(l.factory.createModifier(n)),e}Object.assign(e,{_m:n});function r(){return t}return{list:r}}var fi=class{abstract(e=!0){return this._m(l.SyntaxKind.AbstractKeyword,e)}},pi=class{async(e=!0){return this._m(l.SyntaxKind.AsyncKeyword,e)}},mi=class{default(e=!0){return this._m(l.SyntaxKind.DefaultKeyword,e)}},hi=class{export(e=!0){return this._m(l.SyntaxKind.ExportKeyword,e)}},gi=class{private(e=!0){return this._m(l.SyntaxKind.PrivateKeyword,e)}},_i=class{protected(e=!0){return this._m(l.SyntaxKind.ProtectedKeyword,e)}},vi=class{public(e=!0){return this._m(l.SyntaxKind.PublicKeyword,e)}},yi=class{readonly(e=!0){return this._m(l.SyntaxKind.ReadonlyKeyword,e)}},bi=class{static(e=!0){return this._m(l.SyntaxKind.StaticKeyword,e)}},xi=class extends R{value;constructor(e){super(),this.value=e}$render(){switch(typeof this.value){case`boolean`:return this.value?l.factory.createTrue():l.factory.createFalse();case`number`:return l.factory.createNumericLiteral(this.value);case`string`:return l.factory.createStringLiteral(this.value);default:throw Error(`Unsupported literal: ${String(this.value)}`)}}},Si=class extends R{_generics;generic(e,t){let n=new Ti(e,t);return this._generics||=[],this._generics.push(n),this}generics(...e){return this._generics=[...e],this}$generics(){return this._generics?.map(e=>typeof e==`string`?l.factory.createTypeParameterDeclaration(void 0,l.factory.createIdentifier(e),void 0,void 0):this.$node(e))}$render(){throw Error(`noop`)}},Ci=class extends R{base;constraint;defaultValue;constructor(e){super(),e&&(this.base=this.$expr(e))}default(e){return this.defaultValue=e,this}extends(e){return this.constraint=e,this}},wi=class extends Ci{objectBuilder;constructor(e,t){super(e),t&&t(this)}object(e){return this.objectBuilder=new Di(e),this}$render(){if(this.objectBuilder)return l.factory.createTypeLiteralNode(this.objectBuilder.$render());if(!this.base)throw Error(`Missing base type`);let e=this._generics?.map(e=>this.$type(e));return l.factory.createTypeReferenceNode(this.base,e)}};z(wi,Si);var Ti=class extends Ci{constructor(e,t){super(e),t&&t(this)}$render(){if(!this.base)throw Error(`Missing type name`);return l.factory.createTypeParameterDeclaration(void 0,this.base,this.$type(this.constraint),this.$type(this.defaultValue))}};z(Ti,Si);var Ei=class extends R{literal;constructor(e){super(),this.literal=new xi(e)}$render(){let e=this.literal.$render();return l.factory.createLiteralTypeNode(e)}},Di=class{props=[];constructor(e){e(this)}prop(e,t){let n=new Oi(e,t);return this.props.push(n),this}$render(){return this.props.map(e=>e.$render())}},Oi=class{name;typeInput;constructor(e,t){this.name=e,t(this)}type(e){return this.typeInput=e,this}$render(){if(!this.typeInput)throw Error(`Type not specified for property '${this.name}'`);let e=typeof this.typeInput==`string`?l.factory.createTypeReferenceNode(this.typeInput):this.typeInput;return l.factory.createPropertySignature(void 0,l.factory.createIdentifier(this.name),this.questionToken,e)}};z(Oi,ii);const ki=Object.assign((...e)=>new wi(...e),{literal:(...e)=>new Ei(...e),object:(...e)=>new Di(...e),param:(...e)=>new Ti(...e),ref:(...e)=>new wi(...e)});function Ai(e){let t=e.$type.bind(e),n,r;function i(){return n?n.$render():t(r)}function a(t){return t===void 0?(n||=ki(),n):(r=t,e)}return{$render:i,method:a}}var ji=class{initializer;assign(e){return this.initializer=e,this}},Mi=class extends R{modifiers=di(this);name;_type=Ai(this);constructor(e,t){super(),this.name=e,t&&t(this)}type=this._type.method;$render(){return l.factory.createPropertyDeclaration([...this.decorators??[],...this.modifiers.list()],l.factory.createIdentifier(this.name),void 0,this._type.$render(),this.$node(this.initializer))}};z(Mi,ci,[ui,{overrideRender:!0}],gi,_i,vi,yi,bi,ji);var Ni=class extends R{name;_type=Ai(this);constructor(e,t){super(),this.name=e,t&&t(this)}type=this._type.method;$render(){return l.factory.createParameterDeclaration(this.decorators,void 0,l.factory.createIdentifier(this.name),this.questionToken,this._type.$render(),this.$node(this.initializer))}};z(Ni,ci,ii,ji);var Pi=class{_params;param(e,t){let n=new Ni(e,t);return this._params||=[],this._params.push(n),this}params(...e){return this._params||=[],this._params.push(...e),this}},Fi=class extends R{body=[];modifiers=di(this);constructor(e){super(),e&&e(this)}do(...e){return this.body.push(...e),this}$render(){let e=this.$node(this._params??[]),t=this.$stmt(this.body);return l.factory.createConstructorDeclaration([...this.decorators??[],...this.modifiers.list()],e,l.factory.createBlock(t,!0))}};z(Fi,ci,[ui,{overrideRender:!0}],Pi,gi,_i,vi);var Ii=class extends R{body=[];modifiers=di(this);name;_returns=Ai(this);constructor(e,t){super(),this.name=e,t&&t(this)}returns=this._returns.method;do(...e){return this.body.push(...e),this}$render(){let e=this.$node(this._params??[]),t=this.$stmt(this.body);return l.factory.createMethodDeclaration([...this.decorators??[],...this.modifiers.list()],void 0,l.factory.createIdentifier(this.name),this.questionToken,this.$generics(),e,this._returns.$render(),l.factory.createBlock(t,!0))}};z(Ii,fi,pi,ci,[ui,{overrideRender:!0}],Si,ii,Pi,gi,_i,vi,bi);var Li=class extends R{$render(){return l.factory.createIdentifier(`
|
|
7
|
-
`)}},Ri=class extends R{heritageClauses=[];body=[];modifiers=di(this);name;constructor(e){super(),this.name=e}init(e){let t=new Fi(e);return this.body.push(t),this}extends(e){return e&&this.heritageClauses.push(l.factory.createHeritageClause(l.SyntaxKind.ExtendsKeyword,[l.factory.createExpressionWithTypeArguments(this.$expr(e),void 0)])),this}field(e,t){let n=new Mi(e,t);return this.body.push(n),this}method(e,t){let n=new Ii(e,t);return this.body.push(n),this}do(...e){return this.body.push(...e),this}newline(){return this.body.push(new Li),this}$render(){let e=this.$node(this.body);return l.factory.createClassDeclaration([...this.decorators??[],...this.modifiers.list()],l.factory.createIdentifier(this.name),this.$generics(),this.heritageClauses,e)}};z(Ri,fi,ci,[ui,{overrideRender:!0}],mi,hi,Si);var zi=class extends R{modifiers=di(this);name;constructor(e){super(),this.name=e}$render(){return l.factory.createVariableStatement(this.modifiers.list(),l.factory.createVariableDeclarationList([l.factory.createVariableDeclaration(l.factory.createIdentifier(this.name),void 0,void 0,this.$node(this.initializer))],l.NodeFlags.Const))}};z(zi,mi,[ui,{overrideRender:!0}],hi,ji);var Bi=class extends R{body=[];modifiers=di(this);name;constructor(e,t){super(),this.name=e,t&&t(this)}do(...e){return this.body.push(...e),this}$render(){let e=this.$node(this._params??[]),t=this.$stmt(this.body);return l.factory.createGetAccessorDeclaration([...this.decorators??[],...this.modifiers.list()],this.name,e,void 0,l.factory.createBlock(t,!0))}};z(Bi,fi,ci,[ui,{overrideRender:!0}],Pi,gi,_i,vi,bi);var Vi=class extends R{conditionInput;thenInput;elseInput;constructor(e){super(),e&&this.condition(e)}condition(e){return this.conditionInput=e,this}do(...e){return this.thenInput=e,this}otherwise(...e){return this.elseInput=e,this}$render(){if(!this.conditionInput)throw Error(`Missing condition in if`);if(!this.thenInput)throw Error(`Missing then block in if`);let e=this.$node(this.conditionInput),t=this.$node(this.thenInput),n=t.length===1?t[0]:l.factory.createBlock(t,!0),r=l.isBlock(n)?n:l.factory.createBlock([n],!0),i;if(this.elseInput){let e=this.$node(this.elseInput),t=e.length===1?e[0]:l.factory.createBlock(e,!0);i=l.isBlock(t)?t:l.factory.createBlock([t],!0)}return l.factory.createIfStatement(e,r,i)}},Hi=class extends R{classExpr;argList=[];constructor(e,...t){super(),this.classExpr=e,t.length&&(this.argList=[...t])}args(...e){return this.argList=[...e],this}$render(){let e=this.$node(this.classExpr),t=this.$node(this.argList).map(e=>this.$expr(e)),n=this._generics?.map(e=>this.$type(e));return l.factory.createNewExpression(e,n,t)}};z(Hi,Si);var Ui=class extends R{exprInput;constructor(e){super(),this.exprInput=e}$render(){let e=this.$node(this.exprInput);return l.factory.createPrefixUnaryExpression(l.SyntaxKind.ExclamationToken,e)}},Wi=class extends R{expr;constructor(e){super(),this.expr=e}$render(){let e=this.$node(this.expr);return l.factory.createReturnStatement(e)}},Gi=class extends R{body=[];modifiers=di(this);name;constructor(e,t){super(),this.name=e,t&&t(this)}do(...e){return this.body.push(...e),this}$render(){let e=this.$node(this._params??[]),t=this.$stmt(this.body);return l.factory.createSetAccessorDeclaration([...this.decorators??[],...this.modifiers.list()],this.name,e,l.factory.createBlock(t,!0))}};z(Gi,fi,ci,[ui,{overrideRender:!0}],Pi,gi,_i,vi,bi);var Ki=class extends R{parts=[];constructor(e){super(),e!==void 0&&this.add(e)}add(e){return this.parts.push(e),this}$render(){let e=this.$node(this.parts),t=[];for(let n=0;n<e.length;n++){let r=e[n];if(typeof r==`string`){let i=r;for(;n+1<e.length&&typeof e[n+1]==`string`;)i+=e[n+1],n++;t.push(i)}else t.push(r)}if((t.length===0||typeof t[0]!=`string`)&&t.unshift(``),t.length===1&&typeof t[0]==`string`)return l.factory.createNoSubstitutionTemplateLiteral(t[0]);if(t.length===2&&typeof t[0]==`string`&&typeof t[1]!=`string`)return l.factory.createTemplateExpression(l.factory.createTemplateHead(t[0]),[l.factory.createTemplateSpan(t[1],l.factory.createTemplateTail(``))]);let n=l.factory.createTemplateHead(t.shift()),r=[];for(;t.length;){let e=t.shift(),n=typeof t[0]==`string`?t.shift():``,i=t.length===0;r.push(l.factory.createTemplateSpan(e,i?l.factory.createTemplateTail(n):l.factory.createTemplateMiddle(n)))}return l.factory.createTemplateExpression(n,r)}},qi=class extends R{error;msg;useNew;constructor(e,t=!0){super(),this.error=e,this.useNew=t}message(e){return this.msg=e,this}$render(){let e=this.$node(this.error),t=this.$node(this.msg?[this.msg]:[]).map(e=>typeof e==`string`?l.factory.createStringLiteral(e):e);if(this.useNew)return l.factory.createThrowStatement(l.factory.createNewExpression(e,void 0,t));let n=t.length?[l.factory.createCallExpression(e,void 0,t)]:[e];return l.factory.createThrowStatement(n[0])}};const Ji={attr:(...e)=>new ai(...e),binary:(...e)=>new B(...e),call:(...e)=>new ei(...e),class:(...e)=>new Ri(...e),const:(...e)=>new zi(...e),describe:(...e)=>new li(...e),expr:(...e)=>new oi(...e),field:(...e)=>new Mi(...e),getter:(...e)=>new Bi(...e),if:(...e)=>new Vi(...e),init:(...e)=>new Fi(...e),literal:(...e)=>new xi(...e),method:(...e)=>new Ii(...e),new:(...e)=>new Hi(...e),newline:(...e)=>new Li(...e),not:(...e)=>new Ui(...e),object:(...e)=>new si(...e),param:(...e)=>new Ni(...e),return:(...e)=>new Wi(...e),setter:(...e)=>new Gi(...e),template:(...e)=>new Ki(...e),throw:(...e)=>new qi(...e),type:ki},V=Object.assign((...e)=>new oi(...e),Ji),Yi=`__registry`,Xi=({sdkName:e,symbol:t})=>{let n=`defaultKey`,r=`instances`;return V.class(t.placeholder).export(t.exported).generic(`T`).field(n,e=>e.private().readonly().assign(V.literal(`default`))).newline().field(r,e=>e.private().readonly().type(V.type(`Map`).generics(`string`,`T`)).assign(V.new(`Map`))).newline().method(`get`,t=>t.returns(`T`).param(`key`,e=>e.type(`string`).optional()).do(V.const(`instance`).assign(V(`this`).attr(`instances`).attr(`get`).call(V(`key`).coalesce(V(`this`).attr(n)))),V.if(V.not(`instance`)).do(V.throw(`Error`).message(V.template(`No SDK client found. Create one with "new `).add(e).add(`()" to fix this error.`))),V.return(`instance`))).newline().method(`set`,e=>e.returns(`void`).param(`value`,e=>e.type(`T`)).param(`key`,e=>e.type(`string`).optional()).do(V(`this`).attr(r).attr(`set`).call(V(`key`).coalesce(V(`this`).attr(n)),`value`)))},Zi=({plugin:e,symbol:t})=>{let n=e.getSymbol({category:`client`}),r=!!(e.config.client&&n),i=e.referenceSymbol({category:`external`,resource:`client.Client`});return V.class(t.placeholder).export(t.exported).field(`client`,e=>e.protected().type(i.placeholder)).newline().init(e=>e.param(`args`,e=>e.optional(r).type().object(e=>e.prop(`client`,e=>e.optional(r).type(i.placeholder)))).do(V(`this`).attr(`client`).assign(V(`args`).attr(`client`).optional(r).$if(r,e=>e.coalesce(n.placeholder)))))},Qi=({plugin:e})=>{let t=E(e.context.config),n=t.name===`@hey-api/client-angular`,r=t.name===`@hey-api/client-nuxt`,i=new Map,a=new Set;e.forEach(`operation`,({operation:a})=>{let o=ar({context:e.context,operation:a}),s=r?e.querySymbol({category:`type`,resource:`operation`,resourceId:a.id,role:`response`}):void 0,c=er({context:e.context,operation:a,plugin:e});for(let l of c.values())l.path.forEach((c,u)=>{let d=e.referenceSymbol({category:`utility`,resource:`class`,resourceId:c,tool:`sdk`});i.has(d.meta.resourceId)||i.set(d.meta.resourceId,{className:d.meta.resourceId,classes:new Set,id:d.id,methods:new Set,nodes:[],root:!u});let f=l.path[u-1];if(f){let t=e.referenceSymbol({category:`utility`,resource:`class`,resourceId:f,tool:`sdk`});if(t.meta?.resourceId!==d.meta?.resourceId){let e=i.get(t.meta.resourceId);e.classes.add(d.meta.resourceId),i.set(t.meta.resourceId,e)}}if(l.path.length!==u+1)return;let p=i.get(d.meta.resourceId);if(p.methods.has(l.methodName))return;let m=nr({isRequiredOptions:o,operation:a,plugin:e}),h=ir({isRequiredOptions:o,opParameters:m,operation:a,plugin:e}),g=V.method(l.methodName,i=>i.$if(L({operation:a}),(e,t)=>e.describe(t)).public().static(!n&&!e.config.instance).$if(r,t=>t.generic(zn,t=>t.extends(e.referenceSymbol({category:`external`,resource:`client.Composable`}).placeholder).default(V.type.literal(`$fetch`))).generic(Bn,e=>e.$if(s,(e,t)=>e.extends(t.placeholder).default(t.placeholder))),e=>e.generic(`ThrowOnError`,e=>e.extends(`boolean`).default((`throwOnError`in t.config?t.config.throwOnError:!1)??!1))).params(...kt(m.parameters)).do(...h));p.nodes.length?p.nodes.push(V.newline(),g):p.nodes.push(g),p.methods.add(l.methodName),i.set(d.meta.resourceId,p)})},{order:`declarations`});let o=e.config.instance?e.registerSymbol({exported:!1,kind:`class`,meta:{category:`utility`,resource:`class`,resourceId:`HeyApiClient`,tool:`sdk`},name:`HeyApiClient`}):void 0,s=e.config.instance?e.registerSymbol({exported:!1,kind:`class`,meta:{category:`utility`,resource:`class`,resourceId:`HeyApiRegistry`,tool:`sdk`},name:`HeyApiRegistry`}):void 0,c=t=>{if(a.has(t.className))return;let r=t.className;if(a.add(r),t.classes.size)for(let n of t.classes){let r=i.get(n);c(r);let a=e.referenceSymbol({category:`utility`,resource:`class`,resourceId:r.className,tool:`sdk`}),o=x({case:`camelCase`,value:a.meta.resourceId});if(t.methods.has(o)){let e=2,n=`${o}${e}`;for(;t.methods.has(n);)n=`${o}${e++}`;o=n}t.methods.add(o);let s;s=e.isSymbolRegistered(a.id)?V.field(o,t=>t.static(!e.config.instance).assign(e.config.instance?V.new(a.placeholder).args(V.object(e=>e.prop(`client`,()=>V(`this`).attr(`client`)))):V(a.placeholder))):V.getter(o,t=>t.$if(!e.config.instance,e=>e.public().static()).do(e.config.instance?V.return(V.new(a.placeholder).args(V.object(e=>e.prop(`client`,()=>V(`this`).attr(`client`))))):V.return(a.placeholder))),t.nodes.length?t.nodes.push(V.newline(),s):t.nodes.push(s)}if(o&&!e.gen.symbols.hasValue(o.id)){let t=Zi({plugin:e,symbol:o}).$render();e.setSymbolValue(o,t)}let l=e.registerSymbol({exported:!0,kind:`class`,meta:{category:`utility`,resource:`class`,resourceId:r,tool:`sdk`},name:r});if(t.root&&s){let n=e.getSymbol({category:`client`}),r=!e.config.client||!n,i=e.referenceSymbol({category:`external`,resource:`client.Client`}),a=V.init(e=>e.param(`args`,e=>e.optional(!r).type().object(e=>e.prop(`client`,e=>e.optional(!r).type(i.placeholder)).prop(`key`,e=>e.optional().type(`string`)))).do(V(`super`).call(`args`),V(l.placeholder).attr(Yi).attr(`set`).call(`this`,V(`args`).attr(`key`).optional(!r))));t.nodes.length?t.nodes.unshift(a,V.newline()):t.nodes.unshift(a);let o=Xi({plugin:e,sdkName:l.placeholder,symbol:s}).$render();e.setSymbolValue(s,o);let c=V.field(Yi,e=>e.public().static().readonly().assign(V.new(s.placeholder).generic(l.placeholder)));t.nodes.unshift(c,V.newline())}let u=V.class(l.placeholder).export(l.exported).extends(o?.placeholder).$if(t.root&&n,t=>t.decorator(e.referenceSymbol({category:`external`,resource:`@angular/core.Injectable`}).placeholder,e=>e.prop(`providedIn`,()=>V.literal(`root`)))).do(...t.nodes).$render();e.setSymbolValue(l,u)};for(let e of i.values())c(e)},$i=({id:e,operation:t,plugin:n})=>n.config.methodNameBuilder?n.config.methodNameBuilder(t):e.match(ot)?`${e}_`:e,ea=({plugin:e})=>{let t=E(e.context.config),n=t.name===`@hey-api/client-nuxt`;e.forEach(`operation`,r=>{let{operation:i}=r,a=ar({context:e.context,operation:i}),o=n?e.querySymbol({category:`type`,resource:`operation`,resourceId:i.id,role:`response`}):void 0,s=nr({isRequiredOptions:a,operation:i,plugin:e}),c=ir({isRequiredOptions:a,opParameters:s,operation:i,plugin:e}),l=e.registerSymbol({meta:{category:`sdk`,path:r._path,resource:`operation`,resourceId:i.id,tags:r.tags,tool:`sdk`},name:$i({id:i.id,operation:i,plugin:e})}),u=F.constVariable({comment:L({operation:i}),exportConst:!0,expression:F.arrowFunction({parameters:s.parameters,returnType:void 0,statements:c,types:n?[{default:F.ots.string(`$fetch`),extends:F.typeNode(e.referenceSymbol({category:`external`,resource:`client.Composable`}).placeholder),name:zn},{default:o?F.typeReferenceNode({typeName:o.placeholder}):F.typeNode(`undefined`),extends:o?F.typeReferenceNode({typeName:o.placeholder}):void 0,name:Bn}]:[{default:(`throwOnError`in t.config?t.config.throwOnError:!1)??!1,extends:`boolean`,name:`ThrowOnError`}]}),name:l.placeholder});e.setSymbolValue(l,u)},{order:`declarations`})},ta=({plugin:e})=>{let t=wr(e.context.config),n=E(e.context.config),r=n.name===`@hey-api/client-nuxt`,i=e.registerSymbol({external:t,kind:`type`,name:`TDataShape`}),a=e.registerSymbol({external:t,kind:`type`,meta:{category:`external`,resource:`client.Client`,tool:n.name},name:`Client`}),o=e.registerSymbol({external:t,kind:`type`,name:`Options`}),s=e.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,resource:`client-options`,tool:`sdk`},name:`Options`}),c=F.typeAliasDeclaration({exportType:s.exported,name:s.placeholder,type:F.typeIntersectionNode({types:[F.typeReferenceNode({typeArguments:r?[F.typeReferenceNode({typeName:`TComposable`}),F.typeReferenceNode({typeName:`TData`}),F.typeReferenceNode({typeName:Vn}),F.typeReferenceNode({typeName:Bn})]:[F.typeReferenceNode({typeName:`TData`}),F.typeReferenceNode({typeName:`ThrowOnError`})],typeName:o.placeholder}),F.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&&!e.config.instance,name:`client`,type:F.typeReferenceNode({typeName:a.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:F.typeReferenceNode({typeArguments:[F.keywordTypeNode({keyword:`string`}),F.keywordTypeNode({keyword:`unknown`})],typeName:`Record`})}],useLegacyResolution:!1})]}),typeParameters:r?[F.typeParameterDeclaration({constraint:F.typeReferenceNode({typeName:e.referenceSymbol({category:`external`,resource:`client.Composable`}).placeholder}),defaultType:F.typeNode(`'$fetch'`),name:`TComposable`}),F.typeParameterDeclaration({constraint:F.typeReferenceNode({typeName:i.placeholder}),defaultType:F.typeReferenceNode({typeName:i.placeholder}),name:`TData`}),F.typeParameterDeclaration({defaultType:F.keywordTypeNode({keyword:`unknown`}),name:Vn}),F.typeParameterDeclaration({defaultType:F.keywordTypeNode({keyword:`undefined`}),name:Bn})]:[F.typeParameterDeclaration({constraint:F.typeReferenceNode({typeName:i.placeholder}),defaultType:F.typeReferenceNode({typeName:i.placeholder}),name:`TData`}),F.typeParameterDeclaration({constraint:F.keywordTypeNode({keyword:`boolean`}),defaultType:F.keywordTypeNode({keyword:`boolean`}),name:`ThrowOnError`})]});e.setSymbolValue(s,c)},na=({plugin:e})=>{let t=wr(e.context.config),n=E(e.context.config),r=n.name===`@hey-api/client-angular`,i=n.name===`@hey-api/client-nuxt`;e.registerSymbol({external:t,meta:{category:`external`,resource:`client.formDataBodySerializer`,tool:n.name},name:`formDataBodySerializer`}),e.registerSymbol({external:t,meta:{category:`external`,resource:`client.urlSearchParamsBodySerializer`,tool:n.name},name:`urlSearchParamsBodySerializer`}),e.registerSymbol({external:t,meta:{category:`external`,resource:`client.buildClientParams`,tool:n.name},name:`buildClientParams`}),i&&e.registerSymbol({external:t,kind:`type`,meta:{category:`external`,resource:`client.Composable`,tool:n.name},name:`Composable`}),r&&e.config.asClass&&e.registerSymbol({external:`@angular/core`,meta:{category:`external`,resource:`@angular/core.Injectable`},name:`Injectable`}),ta({plugin:e}),e.config.asClass?Qi({plugin:e}):ea({plugin:e})},ra={config:{asClass:!1,auth:!0,classNameBuilder:`{{name}}`,classStructure:`auto`,client:!0,exportFromIndex:!0,instance:!1,operationId:!0,paramsStructure:`grouped`,response:`body`,responseStyle:`fields`,transformer:!1,validator:!1},dependencies:[`@hey-api/typescript`],handler:e=>na(e),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`)}},ia=({dataExpression:e,schema:t})=>{if(t.type!==`integer`||t.format!==`int64`)return;let n=e===void 0?void 0:F.callExpression({functionName:`BigInt`,parameters:[F.callExpression({functionName:F.propertyAccessExpression({expression:e,name:`toString`})})]});if(n){if(typeof e==`string`)return[n];if(e)return[F.assignment({left:e,right:n})]}},aa=({dataExpression:e,schema:t})=>{if(t.type!==`string`||!(t.format===`date`||t.format===`date-time`))return;let n=F.identifier({text:`Date`});if(typeof e==`string`)return[F.newExpression({argumentsArray:[F.identifier({text:e})],expression:n})];if(e)return[F.assignment({left:e,right:F.newExpression({argumentsArray:[e],expression:n})})]},oa=`data`,sa=new Set,ca=e=>e.map(e=>l.isStatement(e)?e:F.expressionToStatement({expression:e})),la=({node:e})=>e.kind===l.SyntaxKind.ReturnStatement,ua=({plugin:e,schema:t})=>{let n=F.identifier({text:oa}),r=da({dataExpression:n,plugin:e,schema:t});return r.length&&!la({node:r[r.length-1]})&&r.push(F.returnStatement({expression:n})),r},da=({dataExpression:e,plugin:t,schema:n})=>{if(n.$ref){let r={category:`transform`,resource:`definition`,resourceId:n.$ref},i=t.getSymbol(r);if(i||(i=t.registerSymbol({meta:r,name:S({config:{case:`camelCase`,name:`{{name}}SchemaResponseTransformer`},name:I(n.$ref)})}),t.setSymbolValue(i,null)),!t.gen.symbols.getValue(i.id)&&!sa.has(i.id)){sa.add(i.id);try{let e=ua({plugin:t,schema:t.context.resolveIrRef(n.$ref)});if(e.length){let n=F.constVariable({expression:F.arrowFunction({async:!1,multiLine:!0,parameters:[{name:oa,type:F.keywordTypeNode({keyword:`any`})}],statements:ca(e)}),name:i.placeholder});t.setSymbolValue(i,n)}}finally{sa.delete(i.id)}}if(t.gen.symbols.getValue(i.id)||sa.has(i.id)){let n=t.referenceSymbol(r),i=F.callExpression({functionName:n.placeholder,parameters:[e]});if(e)return typeof e==`string`&&e===`item`?[F.returnStatement({expression:i})]:[typeof e==`string`?i:F.assignment({left:e,right:i})]}return[]}if(n.type===`array`){if(!e||typeof e==`string`)return[];let r=n.items?da({dataExpression:`item`,plugin:t,schema:n.items?.[0]?n.items[0]:{...n,type:void 0}}):[];if(!r.length)return[];let i=ca(r);return i.some(e=>la({node:e}))||i.push(F.returnStatement({expression:F.identifier({text:`item`})})),[F.assignment({left:e,right:F.callExpression({functionName:F.propertyAccessExpression({expression:e,name:`map`}),parameters:[F.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=F.propertyAccessExpression({expression:e||oa,name:a}),c=da({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(F.ifStatement({expression:s,thenStatement:F.block({statements:ca(c)})}))}return r}if(n.items){if(n.items.length===1)return da({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=da({dataExpression:e||`item`,plugin:t,schema:i});if(n.length)if(e)r=r.concat(n);else{let e=F.identifier({text:`item`});r.push(F.ifStatement({expression:e,thenStatement:F.block({statements:ca(n)})}),F.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[]},fa={config:{bigInt:!0,dates:!0,exportFromIndex:!1,transformers:[],typeTransformers:[]},dependencies:[`@hey-api/typescript`],handler:({plugin:e})=>{e.forEach(`operation`,({operation:t})=>{let{response:n}=et(t);if(!n)return;if(n.items&&n.items.length>1){e.context.config.logs.level===`debug`&&console.warn(`❗️ Transformers warning: route ${T(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.querySymbol({category:`type`,resource:`operation`,resourceId:t.id,role:`response`});if(!r)return;let i=ua({plugin:e,schema:n});if(!i.length)return;let a=e.registerSymbol({exported:!0,meta:{category:`transform`,resource:`operation`,resourceId:t.id,role:`response`},name:S({config:{case:`camelCase`,name:`{{name}}ResponseTransformer`},name:t.id})}),o=F.constVariable({exportConst:a.exported,expression:F.arrowFunction({async:!0,multiLine:!0,parameters:[{name:oa,type:F.keywordTypeNode({keyword:`any`})}],returnType:F.typeReferenceNode({typeArguments:[F.typeReferenceNode({typeName:r.placeholder})],typeName:`Promise`}),statements:ca(i)}),name:a.placeholder});e.setSymbolValue(a,o)},{order:`declarations`})},name:`@hey-api/transformers`,resolveConfig:e=>{e.config.transformers||(e.config.transformers=[]),e.config.dates&&(e.config.transformers=[...e.config.transformers,aa]),e.config.bigInt&&(e.config.transformers=[...e.config.transformers,ia])},tags:[`transformer`]},pa=F.keywordTypeNode({keyword:`string`}),ma=({server:e})=>{let t=Ar(e.url);return t.protocol&&t.host?F.literalTypeNode({literal:F.stringLiteral({text:e.url})}):F.templateLiteralType({value:[t.protocol||pa,`://`,t.host||pa,t.port?`:${t.port}`:``,t.path||``]})},ha=({plugin:e,servers:t,symbolClientOptions:n})=>{let r=E(e.context.config),i=t.map(e=>ma({server:e}));t.length?`strictBaseUrl`in r.config&&r.config.strictBaseUrl||i.push(F.typeIntersectionNode({types:[pa,l.factory.createTypeLiteralNode([])]})):i.push(pa);let a=F.typeInterfaceNode({properties:[{name:nt(e.context.config),type:F.typeUnionNode({types:i})}],useLegacyResolution:!1}),o=F.typeAliasDeclaration({exportType:n.exported,name:n.placeholder,type:a});e.setSymbolValue(n,o)},ga=({schema:e})=>{let t=[];return e.title&&t.push(ft(e.title)),e.description&&(t.length&&t.push(``),t.push(ft(e.description))),e.deprecated&&(t.length&&t.push(``),t.push(`@deprecated`)),t.length?t:void 0},_a=({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=x({case:e.config.enums.case,stripLeadingSeparators:!1,value:a}),k.lastIndex=0,k.test(a)&&e.config.enums.enabled&&(e.config.enums.mode===`typescript`||e.config.enums.mode===`typescript-const`)&&(a=`_${a}`)),{comments:ga({schema:t}),key:a,value:t.const}}),typeofItems:n}},va=({plugin:e,schema:t,symbol:n,type:r})=>{if(t.type===`enum`&&e.config.enums.enabled){let r=_a({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=F.constVariable({assertion:`const`,comment:ga({schema:t}),exportConst:!0,expression:F.objectExpression({multiLine:!0,obj:r.obj}),name:n.placeholder}),a=F.typeOfExpression({text:n.placeholder}),o=F.typeAliasDeclaration({comment:ga({schema:t}),exportType:!0,name:n.placeholder,type:F.indexedAccessTypeNode({indexType:F.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=F.enumDeclaration({asConst:e.config.enums.mode===`typescript-const`,leadingComment:ga({schema:t}),name:n.placeholder,obj:r.obj});e.setSymbolValue(n,i);return}}let i=F.typeAliasDeclaration({comment:ga({schema:t}),exportType:n.exported,name:n.placeholder,type:r});e.setSymbolValue(n,i)},ya=({parameters:e})=>{let t={type:`object`};if(e){let n={},r=[];for(let t in e){let i=e[t];n[i.name]=C({detectFormat:!1,schema:i.schema}),i.required&&r.push(i.name)}t.properties=n,r.length&&(t.required=r)}return t},ba=({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=ya({parameters:e.parameters.header}),r.properties.headers.required&&i.push(`headers`)),e.parameters?.path?(r.properties.path=ya({parameters:e.parameters.path}),r.properties.path.required&&i.push(`path`)):r.properties.path={type:`never`},e.parameters?.query?(r.properties.query=ya({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,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`operation`,resourceId:e.id,role:`data`,tags:n.tags?.value,tool:`typescript`},name:S({config:t.config.requests,name:e.id})}),o=H({plugin:t,schema:r,state:n}),s=F.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:o});t.setSymbolValue(a,s)},xa=({operation:e,plugin:t,state:n})=>{ba({operation:e,plugin:t,state:n});let{error:r,errors:i,response:a,responses:o}=et(e);if(i){let a=t.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`operation`,resourceId:e.id,role:`errors`,tags:n.tags?.value,tool:`typescript`},name:S({config:t.config.errors,name:e.id})}),o=H({plugin:t,schema:i,state:n}),s=F.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:o});if(t.setSymbolValue(a,s),r){let r=t.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`operation`,resourceId:e.id,role:`error`,tags:n.tags?.value,tool:`typescript`},name:S({config:{case:t.config.errors.case,name:t.config.errors.error},name:e.id})}),i=F.indexedAccessTypeNode({indexType:F.typeOperatorNode({operator:`keyof`,type:F.typeReferenceNode({typeName:a.placeholder})}),objectType:F.typeReferenceNode({typeName:a.placeholder})}),o=F.typeAliasDeclaration({exportType:r.exported,name:r.placeholder,type:i});t.setSymbolValue(r,o)}}if(o){let r=t.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`operation`,resourceId:e.id,role:`responses`,tags:n.tags?.value,tool:`typescript`},name:S({config:t.config.responses,name:e.id})}),i=H({plugin:t,schema:o,state:n}),s=F.typeAliasDeclaration({exportType:r.exported,name:r.placeholder,type:i});if(t.setSymbolValue(r,s),a){let i=t.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`operation`,resourceId:e.id,role:`response`,tags:n.tags?.value,tool:`typescript`},name:S({config:{case:t.config.responses.case,name:t.config.responses.response},name:e.id})}),a=F.indexedAccessTypeNode({indexType:F.typeOperatorNode({operator:`keyof`,type:F.typeReferenceNode({typeName:r.placeholder})}),objectType:F.typeReferenceNode({typeName:r.placeholder})}),o=F.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:a});t.setSymbolValue(i,o)}}},Sa=({operation:e,plugin:t,state:n})=>{let r={type:`object`},i=[];if(r.properties||={},e.body){let a=t.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`webhook`,resourceId:e.id,role:`data`,tags:n.tags?.value,tool:`typescript`},name:S({config:{case:t.config.webhooks.case,name:t.config.webhooks.payload},name:e.id})}),o=H({plugin:t,schema:e.body.schema,state:n}),s=F.typeAliasDeclaration({comment:ga({schema:e.body.schema}),exportType:a.exported,name:a.placeholder,type:o});t.setSymbolValue(a,s),t.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`definition`,resourceId:a.placeholder,tags:n.tags?.value,tool:`typescript`},name:a.name,placeholder: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,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`webhook`,resourceId:e.id,role:`data`,tags:n.tags?.value,tool:`typescript`},name:S({config:t.config.webhooks,name:e.id})}),o=H({plugin:t,schema:r,state:n}),s=F.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:o});return t.setSymbolValue(a,s),a.placeholder},Ca=({operation:e,plugin:t,state:n})=>Sa({operation:e,plugin:t,state:n}),wa=({plugin:e,symbolWebhooks:t,webhookNames:n})=>{if(!n.length)return;let r=F.typeUnionNode({types:n.map(e=>F.typeReferenceNode({typeName:e}))}),i=F.typeAliasDeclaration({exportType:t.exported,name:t.placeholder,type:r});e.setSymbolValue(t,i)},Ta=({plugin:e,schema:t,state:n})=>{if(!t.items)return F.typeArrayNode(F.keywordTypeNode({keyword:e.config.topType}));t=C({detectFormat:!0,schema:t});let r=[];return t.items&&t.items.forEach((t,i)=>{let a=H({plugin:e,schema:t,state:{...n,path:D([...n.path.value,`items`,i])}});r.push(a)}),r.length===1?F.typeArrayNode(r[0]):t.logicalOperator===`and`?F.typeArrayNode(F.typeIntersectionNode({types:r})):F.typeArrayNode(F.typeUnionNode({types:r}))},Ea=({schema:e})=>e.const===void 0?F.keywordTypeNode({keyword:`boolean`}):F.literalTypeNode({literal:F.ots.boolean(e.const)}),Da=({plugin:e,schema:t,state:n})=>H({plugin:e,schema:{...t,type:void 0},state:n}),Oa=e=>F.keywordTypeNode({keyword:`never`}),ka=e=>F.literalTypeNode({literal:F.null()}),Aa=({plugin:e,schema:t})=>t.const===void 0?t.type===`integer`&&t.format===`int64`&&e.getPlugin(`@hey-api/transformers`)?.config.bigInt?F.typeReferenceNode({typeName:`bigint`}):F.keywordTypeNode({keyword:`number`}):F.literalTypeNode({literal:F.ots.number(t.const)}),ja=({context:e,name:t})=>(k.lastIndex=0,k.test(t)?t.startsWith(`-`)?l.factory.createStringLiteral(t):l.factory.createNumericLiteral(t):x({case:e.config.output.case,value:t})),Ma=({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=H({plugin:e,schema:i,state:{...n,path:D([...n.path.value,`properties`,r])}}),u=s.includes(r);a.push({comment:ga({schema:i}),isReadOnly:i.accessScope===`read`,isRequired:u,name:ja({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?H({plugin:e,schema:o[0],state:n}):H({plugin:e,schema:{items:o,logicalOperator:`or`},state:n})},t.propertyNames?.$ref&&(r=H({plugin:e,schema:{$ref:t.propertyNames.$ref},state:n}))}return F.typeInterfaceNode({indexKey:r,indexProperty:i,properties:a,useLegacyResolution:!1})},Na=({plugin:e,schema:t})=>{if(t.const!==void 0)return F.literalTypeNode({literal:F.stringLiteral({text:t.const})});if(t.format){if(t.format===`binary`)return F.typeUnionNode({types:[F.typeReferenceNode({typeName:`Blob`}),F.typeReferenceNode({typeName:`File`})]});if((t.format===`date-time`||t.format===`date`)&&e.getPlugin(`@hey-api/transformers`)?.config.dates)return F.typeReferenceNode({typeName:`Date`});if(t.format===`typeid`&&typeof t.example==`string`){let n=String(t.example).split(`_`);n.pop();let r=n.join(`_`),i={category:`type`,resource:`type-id`,resourceId:r,tool:`typescript`};if(!e.getSymbol(i)){let t={category:`type`,resource:`type-id`,tool:`typescript`,variant:`container`};if(!e.getSymbol(t)){let n=e.registerSymbol({exported:!0,kind:`type`,meta:t,name:`TypeID`}),r=F.typeAliasDeclaration({exportType:n.exported,name:n.placeholder,type:F.templateLiteralType({value:[F.typeReferenceNode({typeName:`T`}),`_`,F.keywordTypeNode({keyword:`string`})]}),typeParameters:[F.typeParameterDeclaration({constraint:F.keywordTypeNode({keyword:`string`}),name:`T`})]});e.setSymbolValue(n,r)}let n=e.referenceSymbol(t),a=e.registerSymbol({exported:!0,kind:`type`,meta:i,name:x({case:e.config.case,value:`${r}_id`})}),o=F.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:F.typeReferenceNode({typeArguments:[F.literalTypeNode({literal:F.stringLiteral({text:r})})],typeName:n.placeholder})});e.setSymbolValue(a,o)}let a=e.referenceSymbol(i);return F.typeReferenceNode({typeName:a.placeholder})}}return F.keywordTypeNode({keyword:`string`})},Pa=({plugin:e,schema:t,state:n})=>{let r=[];return t.const&&Array.isArray(t.const)?r=t.const.map(t=>F.valueToExpression({value:t})??F.identifier({text:e.config.topType})):t.items&&t.items.forEach((t,i)=>{let a=H({plugin:e,schema:t,state:{...n,path:D([...n.path.value,`items`,i])}});r.push(a)}),F.typeTupleNode({types:r})},Fa=e=>F.keywordTypeNode({keyword:`undefined`}),Ia=({plugin:e})=>F.keywordTypeNode({keyword:e.config.topType}),La=e=>F.keywordTypeNode({keyword:`void`}),Ra=({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 Ta({...t,schema:e});case`boolean`:return Ea({...t,schema:e});case`enum`:return Da({...t,schema:e});case`integer`:case`number`:return Aa({...t,schema:e});case`never`:return Oa({...t,schema:e});case`null`:return ka({...t,schema:e});case`object`:return Ma({...t,schema:e});case`string`:return Na({...t,schema:e});case`tuple`:return Pa({...t,schema:e});case`undefined`:return Fa({...t,schema:e});case`unknown`:return Ia({...t,schema:e});case`void`:return La({...t,schema:e})}},H=({plugin:e,schema:t,state:n})=>{if(t.$ref){let n=e.referenceSymbol({category:`type`,resource:`definition`,resourceId:t.$ref});return F.typeReferenceNode({typeName:n.placeholder})}if(t.type)return Ra({plugin:e,schema:t,state:n});if(t.items){if(t=C({detectFormat:!1,schema:t}),t.items){let r=[];for(let i of t.items){let t=H({plugin:e,schema:i,state:n});r.push(t)}return t.logicalOperator===`and`?F.typeIntersectionNode({types:r}):F.typeUnionNode({types:r})}return H({plugin:e,schema:t,state:n})}return Ra({plugin:e,schema:{type:`unknown`},state:n})},za=({plugin:e,schema:t,state:n})=>{let r=H({plugin:e,schema:t,state:n}),i=t.type===`enum`&&e.config.enums.enabled,a=qn(n.path.value);va({plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,kind:i?void 0:`type`,meta:{category:`type`,path:n.path.value,resource:`definition`,resourceId:a,tags:n.tags?.value,tool:`typescript`},name:S({config:e.config.definitions,name:I(a)})}),type:r})},Ba=({plugin:e})=>{let t=e.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,resource:`client`,role:`options`,tool:`typescript`},name:S({config:{case:e.config.case},name:`ClientOptions`})}),n=e.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,resource:`webhook`,tool:`typescript`,variant:`container`},name:S({config:{case:e.config.case},name:`Webhooks`})}),r=[],i=[];e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`server`,`webhook`,t=>{let n=O({path:t._path,tags:t.tags});switch(t.type){case`operation`:xa({operation:t.operation,plugin:e,state:n});break;case`parameter`:za({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:za({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:za({plugin:e,schema:t.schema,state:n});break;case`server`:r.push(t.server);break;case`webhook`:i.push(Ca({operation:t.operation,plugin:e,state:n}));break}},{order:`declarations`}),ha({plugin:e,servers:r,symbolClientOptions:t}),wa({plugin:e,symbolWebhooks:n,webhookNames:i})},Va={api:new class{schemaToType(e){return H(e)}},config:{case:`PascalCase`,exportFromIndex:!0,topType:`unknown`},handler:e=>Ba(e),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})}},Ha=(e,t,n)=>{let r=e.config[n].meta;if(!r)return;let i=r(t);if(Object.keys(i).length)return F.valueToExpression({value:i})},Ua=({operation:e,plugin:t})=>tr({operation:e,plugin:t.getPluginOrThrow(`@hey-api/sdk`)}),Wa=({operation:e,plugin:t})=>{let n=E(t.context.config),r=t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`error`})?.placeholder;return r||=`Error`,n.name===`@hey-api/client-axios`&&(r=`${t.referenceSymbol({category:`external`,resource:`axios.AxiosError`}).placeholder}<${r}>`),r},Ga=({operation:e,plugin:t})=>t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`response`})?.placeholder||`unknown`,Ka=({plugin:e,typeData:t})=>{let n=E(e.context.config).name===`@hey-api/client-nuxt`;return{isNuxtClient:n,strippedTypeData:n?`Omit<${t}, 'composable'>`:t}},qa=({operation:e,plugin:t,queryFn:n})=>{let r=t.referenceSymbol({category:`external`,resource:`${t.name}.UseMutationOptions`}),i=Ua({operation:e,plugin:t}),a=Wa({operation:e,plugin:t}),o=Ga({operation:e,plugin:t}),{isNuxtClient:s,strippedTypeData:c}=Ka({plugin:t,typeData:i}),l=s?`${r.placeholder}<${o}, ${c}, ${a}>`:`${r.placeholder}<${o}, ${i}, ${a}>`,u=`fnOptions`,d=F.awaitExpression({expression:F.callExpression({functionName:n,parameters:[F.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:u},{key:`throwOnError`,value:!0}]})]})}),f=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?f.push(F.returnVariable({expression:d})):f.push(F.constVariable({destructure:!0,expression:d,name:`data`}),F.returnVariable({expression:`data`}));let p=[{key:`mutation`,value:F.arrowFunction({async:!0,multiLine:!0,parameters:[s?{name:u,type:`Partial<${c}>`}:{name:u}],statements:f})}],m=Ha(t,e,`mutationOptions`);m&&p.push({key:`meta`,value:m});let h=t.registerSymbol({exported:!0,name:S({config:t.config.mutationOptions,name:e.id})}),g=F.constVariable({comment:t.config.comments?L({operation:e}):void 0,exportConst:h.exported,expression:F.arrowFunction({parameters:[{isRequired:!1,name:`options`,type:`Partial<${c}>`}],returnType:l,statements:[F.returnStatement({expression:F.objectExpression({obj:p})})]}),name:h.placeholder});t.setSymbolValue(h,g)},Ja=`TOptions`,Ya=F.identifier({text:`options`}),Xa=({plugin:e})=>{let t=e.registerSymbol({meta:{category:`utility`,resource:`createQueryKey`,tool:e.name},name:S({config:{case:e.config.case},name:`createQueryKey`})}),n=e.referenceSymbol({category:`type`,resource:`QueryKey`,tool:e.name}),r=e.referenceSymbol({category:`external`,resource:`${e.name}._JSONValue`}),i=F.indexedAccessTypeNode({indexType:F.literalTypeNode({literal:F.ots.number(0)}),objectType:F.typeReferenceNode({typeArguments:[F.typeReferenceNode({typeName:Ja})],typeName:n.placeholder})}),a=nt(e.context.config),o=e.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),s=e.getSymbol({category:`client`}),c=wr(e.context.config),l=e.registerSymbol({external:c,meta:{category:`external`,resource:`${c}.serializeQueryKeyValue`},name:`serializeQueryKeyValue`}),u=F.constVariable({expression:F.arrowFunction({multiLine:!0,parameters:[{name:`id`,type:F.typeReferenceNode({typeName:`string`})},{isRequired:!1,name:`options`,type:F.typeReferenceNode({typeName:Ja})},{isRequired:!1,name:`tags`,type:F.typeReferenceNode({typeName:`ReadonlyArray<string>`})}],returnType:F.typeTupleNode({types:[i]}),statements:[F.constVariable({assertion:i,expression:F.objectExpression({multiLine:!1,obj:[{key:`_id`,value:F.identifier({text:`id`})},{key:a,value:F.identifier({text:`options?.${a} || (options?.client ?? ${s?.placeholder}).getConfig().${a}`})}]}),name:`params`,typeName:i}),F.ifStatement({expression:F.identifier({text:`tags`}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`tags`}),right:F.asExpression({expression:F.asExpression({expression:F.identifier({text:`tags`}),type:F.keywordTypeNode({keyword:`unknown`})}),type:F.typeReferenceNode({typeName:r.placeholder})})})})]})}),F.ifStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:Ya,isOptional:!0,name:F.identifier({text:`body`})}),operator:`!==`,right:`undefined`}),thenStatement:F.block({statements:[F.constVariable({expression:F.callExpression({functionName:l.placeholder,parameters:[F.propertyAccessExpression({expression:`options`,name:`body`})]}),name:`normalizedBody`}),F.ifStatement({expression:F.binaryExpression({left:F.identifier({text:`normalizedBody`}),operator:`!==`,right:`undefined`}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`body`}),right:F.identifier({text:`normalizedBody`})})})]})})]})}),F.ifStatement({expression:F.propertyAccessExpression({expression:Ya,isOptional:!0,name:F.identifier({text:`path`})}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`path`}),right:F.propertyAccessExpression({expression:`options`,name:`path`})})})]})}),F.ifStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:Ya,isOptional:!0,name:F.identifier({text:`query`})}),operator:`!==`,right:`undefined`}),thenStatement:F.block({statements:[F.constVariable({expression:F.callExpression({functionName:l.placeholder,parameters:[F.propertyAccessExpression({expression:`options`,name:`query`})]}),name:`normalizedQuery`}),F.ifStatement({expression:F.binaryExpression({left:F.identifier({text:`normalizedQuery`}),operator:`!==`,right:`undefined`}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`query`}),right:F.identifier({text:`normalizedQuery`})})})]})})]})}),F.returnStatement({expression:F.arrayLiteralExpression({elements:[F.identifier({text:`params`})]})})],types:[{extends:F.typeReferenceNode({typeName:F.identifier({text:o.placeholder})}),name:Ja}]}),name:t.placeholder});e.setSymbolValue(t,u)},Za=({id:e,operation:t,plugin:n})=>{let r=n.config.queryKeys,i;r.tags&&t.tags&&t.tags.length>0&&(i=F.arrayLiteralExpression({elements:t.tags.map(e=>F.stringLiteral({text:e}))}));let a=n.referenceSymbol({category:`utility`,resource:`createQueryKey`,tool:n.name});return F.callExpression({functionName:a.placeholder,parameters:[F.ots.string(e),`options`,i]})},Qa=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`${e.name}._JSONValue`}),n=[{name:`_id`,type:F.keywordTypeNode({keyword:`string`})},{isRequired:!1,name:nt(e.context.config),type:F.typeReferenceNode({typeName:t.placeholder})},{isRequired:!1,name:`body`,type:F.typeReferenceNode({typeName:t.placeholder})},{isRequired:!1,name:`query`,type:F.typeReferenceNode({typeName:t.placeholder})},{isRequired:!1,name:`tags`,type:F.typeReferenceNode({typeName:t.placeholder})}],r=e.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),i=e.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,resource:`QueryKey`,tool:e.name},name:`QueryKey`}),a=F.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:F.typeTupleNode({types:[F.typeIntersectionNode({types:[F.typeReferenceNode({typeName:`Pick<${Ja}, 'path'>`}),F.typeInterfaceNode({properties:n,useLegacyResolution:!0})]})]}),typeParameters:[{extends:F.typeReferenceNode({typeName:F.identifier({text:r.placeholder})}),name:Ja}]});e.setSymbolValue(i,a)},$a=({operation:e,plugin:t,symbol:n})=>{let{strippedTypeData:r}=Ka({plugin:t,typeData:Ua({operation:e,plugin:t})});return F.constVariable({exportConst:n.exported,expression:F.arrowFunction({parameters:[{isRequired:Ze(e),name:`options`,type:r}],statements:Za({id:e.id,operation:e,plugin:t})}),name:n.placeholder})},eo=`options`,to=`context`,no=({operation:e,plugin:t,queryFn:n})=>{if(or({operation:e}))return;let r=ar({context:t.context,operation:e});t.getSymbol({category:`utility`,resource:`createQueryKey`,tool:t.name})||(Qa({plugin:t}),Xa({plugin:t}));let i;if(t.config.queryKeys.enabled){let n=t.registerSymbol({exported:!0,name:S({config:t.config.queryKeys,name:e.id})}),r=$a({operation:e,plugin:t,symbol:n});t.setSymbolValue(n,r),i=F.callExpression({functionName:n.placeholder,parameters:[eo]})}else{let n=t.referenceSymbol({category:`utility`,resource:`createQueryKey`,tool:t.name}),r;t.config.queryKeys.tags&&e.tags&&e.tags.length>0&&(r=F.arrayLiteralExpression({elements:e.tags.map(e=>F.stringLiteral({text:e}))})),i=F.callExpression({functionName:n.placeholder,parameters:[F.ots.string(e.id),eo,r]})}let{strippedTypeData:a}=Ka({plugin:t,typeData:Ua({operation:e,plugin:t})}),o=F.awaitExpression({expression:F.callExpression({functionName:n,parameters:[F.objectExpression({multiLine:!0,obj:[{spread:eo},{spread:to},{key:`throwOnError`,value:!0}]})]})}),s=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?s.push(F.returnVariable({expression:o})):s.push(F.constVariable({destructure:!0,expression:o,name:`data`}),F.returnVariable({expression:`data`}));let c=[{key:`key`,value:i},{key:`query`,value:F.arrowFunction({async:!0,multiLine:!0,parameters:[{name:to}],statements:s})}],l=Ha(t,e,`queryOptions`);l&&c.push({key:`meta`,value:l});let u=t.registerSymbol({exported:!0,meta:{category:`hook`,resource:`operation`,resourceId:e.id,role:`queryOptions`,tool:t.name},name:S({config:t.config.queryOptions,name:e.id})}),d=t.referenceSymbol({category:`external`,resource:`${t.name}.defineQueryOptions`}),f=F.constVariable({comment:t.config.comments?L({operation:e}):void 0,exportConst:u.exported,expression:F.callExpression({functionName:d.placeholder,parameters:[F.arrowFunction({parameters:[{isRequired:r,name:eo,type:a}],statements:F.objectExpression({obj:c})})]}),name:u.placeholder});t.setSymbolValue(u,f)},ro=({plugin:e})=>{e.registerSymbol({external:e.name,meta:{category:`external`,resource:`${e.name}.defineQueryOptions`},name:`defineQueryOptions`}),e.registerSymbol({external:e.name,kind:`type`,meta:{category:`external`,resource:`${e.name}.UseMutationOptions`},name:`UseMutationOptions`}),e.registerSymbol({external:e.name,kind:`type`,meta:{category:`external`,resource:`${e.name}.UseQueryOptions`},name:`UseQueryOptions`}),e.registerSymbol({external:e.name,kind:`type`,meta:{category:`external`,resource:`${e.name}._JSONValue`},name:`_JSONValue`}),e.registerSymbol({external:`axios`,kind:`type`,meta:{category:`external`,resource:`axios.AxiosError`},name:`AxiosError`});let t=e.getPluginOrThrow(`@hey-api/sdk`);e.forEach(`operation`,({operation:n})=>{let r=t.config.asClass?er({context:e.context,operation:n,plugin:t}):void 0,i=r?r.values().next().value:void 0,a=i?[e.referenceSymbol({category:`utility`,resource:`class`,resourceId:i.path[0],tool:`sdk`}).placeholder,...i.path.slice(1).map(e=>x({case:`camelCase`,value:e})),i.methodName].filter(Boolean).join(`.`):e.referenceSymbol({category:`sdk`,resource:`operation`,resourceId:n.id}).placeholder;e.hooks.operation.isQuery(n)&&e.config.queryOptions.enabled&&no({operation:n,plugin:e,queryFn:a}),e.hooks.operation.isMutation(n)&&e.config.mutationOptions.enabled&&qa({operation:n,plugin:e,queryFn:a})},{order:`declarations`})},io={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/typescript`,`@hey-api/sdk`],handler:e=>ro(e),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})}},ao=({operation:e,plugin:t})=>tr({operation:e,plugin:t.getPluginOrThrow(`@hey-api/sdk`)}),oo=({operation:e,plugin:t})=>{let n=E(t.context.config),r=t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`error`})?.placeholder;return r||=t.referenceSymbol({category:`external`,resource:`${t.name}.DefaultError`}).placeholder,n.name===`@hey-api/client-axios`&&(r=`${t.referenceSymbol({category:`external`,resource:`axios.AxiosError`}).placeholder}<${r}>`),r},so=({operation:e,plugin:t})=>t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`response`})?.placeholder||`unknown`,co=`TOptions`,lo=F.identifier({text:`infinite`}),uo=F.identifier({text:`options`}),fo=({plugin:e})=>{let t=e.registerSymbol({meta:{category:`utility`,resource:`createQueryKey`,tool:e.name},name:S({config:{case:e.config.case},name:`createQueryKey`})}),n=e.referenceSymbol({category:`type`,resource:`QueryKey`,tool:e.name}),r=F.indexedAccessTypeNode({indexType:F.literalTypeNode({literal:F.ots.number(0)}),objectType:F.typeReferenceNode({typeArguments:[F.typeReferenceNode({typeName:co})],typeName:n.placeholder})}),i=nt(e.context.config),a=e.getSymbol({category:`client`}),o=e.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),s=F.constVariable({expression:F.arrowFunction({multiLine:!0,parameters:[{name:`id`,type:F.typeReferenceNode({typeName:`string`})},{isRequired:!1,name:`options`,type:F.typeReferenceNode({typeName:co})},{isRequired:!1,name:`infinite`,type:F.typeReferenceNode({typeName:`boolean`})},{isRequired:!1,name:`tags`,type:F.typeReferenceNode({typeName:`ReadonlyArray<string>`})}],returnType:F.typeTupleNode({types:[r]}),statements:[F.constVariable({assertion:r,expression:F.objectExpression({multiLine:!1,obj:[{key:`_id`,value:F.identifier({text:`id`})},{key:i,value:F.identifier({text:`options?.${i} || (options?.client ?? ${a?.placeholder}).getConfig().${i}`})}]}),name:`params`,typeName:r}),F.ifStatement({expression:lo,thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`_infinite`}),right:lo})})]})}),F.ifStatement({expression:F.identifier({text:`tags`}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`tags`}),right:F.identifier({text:`tags`})})})]})}),F.ifStatement({expression:F.propertyAccessExpression({expression:uo,isOptional:!0,name:F.identifier({text:`body`})}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`body`}),right:F.propertyAccessExpression({expression:`options`,name:`body`})})})]})}),F.ifStatement({expression:F.propertyAccessExpression({expression:uo,isOptional:!0,name:F.identifier({text:`headers`})}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`headers`}),right:F.propertyAccessExpression({expression:`options`,name:`headers`})})})]})}),F.ifStatement({expression:F.propertyAccessExpression({expression:uo,isOptional:!0,name:F.identifier({text:`path`})}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`path`}),right:F.propertyAccessExpression({expression:`options`,name:`path`})})})]})}),F.ifStatement({expression:F.propertyAccessExpression({expression:uo,isOptional:!0,name:F.identifier({text:`query`})}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`query`}),right:F.propertyAccessExpression({expression:`options`,name:`query`})})})]})}),F.returnStatement({expression:F.arrayLiteralExpression({elements:[F.identifier({text:`params`})]})})],types:[{extends:F.typeReferenceNode({typeName:F.identifier({text:o.placeholder})}),name:co}]}),name:t.placeholder});e.setSymbolValue(t,s)},po=({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=F.arrayLiteralExpression({elements:n.tags.map(e=>F.stringLiteral({text:e}))}));let o=r.referenceSymbol({category:`utility`,resource:`createQueryKey`,tool:r.name});return F.callExpression({functionName:o.placeholder,parameters:[F.ots.string(e),`options`,t||a?F.ots.boolean(!!t):void 0,a]})},mo=({plugin:e})=>{let t=[{name:`_id`,type:F.keywordTypeNode({keyword:`string`})},{isRequired:!1,name:`_infinite`,type:F.keywordTypeNode({keyword:`boolean`})},{isRequired:!1,name:`tags`,type:F.typeReferenceNode({typeName:`ReadonlyArray<string>`})}],n=e.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),r=e.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,resource:`QueryKey`,tool:e.name},name:`QueryKey`}),i=F.typeAliasDeclaration({exportType:r.exported,name:r.placeholder,type:F.typeTupleNode({types:[F.typeIntersectionNode({types:[F.typeReferenceNode({typeName:`Pick<${co}, '${nt(e.context.config)}' | 'body' | 'headers' | 'path' | 'query'>`}),F.typeInterfaceNode({properties:t,useLegacyResolution:!0})]})]}),typeParameters:[{extends:F.typeReferenceNode({typeName:F.identifier({text:n.placeholder})}),name:co}]});e.setSymbolValue(r,i)},ho=({isInfinite:e,operation:t,plugin:n,symbol:r,typeQueryKey:i})=>{let a=ao({operation:t,plugin:n});return F.constVariable({exportConst:r.exported,expression:F.arrowFunction({parameters:[{isRequired:Ze(t),name:`options`,type:a}],returnType:e?i:void 0,statements:po({id:t.id,isInfinite:e,operation:t,plugin:n})}),name:r.placeholder})},go=(e,t,n)=>{let r=e.config[n].meta;if(!r)return;let i=r(t);if(Object.keys(i).length)return F.valueToExpression({value:i})},_o=({plugin:e})=>{let t=e.registerSymbol({meta:{category:`utility`,resource:`createInfiniteParams`,tool:e.name},name:S({config:{case:e.config.case},name:`createInfiniteParams`})}),n=F.constVariable({expression:F.arrowFunction({multiLine:!0,parameters:[{name:`queryKey`,type:F.typeReferenceNode({typeName:`QueryKey<Options>`})},{name:`page`,type:F.typeReferenceNode({typeName:`K`})}],statements:[F.constVariable({expression:F.objectExpression({obj:[{spread:F.propertyAccessExpression({expression:`queryKey`,name:0})}]}),name:`params`}),F.ifStatement({expression:F.propertyAccessExpression({expression:F.identifier({text:`page`}),name:F.identifier({text:`body`})}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`body`}),right:F.objectExpression({multiLine:!0,obj:[{assertion:`any`,spread:`queryKey[0].body`},{assertion:`any`,spread:`page.body`}]})})})]})}),F.ifStatement({expression:F.propertyAccessExpression({expression:F.identifier({text:`page`}),name:F.identifier({text:`headers`})}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`headers`}),right:F.objectExpression({multiLine:!0,obj:[{spread:`queryKey[0].headers`},{spread:`page.headers`}]})})})]})}),F.ifStatement({expression:F.propertyAccessExpression({expression:F.identifier({text:`page`}),name:F.identifier({text:`path`})}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`path`}),right:F.objectExpression({multiLine:!0,obj:[{assertion:`any`,spread:`queryKey[0].path`},{assertion:`any`,spread:`page.path`}]})})})]})}),F.ifStatement({expression:F.propertyAccessExpression({expression:F.identifier({text:`page`}),name:F.identifier({text:`query`})}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`query`}),right:F.objectExpression({multiLine:!0,obj:[{assertion:`any`,spread:`queryKey[0].query`},{assertion:`any`,spread:`page.query`}]})})})]})}),F.returnVariable({expression:F.asExpression({expression:F.asExpression({expression:F.identifier({text:`params`}),type:F.keywordTypeNode({keyword:`unknown`})}),type:l.factory.createTypeQueryNode(F.identifier({text:`page`}))})})],types:[{extends:F.typeReferenceNode({typeName:F.identifier({text:`Pick<QueryKey<Options>[0], 'body' | 'headers' | 'path' | 'query'>`})}),name:`K`}]}),name:t.placeholder});e.setSymbolValue(t,n)},vo=({operation:e,plugin:t,queryFn:n})=>{let r=Qe({context:t.context,operation:e});if(!r)return;let i=ar({context:t.context,operation:e});t.getSymbol({category:`utility`,resource:`createQueryKey`,tool:t.name})||(mo({plugin:t}),fo({plugin:t})),t.getSymbol({category:`utility`,resource:`createInfiniteParams`,tool:t.name})||_o({plugin:t});let a=t.referenceSymbol({category:`external`,resource:`${t.name}.infiniteQueryOptions`}),o=t.referenceSymbol({category:`external`,resource:`${t.name}.InfiniteData`}),s=ao({operation:e,plugin:t}),c=oo({operation:e,plugin:t}),l=so({operation:e,plugin:t}),u=`${t.referenceSymbol({category:`type`,resource:`QueryKey`,tool:t.name}).placeholder}<${s}>`,d=`Pick<${u}[0], 'body' | 'headers' | 'path' | 'query'>`,f=t.getPluginOrThrow(`@hey-api/typescript`),p=`${gt({node:f.api.schemaToType({plugin:f,schema:r.schema,state:{path:{value:[]}}}),unescape:!0})} | ${d}`,m=t.registerSymbol({exported:!0,name:S({config:t.config.infiniteQueryKeys,name:e.id})}),h=ho({isInfinite:!0,operation:e,plugin:t,symbol:m,typeQueryKey:u});t.setSymbolValue(m,h);let g=F.awaitExpression({expression:F.callExpression({functionName:n,parameters:[F.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:`params`},{key:`signal`,shorthand:!0,value:F.identifier({text:`signal`})},{key:`throwOnError`,value:!0}]})]})}),ee=t.referenceSymbol({category:`utility`,resource:`createInfiniteParams`,tool:t.name}),te=[F.constVariable({comment:[{jsdoc:!1,lines:[`@ts-ignore`]}],expression:F.conditionalExpression({condition:F.binaryExpression({left:F.typeOfExpression({text:`pageParam`}),operator:`===`,right:F.ots.string(`object`)}),whenFalse:F.objectExpression({multiLine:!0,obj:[{key:r.in,value:F.objectExpression({multiLine:!0,obj:[{key:r.name,value:F.identifier({text:`pageParam`})}]})}]}),whenTrue:F.identifier({text:`pageParam`})}),name:`page`,typeName:d}),F.constVariable({expression:F.callExpression({functionName:ee.placeholder,parameters:[`queryKey`,`page`]}),name:`params`})];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?te.push(F.returnVariable({expression:g})):te.push(F.constVariable({destructure:!0,expression:g,name:`data`}),F.returnVariable({expression:`data`}));let ne=[{key:`queryFn`,value:F.arrowFunction({async:!0,multiLine:!0,parameters:[{destructure:[{name:`pageParam`},{name:`queryKey`},{name:`signal`}]}],statements:te})},{key:`queryKey`,value:F.callExpression({functionName:m.placeholder,parameters:[`options`]})}],_=go(t,e,`infiniteQueryOptions`);_&&ne.push({key:`meta`,value:_});let v=t.registerSymbol({exported:!0,name:S({config:t.config.infiniteQueryOptions,name:e.id})}),re=F.constVariable({comment:t.config.comments?L({operation:e}):void 0,exportConst:v.exported,expression:F.arrowFunction({parameters:[{isRequired:i,name:`options`,type:s}],statements:[F.returnFunctionCall({args:[F.objectExpression({comments:[{jsdoc:!1,lines:[`@ts-ignore`]}],obj:ne})],name:a.placeholder,types:[l,c||`unknown`,`${o.placeholder}<${l}>`,u,p]})]}),name:v.placeholder});t.setSymbolValue(v,re)},yo=({operation:e,plugin:t,queryFn:n})=>{let r=t.referenceSymbol({category:`external`,resource:`${t.name}.MutationOptions`}),i=ao({operation:e,plugin:t}),a=oo({operation:e,plugin:t}),o=so({operation:e,plugin:t}),s=`${r.placeholder}<${o}, ${a}, ${i}>`,c=`fnOptions`,l=F.awaitExpression({expression:F.callExpression({functionName:n,parameters:[F.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:c},{key:`throwOnError`,value:!0}]})]})}),u=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?u.push(F.returnVariable({expression:l})):u.push(F.constVariable({destructure:!0,expression:l,name:`data`}),F.returnVariable({expression:`data`}));let d=[{key:`mutationFn`,value:F.arrowFunction({async:!0,multiLine:!0,parameters:[{name:c}],statements:u})}],f=go(t,e,`mutationOptions`);f&&d.push({key:`meta`,value:f});let p=`mutationOptions`,m=F.arrowFunction({parameters:[{isRequired:!1,name:`options`,type:`Partial<${i}>`}],returnType:s,statements:[F.constVariable({expression:F.objectExpression({obj:d}),name:p,typeName:s}),F.returnVariable({expression:p})]}),h=t.registerSymbol({exported:!0,name:S({config:t.config.mutationOptions,name:e.id})}),g=F.constVariable({comment:t.config.comments?L({operation:e}):void 0,exportConst:h.exported,expression:m,name:h.placeholder});t.setSymbolValue(h,g)},bo=`options`,xo=({operation:e,plugin:t,queryFn:n})=>{if(or({operation:e}))return;let r=ar({context:t.context,operation:e});t.getSymbol({category:`utility`,resource:`createQueryKey`,tool:t.name})||(mo({plugin:t}),fo({plugin:t}));let i=t.referenceSymbol({category:`external`,resource:`${t.name}.queryOptions`}),a=t.registerSymbol({exported:!0,name:S({config:t.config.queryKeys,name:e.id})}),o=ho({isInfinite:!1,operation:e,plugin:t,symbol:a});t.setSymbolValue(a,o);let s=ao({operation:e,plugin:t}),c=F.awaitExpression({expression:F.callExpression({functionName:n,parameters:[F.objectExpression({multiLine:!0,obj:[{spread:bo},{spread:`queryKey[0]`},{key:`signal`,shorthand:!0,value:F.identifier({text:`signal`})},{key:`throwOnError`,value:!0}]})]})}),l=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?l.push(F.returnVariable({expression:c})):l.push(F.constVariable({destructure:!0,expression:c,name:`data`}),F.returnVariable({expression:`data`}));let u=[{key:`queryFn`,value:F.arrowFunction({async:!0,multiLine:!0,parameters:[{destructure:[{name:`queryKey`},{name:`signal`}]}],statements:l})},{key:`queryKey`,value:F.callExpression({functionName:a.placeholder,parameters:[bo]})}],d=go(t,e,`queryOptions`);d&&u.push({key:`meta`,value:d});let f=t.registerSymbol({exported:t.config.queryOptions.exported,meta:{category:`hook`,resource:`operation`,resourceId:e.id,role:`queryOptions`,tool:t.name},name:S({config:t.config.queryOptions,name:e.id})}),p=F.constVariable({comment:t.config.comments?L({operation:e}):void 0,exportConst:f.exported,expression:F.arrowFunction({parameters:[{isRequired:r,name:bo,type:s}],statements:[F.returnFunctionCall({args:[F.objectExpression({obj:u})],name:i.placeholder})]}),name:f.placeholder});t.setSymbolValue(f,p)},So=`options`,Co=({operation:e,plugin:t})=>{if(or({operation:e})||!(`useQuery`in t.config))return;let n=t.registerSymbol({exported:!0,name:S({config:t.config.useQuery,name:e.id})}),r=t.referenceSymbol({category:`external`,resource:`${t.name}.useQuery`}),i=ar({context:t.context,operation:e}),a=ao({operation:e,plugin:t}),o=t.referenceSymbol({category:`hook`,resource:`operation`,resourceId:e.id,role:`queryOptions`,tool:t.name}),s=F.constVariable({comment:t.config.comments?L({operation:e}):void 0,exportConst:n.exported,expression:F.arrowFunction({parameters:[{isRequired:i,name:So,type:a}],statements:[F.returnStatement({expression:F.callExpression({functionName:r.placeholder,parameters:[F.callExpression({functionName:o.placeholder,parameters:[So]})]})})]}),name:n.placeholder});t.setSymbolValue(n,s)},wo=({plugin:e})=>{e.registerSymbol({external:e.name,kind:`type`,meta:{category:`external`,resource:`${e.name}.DefaultError`},name:`DefaultError`}),e.registerSymbol({external:e.name,kind:`type`,meta:{category:`external`,resource:`${e.name}.InfiniteData`},name:`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,kind:`type`,meta:{category:`external`,resource:`${e.name}.MutationOptions`},name:t}),e.registerSymbol({external:e.name,meta:{category:`external`,resource:`${e.name}.infiniteQueryOptions`},name:`infiniteQueryOptions`}),e.registerSymbol({external:e.name,meta:{category:`external`,resource:`${e.name}.queryOptions`},name:`queryOptions`}),e.registerSymbol({external:e.name,meta:{category:`external`,resource:`${e.name}.useQuery`},name:`useQuery`}),e.registerSymbol({external:`axios`,kind:`type`,meta:{category:`external`,resource:`axios.AxiosError`},name:`AxiosError`});let n=e.getPluginOrThrow(`@hey-api/sdk`);e.forEach(`operation`,({operation:t})=>{let r=n.config.asClass?er({context:e.context,operation:t,plugin:n}):void 0,i=r?r.values().next().value:void 0,a;a=i?[e.referenceSymbol({category:`utility`,resource:`class`,resourceId:i.path[0],tool:`sdk`}).placeholder,...n.config.instance?[Yi,`get()`]:[],...i.path.slice(1).map(e=>x({case:`camelCase`,value:e})),i.methodName].filter(Boolean).join(`.`):e.referenceSymbol({category:`sdk`,resource:`operation`,resourceId:t.id}).placeholder,e.hooks.operation.isQuery(t)&&(e.config.queryOptions.enabled&&xo({operation:t,plugin:e,queryFn:a}),e.config.infiniteQueryOptions.enabled&&vo({operation:t,plugin:e,queryFn:a}),`useQuery`in e.config&&e.config.useQuery.enabled&&Co({operation:t,plugin:e})),e.hooks.operation.isMutation(t)&&e.config.mutationOptions.enabled&&yo({operation:t,plugin:e,queryFn:a})},{order:`declarations`})},To=e=>wo(e),Eo={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:To,name:`@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})}},Do={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:To,name:`@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))}},Oo={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:To,name:`@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})}},ko={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:To,name:`@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})}},Ao={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:To,name:`@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})}},jo=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`data`,tool:`arktype`});if(!n)return;let r=`data`;return F.arrowFunction({async:!0,parameters:[{name:r}],statements:[F.returnStatement({expression:F.awaitExpression({expression:F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:`parseAsync`}),parameters:[F.identifier({text:r})]})})})]})},Mo=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`responses`,tool:`arktype`});if(!n)return;let r=`data`;return F.arrowFunction({async:!0,parameters:[{name:r}],statements:[F.returnStatement({expression:F.awaitExpression({expression:F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:`parseAsync`}),parameters:[F.identifier({text:r})]})})})]})};var No=class{createRequestValidator(e){return jo(e)}createResponseValidator(e){return Mo(e)}};const U={keywords:{false:F.identifier({text:`false`}),true:F.identifier({text:`true`})},number:{Infinity:F.identifier({text:`Infinity`}),NaN:F.identifier({text:`NaN`}),NegativeInfinity:F.identifier({text:`NegativeInfinity`}),epoch:F.identifier({text:`epoch`}),integer:F.identifier({text:`integer`}),safe:F.identifier({text:`safe`})},primitives:{bigint:F.identifier({text:`bigint`}),boolean:F.identifier({text:`boolean`}),keywords:F.identifier({text:`keywords`}),null:`null`,number:F.identifier({text:`number`}),string:`string`,symbol:F.identifier({text:`symbol`}),undefined:F.identifier({text:`undefined`}),unit:F.identifier({text:`unit`})},string:{NFC:F.identifier({text:`NFC`}),NFD:F.identifier({text:`NFD`}),NFKC:F.identifier({text:`NFKC`}),NFKD:F.identifier({text:`NFKD`}),alpha:F.identifier({text:`alpha`}),alphanumeric:F.identifier({text:`alphanumeric`}),base64:F.identifier({text:`base64`}),capitalize:F.identifier({text:`capitalize`}),creditCard:F.identifier({text:`creditCard`}),date:`date`,digits:F.identifier({text:`digits`}),email:`email`,epoch:F.identifier({text:`epoch`}),hex:F.identifier({text:`hex`}),integer:F.identifier({text:`integer`}),ip:`ip`,iso:`iso`,json:F.identifier({text:`json`}),lower:F.identifier({text:`lower`}),normalize:F.identifier({text:`normalize`}),numeric:F.identifier({text:`numeric`}),parse:F.identifier({text:`parse`}),preformatted:F.identifier({text:`preformatted`}),regex:F.identifier({text:`regex`}),semver:F.identifier({text:`semver`}),trim:F.identifier({text:`trim`}),upper:F.identifier({text:`upper`}),url:`url`,uuid:`uuid`,v1:`v1`,v2:`v2`,v3:`v3`,v4:`v4`,v5:`v5`,v6:`v6`,v7:`v7`,v8:`v8`},type:{$:F.identifier({text:`$`}),allows:F.identifier({text:`allows`}),and:F.identifier({text:`and`}),array:F.identifier({text:`array`}),as:F.identifier({text:`as`}),assert:F.identifier({text:`assert`}),brand:F.identifier({text:`brand`}),configure:F.identifier({text:`configure`}),default:F.identifier({text:`default`}),describe:F.identifier({text:`describe`}),description:F.identifier({text:`description`}),equals:F.identifier({text:`equals`}),exclude:F.identifier({text:`exclude`}),expression:F.identifier({text:`expression`}),extends:F.identifier({text:`extends`}),extract:F.identifier({text:`extract`}),filter:F.identifier({text:`filter`}),from:F.identifier({text:`from`}),ifEquals:F.identifier({text:`ifEquals`}),ifExtends:F.identifier({text:`ifExtends`}),infer:F.identifier({text:`infer`}),inferIn:F.identifier({text:`inferIn`}),intersect:F.identifier({text:`intersect`}),json:F.identifier({text:`json`}),meta:F.identifier({text:`meta`}),narrow:F.identifier({text:`narrow`}),onDeepUndeclaredKey:F.identifier({text:`onDeepUndeclaredKey`}),onUndeclaredKey:F.identifier({text:`onUndeclaredKey`}),optional:F.identifier({text:`optional`}),or:F.identifier({text:`or`}),overlaps:F.identifier({text:`overlaps`}),pipe:F.identifier({text:`pipe`}),select:F.identifier({text:`select`}),to:F.identifier({text:`to`}),toJsonSchema:F.identifier({text:`toJsonSchema`})}},Po=({ast:e,plugin:t,schema:n,symbol:r,typeInferSymbol:i})=>{let a=t.referenceSymbol({category:`external`,resource:`arktype.type`}),o=F.constVariable({comment:t.config.comments?ga({schema:n}):void 0,exportConst:r.exported,expression:F.callExpression({functionName:a.placeholder,parameters:[e.def?F.stringLiteral({text:e.def}):e.expression]}),name:r.placeholder});if(t.setSymbolValue(r,o),i){let e=F.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:l.factory.createTypeQueryNode(l.factory.createQualifiedName(l.factory.createIdentifier(r.placeholder),U.type.infer))});t.setSymbolValue(i,e)}},Fo=e=>{let t={};return t.def=U.primitives.null,t},Io=({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=zo({optional:!c,plugin:e,schema:s,state:{...n,path:D([...n.path.value,`properties`,o])}});u.hasLazyExpression&&(r.hasLazyExpression=!0);let d=c?o:`${o}?`;d.endsWith(`?`)?d=l.factory.createComputedPropertyName(F.stringLiteral({text:d})):((d.match(/^[0-9]/)&&d.match(/\D+/g)||d.match(/\W/g))&&!d.startsWith(`'`)&&!d.endsWith(`'`)&&(d=`'${d}'`),k.lastIndex=0,d=k.test(d)?d.startsWith(`-`)?F.stringLiteral({text:o}):l.factory.createNumericLiteral(o):o),i.push(F.propertyAssignment({initializer:u.expression,name:d}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=zo({plugin:e,schema:t.additionalProperties,state:{...n,path:D([...n.path.value,`additionalProperties`])}});return r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:`TODO`,name:`record`}),parameters:[F.callExpression({functionName:F.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},Lo=({schema:e})=>{let t={};if(typeof e.const==`string`)return t.def=e.const,t;let n=U.primitives.string;if(e.format)switch(e.format){case`date`:case`date-time`:case`time`:n=`${n}.${U.string.date}.${U.string.iso}`;break;case`email`:n=`${n}.${U.string.email}`;break;case`ipv4`:n=`${n}.${U.string.ip}.${U.string.v4}`;break;case`ipv6`:n=`${n}.${U.string.ip}.${U.string.v6}`;break;case`uri`:n=`${n}.${U.string.url}`;break;case`uuid`:n=`${n}.${U.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},Ro=({schema:e,...t})=>{switch(e.type){case`null`:return Fo({...t,schema:e});case`object`:return Io({...t,schema:e});case`string`:return Lo({...t,schema:e})}let n=t.plugin.referenceSymbol({category:`external`,resource:`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}},zo=({plugin:e,schema:t,state:n})=>{let r={};if(t.$ref){let i={category:`schema`,resource:`definition`,resourceId:t.$ref,tool:`arktype`},a=e.referenceSymbol(i);e.isSymbolRegistered(i)?r.expression=F.identifier({text:a.placeholder}):(r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:`TODO`,name:`TODO`}),parameters:[F.arrowFunction({returnType:F.keywordTypeNode({keyword:`any`}),statements:[F.returnStatement({expression:F.identifier({text:a.placeholder})})]})]}),r.hasLazyExpression=!0,n.hasLazyExpression.value=!0)}else if(t.type){let i=Ro({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=C({schema:t}),t.items||(r=zo({plugin:e,schema:t,state:n}));else{let t=Ro({plugin:e,schema:{type:`unknown`},state:n});r.def=t.def,r.expression=t.expression}return r.expression||=Ro({plugin:e,schema:{type:`unknown`},state:n}).expression,r},Bo=({plugin:e,schema:t,state:n})=>{let r=qn(n.path.value),i=zo({plugin:e,schema:t,state:n}),a=I(r);Po({ast:i,plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{category:`schema`,path:n.path.value,resource:`definition`,resourceId:r,tags:n.tags?.value,tool:`arktype`},name:S({config:e.config.definitions,name:a})}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`definition`,resourceId:r,tool:`arktype`,variant:`infer`},name:S({config:e.config.definitions.types.infer,name:a})}):void 0})},Vo=({plugin:e})=>{e.registerSymbol({external:`arktype`,meta:{category:`external`,resource:`arktype.type`},name:`type`}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=O({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`parameter`:Bo({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:Bo({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:Bo({plugin:e,schema:t.schema,state:n});break}})},Ho={api:new No,config:{case:`PascalCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:e=>Vo(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:b,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:{...b,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:b,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:{...b,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:b,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:{...b,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:b,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:{...b,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:b,value:e.infer})})},value:e.types})})},value:e.config.webhooks})},tags:[`validator`]},Uo=({operation:e,plugin:t})=>{let n=[],r=t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`data`,tool:`typescript`});r&&(e.body&&n.push({isRequired:e.body.required,name:`Body`,type:`${r.placeholder}['body']`}),e.parameters&&(e.parameters.header&&n.push({isRequired:Je(e.parameters.header),name:`Headers`,type:`${r.placeholder}['headers']`}),e.parameters.path&&n.push({isRequired:Je(e.parameters.path),name:`Params`,type:`${r.placeholder}['path']`}),e.parameters.query&&n.push({isRequired:Je(e.parameters.query),name:`Querystring`,type:`${r.placeholder}['query']`})));let{errors:i,responses:a}=et(e),o,s=t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`errors`});if(s&&i&&i.properties){let e=Object.keys(i.properties);if(e.length){if(!e.includes(`default`))o=F.typeReferenceNode({typeName:s.placeholder});else if(e.length>1){let e=F.typeReferenceNode({typeName:s.placeholder}),t=F.literalTypeNode({literal:F.stringLiteral({text:`default`})});o=F.typeReferenceNode({typeArguments:[e,t],typeName:`Omit`})}}}let c,l=t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`responses`});if(l&&a&&a.properties){let e=Object.keys(a.properties);if(e.length){if(!e.includes(`default`))c=F.typeReferenceNode({typeName:l.placeholder});else if(e.length>1){let e=F.typeReferenceNode({typeName:l.placeholder}),t=F.literalTypeNode({literal:F.stringLiteral({text:`default`})});c=F.typeReferenceNode({typeArguments:[e,t],typeName:`Omit`})}}}let u=[o,c].filter(Boolean);if(u.length&&n.push({name:`Reply`,type:F.typeIntersectionNode({types:u})}),!n.length)return;let d=t.referenceSymbol({category:`type`,resource:`route-handler`,tool:`fastify`});return{name:e.id,type:F.typeReferenceNode({typeArguments:[F.typeInterfaceNode({properties:n,useLegacyResolution:!1})],typeName:d.placeholder})}},Wo={config:{exportFromIndex:!1},dependencies:[`@hey-api/typescript`],handler:({plugin:e})=>{e.registerSymbol({external:`fastify`,kind:`type`,meta:{category:`type`,resource:`route-handler`,tool:`fastify`},name:`RouteHandler`});let t=e.registerSymbol({exported:!0,kind:`type`,name:`RouteHandlers`}),n=[];e.forEach(`operation`,({operation:t})=>{let r=Uo({operation:t,plugin:e});r&&n.push(r)},{order:`declarations`});let r=F.typeAliasDeclaration({exportType:t.exported,name:t.placeholder,type:F.typeInterfaceNode({properties:n,useLegacyResolution:!1})});e.setSymbolValue(t,r)},name:`fastify`},Go=({operation:e,plugin:t,queryFn:n})=>{if(or({operation:e}))return;let r=t.referenceSymbol({category:`external`,resource:`swr`}),i=t.registerSymbol({exported:!0,name:S({config:t.config.useSwr,name:e.id})}),a=F.awaitExpression({expression:F.callExpression({functionName:n,parameters:[F.objectExpression({multiLine:!0,obj:[{key:`throwOnError`,value:!0}]})]})}),o=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?o.push(F.returnVariable({expression:a})):o.push(F.constVariable({destructure:!0,expression:a,name:`data`}),F.returnVariable({expression:`data`}));let s=F.constVariable({comment:t.config.comments?L({operation:e}):void 0,exportConst:i.exported,expression:F.arrowFunction({parameters:[],statements:[F.returnStatement({expression:F.callExpression({functionName:r.placeholder,parameters:[F.stringLiteral({text:e.path}),F.arrowFunction({async:!0,statements:o})]})})]}),name:i.placeholder});t.setSymbolValue(i,s)},Ko=({plugin:e})=>{e.registerSymbol({external:`swr`,importKind:`default`,kind:`function`,meta:{category:`external`,resource:`swr`},name:`useSWR`});let t=e.getPluginOrThrow(`@hey-api/sdk`);e.forEach(`operation`,({operation:n})=>{let r=t.config.asClass?er({context:e.context,operation:n,plugin:t}):void 0,i=r?r.values().next().value:void 0,a=i?[e.referenceSymbol({category:`utility`,resource:`class`,resourceId:i.path[0],tool:`sdk`}).placeholder,...i.path.slice(1).map(e=>x({case:`camelCase`,value:e})),i.methodName].filter(Boolean).join(`.`):e.referenceSymbol({category:`sdk`,resource:`operation`,resourceId:n.id}).placeholder;e.hooks.operation.isQuery(n)&&e.config.useSwr.enabled&&Go({operation:n,plugin:e,queryFn:a})},{order:`declarations`})},qo={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:e=>Ko(e),name:`swr`,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.useSwr=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`use{{name}}`},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.useSwr}),e.config.useSwr.enabled&&(e.config.queryOptions.enabled||(e.config.queryOptions.enabled=!0,e.config.queryOptions.exported=!1))}},W={actions:{args:F.identifier({text:`args`}),base64:F.identifier({text:`base64`}),bic:F.identifier({text:`bic`}),brand:F.identifier({text:`brand`}),bytes:F.identifier({text:`bytes`}),check:F.identifier({text:`check`}),checkItems:F.identifier({text:`checkItems`}),creditCard:F.identifier({text:`creditCard`}),cuid2:F.identifier({text:`cuid2`}),decimal:F.identifier({text:`decimal`}),description:F.identifier({text:`description`}),digits:F.identifier({text:`digits`}),email:F.identifier({text:`email`}),emoji:F.identifier({text:`emoji`}),empty:F.identifier({text:`empty`}),endsWith:F.identifier({text:`endsWith`}),entries:F.identifier({text:`entries`}),everyItem:F.identifier({text:`everyItem`}),excludes:F.identifier({text:`excludes`}),filterItems:F.identifier({text:`filterItems`}),findItem:F.identifier({text:`findItem`}),finite:F.identifier({text:`finite`}),flavor:F.identifier({text:`flavor`}),graphemes:F.identifier({text:`graphemes`}),gtValue:F.identifier({text:`gtValue`}),hash:F.identifier({text:`hash`}),hexColor:F.identifier({text:`hexColor`}),hexadecimal:F.identifier({text:`hexadecimal`}),imei:F.identifier({text:`imei`}),includes:F.identifier({text:`includes`}),integer:F.identifier({text:`integer`}),ip:F.identifier({text:`ip`}),ipv4:F.identifier({text:`ipv4`}),ipv6:F.identifier({text:`ipv6`}),isoDate:F.identifier({text:`isoDate`}),isoDateTime:F.identifier({text:`isoDateTime`}),isoTime:F.identifier({text:`isoTime`}),isoTimeSecond:F.identifier({text:`isoTimeSecond`}),isoTimestamp:F.identifier({text:`isoTimestamp`}),isoWeek:F.identifier({text:`isoWeek`}),length:F.identifier({text:`length`}),ltValue:F.identifier({text:`ltValue`}),mac:F.identifier({text:`mac`}),mac48:F.identifier({text:`mac48`}),mac64:F.identifier({text:`mac64`}),mapItems:F.identifier({text:`mapItems`}),maxBytes:F.identifier({text:`maxBytes`}),maxEntries:F.identifier({text:`maxEntries`}),maxGraphemes:F.identifier({text:`maxGraphemes`}),maxLength:F.identifier({text:`maxLength`}),maxSize:F.identifier({text:`maxSize`}),maxValue:F.identifier({text:`maxValue`}),maxWords:F.identifier({text:`maxWords`}),metadata:F.identifier({text:`metadata`}),mimeType:F.identifier({text:`mimeType`}),minBytes:F.identifier({text:`minBytes`}),minEntries:F.identifier({text:`minEntries`}),minGraphemes:F.identifier({text:`minGraphemes`}),minLength:F.identifier({text:`minLength`}),minSize:F.identifier({text:`minSize`}),minValue:F.identifier({text:`minValue`}),minWords:F.identifier({text:`minWords`}),multipleOf:F.identifier({text:`multipleOf`}),nanoid:F.identifier({text:`nanoid`}),nonEmpty:F.identifier({text:`nonEmpty`}),normalize:F.identifier({text:`normalize`}),notBytes:F.identifier({text:`notBytes`}),notEntries:F.identifier({text:`notEntries`}),notGraphemes:F.identifier({text:`notGraphemes`}),notLength:F.identifier({text:`notLength`}),notSize:F.identifier({text:`notSize`}),notValue:F.identifier({text:`notValue`}),notValues:F.identifier({text:`notValues`}),notWords:F.identifier({text:`notWords`}),octal:F.identifier({text:`octal`}),parseJson:F.identifier({text:`parseJson`}),partialCheck:F.identifier({text:`partialCheck`}),rawCheck:F.identifier({text:`rawCheck`}),rawTransform:F.identifier({text:`rawTransform`}),readonly:F.identifier({text:`readonly`}),reduceItems:F.identifier({text:`reduceItems`}),regex:F.identifier({text:`regex`}),returns:F.identifier({text:`returns`}),rfcEmail:F.identifier({text:`rfcEmail`}),safeInteger:F.identifier({text:`safeInteger`}),size:F.identifier({text:`size`}),slug:F.identifier({text:`slug`}),someItem:F.identifier({text:`someItem`}),sortItems:F.identifier({text:`sortItems`}),startsWith:F.identifier({text:`startsWith`}),stringifyJson:F.identifier({text:`stringifyJson`}),title:F.identifier({text:`title`}),toLowerCase:F.identifier({text:`toLowerCase`}),toMaxValue:F.identifier({text:`toMaxValue`}),toMinValue:F.identifier({text:`toMinValue`}),toUpperCase:F.identifier({text:`toUpperCase`}),transform:F.identifier({text:`transform`}),trim:F.identifier({text:`trim`}),trimEnd:F.identifier({text:`trimEnd`}),trimStart:F.identifier({text:`trimStart`}),ulid:F.identifier({text:`ulid`}),url:F.identifier({text:`url`}),uuid:F.identifier({text:`uuid`}),value:F.identifier({text:`value`}),values:F.identifier({text:`values`}),words:F.identifier({text:`words`})},async:{argsAsync:F.identifier({text:`argsAsync`}),arrayAsync:F.identifier({text:`arrayAsync`}),awaitAsync:F.identifier({text:`awaitAsync`}),checkAsync:F.identifier({text:`checkAsync`}),checkItemsAsync:F.identifier({text:`checkItemsAsync`}),customAsync:F.identifier({text:`customAsync`}),exactOptionalAsync:F.identifier({text:`exactOptionalAsync`}),fallbackAsync:F.identifier({text:`fallbackAsync`}),forwardAsync:F.identifier({text:`forwardAsync`}),getDefaultsAsync:F.identifier({text:`getDefaultsAsync`}),getFallbacksAsync:F.identifier({text:`getFallbacksAsync`}),intersectAsync:F.identifier({text:`intersectAsync`}),lazyAsync:F.identifier({text:`lazyAsync`}),looseObjectAsync:F.identifier({text:`looseObjectAsync`}),looseTupleAsync:F.identifier({text:`looseTupleAsync`}),mapAsync:F.identifier({text:`mapAsync`}),nonNullableAsync:F.identifier({text:`nonNullableAsync`}),nonNullishAsync:F.identifier({text:`nonNullishAsync`}),nonOptionalAsync:F.identifier({text:`nonOptionalAsync`}),nullableAsync:F.identifier({text:`nullableAsync`}),nullishAsync:F.identifier({text:`nullishAsync`}),objectAsync:F.identifier({text:`objectAsync`}),objectWithRestAsync:F.identifier({text:`objectWithRestAsync`}),optionalAsync:F.identifier({text:`optionalAsync`}),parseAsync:F.identifier({text:`parseAsync`}),parserAsync:F.identifier({text:`parserAsync`}),partialAsync:F.identifier({text:`partialAsync`}),partialCheckAsync:F.identifier({text:`partialCheckAsync`}),pipeAsync:F.identifier({text:`pipeAsync`}),rawCheckAsync:F.identifier({text:`rawCheckAsync`}),rawTransformAsync:F.identifier({text:`rawTransformAsync`}),recordAsync:F.identifier({text:`recordAsync`}),requiredAsync:F.identifier({text:`requiredAsync`}),returnsAsync:F.identifier({text:`returnsAsync`}),safeParseAsync:F.identifier({text:`safeParseAsync`}),safeParserAsync:F.identifier({text:`safeParserAsync`}),setAsync:F.identifier({text:`setAsync`}),strictObjectAsync:F.identifier({text:`strictObjectAsync`}),strictTupleAsync:F.identifier({text:`strictTupleAsync`}),transformAsync:F.identifier({text:`transformAsync`}),tupleAsync:F.identifier({text:`tupleAsync`}),tupleWithRestAsync:F.identifier({text:`tupleWithRestAsync`}),undefinedableAsync:F.identifier({text:`undefinedableAsync`}),unionAsync:F.identifier({text:`unionAsync`}),variantAsync:F.identifier({text:`variantAsync`})},methods:{assert:F.identifier({text:`assert`}),config:F.identifier({text:`config`}),fallback:F.identifier({text:`fallback`}),flatten:F.identifier({text:`flatten`}),forward:F.identifier({text:`forward`}),getDefault:F.identifier({text:`getDefault`}),getDefaults:F.identifier({text:`getDefaults`}),getDescription:F.identifier({text:`getDescription`}),getFallback:F.identifier({text:`getFallback`}),getFallbacks:F.identifier({text:`getFallbacks`}),getMetadata:F.identifier({text:`getMetadata`}),getTitle:F.identifier({text:`getTitle`}),is:F.identifier({text:`is`}),keyof:F.identifier({text:`keyof`}),message:F.identifier({text:`message`}),omit:F.identifier({text:`omit`}),parse:F.identifier({text:`parse`}),parser:F.identifier({text:`parser`}),partial:F.identifier({text:`partial`}),pick:F.identifier({text:`pick`}),pipe:F.identifier({text:`pipe`}),required:F.identifier({text:`required`}),safeParse:F.identifier({text:`safeParse`}),safeParser:F.identifier({text:`safeParser`}),summarize:F.identifier({text:`summarize`}),unwrap:F.identifier({text:`unwrap`})},schemas:{any:F.identifier({text:`any`}),array:F.identifier({text:`array`}),bigInt:F.identifier({text:`bigint`}),blob:F.identifier({text:`blob`}),boolean:F.identifier({text:`boolean`}),custom:F.identifier({text:`custom`}),date:F.identifier({text:`date`}),enum:F.identifier({text:`enum`}),exactOptional:F.identifier({text:`exactOptional`}),file:F.identifier({text:`file`}),function:F.identifier({text:`function`}),instance:F.identifier({text:`instance`}),intersect:F.identifier({text:`intersect`}),lazy:F.identifier({text:`lazy`}),literal:F.identifier({text:`literal`}),looseObject:F.identifier({text:`looseObject`}),looseTuple:F.identifier({text:`looseTuple`}),map:F.identifier({text:`map`}),nan:F.identifier({text:`nan`}),never:F.identifier({text:`never`}),nonNullable:F.identifier({text:`nonNullable`}),nonNullish:F.identifier({text:`nonNullish`}),nonOptional:F.identifier({text:`nonOptional`}),null:F.identifier({text:`null`}),nullable:F.identifier({text:`nullable`}),nullish:F.identifier({text:`nullish`}),number:F.identifier({text:`number`}),object:F.identifier({text:`object`}),objectWithRest:F.identifier({text:`objectWithRest`}),optional:F.identifier({text:`optional`}),picklist:F.identifier({text:`picklist`}),promise:F.identifier({text:`promise`}),record:F.identifier({text:`record`}),set:F.identifier({text:`set`}),strictObject:F.identifier({text:`strictObject`}),strictTuple:F.identifier({text:`strictTuple`}),string:F.identifier({text:`string`}),symbol:F.identifier({text:`symbol`}),tuple:F.identifier({text:`tuple`}),tupleWithRest:F.identifier({text:`tupleWithRest`}),undefined:F.identifier({text:`undefined`}),undefinedable:F.identifier({text:`undefinedable`}),union:F.identifier({text:`union`}),unknown:F.identifier({text:`unknown`}),variant:F.identifier({text:`variant`}),void:F.identifier({text:`void`})},storages:{},types:{GenericSchema:F.identifier({text:`GenericSchema`})},utils:{}},Jo=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`data`,tool:`valibot`});if(!n)return;let r=t.referenceSymbol({category:`external`,resource:`valibot.v`}),i=`data`;return F.arrowFunction({async:!0,parameters:[{name:i}],statements:[F.returnStatement({expression:F.awaitExpression({expression:F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:W.async.parseAsync}),parameters:[F.identifier({text:n.placeholder}),F.identifier({text:i})]})})})]})},Yo=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`responses`,tool:`valibot`});if(!n)return;let r=t.referenceSymbol({category:`external`,resource:`valibot.v`}),i=`data`;return F.arrowFunction({async:!0,parameters:[{name:i}],statements:[F.returnStatement({expression:F.awaitExpression({expression:F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:W.async.parseAsync}),parameters:[F.identifier({text:n.placeholder}),F.identifier({text:i})]})})})]})};var Xo=class{createRequestValidator(e){return Jo(e)}createResponseValidator(e){return Yo(e)}};const G=({pipes:e,plugin:t})=>{if(e.length===1)return e[0];let n=t.referenceSymbol({category:`external`,resource:`valibot.v`});return F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:W.methods.pipe}),parameters:e})},Zo=({ast:e,plugin:t,schema:n,state:r,symbol:i})=>{let a=t.referenceSymbol({category:`external`,resource:`valibot.v`}),o=F.constVariable({comment:t.config.comments?ga({schema:n}):void 0,exportConst:i.exported,expression:G({pipes:e.pipes,plugin:t}),name:i.placeholder,typeName:r.hasLazyExpression.value?F.propertyAccessExpression({expression:a.placeholder,name:e.typeName||W.types.GenericSchema.text}):void 0});t.setSymbolValue(i,o)},Qo={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}},$o=e=>e!==void 0&&e in Qo,es=e=>$o(e)&&Qo[e].needsBigInt,ts=({isBigInt:e,value:t})=>{let n=F.valueToExpression({value:t});return e&&(typeof t==`bigint`||typeof t==`number`||typeof t==`string`||typeof t==`boolean`)?F.callExpression({functionName:`BigInt`,parameters:[n]}):n},ns=({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],Zo({ast:e(a,r.path.value),plugin:n,schema:a,state:r,symbol:n.registerSymbol({exported:!0,meta:{category:`schema`,path:r.path.value,resource:`operation`,resourceId:t.id,role:`data`,tags:r.tags?.value,tool:`valibot`},name:S({config:n.config.requests,name:t.id})})})}if(n.config.responses.enabled&&t.responses){let{response:i}=et(t);if(i){let a=[...r.path.value,`responses`];Zo({ast:e(i,a),plugin:n,schema:i,state:r,symbol:n.registerSymbol({exported:!0,meta:{category:`schema`,path:a,resource:`operation`,resourceId:t.id,role:`responses`,tags:r.tags?.value,tool:`valibot`},name:S({config:n.config.responses,name:t.id})})})}}},rs=({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],Zo({ast:e(a,r.path.value),plugin:n,schema:a,state:r,symbol:n.registerSymbol({exported:!0,meta:{category:`schema`,path:r.path.value,resource:`webhook`,resourceId:t.id,role:`data`,tags:r.tags?.value,tool:`valibot`},name:S({config:n.config.webhooks,name:t.id})})})}},is=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`valibot.v`});return F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:W.schemas.unknown})})},as=({plugin:e,schema:t,state:n})=>{let r={pipes:[]},i=e.referenceSymbol({category:`external`,resource:`valibot.v`}),a=F.propertyAccessExpression({expression:i.placeholder,name:W.schemas.array});if(t.items){t=C({schema:t});let i=t.items.map((t,i)=>{let a=_s({plugin:e,schema:t,state:{...n,path:D([...n.path.value,`items`,i])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),G({pipes:a.pipes,plugin:e})});if(i.length===1){let e=F.callExpression({functionName:a,parameters:i});r.pipes.push(e)}else{t.logicalOperator;let i=F.callExpression({functionName:a,parameters:[is({plugin:e,schema:{type:`unknown`},state:n})]});r.pipes.push(i)}}else{let t=F.callExpression({functionName:a,parameters:[is({plugin:e,schema:{type:`unknown`},state:n})]});r.pipes.push(t)}if(t.minItems===t.maxItems&&t.minItems!==void 0){let e=F.callExpression({functionName:F.propertyAccessExpression({expression:i.placeholder,name:W.actions.length}),parameters:[F.valueToExpression({value:t.minItems})]});r.pipes.push(e)}else{if(t.minItems!==void 0){let e=F.callExpression({functionName:F.propertyAccessExpression({expression:i.placeholder,name:W.actions.minLength}),parameters:[F.valueToExpression({value:t.minItems})]});r.pipes.push(e)}if(t.maxItems!==void 0){let e=F.callExpression({functionName:F.propertyAccessExpression({expression:i.placeholder,name:W.actions.maxLength}),parameters:[F.valueToExpression({value:t.maxItems})]});r.pipes.push(e)}}return r},os=({plugin:e,schema:t})=>{let n=e.referenceSymbol({category:`external`,resource:`valibot.v`});return typeof t.const==`boolean`?F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:W.schemas.literal}),parameters:[F.ots.boolean(t.const)]}):F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:W.schemas.boolean})})},ss=({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(F.stringLiteral({text:e.const})):(e.type===`null`||e.const===null)&&(i=!0);if(!r.length)return is({plugin:e,schema:{type:`unknown`},state:n});let a=e.referenceSymbol({category:`external`,resource:`valibot.v`}),o=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:W.schemas.picklist}),parameters:[F.arrayLiteralExpression({elements:r,multiLine:!1})]});return i&&(o=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:W.schemas.nullable}),parameters:[o]})),o},cs=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`valibot.v`});return F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:W.schemas.never})})},ls=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`valibot.v`});return F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:W.schemas.null})})},us=({plugin:e,schema:t})=>{let n=t.format,r=t.type===`integer`,i=es(n),a=$o(n)?Qo[n]:null,o=e.referenceSymbol({category:`external`,resource:`valibot.v`});if(t.const!==void 0&&t.const!==null){let e=t.const,r;if(typeof e==`number`&&!n)r=F.ots.number(e);else if(typeof e==`number`&&n)r=i?F.callExpression({functionName:`BigInt`,parameters:[F.ots.string(e.toString())]}):F.ots.number(e);else if(typeof e==`string`&&i){let t=e.endsWith(`n`)?e.slice(0,-1):e;r=F.callExpression({functionName:`BigInt`,parameters:[F.ots.string(t)]})}else if(typeof e==`bigint`){let t=e.toString(),n=t.endsWith(`n`)?t.slice(0,-1):t;r=F.callExpression({functionName:`BigInt`,parameters:[F.ots.string(n)]})}else r=F.valueToExpression({value:e});return F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:W.schemas.literal}),parameters:[r]})}let s=[];if(i){let e=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:W.schemas.union}),parameters:[F.arrayLiteralExpression({elements:[F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:W.schemas.number})}),F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:W.schemas.string})}),F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:W.schemas.bigInt})})],multiLine:!1})]});s.push(e);let t=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:W.actions.transform}),parameters:[F.arrowFunction({parameters:[{name:`x`}],statements:F.callExpression({functionName:`BigInt`,parameters:[F.identifier({text:`x`})]})})]});s.push(t)}else{let e=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:W.schemas.number})});s.push(e)}if(!i&&r){let e=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:W.actions.integer})});s.push(e)}if(a){let e=a.min,t=a.max,n=a.minError,r=a.maxError,c=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:W.actions.minValue}),parameters:[i?F.callExpression({functionName:`BigInt`,parameters:[F.ots.string(e.toString())]}):F.ots.number(e),F.ots.string(n)]});s.push(c);let l=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:W.actions.maxValue}),parameters:[i?F.callExpression({functionName:`BigInt`,parameters:[F.ots.string(t.toString())]}):F.ots.number(t),F.ots.string(r)]});s.push(l)}if(t.exclusiveMinimum!==void 0){let e=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:W.actions.gtValue}),parameters:[ts({isBigInt:i,value:t.exclusiveMinimum})]});s.push(e)}else if(t.minimum!==void 0){let e=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:W.actions.minValue}),parameters:[ts({isBigInt:i,value:t.minimum})]});s.push(e)}if(t.exclusiveMaximum!==void 0){let e=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:W.actions.ltValue}),parameters:[ts({isBigInt:i,value:t.exclusiveMaximum})]});s.push(e)}else if(t.maximum!==void 0){let e=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:W.actions.maxValue}),parameters:[ts({isBigInt:i,value:t.maximum})]});s.push(e)}return G({pipes:s,plugin:e})},ds=({plugin:e,schema:t,state:n})=>{let r={},i=[],a=t.required??[];for(let o in t.properties){let s=t.properties[o],c=_s({optional:!a.includes(o),plugin:e,schema:s,state:{...n,path:D([...n.path.value,`properties`,o])}});c.hasLazyExpression&&(r.hasLazyExpression=!0),k.lastIndex=0;let u;u=k.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(F.propertyAssignment({initializer:G({pipes:c.pipes,plugin:e}),name:u}))}let o=e.referenceSymbol({category:`external`,resource:`valibot.v`});if(t.additionalProperties&&typeof t.additionalProperties==`object`&&t.additionalProperties.type!==void 0){let a=_s({plugin:e,schema:t.additionalProperties,state:{...n,path:D([...n.path.value,`additionalProperties`])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),Object.keys(i).length?(r.pipes=[F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:W.schemas.objectWithRest}),parameters:[l.factory.createObjectLiteralExpression(i,!0),G({pipes:a.pipes,plugin:e})]})],r):(r.pipes=[F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:W.schemas.record}),parameters:[F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:W.schemas.string}),parameters:[]}),G({pipes:a.pipes,plugin:e})]})],r)}return r.pipes=[F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:W.schemas.object}),parameters:[l.factory.createObjectLiteralExpression(i,!0)]})],r},fs=({plugin:e,schema:t})=>{let n=e.referenceSymbol({category:`external`,resource:`valibot.v`});if(typeof t.const==`string`)return F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:W.schemas.literal}),parameters:[F.ots.string(t.const)]});let r=[],i=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:W.schemas.string})});if(r.push(i),t.format)switch(t.format){case`date`:r.push(F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:W.actions.isoDate})}));break;case`date-time`:r.push(F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:W.actions.isoTimestamp})}));break;case`ipv4`:case`ipv6`:r.push(F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:W.actions.ip})}));break;case`time`:r.push(F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:W.actions.isoTimeSecond})}));break;case`uri`:r.push(F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:W.actions.url})}));break;case`email`:case`uuid`:r.push(F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:F.identifier({text:t.format})})}));break}if(t.minLength===t.maxLength&&t.minLength!==void 0){let e=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:W.actions.length}),parameters:[F.valueToExpression({value:t.minLength})]});r.push(e)}else{if(t.minLength!==void 0){let e=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:W.actions.minLength}),parameters:[F.valueToExpression({value:t.minLength})]});r.push(e)}if(t.maxLength!==void 0){let e=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:W.actions.maxLength}),parameters:[F.valueToExpression({value:t.maxLength})]});r.push(e)}}if(t.pattern){let e=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:W.actions.regex}),parameters:[F.regularExpressionLiteral({text:t.pattern})]});r.push(e)}return G({pipes:r,plugin:e})},ps=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol({category:`external`,resource:`valibot.v`});if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>F.callExpression({functionName:F.propertyAccessExpression({expression:i.placeholder,name:W.schemas.literal}),parameters:[F.valueToExpression({value:e})]}));return r.pipes=[F.callExpression({functionName:F.propertyAccessExpression({expression:i.placeholder,name:W.schemas.tuple}),parameters:[F.arrayLiteralExpression({elements:e})]})],r}if(t.items){let a=t.items.map((t,i)=>{let a=_s({plugin:e,schema:t,state:{...n,path:D([...n.path.value,`items`,i])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),G({pipes:a.pipes,plugin:e})});return r.pipes=[F.callExpression({functionName:F.propertyAccessExpression({expression:i.placeholder,name:W.schemas.tuple}),parameters:[F.arrayLiteralExpression({elements:a})]})],r}return{pipes:[is({plugin:e,schema:{type:`unknown`},state:n})]}},ms=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`valibot.v`});return F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:W.schemas.undefined})})},hs=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`valibot.v`});return F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:W.schemas.void})})},gs=({schema:e,...t})=>{switch(e.type){case`array`:return{expression:G({pipes:as({...t,schema:e}).pipes,plugin:t.plugin})};case`boolean`:return{expression:os({...t,schema:e})};case`enum`:return{expression:ss({...t,schema:e})};case`integer`:case`number`:return{expression:us({...t,schema:e})};case`never`:return{expression:cs({...t,schema:e})};case`null`:return{expression:ls({...t,schema:e})};case`object`:return{expression:G({pipes:ds({...t,schema:e}).pipes,plugin:t.plugin})};case`string`:return e.format===`int64`||e.format===`uint64`?{expression:us({...t,schema:e})}:{expression:fs({...t,schema:e})};case`tuple`:return{expression:G({pipes:ps({...t,schema:e}).pipes,plugin:t.plugin})};case`undefined`:return{expression:ms({...t,schema:e})};case`unknown`:return{expression:is({...t,schema:e})};case`void`:return{expression:hs({...t,schema:e})}}},_s=({optional:e,plugin:t,schema:n,state:r})=>{let i={pipes:[]},a=t.referenceSymbol({category:`external`,resource:`valibot.v`});if(n.$ref){let e={category:`schema`,resource:`definition`,resourceId:n.$ref,tool:`valibot`},o=t.referenceSymbol(e);if(t.isSymbolRegistered(e)){let e=F.identifier({text:o.placeholder});i.pipes.push(e)}else{let e=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:W.schemas.lazy}),parameters:[F.arrowFunction({statements:[F.returnStatement({expression:F.identifier({text:o.placeholder})})]})]});i.pipes.push(e),r.hasLazyExpression.value=!0}}else if(n.type){let e=gs({plugin:t,schema:n,state:r});if(i.typeName=e.anyType,i.pipes.push(e.expression),t.config.metadata&&n.description){let e=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:W.actions.metadata}),parameters:[F.objectExpression({obj:[{key:`description`,value:F.stringLiteral({text:n.description})}]})]});i.pipes.push(e)}}else if(n.items)if(n=C({schema:n}),n.items){let e=n.items.map((e,n)=>G({pipes:_s({plugin:t,schema:e,state:{...r,path:D([...r.path.value,`items`,n])}}).pipes,plugin:t}));if(n.logicalOperator===`and`){let t=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:W.schemas.intersect}),parameters:[F.arrayLiteralExpression({elements:e})]});i.pipes.push(t)}else{let t=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:W.schemas.union}),parameters:[F.arrayLiteralExpression({elements:e})]});i.pipes.push(t)}}else{let e=_s({plugin:t,schema:n,state:r});i.pipes.push(...e.pipes)}else{let e=gs({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=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:W.actions.readonly})});i.pipes.push(e)}let r;n.default!==void 0&&(r=ts({isBigInt:n.type===`integer`&&n.format===`int64`,value:n.default}),r&&(i.pipes=[F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:W.schemas.optional}),parameters:[G({pipes:i.pipes,plugin:t}),r]})])),e&&!r&&(i.pipes=[F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:W.schemas.optional}),parameters:[G({pipes:i.pipes,plugin:t})]})])}return i},vs=({plugin:e,schema:t,state:n})=>{let r=qn(n.path.value),i=_s({plugin:e,schema:t,state:n}),a=I(r);Zo({ast:i,plugin:e,schema:t,state:n,symbol:e.registerSymbol({exported:!0,meta:{category:`schema`,path:n.path.value,resource:`definition`,resourceId:r,tags:n.tags?.value,tool:`valibot`},name:S({config:e.config.definitions,name:a})})})},ys=({plugin:e})=>{e.registerSymbol({external:`valibot`,importKind:`namespace`,meta:{category:`external`,resource:`valibot.v`},name:`v`}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=O({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:ns({getAst:(n,r)=>_s({plugin:e,schema:n,state:O({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:vs({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:vs({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:vs({plugin:e,schema:t.schema,state:n});break;case`webhook`:rs({getAst:(n,r)=>_s({plugin:e,schema:n,state:O({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},bs={api:new Xo,config:{case:`camelCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:e=>ys(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`]},K={ZodMiniOptional:F.identifier({text:`ZodMiniOptional`}),ZodOptional:F.identifier({text:`ZodOptional`}),_default:F.identifier({text:`_default`}),and:F.identifier({text:`and`}),array:F.identifier({text:`array`}),bigint:F.identifier({text:`bigint`}),boolean:F.identifier({text:`boolean`}),check:F.identifier({text:`check`}),coerce:F.identifier({text:`coerce`}),date:F.identifier({text:`date`}),datetime:F.identifier({text:`datetime`}),default:F.identifier({text:`default`}),describe:F.identifier({text:`describe`}),email:F.identifier({text:`email`}),enum:F.identifier({text:`enum`}),globalRegistry:F.identifier({text:`globalRegistry`}),gt:F.identifier({text:`gt`}),gte:F.identifier({text:`gte`}),infer:F.identifier({text:`infer`}),int:F.identifier({text:`int`}),intersection:F.identifier({text:`intersection`}),ip:F.identifier({text:`ip`}),ipv4:F.identifier({text:`ipv4`}),ipv6:F.identifier({text:`ipv6`}),iso:F.identifier({text:`iso`}),lazy:F.identifier({text:`lazy`}),length:F.identifier({text:`length`}),literal:F.identifier({text:`literal`}),lt:F.identifier({text:`lt`}),lte:F.identifier({text:`lte`}),max:F.identifier({text:`max`}),maxLength:F.identifier({text:`maxLength`}),min:F.identifier({text:`min`}),minLength:F.identifier({text:`minLength`}),never:F.identifier({text:`never`}),null:F.identifier({text:`null`}),nullable:F.identifier({text:`nullable`}),number:F.identifier({text:`number`}),object:F.identifier({text:`object`}),optional:F.identifier({text:`optional`}),parseAsync:F.identifier({text:`parseAsync`}),readonly:F.identifier({text:`readonly`}),record:F.identifier({text:`record`}),regex:F.identifier({text:`regex`}),register:F.identifier({text:`register`}),string:F.identifier({text:`string`}),time:F.identifier({text:`time`}),tuple:F.identifier({text:`tuple`}),undefined:F.identifier({text:`undefined`}),union:F.identifier({text:`union`}),unknown:F.identifier({text:`unknown`}),url:F.identifier({text:`url`}),uuid:F.identifier({text:`uuid`}),void:F.identifier({text:`void`})},xs=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`data`,tool:`zod`});if(!n)return;let r=`data`;return F.arrowFunction({async:!0,parameters:[{name:r}],statements:[F.returnStatement({expression:F.awaitExpression({expression:F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.parseAsync}),parameters:[F.identifier({text:r})]})})})]})},Ss=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`responses`,tool:`zod`});if(!n)return;let r=`data`;return F.arrowFunction({async:!0,parameters:[{name:r}],statements:[F.returnStatement({expression:F.awaitExpression({expression:F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.parseAsync}),parameters:[F.identifier({text:r})]})})})]})},Cs=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`data`,tool:`zod`});if(!n)return;let r=`data`;return F.arrowFunction({async:!0,parameters:[{name:r}],statements:[F.returnStatement({expression:F.awaitExpression({expression:F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.parseAsync}),parameters:[F.identifier({text:r})]})})})]})},ws=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`responses`,tool:`zod`});if(!n)return;let r=`data`;return F.arrowFunction({async:!0,parameters:[{name:r}],statements:[F.returnStatement({expression:F.awaitExpression({expression:F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.parseAsync}),parameters:[F.identifier({text:r})]})})})]})},Ts=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`data`,tool:`zod`});if(!n)return;let r=`data`;return F.arrowFunction({async:!0,parameters:[{name:r}],statements:[F.returnStatement({expression:F.awaitExpression({expression:F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.parseAsync}),parameters:[F.identifier({text:r})]})})})]})},Es=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`responses`,tool:`zod`});if(!n)return;let r=`data`;return F.arrowFunction({async:!0,parameters:[{name:r}],statements:[F.returnStatement({expression:F.awaitExpression({expression:F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.parseAsync}),parameters:[F.identifier({text:r})]})})})]})};var Ds=class{createRequestValidator(e){let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return Cs(e);case`mini`:return xs(e);case 4:default:return Ts(e)}}createResponseValidator(e){let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return ws(e);case`mini`:return Ss(e);case 4:default:return Es(e)}}};const Os=({ast:e,plugin:t,schema:n,symbol:r,typeInferSymbol:i})=>{let a=t.referenceSymbol({category:`external`,resource:`zod.z`}),o=F.constVariable({comment:t.config.comments?ga({schema:n}):void 0,exportConst:r.exported,expression:e.expression,name:r.placeholder,typeName:e.typeName?F.propertyAccessExpression({expression:a.placeholder,name:e.typeName}):void 0});if(t.setSymbolValue(r,o),i){let e=F.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:F.typeReferenceNode({typeArguments:[F.typeOfExpression({text:r.placeholder})],typeName:F.propertyAccessExpression({expression:a.placeholder,name:K.infer})})});t.setSymbolValue(i,e)}},ks=({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`}},q=({isBigInt:e,value:t})=>{let n=F.valueToExpression({value:t});return e&&(typeof t==`bigint`||typeof t==`number`||typeof t==`string`||typeof t==`boolean`)?F.callExpression({functionName:`BigInt`,parameters:[n]}):n},As=({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],Os({ast:e(a,r.path.value),plugin:n,schema:a,symbol:n.registerSymbol({exported:!0,meta:{category:`schema`,path:r.path.value,resource:`operation`,resourceId:t.id,role:`data`,tags:r.tags?.value,tool:`zod`},name:S({config:n.config.requests,name:t.id})}),typeInferSymbol:n.config.requests.types.infer.enabled?n.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:r.path.value,resource:`operation`,resourceId:t.id,role:`data`,tags:r.tags?.value,tool:`zod`,variant:`infer`},name:S({config:n.config.requests.types.infer,name:t.id})}):void 0})}if(n.config.responses.enabled&&t.responses){let{response:i}=et(t);if(i){let a=[...r.path.value,`responses`];Os({ast:e(i,a),plugin:n,schema:i,symbol:n.registerSymbol({exported:!0,meta:{category:`schema`,path:a,resource:`operation`,resourceId:t.id,role:`responses`,tags:r.tags?.value,tool:`zod`},name:S({config:n.config.responses,name:t.id})}),typeInferSymbol:n.config.responses.types.infer.enabled?n.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:a,resource:`operation`,resourceId:t.id,role:`responses`,tags:r.tags?.value,tool:`zod`,variant:`infer`},name:S({config:n.config.responses.types.infer,name:t.id})}):void 0})}}},js=({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],Os({ast:e(a,r.path.value),plugin:n,schema:a,symbol:n.registerSymbol({exported:!0,meta:{category:`schema`,path:r.path.value,resource:`webhook`,resourceId:t.id,role:`data`,tags:r.tags?.value,tool:`zod`},name:S({config:n.config.webhooks,name:t.id})}),typeInferSymbol:n.config.webhooks.types.infer.enabled?n.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:r.path.value,resource:`webhook`,resourceId:t.id,role:`data`,tags:r.tags?.value,tool:`zod`,variant:`infer`},name:S({config:n.config.webhooks.types.infer,name:t.id})}):void 0})}},Ms=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:K.unknown})}),n},Ns=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol({category:`external`,resource:`zod.z`}),i={},a=F.propertyAccessExpression({expression:r.placeholder,name:K.array});if(!t.items)i.expression=F.callExpression({functionName:a,parameters:[Ms({plugin:e,schema:{type:`unknown`},state:n}).expression]});else{t=C({schema:t});let o=t.items.map((t,r)=>{let a=Gs({plugin:e,schema:t,state:{...n,path:D([...n.path.value,`items`,r])}});return a.hasLazyExpression&&(i.hasLazyExpression=!0),a.expression});if(o.length===1)i.expression=F.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=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.intersection}),parameters:o});else{n=o[0];for(let e=1;e<o.length;e++)n=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.intersection}),parameters:[n,o[e]]})}i.expression=F.callExpression({functionName:a,parameters:[n]})}else i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.array}),parameters:[F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.union}),parameters:[F.arrayLiteralExpression({elements:o})]})]})}let o=[];return t.minItems===t.maxItems&&t.minItems!==void 0?o.push(F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.length}),parameters:[F.valueToExpression({value:t.minItems})]})):(t.minItems!==void 0&&o.push(F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.minLength}),parameters:[F.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&o.push(F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.maxLength}),parameters:[F.valueToExpression({value:t.maxItems})]}))),o.length&&(i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:i.expression,name:K.check}),parameters:o})),i},Ps=({plugin:e,schema:t})=>{let n=e.referenceSymbol({category:`external`,resource:`zod.z`}),r={};return typeof t.const==`boolean`?(r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.literal}),parameters:[F.ots.boolean(t.const)]}),r):(r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.boolean})}),r)},Fs=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol({category:`external`,resource:`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=F.stringLiteral({text:e.const});a.push(t),o.push(F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.literal}),parameters:[t]}))}else if((e.type===`number`||e.type===`integer`)&&typeof e.const==`number`){c=!1;let t=F.ots.number(e.const);o.push(F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.literal}),parameters:[t]}))}else if(e.type===`boolean`&&typeof e.const==`boolean`){c=!1;let t=F.ots.boolean(e.const);o.push(F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.literal}),parameters:[t]}))}else (e.type===`null`||e.const===null)&&(s=!0);return o.length?(c&&a.length>0?i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.enum}),parameters:[F.arrayLiteralExpression({elements:a,multiLine:!1})]}):o.length===1?i.expression=o[0]:i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.union}),parameters:[F.arrayLiteralExpression({elements:o,multiLine:o.length>3})]}),s&&(i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.nullable}),parameters:[i.expression]})),i):Ms({plugin:e,schema:{type:`unknown`},state:n})},Is=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:K.never})}),n},Ls=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:K.null})}),n},Rs=({plugin:e,schema:t})=>{let n=e.referenceSymbol({category:`external`,resource:`zod.z`}),r={},i=t.type===`integer`&&t.format===`int64`;if(typeof t.const==`number`)return r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.literal}),parameters:[F.ots.number(t.const)]}),r;r.expression=F.callExpression({functionName:i?F.propertyAccessExpression({expression:F.propertyAccessExpression({expression:n.placeholder,name:K.coerce}),name:K.bigint}):F.propertyAccessExpression({expression:n.placeholder,name:K.number})}),!i&&t.type===`integer`&&(r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.int})}));let a=[];return t.exclusiveMinimum===void 0?t.minimum!==void 0&&a.push(F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.gte}),parameters:[q({isBigInt:i,value:t.minimum})]})):a.push(F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.gt}),parameters:[q({isBigInt:i,value:t.exclusiveMinimum})]})),t.exclusiveMaximum===void 0?t.maximum!==void 0&&a.push(F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.lte}),parameters:[q({isBigInt:i,value:t.maximum})]})):a.push(F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.lt}),parameters:[q({isBigInt:i,value:t.exclusiveMaximum})]})),a.length&&(r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.expression,name:K.check}),parameters:a})),r},zs=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol({category:`external`,resource:`zod.z`}),i={},a=[],o=t.required??[];for(let r in t.properties){let s=t.properties[r],c=Gs({optional:!o.includes(r),plugin:e,schema:s,state:{...n,path:D([...n.path.value,`properties`,r])}});c.hasLazyExpression&&(i.hasLazyExpression=!0),k.lastIndex=0;let u;u=k.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(F.getAccessorDeclaration({name:u,statements:[F.returnStatement({expression:c.expression})]})):a.push(F.propertyAssignment({initializer:c.expression,name:u}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let a=Gs({plugin:e,schema:t.additionalProperties,state:{...n,path:D([...n.path.value,`additionalProperties`])}});return i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.record}),parameters:[F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.string}),parameters:[]}),a.expression]}),a.hasLazyExpression&&(i.hasLazyExpression=!0),i}return i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.object}),parameters:[l.factory.createObjectLiteralExpression(a,!0)]}),i},Bs=({plugin:e,schema:t})=>{let n=e.referenceSymbol({category:`external`,resource:`zod.z`}),r={};if(typeof t.const==`string`)return r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.literal}),parameters:[F.ots.string(t.const)]}),r;r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.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=F.callExpression({functionName:F.propertyAccessExpression({expression:F.propertyAccessExpression({expression:n.placeholder,name:K.iso}),name:K.date})});break;case`date-time`:r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:F.propertyAccessExpression({expression:n.placeholder,name:K.iso}),name:K.datetime}),parameters:i.length>0?[F.objectExpression({obj:i})]:[]});break;case`email`:r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.email})});break;case`ipv4`:r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.ipv4})});break;case`ipv6`:r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.ipv6})});break;case`time`:r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:F.propertyAccessExpression({expression:n.placeholder,name:K.iso}),name:K.time})});break;case`uri`:r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.url})});break;case`uuid`:r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.uuid})});break}let a=[];return t.minLength===t.maxLength&&t.minLength!==void 0?a.push(F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.length}),parameters:[F.valueToExpression({value:t.minLength})]})):(t.minLength!==void 0&&a.push(F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.minLength}),parameters:[F.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&a.push(F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.maxLength}),parameters:[F.valueToExpression({value:t.maxLength})]}))),t.pattern&&a.push(F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.regex}),parameters:[F.regularExpressionLiteral({text:t.pattern})]})),a.length&&(r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.expression,name:K.check}),parameters:a})),r},Vs=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol({category:`external`,resource:`zod.z`}),i={};if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.literal}),parameters:[F.valueToExpression({value:e})]}));return i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.tuple}),parameters:[F.arrayLiteralExpression({elements:e})]}),i}let a=[];return t.items&&t.items.forEach((t,r)=>{let o=Gs({plugin:e,schema:t,state:{...n,path:D([...n.path.value,`items`,r])}});a.push(o.expression),o.hasLazyExpression&&(i.hasLazyExpression=!0)}),i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.tuple}),parameters:[F.arrayLiteralExpression({elements:a})]}),i},Hs=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:K.undefined})}),n},Us=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:K.void})}),n},Ws=({schema:e,...t})=>{switch(e.type){case`array`:return Ns({...t,schema:e});case`boolean`:return Ps({...t,schema:e});case`enum`:return Fs({...t,schema:e});case`integer`:case`number`:return Rs({...t,schema:e});case`never`:return Is({...t,schema:e});case`null`:return Ls({...t,schema:e});case`object`:return zs({...t,schema:e});case`string`:return Bs({...t,schema:e});case`tuple`:return Vs({...t,schema:e});case`undefined`:return Hs({...t,schema:e});case`unknown`:return Ms({...t,schema:e});case`void`:return Us({...t,schema:e})}},Gs=({optional:e,plugin:t,schema:n,state:r})=>{let i={},a=t.referenceSymbol({category:`external`,resource:`zod.z`});if(n.$ref){let e={category:`schema`,resource:`definition`,resourceId:n.$ref,tool:`zod`},o=t.referenceSymbol(e);t.isSymbolRegistered(e)?i.expression=F.identifier({text:o.placeholder}):(i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:K.lazy}),parameters:[F.arrowFunction({returnType:F.keywordTypeNode({keyword:`any`}),statements:[F.returnStatement({expression:F.identifier({text:o.placeholder})})]})]}),i.hasLazyExpression=!0,r.hasLazyExpression.value=!0)}else if(n.type){let e=Ws({plugin:t,schema:n,state:r});i.expression=e.expression,i.hasLazyExpression=e.hasLazyExpression,t.config.metadata&&n.description&&(i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:i.expression,name:K.register}),parameters:[F.propertyAccessExpression({expression:a.placeholder,name:K.globalRegistry}),F.objectExpression({obj:[{key:`description`,value:F.stringLiteral({text:n.description})}]})]}))}else if(n.items)if(n=C({schema:n}),n.items){let e=n.items.map((e,n)=>Gs({plugin:t,schema:e,state:{...r,path:D([...r.path.value,`items`,n])}}));if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:K.intersection}),parameters:e.map(e=>e.expression)}):(i.expression=e[0].expression,e.slice(1).forEach(e=>{i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:K.intersection}),parameters:[i.expression,e.hasLazyExpression?F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:K.lazy}),parameters:[F.arrowFunction({statements:[F.returnStatement({expression:e.expression})]})]}):e.expression]})}))}else i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:K.union}),parameters:[F.arrayLiteralExpression({elements:e.map(e=>e.expression)})]})}else i=Gs({plugin:t,schema:n,state:r});else i.expression=Ws({plugin:t,schema:{type:`unknown`},state:r}).expression;if(i.expression&&(n.accessScope===`read`&&(i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:K.readonly}),parameters:[i.expression]})),e&&(i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:K.optional}),parameters:[i.expression]}),i.typeName=K.ZodMiniOptional),n.default!==void 0)){let e=q({isBigInt:n.type===`integer`&&n.format===`int64`,value:n.default});e&&(i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:K._default}),parameters:[i.expression,e]}))}return i},Ks=({plugin:e,schema:t,state:n})=>{let r=qn(n.path.value),i=Gs({plugin:e,schema:t,state:n}),a=I(r);Os({ast:i,plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{category:`schema`,path:n.path.value,resource:`definition`,resourceId:r,tags:n.tags?.value,tool:`zod`},name:S({config:e.config.definitions,name:a})}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`definition`,resourceId:r,tags:n.tags?.value,tool:`zod`,variant:`infer`},name:S({config:e.config.definitions.types.infer,name:a})}):void 0})},qs=({plugin:e})=>{e.registerSymbol({external:ks({plugin:e}),importKind:`namespace`,meta:{category:`external`,resource:`zod.z`},name:`z`}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=O({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:As({getAst:(n,r)=>Gs({plugin:e,schema:n,state:O({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:Ks({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:Ks({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:Ks({plugin:e,schema:t.schema,state:n});break;case`webhook`:js({getAst:(n,r)=>Gs({plugin:e,schema:n,state:O({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},Js=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`});return F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:K.unknown})})},Ys=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol({category:`external`,resource:`zod.z`}),i=F.propertyAccessExpression({expression:r.placeholder,name:K.array}),a,o=!1;if(!t.items)a=F.callExpression({functionName:i,parameters:[Js({plugin:e,schema:{type:`unknown`},state:n})]});else{t=C({schema:t});let s=t.items.map((t,r)=>{let i=sc({plugin:e,schema:t,state:{...n,path:D([...n.path.value,`items`,r])}});return i.hasLazyExpression&&(o=!0),i.expression});if(s.length===1)a=F.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=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.intersection}),parameters:s});else{n=s[0];for(let e=1;e<s.length;e++)n=F.callExpression({functionName:F.propertyAccessExpression({expression:n,name:K.and}),parameters:[s[e]]})}a=F.callExpression({functionName:i,parameters:[n]})}else a=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.array}),parameters:[F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.union}),parameters:[F.arrayLiteralExpression({elements:s})]})]})}return t.minItems===t.maxItems&&t.minItems!==void 0?a=F.callExpression({functionName:F.propertyAccessExpression({expression:a,name:K.length}),parameters:[F.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(a=F.callExpression({functionName:F.propertyAccessExpression({expression:a,name:K.min}),parameters:[F.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(a=F.callExpression({functionName:F.propertyAccessExpression({expression:a,name:K.max}),parameters:[F.valueToExpression({value:t.maxItems})]}))),{expression:a,hasLazyExpression:o}},Xs=({plugin:e,schema:t})=>{let n=e.referenceSymbol({category:`external`,resource:`zod.z`});return typeof t.const==`boolean`?F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.literal}),parameters:[F.ots.boolean(t.const)]}):F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.boolean})})},Zs=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol({category:`external`,resource:`zod.z`}),i=[],a=[],o=!1,s=!0;for(let e of t.items??[])if(e.type===`string`&&typeof e.const==`string`){let t=F.stringLiteral({text:e.const});i.push(t),a.push(F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.literal}),parameters:[t]}))}else if((e.type===`number`||e.type===`integer`)&&typeof e.const==`number`){s=!1;let t=F.ots.number(e.const);a.push(F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.literal}),parameters:[t]}))}else if(e.type===`boolean`&&typeof e.const==`boolean`){s=!1;let t=F.ots.boolean(e.const);a.push(F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.literal}),parameters:[t]}))}else (e.type===`null`||e.const===null)&&(o=!0);if(!a.length)return Js({plugin:e,schema:{type:`unknown`},state:n});let c;return c=s&&i.length>0?F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.enum}),parameters:[F.arrayLiteralExpression({elements:i,multiLine:!1})]}):a.length===1?a[0]:F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.union}),parameters:[F.arrayLiteralExpression({elements:a,multiLine:a.length>3})]}),o&&(c=F.callExpression({functionName:F.propertyAccessExpression({expression:c,name:K.nullable})})),c},Qs=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`});return F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:K.never})})},$s=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`});return F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:K.null})})},ec=({plugin:e,schema:t})=>{let n=e.referenceSymbol({category:`external`,resource:`zod.z`}),r=t.type===`integer`&&t.format===`int64`;if(typeof t.const==`number`)return F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.literal}),parameters:[F.ots.number(t.const)]});let i=F.callExpression({functionName:r?F.propertyAccessExpression({expression:F.propertyAccessExpression({expression:n.placeholder,name:K.coerce}),name:K.bigint}):F.propertyAccessExpression({expression:n.placeholder,name:K.number})});return!r&&t.type===`integer`&&(i=F.callExpression({functionName:F.propertyAccessExpression({expression:i,name:K.int})})),t.exclusiveMinimum===void 0?t.minimum!==void 0&&(i=F.callExpression({functionName:F.propertyAccessExpression({expression:i,name:K.gte}),parameters:[q({isBigInt:r,value:t.minimum})]})):i=F.callExpression({functionName:F.propertyAccessExpression({expression:i,name:K.gt}),parameters:[q({isBigInt:r,value:t.exclusiveMinimum})]}),t.exclusiveMaximum===void 0?t.maximum!==void 0&&(i=F.callExpression({functionName:F.propertyAccessExpression({expression:i,name:K.lte}),parameters:[q({isBigInt:r,value:t.maximum})]})):i=F.callExpression({functionName:F.propertyAccessExpression({expression:i,name:K.lt}),parameters:[q({isBigInt:r,value:t.exclusiveMaximum})]}),i},tc=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol({category:`external`,resource:`zod.z`}),i=!1,a=[],o=t.required??[];for(let r in t.properties){let s=t.properties[r],c=sc({optional:!o.includes(r),plugin:e,schema:s,state:{...n,path:D([...n.path.value,`properties`,r])}});c.hasLazyExpression&&(i=!0),k.lastIndex=0;let u;u=k.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(F.propertyAssignment({initializer:c.expression,name:u}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=sc({plugin:e,schema:t.additionalProperties,state:{...n,path:D([...n.path.value,`additionalProperties`])}});return{anyType:`AnyZodObject`,expression:F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.record}),parameters:[i.expression]}),hasLazyExpression:i.hasLazyExpression}}return{anyType:`AnyZodObject`,expression:F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.object}),parameters:[l.factory.createObjectLiteralExpression(a,!0)]}),hasLazyExpression:i}},nc=({plugin:e,schema:t})=>{let n=e.referenceSymbol({category:`external`,resource:`zod.z`});if(typeof t.const==`string`)return F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.literal}),parameters:[F.ots.string(t.const)]});let r=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.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=F.callExpression({functionName:F.propertyAccessExpression({expression:r,name:K.date})});break;case`date-time`:r=F.callExpression({functionName:F.propertyAccessExpression({expression:r,name:K.datetime}),parameters:i.length>0?[F.objectExpression({obj:i})]:[]});break;case`email`:r=F.callExpression({functionName:F.propertyAccessExpression({expression:r,name:K.email})});break;case`ipv4`:case`ipv6`:r=F.callExpression({functionName:F.propertyAccessExpression({expression:r,name:K.ip})});break;case`time`:r=F.callExpression({functionName:F.propertyAccessExpression({expression:r,name:K.time})});break;case`uri`:r=F.callExpression({functionName:F.propertyAccessExpression({expression:r,name:K.url})});break;case`uuid`:r=F.callExpression({functionName:F.propertyAccessExpression({expression:r,name:K.uuid})});break}return t.minLength===t.maxLength&&t.minLength!==void 0?r=F.callExpression({functionName:F.propertyAccessExpression({expression:r,name:K.length}),parameters:[F.valueToExpression({value:t.minLength})]}):(t.minLength!==void 0&&(r=F.callExpression({functionName:F.propertyAccessExpression({expression:r,name:K.min}),parameters:[F.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&(r=F.callExpression({functionName:F.propertyAccessExpression({expression:r,name:K.max}),parameters:[F.valueToExpression({value:t.maxLength})]}))),t.pattern&&(r=F.callExpression({functionName:F.propertyAccessExpression({expression:r,name:K.regex}),parameters:[F.regularExpressionLiteral({text:t.pattern})]})),r},rc=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol({category:`external`,resource:`zod.z`}),i=!1;if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.literal}),parameters:[F.valueToExpression({value:e})]}));return{expression:F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.tuple}),parameters:[F.arrayLiteralExpression({elements:e})]}),hasLazyExpression:i}}let a=[];return t.items&&t.items.forEach((t,r)=>{let o=sc({plugin:e,schema:t,state:{...n,path:D([...n.path.value,`items`,r])}});a.push(o.expression),o.hasLazyExpression&&(i=!0)}),{expression:F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.tuple}),parameters:[F.arrayLiteralExpression({elements:a})]}),hasLazyExpression:i}},ic=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`});return F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:K.undefined})})},ac=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`});return F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:K.void})})},oc=({schema:e,...t})=>{switch(e.type){case`array`:return Ys({...t,schema:e});case`boolean`:return{expression:Xs({...t,schema:e})};case`enum`:return{expression:Zs({...t,schema:e})};case`integer`:case`number`:return{expression:ec({...t,schema:e})};case`never`:return{expression:Qs({...t,schema:e})};case`null`:return{expression:$s({...t,schema:e})};case`object`:return tc({...t,schema:e});case`string`:return{expression:nc({...t,schema:e})};case`tuple`:return rc({...t,schema:e});case`undefined`:return{expression:ic({...t,schema:e})};case`unknown`:return{expression:Js({...t,schema:e})};case`void`:return{expression:ac({...t,schema:e})}}},sc=({optional:e,plugin:t,schema:n,state:r})=>{let i={},a=t.referenceSymbol({category:`external`,resource:`zod.z`});if(n.$ref){let e={category:`schema`,resource:`definition`,resourceId:n.$ref,tool:`zod`},o=t.referenceSymbol(e);t.isSymbolRegistered(e)?i.expression=F.identifier({text:o.placeholder}):(i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:K.lazy}),parameters:[F.arrowFunction({statements:[F.returnStatement({expression:F.identifier({text:o.placeholder})})]})]}),i.hasLazyExpression=!0,r.hasLazyExpression.value=!0)}else if(n.type){let e=oc({plugin:t,schema:n,state:r});i.expression=e.expression,i.typeName=e.anyType,t.config.metadata&&n.description&&(i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:i.expression,name:K.describe}),parameters:[F.stringLiteral({text:n.description})]}))}else if(n.items)if(n=C({schema:n}),n.items){let e=n.items.map((e,n)=>sc({plugin:t,schema:e,state:{...r,path:D([...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=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:K.intersection}),parameters:e}):(i.expression=e[0],e.slice(1).forEach(e=>{i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:i.expression,name:K.and}),parameters:[e]})}))}else i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:K.union}),parameters:[F.arrayLiteralExpression({elements:e})]})}else i=sc({plugin:t,schema:n,state:r});else{let e=oc({plugin:t,schema:{type:`unknown`},state:r});i.expression=e.expression,i.typeName=e.anyType}if(i.expression&&(n.accessScope===`read`&&(i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:i.expression,name:K.readonly})})),e&&(i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:i.expression,name:K.optional})})),n.default!==void 0)){let e=q({isBigInt:n.type===`integer`&&n.format===`int64`,value:n.default});e&&(i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:i.expression,name:K.default}),parameters:[e]}))}return r.hasLazyExpression.value?i.typeName||=`ZodTypeAny`:i.typeName&&=void 0,i},cc=({plugin:e,schema:t,state:n})=>{let r=qn(n.path.value),i=sc({plugin:e,schema:t,state:n}),a=I(r);Os({ast:i,plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{category:`schema`,path:n.path.value,resource:`definition`,resourceId:r,tags:n.tags?.value,tool:`zod`},name:S({config:e.config.definitions,name:a})}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`definition`,resourceId:r,tags:n.tags?.value,tool:`zod`,variant:`infer`},name:S({config:e.config.definitions.types.infer,name:a})}):void 0})},lc=({plugin:e})=>{e.registerSymbol({external:ks({plugin:e}),meta:{category:`external`,resource:`zod.z`},name:`z`}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=O({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:As({getAst:(n,r)=>sc({plugin:e,schema:n,state:O({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:cc({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:cc({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:cc({plugin:e,schema:t.schema,state:n});break;case`webhook`:js({getAst:(n,r)=>sc({plugin:e,schema:n,state:O({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},uc=({plugin:e})=>{let t={},n=e.referenceSymbol({category:`external`,resource:`zod.z`});return t.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.unknown})}),t},dc=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol({category:`external`,resource:`zod.z`}),a=F.propertyAccessExpression({expression:i.placeholder,name:K.array});if(!t.items)r.expression=F.callExpression({functionName:a,parameters:[uc({plugin:e,schema:{type:`unknown`},state:n}).expression]});else{t=C({schema:t});let o=t.items.map((t,i)=>{let a=Cc({plugin:e,schema:t,state:{...n,path:D([...n.path.value,`items`,i])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),a.expression});if(o.length===1)r.expression=F.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=F.callExpression({functionName:F.propertyAccessExpression({expression:i.placeholder,name:K.intersection}),parameters:o});else{n=o[0];for(let e=1;e<o.length;e++)n=F.callExpression({functionName:F.propertyAccessExpression({expression:n,name:K.and}),parameters:[o[e]]})}r.expression=F.callExpression({functionName:a,parameters:[n]})}else r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:i.placeholder,name:K.array}),parameters:[F.callExpression({functionName:F.propertyAccessExpression({expression:i.placeholder,name:K.union}),parameters:[F.arrayLiteralExpression({elements:o})]})]})}return t.minItems===t.maxItems&&t.minItems!==void 0?r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.expression,name:K.length}),parameters:[F.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.expression,name:K.min}),parameters:[F.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.expression,name:K.max}),parameters:[F.valueToExpression({value:t.maxItems})]}))),r},fc=({plugin:e,schema:t})=>{let n={},r=e.referenceSymbol({category:`external`,resource:`zod.z`});return typeof t.const==`boolean`?(n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.literal}),parameters:[F.ots.boolean(t.const)]}),n):(n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.boolean})}),n)},pc=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol({category:`external`,resource:`zod.z`}),a=[],o=[],s=!1,c=!0;for(let e of t.items??[])if(e.type===`string`&&typeof e.const==`string`){let t=F.stringLiteral({text:e.const});a.push(t),o.push(F.callExpression({functionName:F.propertyAccessExpression({expression:i.placeholder,name:K.literal}),parameters:[t]}))}else if((e.type===`number`||e.type===`integer`)&&typeof e.const==`number`){c=!1;let t=F.ots.number(e.const);o.push(F.callExpression({functionName:F.propertyAccessExpression({expression:i.placeholder,name:K.literal}),parameters:[t]}))}else if(e.type===`boolean`&&typeof e.const==`boolean`){c=!1;let t=F.ots.boolean(e.const);o.push(F.callExpression({functionName:F.propertyAccessExpression({expression:i.placeholder,name:K.literal}),parameters:[t]}))}else (e.type===`null`||e.const===null)&&(s=!0);return o.length?(c&&a.length>0?r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:i.placeholder,name:K.enum}),parameters:[F.arrayLiteralExpression({elements:a,multiLine:!1})]}):o.length===1?r.expression=o[0]:r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:i.placeholder,name:K.union}),parameters:[F.arrayLiteralExpression({elements:o,multiLine:o.length>3})]}),s&&(r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:i.placeholder,name:K.nullable}),parameters:[r.expression]})),r):uc({plugin:e,schema:{type:`unknown`},state:n})},mc=({plugin:e})=>{let t={},n=e.referenceSymbol({category:`external`,resource:`zod.z`});return t.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.never})}),t},hc=({plugin:e})=>{let t={},n=e.referenceSymbol({category:`external`,resource:`zod.z`});return t.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.null})}),t},gc=({plugin:e,schema:t})=>{let n={},r=t.type===`integer`&&t.format===`int64`,i=e.referenceSymbol({category:`external`,resource:`zod.z`});return typeof t.const==`number`?(n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:i.placeholder,name:K.literal}),parameters:[F.ots.number(t.const)]}),n):(n.expression=F.callExpression({functionName:r?F.propertyAccessExpression({expression:F.propertyAccessExpression({expression:i.placeholder,name:K.coerce}),name:K.bigint}):F.propertyAccessExpression({expression:i.placeholder,name:K.number})}),!r&&t.type===`integer`&&(n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:i.placeholder,name:K.int})})),t.exclusiveMinimum===void 0?t.minimum!==void 0&&(n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.expression,name:K.gte}),parameters:[q({isBigInt:r,value:t.minimum})]})):n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.expression,name:K.gt}),parameters:[q({isBigInt:r,value:t.exclusiveMinimum})]}),t.exclusiveMaximum===void 0?t.maximum!==void 0&&(n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.expression,name:K.lte}),parameters:[q({isBigInt:r,value:t.maximum})]})):n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.expression,name:K.lt}),parameters:[q({isBigInt:r,value:t.exclusiveMaximum})]}),n)},_c=({plugin:e,schema:t,state:n})=>{let r={},i=[],a=t.required??[],o=e.referenceSymbol({category:`external`,resource:`zod.z`});for(let o in t.properties){let s=t.properties[o],c=Cc({optional:!a.includes(o),plugin:e,schema:s,state:{...n,path:D([...n.path.value,`properties`,o])}});c.hasLazyExpression&&(r.hasLazyExpression=!0),k.lastIndex=0;let u;u=k.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(F.getAccessorDeclaration({name:u,statements:[F.returnStatement({expression:c.expression})]})):i.push(F.propertyAssignment({initializer:c.expression,name:u}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=Cc({plugin:e,schema:t.additionalProperties,state:{...n,path:D([...n.path.value,`additionalProperties`])}});return r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:K.record}),parameters:[F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:K.string}),parameters:[]}),i.expression]}),i.hasLazyExpression&&(r.hasLazyExpression=!0),r.hasLazyExpression?{...r,typeName:`ZodType`}:r}return r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:K.object}),parameters:[l.factory.createObjectLiteralExpression(i,!0)]}),r.hasLazyExpression?{...r,typeName:`ZodType`}:r},vc=({plugin:e,schema:t})=>{let n={},r=e.referenceSymbol({category:`external`,resource:`zod.z`});if(typeof t.const==`string`)return n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.literal}),parameters:[F.ots.string(t.const)]}),n;n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.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=F.callExpression({functionName:F.propertyAccessExpression({expression:F.propertyAccessExpression({expression:r.placeholder,name:K.iso}),name:K.date})});break;case`date-time`:n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:F.propertyAccessExpression({expression:r.placeholder,name:K.iso}),name:K.datetime}),parameters:i.length>0?[F.objectExpression({obj:i})]:[]});break;case`email`:n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.email})});break;case`ipv4`:n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.ipv4})});break;case`ipv6`:n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.ipv6})});break;case`time`:n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:F.propertyAccessExpression({expression:r.placeholder,name:K.iso}),name:K.time})});break;case`uri`:n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.url})});break;case`uuid`:n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:K.uuid})});break}return t.minLength===t.maxLength&&t.minLength!==void 0?n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.expression,name:K.length}),parameters:[F.valueToExpression({value:t.minLength})]}):(t.minLength!==void 0&&(n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.expression,name:K.min}),parameters:[F.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&(n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.expression,name:K.max}),parameters:[F.valueToExpression({value:t.maxLength})]}))),t.pattern&&(n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.expression,name:K.regex}),parameters:[F.regularExpressionLiteral({text:t.pattern})]})),n},yc=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol({category:`external`,resource:`zod.z`});if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>F.callExpression({functionName:F.propertyAccessExpression({expression:i.placeholder,name:K.literal}),parameters:[F.valueToExpression({value:e})]}));return r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:i.placeholder,name:K.tuple}),parameters:[F.arrayLiteralExpression({elements:e})]}),r}let a=[];return t.items&&t.items.forEach((t,i)=>{let o=Cc({plugin:e,schema:t,state:{...n,path:D([...n.path.value,`items`,i])}});a.push(o.expression),o.hasLazyExpression&&(r.hasLazyExpression=!0)}),r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:i.placeholder,name:K.tuple}),parameters:[F.arrayLiteralExpression({elements:a})]}),r},bc=({plugin:e})=>{let t={},n=e.referenceSymbol({category:`external`,resource:`zod.z`});return t.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.undefined})}),t},xc=({plugin:e})=>{let t={},n=e.referenceSymbol({category:`external`,resource:`zod.z`});return t.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:K.void})}),t},Sc=({schema:e,...t})=>{switch(e.type){case`array`:return dc({...t,schema:e});case`boolean`:return fc({...t,schema:e});case`enum`:return pc({...t,schema:e});case`integer`:case`number`:return gc({...t,schema:e});case`never`:return mc({...t,schema:e});case`null`:return hc({...t,schema:e});case`object`:return _c({...t,schema:e});case`string`:return vc({...t,schema:e});case`tuple`:return yc({...t,schema:e});case`undefined`:return bc({...t,schema:e});case`unknown`:return uc({...t,schema:e});case`void`:return xc({...t,schema:e})}},Cc=({optional:e,plugin:t,schema:n,state:r})=>{let i={},a=t.referenceSymbol({category:`external`,resource:`zod.z`});if(n.$ref){let e={category:`schema`,resource:`definition`,resourceId:n.$ref,tool:`zod`},o=t.referenceSymbol(e);t.isSymbolRegistered(e)?i.expression=F.identifier({text:o.placeholder}):(i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:K.lazy}),parameters:[F.arrowFunction({returnType:F.keywordTypeNode({keyword:`any`}),statements:[F.returnStatement({expression:F.identifier({text:o.placeholder})})]})]}),i.hasLazyExpression=!0,r.hasLazyExpression.value=!0)}else if(n.type){let e=Sc({plugin:t,schema:n,state:r});i.expression=e.expression,i.hasLazyExpression=e.hasLazyExpression,t.config.metadata&&n.description&&(i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:i.expression,name:K.register}),parameters:[F.propertyAccessExpression({expression:a.placeholder,name:K.globalRegistry}),F.objectExpression({obj:[{key:`description`,value:F.stringLiteral({text:n.description})}]})]}))}else if(n.items)if(n=C({schema:n}),n.items){let e=n.items.map((e,n)=>Cc({plugin:t,schema:e,state:{...r,path:D([...r.path.value,`items`,n])}}));if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:K.intersection}),parameters:e.map(e=>e.expression)}):(i.expression=e[0].expression,e.slice(1).forEach(e=>{i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:i.expression,name:K.and}),parameters:[e.hasLazyExpression?F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:K.lazy}),parameters:[F.arrowFunction({statements:[F.returnStatement({expression:e.expression})]})]}):e.expression]})}))}else i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:K.union}),parameters:[F.arrayLiteralExpression({elements:e.map(e=>e.expression)})]})}else i=Cc({plugin:t,schema:n,state:r});else i.expression=Sc({plugin:t,schema:{type:`unknown`},state:r}).expression;if(i.expression&&(n.accessScope===`read`&&(i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:i.expression,name:K.readonly})})),e&&(i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:K.optional}),parameters:[i.expression]}),i.typeName=K.ZodOptional),n.default!==void 0)){let e=q({isBigInt:n.type===`integer`&&n.format===`int64`,value:n.default});e&&(i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:i.expression,name:K.default}),parameters:[e]}))}return i},wc=({plugin:e,schema:t,state:n})=>{let r=qn(n.path.value),i=Cc({plugin:e,schema:t,state:n}),a=I(r);Os({ast:i,plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{category:`schema`,path:n.path.value,resource:`definition`,resourceId:r,tags:n.tags?.value,tool:`zod`},name:S({config:e.config.definitions,name:a})}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`definition`,resourceId:r,tags:n.tags?.value,tool:`zod`,variant:`infer`},name:S({config:e.config.definitions.types.infer,name:a})}):void 0})},Tc=({plugin:e})=>{e.registerSymbol({external:ks({plugin:e}),meta:{category:`external`,resource:`zod.z`},name:`z`}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=O({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:As({getAst:(n,r)=>Cc({plugin:e,schema:n,state:O({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:wc({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:wc({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:wc({plugin:e,schema:t.schema,state:n});break;case`webhook`:js({getAst:(n,r)=>Cc({plugin:e,schema:n,state:O({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},Ec={api:new Ds,config:{case:`camelCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:e=>{let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return lc(e);case`mini`:return qs(e);case 4:default:return Tc(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:b,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:{...b,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:b,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:{...b,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:b,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:{...b,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:b,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:{...b,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:b,value:e.infer})})},value:e.types})})},value:e.config.webhooks})},tags:[`validator`]},Dc={"@angular/common":yr,"@hey-api/client-angular":Fr,"@hey-api/client-axios":Ir,"@hey-api/client-fetch":Lr,"@hey-api/client-next":Rr,"@hey-api/client-nuxt":zr,"@hey-api/client-ofetch":Br,"@hey-api/schemas":$r,"@hey-api/sdk":ra,"@hey-api/transformers":fa,"@hey-api/typescript":Va,"@pinia/colada":io,"@tanstack/angular-query-experimental":Eo,"@tanstack/react-query":Do,"@tanstack/solid-query":Oo,"@tanstack/svelte-query":ko,"@tanstack/vue-query":Ao,arktype:Ho,fastify:Wo,swr:qo,valibot:bs,zod:Ec},Oc=[`@hey-api/typescript`,`@hey-api/sdk`],kc=({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=Dc[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:Hr(e),pluginByTag:(e,r={})=>{let{defaultPlugin:i,errorMessage:a}=r;for(let r of t){let t=Dc[r]||n[r];if(t&&t.tags?.includes(e)&&r!==s)return r}if(i){let t=Dc[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:y};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}},Ac=e=>typeof e==`string`?e.startsWith(`@hey-api/client`):e.name.startsWith(`@hey-api/client`)||e.tags&&e.tags.includes(`client`),jc=({dependencies:e,userConfig:t})=>{let n={},r=Oc;return t.plugins&&(t.plugins=t.plugins.filter(e=>typeof e==`string`&&e||typeof e!=`string`&&e.name),r=t.plugins.length===1&&Ac(t.plugins[0])?[...Oc,...t.plugins]:t.plugins),kc({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})},Mc=()=>!!(process.stdin.isTTY&&process.stdout.isTTY&&!process.env.CI&&!process.env.NO_INTERACTIVE&&!process.env.NO_INTERACTION),Nc=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=Fe(Object.keys(c).length?l:void 0));let u=c instanceof Array?c.map(e=>je(e,i)):[je(c,i)];for(let e of u){let t=Oe(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 t=ke(e),n=Oe(e),i=Pe(e),c=Le(e),l=[];n.length||l.push(new v(`missing input - which OpenAPI specification should we use to generate your output?`)),i.path||l.push(new v(`missing output - where should we generate your output?`)),i.path=s.resolve(process.cwd(),i.path);let u;try{u=jc({dependencies:r,userConfig:e})}catch(e){l.push(e),u={pluginOrder:[],plugins:{}}}let d={configFile:e.configFile??``,dryRun:e.dryRun??!1,input:n,interactive:e.interactive??Mc(),logs:t,output:i,parser:c,pluginOrder:u.pluginOrder,plugins:u.plugins},f=o.length;if(t.level===`debug`){let e=a.gray(`[Job ${f+1}] `);console.warn(`${e}${a.cyan(`config:`)}`,d)}o.push({config:d,errors:l,jobIndex:f})}return c.timeEnd(),{dependencies:r,results:o}};Object.entries({$body_:`body`,$headers_:`headers`,$path_:`path`,$query_:`query`});const Pc=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},Fc=e=>{switch(e){case`form`:return`,`;case`pipeDelimited`:return`|`;case`spaceDelimited`:return`%20`;default:return`,`}},Ic=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},Lc=({allowReserved:e,explode:t,name:n,style:r,value:i})=>{if(!t){let t=(e?i:i.map(e=>encodeURIComponent(e))).join(Fc(r));switch(r){case`label`:return`.${t}`;case`matrix`:return`;${n}=${t}`;case`simple`:return t;default:return`${n}=${t}`}}let a=Pc(r),o=i.map(t=>r===`label`||r===`simple`?e?t:encodeURIComponent(t):Rc({allowReserved:e,name:n,value:t})).join(a);return r===`label`||r===`matrix`?a+o:o},Rc=({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)}`},zc=({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=Ic(r),s=Object.entries(i).map(([t,i])=>Rc({allowReserved:e,name:r===`deepObject`?`${n}[${t}]`:t,value:i})).join(o);return r===`label`||r===`matrix`?o+s:s},Bc=({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=Lc({allowReserved:o.allowReserved,explode:!0,name:i,style:`form`,value:a,...o.array});e&&r.push(e)}else if(typeof a==`object`){let e=zc({allowReserved:o.allowReserved,explode:!0,name:i,style:`deepObject`,value:a,...o.object});e&&r.push(e)}else{let e=Rc({allowReserved:o.allowReserved,name:i,value:a});e&&r.push(e)}}return r.join(`&`)},Vc=e=>{let t=[];return e.forEach((e,n)=>{t.push([n,e])}),t},Hc=(...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let e=n instanceof Headers?Vc(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};Bc({allowReserved:!1,array:{explode:!0,style:`form`},object:{explode:!0,style:`deepObject`}});const Uc=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:Hc(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}},Wc=new Set(`buffer.child_process.cluster.console.constants.crypto.dgram.dns.domain.events.freelist.fs.http.https.module.net.os.path.process.punycode.querystring.readline.repl.stream.string_decoder.timers.tls.tty.url.util.v8.vm.worker_threads.zlib`.split(`.`));var Gc=class{renderFile(e,t,n,r){let a=new Map;if(e=i(e,e=>{let i=n.symbols.get(e),o=this.replacerFn({file:t,project:n,symbol:i});return i&&this.addBinding({bindings:a,file:t,meta:r,project:n,symbol:i}),o}),!e.length)return``;let o=``,s=this.getHeaderLines();o+=`${s.join(`
|
|
8
|
-
`)}${s.length?`
|
|
9
|
-
|
|
10
|
-
`:``}`;let c=this.getImportLines(a,t,n);return o+=`${c.join(`
|
|
11
|
-
`)}${c.length?`
|
|
12
|
-
|
|
13
|
-
`:``}`,`${o}${e}`}renderSymbols(e,t,n){let r=new Map,a=``,o=this.getBodyLines(e,t);a+=`${o.join(`
|
|
14
|
-
|
|
15
|
-
`)}${o.length?`
|
|
16
|
-
`:``}`,a=i(a,n=>{if(!e.symbols.body.includes(n))return;let r=t.symbols.get(n);return this.replacerFn({file:e,project:t,symbol:r})});for(let i of e.symbols.exports){let a=t.symbols.get(i);a&&this.addBinding({bindings:r,file:e,meta:n,project:t,symbol:a})}for(let e of r.values())e.namespaceBinding=!0,e.typeNamespaceBinding=e.names&&e.typeNames&&e.names.length===e.typeNames.length&&e.names.every(t=>(e.typeNames??[]).includes(t));let s=this.getExportLines(r,e,t);return a+=`${s.join(`
|
|
17
|
-
`)}${s.length?`
|
|
18
|
-
`:``}`,a}addBinding({bindings:e,file:t,meta:i,project:a,symbol:o}){if(!o.external&&!a.symbols.hasValue(o.id))return;let[s]=a.symbolIdToFiles(o.id);if(!s||t===s)return;let c=this.getBindingPath(t,s,i),l=e.get(c),u=n({file:t,modulePath:c,symbol:o,symbolFile:s});l?(r(l,u),e.set(c,l)):e.set(c,u)}getBindingPath(e,t,n){if(!e.path||!t.path)return``;if(t.external&&!s.isAbsolute(t.path))return t.path;let r=s.posix.relative(s.posix.dirname(e.path.split(s.sep).join(s.posix.sep)),t.path.split(s.sep).join(s.posix.sep));return!r.startsWith(`.`)&&r!==``&&(r=`./${r}`),t.extension===`.ts`&&(r.endsWith(t.extension)&&(r=r.slice(0,-t.extension.length)),n?.importFileExtension?r+=n.importFileExtension:r.endsWith(`/index`)&&(r=r.slice(0,-6))),r}getBodyLines(e,t){let n=[];for(let r of e.symbols.body){let e=t.symbols.getValue(r);if(typeof e==`string`)n.push(e);else if(e instanceof Array)for(let t of e)n.push(gt({node:t,unescape:!0}));else e!=null&&n.push(gt({node:e,unescape:!0}))}return n}getExportLines(e,t,n){let r=[];for(let[a,o]of e.entries()){let e=[],s,c=!1;if(o.namespaceBinding!==void 0)typeof o.namespaceBinding==`string`&&(s=i(o.namespaceBinding,e=>{let r=n.symbols.get(e);return this.replacerFn({file:t,project:n,symbol:r})})),o.typeNamespaceBinding&&(c=!0);else if(o.names&&o.names.length>0){o.names.every(e=>(o.typeNames??[]).includes(e))&&(c=!0);for(let r of o.names){let a=o.aliases?.[r],s=r,u;a&&a!==s&&(u=s,s=a),s=i(s,e=>{let r=n.symbols.get(e),i=this.replacerFn({file:t,project:n,symbol:r}),[a]=n.symbolIdToFiles(e),o=a?a.resolvedNames.get(e):void 0;return o&&o!==i&&(u||=o),i}),u&&(u=i(u,e=>{let r=n.symbols.get(e);return this.replacerFn({file:t,project:n,symbol:r})}),u===s&&(u=void 0));let d=l.factory.createExportSpecifier(c?!1:o.typeNames?.includes(r)??!1,u?F.identifier({text:u}):void 0,F.identifier({text:s}));e.push(d)}}let u=s?l.factory.createNamespaceExport(F.identifier({text:s})):e.length?l.factory.createNamedExports(e):void 0,d=l.factory.createExportDeclaration(void 0,c,u,F.stringLiteral({isSingleQuote:!0,text:a}));r.push(gt({node:d,unescape:!0}))}return r}getHeaderLines(){return[`// This file is auto-generated by @hey-api/openapi-ts`]}getImportLines(e,t,n){let r=[],a=-1,o=e=>{let t=e.from;return t.startsWith(`.`)?t.startsWith(`./`)?[2,0,t]:[2,t.match(/\.\.\//g)?.length??0,t]:Wc.has(t.split(`/`)[0])?[0,0,t]:[1,0,t]},s=Array.from(e.values()).map(e=>({...e,k:o(e)})).sort((e,t)=>e.k[0]-t.k[0]||e.k[1]-t.k[1]||e.k[2].localeCompare(t.k[2]));for(let e of s){let o=[],s,c,u=!1;if(e.defaultBinding){let r=i(e.defaultBinding,e=>{let r=n.symbols.get(e);return this.replacerFn({file:t,project:n,symbol:r})});s=F.identifier({text:r}),e.typeDefaultBinding&&(u=!0)}else if(typeof e.namespaceBinding==`string`)c=i(e.namespaceBinding,e=>{let r=n.symbols.get(e);return this.replacerFn({file:t,project:n,symbol:r})}),e.typeNamespaceBinding&&(u=!0);else if(e.names&&e.names.length>0){e.names.every(t=>e.typeNames?.includes(t))&&(u=!0);let r=[];for(let a of e.names){let o=e.aliases?.[a],s=a,c;o&&o!==s&&(c=s,s=o),s=i(s,e=>{let r=n.symbols.get(e),i=this.replacerFn({file:t,project:n,symbol:r}),[a]=n.symbolIdToFiles(e),o=a?a.resolvedNames.get(e):void 0;return o&&o!==i&&(c||=o),i}),c&&(c=i(c,e=>{let r=n.symbols.get(e);return this.replacerFn({file:t,project:n,symbol:r})}),c===s&&(c=void 0)),r.push({isTypeOnly:u?!1:e.typeNames?.includes(a)??!1,name:s,propertyName:c?F.identifier({text:c}):void 0})}o=r.sort((e,t)=>e.name.localeCompare(t.name)).map(({isTypeOnly:e,name:t,propertyName:n})=>l.factory.createImportSpecifier(e,n,F.identifier({text:t})))}let d=l.factory.createImportClause(u,s,c?l.factory.createNamespaceImport(F.identifier({text:c})):o.length?l.factory.createNamedImports(o):void 0),f=l.factory.createImportDeclaration(void 0,d,F.stringLiteral({isSingleQuote:!0,text:e.from}));a!==-1&&e.k[0]!==a&&r.push(``),r.push(gt({node:f,unescape:!0})),a=e.k[0]}return r}getUniqueName(e,t){let n=2,r=e;for(;t.hasValue(r);)r=`${e}${n}`,n+=1;return r}replacerFn({file:e,project:t,symbol:n}){if(!n)return;let r=e.resolvedNames.get(n.id);if(r)return r;if(!n.name)return;let[i]=t.symbolIdToFiles(n.id),a=i?.resolvedNames.get(n.id),o=Wr(a??n.name),s=e.resolvedNames.getKey(o);if(s!==void 0){let r=t.symbols.get(s);if(r){let t=[r.kind,n.kind];(t.every(e=>e===`type`)||t.every(e=>e!==`type`)||t.includes(`class`)&&t.includes(`type`))&&(o=this.getUniqueName(o,e.resolvedNames))}}return e.resolvedNames.set(n.id,o),o}},Kc=class{heap=[];constructor(e){this.declIndex=e}isEmpty(){return!this.heap.length}pop(){let[e]=this.heap;if(!this.heap.length)return;let t=this.heap.pop();return this.heap.length?(this.heap[0]=t,this.sinkDown(0),e):e}push(e){this.heap.push(e),this.bubbleUp(this.heap.length-1)}bubbleUp(e){let t=this.heap;for(;e>0;){let n=Math.floor((e-1)/2),r=t[n],i=t[e];if(this.declIndex.get(r)<=this.declIndex.get(i))break;t[n]=i,t[e]=r,e=n}}sinkDown(e){let t=this.heap,n=t.length;for(;;){let r=2*e+1,i=2*e+2,a=e;if(r<n){let e=t[r],n=t[a];this.declIndex.get(e)<this.declIndex.get(n)&&(a=r)}if(i<n){let e=t[i],n=t[a];this.declIndex.get(e)<this.declIndex.get(n)&&(a=i)}if(a===e)break;let o=t[a];t[a]=t[e],t[e]=o,e=a}}};const qc=(e,t,n)=>{let r=Array.from(e.nodes.keys());if(n?.preferGroups&&n.preferGroups.length>0){let i=new Set;if(n.matchPointerToGroup)for(let a of n.preferGroups)for(let o of r){let r=n.matchPointerToGroup(o);r.matched&&r.kind===a&&(i.add(o),t(o,e.nodes.get(o)))}for(let n of r)i.has(n)||t(n,e.nodes.get(n));return}for(let n of r)t(n,e.nodes.get(n))},Jc=(e,t,n)=>{let r=Array.from(e.nodes.keys()),i=new Map;r.forEach((e,t)=>i.set(e,t));let a=new Map;for(let e of r){let t=(n?.getPointerPriority?.(e)??10)*1e6+(i.get(e)??0);a.set(e,t)}let o=new Map;for(let t of r){let n=e.subtreeDependencies?.get(t)??new Set,r=new Set;for(let i of n)i!==t&&e.nodes.has(i)&&r.add(i);o.set(t,r)}let s=new Map,c=new Map;for(let e of r)s.set(e,0);for(let[e,t]of o){s.set(e,t.size);for(let n of t)c.has(n)||c.set(n,new Set),c.get(n).add(e)}let l=e=>e.sort((e,t)=>a.get(e)-a.get(t)),u=new Kc(a);for(let e of r)(s.get(e)??0)===0&&u.push(e);let d=new Set,f=[];for(;!u.isEmpty();){let e=u.pop();if(d.has(e))continue;d.add(e),f.push(e);let t=c.get(e);if(t)for(let e of t){let t=(s.get(e)??0)-1;s.set(e,t),t===0&&u.push(e)}}let p=r.filter(e=>!d.has(e));l(p);for(let e of p)d.add(e),f.push(e);let m=f;if(n?.preferGroups&&n.preferGroups.length>0){let e=new Map;for(let t=0;t<n.preferGroups.length;t++){let r=n.preferGroups[t];r&&e.set(r,t)}let t=t=>{if(n.matchPointerToGroup){let r=n.matchPointerToGroup(t);if(r.matched)return e.has(r.kind)?e.get(r.kind):n.preferGroups.length}return n.preferGroups.length},r=[...f].sort((e,n)=>{let r=t(e),i=t(n);return r===i?f.indexOf(e)-f.indexOf(n):r-i}),i=new Map;for(let e=0;e<r.length;e++)i.set(r[e],e);(()=>{for(let[e,n]of o)for(let r of n)if(!(t(r)<=t(e))&&i.get(r)>=i.get(e))return!0;return!1})()||(m=r)}for(let n of m)t(n,e.nodes.get(n))},Yc=(e,t,n)=>n?.order===`topological`?Jc(e,t,n):qc(e,t,n),Xc=[`operation`,`parameter`,`requestBody`,`schema`,`server`,`webhook`],Zc=(e,t)=>{let n={operation:/^#\/paths\/[^/]+\/(get|put|post|delete|options|head|patch|trace)$/,parameter:/^#\/components\/parameters\/[^/]+$/,requestBody:/^#\/components\/requestBodies\/[^/]+$/,schema:/^#\/components\/schemas\/[^/]+$/,server:/^#\/servers\/(\d+|[^/]+)$/,webhook:/^#\/webhooks\/[^/]+\/(get|put|post|delete|options|head|patch|trace)$/};if(t)return n[t].test(e)?{kind:t,matched:!0}:{matched:!1};for(let t of Object.keys(n)){let r=t;if(n[r].test(e))return{kind:r,matched:!0}}return{matched:!1}},Qc=[`server`,`schema`,`parameter`,`requestBody`,`operation`,`webhook`],$c=(()=>{let e={};for(let t=0;t<Qc.length;t++){let n=Qc[t];n&&(e[n]=t)}for(let t of Xc)e[t]===void 0&&(e[t]=Qc.length);return e})(),el=e=>{let t=Zc(e);return t.matched?$c[t.kind]??10:10},tl=e=>{if(!(!e.meta?.pluginName||typeof e.meta.pluginName!=`string`))return e.meta.pluginName.startsWith(`@hey-api/client-`)?`client`:e.meta.pluginName===`@hey-api/typescript`?`types`:e.meta.pluginName.startsWith(`@hey-api/`)?e.meta.pluginName.split(`/`)[1]:e.meta.pluginName},nl=e=>{switch(e.method){case`delete`:case`patch`:case`post`:case`put`:return[`mutation`];case`get`:return[`query`];default:return}};var rl=class{api;config;context;dependencies=[];eventHooks;gen;handler;name;package;constructor(e){this.api=e.api??{},this.config=e.config,this.context=e.context,this.dependencies=e.dependencies,this.eventHooks=this.buildEventHooks(),this.gen=e.gen,this.handler=e.handler,this.name=e.name,this.package=e.context.package}forEach(...e){if(!this.context.graph)throw Error(`No graph available in context`);let t,n,r={getPointerPriority:el,matchPointerToGroup:Zc,order:`topological`,preferGroups:Qc};typeof e[e.length-1]==`function`?(n=e.slice(0,-1),t=e[e.length-1]):(n=e.slice(0,-2),t=e[e.length-2],r={...r,...e[e.length-1]});let i=new Set(n.length?n:Xc);Yc(this.context.graph,(e,n)=>{let r=Zc(e);if(!r.matched||!i.has(r.kind))return;let a,o={_path:Gn(e),pointer:e,tags:n.tags?Array.from(n.tags):void 0};switch(r.kind){case`operation`:a={...o,method:n.key,operation:n.node,path:o._path[1],type:r.kind};break;case`parameter`:a={...o,name:n.key,parameter:n.node,type:r.kind};break;case`requestBody`:a={...o,name:n.key,requestBody:n.node,type:r.kind};break;case`schema`:a={...o,name:n.key,schema:n.node,type:r.kind};break;case`server`:a={...o,server:n.node,type:r.kind};break;case`webhook`:a={...o,key:o._path[1],method:n.key,operation:n.node,type:r.kind};break}if(a)try{t(a)}catch(e){this.forEachError(e,a)}},r)}getPlugin(e){return this.context.plugins[e]}getPluginOrThrow(e){let t=this.getPlugin(e);if(!t)throw Error(`plugin not found ${e}`);return t}getSymbol(e){return this.gen.symbols.get(e)}hooks={operation:{isMutation:e=>this.isOperationKind(e,`mutation`),isQuery:e=>this.isOperationKind(e,`query`)}};isSymbolRegistered(e){return this.gen.symbols.isRegistered(e)}querySymbol(e){return this.gen.symbols.query(e)[0]}referenceSymbol(e){return this.gen.symbols.reference(e)}registerSymbol(e){let t={...e,exportFrom:e.exportFrom??(!e.external&&this.context.config.output.indexFile&&this.config.exportFromIndex?[`index`]:void 0),getFilePath:e.getFilePath??this.getSymbolFilePath.bind(this),meta:{pluginName:s.isAbsolute(this.name)?`custom`:this.name,...e.meta}};for(let e of this.eventHooks[`symbol:register:before`])e({plugin:this,symbol:t});let n=this.gen.symbols.register(t);for(let e of this.eventHooks[`symbol:register:after`])e({plugin:this,symbol:n});return n}async run(){for(let e of this.eventHooks[`plugin:handler:before`])e({plugin:this});await this.handler({plugin:this});for(let e of this.eventHooks[`plugin:handler:after`])e({plugin:this})}setSymbolValue(e,t){for(let n of this.eventHooks[`symbol:setValue:before`])n({plugin:this,symbol:e,value:t});this.gen.symbols.setValue(e.id,t);for(let n of this.eventHooks[`symbol:setValue:after`])n({plugin:this,symbol:e,value:t})}buildEventHooks(){let e={"plugin:handler:after":[],"plugin:handler:before":[],"symbol:register:after":[],"symbol:register:before":[],"symbol:setValue:after":[],"symbol:setValue:before":[]},t=[this.config[`~hooks`]?.events,this.context.config.parser.hooks.events];for(let n of t)if(n)for(let[t,r]of Object.entries(n))r&&e[t].push(r.bind(n));return e}forEachError(e,t){let n=e instanceof Error?e:Error(String(e));throw new ae({args:[t],error:n,event:t.type,name:`Error`,pluginName:this.name})}getSymbolFilePath(e){let t=[this.config[`~hooks`]?.symbols,this.context.config.parser.hooks.symbols];for(let n of t){let t=n?.getFilePath?.(e);if(t!==void 0)return t}return tl(e)}isOperationKind(e,t){let n=t===`query`?`isQuery`:`isMutation`,r=[this.config[`~hooks`]?.operations?.[n],this.config[`~hooks`]?.operations?.getKind,this.context.config.parser.hooks.operations?.[n],this.context.config.parser.hooks.operations?.getKind,nl];for(let n of r)if(n){let r=n(e);if(r!==void 0)return typeof r==`boolean`?r:r.includes(t)}return!1}},il=class{config;gen;graph;ir={};logger;package;plugins={};spec;constructor({config:e,dependencies:n,logger:r,spec:i}){this.config=e,this.gen=new t({defaultFileName:`index`,fileName:t=>{let n=S({config:e.output.fileName,name:t}),{suffix:r}=e.output.fileName;return r?n===`index`||n.endsWith(r)?n:`${n}${r}`:n},renderers:{".ts":new Gc},root:e.output.path}),this.logger=r,this.package=Hr(n),this.spec=i}dereference(e){let t=this.resolveRef(e.$ref),n={...e,...t};return delete n.$ref,n}registerPlugin(e){let t=this.config.plugins[e],n=new rl({api:t.api,config:t.config,context:this,dependencies:t.dependencies??[],gen:this.gen,handler:t.handler,name:t.name});return this.plugins[n.name]=n,n}registerPlugins(){return this.config.pluginOrder.map(e=>this.registerPlugin(e))}resolveIrRef(e){return Jn({$ref:e,spec:this.ir})}resolveRef(e){return Jn({$ref:e,spec:this.spec})}};const al=[`delete`,`get`,`head`,`options`,`patch`,`post`,`put`,`trace`],ol=({context:e,count:t=1,id:n,method:r,path:i,state:a})=>{let o,{output:s}=e.config,c=(s!==void 0&&typeof s==`object`&&`case`in s?s.case:void 0)??`camelCase`;return o=n&&(!e.config.plugins[`@hey-api/sdk`]||e.config.plugins[`@hey-api/sdk`].config.operationId)?x({case:c,value:tt(n)}):x({case:c,value:`${r}-${i.replace(/{(.*?)}/g,`by-$1`).replace(/[/:+]/g,`-`)}`}),t>1&&(o=`${o}${t}`),a.ids.has(o)?ol({context:e,count:t+1,id:n,method:r,path:i,state:a}):(a.ids.set(o,T({method:r,path:i})),o)},J=(e,t=``)=>`${e}/${t}`,Y=e=>{let t=e.indexOf(`/`);return{name:e.slice(t+1),namespace:e.slice(0,t)}},sl=e=>{switch(e){case`parameters`:return`parameter`;case`requestBodies`:return`body`;case`responses`:return`response`;case`definitions`:case`schemas`:return`schema`;default:return`unknown`}},cl=(e,t)=>{let n=[],r=[];if(t)for(let i of t)i.startsWith(`/`)&&i.endsWith(`/`)?r.push(new RegExp(i.slice(1,i.length-1))):n.push(J(e,i));return{regexps:r,set:new Set(n)}},ll=({excludeOperations:e,excludeSchemas:t,includeOperations:n,includeSchemas:r,spec:i})=>{if((e.regexps.length||n.regexps.length)&&i.paths)for(let t of Object.entries(i.paths)){let r=t[0],i=t[1];for(let t of al){if(!i[t])continue;let a=T({method:t,path:r});e.regexps.some(e=>e.test(a))&&e.set.add(J(`operation`,a)),n.regexps.some(e=>e.test(a))&&n.set.add(J(`operation`,a))}}if(i.definitions&&(t.regexps.length||r.regexps.length))for(let e of Object.keys(i.definitions))t.regexps.some(t=>t.test(e))&&t.set.add(J(`schema`,e)),r.regexps.some(t=>t.test(e))&&r.set.add(J(`schema`,e))},ul=({excludeOperations:e,excludeParameters:t,excludeRequestBodies:n,excludeResponses:r,excludeSchemas:i,includeOperations:a,includeParameters:o,includeRequestBodies:s,includeResponses:c,includeSchemas:l,spec:u})=>{if((e.regexps.length||a.regexps.length)&&u.paths)for(let t of Object.entries(u.paths)){let n=t[0],r=t[1];for(let t of al){if(!r[t])continue;let i=T({method:t,path:n});e.regexps.some(e=>e.test(i))&&e.set.add(J(`operation`,i)),a.regexps.some(e=>e.test(i))&&a.set.add(J(`operation`,i))}}if(u.components){if((t.regexps.length||o.regexps.length)&&u.components.parameters)for(let e of Object.keys(u.components.parameters))t.regexps.some(t=>t.test(e))&&t.set.add(J(`parameter`,e)),o.regexps.some(t=>t.test(e))&&o.set.add(J(`parameter`,e));if((n.regexps.length||s.regexps.length)&&u.components.requestBodies)for(let e of Object.keys(u.components.requestBodies))n.regexps.some(t=>t.test(e))&&n.set.add(J(`body`,e)),s.regexps.some(t=>t.test(e))&&s.set.add(J(`body`,e));if((r.regexps.length||c.regexps.length)&&u.components.responses)for(let e of Object.keys(u.components.responses))r.regexps.some(t=>t.test(e))&&r.set.add(J(`response`,e)),c.regexps.some(t=>t.test(e))&&c.set.add(J(`response`,e));if((i.regexps.length||l.regexps.length)&&u.components.schemas)for(let e of Object.keys(u.components.schemas))i.regexps.some(t=>t.test(e))&&i.set.add(J(`schema`,e)),l.regexps.some(t=>t.test(e))&&l.set.add(J(`schema`,e))}},dl=({spec:e,...t})=>{`swagger`in e?ll({...t,spec:e}):ul({...t,spec:e})},fl=(e,t,n)=>{let r=n.timeEvent(`create-filters`),i=cl(`operation`,e?.operations?.exclude),a=cl(`operation`,e?.operations?.include),o=cl(`parameter`,e?.parameters?.exclude),s=cl(`parameter`,e?.parameters?.include),c=cl(`body`,e?.requestBodies?.exclude),l=cl(`body`,e?.requestBodies?.include),u=cl(`response`,e?.responses?.exclude),d=cl(`response`,e?.responses?.include),f=cl(`schema`,e?.schemas?.exclude),p=cl(`schema`,e?.schemas?.include);dl({excludeOperations:i,excludeParameters:o,excludeRequestBodies:c,excludeResponses:u,excludeSchemas:f,includeOperations:a,includeParameters:s,includeRequestBodies:l,includeResponses:d,includeSchemas:p,spec:t});let m={deprecated:e?.deprecated??!0,operations:{exclude:i.set,include:a.set},orphans:e?.orphans??!1,parameters:{exclude:o.set,include:s.set},preserveOrder:e?.preserveOrder??!1,requestBodies:{exclude:c.set,include:l.set},responses:{exclude:u.set,include:d.set},schemas:{exclude:f.set,include:p.set},tags:{exclude:new Set(e?.tags?.exclude),include:new Set(e?.tags?.include)}};return r.timeEnd(),m},pl=e=>e?e.orphans===!1||e.deprecated===!1?!0:!!(e.operations?.exclude?.length||e.operations?.include?.length||e.parameters?.exclude?.length||e.parameters?.include?.length||e.requestBodies?.exclude?.length||e.requestBodies?.include?.length||e.responses?.exclude?.length||e.responses?.include?.length||e.schemas?.exclude?.length||e.schemas?.include?.length||e.tags?.exclude?.length||e.tags?.include?.length):!1,ml=({filters:e,parameters:t,requestBodies:n,resourceMetadata:r,responses:i,schemas:a})=>{let o=new Set,s=[...e.operations.include.size?e.operations.include:new Set(r.operations.keys())];for(;s.length;){let c=s.pop();if(e.operations.exclude.has(c)||o.has(c))continue;let l=r.operations.get(c);l&&(!e.deprecated&&l.deprecated||e.tags.exclude.size&&l.tags.size&&[...e.tags.exclude].some(e=>l.tags.has(e))||e.tags.include.size&&!new Set([...e.tags.include].filter(e=>l.tags.has(e))).size||[...l.dependencies].some(e=>{let{namespace:r}=Y(e);switch(r){case`body`:return!n.has(e);case`parameter`:return!t.has(e);case`response`:return!i.has(e);case`schema`:return!a.has(e);default:return!1}})||o.add(c))}return{operations:o}},hl=({filters:e,resourceMetadata:t,schemas:n})=>{let r=new Set,i=[...e.parameters.include.size?e.parameters.include:new Set(t.parameters.keys())];for(;i.length;){let a=i.pop();if(e.parameters.exclude.has(a)||r.has(a))continue;let o=t.parameters.get(a);if(o&&!(!e.deprecated&&o.deprecated)&&(r.add(a),o.dependencies.size))for(let t of o.dependencies){let{namespace:o}=Y(t);switch(o){case`body`:e.requestBodies.exclude.has(t)?r.delete(a):r.has(t)||i.push(t);break;case`schema`:e.schemas.exclude.has(t)?r.delete(a):n.has(t)||n.add(t);break}}}return{parameters:r}},gl=({filters:e,resourceMetadata:t,schemas:n})=>{let r=new Set,i=[...e.requestBodies.include.size?e.requestBodies.include:new Set(t.requestBodies.keys())];for(;i.length;){let a=i.pop();if(e.requestBodies.exclude.has(a)||r.has(a))continue;let o=t.requestBodies.get(a);if(o&&!(!e.deprecated&&o.deprecated)&&(r.add(a),o.dependencies.size))for(let t of o.dependencies){let{namespace:o}=Y(t);switch(o){case`body`:e.requestBodies.exclude.has(t)?r.delete(a):r.has(t)||i.push(t);break;case`schema`:e.schemas.exclude.has(t)?r.delete(a):n.has(t)||n.add(t);break}}}return{requestBodies:r}},_l=({filters:e,resourceMetadata:t,schemas:n})=>{let r=new Set,i=[...e.responses.include.size?e.responses.include:new Set(t.responses.keys())];for(;i.length;){let a=i.pop();if(e.responses.exclude.has(a)||r.has(a))continue;let o=t.responses.get(a);if(o&&!(!e.deprecated&&o.deprecated)&&(r.add(a),o.dependencies.size))for(let t of o.dependencies){let{namespace:o}=Y(t);switch(o){case`body`:e.requestBodies.exclude.has(t)?r.delete(a):r.has(t)||i.push(t);break;case`schema`:e.schemas.exclude.has(t)?r.delete(a):n.has(t)||n.add(t);break}}}return{responses:r}},vl=({filters:e,resourceMetadata:t})=>{let n=new Set,r=[...e.schemas.include.size?e.schemas.include:new Set(t.schemas.keys())];for(;r.length;){let i=r.pop();if(e.schemas.exclude.has(i)||n.has(i))continue;let a=t.schemas.get(i);if(a&&!(!e.deprecated&&a.deprecated)&&(n.add(i),a.dependencies.size))for(let t of a.dependencies){let{namespace:i}=Y(t);switch(i){case`schema`:!n.has(t)&&!e.schemas.exclude.has(t)&&r.push(t);break}}}return{schemas:n}},yl=({filters:e,parameters:t,resourceMetadata:n})=>{if(e.parameters.exclude.size)for(let r of t){let i=n.parameters.get(r);if(i?.dependencies.size){for(let n of e.parameters.exclude)if(i.dependencies.has(n)){t.delete(r);break}}}},bl=({filters:e,requestBodies:t,resourceMetadata:n})=>{if(e.requestBodies.exclude.size)for(let r of t){let i=n.requestBodies.get(r);if(i?.dependencies.size){for(let n of e.requestBodies.exclude)if(i.dependencies.has(n)){t.delete(r);break}}}},xl=({filters:e,resourceMetadata:t,responses:n})=>{if(e.responses.exclude.size)for(let r of n){let i=t.responses.get(r);if(i?.dependencies.size){for(let t of e.responses.exclude)if(i.dependencies.has(t)){n.delete(r);break}}}},Sl=({filters:e,resourceMetadata:t,schemas:n})=>{if(e.schemas.exclude.size)for(let r of n){let i=t.schemas.get(r);if(i?.dependencies.size){for(let t of e.schemas.exclude)if(i.dependencies.has(t)){n.delete(r);break}}}},Cl=({operationDependencies:e,parameters:t,requestBodies:n,responses:r,schemas:i})=>{for(let t of i)e.has(t)||i.delete(t);for(let n of t)e.has(n)||t.delete(n);for(let t of n)e.has(t)||n.delete(t);for(let t of r)e.has(t)||r.delete(t)},wl=({operations:e,resourceMetadata:t})=>{let n=new Set,r=[...new Set([...e].flatMap(e=>[...t.operations.get(e)?.dependencies??[]]))];for(;r.length;){let e=r.pop();if(n.has(e))continue;n.add(e);let{namespace:i}=Y(e),a;if(i===`body`?a=t.requestBodies.get(e)?.dependencies:i===`operation`?a=t.operations.get(e)?.dependencies:i===`parameter`?a=t.parameters.get(e)?.dependencies:i===`response`?a=t.responses.get(e)?.dependencies:i===`schema`&&(a=t.schemas.get(e)?.dependencies),a?.size)for(let e of a)n.has(e)||r.push(e)}return{operationDependencies:n}},Tl=({filters:e,logger:t,resourceMetadata:n})=>{let r=t.timeEvent(`create-filtered-dependencies`),{schemas:i}=vl({filters:e,resourceMetadata:n}),{parameters:a}=hl({filters:e,resourceMetadata:n,schemas:i}),{requestBodies:o}=gl({filters:e,resourceMetadata:n,schemas:i}),{responses:s}=_l({filters:e,resourceMetadata:n,schemas:i});Sl({filters:e,resourceMetadata:n,schemas:i}),yl({filters:e,parameters:a,resourceMetadata:n}),bl({filters:e,requestBodies:o,resourceMetadata:n}),xl({filters:e,resourceMetadata:n,responses:s});let{operations:c}=ml({filters:e,parameters:a,requestBodies:o,resourceMetadata:n,responses:s,schemas:i});if(!e.orphans&&c.size){let{operationDependencies:e}=wl({operations:c,resourceMetadata:n});Cl({operationDependencies:e,parameters:a,requestBodies:o,responses:s,schemas:i})}return r.timeEnd(),{operations:c,parameters:a,requestBodies:o,responses:s,schemas:i}},El=(e,t)=>{let n=t.timeEvent(`build-resource-metadata`),r={operations:new Map,parameters:new Map,requestBodies:new Map,responses:new Map,schemas:new Map},i=t=>{let n=new Set,r=e.transitiveDependencies.get(t);if(r?.size)for(let e of r){let t=Gn(e),r=t[t.length-2],i=t[t.length-1];if(r&&i){let e=sl(r);e===`unknown`&&console.warn(`unsupported type: ${r}`),n.add(J(e,i))}}return n};for(let[t,n]of e.nodes){let e=Gn(t);if(e[0]===`components`){if(e.length===3){if(e[1]===`schemas`){let a=e[e.length-1];r.schemas.set(J(`schema`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}else if(e[1]===`parameters`){let a=e[e.length-1];r.parameters.set(J(`parameter`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}else if(e[1]===`requestBodies`){let a=e[e.length-1];r.requestBodies.set(J(`body`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}else if(e[1]===`responses`){let a=e[e.length-1];r.responses.set(J(`response`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}}continue}if(e[0]===`paths`){if(e.length===3&&al.includes(e[2])){let a=e[e.length-1],o=T({method:a,path:e.slice(1,-1).join(`/`)});r.operations.set(J(`operation`,o),{dependencies:i(t),deprecated:n.deprecated??!1,tags:n.tags??new Set})}continue}if(e[0]===`definitions`){if(e.length===2){let a=e[e.length-1];r.schemas.set(J(`schema`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}continue}}return n.timeEnd(),{resourceMetadata:r}},Dl=e=>JSON.parse(JSON.stringify(e)),Ol=[[`additionalProperties`,`single`],[`allOf`,`array`],[`anyOf`,`array`],[`contains`,`single`],[`dependentSchemas`,`objectMap`],[`else`,`single`],[`if`,`single`],[`items`,`singleOrArray`],[`oneOf`,`array`],[`patternProperties`,`objectMap`],[`properties`,`objectMap`],[`propertyNames`,`single`],[`then`,`single`]],kl=e=>{if(Al(e))return e.components.schemas;if(jl(e))return e.definitions},Al=e=>typeof e==`object`&&!!e&&`components`in e&&typeof e.components==`object`&&e.components!==null&&`schemas`in e.components&&typeof e.components.schemas==`object`&&e.components.schemas!==null,jl=e=>typeof e==`object`&&!!e&&`definitions`in e&&typeof e.definitions==`object`&&e.definitions!==null,Ml=(e,t)=>e instanceof Set?e.has(t):e instanceof Array?e.includes(t):t in e,Nl=({base:e,components:t,extraComponents:n})=>{let r=2,i=e;for(;Ml(t,i)||n&&Ml(n,i);)i=`${e}${r}`,r+=1;return i},Pl=e=>e.length===3&&e[0]===`components`&&e[1]===`schemas`||e.length===2&&e[0]===`definitions`,Fl=e=>{if(e&&typeof e==`object`){if(`swagger`in e)return`#/definitions/`;if(`openapi`in e)return`#/components/schemas/`}return``},Il=e=>{if(!e||typeof e!=`object`||!(`enum`in e)||!(e.enum instanceof Array))return;let t=(`type`in e?e.type:void 0)||``,n=[...e.enum].sort();return JSON.stringify({type:t,values:n})},Ll=({key:e,node:t,parent:n,path:r,visitor:i})=>{if(!t||typeof t!=`object`||t instanceof Array)return;let a=t;(`type`in a||`enum`in a||Ol.some(([e])=>e in a))&&i({key:e,node:t,parent:n,path:r});for(let[e,n]of Object.entries(a))typeof n==`object`&&n&&(n instanceof Array?n.forEach((t,a)=>Ll({key:a,node:t,parent:n,path:[...r,e,a],visitor:i})):Ll({key:e,node:n,parent:t,path:[...r,e],visitor:i}))},Rl=({spec:e})=>{let t=kl(e);if(!t)return;let n=Fl(e),r={};for(let[e,i]of Object.entries(t))Il(i)&&(r[`${n}${e}`]=i);let i=e=>{if(e instanceof Array)e.forEach(i);else if(e&&typeof e==`object`)for(let[t,n]of Object.entries(e))t===`$ref`&&typeof n==`string`&&n in r?(Object.assign(e,Dl(r[n])),delete e.$ref):i(n)};i(e);for(let e of Object.keys(r)){let n=Gn(e),r=n[n.length-1];r&&delete t[r]}},zl=({config:e,spec:t})=>{let n=kl(t);if(!n)return;let r={};for(let[e,t]of Object.entries(n)){let n=Il(t);n&&(r[n]=e)}let i=[];Ll({key:null,node:t,parent:null,path:[],visitor:e=>{if(!Pl(e.path)){let t=Il(e.node);t&&i.push({...e,signature:t})}}});let a={},o={};for(let{key:t,node:s,signature:c}of i)if(!(c in a)){if(c in r){a[c]=r[c];continue}a[c]=Nl({base:S({config:e,name:typeof s==`object`&&s&&`title`in s&&typeof s.title==`string`?s.title:String(t)}),components:n,extraComponents:Object.values(a)}),o[c]=s}for(let[e,t]of Object.entries(a)){let r=o[e];t&&!(t in n)&&r&&typeof r==`object`&&(n[t]=r)}let s=Fl(t);for(let{key:e,parent:t,signature:n}of i){let r=a[n];r&&e!=null&&t&&typeof t==`object`&&(t[e]={$ref:`${s}${r}`})}},Bl=({config:e,spec:t})=>{if(e.mode===`inline`){Rl({spec:t});return}if(e.mode===`root`){zl({config:e,spec:t});return}},Vl=({key:e,node:t,parent:n,path:r,visitor:i})=>{if(!t||typeof t!=`object`||t instanceof Array)return;let a=t;(`type`in a||Ol.some(([e])=>e in a))&&i({key:e,node:t,parent:n,path:r});for(let[e,n]of Object.entries(a))typeof n==`object`&&n&&(n instanceof Array?n.forEach((t,a)=>Vl({key:a,node:t,parent:n,path:[...r,e,a],visitor:i})):Vl({key:e,node:n,parent:t,path:[...r,e],visitor:i}))},Hl=({spec:e})=>{Vl({key:null,node:e,parent:null,path:[],visitor:e=>{if(e.node&&typeof e.node==`object`&&`type`in e.node&&e.node.type===`object`&&`properties`in e.node&&e.node.properties&&typeof e.node.properties==`object`&&!(`required`in e.node)){let t=Object.keys(e.node.properties);t.length>0&&(e.node.required=t)}}})},Ul=(e,t)=>{if(e===t)return!0;if(e===null||t===null)return e===t;let n=typeof e;if(n!==typeof t||n!==`object`)return!1;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Ul(e[n],t[n]))return!1;return!0}let r=e,i=t,a=Object.keys(r).sort(),o=Object.keys(i).sort();if(a.length!==o.length)return!1;for(let e=0;e<a.length;e++)if(a[e]!==o[e])return!1;for(let e of a)if(!Ul(r[e],i[e]))return!1;return!0};var Wl=Ul;const Gl=e=>{for(let[,t]of e)if(!t.scopes&&t.parentPointer){let n=e.get(t.parentPointer);n?.scopes&&(t.scopes=new Set(n.scopes))}},Kl=({cache:e,graph:t,pointer:n,visited:r})=>{let i=e.transitiveDependencies.get(n);if(i)return{subtreeDependencies:e.subtreeDependencies.get(n),transitiveDependencies:i};if(r.has(n)||(r.add(n),!t.nodes.get(n)))return{subtreeDependencies:new Set,transitiveDependencies:new Set};let a=new Set,o=new Set,s=t.nodeDependencies.get(n);if(s)for(let n of s){a.add(n),o.add(n);let i=Kl({cache:e,graph:t,pointer:n,visited:r});for(let e of i.transitiveDependencies)a.add(e)}let c=e.parentToChildren.get(n)??[];for(let n of c){let i={subtreeDependencies:e.subtreeDependencies.get(n),transitiveDependencies:e.transitiveDependencies.get(n)};(!i.subtreeDependencies||!i.transitiveDependencies)&&(i=Kl({cache:e,graph:t,pointer:n,visited:r}),e.transitiveDependencies.set(n,i.transitiveDependencies),e.subtreeDependencies.set(n,i.subtreeDependencies));for(let e of i.transitiveDependencies)a.add(e);for(let e of i.subtreeDependencies)o.add(e)}return e.transitiveDependencies.set(n,a),e.subtreeDependencies.set(n,o),{subtreeDependencies:o,transitiveDependencies:a}},ql=e=>{let t=new Set(Array.from(e.nodes.entries()).filter(([,e])=>e.scopes&&e.scopes.size>0).map(([e])=>e)),n=(n,r,i)=>{r.parentPointer&&t.add(r.parentPointer);let a=e.reverseNodeDependencies.get(n);if(a)for(let e of a)t.add(e);if(i){let e=i.match(/(.*)\/(allOf|anyOf|oneOf)\/\d+$/);if(e){let n=e[1];n&&t.add(n)}}},r=(t,r,i)=>{if(!r?.scopes)return;let a=e.nodes.get(i);a?.scopes&&Jl(a,r)&&n(t,r,i)};for(;t.size>0;){let i=t.values().next().value;t.delete(i);let a=e.nodes.get(i);if(!a)continue;a.scopes||=new Set;let o=a.node;for(let[e,t]of Ol){if(!o||typeof o!=`object`||!(e in o))continue;let n=o[e];if(t===`array`&&n instanceof Array)for(let t=0;t<n.length;t++)r(i,a,`${i}/${e}/${t}`);else if(t===`objectMap`&&typeof n==`object`&&n&&!(n instanceof Array))for(let t of Object.keys(n))r(i,a,`${i}/${e}/${t}`);else if(t===`single`&&typeof n==`object`&&n)r(i,a,`${i}/${e}`);else if(t===`singleOrArray`)if(n instanceof Array)for(let t=0;t<n.length;t++)r(i,a,`${i}/${e}/${t}`);else typeof n==`object`&&n&&r(i,a,`${i}/${e}`)}let s=e.nodeDependencies.get(i);if(s)for(let t of s){let r=e.nodes.get(t);r?.scopes&&Jl(r,a)&&n(i,a)}if(a.parentPointer){let t=e.nodes.get(a.parentPointer);t&&Jl(a,t)&&n(a.parentPointer,t)}}},Jl=(e,t)=>{if(!e.scopes)return!1;t.scopes||=new Set;let n=!1;for(let r of e.scopes)t.scopes.has(r)||(t.scopes.add(r),n=!0);return n},Yl=e=>{for(let[t,n]of e){let{node:e}=n;typeof e!=`object`||!e||e instanceof Array||(`readOnly`in e&&e.readOnly===!0?n.scopes=new Set([`read`]):`writeOnly`in e&&e.writeOnly===!0?n.scopes=new Set([`write`]):t.match(/\/properties\/[^/]+$/)&&(n.scopes=new Set([`normal`])))}},Xl=(e,t)=>{let n=t.timeEvent(`build-graph`),r={nodeDependencies:new Map,nodes:new Map,reverseNodeDependencies:new Map,subtreeDependencies:new Map,transitiveDependencies:new Map},i=({key:e,node:t,parentPointer:n,path:a})=>{if(typeof t!=`object`||!t)return;let o=qn(a),s,c;if(typeof t==`object`&&t){if(`deprecated`in t&&typeof t.deprecated==`boolean`&&(s=!!t.deprecated),`$ref`in t&&typeof t.$ref==`string`){let e=Kn(t.$ref);r.nodeDependencies.has(o)||r.nodeDependencies.set(o,new Set),r.nodeDependencies.get(o).add(e)}`tags`in t&&t.tags instanceof Array&&(c=new Set(t.tags.filter(e=>typeof e==`string`)))}if(r.nodes.set(o,{deprecated:s,key:e,node:t,parentPointer:n,tags:c}),t instanceof Array)t.forEach((e,t)=>i({key:t,node:e,parentPointer:o,path:[...a,t]}));else for(let[e,n]of Object.entries(t))i({key:e,node:n,parentPointer:o,path:[...a,e]})};i({key:null,node:e,parentPointer:null,path:[]});let a={parentToChildren:new Map,subtreeDependencies:new Map,transitiveDependencies:new Map};for(let[e,t]of r.nodes){let n=t.parentPointer;n&&(a.parentToChildren.has(n)||a.parentToChildren.set(n,[]),a.parentToChildren.get(n).push(e))}for(let[e,t]of r.nodeDependencies)for(let n of t)r.reverseNodeDependencies.has(n)||r.reverseNodeDependencies.set(n,new Set),r.reverseNodeDependencies.get(n).add(e);Yl(r.nodes),ql(r),Gl(r.nodes);for(let e of r.nodes.keys()){let t=Kl({cache:a,graph:r,pointer:e,visited:new Set});r.transitiveDependencies.set(e,t.transitiveDependencies),r.subtreeDependencies.set(e,t.subtreeDependencies)}return n.timeEnd(),{graph:r}},Zl=new Set([`additionalProperties`,`allOf`,`anyOf`,`items`,`not`,`oneOf`,`patternProperties`,`properties`,`schema`]),Ql=e=>{if(e.length===3&&e[0]===`components`){let t=e[1];if(t===`parameters`||t===`requestBodies`)return`write`;if(t===`responses`||t===`headers`)return`read`}if(e.length===2){let t=e[0];if(t===`parameters`)return`write`;if(t===`responses`)return`read`}},$l=(e,t)=>{let n=t.timeEvent(`capture-original-schemas`),r={};if(Al(e))for(let[t,n]of Object.entries(e.components.schemas))r[`#/components/schemas/${t}`]=n;else if(jl(e))for(let[t,n]of Object.entries(e.definitions))r[`#/definitions/${t}`]=n;return n.timeEnd(),r},eu=({logger:e,spec:t,split:n})=>{let r=e.timeEvent(`insert-split-schemas-into-spec`);Al(t)?Object.assign(t.components.schemas,n.schemas):jl(t)&&Object.assign(t.definitions,n.schemas),r.timeEnd()},tu=(e,t,n)=>{if(t&&typeof t==`object`){if(`$ref`in t&&typeof t.$ref==`string`){let r=e.nodes.get(t.$ref);if(r?.scopes&&(n===`writeOnly`&&r.scopes.size===1&&r.scopes.has(`write`)||n===`readOnly`&&r.scopes.size===1&&r.scopes.has(`read`))&&(delete t.$ref,!Ol.some(([e])=>e in t)))return!0}for(let[r,i]of Ol){if(!(r in t))continue;let a=t[r];if(i===`array`&&a instanceof Array){for(let t=a.length-1;t>=0;t--){let r=a[t];(r&&typeof r==`object`&&r[n]===!0||tu(e,r,n))&&a.splice(t,1)}a.length||delete t[r]}else if(i===`objectMap`&&typeof a==`object`&&a&&!(a instanceof Array)){let i=a,o=new Set;for(let t of Object.keys(i)){let a=i[t];(a&&typeof a==`object`&&a[n]===!0||tu(e,a,n))&&(delete i[t],r===`properties`&&o.add(t))}if(o.size>0&&r===`properties`&&`required`in t&&Array.isArray(t.required)){let e=t.required.filter(e=>!o.has(e));e.length?t.required=e:delete t.required}Object.keys(i).length||delete t[r]}else if(i===`single`&&typeof a==`object`&&a)(a[n]===!0||tu(e,a,n))&&delete t[r];else if(i===`singleOrArray`)if(a instanceof Array){for(let t=a.length-1;t>=0;t--){let r=a[t];(r&&typeof r==`object`&&r[n]===!0||tu(e,r,n))&&a.splice(t,1)}a.length||delete t[r]}else typeof a==`object`&&a&&(a[n]===!0||tu(e,a,n))&&delete t[r]}if(t.type===`object`&&!Ol.some(([e])=>e in t))return!0}return!1},nu=({logger:e,originalSchemas:t,spec:n,split:r})=>{let i=e.timeEvent(`remove-original-split-schemas`),a=kl(n);for(let e of Object.keys(r.mapping)){let n=Gn(e),r=n[n.length-1];typeof r==`string`&&a&&Object.prototype.hasOwnProperty.call(a,r)&&a[r]===t[e]&&delete a[r]}i.timeEnd()},ru=({config:e,graph:t,logger:n,spec:r})=>{let i=n.timeEvent(`split-schemas`),a=new Set,o={mapping:{},reverseMapping:{},schemas:{}},s=Fl(r),c=s.split(`/`).length-1,l=e=>{if(e.startsWith(s)){let t=Gn(e);if(t.length===c)return t[c-1]||``}return``};for(let e of t.nodes.keys()){let t=l(e);t&&a.add(t)}for(let[n,r]of t.nodes){let i=l(n);if(!i||!(r.scopes?.has(`read`)||r.scopes?.has(`write`))||!r.scopes?.has(`normal`))continue;let c=Dl(r.node);tu(t,c,`writeOnly`);let u=S({config:e.responses,name:i}),d=u===i?u:Nl({base:u,components:a});a.add(d),o.schemas[d]=c;let f=`${s}${d}`,p=Dl(r.node);tu(t,p,`readOnly`);let m=t.transitiveDependencies.get(n)||new Set;if(!Array.from(m).some(e=>{let n=t.nodes.get(e);return n?.scopes?.has(`normal`)&&(n.scopes.has(`read`)||n.scopes.has(`write`))})&&Wl(c,p)&&Wl(c,r.node))continue;let h=S({config:e.requests,name:i}),g=h===i&&h!==d?h:Nl({base:h,components:a});a.add(g),o.schemas[g]=p;let ee=`${s}${g}`;o.mapping[n]={read:f,write:ee},o.reverseMapping[f]=n,o.reverseMapping[ee]=n}return i.timeEnd(),o},iu=({logger:e,spec:t,split:n})=>{let r=e.timeEvent(`update-refs-in-spec`),i=Fl(t),a=({context:e,currentPointer:t,inSchema:r,node:o,path:s,visited:c=new Set})=>{if(o instanceof Array)o.forEach((n,i)=>a({context:e,currentPointer:t,inSchema:r,node:n,path:[...s,i],visited:c}));else if(o&&typeof o==`object`){let l=t,u=e;if(Pl(s)){l=`${i}${s[s.length-1]}`;let e=n.reverseMapping[l];if(e){let t=n.mapping[e];t?.read===l?u=`read`:t?.write===l&&(u=`write`)}}let d=Ql(s);if(d!==void 0){for(let e in o)Object.prototype.hasOwnProperty.call(o,e)&&a({context:d,currentPointer:l,inSchema:!1,node:o[e],path:[...s,e],visited:c});return}for(let e in o){if(!Object.prototype.hasOwnProperty.call(o,e))continue;let t=o[e];if(!r){if(e===`requestBody`){a({context:`write`,currentPointer:l,inSchema:!1,node:t,path:[...s,e],visited:c});continue}if(e===`responses`){a({context:`read`,currentPointer:l,inSchema:!1,node:t,path:[...s,e],visited:c});continue}if(e===`parameters`&&Array.isArray(t)){t.forEach((t,n)=>{t&&typeof t==`object`&&`schema`in t&&a({context:`write`,currentPointer:l,inSchema:!0,node:t.schema,path:[...s,e,n,`schema`],visited:c}),t&&typeof t==`object`&&`content`in t&&a({context:`write`,currentPointer:l,inSchema:!1,node:t.content,path:[...s,e,n,`content`],visited:c})});continue}if(e===`headers`&&typeof t==`object`&&t){for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&a({context:`read`,currentPointer:l,inSchema:!1,node:t[n],path:[...s,e,n],visited:c});continue}}if(Zl.has(e))a({context:u,currentPointer:l,inSchema:!0,node:t,path:[...s,e],visited:c});else if(e===`$ref`&&typeof t==`string`){let r=n.mapping[t];r&&(u===`read`&&r.read?o[e]=r.read:u===`write`&&r.write?o[e]=r.write:!u&&r.read&&(o[e]=r.read))}else a({context:u,currentPointer:l,inSchema:r,node:t,path:[...s,e],visited:c})}}};a({context:null,currentPointer:null,inSchema:!1,node:t,path:[]}),r.timeEnd()},au=({config:e,logger:t,spec:n})=>{let{graph:r}=Xl(n,t),i=$l(n,t),a=ru({config:e,graph:r,logger:t,spec:n});eu({logger:t,spec:n,split:a}),iu({logger:t,spec:n,split:a}),nu({logger:t,originalSchemas:i,spec:n,split:a})},ou=({context:e})=>{let{logger:t}=e,n=t.timeEvent(`transform-openapi-spec`);e.config.parser.transforms.enums.enabled&&Bl({config:e.config.parser.transforms.enums,spec:e.spec}),e.config.parser.transforms.propertiesRequiredByDefault&&Hl({spec:e.spec}),e.config.parser.transforms.readWrite.enabled&&au({config:e.config.parser.transforms.readWrite,logger:t,spec:e.spec}),n.timeEnd()},X=({source:e,target:t})=>{let n={...t};if(e&&(e.cookie&&(n.cookie?n.cookie={...n.cookie,...e.cookie}:n.cookie=e.cookie),e.header&&(n.header?n.header={...n.header,...e.header}:n.header=e.header),e.path&&(n.path?n.path={...n.path,...e.path}:n.path=e.path),e.query&&(n.query?n.query={...n.query,...e.query}:n.query=e.query)),Object.keys(n).length)return n},su=e=>/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e),cu=e=>e.map((e,t)=>typeof e==`number`?`[${e}]`:t===0?e:su(e)?`.${e}`:`['${e.replace(/"/g,`\\'`)}']`).join(``),lu=e=>{let t=cu(e.path),n=e.severity===`error`?a.bold.red:a.bold.yellow,r=e.message.replace(/`([^`]+)`/g,(e,t)=>a.yellow(`\`${t}\``));return`${n(`[${e.severity.toUpperCase()}]`)} ${a.cyan(t)}: ${r}`},uu=({context:e,issue:t})=>e.config.logs.level===`silent`?!1:t.severity===`error`?e.config.logs.level!==`warn`:!0,du=({context:e,result:t})=>{for(let n of t.issues)uu({context:e,issue:n})&&console.log(lu(n));t.valid||process.exit(1)},fu=({logger:e,operations:t,preserveOrder:n,schemas:r,spec:i})=>{let a=e.timeEvent(`filter-spec`);if(i.definitions){let e={};if(n)for(let[t,n]of Object.entries(i.definitions))r.has(J(`schema`,t))&&(e[t]=n);else for(let t of r){let{name:n}=Y(t),r=i.definitions[n];r&&(e[n]=r)}i.definitions=e}if(i.paths)for(let e of Object.entries(i.paths)){let n=e[0],r=e[1];for(let e of al){if(!r[e])continue;let i=J(`operation`,T({method:e,path:n}));t.has(i)||delete r[e]}Object.keys(r).length||delete i.paths[n]}a.timeEnd()},pu=/^(application\/(pdf|rtf|msword|vnd\.(ms-|openxmlformats-officedocument\.)|zip|x-(7z|tar|rar|zip|iso)|octet-stream|gzip|x-msdownload|json\+download|xml|x-yaml|x-7z-compressed|x-tar)|text\/(yaml|css|javascript)|audio\/(mpeg|wav)|video\/(mp4|x-matroska)|image\/(vnd\.adobe\.photoshop|svg\+xml))(; ?charset=[^;]+)?$/i,mu=/^application\/(.*\+)?json(;.*)?$/i,hu=/^multipart\/form-data(;.*)?$/i,gu=/^text\/[a-z0-9.+-]+(;.*)?$/i,_u=/^application\/x-www-form-urlencoded(;.*)?$/i,vu=/^application\/octet-stream(;.*)?$/i,yu=({mediaType:e})=>(pu.lastIndex=0,pu.test(e)),bu=({mediaType:e})=>{if(mu.lastIndex=0,mu.test(e))return`json`;if(hu.lastIndex=0,hu.test(e))return`form-data`;if(gu.lastIndex=0,gu.test(e))return`text`;if(_u.lastIndex=0,_u.test(e))return`url-search-params`;if(vu.lastIndex=0,vu.test(e))return`octet-stream`},xu=({content:e})=>{let{mediaType:t,schema:n}=e;return n&&`$ref`in n?{allOf:[{...n}]}:n?n.type===`string`&&!n.format&&yu({mediaType:t})?{...n,format:`binary`}:n:yu({mediaType:t})?{format:`binary`,type:`string`}:void 0},Su=({mimeTypes:e,response:t})=>{let n=[];for(let r of e??[])n.push({mediaType:r,schema:t.schema,type:bu({mediaType:r})});return n};function Cu(e){let t=`^(${e.keywords.join(`|`)})$`;return new RegExp(t)}const wu=(e,t,n)=>{let r=[];for(let n in t)t[n]===e&&r.push(n);return!r.length&&(!n||n())?[I(e)]:r},Tu=({schema:e})=>{if(e.type)return e.type;if(e.properties)return`object`},Eu=({irSchema:e,schema:t})=>{t.example&&(e.example=t.example),t.description&&(e.description=t.description),t.title&&(e.title=t.title)},Du=({irSchema:e,schema:t})=>{t.default!==void 0&&(e.default=t.default),t.exclusiveMaximum?t.maximum!==void 0&&(e.exclusiveMaximum=t.maximum):t.maximum!==void 0&&(e.maximum=t.maximum),t.exclusiveMinimum?t.minimum!==void 0&&(e.exclusiveMinimum=t.minimum):t.minimum!==void 0&&(e.minimum=t.minimum),t.format&&(e.format=t.format),t.maxItems!==void 0&&(e.maxItems=t.maxItems),t.maxLength!==void 0&&(e.maxLength=t.maxLength),t.minItems!==void 0&&(e.minItems=t.minItems),t.minLength!==void 0&&(e.minLength=t.minLength),t.pattern&&(e.pattern=t.pattern),t.readOnly&&(e.accessScope=`read`)},Ou=({context:e,irSchema:t={},schema:n,state:r})=>{n.maxItems&&n.maxItems===n.minItems?t.type=`tuple`:t.type=`array`;let i=[];if(n.items){let a=Vu({context:e,schema:n.items,state:r});if(!i.length&&n.maxItems&&n.maxItems===n.minItems)i=Array(n.maxItems).fill(a);else if(`$ref`in n.items)i.push(a);else{let e=n.items.allOf;e&&e.length>1&&!n.items[`x-nullable`]?t={...t,...a}:i.push(a)}}return t=w({items:i,schema:t}),t},ku=({irSchema:e={}})=>(e.type=`boolean`,e),Au=({irSchema:e={},schema:t})=>(e.type=t.type,e),ju=({context:e,irSchema:t={},schema:n,state:r})=>{t.type=`object`;let i={};for(let t in n.properties){let a=n.properties[t];typeof a==`boolean`||(i[t]=Vu({context:e,schema:a,state:r}))}return Object.keys(i).length&&(t.properties=i),n.additionalProperties===void 0?t.properties||(t.additionalProperties={type:`unknown`}):typeof n.additionalProperties==`boolean`?r.inAllOf&&n.additionalProperties===!1&&(!n.properties||!Object.keys(n.properties).length)||(t.additionalProperties={type:n.additionalProperties?`unknown`:`never`}):t.additionalProperties=Vu({context:e,schema:n.additionalProperties,state:r}),n.required&&(t.required=n.required),t},Mu=({irSchema:e={}})=>(e.type=`string`,e),Nu=({schema:e})=>{let t={};return Eu({irSchema:t,schema:e}),t},Pu=({context:e,schema:t,state:n})=>{let r=Nu({schema:t}),i=[],a=Tu({schema:t}),o=t.allOf;for(let r of o){let a=n.inAllOf;`$ref`in r||(n.inAllOf=!0);let o=Vu({context:e,schema:r,state:n});if(n.inAllOf=a,n.inAllOf===void 0&&delete n.inAllOf,t.required&&(o.required?o.required=[...o.required,...t.required]:o.required=t.required),i.push(o),r.$ref){let t=e.resolveRef(r.$ref);if(t.discriminator&&n.$ref){let e=wu(n.$ref).map(e=>({const:e,type:`string`})),r={properties:{[t.discriminator]:e.length>1?{items:e,logicalOperator:`or`}:e[0]},type:`object`};t.required?.includes(t.discriminator)&&(r.required=[t.discriminator]),i.push(r)}}}if(a===`object`){let r=zu({context:e,schema:{...t,type:`object`},state:n});if(r.properties){for(let t of r.required??[])if(!r.properties[t])for(let i of o){let a=i.$ref?e.resolveRef(i.$ref):i;if(Tu({schema:a})===`object`){let i=zu({context:e,schema:{...a,type:`object`},state:n});if(i.properties?.[t]){r.properties[t]=i.properties[t];break}}}i.push(r)}}if(r=w({items:i,logicalOperator:`and`,mutateSchemaOneItem:!0,schema:r}),t[`x-nullable`]){let e=[{type:`null`}];i.length&&e.unshift(r),r={items:e,logicalOperator:`or`},e[0].deprecated&&(r.deprecated=e[0].deprecated),e[0].description&&(r.description=e[0].description)}return r},Fu=({context:e,schema:t,state:n})=>{let r=Nu({schema:t});r.type=`enum`;let i=[];for(let[r,a]of t.enum.entries()){let o=typeof a,s;if(o===`string`||o===`number`||o===`boolean`?s=o:o===`object`&&Array.isArray(a)?s=`array`:a===null?t[`x-nullable`]&&(s=`null`):console.warn(`🚨`,`unhandled "${o}" typeof value "${a}" for enum`,t.enum),!s)continue;let c=zu({context:e,schema:{description:t[`x-enum-descriptions`]?.[r],title:t[`x-enum-varnames`]?.[r]??t[`x-enumNames`]?.[r],type:s===`null`?`string`:s},state:n});c.const=a,s===`null`&&(c.type=s),c.type===`array`&&(c.type=`tuple`),i.push(c)}return r=w({items:i,schema:r}),r},Iu=({context:e,schema:t,state:n})=>{let r={};if(!t.$ref.startsWith(`#/definitions/`)&&!n.circularReferenceTracker.has(t.$ref)){let r=e.resolveRef(t.$ref),i=n.$ref;n.$ref=t.$ref;let a=Vu({context:e,schema:r,state:n});return n.$ref=i,a}if(r.$ref=decodeURI(t.$ref),r.$ref=r.$ref.replace(/#\/definitions\/([^/]+)/g,`#/components/schemas/$1`),!n.circularReferenceTracker.has(t.$ref)){let r=e.resolveRef(t.$ref),i=n.$ref;n.$ref=t.$ref,Vu({context:e,schema:r,state:n}),n.$ref=i}return r},Lu=({context:e,irSchema:t,schema:n,state:r})=>{t||=Nu({schema:n});let i={};return Du({irSchema:i,schema:n}),i.default===null&&delete i.default,t=w({items:[zu({context:e,irSchema:i,schema:n,state:r}),{type:`null`}],schema:t}),t},Ru=({context:e,schema:t,state:n})=>{let r=Nu({schema:t});Du({irSchema:r,schema:t});let i=Tu({schema:t});return i?t[`x-nullable`]?Lu({context:e,irSchema:r,schema:{...t,type:i},state:n}):zu({context:e,irSchema:r,schema:{...t,type:i},state:n}):r},zu=({context:e,irSchema:t,schema:n,state:r})=>{switch(t||(t=Nu({schema:n}),Du({irSchema:t,schema:n})),n.type){case`array`:return Ou({context:e,irSchema:t,schema:n,state:r});case`boolean`:return ku({context:e,irSchema:t,schema:n,state:r});case`integer`:case`number`:return Au({context:e,irSchema:t,schema:n,state:r});case`object`:return ju({context:e,irSchema:t,schema:n,state:r});case`string`:return Mu({context:e,irSchema:t,schema:n,state:r});default:return Bu({context:e,irSchema:t,schema:n})}},Bu=({irSchema:e,schema:t})=>(e||=Nu({schema:t}),e.type=`unknown`,Du({irSchema:e,schema:t}),e),Vu=({context:e,schema:t,state:n})=>(n||={circularReferenceTracker:new Set},n.$ref&&n.circularReferenceTracker.add(n.$ref),t.$ref?Iu({context:e,schema:t,state:n}):t.enum?Fu({context:e,schema:t,state:n}):t.allOf?Pu({context:e,schema:t,state:n}):t.type||t.properties?Ru({context:e,schema:t,state:n}):Bu({context:e,schema:t})),Hu=({$ref:e,context:t,schema:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.schemas||(t.ir.components.schemas={}),t.ir.components.schemas[I(e)]=Vu({context:t,schema:n,state:{$ref:e,circularReferenceTracker:new Set}})},Uu=e=>e===`boolean`||e===`integer`||e===`number`||e===`string`,Wu=({context:e,name:t,schema:n})=>{if(Cu(e.config.parser.pagination).test(t))return!0;if(`$ref`in n){let r=e.resolveRef(n.$ref??``);return`in`in r&&r.in?Wu({context:e,name:t,schema:`schema`in r?r.schema:{...r,in:void 0}}):Wu({context:e,name:t,schema:r})}if(`in`in n)return n.in?Wu({context:e,name:t,schema:`schema`in n?n.schema:{...n,in:void 0}}):!1;for(let t in n.properties)if(Cu(e.config.parser.pagination).test(t)){let e=n.properties[t];if(typeof e!=`boolean`&&!(`$ref`in e)&&Uu(Tu({schema:e})))return t}for(let r of n.allOf??[]){let n=Wu({context:e,name:t,schema:r});if(n)return n}return!1},Gu=({irOperation:e,operation:t})=>{t.deprecated!==void 0&&(e.deprecated=t.deprecated),t.description&&(e.description=t.description),t.summary&&(e.summary=t.summary),t.tags?.length&&(e.tags=t.tags)},Ku=({context:e,method:t,operation:n,path:r,state:i})=>{let a={id:ol({context:e,id:n.operationId,method:t,path:r,state:i}),method:t,path:r};return n.operationId&&(a.operationId=n.operationId),Gu({irOperation:a,operation:n}),a},qu=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{let o=Ku({context:e,method:t,operation:n,path:r,state:a});n.parameters&&(o.parameters=n.parameters);let s=!1,c={mediaType:``,schema:{properties:{},required:[],type:`object`}},l=[],u=n.requestBody?.some(t=>(`$ref`in t?e.resolveRef(t.$ref):t).in===`body`);for(let t of n.requestBody??[]){let r=`$ref`in t?e.resolveRef(t.$ref):t,i=r.in===`body`?r.schema:{...r,format:r.type===`file`?`binary`:r.format,required:void 0,type:r.type===`file`?`string`:r.type},a=n.consumes;!a&&u&&r.in===`body`&&(a=[`application/json`]);let o=Su({mimeTypes:a,response:{schema:i}}),d=o.find(e=>e.type===`json`)||o[0];if(d){let t=Wu({context:e,name:``,schema:d.schema&&`$ref`in d.schema?{allOf:[{...d.schema}],description:r.description}:{description:r.description,...d.schema}}),n=Vu({context:e,schema:`$ref`in r?{allOf:[{...r,$ref:r.$ref,required:[],type:`string`}],description:r.description}:d.schema&&`$ref`in d.schema?{allOf:[{...d.schema}],description:r.description}:{description:r.description,...d.schema},state:void 0});c.mediaType=d.mediaType,r.in===`body`?c.schema=n:(c.schema.properties[r.name]=n,r.required&&l.push(r.name)),t&&(c.pagination=t),d.type&&(c.type=d.type)}r.required&&(s=!0)}for(let t in c.mediaType&&(l.length&&(c.schema.required=l),o.body=c,s&&(o.body.required=s)),n.responses){o.responses||={};let r=n.responses[t],i=`$ref`in r?e.resolveRef(r.$ref):r,a=Su({mimeTypes:n.produces?n.produces:[`application/json`],response:i}),s=a.find(e=>e.type===`json`)||a[0];s?o.responses[t]={mediaType:s.mediaType,schema:Vu({context:e,schema:{description:i.description,...xu({content:s})},state:void 0})}:o.responses[t]={schema:{description:i.description,type:t===`204`?`void`:`unknown`}}}if(n.security){let e=new Map;for(let t of n.security)for(let n in t){let t=i.get(n);if(!t)continue;let r;if(t.type===`apiKey`&&(r=t),t.type===`basic`&&(r={description:t.description,scheme:`basic`,type:`http`}),t.type===`oauth2`)switch(r={description:t.description,flows:{},type:`oauth2`},t.flow){case`accessCode`:r.flows.authorizationCode={authorizationUrl:t.authorizationUrl,scopes:t.scopes,tokenUrl:t.tokenUrl};break;case`application`:r.flows.clientCredentials={scopes:t.scopes,tokenUrl:t.tokenUrl};break;case`implicit`:r.flows.implicit={authorizationUrl:t.authorizationUrl,scopes:t.scopes};break;case`password`:r.flows.password={scopes:t.scopes,tokenUrl:t.tokenUrl};break}r&&e.set(n,r)}e.size&&(o.security=Array.from(e.values()))}return o},Ju=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{e.ir.paths||(e.ir.paths={}),e.ir.paths[r]||(e.ir.paths[r]={}),e.ir.paths[r][t]=qu({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})},Yu=e=>{switch(e){case`multi`:return!0;case`csv`:case`pipes`:case`ssv`:case`tsv`:default:return!1}},Xu=e=>{switch(e){case`header`:case`path`:return`simple`;case`query`:default:return`form`}},Zu=({context:e,operation:t,parameters:n})=>{if(!n||!Object.keys(n).length)return;let r={};for(let i of n){let n=`$ref`in i?e.dereference(i):i;if(n.in===`body`||n.in===`formData`){t.requestBody||=[],t.requestBody.push(n);continue}r[n.in]||(r[n.in]={}),r[n.in][n.name.toLocaleLowerCase()]=Qu({$ref:`#/todo/real/path/to/parameter/${n.name}`,context:e,parameter:n})}return r},Qu=({$ref:e,context:t,parameter:n})=>{let r=n,i=r&&`$ref`in r?{allOf:[{...r,$ref:r.$ref,required:Array.isArray(r.required)?r.required:[],type:r.type}],description:n.description}:{description:n.description,...r,required:Array.isArray(r.required)?r.required:[],type:r.type},a=Wu({context:t,name:n.name,schema:i}),o=Xu(n.in),s={allowReserved:!1,explode:Yu(n.collectionFormat),location:n.in,name:n.name,schema:Vu({context:t,schema:i,state:{$ref:e,circularReferenceTracker:new Set}}),style:o};return n.description&&(s.description=n.description),a&&(s.pagination=a),n.required&&(s.required=n.required),s},$u=({context:e})=>{let t=e.spec.schemes??[],n=e.spec.host??``,r=e.spec.basePath??``;for(let r of e.config.input)if(typeof r.path==`string`){let e=Ar(r.path);t.length||e.protocol&&(t=[e.protocol]),n||=`${e.host}${e.port?`:${e.port}`:``}`}t.length||(t=[``]);let i=t.map(e=>`${e?`${e}://`:``}${n}${r}`).filter(Boolean);i.length&&(e.ir.servers=i.map(e=>({url:e})))},ed=(e,t)=>{let n=t.timeEvent(`validate`),r=[],i=new Map;if(e.paths)for(let t of Object.entries(e.paths)){let e=t[0],n=t[1];for(let t of al){if(t===`trace`)continue;let a=n[t];if(!a)continue;let o=T({method:t,path:e});a.operationId&&(i.has(a.operationId)?r.push({code:`duplicate_key`,context:{key:`operationId`,value:a.operationId},message:"Duplicate `operationId` found. Each `operationId` must be unique.",path:[`paths`,e,t,`operationId`],severity:`error`}):i.set(a.operationId,o))}}return n.timeEnd(),{issues:r,valid:!r.some(e=>e.severity===`error`)}},td=e=>{if(e.config.parser.validate_EXPERIMENTAL&&du({context:e,result:ed(e.spec,e.logger)}),pl(e.config.parser.filters)){let t=fl(e.config.parser.filters,e.spec,e.logger),{graph:n}=Xl(e.spec,e.logger),{resourceMetadata:r}=El(n,e.logger);fu({...Tl({filters:t,logger:e.logger,resourceMetadata:r}),logger:e.logger,preserveOrder:t.preserveOrder,spec:e.spec})}ou({context:e});let t={ids:new Map},n=new Map;for(let t in e.spec.securityDefinitions){let r=e.spec.securityDefinitions[t];n.set(t,r)}if(e.spec.definitions)for(let t in e.spec.definitions){let n=`#/definitions/${t}`,r=e.spec.definitions[t];Hu({$ref:n,context:e,schema:r})}for(let r in $u({context:e}),e.spec.paths){if(r.startsWith(`x-`))continue;let i=e.spec.paths[r],a=i.$ref?{...e.resolveRef(i.$ref),...i}:i,o={consumes:e.spec.consumes,produces:e.spec.produces,responses:{},security:e.spec.security},s={context:e,operation:{...o,parameters:Zu({context:e,operation:o,parameters:a.parameters})},path:r,securitySchemesMap:n,state:t};if(a.delete){let t=X({source:Zu({context:e,operation:a.delete,parameters:a.delete.parameters}),target:s.operation.parameters});Ju({...s,method:`delete`,operation:{...s.operation,...a.delete,parameters:t}})}if(a.get){let t=X({source:Zu({context:e,operation:a.get,parameters:a.get.parameters}),target:s.operation.parameters});Ju({...s,method:`get`,operation:{...s.operation,...a.get,parameters:t}})}if(a.head){let t=X({source:Zu({context:e,operation:a.head,parameters:a.head.parameters}),target:s.operation.parameters});Ju({...s,method:`head`,operation:{...s.operation,...a.head,parameters:t}})}if(a.options){let t=X({source:Zu({context:e,operation:a.options,parameters:a.options.parameters}),target:s.operation.parameters});Ju({...s,method:`options`,operation:{...s.operation,...a.options,parameters:t}})}if(a.patch){let t=X({source:Zu({context:e,operation:a.patch,parameters:a.patch.parameters}),target:s.operation.parameters});Ju({...s,method:`patch`,operation:{...s.operation,...a.patch,parameters:t}})}if(a.post){let t=X({source:Zu({context:e,operation:a.post,parameters:a.post.parameters}),target:s.operation.parameters});Ju({...s,method:`post`,operation:{...s.operation,...a.post,parameters:t}})}if(a.put){let t=X({source:Zu({context:e,operation:a.put,parameters:a.put.parameters}),target:s.operation.parameters});Ju({...s,method:`put`,operation:{...s.operation,...a.put,parameters:t}})}}},nd=({logger:e,operations:t,parameters:n,preserveOrder:r,requestBodies:i,responses:a,schemas:o,spec:s})=>{let c=e.timeEvent(`filter-spec`);if(s.components){if(s.components.parameters){let e={};if(r)for(let[t,r]of Object.entries(s.components.parameters))n.has(J(`parameter`,t))&&(e[t]=r);else for(let t of n){let{name:n}=Y(t),r=s.components.parameters[n];r&&(e[n]=r)}s.components.parameters=e}if(s.components.requestBodies){let e={};if(r)for(let[t,n]of Object.entries(s.components.requestBodies))i.has(J(`body`,t))&&(e[t]=n);else for(let t of i){let{name:n}=Y(t),r=s.components.requestBodies[n];r&&(e[n]=r)}s.components.requestBodies=e}if(s.components.responses){let e={};if(r)for(let[t,n]of Object.entries(s.components.responses))a.has(J(`response`,t))&&(e[t]=n);else for(let t of a){let{name:n}=Y(t),r=s.components.responses[n];r&&(e[n]=r)}s.components.responses=e}if(s.components.schemas){let e={};if(r)for(let[t,n]of Object.entries(s.components.schemas))o.has(J(`schema`,t))&&(e[t]=n);else for(let t of o){let{name:n}=Y(t),r=s.components.schemas[n];r&&(e[n]=r)}s.components.schemas=e}}if(s.paths)for(let e of Object.entries(s.paths)){let n=e[0],r=e[1];for(let e of al){if(!r[e])continue;let i=J(`operation`,T({method:e,path:n}));t.has(i)||delete r[e]}Object.keys(r).length||delete s.paths[n]}c.timeEnd()},rd=({content:e})=>{let{mediaType:t,schema:n}=e;return n&&`$ref`in n?{allOf:[{...n}]}:n?n.type===`string`&&!n.format&&yu({mediaType:t})?{...n,format:`binary`}:n:yu({mediaType:t})?{format:`binary`,type:`string`}:void 0},id=({content:e})=>{let t=[];for(let n in e)t.push({mediaType:n,schema:e[n].schema,type:bu({mediaType:n})});return t},ad=({schema:e})=>{if(e.type)return e.type;if(e.properties)return`object`},od=({irSchema:e,schema:t})=>{t.deprecated!==void 0&&(e.deprecated=t.deprecated),t.example&&(e.example=t.example),t.description&&(e.description=t.description),t.title&&(e.title=t.title)},sd=({irSchema:e,schema:t})=>{t.default!==void 0&&(e.default=t.default),t.exclusiveMaximum?t.maximum!==void 0&&(e.exclusiveMaximum=t.maximum):t.maximum!==void 0&&(e.maximum=t.maximum),t.exclusiveMinimum?t.minimum!==void 0&&(e.exclusiveMinimum=t.minimum):t.minimum!==void 0&&(e.minimum=t.minimum),t.format&&(e.format=t.format),t.maxItems!==void 0&&(e.maxItems=t.maxItems),t.maxLength!==void 0&&(e.maxLength=t.maxLength),t.minItems!==void 0&&(e.minItems=t.minItems),t.minLength!==void 0&&(e.minLength=t.minLength),t.pattern&&(e.pattern=t.pattern),t.readOnly?e.accessScope=`read`:t.writeOnly&&(e.accessScope=`write`)},cd=({context:e,irSchema:t={},schema:n,state:r})=>{n.maxItems&&n.maxItems===n.minItems?t.type=`tuple`:t.type=`array`;let i=[];if(n.items){let a=Z({context:e,schema:n.items,state:r});if(!i.length&&n.maxItems&&n.maxItems===n.minItems)i=Array(n.maxItems).fill(a);else if(`$ref`in n.items)i.push(a);else{let e=n.items.allOf||n.items.anyOf||n.items.oneOf;e&&e.length>1&&!n.items.nullable?t={...t,...a}:i.push(a)}}return t=w({items:i,schema:t}),t},ld=({irSchema:e={}})=>(e.type=`boolean`,e),ud=({irSchema:e={},schema:t})=>(e.type=t.type,e),dd=({context:e,irSchema:t={},schema:n,state:r})=>{t.type=`object`;let i={};for(let t in n.properties){let a=n.properties[t];typeof a==`boolean`||(i[t]=Z({context:e,schema:a,state:r}))}return Object.keys(i).length&&(t.properties=i),n.additionalProperties===void 0?t.properties||(t.additionalProperties={type:`unknown`}):typeof n.additionalProperties==`boolean`?r.inAllOf&&n.additionalProperties===!1&&(!n.properties||!Object.keys(n.properties).length)||(t.additionalProperties={type:n.additionalProperties?`unknown`:`never`}):t.additionalProperties=Z({context:e,schema:n.additionalProperties,state:r}),n.required&&(t.required=n.required),t},fd=({irSchema:e={}})=>(e.type=`string`,e),pd=({schema:e})=>{let t={};return od({irSchema:t,schema:e}),t},md=({context:e,schema:t,state:n})=>{let r=pd({schema:t}),i=[],a=ad({schema:t}),o=t.allOf;for(let r of o){let a=n.inAllOf;`$ref`in r||(n.inAllOf=!0);let o=Z({context:e,schema:r,state:n});if(n.inAllOf=a,n.inAllOf===void 0&&delete n.inAllOf,t.required&&(o.required?o.required=[...o.required,...t.required]:o.required=t.required),i.push(o),`$ref`in r){let t=e.resolveRef(r.$ref);if(t.discriminator&&n.$ref){let e=wu(n.$ref,t.discriminator.mapping,t.oneOf?()=>t.oneOf.some(e=>`$ref`in e&&e.$ref===n.$ref):void 0);if(e.length>0){let n=e.map(e=>({const:e,type:`string`})),r={properties:{[t.discriminator.propertyName]:n.length>1?{items:n,logicalOperator:`or`}:n[0]},type:`object`};t.required?.includes(t.discriminator.propertyName)&&(r.required=[t.discriminator.propertyName]),i.push(r)}}}}if(a===`object`){let r=xd({context:e,schema:{...t,type:`object`},state:n});if(r.properties){for(let t of r.required??[])if(!r.properties[t])for(let i of o){let a=`$ref`in i?e.resolveRef(i.$ref):i;if(ad({schema:a})===`object`){let i=xd({context:e,schema:{...a,type:`object`},state:n});if(i.properties?.[t]){r.properties[t]=i.properties[t];break}}}i.push(r)}}if(r=w({items:i,logicalOperator:`and`,mutateSchemaOneItem:!0,schema:r}),t.nullable){let e=[{type:`null`}];i.length&&e.unshift(r),r={items:e,logicalOperator:`or`},e[0].deprecated&&(r.deprecated=e[0].deprecated),e[0].description&&(r.description=e[0].description)}return r},hd=({context:e,schema:t,state:n})=>{let r=pd({schema:t}),i=[],a=ad({schema:t}),o=t.anyOf;for(let r of o){let a=Z({context:e,schema:r,state:n});if(t.discriminator&&a.$ref!=null){let e=wu(a.$ref,t.discriminator.mapping).map(e=>({const:e,type:`string`}));a={items:[{properties:{[t.discriminator.propertyName]:e.length>1?{items:e,logicalOperator:`or`}:e[0]},type:`object`},a],logicalOperator:`and`}}i.push(a)}if(t.nullable&&i.push({type:`null`}),r=w({items:i,mutateSchemaOneItem:!0,schema:r}),a===`object`){let i=xd({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},gd=({context:e,schema:t,state:n})=>{let r=pd({schema:t});r.type=`enum`;let i=[];for(let[r,a]of t.enum.entries()){let o=typeof a,s;if(o===`string`||o===`number`||o===`boolean`?s=o:o===`object`&&Array.isArray(a)?s=`array`:a===null?t.nullable&&(s=`null`):console.warn(`🚨`,`unhandled "${o}" typeof value "${a}" for enum`,t.enum),!s)continue;let c=xd({context:e,schema:{description:t[`x-enum-descriptions`]?.[r],title:t[`x-enum-varnames`]?.[r]??t[`x-enumNames`]?.[r],type:s===`null`?`string`:s},state:n});c.const=a,s===`null`&&(c.type=s),c.type===`array`&&(c.type=`tuple`),i.push(c)}return r=w({items:i,schema:r}),r},_d=({context:e,schema:t,state:n})=>{let r=pd({schema:t}),i=[],a=ad({schema:t}),o=t.oneOf;for(let r of o){let a=Z({context:e,schema:r,state:n});if(t.discriminator&&a.$ref!=null){let e=wu(a.$ref,t.discriminator.mapping).map(e=>({const:e,type:`string`}));a={items:[{properties:{[t.discriminator.propertyName]:e.length>1?{items:e,logicalOperator:`or`}:e[0]},required:[t.discriminator.propertyName],type:`object`},a],logicalOperator:`and`}}a.logicalOperator===`or`&&a.type!==`array`&&a.items?i=i.concat(a.items):i.push(a)}if(t.nullable&&i.push({type:`null`}),r=w({items:i,mutateSchemaOneItem:!0,schema:r}),a===`object`){let i=xd({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},vd=({context:e,schema:t,state:n})=>{if(!t.$ref.startsWith(`#/components/`)&&!n.circularReferenceTracker.has(t.$ref)){let r=e.resolveRef(t.$ref),i=n.$ref;n.$ref=t.$ref;let a=Z({context:e,schema:r,state:n});return n.$ref=i,a}let r={};if(r.$ref=decodeURI(t.$ref),!n.circularReferenceTracker.has(t.$ref)){let r=e.resolveRef(t.$ref),i=n.$ref;n.$ref=t.$ref,Z({context:e,schema:r,state:n}),n.$ref=i}return r},yd=({context:e,irSchema:t,schema:n,state:r})=>{t||=pd({schema:n});let i={};return sd({irSchema:i,schema:n}),i.default===null&&delete i.default,t=w({items:[xd({context:e,irSchema:i,schema:n,state:r}),{type:`null`}],schema:t}),t},bd=({context:e,schema:t,state:n})=>{let r=pd({schema:t});sd({irSchema:r,schema:t});let i=ad({schema:t});return i?t.nullable?yd({context:e,irSchema:r,schema:{...t,type:i},state:n}):xd({context:e,irSchema:r,schema:{...t,type:i},state:n}):r},xd=({context:e,irSchema:t,schema:n,state:r})=>{switch(t||(t=pd({schema:n}),sd({irSchema:t,schema:n})),n.type){case`array`:return cd({context:e,irSchema:t,schema:n,state:r});case`boolean`:return ld({context:e,irSchema:t,schema:n,state:r});case`integer`:case`number`:return ud({context:e,irSchema:t,schema:n,state:r});case`object`:return dd({context:e,irSchema:t,schema:n,state:r});case`string`:return fd({context:e,irSchema:t,schema:n,state:r});default:return Sd({context:e,irSchema:t,schema:n})}},Sd=({irSchema:e,schema:t})=>(e||=pd({schema:t}),e.type=`unknown`,sd({irSchema:e,schema:t}),e),Z=({context:e,schema:t,state:n})=>(n||={circularReferenceTracker:new Set},n.$ref&&n.circularReferenceTracker.add(n.$ref),`$ref`in t?vd({context:e,schema:t,state:n}):t.enum?gd({context:e,schema:t,state:n}):t.allOf?md({context:e,schema:t,state:n}):t.anyOf?hd({context:e,schema:t,state:n}):t.oneOf?_d({context:e,schema:t,state:n}):t.type||t.properties?bd({context:e,schema:t,state:n}):Sd({context:e,schema:t})),Cd=({$ref:e,context:t,schema:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.schemas||(t.ir.components.schemas={}),t.ir.components.schemas[I(e)]=Z({context:t,schema:n,state:{$ref:e,circularReferenceTracker:new Set}})},wd=e=>e===`boolean`||e===`integer`||e===`number`||e===`string`,Td=({context:e,name:t,schema:n})=>{if(Cu(e.config.parser.pagination).test(t))return!0;if(`$ref`in n){let r=e.resolveRef(n.$ref);if(`content`in r||`in`in r){let n;if(`in`in r&&(n=r.schema),!n){let e=id({content:r.content}),t=e.find(e=>e.type===`json`)||e[0];t?.schema&&(n=t.schema)}return n?Td({context:e,name:t,schema:n}):!1}return Td({context:e,name:t,schema:r})}for(let t in n.properties)if(Cu(e.config.parser.pagination).test(t)){let e=n.properties[t];if(typeof e!=`boolean`&&!(`$ref`in e)&&wd(ad({schema:e})))return t}for(let r of n.allOf??[]){let n=Td({context:e,name:t,schema:r});if(n)return n}return!1},Ed=({irOperation:e,operation:t})=>{t.deprecated!==void 0&&(e.deprecated=t.deprecated),t.description&&(e.description=t.description),t.summary&&(e.summary=t.summary),t.tags?.length&&(e.tags=t.tags)},Dd=({context:e,method:t,operation:n,path:r,state:i})=>{let a={id:ol({context:e,id:n.operationId,method:t,path:r,state:i}),method:t,path:r};return n.operationId&&(a.operationId=n.operationId),Ed({irOperation:a,operation:n}),a},Od=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{let o=Dd({context:e,method:t,operation:n,path:r,state:a});if(n.parameters&&(o.parameters=n.parameters),n.requestBody){let t=`$ref`in n.requestBody?e.resolveRef(n.requestBody.$ref):n.requestBody,r=id({content:t.content}),i=r.find(e=>e.type===`json`)||r[0];if(i){let r=Td({context:e,name:``,schema:i.schema&&`$ref`in i.schema?{allOf:[{...i.schema}],description:t.description}:{description:t.description,...i.schema}});o.body={mediaType:i.mediaType,schema:Z({context:e,schema:`$ref`in n.requestBody?{allOf:[{...n.requestBody}],description:t.description}:i.schema&&`$ref`in i.schema?{allOf:[{...i.schema}],description:t.description}:{description:t.description,...i.schema},state:void 0})},r&&(o.body.pagination=r),t.required&&(o.body.required=t.required),i.type&&(o.body.type=i.type)}}for(let t in n.responses){o.responses||={};let r=n.responses[t],i=`$ref`in r?e.resolveRef(r.$ref):r,a=id({content:i.content}),s=a.find(e=>e.type===`json`)||a[0];s?o.responses[t]={mediaType:s.mediaType,schema:Z({context:e,schema:{description:i.description,...rd({content:s})},state:void 0})}:o.responses[t]={schema:{description:i.description,type:t===`204`?`void`:`unknown`}}}if(n.security){let e=new Map;for(let t of n.security)for(let n in t){let t=i.get(n);t&&e.set(n,t)}e.size&&(o.security=Array.from(e.values()))}return o},kd=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{e.ir.paths||(e.ir.paths={}),e.ir.paths[r]||(e.ir.paths[r]={}),n.servers&&(e.ir.servers=[...e.ir.servers??[],...n.servers]),e.ir.paths[r][t]=Od({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})},Ad=e=>{switch(e){case`query`:return!1;default:return}},jd=e=>{switch(e){case`deepObject`:case`form`:return!0;default:return!1}},Md=e=>{switch(e){case`header`:case`path`:return`simple`;case`cookie`:case`query`:return`form`}},Nd=({context:e,parameters:t})=>{if(!t||!Object.keys(t).length)return;let n={};for(let r of t){let t=`$ref`in r?e.dereference(r):r;n[t.in]||(n[t.in]={}),n[t.in][t.name.toLocaleLowerCase()]=Pd({$ref:`#/todo/real/path/to/parameter/${t.name}`,context:e,parameter:t})}return n},Pd=({$ref:e,context:t,parameter:n})=>{let r=n.schema;if(!r){let e=id({content:n.content}),t=e.find(e=>e.type===`json`)||e[0];t&&(r=t.schema)}let i=r&&`$ref`in r?{allOf:[{...r}],deprecated:n.deprecated,description:n.description}:{deprecated:n.deprecated,description:n.description,...r},a=Td({context:t,name:n.name,schema:i}),o=n.style||Md(n.in),s=n.explode===void 0?jd(o):n.explode,c={allowReserved:n.allowReserved===void 0?Ad(n.in):n.allowReserved,explode:s,location:n.in,name:n.name,schema:Z({context:t,schema:i,state:{$ref:e,circularReferenceTracker:new Set}}),style:o};return n.deprecated&&(c.deprecated=n.deprecated),n.description&&(c.description=n.description),a&&(c.pagination=a),n.required&&(c.required=n.required),c},Fd=({$ref:e,context:t,parameter:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.parameters||(t.ir.components.parameters={}),t.ir.components.parameters[I(e)]=Pd({$ref:e,context:t,parameter:n})},Id=({$ref:e,context:t,requestBody:n})=>{let r=id({content:n.content}),i=r.find(e=>e.type===`json`)||r[0],a=i?i.schema:void 0,o={schema:Z({context:t,schema:{description:n.description,...a},state:{$ref:e,circularReferenceTracker:new Set}})};return n.description&&(o.description=n.description),n.required&&(o.required=n.required),o},Ld=({$ref:e,context:t,requestBody:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.requestBodies||(t.ir.components.requestBodies={}),t.ir.components.requestBodies[I(e)]=Id({$ref:e,context:t,requestBody:n})},Rd=({context:e})=>{if(e.spec.servers){e.ir.servers=e.spec.servers;return}for(let t of e.config.input)if(typeof t.path==`string`){let n=Ar(t.path);e.ir.servers=[{url:`${n.protocol?`${n.protocol}://`:``}${n.host}${n.port?`:${n.port}`:``}`}]}e.ir.servers||(e.ir.servers=[{url:`/`}])},zd=(e,t)=>{let n=t.timeEvent(`validate`),r=[],i=new Map;if(e.paths)for(let t of Object.entries(e.paths)){let e=t[0],n=t[1];for(let t of al){let a=n[t];if(!a)continue;let o=T({method:t,path:e});a.operationId&&(i.has(a.operationId)?r.push({code:`duplicate_key`,context:{key:`operationId`,value:a.operationId},message:"Duplicate `operationId` found. Each `operationId` must be unique.",path:[`paths`,e,t,`operationId`],severity:`error`}):i.set(a.operationId,o))}}if(e.servers){(typeof e.servers!=`object`||!Array.isArray(e.servers))&&r.push({code:`invalid_type`,message:"`servers` must be an array.",path:[],severity:`error`});for(let t=0;t<e.servers.length;t++){let n=e.servers[t];!n||typeof n!=`object`?r.push({code:`invalid_type`,context:{actual:typeof n,expected:`object`},message:"Each entry in `servers` must be an object.",path:[`servers`,t],severity:`error`}):n.url||r.push({code:`missing_required_field`,context:{field:`url`},message:"Missing required field `url` in server object.",path:[`servers`,t],severity:`error`})}}return n.timeEnd(),{issues:r,valid:!r.some(e=>e.severity===`error`)}},Bd=e=>{if(e.config.parser.validate_EXPERIMENTAL&&du({context:e,result:zd(e.spec,e.logger)}),pl(e.config.parser.filters)){let t=fl(e.config.parser.filters,e.spec,e.logger),{graph:n}=Xl(e.spec,e.logger),{resourceMetadata:r}=El(n,e.logger);nd({...Tl({filters:t,logger:e.logger,resourceMetadata:r}),logger:e.logger,preserveOrder:t.preserveOrder,spec:e.spec})}ou({context:e});let t={ids:new Map},n=new Map;if(e.spec.components){for(let t in e.spec.components.securitySchemes){let r=e.spec.components.securitySchemes[t],i=`$ref`in r?e.resolveRef(r.$ref):r;n.set(t,i)}for(let t in e.spec.components.parameters){let n=`#/components/parameters/${t}`,r=e.spec.components.parameters[t];Fd({$ref:n,context:e,parameter:`$ref`in r?e.resolveRef(r.$ref):r})}for(let t in e.spec.components.requestBodies){let n=`#/components/requestBodies/${t}`,r=e.spec.components.requestBodies[t];Ld({$ref:n,context:e,requestBody:`$ref`in r?e.resolveRef(r.$ref):r})}for(let t in e.spec.components.schemas){let n=`#/components/schemas/${t}`,r=e.spec.components.schemas[t];Cd({$ref:n,context:e,schema:r})}}for(let r in Rd({context:e}),e.spec.paths){let i=e.spec.paths[r],a=i.$ref?{...e.resolveRef(i.$ref),...i}:i,o={context:e,operation:{description:a.description,parameters:Nd({context:e,parameters:a.parameters}),security:e.spec.security,servers:a.servers,summary:a.summary},path:r,securitySchemesMap:n,state:t};a.delete&&kd({...o,method:`delete`,operation:{...o.operation,...a.delete,parameters:X({source:Nd({context:e,parameters:a.delete.parameters}),target:o.operation.parameters})}}),a.get&&kd({...o,method:`get`,operation:{...o.operation,...a.get,parameters:X({source:Nd({context:e,parameters:a.get.parameters}),target:o.operation.parameters})}}),a.head&&kd({...o,method:`head`,operation:{...o.operation,...a.head,parameters:X({source:Nd({context:e,parameters:a.head.parameters}),target:o.operation.parameters})}}),a.options&&kd({...o,method:`options`,operation:{...o.operation,...a.options,parameters:X({source:Nd({context:e,parameters:a.options.parameters}),target:o.operation.parameters})}}),a.patch&&kd({...o,method:`patch`,operation:{...o.operation,...a.patch,parameters:X({source:Nd({context:e,parameters:a.patch.parameters}),target:o.operation.parameters})}}),a.post&&kd({...o,method:`post`,operation:{...o.operation,...a.post,parameters:X({source:Nd({context:e,parameters:a.post.parameters}),target:o.operation.parameters})}}),a.put&&kd({...o,method:`put`,operation:{...o.operation,...a.put,parameters:X({source:Nd({context:e,parameters:a.put.parameters}),target:o.operation.parameters})}}),a.trace&&kd({...o,method:`trace`,operation:{...o.operation,...a.trace,parameters:X({source:Nd({context:e,parameters:a.trace.parameters}),target:o.operation.parameters})}})}},Vd=({logger:e,operations:t,parameters:n,preserveOrder:r,requestBodies:i,responses:a,schemas:o,spec:s})=>{let c=e.timeEvent(`filter-spec`);if(s.components){if(s.components.parameters){let e={};if(r)for(let[t,r]of Object.entries(s.components.parameters))n.has(J(`parameter`,t))&&(e[t]=r);else for(let t of n){let{name:n}=Y(t),r=s.components.parameters[n];r&&(e[n]=r)}s.components.parameters=e}if(s.components.requestBodies){let e={};if(r)for(let[t,n]of Object.entries(s.components.requestBodies))i.has(J(`body`,t))&&(e[t]=n);else for(let t of i){let{name:n}=Y(t),r=s.components.requestBodies[n];r&&(e[n]=r)}s.components.requestBodies=e}if(s.components.responses){let e={};if(r)for(let[t,n]of Object.entries(s.components.responses))a.has(J(`response`,t))&&(e[t]=n);else for(let t of a){let{name:n}=Y(t),r=s.components.responses[n];r&&(e[n]=r)}s.components.responses=e}if(s.components.schemas){let e={};if(r)for(let[t,n]of Object.entries(s.components.schemas))o.has(J(`schema`,t))&&(e[t]=n);else for(let t of o){let{name:n}=Y(t),r=s.components.schemas[n];r&&(e[n]=r)}s.components.schemas=e}}if(s.paths)for(let e of Object.entries(s.paths)){let n=e[0],r=e[1];for(let e of al){if(!r[e])continue;let i=J(`operation`,T({method:e,path:n}));t.has(i)||delete r[e]}Object.keys(r).length||delete s.paths[n]}c.timeEnd()},Hd=({content:e})=>{let{mediaType:t,schema:n}=e;return n?n.type===`string`&&!n.format&&yu({mediaType:t})?{...n,format:`binary`}:n:yu({mediaType:t})?{format:`binary`,type:`string`}:void 0},Ud=({content:e})=>{let t=[];for(let n in e)t.push({mediaType:n,schema:e[n].schema,type:bu({mediaType:n})});return t},Wd=({schema:e})=>typeof e.type==`string`?[e.type]:e.type?e.type:e.properties?[`object`]:[],Gd=({irSchema:e,schema:t})=>{t.deprecated!==void 0&&(e.deprecated=t.deprecated),t.example&&(e.example=t.example),t.description&&(e.description=t.description),t.title&&(e.title=t.title)},Kd=({irSchema:e,schema:t})=>{if(t.const!==void 0&&(e.const=t.const,!t.type))if(t.const===null)e.type=`null`;else switch(typeof t.const){case`bigint`:case`number`:e.type=`number`;break;case`boolean`:e.type=`boolean`;break;case`string`:e.type=`string`;break}t.default!==void 0&&(e.default=t.default),t.exclusiveMaximum!==void 0&&(e.exclusiveMaximum=t.exclusiveMaximum),t.exclusiveMinimum!==void 0&&(e.exclusiveMinimum=t.exclusiveMinimum),t.format&&(e.format=t.format),t.maximum!==void 0&&(e.maximum=t.maximum),t.maxItems!==void 0&&(e.maxItems=t.maxItems),t.maxLength!==void 0&&(e.maxLength=t.maxLength),t.minimum!==void 0&&(e.minimum=t.minimum),t.minItems!==void 0&&(e.minItems=t.minItems),t.minLength!==void 0&&(e.minLength=t.minLength),t.pattern&&(e.pattern=t.pattern),t.readOnly?e.accessScope=`read`:t.writeOnly&&(e.accessScope=`write`)},qd=({context:e,irSchema:t={},schema:n,state:r})=>{n.prefixItems&&n.prefixItems.length||n.maxItems&&n.maxItems===n.minItems||n.const!==void 0?t.type=`tuple`:t.type=`array`;let i=[];for(let t of n.prefixItems??[]){let n=Q({context:e,schema:t,state:r});i.push(n)}if(n.items){let a=Q({context:e,schema:n.items,state:r});if(!i.length&&n.maxItems&&n.maxItems===n.minItems)i=Array(n.maxItems).fill(a);else{let e=n.items.allOf||n.items.anyOf||n.items.oneOf;e&&e.length>1&&!Wd({schema:n.items}).includes(`null`)?t={...t,...a}:i.push(a)}}return t=w({items:i,schema:t}),t},Jd=({irSchema:e={}})=>(e.type=`boolean`,e),Yd=({irSchema:e={}})=>(e.type=`null`,e),Xd=({irSchema:e={},schema:t})=>(e.type=t.type,e),Zd=({context:e,irSchema:t={},schema:n,state:r})=>{t.type=`object`;let i={};for(let t in n.properties){let a=n.properties[t];typeof a==`boolean`||(i[t]=Q({context:e,schema:a,state:r}))}if(Object.keys(i).length&&(t.properties=i),n.additionalProperties===void 0?t.properties||(t.additionalProperties={type:`unknown`}):typeof n.additionalProperties==`boolean`?r.inAllOf&&n.additionalProperties===!1&&(!n.properties||!Object.keys(n.properties).length)&&(!n.patternProperties||!Object.keys(n.patternProperties).length)||(t.additionalProperties={type:n.additionalProperties?`unknown`:`never`}):t.additionalProperties=Q({context:e,schema:n.additionalProperties,state:r}),n.patternProperties){let i={};for(let t in n.patternProperties){let a=n.patternProperties[t];i[t]=Q({context:e,schema:a,state:r})}Object.keys(i).length&&(t.patternProperties=i)}return n.propertyNames&&(t.propertyNames=Q({context:e,schema:n.propertyNames,state:r})),n.required&&(t.required=n.required),t},Qd=({irSchema:e={}})=>(e.type=`string`,e),$d=({schema:e})=>{let t={};return Gd({irSchema:t,schema:e}),t},ef=({context:e,schema:t,state:n})=>{let r=$d({schema:t}),i=[],a=Wd({schema:t}),o=t.allOf;for(let r of o){let a=n.inAllOf;`$ref`in r||(n.inAllOf=!0);let o=Q({context:e,schema:r,state:n});if(n.inAllOf=a,n.inAllOf===void 0&&delete n.inAllOf,t.required&&(o.required?o.required=[...o.required,...t.required]:o.required=t.required),i.push(o),r.$ref){let t=e.resolveRef(r.$ref);if(t.discriminator&&n.$ref){let e=wu(n.$ref,t.discriminator.mapping,t.oneOf?()=>t.oneOf.some(e=>`$ref`in e&&e.$ref===n.$ref):void 0);if(e.length>0){let n=e.map(e=>({const:e,type:`string`})),r={properties:{[t.discriminator.propertyName]:n.length>1?{items:n,logicalOperator:`or`}:n[0]},type:`object`};t.required?.includes(t.discriminator.propertyName)&&(r.required=[t.discriminator.propertyName]),i.push(r)}}}}if(a.includes(`object`)){let r=of({context:e,schema:{...t,type:`object`},state:n});if(r.properties){for(let t of r.required??[])if(!r.properties[t])for(let i of o){let a=i.$ref?e.resolveRef(i.$ref):i;if(Wd({schema:a}).includes(`object`)){let i=of({context:e,schema:{...a,type:`object`},state:n});if(i.properties?.[t]){r.properties[t]=i.properties[t];break}}}i.push(r)}}if(r=w({items:i,logicalOperator:`and`,mutateSchemaOneItem:!0,schema:r}),a.includes(`null`)){let e=[{type:`null`}];i.length&&e.unshift(r),r={items:e,logicalOperator:`or`}}return r},tf=({context:e,schema:t,state:n})=>{let r=$d({schema:t}),i=[],a=Wd({schema:t}),o=t.anyOf;for(let r of o){let a=Q({context:e,schema:r,state:n});if(t.discriminator&&a.$ref!=null){let e=wu(a.$ref,t.discriminator.mapping).map(e=>({const:e,type:`string`}));a={items:[{properties:{[t.discriminator.propertyName]:e.length>1?{items:e,logicalOperator:`or`}:e[0]},type:`object`},a],logicalOperator:`and`}}i.push(a)}if(a.includes(`null`)&&i.push({type:`null`}),r=w({items:i,mutateSchemaOneItem:!0,schema:r}),a.includes(`object`)){let i=of({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},nf=({context:e,schema:t,state:n})=>{let r=$d({schema:t});r.type=`enum`;let i=[],a=Wd({schema:t});for(let[r,o]of t.enum.entries()){let s=typeof o,c;if(s===`string`||s===`number`||s===`boolean`?c=s:s===`object`&&Array.isArray(o)?c=`array`:o===null?a.includes(`null`)&&(c=`null`):console.warn(`🚨`,`unhandled "${s}" typeof value "${o}" for enum`,t.enum),!c)continue;let l=of({context:e,schema:{const:o,description:t[`x-enum-descriptions`]?.[r],title:t[`x-enum-varnames`]?.[r]??t[`x-enumNames`]?.[r],type:c},state:n});i.push(l)}return r=w({items:i,schema:r}),r},rf=({context:e,schema:t,state:n})=>{let r=$d({schema:t}),i=[],a=Wd({schema:t}),o=t.oneOf;for(let r of o){let a=Q({context:e,schema:r,state:n});if(t.discriminator&&a.$ref!=null){let e=wu(a.$ref,t.discriminator.mapping).map(e=>({const:e,type:`string`}));a={items:[{properties:{[t.discriminator.propertyName]:e.length>1?{items:e,logicalOperator:`or`}:e[0]},required:[t.discriminator.propertyName],type:`object`},a],logicalOperator:`and`}}a.logicalOperator===`or`&&a.type!==`array`&&a.items?i=i.concat(a.items):i.push(a)}if(a.includes(`null`)&&i.push({type:`null`}),r=w({items:i,mutateSchemaOneItem:!0,schema:r}),a.includes(`object`)){let i=of({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},af=({context:e,schema:t,state:n})=>{if(!t.$ref.startsWith(`#/components/`)&&!n.circularReferenceTracker.has(t.$ref)){let r=e.resolveRef(t.$ref),i=n.$ref;n.$ref=t.$ref;let a=Q({context:e,schema:r,state:n});return n.$ref=i,a}let r=$d({schema:t}),i={};if(i.$ref=decodeURI(t.$ref),!n.circularReferenceTracker.has(t.$ref)){let r=e.resolveRef(t.$ref),i=n.$ref;n.$ref=t.$ref,Q({context:e,schema:r,state:n}),n.$ref=i}let a=[];return a.push(i),t.type&&typeof t.type!=`string`&&t.type.includes(`null`)&&a.push({type:`null`}),r=w({items:a,mutateSchemaOneItem:!0,schema:r}),r},of=({context:e,irSchema:t,schema:n,state:r})=>{switch(t||(t=$d({schema:n}),Kd({irSchema:t,schema:n})),n.type){case`array`:return qd({context:e,irSchema:t,schema:n,state:r});case`boolean`:return Jd({context:e,irSchema:t,schema:n});case`integer`:case`number`:return Xd({context:e,irSchema:t,schema:n});case`null`:return Yd({context:e,irSchema:t,schema:n});case`object`:return Zd({context:e,irSchema:t,schema:n,state:r});case`string`:return Qd({context:e,irSchema:t,schema:n});default:return lf({context:e,irSchema:t,schema:n})}},sf=({context:e,irSchema:t,schema:n,state:r})=>{t||=$d({schema:n});let i={};Kd({irSchema:i,schema:n}),n.type.includes(`null`)&&i.default===null&&delete i.default;let a=[];for(let t of n.type)if(t===`null`)a.push({type:`null`});else{let o=of({context:e,irSchema:{...i},schema:{...n,type:t},state:r});a.push(o)}return t=w({items:a,schema:t}),t},cf=({context:e,schema:t,state:n})=>{let r=$d({schema:t});Kd({irSchema:r,schema:t});let i=Wd({schema:t});return i.length===1?of({context:e,irSchema:r,schema:{...t,type:i[0]},state:n}):sf({context:e,irSchema:r,schema:{...t,type:i},state:n})},lf=({irSchema:e,schema:t})=>(e||=$d({schema:t}),e.type=`unknown`,Kd({irSchema:e,schema:t}),e),Q=({context:e,schema:t,state:n})=>(n||={circularReferenceTracker:new Set},n.$ref&&n.circularReferenceTracker.add(n.$ref),t.$ref?af({context:e,schema:t,state:n}):t.enum?nf({context:e,schema:t,state:n}):t.allOf?ef({context:e,schema:t,state:n}):t.anyOf?tf({context:e,schema:t,state:n}):t.oneOf?rf({context:e,schema:t,state:n}):t.type||t.properties?cf({context:e,schema:t,state:n}):lf({context:e,schema:t})),uf=({$ref:e,context:t,schema:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.schemas||(t.ir.components.schemas={}),t.ir.components.schemas[I(e)]=Q({context:t,schema:n,state:{$ref:e,circularReferenceTracker:new Set}})},df=e=>e.includes(`boolean`)||e.includes(`integer`)||e.includes(`number`)||e.includes(`string`),ff=({context:e,name:t,schema:n})=>{if(Cu(e.config.parser.pagination).test(t))return!0;if(n.$ref){let r=e.resolveRef(n.$ref);if(`content`in r||`in`in r){let n;if(`in`in r&&(n=r.schema),!n){let e=Ud({content:r.content}),t=e.find(e=>e.type===`json`)||e[0];t?.schema&&(n=t.schema)}return n?ff({context:e,name:t,schema:n}):!1}return ff({context:e,name:t,schema:r})}for(let t in n.properties)if(Cu(e.config.parser.pagination).test(t)){let e=n.properties[t];if(typeof e!=`boolean`){let n=Wd({schema:e});if(!n.length){let n=(e.anyOf??e.oneOf??[]).filter(e=>e.type!==`null`);if(n.length===1&&df(Wd({schema:n[0]})))return t}if(df(n))return t}}for(let r of n.allOf??[]){let n=ff({context:e,name:t,schema:r});if(n)return n}return!1},pf=({irOperation:e,operation:t})=>{t.deprecated!==void 0&&(e.deprecated=t.deprecated),t.description&&(e.description=t.description),t.summary&&(e.summary=t.summary),t.tags?.length&&(e.tags=t.tags)},mf=({context:e,method:t,operation:n,path:r,state:i})=>{let a={id:ol({context:e,id:n.operationId,method:t,path:r,state:i}),method:t,path:r};return n.operationId&&(a.operationId=n.operationId),pf({irOperation:a,operation:n}),a},hf=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{let o=mf({context:e,method:t,operation:n,path:r,state:a});if(n.parameters&&(o.parameters=n.parameters),n.requestBody){let t=`$ref`in n.requestBody?e.resolveRef(n.requestBody.$ref):n.requestBody,r=Ud({content:t.content}),i=r.find(e=>e.type===`json`)||r[0];if(i){let r=ff({context:e,name:``,schema:{description:t.description,...i.schema}});o.body={mediaType:i.mediaType,schema:Q({context:e,schema:{description:t.description,...`$ref`in n.requestBody?n.requestBody:i.schema},state:void 0})},r&&(o.body.pagination=r),t.required&&(o.body.required=t.required),i.type&&(o.body.type=i.type)}}for(let t in n.responses){o.responses||={};let r=n.responses[t],i=`$ref`in r?e.resolveRef(r.$ref):r,a=Ud({content:i.content}),s=a.find(e=>e.type===`json`)||a[0];s?o.responses[t]={mediaType:s.mediaType,schema:Q({context:e,schema:{description:i.description,...Hd({content:s})},state:void 0})}:o.responses[t]={schema:{description:i.description,type:t===`204`?`void`:`unknown`}}}if(n.security){let e=new Map;for(let t of n.security)for(let n in t){let t=i.get(n);t&&e.set(n,t)}e.size&&(o.security=Array.from(e.values()))}return o},gf=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>(n.servers&&(e.ir.servers=[...e.ir.servers??[],...n.servers]),{parsed:hf({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})}),_f=({context:e,method:t,path:n,...r})=>{e.ir.paths||(e.ir.paths={}),e.ir.paths[n]||(e.ir.paths[n]={});let{parsed:i}=gf({context:e,method:t,path:n,...r});e.ir.paths[n][t]=i},vf=({context:e,key:t,method:n,...r})=>{e.ir.webhooks||(e.ir.webhooks={}),e.ir.webhooks[t]||(e.ir.webhooks[t]={});let{parsed:i}=gf({context:e,method:n,path:t,...r});e.ir.webhooks[t][n]=i},yf=e=>{switch(e){case`query`:return!1;default:return}},bf=e=>{switch(e){case`deepObject`:case`form`:return!0;default:return!1}},xf=e=>{switch(e){case`header`:case`path`:return`simple`;case`cookie`:case`query`:return`form`}},$=({context:e,parameters:t})=>{if(!t||!Object.keys(t).length)return;let n={};for(let r of t){let t=`$ref`in r?e.dereference(r):r;n[t.in]||(n[t.in]={}),n[t.in][t.name.toLocaleLowerCase()]=Sf({$ref:`#/todo/real/path/to/parameter/${t.name}`,context:e,parameter:t})}return n},Sf=({$ref:e,context:t,parameter:n})=>{let r=n.schema;if(!r){let e=Ud({content:n.content}),t=e.find(e=>e.type===`json`)||e[0];t&&(r=t.schema)}let i={deprecated:n.deprecated,description:n.description,...r},a=ff({context:t,name:n.name,schema:i}),o=n.style||xf(n.in),s=n.explode===void 0?bf(o):n.explode,c={allowReserved:n.allowReserved===void 0?yf(n.in):n.allowReserved,explode:s,location:n.in,name:n.name,schema:Q({context:t,schema:i,state:{$ref:e,circularReferenceTracker:new Set}}),style:o};return n.deprecated&&(c.deprecated=n.deprecated),n.description&&(c.description=n.description),a&&(c.pagination=a),n.required&&(c.required=n.required),c},Cf=({$ref:e,context:t,parameter:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.parameters||(t.ir.components.parameters={}),t.ir.components.parameters[I(e)]=Sf({$ref:e,context:t,parameter:n})},wf=({$ref:e,context:t,requestBody:n})=>{let r=Ud({content:n.content}),i=r.find(e=>e.type===`json`)||r[0],a=i?i.schema:void 0,o={schema:Q({context:t,schema:{description:n.description,...a},state:{$ref:e,circularReferenceTracker:new Set}})};return n.description&&(o.description=n.description),n.required&&(o.required=n.required),o},Tf=({$ref:e,context:t,requestBody:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.requestBodies||(t.ir.components.requestBodies={}),t.ir.components.requestBodies[I(e)]=wf({$ref:e,context:t,requestBody:n})},Ef=({context:e})=>{if(e.spec.servers){e.ir.servers=e.spec.servers;return}for(let t of e.config.input)if(typeof t.path==`string`){let n=Ar(t.path);e.ir.servers=[{url:`${n.protocol?`${n.protocol}://`:``}${n.host}${n.port?`:${n.port}`:``}`}]}e.ir.servers||(e.ir.servers=[{url:`/`}])},Df=(e,t)=>{let n=t.timeEvent(`validate`),r=[],i=new Map;if(e.paths)for(let t of Object.entries(e.paths)){let e=t[0],n=t[1];for(let t of al){let a=n[t];if(!a)continue;let o=T({method:t,path:e});a.operationId&&(i.has(a.operationId)?r.push({code:`duplicate_key`,context:{key:`operationId`,value:a.operationId},message:"Duplicate `operationId` found. Each `operationId` must be unique.",path:[`paths`,e,t,`operationId`],severity:`error`}):i.set(a.operationId,o))}}if(e.servers){(typeof e.servers!=`object`||!Array.isArray(e.servers))&&r.push({code:`invalid_type`,message:"`servers` must be an array.",path:[],severity:`error`});for(let t=0;t<e.servers.length;t++){let n=e.servers[t];!n||typeof n!=`object`?r.push({code:`invalid_type`,context:{actual:typeof n,expected:`object`},message:"Each entry in `servers` must be an object.",path:[`servers`,t],severity:`error`}):n.url||r.push({code:`missing_required_field`,context:{field:`url`},message:"Missing required field `url` in server object.",path:[`servers`,t],severity:`error`})}}return n.timeEnd(),{issues:r,valid:!r.some(e=>e.severity===`error`)}},Of=({context:e,securitySchemesMap:t})=>{let n={ids:new Map};for(let r in e.spec.webhooks){let i=e.spec.webhooks[r],a=`$ref`in i?{...e.resolveRef(i.$ref),...i}:i,o={context:e,key:r,operation:{description:a.description,parameters:$({context:e,parameters:a.parameters}),security:e.spec.security,servers:a.servers,summary:a.summary},securitySchemesMap:t,state:n};a.delete&&vf({...o,method:`delete`,operation:{...o.operation,...a.delete,parameters:X({source:$({context:e,parameters:a.delete.parameters}),target:o.operation.parameters})}}),a.get&&vf({...o,method:`get`,operation:{...o.operation,...a.get,parameters:X({source:$({context:e,parameters:a.get.parameters}),target:o.operation.parameters})}}),a.head&&vf({...o,method:`head`,operation:{...o.operation,...a.head,parameters:X({source:$({context:e,parameters:a.head.parameters}),target:o.operation.parameters})}}),a.options&&vf({...o,method:`options`,operation:{...o.operation,...a.options,parameters:X({source:$({context:e,parameters:a.options.parameters}),target:o.operation.parameters})}}),a.patch&&vf({...o,method:`patch`,operation:{...o.operation,...a.patch,parameters:X({source:$({context:e,parameters:a.patch.parameters}),target:o.operation.parameters})}}),a.post&&vf({...o,method:`post`,operation:{...o.operation,...a.post,parameters:X({source:$({context:e,parameters:a.post.parameters}),target:o.operation.parameters})}}),a.put&&vf({...o,method:`put`,operation:{...o.operation,...a.put,parameters:X({source:$({context:e,parameters:a.put.parameters}),target:o.operation.parameters})}}),a.trace&&vf({...o,method:`trace`,operation:{...o.operation,...a.trace,parameters:X({source:$({context:e,parameters:a.trace.parameters}),target:o.operation.parameters})}})}},kf=e=>{if(e.config.parser.validate_EXPERIMENTAL&&du({context:e,result:Df(e.spec,e.logger)}),pl(e.config.parser.filters)){let t=fl(e.config.parser.filters,e.spec,e.logger),{graph:n}=Xl(e.spec,e.logger),{resourceMetadata:r}=El(n,e.logger);Vd({...Tl({filters:t,logger:e.logger,resourceMetadata:r}),logger:e.logger,preserveOrder:t.preserveOrder,spec:e.spec})}ou({context:e});let t={ids:new Map},n=new Map;if(e.spec.components){for(let t in e.spec.components.securitySchemes){let r=e.spec.components.securitySchemes[t],i=`$ref`in r?e.resolveRef(r.$ref):r;n.set(t,i)}for(let t in e.spec.components.parameters){let n=`#/components/parameters/${t}`,r=e.spec.components.parameters[t];Cf({$ref:n,context:e,parameter:`$ref`in r?e.resolveRef(r.$ref):r})}for(let t in e.spec.components.requestBodies){let n=`#/components/requestBodies/${t}`,r=e.spec.components.requestBodies[t];Tf({$ref:n,context:e,requestBody:`$ref`in r?e.resolveRef(r.$ref):r})}for(let t in e.spec.components.schemas){let n=`#/components/schemas/${t}`,r=e.spec.components.schemas[t];uf({$ref:n,context:e,schema:r})}}for(let r in Ef({context:e}),e.spec.paths){let i=e.spec.paths[r],a=i.$ref?{...e.resolveRef(i.$ref),...i}:i,o={context:e,operation:{description:a.description,parameters:$({context:e,parameters:a.parameters}),security:e.spec.security,servers:a.servers,summary:a.summary},path:r,securitySchemesMap:n,state:t};a.delete&&_f({...o,method:`delete`,operation:{...o.operation,...a.delete,parameters:X({source:$({context:e,parameters:a.delete.parameters}),target:o.operation.parameters})}}),a.get&&_f({...o,method:`get`,operation:{...o.operation,...a.get,parameters:X({source:$({context:e,parameters:a.get.parameters}),target:o.operation.parameters})}}),a.head&&_f({...o,method:`head`,operation:{...o.operation,...a.head,parameters:X({source:$({context:e,parameters:a.head.parameters}),target:o.operation.parameters})}}),a.options&&_f({...o,method:`options`,operation:{...o.operation,...a.options,parameters:X({source:$({context:e,parameters:a.options.parameters}),target:o.operation.parameters})}}),a.patch&&_f({...o,method:`patch`,operation:{...o.operation,...a.patch,parameters:X({source:$({context:e,parameters:a.patch.parameters}),target:o.operation.parameters})}}),a.post&&_f({...o,method:`post`,operation:{...o.operation,...a.post,parameters:X({source:$({context:e,parameters:a.post.parameters}),target:o.operation.parameters})}}),a.put&&_f({...o,method:`put`,operation:{...o.operation,...a.put,parameters:X({source:$({context:e,parameters:a.put.parameters}),target:o.operation.parameters})}}),a.trace&&_f({...o,method:`trace`,operation:{...o.operation,...a.trace,parameters:X({source:$({context:e,parameters:a.trace.parameters}),target:o.operation.parameters})}})}Of({context:e,securitySchemesMap:n})},Af=({config:e,dependencies:t,logger:n,spec:r})=>{let i=new il({config:e,dependencies:t,logger:n,spec:r});if(`swagger`in i.spec)return td(i),i;if(Vr(i.spec.openapi,`>=3.0.0 <3.1.0`))return Bd(i),i;if(Vr(i.spec.openapi,`>=3.1.0`))return kf(i),i;throw Error(`Unsupported OpenAPI specification`)};export{le as C,ce as S,v as _,Oc as a,oe as b,br as c,F as d,E as f,ke as g,Ie as h,Nc as i,xr as l,Re as m,Xl as n,Pr as o,x as p,Uc as r,Or as s,Af as t,Fn as u,re as v,ee as w,se as x,ie as y};
|
|
19
|
-
//# sourceMappingURL=openApi-D7xrG_wR.js.map
|