"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.STATIC_STARTER_HTML = void 0;
exports.ensureStaticStarterCanvas = ensureStaticStarterCanvas;
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const logger_1 = require("../utils/logger");
const log = (0, logger_1.createLogger)('staticStarter');
/**
 * Minimal, dependency-free landing page written into an empty static workspace
 * so the visual editor has a real canvas to render — and the user has an actual
 * file on disk to save visual edits to.
 */
exports.STATIC_STARTER_HTML = `<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>New Rivet project</title>
    <style>
      * { box-sizing: border-box; margin: 0; padding: 0; }
      html, body { height: 100%; }
      body {
        font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica,
          Arial, sans-serif;
        -webkit-font-smoothing: antialiased;
        background: #f3ede3;
        color: #1a1a17;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
      }
      header { padding: 28px clamp(24px, 6vw, 56px); }
      .wordmark {
        display: inline-flex;
        align-items: center;
        gap: 10px;
        font-weight: 800;
        font-size: 19px;
        letter-spacing: -0.02em;
      }
      .wordmark .dot {
        width: 13px;
        height: 13px;
        border-radius: 3px;
        background: #ff3300;
        box-shadow: 0 0 0 4px rgba(255, 90, 30, 0.18);
      }
      main {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        padding: 24px clamp(24px, 6vw, 56px) 72px;
      }
      .eyebrow {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        font-size: 12.5px;
        font-weight: 600;
        letter-spacing: 0.05em;
        text-transform: uppercase;
        color: #a4441f;
        background: rgba(255, 90, 30, 0.1);
        border: 1px solid rgba(255, 90, 30, 0.22);
        padding: 6px 14px;
        border-radius: 999px;
        margin-bottom: 26px;
      }
      .eyebrow .pulse {
        width: 7px;
        height: 7px;
        border-radius: 50%;
        background: #ff3300;
      }
      h1 {
        font-size: clamp(34px, 6vw, 60px);
        line-height: 1.05;
        letter-spacing: -0.035em;
        font-weight: 820;
        max-width: 16ch;
      }
      h1 .accent { color: #ff3300; }
      p {
        margin-top: 20px;
        font-size: clamp(15px, 1.8vw, 19px);
        line-height: 1.55;
        max-width: 46ch;
        color: #54504a;
      }
      footer {
        padding: 24px clamp(24px, 6vw, 56px);
        text-align: center;
        font-size: 13px;
        color: #8c877f;
      }
    </style>
  </head>
  <body>
    <header>
      <span class="wordmark"><span class="dot"></span>Rivet</span>
    </header>
    <main>
      <span class="eyebrow"><span class="pulse"></span>Empty project</span>
      <h1>Your <span class="accent">blank canvas</span></h1>
      <p>Point and click to edit this page in Rivet, or ask Claude to build something here.</p>
    </main>
    <footer>Make it yours.</footer>
  </body>
</html>
`;
/**
 * Ensure an empty static workspace has an `index.html` for the visual editor to
 * render. Static mode serves `index.html` at the root, so a truly empty folder
 * opens to a blank / 404 page with nothing to point-and-click. Writing a
 * minimal starter makes "open rivet on an empty folder" self-contained instead
 * of depending on the agent improvising a file.
 *
 * No-op when:
 *  - an `index.html` already exists (HTML-only project — never clobber), or
 *  - the folder is a `.rivet` history workspace (opened for browsing past
 *    variants, not as a blank canvas).
 *
 * Returns true iff a starter was written. Best-effort: a write failure is
 * logged and swallowed so it can't block opening the editor.
 */
function ensureStaticStarterCanvas(projectPath) {
    try {
        if (fs_1.default.existsSync(path_1.default.join(projectPath, 'index.html')))
            return false;
        if (fs_1.default.existsSync(path_1.default.join(projectPath, '.rivet')))
            return false;
        fs_1.default.writeFileSync(path_1.default.join(projectPath, 'index.html'), exports.STATIC_STARTER_HTML, 'utf8');
        log.info(`Wrote starter index.html into empty static workspace: ${projectPath}`);
        return true;
    }
    catch (err) {
        log.warn(`Failed to write starter index.html at ${projectPath}:`, err);
        return false;
    }
}
//# sourceMappingURL=staticStarter.js.map