import { Event } from "../../../../../base/common/event.js";
import { IMatch } from "../../../../../base/common/filters.js";
import { Disposable, IDisposable } from "../../../../../base/common/lifecycle.js";
import { ResourceMap } from "../../../../../base/common/map.js";
import { ThemeIcon } from "../../../../../base/common/themables.js";
import { URI } from "../../../../../base/common/uri.js";
import { ExtensionIdentifier } from "../../../../../platform/extensions/common/extensions.js";
import { IFileService } from "../../../../../platform/files/common/files.service.js";
import { ILabelService } from "../../../../../platform/label/common/label.service.js";
import { IProductService } from "../../../../../platform/product/common/productService.service.js";
import { IPathService } from "../../../../services/path/common/pathService.service.js";
import { IAICustomizationWorkspaceService } from "../../common/aiCustomizationWorkspaceService.service.js";
import { ICustomizationItem, ICustomizationItemProvider } from "../../common/customizationHarnessService.js";
import { PromptsType } from "../../common/promptSyntax/promptTypes.js";
import { IPromptsService } from "../../common/promptSyntax/service/promptsService.service.js";
import { type AICustomizationSource } from "./aiCustomizationManagement.js";
/**
 * Represents an AI customization item in the list widget.
 */
export interface IAICustomizationListItem {
    readonly id: string;
    readonly uri: URI;
    readonly name: string;
    readonly filename: string;
    readonly description?: string;
    /** Storage or provider origin. All items, including those from external providers, must provide a source. */
    readonly source: AICustomizationSource;
    readonly promptType: PromptsType;
    readonly disabled: boolean;
    /** When set, overrides `source` for display grouping purposes. */
    readonly groupKey?: string;
    /** URI of the parent plugin, when this item comes from an installed plugin. */
    readonly pluginUri?: URI;
    /** When set, overrides the formatted name for display. */
    readonly displayName?: string;
    /** When set, shows a small inline badge next to the item name. */
    readonly badge?: string;
    /** Tooltip shown when hovering the badge. */
    readonly badgeTooltip?: string;
    /** When set, overrides the default prompt-type icon. */
    readonly typeIcon?: ThemeIcon;
    /** True when item comes from the default chat extension (grouped under Built-in). */
    readonly isBuiltin?: boolean;
    /** Display name of the contributing extension (for non-built-in extension items). */
    readonly extensionId?: string;
    /** Server-reported loading/sync status for remote customizations. */
    readonly status?: "loading" | "loaded" | "degraded" | "error";
    /** Human-readable status detail (e.g. error message or warning). */
    readonly statusMessage?: string;
    /** When true, this item can be selected for syncing to a remote harness. */
    readonly syncable?: boolean;
    /** When true, this syncable item is currently selected for syncing. */
    readonly synced?: boolean;
    nameMatches?: IMatch[];
    descriptionMatches?: IMatch[];
}
/**
 * Browser-internal item source consumed by the list widget.
 *
 * Item sources fetch provider-shaped customization rows, normalize them into
 * the browser-only list item shape, and add view-only overlays such as sync state.
 */
export interface IAICustomizationItemSource extends IDisposable {
    readonly sessionResource: URI;
    readonly onDidAICustomizationItemsChange: Event<void>;
    fetchProviderItems(): Promise<readonly ICustomizationItem[]>;
    fetchAICustomizationItems(promptType: PromptsType): Promise<IAICustomizationListItem[]>;
}
/**
 * Returns true if the given extension identifier matches the default
 * chat extension (e.g. GitHub Copilot Chat). Used to group items from
 * the chat extension under "Built-in" instead of "Extensions".
 */
export declare function isChatExtensionItem(extensionId: ExtensionIdentifier, productService: IProductService): boolean;
/**
 * Derives a friendly name from a filename by removing extension suffixes.
 */
export declare function getFriendlyName(filename: string): string;
/**
 * Expands hook file items into individual hook entries by parsing hook
 * definitions from the file content. Falls back to the original item
 * when parsing fails.
 */
export declare function expandHookFileItems(hookFileItems: readonly ICustomizationItem[], workspaceService: IAICustomizationWorkspaceService, fileService: IFileService, pathService: IPathService): Promise<ICustomizationItem[]>;
/**
 * Converts provider-shaped customization rows into the rich list model used by the management UI.
 */
export declare class AICustomizationItemNormalizer {
    private readonly labelService;
    private readonly productService;
    constructor(labelService: ILabelService, productService: IProductService);
    normalizeItems(items: readonly ICustomizationItem[], promptType: PromptsType): IAICustomizationListItem[];
    normalizeItem(item: ICustomizationItem, promptType: PromptsType, uriUseCounts?: ResourceMap<number>): IAICustomizationListItem;
    private inferStorageAndGroup;
}
/**
 * Item source backed by a session-scoped customization item provider.
 */
export declare class ItemProviderItemSource extends Disposable implements IAICustomizationItemSource {
    readonly sessionResource: URI;
    private readonly itemProvider;
    private readonly promptsService;
    private readonly workspaceService;
    private readonly fileService;
    private readonly pathService;
    private readonly itemNormalizer;
    readonly onDidAICustomizationItemsChange: Event<void>;
    private cachedPromise;
    constructor(sessionResource: URI, itemProvider: ICustomizationItemProvider, promptsService: IPromptsService, workspaceService: IAICustomizationWorkspaceService, fileService: IFileService, pathService: IPathService, itemNormalizer: AICustomizationItemNormalizer);
    fetchProviderItems(): Promise<readonly ICustomizationItem[]>;
    fetchAICustomizationItems(promptType: PromptsType): Promise<IAICustomizationListItem[]>;
    /**
     * Merges built-in skills (bundled with the app under `vs/sessions/skills/`)
     * into the provider's items. The provider may re-discover the bundled
     * copies when scanning disk — those duplicates are dropped (deduped by
     * URI) and replaced with the authoritative built-in entry tagged
     * `groupKey: BUILTIN_STORAGE` so the UI renders them in the "Built-in"
     * group. User-authored overrides (different URI, same name) are preserved.
     *
     * A workbench that uses the base `PromptsService` will throw on
     * `BUILTIN_STORAGE` — we catch and return the items unchanged in that case.
     */
    private mergeBuiltinSkills;
    private addSkillDescriptionFallbacks;
}
export declare class PureItemProviderItemSource extends Disposable implements IAICustomizationItemSource {
    readonly sessionResource: URI;
    private readonly itemProvider;
    private readonly itemNormalizer;
    readonly onDidAICustomizationItemsChange: Event<void>;
    private cachedPromise;
    constructor(sessionResource: URI, itemProvider: ICustomizationItemProvider, itemNormalizer: AICustomizationItemNormalizer);
    fetchProviderItems(): Promise<readonly ICustomizationItem[]>;
    fetchAICustomizationItems(promptType: PromptsType): Promise<IAICustomizationListItem[]>;
}
