/**
 * WorkspaceViewer.ts — 工作区文件浏览器 UI 组件（基于 Shadow DOM 的文件树）
 *
 * 支持工作区/挂载文件夹切换、文件预览/编辑、搜索、新建、打开/删除文件、原始视图等。
 */
/** WorkspaceViewer 构造选项 */
export interface WorkspaceViewerOptions {
    /** 挂载容器元素（必填） */
    container?: HTMLElement;
    /** KeepworkSDK 实例（默认 window.keepwork） */
    sdk?: unknown;
    /** 工作区名（默认 'workspace_default'） */
    workspace?: string;
    /** 可选挂载文件夹 */
    mountFolder?: string;
    /** 初始打开的文件 */
    file?: string;
    /** 隐藏顶栏 */
    hideTopbar?: boolean;
    /** 隐藏工具栏 */
    hideToolbar?: boolean;
    /** 紧凑布局 */
    compact?: boolean;
    /** 显示名映射 */
    displayNameMap?: Record<string, string>;
    /** 隐藏的页面根 */
    hiddenPageRoots?: string[];
    /** 只读模式 */
    readOnly?: boolean;
    /** 隐藏用户信息 */
    hideUserInfo?: boolean;
    /** 隐藏搜索 */
    hideSearch?: boolean;
    /** 隐藏新建文件 */
    hideNewFile?: boolean;
    /** 隐藏打开文件 */
    hideOpenFile?: boolean;
    /** 隐藏删除 */
    hideDelete?: boolean;
    /** 隐藏原始视图 */
    hideRawView?: boolean;
    /** 允许切换工作区 */
    allowChangeWorkspace?: boolean;
    /** 允许切换挂载文件夹 */
    allowChangeMount?: boolean;
    [key: string]: unknown;
}
/** PersonalPageStore（workspace-scoped）结构化接口 */
interface WVStore {
    mountedFolder?: unknown;
    _remoteTreeCache?: unknown;
    listDir(path: string, recursive?: boolean): Promise<string>;
    readFile(path: string): Promise<string>;
    loadPageData(key: string, sub: string | null, a: boolean, b: boolean): Promise<unknown>;
    savePageData(key: string, sub: string, value: unknown, a: boolean, b: boolean): Promise<unknown>;
    clearPageData(key: string): Promise<unknown>;
    clearLocalDisk(key: string): Promise<unknown>;
    grepSearch(query: string, isRegexp: boolean, fileFilter?: string): Promise<string>;
    _readMountedFile(key: string): Promise<string | null>;
    [key: string]: unknown;
}
/** WorkspaceViewer 依赖的 SDK 表面 */
interface WVSdk {
    token?: unknown;
    personalPageStore: {
        withWorkspace(workspace: string, mountFolder: string | null): WVStore;
        [key: string]: unknown;
    };
    getUserProfile(opts: {
        forceRefresh: boolean;
    }): Promise<Record<string, unknown>>;
    showLoginWindow(opts: {
        title: string;
    }): Promise<{
        token?: unknown;
    } | null>;
    showProfileWindow(): unknown;
    [key: string]: unknown;
}
/** 页面数据（含可选 content / _metadata / metadata 及任意字段） */
type WVPageData = (Record<string, unknown> & {
    content?: unknown;
    _metadata?: unknown;
    metadata?: unknown;
}) | null | undefined;
/** 内部状态 */
interface WVState {
    selectedFile: string | null;
    viewMode: 'content' | 'raw' | 'edit';
    fileItems: string[];
    isMounted: boolean;
    mountedPageSet: Set<string> | null;
    selectedFolder: string | null;
    expandedFolders: Set<string>;
    folderChildren: Record<string, string[]>;
    editPageData: {
        content: string;
    } | null;
    absFiles: string[];
}
/** 解析后的选项（构造内部使用） */
interface WVResolvedOptions {
    workspace: string;
    mountFolder: string;
    file: string;
    hideTopbar: boolean;
    hideToolbar: boolean;
    compact: boolean;
    readOnly: boolean;
    hideUserInfo: boolean;
    hideSearch: boolean;
    hideNewFile: boolean;
    hideOpenFile: boolean;
    hideDelete: boolean;
    hideRawView: boolean;
    allowChangeWorkspace: boolean;
    allowChangeMount: boolean;
}
export declare class WorkspaceViewer {
    sdk: WVSdk;
    StorageUtil: unknown;
    options: WVResolvedOptions;
    currentWorkspace: string;
    displayNameMap: Record<string, string>;
    hiddenPageRoots: string[];
    _state: WVState;
    container: HTMLElement;
    shadowRoot: ShadowRoot;
    root: HTMLElement;
    dom: Record<string, HTMLElement & Record<string, unknown>>;
    _handlers: Record<string, EventListener>;
    constructor(options?: WorkspaceViewerOptions);
    _bindDom(): void;
    _bindEvents(): void;
    _applyFeatureFlags(): void;
    _applyLayoutModes(): void;
    _initBadges(): void;
    _updateBadges(): void;
    initLogin(): Promise<void>;
    showUser(profile: Record<string, unknown> | null): void;
    _promptChangeWorkspace(): void;
    _promptChangeMount(): void;
    _promptOpenFile(): Promise<void>;
    switchWorkspace(workspace: string): Promise<void>;
    setMountFolder(mountFolder: string): Promise<void>;
    _getMountedStore(): WVStore;
    _getLocalStore(): WVStore;
    startWorkspace(): Promise<void>;
    loadWorkspace(): Promise<void>;
    renderFileList(): void;
    renderItems(items: string[], container: HTMLElement, depth: number, parentPath: string): void;
    toggleFolder(folderPath: string, el: HTMLElement, depth: number): Promise<void>;
    selectFile(name: string): Promise<void>;
    loadFileData(): Promise<WVPageData>;
    _updateRevisionInfo(data: WVPageData): void;
    renderContent(): Promise<void>;
    renderEditView(): Promise<void>;
    syncViewModeUI(): void;
    setViewMode(mode: 'content' | 'raw' | 'edit'): void;
    addAbsoluteFile(absPath: string): Promise<boolean>;
    saveEdit(): Promise<void>;
    runSearch(): Promise<void>;
    createNewFile(): Promise<void>;
    deleteSelected(): Promise<void>;
    formatValue(v: unknown): string;
    escapeHtml(s: string): string;
    _getDisplayName(name: string, parentPath: string): string;
    _filterVisibleEntries(entries: string[], parentPath: string): string[];
    _isMarkdownFile(filePath: string): boolean;
    _formatMarkdownContent(text: string): string;
    _inlineFormat(text: string): string;
    _isEditableFile(filePath: string | null): boolean;
    _isMountedFile(filePath: string): boolean;
    _getLoadedFileCount(): number;
    _syncToolbar(): void;
    refreshWorkspace(): Promise<void>;
    _toggleFileTreeMobile(): void;
    _collapseFileTreeMobile(): void;
    _expandFileTreeMobile(): void;
    destroy(): void;
}
export declare function createWorkspaceViewer(options: WorkspaceViewerOptions): WorkspaceViewer;
export default WorkspaceViewer;
//# sourceMappingURL=WorkspaceViewer.d.ts.map