import * as drizzle_orm_sqlite_core from 'drizzle-orm/sqlite-core';
import { AnySQLiteTable, AnySQLiteColumn, BaseSQLiteDatabase } from 'drizzle-orm/sqlite-core';
import { c as SceneDocument } from '../model-BBwyOuWG.js';
import { e as SceneStoreScope, d as SceneStore } from '../store-CFyxgTlD.js';

/** A product table referenced by FK — only the `id` column is touched. */
type DesignCanvasParentTable = AnySQLiteTable & {
    id: AnySQLiteColumn;
};
interface CreateDesignCanvasTablesOptions {
    workspaceTable: DesignCanvasParentTable;
    userTable: DesignCanvasParentTable;
}
declare function createDesignCanvasTables(opts: CreateDesignCanvasTablesOptions): {
    designDocuments: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
        name: "design_document";
        schema: undefined;
        columns: {
            id: drizzle_orm_sqlite_core.SQLiteColumn<{
                name: "id";
                tableName: "design_document";
                dataType: "string";
                columnType: "SQLiteText";
                data: string;
                driverParam: string;
                notNull: true;
                hasDefault: true;
                isPrimaryKey: true;
                isAutoincrement: false;
                hasRuntimeDefault: false;
                enumValues: [string, ...string[]];
                baseColumn: never;
                identity: undefined;
                generated: undefined;
            }, {}, {
                length: number | undefined;
            }>;
            workspaceId: drizzle_orm_sqlite_core.SQLiteColumn<{
                name: "workspace_id";
                tableName: "design_document";
                dataType: "string";
                columnType: "SQLiteText";
                data: string;
                driverParam: string;
                notNull: true;
                hasDefault: false;
                isPrimaryKey: false;
                isAutoincrement: false;
                hasRuntimeDefault: false;
                enumValues: [string, ...string[]];
                baseColumn: never;
                identity: undefined;
                generated: undefined;
            }, {}, {
                length: number | undefined;
            }>;
            title: drizzle_orm_sqlite_core.SQLiteColumn<{
                name: "title";
                tableName: "design_document";
                dataType: "string";
                columnType: "SQLiteText";
                data: string;
                driverParam: string;
                notNull: true;
                hasDefault: false;
                isPrimaryKey: false;
                isAutoincrement: false;
                hasRuntimeDefault: false;
                enumValues: [string, ...string[]];
                baseColumn: never;
                identity: undefined;
                generated: undefined;
            }, {}, {
                length: number | undefined;
            }>;
            document: drizzle_orm_sqlite_core.SQLiteColumn<{
                name: "document";
                tableName: "design_document";
                dataType: "json";
                columnType: "SQLiteTextJson";
                data: SceneDocument;
                driverParam: string;
                notNull: true;
                hasDefault: false;
                isPrimaryKey: false;
                isAutoincrement: false;
                hasRuntimeDefault: false;
                enumValues: undefined;
                baseColumn: never;
                identity: undefined;
                generated: undefined;
            }, {}, {
                $type: SceneDocument;
            }>;
            rev: drizzle_orm_sqlite_core.SQLiteColumn<{
                name: "rev";
                tableName: "design_document";
                dataType: "number";
                columnType: "SQLiteInteger";
                data: number;
                driverParam: number;
                notNull: true;
                hasDefault: true;
                isPrimaryKey: false;
                isAutoincrement: false;
                hasRuntimeDefault: false;
                enumValues: undefined;
                baseColumn: never;
                identity: undefined;
                generated: undefined;
            }, {}, {}>;
            isTemplate: drizzle_orm_sqlite_core.SQLiteColumn<{
                name: "is_template";
                tableName: "design_document";
                dataType: "boolean";
                columnType: "SQLiteBoolean";
                data: boolean;
                driverParam: number;
                notNull: true;
                hasDefault: true;
                isPrimaryKey: false;
                isAutoincrement: false;
                hasRuntimeDefault: false;
                enumValues: undefined;
                baseColumn: never;
                identity: undefined;
                generated: undefined;
            }, {}, {}>;
            createdBy: drizzle_orm_sqlite_core.SQLiteColumn<{
                name: "created_by";
                tableName: "design_document";
                dataType: "string";
                columnType: "SQLiteText";
                data: string;
                driverParam: string;
                notNull: true;
                hasDefault: false;
                isPrimaryKey: false;
                isAutoincrement: false;
                hasRuntimeDefault: false;
                enumValues: [string, ...string[]];
                baseColumn: never;
                identity: undefined;
                generated: undefined;
            }, {}, {
                length: number | undefined;
            }>;
            createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
                name: "created_at";
                tableName: "design_document";
                dataType: "date";
                columnType: "SQLiteTimestamp";
                data: Date;
                driverParam: number;
                notNull: true;
                hasDefault: true;
                isPrimaryKey: false;
                isAutoincrement: false;
                hasRuntimeDefault: false;
                enumValues: undefined;
                baseColumn: never;
                identity: undefined;
                generated: undefined;
            }, {}, {}>;
            updatedAt: drizzle_orm_sqlite_core.SQLiteColumn<{
                name: "updated_at";
                tableName: "design_document";
                dataType: "date";
                columnType: "SQLiteTimestamp";
                data: Date;
                driverParam: number;
                notNull: true;
                hasDefault: true;
                isPrimaryKey: false;
                isAutoincrement: false;
                hasRuntimeDefault: false;
                enumValues: undefined;
                baseColumn: never;
                identity: undefined;
                generated: undefined;
            }, {}, {}>;
        };
        dialect: "sqlite";
    }>;
    designDecisions: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
        name: "design_decision";
        schema: undefined;
        columns: {
            id: drizzle_orm_sqlite_core.SQLiteColumn<{
                name: "id";
                tableName: "design_decision";
                dataType: "string";
                columnType: "SQLiteText";
                data: string;
                driverParam: string;
                notNull: true;
                hasDefault: true;
                isPrimaryKey: true;
                isAutoincrement: false;
                hasRuntimeDefault: false;
                enumValues: [string, ...string[]];
                baseColumn: never;
                identity: undefined;
                generated: undefined;
            }, {}, {
                length: number | undefined;
            }>;
            documentId: drizzle_orm_sqlite_core.SQLiteColumn<{
                name: "document_id";
                tableName: "design_decision";
                dataType: "string";
                columnType: "SQLiteText";
                data: string;
                driverParam: string;
                notNull: true;
                hasDefault: false;
                isPrimaryKey: false;
                isAutoincrement: false;
                hasRuntimeDefault: false;
                enumValues: [string, ...string[]];
                baseColumn: never;
                identity: undefined;
                generated: undefined;
            }, {}, {
                length: number | undefined;
            }>;
            workspaceId: drizzle_orm_sqlite_core.SQLiteColumn<{
                name: "workspace_id";
                tableName: "design_decision";
                dataType: "string";
                columnType: "SQLiteText";
                data: string;
                driverParam: string;
                notNull: true;
                hasDefault: false;
                isPrimaryKey: false;
                isAutoincrement: false;
                hasRuntimeDefault: false;
                enumValues: [string, ...string[]];
                baseColumn: never;
                identity: undefined;
                generated: undefined;
            }, {}, {
                length: number | undefined;
            }>;
            kind: drizzle_orm_sqlite_core.SQLiteColumn<{
                name: "kind";
                tableName: "design_decision";
                dataType: "string";
                columnType: "SQLiteText";
                data: "human_edit" | "agent_edit" | "agent_proposal" | "export" | "note";
                driverParam: string;
                notNull: true;
                hasDefault: false;
                isPrimaryKey: false;
                isAutoincrement: false;
                hasRuntimeDefault: false;
                enumValues: ["human_edit", "agent_edit", "agent_proposal", "export", "note"];
                baseColumn: never;
                identity: undefined;
                generated: undefined;
            }, {}, {
                length: number | undefined;
            }>;
            instruction: drizzle_orm_sqlite_core.SQLiteColumn<{
                name: "instruction";
                tableName: "design_decision";
                dataType: "string";
                columnType: "SQLiteText";
                data: string;
                driverParam: string;
                notNull: true;
                hasDefault: false;
                isPrimaryKey: false;
                isAutoincrement: false;
                hasRuntimeDefault: false;
                enumValues: [string, ...string[]];
                baseColumn: never;
                identity: undefined;
                generated: undefined;
            }, {}, {
                length: number | undefined;
            }>;
            reasoningSummary: drizzle_orm_sqlite_core.SQLiteColumn<{
                name: "reasoning_summary";
                tableName: "design_decision";
                dataType: "string";
                columnType: "SQLiteText";
                data: string;
                driverParam: string;
                notNull: false;
                hasDefault: false;
                isPrimaryKey: false;
                isAutoincrement: false;
                hasRuntimeDefault: false;
                enumValues: [string, ...string[]];
                baseColumn: never;
                identity: undefined;
                generated: undefined;
            }, {}, {
                length: number | undefined;
            }>;
            metadata: drizzle_orm_sqlite_core.SQLiteColumn<{
                name: "metadata";
                tableName: "design_decision";
                dataType: "json";
                columnType: "SQLiteTextJson";
                data: Record<string, unknown>;
                driverParam: string;
                notNull: false;
                hasDefault: true;
                isPrimaryKey: false;
                isAutoincrement: false;
                hasRuntimeDefault: false;
                enumValues: undefined;
                baseColumn: never;
                identity: undefined;
                generated: undefined;
            }, {}, {
                $type: Record<string, unknown>;
            }>;
            createdBy: drizzle_orm_sqlite_core.SQLiteColumn<{
                name: "created_by";
                tableName: "design_decision";
                dataType: "string";
                columnType: "SQLiteText";
                data: string;
                driverParam: string;
                notNull: true;
                hasDefault: false;
                isPrimaryKey: false;
                isAutoincrement: false;
                hasRuntimeDefault: false;
                enumValues: [string, ...string[]];
                baseColumn: never;
                identity: undefined;
                generated: undefined;
            }, {}, {
                length: number | undefined;
            }>;
            createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
                name: "created_at";
                tableName: "design_decision";
                dataType: "date";
                columnType: "SQLiteTimestamp";
                data: Date;
                driverParam: number;
                notNull: true;
                hasDefault: true;
                isPrimaryKey: false;
                isAutoincrement: false;
                hasRuntimeDefault: false;
                enumValues: undefined;
                baseColumn: never;
                identity: undefined;
                generated: undefined;
            }, {}, {}>;
        };
        dialect: "sqlite";
    }>;
    designExports: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
        name: "design_export";
        schema: undefined;
        columns: {
            id: drizzle_orm_sqlite_core.SQLiteColumn<{
                name: "id";
                tableName: "design_export";
                dataType: "string";
                columnType: "SQLiteText";
                data: string;
                driverParam: string;
                notNull: true;
                hasDefault: true;
                isPrimaryKey: true;
                isAutoincrement: false;
                hasRuntimeDefault: false;
                enumValues: [string, ...string[]];
                baseColumn: never;
                identity: undefined;
                generated: undefined;
            }, {}, {
                length: number | undefined;
            }>;
            documentId: drizzle_orm_sqlite_core.SQLiteColumn<{
                name: "document_id";
                tableName: "design_export";
                dataType: "string";
                columnType: "SQLiteText";
                data: string;
                driverParam: string;
                notNull: true;
                hasDefault: false;
                isPrimaryKey: false;
                isAutoincrement: false;
                hasRuntimeDefault: false;
                enumValues: [string, ...string[]];
                baseColumn: never;
                identity: undefined;
                generated: undefined;
            }, {}, {
                length: number | undefined;
            }>;
            workspaceId: drizzle_orm_sqlite_core.SQLiteColumn<{
                name: "workspace_id";
                tableName: "design_export";
                dataType: "string";
                columnType: "SQLiteText";
                data: string;
                driverParam: string;
                notNull: true;
                hasDefault: false;
                isPrimaryKey: false;
                isAutoincrement: false;
                hasRuntimeDefault: false;
                enumValues: [string, ...string[]];
                baseColumn: never;
                identity: undefined;
                generated: undefined;
            }, {}, {
                length: number | undefined;
            }>;
            format: drizzle_orm_sqlite_core.SQLiteColumn<{
                name: "format";
                tableName: "design_export";
                dataType: "string";
                columnType: "SQLiteText";
                data: "png" | "jpeg" | "json";
                driverParam: string;
                notNull: true;
                hasDefault: false;
                isPrimaryKey: false;
                isAutoincrement: false;
                hasRuntimeDefault: false;
                enumValues: ["png", "jpeg", "json"];
                baseColumn: never;
                identity: undefined;
                generated: undefined;
            }, {}, {
                length: number | undefined;
            }>;
            status: drizzle_orm_sqlite_core.SQLiteColumn<{
                name: "status";
                tableName: "design_export";
                dataType: "string";
                columnType: "SQLiteText";
                data: "queued" | "processing" | "completed" | "failed";
                driverParam: string;
                notNull: true;
                hasDefault: true;
                isPrimaryKey: false;
                isAutoincrement: false;
                hasRuntimeDefault: false;
                enumValues: ["queued", "processing", "completed", "failed"];
                baseColumn: never;
                identity: undefined;
                generated: undefined;
            }, {}, {
                length: number | undefined;
            }>;
            resultUrl: drizzle_orm_sqlite_core.SQLiteColumn<{
                name: "result_url";
                tableName: "design_export";
                dataType: "string";
                columnType: "SQLiteText";
                data: string;
                driverParam: string;
                notNull: false;
                hasDefault: false;
                isPrimaryKey: false;
                isAutoincrement: false;
                hasRuntimeDefault: false;
                enumValues: [string, ...string[]];
                baseColumn: never;
                identity: undefined;
                generated: undefined;
            }, {}, {
                length: number | undefined;
            }>;
            metadata: drizzle_orm_sqlite_core.SQLiteColumn<{
                name: "metadata";
                tableName: "design_export";
                dataType: "json";
                columnType: "SQLiteTextJson";
                data: Record<string, unknown>;
                driverParam: string;
                notNull: false;
                hasDefault: true;
                isPrimaryKey: false;
                isAutoincrement: false;
                hasRuntimeDefault: false;
                enumValues: undefined;
                baseColumn: never;
                identity: undefined;
                generated: undefined;
            }, {}, {
                $type: Record<string, unknown>;
            }>;
            createdBy: drizzle_orm_sqlite_core.SQLiteColumn<{
                name: "created_by";
                tableName: "design_export";
                dataType: "string";
                columnType: "SQLiteText";
                data: string;
                driverParam: string;
                notNull: true;
                hasDefault: false;
                isPrimaryKey: false;
                isAutoincrement: false;
                hasRuntimeDefault: false;
                enumValues: [string, ...string[]];
                baseColumn: never;
                identity: undefined;
                generated: undefined;
            }, {}, {
                length: number | undefined;
            }>;
            createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
                name: "created_at";
                tableName: "design_export";
                dataType: "date";
                columnType: "SQLiteTimestamp";
                data: Date;
                driverParam: number;
                notNull: true;
                hasDefault: true;
                isPrimaryKey: false;
                isAutoincrement: false;
                hasRuntimeDefault: false;
                enumValues: undefined;
                baseColumn: never;
                identity: undefined;
                generated: undefined;
            }, {}, {}>;
        };
        dialect: "sqlite";
    }>;
};
type DesignCanvasTables = ReturnType<typeof createDesignCanvasTables>;
type DesignDocumentRow = DesignCanvasTables['designDocuments']['$inferSelect'];
type DesignDecisionRow = DesignCanvasTables['designDecisions']['$inferSelect'];
type DesignExportRow = DesignCanvasTables['designExports']['$inferSelect'];

/**
 * Drizzle-backed `SceneStore` over the tables from `createDesignCanvasTables`.
 * Works against any SQLite drizzle driver (better-sqlite3, D1, libsql).
 *
 * Defense in depth: RBAC runs before the store is constructed, but every
 * query still pins `workspaceId` AND `documentId` from the scope in its WHERE
 * clause, so a leaked or attacker-supplied row id from another workspace can
 * never read or write across the boundary — it surfaces as "not found".
 *
 * Optimistic concurrency for saveDocument: the UPDATE WHERE clause includes
 * `rev = expectedRev`; when 0 rows are changed (stale revision or missing
 * document), the store reads back the row to emit a precise error — either
 * "stale rev" or "not found" — so callers know whether to refetch-and-replay
 * or abort.
 */

/** Any SQLite drizzle database — `any` erases the driver-specific run-result
 *  and schema generics so better-sqlite3, D1, and libsql handles all fit. */
type DesignCanvasDatabase = BaseSQLiteDatabase<'sync' | 'async', any, any>;
interface CreateDrizzleSceneStoreOptions {
    db: DesignCanvasDatabase;
    tables: DesignCanvasTables;
    scope: SceneStoreScope;
}
declare function createDrizzleSceneStore(options: CreateDrizzleSceneStoreOptions): SceneStore;

export { type CreateDesignCanvasTablesOptions, type CreateDrizzleSceneStoreOptions, type DesignCanvasDatabase, type DesignCanvasParentTable, type DesignCanvasTables, type DesignDecisionRow, type DesignDocumentRow, type DesignExportRow, createDesignCanvasTables, createDrizzleSceneStore };
