import{s as e,t}from"./rolldown-runtime-Bjp52BOI.js?dpl=dpl_4UDxC3erAcBDHX8QT9FjyxxnLZSQ";import{C as n,a as r,i,o as a,r as o}from"./utils-DRi8JwoB.js?dpl=dpl_4UDxC3erAcBDHX8QT9FjyxxnLZSQ";import{t as s}from"./toString-BX-iyh8G.js?dpl=dpl_4UDxC3erAcBDHX8QT9FjyxxnLZSQ";import{Na as c}from"./index-DiVFqI9q.js?dpl=dpl_4UDxC3erAcBDHX8QT9FjyxxnLZSQ";var l=`$circularRef`,u={server:{},path:{},query:{},querystring:{},header:{},cookie:{},body:void 0},d={server:`server`,path:`path`,query:`query`,querystring:`querystring`,header:`header`,cookie:`cookie`,body:`body`},ee=` | null`,te=t(((e,t)=>{var n=s(),r=/[\\^$.*+?()[\]{}|]/g,i=RegExp(r.source);function a(e){return e=n(e),e&&i.test(e)?e.replace(r,`\\$&`):e}t.exports=a})),ne=new Set([`application/jsonl`,`application/x-ndjson`,`application/json-seq`]),f=e=>{if(!e)return!1;let t=i(e);return t===`text/event-stream`||t===`multipart/mixed`||ne.has(t)},p=(e,t)=>f(e)&&t!==void 0&&`itemSchema`in t&&t.itemSchema!==void 0,m=e=>{if(e!==void 0)return`itemSchema`in e&&e.itemSchema!==void 0?e.itemSchema:`schema`in e?e.schema:void 0},h=``,g=`boundary`,_=e=>{let t=/;\s*boundary=(?:"([^"]+)"|([^;\s]+))/i.exec(e);return t?.[1]??t?.[2]},v=e=>{for(let t of e.split(/\r?\n/)){let e=/^--(.+?)(?:--)?\s*$/.exec(t);if(e?.[1]!==void 0)return e[1]}},y=(e,t)=>_(e)??(t===void 0?void 0:v(t))??g,b=e=>/^[A-Za-z0-9!#$%&'*+\-.^_`|~]+$/.test(e)?e:`"${e}"`,x=(e,t)=>i(e).startsWith(`multipart/`)&&_(e)===void 0?`${e.trim().replace(/;\s*$/,``)}; boundary=${b(y(e,t))}`:e,re=(e,t)=>{if(!i(e).startsWith(`multipart/`))return e;let n=v(t);return n===void 0?x(e,t):`${e.replace(/;\s*boundary=(?:"[^"]*"|[^;]*)/i,``).trim().replace(/;\s*$/,``)}; boundary=${b(n)}`},ie=(e,t)=>i(e)===`multipart/mixed`?x(e,t):e,ae=e=>/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+\/[!#$%&'*+\-.^_`|~0-9A-Za-z]+(?:[ \t]*;\P{Cc}*)?$/u.test(e),oe=e=>{if(e!==void 0&&`itemEncoding`in e){let{itemEncoding:t}=e,n=typeof t==`object`&&t&&`contentType`in t&&typeof t.contentType==`string`?o(t.contentType):void 0;if(n&&ae(n))return n}return`application/json`},S=(e,t)=>{let n=e;for(let r=1;t.includes(`--${n}`);r+=1)n=`${e}-${r}`;return n},C=(e,t,n)=>{let a=JSON.stringify(e);switch(i(t)){case`text/event-stream`:return`data: ${a}\n\n`;case`application/json-seq`:return`${h}${a}\n`;case`multipart/mixed`:{let i=oe(n),o=`Content-Type: ${i}\r\n\r\n${typeof e==`string`&&!r(i)?e:a}`,s=S(y(t),o);return`--${s}\r\n${o}\r\n--${s}--\r\n`}default:return`${a}\n`}},w=e=>{try{return JSON.parse(e)}catch{return}},se=e=>{let t=e.split(/\r?\n/).filter(e=>e.startsWith(`data:`));if(t.length!==0)return t.map(e=>e.slice(5).replace(/^ /,``)).join(` `)},ce=(e,t)=>{switch(i(t)){case`text/event-stream`:for(let t of e.split(/\r?\n\r?\n/)){let e=se(t);if(e===void 0)continue;let n=w(e);return n===void 0?e:n}return;case`application/json-seq`:{let t=e.split(h).find(e=>e.trim()!==``);return t===void 0?void 0:w(t.trim())}case`multipart/mixed`:{let n=v(e)??_(t)??g,i=RegExp(`(?:^|\\r?\\n)--${n.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}(?:--)?[ \\t]*(?:\\r?\\n|$)`),[,o]=e.split(i);if(o===void 0)return;let s=/\r?\n\r?\n/.exec(o),c=s===null?o:o.slice(0,s.index),l=s===null?``:o.slice(s.index+s[0].length),u=/^content-type:\s*(.+?)\s*$/im.exec(c)?.[1]??`application/json`;return r(u)?w(l):a(u)?l:void 0}default:{let t=e.split(/\r?\n/).find(e=>e.trim()!==``);return t===void 0?void 0:w(t)}}},le=e(te(),1),T=`application/x-www-form-urlencoded`,E=e=>{let t=new Map;for(let[n,r]of e){let e=t.get(n);t.set(n,e===void 0?r:[e,r].flat())}return Object.fromEntries(t)},ue=e=>E(new URLSearchParams(e)),D=`multipart/form-data`,de=(e,t)=>_(t)??v(e),fe=e=>{let t=/content-disposition:\s*form-data;([^\r\n]*)/i.exec(e),n=/(?:^|;)\s*name=(?:"([^"]*)"|([^;\s]+))/i.exec(t?.[1]??``);return n?.[1]??n?.[2]},pe=(e,t)=>{let n=RegExp(`(?:^|\\r?\\n)--${(0,le.default)(t)}(--)?[ \\t]*(?:\\r?\\n|$)`,`g`),r=[],i=e=>{let t=/\r?\n\r?\n/.exec(e);r.push(t?{headers:e.slice(0,t.index),value:e.slice(t.index+t[0].length)}:{headers:e.replace(/\r?\n$/,``),value:``})},a;for(let t of e.matchAll(n)){if(a!==void 0&&i(e.slice(a,t.index)),t[1]===`--`){a=void 0;break}a=t.index+t[0].length}return a!==void 0&&i(e.slice(a).replace(/\r?\n$/,``)),r},me=(e,t)=>{let n=de(e,t);if(n===void 0)return;let r=pe(e,n);if(r.some(e=>/content-disposition:[^\r\n]*;\s*filename\*?=/i.test(e.headers)))return;let i=E(r.flatMap(({headers:e,value:t})=>{let n=fe(e);return n===void 0?[]:[[n,t]]}));return Object.keys(i).length>0?i:void 0},he=(e,t,n)=>{if(n)return ce(e,t);if(r(t))try{return JSON.parse(e)}catch{return}let o=i(t);return o===T?ue(e):o===D?me(e,t):a(t)?e:void 0},ge=(e,t,n)=>{if(e.dataValue!==void 0)return e.dataValue;if(e.value!==void 0)return e.value;if(e.serializedValue!==void 0)return he(e.serializedValue,t,n)},_e=(e,t,n,r)=>{let i=p(n,r),a=ge(t,n,i);return Object.assign(Object.assign({title:e,description:t.description,value:a},t.serializedValue===void 0?i&&a!==void 0&&t.externalValue===void 0&&{serializedValue:C(a,n,r)}:{serializedValue:t.serializedValue}),t.externalValue!==void 0&&{externalValue:t.externalValue})},ve=(e,t,n)=>{if(e.value!==void 0)return e.value;if(e.serializedValue!==void 0&&!p(t,n)&&i(t)!==T&&i(t)!==D)return e.serializedValue},O=(e,t,n)=>{let r=ve(e,t,n),i=typeof e.serializedValue==`string`?e.serializedValue:void 0;return r===void 0?i!==void 0&&p(t,n)?{value:void 0,serializedValue:i}:void 0:i===void 0?{value:r}:{value:r,serializedValue:i}},ye=e=>{let t=i(e);return r(t)||t===`application/jsonl`||t===`application/json-seq`?`json`:t.endsWith(`xml`)?`xml`:t===`text/html`?`html`:t===`text/csv`?`csv`:t.endsWith(`yaml`)||t.endsWith(`yml`)?`yaml`:`text`},k=(e,t,n)=>{if(!L(e))return e;let r=Object.assign({},e);if(r.uniqueKey&&r.uniqueKey.startsWith(t)&&(r.uniqueKey=r.uniqueKey.replace(t,n)),r.oneOf&&Array.isArray(r.oneOf)&&(r.oneOf=r.oneOf.map(e=>L(e)?k(e,t,n):e)),r.properties&&typeof r.properties==`object`){let e={};Object.entries(r.properties).forEach(([r,i])=>{L(i)?e[r]=k(i,t,n):e[r]=i}),r.properties=e}return r.additionalProperties&&typeof r.additionalProperties==`object`&&L(r.additionalProperties)&&(r.additionalProperties=k(r.additionalProperties,t,n)),r.type===`array`&&`items`in r&&L(r.items)&&(r.items=k(r.items,t,n)),r},A=({schema:e,example:t})=>M(e,t,d.body);function j(e,t){let n=e;return t.forEach(e=>{n=n.replace(`[INDEX]`,e.toString())}),n}function M(e,t,n,r=[]){let i={};if(t==null)return i;if(e.oneOf&&Array.isArray(e.oneOf)){let a=null;for(let n of e.oneOf)if(L(n)&&N(n,t)){let e=n,r=be(e,t);(a===null||r>a.matchCount)&&(a={variant:e,matchCount:r})}let o=a?.variant??(e.oneOf.length>0&&L(e.oneOf[0])?e.oneOf[0]:null);if(o){if(o.type!==`object`&&o.type!==`array`){if(o.uniqueKey){let e=j(o.uniqueKey,r);i[`${n}.${e}`]=t}return i}return M(o,t,n,r)}}if(e.type===`object`&&e.properties&&typeof t==`object`&&!Array.isArray(t))for(let[a,o]of Object.entries(e.properties)){if(!L(o))continue;let e=t[a];if(e===void 0)continue;let s=o;if(s.type===`object`||s.type===`array`||s.oneOf){let t=M(s,e,n,r);Object.assign(i,t)}else if(s.uniqueKey){let t=j(s.uniqueKey,r);i[`${n}.${t}`]=e}}if(e.type===`object`&&L(e.additionalProperties)&&typeof t==`object`&&!Array.isArray(t)){let a=e.additionalProperties,o=a.uniqueKey??``,s=e.uniqueKey??``;for(let[c,l]of Object.entries(t)){if(!o)break;if(c===`__proto__`||c===`constructor`||c===`prototype`||e.properties&&Object.prototype.hasOwnProperty.call(e.properties,c)||l===void 0)continue;let t=s?`${s}.${U(c)}`:U(c),u=M(k(a,o,t),l,n,r);Object.keys(u).length===0?i[`${n}.${j(t,r)}`]=l:Object.assign(i,u)}}if(e.type===`array`&&Array.isArray(t)&&`items`in e&&L(e.items)){let a=e.items;t.forEach((e,t)=>{let o=[...r,t],s=M(a,e,n,o);Object.keys(s).length===0&&a.uniqueKey?i[`${n}.${j(a.uniqueKey,o)}`]=e:Object.assign(i,s)})}let a=e.type===`object`&&(Object.keys(e.properties??{}).length>0||L(e.additionalProperties)),o=e.type===`array`&&`items`in e&&L(e.items);if(!a&&!o&&!e.oneOf&&e.uniqueKey){let a=j(e.uniqueKey,r);i[`${n}.${a}`]=t}return i}function be(e,t){if(e.type===`object`&&typeof t==`object`&&t&&!Array.isArray(t)&&e.properties&&typeof e.properties==`object`){let n=Object.keys(t),r=Object.keys(e.properties);return n.filter(e=>r.includes(e)).length}return 1}function N(e,t){let n=typeof t;if(e.oneOf&&Array.isArray(e.oneOf))return e.oneOf.some(e=>L(e)?N(e,t):!1);if(e.enum&&Array.isArray(e.enum))return e.enum.includes(t);if(e.type===`string`&&n===`string`&&e.pattern&&typeof t==`string`)try{return new RegExp(e.pattern).test(t)}catch{return!1}if(e.type===`object`&&n===`object`&&t!==null&&!Array.isArray(t)){if(e.properties&&typeof e.properties==`object`){let n=t,r=Object.keys(n),i=Object.keys(e.properties);if(e.required&&Array.isArray(e.required)&&e.required.some(e=>typeof e==`string`&&!r.includes(e)))return!1;for(let t of r)if(i.includes(t)){let r=e.properties[t],i=n[t];if(L(r)&&!P(r,i))return!1}if(r.length>0&&i.length>0)return r.some(e=>i.includes(e));if(r.length===0)return!(e.required&&Array.isArray(e.required)&&e.required.length>0)}return!0}return!!(e.type===`string`&&n===`string`||e.type===`number`&&n===`number`||e.type===`integer`&&n===`number`&&Number.isInteger(t)||e.type===`boolean`&&n===`boolean`||e.type===`array`&&Array.isArray(t))}function P(e,t){if(e.enum&&Array.isArray(e.enum))return e.enum.includes(t);if(e.oneOf&&Array.isArray(e.oneOf))return e.oneOf.some(e=>L(e)?N(e,t):!1);let n=typeof t;if(e.type===`string`&&n!==`string`||e.type===`number`&&n!==`number`||e.type===`integer`&&(n!==`number`||!Number.isInteger(t))||e.type===`boolean`&&n!==`boolean`||e.type===`array`&&!Array.isArray(t)||e.type===`object`&&(n!==`object`||t===null||Array.isArray(t)))return!1;if(e.type===`array`&&Array.isArray(t)&&L(e.items)){for(let n of t)if(!N(e.items,n))return!1}if(e.type===`object`&&typeof t==`object`&&t&&!Array.isArray(t)&&e.properties){let n=t;for(let[t,r]of Object.entries(e.properties))if(t in n&&L(r)&&!P(r,n[t]))return!1}return!0}var xe=e=>`_tupleOriginal`in e&&e._tupleOriginal===!0,F=e=>{let t=e.match(/^\[(\d+)\]$/);return t&&t[1]!==void 0?parseInt(t[1],10):null},Se=e=>{let t=[];for(let[n,r]of Object.entries(e)){let e=F(n);e!==null&&t.push({index:e,value:r})}return t.sort((e,t)=>e.index-t.index),t.map(e=>e.value)};function Ce(e){return typeof e==`object`&&!!e&&`$circularRef`in e&&typeof e.$circularRef==`string`}var we=e=>L(e)&&(`isCircular`in e||`isRequired`in e),I=e=>typeof e==`object`&&!!e&&!Array.isArray(e),L=e=>I(e)?`type`in e||`properties`in e||`oneOf`in e||`anyOf`in e||`allOf`in e||`items`in e||`additionalProperties`in e||`enum`in e||`const`in e||`format`in e||`pattern`in e||`minimum`in e||`maximum`in e||`minLength`in e||`maxLength`in e||`minItems`in e||`maxItems`in e||`minProperties`in e||`maxProperties`in e||`required`in e||`nullable`in e||`description`in e:!1,Te=e=>L(e)?!!e.properties&&Object.keys(e.properties).length>0||!!e.additionalProperties&&Object.keys(e.additionalProperties).length>0:!1,R=e=>L(e)&&e.type===`array`,Ee=e=>R(e)&&L(e.items)&&e.items.type===`object`,De=e=>{if(e.oneOf)return`oneOf`;if(e.enum)switch(e.type){case`string`:return`enum`;case`number`:return`enum`;case`integer`:return`enum`;case`boolean`:return`enum`;default:return e.type}return n(e)===void 0?e.type:`file`},Oe=e=>`enum`in e&&e.enum!==void 0,ke=e=>{if(e.enum&&e.enum.length>0){let t=e.enum.map(e=>typeof e==`boolean`?e:e===`true`||e!==`false`&&null).filter(e=>e!==null);if(t.length>0)return t}return[!0,!1]},z=e=>`placeholder`in e&&typeof e.placeholder==`string`?e.placeholder:void 0,Ae=e=>e.type===`string`,je=e=>e.type===`number`||e.type===`integer`,Me=e=>{let t={};return Object.entries(e.operation?.responses??{}).forEach(([n,r])=>{let i=e.dependencies?.responses?.[r];i&&i.content&&(t[n]=i.content)}),t},B=(e,t)=>{let n=e.dependencies?.requestBody?.content;if(n===void 0)return[];let r=H(e,t);if(!r)return[];let i=n[r],a=m(i);if(!L(a))return[];let o=Object.entries(i?.examples??{});if(o.length===0)return[];let s=[];for(let[e,t]of o)`$ref`in t||O(t,r,i)!==void 0&&s.push({name:e,inputs:t.value===void 0?{}:A({schema:a,example:t.value})});return s},Ne=(e,t=0)=>B(e,t).map(({inputs:e})=>e),Pe=(e,t)=>B(e,t).map(({name:e})=>e),Fe=e=>{let t=e.dependencies?.parameters;if(t){let e=Object.values(t),n=e.filter(e=>!(`in`in e)||e.in===`header`),r=e.filter(e=>e.in===`cookie`);return{header:n,path:e.filter(e=>e.in===`path`),query:e.filter(e=>e.in===`query`),querystring:e.filter(e=>e.in===`querystring`),cookie:r}}return{header:[],path:[],query:[],querystring:[],cookie:[]}},V=e=>{let t;if(e)return typeof e==`object`&&`default`in e&&(t=e.default),typeof e==`object`&&`x-default`in e&&(t=e[`x-default`]),t},Ie=()=>({oneOf:[{type:`string`},{type:`number`},{type:`boolean`},{type:`object`,properties:{}},{type:`array`,items:{oneOf:[{type:`string`},{type:`number`},{type:`boolean`},{type:`object`,properties:{}},{type:`array`,items:{}},{type:`null`}]}},{type:`null`}]}),H=(e,t)=>{let n=e.dependencies?.requestBody?.content;if(n!==void 0)return Object.keys(n)[t]},Le=new Set([`oneOf`,`items`,`additionalProperties`]),U=e=>{let t=e.replace(/\./g,`\\.`);return Le.has(e)||t.startsWith(`\\`)?`\\${t}`:t},W=e=>e.startsWith(`\\`)?e.slice(1):e,G=e=>{switch(e){case`header`:return d.header;case`path`:return d.path;case`query`:return d.query;case`querystring`:return d.querystring;case`cookie`:return d.cookie;default:return d.header}},K=e=>e.split(/(?e.replace(/\\\./g,`.`)),Re=e=>{let t={server:{},header:{},path:{},query:{},querystring:{},cookie:{},body:void 0};return Object.entries(e).forEach(([e,n])=>{if(n===void 0)return;let r=K(e);if(r.length<2){e===`body`&&(t.body=n);return}let[i,...a]=r,o=Object.values(d);if(i&&o.includes(i)){if(i!==d.body){if(n===null)return;X(t[i],[...a],n)}else[...a].length===0?t.body=n:((t.body===void 0||typeof t.body!=`object`)&&(t.body={}),X(t.body,a,n))}}),q(t)},ze=e=>{if(!I(e))return!1;let t=Object.keys(e);return t.length!==0&&t.every(e=>/^\d+$/.test(e))},Be=e=>{if(!I(e))return!1;let t=Object.keys(e);return t.length!==0&&t.every(e=>F(e)!==null)},q=e=>{if(e==null||c(e)||typeof window<`u`&&e instanceof FileList)return e;if(Array.isArray(e))return e.map(q);if(I(e)){if(Be(e)){let t=[];for(let[n,r]of Object.entries(e)){let e=F(n);e!==null&&t.push({index:e,value:q(r)})}return t.sort((e,t)=>e.index-t.index),t.map(e=>e.value)}if(ze(e))return Object.keys(e).sort((e,t)=>Number(e)-Number(t)).map(t=>e[t]).map(q);let t={};for(let[n,r]of Object.entries(e))t[n]=q(r);return t}return e},J=new Set([`__proto__`,`constructor`,`prototype`]),Y=e=>{let t=[];for(let n=0;n{let r=Y(t);if(r===void 0)return;let i=e;for(let e=0;ee.filter(e=>`enum`in e&&e.enum&&`const`in e?e.enum.includes(e.const):!0),Z=(e,t=0)=>{let n={};if(`uniqueKey`in e&&e.uniqueKey!==void 0){let t=V(e);if(t!==void 0){let r=`${d.body}.${e.uniqueKey}`;r=r.replaceAll(`[INDEX]`,`0`),n[r]=t}}if(`oneOf`in e&&Array.isArray(e.oneOf)&&e.oneOf.length>0){let r=t{if(L(e)){let t=Z(e,0);Object.assign(n,t)}}),e.additionalProperties&&typeof e.additionalProperties==`object`&&L(e.additionalProperties)){let t=Z(e.additionalProperties,0);Object.assign(n,t)}return n},He=e=>{let t=`schemes`in e?e.schemes[0]?.scheme:e.scheme;if(!t)return`header.Authorization`;let n=`in`in t?t.in:`header`,r=`name`in t?t.name:Q(t);return`${G(n)}.${U(r)}`},Ue=e=>e&&`type`in e&&e.type===`http`&&e.scheme===`basic`,Q=e=>e&&`type`in e&&e.type===`apiKey`?e.name:`Authorization`,We=(e,t)=>{let n=new TextEncoder().encode(`${e??``}:${t??``}`),r=``;for(let e of n)r+=String.fromCharCode(e);return btoa(r)},$=e=>{let t=e.typeLabel,n=`type`in e&&typeof e.type==`string`?e.type:void 0;return t??n??`unknown`},Ge=e=>{if(e.length<=1)return e.map(e=>$(e));let t=e.every(e=>e.type===`object`),n=e.map(e=>$(e));return t?e.map((e,t)=>e.title??`Option ${t+1}`):new Set(n).size===n.length?n:n.map((t,n)=>{let r=e[n]?.title??`Option ${n+1}`;return t.startsWith(`${r} · `)?t:`${r} · ${t}`})},Ke=e=>n(e)!==void 0;export{l as $,Ae as A,O as B,Oe as C,I as D,Ee as E,Re as F,_ as G,_e as H,Se as I,f as J,m as K,xe as L,Me as M,K as N,we as O,Y as P,C as Q,A as R,Ce as S,je as T,S as U,ye as V,b as W,y as X,re as Y,ie as Z,He as _,Ve as a,R as b,Z as c,Fe as d,d as et,Pe as f,z as g,V as h,U as i,G as j,L as k,ke as l,H as m,W as n,ee as nt,Ge as o,Ne as p,p as q,We as r,$ as s,Ie as t,u as tt,De as u,Q as v,Ke as w,Ue as x,Te as y,k as z};