import { A as StateMachine, C as StateValue, D as PromiseActorLogic, a as ActorRefFromLogic, b as RequiredActorOptions, c as AnyEventObject, g as IsNotNever, h as InputFrom, i as ActorRefFrom, k as MachineSnapshot, m as GetConcreteByKey, o as AnyActorLogic, p as EventObject, r as ActorRef, s as AnyActorRef, u as ConditionalRequired, v as MetaObject, w as Values, x as RequiredLogicInput, y as NonReducibleUnknown } from "./spawn-D9jgw9pW.js"; import "./StateMachine-EDpYWy0i.js"; import { t as Manager } from "./Manager-CQQ99QOI.js"; import "./Actor-iTq7YY48.js"; //#region src/modules/identity-reuse/types.d.ts /** * Configuration options for the IdentityReuse module. * * @example * ```typescript * const config: IdentityReuseConfig = {}; * ``` */ type IdentityReuseConfig = {}; /** * A reusable identity document previously verified with a partner organization. * Internal shape consumed by the state machine, manager, and UI; the service * layer adapts the raw backend payload to this shape. * * Backend orders the array — the first entry is the best match. The * "Recommended" tag in the UI is purely positional; no backend field for it. */ type ReusableDocument = { /** Stable document identifier (uuid). Used as `documentId` in submit. */ id: string; /** Document category, normalized to camelCase (e.g. "driversLicense"). */ documentType: string; /** Masked identifier shown to the user (e.g. "00*****29"). */ maskedNumber: string; /** * Country code as returned by the backend (ISO 3166-1 alpha-3, e.g. "SRB"). * UI is responsible for any presentation transforms (flag emoji, etc.). */ countryCode: string; /** * Verification timestamp as a Unix epoch in seconds (may include fractional * milliseconds). Pass-through from the backend's `validatedAt`; the UI layer * is responsible for any Date construction or formatting. */ verifiedAt: number; }; /** * Documents returned by the service layer after adapting the backend payload. * Always an array; ordered by backend with the best match first. */ type FetchDocumentsResponse = ReusableDocument[]; /** * @internal Request body for POST /omni/identity-reuse/submit. * * - `{ accepted: true, documentId }` — user is reusing the selected document. * - `{ accepted: false }` — user opted to scan a new document instead. */ type SubmitParams = { accepted: true; documentId: string; } | { accepted: false; }; /** @internal Response from POST /omni/identity-reuse/submit — shape TBD */ type SubmitResponse = {}; //#endregion //#region src/modules/identity-reuse/identityReuseStateMachine.d.ts /** * Sentinel selection value for the "Scan a new document" row in the picker. * Picked + SUBMIT calls /submit with `{ accepted: false }`, then finishes. */ declare const SCAN_NEW_DOCUMENT: "scanNew"; type SelectedDocumentId = string | typeof SCAN_NEW_DOCUMENT; type IdentityReuseContext = { config: IdentityReuseConfig; documents: ReusableDocument[]; selectedDocumentId: SelectedDocumentId | undefined; error: string | undefined; }; type IdentityReuseInput = { config: IdentityReuseConfig; }; declare const identityReuseMachine: StateMachine> | ActorRefFromLogic> | undefined; }, Values<{ fetchDocuments: { src: "fetchDocuments"; logic: PromiseActorLogic; id: string | undefined; }; submitDocument: { src: "submitDocument"; logic: PromiseActorLogic; id: string | undefined; }; }>, Values<{ setDocuments: { type: "setDocuments"; params: NonReducibleUnknown; }; setError: { type: "setError"; params: NonReducibleUnknown; }; clearError: { type: "clearError"; params: NonReducibleUnknown; }; setSelectedDocument: { type: "setSelectedDocument"; params: NonReducibleUnknown; }; }>, Values<{ hasDocuments: { type: "hasDocuments"; params: unknown; }; hasSelection: { type: "hasSelection"; params: unknown; }; }>, never, "error" | "idle" | "finished" | "submitting" | "loading" | "documentsFound", string, IdentityReuseInput, NonReducibleUnknown, EventObject, MetaObject, { readonly id: "identityReuse"; readonly initial: "idle"; readonly context: ({ input }: { spawn: { (logic: TSrc, ...[options]: ({ src: "fetchDocuments"; logic: PromiseActorLogic; id: string | undefined; } extends (infer T) ? T extends { src: "fetchDocuments"; logic: PromiseActorLogic; id: string | undefined; } ? T extends { src: TSrc; } ? ConditionalRequired<[options?: ({ id?: T["id"] | undefined; systemId?: string; input?: InputFrom | undefined; syncSnapshot?: boolean; } & { [K in RequiredActorOptions]: unknown; }) | undefined], IsNotNever>> : never : never : never) | ({ src: "submitDocument"; logic: PromiseActorLogic; id: string | undefined; } extends (infer T_1) ? T_1 extends { src: "submitDocument"; logic: PromiseActorLogic; id: string | undefined; } ? T_1 extends { src: TSrc; } ? ConditionalRequired<[options?: ({ id?: T_1["id"] | undefined; systemId?: string; input?: InputFrom | undefined; syncSnapshot?: boolean; } & { [K_1 in RequiredActorOptions]: unknown; }) | undefined], IsNotNever>> : never : never : never)): ActorRefFromLogic; id: string | undefined; }; submitDocument: { src: "submitDocument"; logic: PromiseActorLogic; id: string | undefined; }; }>, "src", TSrc>["logic"]>; (src: TLogic, ...[options]: ConditionalRequired<[options?: ({ id?: never; systemId?: string; input?: InputFrom | undefined; syncSnapshot?: boolean; } & { [K in RequiredLogicInput]: unknown; }) | undefined], IsNotNever>>): ActorRefFromLogic; }; input: IdentityReuseInput; self: ActorRef, StateValue, string, unknown, any, any>, { type: "LOAD"; } | { type: "DOCUMENT_CHOSEN"; documentId: SelectedDocumentId; } | { type: "SUBMIT"; } | { type: "SKIP"; } | { type: "RETRY"; }, AnyEventObject>; }) => { config: IdentityReuseConfig; documents: never[]; selectedDocumentId: undefined; error: undefined; }; readonly states: { readonly idle: { readonly on: { readonly LOAD: { readonly target: "loading"; }; }; }; readonly loading: { readonly invoke: { readonly id: "fetchDocuments"; readonly src: "fetchDocuments"; readonly onDone: readonly [{ readonly target: "documentsFound"; readonly guard: "hasDocuments"; readonly actions: "setDocuments"; }, { readonly target: "finished"; }]; readonly onError: { readonly target: "error"; readonly actions: "setError"; }; }; }; readonly documentsFound: { readonly on: { readonly DOCUMENT_CHOSEN: { readonly actions: "setSelectedDocument"; }; readonly SUBMIT: { readonly target: "submitting"; readonly guard: "hasSelection"; }; readonly SKIP: { readonly target: "finished"; }; }; }; readonly submitting: { readonly invoke: { readonly id: "submitDocument"; readonly src: "submitDocument"; readonly input: ({ context }: { context: IdentityReuseContext; }) => SubmitParams; readonly onDone: { readonly target: "finished"; }; readonly onError: { readonly target: "error"; readonly actions: "setError"; }; }; }; readonly finished: { readonly type: "final"; }; readonly error: { readonly on: { readonly RETRY: { readonly target: "loading"; readonly actions: "clearError"; }; readonly SKIP: { readonly target: "finished"; }; }; }; }; }>; type IdentityReuseMachine = typeof identityReuseMachine; //#endregion //#region src/modules/identity-reuse/identityReuseActor.d.ts /** * Options for creating an IdentityReuse actor. */ type CreateIdentityReuseActorOptions = { /** Module configuration */ config: IdentityReuseConfig; }; /** * Type representing a running IdentityReuse actor. */ type IdentityReuseActor = ActorRefFrom; //#endregion //#region src/modules/identity-reuse/identityReuseManager.d.ts /** IdentityReuse manager is in initial state, waiting for `load()` */ type IdentityReuseIdleState = { status: 'idle'; }; /** Fetching reusable documents from the backend */ type IdentityReuseLoadingState = { status: 'loading'; }; /** * Documents are available — user picks one (or "scan new") and confirms. * The first document in the list is the recommended one; the UI surfaces a * "Recommended" tag based on position alone. * * @property documents - Ordered documents; index 0 is the best match. * @property selectedDocumentId - Currently selected document id, or * `'scanNew'` if the user picked the scan-new row. Auto-populated to * `documents[0].id` on entry. */ type IdentityReuseDocumentsFoundState = { status: 'documentsFound'; documents: ReusableDocument[]; selectedDocumentId: SelectedDocumentId | undefined; }; /** Submitting the chosen document for reuse */ type IdentityReuseSubmittingState = { status: 'submitting'; }; /** Module completed successfully */ type IdentityReuseFinishedState = { status: 'finished'; }; /** * A recoverable error occurred — user can retry or skip * @property error - Error message describing what went wrong */ type IdentityReuseErrorState = { status: 'error'; error: string; }; /** * Union of all possible IdentityReuse manager states. * * @example * ```typescript * const state = manager.getState(); * if (state.status === 'documentsFound') { * console.log(state.documents); * } * ``` */ type IdentityReuseState = IdentityReuseIdleState | IdentityReuseLoadingState | IdentityReuseDocumentsFoundState | IdentityReuseSubmittingState | IdentityReuseFinishedState | IdentityReuseErrorState; /** * Creates an IdentityReuse manager for headless or UI-driven usage. * * @example Headless usage * ```typescript * const manager = createIdentityReuseManager({ config: {} }); * manager.subscribe((state) => { * if (state.status === 'documentsFound') manager.submit(); * if (state.status === 'finished') console.log('Done!'); * }); * manager.load(); * ``` */ declare function createIdentityReuseManager(options: CreateIdentityReuseActorOptions): Manager & { /** * Fetches reusable documents from the backend. * Transitions from 'idle' to 'loading'. */ load(): void; /** * Selects a document by id, or the `'scanNew'` sentinel to indicate the * user prefers to scan a new document instead of reusing one. */ chooseDocument(documentId: SelectedDocumentId): void; /** * Confirms the current selection. If a document is selected, submits it * for reuse; if the scan-new row is selected, finishes the module without * submitting (orchestration will load the next node). */ submit(): void; /** * Skips identity reuse entirely. Finishes the module without submitting; * orchestration moves on to the next node. */ skip(): void; /** * Retries loading documents after an error. */ retry(): void; }; /** * Creates an IdentityReuse manager from a pre-built actor. * Use this when overriding the machine via `.provide()` for custom backends or testing. */ declare function createIdentityReuseManagerFromActor(actor: IdentityReuseActor): Manager & { /** * Fetches reusable documents from the backend. * Transitions from 'idle' to 'loading'. */ load(): void; /** * Selects a document by id, or the `'scanNew'` sentinel to indicate the * user prefers to scan a new document instead of reusing one. */ chooseDocument(documentId: SelectedDocumentId): void; /** * Confirms the current selection. If a document is selected, submits it * for reuse; if the scan-new row is selected, finishes the module without * submitting (orchestration will load the next node). */ submit(): void; /** * Skips identity reuse entirely. Finishes the module without submitting; * orchestration moves on to the next node. */ skip(): void; /** * Retries loading documents after an error. */ retry(): void; }; type IdentityReuseManager = ReturnType; //#endregion export { IdentityReuseActor as a, identityReuseMachine as c, ReusableDocument as d, SubmitResponse as f, createIdentityReuseManagerFromActor as i, FetchDocumentsResponse as l, IdentityReuseState as n, SCAN_NEW_DOCUMENT as o, createIdentityReuseManager as r, SelectedDocumentId as s, IdentityReuseManager as t, IdentityReuseConfig as u };