/**
 * This file is part of the NocoBase (R) project.
 * Copyright (c) 2020-2024 NocoBase Co., Ltd.
 * Authors: NocoBase Team.
 *
 * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
 * For more information, please refer to: https://www.nocobase.com/agreement.
 */
import { FlowModel } from '@nocobase/flow-engine';
import { DepCollector } from './deps';
import type { FormAssignRuleItem, FormValueWriteMeta, NamePath, Patch, SetOptions, ValueSource } from './types';
type ObservableBinding = {
    source: ValueSource;
    pathKey: string;
    dispose: () => void;
};
export type RuleEngineOptions = {
    getBlockModelUid: () => string;
    getActionName: () => string | undefined;
    getBlockContext: () => any;
    getEngine: () => any;
    getEngineModel: (uid: string) => FlowModel | null;
    isDisposed: () => boolean;
    valuesMirror: any;
    changeTick: {
        value: number;
    };
    getWriteSeq: () => number;
    txWriteCounts: Map<string, Map<string, number>>;
    createTrackingFormValues: (collector: DepCollector) => any;
    tryResolveNamePath: (callerCtx: any, path: string | NamePath) => NamePath | null;
    getFormValueAtPath: (namePath: NamePath) => any;
    setFormValues: (callerCtx: any, patch: Patch, options?: SetOptions) => Promise<void>;
    findExplicitHit: (pathKey: string) => string | null;
    findUserEditedHit: (pathKey: string) => string | null;
    lastDefaultValueByPathKey: Map<string, any>;
    lastWriteMetaByPathKey: Map<string, FormValueWriteMeta>;
    observableBindings: Map<string, ObservableBinding>;
};
export declare class RuleEngine {
    private readonly options;
    private readonly rules;
    private readonly lastRuleWriteByTargetKey;
    private readonly assignTemplatesByTargetPath;
    /** 当前表单中“已配置到 UI 的字段（FormItemModel）”的 targetPath 集合，用于避免对 row grid 重复注册规则 */
    private readonly formItemTargetPaths;
    /** targetPath -> updateAssociation（SubForm/SubTable 等） */
    private readonly updateAssociationByTargetPath;
    private readonly pendingRuleIds;
    private readonly ruleDebounceUntilById;
    private readonly ruleDebounceTimersById;
    private readonly defaultRuleIdsByMasterUid;
    private readonly defaultRuleMasterDisposers;
    private runningRules;
    private rulesEnabled;
    private currentRuleTxId;
    constructor(options: RuleEngineOptions);
    private getAssignRuleBlockId;
    private removeAssignRuleBlockInstance;
    private removeRowGridAssignRuleInstances;
    private hasAnyNonBlockAssignRuleInstance;
    private ensureBlockAssignRuleInstancesForTargetPath;
    private getCollectionFromContext;
    private getRootCollection;
    private shouldCreateBlockLevelAssignRule;
    /**
     * 对关联字段嵌套属性（如 user.name / user.profile.name）：
     * - 依赖应包含关联对象本身（user / user.profile），否则当关联对象从 null -> {id} 时，user.name 仍为 undefined，无法触发 rule re-run。
     * - 写入前需校验关联对象已存在，避免隐式创建关联对象。
     */
    private collectAssociationPrefixPaths;
    private shouldSkipToManyAssociationWriteWithoutIndex;
    private shouldSkipAssociationNestedWrite;
    private getAssociationTargetKeyFields;
    private resolveAssociationFieldByPrefixPath;
    private isAssociationTargetKeyWrite;
    private collectUpdateAssociationInitPatches;
    dispose(): void;
    enable(): void;
    syncAssignRules(items: FormAssignRuleItem[]): void;
    onModelMounted(model: FlowModel): void;
    onModelUnmounted(model: FlowModel): void;
    private isModelInThisForm;
    private cacheUpdateAssociationForModel;
    private getUpdateAssociationForTargetPath;
    private getDefaultRuleId;
    private getModelTargetNamePath;
    private getAssignTemplateTargetPathForModel;
    private hasAssignTemplateForTargetPath;
    private tryRegisterDefaultRuleInstance;
    private getModelTargetPath;
    private getAssignRuleInstanceId;
    private getDeepestFieldIndexKey;
    private getDeepestToManyAssociationKey;
    private isRowGridModel;
    private tryRegisterAssignRuleInstancesForModel;
    private tryUnregisterAssignRuleInstancesForModel;
    private tryUnregisterDefaultRuleInstance;
    private bindMasterInitialValue;
    private removeRule;
    rescheduleAllRules(): void;
    private scheduleRule;
    private flushRules;
    private runRule;
    private isTzAwareTargetInterface;
    private normalizeDateOnlyToStartOfDayIso;
    private normalizeResolvedValueForTarget;
    private isPrimitiveAssociationTargetValue;
    private extractAssociationIdentity;
    private isAssociationTargetSemanticallyEqual;
    private resolveCollectionFieldByNamePath;
    private normalizeResolvedValueForAssociationTarget;
    private prepareRuleContext;
    private shouldApplyDefaultRuleInCurrentState;
    private isStaleToManyItemContext;
    private getItemContext;
    private getRowTargetKey;
    private isMismatchedToManyItemContext;
    private shouldRunRule;
    private createRuleCollectorAndContext;
    private evaluateRuleCondition;
    private resolveRuleValue;
    private resolveRunJSValue;
    private resolveTemplateValue;
    private commitRuleDeps;
    private isScalarValueTarget;
    private shouldSkipEmptyArrayAggregateForScalarTarget;
    private normalizeUnresolvedToManyAggregateForScalarTarget;
    private isArrayValueCollectionField;
    private stringifyAggregateItem;
    private normalizeAggregateArrayForScalarTarget;
    private shouldSkipMultiValueAggregateForScalarTarget;
    private getClearedAggregateValueForScalarTarget;
    private isUserClearedToManyAggregate;
    private isTextScalarTarget;
    private getLatestWriteMetaForPath;
    private getToManyAggregateSourceInfo;
    /**
     * Check if default rule value can be applied.
     * Default value can overwrite when:
     * 1. Current value is empty
     * 2. Current value equals the last default value (user hasn't modified it)
     */
    private checkDefaultRuleCanApply;
    private createRuleEvaluationContext;
    private getLocalFormValuesSnapshot;
    private resolveLocalFormValuesPath;
    private recordLocalFormValuesDep;
    private extractSingleLocalFormValuesPath;
    private stringifyTemplateReplacement;
    private createLocalTemplateTokenStore;
    private restoreLocalTemplateTokens;
    private resolveLocalFormValuesTemplates;
    private buildItemChainValue;
    private getFieldIndexSignature;
    private updateRuleDeps;
}
export {};
