@veluai/velu 0.1.15 → 0.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,13 +1,34 @@
1
1
  #!/usr/bin/env node
2
- var vt=Object.defineProperty;var k=(e,t)=>()=>(e&&(t=e(e=0)),t);var de=(e,t)=>{for(var o in t)vt(e,o,{get:t[o],enumerable:!0})};var Ne={};de(Ne,{initProject:()=>wt});import z from"node:fs/promises";import G from"node:path";import{fileURLToPath as yt}from"node:url";async function wt(e,t){try{if((await z.readdir(e)).length>0)throw new Error(`Directory "${t}" already exists and is not empty. Choose a different name or remove the folder first.`)}catch(i){if(i.code!=="ENOENT")throw i}await z.mkdir(e,{recursive:!0}),await z.cp(bt,e,{recursive:!0});let o=G.join(e,"velu.json"),n=JSON.parse(await z.readFile(o,"utf-8"));n.name=t,await z.writeFile(o,JSON.stringify(n,null,2)+`
3
- `,"utf-8");let r=await Ee(e);console.log(`[velu] created ${t}/`);for(let i of r)console.log(` ${i}`);console.log(""),console.log("Next steps:"),console.log(` cd ${t}`),console.log(" velu dev")}async function Ee(e,t=e,o=[]){let n=await z.readdir(e,{withFileTypes:!0});for(let r of n){let i=G.join(e,r.name);r.isDirectory()?await Ee(i,t,o):o.push(G.relative(t,i).split(G.sep).join("/"))}return o.sort()}var xt,bt,Fe=k(()=>{xt=G.dirname(yt(import.meta.url)),bt=G.resolve(xt,"..","templates","starter")});import{visit as kt}from"unist-util-visit";import{toString as St}from"mdast-util-to-string";import $t from"github-slugger";import{valueToEstree as jt}from"estree-util-value-to-estree";function D(){return e=>{let t=new $t,o=[];kt(e,"heading",a=>{let s=St(a);o.push({depth:a.depth,id:t.slug(s),label:s})});let n={children:[]},r=[{node:n,depth:0}];for(let a of o){for(;r.length>1&&r[r.length-1].depth>=a.depth;)r.pop();let s={id:a.id,label:a.label},l=r[r.length-1].node;l.children||(l.children=[]),l.children.push(s),r.push({node:s,depth:a.depth})}let i=n.children;e.children.unshift({type:"mdxjsEsm",value:"",data:{estree:{type:"Program",sourceType:"module",body:[{type:"ExportNamedDeclaration",specifiers:[],declaration:{type:"VariableDeclaration",kind:"const",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:"toc"},init:jt(i)}]}}]}}})}}var ge=k(()=>{});import At from"node:fs/promises";import Ie from"node:path";function Y(e){if(typeof e=="string"){let t=e.trim();return t?{light:t,dark:t,href:"/"}:null}if(e&&typeof e=="object"){let t=(e.light??e.dark)?.trim?.(),o=(e.dark??e.light)?.trim?.();return!t||!o?null:{light:t,dark:o,href:e.href?.trim?.()||"/"}}return null}function ve(e){if(!e||typeof e!="object")return null;let t=[];if(e.socials&&typeof e.socials=="object")for(let[n,r]of Object.entries(e.socials))typeof r!="string"||!r.trim()||t.push({kind:_t[n]??n,href:r.trim()});let o=Array.isArray(e.links)?e.links.filter(n=>n&&typeof n=="object").map(n=>({title:(n.header??n.title??"").trim(),items:(Array.isArray(n.items)?n.items:[]).filter(r=>r&&r.label).map(r=>({label:r.label,href:r.href??"#"}))})).filter(n=>n.title||n.items.length):[];return!t.length&&!o.length?null:{socials:t,links:o}}function he(e){return/^(https?:)?\/\//.test(e)||/^(mailto|tel):/.test(e)}function ye(e){if(!e||typeof e!="object")return null;let t=(Array.isArray(e.links)?e.links:[]).filter(r=>r&&typeof r.href=="string"&&r.href.trim()).map(r=>({label:r.label??"",href:r.href.trim(),icon:r.icon??null,external:he(r.href.trim())})),o=null,n=e.primary;if(n&&typeof n=="object"&&typeof n.href=="string"&&n.href.trim()){let r=n.href.trim();o=n.type==="github"?{kind:"github",label:n.label??"GitHub",href:r,external:he(r)}:{kind:"button",label:n.label??"",href:r,external:he(r)}}return!t.length&&!o?null:{links:t,primary:o}}function xe(e={},t){let o=e.colors?.primary??Lt;return{name:e.name??t??"docs",colors:{primary:o,light:e.colors?.light??o,dark:e.colors?.dark??o},favicon:e.favicon??null,logo:Y(e.logo),footer:ve(e.footer),navbar:ye(e.navbar),font:{family:e.font?.family??Ot},navigation:e.navigation??null}}async function Re(e){let t=Ie.join(e,"velu.json"),o;try{o=await At.readFile(t,"utf-8")}catch(r){throw r.code==="ENOENT"?new Error(`No velu.json found in ${e}. Run \`velu init <name>\` to scaffold one.`):r}let n;try{n=JSON.parse(o)}catch(r){throw new Error(`velu.json is not valid JSON: ${r.message}`)}return xe(n,Ie.basename(e))}function Me(e){let{colors:t,font:o}=e;return[":root:root {",` --accent-color: ${t.light};`,` --font-sans: "${o.family}", sans-serif;`,"}",':root:root[data-theme="dark"] {',` --accent-color: ${t.dark};`,"}"].join(`
4
- `)}var Lt,Ot,ne,oe,_t,re=k(()=>{Lt="#dc143c",Ot="Google Sans Flex",ne="/@velu-logo-light",oe="/@velu-logo-dark";_t={twitter:"x","x-twitter":"x"}});import Pt from"github-slugger";import Ct from"iso-639-1";function Et(e){let t=String(e).toLowerCase();return Ct.getNativeName(t)||e}function ie(e){return new Pt().slug(String(e??""))}function Nt(e){let t=String(e).replace(/^\/+|\/+$/g,"").split("/").filter(Boolean);return t[t.length-1]==="index"&&t.pop(),"/"+t.join("/")}function V(e){let t={kind:"root",children:K(e??{})};return Ge(t.children),t}function K(e){let t=Array.isArray(e.anchors)?e.anchors.map(Ut):[];if(Array.isArray(e.products))return[...t,...e.products.map(Ft)];if(Array.isArray(e.versions))return[...t,...e.versions.map(It)];if(Array.isArray(e.languages))return[...t,...e.languages.map(Rt)];if(Array.isArray(e.tabs))return[...t,...e.tabs.map(Mt)];let o=[...t];return Array.isArray(e.groups)&&o.push(...e.groups.map(Ue)),Array.isArray(e.pages)&&o.push(...e.pages.map(ze)),o}function Ft(e){return{kind:"product",label:e.name??e.product,slug:ie(e.product),icon:e.icon,color:e.color,default:!!e.default,children:K(e)}}function It(e){return{kind:"version",label:e.version,slug:ie(e.version),default:!!e.default,children:K(e)}}function Rt(e){let t=String(e.language);return{kind:"language",code:t,label:Et(t),slug:ie(t),default:!!e.default,children:K(e)}}function Mt(e){return{kind:"tab",label:e.tab,slug:ie(e.tab),icon:e.icon,href:e.href,children:K(e)}}function Ut(e){return{kind:"anchor",label:e.anchor,icon:e.icon,href:e.href,color:e.color}}function Ue(e){let t=(e.pages??[]).map(ze);return e.root&&t.unshift({kind:"page",pagePath:e.root}),{kind:"group",label:e.group,icon:e.icon,expanded:!!e.expanded,root:e.root,children:t}}function ze(e){return typeof e=="string"?{kind:"page",pagePath:e}:Ue(e)}function Ge(e){for(let t of Tt){let o=e.filter(n=>n.kind===t);o.length&&!o.some(n=>n.default)&&(o[0].default=!0)}for(let t of e)t.children&&Ge(t.children)}function Ve(e){let t=[],o=(n,r,i)=>{if(n.kind==="page"){t.push({pagePath:n.pagePath,url:zt(n.pagePath,r),ctx:{...r},ancestors:i,node:n});return}let a=r;n.kind==="product"?a={...r,product:n.default?null:n.slug}:n.kind==="version"?a={...r,version:n.default?null:n.slug}:n.kind==="language"&&(a={...r,language:n.default?null:n.slug});let s=n.kind==="root"?i:[...i,n];for(let l of n.children??[])o(l,a,s)};return o(e,{product:null,version:null,language:null},[]),t}function zt(e,t){let o=[t.product,t.version,t.language].filter(Boolean),n=Nt(e).split("/").filter(Boolean);return"/"+[...o,...n].join("/")}var Tt,W=k(()=>{Tt=["product","version","language"]});import Gt from"node:fs";import Be from"node:path";function B(e,t){let o=[],n=[],r=new Set;for(let i of Ve(e)){if(r.has(i.url)){o.push(`duplicate URL "${i.url}" (page "${i.pagePath}") \u2014 keeping the first occurrence`);continue}r.add(i.url);let a=i.pagePath.replace(/^\/+|\/+$/g,""),s=Be.join(t,...a.split("/"))+".mdx",l=Gt.existsSync(s);l||o.push(`page "${i.pagePath}" \u2192 ${Be.relative(t,s)} not found`),n.push({pagePath:i.pagePath,url:i.url,fileAbsPath:s,exists:l})}return{pageEntries:n,warnings:o}}var se=k(()=>{W()});import Vt from"node:fs";import Z from"node:path";function He(e){return{name:"velu-site",resolveId(t){return t===qe?Je:null},load(t){return t!==Je?null:Bt(e)}}}function Bt(e){let t={};try{t=JSON.parse(Vt.readFileSync(Z.join(e,"velu.json"),"utf-8"))}catch{}let o=V(t.navigation??{}),{pageEntries:n,warnings:r}=B(o,e);for(let c of r)console.warn(`[velu] nav: ${c}`);let i=Y(t.logo),a={name:t.name??Z.basename(e),logo:i?{light:ne,dark:oe,href:i.href,mono:i.light===i.dark}:null,footer:ve(t.footer),navbar:ye(t.navbar)},s=[],l=[],u=0;for(let c of n)if(c.exists){let f=JSON.stringify(c.fileAbsPath.split(Z.sep).join("/")),A=JSON.stringify(Z.relative(e,c.fileAbsPath).split(Z.sep).join("/")),p=`__p${u++}`;s.push(`import * as ${p} from ${f};`),l.push(` ${JSON.stringify(c.url)}: { Component: ${p}.default, frontmatter: ${p}.frontmatter, toc: ${p}.toc, relPath: ${A} },`)}else l.push(` ${JSON.stringify(c.url)}: { missing: true },`);return["// AUTO-GENERATED by vite-plugin-velu-site. Do not edit.",s.join(`
5
- `),"","export const pages = {",l.join(`
6
- `),"};",`export const navigation = ${JSON.stringify(o)};`,`export const site = ${JSON.stringify(a)};`,""].join(`
7
- `)}var qe,Je,De=k(()=>{W();se();re();qe="virtual:velu-site",Je="\0"+qe});function v(e){return{category:"render-crash",severity:"error",file:null,line:null,column:null,frame:null,title:"Something went wrong",detail:"",hint:"",suggestion:null,...e}}function Jt(e,t){if(e=String(e),t=String(t),e===t)return 0;if(!e.length)return t.length;if(!t.length)return e.length;let o=Array.from({length:t.length+1},(r,i)=>i),n=new Array(t.length+1);for(let r=1;r<=e.length;r++){n[0]=r;for(let i=1;i<=t.length;i++){let a=e[r-1]===t[i-1]?0:1;n[i]=Math.min(n[i-1]+1,o[i]+1,o[i-1]+a)}[o,n]=[n,o]}return o[t.length]}function le(e,t=[]){if(!e)return null;let o=String(e).toLowerCase(),n=null,r=1/0;for(let a of t){let s=Jt(o,String(a).toLowerCase());s<r&&(r=s,n=a)}let i=Math.min(3,Math.max(2,Math.floor(o.length/4)));return r<=i?n:null}function qt(e,t){return e==="warning"?P(t,j.yellow,"\u26A0"):e==="info"?P(t,j.cyan,"\u2139"):P(t,j.red,"\u2716")}function we(e,{color:t=!1}={}){let o=be[e.category]||e.category,n=e.line?`${e.line}${e.column?`:${e.column}`:""}`:"",r=e.file?`${e.file}${n?`:${n}`:""}`:n,i=[];if(i.push(`${qt(e.severity,t)} ${P(t,j.bold,o)}`+(r?` ${P(t,j.dim,r)}`:"")),e.title&&i.push(` ${e.title}`),e.detail&&e.detail!==e.title&&i.push(` ${P(t,j.dim,e.detail)}`),e.frame)for(let a of String(e.frame).split(`
8
- `))i.push(` ${a}`);return e.suggestion&&i.push(` ${P(t,j.cyan,`Did you mean <${e.suggestion}>?`)}`),e.hint&&i.push(` ${P(t,j.dim,`\u2192 ${e.hint}`)}`),i.join(`
9
- `)}function ae(e,{color:t=!1}={}){if(!e.length)return P(t,j.cyan,"\u2713 No issues found.");let o=new Map;for(let s of e){let l=s.file||"velu.json";o.has(l)||o.set(l,[]),o.get(l).push(s)}let n=[];for(let[s,l]of o){n.push(P(t,j.bold,s));for(let u of l)n.push(we({...u,file:null},{color:t}).replace(/^/gm," "));n.push("")}let r=e.filter(s=>s.severity!=="warning"&&s.severity!=="info").length,i=e.length-r,a=`${r} error${r===1?"":"s"}`+(i?`, ${i} warning${i===1?"":"s"}`:"");return n.push(P(t,r?j.red:j.yellow,a)),n.join(`
10
- `)}var be,j,P,F=k(()=>{be={"mdx-syntax":"MDX syntax",frontmatter:"Frontmatter","unknown-component":"Unknown component","invalid-props":"Invalid options","render-crash":"Render error","config-json":"velu.json","config-schema":"velu.json","config-nav":"Navigation","config-asset":"Asset"};j={reset:"\x1B[0m",red:"\x1B[31m",yellow:"\x1B[33m",cyan:"\x1B[36m",dim:"\x1B[2m",bold:"\x1B[1m"},P=(e,t,o)=>e?`${t}${o}${j.reset}`:o});function Ht(e){let t=e,o=0;for(;t&&t.cause&&o<3&&!(t.loc||t.line||/`[^`]+` to be defined/.test(t.message||""));)t=t.cause,o+=1;return t||e}function ke(e,t){if(!e)return null;let o=Ye(e).replace(/[?#].*$/,""),n=t?Ye(t).replace(/\/+$/,""):"";return n&&o.toLowerCase().startsWith(n.toLowerCase())?o.slice(n.length).replace(/^\/+/,""):!/^([a-zA-Z]:\/|\/)/.test(o)&&!/node_modules/.test(o)?o:null}function Dt(e){return e?String(e).replace(/([a-zA-Z]:\\|\/)[^\s'"()]+/g,t=>/node_modules|[\\/]vite[\\/]|@veluai|velu-cli|velu-ui/.test(t)?"\u2026":t).trim():""}function Yt(e){let t=/\((\d+):(\d+)(?:-\d+:\d+)?\)\s*$/.exec(String(e||""));return t?{line:Number(t[1]),column:Number(t[2])}:null}function Kt(e){return String(e||"").replace(/\s*\(\d+:\d+(?:-\d+:\d+)?\)\s*$/,"").trim()}function Zt(e,t){if(!e||!t)return null;let o=String(e);return/node_modules|[\\/]vite[\\/]|@veluai[\\/]/.test(o)?null:o}function X(e,t={}){let{projectDir:o="",knownComponents:n=[],file:r=null}=t,i=null;for(let C=e,S=0;C&&S<6;C=C.cause,S+=1)if(C.veluIssue){i=C.veluIssue;break}if(i)return v({...i,file:i.file||r});let a=Ht(e)||{},s=a.message||String(e||""),l=/Expected component `([^`]+)` to be defined/.exec(s);if(l){let C=l[1],S=/referenced in your code at `(\d+):(\d+)/.exec(s),q=/\bin `([^`]+)`/.exec(s),y=q?ke(q[1],o):null;return v({category:"unknown-component",file:y||r,line:S?Number(S[1]):null,column:S?Number(S[2]):null,title:`<${C}> is not a built-in component`,detail:"",hint:"Components are built in \u2014 check the spelling and capitalization (you don\u2019t import them).",suggestion:le(C,n)})}let u=a.loc||(a.line!=null?{line:a.line,column:a.column,file:a.file}:null)||Yt(a.reason||s),c=a.id||u&&u.file||a.file||null,f=ke(c,o)||r,A=!!f&&ke(c,o)!=null,p=Zt(a.frame,A||!!r),L=Dt(Kt(a.reason||s)),d=Wt.test(s),N=a.source==="remark-frontmatter"||/\byaml\b|frontmatter/i.test(s)||u&&u.line===1&&/unexpected|expected/i.test(s)&&/---/.test(s);return u||d||p&&A?v({category:N?"frontmatter":"mdx-syntax",file:f,line:u?u.line:null,column:u?u.column:null,frame:p,title:L||(N?"Invalid frontmatter":"MDX syntax error"),detail:"",hint:N?"Check the YAML between the --- markers \u2014 indentation, quotes, and colons.":"Make sure every <Component> has a matching closing tag and that { } braces are balanced."}):/\.map is not a function|is not iterable|reading '|undefined \(reading/i.test(s)?v({category:"invalid-props",file:f,title:"A component received an invalid value",detail:L,hint:"Check the props/options you passed to a component on this page."}):v({category:"render-crash",file:f,title:"This page failed to render",detail:L,hint:"Set VELU_DEBUG=1 for the full stack trace."})}var Ye,Wt,Se=k(()=>{F();Ye=e=>String(e).replace(/\\/g,"/");Wt=/closing tag|unexpected closing|could not parse (?:expression|import|export)|unexpected character|unexpected end of|expected a closing|expected the closing|unexpected `|in expression|misnested|before name/i});function Xt(e){let t=be[e.category]||e.category,o=e.file?`${e.file}${e.line?`:${e.line}${e.column?`:${e.column}`:""}`:""}`:"",n=[];return n.push('<div class="velu-err-card">'),n.push('<div class="velu-err-head">'),n.push(`<span class="velu-err-pill">${T(t)}</span>`),n.push("</div>"),e.title&&n.push(`<div class="velu-err-title">${T(e.title)}</div>`),o&&n.push(`<a class="velu-err-loc" title="${T(o)}">${T(o)}</a>`),e.detail&&n.push(`<div class="velu-err-detail">${T(e.detail)}</div>`),e.frame&&n.push(`<pre class="velu-err-frame">${T(e.frame)}</pre>`),e.suggestion&&n.push(`<div class="velu-err-suggest">Did you mean <code>&lt;${T(e.suggestion)}&gt;</code>?</div>`),e.hint&&n.push(`<div class="velu-err-hint">${T(e.hint)}</div>`),n.push("</div>"),n.join("")}function $e(e,t={}){let o=Array.isArray(e)?e:[e],n=t.title||(o.length>1?`${o.length} problems to fix`:"There\u2019s a problem to fix"),r=o.map(Xt).join(`
2
+ var Ut=Object.defineProperty;var S=(e,t)=>()=>(e&&(t=e(e=0)),t);var we=(e,t)=>{for(var r in t)Ut(e,r,{get:t[r],enumerable:!0})};var Ve={};we(Ve,{initProject:()=>Bt});import D from"node:fs/promises";import Y from"node:path";import{fileURLToPath as Mt}from"node:url";async function Bt(e,t){try{if((await D.readdir(e)).length>0)throw new Error(`Directory "${t}" already exists and is not empty. Choose a different name or remove the folder first.`)}catch(i){if(i.code!=="ENOENT")throw i}await D.mkdir(e,{recursive:!0}),await D.cp(Gt,e,{recursive:!0});let r=Y.join(e,"velu.json"),n=JSON.parse(await D.readFile(r,"utf-8"));n.name=t,await D.writeFile(r,JSON.stringify(n,null,2)+`
3
+ `,"utf-8");let o=await Je(e);console.log(`[velu] created ${t}/`);for(let i of o)console.log(` ${i}`);console.log(""),console.log("Next steps:"),console.log(` cd ${t}`),console.log(" velu dev")}async function Je(e,t=e,r=[]){let n=await D.readdir(e,{withFileTypes:!0});for(let o of n){let i=Y.join(e,o.name);o.isDirectory()?await Je(i,t,r):r.push(Y.relative(t,i).split(Y.sep).join("/"))}return r.sort()}var zt,Gt,qe=S(()=>{zt=Y.dirname(Mt(import.meta.url)),Gt=Y.resolve(zt,"..","templates","starter")});import{visit as Jt}from"unist-util-visit";import{toString as Vt}from"mdast-util-to-string";import qt from"github-slugger";import{valueToEstree as Ht}from"estree-util-value-to-estree";function Q(){return e=>{let t=new qt,r=[];Jt(e,"heading",a=>{let s=Vt(a);r.push({depth:a.depth,id:t.slug(s),label:s})});let n={children:[]},o=[{node:n,depth:0}];for(let a of r){for(;o.length>1&&o[o.length-1].depth>=a.depth;)o.pop();let s={id:a.id,label:a.label},l=o[o.length-1].node;l.children||(l.children=[]),l.children.push(s),o.push({node:s,depth:a.depth})}let i=n.children;e.children.unshift({type:"mdxjsEsm",value:"",data:{estree:{type:"Program",sourceType:"module",body:[{type:"ExportNamedDeclaration",specifiers:[],declaration:{type:"VariableDeclaration",kind:"const",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:"toc"},init:Ht(i)}]}}]}}})}}var ke=S(()=>{});import Dt from"node:fs/promises";import He from"node:path";function ee(e){if(typeof e=="string"){let t=e.trim();return t?{light:t,dark:t,href:"/"}:null}if(e&&typeof e=="object"){let t=(e.light??e.dark)?.trim?.(),r=(e.dark??e.light)?.trim?.();return!t||!r?null:{light:t,dark:r,href:e.href?.trim?.()||"/"}}return null}function je(e){if(!e||typeof e!="object")return null;let t=[];if(e.socials&&typeof e.socials=="object")for(let[n,o]of Object.entries(e.socials))typeof o!="string"||!o.trim()||t.push({kind:Wt[n]??n,href:o.trim()});let r=Array.isArray(e.links)?e.links.filter(n=>n&&typeof n=="object").map(n=>({title:(n.header??n.title??"").trim(),items:(Array.isArray(n.items)?n.items:[]).filter(o=>o&&o.label).map(o=>({label:o.label,href:o.href??"#"}))})).filter(n=>n.title||n.items.length):[];return!t.length&&!r.length?null:{socials:t,links:r}}function Se(e){return/^(https?:)?\/\//.test(e)||/^(mailto|tel):/.test(e)}function Ae(e){if(!e||typeof e!="object")return null;let t=(Array.isArray(e.links)?e.links:[]).filter(o=>o&&typeof o.href=="string"&&o.href.trim()).map(o=>({label:o.label??"",href:o.href.trim(),icon:o.icon??null,external:Se(o.href.trim())})),r=null,n=e.primary;if(n&&typeof n=="object"&&typeof n.href=="string"&&n.href.trim()){let o=n.href.trim();r=n.type==="github"?{kind:"github",label:n.label??"GitHub",href:o,external:Se(o)}:{kind:"button",label:n.label??"",href:o,external:Se(o)}}return!t.length&&!r?null:{links:t,primary:r}}function Oe(e){if(!e||typeof e!="object")return{server:null,proxy:!0,languages:void 0};let t=e.playground||{};return{server:typeof e.server=="string"?e.server.trim():null,proxy:t.proxy!==!1&&t.display!=="none",languages:Array.isArray(e.examples?.languages)?e.examples.languages:void 0}}function Pe(e={},t){let r=e.colors?.primary??Yt;return{name:e.name??t??"docs",colors:{primary:r,light:e.colors?.light??r,dark:e.colors?.dark??r},favicon:e.favicon??null,api:Oe(e.api),logo:ee(e.logo),footer:je(e.footer),navbar:Ae(e.navbar),font:{family:e.font?.family??Kt},navigation:e.navigation??null}}async function De(e){let t=He.join(e,"velu.json"),r;try{r=await Dt.readFile(t,"utf-8")}catch(o){throw o.code==="ENOENT"?new Error(`No velu.json found in ${e}. Run \`velu init <name>\` to scaffold one.`):o}let n;try{n=JSON.parse(r)}catch(o){throw new Error(`velu.json is not valid JSON: ${o.message}`)}return Pe(n,He.basename(e))}function Ye(e){let{colors:t,font:r}=e;return[":root:root {",` --accent-color: ${t.light};`,` --font-sans: "${r.family}", sans-serif;`,"}",':root:root[data-theme="dark"] {',` --accent-color: ${t.dark};`,"}"].join(`
4
+ `)}var Yt,Kt,le,ce,Wt,ue=S(()=>{Yt="#dc143c",Kt="Google Sans Flex",le="/@velu-logo-light",ce="/@velu-logo-dark";Wt={twitter:"x","x-twitter":"x"}});import Zt from"github-slugger";import Xt from"iso-639-1";function en(e){let t=String(e).toLowerCase();return Xt.getNativeName(t)||e}function pe(e){return new Zt().slug(String(e??""))}function tn(e){let t=String(e).replace(/^\/+|\/+$/g,"").split("/").filter(Boolean);return t[t.length-1]==="index"&&t.pop(),"/"+t.join("/")}function K(e){let t={kind:"root",children:te(e??{})};return Ze(t.children),t}function te(e){let t=Array.isArray(e.anchors)?e.anchors.map(an):[];if(Array.isArray(e.products))return[...t,...e.products.map(nn)];if(Array.isArray(e.versions))return[...t,...e.versions.map(rn)];if(Array.isArray(e.languages))return[...t,...e.languages.map(on)];if(Array.isArray(e.tabs))return[...t,...e.tabs.map(sn)];let r=[...t];return Array.isArray(e.groups)&&r.push(...e.groups.map(Ke)),Array.isArray(e.pages)&&r.push(...e.pages.map(We)),r}function nn(e){return{kind:"product",label:e.name??e.product,slug:pe(e.product),icon:e.icon,color:e.color,default:!!e.default,children:te(e)}}function rn(e){return{kind:"version",label:e.version,slug:pe(e.version),default:!!e.default,children:te(e)}}function on(e){let t=String(e.language);return{kind:"language",code:t,label:en(t),slug:pe(t),default:!!e.default,children:te(e)}}function sn(e){return{kind:"tab",label:e.tab,slug:pe(e.tab),icon:e.icon,href:e.href,children:te(e)}}function an(e){return{kind:"anchor",label:e.anchor,icon:e.icon,href:e.href,color:e.color}}function Ke(e){let t=(e.pages??[]).map(We);return e.root&&t.unshift({kind:"page",pagePath:e.root}),{kind:"group",label:e.group,icon:e.icon,expanded:!!e.expanded,root:e.root,children:t}}function We(e){return typeof e=="string"?{kind:"page",pagePath:e}:e&&e.apiPage?{kind:"page",pagePath:e.apiPage,label:e.label,method:e.method,api:!0}:Ke(e)}function Ze(e){for(let t of Qt){let r=e.filter(n=>n.kind===t);r.length&&!r.some(n=>n.default)&&(r[0].default=!0)}for(let t of e)t.children&&Ze(t.children)}function fe(e){let t=[],r=(n,o,i)=>{if(n.kind==="page"){t.push({pagePath:n.pagePath,url:ln(n.pagePath,o),ctx:{...o},ancestors:i,node:n});return}let a=o;n.kind==="product"?a={...o,product:n.default?null:n.slug}:n.kind==="version"?a={...o,version:n.default?null:n.slug}:n.kind==="language"&&(a={...o,language:n.default?null:n.slug});let s=n.kind==="root"?i:[...i,n];for(let l of n.children??[])r(l,a,s)};return r(e,{product:null,version:null,language:null},[]),t}function ln(e,t){let r=[t.product,t.version,t.language].filter(Boolean),n=tn(e).split("/").filter(Boolean);return"/"+[...r,...n].join("/")}var Qt,ne=S(()=>{Qt=["product","version","language"]});import cn from"node:fs";import Xe from"node:path";function W(e,t){let r=[],n=[],o=new Set;for(let i of fe(e)){if(i.node?.api){o.add(i.url);continue}if(o.has(i.url)){r.push(`duplicate URL "${i.url}" (page "${i.pagePath}") \u2014 keeping the first occurrence`);continue}o.add(i.url);let a=i.pagePath.replace(/^\/+|\/+$/g,""),s=Xe.join(t,...a.split("/"))+".mdx",l=cn.existsSync(s);l||r.push(`page "${i.pagePath}" \u2192 ${Xe.relative(t,s)} not found`),n.push({pagePath:i.pagePath,url:i.url,fileAbsPath:s,exists:l})}return{pageEntries:n,warnings:r}}var me=S(()=>{ne()});import un from"@apidevtools/swagger-parser";async function mn(e){return un.dereference(e)}function G(e){return!e||typeof e!="object"?e||{}:Array.isArray(e.allOf)?e.allOf.reduce((t,r)=>{let n=G(r);return{...t,...n,properties:{...t.properties||{},...n.properties||{}},required:[...t.required||[],...n.required||[]]}},{...e,allOf:void 0}):Array.isArray(e.oneOf)&&e.oneOf.length?G(e.oneOf[0]):Array.isArray(e.anyOf)&&e.anyOf.length?G(e.anyOf[0]):e}function de(e){let t=G(e);if(!t||typeof t!="object")return"any";if(Array.isArray(t.enum)&&t.enum.length)return`enum<${typeof t.enum[0]}>`;if(t.type==="array")return`${de(t.items||{})}[]`;let r=t.type||(t.properties?"object":"any");return t.format?`${r}<${t.format}>`:r}function re(e,t=0){let r=G(e);if(!r||typeof r!="object")return null;if(r.example!==void 0)return r.example;if(r.default!==void 0)return r.default;if(Array.isArray(r.enum)&&r.enum.length)return r.enum[0];if(t>=fn)return r.type==="object"?{}:null;switch(r.type){case"object":{let n={};for(let[o,i]of Object.entries(r.properties||{}))n[o]=re(i,t+1);return n}case"array":return[re(r.items||{},t+1)];case"integer":case"number":return 0;case"boolean":return!0;default:return dn(r)}}function dn(e){switch(e.format){case"date-time":return"2024-01-01T00:00:00Z";case"date":return"2024-01-01";case"email":return"user@example.com";case"uuid":return"3fa85f64-5717-4562-b3fc-2c963f66afa6";case"uri":case"url":return"https://example.com";default:return"<string>"}}function et(e){let t=G(e);if(!t||t.type!=="object"||!t.properties)return t&&(t.type||t.items)?[{name:"body",type:de(t),required:!1,description:t.description||""}]:[];let r=new Set(t.required||[]);return Object.entries(t.properties).map(([n,o])=>{let i=G(o);return{name:n,type:de(i),required:r.has(n),description:i.description||"",enum:Array.isArray(i.enum)?i.enum:void 0,deprecated:i.deprecated||void 0}})}function gn(e){let t=e.schema||{};return{name:e.name,in:e.in,required:e.in==="path"?!0:!!e.required,type:de(t),description:e.description||"",enum:Array.isArray(t.enum)?t.enum:void 0,example:re(t),deprecated:e.deprecated||void 0}}function tt(e){if(!e||typeof e!="object")return null;let t=Object.keys(e),r=t.find(n=>/json/i.test(n))||t[0];return r?{contentType:r,media:e[r]}:null}function hn(e){if(!e)return null;let t=tt(e.content);if(!t)return null;let r=t.media.schema||{};return{required:!!e.required,description:e.description||"",contentType:t.contentType,fields:et(r),example:t.media.example??re(r)}}function yn(e){return!e||typeof e!="object"?[]:Object.entries(e).map(([t,r])=>{let n=tt(r?.content),o=n?.media?.schema||{};return{status:t,description:r?.description||"",contentType:n?.contentType||null,fields:n?et(o):[],example:n?n.media.example??re(o):null}})}function vn(e,t){if(!Array.isArray(e)||!t)return[];let r=[],n=new Set;for(let o of e)for(let i of Object.keys(o||{})){let a=t[i];!a||n.has(i)||(n.add(i),r.push(bn(i,a)))}return r.filter(Boolean)}function bn(e,t){return t.type==="http"&&/bearer/i.test(t.scheme||"")?{name:"Authorization",in:"header",required:!0,type:"string",prefix:"Bearer",description:t.description||"Bearer authentication token."}:t.type==="http"&&/basic/i.test(t.scheme||"")?{name:"Authorization",in:"header",required:!0,type:"string",prefix:"Basic",description:t.description||"Basic authentication credentials."}:t.type==="apiKey"?{name:t.name||e,in:t.in||"header",required:!0,type:"string",description:t.description||"API key."}:t.type==="oauth2"||t.type==="openIdConnect"?{name:"Authorization",in:"header",required:!0,type:"string",prefix:"Bearer",description:t.description||"OAuth 2.0 access token."}:{name:e,in:"header",required:!0,type:"string",description:t.description||""}}function Qe(e){return String(e).replace(/\{[^}]+\}/g,t=>t.slice(1,-1)).replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()}function xn(e){let{method:t,path:r,op:n,sharedParams:o,servers:i,schemes:a}=e,s=[...o||[],...n.parameters||[]],l={path:[],query:[],header:[],cookie:[]};for(let c of s)c&&l[c.in]&&l[c.in].push(gn(c));let u=n.security??e.globalSecurity;return{id:n.operationId?Qe(n.operationId):`${t}-${Qe(r)}`,method:t.toUpperCase(),path:r,title:n.summary||n.operationId||`${t.toUpperCase()} ${r}`,description:n.description||n.summary||"",tags:Array.isArray(n.tags)&&n.tags.length?n.tags:["API"],deprecated:n.deprecated||!1,auth:vn(u,a),parameters:l,body:hn(n.requestBody),responses:yn(n.responses),servers:(i||[]).map(c=>c.url).filter(Boolean)}}function $n(e){let t=[],r=e.components?.securitySchemes||e.securityDefinitions||{},n=e.security||[],o=e.servers||(e.host?[{url:`https://${e.host}${e.basePath||""}`}]:[]);for(let[i,a]of Object.entries(e.paths||{})){if(!a||typeof a!="object")continue;let s=a.parameters||[],l=a.servers||o;for(let u of pn){let c=a[u];!c||typeof c!="object"||t.push(xn({method:u,path:i,op:c,sharedParams:s,servers:c.servers||l,globalSecurity:n,schemes:r}))}}return t}async function nt(e){let t=await mn(e),r=t.servers||(t.host?[{url:`https://${t.host}${t.basePath||""}`}]:[]);return{title:t.info?.title||"API Reference",version:t.info?.version||"",servers:r.map(n=>n.url).filter(Boolean),operations:$n(t)}}var pn,fn,rt=S(()=>{pn=["get","post","put","patch","delete","options","head","trace"],fn=6});function wn(e,{server:t}={}){let n=`${(t||e.servers?.[0]||"").replace(/\/+$/,"")}${e.path}`,o={};for(let a of e.auth||[])a.in==="header"&&(o[a.name]=a.prefix?`${a.prefix} <token>`:"<token>");for(let a of e.parameters?.header||[])o[a.name]||(o[a.name]=String(a.example??`<${a.type}>`));let i=!!e.body;return i&&(o["Content-Type"]=e.body.contentType||"application/json"),{method:e.method,url:n,headers:o,body:i?e.body.example??{}:null}}function kn(e){let t=`curl --request ${e.method} \\
5
+ --url ${e.url}`;for(let[r,n]of Object.entries(e.headers))t+=` \\
6
+ --header '${r}: ${n}'`;return e.body!=null&&(t+=` \\
7
+ --data '${JSON.stringify(e.body)}'`),t}function Sn(e){let t=[` method: '${e.method}'`];if(Object.keys(e.headers).length){let r=Object.entries(e.headers).map(([n,o])=>` '${n}': '${o}'`).join(`,
8
+ `);t.push(` headers: {
9
+ ${r}
10
+ }`)}return e.body!=null&&t.push(` body: JSON.stringify(${Te(e.body," ")})`),[`const res = await fetch('${e.url}', {`,t.join(`,
11
+ `),"});","const data = await res.json();"].join(`
12
+ `)}function jn(e){let t=["import requests","",`url = "${e.url}"`];if(Object.keys(e.headers).length){let n=Object.entries(e.headers).map(([o,i])=>` "${o}": "${i}"`).join(`,
13
+ `);t.push(`headers = {
14
+ ${n}
15
+ }`)}let r=["url"];return e.body!=null&&(t.push(`payload = ${Te(e.body,"")}`),r.push("json=payload")),Object.keys(e.headers).length&&r.push("headers=headers"),t.push("",`response = requests.${e.method.toLowerCase()}(${r.join(", ")})`,"print(response.json())"),t.join(`
16
+ `)}function An(e){let t=e.method.charAt(0)+e.method.slice(1).toLowerCase(),r=["require 'net/http'","require 'json'","",`uri = URI("${e.url}")`,"http = Net::HTTP.new(uri.host, uri.port)","http.use_ssl = true",`request = Net::HTTP::${t}.new(uri)`];for(let[n,o]of Object.entries(e.headers))r.push(`request['${n}'] = '${o}'`);return e.body!=null&&r.push(`request.body = ${Te(e.body,"")}.to_json`),r.push("","response = http.request(request)","puts response.body"),r.join(`
17
+ `)}function it(e,{server:t,languages:r=_e}={}){let n=wn(e,{server:t});return r.filter(o=>ot[o]).map(o=>({key:o,label:On[o],language:Pn[o],code:ot[o](n)}))}var Te,ot,On,Pn,_e,st=S(()=>{Te=(e,t)=>JSON.stringify(e,null,2).split(`
18
+ `).map((r,n)=>n===0?r:t+r).join(`
19
+ `);ot={curl:kn,javascript:Sn,python:jn,ruby:An},On={curl:"cURL",javascript:"JavaScript",python:"Python",ruby:"Ruby"},Pn={curl:"bash",javascript:"javascript",python:"python",ruby:"ruby"},_e=["curl","javascript","python","ruby"]});import Tn from"node:path";function _n(e,t){return/^https?:\/\//.test(e)?e:Tn.resolve(t,e.replace(/^\/+/,""))}function Ln(e,{base:t,server:r,languages:n,ops:o}){let i=new Map;for(let s of e){let l=s.tags?.[0]||"API";i.has(l)||i.set(l,[]),i.get(l).push(s)}let a=[];for(let[s,l]of i){let u=l.map(c=>{let f=`${t}/${Le(s)}/${c.id}`;return o[f]={operation:c,samples:it(c,{server:r||c.servers?.[0],languages:n}),title:c.title,description:c.description,method:c.method},{apiPage:f,label:c.title,method:c.method}});a.push({group:s,pages:u})}return a}async function at(e,{targetDir:t,base:r,api:n,ops:o}){let i=Array.isArray(e)?e:[e],a=[];for(let s of i){let{operations:l,servers:u}=await nt(_n(s,t));for(let c of l)!c.servers?.length&&u?.length&&(c.servers=u),a.push(c)}return Ln(a,{base:r,server:n?.server,languages:n?.languages||_e,ops:o})}async function lt(e,{targetDir:t,api:r,ops:n,baseHint:o}){if(!e||typeof e!="object")return e;if(typeof e.tab=="string"&&e.openapi){let a=Le(e.tab),s=await at(e.openapi,{targetDir:t,base:a,api:r,ops:n}),{openapi:l,...u}=e;return{...u,groups:[...u.groups||[],...s]}}if(typeof e.group=="string"&&e.openapi){let a=Le(e.group),s=await at(e.openapi,{targetDir:t,base:a,api:r,ops:n}),{openapi:l,...u}=e,c=s.flatMap(f=>f.pages);return{...u,pages:[...u.pages||[],...c]}}let i={...e};for(let a of["products","versions","languages","tabs","groups"])Array.isArray(e[a])&&(i[a]=await Promise.all(e[a].map(s=>lt(s,{targetDir:t,api:r,ops:n,baseHint:o}))));return i}async function ct(e,{targetDir:t,api:r}={}){let n={};return!e||typeof e!="object"?{nav:e,ops:n}:{nav:await lt(e,{targetDir:t,api:r,ops:n}),ops:n}}var Le,ut=S(()=>{rt();st();Le=e=>String(e??"").replace(/\{[^}]+\}/g,t=>t.slice(1,-1)).replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()||"x"});import Cn from"node:fs";import oe from"node:path";function mt(e){return{name:"velu-site",resolveId(t){return t===ft?pt:null},async load(t){return t!==pt?null:En(e)}}}async function En(e){let t={};try{t=JSON.parse(Cn.readFileSync(oe.join(e,"velu.json"),"utf-8"))}catch{}let r=Oe(t.api),n=t.navigation??{},o={};try{let p=await ct(t.navigation??{},{targetDir:e,api:r});n=p.nav,o=p.ops}catch(p){console.warn(`[velu] openapi: ${p.message}`)}let i=K(n),{pageEntries:a,warnings:s}=W(i,e);for(let p of s)console.warn(`[velu] nav: ${p}`);let l=ee(t.logo),u={name:t.name??oe.basename(e),logo:l?{light:le,dark:ce,href:l.href,mono:l.light===l.dark}:null,footer:je(t.footer),navbar:Ae(t.navbar)},c=[],f=[],L=0;for(let p of a){if(!p.exists)continue;let T=JSON.stringify(p.fileAbsPath.split(oe.sep).join("/")),z=JSON.stringify(oe.relative(e,p.fileAbsPath).split(oe.sep).join("/")),C=`__p${L++}`;c.push(`import * as ${C} from ${T};`),f.push(` ${JSON.stringify(p.url)}: { Component: ${C}.default, frontmatter: ${C}.frontmatter, toc: ${C}.toc, relPath: ${z} },`)}let g=new Set(a.filter(p=>p.exists).map(p=>p.url));for(let p of a)!p.exists&&!g.has(p.url)&&f.push(` ${JSON.stringify(p.url)}: { missing: true },`);let k=[],d=[],E=[],O=!1,x=0;for(let p of fe(i)){if(!p.node?.api)continue;let T=o[p.pagePath];if(!T)continue;O=!0;let z=`__op${x}`,C=`__samples${x}`,y=`__api${x}`;x+=1,k.push(`const ${z} = ${JSON.stringify(T.operation)};`),k.push(`const ${C} = ${JSON.stringify(T.samples)};`),E.push(`{ id: ${JSON.stringify(T.operation.id)}, method: ${JSON.stringify(T.operation.method)}, title: ${JSON.stringify(T.operation.title)}, url: ${JSON.stringify(p.url)}, operation: ${z}, samples: ${C} }`),d.push(`function ${y}(){ return React.createElement(ApiReferencePage, { operation: ${z}, samples: ${C}, apiOperations: __apiOperations, api: __apiConfig }); }`),f.push(` ${JSON.stringify(p.url)}: { Component: ${y}, frontmatter: { title: ${JSON.stringify(T.title)}, description: ${JSON.stringify(T.description)} }, toc: [], operation: ${z}, samples: ${C}, api: true },`)}O&&(k.push(`const __apiOperations = [
20
+ ${E.join(`,
21
+ `)}
22
+ ];`),k.push(d.join(`
23
+ `)));let R=[];return O&&(R.push("import React from 'react';"),R.push("import { ApiReferencePage } from 'velu-ui';"),R.push(`const __apiConfig = ${JSON.stringify({proxy:r.proxy,server:r.server})};`)),["// AUTO-GENERATED by vite-plugin-velu-site. Do not edit.",R.join(`
24
+ `),c.join(`
25
+ `),k.join(`
26
+ `),"","export const pages = {",f.join(`
27
+ `),"};",`export const navigation = ${JSON.stringify(i)};`,`export const site = ${JSON.stringify(u)};`,""].join(`
28
+ `)}var ft,pt,dt=S(()=>{ne();me();ue();ut();ft="virtual:velu-site",pt="\0"+ft});function $(e){return{category:"render-crash",severity:"error",file:null,line:null,column:null,frame:null,title:"Something went wrong",detail:"",hint:"",suggestion:null,...e}}function Nn(e,t){if(e=String(e),t=String(t),e===t)return 0;if(!e.length)return t.length;if(!t.length)return e.length;let r=Array.from({length:t.length+1},(o,i)=>i),n=new Array(t.length+1);for(let o=1;o<=e.length;o++){n[0]=o;for(let i=1;i<=t.length;i++){let a=e[o-1]===t[i-1]?0:1;n[i]=Math.min(n[i-1]+1,r[i]+1,r[i-1]+a)}[r,n]=[n,r]}return r[t.length]}function ge(e,t=[]){if(!e)return null;let r=String(e).toLowerCase(),n=null,o=1/0;for(let a of t){let s=Nn(r,String(a).toLowerCase());s<o&&(o=s,n=a)}let i=Math.min(3,Math.max(2,Math.floor(r.length/4)));return o<=i?n:null}function Rn(e,t){return e==="warning"?N(t,_.yellow,"\u26A0"):e==="info"?N(t,_.cyan,"\u2139"):N(t,_.red,"\u2716")}function Ee(e,{color:t=!1}={}){let r=Ce[e.category]||e.category,n=e.line?`${e.line}${e.column?`:${e.column}`:""}`:"",o=e.file?`${e.file}${n?`:${n}`:""}`:n,i=[];if(i.push(`${Rn(e.severity,t)} ${N(t,_.bold,r)}`+(o?` ${N(t,_.dim,o)}`:"")),e.title&&i.push(` ${e.title}`),e.detail&&e.detail!==e.title&&i.push(` ${N(t,_.dim,e.detail)}`),e.frame)for(let a of String(e.frame).split(`
29
+ `))i.push(` ${a}`);return e.suggestion&&i.push(` ${N(t,_.cyan,`Did you mean <${e.suggestion}>?`)}`),e.hint&&i.push(` ${N(t,_.dim,`\u2192 ${e.hint}`)}`),i.join(`
30
+ `)}function he(e,{color:t=!1}={}){if(!e.length)return N(t,_.cyan,"\u2713 No issues found.");let r=new Map;for(let s of e){let l=s.file||"velu.json";r.has(l)||r.set(l,[]),r.get(l).push(s)}let n=[];for(let[s,l]of r){n.push(N(t,_.bold,s));for(let u of l)n.push(Ee({...u,file:null},{color:t}).replace(/^/gm," "));n.push("")}let o=e.filter(s=>s.severity!=="warning"&&s.severity!=="info").length,i=e.length-o,a=`${o} error${o===1?"":"s"}`+(i?`, ${i} warning${i===1?"":"s"}`:"");return n.push(N(t,o?_.red:_.yellow,a)),n.join(`
31
+ `)}var Ce,_,N,B=S(()=>{Ce={"mdx-syntax":"MDX syntax",frontmatter:"Frontmatter","unknown-component":"Unknown component","invalid-props":"Invalid options","render-crash":"Render error","config-json":"velu.json","config-schema":"velu.json","config-nav":"Navigation","config-asset":"Asset"};_={reset:"\x1B[0m",red:"\x1B[31m",yellow:"\x1B[33m",cyan:"\x1B[36m",dim:"\x1B[2m",bold:"\x1B[1m"},N=(e,t,r)=>e?`${t}${r}${_.reset}`:r});function In(e){let t=e,r=0;for(;t&&t.cause&&r<3&&!(t.loc||t.line||/`[^`]+` to be defined/.test(t.message||""));)t=t.cause,r+=1;return t||e}function Ne(e,t){if(!e)return null;let r=gt(e).replace(/[?#].*$/,""),n=t?gt(t).replace(/\/+$/,""):"";return n&&r.toLowerCase().startsWith(n.toLowerCase())?r.slice(n.length).replace(/^\/+/,""):!/^([a-zA-Z]:\/|\/)/.test(r)&&!/node_modules/.test(r)?r:null}function Fn(e){return e?String(e).replace(/([a-zA-Z]:\\|\/)[^\s'"()]+/g,t=>/node_modules|[\\/]vite[\\/]|@veluai|velu-cli|velu-ui/.test(t)?"\u2026":t).trim():""}function Un(e){let t=/\((\d+):(\d+)(?:-\d+:\d+)?\)\s*$/.exec(String(e||""));return t?{line:Number(t[1]),column:Number(t[2])}:null}function Mn(e){return String(e||"").replace(/\s*\(\d+:\d+(?:-\d+:\d+)?\)\s*$/,"").trim()}function Gn(e,t){if(!e||!t)return null;let r=String(e);return/node_modules|[\\/]vite[\\/]|@veluai[\\/]/.test(r)?null:r}function ie(e,t={}){let{projectDir:r="",knownComponents:n=[],file:o=null}=t,i=null;for(let O=e,x=0;O&&x<6;O=O.cause,x+=1)if(O.veluIssue){i=O.veluIssue;break}if(i)return $({...i,file:i.file||o});let a=In(e)||{},s=a.message||String(e||""),l=/Expected component `([^`]+)` to be defined/.exec(s);if(l){let O=l[1],x=/referenced in your code at `(\d+):(\d+)/.exec(s),R=/\bin `([^`]+)`/.exec(s),p=R?Ne(R[1],r):null;return $({category:"unknown-component",file:p||o,line:x?Number(x[1]):null,column:x?Number(x[2]):null,title:`<${O}> is not a built-in component`,detail:"",hint:"Components are built in \u2014 check the spelling and capitalization (you don\u2019t import them).",suggestion:ge(O,n)})}let u=a.loc||(a.line!=null?{line:a.line,column:a.column,file:a.file}:null)||Un(a.reason||s),c=a.id||u&&u.file||a.file||null,f=Ne(c,r)||o,L=!!f&&Ne(c,r)!=null,g=Gn(a.frame,L||!!o),k=Fn(Mn(a.reason||s)),d=zn.test(s),E=a.source==="remark-frontmatter"||/\byaml\b|frontmatter/i.test(s)||u&&u.line===1&&/unexpected|expected/i.test(s)&&/---/.test(s);return u||d||g&&L?$({category:E?"frontmatter":"mdx-syntax",file:f,line:u?u.line:null,column:u?u.column:null,frame:g,title:k||(E?"Invalid frontmatter":"MDX syntax error"),detail:"",hint:E?"Check the YAML between the --- markers \u2014 indentation, quotes, and colons.":"Make sure every <Component> has a matching closing tag and that { } braces are balanced."}):/\.map is not a function|is not iterable|reading '|undefined \(reading/i.test(s)?$({category:"invalid-props",file:f,title:"A component received an invalid value",detail:k,hint:"Check the props/options you passed to a component on this page."}):$({category:"render-crash",file:f,title:"This page failed to render",detail:k,hint:"Set VELU_DEBUG=1 for the full stack trace."})}var gt,zn,Re=S(()=>{B();gt=e=>String(e).replace(/\\/g,"/");zn=/closing tag|unexpected closing|could not parse (?:expression|import|export)|unexpected character|unexpected end of|expected a closing|expected the closing|unexpected `|in expression|misnested|before name/i});function Bn(e){let t=Ce[e.category]||e.category,r=e.file?`${e.file}${e.line?`:${e.line}${e.column?`:${e.column}`:""}`:""}`:"",n=[];return n.push('<div class="velu-err-card">'),n.push('<div class="velu-err-head">'),n.push(`<span class="velu-err-pill">${F(t)}</span>`),n.push("</div>"),e.title&&n.push(`<div class="velu-err-title">${F(e.title)}</div>`),r&&n.push(`<a class="velu-err-loc" title="${F(r)}">${F(r)}</a>`),e.detail&&n.push(`<div class="velu-err-detail">${F(e.detail)}</div>`),e.frame&&n.push(`<pre class="velu-err-frame">${F(e.frame)}</pre>`),e.suggestion&&n.push(`<div class="velu-err-suggest">Did you mean <code>&lt;${F(e.suggestion)}&gt;</code>?</div>`),e.hint&&n.push(`<div class="velu-err-hint">${F(e.hint)}</div>`),n.push("</div>"),n.join("")}function Ie(e,t={}){let r=Array.isArray(e)?e:[e],n=t.title||(r.length>1?`${r.length} problems to fix`:"There\u2019s a problem to fix"),o=r.map(Bn).join(`
11
32
  `);return`<!doctype html>
12
33
  <html lang="en">
13
34
  <head>
@@ -74,20 +95,20 @@ var vt=Object.defineProperty;var k=(e,t)=>()=>(e&&(t=e(e=0)),t);var de=(e,t)=>{f
74
95
  <body>
75
96
  <div class="velu-err-wrap">
76
97
  <div class="velu-err-brand">velu</div>
77
- <h1 class="velu-err-h">${T(n)}</h1>
78
- ${r}
98
+ <h1 class="velu-err-h">${F(n)}</h1>
99
+ ${o}
79
100
  <div class="velu-err-foot">Fix the file and save \u2014 this page reloads automatically.</div>
80
101
  </div>
81
102
  </body>
82
- </html>`}var T,Ke=k(()=>{F();T=e=>String(e??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")});var I,je=k(()=>{I=["Callout","Card","CardGroup","Accordion","AccordionGroup","Columns","Field","Prompt","Steps","Step","Tree","Folder","File","Image","CodeBlock","CodeGroup","MethodBadge","ApiPath","TryItBar","ApiField","ApiClient","ApiSidebar"]});import ce from"node:fs";import ee from"node:path";import{fileURLToPath as Qt}from"node:url";import en from"iso-639-1";function Q(e,t){if(!t)return null;let o=e.indexOf(`"${t}"`);return o===-1?null:e.slice(0,o).split(`
83
- `).length}function on(e,t){return t==null||t<0?null:e.slice(0,t).split(`
84
- `).length}function Ae(e,t){if(!t)return null;let o=e.indexOf(`"${t}"`);return o===-1?null:e.slice(0,o).split(`
85
- `).length}function rn(e,t,o){let n=[];return s(e,t,"",null),n;function r(l){if(l&&l.$ref){let u=l.$ref.replace(/^#\//,"").split("/"),c=o;for(let f of u)c=c?.[f];return c||{}}return l}function i(l){return Array.isArray(l)?"array":l===null?"null":typeof l}function a(l,u){let c=n.length;s(l,u,"",null,!0);let f=n.length===c;return f||(n.length=c),f}function s(l,u,c,f,A){let p=r(u);if(p){if(p.oneOf){p.oneOf.some(d=>a(l,d))||n.push({path:c,key:f,message:"value does not match any allowed shape"});return}if(p.type&&i(l)!==p.type){n.push({path:c,key:f,message:`expected ${p.type}, got ${i(l)}`});return}if(p.type==="string"&&p.minLength!=null&&l.length<p.minLength&&n.push({path:c,key:f,message:"must not be empty"}),p.type==="object"&&i(l)==="object"){for(let d of p.required||[])d in l||n.push({path:c?`${c}.${d}`:d,key:d,message:`missing required "${d}"`});let L=p.properties||{};if(p.additionalProperties===!1)for(let d of Object.keys(l))d in L||n.push({path:c?`${c}.${d}`:d,key:d,message:`unknown field "${d}"`});for(let[d,N]of Object.entries(L))d in l&&s(l[d],N,c?`${c}.${d}`:d,d,A)}p.type==="array"&&Array.isArray(l)&&p.items&&l.forEach((L,d)=>s(L,p.items,`${c}[${d}]`,f,A))}}}function sn(e){if(typeof e!="string")return!1;let t=e.trim();return/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)||/^(rgb|rgba|hsl|hsla|color|oklch|lab|lch)\(/i.test(t)||/^[a-z][a-z0-9-]*$/i.test(t)}function ue(e){let t=[],o=ee.join(e,"velu.json"),n;try{n=ce.readFileSync(o,"utf-8")}catch(s){return s.code==="ENOENT"?t.push(v({category:"config-json",file:"velu.json",title:"No velu.json found",hint:"Run `velu init <name>` to scaffold a project."})):t.push(v({category:"config-json",file:"velu.json",title:"Could not read velu.json"})),t}let r;try{r=JSON.parse(n)}catch(s){let l=/position (\d+)/.exec(s.message||""),u=l?on(n,Number(l[1])):null;return t.push(v({category:"config-json",file:"velu.json",line:u,title:"velu.json is not valid JSON",detail:String(s.message||"").replace(/\s+in JSON.*$/,""),hint:"Check for a trailing comma, a missing quote, or an unclosed brace."})),t}let i=null;try{i=JSON.parse(ce.readFileSync(nn,"utf-8"))}catch{}if(i)for(let s of rn(r,i,i)){let l=/^unknown field/.test(s.message);t.push(v({category:"config-schema",severity:l?"warning":"error",file:"velu.json",line:Q(n,s.key),title:s.path?`${s.path}: ${s.message}`:s.message,hint:l?"Remove it, or check the spelling against the velu.json schema.":""}))}for(let s of["primary","light","dark"]){let l=r.colors?.[s];l!=null&&!sn(l)&&t.push(v({category:"config-schema",severity:"warning",file:"velu.json",line:Q(n,s),title:`colors.${s}: "${l}" doesn\u2019t look like a CSS color`,hint:"Use a hex value like #dc143c, an rgb()/hsl() function, or a CSS color name."}))}if(typeof r.favicon=="string"&&r.favicon.trim()){let s=ee.resolve(e,r.favicon.replace(/^\/+/,""));ce.existsSync(s)||t.push(v({category:"config-asset",file:"velu.json",line:Q(n,"favicon"),title:`favicon not found: ${r.favicon}`,hint:"The path is relative to the project root."}))}let a=Y(r.logo);if(a){let s=new Map;for(let l of["light","dark"]){let u=a[l];u&&s.set(u,[...s.get(u)||[],l])}for(let[l,u]of s)if(!ce.existsSync(ee.resolve(e,l.replace(/^\/+/,"")))){let c=u.length===2?"logo":`logo (${u[0]})`;t.push(v({category:"config-asset",file:"velu.json",line:Ae(n,l),title:`${c} not found: ${l}`,hint:"The path is relative to the project root."}))}}if(r.navigation&&typeof r.navigation=="object"){let s;try{s=V(r.navigation)}catch(l){t.push(v({category:"config-nav",file:"velu.json",line:Q(n,"navigation"),title:"navigation could not be processed",detail:String(l.message||"")})),s=null}if(s){let{pageEntries:l,warnings:u}=B(s,e);for(let c of u){let f=/not found$/.test(c),A=/page "([^"]+)"/.exec(c),p=A?Ae(n,A[1]):null;t.push(v({category:"config-nav",severity:f?"error":"warning",file:"velu.json",line:p,title:c,hint:f?"Create the .mdx file, or remove the page from navigation.":""}))}ln(s,n,t)}}return t}function ln(e,t,o){let n=new Set,r=i=>{if(!(!i||typeof i!="object")){if(i.language&&!n.has(i.language)){n.add(i.language);let a=String(i.language).toLowerCase();en.validate(a)||o.push(v({category:"config-nav",severity:"warning",file:"velu.json",line:Ae(t,i.language)||Q(t,"language"),title:`"${i.language}" is not a valid ISO 639-1 language code`,hint:'Use a two-letter code like "en", "fr", or "ja".'}))}for(let a of Object.values(i))Array.isArray(a)?a.forEach(r):a&&typeof a=="object"&&r(a)}};r(e)}var tn,nn,Le=k(()=>{F();W();se();re();tn=ee.dirname(Qt(import.meta.url)),nn=ee.resolve(tn,"..","..","schema","velu.schema.json")});import an from"node:fs/promises";import cn from"node:fs";import R from"node:path";import{fileURLToPath as un,pathToFileURL as fn}from"node:url";import{compile as pn}from"@mdx-js/mdx";import mn from"remark-frontmatter";import dn from"remark-mdx-frontmatter";import gn from"remark-gfm";import hn from"rehype-slug";import{visit as vn}from"unist-util-visit";function Oe(){if(fe)return fe;let e=R.dirname(un(import.meta.url)),t=[R.resolve(e,"..","runtime","velu-ui"),R.resolve(e,"..","..","runtime","velu-ui"),R.resolve(e,"..","..","..","velu-ui","src")],o=null;for(let n of t){let r=R.join(n,"lib","component-schemas.js");if(cn.existsSync(r)){o=r;break}}return fe=o?import(fn(o).href).then(n=>n.validateProps).catch(()=>null):Promise.resolve(null),fe}function yn(e){let t={};for(let o of e.attributes||[])o.type==="mdxJsxAttribute"&&(o.value==null?t[o.name]=!0:typeof o.value=="string"&&(t[o.name]=o.value));return t}function xn(e,t){return()=>o=>{vn(o,n=>{if((n.type==="mdxJsxFlowElement"||n.type==="mdxJsxTextElement")&&typeof n.name=="string"&&/^[A-Z]/.test(n.name)&&!n.name.includes(".")&&e.push({name:n.name,props:yn(n),line:n.position?.start?.line??null,column:n.position?.start?.column??null}),n.type==="mdxjsEsm"&&typeof n.value=="string")for(let r of n.value.matchAll(/\b([A-Z][A-Za-z0-9_]*)\b/g))t.add(r[1])})}}async function bn(e,t){let o=[],n;try{n=await an.readFile(t.fileAbsPath,"utf-8")}catch{return o}let r=R.relative(e,t.fileAbsPath).split(R.sep).join("/"),i=[],a=new Set;try{await pn({value:n,path:t.fileAbsPath},{remarkPlugins:[mn,dn,gn,D,xn(i,a)],rehypePlugins:[hn],providerImportSource:"@mdx-js/react"})}catch(c){return o.push(X(c,{projectDir:e,knownComponents:I,file:r})),o}let s=new Set(I),l=await Oe(),u=new Set;for(let c of i)if(!a.has(c.name)){if(!s.has(c.name)){if(u.has(c.name))continue;u.add(c.name),o.push(v({category:"unknown-component",file:r,line:c.line,column:c.column,title:`<${c.name}> is not a built-in component`,hint:"Components are built in \u2014 check the spelling and capitalization (you don\u2019t import them).",suggestion:le(c.name,I)}));continue}if(l){let f=l(c.name,c.props,{checkRequired:!1});f&&o.push(v({...f,file:r,line:c.line,column:c.column}))}}return o}async function We(e,t){let o=t.filter(s=>s.exists),n=[],r=8,i=0;async function a(){for(;i<o.length;){let s=o[i++],l=await bn(e,s);for(let u of l)n.push(u)}}return await Promise.all(Array.from({length:Math.min(r,o.length)},a)),n}var fe,_e=k(()=>{ge();F();Se();je()});import{visit as wn}from"unist-util-visit";function kn(e,t){let o=Ze(e).replace(/[?#].*$/,""),n=Ze(t).replace(/\/+$/,"");return n&&o.toLowerCase().startsWith(n.toLowerCase())?o.slice(n.length).replace(/^\/+/,""):null}function Xe(e,t){return()=>(o,n)=>{typeof e=="function"&&wn(o,r=>{if(r.type!=="mdxJsxFlowElement"&&r.type!=="mdxJsxTextElement"||typeof r.name!="string"||!/^[A-Z]/.test(r.name)||r.name.includes("."))return;let i={};for(let s of r.attributes||[])s.type==="mdxJsxAttribute"&&(s.value==null?i[s.name]=!0:typeof s.value=="string"&&(i[s.name]=s.value));let a=e(r.name,i,{checkRequired:!1});if(a){let s=new Error(a.title);throw s.veluIssue={...a,file:kn(n?.path,t),line:r.position?.start?.line??null,column:r.position?.start?.column??null},s.loc={line:s.veluIssue.line,column:s.veluIssue.column},s}})}}var Ze,Qe=k(()=>{Ze=e=>String(e||"").replace(/\\/g,"/")});var st={};de(st,{startDevServer:()=>Yn});import et from"node:fs/promises";import M from"node:fs";import Sn from"node:http";import{spawn as $n}from"node:child_process";import w from"node:path";import{fileURLToPath as jn}from"node:url";import{createRequire as An}from"node:module";import Ln from"chokidar";import On from"express";import _n from"@tailwindcss/vite";import Pn from"@vitejs/plugin-react";import Cn from"@mdx-js/rollup";import Tn from"remark-frontmatter";import En from"remark-mdx-frontmatter";import Nn from"remark-gfm";import Fn from"rehype-slug";import{createServer as In,searchForWorkspaceRoot as Rn}from"vite";function Vn(e){return`<link rel="stylesheet" href="${`https://fonts.googleapis.com/css2?family=${encodeURIComponent(e).replace(/%20/g,"+")}:wght@300;400;500;600;700&display=swap`}" />`}function nt(e,t){let o=we(e,{color:!!process.stderr.isTTY});console.error(`
86
- `+o+`
87
- `),process.env.VELU_DEBUG&&t&&console.error(t)}function Bn(){try{return JSON.parse(M.readFileSync(w.join(J,"package.json"),"utf8")).version||"unknown"}catch{return"unknown"}}function Jn(e,t){let o=w.resolve(e,".velu"),n=w.resolve(o,".velu-version"),r=null;try{r=M.readFileSync(n,"utf8").trim()}catch{}if(r!==t){if(r!==null)try{M.rmSync(w.join(o,"vite-cache"),{recursive:!0,force:!0}),console.log("[velu] new version detected \u2014 refreshing the preview cache\u2026")}catch{}try{M.mkdirSync(o,{recursive:!0}),M.writeFileSync(n,t)}catch{}}}async function ot(e){try{return await Re(e)}catch{return xe({},w.basename(e))}}async function rt(e,t){let o=await e.moduleGraph.getModuleByUrl(t,!0),n=new Map,r=new Set;async function i(a){if(!(!a||r.has(a.url))){if(r.add(a.url),a.id&&Un.test(a.id)){let s=a.url.includes("?")?"&":"?",l=await e.transformRequest(`${a.url}${s}direct`);l?.code&&n.set(a.url,l.code)}for(let s of a.importedModules)await i(s)}}return await i(o),[...n.values()].join(`
88
- `)}function Dn(e,t){let o=()=>{process.stdout.isTTY&&!process.env.VELU_NO_BELL&&process.stdout.write("\x07")},n=process.stdout.isTTY,r=f=>n&&process.stdout.write(`\x1B]${f}\x1B\\`),i=()=>{r(`0;\u23F3 ${t}`),r("9;4;3;0")},a=()=>{r(`0;${t}`),r("9;4;0;0")};if(n&&process.once("exit",()=>r("9;4;0;0")),i(),!e)return console.log("Starting Velu\u2026"),{ready:f=>{console.log(`Velu ready \u2192 ${f}`),a(),o()}};let s="\x1B[38;2;220;20;60m",l="\x1B[0m";console.log("");for(let f of qn)console.log(`${s}${f}${l}`);console.log("");let u=null;try{u=$n(process.execPath,["-e",Hn],{stdio:["ignore","inherit","ignore"]}),u.on("error",()=>{})}catch{}let c=()=>{if(u){try{u.kill()}catch{}u=null}};return process.once("exit",c),{ready:f=>{c(),process.stdout.write("\x1B[2K\r"),console.log(` \x1B[32m\u2713${l} Velu ready \u2192 \x1B[36m${f}${l}`),a(),o()}}}async function Yn(e){let t=!!process.env.VELU_PROFILE,o=performance.now(),n=(x,m)=>t&&console.log(`[velu-profile] ${x}: ${(performance.now()-m).toFixed(0)}ms`),r=Dn(!!process.stdout.isTTY&&!t,w.basename(e)),i=await ot(e),a=s();function s(){let m=ue(e).filter(h=>h.severity==="error"&&(h.category==="config-json"||h.category==="config-schema"));return m.length&&console.error(`
89
- `+ae(m,{color:!!process.stderr.isTTY})+`
90
- `),m}let l=e;try{l=M.realpathSync(e)}catch{}let u=0,c=x=>{let m=performance.now();if(m-u<500)return;u=m;let h=X(x,{projectDir:l,knownComponents:I});nt(h,x)};process.on("unhandledRejection",c),process.on("uncaughtException",c);let A=An(import.meta.url).resolve("@mdx-js/react"),p=w.resolve(J,"runtime","velu-ui"),L=M.existsSync(p)?p:w.resolve(J,"..","velu-ui","src"),d=[{find:"@mdx-js/react",replacement:A},{find:/^velu-ui$/,replacement:w.join(L,"index.js")},{find:/^velu-ui\//,replacement:L+"/"}],N=Number(process.env.PORT)||8358,C=await Oe();Jn(e,Bn());let S=On(),q=Sn.createServer(S),y=await In({root:J,appType:"custom",logLevel:t?"info":"warn",plugins:[He(e),Cn({remarkPlugins:[Tn,En,Nn,D,Xe(C,e)],rehypePlugins:[Fn],providerImportSource:"@mdx-js/react"}),Pn(),_n()],cacheDir:w.resolve(e,".velu","vite-cache"),optimizeDeps:{include:["react","react-dom","react-dom/client","react-router-dom","@mdx-js/react","lucide-react","prism-react-renderer","iso-639-1","github-slugger"],exclude:["tailwindcss","@tailwindcss/oxide","playwright","playwright-core"],esbuildOptions:{loader:{".mdx":"jsx"}}},resolve:{alias:d,dedupe:["react","react-dom","@mdx-js/react"]},server:{middlewareMode:!0,fs:{allow:[Rn(J),e,l]},hmr:{server:q}}});n("vite server created",o),S.use(y.middlewares),S.get(tt,async(x,m,h)=>{if(!i.favicon)return m.status(404).end();let g=w.resolve(e,i.favicon.replace(/^\//,""));m.sendFile(g,O=>{O&&m.status(404).end()})});let Ce=x=>(m,h)=>{let g=i.logo?.[x];if(!g)return h.status(404).end();h.sendFile(w.resolve(e,g.replace(/^\//,"")),O=>{O&&h.status(404).end()})};S.get(ne,Ce("light")),S.get(oe,Ce("dark")),S.use("*",async(x,m,h)=>{let g=x.originalUrl,O=performance.now();if(a.length)return m.status(200).set({"Content-Type":"text/html"}).end($e(a,{title:"Fix velu.json to continue"}));try{let b=performance.now(),_=await et.readFile(it,"utf-8");_=await y.transformIndexHtml(g,_),n(`transformIndexHtml ${g}`,b);let U="/src/runtime/server-entry.jsx";b=performance.now();let{render:te}=await y.ssrLoadModule(U);n(`ssrLoadModule ${g} (1st req includes dep pre-bundle)`,b),b=performance.now();let $=await te(g);n(`render ${g}`,b),b=performance.now();let H=await rt(y,U);n(`collectSsrCss ${g}`,b);let me=H?`<style data-velu-ssr>${H}</style>`:"",pt=`<style data-velu-config>
91
- ${Me(i)}
92
- </style>`,mt=zn.has(i.font.family)?"":Vn(i.font.family),dt=i.favicon?`<link rel="icon" href="${tt}" />`:"",gt=[me,pt,mt,dt].filter(Boolean).join(`
93
- `),ht=_.replace("<!--app-title-->",Gn(i.name)).replace("<!--app-head-->",gt).replace("<!--app-html-->",$);m.status(200).set({"Content-Type":"text/html"}).end(ht),n(`TOTAL ${g}`,O)}catch(b){y.ssrFixStacktrace(b);let _=X(b,{projectDir:l,knownComponents:I});nt(_,b),m.status(200).set({"Content-Type":"text/html"}).end($e([_]))}}),Ln.watch(e,{ignoreInitial:!0,ignored:/(^|[\\/])(node_modules|\.git|\.velu)([\\/]|$)/,awaitWriteFinish:{stabilityThreshold:100,pollInterval:20}}).on("all",async(x,m)=>{console.log(`[velu-cli] content ${x}: ${w.relative(e,m)}`);let h=w.basename(m)==="velu.json",g=m.endsWith(".mdx"),O=h||g&&(x==="add"||x==="unlink");if(h&&(i=await ot(e),a=s()),O)y.moduleGraph.invalidateAll();else if(g){let b=m.split(w.sep).join("/"),_=y.moduleGraph.getModulesByFile(b);if(_)for(let U of _)y.moduleGraph.invalidateModule(U)}y.ws.send({type:"full-reload"})});async function Te(x){let m=new Set,h=12,g=0,O=[],b=()=>g<h?(g+=1,Promise.resolve()):new Promise($=>O.push($)).then(()=>{g+=1}),_=()=>{g-=1,O.shift()?.()},U=$=>/[\\/]\.velu[\\/]vite-cache[\\/]|[\\/]deps[\\/]/.test($)||/[\\/]node_modules[\\/]/.test($)&&!/velu-ui/.test($);async function te($){if(!(!$||m.has($)||U($))){m.add($);try{await b();try{await y.transformRequest($,{ssr:!1})}finally{_()}let H=await y.moduleGraph.getModuleByUrl($,!1);H?.importedModules?.size&&await Promise.all([...H.importedModules].map(me=>te(me.url)))}catch{}}}return await te(x),m.size}q.listen(N,async()=>{let x=performance.now(),m=0;try{let{render:h}=await y.ssrLoadModule("/src/runtime/server-entry.jsx");await Te("/src/runtime/client-entry.jsx"),typeof y.waitForRequestsIdle=="function"&&await y.waitForRequestsIdle();let[g]=await Promise.allSettled([Te("/src/runtime/client-entry.jsx"),h("/"),y.transformIndexHtml("/",await et.readFile(it,"utf-8")),rt(y,"/src/runtime/server-entry.jsx")]).then(O=>O.map(b=>b.status==="fulfilled"?b.value:0));m=g}catch(h){t&&console.log("[velu-profile] warmup error:",h?.message)}n(`cold-start warm-up (${m} client modules)`,x),r.ready(`http://localhost:${N}`)})}var Mn,Un,zn,tt,Gn,J,it,qn,Hn,lt=k(()=>{ge();re();De();Se();Ke();F();je();Le();_e();Qe();Mn=w.dirname(jn(import.meta.url)),Un=/\.(css|less|sass|scss|styl|stylus|pcss|postcss)(\?|$)/,zn=new Set(["Google Sans Flex","Google Sans Code","Outfit"]),tt="/@velu-favicon",Gn=e=>String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");J=w.resolve(Mn,".."),it=w.resolve(J,"src","template.html"),qn=[" _ __ __","| | / /__ / /_ __","| | / / _ \\/ / / / /","| |/ / __/ / /_/ /","|___/\\___/_/\\__,_/"],Hn="const F=['\u280B','\u2819','\u2839','\u2838','\u283C','\u2834','\u2826','\u2827','\u2807','\u280F'],M=['Starting Velu','Setting up your preview','Preparing your docs','Warming things up','Almost ready'];let f=0,m=0;const t=Date.now();const C='\\x1b[38;2;220;20;60m',R='\\x1b[0m',D='\\x1b[2m';const d=()=>{const s=(Date.now()-t)/1000|0;process.stdout.write('\\x1b[2K\\r '+C+F[f]+R+' '+M[m]+'\\u2026 '+D+s+'s'+R);f=(f+1)%F.length;};d();setInterval(d,90);setInterval(()=>{if(m<M.length-1)m++;},4000);"});var ct={};de(ct,{default:()=>Xn,runValidate:()=>at});import Kn from"node:fs";import Wn from"node:path";function Zn(e){try{let t=JSON.parse(Kn.readFileSync(Wn.join(e,"velu.json"),"utf-8"));if(!t.navigation||typeof t.navigation!="object")return[];let o=V(t.navigation);return B(o,e).pageEntries}catch{return[]}}async function at(e){let t=ue(e),o=Zn(e),n=await We(e,o),r=[...t,...n],i=!!process.stdout.isTTY;return console.log(ae(r,{color:i})),r.some(s=>s.severity!=="warning"&&s.severity!=="info")?1:0}var Xn,ut=k(()=>{W();se();Le();_e();F();Xn=at});import Pe from"node:path";import E from"node:process";import{readFileSync as Qn}from"node:fs";var[,,ft,pe]=E.argv;function eo(){try{return JSON.parse(Qn(new URL("../package.json",import.meta.url),"utf8")).version}catch{return"unknown"}}async function to(){switch(ft){case"--version":case"-v":case"version":{console.log(eo());break}case"init":{pe||(console.error("Usage: velu init <project-name>"),E.exit(1));let e=pe,t=Pe.resolve(E.cwd(),e),{initProject:o}=await Promise.resolve().then(()=>(Fe(),Ne));await o(t,e);break}case"dev":{let e=Pe.resolve(E.cwd(),pe??"."),{startDevServer:t}=await Promise.resolve().then(()=>(lt(),st));await t(e);break}case"validate":{let e=Pe.resolve(E.cwd(),pe??"."),{runValidate:t}=await Promise.resolve().then(()=>(ut(),ct)),o=await t(e);E.exit(o);break}default:console.log("Usage:"),console.log(" velu init <project-name> scaffold a new docs project"),console.log(" velu dev [dir] start the dev preview server"),console.log(" velu validate [dir] check velu.json + content for problems"),E.exit(ft?1:0)}}to().catch(e=>{console.error(E.env.VELU_DEBUG?e:`Error: ${e.message}`),E.exit(1)});
103
+ </html>`}var F,ht=S(()=>{B();F=e=>String(e??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")});var J,Fe=S(()=>{J=["Callout","Card","CardGroup","Accordion","AccordionGroup","Columns","Field","Prompt","Steps","Step","Tree","Folder","File","Image","CodeBlock","CodeGroup","MethodBadge","ApiPath","TryItBar","ApiField","ApiClient","ApiSidebar"]});import ye from"node:fs";import ae from"node:path";import{fileURLToPath as Jn}from"node:url";import Vn from"iso-639-1";function se(e,t){if(!t)return null;let r=e.indexOf(`"${t}"`);return r===-1?null:e.slice(0,r).split(`
104
+ `).length}function Dn(e,t){return t==null||t<0?null:e.slice(0,t).split(`
105
+ `).length}function Ue(e,t){if(!t)return null;let r=e.indexOf(`"${t}"`);return r===-1?null:e.slice(0,r).split(`
106
+ `).length}function Yn(e,t,r){let n=[];return s(e,t,"",null),n;function o(l){if(l&&l.$ref){let u=l.$ref.replace(/^#\//,"").split("/"),c=r;for(let f of u)c=c?.[f];return c||{}}return l}function i(l){return Array.isArray(l)?"array":l===null?"null":typeof l}function a(l,u){let c=n.length;s(l,u,"",null,!0);let f=n.length===c;return f||(n.length=c),f}function s(l,u,c,f,L){let g=o(u);if(g){if(g.oneOf){g.oneOf.some(d=>a(l,d))||n.push({path:c,key:f,message:"value does not match any allowed shape"});return}if(g.type&&i(l)!==g.type){n.push({path:c,key:f,message:`expected ${g.type}, got ${i(l)}`});return}if(g.type==="string"&&g.minLength!=null&&l.length<g.minLength&&n.push({path:c,key:f,message:"must not be empty"}),g.type==="object"&&i(l)==="object"){for(let d of g.required||[])d in l||n.push({path:c?`${c}.${d}`:d,key:d,message:`missing required "${d}"`});let k=g.properties||{};if(g.additionalProperties===!1)for(let d of Object.keys(l))d in k||n.push({path:c?`${c}.${d}`:d,key:d,message:`unknown field "${d}"`});for(let[d,E]of Object.entries(k))d in l&&s(l[d],E,c?`${c}.${d}`:d,d,L)}g.type==="array"&&Array.isArray(l)&&g.items&&l.forEach((k,d)=>s(k,g.items,`${c}[${d}]`,f,L))}}}function Kn(e){if(typeof e!="string")return!1;let t=e.trim();return/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)||/^(rgb|rgba|hsl|hsla|color|oklch|lab|lch)\(/i.test(t)||/^[a-z][a-z0-9-]*$/i.test(t)}function ve(e){let t=[],r=ae.join(e,"velu.json"),n;try{n=ye.readFileSync(r,"utf-8")}catch(s){return s.code==="ENOENT"?t.push($({category:"config-json",file:"velu.json",title:"No velu.json found",hint:"Run `velu init <name>` to scaffold a project."})):t.push($({category:"config-json",file:"velu.json",title:"Could not read velu.json"})),t}let o;try{o=JSON.parse(n)}catch(s){let l=/position (\d+)/.exec(s.message||""),u=l?Dn(n,Number(l[1])):null;return t.push($({category:"config-json",file:"velu.json",line:u,title:"velu.json is not valid JSON",detail:String(s.message||"").replace(/\s+in JSON.*$/,""),hint:"Check for a trailing comma, a missing quote, or an unclosed brace."})),t}let i=null;try{i=JSON.parse(ye.readFileSync(Hn,"utf-8"))}catch{}if(i)for(let s of Yn(o,i,i)){let l=/^unknown field/.test(s.message);t.push($({category:"config-schema",severity:l?"warning":"error",file:"velu.json",line:se(n,s.key),title:s.path?`${s.path}: ${s.message}`:s.message,hint:l?"Remove it, or check the spelling against the velu.json schema.":""}))}for(let s of["primary","light","dark"]){let l=o.colors?.[s];l!=null&&!Kn(l)&&t.push($({category:"config-schema",severity:"warning",file:"velu.json",line:se(n,s),title:`colors.${s}: "${l}" doesn\u2019t look like a CSS color`,hint:"Use a hex value like #dc143c, an rgb()/hsl() function, or a CSS color name."}))}if(typeof o.favicon=="string"&&o.favicon.trim()){let s=ae.resolve(e,o.favicon.replace(/^\/+/,""));ye.existsSync(s)||t.push($({category:"config-asset",file:"velu.json",line:se(n,"favicon"),title:`favicon not found: ${o.favicon}`,hint:"The path is relative to the project root."}))}let a=ee(o.logo);if(a){let s=new Map;for(let l of["light","dark"]){let u=a[l];u&&s.set(u,[...s.get(u)||[],l])}for(let[l,u]of s)if(!ye.existsSync(ae.resolve(e,l.replace(/^\/+/,"")))){let c=u.length===2?"logo":`logo (${u[0]})`;t.push($({category:"config-asset",file:"velu.json",line:Ue(n,l),title:`${c} not found: ${l}`,hint:"The path is relative to the project root."}))}}if(o.navigation&&typeof o.navigation=="object"){let s;try{s=K(o.navigation)}catch(l){t.push($({category:"config-nav",file:"velu.json",line:se(n,"navigation"),title:"navigation could not be processed",detail:String(l.message||"")})),s=null}if(s){let{pageEntries:l,warnings:u}=W(s,e);for(let c of u){let f=/not found$/.test(c),L=/page "([^"]+)"/.exec(c),g=L?Ue(n,L[1]):null;t.push($({category:"config-nav",severity:f?"error":"warning",file:"velu.json",line:g,title:c,hint:f?"Create the .mdx file, or remove the page from navigation.":""}))}Wn(s,n,t)}}return t}function Wn(e,t,r){let n=new Set,o=i=>{if(!(!i||typeof i!="object")){if(i.language&&!n.has(i.language)){n.add(i.language);let a=String(i.language).toLowerCase();Vn.validate(a)||r.push($({category:"config-nav",severity:"warning",file:"velu.json",line:Ue(t,i.language)||se(t,"language"),title:`"${i.language}" is not a valid ISO 639-1 language code`,hint:'Use a two-letter code like "en", "fr", or "ja".'}))}for(let a of Object.values(i))Array.isArray(a)?a.forEach(o):a&&typeof a=="object"&&o(a)}};o(e)}var qn,Hn,Me=S(()=>{B();ne();me();ue();qn=ae.dirname(Jn(import.meta.url)),Hn=ae.resolve(qn,"..","..","schema","velu.schema.json")});import Zn from"node:fs/promises";import Xn from"node:fs";import V from"node:path";import{fileURLToPath as Qn,pathToFileURL as er}from"node:url";import{compile as tr}from"@mdx-js/mdx";import nr from"remark-frontmatter";import rr from"remark-mdx-frontmatter";import or from"remark-gfm";import ir from"rehype-slug";import{visit as sr}from"unist-util-visit";function ze(){if(be)return be;let e=V.dirname(Qn(import.meta.url)),t=[V.resolve(e,"..","runtime","velu-ui"),V.resolve(e,"..","..","runtime","velu-ui"),V.resolve(e,"..","..","..","velu-ui","src")],r=null;for(let n of t){let o=V.join(n,"lib","component-schemas.js");if(Xn.existsSync(o)){r=o;break}}return be=r?import(er(r).href).then(n=>n.validateProps).catch(()=>null):Promise.resolve(null),be}function ar(e){let t={};for(let r of e.attributes||[])r.type==="mdxJsxAttribute"&&(r.value==null?t[r.name]=!0:typeof r.value=="string"&&(t[r.name]=r.value));return t}function lr(e,t){return()=>r=>{sr(r,n=>{if((n.type==="mdxJsxFlowElement"||n.type==="mdxJsxTextElement")&&typeof n.name=="string"&&/^[A-Z]/.test(n.name)&&!n.name.includes(".")&&e.push({name:n.name,props:ar(n),line:n.position?.start?.line??null,column:n.position?.start?.column??null}),n.type==="mdxjsEsm"&&typeof n.value=="string")for(let o of n.value.matchAll(/\b([A-Z][A-Za-z0-9_]*)\b/g))t.add(o[1])})}}async function cr(e,t){let r=[],n;try{n=await Zn.readFile(t.fileAbsPath,"utf-8")}catch{return r}let o=V.relative(e,t.fileAbsPath).split(V.sep).join("/"),i=[],a=new Set;try{await tr({value:n,path:t.fileAbsPath},{remarkPlugins:[nr,rr,or,Q,lr(i,a)],rehypePlugins:[ir],providerImportSource:"@mdx-js/react"})}catch(c){return r.push(ie(c,{projectDir:e,knownComponents:J,file:o})),r}let s=new Set(J),l=await ze(),u=new Set;for(let c of i)if(!a.has(c.name)){if(!s.has(c.name)){if(u.has(c.name))continue;u.add(c.name),r.push($({category:"unknown-component",file:o,line:c.line,column:c.column,title:`<${c.name}> is not a built-in component`,hint:"Components are built in \u2014 check the spelling and capitalization (you don\u2019t import them).",suggestion:ge(c.name,J)}));continue}if(l){let f=l(c.name,c.props,{checkRequired:!1});f&&r.push($({...f,file:o,line:c.line,column:c.column}))}}return r}async function yt(e,t){let r=t.filter(s=>s.exists),n=[],o=8,i=0;async function a(){for(;i<r.length;){let s=r[i++],l=await cr(e,s);for(let u of l)n.push(u)}}return await Promise.all(Array.from({length:Math.min(o,r.length)},a)),n}var be,Ge=S(()=>{ke();B();Re();Fe()});import{visit as ur}from"unist-util-visit";function pr(e,t){let r=vt(e).replace(/[?#].*$/,""),n=vt(t).replace(/\/+$/,"");return n&&r.toLowerCase().startsWith(n.toLowerCase())?r.slice(n.length).replace(/^\/+/,""):null}function bt(e,t){return()=>(r,n)=>{typeof e=="function"&&ur(r,o=>{if(o.type!=="mdxJsxFlowElement"&&o.type!=="mdxJsxTextElement"||typeof o.name!="string"||!/^[A-Z]/.test(o.name)||o.name.includes("."))return;let i={};for(let s of o.attributes||[])s.type==="mdxJsxAttribute"&&(s.value==null?i[s.name]=!0:typeof s.value=="string"&&(i[s.name]=s.value));let a=e(o.name,i,{checkRequired:!1});if(a){let s=new Error(a.title);throw s.veluIssue={...a,file:pr(n?.path,t),line:o.position?.start?.line??null,column:o.position?.start?.column??null},s.loc={line:s.veluIssue.line,column:s.veluIssue.column},s}})}}var vt,xt=S(()=>{vt=e=>String(e||"").replace(/\\/g,"/")});var Pt={};we(Pt,{startDevServer:()=>Ir});import $t from"node:fs/promises";import q from"node:fs";import fr from"node:http";import{spawn as mr}from"node:child_process";import j from"node:path";import{fileURLToPath as dr}from"node:url";import{createRequire as gr}from"node:module";import hr from"chokidar";import wt from"express";import yr from"@tailwindcss/vite";import vr from"@vitejs/plugin-react";import br from"@mdx-js/rollup";import xr from"remark-frontmatter";import $r from"remark-mdx-frontmatter";import wr from"remark-gfm";import kr from"rehype-slug";import{createServer as Sr,searchForWorkspaceRoot as jr}from"vite";function _r(e){return`<link rel="stylesheet" href="${`https://fonts.googleapis.com/css2?family=${encodeURIComponent(e).replace(/%20/g,"+")}:wght@300;400;500;600;700&display=swap`}" />`}function St(e,t){let r=Ee(e,{color:!!process.stderr.isTTY});console.error(`
107
+ `+r+`
108
+ `),process.env.VELU_DEBUG&&t&&console.error(t)}function Lr(){try{return JSON.parse(q.readFileSync(j.join(Z,"package.json"),"utf8")).version||"unknown"}catch{return"unknown"}}function Cr(e,t){let r=j.resolve(e,".velu"),n=j.resolve(r,".velu-version"),o=null;try{o=q.readFileSync(n,"utf8").trim()}catch{}if(o!==t){if(o!==null)try{q.rmSync(j.join(r,"vite-cache"),{recursive:!0,force:!0}),console.log("[velu] new version detected \u2014 refreshing the preview cache\u2026")}catch{}try{q.mkdirSync(r,{recursive:!0}),q.writeFileSync(n,t)}catch{}}}async function jt(e){try{return await De(e)}catch{return Pe({},j.basename(e))}}async function At(e,t){let r=await e.moduleGraph.getModuleByUrl(t,!0),n=new Map,o=new Set;async function i(a){if(!(!a||o.has(a.url))){if(o.add(a.url),a.id&&Or.test(a.id)){let s=a.url.includes("?")?"&":"?",l=await e.transformRequest(`${a.url}${s}direct`);l?.code&&n.set(a.url,l.code)}for(let s of a.importedModules)await i(s)}}return await i(r),[...n.values()].join(`
109
+ `)}function Rr(e,t){let r=()=>{process.stdout.isTTY&&!process.env.VELU_NO_BELL&&process.stdout.write("\x07")},n=process.stdout.isTTY,o=f=>n&&process.stdout.write(`\x1B]${f}\x1B\\`),i=()=>{o(`0;\u23F3 ${t}`),o("9;4;3;0")},a=()=>{o(`0;${t}`),o("9;4;0;0")};if(n&&process.once("exit",()=>o("9;4;0;0")),i(),!e)return console.log("Starting Velu\u2026"),{ready:f=>{console.log(`Velu ready \u2192 ${f}`),a(),r()}};let s="\x1B[38;2;220;20;60m",l="\x1B[0m";console.log("");for(let f of Er)console.log(`${s}${f}${l}`);console.log("");let u=null;try{u=mr(process.execPath,["-e",Nr],{stdio:["ignore","inherit","ignore"]}),u.on("error",()=>{})}catch{}let c=()=>{if(u){try{u.kill()}catch{}u=null}};return process.once("exit",c),{ready:f=>{c(),process.stdout.write("\x1B[2K\r"),console.log(` \x1B[32m\u2713${l} Velu ready \u2192 \x1B[36m${f}${l}`),a(),r()}}}async function Ir(e){let t=!!process.env.VELU_PROFILE,r=performance.now(),n=(y,m)=>t&&console.log(`[velu-profile] ${y}: ${(performance.now()-m).toFixed(0)}ms`),o=Rr(!!process.stdout.isTTY&&!t,j.basename(e)),i=await jt(e),a=s();function s(){let m=ve(e).filter(v=>v.severity==="error"&&(v.category==="config-json"||v.category==="config-schema"));return m.length&&console.error(`
110
+ `+he(m,{color:!!process.stderr.isTTY})+`
111
+ `),m}let l=e;try{l=q.realpathSync(e)}catch{}let u=0,c=y=>{let m=performance.now();if(m-u<500)return;u=m;let v=ie(y,{projectDir:l,knownComponents:J});St(v,y)};process.on("unhandledRejection",c),process.on("uncaughtException",c);let L=gr(import.meta.url).resolve("@mdx-js/react"),g=j.resolve(Z,"runtime","velu-ui"),k=q.existsSync(g)?g:j.resolve(Z,"..","velu-ui","src"),d=[{find:"@mdx-js/react",replacement:L},{find:/^velu-ui$/,replacement:j.join(k,"index.js")},{find:/^velu-ui\//,replacement:k+"/"}],E=Number(process.env.PORT)||8358,O=await ze();Cr(e,Lr());let x=wt(),R=fr.createServer(x),p=await Sr({root:Z,appType:"custom",logLevel:t?"info":"warn",plugins:[mt(e),br({remarkPlugins:[xr,$r,wr,Q,bt(O,e)],rehypePlugins:[kr],providerImportSource:"@mdx-js/react"}),vr(),yr()],cacheDir:j.resolve(e,".velu","vite-cache"),optimizeDeps:{include:["react","react-dom","react-dom/client","react-router-dom","@mdx-js/react","lucide-react","prism-react-renderer","iso-639-1","github-slugger"],exclude:["tailwindcss","@tailwindcss/oxide","playwright","playwright-core","@apidevtools/swagger-parser"],esbuildOptions:{loader:{".mdx":"jsx"}}},resolve:{alias:d,dedupe:["react","react-dom","@mdx-js/react"]},server:{middlewareMode:!0,fs:{allow:[jr(Z),e,l]},hmr:{server:R}}});n("vite server created",r),x.use(p.middlewares),x.get(kt,async(y,m,v)=>{if(!i.favicon)return m.status(404).end();let h=j.resolve(e,i.favicon.replace(/^\//,""));m.sendFile(h,P=>{P&&m.status(404).end()})});let T=y=>(m,v)=>{let h=i.logo?.[y];if(!h)return v.status(404).end();v.sendFile(j.resolve(e,h.replace(/^\//,"")),P=>{P&&v.status(404).end()})};x.get(le,T("light")),x.get(ce,T("dark")),x.post("/@velu-api-proxy",wt.json({limit:"8mb"}),async(y,m)=>{let{method:v="GET",url:h,headers:P={},body:b}=y.body||{};if(typeof h!="string"||!/^https?:\/\//i.test(h))return m.status(400).json({error:"A valid http(s) target URL is required."});try{let w=await fetch(h,{method:v,headers:P,body:b!=null&&b!==""?b:void 0}),I=await w.text(),H=w.headers.get("content-type")||"",A={};w.headers.forEach((X,$e)=>{A[$e]=X});let M=I;if(/json/i.test(H))try{M=JSON.parse(I)}catch{}m.json({status:w.status,statusText:w.statusText,headers:A,body:M})}catch(w){m.json({error:`Request failed: ${w.message}`})}}),x.use("*",async(y,m,v)=>{let h=y.originalUrl,P=performance.now();if(a.length)return m.status(200).set({"Content-Type":"text/html"}).end(Ie(a,{title:"Fix velu.json to continue"}));try{let b=performance.now(),w=await $t.readFile(Ot,"utf-8");w=await p.transformIndexHtml(h,w),n(`transformIndexHtml ${h}`,b);let I="/src/runtime/server-entry.jsx";b=performance.now();let{render:H}=await p.ssrLoadModule(I);n(`ssrLoadModule ${h} (1st req includes dep pre-bundle)`,b),b=performance.now();let A=await H(h);n(`render ${h}`,b),b=performance.now();let M=await At(p,I);n(`collectSsrCss ${h}`,b);let X=M?`<style data-velu-ssr>${M}</style>`:"",$e=`<style data-velu-config>
112
+ ${Ye(i)}
113
+ </style>`,Nt=Pr.has(i.font.family)?"":_r(i.font.family),Rt=i.favicon?`<link rel="icon" href="${kt}" />`:"",It=[X,$e,Nt,Rt].filter(Boolean).join(`
114
+ `),Ft=w.replace("<!--app-title-->",Tr(i.name)).replace("<!--app-head-->",It).replace("<!--app-html-->",A);m.status(200).set({"Content-Type":"text/html"}).end(Ft),n(`TOTAL ${h}`,P)}catch(b){p.ssrFixStacktrace(b);let w=ie(b,{projectDir:l,knownComponents:J});St(w,b),m.status(200).set({"Content-Type":"text/html"}).end(Ie([w]))}}),hr.watch(e,{ignoreInitial:!0,ignored:/(^|[\\/])(node_modules|\.git|\.velu)([\\/]|$)/,awaitWriteFinish:{stabilityThreshold:100,pollInterval:20}}).on("all",async(y,m)=>{console.log(`[velu-cli] content ${y}: ${j.relative(e,m)}`);let v=j.basename(m)==="velu.json",h=m.endsWith(".mdx"),P=v||h&&(y==="add"||y==="unlink");if(v&&(i=await jt(e),a=s()),P)p.moduleGraph.invalidateAll();else if(h){let b=m.split(j.sep).join("/"),w=p.moduleGraph.getModulesByFile(b);if(w)for(let I of w)p.moduleGraph.invalidateModule(I)}p.ws.send({type:"full-reload"})});async function C(y){let m=new Set,v=12,h=0,P=[],b=()=>h<v?(h+=1,Promise.resolve()):new Promise(A=>P.push(A)).then(()=>{h+=1}),w=()=>{h-=1,P.shift()?.()},I=A=>/[\\/]\.velu[\\/]vite-cache[\\/]|[\\/]deps[\\/]/.test(A)||/[\\/]node_modules[\\/]/.test(A)&&!/velu-ui/.test(A);async function H(A){if(!(!A||m.has(A)||I(A))){m.add(A);try{await b();try{await p.transformRequest(A,{ssr:!1})}finally{w()}let M=await p.moduleGraph.getModuleByUrl(A,!1);M?.importedModules?.size&&await Promise.all([...M.importedModules].map(X=>H(X.url)))}catch{}}}return await H(y),m.size}R.listen(E,async()=>{let y=performance.now(),m=0;try{let{render:v}=await p.ssrLoadModule("/src/runtime/server-entry.jsx");await C("/src/runtime/client-entry.jsx"),typeof p.waitForRequestsIdle=="function"&&await p.waitForRequestsIdle();let[h]=await Promise.allSettled([C("/src/runtime/client-entry.jsx"),v("/"),p.transformIndexHtml("/",await $t.readFile(Ot,"utf-8")),At(p,"/src/runtime/server-entry.jsx")]).then(P=>P.map(b=>b.status==="fulfilled"?b.value:0));m=h}catch(v){t&&console.log("[velu-profile] warmup error:",v?.message)}n(`cold-start warm-up (${m} client modules)`,y),o.ready(`http://localhost:${E}`)})}var Ar,Or,Pr,kt,Tr,Z,Ot,Er,Nr,Tt=S(()=>{ke();ue();dt();Re();ht();B();Fe();Me();Ge();xt();Ar=j.dirname(dr(import.meta.url)),Or=/\.(css|less|sass|scss|styl|stylus|pcss|postcss)(\?|$)/,Pr=new Set(["Google Sans Flex","Google Sans Code","Outfit"]),kt="/@velu-favicon",Tr=e=>String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");Z=j.resolve(Ar,".."),Ot=j.resolve(Z,"src","template.html"),Er=[" _ __ __","| | / /__ / /_ __","| | / / _ \\/ / / / /","| |/ / __/ / /_/ /","|___/\\___/_/\\__,_/"],Nr="const F=['\u280B','\u2819','\u2839','\u2838','\u283C','\u2834','\u2826','\u2827','\u2807','\u280F'],M=['Starting Velu','Setting up your preview','Preparing your docs','Warming things up','Almost ready'];let f=0,m=0;const t=Date.now();const C='\\x1b[38;2;220;20;60m',R='\\x1b[0m',D='\\x1b[2m';const d=()=>{const s=(Date.now()-t)/1000|0;process.stdout.write('\\x1b[2K\\r '+C+F[f]+R+' '+M[m]+'\\u2026 '+D+s+'s'+R);f=(f+1)%F.length;};d();setInterval(d,90);setInterval(()=>{if(m<M.length-1)m++;},4000);"});var Lt={};we(Lt,{default:()=>zr,runValidate:()=>_t});import Fr from"node:fs";import Ur from"node:path";function Mr(e){try{let t=JSON.parse(Fr.readFileSync(Ur.join(e,"velu.json"),"utf-8"));if(!t.navigation||typeof t.navigation!="object")return[];let r=K(t.navigation);return W(r,e).pageEntries}catch{return[]}}async function _t(e){let t=ve(e),r=Mr(e),n=await yt(e,r),o=[...t,...n],i=!!process.stdout.isTTY;return console.log(he(o,{color:i})),o.some(s=>s.severity!=="warning"&&s.severity!=="info")?1:0}var zr,Ct=S(()=>{ne();me();Me();Ge();B();zr=_t});import Be from"node:path";import U from"node:process";import{readFileSync as Gr}from"node:fs";var[,,Et,xe]=U.argv;function Br(){try{return JSON.parse(Gr(new URL("../package.json",import.meta.url),"utf8")).version}catch{return"unknown"}}async function Jr(){switch(Et){case"--version":case"-v":case"version":{console.log(Br());break}case"init":{xe||(console.error("Usage: velu init <project-name>"),U.exit(1));let e=xe,t=Be.resolve(U.cwd(),e),{initProject:r}=await Promise.resolve().then(()=>(qe(),Ve));await r(t,e);break}case"dev":{let e=Be.resolve(U.cwd(),xe??"."),{startDevServer:t}=await Promise.resolve().then(()=>(Tt(),Pt));await t(e);break}case"validate":{let e=Be.resolve(U.cwd(),xe??"."),{runValidate:t}=await Promise.resolve().then(()=>(Ct(),Lt)),r=await t(e);U.exit(r);break}default:console.log("Usage:"),console.log(" velu init <project-name> scaffold a new docs project"),console.log(" velu dev [dir] start the dev preview server"),console.log(" velu validate [dir] check velu.json + content for problems"),U.exit(Et?1:0)}}Jr().catch(e=>{console.error(U.env.VELU_DEBUG?e:`Error: ${e.message}`),U.exit(1)});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veluai/velu",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "type": "module",
5
5
  "bin": "./dist/cli.js",
6
6
  "publishConfig": {
@@ -23,6 +23,7 @@
23
23
  "prepack": "node scripts/build.mjs"
24
24
  },
25
25
  "dependencies": {
26
+ "@apidevtools/swagger-parser": "^10.1.0",
26
27
  "@icons-pack/react-simple-icons": ">=13.0.0 <13.13.0",
27
28
  "@mdx-js/mdx": "^3.1.1",
28
29
  "@mdx-js/react": "^3.1.1",
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useState, useRef, useEffect } from 'react';
2
2
  import resolveIcon from '../lib/resolveIcon.jsx';
3
3
  import Cluster from '../primitives/Cluster.jsx';
4
4
  import MethodBadge from './MethodBadge.jsx';
@@ -46,7 +46,11 @@ export default function ApiClient({
46
46
  label,
47
47
  path = '',
48
48
  description,
49
+ operations = [],
50
+ activeId,
51
+ onSelectOperation,
49
52
  onSend,
53
+ sending = false,
50
54
  onClose,
51
55
  aside,
52
56
  children,
@@ -56,6 +60,29 @@ export default function ApiClient({
56
60
  const key = String(method).toLowerCase();
57
61
  const cls = `velu-api-client velu-api-client--${key} ${className}`.trim();
58
62
 
63
+ // The operation dropdown is interactive only when there's more than one
64
+ // operation to switch between and a handler to call.
65
+ const canSwitch =
66
+ Array.isArray(operations) && operations.length > 1 && typeof onSelectOperation === 'function';
67
+ const [menuOpen, setMenuOpen] = useState(false);
68
+ const opRef = useRef(null);
69
+
70
+ useEffect(() => {
71
+ if (!menuOpen) return undefined;
72
+ const onDown = (e) => {
73
+ if (opRef.current && !opRef.current.contains(e.target)) setMenuOpen(false);
74
+ };
75
+ const onKey = (e) => {
76
+ if (e.key === 'Escape') setMenuOpen(false);
77
+ };
78
+ document.addEventListener('mousedown', onDown);
79
+ document.addEventListener('keydown', onKey);
80
+ return () => {
81
+ document.removeEventListener('mousedown', onDown);
82
+ document.removeEventListener('keydown', onKey);
83
+ };
84
+ }, [menuOpen]);
85
+
59
86
  return (
60
87
  <div className={cls} {...rest}>
61
88
  {/* Close button row — only when shown as a modal (onClose set). */}
@@ -82,20 +109,69 @@ export default function ApiClient({
82
109
  align="flex-start"
83
110
  className="velu-api-client__head"
84
111
  >
85
- <div className="velu-api-client__op">
86
- <MethodBadge method={method} />
87
- {label && (
88
- <span className="velu-api-client__op-label">{label}</span>
112
+ <div className="velu-api-client__op" ref={opRef}>
113
+ {canSwitch ? (
114
+ <button
115
+ type="button"
116
+ className="velu-api-client__op-btn"
117
+ onClick={() => setMenuOpen((v) => !v)}
118
+ aria-haspopup="listbox"
119
+ aria-expanded={menuOpen}
120
+ >
121
+ <MethodBadge method={method} />
122
+ {label && (
123
+ <span className="velu-api-client__op-label">{label}</span>
124
+ )}
125
+ <span className="velu-api-client__op-chevron" aria-hidden="true">
126
+ {resolveIcon('chevron-down', { size: '1em' })}
127
+ </span>
128
+ </button>
129
+ ) : (
130
+ <>
131
+ <MethodBadge method={method} />
132
+ {label && (
133
+ <span className="velu-api-client__op-label">{label}</span>
134
+ )}
135
+ <span className="velu-api-client__op-chevron" aria-hidden="true">
136
+ {resolveIcon('chevron-down', { size: '1em' })}
137
+ </span>
138
+ </>
139
+ )}
140
+ {canSwitch && menuOpen && (
141
+ <ul
142
+ className="velu-api-client__op-menu velu-hide-scrollbar"
143
+ role="listbox"
144
+ >
145
+ {operations.map((o) => (
146
+ <li key={o.id}>
147
+ <button
148
+ type="button"
149
+ role="option"
150
+ aria-selected={o.id === activeId}
151
+ className={`velu-api-client__op-item${
152
+ o.id === activeId ? ' velu-api-client__op-item--active' : ''
153
+ }`}
154
+ onClick={() => {
155
+ onSelectOperation(o.id);
156
+ setMenuOpen(false);
157
+ }}
158
+ >
159
+ <MethodBadge method={o.method} />
160
+ <span className="velu-api-client__op-item-label">
161
+ {o.title}
162
+ </span>
163
+ </button>
164
+ </li>
165
+ ))}
166
+ </ul>
89
167
  )}
90
- <span className="velu-api-client__op-chevron" aria-hidden="true">
91
- {resolveIcon('chevron-down', { size: '1em' })}
92
- </span>
93
168
  </div>
94
169
  <TryItBar
95
170
  method={method}
96
171
  path={path}
97
172
  cta="Send"
98
173
  onTry={onSend}
174
+ loading={sending}
99
175
  className="velu-api-client__bar"
100
176
  />
101
177
  </Cluster>