import { DataAsset } from '../../../../../core/modules/data-assets';
import { SharedProtectionPlanRepository } from '../../domain/repositories/shared-protection-plan-repository';
import { SharedMergingProcessRepository } from '../../domain/repositories/shared-merging-process-repository';
import { SharedPlanEventListener } from '../../domain/services/shared-plan-event-listener';
import { ShareEncryptionService } from '../../domain/services/share-encryption-service';
import { SharedPlanErrorReporter } from '../../domain/services/shared-plan-error-reporter';
import { SharedPlanApprovalOrchestrator } from '../../domain/services/shared-plan-approval-orchestrator';
import { RevealSharedPlanDataUseCase } from './reveal-shared-plan-data-use-case';
import { SharedPlanMergeProcessView } from '../../domain/models/shared-plan-merge-process-view';
import { SharedRevealOptions } from '../../domain/repositories/shared-merging-process-api-repository';
export type RevealStep = 'DISTRIBUTING_CUSTODIAN_SHARE' | 'OPENING_WINDOW' | 'COLLECTING_SHARES' | 'RECONSTRUCTING' | 'PREPARING_VIEW';
export type RevealStepStatus = 'IN_PROCESS' | 'COMPLETE' | 'FAILED';
export declare const DEFAULT_SHARED_REVEAL_OPTIONS: SharedRevealOptions;
type MaybePromise<T = void> = T | Promise<T>;
type CustodianShareRequiredContext = {
    mode: 'distribute';
    planId: string;
    requiresKeyShares?: boolean;
} | {
    mode: 'awaiting-claim';
    planId: string;
    shareId: string;
    distributedAt: string | null;
} | {
    mode: 'awaiting-release';
    planId: string;
    shareId: string;
} | {
    mode: 'collect-from-sk-pro';
    planId: string;
    shareId: string;
};
export interface MergeSharedProtectionPlanCallbacks {
    onApprovalsRequested?: () => MaybePromise;
    onViewUpdate?: (view: SharedPlanMergeProcessView) => MaybePromise;
    onRevealStepUpdate?: (step: RevealStep, status: RevealStepStatus) => MaybePromise;
    onRevealStepError?: (step: RevealStep, error: Error) => MaybePromise;
    onRevealed?: (assets: DataAsset[] | null) => MaybePromise;
    onRevealWindowExpired?: () => MaybePromise;
    onError?: (error: Error) => MaybePromise;
    /**
     * Called when the custodian share step requires user action.
     * `mode: 'distribute'` — share has never been distributed; UI should let the user choose device.
     * `mode: 'awaiting-release'` — share is already on SK-Mobile, release was triggered; UI should show waiting state.
     * `mode: 'collect-from-sk-pro'` — share was already claimed to SK-Pro; user must connect device to provide it.
     * Must resolve once the action is done.
     */
    onCustodianShareRequired?: (processId: string, context: CustodianShareRequiredContext) => MaybePromise<{
        keyShares: string[];
    } | void>;
}
export interface MergeSharedProtectionPlanDeps {
    planRepository: SharedProtectionPlanRepository;
    mergeRepository: SharedMergingProcessRepository;
    revealUseCase: RevealSharedPlanDataUseCase;
    eventListener: SharedPlanEventListener;
    encryptionService: ShareEncryptionService;
    errorReporter: SharedPlanErrorReporter;
    approvalOrchestrator: SharedPlanApprovalOrchestrator;
}
export declare class MergeSharedProtectionPlanUseCase {
    private readonly deps;
    private pendingDmsResolve;
    private pendingCustodianClaimResolve;
    private pendingCustodianClaimProcessId;
    private pendingCustodianShareResolver;
    private pendingCustodianShareProcessId;
    private runCancelled;
    private readonly trackedErrors;
    constructor(deps: MergeSharedProtectionPlanDeps);
    initialize(planId: string, accessIntent?: 'VIEW' | 'EDIT'): Promise<SharedPlanMergeProcessView>;
    getView(processId: string): Promise<SharedPlanMergeProcessView | null>;
    resume(planId: string, callbacks?: MergeSharedProtectionPlanCallbacks): Promise<SharedPlanMergeProcessView | null>;
    resumeReveal(processId: string, callbacks?: MergeSharedProtectionPlanCallbacks, masterKey?: string): Promise<void>;
    abort(processId: string): Promise<void>;
    closePlan(processId: string): Promise<void>;
    clearLocalProcess(processId: string): Promise<void>;
    clearLocalProcessByPlanId(planId: string): Promise<void>;
    /** Runs the process until READY_TO_REVEAL, then stops and waits for manual trigger. */
    run(processId: string, callbacks?: MergeSharedProtectionPlanCallbacks): Promise<void>;
    /**
     * Runs the reveal subprocess and only opens the timed reveal window once the
     * data is ready to be shown:
     * collect shares → decrypt/reconstruct → open window → REVEALED.
     *
     * The SDK subscribes to the process room to handle expiry events during this phase.
     */
    openRevealWindow(processId: string, revealOptions?: SharedRevealOptions, callbacks?: MergeSharedProtectionPlanCallbacks, masterKey?: string): Promise<void>;
    private revealBeforeOpeningWindow;
    private revealWithOpenWindow;
    private collectAndReconstruct;
    private handleCustodianShare;
    private prepareRevealedView;
    private hydrateProcessFromApi;
    private resolveProcessStep;
    private resolveExpiredStep;
    private executeRevealStep;
    private waitForDmsActivation;
    private waitForCustodianShare;
    private waitForCustodianShareClaim;
    private resolvePendingCustodianClaim;
    private resolvePendingCustodianShare;
    private notifyCustodianShareRequired;
    private waitForClaimedMobileCustodianShareAccess;
    private delay;
    private throwIfCancelled;
    private normalizeCustodianShareData;
    private reportRevealStepError;
    getCustodianShareData(processId: string): Promise<{
        id: string;
        shares: string[];
        planId: string;
        isMergeAuthority: boolean;
    }>;
    distributeCustodianShareViaMobile(planId: string): Promise<void>;
    recordCustodianShareClaim(planId: string, shareId: string, deviceId: string, deviceType: 'SK_MOBILE' | 'SK_PRO'): Promise<void>;
    cancelCustodianShareClaim(processId: string): Promise<void>;
    releaseCustodianShareViaMobile(processId: string): Promise<void>;
    markCustodianShareAsCollected(processId: string, shareId: string): Promise<void>;
    private reportMergeErrorIfNeeded;
    private getRevealStepMessage;
}
export {};
