import { TextField } from "./editor/fieldTypes";
import { ItemDescriptor, Version } from "./editor/pageModel";
export type { ItemDescriptor };
export type Rendering = {
    id: string;
    name: string;
    icon: string;
};
export type EditableDictionary = {
    [key: string]: TextField;
};
export type ValidationResult = {
    item: ItemDescriptor;
    results: SingleValidatorResult[];
};
export type SingleValidatorResult = {
    itemId: string;
    itemName: string;
    fieldId: string;
    fieldName: string;
    validator: string;
    result: 0 | 1 | 2 | 3 | 4 | 5;
    message: string;
};
export type FieldDescriptor = {
    item: ItemDescriptor;
    fieldId: string;
    fieldName?: string;
};
export type LanguageVersions = {
    languageCode: string;
    countryCode: string;
    name: string;
    versions: number;
    icon: string;
};
export type AiPrompt = {
    title: string;
    prompt: string;
};
export type EditData = {
    loginUrl: string;
    aiPrompts: AiPrompt[];
};
export type EditSession = {
    sessionId: string;
    url?: string;
    user: User;
    userAgent?: string;
    page?: ItemDescriptor;
    item?: ItemDescriptor;
    fieldLock?: {
        item: ItemDescriptor;
        fieldId: string;
    };
    color: string;
};
export type EditOperation = {
    type: "edit-field" | "remove-component" | "move-component" | "add-component" | "synchronize-components" | "link-component" | "duplicate-components" | "rename-item" | "change-template" | "create-item" | "delete-items" | "add-version" | "remove-version" | "move-items" | "copy-items" | "clone-items" | "import-items" | "publish-item" | "convert-to-shared" | "update-rendering-parameters" | "update-rendering-rules";
    date: string;
    id: string;
    user?: User;
    undone?: boolean;
    sessionId?: string;
    title: string;
    description?: string;
    canUndo?: boolean;
    canRedo?: boolean;
    /**
     * True if the backend captured enough information to support undo for this operation.
     * When false, the UI should show a "not undoable" indicator and avoid calling undo.
     */
    undoSupported?: boolean;
    /** Optional explanation for why undo is not supported. */
    undoNotSupportedReason?: string;
    focus?: string;
    mainItem: ItemDescriptor;
    mainItemPath?: string;
    /** Populated when the server completes copy/create flows (e.g. for selection / terminal waiters). */
    createdItemIds?: string[];
    /** Source items for copy-items / move-items style operations. */
    sourceItemIds?: string[];
    /** Destination parent for copy-items / move-items. */
    targetParentId?: string;
    agentId?: string;
    toolCallId?: string;
    /** Execution status for long-running operations: pending, executing, completed, or failed */
    executionStatus?: "pending" | "executing" | "completed" | "failed";
    /** Human-readable status message for progress updates */
    statusMessage?: string;
    /** Progress percentage (0-100) for long-running operations */
    progress?: number;
    /** When the operation execution started */
    executionStarted?: string;
    /** When the operation execution completed */
    executionCompleted?: string;
    /** Error message if execution failed */
    errorMessage?: string;
};
export type RenameItemOperation = EditOperation & {
    type: "rename-item";
    item: ItemDescriptor;
    newName: string;
    oldName?: string;
};
export type ChangeTemplateOperation = EditOperation & {
    type: "change-template";
    itemId: string;
    newTemplateId: string;
    oldTemplateId?: string;
};
export type EditFieldOperation = EditOperation & {
    type: "edit-field";
    itemId: string;
    fieldName: string;
    fieldId: string;
    fieldType?: string;
    value?: any;
    oldValue?: any;
};
export type AddComponentOperation = EditOperation & {
    type: "add-component";
    componentTypeId: string;
    placeholderKey: string;
    placeholderIndex: number;
    componentId?: string;
    /**
     * When true, write the rendering into Sitecore's shared layout (__Renderings),
     * making it visible across all language versions. Default false (per-language final layout).
     * Honored only by providers that opt in via `supportsLanguageSharedLayout`.
     */
    addToSharedLayout?: boolean;
};
export type LinkComponentOperation = EditOperation & {
    type: "link-component";
    itemName?: string;
    linkedComponentItem: ItemDescriptor;
};
export type MoveComponentOperation = EditOperation & {
    type: "move-component";
    placeholderKey: string;
    placeholderIndex: number;
    componentIds: string[];
};
export type DuplicateComponentsOperation = EditOperation & {
    type: "duplicate-components";
    componentIds: string[];
    sourceComponentIds: string[];
};
export type RemoveComponentOperation = EditOperation & {
    type: "remove-component";
    componentIds: string[];
};
export type SynchronizeComponentsOperation = EditOperation & {
    type: "synchronize-components";
    placeholders: PlaceholderToSynchronize[];
    delete: boolean;
    itemsCreated?: ItemDescriptor[];
};
export type CreateItemOperation = EditOperation & {
    type: "create-item";
    parentId: string;
    templateId: string;
    branchId?: string;
    name: string;
    createdItemId?: string;
};
export type DeleteItemsOperation = EditOperation & {
    type: "delete-items";
    items: ItemDescriptor[];
    hardDelete?: boolean;
};
export type MoveItemsOperation = EditOperation & {
    type: "move-items";
    itemIds: string[];
    targetParentId: string;
    targetIndex?: number;
    originalParentIds?: Record<string, string>;
};
export type CopyItemsOperation = EditOperation & {
    type: "copy-items";
    sourceItemIds: string[];
    targetParentId: string;
    targetIndex?: number;
    createdItemIds?: string[];
    /** Optional name for the copied item (used for duplicate/single item copy) */
    name?: string;
};
export type CloneItemsOperation = EditOperation & {
    type: "clone-items";
    sourceItemIds: string[];
    targetParentId: string;
    targetIndex?: number;
    createdItemIds?: string[];
    /** Optional name for the cloned item (used for single-item clone flows) */
    name?: string;
};
export type ImportItemsOperation = EditOperation & {
    type: "import-items";
    targetItem: ItemDescriptor;
    yaml: string;
    restoreToOriginalParents?: boolean;
    createdItemIds?: string[];
    successCount?: number;
    failureCount?: number;
    summary?: string;
};
export type PublishMode = "smart" | "republish";
export type PublishItemOperation = EditOperation & {
    type: "publish-item";
    item: ItemDescriptor;
    targetDatabases: string[];
    languages: string[];
    publishMode: PublishMode;
    includeSubitems: boolean;
    publishRelatedItems: boolean;
    publishedTargets?: string[];
    publishedLanguages?: string[];
};
export type AddVersionOperation = EditOperation & {
    type: "add-version";
    item: ItemDescriptor;
    newVersion?: number;
};
export type RemoveVersionOperation = EditOperation & {
    type: "remove-version";
    item: ItemDescriptor;
    version: number;
};
export type ConvertToSharedOperation = EditOperation & {
    type: "convert-to-shared";
    componentId: string;
    targetFolderId?: string;
};
export type UpdateRenderingParametersOperation = EditOperation & {
    type: "update-rendering-parameters";
    componentId: string;
    parameters: Record<string, string | null>;
    previousParameters?: Record<string, string | null>;
};
export type PersonalizationRuleSet = {
    rules: PersonalizationRule[];
    rawRulesXml?: string;
    activeRuleId?: string;
    unsupported?: boolean;
    unsupportedReasons?: string[];
};
export type PersonalizationRule = {
    uid: string;
    name: string;
    conditions: PersonalizationConditionNode | null;
    actions: PersonalizationAction[];
    unsupported?: boolean;
};
export type PersonalizationConditionNode = {
    kind: "leaf";
    definitionItemId: string;
    uniqueId?: string;
    parameters: Record<string, string>;
} | {
    kind: "composite";
    op: "and" | "or" | "not";
    children: PersonalizationConditionNode[];
} | {
    kind: "unsupported";
    parameters?: Record<string, string>;
};
export type PersonalizationAction = {
    uid: string;
    definitionItemId: string;
    parameters: Record<string, string>;
};
export type RuleElementParameter = {
    name: string;
    source?: string;
    title?: string;
    type: string;
    rootItemId?: string;
    operators?: RuleOperator[];
};
export type RuleOperator = {
    id: string;
    name: string;
    displayName: string;
};
export type RuleElement = {
    id: string;
    name: string;
    displayName: string;
    text: string;
    category: string;
    kind: "condition" | "action";
    parameters: RuleElementParameter[];
};
export type UpdateRenderingRulesOperation = EditOperation & {
    type: "update-rendering-rules";
    componentId: string;
    rulesJson: string;
    previousRulesXml?: string;
};
export type PlaceholderToSynchronize = {
    name?: string;
    item?: ItemDescriptor | null;
};
/**
 * Workspace settings from Sitecore, containing available sidebars for this workspace.
 */
export type WorkspaceSettings = {
    /** Workspace identifier (e.g., "editor", "settings", "agents-overview") */
    id: string;
    /** List of sidebar IDs available for this workspace */
    sidebars: string[];
};
export type UserInfo = {
    user: User;
    /** Workspace settings with nested sidebars - use this for new code */
    workspaces?: WorkspaceSettings[];
    browseHistory?: UserBrowseHistoryEntry[];
    preferences: UserPreferences;
};
export type User = {
    name: string;
    fullName?: string;
    ai: boolean;
    agentId?: string;
    email?: string;
    isLimitedPreviewUser?: boolean;
    isAdministrator?: boolean;
    /** URL of the user's uploaded avatar image, server-resolved. Absent → render initials. */
    avatarUrl?: string;
};
export type UserPreferences = {
    pinnedSidebars?: string[];
    showSidebarLabels?: boolean;
    showDebugButtons?: boolean;
    showDisplayNames?: boolean;
    showComponentNavigator?: boolean;
    showAgentsPanel?: boolean;
    showMinimap?: boolean;
    showLayoutComponents?: boolean;
    gutterVisibility?: string[];
    gutterShowBadges?: boolean;
    lockedSidebars?: string[];
    /** Legacy default for whether newly opened editor slots start with the editor form hidden. */
    editorFormHidden?: boolean;
    /** Set to true once the user has seen the first-time hint explaining how to re-open the editor form. */
    editorFormHintSeen?: boolean;
    /** Last selected target folder for AI image jobs (Sitecore media folder item ID) */
    aiImageTargetFolderId?: string;
    /** ISO timestamp for the latest feedback item the user has seen on the home screen. */
    latestFeedbackLastSeenAt?: string;
};
export type HistoryEntry = {
    name: string;
    path: string;
    id: string;
    version: number;
    hasLayout: boolean;
    icon?: string;
    templateName: string;
    language: string;
    visitedAt?: string;
};
export type NavigationHistoryEntry = {
    workspaceId: string;
    item?: {
        id: string;
        language: string;
        version: number;
    };
    timestamp: number;
    displayName: string;
    itemName?: string;
    itemPath?: string;
    itemIcon?: string;
};
export type UserBrowseHistoryEntry = {
    id: number;
    userName: string;
    itemId: string;
    itemLanguage: string;
    itemVersion: number;
    visitedAt: string;
    sessionId?: string;
    itemPath: string;
    itemName: string;
    icon?: string;
};
export type FieldHistoryItem = {
    user: string;
    date: string;
    ai: boolean;
    agentId?: string;
    isBaseline?: boolean;
    itemHistoryIndex?: number;
    value: unknown;
    rawValue: string;
    version: number;
    undone: boolean;
};
export type Site = {
    name: string;
};
export type ExecuteEditOptions = {
    refresh: "none" | "immediate" | "delayed" | "waitForQuietPeriod";
};
export type Workbox = {
    items: WorkboxItem[];
};
export type WorkboxItem = {
    item: ItemDescriptor;
    lockedBy: string;
    canLock: boolean;
    hasLock: boolean;
    publishStatus: {
        [target: string]: string;
    };
    workflowState: string;
    isFinalState: boolean;
    isPublishable: boolean;
    isPublished: boolean;
    path: string;
    icon?: string;
    name: string;
    workflowCommands: {
        name: string;
        id: string;
    }[];
};
export type InsertAction = {
    type: string;
    data?: Record<string, unknown>;
};
export type InsertOption = {
    typeId: string;
    name: string;
    icon: string;
    thumbnail?: string;
    group?: string;
    svg?: string;
    isInvalid: boolean;
    message?: string;
    isHidden: any;
    compatibleTypeIds?: string[];
    isCommandTemplate?: boolean;
    action?: InsertAction;
};
export type LanguagesAndVersions = {
    languages: LanguageVersions[];
    versions: Version[];
    itemPublishingRestrictions?: {
        neverPublish: boolean;
        neverPublishFieldId?: string | null;
        publish?: string | null;
        publishFieldId?: string | null;
        unpublish?: string | null;
        unpublishFieldId?: string | null;
    };
    publishingTargets?: {
        name: string;
        targetDatabase: string;
        status: string;
        message: string;
    }[];
};
export type IndexStatus = {
    numberOfIndexedItems: number;
    rebuilding: boolean;
    pendingCount: number;
    batches: EmbeddingBatch[];
    latestEmbeddedItems?: LatestEmbeddedItem[];
    messages?: SystemStatusMessage[];
};
export type EmbeddingBatch = {
    id: string;
    status: string;
    numberOfItems: number;
    created: string;
    errorMessage?: string;
    firstErrors?: string[];
    errorCount?: number;
};
export type LatestEmbeddedItem = {
    itemId: string;
    name?: string;
    path?: string;
    created: string;
};
export type CollectAndStageResult = {
    rebuildId: string;
    requestCount: number;
    estimatedInputTokens: number;
    estimatedBatchCost: number;
    estimatedDirectCost: number;
};
export type CurrentStagingStats = {
    pendingCount: number;
    estimatedTokens: number;
    estimatedBatchCost: number;
    estimatedDirectCost: number;
};
export type GenerationMode = "auto" | "batch" | "direct";
export type ProviderInfo = {
    providerId: string;
    supportsBatchApi: boolean;
    endpointName: string;
    modelName: string;
};
export type ImportStatus = {
    isImporting: boolean;
    status: string;
    startedAt?: string;
    successCount?: number;
    errorCount?: number;
    recentErrors?: string[];
};
export type CentroidsStatus = {
    isPopulating: boolean;
    status: string;
    startedAt?: string;
};
export type CollectionStatus = {
    isCollecting: boolean;
    status: string;
    startedAt?: string;
    itemsProcessed: number;
    languageVersionsProcessed: number;
    batchesUploaded: number;
    subPhase?: string;
    currentItem?: string;
    currentBatch?: number;
    /**
     * Non-fatal warnings from staging / real-time indexing, e.g. text truncated
     * to fit the embedding model's max input tokens. Shown on the index status
     * page instead of the Sitecore log.
     */
    recentWarnings?: string[];
};
export type CombinedIndexStatus = {
    indexStatus: IndexStatus | null;
    importStatus: ImportStatus | null;
    centroidsStatus: CentroidsStatus | null;
    collectionStatus: CollectionStatus | null;
    queueStatus: QueueProcessorStatus | null;
};
export type QueueProcessorStatus = {
    isRunning: boolean;
    status: string;
    startedAt?: string;
    processedCount: number;
    errorCount: number;
    pendingCount: number;
    recentErrors: string[];
};
export type BatchInfo = {
    batchId: string;
    status: string;
    requestCount: number;
    createdAt: string;
    completedAt?: string;
    errorMessage?: string;
    firstErrors?: string[];
    errorCount?: number;
};
export type Error = {
    message: string;
    details: string;
};
export type CommentRelatedItem = {
    itemId: string;
    created: string;
    createdBy: string;
    itemName?: string;
    itemPath?: string;
    templateName?: string;
};
export type Comment = {
    id: string;
    isNew: boolean;
    parentCommentId?: string;
    itemId: string;
    itemName?: string;
    mainItemName?: string;
    mainItemId: string;
    language: string;
    version: number;
    fieldId?: string;
    fieldName?: string;
    text?: string;
    fieldValue?: string | null;
    rangeStart?: number;
    rangeEnd?: number;
    author?: string;
    authorDisplayName?: string;
    created?: string;
    tags?: string;
    isResolved?: boolean;
    resolvedBy?: string;
    resolvedDate?: string;
    suggestedEditId?: string;
    position: number;
    relatedItems?: CommentRelatedItem[];
};
export type CommentTag = {
    label: string;
    color: string;
};
export type ReviewWithPages = {
    reviewId: string;
    collectionId: string;
    title?: string;
    language: string;
    createdBy: string;
    createdAt: string;
    finalDecision?: "Approved" | "Rejected";
    finalDecisionDate?: string;
    expiresAtUtc?: string;
    isExpired?: boolean;
    requiresSecret?: boolean;
    requiredApprovals?: number;
    updateWorkflowOnCompletion?: boolean;
    shareCommentsAndSuggestions?: boolean;
};
export type ReviewAssignment = {
    assignmentId: string;
    reviewId: string;
    reviewerEmail: string;
    reviewerName: string;
    reviewerUserName?: string;
    invitationSentDate?: string;
    assignedBy?: string;
    assignedAt: string;
    decisions?: ItemDecision[];
    secretValidated?: boolean;
};
/** Review header plus assignments (e.g. from GET /parhelia/reviews/index). */
export type ReviewWithAssignments = {
    review: ReviewWithPages;
    assignments: ReviewAssignment[];
};
export type ItemDecision = {
    decisionId: string;
    assignmentId: string;
    itemId: string;
    itemLanguage: string;
    itemVersion?: number;
    decision: "Approved" | "Rejected";
    decisionDate: string;
};
export type ReviewItemStatus = {
    itemId: string;
    language: string;
    includeSubitems: boolean;
    decisions?: {
        [reviewerEmail: string]: {
            decision: "Approved" | "Rejected";
            decisionDate: string;
        };
    };
};
export type ReviewListItem = {
    reviewId: string;
    title?: string;
    language: string;
    createdBy: string;
    createdAt: string;
    reviewersCount: number;
    pagesCount: number;
    commentsCount?: number;
    suggestionsCount?: number;
    finalDecision?: "Approved" | "Rejected";
    finalDecisionDate?: string;
    status?: "Approved" | "Rejected";
    expiresAtUtc?: string;
    isExpired?: boolean;
    requiresSecret?: boolean;
    secretValidated?: boolean;
    requiredApprovals?: number;
    updateWorkflowOnCompletion?: boolean;
};
export type CreateReviewRequest = {
    title?: string;
    languages?: string[];
    reviewers: ReviewerInfo[];
    items: ItemWithSubtree[];
    expirationUtc?: string;
    secret?: string;
    requiredApprovals?: number;
    updateWorkflowOnCompletion?: boolean;
    shareCommentsAndSuggestions?: boolean;
};
export type ReviewerInfo = {
    name: string;
    email: string;
    userName?: string;
};
export type ItemWithSubtree = {
    descriptor: ItemDescriptor;
    includeSubitems: boolean;
};
export type SystemStatusMessage = {
    message: string;
    severity: "info" | "warning" | "error";
};
export type SystemStatus = {
    messages: SystemStatusMessage[];
    settingsExist: boolean;
    setupComplete: boolean;
    currentSiteName?: string;
    shellSiteResolved?: boolean;
    parheliaDatabase?: {
        connectionStringName?: string;
        databaseName?: string;
        serverName?: string;
    };
};
export type ParheliaSettings = {
    itemNameValidation?: string;
    invalidItemNameChars?: string;
    maxItemNameLength?: number;
    defaultComponentsFolderName?: string;
    currency?: string;
    commentResolveProfileId?: string;
    commentResolveProfileName?: string;
    environmentLabel?: string;
    environmentColor?: string;
    aiTextEditProfileId?: string;
    showMinimap?: boolean;
    itemCloningEnabled?: boolean;
    enableWebSocketTransport?: boolean;
    enableSseFallback?: boolean;
};
export type SamplePrompt = {
    title: string;
    description: string;
    prompt: string;
};
export type HomeQuickAction = {
    id: string;
    title: string;
    description: string;
    svgIcon?: string;
    commandType: string;
    sortOrder: number;
    settings: Record<string, unknown>;
};
export type AiTextEditPrompt = {
    id: string;
    label: string;
    icon: string;
    instruction: string;
};
export interface SuggestedEdit {
    id: string;
    mainItemId: string;
    mainItemLanguage: string;
    mainItemVersion: number;
    mainItemName?: string;
    itemId: string;
    itemName?: string;
    fieldId: string;
    oldValue: string;
    newValue: string;
    author?: string;
    authorDisplayName?: string;
    created?: string;
    status: "rejected" | "applied" | "pending";
    updatedBy?: string;
    updated?: string;
    comments?: string;
    type: string;
}
export type ContentEditorWarning = {
    title: string;
    text: string;
    icon?: string;
    isExclusive?: boolean;
};
