import { type Atom, type Action, type Ctx, type Rec, type Fn } from '@reatom/core'; type State = T extends Atom ? Value : T; export declare const LL_PREV: unique symbol; export declare const LL_NEXT: unique symbol; /** Linked List is reusing the model reference to simplify the reference sharing and using it as a key of LL methods. * Btw, symbols works fine with serialization and will not add a garbage to an output. */ export type LLNode = T & { [LL_PREV]: null | LLNode; [LL_NEXT]: null | LLNode; }; type LLChanges = { kind: 'create'; node: Node; } | { kind: 'remove'; node: Node; } | { kind: 'swap'; a: Node; b: Node; } | { kind: 'move'; node: Node; after: null | Node; } | { kind: 'clear'; }; export interface LinkedList { head: null | Node; tail: null | Node; size: number; version: number; changes: Array>; } export interface LinkedListLikeAtom extends Atom { __reatomLinkedList: true; array: Atom ? LLNode : never>>; } export interface LinkedListAtom extends LinkedListLikeAtom>> { batch: Action<[cb: Fn]>; create: Action>; remove: Action<[LLNode], boolean>; swap: Action<[a: LLNode, b: LLNode], void>; move: Action<[node: LLNode, after: null | LLNode], void>; clear: Action<[], void>; find: (ctx: Ctx, cb: (node: LLNode) => boolean) => null | LLNode; /** This lazy map is useful for working with serializable identifier, * but it is not recommended to use it for large (thousands elements) lists */ map: Key extends never ? never : Atom, LLNode>>; initiate: { (initState: Array): LinkedList>; (ctx: Ctx, initSnapshot: Array): LinkedList>; }; reatomMap: (cb: (ctx: Ctx, node: LLNode) => T, options?: string | { name?: string; onCreate?: (ctx: Ctx, node: LLNode) => void; onRemove?: (ctx: Ctx, node: LLNode, origin: LLNode) => void; onSwap?: (ctx: Ctx, payload: { a: LLNode; b: LLNode; }) => void; onMove?: (ctx: Ctx, node: LLNode) => void; onClear?: (ctx: Ctx, lastState: LinkedListDerivedState, LLNode>) => void; }) => LinkedListDerivedAtom, LLNode>; } export interface LinkedListDerivedState extends LinkedList { map: WeakMap; } export interface LinkedListDerivedAtom extends LinkedListLikeAtom> { } export declare function reatomLinkedList(initState: Array, name?: string): LinkedListAtom; export declare function reatomLinkedList(initState: ((ctx: Ctx, ...params: Params) => Node), name?: string): LinkedListAtom; export declare function reatomLinkedList(initState: { create: (ctx: Ctx, ...params: Params) => Node; initState?: Array; key?: Key; }, name?: string): LinkedListAtom; export declare function reatomLinkedList(initState: { create?: (ctx: Ctx, ...params: Params) => Node; initState: Array; key?: Key; }, name?: string): LinkedListAtom; export declare function reatomLinkedList(initSnapshot: { create: (ctx: Ctx, ...params: Params) => Node; initSnapshot?: Array; key?: Key; }, name?: string): LinkedListAtom; export declare const isLinkedListAtom: (thing: any) => thing is LinkedListLikeAtom; export {}; //# sourceMappingURL=reatomLinkedList.d.ts.map