import { z } from 'zod';

/**
 * @module studio/plugin
 *
 * Studio Plugin Protocol
 *
 * Defines the specification for Studio plugins — a VS Code-like extension model
 * that allows each metadata type to contribute custom viewers, designers,
 * sidebar groups, actions, and commands.
 *
 * ## Architecture
 *
 * Like VS Code extensions, Studio plugins have two layers:
 * 1. **Manifest (Declarative)** — JSON-serializable contribution points
 * 2. **Activation (Imperative)** — Runtime registration of React components & handlers
 *
 * ```
 * ┌─────────────────────────────────────────────────────────┐
 * │                    Studio Host                          │
 * │  ┌───────────────────────────────────────────────────┐  │
 * │  │              Plugin Registry                      │  │
 * │  │  ┌──────────┐ ┌──────────┐ ┌──────────┐         │  │
 * │  │  │ Object   │ │  Flow    │ │  Agent   │  ...     │  │
 * │  │  │ Plugin   │ │  Plugin  │ │  Plugin  │         │  │
 * │  │  └──────────┘ └──────────┘ └──────────┘         │  │
 * │  └───────────────────────────────────────────────────┘  │
 * │                                                         │
 * │  ┌─── Sidebar ───┐  ┌──── Main Panel ────────────────┐ │
 * │  │ [plugin icons] │  │  PluginHost renders viewer     │ │
 * │  │ [plugin groups]│  │  from highest-priority plugin  │ │
 * │  └────────────────┘  └────────────────────────────────┘ │
 * └─────────────────────────────────────────────────────────┘
 * ```
 *
 * @example
 * ```typescript
 * import { StudioPluginManifestSchema } from '@objectstack/spec/studio';
 *
 * const manifest = StudioPluginManifestSchema.parse({
 *   id: 'objectstack.object-designer',
 *   name: 'Object Designer',
 *   version: '1.0.0',
 *   contributes: {
 *     metadataViewers: [{
 *       id: 'object-explorer',
 *       metadataTypes: ['object', 'objects'],
 *       label: 'Object Explorer',
 *       priority: 100,
 *       modes: ['preview', 'design', 'data'],
 *     }],
 *   },
 * });
 * ```
 */

/** Supported view modes for metadata viewers */
declare const ViewModeSchema: z.ZodEnum<{
    code: "code";
    data: "data";
    preview: "preview";
    design: "design";
}>;
type ViewMode = z.infer<typeof ViewModeSchema>;
/**
 * Declares a metadata viewer/designer component.
 * The runtime component is registered imperatively during plugin activation.
 */
declare const MetadataViewerContributionSchema: z.ZodObject<{
    id: z.ZodString;
    metadataTypes: z.ZodArray<z.ZodString>;
    label: z.ZodString;
    priority: z.ZodDefault<z.ZodNumber>;
    modes: z.ZodDefault<z.ZodArray<z.ZodEnum<{
        code: "code";
        data: "data";
        preview: "preview";
        design: "design";
    }>>>;
}, z.core.$strip>;
type MetadataViewerContribution = z.infer<typeof MetadataViewerContributionSchema>;
/**
 * Declares a sidebar group that organizes metadata types.
 * Plugins can add new groups or extend existing ones.
 */
declare const SidebarGroupContributionSchema: z.ZodObject<{
    key: z.ZodString;
    label: z.ZodString;
    icon: z.ZodOptional<z.ZodString>;
    metadataTypes: z.ZodArray<z.ZodString>;
    order: z.ZodDefault<z.ZodNumber>;
}, z.core.$strip>;
type SidebarGroupContribution = z.infer<typeof SidebarGroupContributionSchema>;
/** Where an action can appear in the UI */
declare const ActionLocationSchema: z.ZodEnum<{
    toolbar: "toolbar";
    contextMenu: "contextMenu";
    commandPalette: "commandPalette";
}>;
/**
 * Declares an action that can be triggered on metadata items.
 * The handler is registered imperatively during activation.
 */
declare const ActionContributionSchema: z.ZodObject<{
    id: z.ZodString;
    label: z.ZodString;
    icon: z.ZodOptional<z.ZodString>;
    location: z.ZodEnum<{
        toolbar: "toolbar";
        contextMenu: "contextMenu";
        commandPalette: "commandPalette";
    }>;
    metadataTypes: z.ZodDefault<z.ZodArray<z.ZodString>>;
}, z.core.$strip>;
type ActionContribution = z.infer<typeof ActionContributionSchema>;
/**
 * Declares an icon and label for a metadata type.
 * Used by the sidebar and breadcrumbs.
 */
declare const MetadataIconContributionSchema: z.ZodObject<{
    metadataType: z.ZodString;
    label: z.ZodString;
    icon: z.ZodString;
}, z.core.$strip>;
type MetadataIconContribution = z.infer<typeof MetadataIconContributionSchema>;
/** Where a panel can be placed */
declare const PanelLocationSchema: z.ZodEnum<{
    right: "right";
    bottom: "bottom";
    modal: "modal";
}>;
/**
 * Declares an auxiliary panel (like VS Code's Terminal, Problems, Output panels).
 */
declare const PanelContributionSchema: z.ZodObject<{
    id: z.ZodString;
    label: z.ZodString;
    icon: z.ZodOptional<z.ZodString>;
    location: z.ZodDefault<z.ZodEnum<{
        right: "right";
        bottom: "bottom";
        modal: "modal";
    }>>;
}, z.core.$strip>;
type PanelContribution = z.infer<typeof PanelContributionSchema>;
/**
 * Declares a command that can be invoked from the command palette
 * or programmatically by other plugins.
 */
declare const CommandContributionSchema: z.ZodObject<{
    id: z.ZodString;
    label: z.ZodString;
    shortcut: z.ZodOptional<z.ZodString>;
    icon: z.ZodOptional<z.ZodString>;
}, z.core.$strip>;
type CommandContribution = z.infer<typeof CommandContributionSchema>;
/**
 * All contribution points a Studio plugin can declare.
 * Analogous to VS Code's `contributes` section in `package.json`.
 */
declare const StudioPluginContributionsSchema: z.ZodObject<{
    metadataViewers: z.ZodDefault<z.ZodArray<z.ZodObject<{
        id: z.ZodString;
        metadataTypes: z.ZodArray<z.ZodString>;
        label: z.ZodString;
        priority: z.ZodDefault<z.ZodNumber>;
        modes: z.ZodDefault<z.ZodArray<z.ZodEnum<{
            code: "code";
            data: "data";
            preview: "preview";
            design: "design";
        }>>>;
    }, z.core.$strip>>>;
    sidebarGroups: z.ZodDefault<z.ZodArray<z.ZodObject<{
        key: z.ZodString;
        label: z.ZodString;
        icon: z.ZodOptional<z.ZodString>;
        metadataTypes: z.ZodArray<z.ZodString>;
        order: z.ZodDefault<z.ZodNumber>;
    }, z.core.$strip>>>;
    actions: z.ZodDefault<z.ZodArray<z.ZodObject<{
        id: z.ZodString;
        label: z.ZodString;
        icon: z.ZodOptional<z.ZodString>;
        location: z.ZodEnum<{
            toolbar: "toolbar";
            contextMenu: "contextMenu";
            commandPalette: "commandPalette";
        }>;
        metadataTypes: z.ZodDefault<z.ZodArray<z.ZodString>>;
    }, z.core.$strip>>>;
    metadataIcons: z.ZodDefault<z.ZodArray<z.ZodObject<{
        metadataType: z.ZodString;
        label: z.ZodString;
        icon: z.ZodString;
    }, z.core.$strip>>>;
    panels: z.ZodDefault<z.ZodArray<z.ZodObject<{
        id: z.ZodString;
        label: z.ZodString;
        icon: z.ZodOptional<z.ZodString>;
        location: z.ZodDefault<z.ZodEnum<{
            right: "right";
            bottom: "bottom";
            modal: "modal";
        }>>;
    }, z.core.$strip>>>;
    commands: z.ZodDefault<z.ZodArray<z.ZodObject<{
        id: z.ZodString;
        label: z.ZodString;
        shortcut: z.ZodOptional<z.ZodString>;
        icon: z.ZodOptional<z.ZodString>;
    }, z.core.$strip>>>;
}, z.core.$strip>;
type StudioPluginContributions = z.infer<typeof StudioPluginContributionsSchema>;
/**
 * Events that trigger plugin activation.
 * Similar to VS Code's `activationEvents`.
 *
 * Patterns:
 * - `*` — Activate immediately (eager)
 * - `onMetadataType:object` — Activate when metadata type "object" is loaded
 * - `onCommand:myPlugin.doSomething` — Activate when command is invoked
 * - `onView:myPlugin.myPanel` — Activate when panel is opened
 */
declare const ActivationEventSchema: z.ZodString;
/**
 * The declarative manifest for a Studio plugin.
 *
 * This is the "package.json" equivalent for Studio extensions.
 * All contribution points are declared here; runtime components
 * are registered imperatively during the `activate()` call.
 */
declare const StudioPluginManifestSchema: z.ZodObject<{
    id: z.ZodString;
    name: z.ZodString;
    version: z.ZodDefault<z.ZodString>;
    description: z.ZodOptional<z.ZodString>;
    author: z.ZodOptional<z.ZodString>;
    contributes: z.ZodDefault<z.ZodObject<{
        metadataViewers: z.ZodDefault<z.ZodArray<z.ZodObject<{
            id: z.ZodString;
            metadataTypes: z.ZodArray<z.ZodString>;
            label: z.ZodString;
            priority: z.ZodDefault<z.ZodNumber>;
            modes: z.ZodDefault<z.ZodArray<z.ZodEnum<{
                code: "code";
                data: "data";
                preview: "preview";
                design: "design";
            }>>>;
        }, z.core.$strip>>>;
        sidebarGroups: z.ZodDefault<z.ZodArray<z.ZodObject<{
            key: z.ZodString;
            label: z.ZodString;
            icon: z.ZodOptional<z.ZodString>;
            metadataTypes: z.ZodArray<z.ZodString>;
            order: z.ZodDefault<z.ZodNumber>;
        }, z.core.$strip>>>;
        actions: z.ZodDefault<z.ZodArray<z.ZodObject<{
            id: z.ZodString;
            label: z.ZodString;
            icon: z.ZodOptional<z.ZodString>;
            location: z.ZodEnum<{
                toolbar: "toolbar";
                contextMenu: "contextMenu";
                commandPalette: "commandPalette";
            }>;
            metadataTypes: z.ZodDefault<z.ZodArray<z.ZodString>>;
        }, z.core.$strip>>>;
        metadataIcons: z.ZodDefault<z.ZodArray<z.ZodObject<{
            metadataType: z.ZodString;
            label: z.ZodString;
            icon: z.ZodString;
        }, z.core.$strip>>>;
        panels: z.ZodDefault<z.ZodArray<z.ZodObject<{
            id: z.ZodString;
            label: z.ZodString;
            icon: z.ZodOptional<z.ZodString>;
            location: z.ZodDefault<z.ZodEnum<{
                right: "right";
                bottom: "bottom";
                modal: "modal";
            }>>;
        }, z.core.$strip>>>;
        commands: z.ZodDefault<z.ZodArray<z.ZodObject<{
            id: z.ZodString;
            label: z.ZodString;
            shortcut: z.ZodOptional<z.ZodString>;
            icon: z.ZodOptional<z.ZodString>;
        }, z.core.$strip>>>;
    }, z.core.$strip>>;
    activationEvents: z.ZodDefault<z.ZodArray<z.ZodString>>;
}, z.core.$strip>;
type StudioPluginManifest = z.infer<typeof StudioPluginManifestSchema>;
/**
 * Type-safe helper for defining a Studio plugin manifest.
 *
 * @example
 * ```typescript
 * const manifest = defineStudioPlugin({
 *   id: 'objectstack.flow-designer',
 *   name: 'Flow Designer',
 *   contributes: {
 *     metadataViewers: [{
 *       id: 'flow-canvas',
 *       metadataTypes: ['flows'],
 *       label: 'Flow Canvas',
 *       priority: 100,
 *       modes: ['design', 'code'],
 *     }],
 *   },
 * });
 * ```
 */
declare function defineStudioPlugin(input: z.input<typeof StudioPluginManifestSchema>): StudioPluginManifest;

/**
 * @module studio
 *
 * Studio Protocol — Plugin system for ObjectStack Studio
 *
 * Defines the extension model that allows metadata types to contribute
 * custom viewers, designers, sidebar groups, actions, and commands.
 */

type index_ActionContribution = ActionContribution;
declare const index_ActionContributionSchema: typeof ActionContributionSchema;
declare const index_ActionLocationSchema: typeof ActionLocationSchema;
declare const index_ActivationEventSchema: typeof ActivationEventSchema;
type index_CommandContribution = CommandContribution;
declare const index_CommandContributionSchema: typeof CommandContributionSchema;
type index_MetadataIconContribution = MetadataIconContribution;
declare const index_MetadataIconContributionSchema: typeof MetadataIconContributionSchema;
type index_MetadataViewerContribution = MetadataViewerContribution;
declare const index_MetadataViewerContributionSchema: typeof MetadataViewerContributionSchema;
type index_PanelContribution = PanelContribution;
declare const index_PanelContributionSchema: typeof PanelContributionSchema;
declare const index_PanelLocationSchema: typeof PanelLocationSchema;
type index_SidebarGroupContribution = SidebarGroupContribution;
declare const index_SidebarGroupContributionSchema: typeof SidebarGroupContributionSchema;
type index_StudioPluginContributions = StudioPluginContributions;
declare const index_StudioPluginContributionsSchema: typeof StudioPluginContributionsSchema;
type index_StudioPluginManifest = StudioPluginManifest;
declare const index_StudioPluginManifestSchema: typeof StudioPluginManifestSchema;
type index_ViewMode = ViewMode;
declare const index_ViewModeSchema: typeof ViewModeSchema;
declare const index_defineStudioPlugin: typeof defineStudioPlugin;
declare namespace index {
  export { type index_ActionContribution as ActionContribution, index_ActionContributionSchema as ActionContributionSchema, index_ActionLocationSchema as ActionLocationSchema, index_ActivationEventSchema as ActivationEventSchema, type index_CommandContribution as CommandContribution, index_CommandContributionSchema as CommandContributionSchema, type index_MetadataIconContribution as MetadataIconContribution, index_MetadataIconContributionSchema as MetadataIconContributionSchema, type index_MetadataViewerContribution as MetadataViewerContribution, index_MetadataViewerContributionSchema as MetadataViewerContributionSchema, type index_PanelContribution as PanelContribution, index_PanelContributionSchema as PanelContributionSchema, index_PanelLocationSchema as PanelLocationSchema, type index_SidebarGroupContribution as SidebarGroupContribution, index_SidebarGroupContributionSchema as SidebarGroupContributionSchema, type index_StudioPluginContributions as StudioPluginContributions, index_StudioPluginContributionsSchema as StudioPluginContributionsSchema, type index_StudioPluginManifest as StudioPluginManifest, index_StudioPluginManifestSchema as StudioPluginManifestSchema, type index_ViewMode as ViewMode, index_ViewModeSchema as ViewModeSchema, index_defineStudioPlugin as defineStudioPlugin };
}

export { ActionContributionSchema as A, CommandContributionSchema as C, MetadataViewerContributionSchema as M, PanelContributionSchema as P, SidebarGroupContributionSchema as S, ViewModeSchema as V, ActionLocationSchema as a, MetadataIconContributionSchema as b, PanelLocationSchema as c, StudioPluginContributionsSchema as d, ActivationEventSchema as e, StudioPluginManifestSchema as f, type ViewMode as g, type MetadataViewerContribution as h, index as i, type SidebarGroupContribution as j, type ActionContribution as k, type MetadataIconContribution as l, type PanelContribution as m, type CommandContribution as n, type StudioPluginContributions as o, type StudioPluginManifest as p, defineStudioPlugin as q };
