@hey-api/openapi-ts 0.86.3 → 0.86.4

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.
@@ -0,0 +1,24 @@
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let l=require(`@hey-api/codegen-core`);l=c(l);let u=require(`ansi-colors`);u=c(u);let d=require(`node:fs`);d=c(d);let f=require(`node:path`);f=c(f);let p=require(`node:url`);p=c(p);let m=require(`typescript`);m=c(m);let h=require(`semver`);h=c(h);let g=require(`node:os`);g=c(g);let _=require(`@hey-api/json-schema-ref-parser`);_=c(_);const v=(0,p.fileURLToPath)(require(`url`).pathToFileURL(__filename).href),y=f.default.dirname(v),ee=()=>{let e=y;for(;e!==f.default.dirname(e);){let t=d.default.readdirSync(e).filter(e=>e===`package.json`);if(t[0]){let n=f.default.join(e,t[0]);return JSON.parse(d.default.readFileSync(n,{encoding:`utf8`}))}e=f.default.dirname(e)}},te=()=>{let e=ee(),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},ne=e=>{if(e===null)return null;if(e){let t=f.default.isAbsolute(e)?e:f.default.resolve(y,e);return d.default.existsSync(t)?t:null}let t=y;for(;t!==f.default.dirname(t);){let e=d.default.readdirSync(t).filter(e=>e.startsWith(`tsconfig`)&&e.endsWith(`.json`)).sort(e=>e===`tsconfig.json`?-1:1);if(e[0])return f.default.join(t,e[0]);t=f.default.dirname(t)}return null},re=e=>{if(!e)return null;let t=m.default.readConfigFile(e,m.default.sys.readFile);if(t.error)throw Error(`Couldn't read tsconfig from path: ${e}`);return m.default.parseJsonConfigFileContent(t.config,m.default.sys,f.default.dirname(e))},ie=e=>{d.default.existsSync(e)||d.default.mkdirSync(e,{recursive:!0})},ae=e=>{d.default.existsSync(e)&&d.default.rmSync(e,{force:!0,recursive:!0})},oe=({moduleOutput:e,sourceOutput:t})=>{let n=t.split(`/`);return`${Array.from({length:n.length}).fill(``).join(`../`)||`./`}${e}`};var se=class extends Error{constructor(e){super(e),this.name=`ConfigError`}},ce=class extends Error{errors;constructor(e){super(`Found ${e.length} configuration ${e.length===1?`error`:`errors`}.`),this.name=`ConfigValidationError`,this.errors=e}},le=class extends Error{originalError;constructor(e,t){super(e),this.name=`JobError`,this.originalError=t}},ue=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 de=(e,t)=>{if(e instanceof se||e instanceof ce)return;e instanceof le&&(e=e.originalError.error);let n=`openapi-ts-error-${Date.now()}.log`,r=f.default.resolve(process.cwd(),t);ie(r);let i=f.default.resolve(r,n),a=`[${new Date().toISOString()}] `;e instanceof ue&&(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 o=e instanceof Error?e.message:String(e),s=e instanceof Error?e.stack:void 0;return a+=`Error: ${o}\n`,s&&(a+=`Stack:\n${s}\n`),d.default.writeFileSync(i,a),i},fe=async e=>{let t=te();if(!t.bugs.url)return;e instanceof le&&(e=e.originalError.error);let n=``;e instanceof ue&&(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)},pe=({error:e,logPath:t})=>{if(e instanceof ce&&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=u.default.gray(`[Job ${e+1}] `),r=n.length,i=u.default.red(`Found ${r} configuration ${r===1?`error`:`errors`}:`);console.error(`${t}❗️ ${i}`),n.forEach((e,n)=>{let r=` [${n+1}] `,i=u.default.red(r);console.error(`${t}${i}${u.default.white(e.message)}`)})}}else{let t=u.default.gray(`[root] `);e instanceof le&&(t=u.default.gray(`[Job ${e.originalError.jobIndex+1}] `),e=e.originalError.error);let n=u.default.red(`Failed with the message:`);console.error(`${t}❌ ${n}`);let r=u.default.red(` `);console.error(`${t}${r}${typeof e==`string`?e:e instanceof Error?e.message:`Unknown error`}`)}if(t){let e=u.default.gray(`[root] `);console.error(`${e}${u.default.cyan(`📄 Crash log saved to:`)} ${u.default.gray(t)}`)}},me=async({error:e,isInteractive:t})=>!t||e instanceof se||e instanceof ce?!1:new Promise(e=>{let t=u.default.gray(`[root] `);console.log(`${t}${u.default.yellow(`📢 Open a GitHub issue with crash details? (y/N):`)}`),process.stdin.setEncoding(`utf8`),process.stdin.once(`data`,t=>{e(t.trim().toLowerCase()===`y`)})}),he=e=>{let t=b(e);return t.name===`@hey-api/client-axios`||t.name===`@hey-api/client-nuxt`?`baseURL`:`baseUrl`},b=e=>{for(let t of e.pluginOrder){let n=e.plugins[t];if(n?.tags?.includes(`client`))return n}return{config:{name:``},name:``}};let ge;const x=()=>{let e=ge;return e.client=b(e),e},_e=e=>(ge=e,x()),S=e=>b(e).name.startsWith(`legacy/`),ve=e=>{if(S(e))return e.name},ye=/^([\w-]+)\/([\w-]+)(?:\?([\w=&.-]*))?$/,be=`https://get.heyapi.dev`,xe=(e,t,n)=>`${be}/${e}/${t}${n?`?${n}`:``}`,Se=e=>{let t=e.organization,n=e.project,r;if(e.path){let i=e.path.match(ye);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}},Ce=e=>{let t=Se(e);return{path:xe(t.organization,t.project,t.queryParams),registry:`hey-api`}},we=/^(@([\w-]+)\/([\w\-.]+)#)?([\w-]+)$/,Te=e=>`https://dash.readme.com/api/v1/api-registry/${e}`,Ee=`readme`,De=e=>{let t=e.match(we);if(!t)throw Error(`Invalid ReadMe shorthand format. Expected "${Ee}:@organization/project#uuid" or "${Ee}:uuid", received: ${Ee}:${e}`);let[,,n,r,i]=t;if(!i)throw Error(`The ReadMe UUID cannot be empty.`);return{organization:n,project:r,uuid:i}},Oe=e=>{let t=De(e.slice(`${Ee}:`.length));return{...t,path:Te(t.uuid),registry:`readme`}},ke=/^(@[\w-]+)\/([\w.-]+)$/,Ae=(e,t)=>`https://registry.scalar.com/${e}/apis/${t}/latest?format=json`,je=`scalar`,Me=e=>{let t=e.match(ke);if(!t)throw Error(`Invalid Scalar shorthand format. Expected "${je}:@organization/project", received: ${je}:${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}},Ne=e=>{let t=Me(e.slice(`${je}:`.length));return{...t,path:Ae(t.organization,t.project),registry:`scalar`}},Pe=e=>{if(e.path.startsWith(`readme:`)){Object.assign(e,Oe(e.path));return}if(e.path.startsWith(`scalar:`)){Object.assign(e,Ne(e.path));return}if(e.path.startsWith(`.`))return;if(e.path.startsWith(be)){e.path=e.path.slice(23),Object.assign(e,Ce(e));return}let t=e.path.split(`/`);if(t.length===2&&t.filter(Boolean).length===2){Object.assign(e,Ce(e));return}},Fe={enabled:!1,interval:1e3,timeout:6e4},Ie=e=>{let t={...Fe};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},Le=e=>{let t=e.input instanceof Array?e.input:[e.input],n=[];for(let r of t){let t={path:``,watch:Fe};typeof r==`string`?t.path=r:r&&(r.path!==void 0||r.organization!==void 0)?(t={...t,path:be,...r},t.watch!==void 0&&(t.watch=Ie(t))):t={...t,path:r},typeof t.path==`string`&&Pe(t),e.watch!==void 0&&t.watch.enabled===Fe.enabled&&t.watch.interval===Fe.interval&&t.watch.timeout===Fe.timeout&&(t.watch=Ie({path:t.path,watch:e.watch})),t.path&&n.push(t)}return n},Re=e=>{let t={file:!0,level:`info`,path:process.cwd()};return typeof e?.logs==`string`?t.path=e.logs:t={...t,...e?.logs},t},ze=(e,t)=>{let n=e||{},r=t||{};return{...n,...r}},Be=(e,t)=>{let n=e||{},r=t||{},i={...n,...r};return typeof i.logs==`object`&&(i.logs=ze(n.logs,r.logs)),i},Ve=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof e!=`function`,He=(e,t)=>{for(let[n,r]of Object.entries(t))r!==void 0&&r!==``&&(e[n]=r);return e},Ue=({defaultValue:e,mappers:t,value:n})=>{let r={...e};switch(typeof n){case`boolean`:if(t&&`boolean`in t){let e=t.boolean;r=He(r,e(n))}break;case`function`:if(t&&`function`in t){let e=t.function;r=He(r,e(n))}break;case`number`:if(t&&`number`in t){let e=t.number;r=He(r,e(n))}break;case`string`:if(t&&`string`in t){let e=t.string;r=He(r,e(n))}break;case`object`:if(Ve(n))if(t&&`object`in t&&typeof t.object==`function`){let i=t.object;r=He(r,i(n,e))}else r=He(r,n);break}return r},We=e=>{if(e.output instanceof Array)throw Error(`Unexpected array of outputs in user configuration. This should have been expanded already.`);let t=Ue({defaultValue:{clean:!0,fileName:{case:`preserve`,name:`{{name}}`,suffix:`.gen`},format:null,indexFile:!0,lint:null,path:``},mappers:{object:(e,t)=>({...e,fileName:Ue({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=re(ne(t.tsConfigPath)),t.importFileExtension===void 0&&t.tsConfig?.options.moduleResolution===m.default.ModuleResolutionKind.NodeNext&&(t.importFileExtension=`.js`),t.importFileExtension&&!t.importFileExtension.startsWith(`.`)&&(t.importFileExtension=`.${t.importFileExtension}`),t},Ge=e=>{let t=e?f.default.dirname(e):process.cwd();for(;t!==f.default.dirname(t);){let e=f.default.join(t,`package.json`);if(d.default.existsSync(e))try{let t=JSON.parse(d.default.readFileSync(e,`utf8`));return{...t.dependencies,...t.devDependencies,...t.peerDependencies,...t.optionalDependencies}}catch{}let n=f.default.dirname(t);if(n===t)break;t=n}return{}},Ke=[`after`,`before`,`cursor`,`offset`,`page`,`start`],qe=e=>Ue({defaultValue:{hooks:{},pagination:{keywords:Ke},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:Ue({defaultValue:{...t.pagination},value:e.pagination}),transforms:Ue({defaultValue:{...t.transforms},mappers:{object:(e,t)=>({...e,enums:Ue({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:Ue({defaultValue:{...t.readWrite,enabled:e.readWrite===void 0?t.readWrite.enabled:!!e.readWrite},mappers:{boolean:e=>({enabled:e}),object:(e,t)=>({...e,requests:Ue({defaultValue:{...t.requests},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.requests}),responses:Ue({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}),C=e=>t=>({...e,config:{...e.config,...t}}),w={boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})};var Je=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const Ye=/[\p{Lu}]/u,Xe=/[\p{Ll}]/u,Ze=/([\p{Alpha}\p{N}_]|$)/u,Qe=/[_.\- `\\[\]{}\\/]+/,$e=RegExp(`^${Qe.source}`),et=RegExp(`${Qe.source}${Ze.source}`,`gu`),tt=RegExp(`\\d+${Ze.source}`,`gu`),nt=({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(Qe.lastIndex=0;l&&Qe.test(l);)c+=1,l=t[c];let u=c!==e+1;if(Xe.lastIndex=0,Ye.lastIndex=0,Ye.test(s)&&(n||l&&!u&&l!==`s`&&Xe.test(l)))t=`${t.slice(0,e)}${o}${t.slice(e)}`,e++,i=r,n=!1,r=!0;else if(r&&i&&Xe.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},T=({case:e,stripLeadingSeparators:t=!0,value:n})=>{let r=n.trim();return r.length?!e||e===`preserve`?r:r.length===1?(Qe.lastIndex=0,Qe.test(r)?``:e===`PascalCase`||e===`SCREAMING_SNAKE_CASE`?r.toLocaleUpperCase():r.toLocaleLowerCase()):(r!==r.toLocaleLowerCase()&&(r=nt({case:e,string:r})),(t||r[0]!==n[0])&&(r=r.replace($e,``)),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(et,(e,n,r)=>r===0&&!t?e:`_${n}`),r[r.length-1]===`_`&&(r=r.slice(0,r.length-1))):(et.lastIndex=0,tt.lastIndex=0,r=r.replaceAll(tt,(e,t,n)=>[`_`,`-`,`.`].includes(r.charAt(n+e.length))?e:e.toLocaleUpperCase()),r=r.replaceAll(et,(e,r,i)=>i===0&&!t&&e[0]&&n.startsWith(e[0])?e:r.toLocaleUpperCase())),r):``},E=({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 T({case:e.case,value:t})},rt=({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]},it=e=>{for(let t in e)if(e[t].required)return!0;return!1},at=e=>e?!!(it(e.cookie)||it(e.header)||it(e.path)||it(e.query)):!1,ot=({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:rt({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:rt({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:rt({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:rt({context:e,parameter:r})}}}},D=({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},O=({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,st=e=>!!(at(e.parameters)||e.body?.required),k=({method:e,path:t})=>`${e.toUpperCase()} ${t}`,ct=({context:e,operation:t})=>{let n=t.body;if(!n||!n.pagination)return ot({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}:ot({context:e,parameters:t.parameters})},lt=({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`}},ut=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(lt({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=O({items:Object.values(n.properties),mutateSchemaOneItem:!0,schema:{}});e=D({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=O({items:Object.values(r.properties),mutateSchemaOneItem:!0,schema:{}});e=D({schema:e}),Object.keys(e).length&&e.type!==`unknown`&&(t.response=e)}return t},dt=(...e)=>h.satisfies(...e),ft=e=>({getVersion:t=>{let n=e[t];if(n)try{let e=h.parse(n);if(e)return e;let t=h.minVersion(n);if(t)return t;if(e=h.coerce(n),e)return e}catch{}},isInstalled:t=>!!e[t],satisfies:(t,n,r)=>{let i=typeof t==`string`?e[t]:t;return i?dt(i,n,r):!1}}),pt=/^[^$_\p{ID_Start}]+/u,A=/^-?\d+(\.\d+)?$/,mt=/^(document|history|location|navigator|window)$/g,ht=/^(console|Array|Date|Error|Function|JSON|Map|Math|Object|Promise|RegExp|Set|WeakMap|WeakSet)$/g,gt=/^(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,_t=/^(global|process|Buffer)$/g,vt=/^(any|as|bigint|boolean|namespace|never|null|number|string|symbol|type|undefined|unknown|void)$/g,yt=/^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u,bt=[gt,vt,ht,_t,mt],xt=e=>{let t=e.replace(/[^$\u200c\u200d\p{ID_Continue}]/gu,`_`);if(pt.lastIndex=0,pt.test(t))return`_${t}`;for(let e of bt){if(t.startsWith(`_`))return t;t=t.replace(e,`_$1`)}return t},St=e=>(e||e===``)&&(yt.lastIndex=0,!yt.test(e))?`'${e}'`:e,Ct=e=>e&&e.startsWith(`'`)&&e.endsWith(`'`)?e.slice(1,e.length-1):e,j=e=>e.replace(/\*\//g,`*`).replace(/\/\*/g,`*`).replace(/\r?\n(.*)/g,(e,t)=>g.EOL+t.trim()),wt=m.default.createPrinter({newLine:m.default.NewLineKind.LineFeed,removeComments:!1}),Tt=e=>m.default.createSourceFile(``,e,m.default.ScriptTarget.ESNext,!1,m.default.ScriptKind.TS),Et=Tt(``),Dt=e=>e.replace(/\\u([0-9a-fA-F]{4})/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16)));function Ot({node:e,unescape:t=!1}){let n=wt.printNode(m.default.EmitHint.Unspecified,e,Et);if(!t)return n;try{return Dt(n)}catch{return x().logs.level===`debug`&&console.warn(`Could not decode value:`,n),n}}const M=({text:e})=>m.default.factory.createIdentifier(e),kt=()=>m.default.factory.createThis(),N=({keyword:e})=>{let t=Bt({keyword:e});return m.default.factory.createModifier(t)},At=({initializer:e,modifier:t,name:n,type:r})=>m.default.factory.createPropertyDeclaration(t?[N({keyword:t})]:void 0,n,void 0,r,e),jt={boolean:e=>e?m.default.factory.createTrue():m.default.factory.createFalse(),export:({alias:e,asType:t=!1,name:n})=>{let r=M({text:n});if(e){let n=M({text:e});return m.default.factory.createExportSpecifier(t,r,n)}return m.default.factory.createExportSpecifier(t,void 0,r)},import:({alias:e,asType:t=!1,name:n})=>{let r=M({text:n});if(e){let n=M({text:e});return m.default.factory.createImportSpecifier(t,r,n)}return m.default.factory.createImportSpecifier(t,void 0,r)},number:e=>e<0?m.default.factory.createPrefixUnaryExpression(m.default.SyntaxKind.MinusToken,m.default.factory.createNumericLiteral(Math.abs(e))):m.default.factory.createNumericLiteral(e),string:(e,t=!1)=>{let n=e;t&&(n=Ct(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("`")?M({text:n}):an({text:n})}},Mt=e=>typeof e==`object`&&!!e&&typeof e.kind==`number`&&typeof e.flags==`number`&&typeof e.pos==`number`&&typeof e.end==`number`,Nt=e=>e!==void 0,Pt=({commentObject:e,node:t})=>{let n=e.lines.filter(e=>!!e||e===``);if(!n.length)return;if(!e.jsdoc){for(let e of n)m.default.addSyntheticLeadingComment(t,m.default.SyntaxKind.SingleLineCommentTrivia,` ${e}`,!0);return}let r=n.map((e,t)=>{let r=e;return t!==n.length&&(r=`${r}\n`),m.default.factory.createJSDocText(r)}),i=Ot({node:m.default.factory.createJSDocComment(m.default.factory.createNodeArray(r),void 0),unescape:!0}).replace(`/*`,``).replace(`* */`,``);m.default.addSyntheticLeadingComment(t,m.default.SyntaxKind.MultiLineCommentTrivia,i,!0)},P=({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)Pt({commentObject:e,node:t})},F=(e,t)=>m.default.isTypeNode(e)?e:typeof e==`number`?m.default.factory.createLiteralTypeNode(jt.number(e)):ln({typeArguments:t?.map(e=>F(e)),typeName:m.default.isIdentifier(e)?e.text:e}),Ft=({expression:e,name:t})=>m.default.factory.createPropertyAccessChain(e,m.default.factory.createToken(m.default.SyntaxKind.QuestionDotToken),t),It=({expression:e,isOptional:t,name:n})=>{let r=typeof e==`string`?M({text:e}):e;if(t&&typeof n!=`number`)return Ft({expression:r,name:n});if(typeof n==`string`){if(yt.lastIndex=0,!yt.test(n)){!n.startsWith(`'`)&&!n.endsWith(`'`)&&(n=`\'${n}\'`);let e=M({text:n});return m.default.factory.createElementAccessExpression(r,e)}let e=M({text:n});return m.default.factory.createPropertyAccessExpression(r,e)}if(typeof n==`number`){let e=m.default.factory.createNumericLiteral(n);return m.default.factory.createElementAccessExpression(r,e)}return m.default.factory.createPropertyAccessExpression(r,n)},Lt=()=>m.default.factory.createNull(),Rt=({identifiers:e=[],isValueAccess:t,shorthand:n,unescape:r,value:i})=>{if(i===null)return Lt();if(Array.isArray(i))return Yt({elements:i});if(typeof i==`object`)return Qt({identifiers:e,obj:i,shorthand:n});if(typeof i==`number`)return jt.number(i);if(typeof i==`boolean`)return jt.boolean(i);if(typeof i==`string`){if(t){let e=i.split(`.`);return It({expression:e[0],name:e[1]})}return jt.string(i,r)}},zt=e=>e.map(e=>{if(`destructure`in e)return dn({name:m.default.factory.createObjectBindingPattern(e.destructure.map(e=>{if(!(`destructure`in e))return m.default.factory.createBindingElement(void 0,void 0,M({text:e.name}),void 0)}).filter(Boolean)),type:e.type===void 0?void 0:F(e.type)});let t=e.accessLevel?[N({keyword:e.accessLevel})]:[];return e.isReadOnly&&t.push(N({keyword:`readonly`})),dn({initializer:e.default===void 0?void 0:Rt({value:e.default}),modifiers:t,name:M({text:e.name}),required:e.isRequired!==!1,type:e.type===void 0?void 0:F(e.type)})}),Bt=({keyword:e})=>{switch(e){case`any`:return m.default.SyntaxKind.AnyKeyword;case`async`:return m.default.SyntaxKind.AsyncKeyword;case`boolean`:return m.default.SyntaxKind.BooleanKeyword;case`export`:return m.default.SyntaxKind.ExportKeyword;case`never`:return m.default.SyntaxKind.NeverKeyword;case`number`:return m.default.SyntaxKind.NumberKeyword;case`private`:return m.default.SyntaxKind.PrivateKeyword;case`protected`:return m.default.SyntaxKind.ProtectedKeyword;case`public`:return m.default.SyntaxKind.PublicKeyword;case`readonly`:return m.default.SyntaxKind.ReadonlyKeyword;case`static`:return m.default.SyntaxKind.StaticKeyword;case`string`:return m.default.SyntaxKind.StringKeyword;case`undefined`:return m.default.SyntaxKind.UndefinedKeyword;case`unknown`:return m.default.SyntaxKind.UnknownKeyword;case`void`:return m.default.SyntaxKind.VoidKeyword;default:throw Error(`unsupported syntax kind keyword "${e}"`)}},Vt=({keyword:e})=>{let t=Bt({keyword:e});return m.default.factory.createKeywordTypeNode(t)},Ht=e=>e.map(e=>m.default.isTypeParameterDeclaration(e)?e:Wt({constraint:e.extends?typeof e.extends==`string`?Vt({keyword:`boolean`}):e.extends:void 0,defaultType:e.default===void 0?void 0:Mt(e.default)?e.default:m.default.factory.createLiteralTypeNode(e.default?m.default.factory.createTrue():m.default.factory.createFalse()),name:e.name})),Ut=({operator:e,type:t})=>{let n=e===`keyof`?m.default.SyntaxKind.KeyOfKeyword:e===`readonly`?m.default.SyntaxKind.ReadonlyKeyword:m.default.SyntaxKind.UniqueKeyword;return m.default.factory.createTypeOperatorNode(n,t)},Wt=({constraint:e,defaultType:t,modifiers:n,name:r})=>m.default.factory.createTypeParameterDeclaration(n,r,e,t),Gt=({members:e,nameType:t,questionToken:n,readonlyToken:r,type:i,typeParameter:a})=>m.default.factory.createMappedTypeNode(r,a,t,n,i,e),Kt=({literal:e})=>m.default.factory.createLiteralTypeNode(e),qt=({async:e,comment:t,multiLine:n,parameters:r=[],returnType:i,statements:a=[],types:o=[]})=>{let s=m.default.factory.createArrowFunction(e?[N({keyword:`async`})]:void 0,o?Ht(o):void 0,zt(r),i?F(i):void 0,void 0,Array.isArray(a)?hn({multiLine:n,statements:a}):a);return P({comments:t,node:s}),s},Jt=({async:e,comment:t,multiLine:n,parameters:r=[],returnType:i,statements:a=[],types:o=[]})=>{let s=m.default.factory.createFunctionExpression(e?[N({keyword:`async`})]:void 0,void 0,void 0,o?Ht(o):void 0,zt(r),i?F(i):void 0,hn({multiLine:n,statements:a}));return P({comments:t,node:s}),s},Yt=({elements:e,multiLine:t=!1})=>m.default.factory.createArrayLiteralExpression(e.map(e=>Mt(e)?e:Rt({value:e})).filter(Nt),t||!Array.isArray(e[0])&&typeof e[0]==`object`),Xt=({expression:e})=>m.default.factory.createAwaitExpression(e),Zt=({parameters:e=[],returnType:t,typeParameters:n})=>m.default.factory.createFunctionTypeNode(n,e,t),Qt=({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=Mt(e.spread)?e.spread:M({text:e.spread});o=m.default.factory.createSpreadAssignment(e.assertion?vn({expression:t,type:typeof e.assertion==`string`?Vt({keyword:e.assertion}):e.assertion}):t)}else if(e.shorthand||i&&r)o=m.default.factory.createShorthandPropertyAssignment(e.value);else{let r=Mt(e.value)?e.value:Array.isArray(e.value)&&(!e.value.length||typeof e.value[0]==`object`)?Qt({multiLine:n,obj:e.value,shorthand:i,unescape:a}):Rt({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)&&!m.default.isObjectLiteralExpression(r)&&(r=M({text:e.value})),o=gn({initializer:r,name:e.key})}return P({comments:e.comments,node:o}),o}).filter(Nt):Object.entries(r).map(([e,n])=>{let r=Rt({identifiers:t.includes(e)?Object.keys(n):[],shorthand:i,unescape:a,value:n});if(!r)return;t.includes(e)&&!m.default.isObjectLiteralExpression(r)&&(r=M({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?m.default.factory.createShorthandPropertyAssignment(n):gn({initializer:r,name:e})}).filter(Nt),s=m.default.factory.createObjectLiteralExpression(o,n);return P({comments:e,node:s}),s},$t=({asConst:e,comments:t={},leadingComment:n,name:r,obj:i})=>{let a=Array.isArray(i)?i.map(e=>{let t=en({initializer:Rt({value:e.value}),name:e.key});return P({comments:e.comments,node:t}),t}):Object.entries(i).map(([e,n])=>{let r=m.default.factory.createEnumMember(e,Rt({unescape:!0,value:n}));return P({comments:t[e],node:r}),r}),o=[N({keyword:`export`})],s=e?[m.default.factory.createToken(m.default.SyntaxKind.ConstKeyword)]:[],c=[...o,...s],l=m.default.factory.createEnumDeclaration(c,typeof r==`string`?M({text:r}):r,a);return P({comments:n,node:l}),l},en=({initializer:e,name:t})=>{let n=t;return typeof n==`string`&&(n=n.includes(`'`)?an({isSingleQuote:!1,text:n}):St(n)),m.default.factory.createEnumMember(n,e)},tn=({name:e,statements:t})=>m.default.factory.createModuleDeclaration([N({keyword:`export`})],M({text:e}),m.default.factory.createModuleBlock(t),m.default.NodeFlags.Namespace),nn=({indexType:e,objectType:t})=>m.default.factory.createIndexedAccessTypeNode(t,e),rn=({name:e,returnType:t,statements:n})=>m.default.factory.createGetAccessorDeclaration(void 0,e,[],t?ln({typeName:t}):void 0,hn({statements:n})),an=({isSingleQuote:e,text:t})=>(e===void 0&&(e=!t.includes(`'`)),m.default.factory.createStringLiteral(t,e)),on=({condition:e,whenFalse:t,whenTrue:n})=>m.default.factory.createConditionalExpression(e,m.default.factory.createToken(m.default.SyntaxKind.QuestionToken),n,m.default.factory.createToken(m.default.SyntaxKind.ColonToken),t),sn=({text:e})=>m.default.factory.createTypeOfExpression(typeof e==`string`?M({text:e}):e),cn=({comment:e,exportType:t,name:n,type:r,typeParameters:i=[]})=>{let a=m.default.factory.createTypeAliasDeclaration(t?[N({keyword:`export`})]:void 0,typeof n==`string`?M({text:n}):n,Ht(i),F(r));return P({comments:e,node:a}),a},ln=({typeArguments:e,typeName:t})=>m.default.factory.createTypeReferenceNode(t,e),un=({type:e})=>m.default.factory.createParenthesizedType(e),dn=({initializer:e,modifiers:t,name:n,required:r=!0,type:i})=>m.default.factory.createParameterDeclaration(t,void 0,n,r?void 0:m.default.factory.createToken(m.default.SyntaxKind.QuestionToken),i,e),fn=({argumentsArray:e,expression:t,typeArguments:n})=>m.default.factory.createNewExpression(t,n,e),pn=({awaitModifier:e,expression:t,initializer:n,statement:r})=>m.default.factory.createForOfStatement(e,n,t,r),mn=({left:e,right:t})=>m.default.factory.createAssignment(e,t),hn=({multiLine:e=!0,statements:t})=>m.default.factory.createBlock(t,e),gn=({initializer:e,name:t})=>m.default.factory.createPropertyAssignment(t,e),_n=({flags:e=[],text:t})=>{let n=`/${(t.startsWith(`/`)&&t.endsWith(`/`)?t.slice(1,-1):t).replace(/(?<!\\)\//g,`\\/`)}/`;return m.default.factory.createRegularExpressionLiteral(`${n}${e.join(``)}`)},vn=({expression:e,type:t})=>m.default.factory.createAsExpression(e,t),yn=({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?m.default.factory.createTemplateMiddle(n):m.default.factory.createTemplateTail(n),i=m.default.factory.createTemplateLiteralTypeSpan(r,e);t.push(i),n=``}return m.default.factory.createTemplateLiteralType(m.default.factory.createTemplateHead(n),t.reverse())},bn=({module:e,shouldAppendJs:t})=>m.default.factory.createExportDeclaration(void 0,!1,void 0,jt.string(t?`${e}.js`:e)),xn=({functionName:e,parameters:t=[],types:n})=>{let r=typeof e==`string`?M({text:e}):e,i=t.filter(e=>e!==void 0).map(e=>typeof e==`string`?M({text:e}):e);return m.default.factory.createCallExpression(r,n,i)},Sn=({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 jt.export({alias:t.alias,asType:r&&t.asType,name:t.name})}),a=m.default.factory.createNamedExports(i),o=jt.string(t);return m.default.factory.createExportDeclaration(void 0,!r,a,o)},Cn=({assertion:e,comment:t,destructure:n,exportConst:r,expression:i,name:a,typeName:o})=>{let s=e?vn({expression:i,type:typeof e==`string`?ln({typeName:e}):e}):i,c=typeof a==`string`?M({text:a}):a,l=m.default.factory.createVariableDeclaration(n?m.default.factory.createObjectBindingPattern([m.default.factory.createBindingElement(void 0,void 0,c,void 0)]):c,void 0,o?typeof o==`string`?ln({typeName:o}):o:void 0,s),u=m.default.factory.createVariableStatement(r?[N({keyword:`export`})]:void 0,m.default.factory.createVariableDeclarationList([l],m.default.NodeFlags.Const));return P({comments:t,node:u}),u},wn=({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(jt.import({alias:t.alias,asType:r&&t.asType,name:t.name}))});let o=i?m.default.factory.createNamespaceImport(M({text:i.alias})):m.default.factory.createNamedImports(a),s=m.default.factory.createImportClause(!r,void 0,o),c=jt.string(t);return m.default.factory.createImportDeclaration(void 0,s,c)},Tn=({accessLevel:e,comment:t,multiLine:n=!0,parameters:r=[],statements:i=[]})=>{let a=e?[N({keyword:e})]:void 0,o=m.default.factory.createConstructorDeclaration(a,zt(r),hn({multiLine:n,statements:i}));return P({comments:t,node:o}),o},En=({accessLevel:e,comment:t,isStatic:n=!1,multiLine:r=!0,name:i,parameters:a=[],returnType:o,statements:s=[],types:c=[]})=>{let l=e?[N({keyword:e})]:[];n&&l.push(N({keyword:`static`}));let u=m.default.factory.createMethodDeclaration(l,void 0,M({text:i}),void 0,c?Ht(c):void 0,zt(a),o?F(o):void 0,hn({multiLine:r,statements:s}));return P({comments:t,node:u}),u},Dn=({decorator:e,exportClass:t,extendedClasses:n,name:r,nodes:i})=>{let a=[];t&&a.push(N({keyword:`export`})),e&&a.unshift(m.default.factory.createDecorator(xn({functionName:e.name,parameters:e.args.map(e=>Rt({value:e})).filter(Nt)})));let o=[];if(n)for(let e of n)o.push(m.default.factory.createHeritageClause(m.default.SyntaxKind.ExtendsKeyword,[m.default.factory.createExpressionWithTypeArguments(M({text:e}),void 0)]));return m.default.factory.createClassDeclaration(a,M({text:r}),void 0,o,i)},On=({expression:e})=>m.default.factory.createExpressionStatement(e),kn=({expression:e})=>m.default.factory.createReturnStatement(e),An=({args:e=[],name:t,types:n=[]})=>{let r=n.map(e=>ln({typeName:e}));return kn({expression:xn({functionName:t,parameters:e.map(e=>m.default.isExpression(e)?e:M({text:e})).filter(Nt),types:r})})},jn=({expression:e})=>kn({expression:typeof e==`string`?M({text:e}):e}),Mn=e=>e.slice(1).reduce((e,t)=>(yt.lastIndex=0,yt.test(t)?Ft({expression:e,name:t}):m.default.factory.createElementAccessChain(e,m.default.factory.createToken(m.default.SyntaxKind.QuestionDotToken),M({text:t}))),M({text:e[0]})),Nn=e=>e.slice(1).reduce((e,t)=>It({expression:e,name:t}),M({text:e[0]})),Pn=({expressions:e})=>e.reduce((e,t)=>It({expression:e,name:t})),Fn=({left:e,operator:t=`=`,right:n})=>m.default.factory.createBinaryExpression(e,t===`=`?m.default.SyntaxKind.EqualsToken:t===`===`?m.default.SyntaxKind.EqualsEqualsEqualsToken:t===`!==`?m.default.SyntaxKind.ExclamationEqualsEqualsToken:t===`??`?m.default.SyntaxKind.QuestionQuestionToken:m.default.SyntaxKind.InKeyword,typeof n==`string`?M({text:n}):n),In=({elseStatement:e,expression:t,thenStatement:n})=>m.default.factory.createIfStatement(t,n,e),Ln=({path:e})=>{let t=Mn(e),n=Nn(e);return In({expression:t,thenStatement:hn({statements:[On({expression:Fn({left:n,right:fn({argumentsArray:[n],expression:M({text:`Date`})})})})]})})},Rn=({path:e,transformerName:t})=>[In({expression:Mn(e),thenStatement:hn({statements:[On({expression:xn({functionName:t,parameters:[Nn(e)]})})]})})],zn=({path:e,transformerName:t})=>{let n=Mn(e),r=Nn(e);return In({expression:xn({functionName:It({expression:`Array`,name:`isArray`}),parameters:[n]}),thenStatement:hn({statements:[On({expression:m.default.factory.createCallChain(It({expression:r,name:`forEach`}),void 0,void 0,[M({text:t})])})]})})},Bn=({parameterName:e})=>{let t=M({text:`Date`});return fn({argumentsArray:[M({text:e})],expression:t})},Vn=({path:e,transformExpression:t})=>{let n=Mn(e),r=Nn(e);return In({expression:xn({functionName:It({expression:`Array`,name:`isArray`}),parameters:[n]}),thenStatement:hn({statements:[On({expression:Fn({left:r,right:m.default.factory.createCallChain(It({expression:r,name:`map`}),void 0,void 0,[qt({parameters:[{name:`item`}],statements:t})])})})]})})},Hn=ln({typeName:`null`}),Un=({isNullable:e,node:t})=>e?m.default.factory.createUnionTypeNode([t,Hn]):t,Wn=({indexKey:e,indexProperty:t,isNullable:n,properties:r,useLegacyResolution:i})=>{let a=[],o=r.map(e=>{let t=e.isReadOnly?[N({keyword:`readonly`})]:void 0,n=e.isRequired===!1?m.default.factory.createToken(m.default.SyntaxKind.QuestionToken):void 0,r=F(e.type);a.push(r);let o=m.default.factory.createPropertySignature(t,i||typeof e.name==`string`&&e.name.match(yt)||typeof e.name!=`string`&&m.default.isPropertyName(e.name)?e.name:an({text:e.name}),n,r);return P({comments:e.comment,node:o}),o}),s=!1;if(t)if(!r.length&&e){let n=Gt({questionToken:m.default.factory.createToken(m.default.SyntaxKind.QuestionToken),type:t.type??Vt({keyword:`string`}),typeParameter:Wt({constraint:e,name:M({text:String(t.name)})})});o.push(n),s=!0}else{let e=t.isReadOnly?[N({keyword:`readonly`})]:void 0,n=m.default.factory.createIndexSignature(e,[dn({name:M({text:String(t.name)}),type:Vt({keyword:`string`})})],F(t.type));o.push(n)}return Un({isNullable:n,node:s?o[0]:m.default.factory.createTypeLiteralNode(o)})},Gn=({isNullable:e,types:t})=>{let n=[];for(let e of t){let t=F(e);m.default.isUnionTypeNode(t)?n.push(...t.types):n.push(t)}return Un({isNullable:e,node:m.default.factory.createUnionTypeNode(n)})},Kn=({isNullable:e,types:t})=>{let n=[];for(let e of t){let t=F(e);m.default.isIntersectionTypeNode(t)?n.push(...t.types):n.push(t)}return Un({isNullable:e,node:m.default.factory.createIntersectionTypeNode(n)})},qn=({isNullable:e=!1,types:t})=>{let n=t.map(e=>F(e));return Un({isNullable:e,node:m.default.factory.createTupleTypeNode(n)})},Jn=(e,t,n=!1,r=!0)=>{let i=Gn({types:e}),a=Gn({types:t});return Un({isNullable:n,node:Wn({properties:[{name:`[key: ${Ot({node:i,unescape:!0})}]`,type:a}],useLegacyResolution:r})})},Yn=(e,t=!1)=>Un({isNullable:t,node:ln({typeArguments:[Array.isArray(e)?Gn({types:e}):e],typeName:`Array`})}),I={anonymousFunction:Jt,arrayLiteralExpression:Yt,arrowFunction:qt,asExpression:vn,assignment:mn,awaitExpression:Xt,binaryExpression:Fn,block:hn,callExpression:xn,classDeclaration:Dn,conditionalExpression:on,constVariable:Cn,constructorDeclaration:Tn,enumDeclaration:$t,exportAllDeclaration:bn,exportNamedDeclaration:Sn,expressionToStatement:On,forOfStatement:pn,functionTypeNode:Zt,getAccessorDeclaration:rn,identifier:M,ifStatement:In,indexedAccessTypeNode:nn,isTsNode:Mt,keywordTypeNode:Vt,literalTypeNode:Kt,mappedTypeNode:Gt,methodDeclaration:En,namedImportDeclarations:wn,namespaceDeclaration:tn,newExpression:fn,nodeToString:Ot,null:Lt,objectExpression:Qt,ots:jt,parameterDeclaration:dn,propertyAccessExpression:It,propertyAccessExpressions:Pn,propertyAssignment:gn,propertyDeclaration:At,regularExpressionLiteral:_n,returnFunctionCall:An,returnStatement:kn,returnVariable:jn,safeAccessExpression:Mn,stringLiteral:an,templateLiteralType:yn,this:kt,transformArrayMap:Vn,transformArrayMutation:zn,transformDateMutation:Ln,transformFunctionMutation:Rn,transformNewDate:Bn,typeAliasDeclaration:cn,typeArrayNode:Yn,typeInterfaceNode:Wn,typeIntersectionNode:Kn,typeNode:F,typeOfExpression:sn,typeOperatorNode:Ut,typeParameterDeclaration:Wt,typeParenthesizedNode:un,typeRecordNode:Jn,typeReferenceNode:ln,typeTupleNode:qn,typeUnionNode:Gn,valueToExpression:Rt},Xn=I,Zn=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 Qn=class{addBinding({bindings:e,file:t,meta:n,project:r,symbol:i}){if(!i.external&&!r.symbols.hasValue(i.id))return;let[a]=r.symbolIdToFiles(i.id);if(!a)return;let o=this.getBindingPath(t,a,n),s=e.get(o),c=(0,l.createBinding)({file:t,modulePath:o,symbol:i,symbolFile:a});s?((0,l.mergeBindings)(s,c),e.set(o,s)):e.set(o,c)}getBindingPath(e,t,n){if(!e.path||!t.path)return``;if(t.external&&!f.default.isAbsolute(t.path))return t.path;let r=f.default.posix.relative(f.default.posix.dirname(e.path.split(f.default.sep).join(f.default.posix.sep)),t.path.split(f.default.sep).join(f.default.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(Ot({node:t,unescape:!0}));else e!=null&&n.push(Ot({node:e,unescape:!0}))}return n}getExportLines(e,t,n){let r=[];for(let[i,a]of e.entries()){let e=[],o,s=!1;if(a.namespaceBinding!==void 0)typeof a.namespaceBinding==`string`&&(o=(0,l.renderIds)(a.namespaceBinding,e=>{let r=n.symbols.get(e);return this.replacerFn({file:t,project:n,symbol:r})})),a.typeNamespaceBinding&&(s=!0);else if(a.names&&a.names.length>0){a.names.every(e=>(a.typeNames??[]).includes(e))&&(s=!0);for(let r of a.names){let i=a.aliases?.[r],o=r,c;i&&i!==o&&(c=o,o=i),o=(0,l.renderIds)(o,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=(0,l.renderIds)(c,e=>{let r=n.symbols.get(e);return this.replacerFn({file:t,project:n,symbol:r})}),c===o&&(c=void 0));let u=m.default.factory.createExportSpecifier(s?!1:a.typeNames?.includes(r)??!1,c?I.identifier({text:c}):void 0,I.identifier({text:o}));e.push(u)}}let c=o?m.default.factory.createNamespaceExport(I.identifier({text:o})):e.length?m.default.factory.createNamedExports(e):void 0,u=m.default.factory.createExportDeclaration(void 0,s,c,I.stringLiteral({isSingleQuote:!0,text:i}));r.push(Ot({node:u,unescape:!0}))}return r}getHeaderLines(){return[`// This file is auto-generated by @hey-api/openapi-ts`]}getImportLines(e,t,n){let r=[],i=-1,a=e=>{let t=e.from;return t.startsWith(`.`)?t.startsWith(`./`)?[2,0,t]:[2,t.match(/\.\.\//g)?.length??0,t]:Zn.has(t.split(`/`)[0])?[0,0,t]:[1,0,t]},o=Array.from(e.values()).map(e=>({...e,k:a(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 o){let a=[],o,s,c=!1;if(e.defaultBinding){let r=(0,l.renderIds)(e.defaultBinding,e=>{let r=n.symbols.get(e);return this.replacerFn({file:t,project:n,symbol:r})});o=I.identifier({text:r}),e.typeDefaultBinding&&(c=!0)}else if(typeof e.namespaceBinding==`string`)s=(0,l.renderIds)(e.namespaceBinding,e=>{let r=n.symbols.get(e);return this.replacerFn({file:t,project:n,symbol:r})}),e.typeNamespaceBinding&&(c=!0);else if(e.names&&e.names.length>0){e.names.every(t=>e.typeNames?.includes(t))&&(c=!0);let r=[];for(let i of e.names){let a=e.aliases?.[i],o=i,s;a&&a!==o&&(s=o,o=a),o=(0,l.renderIds)(o,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&&(s||=o),i}),s&&(s=(0,l.renderIds)(s,e=>{let r=n.symbols.get(e);return this.replacerFn({file:t,project:n,symbol:r})}),s===o&&(s=void 0)),r.push({isTypeOnly:c?!1:e.typeNames?.includes(i)??!1,name:o,propertyName:s?I.identifier({text:s}):void 0})}a=r.sort((e,t)=>e.name.localeCompare(t.name)).map(({isTypeOnly:e,name:t,propertyName:n})=>m.default.factory.createImportSpecifier(e,n,I.identifier({text:t})))}let u=m.default.factory.createImportClause(c,o,s?m.default.factory.createNamespaceImport(I.identifier({text:s})):a.length?m.default.factory.createNamedImports(a):void 0),d=m.default.factory.createImportDeclaration(void 0,u,I.stringLiteral({isSingleQuote:!0,text:e.from}));i!==-1&&e.k[0]!==i&&r.push(``),r.push(Ot({node:d,unescape:!0})),i=e.k[0]}return r}getUniqueName(e,t){let n=2,r=e;for(;t.hasValue(r);)r=`${e}${n}`,n+=1;return r}renderFile(e,t,n,r){let i=new Map;if(e=(0,l.renderIds)(e,e=>{let a=n.symbols.get(e),o=this.replacerFn({file:t,project:n,symbol:a});return a&&this.addBinding({bindings:i,file:t,meta:r,project:n,symbol:a}),o}),!e.length)return``;let a=``,o=this.getHeaderLines();a+=`${o.join(`
3
+ `)}${o.length?`
4
+
5
+ `:``}`;let s=this.getImportLines(i,t,n);return a+=`${s.join(`
6
+ `)}${s.length?`
7
+
8
+ `:``}`,`${a}${e}`}renderSymbols(e,t,n){let r=new Map,i=``,a=this.getBodyLines(e,t);i+=`${a.join(`
9
+
10
+ `)}${a.length?`
11
+ `:``}`,i=(0,l.renderIds)(i,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 o=this.getExportLines(r,e,t);return i+=`${o.join(`
12
+ `)}${o.length?`
13
+ `:``}`,i}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=xt(a??n.name),s=e.resolvedNames.getKey(o);if(s!==void 0){let r=t.symbols.get(s);(r?.meta?.kind===`type`&&n.meta?.kind===`type`||r?.meta?.kind!==`type`&&n.meta?.kind!==`type`)&&(o=this.getUniqueName(o,e.resolvedNames))}return e.resolvedNames.set(n.id,o),o}},$n=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 er=(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))},tr=(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 $n(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))},nr=(e,t,n)=>n?.order===`topological`?tr(e,t,n):er(e,t,n),rr=[`operation`,`parameter`,`requestBody`,`schema`,`server`,`webhook`],ir=(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}},ar=[`server`,`schema`,`parameter`,`requestBody`,`operation`,`webhook`],or=(()=>{let e={};for(let t=0;t<ar.length;t++){let n=ar[t];n&&(e[n]=t)}for(let t of rr)e[t]===void 0&&(e[t]=ar.length);return e})(),sr=10,cr=e=>{let t=ir(e);return t.matched?or[t.kind]??10:10},lr=/~1/g,ur=/~0/g,L=e=>{let t=fr(e),n=t[t.length-1];return decodeURI(n)},dr=e=>String(e).replace(/~/g,`~0`).replace(/\//g,`~1`),fr=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(lr,`/`).replace(ur,`~`)):[]},pr=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},mr=e=>{let t=e.map(dr).join(`/`);return`#`+(t?`/${t}`:``)},hr=({$ref:e,spec:t})=>{let n=fr(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},gr=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},_r=e=>{switch(e.method){case`delete`:case`patch`:case`post`:case`put`:return[`mutation`];case`get`:return[`query`];default:return}};var vr=class{api;config;context;dependencies=[];eventHooks;gen;handler;name;output;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.output=e.output,this.package=e.context.package}forEach(...e){if(!this.context.graph)throw Error(`No graph available in context`);let t,n,r={getPointerPriority:cr,matchPointerToGroup:ir,order:`topological`,preferGroups:ar};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:rr);nr(this.context.graph,(e,n)=>{let r=ir(e);if(!r.matched||!i.has(r.kind))return;let a,o={_path:fr(e),pointer:e,tags:n.tags};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)}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:f.default.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 ue({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 gr(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,_r];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}},yr=class{config;gen;graph;ir={};logger;package;plugins={};spec;constructor({config:e,dependencies:t,logger:n,spec:r}){this.config=e,this.gen=new l.Project({defaultFileName:`index`,fileName:t=>{let n=E({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 Qn},root:e.output.path}),this.logger=n,this.package=ft(t),this.spec=r}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 vr({api:t.api,config:t.config,context:this,dependencies:t.dependencies??[],gen:this.gen,handler:t.handler,name:t.name,output:t.output});return this.plugins[n.name]=n,n}registerPlugins(){return this.config.pluginOrder.map(e=>this.registerPlugin(e))}resolveIrRef(e){return hr({$ref:e,spec:this.ir})}resolveRef(e){return hr({$ref:e,spec:this.spec})}};const br=e=>{let t=e.replace(/[^$\u200c\u200d\p{ID_Continue}]/gu,`_`);return pt.lastIndex=0,pt.test(t)?`_${t}`:t},xr=e=>e.replace(/^[^\p{ID_Start}]+/u,``).replace(/[^$\u200c\u200d\p{ID_Continue}]/gu,`-`).replace(/[$+]/g,`-`),Sr=e=>xr(e.replace(`[]`,`Array`)),Cr=[`delete`,`get`,`head`,`options`,`patch`,`post`,`put`,`trace`],wr=({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)?T({case:c,value:xr(n)}):T({case:c,value:`${r}-${i.replace(/{(.*?)}/g,`by-$1`).replace(/[/:+]/g,`-`)}`}),t>1&&(o=`${o}${t}`),a.ids.has(o)?wr({context:e,count:t+1,id:n,method:r,path:i,state:a}):(a.ids.set(o,k({method:r,path:i})),o)},Tr=`/`,R=(e,t=``)=>`${e}/${t}`,z=e=>{let t=e.indexOf(`/`);return{name:e.slice(t+1),namespace:e.slice(0,t)}},Er=e=>{switch(e){case`parameters`:return`parameter`;case`requestBodies`:return`body`;case`responses`:return`response`;case`definitions`:case`schemas`:return`schema`;default:return`unknown`}},Dr=(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(R(e,i));return{regexps:r,set:new Set(n)}},Or=({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 Cr){if(!i[t])continue;let a=k({method:t,path:r});e.regexps.some(e=>e.test(a))&&e.set.add(R(`operation`,a)),n.regexps.some(e=>e.test(a))&&n.set.add(R(`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(R(`schema`,e)),r.regexps.some(t=>t.test(e))&&r.set.add(R(`schema`,e))},kr=({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 Cr){if(!r[t])continue;let i=k({method:t,path:n});e.regexps.some(e=>e.test(i))&&e.set.add(R(`operation`,i)),a.regexps.some(e=>e.test(i))&&a.set.add(R(`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(R(`parameter`,e)),o.regexps.some(t=>t.test(e))&&o.set.add(R(`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(R(`body`,e)),s.regexps.some(t=>t.test(e))&&s.set.add(R(`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(R(`response`,e)),c.regexps.some(t=>t.test(e))&&c.set.add(R(`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(R(`schema`,e)),l.regexps.some(t=>t.test(e))&&l.set.add(R(`schema`,e))}},Ar=({spec:e,...t})=>{`swagger`in e?Or({...t,spec:e}):kr({...t,spec:e})},jr=(e,t,n)=>{let r=n.timeEvent(`create-filters`),i=Dr(`operation`,e?.operations?.exclude),a=Dr(`operation`,e?.operations?.include),o=Dr(`parameter`,e?.parameters?.exclude),s=Dr(`parameter`,e?.parameters?.include),c=Dr(`body`,e?.requestBodies?.exclude),l=Dr(`body`,e?.requestBodies?.include),u=Dr(`response`,e?.responses?.exclude),d=Dr(`response`,e?.responses?.include),f=Dr(`schema`,e?.schemas?.exclude),p=Dr(`schema`,e?.schemas?.include);Ar({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},Mr=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,Nr=({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}=z(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}},Pr=({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}=z(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}},Fr=({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}=z(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}},Ir=({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}=z(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}},Lr=({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}=z(t);switch(i){case`schema`:!n.has(t)&&!e.schemas.exclude.has(t)&&r.push(t);break}}}return{schemas:n}},Rr=({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}}}},zr=({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}}}},Br=({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}}}},Vr=({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}}}},Hr=({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)},Ur=({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}=z(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}},Wr=({filters:e,logger:t,resourceMetadata:n})=>{let r=t.timeEvent(`create-filtered-dependencies`),{schemas:i}=Lr({filters:e,resourceMetadata:n}),{parameters:a}=Pr({filters:e,resourceMetadata:n,schemas:i}),{requestBodies:o}=Fr({filters:e,resourceMetadata:n,schemas:i}),{responses:s}=Ir({filters:e,resourceMetadata:n,schemas:i});Vr({filters:e,resourceMetadata:n,schemas:i}),Rr({filters:e,parameters:a,resourceMetadata:n}),zr({filters:e,requestBodies:o,resourceMetadata:n}),Br({filters:e,resourceMetadata:n,responses:s});let{operations:c}=Nr({filters:e,parameters:a,requestBodies:o,resourceMetadata:n,responses:s,schemas:i});if(!e.orphans&&c.size){let{operationDependencies:e}=Ur({operations:c,resourceMetadata:n});Hr({operationDependencies:e,parameters:a,requestBodies:o,responses:s,schemas:i})}return r.timeEnd(),{operations:c,parameters:a,requestBodies:o,responses:s,schemas:i}},Gr=(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=fr(e),r=t[t.length-2],i=t[t.length-1];if(r&&i){let e=Er(r);e===`unknown`&&console.warn(`unsupported type: ${r}`),n.add(R(e,i))}}return n};for(let[t,n]of e.nodes){let e=fr(t);if(e[0]===`components`){if(e.length===3){if(e[1]===`schemas`){let a=e[e.length-1];r.schemas.set(R(`schema`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}else if(e[1]===`parameters`){let a=e[e.length-1];r.parameters.set(R(`parameter`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}else if(e[1]===`requestBodies`){let a=e[e.length-1];r.requestBodies.set(R(`body`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}else if(e[1]===`responses`){let a=e[e.length-1];r.responses.set(R(`response`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}}continue}if(e[0]===`paths`){if(e.length===3&&Cr.includes(e[2])){let a=e[e.length-1],o=k({method:a,path:e.slice(1,-1).join(`/`)});r.operations.set(R(`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(R(`schema`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}continue}}return n.timeEnd(),{resourceMetadata:r}},Kr=e=>JSON.parse(JSON.stringify(e)),qr=[[`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`]],Jr=e=>{if(Yr(e))return e.components.schemas;if(Xr(e))return e.definitions},Yr=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,Xr=e=>typeof e==`object`&&!!e&&`definitions`in e&&typeof e.definitions==`object`&&e.definitions!==null,Zr=(e,t)=>e instanceof Set?e.has(t):e instanceof Array?e.includes(t):t in e,Qr=({base:e,components:t,extraComponents:n})=>{let r=2,i=e;for(;Zr(t,i)||n&&Zr(n,i);)i=`${e}${r}`,r+=1;return i},$r=e=>e.length===3&&e[0]===`components`&&e[1]===`schemas`||e.length===2&&e[0]===`definitions`,ei=e=>{if(e&&typeof e==`object`){if(`swagger`in e)return`#/definitions/`;if(`openapi`in e)return`#/components/schemas/`}return``},ti=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})},ni=({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||qr.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)=>ni({key:a,node:t,parent:n,path:[...r,e,a],visitor:i})):ni({key:e,node:n,parent:t,path:[...r,e],visitor:i}))},ri=({spec:e})=>{let t=Jr(e);if(!t)return;let n=ei(e),r={};for(let[e,i]of Object.entries(t))ti(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,Kr(r[n])),delete e.$ref):i(n)};i(e);for(let e of Object.keys(r)){let n=fr(e),r=n[n.length-1];r&&delete t[r]}},ii=({config:e,spec:t})=>{let n=Jr(t);if(!n)return;let r={};for(let[e,t]of Object.entries(n)){let n=ti(t);n&&(r[n]=e)}let i=[];ni({key:null,node:t,parent:null,path:[],visitor:e=>{if(!$r(e.path)){let t=ti(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]=Qr({base:E({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=ei(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}`})}},ai=({config:e,spec:t})=>{if(e.mode===`inline`){ri({spec:t});return}if(e.mode===`root`){ii({config:e,spec:t});return}},oi=({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||qr.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)=>oi({key:a,node:t,parent:n,path:[...r,e,a],visitor:i})):oi({key:e,node:n,parent:t,path:[...r,e],visitor:i}))},si=({spec:e})=>{oi({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)}}})},ci=(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(!ci(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(!ci(r[e],i[e]))return!1;return!0};var li=ci;const ui=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))}},di=({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=di({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=di({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}},fi=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&&pi(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 qr){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&&pi(r,a)&&n(i,a)}if(a.parentPointer){let t=e.nodes.get(a.parentPointer);t&&pi(a,t)&&n(a.parentPointer,t)}}},pi=(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},mi=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`])))}},hi=(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=mr(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=pr(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);mi(r.nodes),fi(r),ui(r.nodes);for(let e of r.nodes.keys()){let t=di({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}},gi=new Set([`additionalProperties`,`allOf`,`anyOf`,`items`,`not`,`oneOf`,`patternProperties`,`properties`,`schema`]),_i=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`}},vi=(e,t)=>{let n=t.timeEvent(`capture-original-schemas`),r={};if(Yr(e))for(let[t,n]of Object.entries(e.components.schemas))r[`#/components/schemas/${t}`]=n;else if(Xr(e))for(let[t,n]of Object.entries(e.definitions))r[`#/definitions/${t}`]=n;return n.timeEnd(),r},yi=({logger:e,spec:t,split:n})=>{let r=e.timeEvent(`insert-split-schemas-into-spec`);Yr(t)?Object.assign(t.components.schemas,n.schemas):Xr(t)&&Object.assign(t.definitions,n.schemas),r.timeEnd()},bi=(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,!qr.some(([e])=>e in t)))return!0}for(let[r,i]of qr){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||bi(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||bi(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||bi(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||bi(e,r,n))&&a.splice(t,1)}a.length||delete t[r]}else typeof a==`object`&&a&&(a[n]===!0||bi(e,a,n))&&delete t[r]}if(t.type===`object`&&!qr.some(([e])=>e in t))return!0}return!1},xi=({logger:e,originalSchemas:t,spec:n,split:r})=>{let i=e.timeEvent(`remove-original-split-schemas`),a=Jr(n);for(let e of Object.keys(r.mapping)){let n=fr(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()},Si=({config:e,graph:t,logger:n,spec:r})=>{let i=n.timeEvent(`split-schemas`),a=new Set,o={mapping:{},reverseMapping:{},schemas:{}},s=ei(r),c=s.split(`/`).length-1,l=e=>{if(e.startsWith(s)){let t=fr(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=Kr(r.node);bi(t,c,`writeOnly`);let u=E({config:e.responses,name:i}),d=u===i?u:Qr({base:u,components:a});a.add(d),o.schemas[d]=c;let f=`${s}${d}`,p=Kr(r.node);if(bi(t,p,`readOnly`),li(c,p)&&li(c,r.node))continue;let m=E({config:e.requests,name:i}),h=m===i&&m!==d?m:Qr({base:m,components:a});a.add(h),o.schemas[h]=p;let g=`${s}${h}`;o.mapping[n]={read:f,write:g},o.reverseMapping[f]=n,o.reverseMapping[g]=n}return i.timeEnd(),o},Ci=({graph:e,logger:t,spec:n,split:r})=>{let i=t.timeEvent(`update-refs-in-spec`),a=ei(n),o=({context:t,currentPointer:n,inSchema:i,node:s,path:c,visited:l=new Set})=>{if(s instanceof Array)s.forEach((e,r)=>o({context:t,currentPointer:n,inSchema:i,node:e,path:[...c,r],visited:l}));else if(s&&typeof s==`object`){let u=n,d=t;if($r(c)){u=`${a}${c[c.length-1]}`;let t=r.reverseMapping[u];if(t){let e=r.mapping[t];e?.read===u?d=`read`:e?.write===u&&(d=`write`)}else{let t=e.nodes.get(u);if(t?.scopes){let e=t.scopes.has(`read`),n=t.scopes.has(`write`);n&&!e?d=`write`:e&&!n&&(d=`read`)}}}let f=_i(c);if(f!==void 0){for(let e in s)Object.prototype.hasOwnProperty.call(s,e)&&o({context:f,currentPointer:u,inSchema:!1,node:s[e],path:[...c,e],visited:l});return}for(let e in s){if(!Object.prototype.hasOwnProperty.call(s,e))continue;let t=s[e];if(!i){if(e===`requestBody`){o({context:`write`,currentPointer:u,inSchema:!1,node:t,path:[...c,e],visited:l});continue}if(e===`responses`){o({context:`read`,currentPointer:u,inSchema:!1,node:t,path:[...c,e],visited:l});continue}if(e===`parameters`&&Array.isArray(t)){t.forEach((t,n)=>{t&&typeof t==`object`&&`schema`in t&&o({context:`write`,currentPointer:u,inSchema:!0,node:t.schema,path:[...c,e,n,`schema`],visited:l}),t&&typeof t==`object`&&`content`in t&&o({context:`write`,currentPointer:u,inSchema:!1,node:t.content,path:[...c,e,n,`content`],visited:l})});continue}if(e===`headers`&&typeof t==`object`&&t){for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&o({context:`read`,currentPointer:u,inSchema:!1,node:t[n],path:[...c,e,n],visited:l});continue}}if(gi.has(e))o({context:d,currentPointer:u,inSchema:!0,node:t,path:[...c,e],visited:l});else if(e===`$ref`&&typeof t==`string`){let n=r.mapping[t];n&&(d===`read`&&n.read?s[e]=n.read:d===`write`&&n.write?s[e]=n.write:!d&&n.read&&(s[e]=n.read))}else o({context:d,currentPointer:u,inSchema:i,node:t,path:[...c,e],visited:l})}}};o({context:null,currentPointer:null,inSchema:!1,node:n,path:[]}),i.timeEnd()},wi=({config:e,logger:t,spec:n})=>{let{graph:r}=hi(n,t),i=vi(n,t),a=Si({config:e,graph:r,logger:t,spec:n});yi({logger:t,spec:n,split:a}),Ci({graph:r,logger:t,spec:n,split:a}),xi({logger:t,originalSchemas:i,spec:n,split:a})},Ti=({context:e})=>{let{logger:t}=e,n=t.timeEvent(`transform-openapi-spec`);e.config.parser.transforms.enums.enabled&&ai({config:e.config.parser.transforms.enums,spec:e.spec}),e.config.parser.transforms.propertiesRequiredByDefault&&si({spec:e.spec}),e.config.parser.transforms.readWrite.enabled&&wi({config:e.config.parser.transforms.readWrite,logger:t,spec:e.spec}),n.timeEnd()},B=({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},Ei=e=>/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e),Di=e=>e.map((e,t)=>typeof e==`number`?`[${e}]`:t===0?e:Ei(e)?`.${e}`:`['${e.replace(/"/g,`\\'`)}']`).join(``),Oi=e=>{let t=Di(e.path),n=e.severity===`error`?u.default.bold.red:u.default.bold.yellow,r=e.message.replace(/`([^`]+)`/g,(e,t)=>u.default.yellow(`\`${t}\``));return`${n(`[${e.severity.toUpperCase()}]`)} ${u.default.cyan(t)}: ${r}`},ki=({context:e,issue:t})=>e.config.logs.level===`silent`?!1:t.severity===`error`?e.config.logs.level!==`warn`:!0,Ai=({context:e,result:t})=>{for(let n of t.issues)ki({context:e,issue:n})&&console.log(Oi(n));t.valid||process.exit(1)},ji=({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(R(`schema`,t))&&(e[t]=n);else for(let t of r){let{name:n}=z(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 Cr){if(!r[e])continue;let i=R(`operation`,k({method:e,path:n}));t.has(i)||delete r[e]}Object.keys(r).length||delete i.paths[n]}a.timeEnd()},Mi=/^(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,Ni=/^application\/(.*\+)?json(;.*)?$/i,Pi=/^multipart\/form-data(;.*)?$/i,Fi=/^text\/[a-z0-9.+-]+(;.*)?$/i,Ii=/^application\/x-www-form-urlencoded(;.*)?$/i,Li=/^application\/octet-stream(;.*)?$/i,Ri=({mediaType:e})=>(Mi.lastIndex=0,Mi.test(e)),zi=({mediaType:e})=>{if(Ni.lastIndex=0,Ni.test(e))return`json`;if(Pi.lastIndex=0,Pi.test(e))return`form-data`;if(Fi.lastIndex=0,Fi.test(e))return`text`;if(Ii.lastIndex=0,Ii.test(e))return`url-search-params`;if(Li.lastIndex=0,Li.test(e))return`octet-stream`},Bi=({content:e})=>{let{mediaType:t,schema:n}=e;return n&&`$ref`in n?{allOf:[{...n}]}:n?n.type===`string`&&!n.format&&Ri({mediaType:t})?{...n,format:`binary`}:n:Ri({mediaType:t})?{format:`binary`,type:`string`}:void 0},Vi=({mimeTypes:e,response:t})=>{let n=[];for(let r of e??[])n.push({mediaType:r,schema:t.schema,type:zi({mediaType:r})});return n};function Hi(e){let t=`^(${e.keywords.join(`|`)})$`;return new RegExp(t)}const Ui=(e,t,n)=>{let r=[];for(let n in t)t[n]===e&&r.push(n);return!r.length&&(!n||n())?[L(e)]:r},Wi=({schema:e})=>{if(e.type)return e.type;if(e.properties)return`object`},Gi=({irSchema:e,schema:t})=>{t.example&&(e.example=t.example),t.description&&(e.description=t.description),t.title&&(e.title=t.title)},Ki=({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`)},qi=({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=oa({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=O({items:i,schema:t}),t},Ji=({irSchema:e={}})=>(e.type=`boolean`,e),Yi=({irSchema:e={},schema:t})=>(e.type=t.type,e),Xi=({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]=oa({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=oa({context:e,schema:n.additionalProperties,state:r}),n.required&&(t.required=n.required),t},Zi=({irSchema:e={}})=>(e.type=`string`,e),Qi=({schema:e})=>{let t={};return Gi({irSchema:t,schema:e}),t},$i=({context:e,schema:t,state:n})=>{let r=Qi({schema:t}),i=[],a=Wi({schema:t}),o=t.allOf;for(let r of o){let a=n.inAllOf;`$ref`in r||(n.inAllOf=!0);let o=oa({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=Ui(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=ia({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(Wi({schema:a})===`object`){let i=ia({context:e,schema:{...a,type:`object`},state:n});if(i.properties?.[t]){r.properties[t]=i.properties[t];break}}}i.push(r)}}if(r=O({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},ea=({context:e,schema:t,state:n})=>{let r=Qi({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=ia({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=O({items:i,schema:r}),r},ta=({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=oa({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,oa({context:e,schema:r,state:n}),n.$ref=i}return r},na=({context:e,irSchema:t,schema:n,state:r})=>{t||=Qi({schema:n});let i={};return Ki({irSchema:i,schema:n}),i.default===null&&delete i.default,t=O({items:[ia({context:e,irSchema:i,schema:n,state:r}),{type:`null`}],schema:t}),t},ra=({context:e,schema:t,state:n})=>{let r=Qi({schema:t});Ki({irSchema:r,schema:t});let i=Wi({schema:t});return i?t[`x-nullable`]?na({context:e,irSchema:r,schema:{...t,type:i},state:n}):ia({context:e,irSchema:r,schema:{...t,type:i},state:n}):r},ia=({context:e,irSchema:t,schema:n,state:r})=>{switch(t||(t=Qi({schema:n}),Ki({irSchema:t,schema:n})),n.type){case`array`:return qi({context:e,irSchema:t,schema:n,state:r});case`boolean`:return Ji({context:e,irSchema:t,schema:n,state:r});case`integer`:case`number`:return Yi({context:e,irSchema:t,schema:n,state:r});case`object`:return Xi({context:e,irSchema:t,schema:n,state:r});case`string`:return Zi({context:e,irSchema:t,schema:n,state:r});default:return aa({context:e,irSchema:t,schema:n})}},aa=({irSchema:e,schema:t})=>(e||=Qi({schema:t}),e.type=`unknown`,Ki({irSchema:e,schema:t}),e),oa=({context:e,schema:t,state:n})=>(n||={circularReferenceTracker:new Set},n.$ref&&n.circularReferenceTracker.add(n.$ref),t.$ref?ta({context:e,schema:t,state:n}):t.enum?ea({context:e,schema:t,state:n}):t.allOf?$i({context:e,schema:t,state:n}):t.type||t.properties?ra({context:e,schema:t,state:n}):aa({context:e,schema:t})),sa=({$ref:e,context:t,schema:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.schemas||(t.ir.components.schemas={}),t.ir.components.schemas[L(e)]=oa({context:t,schema:n,state:{$ref:e,circularReferenceTracker:new Set}})},ca=e=>e===`boolean`||e===`integer`||e===`number`||e===`string`,la=({context:e,name:t,schema:n})=>{if(Hi(e.config.parser.pagination).test(t))return!0;if(`$ref`in n){let r=e.resolveRef(n.$ref??``);return`in`in r&&r.in?la({context:e,name:t,schema:`schema`in r?r.schema:{...r,in:void 0}}):la({context:e,name:t,schema:r})}if(`in`in n)return n.in?la({context:e,name:t,schema:`schema`in n?n.schema:{...n,in:void 0}}):!1;for(let t in n.properties)if(Hi(e.config.parser.pagination).test(t)){let e=n.properties[t];if(typeof e!=`boolean`&&!(`$ref`in e)&&ca(Wi({schema:e})))return t}for(let r of n.allOf??[]){let n=la({context:e,name:t,schema:r});if(n)return n}return!1},ua=({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)},da=({context:e,method:t,operation:n,path:r,state:i})=>{let a={id:wr({context:e,id:n.operationId,method:t,path:r,state:i}),method:t,path:r};return n.operationId&&(a.operationId=n.operationId),ua({irOperation:a,operation:n}),a},fa=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{let o=da({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=[];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=Vi({mimeTypes:n.consumes,response:{schema:i}}),o=a.find(e=>e.type===`json`)||a[0];if(o){let t=la({context:e,name:``,schema:o.schema&&`$ref`in o.schema?{allOf:[{...o.schema}],description:r.description}:{description:r.description,...o.schema}}),n=oa({context:e,schema:`$ref`in r?{allOf:[{...r,$ref:r.$ref,required:[],type:`string`}],description:r.description}:o.schema&&`$ref`in o.schema?{allOf:[{...o.schema}],description:r.description}:{description:r.description,...o.schema},state:void 0});c.mediaType=o.mediaType,r.in===`body`?c.schema=n:(c.schema.properties[r.name]=n,r.required&&l.push(r.name)),t&&(c.pagination=t),o.type&&(c.type=o.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=Vi({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:oa({context:e,schema:{description:i.description,...Bi({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},pa=({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]=fa({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})},ma=e=>{switch(e){case`multi`:return!0;case`csv`:case`pipes`:case`ssv`:case`tsv`:default:return!1}},ha=e=>{switch(e){case`header`:case`path`:return`simple`;case`query`:default:return`form`}},ga=({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()]=_a({$ref:`#/todo/real/path/to/parameter/${n.name}`,context:e,parameter:n})}return r},_a=({$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=la({context:t,name:n.name,schema:i}),o=ha(n.in),s={allowReserved:!1,explode:ma(n.collectionFormat),location:n.in,name:n.name,schema:oa({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},va=/^(([^:/?#]+):)?((\/\/)?([^:/?#]*)(:?([^/?#]*)))?([^?#]*)(\?([^#]*))?(#(.*))?/,ya=e=>{let t={host:``,path:``,port:``,protocol:``};va.lastIndex=0;let n=e.match(va);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}},ba=({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=ya(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})))},xa=(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 Cr){if(t===`trace`)continue;let a=n[t];if(!a)continue;let o=k({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`)}},Sa=e=>{if(e.config.parser.validate_EXPERIMENTAL&&Ai({context:e,result:xa(e.spec,e.logger)}),Mr(e.config.parser.filters)){let t=jr(e.config.parser.filters,e.spec,e.logger),{graph:n}=hi(e.spec,e.logger),{resourceMetadata:r}=Gr(n,e.logger);ji({...Wr({filters:t,logger:e.logger,resourceMetadata:r}),logger:e.logger,preserveOrder:t.preserveOrder,spec:e.spec})}Ti({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];sa({$ref:n,context:e,schema:r})}for(let r in ba({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:ga({context:e,operation:o,parameters:a.parameters})},path:r,securitySchemesMap:n,state:t};if(a.delete){let t=B({source:ga({context:e,operation:a.delete,parameters:a.delete.parameters}),target:s.operation.parameters});pa({...s,method:`delete`,operation:{...s.operation,...a.delete,parameters:t}})}if(a.get){let t=B({source:ga({context:e,operation:a.get,parameters:a.get.parameters}),target:s.operation.parameters});pa({...s,method:`get`,operation:{...s.operation,...a.get,parameters:t}})}if(a.head){let t=B({source:ga({context:e,operation:a.head,parameters:a.head.parameters}),target:s.operation.parameters});pa({...s,method:`head`,operation:{...s.operation,...a.head,parameters:t}})}if(a.options){let t=B({source:ga({context:e,operation:a.options,parameters:a.options.parameters}),target:s.operation.parameters});pa({...s,method:`options`,operation:{...s.operation,...a.options,parameters:t}})}if(a.patch){let t=B({source:ga({context:e,operation:a.patch,parameters:a.patch.parameters}),target:s.operation.parameters});pa({...s,method:`patch`,operation:{...s.operation,...a.patch,parameters:t}})}if(a.post){let t=B({source:ga({context:e,operation:a.post,parameters:a.post.parameters}),target:s.operation.parameters});pa({...s,method:`post`,operation:{...s.operation,...a.post,parameters:t}})}if(a.put){let t=B({source:ga({context:e,operation:a.put,parameters:a.put.parameters}),target:s.operation.parameters});pa({...s,method:`put`,operation:{...s.operation,...a.put,parameters:t}})}}},Ca=({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(R(`parameter`,t))&&(e[t]=r);else for(let t of n){let{name:n}=z(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(R(`body`,t))&&(e[t]=n);else for(let t of i){let{name:n}=z(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(R(`response`,t))&&(e[t]=n);else for(let t of a){let{name:n}=z(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(R(`schema`,t))&&(e[t]=n);else for(let t of o){let{name:n}=z(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 Cr){if(!r[e])continue;let i=R(`operation`,k({method:e,path:n}));t.has(i)||delete r[e]}Object.keys(r).length||delete s.paths[n]}c.timeEnd()},wa=({content:e})=>{let{mediaType:t,schema:n}=e;return n&&`$ref`in n?{allOf:[{...n}]}:n?n.type===`string`&&!n.format&&Ri({mediaType:t})?{...n,format:`binary`}:n:Ri({mediaType:t})?{format:`binary`,type:`string`}:void 0},Ta=({content:e})=>{let t=[];for(let n in e)t.push({mediaType:n,schema:e[n].schema,type:zi({mediaType:n})});return t},Ea=({schema:e})=>{if(e.type)return e.type;if(e.properties)return`object`},Da=({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)},Oa=({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`)},ka=({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=V({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=O({items:i,schema:t}),t},Aa=({irSchema:e={}})=>(e.type=`boolean`,e),ja=({irSchema:e={},schema:t})=>(e.type=t.type,e),Ma=({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]=V({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=V({context:e,schema:n.additionalProperties,state:r}),n.required&&(t.required=n.required),t},Na=({irSchema:e={}})=>(e.type=`string`,e),Pa=({schema:e})=>{let t={};return Da({irSchema:t,schema:e}),t},Fa=({context:e,schema:t,state:n})=>{let r=Pa({schema:t}),i=[],a=Ea({schema:t}),o=t.allOf;for(let r of o){let a=n.inAllOf;`$ref`in r||(n.inAllOf=!0);let o=V({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=Ui(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=Ha({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(Ea({schema:a})===`object`){let i=Ha({context:e,schema:{...a,type:`object`},state:n});if(i.properties?.[t]){r.properties[t]=i.properties[t];break}}}i.push(r)}}if(r=O({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},Ia=({context:e,schema:t,state:n})=>{let r=Pa({schema:t}),i=[],a=Ea({schema:t}),o=t.anyOf;for(let r of o){let a=V({context:e,schema:r,state:n});if(t.discriminator&&a.$ref!=null){let e=Ui(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=O({items:i,mutateSchemaOneItem:!0,schema:r}),a===`object`){let i=Ha({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},La=({context:e,schema:t,state:n})=>{let r=Pa({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=Ha({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=O({items:i,schema:r}),r},Ra=({context:e,schema:t,state:n})=>{let r=Pa({schema:t}),i=[],a=Ea({schema:t}),o=t.oneOf;for(let r of o){let a=V({context:e,schema:r,state:n});if(t.discriminator&&a.$ref!=null){let e=Ui(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=O({items:i,mutateSchemaOneItem:!0,schema:r}),a===`object`){let i=Ha({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},za=({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=V({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,V({context:e,schema:r,state:n}),n.$ref=i}return r},Ba=({context:e,irSchema:t,schema:n,state:r})=>{t||=Pa({schema:n});let i={};return Oa({irSchema:i,schema:n}),i.default===null&&delete i.default,t=O({items:[Ha({context:e,irSchema:i,schema:n,state:r}),{type:`null`}],schema:t}),t},Va=({context:e,schema:t,state:n})=>{let r=Pa({schema:t});Oa({irSchema:r,schema:t});let i=Ea({schema:t});return i?t.nullable?Ba({context:e,irSchema:r,schema:{...t,type:i},state:n}):Ha({context:e,irSchema:r,schema:{...t,type:i},state:n}):r},Ha=({context:e,irSchema:t,schema:n,state:r})=>{switch(t||(t=Pa({schema:n}),Oa({irSchema:t,schema:n})),n.type){case`array`:return ka({context:e,irSchema:t,schema:n,state:r});case`boolean`:return Aa({context:e,irSchema:t,schema:n,state:r});case`integer`:case`number`:return ja({context:e,irSchema:t,schema:n,state:r});case`object`:return Ma({context:e,irSchema:t,schema:n,state:r});case`string`:return Na({context:e,irSchema:t,schema:n,state:r});default:return Ua({context:e,irSchema:t,schema:n})}},Ua=({irSchema:e,schema:t})=>(e||=Pa({schema:t}),e.type=`unknown`,Oa({irSchema:e,schema:t}),e),V=({context:e,schema:t,state:n})=>(n||={circularReferenceTracker:new Set},n.$ref&&n.circularReferenceTracker.add(n.$ref),`$ref`in t?za({context:e,schema:t,state:n}):t.enum?La({context:e,schema:t,state:n}):t.allOf?Fa({context:e,schema:t,state:n}):t.anyOf?Ia({context:e,schema:t,state:n}):t.oneOf?Ra({context:e,schema:t,state:n}):t.type||t.properties?Va({context:e,schema:t,state:n}):Ua({context:e,schema:t})),Wa=({$ref:e,context:t,schema:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.schemas||(t.ir.components.schemas={}),t.ir.components.schemas[L(e)]=V({context:t,schema:n,state:{$ref:e,circularReferenceTracker:new Set}})},Ga=e=>e===`boolean`||e===`integer`||e===`number`||e===`string`,Ka=({context:e,name:t,schema:n})=>{if(Hi(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=Ta({content:r.content}),t=e.find(e=>e.type===`json`)||e[0];t?.schema&&(n=t.schema)}return n?Ka({context:e,name:t,schema:n}):!1}return Ka({context:e,name:t,schema:r})}for(let t in n.properties)if(Hi(e.config.parser.pagination).test(t)){let e=n.properties[t];if(typeof e!=`boolean`&&!(`$ref`in e)&&Ga(Ea({schema:e})))return t}for(let r of n.allOf??[]){let n=Ka({context:e,name:t,schema:r});if(n)return n}return!1},qa=({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)},Ja=({context:e,method:t,operation:n,path:r,state:i})=>{let a={id:wr({context:e,id:n.operationId,method:t,path:r,state:i}),method:t,path:r};return n.operationId&&(a.operationId=n.operationId),qa({irOperation:a,operation:n}),a},Ya=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{let o=Ja({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=Ta({content:t.content}),i=r.find(e=>e.type===`json`)||r[0];if(i){let r=Ka({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:V({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=Ta({content:i.content}),s=a.find(e=>e.type===`json`)||a[0];s?o.responses[t]={mediaType:s.mediaType,schema:V({context:e,schema:{description:i.description,...wa({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},Xa=({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]=Ya({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})},Za=e=>{switch(e){case`query`:return!1;default:return}},Qa=e=>{switch(e){case`deepObject`:case`form`:return!0;default:return!1}},$a=e=>{switch(e){case`header`:case`path`:return`simple`;case`cookie`:case`query`:return`form`}},eo=({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()]=to({$ref:`#/todo/real/path/to/parameter/${t.name}`,context:e,parameter:t})}return n},to=({$ref:e,context:t,parameter:n})=>{let r=n.schema;if(!r){let e=Ta({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=Ka({context:t,name:n.name,schema:i}),o=n.style||$a(n.in),s=n.explode===void 0?Qa(o):n.explode,c={allowReserved:n.allowReserved===void 0?Za(n.in):n.allowReserved,explode:s,location:n.in,name:n.name,schema:V({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},no=({$ref:e,context:t,parameter:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.parameters||(t.ir.components.parameters={}),t.ir.components.parameters[L(e)]=to({$ref:e,context:t,parameter:n})},ro=({$ref:e,context:t,requestBody:n})=>{let r=Ta({content:n.content}),i=r.find(e=>e.type===`json`)||r[0],a=i?i.schema:void 0,o={schema:V({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},io=({$ref:e,context:t,requestBody:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.requestBodies||(t.ir.components.requestBodies={}),t.ir.components.requestBodies[L(e)]=ro({$ref:e,context:t,requestBody:n})},ao=({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=ya(t.path);e.ir.servers=[{url:`${n.protocol?`${n.protocol}://`:``}${n.host}${n.port?`:${n.port}`:``}`}]}e.ir.servers||(e.ir.servers=[{url:`/`}])},oo=(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 Cr){let a=n[t];if(!a)continue;let o=k({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`)}},so=e=>{if(e.config.parser.validate_EXPERIMENTAL&&Ai({context:e,result:oo(e.spec,e.logger)}),Mr(e.config.parser.filters)){let t=jr(e.config.parser.filters,e.spec,e.logger),{graph:n}=hi(e.spec,e.logger),{resourceMetadata:r}=Gr(n,e.logger);Ca({...Wr({filters:t,logger:e.logger,resourceMetadata:r}),logger:e.logger,preserveOrder:t.preserveOrder,spec:e.spec})}Ti({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];no({$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];io({$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];Wa({$ref:n,context:e,schema:r})}}for(let r in ao({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:eo({context:e,parameters:a.parameters}),security:e.spec.security,servers:a.servers,summary:a.summary},path:r,securitySchemesMap:n,state:t};a.delete&&Xa({...o,method:`delete`,operation:{...o.operation,...a.delete,parameters:B({source:eo({context:e,parameters:a.delete.parameters}),target:o.operation.parameters})}}),a.get&&Xa({...o,method:`get`,operation:{...o.operation,...a.get,parameters:B({source:eo({context:e,parameters:a.get.parameters}),target:o.operation.parameters})}}),a.head&&Xa({...o,method:`head`,operation:{...o.operation,...a.head,parameters:B({source:eo({context:e,parameters:a.head.parameters}),target:o.operation.parameters})}}),a.options&&Xa({...o,method:`options`,operation:{...o.operation,...a.options,parameters:B({source:eo({context:e,parameters:a.options.parameters}),target:o.operation.parameters})}}),a.patch&&Xa({...o,method:`patch`,operation:{...o.operation,...a.patch,parameters:B({source:eo({context:e,parameters:a.patch.parameters}),target:o.operation.parameters})}}),a.post&&Xa({...o,method:`post`,operation:{...o.operation,...a.post,parameters:B({source:eo({context:e,parameters:a.post.parameters}),target:o.operation.parameters})}}),a.put&&Xa({...o,method:`put`,operation:{...o.operation,...a.put,parameters:B({source:eo({context:e,parameters:a.put.parameters}),target:o.operation.parameters})}}),a.trace&&Xa({...o,method:`trace`,operation:{...o.operation,...a.trace,parameters:B({source:eo({context:e,parameters:a.trace.parameters}),target:o.operation.parameters})}})}},co=({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(R(`parameter`,t))&&(e[t]=r);else for(let t of n){let{name:n}=z(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(R(`body`,t))&&(e[t]=n);else for(let t of i){let{name:n}=z(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(R(`response`,t))&&(e[t]=n);else for(let t of a){let{name:n}=z(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(R(`schema`,t))&&(e[t]=n);else for(let t of o){let{name:n}=z(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 Cr){if(!r[e])continue;let i=R(`operation`,k({method:e,path:n}));t.has(i)||delete r[e]}Object.keys(r).length||delete s.paths[n]}c.timeEnd()},lo=({content:e})=>{let{mediaType:t,schema:n}=e;return n?n.type===`string`&&!n.format&&Ri({mediaType:t})?{...n,format:`binary`}:n:Ri({mediaType:t})?{format:`binary`,type:`string`}:void 0},uo=({content:e})=>{let t=[];for(let n in e)t.push({mediaType:n,schema:e[n].schema,type:zi({mediaType:n})});return t},fo=({schema:e})=>typeof e.type==`string`?[e.type]:e.type?e.type:e.properties?[`object`]:[],po=({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)},mo=({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`)},ho=({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=H({context:e,schema:t,state:r});i.push(n)}if(n.items){let a=H({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&&!fo({schema:n.items}).includes(`null`)?t={...t,...a}:i.push(a)}}return t=O({items:i,schema:t}),t},go=({irSchema:e={}})=>(e.type=`boolean`,e),_o=({irSchema:e={}})=>(e.type=`null`,e),vo=({irSchema:e={},schema:t})=>(e.type=t.type,e),yo=({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]=H({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=H({context:e,schema:n.additionalProperties,state:r}),n.patternProperties){let i={};for(let t in n.patternProperties){let a=n.patternProperties[t];i[t]=H({context:e,schema:a,state:r})}Object.keys(i).length&&(t.patternProperties=i)}return n.propertyNames&&(t.propertyNames=H({context:e,schema:n.propertyNames,state:r})),n.required&&(t.required=n.required),t},bo=({irSchema:e={}})=>(e.type=`string`,e),xo=({schema:e})=>{let t={};return po({irSchema:t,schema:e}),t},So=({context:e,schema:t,state:n})=>{let r=xo({schema:t}),i=[],a=fo({schema:t}),o=t.allOf;for(let r of o){let a=n.inAllOf;`$ref`in r||(n.inAllOf=!0);let o=H({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=Ui(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=Do({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(fo({schema:a}).includes(`object`)){let i=Do({context:e,schema:{...a,type:`object`},state:n});if(i.properties?.[t]){r.properties[t]=i.properties[t];break}}}i.push(r)}}if(r=O({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},Co=({context:e,schema:t,state:n})=>{let r=xo({schema:t}),i=[],a=fo({schema:t}),o=t.anyOf;for(let r of o){let a=H({context:e,schema:r,state:n});if(t.discriminator&&a.$ref!=null){let e=Ui(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=O({items:i,mutateSchemaOneItem:!0,schema:r}),a.includes(`object`)){let i=Do({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},wo=({context:e,schema:t,state:n})=>{let r=xo({schema:t});r.type=`enum`;let i=[],a=fo({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=Do({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=O({items:i,schema:r}),r},To=({context:e,schema:t,state:n})=>{let r=xo({schema:t}),i=[],a=fo({schema:t}),o=t.oneOf;for(let r of o){let a=H({context:e,schema:r,state:n});if(t.discriminator&&a.$ref!=null){let e=Ui(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=O({items:i,mutateSchemaOneItem:!0,schema:r}),a.includes(`object`)){let i=Do({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},Eo=({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=H({context:e,schema:r,state:n});return n.$ref=i,a}let r=xo({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,H({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=O({items:a,mutateSchemaOneItem:!0,schema:r}),r},Do=({context:e,irSchema:t,schema:n,state:r})=>{switch(t||(t=xo({schema:n}),mo({irSchema:t,schema:n})),n.type){case`array`:return ho({context:e,irSchema:t,schema:n,state:r});case`boolean`:return go({context:e,irSchema:t,schema:n});case`integer`:case`number`:return vo({context:e,irSchema:t,schema:n});case`null`:return _o({context:e,irSchema:t,schema:n});case`object`:return yo({context:e,irSchema:t,schema:n,state:r});case`string`:return bo({context:e,irSchema:t,schema:n});default:return Ao({context:e,irSchema:t,schema:n})}},Oo=({context:e,irSchema:t,schema:n,state:r})=>{t||=xo({schema:n});let i={};mo({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=Do({context:e,irSchema:{...i},schema:{...n,type:t},state:r});a.push(o)}return t=O({items:a,schema:t}),t},ko=({context:e,schema:t,state:n})=>{let r=xo({schema:t});mo({irSchema:r,schema:t});let i=fo({schema:t});return i.length===1?Do({context:e,irSchema:r,schema:{...t,type:i[0]},state:n}):Oo({context:e,irSchema:r,schema:{...t,type:i},state:n})},Ao=({irSchema:e,schema:t})=>(e||=xo({schema:t}),e.type=`unknown`,mo({irSchema:e,schema:t}),e),H=({context:e,schema:t,state:n})=>(n||={circularReferenceTracker:new Set},n.$ref&&n.circularReferenceTracker.add(n.$ref),t.$ref?Eo({context:e,schema:t,state:n}):t.enum?wo({context:e,schema:t,state:n}):t.allOf?So({context:e,schema:t,state:n}):t.anyOf?Co({context:e,schema:t,state:n}):t.oneOf?To({context:e,schema:t,state:n}):t.type||t.properties?ko({context:e,schema:t,state:n}):Ao({context:e,schema:t})),jo=({$ref:e,context:t,schema:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.schemas||(t.ir.components.schemas={}),t.ir.components.schemas[L(e)]=H({context:t,schema:n,state:{$ref:e,circularReferenceTracker:new Set}})},Mo=e=>e.includes(`boolean`)||e.includes(`integer`)||e.includes(`number`)||e.includes(`string`),No=({context:e,name:t,schema:n})=>{if(Hi(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=uo({content:r.content}),t=e.find(e=>e.type===`json`)||e[0];t?.schema&&(n=t.schema)}return n?No({context:e,name:t,schema:n}):!1}return No({context:e,name:t,schema:r})}for(let t in n.properties)if(Hi(e.config.parser.pagination).test(t)){let e=n.properties[t];if(typeof e!=`boolean`){let n=fo({schema:e});if(!n.length){let n=(e.anyOf??e.oneOf??[]).filter(e=>e.type!==`null`);if(n.length===1&&Mo(fo({schema:n[0]})))return t}if(Mo(n))return t}}for(let r of n.allOf??[]){let n=No({context:e,name:t,schema:r});if(n)return n}return!1},Po=({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)},Fo=({context:e,method:t,operation:n,path:r,state:i})=>{let a={id:wr({context:e,id:n.operationId,method:t,path:r,state:i}),method:t,path:r};return n.operationId&&(a.operationId=n.operationId),Po({irOperation:a,operation:n}),a},Io=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{let o=Fo({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=uo({content:t.content}),i=r.find(e=>e.type===`json`)||r[0];if(i){let r=No({context:e,name:``,schema:{description:t.description,...i.schema}});o.body={mediaType:i.mediaType,schema:H({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=uo({content:i.content}),s=a.find(e=>e.type===`json`)||a[0];s?o.responses[t]={mediaType:s.mediaType,schema:H({context:e,schema:{description:i.description,...lo({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},Lo=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>(n.servers&&(e.ir.servers=[...e.ir.servers??[],...n.servers]),{parsed:Io({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})}),Ro=({context:e,method:t,path:n,...r})=>{e.ir.paths||(e.ir.paths={}),e.ir.paths[n]||(e.ir.paths[n]={});let{parsed:i}=Lo({context:e,method:t,path:n,...r});e.ir.paths[n][t]=i},zo=({context:e,key:t,method:n,...r})=>{e.ir.webhooks||(e.ir.webhooks={}),e.ir.webhooks[t]||(e.ir.webhooks[t]={});let{parsed:i}=Lo({context:e,method:n,path:t,...r});e.ir.webhooks[t][n]=i},Bo=e=>{switch(e){case`query`:return!1;default:return}},Vo=e=>{switch(e){case`deepObject`:case`form`:return!0;default:return!1}},Ho=e=>{switch(e){case`header`:case`path`:return`simple`;case`cookie`:case`query`:return`form`}},U=({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()]=Uo({$ref:`#/todo/real/path/to/parameter/${t.name}`,context:e,parameter:t})}return n},Uo=({$ref:e,context:t,parameter:n})=>{let r=n.schema;if(!r){let e=uo({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=No({context:t,name:n.name,schema:i}),o=n.style||Ho(n.in),s=n.explode===void 0?Vo(o):n.explode,c={allowReserved:n.allowReserved===void 0?Bo(n.in):n.allowReserved,explode:s,location:n.in,name:n.name,schema:H({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},Wo=({$ref:e,context:t,parameter:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.parameters||(t.ir.components.parameters={}),t.ir.components.parameters[L(e)]=Uo({$ref:e,context:t,parameter:n})},Go=({$ref:e,context:t,requestBody:n})=>{let r=uo({content:n.content}),i=r.find(e=>e.type===`json`)||r[0],a=i?i.schema:void 0,o={schema:H({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},Ko=({$ref:e,context:t,requestBody:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.requestBodies||(t.ir.components.requestBodies={}),t.ir.components.requestBodies[L(e)]=Go({$ref:e,context:t,requestBody:n})},qo=({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=ya(t.path);e.ir.servers=[{url:`${n.protocol?`${n.protocol}://`:``}${n.host}${n.port?`:${n.port}`:``}`}]}e.ir.servers||(e.ir.servers=[{url:`/`}])},Jo=(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 Cr){let a=n[t];if(!a)continue;let o=k({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`)}},Yo=({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:U({context:e,parameters:a.parameters}),security:e.spec.security,servers:a.servers,summary:a.summary},securitySchemesMap:t,state:n};a.delete&&zo({...o,method:`delete`,operation:{...o.operation,...a.delete,parameters:B({source:U({context:e,parameters:a.delete.parameters}),target:o.operation.parameters})}}),a.get&&zo({...o,method:`get`,operation:{...o.operation,...a.get,parameters:B({source:U({context:e,parameters:a.get.parameters}),target:o.operation.parameters})}}),a.head&&zo({...o,method:`head`,operation:{...o.operation,...a.head,parameters:B({source:U({context:e,parameters:a.head.parameters}),target:o.operation.parameters})}}),a.options&&zo({...o,method:`options`,operation:{...o.operation,...a.options,parameters:B({source:U({context:e,parameters:a.options.parameters}),target:o.operation.parameters})}}),a.patch&&zo({...o,method:`patch`,operation:{...o.operation,...a.patch,parameters:B({source:U({context:e,parameters:a.patch.parameters}),target:o.operation.parameters})}}),a.post&&zo({...o,method:`post`,operation:{...o.operation,...a.post,parameters:B({source:U({context:e,parameters:a.post.parameters}),target:o.operation.parameters})}}),a.put&&zo({...o,method:`put`,operation:{...o.operation,...a.put,parameters:B({source:U({context:e,parameters:a.put.parameters}),target:o.operation.parameters})}}),a.trace&&zo({...o,method:`trace`,operation:{...o.operation,...a.trace,parameters:B({source:U({context:e,parameters:a.trace.parameters}),target:o.operation.parameters})}})}},Xo=e=>{if(e.config.parser.validate_EXPERIMENTAL&&Ai({context:e,result:Jo(e.spec,e.logger)}),Mr(e.config.parser.filters)){let t=jr(e.config.parser.filters,e.spec,e.logger),{graph:n}=hi(e.spec,e.logger),{resourceMetadata:r}=Gr(n,e.logger);co({...Wr({filters:t,logger:e.logger,resourceMetadata:r}),logger:e.logger,preserveOrder:t.preserveOrder,spec:e.spec})}Ti({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];Wo({$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];Ko({$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];jo({$ref:n,context:e,schema:r})}}for(let r in qo({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:U({context:e,parameters:a.parameters}),security:e.spec.security,servers:a.servers,summary:a.summary},path:r,securitySchemesMap:n,state:t};a.delete&&Ro({...o,method:`delete`,operation:{...o.operation,...a.delete,parameters:B({source:U({context:e,parameters:a.delete.parameters}),target:o.operation.parameters})}}),a.get&&Ro({...o,method:`get`,operation:{...o.operation,...a.get,parameters:B({source:U({context:e,parameters:a.get.parameters}),target:o.operation.parameters})}}),a.head&&Ro({...o,method:`head`,operation:{...o.operation,...a.head,parameters:B({source:U({context:e,parameters:a.head.parameters}),target:o.operation.parameters})}}),a.options&&Ro({...o,method:`options`,operation:{...o.operation,...a.options,parameters:B({source:U({context:e,parameters:a.options.parameters}),target:o.operation.parameters})}}),a.patch&&Ro({...o,method:`patch`,operation:{...o.operation,...a.patch,parameters:B({source:U({context:e,parameters:a.patch.parameters}),target:o.operation.parameters})}}),a.post&&Ro({...o,method:`post`,operation:{...o.operation,...a.post,parameters:B({source:U({context:e,parameters:a.post.parameters}),target:o.operation.parameters})}}),a.put&&Ro({...o,method:`put`,operation:{...o.operation,...a.put,parameters:B({source:U({context:e,parameters:a.put.parameters}),target:o.operation.parameters})}}),a.trace&&Ro({...o,method:`trace`,operation:{...o.operation,...a.trace,parameters:B({source:U({context:e,parameters:a.trace.parameters}),target:o.operation.parameters})}})}Yo({context:e,securitySchemesMap:n})},Zo=[`connect`,`delete`,`get`,`head`,`options`,`patch`,`post`,`put`,`trace`];function Qo(e=`1.0`){return String(e).replace(/^v/gi,``)}const $o=(e,t)=>{if(e.enum&&!t.includes(`boolean`))return`enum`},es=e=>ns(e).includes(`null`),ts=e=>e.nullable===!0||es(e),ns=({type:e})=>Array.isArray(e)?e:e?[e]:[],rs=`#/components/parameters/`,is=`#/components/schemas/`,as=({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},os=e=>x().plugins[`@hey-api/typescript`]?.config.style===`PascalCase`?T({case:`PascalCase`,value:e}):e,ss=e=>br(os(e)).replace(gt,`_$1`),cs=e=>e.trim().replace(/^#\/definitions\//,``).replace(/^#\/parameters\//,``).replace(/^#\/responses\//,``).replace(/^#\/securityDefinitions\//,``).replace(/^#\/components\/schemas\//,``).replace(/^#\/components\/responses\//,``).replace(/^#\/components\/parameters\//,``).replace(/^#\/components\/examples\//,``).replace(/^#\/components\/requestBodies\//,``).replace(/^#\/components\/headers\//,``).replace(/^#\/components\/securitySchemes\//,``).replace(/^#\/components\/links\//,``).replace(/^#\/components\/callbacks\//,``),ls=(e,t)=>{if(t===`binary`)return`binary`;switch(e){case`any`:case`object`:case`unknown`:return`unknown`;case`array`:return`unknown[]`;case`boolean`:return`boolean`;case`byte`:case`double`:case`float`:case`int`:case`integer`:case`long`:case`number`:case`short`:return`number`;case`char`:case`date`:case`date-time`:case`password`:case`string`:return`string`;case`file`:return`binary`;case`null`:return`null`;case`void`:return`void`;default:return}},us=/(?<!`1)\[.*\]$/g,W=({debug:e,format:t,type:n=`unknown`})=>{let r={$refs:[],base:`unknown`,imports:[],isNullable:!1,template:null,type:`unknown`};if(Array.isArray(n)){let e=n.filter(e=>e!==`null`).map(e=>ls(e,t)).filter(Boolean).join(` | `);return r.type=e,r.base=e,r.isNullable=es({type:n}),r}let i=ls(n,t);if(i)return r.type=i,r.base=i,r;let a=decodeURIComponent(cs(n));if(us.lastIndex=0,us.test(a)){let t=a.match(/(.*?)\[(.*)\]$/);if(t?.length){let n=W({debug:e,type:br(t[1])}),i=W({debug:e,type:br(t[2])});return n.type===`unknown[]`?(r.type=`${i.type}[]`,r.base=`${i.type}`,n.$refs=[],n.imports=[]):i.type?(r.type=`${n.type}<${i.type}>`,r.base=n.type,r.template=i.type):(r.type=n.type,r.base=n.type,r.template=n.type),r.$refs=[...r.$refs,...n.$refs,...i.$refs],r.imports=[...r.imports,...n.imports,...i.imports],r}}if(a){let e=os(br(a));return n.startsWith(rs)&&(e=`Parameter${e}`),r.type=e,r.base=e,n.startsWith(`#`)&&(r.$refs=[...r.$refs,decodeURIComponent(n)]),r.imports=[...r.imports,e],r}return r};function ds(e,t,n){return n.indexOf(e)===t}const fs=(e,t)=>{if(!Array.isArray(t))return[];let n=(e[`x-enum-descriptions`]??[]).filter(e=>typeof e==`string`),r=(e[`x-enum-varnames`]??e[`x-enumNames`]??[]).filter(e=>typeof e==`string`);return t.filter(ds).filter(e=>typeof e==`number`||typeof e==`string`).map((e,t)=>({customDescription:n[t],customName:r[t],description:void 0,value:e}))},ps=e=>e?.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`),ms=({definition:e,getModel:t,openApi:n,types:r})=>{let i=[];return Object.entries(e.properties??{}).forEach(([a,o])=>{let s=!!e.required?.includes(a);if(o.$ref){let e=W({type:o.$ref});i.push({$refs:[],base:e.base,description:o.description||null,enum:[],enums:[],exclusiveMaximum:o.exclusiveMaximum,exclusiveMinimum:o.exclusiveMinimum,export:`reference`,format:o.format,imports:e.imports,in:``,isDefinition:!1,isNullable:o[`x-nullable`]===!0,isReadOnly:o.readOnly===!0,isRequired:s,link:null,maxItems:o.maxItems,maxLength:o.maxLength,maxProperties:o.maxProperties,maximum:o.maximum,minItems:o.minItems,minLength:o.minLength,minProperties:o.minProperties,minimum:o.minimum,multipleOf:o.multipleOf,name:St(a),pattern:ps(o.pattern),properties:[],template:e.template,type:e.type,uniqueItems:o.uniqueItems})}else{let e=t({definition:o,openApi:n,types:r});i.push({$refs:[],base:e.base,description:o.description||null,enum:e.enum,enums:e.enums,exclusiveMaximum:o.exclusiveMaximum,exclusiveMinimum:o.exclusiveMinimum,export:e.export,format:o.format,imports:e.imports,in:``,isDefinition:!1,isNullable:o[`x-nullable`]===!0,isReadOnly:o.readOnly===!0,isRequired:s,link:e.link,maxItems:o.maxItems,maxLength:o.maxLength,maxProperties:o.maxProperties,maximum:o.maximum,minItems:o.minItems,minLength:o.minLength,minProperties:o.minProperties,minimum:o.minimum,multipleOf:o.multipleOf,name:St(a),pattern:ps(o.pattern),properties:e.properties,template:e.template,type:e.type,uniqueItems:o.uniqueItems})}}),i},hs=/~1/g,gs=/~0/g;function _s(e,t){if(t.$ref){let n=t.$ref.replace(/^#/g,``).split(`/`).filter(Boolean),r=e;return n.forEach(e=>{let n=decodeURIComponent(e.replace(hs,`/`).replace(gs,`~`));if(r.hasOwnProperty(n))r=r[n];else throw Error(`Could not find reference: "${t.$ref}"`)}),r}return t}const vs=({definitions:e,getModel:t,openApi:n,required:r,types:i})=>e.reduce((e,r)=>{if(r.$ref){let a=_s(n,r);return[...e,...t({definition:a,openApi:n,types:i}).properties]}return[...e,...t({definition:r,openApi:n,types:i}).properties]},[]).filter(e=>!e.isRequired&&r.includes(e.name)).map(e=>({...e,isRequired:!0})),ys=({definition:e,definitions:t,getModel:n,openApi:r,type:i,types:a})=>{let o={$refs:[],enums:[],export:i,imports:[],properties:[]},s=[];if(t.map(e=>n({definition:e,openApi:r,types:a})).filter(e=>{let t=e.properties.length,n=e.enums.length;return!(e.type===`unknown`&&!t&&!n)}).forEach(e=>{o.imports.push(...e.imports),o.enums.push(...e.enums),o.properties.push(e)}),e.required&&i===`all-of`){let i=vs({definitions:t,getModel:n,openApi:r,required:e.required,types:a});i.forEach(e=>{o.imports.push(...e.imports),o.enums.push(...e.enums)}),s.push(...i)}if(e.properties){let t=ms({definition:e,getModel:n,openApi:r,types:a});t.forEach(e=>{o.imports.push(...e.imports),o.enums.push(...e.enums),e.export===`enum`&&o.enums.push(e)}),s.push(...t)}return s.length&&o.properties.push({$refs:[],base:`unknown`,description:``,enum:[],enums:[],export:`interface`,imports:[],in:``,isDefinition:!1,isNullable:!1,isReadOnly:!1,isRequired:!1,link:null,name:`properties`,properties:s,template:null,type:`unknown`}),o},bs=({definition:e,isDefinition:t=!1,meta:n,openApi:r,types:i})=>{let a={$refs:[],base:`unknown`,description:e.description||null,enum:[],enums:[],exclusiveMaximum:e.exclusiveMaximum,exclusiveMinimum:e.exclusiveMinimum,export:`interface`,format:e.format,imports:[],in:``,isDefinition:t,isNullable:e[`x-nullable`]===!0,isReadOnly:e.readOnly===!0,isRequired:!1,link:null,maxItems:e.maxItems,maxLength:e.maxLength,maxProperties:e.maxProperties,maximum:e.maximum,meta:n,minItems:e.minItems,minLength:e.minLength,minProperties:e.minProperties,minimum:e.minimum,multipleOf:e.multipleOf,name:n?.name??``,pattern:ps(e.pattern),properties:[],template:null,type:`unknown`,uniqueItems:e.uniqueItems};if(e.$ref){let t=W({type:e.$ref});return a.export=`reference`,a.type=t.type,a.base=t.base,a.template=t.template,a.imports.push(...t.imports),a}if(e.enum&&e.type!==`boolean`){let t=fs(e,e.enum);if(t.length)return a.base=`string`,a.enum=[...a.enum,...t],a.export=`enum`,a.type=`string`,a}if(e.type===`array`&&e.items)if(e.items.$ref){let t=W({type:e.items.$ref});return a.export=`array`,a.type=t.type,a.base=t.base,a.template=t.template,a.imports.push(...t.imports),a}else{let t=bs({definition:e.items,openApi:r,types:i});return a.export=`array`,a.type=t.type,a.base=t.base,a.template=t.template,a.link=t,a.imports.push(...t.imports),a}if(e.type===`object`&&typeof e.additionalProperties==`object`)if(e.additionalProperties.$ref){let t=W({type:e.additionalProperties.$ref});return a.export=`dictionary`,a.type=t.type,a.base=t.base,a.template=t.template,a.imports.push(...t.imports),a}else{let t=bs({definition:e.additionalProperties,openApi:r,types:i});return a.export=`dictionary`,a.type=t.type,a.base=t.base,a.template=t.template,a.link=t,a.imports.push(...t.imports),a}if(e.allOf?.length){let t=ys({definition:e,definitions:e.allOf,getModel:bs,openApi:r,type:`all-of`,types:i});return a.export=t.export,a.imports.push(...t.imports),a.properties.push(...t.properties),a.enums=[...a.enums,...t.enums],a}if(e.type===`object`)return a.export=`interface`,a.type=`unknown`,a.base=`unknown`,e.properties&&ms({definition:e,getModel:bs,openApi:r,types:i}).forEach(e=>{a.imports.push(...e.imports),a.enums=[...a.enums,...e.enums],a.properties.push(e),e.export===`enum`&&(a.enums=[...a.enums,e])}),a;if(e.type){let t=W({format:e.format,type:e.type});return a.export=`generic`,a.type=t.type,a.base=t.base,a.template=t.template,a.imports.push(...t.imports),a}return a},xs=e=>{let t={},n=[];return Object.entries(e.definitions??{}).forEach(([r,i])=>{let a=W({type:r}).base.replace(gt,`_$1`),o={$ref:`#/definitions/${r}`,name:a};t[a]=o;let s=bs({definition:i,isDefinition:!0,meta:o,openApi:e,types:t});n=[...n,s]}),{models:n,types:t}};function Ss(e,t){let n=e.toLocaleLowerCase(),r=t.toLocaleLowerCase();return n.localeCompare(r,`en`)}const Cs=(e,t)=>Ss(e.name,t.name);function ws(e){return e.sort(Cs)}const Ts=(e,t)=>{if(t)return t;if(typeof e==`number`)return`'_${e}'`;let n=``;return typeof e==`string`&&(n=e.replace(/[^$\u200c\u200d\p{ID_Continue}]/gu,`_`).replace(/^([^$_\p{ID_Start}])/u,`_$1`).replace(/(\p{Lowercase})(\p{Uppercase}+)/gu,`$1_$2`)),n=n.trim(),n||=`empty_string`,n.toUpperCase()},Es=e=>e.map(e=>Ds(e.value,!0)).filter(ds).join(` | `),Ds=(e,t=!1)=>typeof e==`string`?e.includes(`'`)&&t?`"${e}"`:`'${e}'`:e,Os=e=>({key:Ts(e.value,e.customName),value:Ds(e.value)}),ks=e=>{let t=e.enum.map(e=>Os(e)).sort((e,t)=>Ss(e.key,t.key)).map(e=>`${e.key}=${e.value}`).join(`&`);return{$ref:`enum/${e.name}/${t}`,name:br(Ct(e.name))}},As=e=>{let t=`Parameter${W({type:e}).base.replace(gt,`_$1`)}`;return{$ref:rs+e,name:t}},js=e=>{let t=ss(e);return{$ref:is+e,name:t}},Ms=e=>e.format===`date`||e.format===`date-time`,Ns=e=>{let t=x();return e.base===`binary`?I.typeUnionNode({types:[`Blob`,`File`]}):t.plugins[`@hey-api/transformers`]?.config.dates&&Ms(e)?I.typeNode(`Date`):I.typeNode(e.base)},Ps=e=>{let t=e.base===`null`?!1:e.isNullable,n=Ns(e);if(e.export===`reference`&&e.$refs.length===1&&e.$refs[0].startsWith(is)){let t=js(e.base);n=I.typeNode(t.name)}return I.typeUnionNode({isNullable:t,types:[n]})},Fs=e=>{if(e.link){if(Array.isArray(e.link)){let t=e.link.map(e=>Bs(e));return I.typeTupleNode({isNullable:e.isNullable,types:t})}if(e.export===`array`&&e.maxItems&&e.minItems&&e.maxItems===e.minItems&&e.maxItems<=100){let t=Array(e.maxItems).fill(Bs(e.link));return I.typeTupleNode({isNullable:e.isNullable,types:t})}return I.typeArrayNode([Bs(e.link)],e.isNullable)}return I.typeArrayNode([Ns(e)],e.isNullable)},Is=e=>{let t=e.enum.map(e=>Ds(e.value));return I.typeUnionNode({isNullable:e.isNullable,types:t})},Ls=e=>{let t=e.link&&!Array.isArray(e.link)?Bs(e.link):Ns(e);return I.typeRecordNode([`string`],[t],e.isNullable,!0)},Rs=({model:e,style:t})=>{let n=e.properties.map(e=>I.nodeToString({node:Bs(e),unescape:!0})).filter(ds),r=t===`union`?I.typeUnionNode({isNullable:e.isNullable&&!e.properties.find(e=>e.isNullable),types:n}):I.typeIntersectionNode({isNullable:e.isNullable,types:n});return e.meta?r:I.typeParenthesizedNode({type:r})},zs=e=>{if(!e.properties.length)return I.typeNode(`unknown`);let t=S(x()),n=e.properties.map(e=>{let n=e.isRequired?``:`?`,r=Bs(e),i=t?/^\dXX$/.test(e.name)?St(e.name):e.name:St(Ct(Us(e.name)));return e.name===`[key: string]`&&(i=e.name,n&&(n=``,r=I.typeUnionNode({types:[r,`undefined`]}))),{comment:[e.description&&j(e.description),e.deprecated&&`@deprecated`],isReadOnly:e.isReadOnly,isRequired:n===``,name:i,type:r}});return I.typeInterfaceNode({isNullable:e.isNullable,properties:n,useLegacyResolution:!0})},Bs=e=>{switch(e.export){case`all-of`:return Rs({model:e,style:`intersection`});case`any-of`:case`one-of`:return Rs({model:e,style:`union`});case`array`:return Fs(e);case`dictionary`:return Ls(e);case`enum`:return Is(e);case`interface`:return zs(e);case`const`:case`generic`:case`reference`:default:return Ps(e)}},Vs=({client:e,count:t=1,create:n=!1,meta:r,nameTransformer:i})=>{let a={created:!1,name:``},o=r.name;i&&(o=i(o)),t>1&&(o=`${o}${t}`);let s=e.types[o];return s?a=s.$ref===r.$ref?{created:!1,name:o}:Vs({client:e,count:t+1,create:n,meta:r,nameTransformer:i}):n&&(e.types[o]=r,a={created:!0,name:o}),a},Hs=({client:e,name:t})=>{let n={deleted:!1,name:``};return e.types[t]?(delete e.types[t],n={deleted:!0,name:t},n):n},Us=e=>S(x())?T({case:`camelCase`,value:Sr(e)}).replace(gt,`_$1`):e,Ws=e=>{let t=e.find(e=>e.in===`header`);return t?t.name:null},Gs=e=>e.some(e=>e.isRequired),Ks=e=>{if(e===`default`)return`default`;if(e===`1XX`)return`1XX`;if(e===`2XX`)return`2XX`;if(e===`3XX`)return`3XX`;if(e===`4XX`)return`4XX`;if(e===`5XX`)return`5XX`;if(/\d{3}/g.test(e)){let t=Number.parseInt(e,10);if(t>=100&&t<600)return t}return null},qs=(e,t)=>e.code>t.code?1:e.code<t.code?-1:0,Js=e=>e===`3XX`||e===`4XX`||e===`5XX`||typeof e==`number`&&e>=300,Ys=e=>e===`2XX`||typeof e==`number`&&e>=200&&e<300,Xs=(e,t)=>{let n=[],r=e=>{n.includes(e)||(n=[...n,e])};t.some(({code:e})=>Ys(e))||r(`success`);let i=(e.description??``).toLocaleLowerCase(),a=e.$refs.join(`|`).toLocaleLowerCase();return[`success`].some(e=>i.includes(e)||a.includes(e))&&r(`success`),[`error`,`problem`].some(e=>i.includes(e)||a.includes(e))&&r(`error`),n.length||r(`error`),n},Zs=({config:e,operationKey:t})=>{let n=e.plugins[`@hey-api/sdk`]?.config.filter?new RegExp(e.plugins[`@hey-api/sdk`]?.config.filter):void 0;return!n||n.test(t)},Qs=({config:e,method:t,operationId:n,path:r})=>{if(e.plugins[`@hey-api/sdk`]?.config.operationId&&n)return T({case:`camelCase`,value:xr(n)});let i=r;return S(e)&&(i=i.replace(/[^/]*?{api-version}.*?\//g,``)),i=i.replace(/{(.*?)}/g,`by-$1`).replace(/[/:+]/g,`-`),T({case:`camelCase`,value:`${t}-${i}`})},$s=e=>!S(x())||e.prop!==`api-version`,ec=e=>S(x())?Us(e.prop):e.prop,tc=e=>e.map(t=>{let{code:n}=t;return n===`default`?t.responseTypes=Xs(t,e):Ys(n)?t.responseTypes=[`success`]:Js(n)&&(t.responseTypes=[`error`]),t}),G=(e,t)=>{if(e.default===void 0||e.default===null)return e.default;switch(ns(e).find(e=>e!==`null`)||typeof e.default){case`int`:case`integer`:case`number`:if(t?.export===`enum`&&t.enum?.[e.default]){let{value:n}=t.enum[e.default];return n}return e.default;case`array`:case`boolean`:case`object`:case`string`:return e.default;default:return}},nc=({openApi:e,parameter:t,types:n})=>{let r={$refs:[],base:`unknown`,description:t.description||null,enum:[],enums:[],exclusiveMaximum:t.exclusiveMaximum,exclusiveMinimum:t.exclusiveMinimum,export:`interface`,format:t.format,imports:[],in:t.in,isDefinition:!1,isNullable:t[`x-nullable`]===!0,isReadOnly:!1,isRequired:t.required===!0,link:null,maxItems:t.maxItems,maxLength:t.maxLength,maximum:t.maximum,mediaType:null,minItems:t.minItems,minLength:t.minLength,minimum:t.minimum,multipleOf:t.multipleOf,pattern:ps(t.pattern),prop:t.name,properties:[],template:null,type:`unknown`,uniqueItems:t.uniqueItems},i={...r,name:ec(r)};if(t.$ref){let e=W({type:t.$ref});return i={...i,$refs:[...i.$refs,...e.$refs],base:e.base,export:`reference`,imports:[...i.imports,...e.imports],template:e.template,type:e.type},i.default=G(t,i),i}if(t.enum){let e=fs(t,t.enum);if(e.length)return i={...i,base:`string`,enum:[...i.enum,...e],export:`enum`,type:`string`},i.default=G(t,i),i}if(t.type===`array`&&t.items){let e=W({format:t.items.format,type:t.items.type});return i={...i,$refs:[...i.$refs,...e.$refs],base:e.base,export:`array`,imports:[...i.imports,...e.imports],template:e.template,type:e.type},i.default=G(t,i),i}if(t.type===`object`&&t.items){let e=W({format:t.items.format,type:t.items.type});return i={...i,$refs:[...i.$refs,...e.$refs],base:e.base,export:`dictionary`,imports:[...i.imports,...e.imports],template:e.template,type:e.type},i.default=G(t,i),i}let a=t.schema;if(a){if(a.$ref?.startsWith(`#/parameters/`)&&(a=_s(e,a)),a.$ref){let e=W({type:a.$ref});return i={...i,$refs:[...i.$refs,...e.$refs],base:e.base,export:`reference`,imports:[...i.imports,...e.imports],template:e.template,type:e.type},i.default=G(t,i),i}let r=bs({definition:a,openApi:e,types:n});return i={...i,$refs:[...i.$refs,...r.$refs],base:r.base,enum:[...i.enum,...r.enum],enums:[...i.enums,...r.enums],export:r.export,imports:[...i.imports,...r.imports],link:r.link,properties:[...i.properties,...r.properties],template:r.template,type:r.type},i.default=G(t,i),i}if(t.type){let e=W({format:t.format,type:t.type});return i={...i,$refs:[...i.$refs,...e.$refs],base:e.base,export:`generic`,imports:[...i.imports,...e.imports],template:e.template,type:e.type},i.default=G(t,i),i}return i},rc=[`body`,`formData`,`header`,`path`,`query`],ic=({openApi:e,parameters:t,types:n})=>{let r={$refs:[],imports:[],parameters:[],parametersBody:null,parametersCookie:[],parametersForm:[],parametersHeader:[],parametersPath:[],parametersQuery:[]};return t.forEach(t=>{let i=_s(e,t),a=nc({openApi:e,parameter:i,types:n}),o=!$s(a);if(!(!rc.includes(i.in)||o)){switch(i.in){case`body`:r.parametersBody=a;break;case`formData`:r.parametersForm=[...r.parametersForm,a];break;case`header`:r.parametersHeader=[...r.parametersHeader,a];break;case`path`:r.parametersPath=[...r.parametersPath,a];break;case`query`:r.parametersQuery=[...r.parametersQuery,a];break}r.$refs=[...r.$refs,...a.$refs],r.imports=[...r.imports,...a.imports],r.parameters=[...r.parameters,a]}}),r};function ac(e){return e.sort((e,t)=>{let n=e.isRequired&&e.default===void 0,r=t.isRequired&&t.default===void 0;return n&&!r?-1:r&&!n?1:0})}const oc=({code:e,openApi:t,response:n,types:r})=>{let i={$refs:[],base:e===204?`void`:`unknown`,code:e,description:n.description||null,enum:[],enums:[],export:`generic`,imports:[],in:`response`,isDefinition:!1,isNullable:!1,isReadOnly:!1,isRequired:!1,link:null,name:``,properties:[],responseTypes:[],template:null,type:e===204?`void`:`unknown`},a=n.schema;if(a){if(a.$ref?.startsWith(`#/responses/`)&&(a=_s(t,a)),a.$ref){let e=W({type:a.$ref});return i.export=`reference`,i.type=e.type,i.base=e.base,i.template=e.template,i.imports=[...i.imports,...e.imports],i}let e=bs({definition:a,openApi:t,types:r});return i.export=e.export,i.type=e.type,i.base=e.base,i.template=e.template,i.link=e.link,i.isReadOnly=e.isReadOnly,i.isRequired=e.isRequired,i.isNullable=e.isNullable,i.format=e.format,i.maximum=e.maximum,i.exclusiveMaximum=e.exclusiveMaximum,i.minimum=e.minimum,i.exclusiveMinimum=e.exclusiveMinimum,i.multipleOf=e.multipleOf,i.maxLength=e.maxLength,i.minLength=e.minLength,i.maxItems=e.maxItems,i.minItems=e.minItems,i.uniqueItems=e.uniqueItems,i.maxProperties=e.maxProperties,i.minProperties=e.minProperties,i.pattern=ps(e.pattern),i.imports=[...i.imports,...e.imports],i.enum=[...i.enum,...e.enum],i.enums=[...i.enums,...e.enums],i.properties=[...i.properties,...e.properties],i}if(n.headers)for(let e in n.headers)return i.in=`header`,i.name=e,i.type=`string`,i.base=`string`,i;return i},sc=({openApi:e,responses:t,types:n})=>{let r=[];return Object.entries(t).forEach(([t,i])=>{let a=Ks(t);if(!a)return;let o=oc({code:a,openApi:e,response:_s(e,i),types:n});r=[...r,o]}),r=tc(r),r.sort(qs)},cc=({method:e,op:t,openApi:n,pathParams:r,types:i,url:a})=>{let o={$refs:[],deprecated:t.deprecated===!0,description:t.description||null,id:t.operationId||null,imports:[],method:e.toUpperCase(),parameters:[...r.parameters],parametersBody:r.parametersBody,parametersCookie:[...r.parametersCookie],parametersForm:[...r.parametersForm],parametersHeader:[...r.parametersHeader],parametersPath:[...r.parametersPath],parametersQuery:[...r.parametersQuery],path:a,responseHeader:null,responses:[],summary:t.summary||null,tags:t.tags||null},s={...o,name:Qs({config:x(),method:o.method,operationId:t.operationId,path:o.path})};if(t.parameters){let e=ic({openApi:n,parameters:t.parameters,types:i});s.$refs=[...s.$refs,...e.$refs],s.imports=[...s.imports,...e.imports],s.parameters=[...s.parameters,...e.parameters],s.parametersBody=e.parametersBody,s.parametersCookie=[...s.parametersCookie,...e.parametersCookie],s.parametersForm=[...s.parametersForm,...e.parametersForm],s.parametersHeader=[...s.parametersHeader,...e.parametersHeader],s.parametersPath=[...s.parametersPath,...e.parametersPath],s.parametersQuery=[...s.parametersQuery,...e.parametersQuery]}if(t.responses){s.responses=sc({openApi:n,responses:t.responses,types:i});let e=s.responses.filter(e=>e.responseTypes.includes(`success`));s.responseHeader=Ws(e),e.forEach(e=>{s.$refs=[...s.$refs,...e.$refs],s.imports=[...s.imports,...e.imports]})}return s.parameters=ac(s.parameters),s},lc=({openApi:e,types:t})=>{let n=new Map,r=[],i=x();for(let a in e.paths){let o=e.paths[a],s=ic({openApi:e,parameters:o.parameters??[],types:t});for(let c in o){let l=c,u=k({method:l,path:a});if(Zo.includes(l)){let c=o[l];if(c.operationId&&(n.has(c.operationId)?i.logs.level!==`silent`&&console.warn(`❗️ Duplicate operationId: ${c.operationId} in ${u}. Please ensure your operation IDs are unique. This behavior is not supported and will likely lead to unexpected results.`):n.set(c.operationId,u)),Zs({config:i,operationKey:u})){let n=cc({method:l,op:c,openApi:e,pathParams:s,types:t,url:a});r.push(n)}}}}return r},uc=e=>{let t=e.schemes?.[0]||`http`,n=e.host,r=e.basePath||``;return(n?`${t}://${n}${r}`:r).replace(/\/$/g,``)},dc=e=>{let t=Qo(e.info.version),n=uc(e),{models:r,types:i}=xs(e);return{models:r,operations:lc({openApi:e,types:i}),server:n,types:i,version:t}},fc=e=>{let t={};for(let n in e)t[e[n]]=n;return t},pc=(e,t)=>{if(e.components&&t){for(let n in e.components.schemas)if(e.components.schemas.hasOwnProperty(n)){let r=e.components.schemas[n];if(r.discriminator&&r.oneOf?.length&&r.oneOf.some(e=>e.$ref&&cs(e.$ref)==t.name))return r.discriminator}}},mc=(e,t)=>{if(e.mapping){let n=fc(e.mapping),r=Object.keys(n).find(e=>cs(e)==t.name);if(r&&n[r])return n[r]}return t.name},hc=({debug:e,definition:t,getModel:n,model:r,openApi:i,types:a})=>{let o=typeof t.additionalProperties==`object`?t.additionalProperties:{},s=n({debug:e,definition:o,openApi:i,parentDefinition:t,types:a});if(o.$ref){let e=W({type:o.$ref});return r.base=e.base,r.default=G(t,r),r.export=`dictionary`,r.imports.push(...e.imports),r.template=e.template,r.type=e.type,r}return t.additionalProperties&&t.properties&&Object.keys(t.properties).length>0?(s.base=[W({type:typeof t.additionalProperties==`object`&&t.additionalProperties.type&&!Array.isArray(t.additionalProperties.type)?t.additionalProperties.type:s.base}).base,...r.properties.map(e=>e.base)].filter(ds).join(` | `),s.default=G(t,r),s.export=`generic`,s.isRequired=t.additionalProperties===!0,s.name=`[key: string]`,s):(r.base=s.base,r.default=G(t,r),r.export=`dictionary`,r.imports.push(...s.imports),r.link=s,r.template=s.template,r.type=s.type,r)},gc=({debug:e,definition:t,getModel:n,openApi:r,parent:i,types:a})=>{let o=[],s=pc(r,i);return Object.entries(t.properties??{}).forEach(([c,l])=>{let u=!!t.required?.includes(c),d={default:l.default,deprecated:l.deprecated===!0,description:l.description||null,exclusiveMaximum:l.exclusiveMaximum,exclusiveMinimum:l.exclusiveMinimum,format:l.type===`array`?l.items?.format??l.format:l.format,in:``,isDefinition:!1,isReadOnly:l.readOnly===!0,isRequired:u,maxItems:l.maxItems,maxLength:l.maxLength,maxProperties:l.maxProperties,maximum:l.maximum,minItems:l.minItems,minLength:l.minLength,minProperties:l.minProperties,minimum:l.minimum,multipleOf:l.multipleOf,name:St(c),pattern:ps(l.pattern),uniqueItems:l.uniqueItems};if(i&&s?.propertyName==c){o=[...o,{...d,$refs:[],base:`'${mc(s,i)}'`,enum:[],enums:[],export:`reference`,imports:[],isNullable:ts(l),link:null,properties:[],template:null,type:`string`}];return}if(l.$ref){let e=W({type:l.$ref});o=[...o,{...d,$refs:e.$refs,base:e.base,enum:[],enums:[],export:`reference`,imports:e.imports,isNullable:e.isNullable||ts(l),link:null,properties:[],template:e.template,type:e.type}];return}let f=n({debug:e,definition:l,initialValues:d,openApi:r,parentDefinition:t,types:a});f.isNullable=f.isNullable||ts(l),o=[...o,f]}),o},_c=({debug:e,definitions:t,getModel:n,openApi:r,required:i,types:a})=>t.reduce((t,i)=>{if(i.$ref){let o=W({type:i.$ref}),s={$ref:i.$ref,name:o.base};a[o.base]=s;let c=_s(r,i);return[...t,...n({debug:e,definition:c,meta:s,openApi:r,types:a}).properties]}return[...t,...n({debug:e,definition:i,openApi:r,parentDefinition:i,types:a}).properties]},[]).filter(e=>!e.isRequired&&i.includes(e.name)).map(e=>({...e,isRequired:!0})),vc=e=>[{definitions:e.allOf,type:`all-of`},{definitions:e.anyOf,type:`any-of`},{definitions:e.oneOf,type:`one-of`}].find(e=>e.definitions?.length),yc=({debug:e,definition:t,definitions:n,getModel:r,model:i,openApi:a,type:o,types:s})=>{let c={$refs:i.$refs,enums:i.enums,export:o,imports:i.imports,properties:i.properties},l=[];if(n.map(n=>r({debug:e,definition:n,openApi:a,parentDefinition:t,types:s})).forEach(e=>{c.$refs=[...c.$refs,...e.$refs],c.imports=[...c.imports,...e.imports],c.enums=[...c.enums,...e.enums],c.properties=[...c.properties,e]}),t.required&&o===`all-of`){let i=_c({debug:e,definitions:n,getModel:r,openApi:a,required:t.required,types:s});i.forEach(e=>{c.$refs=[...c.$refs,...e.$refs],c.imports=[...c.imports,...e.imports],c.enums=[...c.enums,...e.enums]}),l=[...l,...i]}if(t.properties){let e=gc({definition:t,getModel:r,openApi:a,types:s});e.forEach(e=>{c.$refs=[...c.$refs,...e.$refs],c.imports=[...c.imports,...e.imports],c.enums=[...c.enums,...e.enums],e.export===`enum`&&(c.enums=[...c.enums,e])}),l=[...l,...e]}if(l.length){let e=vc(t);if(e){let t={$refs:[],base:`unknown`,description:``,enum:[],enums:[],export:`interface`,imports:[],in:``,isDefinition:!1,isNullable:!1,isReadOnly:!1,isRequired:!1,link:null,name:`properties`,properties:l,template:null,type:`unknown`};e.type===`one-of`?(c.properties=[{...c,base:``,description:null,enum:[],in:``,isDefinition:!1,isNullable:!1,isReadOnly:!1,isRequired:!0,link:null,name:``,template:null,type:``},t],c.export=`all-of`):c.properties=[...c.properties,t]}}return c},bc=({debug:e,definition:t,initialValues:n={},isDefinition:r=!1,meta:i,openApi:a,parentDefinition:o=null,types:s})=>{let c=ns(t),l=$o(t,c),u={$refs:[],base:`unknown`,deprecated:!!t.deprecated,description:t.description||null,enum:[],enums:[],exclusiveMaximum:t.exclusiveMaximum,exclusiveMinimum:t.exclusiveMinimum,export:`interface`,format:t.format,imports:[],in:``,isDefinition:r,isNullable:ts(t),isReadOnly:t.readOnly===!0,isRequired:!1,link:null,maxItems:t.maxItems,maxLength:t.maxLength,maxProperties:t.maxProperties,maximum:t.maximum,meta:i,minItems:t.minItems,minLength:t.minLength,minProperties:t.minProperties,minimum:t.minimum,multipleOf:t.multipleOf,name:i?.name??``,pattern:ps(t.pattern),properties:[],template:null,type:`unknown`,uniqueItems:t.uniqueItems,...n};if(t.$ref){let n=W({debug:e,type:t.$ref});return u.$refs=[...u.$refs,decodeURIComponent(t.$ref)],u.base=n.base,u.export=`reference`,u.imports=[...u.imports,...n.imports],u.template=n.template,u.type=n.type,u.default=G(t,u),u}if(l===`enum`){let e=fs(t,t.enum);if(e.length)return u.base=`string`,u.enum=[...u.enum,...e],u.export=`enum`,u.type=`string`,u.default=G(t,u),u.meta||=ks(u),u}if(c.includes(`array`)&&(t.items||t.prefixItems)){if(t.prefixItems){let e=t.prefixItems.map(e=>bc({definition:e,openApi:a,parentDefinition:t,types:s}));return u.export=`array`,u.$refs=[...u.$refs,...e.reduce((e,t)=>[...e,...t.$refs],[])],u.imports=[...u.imports,...e.reduce((e,t)=>[...e,...t.imports],[])],u.link=e,u.default=G(t,u),u}if(!t.items)return u;if(t.items.$ref){let e=W({type:t.items.$ref});return u.$refs=[...u.$refs,decodeURIComponent(t.items.$ref)],u.base=e.base,u.export=`array`,u.imports=[...u.imports,...e.imports],u.template=e.template,u.type=e.type,u.default=G(t,u),u}if(t.items.anyOf&&o&&o.type){let e=vc(o);if(e&&e.definitions.some(e=>!ns(e).includes(`array`)))return bc({definition:t.items,openApi:a,parentDefinition:t,types:s})}let e=bc({definition:Array.isArray(t.items)?{anyOf:t.items}:t.items,openApi:a,parentDefinition:t,types:s});return u.base=e.base,u.export=`array`,u.$refs=[...u.$refs,...e.$refs],u.imports=[...u.imports,...e.imports],u.link=e,u.template=e.template,u.type=e.type,u.default=G(t,u),u}let d=vc(t);if(d){let n=yc({...d,debug:e,definition:t,getModel:bc,model:u,openApi:a,types:s});return{...u,...n}}if(c.includes(`object`)||t.properties||t.additionalProperties){if(t.properties&&(Object.keys(t.properties).length>0||!t.additionalProperties)){if(u.base=`unknown`,u.export=`interface`,u.type=`unknown`,u.default=G(t,u),gc({debug:e,definition:t,getModel:bc,openApi:a,parent:u,types:s}).forEach(e=>{u.$refs=[...u.$refs,...e.$refs],u.enums=[...u.enums,...e.enums],u.imports=[...u.imports,...e.imports],u.properties=[...u.properties,e],e.export===`enum`&&(u.enums=[...u.enums,e])}),t.additionalProperties){let n=hc({debug:e,definition:t,getModel:bc,model:u,openApi:a,types:s});u.properties=[...u.properties,n]}return!u.properties.length&&u.base===`unknown`&&u.type===`unknown`&&(u.export=`dictionary`,u.name||=`[key: string]`),u}return hc({debug:e,definition:t,getModel:bc,model:u,openApi:a,types:s})}if(t.const!==void 0){let e=t.const,n=typeof e==`string`?`"${e}"`:`${e}`;return u.base=n,u.export=`const`,u.type=n,u}if(c.length){let e=W({format:t.format,type:t.type});return u.base=e.base,u.export=`generic`,u.$refs=[...u.$refs,...e.$refs],u.imports=[...u.imports,...e.imports],u.isNullable=e.isNullable||u.isNullable,u.template=e.template,u.type=e.type,u.default=G(t,u),u}return u},xc=e=>{if(e.schema)return e.schema;if(e.content){let t=Object.entries(e.content);for(let[n,r]of t)if(r.schema){let t=n;return e.content[t].schema}}},Sc=e=>{let t={},n=[];return e.components?(Object.entries(e.components.schemas??{}).forEach(([r,i])=>{let a=js(r);t[a.name]=a;let o=bc({definition:i,isDefinition:!0,meta:a,openApi:e,types:t});n=[...n,o]}),Object.entries(e.components.parameters??{}).forEach(([r,i])=>{let a=xc(i);if(!a)return;let o=As(r);t[o.name]=o;let s=bc({definition:a,isDefinition:!0,meta:o,openApi:e,types:t});s.deprecated=i.deprecated,s.description=i.description||null,n=[...n,s]}),{models:n,types:t}):{models:n,types:t}},Cc=({openApi:e,parameter:t,types:n})=>{let r={$refs:[],base:`unknown`,deprecated:t.deprecated===!0,description:t.description||null,enum:[],enums:[],export:`interface`,imports:[],in:t.in,isDefinition:!1,isNullable:ts(t),isReadOnly:!1,isRequired:t.required===!0,link:null,mediaType:null,prop:t.name,properties:[],template:null,type:`unknown`},i={...r,name:ec(r)};if(t.$ref){let e=W({type:t.$ref});return i={...i,$refs:[...i.$refs,...e.$refs],base:e.base,export:`reference`,imports:[...i.imports,...e.imports],template:e.template,type:e.type},i}let a=xc(t);if(a){if(a.$ref?.startsWith(rs)&&(a=_s(e,a)),a.$ref){let e=W({type:a.$ref});return i={...i,$refs:[...i.$refs,...e.$refs],base:e.base,export:`reference`,imports:[...i.imports,...e.imports],template:e.template,type:e.type},i.default=G(a),i}let t=bc({definition:a,openApi:e,types:n});return i={...i,$refs:[...i.$refs,...t.$refs],base:t.base,enum:[...i.enum,...t.enum],enums:[...i.enums,...t.enums],exclusiveMaximum:t.exclusiveMaximum,exclusiveMinimum:t.exclusiveMinimum,export:t.export,format:t.format,imports:[...i.imports,...t.imports],isNullable:i.isNullable||t.isNullable,isReadOnly:t.isReadOnly,isRequired:i.isRequired||t.isRequired,link:t.link,maxItems:t.maxItems,maxLength:t.maxLength,maxProperties:t.maxProperties,maximum:t.maximum,minItems:t.minItems,minLength:t.minLength,minProperties:t.minProperties,minimum:t.minimum,multipleOf:t.multipleOf,pattern:ps(t.pattern),properties:[...i.properties,...t.properties],template:t.template,type:t.type,uniqueItems:t.uniqueItems},(i.enum.length||i.enums.length)&&!i.meta&&(i.meta=ks(i)),i.default=t.default,i}return i},wc=[`cookie`,`formData`,`header`,`path`,`query`],Tc=({openApi:e,parameters:t,types:n})=>{let r={$refs:[],imports:[],parameters:[],parametersBody:null,parametersCookie:[],parametersForm:[],parametersHeader:[],parametersPath:[],parametersQuery:[]};return t.forEach(t=>{let i=_s(e,t),a=Cc({openApi:e,parameter:i,types:n}),o=!$s(a);if(!(!wc.includes(i.in)||o)){switch(i.in){case`cookie`:r.parametersCookie=[...r.parametersCookie,a];break;case`formData`:r.parametersForm=[...r.parametersForm,a];break;case`header`:r.parametersHeader=[...r.parametersHeader,a];break;case`path`:r.parametersPath=[...r.parametersPath,a];break;case`query`:r.parametersQuery=[...r.parametersQuery,a];break}r.$refs=[...r.$refs,...a.$refs],r.imports=[...r.imports,...a.imports],r.parameters=[...r.parameters,a]}}),r},Ec=[`application/json-patch+json`,`application/json`,`application/ld+json`,`application/x-www-form-urlencoded`,`multipart/batch`,`multipart/form-data`,`multipart/mixed`,`multipart/related`,`text/json`,`text/plain`],Dc=(e,t)=>{let n=Object.keys(t).filter(e=>{let t=e.split(`;`)[0].trim();return Ec.includes(t)}).find(e=>!!t[e]?.schema);if(n)return{mediaType:n,schema:t[n].schema};let r=Object.keys(t).find(e=>!!t[e]?.schema);if(r)return{mediaType:r,schema:t[r].schema}},Oc=({body:e,debug:t,openApi:n,types:r})=>{let i=e[`x-body-name`]??`requestBody`,a={$refs:[],base:`unknown`,default:void 0,description:e.description||null,enum:[],enums:[],export:`interface`,imports:[],in:`body`,isDefinition:!1,isNullable:e.nullable===!0,isReadOnly:!1,isRequired:e.required===!0,link:null,mediaType:null,name:i,prop:i,properties:[],template:null,type:`unknown`};if(!e.content)return a;let o=Dc(n,e.content);if(!o)return a;switch(a.mediaType=o.mediaType,a.mediaType){case`application/x-www-form-urlencoded`:case`multipart/form-data`:a.in=`formData`,a.name=`formData`,a.prop=`formData`;break}if(o.schema.$ref){let e=W({type:o.schema.$ref});return a.export=`reference`,a.type=e.type,a.base=e.base,a.template=e.template,a.$refs=[...a.$refs,...e.$refs],a.imports=[...a.imports,...e.imports],a}let s=bc({debug:t,definition:o.schema,openApi:n,types:r});return a.$refs=[...a.$refs,...s.$refs],a.base=s.base,a.enum=[...a.enum,...s.enum],a.enums=[...a.enums,...s.enums],a.exclusiveMaximum=s.exclusiveMaximum,a.exclusiveMinimum=s.exclusiveMinimum,a.export=s.export,a.format=s.format,a.imports=[...a.imports,...s.imports],a.isNullable=a.isNullable||s.isNullable,a.isReadOnly=s.isReadOnly,a.isRequired=a.isRequired||s.isRequired,a.link=s.link,a.maximum=s.maximum,a.maxItems=s.maxItems,a.maxLength=s.maxLength,a.maxProperties=s.maxProperties,a.minimum=s.minimum,a.minItems=s.minItems,a.minLength=s.minLength,a.minProperties=s.minProperties,a.multipleOf=s.multipleOf,a.pattern=ps(s.pattern),a.properties=[...a.properties,...s.properties],a.template=s.template,a.type=s.type,a.uniqueItems=s.uniqueItems,a},kc=({code:e,openApi:t,response:n,types:r})=>{let i={$refs:[],base:e===204?`void`:`unknown`,code:e,description:n.description||null,enum:[],enums:[],export:`generic`,imports:[],in:`response`,isDefinition:!1,isNullable:!1,isReadOnly:!1,isRequired:!1,link:null,name:``,properties:[],responseTypes:[],template:null,type:e===204?`void`:`unknown`};if(n.content){let e=Dc(t,n.content);if(e){if(e.schema.$ref?.startsWith(`#/components/responses/`)&&(e.schema=_s(t,e.schema)),e.schema.$ref){let t=W({type:e.schema.$ref});return i.base=t.base,i.export=`reference`,i.$refs=[...i.$refs,...t.$refs],i.imports=[...i.imports,...t.imports],i.template=t.template,i.type=t.type,i}let n=bc({definition:e.schema,openApi:t,types:r});return i.export=n.export,i.type=n.type,i.base=n.base,i.template=n.template,i.link=n.link,i.isReadOnly=n.isReadOnly,i.isRequired=n.isRequired,i.isNullable=n.isNullable,i.format=n.format,i.maximum=n.maximum,i.exclusiveMaximum=n.exclusiveMaximum,i.minimum=n.minimum,i.exclusiveMinimum=n.exclusiveMinimum,i.multipleOf=n.multipleOf,i.maxLength=n.maxLength,i.minLength=n.minLength,i.maxItems=n.maxItems,i.minItems=n.minItems,i.uniqueItems=n.uniqueItems,i.maxProperties=n.maxProperties,i.minProperties=n.minProperties,i.pattern=ps(n.pattern),i.$refs=[...i.$refs,...n.$refs],i.imports=[...i.imports,...n.imports],i.enum=[...i.enum,...n.enum],i.enums=[...i.enums,...n.enums],i.properties=[...i.properties,...n.properties],i}}if(n.headers)for(let e in n.headers)return i.in=`header`,i.name=e,i.type=`string`,i.base=`string`,i;return i},Ac=({openApi:e,responses:t,types:n})=>{let r=[];return Object.entries(t).forEach(([t,i])=>{let a=Ks(t);if(!a)return;let o=kc({code:a,openApi:e,response:_s(e,i),types:n});r=[...r,o]}),r=tc(r),r.sort(qs)},jc=(e,t)=>{let n=[...e],r=[...t];for(;r.length>0;){let e=r[0];r=r.slice(1),n.every(t=>t.in!==e.in||t.name!==e.name)&&(n=[...n,e])}return n},Mc=({debug:e,method:t,op:n,openApi:r,pathParams:i,types:a,url:o})=>{let s={$refs:[],deprecated:!!n.deprecated,description:n.description||null,id:n.operationId||null,imports:[],method:t.toUpperCase(),parameters:[],parametersBody:i.parametersBody,parametersCookie:[],parametersForm:[],parametersHeader:[],parametersPath:[],parametersQuery:[],path:o,responseHeader:null,responses:[],summary:n.summary||null,tags:n.tags||null},c={...s,name:Qs({config:x(),method:s.method,operationId:n.operationId,path:s.path})};if(n.parameters){let e=Tc({openApi:r,parameters:n.parameters,types:a});c.$refs=[...c.$refs,...e.$refs],c.imports=[...c.imports,...e.imports],c.parameters=[...c.parameters,...e.parameters],c.parametersBody=e.parametersBody,c.parametersCookie=[...c.parametersCookie,...e.parametersCookie],c.parametersForm=[...c.parametersForm,...e.parametersForm],c.parametersHeader=[...c.parametersHeader,...e.parametersHeader],c.parametersPath=[...c.parametersPath,...e.parametersPath],c.parametersQuery=[...c.parametersQuery,...e.parametersQuery]}if(n.requestBody){let t=Oc({body:_s(r,n.requestBody),debug:e,openApi:r,types:a});c.$refs=[...c.$refs,...t.$refs],c.imports=[...c.imports,...t.imports],c.parameters=[...c.parameters,t],c.parametersBody=t}if(n.responses){c.responses=Ac({openApi:r,responses:n.responses,types:a});let e=c.responses.filter(e=>e.responseTypes.includes(`success`));c.responseHeader=Ws(e),e.forEach(e=>{c.$refs=[...c.$refs,...e.$refs],c.imports=[...c.imports,...e.imports]})}return c.parameters=jc(c.parameters,i.parameters),c.parametersCookie=jc(c.parametersCookie,i.parametersCookie),c.parametersForm=jc(c.parametersForm,i.parametersForm),c.parametersHeader=jc(c.parametersHeader,i.parametersHeader),c.parametersPath=jc(c.parametersPath,i.parametersPath),c.parametersQuery=jc(c.parametersQuery,i.parametersQuery),c.parameters=ac(c.parameters),c},Nc=({openApi:e,types:t})=>{let n=new Map,r=[],i=x();for(let a in e.paths){let o=e.paths[a],s=Tc({openApi:e,parameters:o.parameters??[],types:t});for(let c in o){let l=c,u=k({method:l,path:a});if(Zo.includes(l)){let c=o[l];if(c.operationId&&(n.has(c.operationId)?i.logs.level!==`silent`&&console.warn(`❗️ Duplicate operationId: ${c.operationId} in ${u}. Please ensure your operation IDs are unique. This behavior is not supported and will likely lead to unexpected results.`):n.set(c.operationId,u)),Zs({config:i,operationKey:u})){let n=Mc({method:l,op:c,openApi:e,pathParams:s,types:t,url:a});r.push(n)}}}}return r},Pc=e=>{let t=e.servers?.[0],n=t?.variables||{},r=t?.url||``;return Object.entries(n).forEach(([e,t])=>{r=r.replace(`{${e}}`,t.default)}),r.replace(/\/$/g,``)},Fc=e=>{let t=Qo(e.info.version),n=Pc(e),{models:r,types:i}=Sc(e);return{models:r,operations:Nc({openApi:e,types:i}),server:n,types:i,version:t}};function Ic({openApi:e}){let t=e;if(`openapi`in t)return Fc(t);if(`swagger`in t)return dc(t);throw Error(`Unsupported OpenAPI specification: ${JSON.stringify(t,null,2)}`)}const Lc=({config:e,dependencies:t,logger:n,spec:r})=>{let i=new yr({config:e,dependencies:t,logger:n,spec:r});if(`swagger`in i.spec)return Sa(i),i;if(dt(i.spec.openapi,`>=3.0.0 <3.1.0`))return so(i),i;if(dt(i.spec.openapi,`>=3.1.0`))return Xo(i),i;throw Error(`Unsupported OpenAPI specification`)},Rc=({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}},zc=({operation:e,plugin:t})=>{if(!e.security||!t.config.auth)return[];let n=[];for(let t of e.security){let e=Rc({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},Bc=`TComposable`,Vc=`DefaultT`,Hc=`ResT`,Uc=({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})},Wc=({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})},Gc=({context:e,value:t})=>{let n=T({case:`PascalCase`,value:xr(t)});return as({config:e.config,name:n})},Kc=({operation:e,plugin:t})=>t.config.methodNameBuilder?t.config.methodNameBuilder(e):!t.config.asClass&&e.id.match(gt)?`${e.id}_`:e.id,qc=({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=T({case:`camelCase`,value:xr(o.pop())}),i=o.pop()));let s=n.config.instance?[n.config.instance]:t.tags??[`default`];for(let c of s){let s=Gc({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||Kc({operation:t,plugin:n}),path:l.map(t=>Gc({context:e,value:t}))})}return r},Jc=({operation:e,plugin:t,throwOnError:n})=>{let r=b(t.context.config).name===`@hey-api/client-nuxt`,i=t.getPluginOrThrow(`@hey-api/typescript`),a=t.getSymbol(i.api.selector(`data`,e.id)),o=a?.placeholder||`unknown`,s=t.referenceSymbol(t.api.selector(`Options`));if(r){let n=t.getSymbol(i.api.selector(`response`,e.id))?.placeholder||`unknown`;return`${s.placeholder}<${Bc}, ${o}, ${n}, ${Vc}>`}return n?`${s.placeholder}<${o}, ${n}>`:a?`${s.placeholder}<${a.placeholder}>`:s.placeholder},Yc=({isRequiredOptions:e,operation:t,plugin:n})=>{let r={argNames:[],fields:[],parameters:[]},i=n.getPluginOrThrow(`@hey-api/typescript`),a=b(n.context.config).name===`@hey-api/client-nuxt`;if(n.config.params_EXPERIMENTAL===`experiment`){if(t.parameters?.path)for(let e in t.parameters.path){let n=t.parameters.path[e],a=xt(n.name);r.argNames.push(a),r.fields.push({in:`path`,key:a}),r.parameters.push({isRequired:n.required,name:a,type:i.api.schemaToType({plugin:i,schema:n.schema,state:{path:{value:[]}}})})}if(t.parameters?.query)for(let e in t.parameters.query){let n=t.parameters.query[e],a=xt(n.name);r.argNames.push(a),r.fields.push({in:`path`,key:a}),r.parameters.push({isRequired:n.required,name:a,type:i.api.schemaToType({plugin:i,schema:n.schema,state:{path:{value:[]}}})})}if(t.body){let e=`body`;r.argNames.push(e),r.fields.push({in:`body`}),r.parameters.push({isRequired:t.body.required,name:e,type:i.api.schemaToType({plugin:i,schema:t.body.schema,state:{path:{value:[]}}})})}}return r.parameters.push({isRequired:e,name:`options`,type:Jc({operation:t,plugin:n,throwOnError:a?void 0:`ThrowOnError`})}),r},Xc=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`}},Zc=({isRequiredOptions:e,opParameters:t,operation:n,plugin:r})=>{let i=b(r.context.config),a=i.name===`@hey-api/client-nuxt`,o=r.getPluginOrThrow(`@hey-api/typescript`),s=r.getSymbol(o.api.selector(a?`response`:`responses`,n.id))?.placeholder||`unknown`,c=r.getSymbol(o.api.selector(a?`error`:`errors`,n.id))?.placeholder||`unknown`,l=[];if(n.body)switch(n.body.type){case`form-data`:{let e=r.referenceSymbol(r.api.selector(`formDataBodySerializer`));l.push({spread:e.placeholder});break}case`json`:break;case`text`:case`octet-stream`:l.push({key:`bodySerializer`,value:null});break;case`url-search-params`:{let e=r.referenceSymbol(r.api.selector(`urlSearchParamsBodySerializer`));l.push({spread:e.placeholder});break}}let u=[];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)&&u.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)&&u.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)}]})}u.length&&l.push({key:`querySerializer`,value:[{key:`parameters`,value:u}]});let d=Uc({operation:n,plugin:r});if(d&&l.push({key:`requestValidator`,value:d}),r.config.transformer===`@hey-api/transformers`){let e=r.getPluginOrThrow(r.config.transformer).api.selector(`response`,n.id);if(r.isSymbolRegistered(e)){let t=r.referenceSymbol(e);l.push({key:`responseTransformer`,value:t.placeholder})}}let f=!1,p;for(let e in n.responses){let t=n.responses[e];!p&&i.name===`@hey-api/client-axios`&&lt({statusCode:e})===`2XX`&&(p=Xc(t.mediaType),p&&l.push({key:`responseType`,value:p})),t.mediaType===`text/event-stream`&&(f=!0)}let m=Wc({operation:n,plugin:r});m&&l.push({key:`responseValidator`,value:m}),r.config.responseStyle===`data`&&l.push({key:`responseStyle`,value:r.config.responseStyle});let h=zc({context:r.context,operation:n,plugin:r});h.length&&l.push({key:`security`,value:I.arrayLiteralExpression({elements:h})}),l.push({key:`url`,value:n.path}),l.push({spread:`options`});let g=[],_=t.argNames.length;if(_){let e=[],n=[];for(let n of t.argNames)e.push(I.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(I.objectExpression({obj:t}))}let i=r.referenceSymbol(r.api.selector(`buildClientParams`));g.push(I.constVariable({expression:I.callExpression({functionName:i.placeholder,parameters:[I.arrayLiteralExpression({elements:e}),I.arrayLiteralExpression({elements:n})]}),name:`params`})),l.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:I.propertyAccessExpression({expression:I.identifier({text:`options`}),isOptional:!e,name:`headers`})}];_&&r.push({spread:I.propertyAccessExpression({expression:I.identifier({text:`params`}),name:`headers`})}),l.push({key:`headers`,value:r})}}let v=r.config.client&&i.api&&`selector`in i.api?r.getSymbol(i.api.selector(`client`)):void 0,y=I.propertyAccessExpression({expression:I.identifier({text:`options`}),isOptional:!e,name:`client`}),ee;ee=r.config.instance?I.binaryExpression({left:y,operator:`??`,right:I.propertyAccessExpression({expression:I.this(),name:`_client`})}):v?I.binaryExpression({left:y,operator:`??`,right:v.placeholder}):y;let te=[];a?te.push(Bc,`${s} | ${Vc}`,c,Vc):te.push(s,c,`ThrowOnError`),r.config.responseStyle===`data`&&te.push(I.stringLiteral({text:r.config.responseStyle}));let ne=f?I.propertyAccessExpression({expression:ee,name:I.identifier({text:`sse`})}):ee;return ne=I.propertyAccessExpression({expression:ne,name:I.identifier({text:n.method})}),g.push(I.returnFunctionCall({args:[I.objectExpression({identifiers:[`responseTransformer`],obj:l})],name:ne,types:te})),g},Qc=({operation:e})=>{let t=[];if(e.summary&&t.push(j(e.summary)),e.description&&(t.length&&t.push(``),t.push(j(e.description))),e.deprecated&&(t.length&&t.push(``),t.push(`@deprecated`)),t.length)return t},$c=({context:e,operation:t})=>{let n=b(e.config).name===`@hey-api/client-nuxt`,r=e.config.plugins[`@hey-api/sdk`];return r&&!r.config.client&&!r.config.instance||n||st(t)},el=({operation:e})=>{for(let t in e.responses)if(e.responses[t].mediaType===`text/event-stream`)return!0;return!1},tl=({plugin:e})=>{let t=new Map,n=new Set,r=e.getPluginOrThrow(`@hey-api/sdk`);e.forEach(`operation`,({operation:n})=>{let i=$c({context:e.context,operation:n}),a=qc({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=il({isRequiredOptions:i,methodName:l,operation:n,plugin:e});c.nodes.length?c.nodes.push(I.identifier({text:`
14
+ `}),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(I.propertyDeclaration({initializer:I.newExpression({argumentsArray:[],expression:I.identifier({text:E({config:{case:`preserve`,name:e.config.httpRequests.classNameBuilder},name:a.className})})}),name:T({case:`camelCase`,value:a.className})}))}let a=e.referenceSymbol(e.api.selector(`Injectable`)),o=e.registerSymbol({exported:!0,name:E({config:{case:`preserve`,name:e.config.httpRequests.classNameBuilder},name:r.className}),selector:e.api.selector(`class`,r.className)}),s=I.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)},nl=({plugin:e})=>{e.forEach(`operation`,({operation:t})=>{let n=$c({context:e.context,operation:t}),r=e.registerSymbol({exported:!0,name:e.config.httpRequests.methodNameBuilder(t),selector:e.api.selector(`httpRequest`,t.id)}),i=al({isRequiredOptions:n,operation:t,plugin:e,symbol:r});e.setSymbolValue(r,i)},{order:`declarations`})},rl=({operation:e,plugin:t})=>{let n=b(t.context.config),r=n.api&&`selector`in n.api?t.getSymbol(n.api.selector(`client`)):void 0,i=I.propertyAccessExpression({expression:I.identifier({text:`options`}),isOptional:!0,name:`client`}),a;return a=r?I.binaryExpression({left:i,operator:`??`,right:r.placeholder}):i,I.callExpression({functionName:I.propertyAccessExpression({expression:a,name:`requestOptions`}),parameters:[I.objectExpression({obj:[{key:`responseStyle`,value:I.identifier({text:`'data'`})},{key:`method`,value:I.identifier({text:`'${e.method.toUpperCase()}'`})},{key:`url`,value:I.identifier({text:`'${e.path}'`})},{spread:`options`}]})]})},il=({isRequiredOptions:e,methodName:t,operation:n,plugin:r})=>{let i=r.getPluginOrThrow(`@hey-api/typescript`),a=r.referenceSymbol(r.api.selector(`HttpRequest`)),o=r.getPluginOrThrow(`@hey-api/sdk`),s=r.referenceSymbol(o.api.selector(`Options`)),c=r.getSymbol(i.api.selector(`data`,n.id))?.placeholder||`unknown`;return I.methodDeclaration({accessLevel:`public`,comment:Qc({operation:n}),name:t,parameters:[{isRequired:e,name:`options`,type:`${s.placeholder}<${c}, ThrowOnError>`}],returnType:`${a.placeholder}<unknown>`,statements:[I.returnStatement({expression:rl({operation:n,plugin:r})})],types:[{default:!1,extends:`boolean`,name:`ThrowOnError`}]})},al=({isRequiredOptions:e,operation:t,plugin:n,symbol:r})=>{let i=n.getPluginOrThrow(`@hey-api/typescript`),a=n.referenceSymbol(n.api.selector(`HttpRequest`)),o=n.getPluginOrThrow(`@hey-api/sdk`),s=n.referenceSymbol(o.api.selector(`Options`)),c=n.getSymbol(i.api.selector(`data`,t.id))?.placeholder||`unknown`;return I.constVariable({comment:Qc({operation:t}),exportConst:r.exported,expression:I.arrowFunction({parameters:[{isRequired:e,name:`options`,type:`${s.placeholder}<${c}, ThrowOnError>`}],returnType:`${a.placeholder}<unknown>`,statements:[I.returnStatement({expression:rl({operation:t,plugin:n})})],types:[{default:!1,extends:`boolean`,name:`ThrowOnError`}]}),name:r.placeholder})},ol=({plugin:e})=>{e.config.httpRequests.asClass?tl({plugin:e}):nl({plugin:e})},sl=({plugin:e})=>{let t=new Map,n=new Set,r=e.getPluginOrThrow(`@hey-api/sdk`);e.forEach(`operation`,({operation:n})=>{let i=$c({context:e.context,operation:n}),a=qc({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=ul({isRequiredOptions:i,methodName:l,operation:n,plugin:e});c.nodes.length?c.nodes.push(I.identifier({text:`
15
+ `}),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(I.propertyDeclaration({initializer:I.newExpression({argumentsArray:[],expression:I.identifier({text:E({config:{case:`preserve`,name:e.config.httpResources.classNameBuilder},name:a.className})})}),name:T({case:`camelCase`,value:a.className})}))}let a=e.referenceSymbol(e.api.selector(`Injectable`)),o=e.registerSymbol({exported:!0,name:E({config:{case:`preserve`,name:e.config.httpResources.classNameBuilder},name:r.className})}),s=I.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)},cl=({plugin:e})=>{e.forEach(`operation`,({operation:t})=>{let n=$c({context:e.context,operation:t}),r=e.registerSymbol({exported:!0,name:e.config.httpResources.methodNameBuilder(t)}),i=dl({isRequiredOptions:n,operation:t,plugin:e,symbol:r});e.setSymbolValue(r,i)},{order:`declarations`})},ll=({operation:e,plugin:t})=>{let n=t.getPluginOrThrow(`@hey-api/sdk`),r=t.getPluginOrThrow(`@hey-api/typescript`),i=t.referenceSymbol(t.api.selector(`httpResource`)),a=t.getSymbol(r.api.selector(`response`,e.id))?.placeholder||`unknown`;if(t.config.httpRequests.asClass){let r=qc({context:t.context,operation:e,plugin:n}),o=Array.from(r.values())[0];if(o){let n=o.path[0],r=t.referenceSymbol(t.api.selector(`class`,n)),s=t.referenceSymbol(t.api.selector(`inject`)),c=I.callExpression({functionName:s.placeholder,parameters:[I.identifier({text:r.placeholder})]});for(let e=1;e<o.path.length;e++){let t=o.path[e];t&&(c=I.propertyAccessExpression({expression:c,name:T({case:`camelCase`,value:t})}))}return c=I.propertyAccessExpression({expression:c,name:t.config.httpRequests.methodNameBuilder(e)}),I.callExpression({functionName:i.placeholder,parameters:[I.arrowFunction({parameters:[],statements:[I.constVariable({expression:I.conditionalExpression({condition:I.identifier({text:`options`}),whenFalse:I.identifier({text:`undefined`}),whenTrue:I.callExpression({functionName:`options`,parameters:[]})}),name:`opts`}),I.returnStatement({expression:I.conditionalExpression({condition:I.identifier({text:`opts`}),whenFalse:I.identifier({text:`undefined`}),whenTrue:I.callExpression({functionName:c,parameters:[I.identifier({text:`opts`})]})})})]})],types:[I.typeNode(a)]})}}else{let n=t.referenceSymbol(t.api.selector(`httpRequest`,e.id));return I.callExpression({functionName:i.placeholder,parameters:[I.arrowFunction({parameters:[],statements:[I.constVariable({expression:I.conditionalExpression({condition:I.identifier({text:`options`}),whenFalse:I.identifier({text:`undefined`}),whenTrue:I.callExpression({functionName:`options`,parameters:[]})}),name:`opts`}),I.returnStatement({expression:I.conditionalExpression({condition:I.identifier({text:`opts`}),whenFalse:I.identifier({text:`undefined`}),whenTrue:I.callExpression({functionName:n.placeholder,parameters:[I.identifier({text:`opts`})]})})})]})],types:[I.typeNode(a)]})}return I.callExpression({functionName:i.placeholder,parameters:[I.arrowFunction({parameters:[],statements:[I.returnStatement({expression:I.identifier({text:`undefined`})})]})],types:[I.typeNode(a)]})},ul=({isRequiredOptions:e,methodName:t,operation:n,plugin:r})=>{let i=r.getPluginOrThrow(`@hey-api/typescript`),a=r.getPluginOrThrow(`@hey-api/sdk`),o=r.referenceSymbol(a.api.selector(`Options`)),s=r.getSymbol(i.api.selector(`data`,n.id))?.placeholder||`unknown`;return I.methodDeclaration({accessLevel:`public`,comment:Qc({operation:n}),name:t,parameters:[{isRequired:e,name:`options`,type:`() => ${o.placeholder}<${s}, ThrowOnError> | undefined`}],returnType:void 0,statements:[I.returnStatement({expression:ll({operation:n,plugin:r})})],types:[{default:!1,extends:`boolean`,name:`ThrowOnError`}]})},dl=({isRequiredOptions:e,operation:t,plugin:n,symbol:r})=>{let i=n.getPluginOrThrow(`@hey-api/typescript`),a=n.getPluginOrThrow(`@hey-api/sdk`),o=n.referenceSymbol(a.api.selector(`Options`)),s=n.getSymbol(i.api.selector(`data`,t.id))?.placeholder||`unknown`;return I.constVariable({comment:Qc({operation:t}),exportConst:r.exported,expression:I.arrowFunction({parameters:[{isRequired:e,name:`options`,type:`() => ${o.placeholder}<${s}, ThrowOnError> | undefined`}],statements:[I.returnStatement({expression:ll({operation:t,plugin:n})})],types:[{default:!1,extends:`boolean`,name:`ThrowOnError`}]}),name:r.placeholder})},fl=({plugin:e})=>{e.config.httpResources.asClass?sl({plugin:e}):cl({plugin:e})},pl=({plugin:e})=>{e.registerSymbol({external:`@angular/common/http`,meta:{kind:`type`},name:`HttpRequest`,selector:e.api.selector(`HttpRequest`)}),e.registerSymbol({external:`@angular/core`,name:`inject`,selector:e.api.selector(`inject`)}),e.registerSymbol({external:`@angular/core`,name:`Injectable`,selector:e.api.selector(`Injectable`)}),e.registerSymbol({external:`@angular/common/http`,name:`httpResource`,selector:e.api.selector(`httpResource`)}),e.config.httpRequests.enabled&&ol({plugin:e}),e.config.httpResources.enabled&&fl({plugin:e})},ml={api:new Je({name:`@angular/common`}),config:{exportFromIndex:!1},dependencies:[`@hey-api/client-angular`,`@hey-api/sdk`],handler:pl,name:`@angular/common`,output:`@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`}}},hl=C(ml),gl={baseUrl:!0,bundle:!0,exportFromIndex:!1},_l={dependencies:[`@hey-api/typescript`],tags:[`client`]},vl=(0,p.fileURLToPath)(require(`url`).pathToFileURL(__filename).href),yl=f.default.dirname(vl),bl=({config:e,sourceOutput:t})=>{let n=b(e);if(`bundle`in n.config&&n.config.bundle)return oe({moduleOutput:`client`,sourceOutput:t});if(f.default.isAbsolute(n.name)){let t=f.default.dirname(n.name),r=f.default.resolve(e.output.path);return f.default.relative(r,t).replace(/\\/g,`/`)}return n.name},xl=e=>{let t=b(e);if(`bundle`in t.config&&t.config.bundle){let t=e._FRAGILE_CLIENT_BUNDLE_RENAMED;return f.default.resolve(e.output.path,`client`,`${t?.get(`index`)??`index`}.ts`)}return t.name},Sl=(e,t)=>{if(d.default.statSync(e).isDirectory()){d.default.existsSync(t)||d.default.mkdirSync(t,{recursive:!0});let n=d.default.readdirSync(e);for(let r of n)Sl(f.default.join(e,r),f.default.join(t,r))}else{let n=d.default.readFileSync(e);d.default.writeFileSync(t,n)}},Cl=({filePath:e,project:t,renamed:n})=>{let r=f.default.extname(e),i=f.default.basename(e,r),a=t.fileName?.(i)||i;if(a!==i){let t=f.default.dirname(e);d.default.renameSync(e,f.default.resolve(t,`${a}${r}`)),n.set(i,a)}},wl=({filePath:e,meta:t,renamed:n})=>{let r=d.default.readFileSync(e,`utf8`);r=r.replace(/from\s+['"](\.\.?\/[^'"]*?)['"]/g,(e,r)=>{let i=e.indexOf(r),a=f.default.extname(r),o=f.default.basename(r,a),s=f.default.dirname(r),c=(n.get(o)??o)+(t.importFileExtension?t.importFileExtension:a);return e.slice(0,i)+[s,c].filter(Boolean).join(`/`)+e.slice(i+r.length)}),r=`// This file is auto-generated by @hey-api/openapi-ts
16
+
17
+ ${r}`,d.default.writeFileSync(e,r,`utf8`)},Tl=({meta:e,outputPath:t,plugin:n,project:r})=>{let i=new Map;if(n.name.startsWith(`@hey-api/client-`)){let a=f.default.resolve(t,`core`);ie(a),Sl(f.default.resolve(yl,`clients`,`core`),a);let o=f.default.resolve(t,`client`);ie(o);let s=n.name.slice(16);if(Sl(f.default.resolve(yl,`clients`,s),o),r){let e=d.default.readdirSync(a);for(let t of e)Cl({filePath:f.default.resolve(a,t),project:r,renamed:i});let t=d.default.readdirSync(o);for(let e of t)Cl({filePath:f.default.resolve(o,e),project:r,renamed:i})}let c=d.default.readdirSync(a);for(let t of c)wl({filePath:f.default.resolve(a,t),meta:e,renamed:i});let l=d.default.readdirSync(o);for(let t of l)wl({filePath:f.default.resolve(o,t),meta:e,renamed:i});return i}let a=f.default.isAbsolute(n.name)?f.default.dirname(n.name):void 0;if(a){let e=f.default.resolve(t,`client`);ie(e),Sl(a,e);return}let o=f.default.normalize(require.resolve(n.name)).split(f.default.sep),s=o.slice(0,o.indexOf(`dist`)+1).join(f.default.sep),c=[o[o.length-1],`index.d.ts`,`index.d.cts`],l=f.default.resolve(t,`client`);ie(l);for(let e of c)d.default.copyFileSync(f.default.resolve(s,e),f.default.resolve(l,e))},El=({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},Dl=({plugin:e})=>{let t=xl(e.context.config),n=e.registerSymbol({external:t,name:`createClient`}),r=e.registerSymbol({external:t,name:`createConfig`}),i=e.getPluginOrThrow(`@hey-api/typescript`),a=e.referenceSymbol(i.api.selector(`ClientOptions`)),{runtimeConfigPath:o}=e.config,s=o?e.registerSymbol({external:o,name:`createClientConfig`}):void 0,c=[],l=El({plugin:e});if(l){let t=ya(l);if(t.protocol&&t.host&&!l.includes(`{`))c.push({key:he(e.context.config),value:l});else if(l!==`/`&&l.startsWith(`/`)){let t=l.endsWith(`/`)?l.slice(0,-1):l;c.push({key:he(e.context.config),value:t})}}`throwOnError`in e.config&&e.config.throwOnError&&c.push({key:`throwOnError`,value:!0});let u=[I.callExpression({functionName:r.placeholder,parameters:c.length?[I.objectExpression({obj:c})]:void 0,types:[I.typeReferenceNode({typeName:a.placeholder})]})],d=e.registerSymbol({meta:{path:[]},name:`client`,selector:e.api.selector(`client`)}),f=I.constVariable({exportConst:!0,expression:I.callExpression({functionName:n.placeholder,parameters:s?[I.callExpression({functionName:s.placeholder,parameters:u})]:u}),name:d.placeholder});e.setSymbolValue(d,f)},Ol=({plugin:e})=>{let t=xl(e.context.config),n=e.getPluginOrThrow(`@hey-api/typescript`),r=e.referenceSymbol(n.api.selector(`ClientOptions`)),i=e.registerSymbol({external:t,meta:{kind:`type`},name:`Config`}),a=e.registerSymbol({external:t,meta:{kind:`type`},name:`ClientOptions`}),o=e.registerSymbol({exported:!0,meta:{kind:`type`,path:[]},name:`CreateClientConfig`}),s=I.typeReferenceNode({typeName:a.placeholder}),c=I.typeReferenceNode({typeName:`T`}),l=I.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:o.exported,name:o.placeholder,type:I.functionTypeNode({parameters:[I.parameterDeclaration({name:`override`,required:!1,type:I.typeReferenceNode({typeArguments:[I.typeIntersectionNode({types:[s,c]})],typeName:i.placeholder})})],returnType:I.typeReferenceNode({typeArguments:[I.typeIntersectionNode({types:[I.typeReferenceNode({typeArguments:[s],typeName:`Required`}),c]})],typeName:i.placeholder})}),typeParameters:[{default:I.typeReferenceNode({typeName:r.placeholder}),extends:s,name:`T`}]});e.setSymbolValue(o,l)},kl=({plugin:e})=>{Ol({plugin:e}),Dl({plugin:e})};var Al=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const jl={..._l,api:new Al({name:`@hey-api/client-angular`}),config:{...gl,throwOnError:!1},handler:kl,name:`@hey-api/client-angular`},Ml=C(jl);var Nl=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const Pl={..._l,api:new Nl({name:`@hey-api/client-axios`}),config:{...gl,throwOnError:!1},handler:kl,name:`@hey-api/client-axios`},Fl=C(Pl);var Il=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const Ll={..._l,api:new Il({name:`@hey-api/client-fetch`}),config:{...gl,throwOnError:!1},handler:kl,name:`@hey-api/client-fetch`},Rl=C(Ll);var zl=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const Bl={..._l,api:new zl({name:`@hey-api/client-next`}),config:{...gl,throwOnError:!1},handler:kl,name:`@hey-api/client-next`},Vl=C(Bl);var Hl=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const Ul={..._l,api:new Hl({name:`@hey-api/client-nuxt`}),config:gl,handler:kl,name:`@hey-api/client-nuxt`},Wl=C(Ul);var Gl=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const Kl={..._l,api:new Gl({name:`@hey-api/client-ofetch`}),config:{...gl,throwOnError:!1},handler:kl,name:`@hey-api/client-ofetch`},ql=C(Kl),Jl={config:{},handler:()=>{},name:`legacy/angular`,output:`client`,tags:[`client`]},Yl=C(Jl),Xl={config:{},handler:()=>{},name:`legacy/axios`,output:`client`,tags:[`client`]},Zl=C(Xl),Ql={config:{},handler:()=>{},name:`legacy/fetch`,output:`client`,tags:[`client`]},$l=C(Ql),eu={config:{},handler:()=>{},name:`legacy/node`,output:`client`,tags:[`client`]},tu=C(eu),nu={config:{},handler:()=>{},name:`legacy/xhr`,output:`client`,tags:[`client`]},ru=C(nu);var iu=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const au=({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)},ou=({context:e,plugin:t,schema:n})=>{if(Array.isArray(n))return n.map(n=>ou({context:e,plugin:t,schema:n}));let r=structuredClone(n);if(r.$ref)return r.$ref=decodeURI(r.$ref),r;if(au({plugin:t,schema:r}),r.additionalProperties&&typeof r.additionalProperties!=`boolean`&&(r.additionalProperties=ou({context:e,plugin:t,schema:r.additionalProperties})),r.allOf&&=r.allOf.map(n=>ou({context:e,plugin:t,schema:n})),r.items&&=ou({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]=ou({context:e,plugin:t,schema:i}))}return r},su=({context:e,plugin:t,schema:n})=>{if(Array.isArray(n))return n.map(n=>su({context:e,plugin:t,schema:n}));let r=structuredClone(n);if(`$ref`in r)return r.$ref=decodeURI(r.$ref),r;if(au({plugin:t,schema:r}),r.additionalProperties&&typeof r.additionalProperties!=`boolean`&&(r.additionalProperties=su({context:e,plugin:t,schema:r.additionalProperties})),r.allOf&&=r.allOf.map(n=>su({context:e,plugin:t,schema:n})),r.anyOf&&=r.anyOf.map(n=>su({context:e,plugin:t,schema:n})),r.items&&=su({context:e,plugin:t,schema:r.items}),r.oneOf&&=r.oneOf.map(n=>su({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]=su({context:e,plugin:t,schema:i}))}return r},cu=({context:e,plugin:t,schema:n})=>{if(Array.isArray(n))return n.map(n=>cu({context:e,plugin:t,schema:n}));let r=structuredClone(n);if(au({plugin:t,schema:r}),r.$ref&&=decodeURI(r.$ref),r.additionalProperties&&typeof r.additionalProperties!=`boolean`&&(r.additionalProperties=cu({context:e,plugin:t,schema:r.additionalProperties})),r.allOf&&=r.allOf.map(n=>cu({context:e,plugin:t,schema:n})),r.anyOf&&=r.anyOf.map(n=>cu({context:e,plugin:t,schema:n})),r.items&&=cu({context:e,plugin:t,schema:r.items}),r.oneOf&&=r.oneOf.map(n=>cu({context:e,plugin:t,schema:n})),r.prefixItems&&=r.prefixItems.map(n=>cu({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]=cu({context:e,plugin:t,schema:i}))}return r},lu=({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`,xt(r)},uu=({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,name:lu({name:n,plugin:t,schema:r}),selector:t.api.selector(`ref`,n)}),a=ou({context:e,plugin:t,schema:r}),o=I.constVariable({assertion:`const`,exportConst:i.exported,expression:I.objectExpression({obj:a}),name:i.placeholder});t.setSymbolValue(i,o)}},du=({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,name:lu({name:n,plugin:t,schema:r}),selector:t.api.selector(`ref`,n)}),a=su({context:e,plugin:t,schema:r}),o=I.constVariable({assertion:`const`,exportConst:i.exported,expression:I.objectExpression({obj:a}),name:i.placeholder});t.setSymbolValue(i,o)}},fu=({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,name:lu({name:n,plugin:t,schema:r}),selector:t.api.selector(`ref`,n)}),a=cu({context:e,plugin:t,schema:r}),o=I.constVariable({assertion:`const`,exportConst:i.exported,expression:I.objectExpression({obj:a}),name:i.placeholder});t.setSymbolValue(i,o)}},pu=({plugin:e})=>{if(`swagger`in e.context.spec){uu({context:e.context,plugin:e});return}if(dt(e.context.spec.openapi,`>=3.0.0 <3.1.0`)){du({context:e.context,plugin:e});return}if(dt(e.context.spec.openapi,`>=3.1.0`)){fu({context:e.context,plugin:e});return}throw Error(`Unsupported OpenAPI specification`)};var mu=class{_exportFromIndex;_headers=[];_id;_imports=new Map;_items=[];_name;_path;constructor({dir:e,exportFromIndex:t=!1,header:n=!0,id:r,name:i}){this._exportFromIndex=t,this._id=r,this._name=this._setName(i),this._path=f.default.resolve(e,this._name),n&&this._headers.push(`// This file is auto-generated by @hey-api/openapi-ts`)}add(...e){this._items=this._items.concat(e)}get exportFromIndex(){return this._exportFromIndex}get id(){return this._id}import({module:e,...t}){if(!t.name)return{name:void 0};let n=this._imports.get(e);n||(n=new Map,this._imports.set(e,n));let r=n.get(t.name);return r?{...r,name:r.alias||r.name}:(n.set(t.name,t),{...t,name:t.alias||t.name})}isEmpty(){return!this._items.length}nameWithoutExtension(){let{name:e}=hu(this._name);return e}remove(e){d.default.rmSync(this._path,e)}removeNode_LEGACY(){this._items=this._items.slice(0,this._items.length-1)}_setName(e){if(e.includes(`index`))return e;let{extension:t,name:n}=hu(e);return[n,`gen`,t].filter(Boolean).join(`.`)}_toString(e,t){let n=[];this._headers.length&&n.push(this._headers.join(`
18
+ `));let r=t?.options.moduleResolution===m.default.ModuleResolutionKind.NodeNext,i=[];for(let[e,t]of this._imports.entries()){let n=Array.from(t.values()),a=e;r&&(a.startsWith(`./`)||a.startsWith(`../`))&&(a=a===`./client`?`./client/index.js`:`${a}.js`);let o=I.namedImportDeclarations({imports:n,module:a});i.push(Ot({node:o}))}return i.length&&n.push(i.join(`
19
+ `)),n=n.concat(this._items.map(e=>typeof e==`string`?e:Ot({node:e,unescape:!0}))),n.join(e)}write(e=`
20
+ `,t=null){if(this.isEmpty()){this.remove({force:!0});return}let n=this._path;if(typeof this._path==`string`){let e=this._path.split(f.default.sep);n=e.slice(0,e.length-1).join(f.default.sep)}ie(n),d.default.writeFileSync(this._path,this._toString(e,t))}};const hu=e=>{let t=e.match(/\.[0-9a-z]+$/i),n=t?t[0].slice(1):``;return{extension:n,name:e.slice(0,e.length-(n?n.length+1:0))}},gu=(e,t)=>{let n=x();if(Array.isArray(e))return e.map(e=>gu(e));if(typeof e!=`object`||!e)return e;let r={...e};return Object.entries(r).forEach(([e,i])=>{if(n.plugins[`@hey-api/schemas`]?.config.type===`form`&&[`description`,`x-enum-descriptions`,`x-enum-varnames`,`x-enumNames`,`title`].includes(e)&&t!==`properties`){delete r[e];return}e===`$ref`&&typeof i==`string`&&(r[e]=decodeURIComponent(i)),i&&typeof i==`object`&&(r[e]=gu(i,e))}),r},_u=(e,t)=>{let n=x(),r=br(e),i=n.plugins[`@hey-api/schemas`];return i?.config.nameBuilder?typeof i.config.nameBuilder==`function`?i.config.nameBuilder(r,t):i.config.nameBuilder.replace(`{{name}}`,r):`${r}Schema`},vu=({files:e,openApi:t,plugin:n})=>{e.schemas=new mu({dir:x().output.path,exportFromIndex:n.config.exportFromIndex,id:`schemas`,name:`schemas.ts`});let r=(t,n)=>{let r=gu(n),i=I.objectExpression({obj:r}),a=I.constVariable({assertion:`const`,exportConst:!0,expression:i,name:_u(t,n)});e.schemas.add(a)};`swagger`in t&&Object.entries(t.definitions??{}).forEach(([e,t])=>{r(e,t)}),`openapi`in t&&Object.entries(t.components?.schemas??{}).forEach(([e,t])=>{r(e,t)})},yu={api:new iu({name:`@hey-api/schemas`}),config:{exportFromIndex:!1,nameBuilder:e=>`${e}Schema`,type:`json`},handler:pu,handlerLegacy:vu,name:`@hey-api/schemas`},bu=C(yu);var xu=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const Su=({plugin:e})=>{let t=I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:I.this(),name:`_client`}),operator:`=`,right:I.propertyAccessExpression({expression:I.identifier({text:`args`}),name:`client`})})}),n=e.referenceSymbol(e.api.selector(`Client`)),r=b(e.context.config),i=r.api&&`selector`in r.api?e.getSymbol(r.api.selector(`client`)):void 0;return[I.propertyDeclaration({initializer:i?I.identifier({text:i.placeholder}):void 0,modifier:`protected`,name:`_client`,type:I.typeReferenceNode({typeName:n.placeholder})}),I.identifier({text:`
21
+ `}),I.constructorDeclaration({multiLine:!0,parameters:[{isRequired:!e.config.client,name:`args`,type:I.typeInterfaceNode({properties:[{isRequired:!e.config.client,name:`client`,type:n.placeholder}],useLegacyResolution:!1})}],statements:[e.config.client?I.ifStatement({expression:I.propertyAccessExpression({expression:I.identifier({text:`args`}),isOptional:!0,name:`client`}),thenStatement:I.block({statements:[t]})}):t]})]},Cu=({plugin:e})=>{let t=b(e.context.config),n=t.name===`@hey-api/client-angular`,r=t.name===`@hey-api/client-nuxt`,i=new Map,a=new Set,o=e.config.instance?Su({plugin:e}):[];e.forEach(`operation`,({operation:a})=>{let o=$c({context:e.context,operation:a}),s=e.getPluginOrThrow(`@hey-api/typescript`),c=r?e.getSymbol(s.api.selector(`response`,a.id)):void 0,l=qc({context:e.context,operation:a,plugin:e});for(let s of l.values())s.path.forEach((l,u)=>{let d=e.referenceSymbol(e.api.selector(`class`,l));i.has(d.id)||i.set(d.id,{className:l,classes:new Set,id:d.id,methods:new Set,nodes:[],root:!u});let f=s.path[u-1];if(f){let t=e.referenceSymbol(e.api.selector(`class`,f));if(t.placeholder!==d.placeholder){let e=i.get(t.id);e.classes.add(d.id),i.set(t.id,e)}}if(s.path.length!==u+1)return;let p=i.get(d.id);if(p.methods.has(s.methodName))return;let m=Yc({isRequiredOptions:o,operation:a,plugin:e}),h=Zc({isRequiredOptions:o,opParameters:m,operation:a,plugin:e}),g=I.methodDeclaration({accessLevel:`public`,comment:Qc({operation:a}),isStatic:n?!1:!e.config.instance,name:s.methodName,parameters:m.parameters,returnType:void 0,statements:h,types:r?[{default:I.ots.string(`$fetch`),extends:I.typeNode(e.referenceSymbol(e.api.selector(`Composable`)).placeholder),name:Bc},{default:c?I.typeReferenceNode({typeName:c.placeholder}):I.typeNode(`undefined`),extends:c?I.typeReferenceNode({typeName:c.placeholder}):void 0,name:Vc}]:[{default:(`throwOnError`in t.config?t.config.throwOnError:!1)??!1,extends:`boolean`,name:`ThrowOnError`}]});p.nodes.length?p.nodes.push(I.identifier({text:`
22
+ `}),g):p.nodes.push(g),p.methods.add(s.methodName),i.set(d.id,p)})},{order:`declarations`});let s=e.registerSymbol({exported:!1,meta:{path:[]},name:`_HeyApiClient`}),c=t=>{if(a.has(t.id))return;if(t.classes.size)for(let n of t.classes){let r=i.get(n);c(r),t.nodes.push(I.propertyDeclaration({initializer:e.config.instance?I.newExpression({argumentsArray:e.config.instance?[I.objectExpression({multiLine:!1,obj:[{key:`client`,value:I.propertyAccessExpression({expression:I.this(),name:`_client`})}]})]:[],expression:I.identifier({text:e.referenceSymbol(r.id).placeholder})}):I.identifier({text:e.referenceSymbol(r.id).placeholder}),modifier:e.config.instance?void 0:`static`,name:T({case:`camelCase`,value:r.className})}))}let r=e.registerSymbol({exported:!0,meta:{path:[]},name:t.className,selector:e.api.selector(`class`,t.className)}),o=I.classDeclaration({decorator:t.root&&n?{args:[{providedIn:`root`}],name:e.referenceSymbol(e.api.selector(`Injectable`)).placeholder}:void 0,exportClass:r.exported,extendedClasses:e.config.instance?[s.placeholder]:void 0,name:r.placeholder,nodes:t.nodes});e.setSymbolValue(r,o),a.add(r.id)};if(o.length){let t=I.classDeclaration({exportClass:s.exported,name:s.placeholder,nodes:o});e.setSymbolValue(s,t)}for(let e of i.values())c(e)},wu=({meta:e,onImport:t,...n})=>{if(!e)return{created:!1,name:``};let{created:r,name:i}=Vs({meta:e,...n});return i&&t(i),{created:r,name:i}},Tu=e=>`${e}ModelResponseTransformer`,Eu=e=>`${T({case:`PascalCase`,value:e})}Data`,Du=e=>`${T({case:`PascalCase`,value:e})}Error`,Ou=e=>`${e}Transformer`,ku=e=>`${T({case:`PascalCase`,value:e})}Response`,Au=({importedType:e,throwOnError:t})=>{let n=`OptionsLegacyParser`;return t?`${n}<${e||`unknown`}, ${t}>`:e?`${n}<${e}>`:n},ju=(e,t)=>{let n=x(),{name:r}=Vs({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:Eu}),i=Gs(t.parameters);if(!S(n))return[{isRequired:i,name:`options`,type:Au({importedType:r,throwOnError:`ThrowOnError`})}];if(!t.parameters.length)return[];let a=e=>{if(e.default!==void 0)return JSON.stringify(e.default,null,4)};return n.useOptions?[{default:i?void 0:{},name:`data`,type:r}]:t.parameters.map(e=>{let t=`${r}['${e.name}']`;return{default:e?.default,isRequired:(!e.isRequired&&!a(e)?`?`:``)==``,name:e.name,type:t}})},Mu=(e,t)=>{let n=x(),r=I.typeNode(`void`);if(t.responses.filter(e=>e.responseTypes.includes(`success`)).length){let{name:n}=Vs({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:ku});r=I.typeUnionNode({types:[n]})}return n.useOptions&&n.plugins[`@hey-api/sdk`]?.config.response===`response`&&(r=I.typeNode(`ApiResult`,[r])),r=b(n).name===`legacy/angular`?I.typeNode(`Observable`,[r]):I.typeNode(`CancelablePromise`,[r]),r},Nu=e=>{let t=x();if(!S(t))return[e.deprecated&&`@deprecated`,e.summary&&j(e.summary),e.description&&j(e.description)];let n=[];e.parameters.length&&(n=t.useOptions?[`@param data The data for the request.`,...e.parameters.map(e=>`@param data.${e.name} ${e.description?j(e.description):``}`)]:e.parameters.map(e=>`@param ${e.name} ${e.description?j(e.description):``}`));let r=e.responses.filter(e=>e.responseTypes.includes(`success`));return[e.deprecated&&`@deprecated`,e.summary&&j(e.summary),e.description&&j(e.description),...n,...r.map(e=>`@returns ${e.type} ${e.description?j(e.description):``}`),`@throws ApiError`]},Pu=({client:e,onClientImport:t,onImport:n,operation:r})=>{let i=x(),a=ku(r.name),{name:o}=Vs({client:e,meta:{$ref:`transformers/${a}`,name:a},nameTransformer:Ou});if(o&&n(o),!S(i)){let e=[{spread:`options`}],n=r.parameters.filter(e=>e.in===`body`||e.in===`formData`).map(e=>e.mediaType||(e.in===`formData`?`multipart/form-data`:void 0)).filter(Boolean).filter(ds);return n.length===1&&(n[0]===`multipart/form-data`&&(e=[...e,{spread:`formDataBodySerializer`},{key:`headers`,value:[{key:`Content-Type`,value:null},{spread:`options?.headers`}]}],t?.(`formDataBodySerializer`)),n[0]===`application/x-www-form-urlencoded`&&(e=[...e,{spread:`urlSearchParamsBodySerializer`},{key:`headers`,value:[{key:`Content-Type`,value:n[0]},{spread:`options?.headers`}]}],t?.(`urlSearchParamsBodySerializer`))),e=[...e,{key:`url`,value:r.path}],o&&(e=[...e,{key:`responseTransformer`,value:o}]),I.objectExpression({identifiers:[`responseTransformer`],obj:e})}let s=e=>e.reduce((e,t)=>{let n=t.prop,r=i.useOptions?`data.${t.name}`:t.name;return n===r?e[n]=n:St(n)===n?e[n]=r:e[`'${n}'`]=r,e},{}),c={method:r.method,url:r.path};r.parametersPath.length&&(c.path=s(r.parametersPath)),r.parametersCookie.length&&(c.cookies=s(r.parametersCookie)),r.parametersHeader.length&&(c.headers=s(r.parametersHeader)),r.parametersQuery.length&&(c.query=s(r.parametersQuery)),r.parametersForm.length&&(c.formData=s(r.parametersForm)),r.parametersBody&&(r.parametersBody.in===`formData`&&(i.useOptions?c.formData=`data.${r.parametersBody.name}`:c.formData=r.parametersBody.name),r.parametersBody.in===`body`&&(i.useOptions?c.body=`data.${r.parametersBody.name}`:c.body=r.parametersBody.name)),r.parametersBody?.mediaType&&(c.mediaType=r.parametersBody?.mediaType),r.responseHeader&&(c.responseHeader=r.responseHeader),o&&(c.responseTransformer=o);let l=r.responses.filter(e=>e.responseTypes.includes(`error`));if(l.length>0){let e={};l.forEach(t=>{e[t.code]=t.description??``}),c.errors=e}return I.objectExpression({identifiers:[`body`,`cookies`,`formData`,`headers`,`path`,`query`,`responseTransformer`],obj:c,shorthand:!0})},Fu=({config:e,handleIllegal:t,id:n,operation:r})=>e.plugins[`@hey-api/sdk`]?.config.methodNameBuilder?e.plugins[`@hey-api/sdk`].config.methodNameBuilder(r):t&&n.match(gt)?`${n}_`:n,Iu=({client:e,onClientImport:t,onImport:n,operation:r})=>{let i=x(),a=Pu({client:e,onClientImport:t,onImport:n,operation:r});if(!S(i)){let t=Vs({client:e,meta:{$ref:r.name,name:r.name},nameTransformer:Du}).name,n=r.responses.filter(e=>e.responseTypes.includes(`success`)).length?Vs({client:e,meta:{$ref:r.name,name:r.name},nameTransformer:ku}).name:`void`;return[I.returnFunctionCall({args:[a],name:`(options?.client ?? client).${r.method.toLocaleLowerCase()}`,types:t&&n?[n,t,`ThrowOnError`]:t?[`unknown`,t,`ThrowOnError`]:n?[n,`unknown`,`ThrowOnError`]:[]})]}return ve(i)?[I.returnFunctionCall({args:[a],name:`this.httpRequest.request`})]:b(i).name===`legacy/angular`?[I.returnFunctionCall({args:[`OpenAPI`,`this.http`,a],name:`__request`})]:[I.returnFunctionCall({args:[`OpenAPI`,a],name:`__request`})]},Lu=({client:e,onClientImport:t,onImport:n,onNode:r,service:i})=>{let a=x(),o=b(a),s=S(a);for(let t of i.operations)t.parameters.length&&wu({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:Eu,onImport:n}),s||wu({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:Du,onImport:n}),t.responses.filter(e=>e.responseTypes.includes(`success`)).length&&wu({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:ku,onImport:n});let c={default:(`throwOnError`in o.config?o.config.throwOnError:!1)??!1,extends:`boolean`,name:`ThrowOnError`};if(!a.plugins[`@hey-api/sdk`]?.config.asClass&&!ve(a)){for(let l of i.operations){let i={parameters:ju(e,l),returnType:s?Mu(e,l):void 0,statements:Iu({client:e,onClientImport:t,onImport:n,operation:l}),types:s?void 0:[c]},u=o.name===`legacy/angular`?I.anonymousFunction(i):I.arrowFunction(i);r(I.constVariable({comment:Nu(l),exportConst:!0,expression:u,name:Fu({config:a,handleIllegal:!0,id:l.name,operation:l})}))}return}let l=i.operations.map(r=>I.methodDeclaration({accessLevel:`public`,comment:Nu(r),isStatic:ve(a)===void 0&&o.name!==`legacy/angular`,name:Fu({config:a,id:r.name,operation:r}),parameters:ju(e,r),returnType:s?Mu(e,r):void 0,statements:Iu({client:e,onClientImport:t,onImport:n,operation:r}),types:s?void 0:[c]}));if(!l.length)return;ve(a)?l=[I.constructorDeclaration({multiLine:!1,parameters:[{accessLevel:`public`,isReadOnly:!0,name:`httpRequest`,type:`BaseHttpRequest`}]}),...l]:o.name===`legacy/angular`&&(l=[I.constructorDeclaration({multiLine:!1,parameters:[{accessLevel:`public`,isReadOnly:!0,name:`http`,type:`HttpClient`}]}),...l]);let u=[];l.forEach((e,t)=>{t&&u.push(I.identifier({text:`
23
+ `})),u.push(e)}),r(I.classDeclaration({decorator:o.name===`legacy/angular`?{args:[{providedIn:`root`}],name:`Injectable`}:void 0,exportClass:!0,name:as({config:a,name:i.name}),nodes:u}))},Ru=({client:e,files:t,plugin:n})=>{let r=x(),i=S(r);if(t.sdk=new mu({dir:r.output.path,exportFromIndex:n.config.exportFromIndex,id:`sdk`,name:`sdk.ts`}),!i)t.sdk.import({module:bl({config:r,sourceOutput:`sdk`}),name:`createClient`}),t.sdk.import({module:bl({config:r,sourceOutput:`sdk`}),name:`createConfig`}),t.sdk.import({asType:!0,module:bl({config:r,sourceOutput:`sdk`}),name:`OptionsLegacyParser`});else if(b(r).name===`legacy/angular`?(t.sdk.import({module:`@angular/core`,name:`Injectable`}),ve(r)||t.sdk.import({module:`@angular/common/http`,name:`HttpClient`}),t.sdk.import({asType:!0,module:`rxjs`,name:`Observable`})):t.sdk.import({asType:!0,module:`./core/CancelablePromise`,name:`CancelablePromise`}),r.plugins[`@hey-api/sdk`]?.config.response===`response`&&t.sdk.import({asType:!0,module:`./core/ApiResult`,name:`ApiResult`}),ve(r)){let e=b(r);t.sdk.import({asType:e.name!==`legacy/angular`,module:`./core/BaseHttpRequest`,name:`BaseHttpRequest`})}else t.sdk.import({module:`./core/OpenAPI`,name:`OpenAPI`}),t.sdk.import({alias:`__request`,module:`./core/request`,name:`request`});if(!i){let e=b(r),n=I.constVariable({exportConst:!0,expression:I.callExpression({functionName:`createClient`,parameters:[I.callExpression({functionName:`createConfig`,parameters:[`throwOnError`in e&&e.throwOnError?I.objectExpression({obj:[{key:`throwOnError`,value:!0}]}):void 0]})]}),name:`client`});t.sdk.add(n)}for(let n of e.services)Lu({client:e,onClientImport:e=>{t.sdk.import({module:bl({config:r,sourceOutput:`sdk`}),name:e})},onImport:e=>{t.sdk.import({asType:!e.endsWith(`Transformer`),module:`./${t.types.nameWithoutExtension()}`,name:e})},onNode:e=>{t.sdk.add(e)},service:n})},zu=({plugin:e})=>{let t=b(e.context.config),n=t.name===`@hey-api/client-nuxt`;e.forEach(`operation`,r=>{let{operation:i}=r,a=$c({context:e.context,operation:i}),o=e.getPluginOrThrow(`@hey-api/typescript`),s=n?e.getSymbol(o.api.selector(`response`,i.id)):void 0,c=Yc({isRequiredOptions:a,operation:i,plugin:e}),l=Zc({isRequiredOptions:a,opParameters:c,operation:i,plugin:e}),u=e.registerSymbol({meta:{path:r._path,tags:r.tags},name:Fu({config:e.context.config,handleIllegal:!0,id:i.id,operation:i}),selector:e.api.selector(`function`,i.id)}),d=I.constVariable({comment:Qc({operation:i}),exportConst:!0,expression:I.arrowFunction({parameters:c.parameters,returnType:void 0,statements:l,types:n?[{default:I.ots.string(`$fetch`),extends:I.typeNode(e.referenceSymbol(e.api.selector(`Composable`)).placeholder),name:Bc},{default:s?I.typeReferenceNode({typeName:s.placeholder}):I.typeNode(`undefined`),extends:s?I.typeReferenceNode({typeName:s.placeholder}):void 0,name:Vc}]:[{default:(`throwOnError`in t.config?t.config.throwOnError:!1)??!1,extends:`boolean`,name:`ThrowOnError`}]}),name:u.placeholder});e.setSymbolValue(u,d)},{order:`declarations`})},Bu=({plugin:e})=>{let t=xl(e.context.config),n=b(e.context.config).name===`@hey-api/client-nuxt`,r=e.registerSymbol({external:t,meta:{kind:`type`,path:[]},name:`TDataShape`}),i=e.registerSymbol({external:t,meta:{kind:`type`,path:[]},name:`Client`,selector:e.api.selector(`Client`)}),a=e.registerSymbol({external:t,meta:{kind:`type`,path:[]},name:`Options`}),o=e.registerSymbol({exported:!0,meta:{kind:`type`,path:[]},name:`Options`,selector:e.api.selector(`Options`)}),s=I.typeAliasDeclaration({exportType:o.exported,name:o.placeholder,type:I.typeIntersectionNode({types:[I.typeReferenceNode({typeArguments:n?[I.typeReferenceNode({typeName:`TComposable`}),I.typeReferenceNode({typeName:`TData`}),I.typeReferenceNode({typeName:Hc}),I.typeReferenceNode({typeName:Vc})]:[I.typeReferenceNode({typeName:`TData`}),I.typeReferenceNode({typeName:`ThrowOnError`})],typeName:a.placeholder}),I.typeInterfaceNode({properties:[{comment:["You can provide a client instance returned by `createClient()` instead of",`individual options. This might be also useful if you want to implement a`,`custom client.`],isRequired:!e.config.client,name:`client`,type:I.typeReferenceNode({typeName:i.placeholder})},{comment:["You can pass arbitrary values through the `meta` object. This can be",`used to access values that aren't defined as part of the SDK function.`],isRequired:!1,name:`meta`,type:I.typeReferenceNode({typeArguments:[I.keywordTypeNode({keyword:`string`}),I.keywordTypeNode({keyword:`unknown`})],typeName:`Record`})}],useLegacyResolution:!1})]}),typeParameters:n?[I.typeParameterDeclaration({constraint:I.typeReferenceNode({typeName:e.referenceSymbol(e.api.selector(`Composable`)).placeholder}),defaultType:I.typeNode(`'$fetch'`),name:`TComposable`}),I.typeParameterDeclaration({constraint:I.typeReferenceNode({typeName:r.placeholder}),defaultType:I.typeReferenceNode({typeName:r.placeholder}),name:`TData`}),I.typeParameterDeclaration({defaultType:I.keywordTypeNode({keyword:`unknown`}),name:Hc}),I.typeParameterDeclaration({defaultType:I.keywordTypeNode({keyword:`undefined`}),name:Vc})]:[I.typeParameterDeclaration({constraint:I.typeReferenceNode({typeName:r.placeholder}),defaultType:I.typeReferenceNode({typeName:r.placeholder}),name:`TData`}),I.typeParameterDeclaration({constraint:I.keywordTypeNode({keyword:`boolean`}),defaultType:I.keywordTypeNode({keyword:`boolean`}),name:`ThrowOnError`})]});e.setSymbolValue(o,s)},Vu=({plugin:e})=>{let t=xl(e.context.config);e.registerSymbol({external:t,name:`formDataBodySerializer`,selector:e.api.selector(`formDataBodySerializer`)}),e.registerSymbol({external:t,name:`urlSearchParamsBodySerializer`,selector:e.api.selector(`urlSearchParamsBodySerializer`)}),e.registerSymbol({external:t,name:`buildClientParams`,selector:e.api.selector(`buildClientParams`)});let n=b(e.context.config),r=n.name===`@hey-api/client-angular`;n.name===`@hey-api/client-nuxt`&&e.registerSymbol({external:t,meta:{kind:`type`},name:`Composable`,selector:e.api.selector(`Composable`)}),r&&e.config.asClass&&e.registerSymbol({external:`@angular/core`,name:`Injectable`,selector:e.api.selector(`Injectable`)}),Bu({plugin:e}),e.config.asClass?Cu({plugin:e}):zu({plugin:e})},Hu=e=>Vu(e),Uu={api:new xu({name:`@hey-api/sdk`}),config:{asClass:!1,auth:!0,classNameBuilder:`{{name}}`,classStructure:`auto`,client:!0,exportFromIndex:!0,instance:!1,operationId:!0,params_EXPERIMENTAL:`default`,response:`body`,responseStyle:`fields`,transformer:!1,validator:!1},dependencies:[`@hey-api/typescript`],handler:Hu,handlerLegacy:Ru,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`)}},Wu=C(Uu);var Gu=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const Ku=({dataExpression:e,schema:t})=>{if(t.type!==`integer`||t.format!==`int64`)return;let n=e===void 0?void 0:I.callExpression({functionName:`BigInt`,parameters:[I.callExpression({functionName:I.propertyAccessExpression({expression:e,name:`toString`})})]});if(n){if(typeof e==`string`)return[n];if(e)return[I.assignment({left:e,right:n})]}},qu=({dataExpression:e,schema:t})=>{if(t.type!==`string`||!(t.format===`date`||t.format===`date-time`))return;let n=I.identifier({text:`Date`});if(typeof e==`string`)return[I.newExpression({argumentsArray:[I.identifier({text:e})],expression:n})];if(e)return[I.assignment({left:e,right:I.newExpression({argumentsArray:[e],expression:n})})]},Ju=`data`,Yu=e=>e.map(e=>m.default.isStatement(e)?e:I.expressionToStatement({expression:e})),Xu=({node:e})=>e.kind===m.default.SyntaxKind.ReturnStatement,Zu=({plugin:e,schema:t})=>{let n=I.identifier({text:Ju}),r=Qu({dataExpression:n,plugin:e,schema:t});return r.length&&!Xu({node:r[r.length-1]})&&r.push(I.returnStatement({expression:n})),r},Qu=({dataExpression:e,plugin:t,schema:n})=>{if(n.$ref){let r=t.api.selector(`response-ref`,n.$ref);if(!t.getSymbol(r)){let e=Zu({plugin:t,schema:t.context.resolveIrRef(n.$ref)});if(e.length){let i=t.registerSymbol({name:E({config:{case:`camelCase`,name:`{{name}}SchemaResponseTransformer`},name:L(n.$ref)}),selector:r}),a=I.constVariable({expression:I.arrowFunction({async:!1,multiLine:!0,parameters:[{name:Ju,type:I.keywordTypeNode({keyword:`any`})}],statements:Yu(e)}),name:i.placeholder});t.setSymbolValue(i,a)}}if(t.isSymbolRegistered(r)){let n=t.referenceSymbol(r),i=I.callExpression({functionName:n.placeholder,parameters:[e]});if(e)return typeof e==`string`&&e===`item`?[I.returnStatement({expression:i})]:[typeof e==`string`?i:I.assignment({left:e,right:i})]}return[]}if(n.type===`array`){if(!e||typeof e==`string`)return[];let r=n.items?Qu({dataExpression:`item`,plugin:t,schema:n.items?.[0]?n.items[0]:{...n,type:void 0}}):[];if(!r.length)return[];let i=Yu(r);return i.some(e=>Xu({node:e}))||i.push(I.returnStatement({expression:I.identifier({text:`item`})})),[I.assignment({left:e,right:I.callExpression({functionName:I.propertyAccessExpression({expression:e,name:`map`}),parameters:[I.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=I.propertyAccessExpression({expression:e||Ju,name:a}),c=Qu({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(I.ifStatement({expression:s,thenStatement:I.block({statements:Yu(c)})}))}return r}if(n.items){if(n.items.length===1)return Qu({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=Qu({dataExpression:e||`item`,plugin:t,schema:i});if(n.length)if(e)r=r.concat(n);else{let e=I.identifier({text:`item`});r.push(I.ifStatement({expression:e,thenStatement:I.block({statements:Yu(n)})}),I.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[]},$u=({plugin:e})=>{e.forEach(`operation`,({operation:t})=>{let{response:n}=ut(t);if(!n)return;if(n.items&&n.items.length>1){e.context.config.logs.level===`debug`&&console.warn(`❗️ Transformers warning: route ${k(t)} has ${n.items.length} non-void success responses. This is currently not handled and we will not generate a response transformer. Please open an issue if you'd like this feature https://github.com/hey-api/openapi-ts/issues`);return}let r=e.getPluginOrThrow(`@hey-api/typescript`),i=e.getSymbol(r.api.selector(`response`,t.id));if(!i)return;let a=Zu({plugin:e,schema:n});if(!a.length)return;let o=e.registerSymbol({exported:!0,name:E({config:{case:`camelCase`,name:`{{name}}ResponseTransformer`},name:t.id}),selector:e.api.selector(`response`,t.id)}),s=I.constVariable({exportConst:o.exported,expression:I.arrowFunction({async:!0,multiLine:!0,parameters:[{name:Ju,type:I.keywordTypeNode({keyword:`any`})}],returnType:I.typeReferenceNode({typeArguments:[I.typeReferenceNode({typeName:i.placeholder})],typeName:`Promise`}),statements:Yu(a)}),name:o.placeholder});e.setSymbolValue(o,s)},{order:`declarations`})},ed=`$OpenApiTs`,K={$refs:[],base:``,description:null,enum:[],enums:[],export:`interface`,imports:[],in:``,isDefinition:!1,isNullable:!1,isReadOnly:!1,isRequired:!1,link:null,name:``,properties:[],template:null,type:``},td=({comments:e,leadingComment:t,meta:n,obj:r,onNode:i,...a})=>{if(!n)return;let{created:o,name:s}=Vs({create:!0,meta:n,...a});if(o){let n=x().plugins[`@hey-api/typescript`];i(I.enumDeclaration({asConst:typeof n?.config.enums==`object`&&n.config.enums.mode===`typescript-const`,comments:e,leadingComment:t,name:s,obj:r}))}},nd=({comment:e,meta:t,onCreated:n,onNode:r,type:i,...a})=>{if(!t)return{created:!1,name:``};let o=Vs({create:!0,meta:t,...a}),{created:s,name:c}=o;return s&&(r(I.typeAliasDeclaration({comment:e,exportType:!0,name:c,type:i})),n?.(c)),o},rd=e=>{let t=[];od(e),e.model.enums.forEach(n=>ad({...e,model:n,onNode:e=>{t.push(e)}})),t.length&&e.onNode(I.namespaceDeclaration({name:e.model.name,statements:t}))},id=({client:e,model:t,onNode:n})=>{let r=x(),i={},a={};t.enum.forEach(e=>{let{key:t,value:n}=Os(e);i[t]=n;let r=e.customDescription||e.description;r&&(a[t]=[j(r)])});let o=[t.description&&j(t.description),t.deprecated&&`@deprecated`],s=r.plugins[`@hey-api/typescript`];if(s?.config&&typeof s.config.enums==`object`&&s.config.enums.enabled&&(s.config.enums.mode===`typescript`||s.config.enums.mode===`typescript-const`)){td({asConst:s.config.enums.mode===`typescript-const`,client:e,comments:a,leadingComment:o,meta:t.meta,obj:i,onNode:n});return}nd({client:e,comment:o,meta:t.meta,onCreated:e=>{let t=r.plugins[`@hey-api/typescript`];if(t?.config&&typeof t.config.enums==`object`&&t.config.enums.enabled&&t.config.enums.mode===`javascript`){let t=I.objectExpression({multiLine:!0,obj:Object.entries(i).map(([e,t])=>({comments:a[e],key:e,value:t})),unescape:!0});n(I.constVariable({assertion:`const`,comment:o,exportConst:!0,expression:t,name:e}))}},onNode:n,type:Es(t.enum)})},ad=({model:e,onNode:t})=>{let n={},r={};e.enum.forEach(e=>{let{key:t,value:i}=Os(e);n[t]=i;let a=e.customDescription||e.description;a&&(r[t]=[j(a)])});let i=x().plugins[`@hey-api/typescript`];t(I.enumDeclaration({asConst:typeof i?.config.enums==`object`&&i.config.enums.mode===`typescript-const`,comments:r,leadingComment:[e.description&&j(e.description),e.deprecated&&`@deprecated`],name:e.meta?.name||e.name,obj:n}))},od=({client:e,model:t,onNode:n})=>{nd({client:e,comment:[t.description&&j(t.description),t.deprecated&&`@deprecated`],meta:t.meta,onNode:n,type:Bs(t)})},sd=e=>{switch(e.model.export){case`all-of`:case`any-of`:case`one-of`:case`interface`:return rd(e);case`enum`:return id(e);default:return od(e)}},cd=({client:e,onNode:t})=>{let n={},r=x();if(!r.plugins[`@hey-api/sdk`]&&!r.plugins[`@hey-api/typescript`]?.config.tree)return;let i=S(r);for(let r of e.services)for(let a of r.operations){if(!a.parameters.length&&!a.responses.length)continue;n[a.path]||(n[a.path]={});let r=n[a.path];r[a.method]||(r[a.method]={});let o=r[a.method];if(o.$ref=a.name,a.responses.length>0){if(o.res||={},Array.isArray(o.res))continue;a.responses.forEach(e=>{o.res[e.code]=e})}if(a.parameters.length>0){let n={mediaType:null,...K,in:`body`,name:`body`,prop:`body`},r=a.parameters.filter(e=>e.in===`body`);r.length||(r=a.parameters.filter(e=>e.in===`formData`)),r.length===1?n={...K,...r[0],in:`body`,isRequired:r[0].isRequired,name:`body`,prop:`body`}:r.length>1&&(n={...K,in:`body`,isRequired:r.some(e=>e.isRequired),mediaType:`multipart/form-data`,name:`body`,prop:`body`,properties:r});let s={...K,in:`header`,isRequired:Gs(a.parameters.filter(e=>e.in===`header`)),mediaType:null,name:i?`header`:`headers`,prop:i?`header`:`headers`,properties:a.parameters.filter(e=>e.in===`header`).sort(Cs)},c={...K,in:`path`,isRequired:Gs(a.parameters.filter(e=>e.in===`path`)),mediaType:null,name:`path`,prop:`path`,properties:a.parameters.filter(e=>e.in===`path`).sort(Cs)},l={...K,in:`query`,isRequired:Gs(a.parameters.filter(e=>e.in===`query`)),mediaType:null,name:`query`,prop:`query`,properties:a.parameters.filter(e=>e.in===`query`).sort(Cs)},u=i?ws([...a.parameters]):[n,s,c,l].filter(e=>e.properties.length||e.$refs.length||e.mediaType);o.req=u,nd({client:e,meta:{$ref:a.name,name:a.name},nameTransformer:Eu,onNode:t,type:Bs({...K,isRequired:!0,properties:u})})}let s=a.responses.filter(e=>e.responseTypes.includes(`success`));if(s.length>0){nd({client:e,meta:{$ref:a.name,name:a.name},nameTransformer:ku,onNode:t,type:Bs({...K,export:`any-of`,isRequired:!0,properties:s})});let n=a.responses.filter(e=>e.responseTypes.includes(`error`));i||nd({client:e,meta:{$ref:a.name,name:a.name},nameTransformer:Du,onNode:t,type:Bs(n.length?{...K,export:`one-of`,isRequired:!0,properties:n}:{...K,base:`unknown`,isRequired:!0,type:`unknown`})})}}let a=Object.entries(n).map(([t,n])=>{let r=Object.entries(n).map(([t,n])=>{let r=t,i=[];if(n.req){let t=n.$ref,{name:r}=Vs({client:e,meta:{$ref:t,name:t},nameTransformer:Eu}),a={...K,base:r,export:`reference`,isRequired:!0,name:`req`,properties:[],type:r};i=[...i,a]}if(n.res){let e=Object.entries(n.res).map(([e,t])=>({...K,...t,isRequired:!0,name:String(e)})),t={...K,isRequired:!0,name:`res`,properties:e};i=[...i,t]}return{...K,isRequired:!0,name:r.toLocaleLowerCase(),properties:i}}).filter(Boolean);return{...K,isRequired:!0,name:`'${t}'`,properties:r}});r.plugins[`@hey-api/typescript`]?.config.tree&&nd({client:e,meta:{$ref:`@hey-api/openapi-ts`,name:`$OpenApiTs`},onNode:t,type:Bs({...K,properties:a})})},ld=({client:e,files:t,plugin:n})=>{t.types=new mu({dir:x().output.path,exportFromIndex:n.config.exportFromIndex,id:`types`,name:`types.ts`});let r=e=>{t.types?.add(e)};for(let t of e.models)sd({client:e,model:t,onNode:r});cd({client:e,onNode:r})},ud=`data`,dd=e=>e.base===`unknown`&&e.export===`generic`&&e.type===`unknown`,fd=({client:e,model:t})=>t.$refs.map(t=>{let n=e.models.find(e=>e.meta?.$ref===t);if(!n)throw Error(`Ref ${t} could not be found. Transformers cannot be generated without having access to all refs.`);return n}),pd=e=>{let t=e.model.meta.name,{name:n}=nd({...e,meta:{$ref:`transformers/${t}`,name:t},nameTransformer:Tu,onCreated:n=>{let r=gd({...e,meta:{$ref:`transformers/${t}`,name:n},path:[ud]});_d({...e,async:!1,name:n,statements:r})},type:`(${ud}: any) => ${t}`});return{created:!!e.client.types[n],name:n}},md=e=>{let{model:t}=e,n=fd(e);if(n.length===1){let{created:t,name:r}=pd({...e,model:n[0]});return t?[I.transformArrayMutation({path:e.path,transformerName:r})]:[]}return Ms(t)||t.link&&!Array.isArray(t.link)&&t.link.export===`any-of`&&t.link.properties.find(e=>Ms(e))?[I.transformArrayMap({path:e.path,transformExpression:I.conditionalExpression({condition:I.identifier({text:`item`}),whenFalse:I.identifier({text:`item`}),whenTrue:I.transformNewDate({parameterName:`item`})})})]:[]},hd=e=>{let{model:t}=e,n=[...e.path,t.name];return t.type===`string`&&t.export!==`array`&&Ms(t)?[I.transformDateMutation({path:n})]:gd({...e,model:t,path:n})},gd=e=>{let{model:t}=e;switch(t.export){case`array`:return md(e);case`interface`:return t.properties.flatMap(t=>hd({...e,model:t}));case`reference`:{if(t.$refs.length!==1)return[];let n=fd(e),{created:r,name:i}=pd({...e,model:n[0]});return r?t.in===`response`?[I.expressionToStatement({expression:I.callExpression({functionName:i,parameters:[ud]})})]:I.transformFunctionMutation({path:e.path,transformerName:i}):[]}default:return[]}},_d=({async:e,client:t,name:n,onNode:r,onRemoveNode:i,statements:a})=>{let o={created:!1,name:n};if(!a.length)return Hs({client:t,name:n}),i?.(),o;let s=I.arrowFunction({async:e,multiLine:!0,parameters:[{name:ud}],statements:[...a,I.returnVariable({expression:ud})]});return r(I.constVariable({exportConst:!0,expression:s,name:n,typeName:n})),{created:!0,name:n}},vd=({client:e,files:t})=>{let n=x(),r=e=>{t.types?.add(e)},i=()=>{t.types?.removeNode_LEGACY()};for(let t of e.services)for(let a of t.operations){let t=a.responses.filter(e=>e.responseTypes.includes(`success`));if(!t.length)continue;let o=t.filter(e=>!dd(e));if(!o.length)continue;if(o.length>1){n.logs.level===`debug`&&console.warn(`❗️ Transformers warning: route ${k(a)} has ${o.length} non-void success responses. This is currently not handled and we will not generate a response transformer. Please open an issue if you'd like this feature https://github.com/hey-api/openapi-ts/issues`);continue}let s=ku(a.name);nd({client:e,meta:{$ref:`transformers/${s}`,name:s},nameTransformer:Ou,onCreated:n=>{_d({async:!0,client:e,name:n,onNode:r,onRemoveNode:i,statements:t.length>1?t.flatMap(t=>{let n=gd({client:e,meta:{$ref:`transformers/${s}`,name:s},model:t,onNode:r,onRemoveNode:i,path:[ud]});return n.length?[I.ifStatement({expression:I.safeAccessExpression([`data`]),thenStatement:I.block({statements:n})})]:[]}):gd({client:e,meta:{$ref:`transformers/${s}`,name:s},model:t[0],onNode:r,onRemoveNode:i,path:[ud]})})},onNode:r,type:`(${ud}: any) => Promise<${s}>`})}},yd={api:new Gu({name:`@hey-api/transformers`}),config:{bigInt:!0,dates:!0,exportFromIndex:!1,transformers:[],typeTransformers:[]},dependencies:[`@hey-api/typescript`],handler:$u,handlerLegacy:vd,name:`@hey-api/transformers`,resolveConfig:e=>{e.config.transformers||(e.config.transformers=[]),e.config.dates&&(e.config.transformers=[...e.config.transformers,qu]),e.config.bigInt&&(e.config.transformers=[...e.config.transformers,Ku])},tags:[`transformer`]},bd=C(yd),q=e=>({value:e}),J=e=>{let t={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=q(e[n]));return t},xd=I.keywordTypeNode({keyword:`string`}),Sd=({server:e})=>{let t=ya(e.url);return t.protocol&&t.host?I.literalTypeNode({literal:I.stringLiteral({text:e.url})}):I.templateLiteralType({value:[t.protocol||xd,`://`,t.host||xd,t.port?`:${t.port}`:``,t.path||``]})},Cd=({plugin:e,servers:t,symbolClientOptions:n})=>{let r=b(e.context.config),i=t.map(e=>Sd({server:e}));t.length?`strictBaseUrl`in r.config&&r.config.strictBaseUrl||i.push(I.typeIntersectionNode({types:[xd,m.default.factory.createTypeLiteralNode([])]})):i.push(xd);let a=I.typeInterfaceNode({properties:[{name:he(e.context.config),type:I.typeUnionNode({types:i})}],useLegacyResolution:!1}),o=I.typeAliasDeclaration({exportType:n.exported,name:n.placeholder,type:a});e.setSymbolValue(n,o)},wd=({schema:e})=>{let t=[];return e.title&&t.push(j(e.title)),e.description&&(t.length&&t.push(``),t.push(j(e.description))),e.deprecated&&(t.length&&t.push(``),t.push(`@deprecated`)),t.length?t:void 0},Td=({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=T({case:e.config.enums.case,stripLeadingSeparators:!1,value:a}),A.lastIndex=0,A.test(a)&&e.config.enums.enabled&&(e.config.enums.mode===`typescript`||e.config.enums.mode===`typescript-const`)&&(a=`_${a}`)),{comments:wd({schema:t}),key:a,value:t.const}}),typeofItems:n}},Ed=({plugin:e,schema:t,symbol:n,type:r})=>{if(t.type===`enum`&&e.config.enums.enabled){let r=Td({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=I.constVariable({assertion:`const`,comment:wd({schema:t}),exportConst:!0,expression:I.objectExpression({multiLine:!0,obj:r.obj}),name:n.placeholder}),a=I.typeOfExpression({text:n.placeholder}),o=I.typeAliasDeclaration({comment:wd({schema:t}),exportType:!0,name:n.placeholder,type:I.indexedAccessTypeNode({indexType:I.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=I.enumDeclaration({asConst:e.config.enums.mode===`typescript-const`,leadingComment:wd({schema:t}),name:n.placeholder,obj:r.obj});e.setSymbolValue(n,i);return}}let i=I.typeAliasDeclaration({comment:wd({schema:t}),exportType:n.exported,name:n.placeholder,type:r});e.setSymbolValue(n,i)},Dd=({parameters:e})=>{let t={type:`object`};if(e){let n={},r=[];for(let t in e){let i=e[t];n[i.name]=D({detectFormat:!1,schema:i.schema}),i.required&&r.push(i.name)}t.properties=n,r.length&&(t.required=r)}return t},Od=({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=Dd({parameters:e.parameters.header}),r.properties.headers.required&&i.push(`headers`)),e.parameters?.path?(r.properties.path=Dd({parameters:e.parameters.path}),r.properties.path.required&&i.push(`path`)):r.properties.path={type:`never`},e.parameters?.query?(r.properties.query=Dd({parameters:e.parameters.query}),r.properties.query.required&&i.push(`query`)):r.properties.query={type:`never`},r.properties.url={const:e.path,type:`string`},i.push(`url`),r.required=i;let a=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:E({config:t.config.requests,name:e.id}),selector:t.api.selector(`data`,e.id)}),o=Y({plugin:t,schema:r,state:n}),s=I.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:o});t.setSymbolValue(a,s)},kd=({operation:e,plugin:t,state:n})=>{Od({operation:e,plugin:t,state:n});let{error:r,errors:i,response:a,responses:o}=ut(e);if(i){let a=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:E({config:t.config.errors,name:e.id}),selector:t.api.selector(`errors`,e.id)}),o=Y({plugin:t,schema:i,state:n}),s=I.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:o});if(t.setSymbolValue(a,s),r){let r=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:E({config:{case:t.config.errors.case,name:t.config.errors.error},name:e.id}),selector:t.api.selector(`error`,e.id)}),i=I.indexedAccessTypeNode({indexType:I.typeOperatorNode({operator:`keyof`,type:I.typeReferenceNode({typeName:a.placeholder})}),objectType:I.typeReferenceNode({typeName:a.placeholder})}),o=I.typeAliasDeclaration({exportType:r.exported,name:r.placeholder,type:i});t.setSymbolValue(r,o)}}if(o){let r=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:E({config:t.config.responses,name:e.id}),selector:t.api.selector(`responses`,e.id)}),i=Y({plugin:t,schema:o,state:n}),s=I.typeAliasDeclaration({exportType:r.exported,name:r.placeholder,type:i});if(t.setSymbolValue(r,s),a){let i=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:E({config:{case:t.config.responses.case,name:t.config.responses.response},name:e.id}),selector:t.api.selector(`response`,e.id)}),a=I.indexedAccessTypeNode({indexType:I.typeOperatorNode({operator:`keyof`,type:I.typeReferenceNode({typeName:r.placeholder})}),objectType:I.typeReferenceNode({typeName:r.placeholder})}),o=I.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:a});t.setSymbolValue(i,o)}}},Ad=({operation:e,plugin:t,state:n})=>{let r={type:`object`},i=[];if(r.properties||={},e.body){let a=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:E({config:{case:t.config.webhooks.case,name:t.config.webhooks.payload},name:e.id}),selector:t.api.selector(`webhook-payload`,e.id)}),o=Y({plugin:t,schema:e.body.schema,state:n}),s=I.typeAliasDeclaration({comment:wd({schema:e.body.schema}),exportType:a.exported,name:a.placeholder,type:o});t.setSymbolValue(a,s),t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:a.name,placeholder:a.placeholder,selector:t.api.selector(`ref`,a.placeholder)}),r.properties.body={$ref:a.placeholder},i.push(`body`)}else r.properties.body={type:`never`};r.properties.key={const:e.path,type:`string`},i.push(`key`),r.properties.path={type:`never`},r.properties.query={type:`never`},r.required=i;let a=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:E({config:t.config.webhooks,name:e.id}),selector:t.api.selector(`webhook-request`,e.id)}),o=Y({plugin:t,schema:r,state:n}),s=I.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:o});return t.setSymbolValue(a,s),a.placeholder},jd=({operation:e,plugin:t,state:n})=>Ad({operation:e,plugin:t,state:n}),Md=({plugin:e,symbolWebhooks:t,webhookNames:n})=>{if(!n.length)return;let r=I.typeUnionNode({types:n.map(e=>I.typeReferenceNode({typeName:e}))}),i=I.typeAliasDeclaration({exportType:t.exported,name:t.placeholder,type:r});e.setSymbolValue(t,i)},Nd=({plugin:e,schema:t,state:n})=>{if(!t.items)return I.typeArrayNode(I.keywordTypeNode({keyword:e.config.topType}));t=D({detectFormat:!0,schema:t});let r=[];return t.items&&t.items.forEach((t,i)=>{let a=Y({plugin:e,schema:t,state:{...n,path:q([...n.path.value,`items`,i])}});r.push(a)}),r.length===1?I.typeArrayNode(r[0]):t.logicalOperator===`and`?I.typeArrayNode(I.typeIntersectionNode({types:r})):I.typeArrayNode(I.typeUnionNode({types:r}))},Pd=({schema:e})=>e.const===void 0?I.keywordTypeNode({keyword:`boolean`}):I.literalTypeNode({literal:I.ots.boolean(e.const)}),Fd=({plugin:e,schema:t,state:n})=>Y({plugin:e,schema:{...t,type:void 0},state:n}),Id=e=>I.keywordTypeNode({keyword:`never`}),Ld=e=>I.literalTypeNode({literal:I.null()}),Rd=({plugin:e,schema:t})=>t.const===void 0?t.type===`integer`&&t.format===`int64`&&e.getPlugin(`@hey-api/transformers`)?.config.bigInt?I.typeReferenceNode({typeName:`bigint`}):I.keywordTypeNode({keyword:`number`}):I.literalTypeNode({literal:I.ots.number(t.const)}),zd=({context:e,name:t})=>(A.lastIndex=0,A.test(t)?t.startsWith(`-`)?m.default.factory.createStringLiteral(t):m.default.factory.createNumericLiteral(t):T({case:e.config.output.case,value:t})),Bd=({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=Y({plugin:e,schema:i,state:{...n,path:q([...n.path.value,`properties`,r])}}),u=s.includes(r);a.push({comment:wd({schema:i}),isReadOnly:i.accessScope===`read`,isRequired:u,name:zd({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?Y({plugin:e,schema:o[0],state:n}):Y({plugin:e,schema:{items:o,logicalOperator:`or`},state:n})},t.propertyNames?.$ref&&(r=Y({plugin:e,schema:{$ref:t.propertyNames.$ref},state:n}))}return I.typeInterfaceNode({indexKey:r,indexProperty:i,properties:a,useLegacyResolution:!1})},Vd=({plugin:e,schema:t})=>{if(t.const!==void 0)return I.literalTypeNode({literal:I.stringLiteral({text:t.const})});if(t.format){if(t.format===`binary`)return I.typeUnionNode({types:[I.typeReferenceNode({typeName:`Blob`}),I.typeReferenceNode({typeName:`File`})]});if((t.format===`date-time`||t.format===`date`)&&e.getPlugin(`@hey-api/transformers`)?.config.dates)return I.typeReferenceNode({typeName:`Date`});if(t.format===`typeid`&&typeof t.example==`string`){let n=String(t.example).split(`_`);n.pop();let r=n.join(`_`),i=e.api.selector(`TypeID`,r);if(!e.getSymbol(i)){let t=e.api.selector(`TypeID`);if(!e.getSymbol(t)){let n=e.registerSymbol({exported:!0,meta:{kind:`type`,path:[]},name:`TypeID`,selector:t}),r=I.typeAliasDeclaration({exportType:n.exported,name:n.placeholder,type:I.templateLiteralType({value:[I.typeReferenceNode({typeName:`T`}),`_`,I.keywordTypeNode({keyword:`string`})]}),typeParameters:[I.typeParameterDeclaration({constraint:I.keywordTypeNode({keyword:`string`}),name:`T`})]});e.setSymbolValue(n,r)}let n=e.referenceSymbol(t),a=e.registerSymbol({exported:!0,meta:{kind:`type`,path:[]},name:T({case:e.config.case,value:`${r}_id`}),selector:i}),o=I.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:I.typeReferenceNode({typeArguments:[I.literalTypeNode({literal:I.stringLiteral({text:r})})],typeName:n.placeholder})});e.setSymbolValue(a,o)}let a=e.referenceSymbol(i);return I.typeReferenceNode({typeName:a.placeholder})}}return I.keywordTypeNode({keyword:`string`})},Hd=({plugin:e,schema:t,state:n})=>{let r=[];return t.const&&Array.isArray(t.const)?r=t.const.map(t=>I.valueToExpression({value:t})??I.identifier({text:e.config.topType})):t.items&&t.items.forEach((t,i)=>{let a=Y({plugin:e,schema:t,state:{...n,path:q([...n.path.value,`items`,i])}});r.push(a)}),I.typeTupleNode({types:r})},Ud=e=>I.keywordTypeNode({keyword:`undefined`}),Wd=({plugin:e})=>I.keywordTypeNode({keyword:e.config.topType}),Gd=e=>I.keywordTypeNode({keyword:`void`}),Kd=({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 Nd({...t,schema:e});case`boolean`:return Pd({...t,schema:e});case`enum`:return Fd({...t,schema:e});case`integer`:case`number`:return Rd({...t,schema:e});case`never`:return Id({...t,schema:e});case`null`:return Ld({...t,schema:e});case`object`:return Bd({...t,schema:e});case`string`:return Vd({...t,schema:e});case`tuple`:return Hd({...t,schema:e});case`undefined`:return Ud({...t,schema:e});case`unknown`:return Wd({...t,schema:e});case`void`:return Gd({...t,schema:e})}},Y=({plugin:e,schema:t,state:n})=>{if(t.$ref){let n=e.referenceSymbol(e.api.selector(`ref`,t.$ref));return I.typeReferenceNode({typeName:n.placeholder})}if(t.type)return Kd({plugin:e,schema:t,state:n});if(t.items){if(t=D({detectFormat:!1,schema:t}),t.items){let r=[];for(let i of t.items){let t=Y({plugin:e,schema:i,state:n});r.push(t)}return t.logicalOperator===`and`?I.typeIntersectionNode({types:r}):I.typeUnionNode({types:r})}return Y({plugin:e,schema:t,state:n})}return Kd({plugin:e,schema:{type:`unknown`},state:n})},qd=({plugin:e,schema:t,state:n})=>{let r=Y({plugin:e,schema:t,state:n}),i=t.type===`enum`&&e.config.enums.enabled,a=mr(n.path.value);Ed({plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{kind:i?void 0:`type`,path:n.path.value,tags:n.tags?.value},name:E({config:e.config.definitions,name:L(a)}),selector:e.api.selector(`ref`,a)}),type:r})},Jd=({plugin:e})=>{let t=e.registerSymbol({exported:!0,meta:{kind:`type`,path:[]},name:E({config:{case:e.config.case},name:`ClientOptions`}),selector:e.api.selector(`ClientOptions`)}),n=e.registerSymbol({exported:!0,meta:{kind:`type`,path:[]},name:E({config:{case:e.config.case},name:`Webhooks`}),selector:e.api.selector(`Webhooks`)}),r=[],i=[];e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`server`,`webhook`,t=>{let n=J({path:t._path,tags:t.tags});switch(t.type){case`operation`:kd({operation:t.operation,plugin:e,state:n});break;case`parameter`:qd({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:qd({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:qd({plugin:e,schema:t.schema,state:n});break;case`server`:r.push(t.server);break;case`webhook`:i.push(jd({operation:t.operation,plugin:e,state:n}));break}},{order:`declarations`}),Cd({plugin:e,servers:r,symbolClientOptions:t}),Md({plugin:e,symbolWebhooks:n,webhookNames:i})};var Yd=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}schemaToType(e){return Y(e)}};const Xd=e=>Jd(e),Zd={api:new Yd({name:`@hey-api/typescript`}),config:{case:`PascalCase`,exportFromIndex:!0,style:`preserve`,topType:`unknown`,tree:!1},handler:Xd,handlerLegacy:ld,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})}},Qd=C(Zd);var $d=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const ef=(e,t,n)=>{let r=e.config[n].meta;if(!r)return;let i=r(t);if(Object.keys(i).length)return I.valueToExpression({value:i})},tf=({operation:e,plugin:t})=>Jc({operation:e,plugin:t.getPluginOrThrow(`@hey-api/sdk`)}),nf=({operation:e,plugin:t})=>{let n=b(t.context.config),r=t.getPluginOrThrow(`@hey-api/typescript`),i=t.getSymbol(r.api.selector(`error`,e.id))?.placeholder;return i||=`Error`,n.name===`@hey-api/client-axios`&&(i=`${t.referenceSymbol(t.api.selector(`AxiosError`)).placeholder}<${i}>`),i},rf=({operation:e,plugin:t})=>{let n=t.getPluginOrThrow(`@hey-api/typescript`);return t.getSymbol(n.api.selector(`response`,e.id))?.placeholder||`unknown`},af=({plugin:e,typeData:t})=>{let n=b(e.context.config).name===`@hey-api/client-nuxt`;return{isNuxtClient:n,strippedTypeData:n?`Omit<${t}, 'composable'>`:t}},of=({operation:e,plugin:t,queryFn:n})=>{let r=t.referenceSymbol(t.api.selector(`UseMutationOptions`)),i=tf({operation:e,plugin:t}),a=nf({operation:e,plugin:t}),o=rf({operation:e,plugin:t}),{isNuxtClient:s,strippedTypeData:c}=af({plugin:t,typeData:i}),l=s?`${r.placeholder}<${o}, ${c}, ${a}>`:`${r.placeholder}<${o}, ${i}, ${a}>`,u=`fnOptions`,d=I.awaitExpression({expression:I.callExpression({functionName:n,parameters:[I.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:u},{key:`throwOnError`,value:!0}]})]})}),f=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?f.push(I.returnVariable({expression:d})):f.push(I.constVariable({destructure:!0,expression:d,name:`data`}),I.returnVariable({expression:`data`}));let p=[{key:`mutation`,value:I.arrowFunction({async:!0,multiLine:!0,parameters:[s?{name:u,type:`Partial<${c}>`}:{name:u}],statements:f})}],m=ef(t,e,`mutationOptions`);m&&p.push({key:`meta`,value:m});let h=t.registerSymbol({exported:!0,name:E({config:t.config.mutationOptions,name:e.id})}),g=I.constVariable({comment:t.config.comments?Qc({operation:e}):void 0,exportConst:h.exported,expression:I.arrowFunction({parameters:[{isRequired:!1,name:`options`,type:`Partial<${c}>`}],returnType:l,statements:[I.returnStatement({expression:I.objectExpression({obj:p})})]}),name:h.placeholder});t.setSymbolValue(h,g)},sf=`TOptions`,cf=I.identifier({text:`options`}),lf=({plugin:e})=>{let t=e.registerSymbol({name:E({config:{case:e.config.case},name:`createQueryKey`}),selector:e.api.selector(`createQueryKey`)}),n=e.referenceSymbol(e.api.selector(`QueryKey`)),r=e.referenceSymbol(e.api.selector(`_JSONValue`)),i=I.indexedAccessTypeNode({indexType:I.literalTypeNode({literal:I.ots.number(0)}),objectType:I.typeReferenceNode({typeArguments:[I.typeReferenceNode({typeName:sf})],typeName:n.placeholder})}),a=he(e.context.config),o=e.getPluginOrThrow(`@hey-api/sdk`),s=e.referenceSymbol(o.api.selector(`Options`)),c=b(e.context.config),l=c.api&&`selector`in c.api?e.getSymbol(c.api.selector(`client`)):void 0,u=xl(e.context.config),d=e.registerSymbol({external:u,name:`serializeQueryKeyValue`}),f=I.constVariable({expression:I.arrowFunction({multiLine:!0,parameters:[{name:`id`,type:I.typeReferenceNode({typeName:`string`})},{isRequired:!1,name:`options`,type:I.typeReferenceNode({typeName:sf})},{isRequired:!1,name:`tags`,type:I.typeReferenceNode({typeName:`ReadonlyArray<string>`})}],returnType:I.typeTupleNode({types:[i]}),statements:[I.constVariable({assertion:i,expression:I.objectExpression({multiLine:!1,obj:[{key:`_id`,value:I.identifier({text:`id`})},{key:a,value:I.identifier({text:`options?.${a} || (options?.client ?? ${l?.placeholder}).getConfig().${a}`})}]}),name:`params`,typeName:i}),I.ifStatement({expression:I.identifier({text:`tags`}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`tags`}),right:I.asExpression({expression:I.asExpression({expression:I.identifier({text:`tags`}),type:I.keywordTypeNode({keyword:`unknown`})}),type:I.typeReferenceNode({typeName:r.placeholder})})})})]})}),I.ifStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:cf,isOptional:!0,name:I.identifier({text:`body`})}),operator:`!==`,right:`undefined`}),thenStatement:I.block({statements:[I.constVariable({expression:I.callExpression({functionName:d.placeholder,parameters:[I.propertyAccessExpression({expression:`options`,name:`body`})]}),name:`normalizedBody`}),I.ifStatement({expression:I.binaryExpression({left:I.identifier({text:`normalizedBody`}),operator:`!==`,right:`undefined`}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`body`}),right:I.identifier({text:`normalizedBody`})})})]})})]})}),I.ifStatement({expression:I.propertyAccessExpression({expression:cf,isOptional:!0,name:I.identifier({text:`path`})}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`path`}),right:I.propertyAccessExpression({expression:`options`,name:`path`})})})]})}),I.ifStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:cf,isOptional:!0,name:I.identifier({text:`query`})}),operator:`!==`,right:`undefined`}),thenStatement:I.block({statements:[I.constVariable({expression:I.callExpression({functionName:d.placeholder,parameters:[I.propertyAccessExpression({expression:`options`,name:`query`})]}),name:`normalizedQuery`}),I.ifStatement({expression:I.binaryExpression({left:I.identifier({text:`normalizedQuery`}),operator:`!==`,right:`undefined`}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`query`}),right:I.identifier({text:`normalizedQuery`})})})]})})]})}),I.returnStatement({expression:I.arrayLiteralExpression({elements:[I.identifier({text:`params`})]})})],types:[{extends:I.typeReferenceNode({typeName:I.identifier({text:s.placeholder})}),name:sf}]}),name:t.placeholder});e.setSymbolValue(t,f)},uf=({id:e,operation:t,plugin:n})=>{let r=n.config.queryKeys,i;r.tags&&t.tags&&t.tags.length>0&&(i=I.arrayLiteralExpression({elements:t.tags.map(e=>I.stringLiteral({text:e}))}));let a=n.referenceSymbol(n.api.selector(`createQueryKey`));return I.callExpression({functionName:a.placeholder,parameters:[I.ots.string(e),`options`,i]})},df=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`_JSONValue`)),n=[{name:`_id`,type:I.keywordTypeNode({keyword:`string`})},{isRequired:!1,name:he(e.context.config),type:I.typeReferenceNode({typeName:t.placeholder})},{isRequired:!1,name:`body`,type:I.typeReferenceNode({typeName:t.placeholder})},{isRequired:!1,name:`query`,type:I.typeReferenceNode({typeName:t.placeholder})},{isRequired:!1,name:`tags`,type:I.typeReferenceNode({typeName:t.placeholder})}],r=e.getPluginOrThrow(`@hey-api/sdk`),i=e.referenceSymbol(r.api.selector(`Options`)),a=e.registerSymbol({exported:!0,meta:{kind:`type`},name:`QueryKey`,selector:e.api.selector(`QueryKey`)}),o=I.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:I.typeTupleNode({types:[I.typeIntersectionNode({types:[I.typeReferenceNode({typeName:`Pick<${sf}, 'path'>`}),I.typeInterfaceNode({properties:n,useLegacyResolution:!0})]})]}),typeParameters:[{extends:I.typeReferenceNode({typeName:I.identifier({text:i.placeholder})}),name:sf}]});e.setSymbolValue(a,o)},ff=({operation:e,plugin:t,symbol:n})=>{let{strippedTypeData:r}=af({plugin:t,typeData:tf({operation:e,plugin:t})});return I.constVariable({exportConst:n.exported,expression:I.arrowFunction({parameters:[{isRequired:st(e),name:`options`,type:r}],statements:uf({id:e.id,operation:e,plugin:t})}),name:n.placeholder})},pf=`options`,mf=`context`,hf=({operation:e,plugin:t,queryFn:n})=>{if(el({operation:e}))return;let r=$c({context:t.context,operation:e});t.getSymbol(t.api.selector(`createQueryKey`))||(df({plugin:t}),lf({plugin:t}));let i;if(t.config.queryKeys.enabled){let n=t.registerSymbol({exported:!0,name:E({config:t.config.queryKeys,name:e.id})}),r=ff({operation:e,plugin:t,symbol:n});t.setSymbolValue(n,r),i=I.callExpression({functionName:n.placeholder,parameters:[pf]})}else{let n=t.referenceSymbol(t.api.selector(`createQueryKey`)),r;t.config.queryKeys.tags&&e.tags&&e.tags.length>0&&(r=I.arrayLiteralExpression({elements:e.tags.map(e=>I.stringLiteral({text:e}))})),i=I.callExpression({functionName:n.placeholder,parameters:[I.ots.string(e.id),pf,r]})}let{strippedTypeData:a}=af({plugin:t,typeData:tf({operation:e,plugin:t})}),o=I.awaitExpression({expression:I.callExpression({functionName:n,parameters:[I.objectExpression({multiLine:!0,obj:[{spread:pf},{spread:mf},{key:`throwOnError`,value:!0}]})]})}),s=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?s.push(I.returnVariable({expression:o})):s.push(I.constVariable({destructure:!0,expression:o,name:`data`}),I.returnVariable({expression:`data`}));let c=[{key:`key`,value:i},{key:`query`,value:I.arrowFunction({async:!0,multiLine:!0,parameters:[{name:mf}],statements:s})}],l=ef(t,e,`queryOptions`);l&&c.push({key:`meta`,value:l});let u=t.registerSymbol({exported:!0,name:E({config:t.config.queryOptions,name:e.id}),selector:t.api.selector(`queryOptionsFn`,e.id)}),d=t.registerSymbol({external:t.name,name:`defineQueryOptions`,selector:t.api.selector(`defineQueryOptions`)}),f=I.constVariable({comment:t.config.comments?Qc({operation:e}):void 0,exportConst:u.exported,expression:I.callExpression({functionName:d.placeholder,parameters:[I.arrowFunction({parameters:[{isRequired:r,name:pf,type:a}],statements:I.objectExpression({obj:c})})]}),name:u.placeholder});t.setSymbolValue(u,f)},gf=({plugin:e})=>{e.registerSymbol({external:e.name,meta:{kind:`type`},name:`UseMutationOptions`,selector:e.api.selector(`UseMutationOptions`)}),e.registerSymbol({external:e.name,meta:{kind:`type`},name:`UseQueryOptions`,selector:e.api.selector(`UseQueryOptions`)}),e.registerSymbol({external:e.name,meta:{kind:`type`},name:`_JSONValue`,selector:e.api.selector(`_JSONValue`)}),e.registerSymbol({external:`axios`,meta:{kind:`type`},name:`AxiosError`,selector:e.api.selector(`AxiosError`)});let t=e.getPluginOrThrow(`@hey-api/sdk`);e.forEach(`operation`,({operation:n})=>{let r=t.config.asClass?qc({context:e.context,operation:n,plugin:t}):void 0,i=r?r.values().next().value:void 0,a=i?[e.referenceSymbol(t.api.selector(`class`,i.path[0])).placeholder,...i.path.slice(1).map(e=>T({case:`camelCase`,value:e})),i.methodName].filter(Boolean).join(`.`):e.referenceSymbol(t.api.selector(`function`,n.id)).placeholder;e.hooks.operation.isQuery(n)&&e.config.queryOptions.enabled&&hf({operation:n,plugin:e,queryFn:a}),e.hooks.operation.isMutation(n)&&e.config.mutationOptions.enabled&&of({operation:n,plugin:e,queryFn:a})},{order:`declarations`})},_f={api:new $d({name:`@pinia/colada`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/typescript`,`@hey-api/sdk`],handler:gf,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})}},vf=C(_f),yf=(e,t,n)=>{let r=e.config[n].meta;if(!r)return;let i=r(t);if(Object.keys(i).length)return I.valueToExpression({value:i})},bf=({operation:e,plugin:t})=>Jc({operation:e,plugin:t.getPluginOrThrow(`@hey-api/sdk`)}),xf=({operation:e,plugin:t})=>{let n=b(t.context.config),r=t.getPluginOrThrow(`@hey-api/typescript`),i=t.getSymbol(r.api.selector(`error`,e.id))?.placeholder;return i||=t.referenceSymbol(t.api.selector(`DefaultError`)).placeholder,n.name===`@hey-api/client-axios`&&(i=`${t.referenceSymbol(t.api.selector(`AxiosError`)).placeholder}<${i}>`),i},Sf=({operation:e,plugin:t})=>{let n=t.getPluginOrThrow(`@hey-api/typescript`);return t.getSymbol(n.api.selector(`response`,e.id))?.placeholder||`unknown`},Cf=`TOptions`,wf=I.identifier({text:`infinite`}),Tf=I.identifier({text:`options`}),Ef=({plugin:e})=>{let t=e.registerSymbol({name:E({config:{case:e.config.case},name:`createQueryKey`}),selector:e.api.selector(`createQueryKey`)}),n=e.referenceSymbol(e.api.selector(`QueryKey`)),r=I.indexedAccessTypeNode({indexType:I.literalTypeNode({literal:I.ots.number(0)}),objectType:I.typeReferenceNode({typeArguments:[I.typeReferenceNode({typeName:Cf})],typeName:n.placeholder})}),i=he(e.context.config),a=b(e.context.config),o=a.api&&`selector`in a.api?e.getSymbol(a.api.selector(`client`)):void 0,s=e.getPluginOrThrow(`@hey-api/sdk`),c=e.referenceSymbol(s.api.selector(`Options`)),l=I.constVariable({expression:I.arrowFunction({multiLine:!0,parameters:[{name:`id`,type:I.typeReferenceNode({typeName:`string`})},{isRequired:!1,name:`options`,type:I.typeReferenceNode({typeName:Cf})},{isRequired:!1,name:`infinite`,type:I.typeReferenceNode({typeName:`boolean`})},{isRequired:!1,name:`tags`,type:I.typeReferenceNode({typeName:`ReadonlyArray<string>`})}],returnType:I.typeTupleNode({types:[r]}),statements:[I.constVariable({assertion:r,expression:I.objectExpression({multiLine:!1,obj:[{key:`_id`,value:I.identifier({text:`id`})},{key:i,value:I.identifier({text:`options?.${i} || (options?.client ?? ${o?.placeholder}).getConfig().${i}`})}]}),name:`params`,typeName:r}),I.ifStatement({expression:wf,thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`_infinite`}),right:wf})})]})}),I.ifStatement({expression:I.identifier({text:`tags`}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`tags`}),right:I.identifier({text:`tags`})})})]})}),I.ifStatement({expression:I.propertyAccessExpression({expression:Tf,isOptional:!0,name:I.identifier({text:`body`})}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`body`}),right:I.propertyAccessExpression({expression:`options`,name:`body`})})})]})}),I.ifStatement({expression:I.propertyAccessExpression({expression:Tf,isOptional:!0,name:I.identifier({text:`headers`})}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`headers`}),right:I.propertyAccessExpression({expression:`options`,name:`headers`})})})]})}),I.ifStatement({expression:I.propertyAccessExpression({expression:Tf,isOptional:!0,name:I.identifier({text:`path`})}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`path`}),right:I.propertyAccessExpression({expression:`options`,name:`path`})})})]})}),I.ifStatement({expression:I.propertyAccessExpression({expression:Tf,isOptional:!0,name:I.identifier({text:`query`})}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`query`}),right:I.propertyAccessExpression({expression:`options`,name:`query`})})})]})}),I.returnStatement({expression:I.arrayLiteralExpression({elements:[I.identifier({text:`params`})]})})],types:[{extends:I.typeReferenceNode({typeName:I.identifier({text:c.placeholder})}),name:Cf}]}),name:t.placeholder});e.setSymbolValue(t,l)},Df=({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=I.arrayLiteralExpression({elements:n.tags.map(e=>I.stringLiteral({text:e}))}));let o=r.referenceSymbol(r.api.selector(`createQueryKey`));return I.callExpression({functionName:o.placeholder,parameters:[I.ots.string(e),`options`,t||a?I.ots.boolean(!!t):void 0,a]})},Of=({plugin:e})=>{let t=[{name:`_id`,type:I.keywordTypeNode({keyword:`string`})},{isRequired:!1,name:`_infinite`,type:I.keywordTypeNode({keyword:`boolean`})},{isRequired:!1,name:`tags`,type:I.typeReferenceNode({typeName:`ReadonlyArray<string>`})}],n=e.getPluginOrThrow(`@hey-api/sdk`),r=e.referenceSymbol(n.api.selector(`Options`)),i=e.registerSymbol({exported:!0,meta:{kind:`type`},name:`QueryKey`,selector:e.api.selector(`QueryKey`)}),a=I.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:I.typeTupleNode({types:[I.typeIntersectionNode({types:[I.typeReferenceNode({typeName:`Pick<${Cf}, '${he(e.context.config)}' | 'body' | 'headers' | 'path' | 'query'>`}),I.typeInterfaceNode({properties:t,useLegacyResolution:!0})]})]}),typeParameters:[{extends:I.typeReferenceNode({typeName:I.identifier({text:r.placeholder})}),name:Cf}]});e.setSymbolValue(i,a)},kf=({isInfinite:e,operation:t,plugin:n,symbol:r,typeQueryKey:i})=>{let a=bf({operation:t,plugin:n});return I.constVariable({exportConst:r.exported,expression:I.arrowFunction({parameters:[{isRequired:st(t),name:`options`,type:a}],returnType:e?i:void 0,statements:Df({id:t.id,isInfinite:e,operation:t,plugin:n})}),name:r.placeholder})},Af=({plugin:e})=>{let t=e.registerSymbol({name:E({config:{case:e.config.case},name:`createInfiniteParams`}),selector:e.api.selector(`createInfiniteParams`)}),n=I.constVariable({expression:I.arrowFunction({multiLine:!0,parameters:[{name:`queryKey`,type:I.typeReferenceNode({typeName:`QueryKey<Options>`})},{name:`page`,type:I.typeReferenceNode({typeName:`K`})}],statements:[I.constVariable({expression:I.objectExpression({obj:[{spread:I.propertyAccessExpression({expression:`queryKey`,name:0})}]}),name:`params`}),I.ifStatement({expression:I.propertyAccessExpression({expression:I.identifier({text:`page`}),name:I.identifier({text:`body`})}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`body`}),right:I.objectExpression({multiLine:!0,obj:[{assertion:`any`,spread:`queryKey[0].body`},{assertion:`any`,spread:`page.body`}]})})})]})}),I.ifStatement({expression:I.propertyAccessExpression({expression:I.identifier({text:`page`}),name:I.identifier({text:`headers`})}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`headers`}),right:I.objectExpression({multiLine:!0,obj:[{spread:`queryKey[0].headers`},{spread:`page.headers`}]})})})]})}),I.ifStatement({expression:I.propertyAccessExpression({expression:I.identifier({text:`page`}),name:I.identifier({text:`path`})}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`path`}),right:I.objectExpression({multiLine:!0,obj:[{assertion:`any`,spread:`queryKey[0].path`},{assertion:`any`,spread:`page.path`}]})})})]})}),I.ifStatement({expression:I.propertyAccessExpression({expression:I.identifier({text:`page`}),name:I.identifier({text:`query`})}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`query`}),right:I.objectExpression({multiLine:!0,obj:[{assertion:`any`,spread:`queryKey[0].query`},{assertion:`any`,spread:`page.query`}]})})})]})}),I.returnVariable({expression:I.asExpression({expression:I.asExpression({expression:I.identifier({text:`params`}),type:I.keywordTypeNode({keyword:`unknown`})}),type:m.default.factory.createTypeQueryNode(I.identifier({text:`page`}))})})],types:[{extends:I.typeReferenceNode({typeName:I.identifier({text:`Pick<QueryKey<Options>[0], 'body' | 'headers' | 'path' | 'query'>`})}),name:`K`}]}),name:t.placeholder});e.setSymbolValue(t,n)},jf=({operation:e,plugin:t,queryFn:n})=>{let r=ct({context:t.context,operation:e});if(!r)return;let i=$c({context:t.context,operation:e});t.getSymbol(t.api.selector(`createQueryKey`))||(Of({plugin:t}),Ef({plugin:t})),t.getSymbol(t.api.selector(`createInfiniteParams`))||Af({plugin:t});let a=t.referenceSymbol(t.api.selector(`infiniteQueryOptions`)),o=t.referenceSymbol(t.api.selector(`InfiniteData`)),s=bf({operation:e,plugin:t}),c=xf({operation:e,plugin:t}),l=Sf({operation:e,plugin:t}),u=`${t.referenceSymbol(t.api.selector(`QueryKey`)).placeholder}<${s}>`,d=`Pick<${u}[0], 'body' | 'headers' | 'path' | 'query'>`,f=t.getPluginOrThrow(`@hey-api/typescript`),p=`${Ot({node:f.api.schemaToType({plugin:f,schema:r.schema,state:{path:{value:[]}}}),unescape:!0})} | ${d}`,m=t.registerSymbol({exported:!0,name:E({config:t.config.infiniteQueryKeys,name:e.id})}),h=kf({isInfinite:!0,operation:e,plugin:t,symbol:m,typeQueryKey:u});t.setSymbolValue(m,h);let g=I.awaitExpression({expression:I.callExpression({functionName:n,parameters:[I.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:`params`},{key:`signal`,shorthand:!0,value:I.identifier({text:`signal`})},{key:`throwOnError`,value:!0}]})]})}),_=t.referenceSymbol(t.api.selector(`createInfiniteParams`)),v=[I.constVariable({comment:[{jsdoc:!1,lines:[`@ts-ignore`]}],expression:I.conditionalExpression({condition:I.binaryExpression({left:I.typeOfExpression({text:`pageParam`}),operator:`===`,right:I.ots.string(`object`)}),whenFalse:I.objectExpression({multiLine:!0,obj:[{key:r.in,value:I.objectExpression({multiLine:!0,obj:[{key:r.name,value:I.identifier({text:`pageParam`})}]})}]}),whenTrue:I.identifier({text:`pageParam`})}),name:`page`,typeName:d}),I.constVariable({expression:I.callExpression({functionName:_.placeholder,parameters:[`queryKey`,`page`]}),name:`params`})];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?v.push(I.returnVariable({expression:g})):v.push(I.constVariable({destructure:!0,expression:g,name:`data`}),I.returnVariable({expression:`data`}));let y=[{key:`queryFn`,value:I.arrowFunction({async:!0,multiLine:!0,parameters:[{destructure:[{name:`pageParam`},{name:`queryKey`},{name:`signal`}]}],statements:v})},{key:`queryKey`,value:I.callExpression({functionName:m.placeholder,parameters:[`options`]})}],ee=yf(t,e,`infiniteQueryOptions`);ee&&y.push({key:`meta`,value:ee});let te=t.registerSymbol({exported:!0,name:E({config:t.config.infiniteQueryOptions,name:e.id})}),ne=I.constVariable({comment:t.config.comments?Qc({operation:e}):void 0,exportConst:te.exported,expression:I.arrowFunction({parameters:[{isRequired:i,name:`options`,type:s}],statements:[I.returnFunctionCall({args:[I.objectExpression({comments:[{jsdoc:!1,lines:[`@ts-ignore`]}],obj:y})],name:a.placeholder,types:[l,c||`unknown`,`${o.placeholder}<${l}>`,u,p]})]}),name:te.placeholder});t.setSymbolValue(te,ne)},Mf=({operation:e,plugin:t,queryFn:n})=>{let r=t.referenceSymbol(t.api.selector(`MutationOptions`)),i=bf({operation:e,plugin:t}),a=xf({operation:e,plugin:t}),o=Sf({operation:e,plugin:t}),s=`${r.placeholder}<${o}, ${a}, ${i}>`,c=`fnOptions`,l=I.awaitExpression({expression:I.callExpression({functionName:n,parameters:[I.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:c},{key:`throwOnError`,value:!0}]})]})}),u=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?u.push(I.returnVariable({expression:l})):u.push(I.constVariable({destructure:!0,expression:l,name:`data`}),I.returnVariable({expression:`data`}));let d=[{key:`mutationFn`,value:I.arrowFunction({async:!0,multiLine:!0,parameters:[{name:c}],statements:u})}],f=yf(t,e,`mutationOptions`);f&&d.push({key:`meta`,value:f});let p=`mutationOptions`,m=I.arrowFunction({parameters:[{isRequired:!1,name:`options`,type:`Partial<${i}>`}],returnType:s,statements:[I.constVariable({expression:I.objectExpression({obj:d}),name:p,typeName:s}),I.returnVariable({expression:p})]}),h=t.registerSymbol({exported:!0,name:E({config:t.config.mutationOptions,name:e.id})}),g=I.constVariable({comment:t.config.comments?Qc({operation:e}):void 0,exportConst:h.exported,expression:m,name:h.placeholder});t.setSymbolValue(h,g)},Nf=`options`,Pf=({operation:e,plugin:t,queryFn:n})=>{if(el({operation:e}))return;let r=$c({context:t.context,operation:e});t.getSymbol(t.api.selector(`createQueryKey`))||(Of({plugin:t}),Ef({plugin:t}));let i=t.referenceSymbol(t.api.selector(`queryOptions`)),a=t.registerSymbol({exported:!0,name:E({config:t.config.queryKeys,name:e.id})}),o=kf({isInfinite:!1,operation:e,plugin:t,symbol:a});t.setSymbolValue(a,o);let s=bf({operation:e,plugin:t}),c=I.awaitExpression({expression:I.callExpression({functionName:n,parameters:[I.objectExpression({multiLine:!0,obj:[{spread:Nf},{spread:`queryKey[0]`},{key:`signal`,shorthand:!0,value:I.identifier({text:`signal`})},{key:`throwOnError`,value:!0}]})]})}),l=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?l.push(I.returnVariable({expression:c})):l.push(I.constVariable({destructure:!0,expression:c,name:`data`}),I.returnVariable({expression:`data`}));let u=[{key:`queryFn`,value:I.arrowFunction({async:!0,multiLine:!0,parameters:[{destructure:[{name:`queryKey`},{name:`signal`}]}],statements:l})},{key:`queryKey`,value:I.callExpression({functionName:a.placeholder,parameters:[Nf]})}],d=yf(t,e,`queryOptions`);d&&u.push({key:`meta`,value:d});let f=t.registerSymbol({exported:t.config.queryOptions.exported,name:E({config:t.config.queryOptions,name:e.id}),selector:t.api.selector(`queryOptionsFn`,e.id)}),p=I.constVariable({comment:t.config.comments?Qc({operation:e}):void 0,exportConst:f.exported,expression:I.arrowFunction({parameters:[{isRequired:r,name:Nf,type:s}],statements:[I.returnFunctionCall({args:[I.objectExpression({obj:u})],name:i.placeholder})]}),name:f.placeholder});t.setSymbolValue(f,p)},Ff=`options`,If=({operation:e,plugin:t})=>{if(el({operation:e})||!(`useQuery`in t.config))return;let n=t.registerSymbol({exported:!0,name:E({config:t.config.useQuery,name:e.id})}),r=t.referenceSymbol(t.api.selector(`useQuery`)),i=$c({context:t.context,operation:e}),a=bf({operation:e,plugin:t}),o=t.referenceSymbol(t.api.selector(`queryOptionsFn`,e.id)),s=I.constVariable({comment:t.config.comments?Qc({operation:e}):void 0,exportConst:n.exported,expression:I.arrowFunction({parameters:[{isRequired:i,name:Ff,type:a}],statements:[I.returnStatement({expression:I.callExpression({functionName:r.placeholder,parameters:[I.callExpression({functionName:o.placeholder,parameters:[Ff]})]})})]}),name:n.placeholder});t.setSymbolValue(n,s)},Lf=({plugin:e})=>{e.registerSymbol({external:e.name,meta:{kind:`type`},name:`DefaultError`,selector:e.api.selector(`DefaultError`)}),e.registerSymbol({external:e.name,meta:{kind:`type`},name:`InfiniteData`,selector:e.api.selector(`InfiniteData`)});let t=e.name===`@tanstack/angular-query-experimental`||e.name===`@tanstack/svelte-query`||e.name===`@tanstack/solid-query`?`MutationOptions`:`UseMutationOptions`;e.registerSymbol({external:e.name,meta:{kind:`type`},name:t,selector:e.api.selector(`MutationOptions`)}),e.registerSymbol({external:e.name,name:`infiniteQueryOptions`,selector:e.api.selector(`infiniteQueryOptions`)}),e.registerSymbol({external:e.name,name:`queryOptions`,selector:e.api.selector(`queryOptions`)}),e.registerSymbol({external:e.name,name:`useQuery`,selector:e.api.selector(`useQuery`)}),e.registerSymbol({external:`axios`,meta:{kind:`type`},name:`AxiosError`,selector:e.api.selector(`AxiosError`)});let n=e.getPluginOrThrow(`@hey-api/sdk`);e.forEach(`operation`,({operation:t})=>{let r=n.config.asClass?qc({context:e.context,operation:t,plugin:n}):void 0,i=r?r.values().next().value:void 0,a=i?[e.referenceSymbol(n.api.selector(`class`,i.path[0])).placeholder,...i.path.slice(1).map(e=>T({case:`camelCase`,value:e})),i.methodName].filter(Boolean).join(`.`):e.referenceSymbol(n.api.selector(`function`,t.id)).placeholder;e.hooks.operation.isQuery(t)&&(e.config.queryOptions.enabled&&Pf({operation:t,plugin:e,queryFn:a}),e.config.infiniteQueryOptions.enabled&&jf({operation:t,plugin:e,queryFn:a}),`useQuery`in e.config&&e.config.useQuery.enabled&&If({operation:t,plugin:e})),e.hooks.operation.isMutation(t)&&e.config.mutationOptions.enabled&&Mf({operation:t,plugin:e,queryFn:a})},{order:`declarations`})},Rf=e=>`${Fu({config:x(),id:e.name,operation:e})}InfiniteOptions`,zf=e=>`${Fu({config:x(),id:e.name,operation:e})}Mutation`,Bf=({config:e,id:t,operation:n})=>`${Fu({config:e,id:t,operation:n})}Options`,Vf=({config:e,id:t,isInfinite:n,operation:r})=>`${Fu({config:e,id:t,operation:r})}${n?`Infinite`:``}QueryKey`,Hf=e=>{switch(e.in){case`formData`:return`body`;case`header`:return`headers`;default:return e.in}},Uf=`createInfiniteParams`,Wf=`createQueryKey`,Gf=`infiniteQueryOptions`,Kf=`mutationOptions`,qf=`QueryKey`,Jf=`queryOptions`,Yf=`TOptions`,Xf=({file:e})=>{let t=I.constVariable({expression:I.arrowFunction({multiLine:!0,parameters:[{name:`queryKey`,type:I.typeNode(`QueryKey<OptionsLegacyParser>`)},{name:`page`,type:I.typeNode(`K`)}],statements:[I.constVariable({expression:I.identifier({text:`queryKey[0]`}),name:`params`}),I.ifStatement({expression:I.propertyAccessExpression({expression:I.identifier({text:`page`}),name:I.identifier({text:`body`})}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`body`}),right:I.objectExpression({multiLine:!0,obj:[{assertion:`any`,spread:`queryKey[0].body`},{assertion:`any`,spread:`page.body`}]})})})]})}),I.ifStatement({expression:I.propertyAccessExpression({expression:I.identifier({text:`page`}),name:I.identifier({text:`headers`})}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`headers`}),right:I.objectExpression({multiLine:!0,obj:[{spread:`queryKey[0].headers`},{spread:`page.headers`}]})})})]})}),I.ifStatement({expression:I.propertyAccessExpression({expression:I.identifier({text:`page`}),name:I.identifier({text:`path`})}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`path`}),right:I.objectExpression({multiLine:!0,obj:[{spread:`queryKey[0].path`},{spread:`page.path`}]})})})]})}),I.ifStatement({expression:I.propertyAccessExpression({expression:I.identifier({text:`page`}),name:I.identifier({text:`query`})}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`query`}),right:I.objectExpression({multiLine:!0,obj:[{spread:`queryKey[0].query`},{spread:`page.query`}]})})})]})}),I.returnVariable({expression:m.default.factory.createAsExpression(m.default.factory.createAsExpression(I.identifier({text:`params`}),m.default.factory.createKeywordTypeNode(m.default.SyntaxKind.UnknownKeyword)),m.default.factory.createTypeQueryNode(I.identifier({text:`page`})))})],types:[{extends:I.typeReferenceNode({typeName:I.identifier({text:`Pick<QueryKey<OptionsLegacyParser>[0], 'body' | 'headers' | 'path' | 'query'>`})}),name:`K`}]}),name:`createInfiniteParams`});e.add(t)},Zf=({file:e})=>{let t=I.indexedAccessTypeNode({indexType:I.typeNode(0),objectType:I.typeNode(qf,[I.typeNode(Yf)])}),n=I.identifier({text:`infinite`}),r=he(x()),i=I.constVariable({expression:I.arrowFunction({multiLine:!0,parameters:[{name:`id`,type:I.typeNode(`string`)},{isRequired:!1,name:`options`,type:I.typeNode(Yf)},{isRequired:!1,name:`infinite`,type:I.typeNode(`boolean`)}],returnType:t,statements:[I.constVariable({assertion:t,expression:I.objectExpression({multiLine:!1,obj:[{key:`_id`,value:I.identifier({text:`id`})},{key:r,value:I.identifier({text:`options?.${r} || (options?.client ?? _heyApiClient).getConfig().${r}`})}]}),name:`params`,typeName:t}),I.ifStatement({expression:n,thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`_infinite`}),right:n})})]})}),I.ifStatement({expression:I.propertyAccessExpression({expression:I.identifier({text:`options`}),isOptional:!0,name:I.identifier({text:`body`})}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`body`}),right:I.propertyAccessExpression({expression:`options`,name:`body`})})})]})}),I.ifStatement({expression:I.propertyAccessExpression({expression:I.identifier({text:`options`}),isOptional:!0,name:I.identifier({text:`headers`})}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`headers`}),right:I.propertyAccessExpression({expression:`options`,name:`headers`})})})]})}),I.ifStatement({expression:I.propertyAccessExpression({expression:I.identifier({text:`options`}),isOptional:!0,name:I.identifier({text:`path`})}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`path`}),right:I.propertyAccessExpression({expression:`options`,name:`path`})})})]})}),I.ifStatement({expression:I.propertyAccessExpression({expression:I.identifier({text:`options`}),isOptional:!0,name:I.identifier({text:`query`})}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`query`}),right:I.propertyAccessExpression({expression:`options`,name:`query`})})})]})}),I.returnVariable({expression:`params`})],types:[{extends:I.typeReferenceNode({typeName:I.identifier({text:`OptionsLegacyParser`})}),name:Yf}]}),name:Wf});e.add(i)},Qf=({file:e})=>{let t=[{name:`_id`,type:I.keywordTypeNode({keyword:`string`})},{isRequired:!1,name:`_infinite`,type:I.keywordTypeNode({keyword:`boolean`})}],n=I.typeAliasDeclaration({name:qf,type:I.typeTupleNode({types:[I.typeIntersectionNode({types:[I.typeReferenceNode({typeName:`Pick<${Yf}, '${he(x())}' | 'body' | 'headers' | 'path' | 'query'>`}),I.typeInterfaceNode({properties:t,useLegacyResolution:!0})]})]}),typeParameters:[{extends:I.typeReferenceNode({typeName:I.identifier({text:`OptionsLegacyParser`})}),name:Yf}]});e.add(n)},$f=({client:e,file:t,operation:n,typesModulePath:r})=>{let{name:i}=wu({client:e,meta:n.parameters.length?{$ref:n.name,name:n.name}:void 0,nameTransformer:Eu,onImport:e=>{t.import({asType:!0,module:r,name:e})}});return{typeData:Au({importedType:i})}},ep=({client:e,file:t,operation:n,pluginName:r,typesModulePath:i})=>{let a=x(),{name:o}=wu({client:e,meta:{$ref:n.name,name:n.name},nameTransformer:Du,onImport:e=>{t.import({asType:!0,module:i,name:e})}}),s={asType:!0,name:o};if(s.name||(s=t.import({asType:!0,module:r,name:`DefaultError`})),b(a).name===`@hey-api/client-axios`){let e=t.import({asType:!0,module:`axios`,name:`AxiosError`});s={...e,name:`${e.name}<${s.name}>`}}return{typeError:s}},tp=({client:e,file:t,operation:n,typesModulePath:r})=>{let{name:i}=wu({client:e,meta:{$ref:n.name,name:n.name},nameTransformer:ku,onImport:e=>{t.import({asType:!0,module:r,name:e})}});return{typeResponse:i||`void`}},np=({id:e,isInfinite:t})=>I.arrayLiteralExpression({elements:[I.callExpression({functionName:Wf,parameters:[I.ots.string(e),`options`,t?I.ots.boolean(!0):void 0]})],multiLine:!1}),rp=({client:e,files:t,plugin:n})=>{let r=x();if(S(r))throw Error(`TanStack Query plugin does not support legacy clients`);let i=t[n.name];i.import({asType:!0,module:bl({config:r,sourceOutput:n.output}),name:`OptionsLegacyParser`});let a=oe({moduleOutput:t.types.nameWithoutExtension(),sourceOutput:n.output}),o=n.name===`@tanstack/angular-query-experimental`||n.name===`@tanstack/svelte-query`||n.name===`@tanstack/solid-query`?`MutationOptions`:`UseMutationOptions`,s,c=!1,l=!1,u=!1,d=!1,f=!1,p=new Map;for(let m of e.services)for(let h of m.operations){let g=k(h);if(p.has(g))continue;p.set(g,!0);let _=[r.plugins[`@hey-api/sdk`]?.config.asClass&&as({config:r,name:m.name}),Fu({config:r,handleIllegal:!r.plugins[`@hey-api/sdk`]?.config.asClass,id:h.name,operation:h})].filter(Boolean).join(`.`),v=!1;if(n.config.queryOptions.enabled&&[`GET`,`POST`].includes(h.method)){f||(f=!0,l||=(Qf({file:i}),Zf({file:i}),!0),i.import({module:n.name,name:Jf})),v=!0;let{typeData:t}=$f({client:e,file:i,operation:h,typesModulePath:a}),o=Gs(h.parameters),s=I.constVariable({exportConst:!0,expression:I.arrowFunction({parameters:[{isRequired:o,name:`options`,type:t}],statements:np({id:h.name})}),name:Vf({config:r,id:h.name,operation:h})});i.add(s);let c=I.constVariable({comment:[],exportConst:!0,expression:I.arrowFunction({parameters:[{isRequired:o,name:`options`,type:t}],statements:[I.returnFunctionCall({args:[I.objectExpression({obj:[{key:`queryFn`,value:I.arrowFunction({async:!0,multiLine:!0,parameters:[{destructure:[{name:`queryKey`},{name:`signal`}]}],statements:[I.constVariable({destructure:!0,expression:I.awaitExpression({expression:I.callExpression({functionName:_,parameters:[I.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:`queryKey[0]`},{key:`signal`,shorthand:!0,value:I.identifier({text:`signal`})},{key:`throwOnError`,value:!0}]})]})}),name:`data`}),I.returnVariable({expression:`data`})]})},{key:`queryKey`,value:I.callExpression({functionName:Vf({config:r,id:h.name,operation:h}),parameters:[`options`]})}]})],name:Jf})]}),name:Bf({config:r,id:h.name,operation:h})});i.add(c)}if(n.config.infiniteQueryOptions&&[`GET`,`POST`].includes(h.method)){let t,o=h.parameters.find(n=>{if(Hi(r.parser.pagination).test(n.name))return t=n,!0;if(n.in===`body`){if(n.export===`reference`){let i=n.$refs[0];return e.models.find(e=>e.meta?.$ref===i)?.properties.find(e=>{if(Hi(r.parser.pagination).test(e.name))return t=e,!0})}return n.properties.find(e=>{if(Hi(r.parser.pagination).test(e.name))return t=e,!0})}});if(o&&t){u||(u=!0,l||=(Qf({file:i}),Zf({file:i}),!0),c||=(Xf({file:i}),!0),i.import({module:n.name,name:Gf}),s=i.import({asType:!0,module:n.name,name:`InfiniteData`})),v=!0;let{typeData:d}=$f({client:e,file:i,operation:h,typesModulePath:a}),{typeError:f}=ep({client:e,file:i,operation:h,pluginName:n.name,typesModulePath:a}),{typeResponse:p}=tp({client:e,file:i,operation:h,typesModulePath:a}),m=Gs(h.parameters),g=`${qf}<${d}>`,y=`Pick<${g}[0], 'body' | 'headers' | 'path' | 'query'>`,ee=`${t.base} | ${y}`,te=I.constVariable({exportConst:!0,expression:I.arrowFunction({parameters:[{isRequired:m,name:`options`,type:d}],returnType:g,statements:np({id:h.name,isInfinite:!0})}),name:Vf({config:r,id:h.name,isInfinite:!0,operation:h})});i.add(te);let ne=I.constVariable({comment:[],exportConst:!0,expression:I.arrowFunction({parameters:[{isRequired:m,name:`options`,type:d}],statements:[I.returnFunctionCall({args:[I.objectExpression({comments:[{jsdoc:!1,lines:[`@ts-ignore`]}],obj:[{key:`queryFn`,value:I.arrowFunction({async:!0,multiLine:!0,parameters:[{destructure:[{name:`pageParam`},{name:`queryKey`},{name:`signal`}]}],statements:[I.constVariable({comment:[{jsdoc:!1,lines:[`@ts-ignore`]}],expression:I.conditionalExpression({condition:I.binaryExpression({left:I.typeOfExpression({text:`pageParam`}),operator:`===`,right:I.ots.string(`object`)}),whenFalse:I.objectExpression({multiLine:!0,obj:[{key:Hf(o),value:I.objectExpression({multiLine:!0,obj:[{key:t.name,value:I.identifier({text:`pageParam`})}]})}]}),whenTrue:I.identifier({text:`pageParam`})}),name:`page`,typeName:y}),I.constVariable({expression:I.callExpression({functionName:`createInfiniteParams`,parameters:[`queryKey`,`page`]}),name:`params`}),I.constVariable({destructure:!0,expression:I.awaitExpression({expression:I.callExpression({functionName:_,parameters:[I.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:`params`},{key:`signal`,shorthand:!0,value:I.identifier({text:`signal`})},{key:`throwOnError`,value:!0}]})]})}),name:`data`}),I.returnVariable({expression:`data`})]})},{key:`queryKey`,value:I.callExpression({functionName:Vf({config:r,id:h.name,isInfinite:!0,operation:h}),parameters:[`options`]})}]})],name:Gf,types:[p,f.name,`${typeof s==`string`?s:s.name}<${p}>`,g,ee]})]}),name:Rf(h)});i.add(ne)}}if(n.config.mutationOptions&&[`DELETE`,`PATCH`,`POST`,`PUT`].includes(h.method)){d||(d=!0,i.import({asType:!0,module:n.name,name:o})),v=!0;let{typeData:t}=$f({client:e,file:i,operation:h,typesModulePath:a}),{typeError:r}=ep({client:e,file:i,operation:h,pluginName:n.name,typesModulePath:a}),{typeResponse:s}=tp({client:e,file:i,operation:h,typesModulePath:a}),c=`fnOptions`,l=I.arrowFunction({parameters:[{isRequired:!1,name:`options`,type:`Partial<${t}>`}],statements:[I.constVariable({expression:I.objectExpression({obj:[{key:`mutationFn`,value:I.arrowFunction({async:!0,multiLine:!0,parameters:[{name:c}],statements:[I.constVariable({destructure:!0,expression:I.awaitExpression({expression:I.callExpression({functionName:_,parameters:[I.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:c},{key:`throwOnError`,value:!0}]})]})}),name:`data`}),I.returnVariable({expression:`data`})]})}]}),name:Kf,typeName:`${o}<${s}, ${r.name}, ${t}>`}),I.returnVariable({expression:Kf})]}),u=I.constVariable({comment:[],exportConst:!0,expression:l,name:zf(h)});i.add(u)}(f||u)&&i.import({alias:`_heyApiClient`,module:oe({moduleOutput:t.client.nameWithoutExtension(),sourceOutput:n.output}),name:`client`}),v&&i.import({module:oe({moduleOutput:t.sdk.nameWithoutExtension(),sourceOutput:n.output}),name:_.split(`.`)[0]})}};var ip=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const ap={api:new ip({name:`@tanstack/angular-query-experimental`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Lf,handlerLegacy:rp,name:`@tanstack/angular-query-experimental`,output:`@tanstack/angular-query-experimental`,resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteQueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteOptions`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,exported:!0,name:`{{name}}Options`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions})}},op=C(ap);var sp=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const cp={api:new sp({name:`@tanstack/react-query`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Lf,handlerLegacy:rp,name:`@tanstack/react-query`,output:`@tanstack/react-query`,resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteQueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteOptions`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,exported:!0,name:`{{name}}Options`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions}),e.config.useQuery=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!1,name:`use{{name}}Query`},mappers:{boolean:e=>({enabled:e}),function:e=>({enabled:!0,name:e}),object:e=>({enabled:!0,...e}),string:e=>({enabled:!0,name:e})},value:e.config.useQuery}),e.config.useQuery.enabled&&(e.config.queryOptions.enabled||(e.config.queryOptions.enabled=!0,e.config.queryOptions.exported=!1))}},lp=C(cp);var up=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const dp={api:new up({name:`@tanstack/solid-query`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Lf,handlerLegacy:rp,name:`@tanstack/solid-query`,output:`@tanstack/solid-query`,resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteQueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteOptions`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,exported:!0,name:`{{name}}Options`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions})}},fp=C(dp);var pp=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const mp={api:new pp({name:`@tanstack/svelte-query`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Lf,handlerLegacy:rp,name:`@tanstack/svelte-query`,output:`@tanstack/svelte-query`,resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteQueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteOptions`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,exported:!0,name:`{{name}}Options`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions})}},hp=C(mp);var gp=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const _p={api:new gp({name:`@tanstack/vue-query`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Lf,handlerLegacy:rp,name:`@tanstack/vue-query`,output:`@tanstack/vue-query`,resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteQueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteOptions`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,exported:!0,name:`{{name}}Options`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions})}},vp=C(_p),yp=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`data`,e.id));if(!n)return;let r=`data`;return I.arrowFunction({async:!0,parameters:[{name:r}],statements:[I.returnStatement({expression:I.awaitExpression({expression:I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:`parseAsync`}),parameters:[I.identifier({text:r})]})})})]})},bp=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`responses`,e.id));if(!n)return;let r=`data`;return I.arrowFunction({async:!0,parameters:[{name:r}],statements:[I.returnStatement({expression:I.awaitExpression({expression:I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:`parseAsync`}),parameters:[I.identifier({text:r})]})})})]})};var xp=class{constructor(e){this.meta=e}createRequestValidator(e){return yp(e)}createResponseValidator(e){return bp(e)}selector(...e){return[this.meta.name,...e]}};const Sp={keywords:{false:I.identifier({text:`false`}),true:I.identifier({text:`true`})},number:{Infinity:I.identifier({text:`Infinity`}),NaN:I.identifier({text:`NaN`}),NegativeInfinity:I.identifier({text:`NegativeInfinity`}),epoch:I.identifier({text:`epoch`}),integer:I.identifier({text:`integer`}),safe:I.identifier({text:`safe`})},primitives:{bigint:I.identifier({text:`bigint`}),boolean:I.identifier({text:`boolean`}),keywords:I.identifier({text:`keywords`}),null:`null`,number:I.identifier({text:`number`}),string:`string`,symbol:I.identifier({text:`symbol`}),undefined:I.identifier({text:`undefined`}),unit:I.identifier({text:`unit`})},string:{NFC:I.identifier({text:`NFC`}),NFD:I.identifier({text:`NFD`}),NFKC:I.identifier({text:`NFKC`}),NFKD:I.identifier({text:`NFKD`}),alpha:I.identifier({text:`alpha`}),alphanumeric:I.identifier({text:`alphanumeric`}),base64:I.identifier({text:`base64`}),capitalize:I.identifier({text:`capitalize`}),creditCard:I.identifier({text:`creditCard`}),date:`date`,digits:I.identifier({text:`digits`}),email:`email`,epoch:I.identifier({text:`epoch`}),hex:I.identifier({text:`hex`}),integer:I.identifier({text:`integer`}),ip:`ip`,iso:`iso`,json:I.identifier({text:`json`}),lower:I.identifier({text:`lower`}),normalize:I.identifier({text:`normalize`}),numeric:I.identifier({text:`numeric`}),parse:I.identifier({text:`parse`}),preformatted:I.identifier({text:`preformatted`}),regex:I.identifier({text:`regex`}),semver:I.identifier({text:`semver`}),trim:I.identifier({text:`trim`}),upper:I.identifier({text:`upper`}),url:`url`,uuid:`uuid`,v1:`v1`,v2:`v2`,v3:`v3`,v4:`v4`,v5:`v5`,v6:`v6`,v7:`v7`,v8:`v8`},type:{$:I.identifier({text:`$`}),allows:I.identifier({text:`allows`}),and:I.identifier({text:`and`}),array:I.identifier({text:`array`}),as:I.identifier({text:`as`}),assert:I.identifier({text:`assert`}),brand:I.identifier({text:`brand`}),configure:I.identifier({text:`configure`}),default:I.identifier({text:`default`}),describe:I.identifier({text:`describe`}),description:I.identifier({text:`description`}),equals:I.identifier({text:`equals`}),exclude:I.identifier({text:`exclude`}),expression:I.identifier({text:`expression`}),extends:I.identifier({text:`extends`}),extract:I.identifier({text:`extract`}),filter:I.identifier({text:`filter`}),from:I.identifier({text:`from`}),ifEquals:I.identifier({text:`ifEquals`}),ifExtends:I.identifier({text:`ifExtends`}),infer:I.identifier({text:`infer`}),inferIn:I.identifier({text:`inferIn`}),intersect:I.identifier({text:`intersect`}),json:I.identifier({text:`json`}),meta:I.identifier({text:`meta`}),narrow:I.identifier({text:`narrow`}),onDeepUndeclaredKey:I.identifier({text:`onDeepUndeclaredKey`}),onUndeclaredKey:I.identifier({text:`onUndeclaredKey`}),optional:I.identifier({text:`optional`}),or:I.identifier({text:`or`}),overlaps:I.identifier({text:`overlaps`}),pipe:I.identifier({text:`pipe`}),select:I.identifier({text:`select`}),to:I.identifier({text:`to`}),toJsonSchema:I.identifier({text:`toJsonSchema`})}},Cp=({ast:e,plugin:t,schema:n,symbol:r,typeInferSymbol:i})=>{let a=t.referenceSymbol(t.api.selector(`external`,`arktype.type`)),o=I.constVariable({comment:t.config.comments?wd({schema:n}):void 0,exportConst:r.exported,expression:I.callExpression({functionName:a.placeholder,parameters:[e.def?I.stringLiteral({text:e.def}):e.expression]}),name:r.placeholder});if(t.setSymbolValue(r,o),i){let e=I.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:m.default.factory.createTypeQueryNode(m.default.factory.createQualifiedName(m.default.factory.createIdentifier(r.placeholder),Sp.type.infer))});t.setSymbolValue(i,e)}},wp=e=>{let t={};return t.def=Sp.primitives.null,t},Tp=({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),l=Op({optional:!c,plugin:e,schema:s,state:{...n,path:q([...n.path.value,`properties`,o])}});l.hasLazyExpression&&(r.hasLazyExpression=!0);let u=c?o:`${o}?`;u.endsWith(`?`)?u=m.default.factory.createComputedPropertyName(I.stringLiteral({text:u})):((u.match(/^[0-9]/)&&u.match(/\D+/g)||u.match(/\W/g))&&!u.startsWith(`'`)&&!u.endsWith(`'`)&&(u=`'${u}'`),A.lastIndex=0,u=A.test(u)?u.startsWith(`-`)?I.stringLiteral({text:o}):m.default.factory.createNumericLiteral(o):o),i.push(I.propertyAssignment({initializer:l.expression,name:u}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=Op({plugin:e,schema:t.additionalProperties,state:{...n,path:q([...n.path.value,`additionalProperties`])}});return r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:`TODO`,name:`record`}),parameters:[I.callExpression({functionName:I.propertyAccessExpression({expression:`TODO`,name:`string`}),parameters:[]}),i.expression]}),i.hasLazyExpression&&(r.hasLazyExpression=!0),r.hasLazyExpression?{...r,typeName:`TODO`}:r}return r.expression=m.default.factory.createObjectLiteralExpression(i,!0),r.hasLazyExpression?{...r,typeName:`TODO`}:r},Ep=({schema:e})=>{let t={};if(typeof e.const==`string`)return t.def=e.const,t;let n=Sp.primitives.string;if(e.format)switch(e.format){case`date`:case`date-time`:case`time`:n=`${n}.${Sp.string.date}.${Sp.string.iso}`;break;case`email`:n=`${n}.${Sp.string.email}`;break;case`ipv4`:n=`${n}.${Sp.string.ip}.${Sp.string.v4}`;break;case`ipv6`:n=`${n}.${Sp.string.ip}.${Sp.string.v6}`;break;case`uri`:n=`${n}.${Sp.string.url}`;break;case`uuid`:n=`${n}.${Sp.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},Dp=({schema:e,...t})=>{switch(e.type){case`null`:return wp({...t,schema:e});case`object`:return Tp({...t,schema:e});case`string`:return Ep({...t,schema:e})}let n=t.plugin.referenceSymbol(t.plugin.api.selector(`external`,`arktype.type`));return{def:``,expression:m.default.factory.createCallExpression(m.default.factory.createIdentifier(n.placeholder),void 0,[m.default.factory.createObjectLiteralExpression([m.default.factory.createPropertyAssignment(`name`,m.default.factory.createStringLiteral(`string`)),m.default.factory.createPropertyAssignment(`platform`,m.default.factory.createStringLiteral(`'android' | 'ios'`)),m.default.factory.createPropertyAssignment(m.default.factory.createComputedPropertyName(m.default.factory.createStringLiteral(`versions?`)),m.default.factory.createStringLiteral(`(number | string)[]`))],!0)]),hasLazyExpression:!1}},Op=({plugin:e,schema:t,state:n})=>{let r={};if(t.$ref){let i=e.api.selector(`ref`,t.$ref),a=e.referenceSymbol(i);e.isSymbolRegistered(i)?r.expression=I.identifier({text:a.placeholder}):(r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:`TODO`,name:`TODO`}),parameters:[I.arrowFunction({returnType:I.keywordTypeNode({keyword:`any`}),statements:[I.returnStatement({expression:I.identifier({text:a.placeholder})})]})]}),r.hasLazyExpression=!0,n.hasLazyExpression.value=!0)}else if(t.type){let i=Dp({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=D({schema:t}),t.items||(r=Op({plugin:e,schema:t,state:n}));else{let t=Dp({plugin:e,schema:{type:`unknown`},state:n});r.def=t.def,r.expression=t.expression}return r.expression||=Dp({plugin:e,schema:{type:`unknown`},state:n}).expression,r},kp=({plugin:e,schema:t,state:n})=>{let r=mr(n.path.value),i=Op({plugin:e,schema:t,state:n}),a=L(r);Cp({ast:i,plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{path:n.path.value},name:E({config:e.config.definitions,name:a}),selector:e.api.selector(`ref`,r)}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value},name:E({config:e.config.definitions.types.infer,name:a}),selector:e.api.selector(`type-infer-ref`,r)}):void 0})},Ap=({plugin:e})=>{e.registerSymbol({external:`arktype`,name:`type`,selector:e.api.selector(`external`,`arktype.type`)}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=J({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`parameter`:kp({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:kp({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:kp({plugin:e,schema:t.schema,state:n});break}})},jp=e=>Ap(e),Mp={api:new xp({name:`arktype`}),config:{case:`PascalCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:jp,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:w,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:{...w,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:w,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:{...w,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:w,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:{...w,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:w,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:{...w,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:w,value:e.infer})})},value:e.types})})},value:e.config.webhooks})},tags:[`validator`]},Np=C(Mp);var Pp=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const Fp=({operation:e,plugin:t})=>{let n=[],r=t.getPluginOrThrow(`@hey-api/typescript`),i=t.getSymbol(r.api.selector(`data`,e.id));i&&(e.body&&n.push({isRequired:e.body.required,name:`Body`,type:`${i.placeholder}['body']`}),e.parameters&&(e.parameters.header&&n.push({isRequired:it(e.parameters.header),name:`Headers`,type:`${i.placeholder}['headers']`}),e.parameters.path&&n.push({isRequired:it(e.parameters.path),name:`Params`,type:`${i.placeholder}['path']`}),e.parameters.query&&n.push({isRequired:it(e.parameters.query),name:`Querystring`,type:`${i.placeholder}['query']`})));let{errors:a,responses:o}=ut(e),s,c=t.getSymbol(r.api.selector(`errors`,e.id));if(c&&a&&a.properties){let e=Object.keys(a.properties);if(e.length){if(!e.includes(`default`))s=I.typeReferenceNode({typeName:c.placeholder});else if(e.length>1){let e=I.typeReferenceNode({typeName:c.placeholder}),t=I.literalTypeNode({literal:I.stringLiteral({text:`default`})});s=I.typeReferenceNode({typeArguments:[e,t],typeName:`Omit`})}}}let l,u=t.getSymbol(r.api.selector(`responses`,e.id));if(u&&o&&o.properties){let e=Object.keys(o.properties);if(e.length){if(!e.includes(`default`))l=I.typeReferenceNode({typeName:u.placeholder});else if(e.length>1){let e=I.typeReferenceNode({typeName:u.placeholder}),t=I.literalTypeNode({literal:I.stringLiteral({text:`default`})});l=I.typeReferenceNode({typeArguments:[e,t],typeName:`Omit`})}}}let d=[s,l].filter(Boolean);if(d.length&&n.push({name:`Reply`,type:I.typeIntersectionNode({types:d})}),!n.length)return;let f=t.referenceSymbol(t.api.selector(`RouteHandler`));return{name:e.id,type:I.typeReferenceNode({typeArguments:[I.typeInterfaceNode({properties:n,useLegacyResolution:!1})],typeName:f.placeholder})}},Ip=({plugin:e})=>{e.registerSymbol({external:`fastify`,meta:{kind:`type`},name:`RouteHandler`,selector:e.api.selector(`RouteHandler`)});let t=e.registerSymbol({exported:!0,meta:{kind:`type`},name:`RouteHandlers`}),n=[];e.forEach(`operation`,({operation:t})=>{let r=Fp({operation:t,plugin:e});r&&n.push(r)},{order:`declarations`});let r=I.typeAliasDeclaration({exportType:t.exported,name:t.placeholder,type:I.typeInterfaceNode({properties:n,useLegacyResolution:!1})});e.setSymbolValue(t,r)},Lp={api:new Pp({name:`fastify`}),config:{exportFromIndex:!1},dependencies:[`@hey-api/typescript`],handler:Ip,name:`fastify`},Rp=C(Lp),X={actions:{args:I.identifier({text:`args`}),base64:I.identifier({text:`base64`}),bic:I.identifier({text:`bic`}),brand:I.identifier({text:`brand`}),bytes:I.identifier({text:`bytes`}),check:I.identifier({text:`check`}),checkItems:I.identifier({text:`checkItems`}),creditCard:I.identifier({text:`creditCard`}),cuid2:I.identifier({text:`cuid2`}),decimal:I.identifier({text:`decimal`}),description:I.identifier({text:`description`}),digits:I.identifier({text:`digits`}),email:I.identifier({text:`email`}),emoji:I.identifier({text:`emoji`}),empty:I.identifier({text:`empty`}),endsWith:I.identifier({text:`endsWith`}),entries:I.identifier({text:`entries`}),everyItem:I.identifier({text:`everyItem`}),excludes:I.identifier({text:`excludes`}),filterItems:I.identifier({text:`filterItems`}),findItem:I.identifier({text:`findItem`}),finite:I.identifier({text:`finite`}),flavor:I.identifier({text:`flavor`}),graphemes:I.identifier({text:`graphemes`}),gtValue:I.identifier({text:`gtValue`}),hash:I.identifier({text:`hash`}),hexColor:I.identifier({text:`hexColor`}),hexadecimal:I.identifier({text:`hexadecimal`}),imei:I.identifier({text:`imei`}),includes:I.identifier({text:`includes`}),integer:I.identifier({text:`integer`}),ip:I.identifier({text:`ip`}),ipv4:I.identifier({text:`ipv4`}),ipv6:I.identifier({text:`ipv6`}),isoDate:I.identifier({text:`isoDate`}),isoDateTime:I.identifier({text:`isoDateTime`}),isoTime:I.identifier({text:`isoTime`}),isoTimeSecond:I.identifier({text:`isoTimeSecond`}),isoTimestamp:I.identifier({text:`isoTimestamp`}),isoWeek:I.identifier({text:`isoWeek`}),length:I.identifier({text:`length`}),ltValue:I.identifier({text:`ltValue`}),mac:I.identifier({text:`mac`}),mac48:I.identifier({text:`mac48`}),mac64:I.identifier({text:`mac64`}),mapItems:I.identifier({text:`mapItems`}),maxBytes:I.identifier({text:`maxBytes`}),maxEntries:I.identifier({text:`maxEntries`}),maxGraphemes:I.identifier({text:`maxGraphemes`}),maxLength:I.identifier({text:`maxLength`}),maxSize:I.identifier({text:`maxSize`}),maxValue:I.identifier({text:`maxValue`}),maxWords:I.identifier({text:`maxWords`}),metadata:I.identifier({text:`metadata`}),mimeType:I.identifier({text:`mimeType`}),minBytes:I.identifier({text:`minBytes`}),minEntries:I.identifier({text:`minEntries`}),minGraphemes:I.identifier({text:`minGraphemes`}),minLength:I.identifier({text:`minLength`}),minSize:I.identifier({text:`minSize`}),minValue:I.identifier({text:`minValue`}),minWords:I.identifier({text:`minWords`}),multipleOf:I.identifier({text:`multipleOf`}),nanoid:I.identifier({text:`nanoid`}),nonEmpty:I.identifier({text:`nonEmpty`}),normalize:I.identifier({text:`normalize`}),notBytes:I.identifier({text:`notBytes`}),notEntries:I.identifier({text:`notEntries`}),notGraphemes:I.identifier({text:`notGraphemes`}),notLength:I.identifier({text:`notLength`}),notSize:I.identifier({text:`notSize`}),notValue:I.identifier({text:`notValue`}),notValues:I.identifier({text:`notValues`}),notWords:I.identifier({text:`notWords`}),octal:I.identifier({text:`octal`}),parseJson:I.identifier({text:`parseJson`}),partialCheck:I.identifier({text:`partialCheck`}),rawCheck:I.identifier({text:`rawCheck`}),rawTransform:I.identifier({text:`rawTransform`}),readonly:I.identifier({text:`readonly`}),reduceItems:I.identifier({text:`reduceItems`}),regex:I.identifier({text:`regex`}),returns:I.identifier({text:`returns`}),rfcEmail:I.identifier({text:`rfcEmail`}),safeInteger:I.identifier({text:`safeInteger`}),size:I.identifier({text:`size`}),slug:I.identifier({text:`slug`}),someItem:I.identifier({text:`someItem`}),sortItems:I.identifier({text:`sortItems`}),startsWith:I.identifier({text:`startsWith`}),stringifyJson:I.identifier({text:`stringifyJson`}),title:I.identifier({text:`title`}),toLowerCase:I.identifier({text:`toLowerCase`}),toMaxValue:I.identifier({text:`toMaxValue`}),toMinValue:I.identifier({text:`toMinValue`}),toUpperCase:I.identifier({text:`toUpperCase`}),transform:I.identifier({text:`transform`}),trim:I.identifier({text:`trim`}),trimEnd:I.identifier({text:`trimEnd`}),trimStart:I.identifier({text:`trimStart`}),ulid:I.identifier({text:`ulid`}),url:I.identifier({text:`url`}),uuid:I.identifier({text:`uuid`}),value:I.identifier({text:`value`}),values:I.identifier({text:`values`}),words:I.identifier({text:`words`})},async:{argsAsync:I.identifier({text:`argsAsync`}),arrayAsync:I.identifier({text:`arrayAsync`}),awaitAsync:I.identifier({text:`awaitAsync`}),checkAsync:I.identifier({text:`checkAsync`}),checkItemsAsync:I.identifier({text:`checkItemsAsync`}),customAsync:I.identifier({text:`customAsync`}),exactOptionalAsync:I.identifier({text:`exactOptionalAsync`}),fallbackAsync:I.identifier({text:`fallbackAsync`}),forwardAsync:I.identifier({text:`forwardAsync`}),getDefaultsAsync:I.identifier({text:`getDefaultsAsync`}),getFallbacksAsync:I.identifier({text:`getFallbacksAsync`}),intersectAsync:I.identifier({text:`intersectAsync`}),lazyAsync:I.identifier({text:`lazyAsync`}),looseObjectAsync:I.identifier({text:`looseObjectAsync`}),looseTupleAsync:I.identifier({text:`looseTupleAsync`}),mapAsync:I.identifier({text:`mapAsync`}),nonNullableAsync:I.identifier({text:`nonNullableAsync`}),nonNullishAsync:I.identifier({text:`nonNullishAsync`}),nonOptionalAsync:I.identifier({text:`nonOptionalAsync`}),nullableAsync:I.identifier({text:`nullableAsync`}),nullishAsync:I.identifier({text:`nullishAsync`}),objectAsync:I.identifier({text:`objectAsync`}),objectWithRestAsync:I.identifier({text:`objectWithRestAsync`}),optionalAsync:I.identifier({text:`optionalAsync`}),parseAsync:I.identifier({text:`parseAsync`}),parserAsync:I.identifier({text:`parserAsync`}),partialAsync:I.identifier({text:`partialAsync`}),partialCheckAsync:I.identifier({text:`partialCheckAsync`}),pipeAsync:I.identifier({text:`pipeAsync`}),rawCheckAsync:I.identifier({text:`rawCheckAsync`}),rawTransformAsync:I.identifier({text:`rawTransformAsync`}),recordAsync:I.identifier({text:`recordAsync`}),requiredAsync:I.identifier({text:`requiredAsync`}),returnsAsync:I.identifier({text:`returnsAsync`}),safeParseAsync:I.identifier({text:`safeParseAsync`}),safeParserAsync:I.identifier({text:`safeParserAsync`}),setAsync:I.identifier({text:`setAsync`}),strictObjectAsync:I.identifier({text:`strictObjectAsync`}),strictTupleAsync:I.identifier({text:`strictTupleAsync`}),transformAsync:I.identifier({text:`transformAsync`}),tupleAsync:I.identifier({text:`tupleAsync`}),tupleWithRestAsync:I.identifier({text:`tupleWithRestAsync`}),undefinedableAsync:I.identifier({text:`undefinedableAsync`}),unionAsync:I.identifier({text:`unionAsync`}),variantAsync:I.identifier({text:`variantAsync`})},methods:{assert:I.identifier({text:`assert`}),config:I.identifier({text:`config`}),fallback:I.identifier({text:`fallback`}),flatten:I.identifier({text:`flatten`}),forward:I.identifier({text:`forward`}),getDefault:I.identifier({text:`getDefault`}),getDefaults:I.identifier({text:`getDefaults`}),getDescription:I.identifier({text:`getDescription`}),getFallback:I.identifier({text:`getFallback`}),getFallbacks:I.identifier({text:`getFallbacks`}),getMetadata:I.identifier({text:`getMetadata`}),getTitle:I.identifier({text:`getTitle`}),is:I.identifier({text:`is`}),keyof:I.identifier({text:`keyof`}),message:I.identifier({text:`message`}),omit:I.identifier({text:`omit`}),parse:I.identifier({text:`parse`}),parser:I.identifier({text:`parser`}),partial:I.identifier({text:`partial`}),pick:I.identifier({text:`pick`}),pipe:I.identifier({text:`pipe`}),required:I.identifier({text:`required`}),safeParse:I.identifier({text:`safeParse`}),safeParser:I.identifier({text:`safeParser`}),summarize:I.identifier({text:`summarize`}),unwrap:I.identifier({text:`unwrap`})},schemas:{any:I.identifier({text:`any`}),array:I.identifier({text:`array`}),bigInt:I.identifier({text:`bigint`}),blob:I.identifier({text:`blob`}),boolean:I.identifier({text:`boolean`}),custom:I.identifier({text:`custom`}),date:I.identifier({text:`date`}),enum:I.identifier({text:`enum`}),exactOptional:I.identifier({text:`exactOptional`}),file:I.identifier({text:`file`}),function:I.identifier({text:`function`}),instance:I.identifier({text:`instance`}),intersect:I.identifier({text:`intersect`}),lazy:I.identifier({text:`lazy`}),literal:I.identifier({text:`literal`}),looseObject:I.identifier({text:`looseObject`}),looseTuple:I.identifier({text:`looseTuple`}),map:I.identifier({text:`map`}),nan:I.identifier({text:`nan`}),never:I.identifier({text:`never`}),nonNullable:I.identifier({text:`nonNullable`}),nonNullish:I.identifier({text:`nonNullish`}),nonOptional:I.identifier({text:`nonOptional`}),null:I.identifier({text:`null`}),nullable:I.identifier({text:`nullable`}),nullish:I.identifier({text:`nullish`}),number:I.identifier({text:`number`}),object:I.identifier({text:`object`}),objectWithRest:I.identifier({text:`objectWithRest`}),optional:I.identifier({text:`optional`}),picklist:I.identifier({text:`picklist`}),promise:I.identifier({text:`promise`}),record:I.identifier({text:`record`}),set:I.identifier({text:`set`}),strictObject:I.identifier({text:`strictObject`}),strictTuple:I.identifier({text:`strictTuple`}),string:I.identifier({text:`string`}),symbol:I.identifier({text:`symbol`}),tuple:I.identifier({text:`tuple`}),tupleWithRest:I.identifier({text:`tupleWithRest`}),undefined:I.identifier({text:`undefined`}),undefinedable:I.identifier({text:`undefinedable`}),union:I.identifier({text:`union`}),unknown:I.identifier({text:`unknown`}),variant:I.identifier({text:`variant`}),void:I.identifier({text:`void`})},storages:{},types:{GenericSchema:I.identifier({text:`GenericSchema`})},utils:{}},zp=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`data`,e.id));if(!n)return;let r=t.referenceSymbol(t.api.selector(`external`,`valibot.v`)),i=`data`;return I.arrowFunction({async:!0,parameters:[{name:i}],statements:[I.returnStatement({expression:I.awaitExpression({expression:I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:X.async.parseAsync}),parameters:[I.identifier({text:n.placeholder}),I.identifier({text:i})]})})})]})},Bp=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`responses`,e.id));if(!n)return;let r=t.referenceSymbol(t.api.selector(`external`,`valibot.v`)),i=`data`;return I.arrowFunction({async:!0,parameters:[{name:i}],statements:[I.returnStatement({expression:I.awaitExpression({expression:I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:X.async.parseAsync}),parameters:[I.identifier({text:n.placeholder}),I.identifier({text:i})]})})})]})};var Vp=class{constructor(e){this.meta=e}createRequestValidator(e){return zp(e)}createResponseValidator(e){return Bp(e)}selector(...e){return[this.meta.name,...e]}};const Z=({pipes:e,plugin:t})=>{if(e.length===1)return e[0];let n=t.referenceSymbol(t.api.selector(`external`,`valibot.v`));return I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.methods.pipe}),parameters:e})},Hp=({ast:e,plugin:t,schema:n,state:r,symbol:i})=>{let a=t.referenceSymbol(t.api.selector(`external`,`valibot.v`)),o=I.constVariable({comment:t.config.comments?wd({schema:n}):void 0,exportConst:i.exported,expression:Z({pipes:e.pipes,plugin:t}),name:i.placeholder,typeName:r.hasLazyExpression.value?I.propertyAccessExpression({expression:a.placeholder,name:e.typeName||X.types.GenericSchema.text}):void 0});t.setSymbolValue(i,o)},Up={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}},Wp=e=>e!==void 0&&e in Up,Gp=e=>Wp(e)&&Up[e].needsBigInt,Kp=({isBigInt:e,value:t})=>{let n=I.valueToExpression({value:t});return e&&(typeof t==`bigint`||typeof t==`number`||typeof t==`string`||typeof t==`boolean`)?I.callExpression({functionName:`BigInt`,parameters:[n]}):n},qp=({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],Hp({ast:e(a,r.path.value),plugin:n,schema:a,state:r,symbol:n.registerSymbol({exported:!0,meta:{path:r.path.value,tags:r.tags?.value},name:E({config:n.config.requests,name:t.id}),selector:n.api.selector(`data`,t.id)})})}if(n.config.responses.enabled&&t.responses){let{response:i}=ut(t);if(i){let a=[...r.path.value,`responses`];Hp({ast:e(i,a),plugin:n,schema:i,state:r,symbol:n.registerSymbol({exported:!0,meta:{path:a,tags:r.tags?.value},name:E({config:n.config.responses,name:t.id}),selector:n.api.selector(`responses`,t.id)})})}}},Jp=({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],Hp({ast:e(a,r.path.value),plugin:n,schema:a,state:r,symbol:n.registerSymbol({exported:!0,meta:{path:r.path.value,tags:r.tags?.value},name:E({config:n.config.webhooks,name:t.id}),selector:n.api.selector(`webhook-request`,t.id)})})}},Yp=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:X.schemas.unknown})})},Xp=({plugin:e,schema:t,state:n})=>{let r={pipes:[]},i=e.referenceSymbol(e.api.selector(`external`,`valibot.v`)),a=I.propertyAccessExpression({expression:i.placeholder,name:X.schemas.array});if(t.items){t=D({schema:t});let i=t.items.map((t,i)=>{let a=cm({plugin:e,schema:t,state:{...n,path:q([...n.path.value,`items`,i])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),Z({pipes:a.pipes,plugin:e})});if(i.length===1){let e=I.callExpression({functionName:a,parameters:i});r.pipes.push(e)}else{t.logicalOperator;let i=I.callExpression({functionName:a,parameters:[Yp({plugin:e,schema:{type:`unknown`},state:n})]});r.pipes.push(i)}}else{let t=I.callExpression({functionName:a,parameters:[Yp({plugin:e,schema:{type:`unknown`},state:n})]});r.pipes.push(t)}if(t.minItems===t.maxItems&&t.minItems!==void 0){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:X.actions.length}),parameters:[I.valueToExpression({value:t.minItems})]});r.pipes.push(e)}else{if(t.minItems!==void 0){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:X.actions.minLength}),parameters:[I.valueToExpression({value:t.minItems})]});r.pipes.push(e)}if(t.maxItems!==void 0){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:X.actions.maxLength}),parameters:[I.valueToExpression({value:t.maxItems})]});r.pipes.push(e)}}return r},Zp=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return typeof t.const==`boolean`?I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.schemas.literal}),parameters:[I.ots.boolean(t.const)]}):I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.schemas.boolean})})},Qp=({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(I.stringLiteral({text:e.const})):(e.type===`null`||e.const===null)&&(i=!0);if(!r.length)return Yp({plugin:e,schema:{type:`unknown`},state:n});let a=e.referenceSymbol(e.api.selector(`external`,`valibot.v`)),o=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:X.schemas.picklist}),parameters:[I.arrayLiteralExpression({elements:r,multiLine:!1})]});return i&&(o=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:X.schemas.nullable}),parameters:[o]})),o},$p=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:X.schemas.never})})},em=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:X.schemas.null})})},tm=({plugin:e,schema:t})=>{let n=t.format,r=t.type===`integer`,i=Gp(n),a=Wp(n)?Up[n]:null,o=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));if(t.const!==void 0&&t.const!==null){let e=t.const,r;if(typeof e==`number`&&!n)r=I.ots.number(e);else if(typeof e==`number`&&n)r=i?I.callExpression({functionName:`BigInt`,parameters:[I.ots.string(e.toString())]}):I.ots.number(e);else if(typeof e==`string`&&i){let t=e.endsWith(`n`)?e.slice(0,-1):e;r=I.callExpression({functionName:`BigInt`,parameters:[I.ots.string(t)]})}else if(typeof e==`bigint`){let t=e.toString(),n=t.endsWith(`n`)?t.slice(0,-1):t;r=I.callExpression({functionName:`BigInt`,parameters:[I.ots.string(n)]})}else r=I.valueToExpression({value:e});return I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.schemas.literal}),parameters:[r]})}let s=[];if(i){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.schemas.union}),parameters:[I.arrayLiteralExpression({elements:[I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.schemas.number})}),I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.schemas.string})}),I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.schemas.bigInt})})],multiLine:!1})]});s.push(e);let t=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.actions.transform}),parameters:[I.arrowFunction({parameters:[{name:`x`}],statements:I.callExpression({functionName:`BigInt`,parameters:[I.identifier({text:`x`})]})})]});s.push(t)}else{let e=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.schemas.number})});s.push(e)}if(!i&&r){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.actions.integer})});s.push(e)}if(a){let e=a.min,t=a.max,n=a.minError,r=a.maxError,c=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.actions.minValue}),parameters:[i?I.callExpression({functionName:`BigInt`,parameters:[I.ots.string(e.toString())]}):I.ots.number(e),I.ots.string(n)]});s.push(c);let l=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.actions.maxValue}),parameters:[i?I.callExpression({functionName:`BigInt`,parameters:[I.ots.string(t.toString())]}):I.ots.number(t),I.ots.string(r)]});s.push(l)}if(t.exclusiveMinimum!==void 0){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.actions.gtValue}),parameters:[Kp({isBigInt:i,value:t.exclusiveMinimum})]});s.push(e)}else if(t.minimum!==void 0){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.actions.minValue}),parameters:[Kp({isBigInt:i,value:t.minimum})]});s.push(e)}if(t.exclusiveMaximum!==void 0){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.actions.ltValue}),parameters:[Kp({isBigInt:i,value:t.exclusiveMaximum})]});s.push(e)}else if(t.maximum!==void 0){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.actions.maxValue}),parameters:[Kp({isBigInt:i,value:t.maximum})]});s.push(e)}return Z({pipes:s,plugin:e})},nm=({plugin:e,schema:t,state:n})=>{let r={},i=[],a=t.required??[];for(let o in t.properties){let s=t.properties[o],c=cm({optional:!a.includes(o),plugin:e,schema:s,state:{...n,path:q([...n.path.value,`properties`,o])}});c.hasLazyExpression&&(r.hasLazyExpression=!0),A.lastIndex=0;let l;l=A.test(o)?o.startsWith(`-`)?m.default.factory.createStringLiteral(o):m.default.factory.createNumericLiteral(o):o,(o.match(/^[0-9]/)&&o.match(/\D+/g)||o.match(/\W/g))&&!o.startsWith(`'`)&&!o.endsWith(`'`)&&(l=`'${o}'`),i.push(I.propertyAssignment({initializer:Z({pipes:c.pipes,plugin:e}),name:l}))}let o=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));if(t.additionalProperties&&t.additionalProperties.type===`object`&&!Object.keys(i).length){let i=cm({plugin:e,schema:t.additionalProperties,state:{...n,path:q([...n.path.value,`additionalProperties`])}});return i.hasLazyExpression&&(r.hasLazyExpression=!0),r.pipes=[I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.schemas.record}),parameters:[I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.schemas.string}),parameters:[]}),Z({pipes:i.pipes,plugin:e})]})],r}return r.pipes=[I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.schemas.object}),parameters:[m.default.factory.createObjectLiteralExpression(i,!0)]})],r},rm=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));if(typeof t.const==`string`)return I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.schemas.literal}),parameters:[I.ots.string(t.const)]});let r=[],i=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.schemas.string})});if(r.push(i),t.format)switch(t.format){case`date`:r.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.actions.isoDate})}));break;case`date-time`:r.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.actions.isoTimestamp})}));break;case`ipv4`:case`ipv6`:r.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.actions.ip})}));break;case`uri`:r.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.actions.url})}));break;case`email`:case`time`:case`uuid`:r.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:I.identifier({text:t.format})})}));break}if(t.minLength===t.maxLength&&t.minLength!==void 0){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.actions.length}),parameters:[I.valueToExpression({value:t.minLength})]});r.push(e)}else{if(t.minLength!==void 0){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.actions.minLength}),parameters:[I.valueToExpression({value:t.minLength})]});r.push(e)}if(t.maxLength!==void 0){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.actions.maxLength}),parameters:[I.valueToExpression({value:t.maxLength})]});r.push(e)}}if(t.pattern){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.actions.regex}),parameters:[I.regularExpressionLiteral({text:t.pattern})]});r.push(e)}return Z({pipes:r,plugin:e})},im=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:X.schemas.literal}),parameters:[I.valueToExpression({value:e})]}));return r.pipes=[I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:X.schemas.tuple}),parameters:[I.arrayLiteralExpression({elements:e})]})],r}if(t.items){let a=t.items.map((t,i)=>{let a=cm({plugin:e,schema:t,state:{...n,path:q([...n.path.value,`items`,i])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),Z({pipes:a.pipes,plugin:e})});return r.pipes=[I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:X.schemas.tuple}),parameters:[I.arrayLiteralExpression({elements:a})]})],r}return{pipes:[Yp({plugin:e,schema:{type:`unknown`},state:n})]}},am=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:X.schemas.undefined})})},om=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:X.schemas.void})})},sm=({schema:e,...t})=>{switch(e.type){case`array`:return{expression:Z({pipes:Xp({...t,schema:e}).pipes,plugin:t.plugin})};case`boolean`:return{expression:Zp({...t,schema:e})};case`enum`:return{expression:Qp({...t,schema:e})};case`integer`:case`number`:return{expression:tm({...t,schema:e})};case`never`:return{expression:$p({...t,schema:e})};case`null`:return{expression:em({...t,schema:e})};case`object`:return{expression:Z({pipes:nm({...t,schema:e}).pipes,plugin:t.plugin})};case`string`:return e.format===`int64`||e.format===`uint64`?{expression:tm({...t,schema:e})}:{expression:rm({...t,schema:e})};case`tuple`:return{expression:Z({pipes:im({...t,schema:e}).pipes,plugin:t.plugin})};case`undefined`:return{expression:am({...t,schema:e})};case`unknown`:return{expression:Yp({...t,schema:e})};case`void`:return{expression:om({...t,schema:e})}}},cm=({optional:e,plugin:t,schema:n,state:r})=>{let i={pipes:[]},a=t.referenceSymbol(t.api.selector(`external`,`valibot.v`));if(n.$ref){let e=t.api.selector(`ref`,n.$ref),o=t.referenceSymbol(e);if(t.isSymbolRegistered(e)){let e=I.identifier({text:o.placeholder});i.pipes.push(e)}else{let e=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:X.schemas.lazy}),parameters:[I.arrowFunction({statements:[I.returnStatement({expression:I.identifier({text:o.placeholder})})]})]});i.pipes.push(e),r.hasLazyExpression.value=!0}}else if(n.type){let e=sm({plugin:t,schema:n,state:r});if(i.typeName=e.anyType,i.pipes.push(e.expression),t.config.metadata&&n.description){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:X.actions.metadata}),parameters:[I.objectExpression({obj:[{key:`description`,value:I.stringLiteral({text:n.description})}]})]});i.pipes.push(e)}}else if(n.items)if(n=D({schema:n}),n.items){let e=n.items.map((e,n)=>Z({pipes:cm({plugin:t,schema:e,state:{...r,path:q([...r.path.value,`items`,n])}}).pipes,plugin:t}));if(n.logicalOperator===`and`){let t=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:X.schemas.intersect}),parameters:[I.arrayLiteralExpression({elements:e})]});i.pipes.push(t)}else{let t=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:X.schemas.union}),parameters:[I.arrayLiteralExpression({elements:e})]});i.pipes.push(t)}}else{let e=cm({plugin:t,schema:n,state:r});i.pipes.push(...e.pipes)}else{let e=sm({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=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:X.actions.readonly})});i.pipes.push(e)}let r;n.default!==void 0&&(r=Kp({isBigInt:n.type===`integer`&&n.format===`int64`,value:n.default}),r&&(i.pipes=[I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:X.schemas.optional}),parameters:[Z({pipes:i.pipes,plugin:t}),r]})])),e&&!r&&(i.pipes=[I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:X.schemas.optional}),parameters:[Z({pipes:i.pipes,plugin:t})]})])}return i},lm=({plugin:e,schema:t,state:n})=>{let r=mr(n.path.value),i=cm({plugin:e,schema:t,state:n}),a=L(r);Hp({ast:i,plugin:e,schema:t,state:n,symbol:e.registerSymbol({exported:!0,meta:{path:n.path.value,tags:n.tags?.value},name:E({config:e.config.definitions,name:a}),selector:e.api.selector(`ref`,r)})})},um=({plugin:e})=>{e.registerSymbol({external:`valibot`,meta:{importKind:`namespace`},name:`v`,selector:e.api.selector(`external`,`valibot.v`)}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=J({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:qp({getAst:(n,r)=>cm({plugin:e,schema:n,state:J({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:lm({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:lm({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:lm({plugin:e,schema:t.schema,state:n});break;case`webhook`:Jp({getAst:(n,r)=>cm({plugin:e,schema:n,state:J({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},dm=e=>um(e),fm={api:new Vp({name:`valibot`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:dm,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`]},pm=C(fm),Q={ZodMiniOptional:I.identifier({text:`ZodMiniOptional`}),ZodOptional:I.identifier({text:`ZodOptional`}),_default:I.identifier({text:`_default`}),and:I.identifier({text:`and`}),array:I.identifier({text:`array`}),bigint:I.identifier({text:`bigint`}),boolean:I.identifier({text:`boolean`}),check:I.identifier({text:`check`}),coerce:I.identifier({text:`coerce`}),date:I.identifier({text:`date`}),datetime:I.identifier({text:`datetime`}),default:I.identifier({text:`default`}),describe:I.identifier({text:`describe`}),email:I.identifier({text:`email`}),enum:I.identifier({text:`enum`}),globalRegistry:I.identifier({text:`globalRegistry`}),gt:I.identifier({text:`gt`}),gte:I.identifier({text:`gte`}),infer:I.identifier({text:`infer`}),int:I.identifier({text:`int`}),intersection:I.identifier({text:`intersection`}),ip:I.identifier({text:`ip`}),ipv4:I.identifier({text:`ipv4`}),ipv6:I.identifier({text:`ipv6`}),iso:I.identifier({text:`iso`}),lazy:I.identifier({text:`lazy`}),length:I.identifier({text:`length`}),literal:I.identifier({text:`literal`}),lt:I.identifier({text:`lt`}),lte:I.identifier({text:`lte`}),max:I.identifier({text:`max`}),maxLength:I.identifier({text:`maxLength`}),min:I.identifier({text:`min`}),minLength:I.identifier({text:`minLength`}),never:I.identifier({text:`never`}),null:I.identifier({text:`null`}),nullable:I.identifier({text:`nullable`}),number:I.identifier({text:`number`}),object:I.identifier({text:`object`}),optional:I.identifier({text:`optional`}),parseAsync:I.identifier({text:`parseAsync`}),readonly:I.identifier({text:`readonly`}),record:I.identifier({text:`record`}),regex:I.identifier({text:`regex`}),register:I.identifier({text:`register`}),string:I.identifier({text:`string`}),time:I.identifier({text:`time`}),tuple:I.identifier({text:`tuple`}),undefined:I.identifier({text:`undefined`}),union:I.identifier({text:`union`}),unknown:I.identifier({text:`unknown`}),url:I.identifier({text:`url`}),uuid:I.identifier({text:`uuid`}),void:I.identifier({text:`void`})},mm=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`data`,e.id));if(!n)return;let r=`data`;return I.arrowFunction({async:!0,parameters:[{name:r}],statements:[I.returnStatement({expression:I.awaitExpression({expression:I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[I.identifier({text:r})]})})})]})},hm=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`responses`,e.id));if(!n)return;let r=`data`;return I.arrowFunction({async:!0,parameters:[{name:r}],statements:[I.returnStatement({expression:I.awaitExpression({expression:I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[I.identifier({text:r})]})})})]})},gm=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`data`,e.id));if(!n)return;let r=`data`;return I.arrowFunction({async:!0,parameters:[{name:r}],statements:[I.returnStatement({expression:I.awaitExpression({expression:I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[I.identifier({text:r})]})})})]})},_m=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`responses`,e.id));if(!n)return;let r=`data`;return I.arrowFunction({async:!0,parameters:[{name:r}],statements:[I.returnStatement({expression:I.awaitExpression({expression:I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[I.identifier({text:r})]})})})]})},vm=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`data`,e.id));if(!n)return;let r=`data`;return I.arrowFunction({async:!0,parameters:[{name:r}],statements:[I.returnStatement({expression:I.awaitExpression({expression:I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[I.identifier({text:r})]})})})]})},ym=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`responses`,e.id));if(!n)return;let r=`data`;return I.arrowFunction({async:!0,parameters:[{name:r}],statements:[I.returnStatement({expression:I.awaitExpression({expression:I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[I.identifier({text:r})]})})})]})};var bm=class{constructor(e){this.meta=e}createRequestValidator(e){let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return gm(e);case`mini`:return mm(e);case 4:default:return vm(e)}}createResponseValidator(e){let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return _m(e);case`mini`:return hm(e);case 4:default:return ym(e)}}selector(...e){return[this.meta.name,...e]}};const xm=({ast:e,plugin:t,schema:n,symbol:r,typeInferSymbol:i})=>{let a=t.referenceSymbol(t.api.selector(`external`,`zod.z`)),o=I.constVariable({comment:t.config.comments?wd({schema:n}):void 0,exportConst:r.exported,expression:e.expression,name:r.placeholder,typeName:e.typeName?I.propertyAccessExpression({expression:a.placeholder,name:e.typeName}):void 0});if(t.setSymbolValue(r,o),i){let e=I.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:I.typeReferenceNode({typeArguments:[I.typeOfExpression({text:r.placeholder})],typeName:I.propertyAccessExpression({expression:a.placeholder,name:Q.infer})})});t.setSymbolValue(i,e)}},Sm=({plugin:e})=>{let t=e.package.getVersion(`zod`);if(t&&e.package.satisfies(t,`<4.0.0`))switch(e.config.compatibilityVersion){case 3:default:return`zod`;case 4:return`zod/v4`;case`mini`:return`zod/v4-mini`}switch(e.config.compatibilityVersion){case 3:return`zod/v3`;case 4:default:return`zod`;case`mini`:return`zod/mini`}},$=({isBigInt:e,value:t})=>{let n=I.valueToExpression({value:t});return e&&(typeof t==`bigint`||typeof t==`number`||typeof t==`string`||typeof t==`boolean`)?I.callExpression({functionName:`BigInt`,parameters:[n]}):n},Cm=({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],xm({ast:e(a,r.path.value),plugin:n,schema:a,symbol:n.registerSymbol({exported:!0,meta:{path:r.path.value,tags:r.tags?.value},name:E({config:n.config.requests,name:t.id}),selector:n.api.selector(`data`,t.id)}),typeInferSymbol:n.config.requests.types.infer.enabled?n.registerSymbol({exported:!0,meta:{kind:`type`,path:r.path.value,tags:r.tags?.value},name:E({config:n.config.requests.types.infer,name:t.id}),selector:n.api.selector(`type-infer-data`,t.id)}):void 0})}if(n.config.responses.enabled&&t.responses){let{response:i}=ut(t);if(i){let a=[...r.path.value,`responses`];xm({ast:e(i,a),plugin:n,schema:i,symbol:n.registerSymbol({exported:!0,meta:{path:a,tags:r.tags?.value},name:E({config:n.config.responses,name:t.id}),selector:n.api.selector(`responses`,t.id)}),typeInferSymbol:n.config.responses.types.infer.enabled?n.registerSymbol({exported:!0,meta:{kind:`type`,path:a,tags:r.tags?.value},name:E({config:n.config.responses.types.infer,name:t.id}),selector:n.api.selector(`type-infer-responses`,t.id)}):void 0})}}},wm=({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],xm({ast:e(a,r.path.value),plugin:n,schema:a,symbol:n.registerSymbol({exported:!0,meta:{path:r.path.value,tags:r.tags?.value},name:E({config:n.config.webhooks,name:t.id}),selector:n.api.selector(`webhook-request`,t.id)}),typeInferSymbol:n.config.webhooks.types.infer.enabled?n.registerSymbol({exported:!0,meta:{kind:`type`,path:r.path.value,tags:r.tags?.value},name:E({config:n.config.webhooks.types.infer,name:t.id}),selector:n.api.selector(`type-infer-webhook-request`,t.id)}):void 0})}},Tm=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),n={};return n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:Q.unknown})}),n},Em=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i={},a=I.propertyAccessExpression({expression:r.placeholder,name:Q.array});if(!t.items)i.expression=I.callExpression({functionName:a,parameters:[Tm({plugin:e,schema:{type:`unknown`},state:n}).expression]});else{t=D({schema:t});let o=t.items.map((t,r)=>{let a=Rm({plugin:e,schema:t,state:{...n,path:q([...n.path.value,`items`,r])}});return a.hasLazyExpression&&(i.hasLazyExpression=!0),a.expression});if(o.length===1)i.expression=I.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=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.intersection}),parameters:o});else{n=o[0];for(let e=1;e<o.length;e++)n=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.intersection}),parameters:[n,o[e]]})}i.expression=I.callExpression({functionName:a,parameters:[n]})}else i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.array}),parameters:[I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.union}),parameters:[I.arrayLiteralExpression({elements:o})]})]})}let o=[];return t.minItems===t.maxItems&&t.minItems!==void 0?o.push(I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.length}),parameters:[I.valueToExpression({value:t.minItems})]})):(t.minItems!==void 0&&o.push(I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.minLength}),parameters:[I.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&o.push(I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.maxLength}),parameters:[I.valueToExpression({value:t.maxItems})]}))),o.length&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.expression,name:Q.check}),parameters:o})),i},Dm=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),r={};return typeof t.const==`boolean`?(r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[I.ots.boolean(t.const)]}),r):(r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.boolean})}),r)},Om=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i={},a=[],o=[],s=!1,c=!0;for(let e of t.items??[])if(e.type===`string`&&typeof e.const==`string`){let t=I.stringLiteral({text:e.const});a.push(t),o.push(I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[t]}))}else if((e.type===`number`||e.type===`integer`)&&typeof e.const==`number`){c=!1;let t=I.ots.number(e.const);o.push(I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[t]}))}else if(e.type===`boolean`&&typeof e.const==`boolean`){c=!1;let t=I.ots.boolean(e.const);o.push(I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[t]}))}else (e.type===`null`||e.const===null)&&(s=!0);return o.length?(c&&a.length>0?i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.enum}),parameters:[I.arrayLiteralExpression({elements:a,multiLine:!1})]}):o.length===1?i.expression=o[0]:i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.union}),parameters:[I.arrayLiteralExpression({elements:o,multiLine:o.length>3})]}),s&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.nullable}),parameters:[i.expression]})),i):Tm({plugin:e,schema:{type:`unknown`},state:n})},km=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),n={};return n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:Q.never})}),n},Am=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),n={};return n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:Q.null})}),n},jm=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),r={},i=t.type===`integer`&&t.format===`int64`;if(typeof t.const==`number`)return r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[I.ots.number(t.const)]}),r;r.expression=I.callExpression({functionName:i?I.propertyAccessExpression({expression:I.propertyAccessExpression({expression:n.placeholder,name:Q.coerce}),name:Q.bigint}):I.propertyAccessExpression({expression:n.placeholder,name:Q.number})}),!i&&t.type===`integer`&&(r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.int})}));let a=[];return t.exclusiveMinimum===void 0?t.minimum!==void 0&&a.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.gte}),parameters:[$({isBigInt:i,value:t.minimum})]})):a.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.gt}),parameters:[$({isBigInt:i,value:t.exclusiveMinimum})]})),t.exclusiveMaximum===void 0?t.maximum!==void 0&&a.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.lte}),parameters:[$({isBigInt:i,value:t.maximum})]})):a.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.lt}),parameters:[$({isBigInt:i,value:t.exclusiveMaximum})]})),a.length&&(r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.expression,name:Q.check}),parameters:a})),r},Mm=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i={},a=[],o=t.required??[];for(let r in t.properties){let s=t.properties[r],c=Rm({optional:!o.includes(r),plugin:e,schema:s,state:{...n,path:q([...n.path.value,`properties`,r])}});c.hasLazyExpression&&(i.hasLazyExpression=!0),A.lastIndex=0;let l;l=A.test(r)?r.startsWith(`-`)?m.default.factory.createStringLiteral(r):m.default.factory.createNumericLiteral(r):r,(r.match(/^[0-9]/)&&r.match(/\D+/g)||r.match(/\W/g))&&!r.startsWith(`'`)&&!r.endsWith(`'`)&&(l=`'${r}'`),c.hasLazyExpression?a.push(I.getAccessorDeclaration({name:l,statements:[I.returnStatement({expression:c.expression})]})):a.push(I.propertyAssignment({initializer:c.expression,name:l}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let a=Rm({plugin:e,schema:t.additionalProperties,state:{...n,path:q([...n.path.value,`additionalProperties`])}});return i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.record}),parameters:[I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.string}),parameters:[]}),a.expression]}),a.hasLazyExpression&&(i.hasLazyExpression=!0),i}return i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.object}),parameters:[m.default.factory.createObjectLiteralExpression(a,!0)]}),i},Nm=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),r={};if(typeof t.const==`string`)return r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[I.ots.string(t.const)]}),r;r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.string})});let i=[];if(e.config.dates.offset&&i.push({key:`offset`,value:!0}),e.config.dates.local&&i.push({key:`local`,value:!0}),t.format)switch(t.format){case`date`:r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:I.propertyAccessExpression({expression:n.placeholder,name:Q.iso}),name:Q.date})});break;case`date-time`:r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:I.propertyAccessExpression({expression:n.placeholder,name:Q.iso}),name:Q.datetime}),parameters:i.length>0?[I.objectExpression({obj:i})]:[]});break;case`email`:r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.email})});break;case`ipv4`:r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.ipv4})});break;case`ipv6`:r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.ipv6})});break;case`time`:r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:I.propertyAccessExpression({expression:n.placeholder,name:Q.iso}),name:Q.time})});break;case`uri`:r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.url})});break;case`uuid`:r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.uuid})});break}let a=[];return t.minLength===t.maxLength&&t.minLength!==void 0?a.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.length}),parameters:[I.valueToExpression({value:t.minLength})]})):(t.minLength!==void 0&&a.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.minLength}),parameters:[I.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&a.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.maxLength}),parameters:[I.valueToExpression({value:t.maxLength})]}))),t.pattern&&a.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.regex}),parameters:[I.regularExpressionLiteral({text:t.pattern})]})),a.length&&(r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.expression,name:Q.check}),parameters:a})),r},Pm=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i={};if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[I.valueToExpression({value:e})]}));return i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.tuple}),parameters:[I.arrayLiteralExpression({elements:e})]}),i}let a=[];return t.items&&t.items.forEach((t,r)=>{let o=Rm({plugin:e,schema:t,state:{...n,path:q([...n.path.value,`items`,r])}});a.push(o.expression),o.hasLazyExpression&&(i.hasLazyExpression=!0)}),i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.tuple}),parameters:[I.arrayLiteralExpression({elements:a})]}),i},Fm=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),n={};return n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:Q.undefined})}),n},Im=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),n={};return n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:Q.void})}),n},Lm=({schema:e,...t})=>{switch(e.type){case`array`:return Em({...t,schema:e});case`boolean`:return Dm({...t,schema:e});case`enum`:return Om({...t,schema:e});case`integer`:case`number`:return jm({...t,schema:e});case`never`:return km({...t,schema:e});case`null`:return Am({...t,schema:e});case`object`:return Mm({...t,schema:e});case`string`:return Nm({...t,schema:e});case`tuple`:return Pm({...t,schema:e});case`undefined`:return Fm({...t,schema:e});case`unknown`:return Tm({...t,schema:e});case`void`:return Im({...t,schema:e})}},Rm=({optional:e,plugin:t,schema:n,state:r})=>{let i={},a=t.referenceSymbol(t.api.selector(`external`,`zod.z`));if(n.$ref){let e=t.api.selector(`ref`,n.$ref),o=t.referenceSymbol(e);t.isSymbolRegistered(e)?i.expression=I.identifier({text:o.placeholder}):(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.lazy}),parameters:[I.arrowFunction({returnType:I.keywordTypeNode({keyword:`any`}),statements:[I.returnStatement({expression:I.identifier({text:o.placeholder})})]})]}),i.hasLazyExpression=!0,r.hasLazyExpression.value=!0)}else if(n.type){let e=Lm({plugin:t,schema:n,state:r});i.expression=e.expression,i.hasLazyExpression=e.hasLazyExpression,t.config.metadata&&n.description&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.expression,name:Q.register}),parameters:[I.propertyAccessExpression({expression:a.placeholder,name:Q.globalRegistry}),I.objectExpression({obj:[{key:`description`,value:I.stringLiteral({text:n.description})}]})]}))}else if(n.items)if(n=D({schema:n}),n.items){let e=n.items.map((e,n)=>Rm({plugin:t,schema:e,state:{...r,path:q([...r.path.value,`items`,n])}}));if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.intersection}),parameters:e.map(e=>e.expression)}):(i.expression=e[0].expression,e.slice(1).forEach(e=>{i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.intersection}),parameters:[i.expression,e.hasLazyExpression?I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.lazy}),parameters:[I.arrowFunction({statements:[I.returnStatement({expression:e.expression})]})]}):e.expression]})}))}else i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.union}),parameters:[I.arrayLiteralExpression({elements:e.map(e=>e.expression)})]})}else i=Rm({plugin:t,schema:n,state:r});else i.expression=Lm({plugin:t,schema:{type:`unknown`},state:r}).expression;if(i.expression&&(n.accessScope===`read`&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.readonly}),parameters:[i.expression]})),e&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.optional}),parameters:[i.expression]}),i.typeName=Q.ZodMiniOptional),n.default!==void 0)){let e=$({isBigInt:n.type===`integer`&&n.format===`int64`,value:n.default});e&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q._default}),parameters:[i.expression,e]}))}return i},zm=({plugin:e,schema:t,state:n})=>{let r=mr(n.path.value),i=Rm({plugin:e,schema:t,state:n}),a=L(r);xm({ast:i,plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{path:n.path.value,tags:n.tags?.value},name:E({config:e.config.definitions,name:a}),selector:e.api.selector(`ref`,r)}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:E({config:e.config.definitions.types.infer,name:a}),selector:e.api.selector(`type-infer-ref`,r)}):void 0})},Bm=({plugin:e})=>{e.registerSymbol({external:Sm({plugin:e}),meta:{importKind:`namespace`},name:`z`,selector:e.api.selector(`external`,`zod.z`)}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=J({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:Cm({getAst:(n,r)=>Rm({plugin:e,schema:n,state:J({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:zm({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:zm({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:zm({plugin:e,schema:t.schema,state:n});break;case`webhook`:wm({getAst:(n,r)=>Rm({plugin:e,schema:n,state:J({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},Vm=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:Q.unknown})})},Hm=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i=I.propertyAccessExpression({expression:r.placeholder,name:Q.array}),a,o=!1;if(!t.items)a=I.callExpression({functionName:i,parameters:[Vm({plugin:e,schema:{type:`unknown`},state:n})]});else{t=D({schema:t});let s=t.items.map((t,r)=>{let i=eh({plugin:e,schema:t,state:{...n,path:q([...n.path.value,`items`,r])}});return i.hasLazyExpression&&(o=!0),i.expression});if(s.length===1)a=I.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=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.intersection}),parameters:s});else{n=s[0];for(let e=1;e<s.length;e++)n=I.callExpression({functionName:I.propertyAccessExpression({expression:n,name:Q.and}),parameters:[s[e]]})}a=I.callExpression({functionName:i,parameters:[n]})}else a=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.array}),parameters:[I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.union}),parameters:[I.arrayLiteralExpression({elements:s})]})]})}return t.minItems===t.maxItems&&t.minItems!==void 0?a=I.callExpression({functionName:I.propertyAccessExpression({expression:a,name:Q.length}),parameters:[I.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(a=I.callExpression({functionName:I.propertyAccessExpression({expression:a,name:Q.min}),parameters:[I.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(a=I.callExpression({functionName:I.propertyAccessExpression({expression:a,name:Q.max}),parameters:[I.valueToExpression({value:t.maxItems})]}))),{expression:a,hasLazyExpression:o}},Um=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return typeof t.const==`boolean`?I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[I.ots.boolean(t.const)]}):I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.boolean})})},Wm=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i=[],a=[],o=!1,s=!0;for(let e of t.items??[])if(e.type===`string`&&typeof e.const==`string`){let t=I.stringLiteral({text:e.const});i.push(t),a.push(I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[t]}))}else if((e.type===`number`||e.type===`integer`)&&typeof e.const==`number`){s=!1;let t=I.ots.number(e.const);a.push(I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[t]}))}else if(e.type===`boolean`&&typeof e.const==`boolean`){s=!1;let t=I.ots.boolean(e.const);a.push(I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[t]}))}else (e.type===`null`||e.const===null)&&(o=!0);if(!a.length)return Vm({plugin:e,schema:{type:`unknown`},state:n});let c;return c=s&&i.length>0?I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.enum}),parameters:[I.arrayLiteralExpression({elements:i,multiLine:!1})]}):a.length===1?a[0]:I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.union}),parameters:[I.arrayLiteralExpression({elements:a,multiLine:a.length>3})]}),o&&(c=I.callExpression({functionName:I.propertyAccessExpression({expression:c,name:Q.nullable})})),c},Gm=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:Q.never})})},Km=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:Q.null})})},qm=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),r=t.type===`integer`&&t.format===`int64`;if(typeof t.const==`number`)return I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[I.ots.number(t.const)]});let i=I.callExpression({functionName:r?I.propertyAccessExpression({expression:I.propertyAccessExpression({expression:n.placeholder,name:Q.coerce}),name:Q.bigint}):I.propertyAccessExpression({expression:n.placeholder,name:Q.number})});return!r&&t.type===`integer`&&(i=I.callExpression({functionName:I.propertyAccessExpression({expression:i,name:Q.int})})),t.exclusiveMinimum===void 0?t.minimum!==void 0&&(i=I.callExpression({functionName:I.propertyAccessExpression({expression:i,name:Q.gte}),parameters:[$({isBigInt:r,value:t.minimum})]})):i=I.callExpression({functionName:I.propertyAccessExpression({expression:i,name:Q.gt}),parameters:[$({isBigInt:r,value:t.exclusiveMinimum})]}),t.exclusiveMaximum===void 0?t.maximum!==void 0&&(i=I.callExpression({functionName:I.propertyAccessExpression({expression:i,name:Q.lte}),parameters:[$({isBigInt:r,value:t.maximum})]})):i=I.callExpression({functionName:I.propertyAccessExpression({expression:i,name:Q.lt}),parameters:[$({isBigInt:r,value:t.exclusiveMaximum})]}),i},Jm=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i=!1,a=[],o=t.required??[];for(let r in t.properties){let s=t.properties[r],c=eh({optional:!o.includes(r),plugin:e,schema:s,state:{...n,path:q([...n.path.value,`properties`,r])}});c.hasLazyExpression&&(i=!0),A.lastIndex=0;let l;l=A.test(r)?r.startsWith(`-`)?m.default.factory.createStringLiteral(r):m.default.factory.createNumericLiteral(r):r,(r.match(/^[0-9]/)&&r.match(/\D+/g)||r.match(/\W/g))&&!r.startsWith(`'`)&&!r.endsWith(`'`)&&(l=`'${r}'`),a.push(I.propertyAssignment({initializer:c.expression,name:l}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=eh({plugin:e,schema:t.additionalProperties,state:{...n,path:q([...n.path.value,`additionalProperties`])}});return{anyType:`AnyZodObject`,expression:I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.record}),parameters:[i.expression]}),hasLazyExpression:i.hasLazyExpression}}return{anyType:`AnyZodObject`,expression:I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.object}),parameters:[m.default.factory.createObjectLiteralExpression(a,!0)]}),hasLazyExpression:i}},Ym=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));if(typeof t.const==`string`)return I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[I.ots.string(t.const)]});let r=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.string})}),i=[];if(e.config.dates.offset&&i.push({key:`offset`,value:!0}),e.config.dates.local&&i.push({key:`local`,value:!0}),t.format)switch(t.format){case`date`:r=I.callExpression({functionName:I.propertyAccessExpression({expression:r,name:Q.date})});break;case`date-time`:r=I.callExpression({functionName:I.propertyAccessExpression({expression:r,name:Q.datetime}),parameters:i.length>0?[I.objectExpression({obj:i})]:[]});break;case`email`:r=I.callExpression({functionName:I.propertyAccessExpression({expression:r,name:Q.email})});break;case`ipv4`:case`ipv6`:r=I.callExpression({functionName:I.propertyAccessExpression({expression:r,name:Q.ip})});break;case`time`:r=I.callExpression({functionName:I.propertyAccessExpression({expression:r,name:Q.time})});break;case`uri`:r=I.callExpression({functionName:I.propertyAccessExpression({expression:r,name:Q.url})});break;case`uuid`:r=I.callExpression({functionName:I.propertyAccessExpression({expression:r,name:Q.uuid})});break}return t.minLength===t.maxLength&&t.minLength!==void 0?r=I.callExpression({functionName:I.propertyAccessExpression({expression:r,name:Q.length}),parameters:[I.valueToExpression({value:t.minLength})]}):(t.minLength!==void 0&&(r=I.callExpression({functionName:I.propertyAccessExpression({expression:r,name:Q.min}),parameters:[I.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&(r=I.callExpression({functionName:I.propertyAccessExpression({expression:r,name:Q.max}),parameters:[I.valueToExpression({value:t.maxLength})]}))),t.pattern&&(r=I.callExpression({functionName:I.propertyAccessExpression({expression:r,name:Q.regex}),parameters:[I.regularExpressionLiteral({text:t.pattern})]})),r},Xm=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i=!1;if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[I.valueToExpression({value:e})]}));return{expression:I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.tuple}),parameters:[I.arrayLiteralExpression({elements:e})]}),hasLazyExpression:i}}let a=[];return t.items&&t.items.forEach((t,r)=>{let o=eh({plugin:e,schema:t,state:{...n,path:q([...n.path.value,`items`,r])}});a.push(o.expression),o.hasLazyExpression&&(i=!0)}),{expression:I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.tuple}),parameters:[I.arrayLiteralExpression({elements:a})]}),hasLazyExpression:i}},Zm=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:Q.undefined})})},Qm=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:Q.void})})},$m=({schema:e,...t})=>{switch(e.type){case`array`:return Hm({...t,schema:e});case`boolean`:return{expression:Um({...t,schema:e})};case`enum`:return{expression:Wm({...t,schema:e})};case`integer`:case`number`:return{expression:qm({...t,schema:e})};case`never`:return{expression:Gm({...t,schema:e})};case`null`:return{expression:Km({...t,schema:e})};case`object`:return Jm({...t,schema:e});case`string`:return{expression:Ym({...t,schema:e})};case`tuple`:return Xm({...t,schema:e});case`undefined`:return{expression:Zm({...t,schema:e})};case`unknown`:return{expression:Vm({...t,schema:e})};case`void`:return{expression:Qm({...t,schema:e})}}},eh=({optional:e,plugin:t,schema:n,state:r})=>{let i={},a=t.referenceSymbol(t.api.selector(`external`,`zod.z`));if(n.$ref){let e=t.api.selector(`ref`,n.$ref),o=t.referenceSymbol(e);t.isSymbolRegistered(e)?i.expression=I.identifier({text:o.placeholder}):(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.lazy}),parameters:[I.arrowFunction({statements:[I.returnStatement({expression:I.identifier({text:o.placeholder})})]})]}),i.hasLazyExpression=!0,r.hasLazyExpression.value=!0)}else if(n.type){let e=$m({plugin:t,schema:n,state:r});i.expression=e.expression,i.typeName=e.anyType,t.config.metadata&&n.description&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.expression,name:Q.describe}),parameters:[I.stringLiteral({text:n.description})]}))}else if(n.items)if(n=D({schema:n}),n.items){let e=n.items.map((e,n)=>eh({plugin:t,schema:e,state:{...r,path:q([...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=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.intersection}),parameters:e}):(i.expression=e[0],e.slice(1).forEach(e=>{i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.expression,name:Q.and}),parameters:[e]})}))}else i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.union}),parameters:[I.arrayLiteralExpression({elements:e})]})}else i=eh({plugin:t,schema:n,state:r});else{let e=$m({plugin:t,schema:{type:`unknown`},state:r});i.expression=e.expression,i.typeName=e.anyType}if(i.expression&&(n.accessScope===`read`&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.expression,name:Q.readonly})})),e&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.expression,name:Q.optional})})),n.default!==void 0)){let e=$({isBigInt:n.type===`integer`&&n.format===`int64`,value:n.default});e&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.expression,name:Q.default}),parameters:[e]}))}return r.hasLazyExpression.value?i.typeName||=`ZodTypeAny`:i.typeName&&=void 0,i},th=({plugin:e,schema:t,state:n})=>{let r=mr(n.path.value),i=eh({plugin:e,schema:t,state:n}),a=L(r);xm({ast:i,plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{path:n.path.value,tags:n.tags?.value},name:E({config:e.config.definitions,name:a}),selector:e.api.selector(`ref`,r)}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:E({config:e.config.definitions.types.infer,name:a}),selector:e.api.selector(`type-infer-ref`,r)}):void 0})},nh=({plugin:e})=>{e.registerSymbol({external:Sm({plugin:e}),name:`z`,selector:e.api.selector(`external`,`zod.z`)}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=J({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:Cm({getAst:(n,r)=>eh({plugin:e,schema:n,state:J({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:th({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:th({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:th({plugin:e,schema:t.schema,state:n});break;case`webhook`:wm({getAst:(n,r)=>eh({plugin:e,schema:n,state:J({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},rh=({plugin:e})=>{let t={},n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return t.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.unknown})}),t},ih=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),a=I.propertyAccessExpression({expression:i.placeholder,name:Q.array});if(!t.items)r.expression=I.callExpression({functionName:a,parameters:[rh({plugin:e,schema:{type:`unknown`},state:n}).expression]});else{t=D({schema:t});let o=t.items.map((t,i)=>{let a=gh({plugin:e,schema:t,state:{...n,path:q([...n.path.value,`items`,i])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),a.expression});if(o.length===1)r.expression=I.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=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.intersection}),parameters:o});else{n=o[0];for(let e=1;e<o.length;e++)n=I.callExpression({functionName:I.propertyAccessExpression({expression:n,name:Q.and}),parameters:[o[e]]})}r.expression=I.callExpression({functionName:a,parameters:[n]})}else r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.array}),parameters:[I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.union}),parameters:[I.arrayLiteralExpression({elements:o})]})]})}return t.minItems===t.maxItems&&t.minItems!==void 0?r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.expression,name:Q.length}),parameters:[I.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.expression,name:Q.min}),parameters:[I.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.expression,name:Q.max}),parameters:[I.valueToExpression({value:t.maxItems})]}))),r},ah=({plugin:e,schema:t})=>{let n={},r=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return typeof t.const==`boolean`?(n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[I.ots.boolean(t.const)]}),n):(n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.boolean})}),n)},oh=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),a=[],o=[],s=!1,c=!0;for(let e of t.items??[])if(e.type===`string`&&typeof e.const==`string`){let t=I.stringLiteral({text:e.const});a.push(t),o.push(I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.literal}),parameters:[t]}))}else if((e.type===`number`||e.type===`integer`)&&typeof e.const==`number`){c=!1;let t=I.ots.number(e.const);o.push(I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.literal}),parameters:[t]}))}else if(e.type===`boolean`&&typeof e.const==`boolean`){c=!1;let t=I.ots.boolean(e.const);o.push(I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.literal}),parameters:[t]}))}else (e.type===`null`||e.const===null)&&(s=!0);return o.length?(c&&a.length>0?r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.enum}),parameters:[I.arrayLiteralExpression({elements:a,multiLine:!1})]}):o.length===1?r.expression=o[0]:r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.union}),parameters:[I.arrayLiteralExpression({elements:o,multiLine:o.length>3})]}),s&&(r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.nullable}),parameters:[r.expression]})),r):rh({plugin:e,schema:{type:`unknown`},state:n})},sh=({plugin:e})=>{let t={},n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return t.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.never})}),t},ch=({plugin:e})=>{let t={},n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return t.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.null})}),t},lh=({plugin:e,schema:t})=>{let n={},r=t.type===`integer`&&t.format===`int64`,i=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return typeof t.const==`number`?(n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.literal}),parameters:[I.ots.number(t.const)]}),n):(n.expression=I.callExpression({functionName:r?I.propertyAccessExpression({expression:I.propertyAccessExpression({expression:i.placeholder,name:Q.coerce}),name:Q.bigint}):I.propertyAccessExpression({expression:i.placeholder,name:Q.number})}),!r&&t.type===`integer`&&(n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.int})})),t.exclusiveMinimum===void 0?t.minimum!==void 0&&(n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.expression,name:Q.gte}),parameters:[$({isBigInt:r,value:t.minimum})]})):n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.expression,name:Q.gt}),parameters:[$({isBigInt:r,value:t.exclusiveMinimum})]}),t.exclusiveMaximum===void 0?t.maximum!==void 0&&(n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.expression,name:Q.lte}),parameters:[$({isBigInt:r,value:t.maximum})]})):n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.expression,name:Q.lt}),parameters:[$({isBigInt:r,value:t.exclusiveMaximum})]}),n)},uh=({plugin:e,schema:t,state:n})=>{let r={},i=[],a=t.required??[],o=e.referenceSymbol(e.api.selector(`external`,`zod.z`));for(let o in t.properties){let s=t.properties[o],c=gh({optional:!a.includes(o),plugin:e,schema:s,state:{...n,path:q([...n.path.value,`properties`,o])}});c.hasLazyExpression&&(r.hasLazyExpression=!0),A.lastIndex=0;let l;l=A.test(o)?o.startsWith(`-`)?m.default.factory.createStringLiteral(o):m.default.factory.createNumericLiteral(o):o,(o.match(/^[0-9]/)&&o.match(/\D+/g)||o.match(/\W/g))&&!o.startsWith(`'`)&&!o.endsWith(`'`)&&(l=`'${o}'`),c.hasLazyExpression?i.push(I.getAccessorDeclaration({name:l,statements:[I.returnStatement({expression:c.expression})]})):i.push(I.propertyAssignment({initializer:c.expression,name:l}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=gh({plugin:e,schema:t.additionalProperties,state:{...n,path:q([...n.path.value,`additionalProperties`])}});return r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:Q.record}),parameters:[I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:Q.string}),parameters:[]}),i.expression]}),i.hasLazyExpression&&(r.hasLazyExpression=!0),r.hasLazyExpression?{...r,typeName:`ZodType`}:r}return r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:Q.object}),parameters:[m.default.factory.createObjectLiteralExpression(i,!0)]}),r.hasLazyExpression?{...r,typeName:`ZodType`}:r},dh=({plugin:e,schema:t})=>{let n={},r=e.referenceSymbol(e.api.selector(`external`,`zod.z`));if(typeof t.const==`string`)return n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[I.ots.string(t.const)]}),n;n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.string})});let i=[];if(e.config.dates.offset&&i.push({key:`offset`,value:!0}),e.config.dates.local&&i.push({key:`local`,value:!0}),t.format)switch(t.format){case`date`:n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:I.propertyAccessExpression({expression:r.placeholder,name:Q.iso}),name:Q.date})});break;case`date-time`:n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:I.propertyAccessExpression({expression:r.placeholder,name:Q.iso}),name:Q.datetime}),parameters:i.length>0?[I.objectExpression({obj:i})]:[]});break;case`email`:n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.email})});break;case`ipv4`:n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.ipv4})});break;case`ipv6`:n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.ipv6})});break;case`time`:n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:I.propertyAccessExpression({expression:r.placeholder,name:Q.iso}),name:Q.time})});break;case`uri`:n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.url})});break;case`uuid`:n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.uuid})});break}return t.minLength===t.maxLength&&t.minLength!==void 0?n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.expression,name:Q.length}),parameters:[I.valueToExpression({value:t.minLength})]}):(t.minLength!==void 0&&(n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.expression,name:Q.min}),parameters:[I.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&(n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.expression,name:Q.max}),parameters:[I.valueToExpression({value:t.maxLength})]}))),t.pattern&&(n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.expression,name:Q.regex}),parameters:[I.regularExpressionLiteral({text:t.pattern})]})),n},fh=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol(e.api.selector(`external`,`zod.z`));if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.literal}),parameters:[I.valueToExpression({value:e})]}));return r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.tuple}),parameters:[I.arrayLiteralExpression({elements:e})]}),r}let a=[];return t.items&&t.items.forEach((t,i)=>{let o=gh({plugin:e,schema:t,state:{...n,path:q([...n.path.value,`items`,i])}});a.push(o.expression),o.hasLazyExpression&&(r.hasLazyExpression=!0)}),r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.tuple}),parameters:[I.arrayLiteralExpression({elements:a})]}),r},ph=({plugin:e})=>{let t={},n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return t.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.undefined})}),t},mh=({plugin:e})=>{let t={},n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return t.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.void})}),t},hh=({schema:e,...t})=>{switch(e.type){case`array`:return ih({...t,schema:e});case`boolean`:return ah({...t,schema:e});case`enum`:return oh({...t,schema:e});case`integer`:case`number`:return lh({...t,schema:e});case`never`:return sh({...t,schema:e});case`null`:return ch({...t,schema:e});case`object`:return uh({...t,schema:e});case`string`:return dh({...t,schema:e});case`tuple`:return fh({...t,schema:e});case`undefined`:return ph({...t,schema:e});case`unknown`:return rh({...t,schema:e});case`void`:return mh({...t,schema:e})}},gh=({optional:e,plugin:t,schema:n,state:r})=>{let i={},a=t.referenceSymbol(t.api.selector(`external`,`zod.z`));if(n.$ref){let e=t.api.selector(`ref`,n.$ref),o=t.referenceSymbol(e);t.isSymbolRegistered(e)?i.expression=I.identifier({text:o.placeholder}):(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.lazy}),parameters:[I.arrowFunction({returnType:I.keywordTypeNode({keyword:`any`}),statements:[I.returnStatement({expression:I.identifier({text:o.placeholder})})]})]}),i.hasLazyExpression=!0,r.hasLazyExpression.value=!0)}else if(n.type){let e=hh({plugin:t,schema:n,state:r});i.expression=e.expression,i.hasLazyExpression=e.hasLazyExpression,t.config.metadata&&n.description&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.expression,name:Q.register}),parameters:[I.propertyAccessExpression({expression:a.placeholder,name:Q.globalRegistry}),I.objectExpression({obj:[{key:`description`,value:I.stringLiteral({text:n.description})}]})]}))}else if(n.items)if(n=D({schema:n}),n.items){let e=n.items.map((e,n)=>gh({plugin:t,schema:e,state:{...r,path:q([...r.path.value,`items`,n])}}));if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.intersection}),parameters:e.map(e=>e.expression)}):(i.expression=e[0].expression,e.slice(1).forEach(e=>{i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.expression,name:Q.and}),parameters:[e.hasLazyExpression?I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.lazy}),parameters:[I.arrowFunction({statements:[I.returnStatement({expression:e.expression})]})]}):e.expression]})}))}else i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.union}),parameters:[I.arrayLiteralExpression({elements:e.map(e=>e.expression)})]})}else i=gh({plugin:t,schema:n,state:r});else i.expression=hh({plugin:t,schema:{type:`unknown`},state:r}).expression;if(i.expression&&(n.accessScope===`read`&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.expression,name:Q.readonly})})),e&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.optional}),parameters:[i.expression]}),i.typeName=Q.ZodOptional),n.default!==void 0)){let e=$({isBigInt:n.type===`integer`&&n.format===`int64`,value:n.default});e&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.expression,name:Q.default}),parameters:[e]}))}return i},_h=({plugin:e,schema:t,state:n})=>{let r=mr(n.path.value),i=gh({plugin:e,schema:t,state:n}),a=L(r);xm({ast:i,plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{path:n.path.value,tags:n.tags?.value},name:E({config:e.config.definitions,name:a}),selector:e.api.selector(`ref`,r)}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:E({config:e.config.definitions.types.infer,name:a}),selector:e.api.selector(`type-infer-ref`,r)}):void 0})},vh=({plugin:e})=>{e.registerSymbol({external:Sm({plugin:e}),name:`z`,selector:e.api.selector(`external`,`zod.z`)}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=J({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:Cm({getAst:(n,r)=>gh({plugin:e,schema:n,state:J({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:_h({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:_h({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:_h({plugin:e,schema:t.schema,state:n});break;case`webhook`:wm({getAst:(n,r)=>gh({plugin:e,schema:n,state:J({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},yh=e=>{let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return nh(e);case`mini`:return Bm(e);case 4:default:return vh(e)}},bh={api:new bm({name:`zod`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:yh,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(`🔌 ${u.default.yellow(`Warning:`)} Installed ${u.default.cyan(`zod`)} ${u.default.cyan(`v${n.version}`)} does not support compatibility version ${u.default.yellow(String(e))}, using ${u.default.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:w,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:{...w,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:w,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:{...w,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:w,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:{...w,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:w,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:{...w,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:w,value:e.infer})})},value:e.types})})},value:e.config.webhooks})},tags:[`validator`]},xh=C(bh),Sh={"@angular/common":ml,"@hey-api/client-angular":jl,"@hey-api/client-axios":Pl,"@hey-api/client-fetch":Ll,"@hey-api/client-next":Bl,"@hey-api/client-nuxt":Ul,"@hey-api/client-ofetch":Kl,"@hey-api/schemas":yu,"@hey-api/sdk":Uu,"@hey-api/transformers":yd,"@hey-api/typescript":Zd,"@pinia/colada":_f,"@tanstack/angular-query-experimental":ap,"@tanstack/react-query":cp,"@tanstack/solid-query":dp,"@tanstack/svelte-query":mp,"@tanstack/vue-query":_p,arktype:Mp,fastify:Lp,"legacy/angular":Jl,"legacy/axios":Xl,"legacy/fetch":Ql,"legacy/node":eu,"legacy/xhr":nu,valibot:fm,zod:bh},Ch=[`@hey-api/typescript`,`@hey-api/sdk`],wh=({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=Sh[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:ft(e),pluginByTag:(e,r={})=>{let{defaultPlugin:i,errorMessage:a}=r;for(let r of t){let t=Sh[r]||n[r];if(t&&t.tags?.includes(e)&&r!==s)return r}if(i){let t=Sh[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:Ue};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}},Th=e=>typeof e==`string`?e.startsWith(`@hey-api/client`)||e.startsWith(`legacy/`):e.name.startsWith(`@hey-api/client`)||e.name.startsWith(`legacy/`)||e.tags&&e.tags.includes(`client`),Eh=({dependencies:e,userConfig:t})=>{let n={},r=Ch;return t.plugins&&(t.plugins=t.plugins.filter(e=>typeof e==`string`&&e||typeof e!=`string`&&e.name),r=t.plugins.length===1&&Th(t.plugins[0])?[...Ch,...t.plugins]:t.plugins),wh({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})},Dh=()=>!!(process.stdin.isTTY&&process.stdout.isTTY&&!process.env.CI&&!process.env.NO_INTERACTIVE&&!process.env.NO_INTERACTION),Oh=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 a=e.timeEvent(`c12`),{loadConfig:o}=await import(`c12`),{config:s,configFile:c}=await o({configFile:t,name:`openapi-ts`});a.timeEnd(),Object.keys(r).length||(r=Ge(Object.keys(s).length?c:void 0));let l=s instanceof Array?s.map(e=>Be(e,i)):[Be(s,i)];for(let e of l){let t=Le(e);if(e.output instanceof Array){let r=t.length,i=e.output.length;if(i>1)if(r!==i){console.warn(`⚙️ ${u.default.yellow(`Warning:`)} You provided ${u.default.cyan(String(r))} ${u.default.cyan(r===1?`input`:`inputs`)} and ${u.default.yellow(String(i))} ${u.default.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 a=[],o=e.timeEvent(`build`);for(let e of n){let{base:t,configFile:n=``,dryRun:i=!1,experimentalParser:o=!0,exportCore:s=!0,name:c,request:l,useOptions:d=!0}=e,p=e.interactive===void 0?Dh():e.interactive,m=Re(e),h=Le(e),g=We(e),_=qe(e),v=[];h.length||v.push(new se(`missing input - which OpenAPI specification should we use to generate your output?`)),g.path||v.push(new se(`missing output - where should we generate your output?`)),!d&&m.level!==`silent`&&console.warn(`❗️ Deprecation warning: useOptions set to false. This setting will be removed in future versions. Please migrate useOptions to true https://heyapi.dev/openapi-ts/migrating.html#v0-27-38`),g.path=f.default.resolve(process.cwd(),g.path);let y;try{y=Eh({dependencies:r,userConfig:e})}catch(e){v.push(e),y={pluginOrder:[],plugins:{}}}let ee=_e({...y,base:t,configFile:n,dryRun:i,experimentalParser:o,exportCore:!1,input:h,interactive:p,logs:m,name:c,output:g,parser:_,request:l,useOptions:d});ee.exportCore=S(ee)?s:!1;let te=a.length;if(m.level===`debug`){let e=u.default.gray(`[Job ${te+1}] `);console.warn(`${e}${u.default.cyan(`config:`)}`,ee)}a.push({config:ee,errors:v,jobIndex:te})}return o.timeEnd(),{dependencies:r,results:a}},kh=Object.entries({$body_:`body`,$headers_:`headers`,$path_:`path`,$query_:`query`}),Ah=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},jh=e=>{switch(e){case`form`:return`,`;case`pipeDelimited`:return`|`;case`spaceDelimited`:return`%20`;default:return`,`}},Mh=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},Nh=({allowReserved:e,explode:t,name:n,style:r,value:i})=>{if(!t){let t=(e?i:i.map(e=>encodeURIComponent(e))).join(jh(r));switch(r){case`label`:return`.${t}`;case`matrix`:return`;${n}=${t}`;case`simple`:return t;default:return`${n}=${t}`}}let a=Ah(r),o=i.map(t=>r===`label`||r===`simple`?e?t:encodeURIComponent(t):Ph({allowReserved:e,name:n,value:t})).join(a);return r===`label`||r===`matrix`?a+o:o},Ph=({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)}`},Fh=({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=Mh(r),s=Object.entries(i).map(([t,i])=>Ph({allowReserved:e,name:r===`deepObject`?`${n}[${t}]`:t,value:i})).join(o);return r===`label`||r===`matrix`?o+s:s},Ih=({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=Nh({allowReserved:o.allowReserved,explode:!0,name:i,style:`form`,value:a,...o.array});e&&r.push(e)}else if(typeof a==`object`){let e=Fh({allowReserved:o.allowReserved,explode:!0,name:i,style:`deepObject`,value:a,...o.object});e&&r.push(e)}else{let e=Ph({allowReserved:o.allowReserved,name:i,value:a});e&&r.push(e)}}return r.join(`&`)},Lh=e=>{let t=[];return e.forEach((e,n)=>{t.push([n,e])}),t},Rh=(...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let e=n instanceof Headers?Lh(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},zh=Ih({allowReserved:!1,array:{explode:!0,style:`form`},object:{explode:!0,style:`deepObject`}}),Bh=async({fetchOptions:e,inputPath:t,timeout:n,watch:r})=>{let i=(0,_.getResolvedInput)({pathOrUrlOrSchema:t}),a,o,s;if(i.type===`url`){if(r.lastValue&&r.isHeadMethodSupported!==!1){try{let t=await(0,_.sendRequest)({fetchOptions:{method:`HEAD`,...e,headers:Rh(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(0,_.sendRequest)({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}};Object.defineProperty(exports,`A`,{enumerable:!0,get:function(){return de}}),Object.defineProperty(exports,`C`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`D`,{enumerable:!0,get:function(){return se}}),Object.defineProperty(exports,`E`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`F`,{enumerable:!0,get:function(){return ae}}),Object.defineProperty(exports,`I`,{enumerable:!0,get:function(){return te}}),Object.defineProperty(exports,`L`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`M`,{enumerable:!0,get:function(){return pe}}),Object.defineProperty(exports,`N`,{enumerable:!0,get:function(){return me}}),Object.defineProperty(exports,`O`,{enumerable:!0,get:function(){return ce}}),Object.defineProperty(exports,`P`,{enumerable:!0,get:function(){return ie}}),Object.defineProperty(exports,`R`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`S`,{enumerable:!0,get:function(){return Re}}),Object.defineProperty(exports,`T`,{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return Xn}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return kl}}),Object.defineProperty(exports,`b`,{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return _l}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return Ss}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return ws}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return xr}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return hi}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return mu}}),Object.defineProperty(exports,`j`,{enumerable:!0,get:function(){return fe}}),Object.defineProperty(exports,`k`,{enumerable:!0,get:function(){return le}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return Ic}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return as}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return Oh}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return Tl}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return ds}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return Ch}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return gl}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return Bh}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return Lc}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,`w`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`x`,{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return T}});
24
+ //# sourceMappingURL=getSpec-6kHHn13e.cjs.map