// @bun
var{defineProperty:Z,getOwnPropertyNames:F,getOwnPropertyDescriptor:K}=Object,L=Object.prototype.hasOwnProperty;function k(v){return this[v]}var Zq=(v)=>{var w=(R??=new WeakMap).get(v),q;if(w)return w;if(w=Z({},"__esModule",{value:!0}),v&&typeof v==="object"||typeof v==="function"){for(var z of F(v))if(!L.call(w,z))Z(w,z,{get:k.bind(v,z),enumerable:!(q=K(v,z))||q.enumerable})}return R.set(v,w),w},R;var x=(v)=>v;function D(v,w){this[v]=x.bind(null,w)}var $q=(v,w)=>{for(var q in w)Z(v,q,{get:w[q],enumerable:!0,configurable:!0,set:D.bind(w,q)})};var y=(v,w)=>()=>(v&&(w=v(v=0)),w);var Gq=import.meta.require;import{existsSync as X,mkdirSync as $}from"fs";import{join as U,dirname as S}from"path";import{execSync as _}from"child_process";async function Bq(v,w={}){let q={success:!0,message:"",files:[],errors:[]},z=w.template||"default",E=U(process.cwd(),v);if(X(E))return q.success=!1,q.message=`Directory ${v} already exists`,q;try{$(E,{recursive:!0});let O=b(z);for(let V of O)$(U(E,V),{recursive:!0});let Q=C(z,v,w);for(let[V,I]of Object.entries(Q)){let J=U(E,V);Y(S(J)),await Bun.write(J,I),q.files.push(V)}if(!w.skipGit)try{_("git init",{cwd:E,stdio:"ignore"}),await Bun.write(U(E,".gitignore"),g()),q.files.push(".gitignore")}catch{q.errors.push("Failed to initialize git repository")}if(!w.skipInstall){let V=w.packageManager||Wq();try{console.log(`
Installing dependencies with ${V}...`),_(`${V} install`,{cwd:E,stdio:"inherit"})}catch{q.errors.push("Failed to install dependencies")}}q.message=`Created project: ${v}`,console.log(`
\u2705 ${q.message}

Next steps:
  cd ${v}
  ${w.packageManager||"bun"} run dev
`)}catch(O){q.success=!1,q.message=`Failed to create project: ${O}`}return q}function b(v){let w=["pages","components","layouts","partials","public"];switch(v){case"minimal":return["src","public"];case"full":return[...w,"src/stores","src/api","src/i18n","src/utils","test"];case"blog":return[...w,"src/posts","src/utils"];case"dashboard":return[...w,"src/stores","src/api","src/utils"];case"landing":return[...w,"src/sections"];default:return[...w,"src/stores"]}}function C(v,w,q){let z={};if(z["package.json"]=P(w,v,q),z["stx.config.ts"]=f(v,q),z["README.md"]=c(w,v),q.typescript!==!1)z["tsconfig.json"]=u();switch(v){case"minimal":z["src/index.stx"]=m();break;case"blog":z["pages/index.stx"]=i(),z["pages/[slug].stx"]=a(),z["layouts/app.stx"]=n(),z["components/PostCard.stx"]=s();break;case"dashboard":z["pages/index.stx"]=o(),z["pages/settings.stx"]=t(),z["layouts/app.stx"]=e(),z["components/Sidebar.stx"]=qq(),z["components/StatsCard.stx"]=vq(),z["src/stores/dashboard.ts"]=wq();break;case"landing":z["pages/index.stx"]=zq(),z["layouts/app.stx"]=Eq(),z["src/sections/Hero.stx"]=Oq(),z["src/sections/Features.stx"]=Qq(),z["src/sections/Pricing.stx"]=Uq(),z["components/Button.stx"]=Vq();break;case"full":z["pages/index.stx"]=M(),z["pages/about.stx"]=p(),z["layouts/app.stx"]=A(),z["components/Header.stx"]=H(),z["components/Footer.stx"]=B(),z["src/stores/app.ts"]=T(),z["src/i18n/en.json"]=l("en"),z["test/example.test.ts"]=r();break;default:z["pages/index.stx"]=M(),z["layouts/app.stx"]=A(),z["components/Header.stx"]=H(),z["components/Footer.stx"]=B(),z["src/stores/app.ts"]=T()}return z}async function Tq(v,w={}){let q={success:!0,message:"",files:[],errors:[]},z=w.dir||"components",E=G(v),O=U(z,`${E}.stx`);if(await Bun.file(O).exists()&&!w.force)return q.success=!1,q.message=`Component ${E} already exists. Use --force to overwrite.`,q;try{Y(z);let Q=N(E,w);await Bun.write(O,Q),q.files.push(O),q.message=`Created component: ${O}`,console.log(`\u2705 ${q.message}`)}catch(Q){q.success=!1,q.message=`Failed to create component: ${Q}`}return q}async function Iq(v,w={}){let q={success:!0,message:"",files:[],errors:[]},z=w.dir||"pages",E=v.toLowerCase().replace(/\s+/g,"-"),O=U(z,`${E}.stx`);if(await Bun.file(O).exists()&&!w.force)return q.success=!1,q.message=`Page ${E} already exists. Use --force to overwrite.`,q;try{Y(z);let Q=j(E,w);await Bun.write(O,Q),q.files.push(O),q.message=`Created page: ${O}`,console.log(`\u2705 ${q.message}`)}catch(Q){q.success=!1,q.message=`Failed to create page: ${Q}`}return q}async function Fq(v,w={}){let q={success:!0,message:"",files:[],errors:[]},z=w.dir||"src/stores",E=Xq(v),O=U(z,`${E}.ts`);if(await Bun.file(O).exists()&&!w.force)return q.success=!1,q.message=`Store ${E} already exists. Use --force to overwrite.`,q;try{Y(z);let Q=h(E,w);await Bun.write(O,Q),q.files.push(O),q.message=`Created store: ${O}`,console.log(`\u2705 ${q.message}`)}catch(Q){q.success=!1,q.message=`Failed to create store: ${Q}`}return q}async function Kq(v,w={}){let q={success:!0,message:"",files:[],errors:[]},z=w.dir||"layouts",E=v.toLowerCase().replace(/\s+/g,"-"),O=U(z,`${E}.stx`);if(await Bun.file(O).exists()&&!w.force)return q.success=!1,q.message=`Layout ${E} already exists. Use --force to overwrite.`,q;try{Y(z);let Q=d(E,w);await Bun.write(O,Q),q.files.push(O),q.message=`Created layout: ${O}`,console.log(`\u2705 ${q.message}`)}catch(Q){q.success=!1,q.message=`Failed to create layout: ${Q}`}return q}function N(v,w){let q=[];if(q.push(`{{-- Component: ${v} --}}`),w.props!==!1)q.push(`<script>
// Props
const title = props.title || '${v}'
const variant = props.variant || 'default'
</script>
`);if(q.push(`<div class="${W(v)} ${W(v)}--{{ variant }}">
  <h3>{{ title }}</h3>
  <div class="${W(v)}__content">
    {{ slot }}
  </div>
</div>`),w.styles!==!1)q.push(`
<style scoped>
.${W(v)} {
  padding: 1rem;
  border-radius: 8px;
  background: #f8f9fa;
}

.${W(v)}--primary {
  border-left: 3px solid #3498db;
}

.${W(v)}--success {
  border-left: 3px solid #2ecc71;
}

.${W(v)}__content {
  margin-top: 0.5rem;
}
</style>`);return q.join(`
`)}function j(v,w){let q=G(v.replace(/-/g," ")),z=[];if(z.push(`<script>
const title = '${q}'
const description = 'Page description'
</script>
`),w.layout)z.push(`@layout('${w.layout}')
`);if(w.dynamic)z.push(`{{-- Dynamic route: /pages/[${v}].stx --}}
{{-- Access params via props.params --}}
`);return z.push(`@section('content')
<div class="page-${v}">
  <h1>{{ title }}</h1>
  <p>{{ description }}</p>
</div>
@endsection`),z.join(`
`)}function h(v,w){let q=`${v}Store`,z=`${G(v)}State`,E=`import { defineStore } from 'stx'

interface ${z} {
  // Add your state properties here
  count: number
  loading: boolean
}

export const ${q} = defineStore('${v}', {
  state: (): ${z} => ({
    count: 0,
    loading: false,
  }),

  getters: {
    doubleCount(): number {
      return this.count * 2
    },
  },
`;if(w.actions!==!1)E+=`
  actions: {
    increment() {
      this.count++
    },

    decrement() {
      this.count--
    },

    async fetchData() {
      this.loading = true
      try {
        // Add your async logic here
        await new Promise(resolve => setTimeout(resolve, 1000))
      }
finally {
        this.loading = false
      }
    },
  },
`;if(w.persist)E+=`
  persist: {
    enabled: true,
    strategies: [
      { key: '${v}', storage: localStorage },
    ],
  },
`;return E+=`})
`,E}function d(v,w){let q=`<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>@yield('title', 'My App')</title>
  @yield('head')
  <style>
    * { box-sizing: border-box; margin: 0; padding: 0; }
    body {
      font-family: system-ui, sans-serif;
      min-height: 100vh;
      display: flex;
      flex-direction: column;
    }
    main {
      flex: 1;
      padding: 2rem;
      max-width: 1200px;
      margin: 0 auto;
      width: 100%;
    }
  </style>
  @yield('styles')
</head>
<body>
`;if(w.nav!==!1)q+=`  <header class="header">
    <nav class="nav">
      <a href="/" class="nav__logo">Logo</a>
      <div class="nav__links">
        <a href="/">Home</a>
        <a href="/about">About</a>
        <a href="/contact">Contact</a>
      </div>
    </nav>
  </header>

`;if(q+=`  <main>
    {{ slot }}
  </main>

`,w.footer!==!1)q+=`  <footer class="footer">
    <p>&copy; {{ new Date().getFullYear() }} My App. All rights reserved.</p>
  </footer>

`;return q+=`  @yield('scripts')
</body>
</html>`,q}function P(v,w,q){let z={name:v,version:"0.0.1",type:"module",scripts:{dev:"stx dev pages/index.stx",build:"stx build",preview:"stx serve dist"},dependencies:{stx:"latest"},devDependencies:{}};if(q.typescript!==!1)z.devDependencies.typescript="^5.0.0";if(q.tailwind)z.devDependencies.tailwindcss="^3.0.0";if(w==="full")z.scripts.test="bun test",z.scripts.lint="bun run lint";return JSON.stringify(z,null,2)}function f(v,w){return`import { defineConfig } from 'stx'

export default defineConfig({
  // Template directories
  partialsDir: 'partials',
  componentsDir: 'components',
  layoutsDir: 'layouts',
  defaultLayout: 'app',

  // Development
  debug: process.env.NODE_ENV !== 'production',
  cache: process.env.NODE_ENV === 'production',

  // Features
  a11y: { enabled: true },
  seo: { enabled: true },
${w.pwa?`  pwa: { enabled: true },
`:""}
  // Analytics (configure when ready)
  // analytics: { enabled: true, driver: 'fathom', fathom: { siteId: 'YOUR_SITE_ID' } },
})
`}function u(){return JSON.stringify({compilerOptions:{target:"ESNext",module:"ESNext",moduleResolution:"bundler",strict:!0,skipLibCheck:!0,esModuleInterop:!0,types:["bun-types"]},include:["src/**/*","test/**/*"]},null,2)}function c(v,w){return`# ${v}

A stx project created with the \`${w}\` template.

## Getting Started

\`\`\`bash
# Start development server
bun run dev

# Build for production
bun run build

# Preview production build
bun run preview
\`\`\`

## Project Structure

\`\`\`
src/
\u251C\u2500\u2500 pages/       # Page components (file-based routing)
\u251C\u2500\u2500 components/  # Reusable components
\u251C\u2500\u2500 layouts/     # Layout templates
\u251C\u2500\u2500 stores/      # State management
\u2514\u2500\u2500 public/      # Static assets
\`\`\`

## Learn More

- [stx Documentation](https://stx.dev/docs)
- [stx GitHub](https://github.com/stacksjs/stx)
`}function g(){return`# Dependencies
node_modules/
.bun/

# Build
dist/
.stx/

# IDE
.idea/
.vscode/
*.swp
*.swo

# OS
.DS_Store
Thumbs.db

# Environment
.env
.env.local
.env.*.local

# Logs
*.log
`}function m(){return`<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Welcome to stx</title>
  <style>
    body { font-family: system-ui; max-width: 600px; margin: 100px auto; text-align: center; }
    h1 { color: #333; }
  </style>
</head>
<body>
  <h1>Welcome to stx</h1>
  <p>Edit <code>src/index.stx</code> to get started.</p>
</body>
</html>
`}function M(){return`<script>
const title = 'Welcome to stx'
const features = [
  { icon: '\u26A1', name: 'Fast', desc: 'Built on Bun for blazing speed' },
  { icon: '\uD83C\uDFA8', name: 'Beautiful', desc: 'Blade-style syntax you know and love' },
  { icon: '\uD83D\uDEE0', name: 'Powerful', desc: 'Full-featured component system' },
]
</script>

@section('title')
{{ title }}
@endsection

@section('content')
<div class="hero">
  <h1>{{ title }}</h1>
  <p>A modern UI framework with Laravel Blade syntax</p>
</div>

<div class="features">
  @foreach(features as feature)
  <div class="feature">
    <span class="feature__icon">{{ feature.icon }}</span>
    <h3>{{ feature.name }}</h3>
    <p>{{ feature.desc }}</p>
  </div>
  @endforeach
</div>
@endsection
`}function p(){return`<script>
const title = 'About'
</script>

@section('title')
{{ title }}
@endsection

@section('content')
<h1>{{ title }}</h1>
<p>This is the about page.</p>
@endsection
`}function A(){return`<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>@yield('title', 'My App')</title>
  @yield('head')
  <style>
    * { box-sizing: border-box; margin: 0; padding: 0; }
    body { font-family: system-ui; color: #333; line-height: 1.6; }
    .container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }
  </style>
  @yield('styles')
</head>
<body>
  @component('Header')@endcomponent
  <main class="container">
    {{ slot }}
  </main>
  @component('Footer')@endcomponent
  @yield('scripts')
</body>
</html>
`}function H(){return`<header class="header">
  <nav class="nav container">
    <a href="/" class="logo">stx</a>
    <div class="nav-links">
      <a href="/">Home</a>
      <a href="/about">About</a>
    </div>
  </nav>
</header>

<style scoped>
.header { background: #2c3e50; padding: 1rem 0; }
.nav { display: flex; justify-content: space-between; align-items: center; }
.logo { color: white; font-weight: bold; text-decoration: none; font-size: 1.25rem; }
.nav-links a { color: rgba(255,255,255,0.8); margin-left: 1.5rem; text-decoration: none; }
.nav-links a:hover { color: white; }
</style>
`}function B(){return`<footer class="footer">
  <div class="container">
    <p>&copy; {{ new Date().getFullYear() }} Built with stx</p>
  </div>
</footer>

<style scoped>
.footer { background: #f8f9fa; padding: 2rem 0; margin-top: 4rem; text-align: center; color: #666; }
</style>
`}function T(){return`import { defineStore } from 'stx'

interface AppState {
  theme: 'light' | 'dark'
  sidebarOpen: boolean
}

export const appStore = defineStore('app', {
  state: (): AppState => ({
    theme: 'light',
    sidebarOpen: true,
  }),

  actions: {
    toggleTheme() {
      this.theme = this.theme === 'light' ? 'dark' : 'light'
    },
    toggleSidebar() {
      this.sidebarOpen = !this.sidebarOpen
    },
  },

  persist: {
    enabled: true,
    strategies: [{ key: 'app-preferences', storage: localStorage }],
  },
})
`}function l(v){return JSON.stringify({common:{welcome:"Welcome",home:"Home",about:"About",contact:"Contact"},messages:{loading:"Loading...",error:"An error occurred"}},null,2)}function r(){return`import { describe, expect, it } from 'bun:test'

describe('Example', () => {
  it('should work', () => {
    expect(1 + 1).toBe(2)
  })
})
`}function i(){return"<!-- Blog index -->"}function a(){return"<!-- Blog post -->"}function n(){return`<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>@yield('title', 'My Blog')</title>
  @yield('head')
  <style>
    * { box-sizing: border-box; margin: 0; padding: 0; }
    body { font-family: system-ui, sans-serif; color: #333; line-height: 1.8; }
    .container { max-width: 800px; margin: 0 auto; padding: 0 1rem; }
    .blog-header { background: #1a1a2e; color: white; padding: 1.5rem 0; }
    .blog-header nav { display: flex; justify-content: space-between; align-items: center; }
    .blog-header a { color: rgba(255,255,255,0.8); text-decoration: none; margin-left: 1.5rem; }
    .blog-header a:hover { color: white; }
    .blog-header .logo { font-weight: bold; font-size: 1.25rem; color: white; margin-left: 0; }
    .blog-footer { background: #f8f9fa; padding: 2rem 0; margin-top: 4rem; text-align: center; color: #666; }
  </style>
  @yield('styles')
</head>
<body>
  <header class="blog-header">
    <nav class="container">
      <a href="/" class="logo">My Blog</a>
      <div>
        <a href="/">Home</a>
        <a href="/about">About</a>
      </div>
    </nav>
  </header>
  <main class="container" style="padding-top: 2rem;">
    {{ slot }}
  </main>
  <footer class="blog-footer">
    <div class="container">
      <p>&copy; {{ new Date().getFullYear() }} My Blog. All rights reserved.</p>
    </div>
  </footer>
  @yield('scripts')
</body>
</html>`}function s(){return"<!-- Post card -->"}function o(){return"<!-- Dashboard index -->"}function t(){return"<!-- Settings -->"}function e(){return`<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>@yield('title', 'Dashboard')</title>
  @yield('head')
  <style>
    * { box-sizing: border-box; margin: 0; padding: 0; }
    body { font-family: system-ui, sans-serif; color: #333; min-height: 100vh; display: flex; flex-direction: column; }
    .dash-header { background: #2c3e50; color: white; padding: 1rem 1.5rem; display: flex; justify-content: space-between; align-items: center; }
    .dash-header .logo { font-weight: bold; font-size: 1.25rem; color: white; text-decoration: none; }
    .dash-header nav a { color: rgba(255,255,255,0.8); text-decoration: none; margin-left: 1.5rem; }
    .dash-body { display: flex; flex: 1; }
    .dash-sidebar { width: 240px; background: #34495e; color: white; padding: 1.5rem; }
    .dash-sidebar a { color: rgba(255,255,255,0.8); text-decoration: none; display: block; padding: 0.5rem 0; }
    .dash-sidebar a:hover { color: white; }
    .dash-content { flex: 1; padding: 2rem; background: #f5f6fa; }
  </style>
  @yield('styles')
</head>
<body>
  <header class="dash-header">
    <a href="/" class="logo">Dashboard</a>
    <nav>
      <a href="/settings">Settings</a>
    </nav>
  </header>
  <div class="dash-body">
    @yield('sidebar')
    <main class="dash-content">
      {{ slot }}
    </main>
  </div>
  @yield('scripts')
</body>
</html>`}function qq(){return"<!-- Sidebar -->"}function vq(){return"<!-- Stats card -->"}function wq(){return"// Dashboard store"}function zq(){return"<!-- Landing page -->"}function Eq(){return`<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>@yield('title', 'Welcome')</title>
  @yield('head')
  <style>
    * { box-sizing: border-box; margin: 0; padding: 0; }
    body { font-family: system-ui, sans-serif; color: #333; line-height: 1.6; }
    .landing-header { position: fixed; top: 0; width: 100%; background: rgba(255,255,255,0.95); backdrop-filter: blur(8px); padding: 1rem 2rem; display: flex; justify-content: space-between; align-items: center; z-index: 100; border-bottom: 1px solid #eee; }
    .landing-header .logo { font-weight: bold; font-size: 1.25rem; color: #333; text-decoration: none; }
    .landing-header nav a { color: #555; text-decoration: none; margin-left: 1.5rem; }
    .landing-header nav a:hover { color: #000; }
    .landing-footer { background: #1a1a2e; color: rgba(255,255,255,0.7); padding: 3rem 2rem; text-align: center; }
  </style>
  @yield('styles')
</head>
<body>
  <header class="landing-header">
    <a href="/" class="logo">Brand</a>
    <nav>
      <a href="#features">Features</a>
      <a href="#pricing">Pricing</a>
      <a href="#contact">Contact</a>
    </nav>
  </header>
  <main>
    {{ slot }}
  </main>
  <footer class="landing-footer">
    <p>&copy; {{ new Date().getFullYear() }} Brand. All rights reserved.</p>
  </footer>
  @yield('scripts')
</body>
</html>`}function Oq(){return"<!-- Hero section -->"}function Qq(){return"<!-- Features -->"}function Uq(){return"<!-- Pricing -->"}function Vq(){return"<!-- Button -->"}function Y(v){if(!X(v))$(v,{recursive:!0})}function Wq(){if(X("bun.lockb"))return"bun";if(X("pnpm-lock.yaml"))return"pnpm";if(X("yarn.lock"))return"yarn";return"bun"}function G(v){return v.replace(/[-_\s]+(.)?/g,(w,q)=>q?q.toUpperCase():"").replace(/^./,(w)=>w.toUpperCase())}function Xq(v){return v.replace(/[-_\s]+(.)?/g,(w,q)=>q?q.toUpperCase():"").replace(/^./,(w)=>w.toLowerCase())}function W(v){return v.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}var Hq;var Yq=y(()=>{Hq={default:{description:"Standard stx project with pages, components, and stores",features:["Pages","Components","Layouts","Stores","Dev server"]},minimal:{description:"Minimal setup with just the essentials",features:["Single page","Basic styles"]},full:{description:"Full-featured project with all stx capabilities",features:["Pages","Components","Layouts","Stores","API routes","PWA","i18n","Testing"]},blog:{description:"Blog template with markdown support",features:["Blog layout","Post pages","Tags","RSS feed","Markdown"]},dashboard:{description:"Admin dashboard template",features:["Sidebar","Charts","Tables","Forms","Auth pages"]},landing:{description:"Marketing landing page template",features:["Hero section","Features","Pricing","CTA","Contact form"]}}});Yq();export{Bq as createProject,Fq as addStore,Iq as addPage,Kq as addLayout,Tq as addComponent,Hq as PROJECT_TEMPLATES};
