// @bun
var{defineProperty:M,getOwnPropertyNames:R,getOwnPropertyDescriptor:W}=Object,X=Object.prototype.hasOwnProperty;function Y(A){return this[A]}var B=(A)=>{var j=(P??=new WeakMap).get(A),H;if(j)return j;if(j=M({},"__esModule",{value:!0}),A&&typeof A==="object"||typeof A==="function"){for(var b of R(A))if(!X.call(j,b))M(j,b,{get:Y.bind(A,b),enumerable:!(H=W(A,b))||H.enumerable})}return P.set(A,j),j},P;var Z=(A)=>A;function _(A,j){this[A]=Z.bind(null,j)}var I=(A,j)=>{for(var H in j)M(A,H,{get:j[H],enumerable:!0,configurable:!0,set:_.bind(j,H)})};var T=(A,j)=>()=>(A&&(j=A(A=0)),j);var U=import.meta.require;import N from"fs";import O from"path";async function C(A,j,H={}){let b=H.outDir||O.join(A.root,".stx","docs");await N.promises.mkdir(b,{recursive:!0});let G=$(j);await N.promises.writeFile(O.join(b,"README.md"),G);for(let J of j){let K=A.storyFiles.find((Q)=>Q.fileName.replace(".story","")===J.name),L=q(J,K,H);await N.promises.writeFile(O.join(b,`${J.name}.md`),L)}}function $(A){let j=[];j.push("# Component Documentation"),j.push(""),j.push("This documentation is auto-generated from component source files."),j.push(""),j.push("## Components"),j.push("");let H=new Map,b=[];for(let G of A)if(G.category){let J=H.get(G.category)||[];J.push(G),H.set(G.category,J)}else b.push(G);for(let[G,J]of H){j.push(`### ${G}`),j.push("");for(let K of J)j.push(`- [${K.name}](./${K.name}.md) - ${K.description||"No description"}`);j.push("")}if(b.length>0){if(H.size>0)j.push("### Other"),j.push("");for(let G of b)j.push(`- [${G.name}](./${G.name}.md) - ${G.description||"No description"}`);j.push("")}return j.join(`
`)}function q(A,j,H={}){let b=[];if(b.push(`# ${A.name}`),b.push(""),A.description)b.push(A.description),b.push("");if(A.tags&&A.tags.length>0)b.push(`**Tags:** ${A.tags.join(", ")}`),b.push("");if(A.props.length>0){b.push("## Props"),b.push(""),b.push("| Name | Type | Required | Default | Description |"),b.push("|------|------|----------|---------|-------------|");for(let G of A.props){let J=G.required?"\u2713":"",K=G.default!==void 0?`\`${JSON.stringify(G.default)}\``:"-",L=G.description||"-";b.push(`| ${G.name} | \`${G.type}\` | ${J} | ${K} | ${L} |`)}b.push("")}if(A.slots.length>0){b.push("## Slots"),b.push(""),b.push("| Name | Description |"),b.push("|------|-------------|");for(let G of A.slots){let J=G.description||"-";b.push(`| ${G.name} | ${J} |`)}b.push("")}if(A.dependencies.length>0){b.push("## Dependencies"),b.push(""),b.push("This component uses the following components:"),b.push("");for(let G of A.dependencies)b.push(`- ${G}`);b.push("")}if(A.cssClasses.length>0)b.push("## CSS Classes"),b.push(""),b.push("The following CSS classes are used:"),b.push(""),b.push("```"),b.push(A.cssClasses.join(" ")),b.push("```"),b.push("");if(H.includeStories&&j?.story){b.push("## Examples"),b.push("");for(let G of j.story.variants)if(b.push(`### ${G.title}`),b.push(""),G.source)b.push("```html"),b.push(G.source),b.push("```"),b.push("")}return b.push("## Usage"),b.push(""),b.push("```html"),b.push(w(A)),b.push("```"),b.push(""),b.join(`
`)}function w(A){let j=A.props.filter((G)=>G.required||G.default!==void 0).map((G)=>{if(G.type==="boolean")return G.default?G.name:"";if(G.type==="string")return`${G.name}="${G.default||"value"}"`;return`:${G.name}="${JSON.stringify(G.default)}"`}).filter(Boolean).join(" "),H=A.slots.length>0,b=A.slots.find((G)=>G.name==="default");if(H&&b)return`<${A.name} ${j}>
  Content goes here
</${A.name}>`;return`<${A.name} ${j} />`}function D(A){let j=A.map((H)=>({name:H.name,description:H.description,category:H.category,tags:H.tags,props:H.props.map((b)=>({name:b.name,type:b.type,required:b.required,default:b.default,description:b.description})),slots:H.slots.map((b)=>({name:b.name,description:b.description}))}));return JSON.stringify(j,null,2)}function F(A){let j={colors:new Set,spacing:new Set,typography:new Set,borders:new Set,shadows:new Set};for(let H of A)for(let b of H.cssClasses){if(b.match(/^(?:text|bg|border|fill|stroke)-/))j.colors.add(b);if(b.match(/^(?:p|m|gap|space)-/))j.spacing.add(b);if(b.match(/^(?:text|font|leading|tracking)-/))j.typography.add(b);if(b.match(/^(?:border|rounded)-/))j.borders.add(b);if(b.match(/^shadow/))j.shadows.add(b)}return{colors:Array.from(j.colors),spacing:Array.from(j.spacing),typography:Array.from(j.typography),borders:Array.from(j.borders),shadows:Array.from(j.shadows)}}export{C as generateStoryDocs,$ as generateDocsIndex,q as generateComponentDocs,D as generateComponentCatalog,F as exportDesignTokens};
