import { c as DevToolsCommandsHost } from "./settings-DfhMlk_9.js";
import { CreateHostContextOptions } from "devframe/node";
import * as _$devframe_types0 from "devframe/types";
import { ConnectionMeta, DevToolsCapabilities, DevToolsNodeContext, EventEmitter } from "devframe/types";
import { Plugin, ResolvedConfig, ViteDevServer } from "vite";
import { ChildProcess } from "node:child_process";

//#region src/types/messages.d.ts
type DevToolsMessageLevel = 'info' | 'warn' | 'error' | 'success' | 'debug';
type DevToolsMessageEntryFrom = 'server' | 'browser';
interface DevToolsMessageElementPosition {
  /** CSS selector for the element */
  selector?: string;
  /** Bounding box of the element */
  boundingBox?: {
    x: number;
    y: number;
    width: number;
    height: number;
  };
  /** Human-readable description of the element */
  description?: string;
}
interface DevToolsMessageFilePosition {
  /** Absolute or relative file path */
  file: string;
  /** Line number (1-based) */
  line?: number;
  /** Column number (1-based) */
  column?: number;
}
interface DevToolsMessageEntry {
  /**
   * Unique identifier for this message entry (auto-generated if not provided)
   */
  id: string;
  /**
   * Short title or summary of the message
   */
  message: string;
  /**
   * Optional detailed description or explanation
   */
  description?: string;
  /**
   * Severity level, determines color and icon
   */
  level: DevToolsMessageLevel;
  /**
   * Optional stack trace string
   */
  stacktrace?: string;
  /**
   * Optional DOM element position info (e.g., for a11y issues)
   */
  elementPosition?: DevToolsMessageElementPosition;
  /**
   * Optional source file position info (e.g., for lint errors)
   */
  filePosition?: DevToolsMessageFilePosition;
  /**
   * Whether this message should also appear as a toast notification
   */
  notify?: boolean;
  /**
   * Origin of the message entry, automatically set by the context
   */
  from: DevToolsMessageEntryFrom;
  /**
   * Grouping category (e.g., 'a11y', 'lint', 'runtime', 'test')
   */
  category?: string;
  /**
   * Optional tags/labels for filtering
   */
  labels?: string[];
  /**
   * Time in ms to auto-dismiss the toast notification (client-side)
   */
  autoDismiss?: number;
  /**
   * Time in ms to auto-delete this message entry (server-side)
   */
  autoDelete?: number;
  /**
   * Timestamp when the message was created (auto-generated if not provided)
   */
  timestamp: number;
  /**
   * Status of the message entry (e.g., 'loading' while an operation is in progress).
   * Defaults to 'idle' when not specified.
   */
  status?: 'loading' | 'idle';
}
/**
 * Input type for creating a message entry.
 * `id`, `timestamp`, and `from` are auto-filled by the host.
 */
type DevToolsMessageEntryInput = Omit<DevToolsMessageEntry, 'id' | 'timestamp' | 'from'> & {
  id?: string;
  timestamp?: number;
};
interface DevToolsMessageHandle {
  /** The underlying message entry data */
  readonly entry: DevToolsMessageEntry;
  /** Shortcut to entry.id */
  readonly id: string;
  /** Partial update of this message entry */
  update: (patch: Partial<DevToolsMessageEntryInput>) => Promise<DevToolsMessageEntry | undefined>;
  /** Remove this message entry */
  dismiss: () => Promise<void>;
}
interface DevToolsMessagesClient {
  /**
   * Add a message entry. Returns a Promise resolving to a handle for subsequent updates/dismissal.
   * Can be used without `await` for fire-and-forget usage.
   */
  add: (input: DevToolsMessageEntryInput) => Promise<DevToolsMessageHandle>;
  /** Remove a message entry by id */
  remove: (id: string) => Promise<void>;
  /** Clear all message entries */
  clear: () => Promise<void>;
}
interface DevToolsMessagesHost {
  readonly entries: Map<string, DevToolsMessageEntry>;
  readonly events: EventEmitter<{
    'message:added': (entry: DevToolsMessageEntry) => void;
    'message:updated': (entry: DevToolsMessageEntry) => void;
    'message:removed': (id: string) => void;
    'message:cleared': () => void;
  }>;
  /**
   * Add a new message entry. If an entry with the same `id` already exists, it will be updated instead.
   * Returns a handle for subsequent updates/dismissal. Can be used without `await` for fire-and-forget.
   */
  add: (entry: DevToolsMessageEntryInput) => Promise<DevToolsMessageHandle>;
  /**
   * Update an existing message entry by id (partial update)
   */
  update: (id: string, patch: Partial<DevToolsMessageEntryInput>) => Promise<DevToolsMessageEntry | undefined>;
  /**
   * Remove a message entry by id
   */
  remove: (id: string) => Promise<void>;
  /**
   * Clear all message entries
   */
  clear: () => Promise<void>;
}
/** @deprecated alias of {@link DevToolsMessageLevel}. Will be removed in a future release. */
type DevToolsLogLevel = DevToolsMessageLevel;
/** @deprecated alias of {@link DevToolsMessageEntryFrom}. Will be removed in a future release. */
type DevToolsLogEntryFrom = DevToolsMessageEntryFrom;
/** @deprecated alias of {@link DevToolsMessageElementPosition}. Will be removed in a future release. */
type DevToolsLogElementPosition = DevToolsMessageElementPosition;
/** @deprecated alias of {@link DevToolsMessageFilePosition}. Will be removed in a future release. */
type DevToolsLogFilePosition = DevToolsMessageFilePosition;
/** @deprecated alias of {@link DevToolsMessageEntry}. Will be removed in a future release. */
type DevToolsLogEntry = DevToolsMessageEntry;
/** @deprecated alias of {@link DevToolsMessageEntryInput}. Will be removed in a future release. */
type DevToolsLogEntryInput = DevToolsMessageEntryInput;
/** @deprecated alias of {@link DevToolsMessageHandle}. Will be removed in a future release. */
type DevToolsLogHandle = DevToolsMessageHandle;
/** @deprecated alias of {@link DevToolsMessagesClient}. Will be removed in a future release. */
type DevToolsLogsClient = DevToolsMessagesClient;
/** @deprecated alias of {@link DevToolsMessagesHost}. Will be removed in a future release. */
type DevToolsLogsHost = DevToolsMessagesHost;
//#endregion
//#region src/types/docks.d.ts
interface DevToolsDockHost {
  readonly views: Map<string, DevToolsDockUserEntry>;
  readonly events: EventEmitter<{
    'dock:entry:updated': (entry: DevToolsDockUserEntry) => void;
  }>;
  register: <T extends DevToolsDockUserEntry>(entry: T, force?: boolean) => {
    update: (patch: Partial<T>) => void;
  };
  update: (entry: DevToolsDockUserEntry) => void;
  values: (options?: {
    includeBuiltin?: boolean;
  }) => DevToolsDockEntry[];
}
type DevToolsDockEntryCategory = 'app' | 'framework' | 'web' | 'advanced' | 'default' | '~viteplus' | '~builtin';
type DevToolsDockEntryIcon = string | {
  light: string;
  dark: string;
};
interface DevToolsDockEntryBase {
  id: string;
  title: string;
  icon: DevToolsDockEntryIcon;
  /**
   * The default order of the entry in the dock.
   * The higher the number the earlier it appears.
   * @default 0
   */
  defaultOrder?: number;
  /**
   * The category of the entry
   * @default 'default'
   */
  category?: DevToolsDockEntryCategory;
  /**
   * Conditional visibility expression.
   * When set, the dock entry is only visible when the expression evaluates to true.
   * Uses the same syntax as command `when` clauses.
   *
   * Set to `'false'` to unconditionally hide the entry.
   *
   * @example 'clientType == embedded'
   * @see {@link import('devframe/utils/when').evaluateWhen}
   */
  when?: string;
  /**
   * Badge text to display on the dock icon (e.g., unread count)
   */
  badge?: string;
}
interface ClientScriptEntry {
  /**
   * The filepath or module name to import from
   */
  importFrom: string;
  /**
   * The name to import the module as
   *
   * @default 'default'
   */
  importName?: string;
}
interface DevToolsViewIframe extends DevToolsDockEntryBase {
  type: 'iframe';
  url: string;
  /**
   * The id of the iframe, if multiple tabs is assigned with the same id, the iframe will be shared.
   *
   * When not provided, it would be treated as a unique frame.
   */
  frameId?: string;
  /**
   * Optional client script to import into the iframe
   */
  clientScript?: ClientScriptEntry;
  /**
   * Enable remote-UI mode: the core injects a connection descriptor
   * (WS URL + pre-approved auth token) into the iframe URL so a hosted
   * page can connect back via `connectRemoteDevTools()` from
   * `@vitejs/devtools-kit/client` — without needing to ship a dist with
   * the plugin.
   *
   * Requires dev mode (no effect in build mode — no WS server exists).
   * When enabled, the dock is automatically hidden in build mode unless
   * the author provides an explicit `when` clause.
   *
   * @example
   *   remote: true
   *   remote: { transport: 'query', originLock: false }
   */
  remote?: boolean | RemoteDockOptions;
}
interface RemoteDockOptions {
  /**
   * How to pass the connection descriptor to the hosted page.
   *
   * - `'fragment'` (default): appended as `#vite-devtools-kit-connection=...`.
   *   Not sent in HTTP requests or Referer headers — safest for auth tokens.
   * - `'query'`: appended as `?vite-devtools-kit-connection=...`. Use when
   *   your hosting platform rewrites fragments or your SPA router repurposes
   *   the fragment for navigation. The token will appear in server access
   *   logs and outbound Referer headers.
   *
   * @default 'fragment'
   */
  transport?: 'fragment' | 'query';
  /**
   * Reject WS handshakes whose `Origin` header doesn't match the dock URL
   * origin. Turn off when the same hosted app is served from multiple
   * origins (e.g. preview deploys).
   *
   * @default true
   */
  originLock?: boolean;
}
interface RemoteConnectionInfo extends ConnectionMeta {
  backend: 'websocket';
  websocket: string;
  v: 1;
  authToken: string;
  origin: string;
}
type DevToolsViewLauncherStatus = 'idle' | 'loading' | 'success' | 'error';
interface DevToolsViewLauncher extends DevToolsDockEntryBase {
  type: 'launcher';
  launcher: {
    icon?: DevToolsDockEntryIcon;
    title: string;
    status?: DevToolsViewLauncherStatus;
    error?: string;
    description?: string;
    buttonStart?: string;
    buttonLoading?: string;
    onLaunch: () => Promise<void>;
  };
}
interface DevToolsViewAction extends DevToolsDockEntryBase {
  type: 'action';
  action: ClientScriptEntry;
}
interface DevToolsViewCustomRender extends DevToolsDockEntryBase {
  type: 'custom-render';
  renderer: ClientScriptEntry;
}
interface DevToolsViewBuiltin extends DevToolsDockEntryBase {
  type: '~builtin';
  id: '~terminals' | '~messages' | '~client-auth-notice' | '~settings' | '~popup';
}
interface DevToolsViewJsonRender extends DevToolsDockEntryBase {
  type: 'json-render';
  /** JsonRenderer handle created by ctx.createJsonRenderer() */
  ui: _$devframe_types0.JsonRenderer;
}
type DevToolsDockUserEntry = DevToolsViewIframe | DevToolsViewAction | DevToolsViewCustomRender | DevToolsViewLauncher | DevToolsViewJsonRender;
type DevToolsDockEntry = DevToolsDockUserEntry | DevToolsViewBuiltin;
type DevToolsDockEntriesGrouped = [category: string, entries: DevToolsDockEntry[]][];
//#endregion
//#region src/types/terminals.d.ts
interface DevToolsTerminalHost {
  readonly sessions: Map<string, DevToolsTerminalSession>;
  readonly events: EventEmitter<{
    'terminal:session:updated': (session: DevToolsTerminalSession) => void;
  }>;
  register: (session: DevToolsTerminalSession) => DevToolsTerminalSession;
  update: (session: DevToolsTerminalSession) => void;
  startChildProcess: (executeOptions: DevToolsChildProcessExecuteOptions, terminal: Omit<DevToolsTerminalSessionBase, 'status'>) => Promise<DevToolsChildProcessTerminalSession>;
}
type DevToolsTerminalStatus = 'running' | 'stopped' | 'error';
interface DevToolsTerminalSessionBase {
  id: string;
  title: string;
  description?: string;
  status: DevToolsTerminalStatus;
  icon?: DevToolsDockEntryIcon;
}
interface DevToolsTerminalSession extends DevToolsTerminalSessionBase {
  buffer?: string[];
  stream?: ReadableStream<string>;
}
interface DevToolsChildProcessExecuteOptions {
  command: string;
  args: string[];
  cwd?: string;
  env?: Record<string, string>;
}
interface DevToolsChildProcessTerminalSession extends DevToolsTerminalSession {
  type: 'child-process';
  executeOptions: DevToolsChildProcessExecuteOptions;
  getChildProcess: () => ChildProcess | undefined;
  terminate: () => Promise<void>;
  restart: () => Promise<void>;
}
//#endregion
//#region src/node/context.d.ts
/**
 * Kit-augmented node context — extends devframe's framework-neutral
 * `DevToolsNodeContext` with the hub-level subsystems (`docks`,
 * `terminals`, `messages`, `commands`) that are owned by
 * `@vitejs/devtools-kit`. When kit hosts the devtool inside Vite
 * DevTools, also exposes the underlying Vite handles.
 */
interface KitNodeContext extends DevToolsNodeContext {
  docks: DevToolsDockHost;
  terminals: DevToolsTerminalHost;
  messages: DevToolsMessagesHost;
  commands: DevToolsCommandsHost;
  readonly viteConfig?: ResolvedConfig;
  readonly viteServer?: ViteDevServer;
}
interface CreateKitContextOptions extends CreateHostContextOptions {
  /** Optional Vite resolved config to surface on the context (for Vite-mounted hubs). */
  viteConfig?: ResolvedConfig;
  /** Optional Vite dev server to surface on the context. */
  viteServer?: ViteDevServer;
}
/**
 * Create a kit-level node context: wraps devframe's `createHostContext`,
 * attaches the hub hosts (`docks`, `terminals`, `messages`, `commands`),
 * and wires the shared-state synchronization that powers the unified
 * client UI.
 */
declare function createKitContext(options: CreateKitContextOptions): Promise<KitNodeContext>;
//#endregion
//#region src/types/vite-plugin.d.ts
interface DevToolsPluginOptions {
  capabilities?: {
    dev?: DevToolsCapabilities | boolean;
    build?: DevToolsCapabilities | boolean;
  };
  setup: (context: ViteDevToolsNodeContext) => void | Promise<void>;
}
/**
 * Vite-extended node context — kit-augmented context with the four hub
 * subsystems (`docks`, `terminals`, `messages`, `commands`) plus the
 * Vite-specific slots (`viteConfig`, `viteServer`). Plugins running
 * under `@vitejs/devtools` rely on this surface; portable devframe
 * apps should target {@link KitNodeContext} or the framework-neutral
 * `DevToolsNodeContext` from `devframe/types`.
 */
interface ViteDevToolsNodeContext extends KitNodeContext {
  readonly viteConfig: ResolvedConfig;
  readonly viteServer?: ViteDevServer;
}
/**
 * @deprecated — alias of {@link ViteDevToolsNodeContext}. Exists for one
 * release cycle while callers migrate.
 */
type DevToolsNodeContext$1 = ViteDevToolsNodeContext;
//#endregion
//#region src/types/vite-augment.d.ts
declare module 'vite' {
  interface Plugin {
    devtools?: DevToolsPluginOptions;
  }
}
interface PluginWithDevTools extends Plugin {
  devtools?: DevToolsPluginOptions;
}
//#endregion
export { RemoteDockOptions as A, DevToolsMessageElementPosition as B, DevToolsViewBuiltin as C, DevToolsViewLauncher as D, DevToolsViewJsonRender as E, DevToolsLogFilePosition as F, DevToolsMessageHandle as G, DevToolsMessageEntryFrom as H, DevToolsLogHandle as I, DevToolsMessagesHost as J, DevToolsMessageLevel as K, DevToolsLogLevel as L, DevToolsLogEntry as M, DevToolsLogEntryFrom as N, DevToolsViewLauncherStatus as O, DevToolsLogEntryInput as P, DevToolsLogsClient as R, DevToolsViewAction as S, DevToolsViewIframe as T, DevToolsMessageEntryInput as U, DevToolsMessageEntry as V, DevToolsMessageFilePosition as W, DevToolsDockEntryBase as _, CreateKitContextOptions as a, DevToolsDockHost as b, DevToolsChildProcessExecuteOptions as c, DevToolsTerminalSession as d, DevToolsTerminalSessionBase as f, DevToolsDockEntry as g, DevToolsDockEntriesGrouped as h, ViteDevToolsNodeContext as i, DevToolsLogElementPosition as j, RemoteConnectionInfo as k, DevToolsChildProcessTerminalSession as l, ClientScriptEntry as m, DevToolsNodeContext$1 as n, KitNodeContext as o, DevToolsTerminalStatus as p, DevToolsMessagesClient as q, DevToolsPluginOptions as r, createKitContext as s, PluginWithDevTools as t, DevToolsTerminalHost as u, DevToolsDockEntryCategory as v, DevToolsViewCustomRender as w, DevToolsDockUserEntry as x, DevToolsDockEntryIcon as y, DevToolsLogsHost as z };