← Notes results

Notes

LFM2.5 2.6B GGUF · typescript

Initial view of Notes

Browser check: Artifact runtime error. This is a technical check, not a quality review.

Reviews & generation details

Reviews

No human review yet. Unreviewed does not mean unsuccessful.

Generation context

Imported historical artifact. Its exact original instructions and lineage are not known.

Generation prompt · exact text unavailable

See the current prompt for reference. It may differ from the instructions used to generate this artifact.

Inspect original source 7,067 bytes · SHA-256 cd7daa452d03
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Notes</title>
<style>
</style>
</head>
<body>
<div id="app"></div>
<script>
(function () {
'use strict';
var __mods = {};
var __cache = {};
var __map = {"src/main.ts":{"./state":"src/state.ts"}};
function __require(id) {
  if (__cache[id]) return __cache[id].exports;
  var module = __cache[id] = { exports: {} };
  var factory = __mods[id];
  if (!factory) throw new Error("Module not found: " + id);
  factory(module.exports, function (spec) {
    var target = (__map[id] && __map[id][spec]) || spec;
    return __require(target);
  }, module);
  return module.exports;
}

// ── module: src/main.ts ──
__mods["src/main.ts"] = function (exports, require, module) {
"use strict";
// Main entry point for the Notes Application
// Initializes the app, sets up the UI, and starts the event loop.
Object.defineProperty(exports, "__esModule", { value: true });
const state_1 = require("./state");
// Create the application instance
const app = new state_1.App();
// Initialize the app
app.init();
// Start the main loop
app.start();
};

// ── module: src/state.ts ──
__mods["src/state.ts"] = function (exports, require, module) {
"use strict";
// ── state.ts ──
// Central data model for the Notes Application
// All state is persisted to localStorage and is the single source of truth.
Object.defineProperty(exports, "__esModule", { value: true });
exports.createAppState = createAppState;
exports.loadState = loadState;
exports.saveState = saveState;
exports.addTag = addTag;
exports.removeTag = removeTag;
exports.getTagById = getTagById;
exports.addNoteToNotebook = addNoteToNotebook;
exports.moveNote = moveNote;
exports.deleteNote = deleteNote;
exports.restoreNoteFromTrash = restoreNoteFromTrash;
exports.getSearchResults = getSearchResults;
function createAppState() {
    const tags = [
        { id: "todo", name: "Todo", color: "#6C8EBF" },
        { id: "idea", name: "Idea", color: "#FFB347" },
        { id: "reference", name: "Reference", color: "#4A90D9" },
    ];
    const notebooks = [
        {
            id: "n1",
            name: "Work",
            color: "#E8E0D5",
            notes: [],
            isCollapsed: false,
            isPinned: false,
        },
        {
            id: "n2",
            name: "Personal",
            color: "#D4E6F1",
            notes: [],
            isCollapsed: false,
            isPinned: false,
        },
    ];
    return {
        notebooks,
        tags,
        currentNotebookId: null,
        currentNoteId: null,
        searchQuery: "",
        sortOrder: "modified",
        undoStack: [],
        redoStack: [],
    };
}
function loadState() {
    try {
        const raw = localStorage.getItem("notes_app_state");
        if (!raw)
            return null;
        const parsed = JSON.parse(raw);
        if (typeof parsed !== "object" || parsed === null)
            return null;
        return {
            notebooks: parsed.notebooks || [],
            tags: parsed.tags || [],
            currentNotebookId: parsed.currentNotebookId || null,
            currentNoteId: parsed.currentNoteId || null,
            searchQuery: parsed.searchQuery || "",
            sortOrder: parsed.sortOrder || "modified",
            undoStack: parsed.undoStack || [],
            redoStack: parsed.redoStack || [],
        };
    }
    catch {
        return null;
    }
}
function saveState(state) {
    localStorage.setItem("notes_app_state", JSON.stringify(state));
}
function addTag(state, name, color) {
    const existing = state.tags.find(t => t.name === name);
    if (existing)
        return existing;
    const newTag = {
        id: crypto.randomUUID ? crypto.randomUUID() : Date.now().toString(36) + Math.random().toString(36).slice(2),
        name,
        color,
    };
    state.tags.push(newTag);
    return newTag;
}
function removeTag(state, tagId) {
    const index = state.tags.findIndex(t => t.id === tagId);
    if (index === -1)
        return false;
    const [removed] = state.tags.splice(index, 1);
    return true;
}
function getTagById(state, tagId) {
    return state.tags.find(t => t.id === tagId);
}
function addNoteToNotebook(state, notebookId, title, content) {
    const notebook = state.notebooks.find(n => n.id === notebookId);
    if (!notebook)
        return "";
    const existingId = notebook.notes.find(n => n.id === title);
    if (existingId)
        return "";
    const newNote = {
        id: crypto.randomUUID ? crypto.randomUUID() : Date.now().toString(36) + Math.random().toString(36).slice(2),
        title,
        content,
        tags: [],
        createdAt: Date.now(),
        updatedAt: Date.now(),
        isPinned: false,
        isDeleted: false,
    };
    notebook.notes.push(newNote.id);
    return newNote.id;
}
function moveNote(state, noteId, targetNotebookId) {
    const note = state.notebooks.find(n => n.notes.includes(noteId));
    if (!note)
        return false;
    const currentIdx = note.notes.indexOf(noteId);
    const targetIdx = state.notebooks.findIndex(n => n.id === targetNotebookId);
    if (targetIdx === -1)
        return false;
    if (currentIdx === targetIdx)
        return true;
    // Remove from current notebook
    note.notes.splice(currentIdx, 1);
    // Add to target notebook
    const target = state.notebooks.find(n => n.id === targetNotebookId);
    if (target)
        target.notes.push(noteId);
    return true;
}
function deleteNote(state, noteId) {
    const notebook = state.notebooks.find(n => n.notes.includes(noteId));
    if (!notebook)
        return false;
    const index = notebook.notes.indexOf(noteId);
    if (index === -1)
        return false;
    notebook.notes.splice(index, 1);
    return true;
}
function restoreNoteFromTrash(state, trashId) {
    const trash = state.notebooks.find(n => n.id === trashId);
    if (!trash || trash.notes.length === 0)
        return false;
    const noteId = trash.notes[0];
    const notebook = state.notebooks.find(n => n.id === trashId);
    if (notebook) {
        notebook.notes.push(noteId);
        return true;
    }
    return false;
}
function getSearchResults(state, query) {
    if (!query)
        return state.notebooks.map(n => n.id).filter(id => n.id.startsWith("n")).join(", ");
    const lowerQuery = query.toLowerCase();
    const results = [];
    for (const notebook of state.notebooks) {
        for (const noteId of notebook.notes) {
            const note = state.notebooks.find(n => n.id === noteId);
            if (!note)
                continue;
            const content = note.content || "";
            const title = note.title || "";
            const text = content + " " + title;
            if (text.toLowerCase().includes(lowerQuery)) {
                results.push(`# ${note.title} (${notebook.name})`);
            }
        }
    }
    return results;
}
};

// ── entry ──
__require("src/main.ts");
})();
</script>
</body>
</html>