local M = {}

local function fallback(value, default_value)
  if value == nil or value == '' then
    return default_value
  end
  return value
end

function M.build_blueprint(input)
  local name = fallback(input.project_name, "starter-app")
  local runtime = fallback(input.runtime, "web")
  local description = fallback(input.description, "Generated by Codegen Studio")

  local files = {
    {
      path = name .. "/README.md",
      content = "# " .. name .. "\n\n" .. description .. "\n"
    },
    {
      path = name .. "/package.json",
      content = "{\n  \"name\": \"" .. name .. "\",\n  \"private\": true\n}\n"
    },
    {
      path = name .. "/src/app/page.tsx",
      content = "export default function Home() {\n  return <div>" .. name .. "</div>\n}\n"
    }
  }

  return {
    name = name,
    runtime = runtime,
    description = description,
    files = files
  }
end

return M
