{"version":3,"file":"derivations.mjs","names":["immerSetAutoFreeze"],"sources":["../src/controlPropKeys.ts","../src/utils/abortReasons.ts","../../../node_modules/clsx/dist/clsx.mjs","../src/utils/signature.ts","../src/utils/coalesce.ts","../src/utils/defaultValidator.ts","../src/utils/deriveClassNames.ts","../src/utils/deriveRuleContext.ts","../src/utils/deriveValueEditor.ts","../src/utils/pathUtils.ts","../src/utils/generateAccessibleDescription.ts","../src/utils/getMatchModesUtil.ts","../src/utils/getRuleDefaultValue.ts","../src/utils/getValidationClassNames.ts","../src/utils/immerInstances.ts","../src/utils/mergeAnyTranslations.ts","../src/utils/mergeClassnames.ts","../src/utils/optionResolvers.ts","../src/utils/optionsEqual.ts","../src/utils/preferProp.ts","../src/utils/regenerateIDs.ts","../src/utils/queryTools.ts","../src/utils/queryActions.ts","../src/utils/ruleFactory.ts"],"sourcesContent":["/**\n * Runtime data describing the set of query builder controls and the props each one receives.\n *\n * These live in `@react-querybuilder/core` (not `react-querybuilder`) so that non-React ports\n * can consume them without a React dependency.\n *\n * Nothing here can drift from the React implementation unnoticed:\n * `react-querybuilder`'s `types/controlPropKeys.test.ts` gates {@link controlKeys} against\n * `defaultControlElements` and `ControlElementsProp`, and every entry of\n * {@link controlPropKeys} against the corresponding props interface—both at runtime and at\n * compile time, in both directions.\n */\n\n/**\n * The name of every query builder control, alphabetized.\n *\n * @group Props\n */\nexport const controlKeys = [\n  'actionElement',\n  'addGroupAction',\n  'addRuleAction',\n  'cloneGroupAction',\n  'cloneRuleAction',\n  'combinatorSelector',\n  'dragHandle',\n  'fieldSelector',\n  'inlineCombinator',\n  'lockGroupAction',\n  'lockRuleAction',\n  'matchModeEditor',\n  'muteGroupAction',\n  'muteRuleAction',\n  'notToggle',\n  'operatorSelector',\n  'removeGroupAction',\n  'removeRuleAction',\n  'rule',\n  'ruleGroup',\n  'ruleGroupBodyElements',\n  'ruleGroupHeaderElements',\n  'shiftActions',\n  'undoRedoActions',\n  'valueEditor',\n  'valueSelector',\n  'valueSourceSelector',\n] as const;\n\n/**\n * The name of a query builder control.\n *\n * @group Props\n */\nexport type ControlKey = (typeof controlKeys)[number];\n\n/**\n * The full set of prop names each default control receives. Ports can use this to declare\n * every prop explicitly instead of relying on fall-through/attribute inheritance.\n *\n * Each array is the complete, alphabetized key set of the control's props interface in\n * `react-querybuilder`. The lists are written out in full rather than composed from shared\n * bases because `--isolatedDeclarations` cannot infer array types built with spreads. A\n * compile-time gate in `react-querybuilder` (`types/controlPropKeys.test.ts`) fails the build\n * if any list drifts from its interface in either direction.\n *\n * @group Props\n */\nexport const controlPropKeys = {\n  actionElement: [\n    'className',\n    'context',\n    'disabled',\n    'disabledTranslation',\n    'handleOnClick',\n    'label',\n    'level',\n    'path',\n    'ruleOrGroup',\n    'rules',\n    'schema',\n    'testID',\n    'title',\n    'validation',\n  ],\n  addGroupAction: [\n    'className',\n    'context',\n    'disabled',\n    'disabledTranslation',\n    'handleOnClick',\n    'label',\n    'level',\n    'path',\n    'ruleOrGroup',\n    'rules',\n    'schema',\n    'testID',\n    'title',\n    'validation',\n  ],\n  addRuleAction: [\n    'className',\n    'context',\n    'disabled',\n    'disabledTranslation',\n    'handleOnClick',\n    'label',\n    'level',\n    'path',\n    'ruleOrGroup',\n    'rules',\n    'schema',\n    'testID',\n    'title',\n    'validation',\n  ],\n  cloneGroupAction: [\n    'className',\n    'context',\n    'disabled',\n    'disabledTranslation',\n    'handleOnClick',\n    'label',\n    'level',\n    'path',\n    'ruleOrGroup',\n    'rules',\n    'schema',\n    'testID',\n    'title',\n    'validation',\n  ],\n  cloneRuleAction: [\n    'className',\n    'context',\n    'disabled',\n    'disabledTranslation',\n    'handleOnClick',\n    'label',\n    'level',\n    'path',\n    'ruleOrGroup',\n    'rules',\n    'schema',\n    'testID',\n    'title',\n    'validation',\n  ],\n  combinatorSelector: [\n    'className',\n    'context',\n    'disabled',\n    'handleOnChange',\n    'level',\n    'options',\n    'path',\n    'ruleGroup',\n    'rules',\n    'schema',\n    'testID',\n    'title',\n    'validation',\n    'value',\n  ],\n  dragHandle: [\n    'className',\n    'context',\n    'disabled',\n    'dragHandleAttributes',\n    'label',\n    'level',\n    'path',\n    'ruleOrGroup',\n    'schema',\n    'testID',\n    'title',\n    'validation',\n  ],\n  fieldSelector: [\n    'className',\n    'context',\n    'disabled',\n    'handleOnChange',\n    'level',\n    'operator',\n    'options',\n    'path',\n    'rule',\n    'schema',\n    'testID',\n    'title',\n    'validation',\n    'value',\n  ],\n  inlineCombinator: [\n    'className',\n    'component',\n    'context',\n    'disabled',\n    'handleOnChange',\n    'level',\n    'options',\n    'path',\n    'ruleGroup',\n    'rules',\n    'schema',\n    'testID',\n    'title',\n    'validation',\n    'value',\n  ],\n  lockGroupAction: [\n    'className',\n    'context',\n    'disabled',\n    'disabledTranslation',\n    'handleOnClick',\n    'label',\n    'level',\n    'path',\n    'ruleOrGroup',\n    'rules',\n    'schema',\n    'testID',\n    'title',\n    'validation',\n  ],\n  lockRuleAction: [\n    'className',\n    'context',\n    'disabled',\n    'disabledTranslation',\n    'handleOnClick',\n    'label',\n    'level',\n    'path',\n    'ruleOrGroup',\n    'rules',\n    'schema',\n    'testID',\n    'title',\n    'validation',\n  ],\n  matchModeEditor: [\n    'className',\n    'classNames',\n    'context',\n    'disabled',\n    'field',\n    'fieldData',\n    'handleOnChange',\n    'level',\n    'match',\n    'numericEditorComponent',\n    'options',\n    'path',\n    'rule',\n    'schema',\n    'selectorComponent',\n    'testID',\n    'thresholdPlaceholder',\n    'title',\n    'validation',\n    'value',\n  ],\n  muteGroupAction: [\n    'className',\n    'context',\n    'disabled',\n    'disabledTranslation',\n    'handleOnClick',\n    'label',\n    'level',\n    'path',\n    'ruleOrGroup',\n    'rules',\n    'schema',\n    'testID',\n    'title',\n    'validation',\n  ],\n  muteRuleAction: [\n    'className',\n    'context',\n    'disabled',\n    'disabledTranslation',\n    'handleOnClick',\n    'label',\n    'level',\n    'path',\n    'ruleOrGroup',\n    'rules',\n    'schema',\n    'testID',\n    'title',\n    'validation',\n  ],\n  notToggle: [\n    'checked',\n    'className',\n    'context',\n    'disabled',\n    'handleOnChange',\n    'label',\n    'level',\n    'path',\n    'ruleGroup',\n    'schema',\n    'testID',\n    'title',\n    'validation',\n  ],\n  operatorSelector: [\n    'className',\n    'context',\n    'disabled',\n    'field',\n    'fieldData',\n    'handleOnChange',\n    'level',\n    'options',\n    'path',\n    'rule',\n    'schema',\n    'testID',\n    'title',\n    'validation',\n    'value',\n  ],\n  removeGroupAction: [\n    'className',\n    'context',\n    'disabled',\n    'disabledTranslation',\n    'handleOnClick',\n    'label',\n    'level',\n    'path',\n    'ruleOrGroup',\n    'rules',\n    'schema',\n    'testID',\n    'title',\n    'validation',\n  ],\n  removeRuleAction: [\n    'className',\n    'context',\n    'disabled',\n    'disabledTranslation',\n    'handleOnClick',\n    'label',\n    'level',\n    'path',\n    'ruleOrGroup',\n    'rules',\n    'schema',\n    'testID',\n    'title',\n    'validation',\n  ],\n  rule: [\n    'actions',\n    'context',\n    'disabled',\n    'dndRef',\n    'dragHandleAttributes',\n    'dragMonitorId',\n    'dragRef',\n    'dropEffect',\n    'dropMonitorId',\n    'dropNotAllowed',\n    'field',\n    'groupItems',\n    'id',\n    'isDragging',\n    'isOver',\n    'operator',\n    'parentDisabled',\n    'parentMuted',\n    'path',\n    'rule',\n    'schema',\n    'shiftDownDisabled',\n    'shiftUpDisabled',\n    'translations',\n    'value',\n    'valueSource',\n  ],\n  ruleGroup: [\n    'actions',\n    'combinator',\n    'context',\n    'disabled',\n    'dragHandleAttributes',\n    'dragMonitorId',\n    'dragRef',\n    'dropEffect',\n    'dropMonitorId',\n    'dropNotAllowed',\n    'dropRef',\n    'groupItems',\n    'id',\n    'isDragging',\n    'isOver',\n    'not',\n    'parentDisabled',\n    'parentMuted',\n    'path',\n    'previewRef',\n    'ruleGroup',\n    'rules',\n    'schema',\n    'shiftDownDisabled',\n    'shiftUpDisabled',\n    'translations',\n  ],\n  ruleGroupBodyElements: [\n    'accessibleDescription',\n    'actions',\n    'addGroup',\n    'addRule',\n    'classNames',\n    'cloneGroup',\n    'combinator',\n    'context',\n    'disabled',\n    'dragHandleAttributes',\n    'dragMonitorId',\n    'dragRef',\n    'dropEffect',\n    'dropMonitorId',\n    'dropNotAllowed',\n    'dropRef',\n    'groupItems',\n    'id',\n    'isDragging',\n    'isOver',\n    'muted',\n    'not',\n    'onCombinatorChange',\n    'onGroupAdd',\n    'onIndependentCombinatorChange',\n    'onNotToggleChange',\n    'outerClassName',\n    'parentDisabled',\n    'parentMuted',\n    'path',\n    'pathsMemo',\n    'previewRef',\n    'removeGroup',\n    'ruleGroup',\n    'rules',\n    'schema',\n    'shiftDownDisabled',\n    'shiftGroupDown',\n    'shiftGroupUp',\n    'shiftUpDisabled',\n    'toggleLockGroup',\n    'toggleMuteGroup',\n    'translations',\n    'validationClassName',\n    'validationResult',\n  ],\n  ruleGroupHeaderElements: [\n    'accessibleDescription',\n    'actions',\n    'addGroup',\n    'addRule',\n    'classNames',\n    'cloneGroup',\n    'combinator',\n    'context',\n    'disabled',\n    'dragHandleAttributes',\n    'dragMonitorId',\n    'dragRef',\n    'dropEffect',\n    'dropMonitorId',\n    'dropNotAllowed',\n    'dropRef',\n    'groupItems',\n    'id',\n    'isDragging',\n    'isOver',\n    'muted',\n    'not',\n    'onCombinatorChange',\n    'onGroupAdd',\n    'onIndependentCombinatorChange',\n    'onNotToggleChange',\n    'outerClassName',\n    'parentDisabled',\n    'parentMuted',\n    'path',\n    'pathsMemo',\n    'previewRef',\n    'removeGroup',\n    'ruleGroup',\n    'rules',\n    'schema',\n    'shiftDownDisabled',\n    'shiftGroupDown',\n    'shiftGroupUp',\n    'shiftUpDisabled',\n    'toggleLockGroup',\n    'toggleMuteGroup',\n    'translations',\n    'validationClassName',\n    'validationResult',\n  ],\n  shiftActions: [\n    'className',\n    'context',\n    'disabled',\n    'labels',\n    'level',\n    'path',\n    'ruleOrGroup',\n    'schema',\n    'shiftDown',\n    'shiftDownDisabled',\n    'shiftUp',\n    'shiftUpDisabled',\n    'testID',\n    'title',\n    'titles',\n    'validation',\n  ],\n  undoRedoActions: [\n    'className',\n    'classNames',\n    'context',\n    'disabled',\n    'labels',\n    'level',\n    'path',\n    'ruleOrGroup',\n    'schema',\n    'testID',\n    'title',\n    'titles',\n    'validation',\n  ],\n  valueEditor: [\n    'className',\n    'context',\n    'disabled',\n    'field',\n    'fieldData',\n    'handleOnChange',\n    'inputType',\n    'level',\n    'listsAsArrays',\n    'operator',\n    'parseNumbers',\n    'path',\n    'rule',\n    'schema',\n    'selectorComponent',\n    'separator',\n    'skipHook',\n    'testID',\n    'title',\n    'type',\n    'validation',\n    'value',\n    'valueSource',\n    'values',\n  ],\n  valueSelector: [\n    'className',\n    'context',\n    'disabled',\n    'handleOnChange',\n    'level',\n    'listsAsArrays',\n    'multiple',\n    'options',\n    'path',\n    'schema',\n    'testID',\n    'title',\n    'validation',\n    'value',\n  ],\n  valueSourceSelector: [\n    'className',\n    'context',\n    'disabled',\n    'field',\n    'fieldData',\n    'handleOnChange',\n    'level',\n    'options',\n    'path',\n    'rule',\n    'schema',\n    'testID',\n    'title',\n    'validation',\n    'value',\n  ],\n} as const;\n\n/**\n * Which bulk override, if any, applies to each control: `\"action\"` for controls that a supplied\n * `actionElement` replaces, `\"selector\"` for controls that a supplied `valueSelector` replaces,\n * and `null` for controls that neither replaces.\n *\n * `actionElement` and `valueSelector` are themselves `null`—they are the _source_ of a bulk\n * override, not a target of one.\n *\n * Replaces name-suffix sniffing (`key.endsWith('Action')`), which would silently misclassify a\n * future control named e.g. `pathSelector`, and which disagrees between implementations about\n * whether `shiftActions`/`undoRedoActions` (plural) match. They do not: neither receives the\n * `actionElement` bulk override.\n *\n * @group Props\n */\nexport const controlKind = {\n  actionElement: null,\n  addGroupAction: 'action',\n  addRuleAction: 'action',\n  cloneGroupAction: 'action',\n  cloneRuleAction: 'action',\n  combinatorSelector: 'selector',\n  dragHandle: null,\n  fieldSelector: 'selector',\n  inlineCombinator: null,\n  lockGroupAction: 'action',\n  lockRuleAction: 'action',\n  matchModeEditor: null,\n  muteGroupAction: 'action',\n  muteRuleAction: 'action',\n  notToggle: null,\n  operatorSelector: 'selector',\n  removeGroupAction: 'action',\n  removeRuleAction: 'action',\n  rule: null,\n  ruleGroup: null,\n  ruleGroupBodyElements: null,\n  ruleGroupHeaderElements: null,\n  shiftActions: null,\n  undoRedoActions: null,\n  valueEditor: null,\n  valueSelector: null,\n  valueSourceSelector: 'selector',\n} as const;\n","import type { AbortReason } from './queryTools';\n\n/**\n * Abort reasons that {@link QueryManager}'s `strict` mode treats as errors. The remaining\n * reasons—`\"same-location\"` and `\"no-change\"`—describe valid operations that had nothing to do,\n * so they are reported to `onInvalidTarget` but never throw.\n *\n * Declared apart from `QueryManager` so the `@react-querybuilder/core/derivations` entry point can\n * export it without putting the manager in its module graph.\n *\n * @group Query Tools\n */\nexport const strictAbortReasons: readonly AbortReason[] = [\n  'target-not-found',\n  'parent-not-found',\n  'parent-not-a-group',\n  'destination-not-found',\n  'root-not-allowed',\n  'not-a-combinator-slot',\n  'target-disabled',\n  'parent-disabled',\n  'max-levels-exceeded',\n];\n\n/** @internal */\nexport const strictAbortReasonSet: ReadonlySet<AbortReason> = new Set<AbortReason>(\n  strictAbortReasons\n);\n","function r(e){var t,f,n=\"\";if(\"string\"==typeof e||\"number\"==typeof e)n+=e;else if(\"object\"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=\" \"),n+=f)}else for(f in e)e[f]&&(n&&(n+=\" \"),n+=f);return n}export function clsx(){for(var e,t,f=0,n=\"\",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=\" \"),n+=t);return n}export default clsx;","import type { RuleGroupTypeAny, RuleType } from '../types';\nimport { isRuleGroup } from './isRuleGroup';\n\n/**\n * Signature returned when a change alters the _shape_ of the query—rules or groups added,\n * removed, moved, or reordered—rather than the properties of a single node. Structural changes\n * never coalesce with each other, so each one produces its own history entry.\n */\nexport const structuralSignature = '~structural';\n\n/**\n * Signature returned when two queries differ by reference only, with no observable difference\n * in their properties.\n */\nexport const unchangedSignature = '';\n\n/**\n * Returns the list of property names that differ between two nodes, ignoring `rules` (which is\n * compared structurally by the caller).\n */\nconst changedProps = (prev: object, next: object): string[] => {\n  const keys = new Set([...Object.keys(prev), ...Object.keys(next)]);\n  keys.delete('rules');\n  const changed: string[] = [];\n  for (const key of keys) {\n    if (!Object.is(prev[key as keyof object], next[key as keyof object])) {\n      changed.push(key);\n    }\n  }\n  return changed.toSorted();\n};\n\nconst signatureOfNode = (\n  prev: RuleGroupTypeAny | RuleType | string,\n  next: RuleGroupTypeAny | RuleType | string,\n  /** Identifier of the parent group, used to describe independent combinator changes. */\n  parentId: string,\n  /** Index within the parent's `rules` array, used to describe independent combinator changes. */\n  index: number\n): string => {\n  // Immer's structural sharing means untouched subtrees keep their identity, so reference\n  // equality prunes the walk to the single mutated path.\n  if (prev === next) return unchangedSignature;\n\n  // Independent combinators are plain strings in the `rules` array.\n  if (typeof prev === 'string' || typeof next === 'string') {\n    return typeof prev === typeof next ? `${parentId}:combinator[${index}]` : structuralSignature;\n  }\n\n  const prevIsGroup = isRuleGroup(prev);\n  const nextIsGroup = isRuleGroup(next);\n  // A rule replaced by a group (or vice versa) is a structural change.\n  if (prevIsGroup !== nextIsGroup) return structuralSignature;\n\n  if (!prevIsGroup || !nextIsGroup) {\n    const props = changedProps(prev, next);\n    return props.length === 0 ? unchangedSignature : `${next.id ?? ''}:${props.join(',')}`;\n  }\n\n  // Adding or removing children is structural.\n  if (prev.rules.length !== next.rules.length) return structuralSignature;\n\n  const ownProps = changedProps(prev, next);\n\n  let changedIndex = -1;\n  for (const [i, prevRule] of prev.rules.entries()) {\n    if (prevRule !== next.rules[i]) {\n      // More than one child changed, which means children were moved or reordered.\n      if (changedIndex !== -1) return structuralSignature;\n      changedIndex = i;\n    }\n  }\n\n  if (changedIndex === -1) {\n    return ownProps.length === 0 ? unchangedSignature : `${next.id ?? ''}:${ownProps.join(',')}`;\n  }\n\n  // Both this group's own properties and one of its children changed, which no single edit\n  // does—treat it as structural rather than attributing it to either.\n  if (ownProps.length > 0) return structuralSignature;\n\n  return signatureOfNode(\n    prev.rules[changedIndex],\n    next.rules[changedIndex],\n    next.id ?? '',\n    changedIndex\n  );\n};\n\n/**\n * Describes _what changed_ between two versions of a query as a short string, so that\n * consecutive edits to the same property of the same rule (e.g. typing in a value editor) can\n * be recognized and coalesced into a single history entry.\n *\n * Returns {@link structuralSignature} for changes to the shape of the query, {@link unchangedSignature} when the\n * two queries differ by reference only, and `\"<id>:<props>\"` otherwise.\n *\n * The walk prunes on reference equality, so it costs O(depth) rather than O(size) for the\n * single-node edits that make up the overwhelming majority of changes.\n *\n * Note that this relies on the structural sharing that Immer—and therefore every query\n * produced by RQB's own update functions—guarantees: nodes that did not change keep their\n * identity. A query that has been wholly rebuilt (deep-cloned, round-tripped through JSON,\n * re-parsed from a string) shares no identity with its predecessor, so it is reported as\n * {@link structuralSignature} and will not coalesce. That is a graceful degradation—every change simply\n * gets its own history entry—but controlled components that clone the query on every change\n * will not benefit from coalescing.\n */\nexport const signatureOf = (prev: RuleGroupTypeAny, next: RuleGroupTypeAny): string =>\n  signatureOfNode(prev, next, '', -1);\n","import { defaultCoalesceMs } from '../defaults';\nimport { structuralSignature } from './signature';\n\n/**\n * Determines whether a change should be absorbed into the current history entry instead of\n * pushing a new one. This is the exact rule {@link QueryManager} applies when recording history,\n * exposed so non-React implementations can manage their own history stacks without\n * reimplementing (and drifting from) the semantics.\n *\n * A change coalesces only when all three hold:\n * - the change is not structural (rules/groups added, removed, moved, or reordered)\n * - its signature matches the previously recorded signature\n * - it occurred within `coalesceMs` of the previous recording\n *\n * Note that {@link unchangedSignature} is not handled here. A change with no observable\n * difference is never recorded at all, which is a separate decision made before this check.\n *\n * @param prevSig Signature of the previously recorded change, or `undefined` if there is none.\n * @param nextSig Signature of the change being recorded, from {@link signatureOf}.\n * @param prevAt Timestamp of the previous recording.\n * @param now Timestamp of the change being recorded.\n * @param coalesceMs Coalescing window in milliseconds.\n */\nexport const shouldCoalesce = (\n  prevSig: string | undefined,\n  nextSig: string,\n  prevAt: number,\n  now: number,\n  coalesceMs: number = defaultCoalesceMs\n): boolean =>\n  nextSig !== structuralSignature &&\n  nextSig === prevSig &&\n  now >= prevAt &&\n  now - prevAt < coalesceMs;\n","import { defaultCombinators, groupInvalidReasons } from '../defaults';\nimport type { QueryValidator, RuleGroupTypeAny, RuleType, ValidationMap } from '../types';\nimport { isRuleGroup, isRuleGroupType } from './isRuleGroup';\n\n/**\n * This is an example validation function you can pass to {@link react-querybuilder!QueryBuilder QueryBuilder} in the\n * `validator` prop. It assumes that you want to validate groups, and has a no-op\n * for validating rules which you can replace with your own implementation.\n */\nexport const defaultValidator: QueryValidator = query => {\n  const result: ValidationMap = {};\n\n  /**\n   * Replace this with your custom rule validator.\n   */\n  const validateRule = (rule: RuleType) => {\n    // Set `result[rule.id] = true` for a valid rule, or either\n    // `{ valid: false, reasons: ['whatever', 'reasons', 'here'] }`\n    // or simply `false` for an invalid rule.\n    /* v8 ignore start -- @preserve */\n    // oxlint-disable-next-line no-unused-expressions\n    if (rule.id) result[rule.id]; // = true;\n    /* v8 ignore stop -- @preserve */\n  };\n\n  const validateGroup = (rg: RuleGroupTypeAny) => {\n    // oxlint-disable-next-line typescript/no-explicit-any\n    const reasons: any[] = [];\n    if (rg.rules.length === 0) {\n      reasons.push(groupInvalidReasons.empty);\n    } else if (!isRuleGroupType(rg)) {\n      // Odd indexes should be valid combinators and even indexes should be rules or groups\n      let invalidICs = false;\n      for (let i = 0; i < rg.rules.length && !invalidICs; i++) {\n        if (\n          (i % 2 === 0 && typeof rg.rules[i] === 'string') ||\n          (i % 2 === 1 && typeof rg.rules[i] !== 'string') ||\n          (i % 2 === 1 &&\n            typeof rg.rules[i] === 'string' &&\n            !defaultCombinators.map(c => c.name as string).includes(rg.rules[i] as string))\n        ) {\n          invalidICs = true;\n        }\n      }\n      if (invalidICs) {\n        reasons.push(groupInvalidReasons.invalidIndependentCombinators);\n      }\n    }\n    // Non-independent combinators should be valid, but only checked if there are multiple rules\n    // since combinators don't really apply to groups with only one rule/group\n    if (\n      isRuleGroupType(rg) &&\n      !defaultCombinators.map(c => c.name as string).includes(rg.combinator) &&\n      rg.rules.length > 1\n    ) {\n      reasons.push(groupInvalidReasons.invalidCombinator);\n    }\n    /* v8 ignore else -- @preserve */\n    if (rg.id) {\n      result[rg.id] = reasons.length > 0 ? { valid: false, reasons } : true;\n    }\n    for (const r of rg.rules) {\n      if (typeof r === 'string') {\n        // Validation for this case was done earlier\n      } else if (isRuleGroup(r)) {\n        validateGroup(r);\n      } else {\n        validateRule(r);\n      }\n    }\n  };\n\n  validateGroup(query);\n\n  return result;\n  // You can return the result object itself like above, or if you just\n  // want the entire query to be marked invalid if _any_ rules/groups are\n  // invalid, return a boolean like this:\n  //   return Object.values(result).map(rv => (typeof rv !== 'boolean')).includes(true);\n  // That will return `true` if no errors were found.\n};\n","import type { ClassValue } from 'clsx';\nimport { standardClassnames } from '../defaults';\nimport type { Classname, Classnames, ValidationMap } from '../types';\nimport { clsx } from './clsx';\n\n/** Classname keys that have both a standard class and a `controlClassnames` entry. */\ntype StandardClassnameKey = keyof typeof standardClassnames & keyof Classnames;\n\n/**\n * A classname applied only when `when` returns true for the current state.\n *\n * `key` is used to look up both the standard classname and the corresponding `controlClassnames`\n * entry. Set `standardOnly` when the standard class is conditional but no custom class\n * corresponds to it.\n */\nexport interface ClassnameCondition<S> {\n  key: StandardClassnameKey;\n  when: (state: S) => boolean | undefined;\n  standardOnly?: boolean;\n}\n\n/**\n * How one derived classname is composed: the `controlClassnames` keys that contribute to it (in\n * application order, after the standard classname), plus any state-dependent classes.\n */\nexport interface ClassnameSpec<S> {\n  sources: readonly (keyof Classnames)[];\n  conditions?: readonly ClassnameCondition<S>[];\n}\n\ntype ClassnameSpecMap<K extends string, S> = Record<\n  K,\n  readonly (keyof Classnames)[] | ClassnameSpec<S>\n>;\n\n/** Keys of the `classNames` object returned for a rule. */\nexport type RuleClassnameKey =\n  | 'shiftActions'\n  | 'dragHandle'\n  | 'fields'\n  | 'matchMode'\n  | 'matchThreshold'\n  | 'operators'\n  | 'valueSource'\n  | 'value'\n  | 'cloneRule'\n  | 'lockRule'\n  | 'muteRule'\n  | 'removeRule'\n  | 'valueListItem';\n\n/** Keys of the `classNames` object returned for a rule group. */\nexport type RuleGroupClassnameKey =\n  | 'header'\n  | 'shiftActions'\n  | 'undoRedoActions'\n  | 'undoAction'\n  | 'redoAction'\n  | 'dragHandle'\n  | 'combinators'\n  | 'notToggle'\n  | 'addRule'\n  | 'addGroup'\n  | 'cloneGroup'\n  | 'lockGroup'\n  | 'muteGroup'\n  | 'removeGroup'\n  | 'body';\n\n/** Drag-and-drop state that can contribute conditional classnames. */\nexport interface DndClassNameState {\n  isDragging?: boolean;\n  isOver?: boolean;\n  dropEffect?: 'move' | 'copy';\n  groupItems?: boolean;\n  dropNotAllowed?: boolean;\n}\n\n/** State that contributes conditional classnames to a rule's wrapper element. */\nexport interface RuleClassNameState extends DndClassNameState {\n  disabled?: boolean;\n  muted?: boolean;\n  hasSubQuery?: boolean;\n}\n\nconst ruleClassnameSources: ClassnameSpecMap<RuleClassnameKey, RuleClassNameState> = {\n  shiftActions: ['shiftActions'],\n  dragHandle: ['dragHandle'],\n  fields: ['valueSelector', 'fields'],\n  matchMode: ['valueSelector', 'matchMode'],\n  matchThreshold: ['valueSelector', 'matchThreshold'],\n  operators: ['valueSelector', 'operators'],\n  valueSource: ['valueSelector', 'valueSource'],\n  value: ['value'],\n  cloneRule: ['actionElement', 'cloneRule'],\n  lockRule: ['actionElement', 'lockRule'],\n  muteRule: ['actionElement', 'muteRule'],\n  removeRule: ['actionElement', 'removeRule'],\n  valueListItem: ['valueListItem'],\n};\n\nconst ruleGroupClassnameSources: ClassnameSpecMap<RuleGroupClassnameKey, DndClassNameState> = {\n  header: {\n    sources: ['header'],\n    conditions: [\n      // The standard `dndOver` class has no custom counterpart on the header element.\n      { key: 'dndOver', when: s => s.isOver, standardOnly: true },\n      { key: 'dndCopy', when: s => s.isOver && s.dropEffect === 'copy' },\n      { key: 'dndDropNotAllowed', when: s => s.dropNotAllowed },\n    ],\n  },\n  shiftActions: ['shiftActions'],\n  undoRedoActions: ['undoRedoActions'],\n  undoAction: ['actionElement', 'undoAction'],\n  redoAction: ['actionElement', 'redoAction'],\n  dragHandle: ['dragHandle'],\n  combinators: ['valueSelector', 'combinators'],\n  notToggle: ['notToggle'],\n  addRule: ['actionElement', 'addRule'],\n  addGroup: ['actionElement', 'addGroup'],\n  cloneGroup: ['actionElement', 'cloneGroup'],\n  lockGroup: ['actionElement', 'lockGroup'],\n  muteGroup: ['actionElement', 'muteGroup'],\n  removeGroup: ['actionElement', 'removeGroup'],\n  body: ['body'],\n};\n\n/**\n * Conditional classes applied to a rule's wrapper element.\n *\n * Note that this is deliberately _not_ the same set as {@link ruleGroupOuterConditions}: a rule\n * reflects more drag-and-drop states than a group does. Declaring each set separately is what\n * keeps an implementation from assuming they're symmetric.\n */\nconst ruleOuterConditions: readonly ClassnameCondition<RuleClassNameState>[] = [\n  { key: 'disabled', when: s => s.disabled },\n  { key: 'muted', when: s => s.muted },\n  { key: 'dndDragging', when: s => s.isDragging },\n  { key: 'dndOver', when: s => s.isOver },\n  { key: 'dndCopy', when: s => s.isOver && s.dropEffect === 'copy' },\n  { key: 'dndGroup', when: s => s.isOver && s.groupItems },\n  { key: 'dndDropNotAllowed', when: s => s.dropNotAllowed },\n  { key: 'hasSubQuery', when: s => s.hasSubQuery },\n];\n\n/** Conditional classes applied to a rule group's wrapper element. */\nconst ruleGroupOuterConditions: readonly ClassnameCondition<RuleClassNameState>[] = [\n  { key: 'disabled', when: s => s.disabled },\n  { key: 'muted', when: s => s.muted },\n  { key: 'dndDragging', when: s => s.isDragging },\n  { key: 'dndGroup', when: s => s.isOver && s.groupItems },\n];\n\n/** State that contributes conditional classnames to the query builder's wrapper element. */\nexport interface QueryBuilderClassNameState {\n  disabled?: boolean;\n  validationResult?: boolean | ValidationMap;\n}\n\n/**\n * Conditional classes applied to the query builder's wrapper element.\n *\n * Only a `boolean` validation result contributes a class; a {@link ValidationMap} describes\n * individual rules and groups, not the query as a whole.\n */\nconst queryBuilderOuterConditions: readonly ClassnameCondition<QueryBuilderClassNameState>[] = [\n  { key: 'disabled', when: s => s.disabled },\n  { key: 'valid', when: s => typeof s.validationResult === 'boolean' && s.validationResult },\n  { key: 'invalid', when: s => typeof s.validationResult === 'boolean' && !s.validationResult },\n];\n\n/** Options common to every classname derivation. */\nexport interface DeriveClassNamesOptions {\n  /** The merged `controlClassnames` for the query builder. */\n  classNames: Partial<Classnames> | undefined;\n  /** When `true`, standard (`rule`, `ruleGroup-*`, etc.) classnames are omitted. */\n  suppressStandardClassnames?: boolean;\n}\n\n/**\n * Expands conditions into `clsx` arguments: every custom class first (in declaration order),\n * then a single object of standard classes.\n */\nconst conditionArgs = <S>(\n  conditions: readonly ClassnameCondition<S>[],\n  state: S,\n  { classNames, suppressStandardClassnames }: DeriveClassNamesOptions\n): ClassValue[] => {\n  const evaluated = conditions.map(condition => [condition, !!condition.when(state)] as const);\n\n  return [\n    ...evaluated\n      .filter(([condition]) => !condition.standardOnly)\n      .map(([condition, active]) => active && classNames?.[condition.key]),\n    suppressStandardClassnames ||\n      Object.fromEntries(\n        evaluated.map(([condition, active]) => [standardClassnames[condition.key], active])\n      ),\n  ];\n};\n\n/** Composes the classname for a single entry of a spec map. */\nconst deriveFromSpec = <S>(\n  key: string,\n  spec: readonly (keyof Classnames)[] | ClassnameSpec<S>,\n  state: S,\n  options: DeriveClassNamesOptions\n): string => {\n  const { sources, conditions }: ClassnameSpec<S> = Array.isArray(spec)\n    ? { sources: spec }\n    : (spec as ClassnameSpec<S>);\n\n  // `classNames` is optional chained because React Native passes a partial schema.\n  return clsx(\n    options.suppressStandardClassnames ||\n      standardClassnames[key as keyof typeof standardClassnames],\n    ...sources.map(source => options.classNames?.[source]),\n    ...(conditions ? conditionArgs(conditions, state, options) : [])\n  );\n};\n\nconst deriveFromSpecs = <K extends string, S>(\n  specs: ClassnameSpecMap<K, S>,\n  state: S,\n  options: DeriveClassNamesOptions\n): Record<K, string> => {\n  const result = {} as Record<K, string>;\n\n  for (const [key, spec] of Object.entries(specs) as [\n    K,\n    readonly (keyof Classnames)[] | ClassnameSpec<S>,\n  ][]) {\n    result[key] = deriveFromSpec(key, spec, state, options);\n  }\n\n  return result;\n};\n\n/**\n * Classnames for each element rendered by a rule. This is the framework-agnostic core of the\n * `classNames` object returned by the `useRule` hook.\n *\n * @group Query Tools\n */\nexport const deriveRuleClassNames = (\n  options: DeriveClassNamesOptions\n): Record<RuleClassnameKey, string> => deriveFromSpecs(ruleClassnameSources, {}, options);\n\n/**\n * The classname for a single element of a rule, composed from the same table as\n * {@link deriveRuleClassNames}. Useful where only one is needed, such as the items of a\n * multi-value editor.\n *\n * @group Query Tools\n */\nexport const deriveRuleClassName = (\n  key: RuleClassnameKey,\n  options: DeriveClassNamesOptions\n): string => deriveFromSpec(key, ruleClassnameSources[key], {}, options);\n\n/**\n * Classnames for each element rendered by a rule group, including its conditionally-classed\n * `header`. This is the framework-agnostic core of the `classNames` object returned by the\n * `useRuleGroup` hook.\n *\n * @group Query Tools\n */\nexport const deriveRuleGroupClassNames = (\n  options: DeriveClassNamesOptions & DndClassNameState\n): Record<RuleGroupClassnameKey, string> =>\n  deriveFromSpecs(ruleGroupClassnameSources, options, options);\n\n/** Inputs common to every outer (wrapper) classname derivation. */\nexport interface OuterClassNameOptionsBase extends DeriveClassNamesOptions {\n  /**\n   * Classnames contributed by the rule or group itself and its configuration, applied first.\n   * For a rule that is the rule/field/operator classnames; for a group, the group and combinator\n   * classnames.\n   */\n  leadingClassNames?: (Classname | null)[];\n  /** Appended last, as produced by `getValidationClassNames`. */\n  validationClassName?: Classname;\n}\n\n/** Inputs to {@link deriveRuleOuterClassName} and {@link deriveRuleGroupOuterClassName}. */\nexport interface OuterClassNameOptions extends OuterClassNameOptionsBase, RuleClassNameState {}\n\nconst deriveOuterClassName = <S extends OuterClassNameOptionsBase>(\n  standardKey: 'rule' | 'ruleGroup' | 'queryBuilder',\n  conditions: readonly ClassnameCondition<S>[],\n  options: S\n): string => {\n  const {\n    classNames,\n    suppressStandardClassnames,\n    leadingClassNames = [],\n    validationClassName,\n  } = options;\n\n  return clsx(\n    ...leadingClassNames,\n    suppressStandardClassnames || standardClassnames[standardKey],\n    classNames?.[standardKey],\n    ...conditionArgs(conditions, options, options),\n    validationClassName\n  );\n};\n\n/**\n * The outer (wrapper) classname for a rule, including every conditional state class.\n *\n * @group Query Tools\n */\nexport const deriveRuleOuterClassName = (options: OuterClassNameOptions): string =>\n  deriveOuterClassName('rule', ruleOuterConditions, options);\n\n/**\n * The outer (wrapper) classname for a rule group, including every conditional state class.\n *\n * A group reflects fewer drag-and-drop states than a rule—`dndOver`, `dndCopy`,\n * `dndDropNotAllowed`, and `hasSubQuery` do not apply—so this is not interchangeable with\n * {@link deriveRuleOuterClassName}.\n *\n * @group Query Tools\n */\nexport const deriveRuleGroupOuterClassName = (options: OuterClassNameOptions): string =>\n  deriveOuterClassName('ruleGroup', ruleGroupOuterConditions, options);\n\n/**\n * The outer (wrapper) classname for the query builder itself, including the conditional\n * `disabled`, `valid`, and `invalid` state classes.\n *\n * @group Query Tools\n */\nexport const deriveQueryBuilderClassNames = (\n  options: OuterClassNameOptionsBase & QueryBuilderClassNameState\n): string => deriveOuterClassName('queryBuilder', queryBuilderOuterConditions, options);\n","import type {\n  Classname,\n  FlexibleOptionList,\n  FullCombinator,\n  FullOptionList,\n  FullField,\n  FullOperator,\n  FullOptionRecord,\n  InputType,\n  MatchModeOptions,\n  Option,\n  OptionList,\n  RuleGroupTypeAny,\n  RuleType,\n  ValidationMap,\n  ValidationResult,\n  ValueEditorType,\n  ValueSourceFullOptions,\n  ValueSources,\n} from '../types';\nimport { filterFieldsByComparator } from './filterFieldsByComparator';\nimport { isRuleGroupType, isRuleGroupTypeIC } from './isRuleGroup';\nimport { lc } from './misc';\nimport {\n  getFirstOption,\n  getOption,\n  isFlexibleOptionArray,\n  isFlexibleOptionGroupArray,\n  toFullOptionList,\n} from './optGroupUtils';\n\n/**\n * Functions used by {@link deriveRuleContext} to resolve a rule's configuration. Each corresponds\n * to the `QueryBuilder` prop (or `useQueryBuilderSetup` output) of the same name.\n */\nexport interface RuleContextResolvers<F extends FullField = FullField> {\n  fields: OptionList<F>;\n  fieldMap: Partial<FullOptionRecord<FullField>>;\n  getInputType: (field: string, operator: string, misc: { fieldData: F }) => InputType | null;\n  getMatchModes: (field: string, misc: { fieldData: F }) => MatchModeOptions;\n  getOperators: (field: string, misc: { fieldData: F }) => OptionList<FullOperator>;\n  getParameters: (\n    field: string,\n    operator: string,\n    misc: { fieldData: F }\n  ) => FlexibleOptionList<Option>;\n  getValueEditorType: (field: string, operator: string, misc: { fieldData: F }) => ValueEditorType;\n  getValues: (\n    field: string,\n    operator: string,\n    misc: { fieldData: F }\n  ) => FlexibleOptionList<Option>;\n  getValueSources: (\n    field: string,\n    operator: string,\n    misc: { fieldData: F }\n  ) => ValueSourceFullOptions;\n  getSubQueryBuilderProps?: (field: string, misc: { fieldData: F }) => Record<string, unknown>;\n}\n\n/**\n * Everything {@link deriveRuleContext} resolves for a single rule.\n */\nexport interface RuleContext<F extends FullField = FullField> {\n  fieldData: F;\n  hideValueControls: boolean;\n  inputType: InputType | null;\n  matchModes: MatchModeOptions;\n  operatorObject: FullOperator | undefined;\n  operators: OptionList<FullOperator>;\n  parameters: FlexibleOptionList<Option> | null;\n  validationResult: boolean | ValidationResult;\n  valueEditorType: ValueEditorType;\n  values: FlexibleOptionList<Option>;\n  valueSourceOptions: ValueSourceFullOptions;\n  valueSources: ValueSources;\n  subQueryBuilderProps: Record<string, unknown>;\n}\n\n/**\n * Resolves the field configuration for a rule's `field`, falling back to a minimal option object\n * when the field isn't present in the field map.\n */\nexport const getFieldData = (\n  field: string,\n  fieldMap: Partial<FullOptionRecord<FullField>>\n): FullField => fieldMap?.[field] ?? { name: field, value: field, label: field };\n\n/**\n * The input type for a rule. A field's own `inputType` takes precedence over `getInputType`.\n */\nexport const getRuleInputType = <F extends FullField = FullField>(\n  field: string,\n  operator: string,\n  fieldData: F,\n  getInputType: RuleContextResolvers<F>['getInputType']\n): InputType | null => fieldData.inputType ?? getInputType(field, operator, { fieldData });\n\n/**\n * Whether the value editor(s) should be hidden for an operator, based on its `arity`.\n */\nexport const hideValueControlsForOperator = (operatorObject?: FullOperator): boolean => {\n  const arity = operatorObject?.arity;\n  return (\n    (typeof arity === 'string' && arity === 'unary') || (typeof arity === 'number' && arity < 2)\n  );\n};\n\n/**\n * The subset of a rule that determines its configuration. Accepting only these properties (rather\n * than the whole rule) lets React callers keep granular memoization dependencies, so editing a\n * rule's `value` doesn't recompute its operators, value sources, or option lists.\n */\nexport type RuleFacet = Pick<RuleType, 'field' | 'operator' | 'valueSource'>;\n\n/**\n * Value source options for a rule. A `valueSource` present on the rule but absent from the\n * configured list is appended, so the current selection is always representable.\n */\nexport const getRuleValueSourceOptions = <F extends FullField = FullField>(\n  rule: RuleFacet,\n  fieldData: F,\n  getValueSources: RuleContextResolvers<F>['getValueSources']\n): ValueSourceFullOptions => {\n  const configuredVSs = getValueSources(rule.field, rule.operator, { fieldData });\n  if (rule.valueSource && !getOption(configuredVSs, rule.valueSource)) {\n    return [\n      ...configuredVSs,\n      { name: rule.valueSource, value: rule.valueSource, label: rule.valueSource },\n    ] as ValueSourceFullOptions;\n  }\n  return configuredVSs;\n};\n\n/**\n * Normalizes the result of `getParameters` to a non-empty list or `null`.\n */\nexport const getParametersAsList = (\n  parameters: FlexibleOptionList<Option>\n): FlexibleOptionList<Option> | null => (parameters && parameters.length > 0 ? parameters : null);\n\n/**\n * The value editor type for a rule. `valueSource: \"field\"` always uses a select list, and\n * `valueSource: \"parameter\"` uses a (multi)select when parameters are available.\n */\nexport const getRuleValueEditorType = <F extends FullField = FullField>(\n  rule: RuleFacet,\n  fieldData: F,\n  parametersAsList: FlexibleOptionList<Option> | null,\n  getValueEditorType: RuleContextResolvers<F>['getValueEditorType']\n): ValueEditorType =>\n  rule.valueSource === 'field'\n    ? 'select'\n    : rule.valueSource === 'parameter'\n      ? parametersAsList\n        ? lc(rule.operator) === 'in' || lc(rule.operator) === 'notin'\n          ? 'multiselect'\n          : 'select'\n        : 'text'\n      : getValueEditorType(rule.field, rule.operator, { fieldData });\n\n/**\n * The option list presented by a rule's value editor, resolved from its `valueSource`.\n */\nexport const getRuleValues = <F extends FullField = FullField>(\n  rule: RuleFacet,\n  fieldData: F,\n  fields: OptionList<F>,\n  parametersAsList: FlexibleOptionList<Option> | null,\n  getValues: RuleContextResolvers<F>['getValues']\n): FlexibleOptionList<Option> => {\n  const v =\n    rule.valueSource === 'field'\n      ? filterFieldsByComparator(fieldData, fields, rule.operator)\n      : rule.valueSource === 'parameter'\n        ? (parametersAsList ?? [])\n        : getValues(rule.field, rule.operator, { fieldData });\n  return isFlexibleOptionArray(v) || isFlexibleOptionGroupArray(v) ? toFullOptionList(v) : v;\n};\n\n/**\n * The validation result for a rule: the entry from a query-level {@link ValidationMap} if present,\n * otherwise the field's own `validator` result, otherwise `null`.\n */\nexport const getRuleValidationResult = (\n  rule: RuleType,\n  fieldData: FullField,\n  validationMap: ValidationMap = {},\n  id: string = rule.id ?? ''\n): boolean | ValidationResult =>\n  validationMap[id] ??\n  (typeof fieldData.validator === 'function' ? fieldData.validator(rule) : null);\n\n/**\n * Resolves everything about a single rule that depends on the field/operator configuration:\n * its field data, operators, value editor type, value list, value sources, match modes, and\n * validation result.\n *\n * This is the framework-agnostic core of the `useRule` hook, shared with\n * {@link QueryManager.getRuleContext} so that non-React implementations derive identical results.\n * It performs no memoization; callers are responsible for caching as appropriate.\n *\n * @group Query Tools\n */\nexport const deriveRuleContext = <F extends FullField = FullField>(\n  rule: RuleType,\n  resolvers: RuleContextResolvers<F>,\n  options: { validationMap?: ValidationMap; id?: string } = {}\n): RuleContext<F> => {\n  const {\n    fields,\n    fieldMap,\n    getInputType,\n    getMatchModes,\n    getOperators,\n    getParameters,\n    getValueEditorType,\n    getValues,\n    getValueSources,\n    getSubQueryBuilderProps,\n  } = resolvers;\n\n  const fieldData = getFieldData(rule.field, fieldMap) as F;\n  const inputType = fieldData.inputType ?? getInputType(rule.field, rule.operator, { fieldData });\n  const matchModes = getMatchModes(rule.field, { fieldData });\n  const operators = getOperators(rule.field, { fieldData });\n  const operatorObject = getOption(operators, rule.operator);\n  const valueSourceOptions = getRuleValueSourceOptions(rule, fieldData, getValueSources);\n  const parameters = getParametersAsList(getParameters(rule.field, rule.operator, { fieldData }));\n\n  return {\n    fieldData,\n    hideValueControls: hideValueControlsForOperator(operatorObject),\n    inputType,\n    matchModes,\n    operatorObject,\n    operators,\n    parameters,\n    validationResult: getRuleValidationResult(rule, fieldData, options.validationMap, options.id),\n    valueEditorType: getRuleValueEditorType(rule, fieldData, parameters, getValueEditorType),\n    values: getRuleValues(rule, fieldData, fields, parameters, getValues),\n    valueSourceOptions,\n    valueSources: valueSourceOptions.map(({ value }) => value) as ValueSources,\n    subQueryBuilderProps: getSubQueryBuilderProps?.(rule.field, { fieldData }) ?? {},\n  };\n};\n\n/**\n * Everything {@link deriveRuleGroupContext} resolves for a single rule group.\n */\nexport interface RuleGroupContext<C extends FullCombinator = FullCombinator> {\n  combinator: string;\n  combinatorObject: C | undefined;\n  combinators: FullOptionList<C>;\n  /** The `className` of the selected combinator, or `null` for independent combinators. */\n  combinatorBasedClassName: Classname | null;\n  independentCombinators: boolean;\n  validationResult: boolean | ValidationResult;\n}\n\n/**\n * The effective combinator for a group: its own `combinator` when it has one, otherwise the\n * first configured combinator (which is the case for groups with independent combinators).\n *\n * This intentionally covers only the current property-based API. The `RuleGroup` component\n * additionally falls back to its deprecated `combinator` prop; that fallback stays in the hook.\n */\nexport const getRuleGroupCombinator = <C extends FullCombinator = FullCombinator>(\n  ruleGroup: RuleGroupTypeAny,\n  combinators: FullOptionList<C>\n): string =>\n  isRuleGroupType(ruleGroup) ? ruleGroup.combinator : (getFirstOption(combinators) ?? '');\n\n/**\n * Resolves everything about a rule group that depends on the combinator configuration, plus its\n * validation result.\n *\n * Note that unlike {@link deriveRuleContext}, there is no field-level validator fallback—a\n * group's validation result comes only from the query-level {@link ValidationMap}.\n *\n * @group Query Tools\n */\nexport const deriveRuleGroupContext = <C extends FullCombinator = FullCombinator>(\n  ruleGroup: RuleGroupTypeAny,\n  combinators: FullOptionList<C>,\n  options: { validationMap?: ValidationMap; id?: string } = {}\n): RuleGroupContext<C> => {\n  const independentCombinators = isRuleGroupTypeIC(ruleGroup);\n  const combinator = getRuleGroupCombinator(ruleGroup, combinators);\n  const combinatorObject = getOption(combinators, combinator);\n\n  return {\n    combinator,\n    combinatorObject,\n    combinators,\n    combinatorBasedClassName: independentCombinators ? null : (combinatorObject?.className ?? ''),\n    independentCombinators,\n    validationResult: (options.validationMap ?? {})[options.id ?? ruleGroup.id ?? ''] ?? null,\n  };\n};\n","import type { InputType, ParseNumberMethod } from '../types';\nimport { joinWith, toArray } from './arrayUtils';\nimport { getFirstOption } from './optGroupUtils';\nimport { parseNumber } from './parseNumber';\n\n/** Operators whose value is a list rather than a single scalar. */\nconst multiValueOperators = new Set(['between', 'notBetween', 'in', 'notIn']);\n\n/**\n * Whether an operator's value is a list of two bounds.\n *\n * @group Value Editors\n */\nexport const isBetweenOperator = (operator: string): boolean =>\n  operator === 'between' || operator === 'notBetween';\n\n/**\n * Determines whether a rule's `value` needs to be collapsed to a single element because it no\n * longer represents a list, and what it should become.\n *\n * This happens when the value is an array (or a comma-containing string in a `number` input,\n * which `<input type=\"number\">` can't display) while the operator is not one of the multi-value\n * operators and the editor is not a multiselect—typically right after the operator changes from\n * `\"in\"` or `\"between\"` to something else.\n *\n * The React `useValueEditor` hook applies the result in an effect; other implementations may\n * apply it wherever is idiomatic.\n *\n * @group Value Editors\n */\nexport const getValueEditorReset = ({\n  skipHook,\n  type,\n  operator,\n  value,\n  inputType,\n}: {\n  skipHook?: boolean;\n  type?: string;\n  operator: string;\n  value: unknown;\n  inputType?: InputType | null;\n}): { reset: boolean; value: unknown } => {\n  const reset =\n    !skipHook &&\n    type !== 'multiselect' &&\n    !multiValueOperators.has(operator) &&\n    (Array.isArray(value) ||\n      (inputType === 'number' && typeof value === 'string' && value.includes(',')));\n\n  return reset\n    ? { reset: true, value: toArray(value, { retainEmptyStrings: true })[0] ?? '' }\n    : { reset: false, value };\n};\n\n/**\n * Produces the next value for a series of value editors when the editor at `index` changes.\n *\n * For `between`/`notBetween`, editing the first bound guarantees an array of at least two\n * elements, seeding the second from the first available option. The result is a comma-joined\n * string unless `listsAsArrays` is `true`.\n *\n * @group Value Editors\n */\nexport const getMultiValueUpdate = ({\n  value,\n  index,\n  valueAsArray,\n  operator,\n  values,\n  listsAsArrays,\n  parseNumberMethod,\n}: {\n  value: unknown;\n  index: number;\n  valueAsArray: unknown[];\n  operator: string;\n  // Matches the `values` prop on value editors, which is loosely typed by design.\n  // oxlint-disable-next-line typescript/no-explicit-any\n  values?: any[];\n  listsAsArrays?: boolean;\n  parseNumberMethod?: ParseNumberMethod;\n}): unknown => {\n  const parsedVal = parseNumber(value, { parseNumbers: parseNumberMethod });\n  const needsBetweenFix =\n    index === 0 &&\n    isBetweenOperator(operator) &&\n    (valueAsArray.length < 2 || valueAsArray[1] === undefined);\n\n  // Unchanged at this index and no bounds to backfill: hand back the array as-is.\n  if (valueAsArray[index] === parsedVal && !needsBetweenFix) {\n    return listsAsArrays ? valueAsArray : joinWith(valueAsArray, ',');\n  }\n\n  const v = [...valueAsArray];\n  v[index] = parsedVal;\n  if (needsBetweenFix) {\n    // `values` may be absent or empty (a plain text editor, for example), in which case the\n    // second bound is seeded with an empty string rather than `undefined`.\n    v[1] = getFirstOption(values) ?? '';\n  }\n\n  return listsAsArrays ? v : joinWith(v, ',');\n};\n\n/**\n * Coerces a value to a `bigint`, falling back to the parsed number when it can't be represented\n * as one (an empty string or a decimal, for example).\n *\n * @group Value Editors\n */\nexport const coerceBigIntValue = (\n  value: unknown,\n  parseNumberMethod?: ParseNumberMethod\n): unknown => {\n  const valAsMaybeNumber = parseNumber(value, {\n    parseNumbers: parseNumberMethod,\n    bigIntOnOverflow: true,\n  });\n\n  try {\n    return BigInt(valAsMaybeNumber as string | number | bigint);\n  } catch {\n    return valAsMaybeNumber;\n  }\n};\n\n/**\n * The `type` attribute an `<input>` should use for a rule. `bigint` values and the `in`/`notIn`\n * operators (whose value is a comma-separated list) both require a text input.\n *\n * @group Value Editors\n */\nexport const coerceInputType = (\n  inputType: InputType | null | undefined,\n  operator: string\n): InputType =>\n  inputType === 'bigint' || operator === 'in' || operator === 'notIn'\n    ? 'text'\n    : inputType || 'text';\n\n/**\n * Produces the next value for a value selector. Multiselect values are normalized to an array\n * first, then comma-joined unless `listsAsArrays` is `true`. Single-select values pass through.\n *\n * @group Value Editors\n */\nexport const getValueSelectorUpdate = (\n  value: string | string[],\n  { multiple, listsAsArrays }: { multiple?: boolean; listsAsArrays?: boolean } = {}\n): string | string[] => {\n  if (!multiple) return value;\n\n  const valueAsArray = toArray(value);\n  return listsAsArrays ? valueAsArray : joinWith(valueAsArray, ',');\n};\n\n/**\n * Normalizes a value selector's current value for display. Multiselect values become an array of\n * strings so they match option names, which are always strings (e.g. `[42]` becomes `[\"42\"]`).\n *\n * @group Value Editors\n */\nexport const normalizeValueSelectorValue = (\n  value: unknown,\n  multiple?: boolean\n  // oxlint-disable-next-line typescript/no-explicit-any\n): any => (multiple ? toArray(value).map(String) : value);\n","import type { Path, RuleGroupTypeAny, RuleType } from '../types';\nimport { isRuleGroup } from './isRuleGroup';\nimport { isPojo } from './misc';\n\n/**\n * Return type for {@link findPath}.\n */\nexport type FindPathReturnType = RuleGroupTypeAny | RuleType | null;\n\n/**\n * Returns the {@link RuleType} or {@link RuleGroupType}/{@link RuleGroupTypeIC}\n * at the given path within a query.\n */\nexport const findPath = (path: Path, query: RuleGroupTypeAny): FindPathReturnType => {\n  let target: FindPathReturnType = query;\n  let level = 0;\n  while (level < path.length && target && isRuleGroup(target)) {\n    const t: RuleGroupTypeAny | RuleType | string = target.rules[path[level]];\n    target = typeof t === 'string' ? null : t;\n    level++;\n  }\n\n  return level < path.length ? null : target;\n};\n\n/**\n * Returns the {@link RuleType} or {@link RuleGroupType}/{@link RuleGroupTypeIC}\n * with the given `id` within a query.\n */\nexport const findID = (id: string, query: RuleGroupTypeAny): FindPathReturnType => {\n  if (query.id === id) {\n    return query;\n  }\n\n  for (const rule of query.rules) {\n    if (typeof rule === 'string') continue;\n    if (rule.id === id) {\n      return rule;\n    } else if (isRuleGroup(rule)) {\n      const subRule = findID(id, rule);\n      if (subRule) {\n        return subRule;\n      }\n    }\n  }\n\n  return null;\n};\n\n/**\n * Returns the {@link Path} of the {@link RuleType} or {@link RuleGroupType}/{@link RuleGroupTypeIC}\n * with the given `id` within a query.\n */\nexport const getPathOfID = (id: string, query: RuleGroupTypeAny): Path | null => {\n  if (query.id === id) return [];\n\n  const idx = query.rules.findIndex(r => !(typeof r === 'string') && r.id === id);\n\n  if (idx >= 0) {\n    return [idx];\n  }\n\n  for (const [i, r] of Object.entries(query.rules)) {\n    if (isRuleGroup(r)) {\n      const subPath = getPathOfID(id, r);\n      if (Array.isArray(subPath)) {\n        return [Number.parseInt(i), ...subPath];\n      }\n    }\n  }\n\n  return null;\n};\n\n/**\n * Truncates the last element of an array and returns the result as a new array.\n */\nexport const getParentPath = (path: Path): Path => path.slice(0, -1);\n\n/**\n * Determines if two paths (each `Path`) are equivalent.\n */\nexport const pathsAreEqual = (path1: Path, path2: Path): boolean => {\n  if (path1.length !== path2.length) return false;\n  for (let i = 0; i < path1.length; i++) {\n    if (path1[i] !== path2[i]) return false;\n  }\n  return true;\n};\n\n/**\n * Determines if the first path is an ancestor of the second path. The first path must\n * be shorter and exactly match the second path up through the length of the first path.\n */\nexport const isAncestor = (maybeAncestor: Path, path: Path): boolean => {\n  if (maybeAncestor.length >= path.length) return false;\n  for (let i = 0; i < maybeAncestor.length; i++) {\n    if (maybeAncestor[i] !== path[i]) return false;\n  }\n  return true;\n};\n\n/**\n * Finds the deepest/longest path that two paths have in common.\n */\nexport const getCommonAncestorPath = (path1: Path, path2: Path): Path => {\n  const commonAncestorPath: Path = [];\n  const parentPath1 = getParentPath(path1);\n  const parentPath2 = getParentPath(path2);\n  let i = 0;\n\n  while (i < parentPath1.length && i < parentPath2.length && parentPath1[i] === parentPath2[i]) {\n    commonAncestorPath.push(parentPath2[i]);\n    i++;\n  }\n\n  return commonAncestorPath;\n};\n\n/**\n * Determines if the rule or group at the specified path is either disabled itself\n * or disabled by an ancestor group.\n */\nexport const pathIsDisabled = (path: Path, query: RuleGroupTypeAny): boolean => {\n  let disabled = !!query.disabled;\n  let target: RuleType | RuleGroupTypeAny = query;\n  let level = 0;\n  while (level < path.length && !disabled && isRuleGroup(target)) {\n    const t: RuleGroupTypeAny | RuleType | string = target.rules[path[level]];\n    if (isPojo(t) && (isRuleGroup(t) || ('field' in t && !!t.field))) {\n      disabled = !!t.disabled;\n      target = t;\n    }\n    level++;\n  }\n  return disabled;\n};\n\n/**\n * Determines if the rule or group at the specified path is disabled by `disabledPaths`—the array\n * form of the `QueryBuilder` `disabled` prop, which disables nodes by position rather than by a\n * `disabled` property on the node itself. A path is disabled if it appears in `disabledPaths` or\n * descends from a path that does.\n *\n * @group Paths\n */\nexport const pathIsDisabledByPaths = (path: Path, disabledPaths: Path[] = []): boolean =>\n  disabledPaths.some(p => pathsAreEqual(p, path) || isAncestor(p, path));\n\n/** The path of a child rule or group, and whether it is disabled. */ export interface PathInfo {\n  path: Path;\n  disabled: boolean;\n}\n\n/**\n * Builds the {@link PathInfo} for each child of a group at `path`. A child is disabled if its\n * parent is disabled or if its own path appears in `disabledPaths`.\n *\n * @group Paths\n */\nexport const derivePathInfo = (\n  path: Path,\n  childCount: number,\n  { disabled = false, disabledPaths = [] }: { disabled?: boolean; disabledPaths?: Path[] } = {}\n): PathInfo[] => {\n  const paths: PathInfo[] = [];\n  for (let i = 0; i < childCount; i++) {\n    const thisPath = [...path, i];\n    paths[i] = {\n      path: thisPath,\n      disabled: disabled || disabledPaths.some(p => pathsAreEqual(thisPath, p)),\n    };\n  }\n  return paths;\n};\n","import type { AccessibleDescriptionGenerator as ADG } from '../types';\nimport { pathsAreEqual } from './pathUtils';\n\n/**\n * The default `accessibleDescriptionGenerator`. Produces the `aria-label` for a rule group:\n * `\"Query builder\"` for the root group, `\"Rule group at path 0-1\"` for any other.\n *\n * @group Accessibility\n */\nexport const generateAccessibleDescription: ADG = params =>\n  pathsAreEqual([], params.path) ? `Query builder` : `Rule group at path ${params.path.join('-')}`;\n","import { defaultMatchModes } from '../defaults';\nimport type {\n  FlexibleOption,\n  FullField,\n  GetOptionIdentifierType,\n  MatchMode,\n  MatchModeOptions,\n} from '../types';\nimport { lc } from './misc';\nimport { isFlexibleOptionArray, toFullOption, toFullOptionList } from './optGroupUtils';\n\nconst dummyFD = {\n  name: 'name',\n  value: 'name',\n  matchModes: null,\n  label: 'label',\n};\n\n/**\n * Utility function to get the match modes array for the given\n * field. If the field definition does not define a `matchModes`\n * property, the `getMatchModes` prop is used. Returns\n * `FullOption<MatchMode>[]` of all match modes by default.\n */\nexport const getMatchModesUtil = <F extends FullField>(\n  fieldData: F,\n  getMatchModes?: (\n    field: GetOptionIdentifierType<F>,\n    misc: { fieldData: F }\n  ) => boolean | MatchMode[] | FlexibleOption<MatchMode>[]\n): MatchModeOptions => {\n  // TypeScript doesn't allow it directly, but in practice\n  // `fieldData` can end up being undefined or null. The nullish\n  // coalescing assignment below avoids errors like\n  // \"TypeError: Cannot read properties of undefined (reading 'name')\"\n  const fd = fieldData ? toFullOption(fieldData) : /* v8 ignore next -- @preserve */ dummyFD;\n\n  let matchModes: boolean | MatchMode[] | FlexibleOption<MatchMode>[] = fd.matchModes ?? false;\n\n  if (!matchModes && getMatchModes) {\n    matchModes = getMatchModes(fd.value as GetOptionIdentifierType<F>, {\n      fieldData: fd as F,\n    });\n  }\n\n  if (matchModes === true) {\n    return defaultMatchModes;\n  } else if (matchModes === false) {\n    return [];\n  }\n\n  if (isFlexibleOptionArray(matchModes)) {\n    return toFullOptionList(matchModes) as MatchModeOptions;\n  }\n\n  return (matchModes?.map(\n    mm =>\n      defaultMatchModes.find(dmm => dmm.value === lc(mm)) ?? {\n        name: mm,\n        value: mm,\n        label: mm,\n      }\n  ) ?? []) as MatchModeOptions;\n};\n","import type {\n  FullField,\n  FullOptionList,\n  Option,\n  OptionList,\n  RuleType,\n  ValueEditorType,\n} from '../types';\nimport { joinWith } from './arrayUtils';\nimport { filterFieldsByComparator } from './filterFieldsByComparator';\nimport { getFirstOption } from './optGroupUtils';\n\n// First option of a list, paired for `between`/`notBetween` operators (array or joined string).\nconst getFirstOptionsFrom = (opts: OptionList, r: RuleType, listsAsArrays?: boolean) => {\n  const firstOption = getFirstOption(opts);\n\n  if (r.operator === 'between' || r.operator === 'notBetween') {\n    const valueAsArray = [firstOption, firstOption];\n    return listsAsArrays\n      ? valueAsArray\n      : joinWith(\n          valueAsArray.map(\n            v => v ?? /* v8 ignore start -- @preserve */ '' /* v8 ignore stop -- @preserve */\n          ),\n          ','\n        );\n  }\n\n  return firstOption;\n};\n\n/** Options for {@link getRuleDefaultValue}. */\nexport interface GetRuleDefaultValueOptions<F extends FullField = FullField> {\n  /** Resolved field configuration for `rule.field` (e.g. `fieldMap[rule.field] ?? {}`). */\n  fieldData: F;\n  /** Full field list, used to seed a comparator-valid field when `valueSource` is `'field'`. */\n  fields: FullOptionList<F>;\n  /** Resolves the editor type for the field/operator (drives select/radio/checkbox defaults). */\n  getValueEditorType: (field: string, operator: string, meta: { fieldData: F }) => ValueEditorType;\n  /** Resolves the value option list for the field/operator. */\n  getValues: (field: string, operator: string, meta: { fieldData: F }) => FullOptionList<Option>;\n  /** Optional escape hatch overriding the computed default. */\n  getDefaultValue?: (rule: RuleType, meta: { fieldData: F }) => unknown;\n  /** Named parameter options, used to seed a default when `valueSource` is `'parameter'`. */\n  getParameters?: (\n    field: string,\n    operator: string,\n    meta: { fieldData: F }\n  ) => FullOptionList<Option> | null;\n  /** When `true`, multi-value defaults are arrays instead of comma-joined strings. */\n  listsAsArrays?: boolean;\n}\n\n/**\n * Computes the default `value` for a rule given its `field`/`operator`/`valueSource`, mirroring\n * the precedence the {@link react-querybuilder!QueryBuilder QueryBuilder} applies: a field's\n * `defaultValue`, then a `getDefaultValue` override, then a value derived from the field/operator's\n * value list and editor type (first option for `select`/`radio`, `false` for `checkbox`, paired for\n * `between`/`notBetween`), or a comparator-valid field when `valueSource` is `'field'`. Falls back\n * to `''`.\n *\n * @group Option Lists\n */\nexport const getRuleDefaultValue = <F extends FullField = FullField>(\n  rule: RuleType,\n  options: GetRuleDefaultValueOptions<F>\n): unknown => {\n  const {\n    fieldData,\n    fields,\n    getValueEditorType,\n    getValues,\n    getDefaultValue,\n    getParameters,\n    listsAsArrays,\n  } = options;\n\n  if (fieldData?.defaultValue !== undefined && fieldData.defaultValue !== null) {\n    return fieldData.defaultValue;\n  } else if (getDefaultValue) {\n    return getDefaultValue(rule, { fieldData });\n  }\n\n  let value: string | (string | null)[] | boolean | null = '';\n\n  const values = getValues(rule.field, rule.operator, { fieldData });\n\n  if (rule.valueSource === 'field') {\n    const filteredFields = filterFieldsByComparator(fieldData, fields, rule.operator);\n    value =\n      filteredFields.length > 0 ? getFirstOptionsFrom(filteredFields, rule, listsAsArrays) : '';\n  } else if (rule.valueSource === 'parameter') {\n    const parameters = getParameters\n      ? getParameters(rule.field, rule.operator, { fieldData })\n      : null;\n    value = parameters && parameters.length > 0 ? getFirstOption(parameters) : '';\n  } else if (values.length > 0) {\n    const editorType = getValueEditorType(rule.field, rule.operator, { fieldData });\n    if (editorType === 'multiselect') {\n      value = listsAsArrays ? [] : '';\n    } else if (editorType === 'select' || editorType === 'radio') {\n      value = getFirstOptionsFrom(values, rule, listsAsArrays);\n    }\n  } else {\n    const editorType = getValueEditorType(rule.field, rule.operator, { fieldData });\n    if (editorType === 'checkbox') {\n      value = false;\n    }\n  }\n\n  return value;\n};\n","import { standardClassnames } from '../defaults';\nimport type { ValidationResult } from '../types';\n\n/**\n * Gets the standard classname for valid or invalid components\n * based on the given validation result.\n */\nexport const getValidationClassNames = (\n  validationResult: boolean | ValidationResult\n): '' | (typeof standardClassnames)['valid'] | (typeof standardClassnames)['invalid'] => {\n  const valid =\n    typeof validationResult === 'boolean'\n      ? validationResult\n      : typeof validationResult === 'object' && validationResult !== null\n        ? validationResult.valid\n        : null;\n  return typeof valid === 'boolean'\n    ? valid\n      ? standardClassnames.valid\n      : standardClassnames.invalid\n    : '';\n};\n","import { Immer, produce, setAutoFreeze as immerSetAutoFreeze } from 'immer';\n\n/**\n * Globally enables or disables immer's auto-freeze, i.e. the deep freeze applied to every query\n * returned by {@link add}, {@link update}, {@link remove}, {@link move}, {@link insert}, and\n * {@link group}.\n *\n * Re-exported from immer so that consumers mixing these tools with their own `produce` calls can\n * switch both at once. Prefer the per-call `freeze` option, or the {@link QueryManager} option of\n * the same name, when the change should not be process-wide. A per-call `freeze: false` wins\n * regardless of this setting; a per-call `freeze: true` does not re-enable freezing once this has\n * turned it off, since it selects immer's default instance.\n *\n * @group Query Tools\n */\nexport const setAutoFreeze: (autoFreeze: boolean) => void = immerSetAutoFreeze;\n\n// Immer has no per-call auto-freeze control, so a second instance with auto-freeze disabled\n// serves calls that opt out. `setAutoFreeze` (re-exported from the root) affects the default\n// instance only, which is what a global escape hatch should do.\nconst unfrozenImmer = new Immer({ autoFreeze: false });\n\n/**\n * The `produce` implementation matching the requested freeze behavior.\n *\n * @internal\n */\nexport const producerFor = (freeze = true): typeof produce =>\n  freeze ? produce : unfrozenImmer.produce;\n","import { isUnsafeKey, objectEntries, objectKeys } from './objectUtils';\n\n/**\n * Merges any number of partial translations into a single definition.\n */\nexport const mergeAnyTranslations = (\n  base: Record<string, Record<string, unknown>>,\n  ...otherTranslations: (Record<string, Record<string, unknown>> | undefined)[]\n): Record<string, Record<string, unknown>> => {\n  const result = { ...base };\n\n  for (const translations of otherTranslations) {\n    // v8 ignore else\n    if (translations) {\n      for (const key of objectKeys(translations)) {\n        if (isUnsafeKey(key)) continue;\n        if (result[key]) {\n          result[key] = { ...result[key], ...translations[key] };\n        } else {\n          result[key] = { ...translations[key] };\n        }\n      }\n    }\n  }\n\n  return result;\n};\n\nexport const mergeAnyTranslation = (\n  el: string,\n  keyPropContextMap: Record<string, [unknown, unknown]>,\n  defaults?: Record<string, Record<string, unknown>>\n): Record<string, Record<string, unknown>> | undefined => {\n  if (isUnsafeKey(el)) return undefined;\n  const finalKeys = objectEntries(keyPropContextMap)\n    .map(([key, [pT, cT]]) => [key, pT ?? cT ?? defaults?.[el]?.[key]])\n    .filter(k => !isUnsafeKey(k[0] as string) && !!k[1]);\n  if (finalKeys.length > 0 || defaults) {\n    const defaultProperties = defaults?.[el] ?? {};\n    const finalObject = Object.assign({}, defaultProperties, Object.fromEntries(finalKeys));\n    return { [el]: finalObject };\n  }\n  return undefined;\n};\n","import type { Classnames } from '../types';\nimport { clsx } from './clsx';\n\ntype MergeClassnamesParams = (Partial<Classnames> | undefined)[];\n\nconst joinClassnamesByName = (name: keyof Classnames, args: MergeClassnamesParams) => {\n  let result = '';\n  for (let i = 0; i < args.length; i++) {\n    const v = args[i]?.[name];\n    if (!v) continue;\n    // clsx only needed for array/object values; plain strings (common case) pass through\n    const s = typeof v === 'string' ? v : clsx(v);\n    if (s) result = result ? `${result} ${s}` : s;\n  }\n  return result;\n};\n\n/**\n * Merges a list of partial {@link Classnames} definitions into a single definition.\n */\nexport const mergeClassnames = (...args: MergeClassnamesParams): Classnames => ({\n  queryBuilder: joinClassnamesByName('queryBuilder', args),\n  ruleGroup: joinClassnamesByName('ruleGroup', args),\n  header: joinClassnamesByName('header', args),\n  body: joinClassnamesByName('body', args),\n  combinators: joinClassnamesByName('combinators', args),\n  addRule: joinClassnamesByName('addRule', args),\n  addGroup: joinClassnamesByName('addGroup', args),\n  cloneRule: joinClassnamesByName('cloneRule', args),\n  cloneGroup: joinClassnamesByName('cloneGroup', args),\n  removeGroup: joinClassnamesByName('removeGroup', args),\n  rule: joinClassnamesByName('rule', args),\n  fields: joinClassnamesByName('fields', args),\n  operators: joinClassnamesByName('operators', args),\n  value: joinClassnamesByName('value', args),\n  removeRule: joinClassnamesByName('removeRule', args),\n  notToggle: joinClassnamesByName('notToggle', args),\n  shiftActions: joinClassnamesByName('shiftActions', args),\n  undoRedoActions: joinClassnamesByName('undoRedoActions', args),\n  undoAction: joinClassnamesByName('undoAction', args),\n  redoAction: joinClassnamesByName('redoAction', args),\n  dragHandle: joinClassnamesByName('dragHandle', args),\n  lockRule: joinClassnamesByName('lockRule', args),\n  lockGroup: joinClassnamesByName('lockGroup', args),\n  muteRule: joinClassnamesByName('muteRule', args),\n  muteGroup: joinClassnamesByName('muteGroup', args),\n  muted: joinClassnamesByName('muted', args),\n  valueSource: joinClassnamesByName('valueSource', args),\n  actionElement: joinClassnamesByName('actionElement', args),\n  valueSelector: joinClassnamesByName('valueSelector', args),\n  betweenRules: joinClassnamesByName('betweenRules', args),\n  valid: joinClassnamesByName('valid', args),\n  invalid: joinClassnamesByName('invalid', args),\n  dndDragging: joinClassnamesByName('dndDragging', args),\n  dndOver: joinClassnamesByName('dndOver', args),\n  dndCopy: joinClassnamesByName('dndCopy', args),\n  dndGroup: joinClassnamesByName('dndGroup', args),\n  dndDropNotAllowed: joinClassnamesByName('dndDropNotAllowed', args),\n  dndPreviewPosition: joinClassnamesByName('dndPreviewPosition', args),\n  dndHidden: joinClassnamesByName('dndHidden', args),\n  disabled: joinClassnamesByName('disabled', args),\n  valueListItem: joinClassnamesByName('valueListItem', args),\n  matchMode: joinClassnamesByName('matchMode', args),\n  matchThreshold: joinClassnamesByName('matchThreshold', args),\n  branches: joinClassnamesByName('branches', args),\n  hasSubQuery: joinClassnamesByName('hasSubQuery', args),\n  loading: joinClassnamesByName('loading', args),\n  valueDateTimeRelative: joinClassnamesByName('valueDateTimeRelative', args),\n});\n","import { defaultOperatorLabelMap } from '../defaults';\nimport type {\n  FlexibleOptionList,\n  FlexibleOptionListProp,\n  FullField,\n  FullOperator,\n  FullOption,\n  FullOptionList,\n  Option,\n  Placeholder,\n  ValueEditorType,\n} from '../types';\nimport { getFirstOption, prepareOptionList } from './optGroupUtils';\n\n/**\n * Options shared by the resolvers below that produce a normalized option list.\n */\nexport interface ResolveOptionListOptions {\n  /**\n   * Prepended as an empty placeholder option when `autoSelectOption` is `false`. Supplied by the\n   * `translations` prop in React; omit it where translations don't apply.\n   */\n  placeholder?: Placeholder;\n  /** Properties applied to every option in the resulting list. */\n  baseOption?: Record<string, unknown>;\n  /** When `false`, an empty placeholder option is prepended. */\n  autoSelectOption?: boolean;\n}\n\n/**\n * Resolves the operator list for a field, applying the same precedence as the `QueryBuilder`\n * component: the field's own `operators`, then the `getOperators` callback, then the\n * query-level operator list.\n *\n * @group Option Lists\n */\nexport const resolveOperatorList = <\n  F extends FullField = FullField,\n  O extends FullOperator = FullOperator,\n>({\n  field,\n  fieldData,\n  getOperators,\n  operators,\n  placeholder,\n  baseOption,\n  autoSelectOption,\n}: {\n  field: string;\n  fieldData: F;\n  getOperators?: (field: string, misc: { fieldData: F }) => FlexibleOptionList<O> | null;\n  operators: FullOptionList<O>;\n} & ResolveOptionListOptions): FullOptionList<O> =>\n  prepareOptionList<O>({\n    optionList: (fieldData?.operators ??\n      getOperators?.(field, { fieldData }) ??\n      operators) as FlexibleOptionListProp<O>,\n    placeholder,\n    baseOption,\n    labelMap: defaultOperatorLabelMap,\n    autoSelectOption,\n  }).optionList;\n\n/**\n * Resolves the default operator for a field, applying the same precedence as the `QueryBuilder`\n * component: the field's own `defaultOperator`, then the `getDefaultOperator` option (a string or\n * a function), then the first available operator.\n *\n * @group Option Lists\n */\nexport const resolveDefaultOperator = <F extends FullField = FullField>({\n  field,\n  fieldData,\n  getDefaultOperator,\n  getOperators,\n}: {\n  field: string;\n  fieldData: F;\n  getDefaultOperator?: string | ((field: string, misc: { fieldData: F }) => string);\n  /** Produces the operator list for the field, i.e. {@link resolveOperatorList} already bound. */\n  getOperators: (field: string, misc: { fieldData: F }) => FullOptionList<FullOperator>;\n}): string => {\n  if (fieldData?.defaultOperator) return fieldData.defaultOperator;\n\n  if (getDefaultOperator) {\n    return typeof getDefaultOperator === 'function'\n      ? getDefaultOperator(field, { fieldData })\n      : getDefaultOperator;\n  }\n\n  return getFirstOption(getOperators(field, { fieldData })) ?? '';\n};\n\n/**\n * Resolves the value editor type for a field/operator pair, applying the same precedence as the\n * `QueryBuilder` component: the field's own `valueEditorType` (a string or a function of the\n * operator), then the `getValueEditorType` callback, then `\"text\"`.\n *\n * @group Option Lists\n */\nexport const resolveValueEditorType = <F extends FullField = FullField>({\n  field,\n  operator,\n  fieldData,\n  getValueEditorType,\n}: {\n  field: string;\n  operator: string;\n  fieldData: F;\n  getValueEditorType?: (field: string, operator: string, misc: { fieldData: F }) => ValueEditorType;\n}): ValueEditorType => {\n  if (fieldData?.valueEditorType) {\n    return typeof fieldData.valueEditorType === 'function'\n      ? fieldData.valueEditorType(operator)\n      : fieldData.valueEditorType;\n  }\n\n  return getValueEditorType?.(field, operator, { fieldData }) ?? 'text';\n};\n\n/**\n * Resolves the value option list for a field/operator pair, applying the same precedence as the\n * `QueryBuilder` component: the field's own `values`, then the `getValues` callback, then an\n * empty list.\n *\n * @group Option Lists\n */\nexport const resolveValueList = <F extends FullField = FullField>({\n  field,\n  operator,\n  fieldData,\n  getValues,\n  placeholder,\n  baseOption,\n  autoSelectOption,\n}: {\n  field: string;\n  operator: string;\n  fieldData: F;\n  getValues?: (\n    field: string,\n    operator: string,\n    misc: { fieldData: F }\n  ) => FlexibleOptionList<Option> | null;\n} & ResolveOptionListOptions): FullOptionList<Option> =>\n  prepareOptionList<FullOption>({\n    optionList: fieldData?.values ?? getValues?.(field, operator, { fieldData }) ?? [],\n    placeholder,\n    baseOption,\n    autoSelectOption,\n  }).optionList;\n","import type { FullCombinator, FullField, FullOperator } from '../types';\n// Type-only, so this does not create a cycle with `QueryManager.ts`, which imports `optionsEqual`.\nimport type { QueryManagerOptions } from './QueryManager';\n\nconst isPlainObject = (x: object): boolean => {\n  const proto = Object.getPrototypeOf(x);\n  return proto === null || proto === Object.prototype;\n};\n\n/**\n * Structural equality for {@link QueryManagerOptions} values. Arrays and plain objects are\n * compared by value; everything else — functions, class instances, `Map`s, `Date`s — by\n * identity.\n *\n * That split is what makes an options object rebuilt on every render compare equal as long as\n * its _data_ did not change, which is the entire point: a caller that passes object literals\n * (`fields={[...]}`, `translations={{...}}`) hands a fresh identity to every reconfigure, so an\n * identity-only comparison would report a change every time.\n *\n * Comparing functions by identity is deliberate rather than a limitation. Two functions cannot\n * be proven equivalent, so a caller that rebuilds `getDefaultValue` per render must either\n * memoize it or accept the reconfigure.\n */\nexport const valuesEqual = (a: unknown, b: unknown): boolean => {\n  if (Object.is(a, b)) return true;\n\n  if (Array.isArray(a) || Array.isArray(b)) {\n    return (\n      Array.isArray(a) &&\n      Array.isArray(b) &&\n      a.length === b.length &&\n      a.every((v, i) => valuesEqual(v, b[i]))\n    );\n  }\n\n  if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) return false;\n\n  // Different shapes are never equal, and non-plain objects (class instances, `Date`, `Map`,\n  // …) are compared by identity only — their state is not exhausted by their own enumerable\n  // keys, so a key-wise walk would report two distinct `Date`s as equal.\n  if (Object.getPrototypeOf(a) !== Object.getPrototypeOf(b) || !isPlainObject(a)) return false;\n\n  const aKeys = Object.keys(a);\n  return (\n    aKeys.length === Object.keys(b).length &&\n    aKeys.every(k =>\n      valuesEqual((a as Record<string, unknown>)[k], (b as Record<string, unknown>)[k])\n    )\n  );\n};\n\n/**\n * Whether two {@link QueryManagerOptions} objects describe the same configuration, per\n * {@link valuesEqual}: data by value, functions by identity.\n *\n * {@link QueryManager.reconfigure} uses this to gate itself, so most callers never need it\n * directly. It is exported for framework adapters that decide whether to _call_ `reconfigure`\n * at all — skipping the call avoids building the merged options object in the first place.\n *\n * Nested option objects (`history`, `translations`, …) are descended into rather than compared\n * by identity, so `{ history: { maxHistory: 10 } }` rebuilt per render compares equal.\n */\nexport const optionsEqual = <\n  F extends FullField = FullField,\n  O extends FullOperator = FullOperator,\n  C extends FullCombinator = FullCombinator,\n>(\n  a: Partial<QueryManagerOptions<F, O, C>> | undefined,\n  b: Partial<QueryManagerOptions<F, O, C>> | undefined\n): boolean => valuesEqual(a, b);\n","import { queryBuilderFlagDefaults } from '../defaults';\nimport type { QueryBuilderFlags } from '../types';\nimport { objectEntries } from './objectUtils';\n\nconst preferPropDefaultTrue = (prop?: boolean, context?: boolean) =>\n  prop === false ? false : prop ? true : !(context === false);\n\nconst preferPropDefaultFalse = (prop?: boolean, context?: boolean) =>\n  prop ? true : prop === false ? false : !!context;\n\n/**\n * For given default, prop, and context values, return the first provided of prop,\n * context, and default, in that order.\n */\nexport const preferProp = (\n  def: boolean,\n  prop?: boolean,\n  context?: boolean,\n  doNotFinalize?: boolean\n): boolean =>\n  !doNotFinalize\n    ? def\n      ? preferPropDefaultTrue(prop, context)\n      : preferPropDefaultFalse(prop, context)\n    : (prop ?? (context as boolean));\n\n/**\n * For given default, prop, and context values, return the first provided of prop,\n * context, and default, in that order.\n */\n// oxlint-disable-next-line typescript/no-explicit-any\nexport const preferAnyProp = (def?: any, prop?: any, context?: any): any =>\n  prop !== undefined && prop != null\n    ? prop\n    : context !== undefined && context != null\n      ? context\n      : def;\n\n/**\n * For a given set of defaults, props, and context values, return the first provided of prop,\n * context, and default—in that order—for each property in the defaults object.\n */\nexport const preferFlagProps = (\n  props: QueryBuilderFlags = {},\n  contextVals: QueryBuilderFlags = {},\n  finalize?: boolean\n): QueryBuilderFlags =>\n  objectEntries(queryBuilderFlagDefaults).reduce<QueryBuilderFlags>((acc, [key, def]) => {\n    acc[key] = preferProp(def, props[key], contextVals[key], !finalize);\n    return acc;\n  }, {});\n","import type { SetRequired } from 'type-fest';\nimport type { RuleGroupTypeAny, RuleType } from '../types';\nimport { generateID } from './generateID';\nimport { isRuleGroup } from './isRuleGroup';\nimport { isPojo } from './misc';\n\n/**\n * Options object for {@link regenerateID}/{@link regenerateIDs}.\n */\nexport interface RegenerateIdOptions {\n  idGenerator?: () => string;\n}\n\n/**\n * Generates a new `id` property for a rule.\n */\nexport const regenerateID = <R extends RuleType>(\n  rule: R,\n  { idGenerator = generateID }: RegenerateIdOptions = {}\n): SetRequired<R, 'id'> => structuredClone({ ...rule, id: idGenerator() } as SetRequired<R, 'id'>);\n\n/**\n * Recursively generates new `id` properties for a rule group and all its rules and subgroups.\n */\nexport const regenerateIDs = <RG>(\n  subject: RG,\n  { idGenerator = generateID }: RegenerateIdOptions = {}\n): RG & { id: string } => {\n  if (!isPojo(subject)) return subject as RG & { id: string };\n\n  if (!isRuleGroup(subject)) {\n    return structuredClone({\n      ...subject,\n      id: idGenerator(),\n    });\n  }\n\n  const newGroup = { ...subject, id: idGenerator() } as RuleGroupTypeAny;\n\n  // v8 ignore else\n  if (Array.isArray(newGroup.rules)) {\n    // oxlint-disable-next-line no-explicit-any\n    (newGroup.rules as any) = subject.rules.map((r: unknown) =>\n      typeof r === 'string'\n        ? r\n        : isRuleGroup(r)\n          ? regenerateIDs(r, { idGenerator })\n          : regenerateID(r as RuleType, { idGenerator })\n    );\n  }\n\n  return newGroup as unknown as RG & { id: string };\n};\n","import { current, isDraft } from 'immer';\nimport { defaultCombinators } from '../defaults';\nimport type {\n  MatchModeOptions,\n  OptionList,\n  Path,\n  RuleGroupTypeAny,\n  RuleType,\n  UpdateableProperties,\n  UpdateValueMap,\n  ValueSourceFlexibleOptions,\n  ValueSources,\n} from '../types';\nimport { generateID } from './generateID';\nimport { getValueSourcesUtil } from './getValueSourcesUtil';\nimport { producerFor } from './immerInstances';\nimport { isRuleGroup, isRuleGroupType, isRuleGroupTypeIC } from './isRuleGroup';\nimport { getFirstOption, getOption } from './optGroupUtils';\nimport {\n  findID,\n  findPath,\n  getCommonAncestorPath,\n  getParentPath,\n  getPathOfID,\n  isAncestor,\n  pathIsDisabled,\n  pathIsDisabledByPaths,\n  pathsAreEqual,\n} from './pathUtils';\nimport { prepareRuleOrGroup } from './prepareQueryObjects';\nimport { regenerateIDs } from './regenerateIDs';\n\n/**\n * Why a query tool returned the query unmodified. Query tools never throw; when they cannot\n * carry out an operation they return the original query and report the reason through\n * {@link AbortOptions.onAbort}.\n *\n * `\"same-location\"` and `\"no-change\"` describe operations that were valid but had nothing to\n * do, so they are not errors. Every other reason indicates a target that could not be used.\n *\n * @group Query Tools\n */\nexport type AbortReason =\n  /** The rule/group identified by the given path or `id` does not exist. */\n  | 'target-not-found'\n  /** The parent group identified by the given path or `id` does not exist. */\n  | 'parent-not-found'\n  /** The given parent path or `id` refers to a rule rather than a group. */\n  | 'parent-not-a-group'\n  /** The destination's parent group does not exist. */\n  | 'destination-not-found'\n  /** The root group cannot be removed, moved, or grouped. */\n  | 'root-not-allowed'\n  /** In a query with independent combinators, the target index holds a rule, not a combinator. */\n  | 'not-a-combinator-slot'\n  /** The rule/group is already at the destination. Not an error. */\n  | 'same-location'\n  /** The property already has the given value. Not an error. */\n  | 'no-change'\n  /** The target rule/group is disabled, or descends from a disabled group. */\n  | 'target-disabled'\n  /** The parent group is disabled, or descends from a disabled group. */\n  | 'parent-disabled'\n  /** Adding the group would nest it deeper than `maxLevels` allows. */\n  | 'max-levels-exceeded';\n\n/**\n * Details about an aborted query tool operation.\n *\n * @group Query Tools\n */\nexport interface AbortInfo {\n  /** Why the operation was aborted. */\n  reason: AbortReason;\n  /** The query tool that aborted. */\n  operation: 'add' | 'remove' | 'update' | 'move' | 'insert' | 'group';\n  /** The path or `id` that could not be used, when the reason relates to a specific target. */\n  pathOrID?: Path | string;\n}\n\n/**\n * Options that block a mutation before it is attempted.\n *\n * `disabled` is a property of the query itself, so honoring it is a matter of data integrity\n * rather than presentation: a query saved with a locked rule should stay locked when it is\n * loaded again. It is opt-in here only to preserve the existing behavior of the standalone\n * query tools; {@link QueryManager} enables it by default.\n *\n * @group Query Tools\n */\nexport interface GuardOptions {\n  /**\n   * Abort when the target (or its parent, for `add`/`insert`) is disabled, either directly or\n   * by descending from a disabled group. Defaults to `false`.\n   *\n   * Updating a rule or group's own `disabled` property is always permitted, since it is the\n   * only way to re-enable it.\n   */\n  respectDisabled?: boolean;\n  /**\n   * Paths that are disabled without the corresponding rule or group carrying a `disabled`\n   * property, mirroring the array form of the `QueryBuilder` `disabled` prop. A path is treated\n   * as disabled if it appears here or descends from a path that does.\n   *\n   * Like the `disabled` property, this is only honored when `respectDisabled` is `true`, and\n   * updating a rule or group's own `disabled` property is still permitted.\n   */\n  disabledPaths?: Path[];\n  /** Abort every mutation, as though the entire query were disabled. Defaults to `false`. */\n  queryDisabled?: boolean;\n  /**\n   * The maximum depth at which a group may be added. A group whose parent path is already this\n   * deep is rejected by `add` and `insert`. Rules are unaffected. Defaults to `Infinity`.\n   */\n  maxLevels?: number;\n}\n\n/**\n * Options for reporting aborted query tool operations.\n *\n * @group Query Tools\n */\nexport interface AbortOptions extends GuardOptions {\n  /**\n   * Called when the operation returns the query unmodified, with the reason why. Query tools\n   * never throw, so this is the only way to distinguish \"the target was invalid\" from\n   * \"the operation had nothing to do\".\n   */\n  onAbort?: (info: AbortInfo) => void;\n}\n\n/**\n * Options shared by every query tool.\n *\n * @group Query Tools\n */\nexport interface QueryToolOptions extends AbortOptions {\n  /**\n   * Set `false` to skip immer's auto-freeze on the returned query, e.g. when the query will be\n   * handed to a framework that wraps it in a proxy (Vue `reactive`, Solid stores) or otherwise\n   * needs to mutate it. Ignored by the `*InPlace` variants, which never freeze.\n   *\n   * @default true\n   */\n  freeze?: boolean;\n}\n\n/**\n * Whether a mutation targeting `pathOrID` is blocked by the given guards, and why.\n * Returns `null` when the mutation may proceed.\n *\n * Exported so that callers which run their own logic before mutating—such as a UI layer that\n * invokes a confirmation callback—can apply the same rules without duplicating them.\n *\n * @group Query Tools\n */\nexport const getGuardAbortReason = (\n  query: RuleGroupTypeAny,\n  pathOrID: Path | string | undefined,\n  guards: GuardOptions = {},\n  { asParent = false }: { asParent?: boolean } = {}\n): AbortReason | null => {\n  if (guards.queryDisabled) return asParent ? 'parent-disabled' : 'target-disabled';\n\n  if (!guards.respectDisabled || pathOrID === undefined) return null;\n\n  const path = Array.isArray(pathOrID) ? pathOrID : getPathOfID(pathOrID, query);\n  if (path && (pathIsDisabled(path, query) || pathIsDisabledByPaths(path, guards.disabledPaths))) {\n    return asParent ? 'parent-disabled' : 'target-disabled';\n  }\n\n  return null;\n};\n\n/**\n * Whether adding a group beneath `parentPath` would exceed `maxLevels`.\n *\n * @group Query Tools\n */\nexport const exceedsMaxLevels = (\n  parentPath: Path | undefined,\n  { maxLevels = Infinity }: GuardOptions = {}\n): boolean => !!parentPath && parentPath.length >= maxLevels;\n\n/**\n * Options for {@link add}.\n *\n * @group Query Tools\n */\nexport interface AddOptions extends QueryToolOptions {\n  /**\n   * If the query extends `RuleGroupTypeIC` (i.e. the query has independent\n   * combinators), then the first combinator in this list will be inserted\n   * before the new rule/group if the parent group is not empty. This option\n   * is overridden by `combinatorPreceding`.\n   */\n  combinators?: OptionList;\n  /**\n   * If the query extends `RuleGroupTypeIC` (i.e. the query has independent\n   * combinators), then this combinator will be inserted before the new rule/group\n   * if the parent group is not empty. This option will supersede `combinators`.\n   */\n  combinatorPreceding?: string;\n  /**\n   * ID generator.\n   */\n  idGenerator?: () => string;\n}\n\nexport interface AddMethod {\n  <RG extends RuleGroupTypeAny>(\n    /** The query to update. */\n    query: RG,\n    /** The rule or group to add. */\n    ruleOrGroup: RG | RuleType,\n    /** Path or ID of the group to add to. */\n    parentPathOrID: Path | string,\n    /** Options. */\n    options?: AddOptions\n  ): RG;\n}\n\n/**\n * Adds a rule or group to a query without mutating the original query.\n *\n * @returns A new query with the rule or group added.\n *\n * @group Query Tools\n */\nexport const add: AddMethod = (query, ruleOrGroup, parentPathOrID, options = {}): typeof query =>\n  producerFor(options.freeze)(query, q =>\n    addInPlace(q, ruleOrGroup as RuleType, parentPathOrID, options)\n  );\n\n/**\n * Adds a rule or group to a query in place.\n *\n * @returns The query (mutated in place) with the rule or group added.\n *\n * @group Query Tools\n */\nexport const addInPlace: AddMethod = (\n  query,\n  ruleOrGroup,\n  parentPathOrID,\n  options = {}\n): typeof query => {\n  const {\n    combinators = defaultCombinators,\n    combinatorPreceding,\n    idGenerator = generateID,\n    onAbort,\n  } = options;\n  const parent = Array.isArray(parentPathOrID)\n    ? findPath(parentPathOrID, query)\n    : findID(parentPathOrID, query);\n\n  if (!parent) {\n    onAbort?.({ reason: 'parent-not-found', operation: 'add', pathOrID: parentPathOrID });\n    return query;\n  }\n\n  if (!isRuleGroup(parent)) {\n    onAbort?.({ reason: 'parent-not-a-group', operation: 'add', pathOrID: parentPathOrID });\n    return query;\n  }\n\n  // The parent is known to exist by this point, so the path always resolves.\n  const parentPath = (\n    Array.isArray(parentPathOrID) ? parentPathOrID : getPathOfID(parentPathOrID, query)\n  ) as Path;\n\n  const addGuardReason = getGuardAbortReason(query, parentPath, options, { asParent: true });\n  if (addGuardReason) {\n    onAbort?.({ reason: addGuardReason, operation: 'add', pathOrID: parentPathOrID });\n    return query;\n  }\n\n  if (isRuleGroup(ruleOrGroup) && exceedsMaxLevels(parentPath, options)) {\n    onAbort?.({ reason: 'max-levels-exceeded', operation: 'add', pathOrID: parentPathOrID });\n    return query;\n  }\n\n  if (isRuleGroupTypeIC(parent) && parent.rules.length > 0) {\n    const prevCombinator = parent.rules.at(-2);\n    parent.rules.push(\n      // @ts-expect-error This is technically a type violation until the next push\n      // to the rules array, but that happens immediately and unconditionally so\n      // there's no significant risk.\n      combinatorPreceding ??\n        (typeof prevCombinator === 'string' ? prevCombinator : getFirstOption(combinators))\n    );\n  }\n  // `as RuleType` is only here to avoid the ambiguity with `RuleGroupTypeAny`\n  parent.rules.push(prepareRuleOrGroup(ruleOrGroup, { idGenerator }) as RuleType);\n\n  return query;\n};\n\n/**\n * Options for {@link update}.\n *\n * @group Query Tools\n */\nexport interface UpdateOptions extends QueryToolOptions {\n  /**\n   * When updating the `field` of a rule, the rule's `operator`, `value`, and `valueSource`\n   * will be reset to their respective defaults. Defaults to `true`.\n   */\n  resetOnFieldChange?: boolean;\n  /**\n   * When updating the `operator` of a rule, the rule's `value` and `valueSource`\n   * will be reset to their respective defaults. Defaults to `false`.\n   */\n  resetOnOperatorChange?: boolean;\n  /**\n   * Determines the default operator name for a given field.\n   */\n  getRuleDefaultOperator?: (field: string) => string;\n  /**\n   * Determines the valid value sources for a given field and operator.\n   */\n  getValueSources?: (field: string, operator: string) => ValueSources | ValueSourceFlexibleOptions;\n  /**\n   * Gets the default value for a given rule, in case the value needs to be reset.\n   */\n  // oxlint-disable-next-line typescript/no-explicit-any\n  getRuleDefaultValue?: (rule: RuleType) => any;\n  /**\n   * Determines the valid match modes for a given field.\n   */\n  getMatchModes?: (field: string) => MatchModeOptions;\n}\n\nexport interface UpdateMethod {\n  /**\n   * Updates a single property of a rule or group.\n   */\n  <RG extends RuleGroupTypeAny>(\n    /** The query to update. */\n    query: RG,\n    /** The name of the property to update. */\n    prop: UpdateableProperties,\n    /** The new value of the property. */\n    // oxlint-disable-next-line typescript/no-explicit-any\n    value: any,\n    /** The path or ID of the rule or group to update. */\n    pathOrID: Path | string,\n    /** Options. */\n    options?: UpdateOptions\n  ): RG;\n  /**\n   * Updates multiple properties of a rule or group using parallel arrays of\n   * property names and corresponding values.\n   */\n  <RG extends RuleGroupTypeAny>(\n    /** The query to update. */\n    query: RG,\n    /** The names of the properties to update. */\n    props: UpdateableProperties[],\n    /** The new values, in the same order as `props`. */\n    // oxlint-disable-next-line typescript/no-explicit-any\n    values: any[],\n    /** The path or ID of the rule or group to update. */\n    pathOrID: Path | string,\n    /** Options. */\n    options?: UpdateOptions\n  ): RG;\n  /**\n   * Updates multiple properties of a rule or group using a map of property\n   * names to their new values.\n   */\n  <RG extends RuleGroupTypeAny>(\n    /** The query to update. */\n    query: RG,\n    /** A map of property names to their new values. */\n    props: UpdateValueMap,\n    /** The path or ID of the rule or group to update. */\n    pathOrID: Path | string,\n    /** Options. */\n    options?: UpdateOptions\n  ): RG;\n}\n\n/**\n * Relative order in which properties are applied during a multi-property update.\n * Lower ranks apply first; `value` applies last so an explicitly-provided value\n * is never clobbered by a reset triggered by a `field`/`operator`/`valueSource`\n * change. Unranked properties default to `3` (between `valueSource` and `value`).\n */\nconst updatePropRank: Record<string, number> = { field: 0, operator: 1, valueSource: 2, value: 4 };\n\n/** Stable-sorts `[prop, value]` entries by {@link updatePropRank}. */\nconst orderUpdateEntries = (entries: [string, unknown][]): [string, unknown][] =>\n  entries.toSorted((x, y) => (updatePropRank[x[0]] ?? 3) - (updatePropRank[y[0]] ?? 3));\n\n/**\n * Normalizes the variadic {@link update}/{@link updateInPlace} arguments (single\n * prop+value, parallel arrays, or property map) into a canonically-ordered list\n * of `[prop, value]` entries plus the target path/ID and options.\n */\nconst normalizeUpdateArgs = (\n  a: unknown,\n  b: unknown,\n  c: unknown,\n  d: unknown\n): { entries: [string, unknown][]; pathOrID: Path | string; options: UpdateOptions } => {\n  // Single property: (prop, value, pathOrID, options)\n  if (typeof a === 'string') {\n    return { entries: [[a, b]], pathOrID: c as Path | string, options: (d as UpdateOptions) ?? {} };\n  }\n  // Parallel arrays: (props, values, pathOrID, options)\n  if (Array.isArray(a)) {\n    const values = b as unknown[];\n    return {\n      entries: orderUpdateEntries(a.map((prop, i): [string, unknown] => [prop, values[i]])),\n      pathOrID: c as Path | string,\n      options: (d as UpdateOptions) ?? {},\n    };\n  }\n  // Property map: (props, pathOrID, options)\n  return {\n    entries: orderUpdateEntries(Object.entries(a as Record<string, unknown>)),\n    pathOrID: b as Path | string,\n    options: (c as UpdateOptions) ?? {},\n  };\n};\n\n/**\n * The options argument of an {@link update} call, whose position depends on the argument form.\n * Cheaper than {@link normalizeUpdateArgs} when only the options are needed.\n */\nconst updateOptionsOf = (a: unknown, b: unknown, c: unknown, d: unknown): UpdateOptions =>\n  ((typeof a === 'string' || Array.isArray(a) ? d : c) as UpdateOptions) ?? {};\n\n/**\n * Applies one or more property updates to a query in place. Shared by\n * {@link update} and {@link updateInPlace}.\n */\nconst applyUpdatesInPlace = <RG extends RuleGroupTypeAny>(\n  query: RG,\n  a: unknown,\n  b: unknown,\n  c: unknown,\n  d: unknown\n): RG => {\n  const { entries, pathOrID, options } = normalizeUpdateArgs(a, b, c, d);\n  for (const [prop, value] of entries) {\n    updateInPlaceSingle(query, prop, value, pathOrID, options);\n  }\n  return query;\n};\n\n/**\n * Updates one or more properties of a rule or group within a query without\n * mutating the original query. Properties may be supplied individually\n * (`prop`, `value`), as parallel arrays (`props`, `values`), or as a\n * property-to-value map. For multi-property updates, `field`, `operator`, and\n * `valueSource` are applied before `value`, so an explicit `value` is never\n * reset by a change to one of those properties.\n *\n * @returns A new query with the rule or group properties updated.\n *\n * @group Query Tools\n */\nexport const update = (<RG extends RuleGroupTypeAny>(\n  query: RG,\n  a: unknown,\n  b?: unknown,\n  c?: unknown,\n  d?: unknown\n): RG =>\n  producerFor(updateOptionsOf(a, b, c, d).freeze)(query, q => {\n    applyUpdatesInPlace(q, a, b, c, d);\n  })) as UpdateMethod;\n\n/**\n * Updates one or more properties of a rule or group within a query in place.\n * See {@link update} for the supported argument forms and ordering semantics.\n *\n * @returns The query (mutated in place) with the rule or group properties updated.\n *\n * @group Query Tools\n */\nexport const updateInPlace = (<RG extends RuleGroupTypeAny>(\n  query: RG,\n  a: unknown,\n  b?: unknown,\n  c?: unknown,\n  d?: unknown\n): RG => applyUpdatesInPlace(query, a, b, c, d)) as UpdateMethod;\n\n/**\n * Updates a single property of a rule or group within a query in place.\n */\nconst updateInPlaceSingle = <RG extends RuleGroupTypeAny>(\n  query: RG,\n  prop: UpdateableProperties,\n  // oxlint-disable-next-line typescript/no-explicit-any\n  value: any,\n  pathOrID: Path | string,\n  options: UpdateOptions = {}\n): RG => {\n  const {\n    resetOnFieldChange: _resetOnFieldChange = true,\n    resetOnOperatorChange = false,\n    getRuleDefaultOperator = () => '=',\n    getValueSources = () => ['value'],\n    getRuleDefaultValue = () => '',\n    getMatchModes = () => [],\n    onAbort,\n  } = options;\n\n  let resetOnFieldChange = _resetOnFieldChange;\n\n  const path = Array.isArray(pathOrID) ? pathOrID : getPathOfID(pathOrID, query);\n\n  // Ignore invalid paths/ids\n  if (!path) {\n    onAbort?.({ reason: 'target-not-found', operation: 'update', pathOrID });\n    return query;\n  }\n\n  // A node's own `disabled` property is exempt from `respectDisabled`—otherwise a disabled node\n  // could never be re-enabled. `queryDisabled` still blocks it, since that disables everything.\n  const updateGuards =\n    prop === 'disabled' ? { queryDisabled: options.queryDisabled } : (options as GuardOptions);\n  const updateGuardReason = getGuardAbortReason(query, path, updateGuards);\n  if (updateGuardReason) {\n    onAbort?.({ reason: updateGuardReason, operation: 'update', pathOrID });\n    return query;\n  }\n\n  // Independent combinators\n  if (prop === 'combinator' && !isRuleGroupType(query)) {\n    // The combinator slot itself is a bare string, so `findPath` can't confirm the target\n    // exists; the containing group has to be resolved instead.\n    const parent = findPath(getParentPath(path), query);\n    if (!parent || !isRuleGroup(parent)) {\n      onAbort?.({ reason: 'target-not-found', operation: 'update', pathOrID });\n      return query;\n    }\n    const parentRules = parent.rules;\n    // Only update an independent combinator if it occupies an odd index\n    if (path.at(-1)! % 2 === 1) {\n      if (parentRules[path.at(-1)!] === value) {\n        onAbort?.({ reason: 'no-change', operation: 'update', pathOrID });\n      } else {\n        parentRules[path.at(-1)!] = value;\n      }\n    } else {\n      onAbort?.({ reason: 'not-a-combinator-slot', operation: 'update', pathOrID });\n    }\n    return query;\n  }\n\n  const ruleOrGroup = findPath(path, query);\n\n  // Ignore invalid paths\n  if (!ruleOrGroup) {\n    onAbort?.({ reason: 'target-not-found', operation: 'update', pathOrID });\n    return query;\n  }\n\n  const isGroup = isRuleGroup(ruleOrGroup);\n\n  // Only update if there is actually a change\n  // @ts-expect-error prop can refer to rule or group properties\n  if (ruleOrGroup[prop] === value) {\n    onAbort?.({ reason: 'no-change', operation: 'update', pathOrID });\n    return query;\n  }\n\n  // Handle valueSource updates later\n  if (prop !== 'valueSource') {\n    // @ts-expect-error prop can refer to rule or group properties\n    ruleOrGroup[prop] = value;\n  }\n\n  // If this is a group, there's no more to do\n  if (isGroup) return query;\n\n  let resetValueSource = false;\n  let resetValue = false;\n\n  if (prop === 'field') {\n    const fromFieldMatchModes = getMatchModes(ruleOrGroup.field);\n    const toFieldMatchModes = getMatchModes(value);\n\n    if (toFieldMatchModes.length === 0) {\n      delete ruleOrGroup.match;\n    } else {\n      const nextMatchMode =\n        ruleOrGroup.match?.mode && getOption(toFieldMatchModes, ruleOrGroup.match.mode)\n          ? null\n          : getFirstOption(toFieldMatchModes);\n      if (nextMatchMode) {\n        ruleOrGroup.match = { mode: nextMatchMode, threshold: 1 };\n      }\n    }\n\n    if (fromFieldMatchModes.length > 0 || toFieldMatchModes.length > 0) {\n      // Force `resetOnFieldChange` when field is updated FROM or TO one that has match modes\n      resetOnFieldChange = true;\n    }\n  }\n\n  // Set default operator, valueSource, and value for field change\n  if (resetOnFieldChange && prop === 'field') {\n    ruleOrGroup.operator = getRuleDefaultOperator(value);\n    resetValueSource = true;\n    resetValue = true;\n  }\n\n  // Set default valueSource and value for operator change\n  if (resetOnOperatorChange && prop === 'operator') {\n    resetValueSource = true;\n    resetValue = true;\n  }\n\n  const valueSources = getValueSourcesUtil(\n    { name: ruleOrGroup.field, value: ruleOrGroup.field, label: '' },\n    ruleOrGroup.operator,\n    getValueSources\n  );\n  const defaultValueSource = getFirstOption(valueSources);\n  if (\n    (resetValueSource &&\n      ruleOrGroup.valueSource &&\n      defaultValueSource !== ruleOrGroup.valueSource) ||\n    (prop === 'valueSource' && value !== ruleOrGroup.valueSource)\n  ) {\n    // Only reset the value if we're changing the valueSource either\n    // 1) from `undefined` to something that is _not_ the default, or\n    // 2) from the current (defined) value to something else\n    resetValue =\n      !!ruleOrGroup.valueSource || (!ruleOrGroup.valueSource && value !== defaultValueSource);\n    ruleOrGroup.valueSource = resetValueSource ? defaultValueSource : value;\n  }\n\n  if (resetValue) {\n    // The default value should be a valid field name if defaultValueSource is 'field'\n    ruleOrGroup.value = getRuleDefaultValue(ruleOrGroup);\n  }\n\n  return query;\n};\n\n/**\n * Options for {@link remove}.\n *\n * @group Query Tools\n */\nexport interface RemoveOptions extends QueryToolOptions {}\n\nexport interface RemoveMethod {\n  <RG extends RuleGroupTypeAny>(\n    /** The query to update. */\n    query: RG,\n    /** The path or ID of the rule or group to remove. */\n    pathOrID: Path | string,\n    /** Options. */\n    options?: RemoveOptions\n  ): RG;\n}\n\n/**\n * Removes a rule or group from a query without mutating the original query.\n *\n * @returns A new query with the rule or group removed.\n *\n * @group Query Tools\n */\nexport const remove: RemoveMethod = (query, pathOrID, options = {}): typeof query =>\n  producerFor(options.freeze)(query, q => removeInPlace(q, pathOrID, options));\n\n/**\n * Removes a rule or group from a query in place.\n *\n * @returns The query (mutated in place) with the rule or group removed.\n *\n * @group Query Tools\n */\nexport const removeInPlace: RemoveMethod = (query, pathOrID, options = {}): typeof query => {\n  const { onAbort } = options;\n  const path = Array.isArray(pathOrID) ? pathOrID : getPathOfID(pathOrID, query);\n\n  // Ignore invalid paths/ids\n  if (!path) {\n    onAbort?.({ reason: 'target-not-found', operation: 'remove', pathOrID });\n    return query;\n  }\n\n  // Can't remove the root group\n  if (path.length === 0) {\n    onAbort?.({ reason: 'root-not-allowed', operation: 'remove', pathOrID });\n    return query;\n  }\n\n  const removeGuardReason = getGuardAbortReason(query, path, options);\n  if (removeGuardReason) {\n    onAbort?.({ reason: removeGuardReason, operation: 'remove', pathOrID });\n    return query;\n  }\n\n  // The target must actually exist. This also covers independent combinators, which `findPath`\n  // reports as missing because they are bare strings rather than rules—they can only be removed\n  // alongside the rule they precede or follow.\n  if (!findPath(path, query)) {\n    onAbort?.({ reason: 'target-not-found', operation: 'remove', pathOrID });\n    return query;\n  }\n\n  // The target resolved, so at a non-root path its parent is necessarily an existing group.\n  const index = path.at(-1)!;\n  const parent = findPath(getParentPath(path), query) as RuleGroupTypeAny;\n  if (!isRuleGroupType(parent) && parent.rules.length > 1) {\n    const idxStartDelete = index === 0 ? 0 : index - 1;\n    parent.rules.splice(idxStartDelete, 2);\n  } else {\n    parent.rules.splice(index, 1);\n  }\n\n  return query;\n};\n\nconst getNextPath = (\n  query: RuleGroupTypeAny,\n  currentPath: Path,\n  newPathOrShiftDirection: Path | 'up' | 'down'\n): Path => {\n  if (Array.isArray(newPathOrShiftDirection)) {\n    return newPathOrShiftDirection;\n  }\n\n  const ic = isRuleGroupTypeIC(query);\n\n  if (newPathOrShiftDirection === 'up') {\n    if (pathsAreEqual(currentPath, [0])) {\n      return currentPath;\n    } else if (currentPath.at(-1) === 0) {\n      const parentPath = getParentPath(currentPath);\n      return [...getParentPath(parentPath), Math.max(0, parentPath.at(-1)! - (ic ? 1 : 0))];\n    } else {\n      const evaluationPath = [\n        ...getParentPath(currentPath),\n        Math.max(0, currentPath.at(-1)! - (ic ? 2 : 1)),\n      ];\n      const entityAtTarget = findPath(evaluationPath, query);\n      if (isRuleGroup(entityAtTarget)) {\n        return [...evaluationPath, entityAtTarget.rules.length];\n      } else {\n        const targetPath = [\n          ...getParentPath(currentPath),\n          Math.max(0, currentPath.at(-1)! - (ic ? 3 : 1)),\n        ];\n        return targetPath;\n      }\n    }\n  } else if (newPathOrShiftDirection === 'down') {\n    if (pathsAreEqual([query.rules.length - 1], currentPath)) {\n      return currentPath;\n    } else if (\n      currentPath.at(-1) ===\n      (findPath(getParentPath(currentPath), query) as RuleGroupTypeAny).rules.length - 1\n    ) {\n      const parentPath = getParentPath(currentPath);\n      return [...getParentPath(parentPath), parentPath.at(-1)! + 1];\n    } else {\n      const evaluationPath = [...getParentPath(currentPath), currentPath.at(-1)! + (ic ? 2 : 1)];\n      const entityToEvaluate = findPath(evaluationPath, query);\n      if (isRuleGroup(entityToEvaluate)) {\n        return [...evaluationPath, 0];\n      } else {\n        const targetPath = [...getParentPath(currentPath), currentPath.at(-1)! + (ic ? 3 : 2)];\n        return targetPath;\n      }\n    }\n  }\n\n  return currentPath;\n};\n\n/**\n * Options for {@link move}.\n *\n * @group Query Tools\n */\nexport interface MoveOptions extends QueryToolOptions {\n  /**\n   * When `true`, the source rule/group will not be removed from its original path.\n   */\n  clone?: boolean;\n  /**\n   * If the query extends `RuleGroupTypeIC` (i.e. the query is using independent\n   * combinators), then the first combinator in this list will be inserted before\n   * the rule/group if necessary.\n   */\n  combinators?: OptionList;\n  /**\n   * ID generator.\n   */\n  idGenerator?: () => string;\n}\n\nexport interface MoveMethod {\n  <RG extends RuleGroupTypeAny>(\n    /** The query to update. */\n    query: RG,\n    /** ID or original path of the rule or group to move. */\n    oldPathOrID: Path | string,\n    /** Path to move the rule or group to, or a shift direction. */\n    newPath: Path | 'up' | 'down',\n    /** Options. */\n    options?: MoveOptions\n  ): RG;\n}\n\n/**\n * Moves a rule or group from one path to another without mutating the original query.\n * In the options parameter, pass `{ clone: true }` to copy instead of move.\n *\n * @returns A new query with the rule or group moved or cloned.\n *\n * @group Query Tools\n */\nexport const move: MoveMethod = (query, oldPathOrID, newPath, options = {}): typeof query =>\n  producerFor(options.freeze)(query, q => moveInPlace(q, oldPathOrID, newPath, options));\n\n/**\n * Moves a rule or group from one path to another in place.\n * In the options parameter, pass `{ clone: true }` to copy instead of move.\n *\n * @returns The query (mutated in place) with the rule or group moved or cloned.\n *\n * @group Query Tools\n */\nexport const moveInPlace: MoveMethod = (\n  query,\n  oldPathOrID,\n  newPath,\n  options = {}\n): typeof query => {\n  const {\n    clone = false,\n    combinators = defaultCombinators,\n    idGenerator = generateID,\n    onAbort,\n  } = options;\n  const oldPath = Array.isArray(oldPathOrID) ? oldPathOrID : getPathOfID(oldPathOrID, query);\n\n  // Ignore invalid paths/ids\n  if (!oldPath) {\n    onAbort?.({ reason: 'target-not-found', operation: 'move', pathOrID: oldPathOrID });\n    return query;\n  }\n\n  // Ignore paths that don't identify anything. This must happen before `getNextPath`, which\n  // assumes the source exists when resolving a shift direction.\n  const ruleOrGroupOriginal = findPath(oldPath, query);\n  if (!ruleOrGroupOriginal) {\n    onAbort?.({ reason: 'target-not-found', operation: 'move', pathOrID: oldPathOrID });\n    return query;\n  }\n\n  const nextPath = getNextPath(query, oldPath, newPath);\n\n  // Can't move the root group\n  if (oldPath.length === 0) {\n    onAbort?.({ reason: 'root-not-allowed', operation: 'move', pathOrID: oldPathOrID });\n    return query;\n  }\n\n  const moveGuardReason = getGuardAbortReason(query, oldPath, options);\n  if (moveGuardReason) {\n    onAbort?.({ reason: moveGuardReason, operation: 'move', pathOrID: oldPathOrID });\n    return query;\n  }\n\n  // Don't move to the same location\n  if (pathsAreEqual(oldPath, nextPath)) {\n    onAbort?.({ reason: 'same-location', operation: 'move', pathOrID: oldPathOrID });\n    return query;\n  }\n\n  // Don't move to a path that doesn't exist yet\n  if (!findPath(getParentPath(nextPath), query)) {\n    onAbort?.({ reason: 'destination-not-found', operation: 'move', pathOrID: newPath });\n    return query;\n  }\n\n  // Don't move a group inside itself. The destination is part of the subtree being relocated,\n  // so it ceases to exist the moment the source is spliced out. (Cloning is fine: the source\n  // stays put and a regenerated copy is inserted.)\n  if (!clone && isAncestor(oldPath, nextPath)) {\n    onAbort?.({ reason: 'destination-not-found', operation: 'move', pathOrID: newPath });\n    return query;\n  }\n\n  const ruleOrGroup = clone\n    ? regenerateIDs(\n        isDraft(ruleOrGroupOriginal) ? current(ruleOrGroupOriginal) : ruleOrGroupOriginal,\n        { idGenerator }\n      )\n    : ruleOrGroupOriginal;\n\n  const independentCombinators = isRuleGroupTypeIC(query);\n  const parentOfRuleToRemove = findPath(getParentPath(oldPath), query) as typeof query;\n  const ruleToRemoveIndex = oldPath.at(-1)!;\n  const oldPrevCombinator =\n    independentCombinators && ruleToRemoveIndex > 0\n      ? (parentOfRuleToRemove.rules[ruleToRemoveIndex - 1] as string)\n      : null;\n  const oldNextCombinator =\n    independentCombinators && ruleToRemoveIndex < parentOfRuleToRemove.rules.length - 1\n      ? (parentOfRuleToRemove.rules[ruleToRemoveIndex + 1] as string)\n      : null;\n\n  // Remove the source item if not cloning\n  if (!clone) {\n    const idxStartDelete = independentCombinators\n      ? Math.max(0, ruleToRemoveIndex - 1)\n      : ruleToRemoveIndex;\n    const deleteLength = independentCombinators ? 2 : 1;\n    parentOfRuleToRemove.rules.splice(idxStartDelete, deleteLength);\n  }\n\n  const newNewPath = [...nextPath];\n  if (independentCombinators && newNewPath.at(-1)! % 2 === 1) {\n    // Odd indexes in an independent combinator array identify combinators, not\n    // rules/groups. Dropping on a combinator means \"insert after the rule that\n    // precedes it\", which is the same slot as the next (even) index. Normalizing\n    // here keeps the destination index even, which the insertion logic below\n    // relies on to maintain the rule/combinator alternation.\n    newNewPath[newNewPath.length - 1] += 1;\n  }\n  const commonAncestorPath = getCommonAncestorPath(oldPath, nextPath);\n  if (\n    !clone &&\n    oldPath.length === commonAncestorPath.length + 1 &&\n    newNewPath[commonAncestorPath.length] > oldPath[commonAncestorPath.length]\n  ) {\n    // Getting here means there will be a shift of paths upward at the common\n    // ancestor level because the object at `oldPath` will be spliced out. The\n    // real new path should therefore be one or two higher than `nextPath`.\n    newNewPath[commonAncestorPath.length] -= independentCombinators ? 2 : 1;\n  }\n  const newNewParentPath = getParentPath(newNewPath);\n  const parentToInsertInto = findPath(newNewParentPath, query) as typeof query;\n  const newIndex = newNewPath.at(-1)!;\n  // For independent combinator arrays, `newIndex` is the (even) index the moved\n  // rule/group should end up at, but the splice inserts a `[combinator, ruleOrGroup]`\n  // pair, so it must happen one slot earlier.\n  const spliceIndex = independentCombinators && newIndex > 0 ? newIndex - 1 : newIndex;\n\n  /**\n   * This function 1) glosses over the need for type assertions to splice directly\n   * into `parentToInsertInto.rules`, and 2) shortens the actual insertion code.\n   */\n  // oxlint-disable-next-line typescript/no-explicit-any\n  const insertRuleOrGroup = (...args: any[]) =>\n    parentToInsertInto.rules.splice(spliceIndex, 0, ...args);\n\n  // Insert the source item at the target path\n  if (parentToInsertInto.rules.length === 0 || !independentCombinators) {\n    insertRuleOrGroup(ruleOrGroup);\n  } else {\n    if (newIndex === 0) {\n      if (ruleToRemoveIndex === 0 && oldNextCombinator) {\n        insertRuleOrGroup(ruleOrGroup, oldNextCombinator);\n      } else {\n        const newNextCombinator =\n          parentToInsertInto.rules[1] ?? oldPrevCombinator ?? getFirstOption(combinators);\n        insertRuleOrGroup(ruleOrGroup, newNextCombinator);\n      }\n    } else {\n      if (oldPrevCombinator) {\n        insertRuleOrGroup(oldPrevCombinator, ruleOrGroup);\n      } else {\n        const newPrevCombinator =\n          parentToInsertInto.rules[spliceIndex - 2] ??\n          oldNextCombinator ??\n          getFirstOption(combinators);\n        insertRuleOrGroup(newPrevCombinator, ruleOrGroup);\n      }\n    }\n  }\n\n  return query;\n};\n\n/**\n * Options for {@link insert}.\n *\n * @group Query Tools\n */\nexport interface InsertOptions extends QueryToolOptions {\n  /**\n   * If the query extends `RuleGroupTypeIC` (i.e. the query has independent\n   * combinators), then the first combinator in this list will be inserted\n   * before the new rule/group if the parent group is not empty. This option\n   * is overridden by `combinatorPreceding`.\n   */\n  combinators?: OptionList;\n  /**\n   * If the query extends `RuleGroupTypeIC` (i.e. the query has independent\n   * combinators), then this combinator will be inserted before the new rule/group\n   * if the parent group is not empty and the new rule/group is not the first in the\n   * group (`path.at(-1) > 0`). This option will supersede `combinators`.\n   */\n  combinatorPreceding?: string;\n  /**\n   * If the query extends `RuleGroupTypeIC` (i.e. the query has independent\n   * combinators), then this combinator will be inserted after the new rule/group\n   * if the parent group is not empty and the new rule/group is the first in the\n   * group (`path.at(-1) === 0`). This option will supersede `combinators`.\n   */\n  combinatorSucceeding?: string;\n  /**\n   * ID generator.\n   *\n   * @default generateID\n   */\n  idGenerator?: () => string;\n  /**\n   * When `true`, the new rule/group will replace the rule/group at `path`.\n   */\n  replace?: boolean;\n}\n\nexport interface InsertMethod {\n  <RG extends RuleGroupTypeAny>(\n    /** The query to update. */\n    query: RG,\n    /** The rule or group to insert. */\n    ruleOrGroup: RG | RuleType,\n    /** Path at which to insert the rule or group. */\n    path: number[],\n    /** Options. */\n    options?: InsertOptions\n  ): RG;\n}\n\n/**\n * Inserts a rule or group into a query without mutating the original query.\n *\n * @returns A new query with the rule or group inserted.\n *\n * @group Query Tools\n */\nexport const insert: InsertMethod = (query, ruleOrGroup, path, options = {}): typeof query =>\n  producerFor(options.freeze)(query, q => insertInPlace(q, ruleOrGroup as RuleType, path, options));\n\n/**\n * Inserts a rule or group into a query in place.\n *\n * @returns The query (mutated in place) with the rule or group inserted.\n *\n * @group Query Tools\n */\nexport const insertInPlace: InsertMethod = (\n  query,\n  ruleOrGroup,\n  path,\n  options = {}\n): typeof query => {\n  const {\n    combinators = defaultCombinators,\n    combinatorPreceding,\n    combinatorSucceeding,\n    idGenerator = generateID,\n    replace = false,\n    onAbort,\n  } = options;\n\n  const parentToInsertInto = findPath(getParentPath(path), query) as typeof query;\n  if (!parentToInsertInto) {\n    onAbort?.({ reason: 'parent-not-found', operation: 'insert', pathOrID: path });\n    return query;\n  }\n\n  if (!isRuleGroup(parentToInsertInto)) {\n    onAbort?.({ reason: 'parent-not-a-group', operation: 'insert', pathOrID: path });\n    return query;\n  }\n\n  const parentPath = getParentPath(path);\n  const insertGuardReason = getGuardAbortReason(query, parentPath, options, { asParent: true });\n  if (insertGuardReason) {\n    onAbort?.({ reason: insertGuardReason, operation: 'insert', pathOrID: path });\n    return query;\n  }\n\n  if (isRuleGroup(ruleOrGroup) && exceedsMaxLevels(parentPath, options)) {\n    onAbort?.({ reason: 'max-levels-exceeded', operation: 'insert', pathOrID: path });\n    return query;\n  }\n\n  const rorg = regenerateIDs(ruleOrGroup, { idGenerator });\n  const independentCombinators = isRuleGroupTypeIC(query);\n  const newIndex = path.at(-1)!;\n\n  /**\n   * This function 1) glosses over the need for type assertions to splice directly\n   * into `parentToInsertInto.rules`, and 2) shortens the actual insertion code.\n   */\n  // oxlint-disable-next-line typescript/no-explicit-any\n  const insertRuleOrGroup = (idx: number, ...args: any[]) =>\n    parentToInsertInto.rules.splice(idx, replace ? args.length : 0, ...args);\n\n  // Insert the source item at the target path\n  if (parentToInsertInto.rules.length === 0 || !independentCombinators) {\n    insertRuleOrGroup(newIndex, rorg);\n  } else if (replace && independentCombinators) {\n    insertRuleOrGroup(newIndex + (newIndex % 2), rorg);\n  } else {\n    if (newIndex === 0) {\n      if (rorg.path?.at(-1) === 0 && combinatorSucceeding) {\n        insertRuleOrGroup(newIndex, rorg, combinatorSucceeding);\n      } else {\n        const newNextCombinator =\n          parentToInsertInto.rules[1] ?? combinatorPreceding ?? getFirstOption(combinators);\n        insertRuleOrGroup(newIndex, rorg, newNextCombinator);\n      }\n    } else {\n      const normalizedNewIndex = newIndex % 2 === 0 ? newIndex - 1 : newIndex;\n      if (combinatorPreceding) {\n        insertRuleOrGroup(normalizedNewIndex, combinatorPreceding, rorg);\n      } else {\n        const newPrevCombinator =\n          parentToInsertInto.rules[normalizedNewIndex - 2] ??\n          combinatorSucceeding ??\n          getFirstOption(combinators);\n        insertRuleOrGroup(normalizedNewIndex, newPrevCombinator, rorg);\n      }\n    }\n  }\n\n  return query;\n};\n\n/**\n * Options for {@link group}.\n *\n * @group Query Tools\n */\nexport interface GroupOptions extends QueryToolOptions {\n  /**\n   * When `true`, the source rule/group will not be removed from its original path.\n   */\n  clone?: boolean;\n  /**\n   * If the query extends `RuleGroupTypeIC` (i.e. the query is using independent\n   * combinators), then the first combinator in this list will be inserted between\n   * the two rules/groups.\n   */\n  combinators?: OptionList;\n  /**\n   * ID generator.\n   */\n  idGenerator?: () => string;\n}\n\nexport interface GroupMethod {\n  <RG extends RuleGroupTypeAny>(\n    /** The query to update. */\n    query: RG,\n    /** Path of the rule/group to move or clone. */\n    sourcePathOrID: Path | string,\n    /** Path of the target rule/group, which will become the path of the new group. */\n    targetPathOrID: Path | string,\n    /** Options. */\n    options?: GroupOptions\n  ): RG;\n}\n\n/**\n * Creates a new group at a target path with its `rules` array containing the current\n * objects at the target path and the source path without mutating the original query.\n * In the options parameter, pass `{ clone: true }` to copy the source rule/group instead of move.\n *\n * @returns A new query with the rules or groups grouped.\n *\n * @group Query Tools\n */\nexport const group: GroupMethod = (\n  query,\n  sourcePathOrID,\n  targetPathOrID,\n  options = {}\n): typeof query =>\n  producerFor(options.freeze)(query, q => groupInPlace(q, sourcePathOrID, targetPathOrID, options));\n\n/**\n * Creates a new group at a target path with its `rules` array containing the current\n * objects at the target path and the source path in place.\n * In the options parameter, pass `{ clone: true }` to copy the source rule/group instead of move.\n *\n * @returns The query (mutated in place) with the rules or groups grouped.\n *\n * @group Query Tools\n */\nexport const groupInPlace: GroupMethod = (\n  query,\n  sourcePathOrID,\n  targetPathOrID,\n  options = {}\n): typeof query => {\n  const {\n    clone = false,\n    combinators = defaultCombinators,\n    idGenerator = generateID,\n    onAbort,\n  } = options;\n  const sourcePath = Array.isArray(sourcePathOrID)\n    ? sourcePathOrID\n    : getPathOfID(sourcePathOrID, query);\n  const targetPath = Array.isArray(targetPathOrID)\n    ? targetPathOrID\n    : getPathOfID(targetPathOrID, query);\n\n  // Ignore invalid paths/ids\n  if (!sourcePath) {\n    onAbort?.({ reason: 'target-not-found', operation: 'group', pathOrID: sourcePathOrID });\n    return query;\n  }\n\n  if (!targetPath) {\n    onAbort?.({ reason: 'target-not-found', operation: 'group', pathOrID: targetPathOrID });\n    return query;\n  }\n\n  const nextPath = getNextPath(query, sourcePath, targetPath);\n\n  // Can't group the root group\n  if (sourcePath.length === 0) {\n    onAbort?.({ reason: 'root-not-allowed', operation: 'group', pathOrID: sourcePathOrID });\n    return query;\n  }\n\n  const groupGuardReason = getGuardAbortReason(query, sourcePath, options);\n  if (groupGuardReason) {\n    onAbort?.({ reason: groupGuardReason, operation: 'group', pathOrID: sourcePathOrID });\n    return query;\n  }\n\n  // Don't move to the same location\n  if (pathsAreEqual(sourcePath, nextPath)) {\n    onAbort?.({ reason: 'same-location', operation: 'group', pathOrID: sourcePathOrID });\n    return query;\n  }\n\n  // Don't move to a path that doesn't exist yet\n  if (!findPath(getParentPath(nextPath), query)) {\n    onAbort?.({ reason: 'destination-not-found', operation: 'group', pathOrID: targetPathOrID });\n    return query;\n  }\n\n  // Don't group a group with something inside itself. See the equivalent check in `moveInPlace`.\n  if (!clone && isAncestor(sourcePath, nextPath)) {\n    onAbort?.({ reason: 'destination-not-found', operation: 'group', pathOrID: targetPathOrID });\n    return query;\n  }\n\n  const sourceRuleOrGroupOriginal = findPath(sourcePath, query);\n  const targetRuleOrGroup = findPath(targetPath, query);\n  if (!sourceRuleOrGroupOriginal) {\n    onAbort?.({ reason: 'target-not-found', operation: 'group', pathOrID: sourcePathOrID });\n    return query;\n  }\n\n  if (!targetRuleOrGroup) {\n    onAbort?.({ reason: 'target-not-found', operation: 'group', pathOrID: targetPathOrID });\n    return query;\n  }\n  const sourceRuleOrGroup = clone\n    ? regenerateIDs(\n        isDraft(sourceRuleOrGroupOriginal)\n          ? current(sourceRuleOrGroupOriginal)\n          : sourceRuleOrGroupOriginal,\n        { idGenerator }\n      )\n    : sourceRuleOrGroupOriginal;\n\n  const independentCombinators = isRuleGroupTypeIC(query);\n  const parentOfRuleToRemove = findPath(getParentPath(sourcePath), query) as typeof query;\n  const ruleToRemoveIndex = sourcePath.at(-1)!;\n\n  // Remove the source item if not cloning\n  if (!clone) {\n    const idxStartDelete = independentCombinators\n      ? Math.max(0, ruleToRemoveIndex - 1)\n      : ruleToRemoveIndex;\n    const deleteLength = independentCombinators ? 2 : 1;\n    parentOfRuleToRemove.rules.splice(idxStartDelete, deleteLength);\n  }\n\n  const newNewPath = [...nextPath];\n  const commonAncestorPath = getCommonAncestorPath(sourcePath, nextPath);\n  if (\n    !clone &&\n    sourcePath.length === commonAncestorPath.length + 1 &&\n    nextPath[commonAncestorPath.length] > sourcePath[commonAncestorPath.length]\n  ) {\n    // Getting here means there will be a shift of paths upward at the common\n    // ancestor level because the object at `oldPath` will be spliced out. The\n    // real new path should therefore be one or two higher than `newPathCalc`.\n    newNewPath[commonAncestorPath.length] -= independentCombinators ? 2 : 1;\n  }\n  const newNewParentPath = getParentPath(newNewPath);\n  const parentOfTargetPath = findPath(newNewParentPath, query) as typeof query;\n  const targetPathIndex = newNewPath.at(-1)!;\n\n  // Convert the target path to a group and insert the source and target items as children\n  parentOfTargetPath.rules.splice(\n    targetPathIndex,\n    1,\n    prepareRuleOrGroup(\n      (independentCombinators\n        ? { rules: [targetRuleOrGroup, getFirstOption(combinators), sourceRuleOrGroup] }\n        : {\n            combinator: getFirstOption(combinators),\n            rules: [targetRuleOrGroup, sourceRuleOrGroup],\n            // oxlint-disable-next-line typescript/no-explicit-any\n          }) as any,\n      { idGenerator }\n      // oxlint-disable-next-line typescript/no-explicit-any\n    ) as any\n  );\n\n  return query;\n};\n","import { LogType } from '../defaults';\nimport type {\n  MatchModeOptions,\n  OptionList,\n  Path,\n  RuleGroupTypeAny,\n  RuleGroupTypeIC,\n  RuleType,\n  UpdateableProperties,\n  ValueSourceFullOptions,\n} from '../types';\nimport { isRuleGroup } from './isRuleGroup';\nimport { findPath } from './pathUtils';\nimport { add, getGuardAbortReason, group, move, remove, update } from './queryTools';\n\n/* oxlint-disable typescript/no-explicit-any */\n\n/**\n * Confirmation callbacks invoked before a mutation is applied. Their return values are\n * interpreted differently depending on the operation:\n *\n * - `onAddRule`/`onAddGroup` may return `true` to proceed, a falsy value to cancel, or a\n *   _replacement rule/group_ to add instead of the one provided.\n * - `onMoveRule`/`onMoveGroup`/`onGroupRule`/`onGroupGroup` may return `true` to proceed, a\n *   falsy value to cancel, or a _replacement query_ to apply instead of the computed one.\n * - `onRemove` is boolean only.\n *\n * @group Query Tools\n */\nexport interface QueryActionCallbacks {\n  onAddRule?: (rule: RuleType, parentPath: Path, query: any, context?: any) => RuleType | boolean;\n  onAddGroup?: (\n    ruleGroup: any,\n    parentPath: Path,\n    query: any,\n    context?: any\n  ) => RuleGroupTypeAny | boolean;\n  onRemove?: (ruleOrGroup: any, path: Path, query: any, context?: any) => boolean;\n  onMoveRule?: (...args: any[]) => RuleGroupTypeAny | boolean;\n  onMoveGroup?: (...args: any[]) => RuleGroupTypeAny | boolean;\n  onGroupRule?: (...args: any[]) => RuleGroupTypeAny | boolean;\n  onGroupGroup?: (...args: any[]) => RuleGroupTypeAny | boolean;\n}\n\n/**\n * Configuration for {@link createQueryActions}.\n *\n * @group Query Tools\n */\nexport interface QueryActionsConfig extends QueryActionCallbacks {\n  /** Identifier included in every log payload. */\n  qbId?: string;\n  combinators?: OptionList;\n  idGenerator?: () => string;\n  /** The maximum depth at which groups may be added. Defaults to `Infinity`. */\n  maxLevels?: number;\n  /** Abort every mutation, as though the entire query were disabled. */\n  queryDisabled?: boolean;\n  /**\n   * Honor `disabled` properties within the query. Defaults to `true`, matching the\n   * `QueryBuilder` component; a node's own `disabled` property can always be changed.\n   */\n  respectDisabled?: boolean;\n  /**\n   * Paths disabled by position rather than by a `disabled` property on the node itself, mirroring\n   * the array form of the `QueryBuilder` `disabled` prop. Honored only when `respectDisabled` is\n   * `true`; as with the `disabled` property, a node's own `disabled` can always be changed.\n   */\n  disabledPaths?: Path[];\n  resetOnFieldChange?: boolean;\n  resetOnOperatorChange?: boolean;\n  getRuleDefaultOperator?: (field: string) => string;\n  getValueSources?: (field: string, operator: string) => ValueSourceFullOptions;\n  getRuleDefaultValue?: (rule: RuleType) => any;\n  getMatchModes?: (field: string) => MatchModeOptions;\n  /**\n   * Set `false` to skip immer's auto-freeze on the queries these handlers return, matching the\n   * option of the same name on the query tools and {@link QueryManager}.\n   *\n   * Deep-freezing throws on the reactive proxies used by signals-based frameworks (Svelte\n   * `$state`, Vue `reactive`), so an adapter whose storage may hand a proxied query to these\n   * handlers has to turn it off.\n   *\n   * @default true\n   */\n  freeze?: boolean;\n  /** Receives a structured event for every action, applied or aborted. */\n  onLog?: (payload: Record<string, any>) => void;\n}\n\n/**\n * The six mutations a query builder performs. Each takes the current query and returns the next\n * one, or `undefined` when the mutation was aborted—because the target is disabled, a\n * confirmation callback declined, or a depth limit was reached.\n *\n * @group Query Tools\n */\nexport interface QueryActionHandlers {\n  addRule: (query: any, rule: RuleType, parentPath: Path, context?: any) => any;\n  addGroup: (query: any, ruleGroup: any, parentPath: Path, context?: any) => any;\n  propChange: (query: any, prop: UpdateableProperties, value: any, path: Path) => any;\n  removeRuleOrGroup: (query: any, path: Path, context?: any) => any;\n  moveRule: (\n    query: any,\n    oldPath: Path,\n    newPath: Path | 'up' | 'down',\n    clone?: boolean,\n    context?: any\n  ) => any;\n  groupRule: (\n    query: any,\n    sourcePath: Path,\n    targetPath: Path,\n    clone?: boolean,\n    context?: any\n  ) => any;\n}\n\n/**\n * Builds the query builder's six mutation handlers as pure functions of the current query.\n *\n * This is the framework-agnostic core of the action handlers in `useQueryBuilderSchema`. It owns\n * the policy that surrounds the query tools—disabled gating, the confirmation callback protocol,\n * `maxLevels`, and debug logging—so an implementation only has to supply its own storage: read\n * the current query, call the action, and apply a non-`undefined` result.\n *\n * @group Query Tools\n */\nexport const createQueryActions = (config: QueryActionsConfig = {}): QueryActionHandlers => {\n  const {\n    qbId,\n    combinators,\n    idGenerator,\n    maxLevels = Infinity,\n    queryDisabled,\n    respectDisabled = true,\n    disabledPaths,\n    resetOnFieldChange,\n    resetOnOperatorChange,\n    getRuleDefaultOperator,\n    getValueSources,\n    getRuleDefaultValue,\n    getMatchModes,\n    freeze,\n    onAddRule,\n    onAddGroup,\n    onRemove,\n    onMoveRule,\n    onMoveGroup,\n    onGroupRule,\n    onGroupGroup,\n    onLog,\n  } = config;\n\n  const log = (payload: Record<string, any>) => onLog?.({ qbId, ...payload });\n\n  const guards = { respectDisabled, queryDisabled, disabledPaths };\n\n  /** Whether the mutation is blocked, using the same rules the query tools apply internally. */\n  const blocked = (query: RuleGroupTypeAny, path: Path, asParent = false) =>\n    !!getGuardAbortReason(query, path, guards, { asParent });\n\n  return {\n    addRule: (query, rule, parentPath, context) => {\n      if (blocked(query, parentPath, true)) {\n        log({ type: LogType.parentPathDisabled, rule, parentPath, query });\n        return undefined;\n      }\n\n      const nextRule = onAddRule ? onAddRule(rule, parentPath, query, context) : true;\n      if (!nextRule) {\n        log({ type: LogType.onAddRuleFalse, rule, parentPath, query });\n        return undefined;\n      }\n\n      const newRule = nextRule === true ? rule : nextRule;\n      const newQuery = add(query, newRule, parentPath, {\n        combinators,\n        combinatorPreceding: (newRule as unknown as RuleGroupTypeIC).combinatorPreceding,\n        idGenerator,\n        freeze,\n      });\n      log({ type: LogType.add, query, newQuery, newRule, parentPath });\n      return newQuery;\n    },\n\n    addGroup: (query, ruleGroup, parentPath, context) => {\n      // Depth is checked before anything else, and is deliberately not logged.\n      if (parentPath.length >= maxLevels) return undefined;\n\n      if (blocked(query, parentPath, true)) {\n        log({ type: LogType.parentPathDisabled, ruleGroup, parentPath, query });\n        return undefined;\n      }\n\n      const nextGroup = onAddGroup ? onAddGroup(ruleGroup, parentPath, query, context) : true;\n      if (!nextGroup) {\n        log({ type: LogType.onAddGroupFalse, ruleGroup, parentPath, query });\n        return undefined;\n      }\n\n      const newGroup = nextGroup === true ? ruleGroup : nextGroup;\n      const newQuery = add(query, newGroup, parentPath, {\n        combinators,\n        combinatorPreceding: (newGroup as RuleGroupTypeIC).combinatorPreceding ?? undefined,\n        idGenerator,\n        freeze,\n      });\n      log({ type: LogType.add, query, newQuery, newGroup, parentPath });\n      return newQuery;\n    },\n\n    propChange: (query, prop, value, path) => {\n      // Changing `disabled` is exempt from the path check—otherwise a disabled node could never\n      // be re-enabled—but `queryDisabled` still blocks it.\n      const propGuards = prop === 'disabled' ? { queryDisabled } : guards;\n      if (getGuardAbortReason(query, path, propGuards)) {\n        log({ type: LogType.pathDisabled, path, prop, value, query });\n        return undefined;\n      }\n\n      const newQuery = update(query, prop, value, path, {\n        resetOnFieldChange,\n        resetOnOperatorChange,\n        getRuleDefaultOperator,\n        getValueSources,\n        getRuleDefaultValue,\n        getMatchModes,\n        freeze,\n      });\n      log({ type: LogType.update, query, newQuery, prop, value, path });\n      return newQuery;\n    },\n\n    removeRuleOrGroup: (query, path, context) => {\n      if (blocked(query, path)) {\n        log({ type: LogType.pathDisabled, path, query });\n        return undefined;\n      }\n\n      const ruleOrGroup = findPath(path, query);\n      /* v8 ignore next -- @preserve */\n      if (!ruleOrGroup) return undefined;\n\n      if (onRemove && !onRemove(ruleOrGroup, path, query, context)) {\n        log({ type: LogType.onRemoveFalse, ruleOrGroup, path, query });\n        return undefined;\n      }\n\n      const newQuery = remove(query, path, { freeze });\n      log({ type: LogType.remove, query, newQuery, path, ruleOrGroup });\n      return newQuery;\n    },\n\n    moveRule: (query, oldPath, newPath, clone, context) => {\n      if (blocked(query, oldPath)) {\n        log({ type: LogType.pathDisabled, oldPath, newPath, query });\n        return undefined;\n      }\n\n      // A path that no longer resolves isn't caught by the guards, so confirm it before\n      // computing anything or handing a null node to the callback.\n      const ruleOrGroup = findPath(oldPath, query);\n      if (!ruleOrGroup) return undefined;\n\n      // Computed before the callback so it can inspect the prospective result.\n      const nextQuery = move(query, oldPath, newPath, { clone, combinators, idGenerator, freeze });\n      const isGroup = isRuleGroup(ruleOrGroup);\n      const callback = isGroup ? onMoveGroup : onMoveRule;\n      const callbackResult = callback\n        ? callback(ruleOrGroup, oldPath, newPath, query, nextQuery, { clone, combinators }, context)\n        : true;\n\n      if (!callbackResult) {\n        log({\n          type: isGroup ? LogType.onMoveGroupFalse : LogType.onMoveRuleFalse,\n          ruleOrGroup,\n          oldPath,\n          newPath,\n          clone,\n          query,\n          nextQuery,\n        });\n        return undefined;\n      }\n\n      const newQuery = isRuleGroup(callbackResult) ? callbackResult : nextQuery;\n      log({ type: LogType.move, query, newQuery, oldPath, newPath, clone });\n      return newQuery;\n    },\n\n    groupRule: (query, sourcePath, targetPath, clone, context) => {\n      if (blocked(query, sourcePath)) {\n        log({ type: LogType.pathDisabled, sourcePath, targetPath, query });\n        return undefined;\n      }\n\n      // A path that no longer resolves isn't caught by the guards, so confirm it before\n      // computing anything or handing a null node to the callback.\n      const ruleOrGroup = findPath(sourcePath, query);\n      if (!ruleOrGroup) return undefined;\n\n      // Computed before the callback so it can inspect the prospective result.\n      const nextQuery = group(query, sourcePath, targetPath, {\n        clone,\n        combinators,\n        idGenerator,\n        freeze,\n      });\n      const isGroup = isRuleGroup(ruleOrGroup);\n      const callback = isGroup ? onGroupGroup : onGroupRule;\n      const callbackResult = callback\n        ? callback(\n            ruleOrGroup,\n            sourcePath,\n            targetPath,\n            query,\n            nextQuery,\n            { clone, combinators },\n            context\n          )\n        : true;\n\n      if (!callbackResult) {\n        log({\n          type: isGroup ? LogType.onGroupGroupFalse : LogType.onGroupRuleFalse,\n          ruleOrGroup,\n          sourcePath,\n          targetPath,\n          clone,\n          query,\n          nextQuery,\n        });\n        return undefined;\n      }\n\n      const newQuery = isRuleGroup(callbackResult) ? callbackResult : nextQuery;\n      log({ type: LogType.group, query, newQuery, sourcePath, targetPath, clone });\n      return newQuery;\n    },\n  };\n};\n","import type {\n  FullCombinator,\n  FullField,\n  FullOptionList,\n  MatchModeOptions,\n  RuleGroupTypeAny,\n  RuleType,\n  ValueSourceFullOptions,\n} from '../types';\nimport { generateID } from './generateID';\nimport { getFirstOption, getOption } from './optGroupUtils';\n\n/**\n * Everything {@link createRule} needs to produce a new rule. Each member corresponds to the\n * `QueryBuilder` prop (or `useQueryBuilderSetup` output) of the same name.\n */\nexport interface CreateRuleOptions<F extends FullField = FullField> {\n  fields: FullOptionList<F>;\n  getDefaultField?: string | ((fieldsData: FullOptionList<F>) => string);\n  /** Produces the default operator for a field, i.e. `resolveDefaultOperator` already bound. */\n  getRuleDefaultOperator: (field: string) => string;\n  /** Produces the value sources for a field/operator pair. */\n  getValueSources: (\n    field: string,\n    operator: string,\n    misc: { fieldData: F }\n  ) => ValueSourceFullOptions;\n  /** Produces the match modes for a field. */\n  getMatchModes: (field: string, misc: { fieldData: F }) => MatchModeOptions;\n  /** Produces the default `value` for an otherwise-complete rule. */\n  getRuleDefaultValue: (rule: RuleType) => unknown;\n  idGenerator?: () => string;\n}\n\n/**\n * Creates a rule from the given configuration, applying the same precedence as the\n * `QueryBuilder` component. The `value` is computed in a second pass, once `field`, `operator`,\n * and `valueSource` are known, since the default value depends on all three.\n *\n * @group Query Tools\n */\nexport const createRule = <F extends FullField = FullField>({\n  fields,\n  getDefaultField,\n  getRuleDefaultOperator,\n  getValueSources,\n  getMatchModes,\n  getRuleDefaultValue,\n  idGenerator = generateID,\n}: CreateRuleOptions<F>): RuleType => {\n  let field = getFirstOption(fields) ?? '';\n\n  if (getDefaultField) {\n    if (typeof getDefaultField === 'function') {\n      const defaultField = getDefaultField(fields);\n      // A falsy return leaves the first option in place, rather than producing an empty field.\n      if (defaultField) field = defaultField;\n    } else {\n      field = getDefaultField;\n    }\n  }\n\n  const fieldData = getOption(fields, field) as F;\n  const operator = getRuleDefaultOperator(field);\n  const valueSource = getFirstOption(getValueSources(field, operator, { fieldData })) ?? 'value';\n  const matchMode = getFirstOption(getMatchModes(field, { fieldData }));\n\n  const newRule: RuleType = {\n    id: idGenerator(),\n    field,\n    operator,\n    valueSource,\n    value: '',\n    ...(matchMode ? { match: { mode: matchMode, threshold: 1 } } : null),\n  };\n\n  return { ...newRule, value: getRuleDefaultValue(newRule) };\n};\n\n/**\n * Everything {@link createRuleGroup} needs to produce a new group.\n */\nexport interface CreateRuleGroupOptions<C extends FullCombinator = FullCombinator> {\n  combinators: FullOptionList<C>;\n  /** When `true`, the new group contains one new rule. */\n  addRuleToNewGroups?: boolean;\n  /** Produces that rule, i.e. {@link createRule} already bound. */\n  createRule: () => RuleType;\n  idGenerator?: () => string;\n}\n\n/**\n * Creates a group from the given configuration. Pass `true` for `independentCombinators` to omit\n * the `combinator` property.\n *\n * The group's own `id` is generated _before_ any contained rule's, matching the order the\n * `QueryBuilder` component has always used. This is observable when `idGenerator` is\n * deterministic, as it often is in tests.\n *\n * @group Query Tools\n */\nexport const createRuleGroup = <C extends FullCombinator = FullCombinator>(\n  {\n    combinators,\n    addRuleToNewGroups,\n    createRule: createRuleMain,\n    idGenerator = generateID,\n  }: CreateRuleGroupOptions<C>,\n  independentCombinators?: boolean\n): RuleGroupTypeAny => {\n  // Evaluation order matters: the group's `id` comes first.\n  const id = idGenerator();\n  const rules = addRuleToNewGroups ? [createRuleMain()] : [];\n\n  if (independentCombinators) {\n    return { id, rules, not: false } as RuleGroupTypeAny;\n  }\n\n  return {\n    id,\n    rules,\n    combinator: getFirstOption(combinators) ?? '',\n    not: false,\n  } as RuleGroupTypeAny;\n};\n"],"x_google_ignoreList":[2],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,MAAa,cAAc;CACzB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;;;;;;AAqBA,MAAa,kBAAkB;CAC7B,eAAe;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,gBAAgB;EACd;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,eAAe;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,kBAAkB;EAChB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,iBAAiB;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,oBAAoB;EAClB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,YAAY;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,eAAe;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,kBAAkB;EAChB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,iBAAiB;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,gBAAgB;EACd;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,iBAAiB;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,iBAAiB;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,gBAAgB;EACd;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,WAAW;EACT;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,kBAAkB;EAChB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,mBAAmB;EACjB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,kBAAkB;EAChB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,MAAM;EACJ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,WAAW;EACT;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,uBAAuB;EACrB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,yBAAyB;EACvB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,cAAc;EACZ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,iBAAiB;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,aAAa;EACX;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,eAAe;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,qBAAqB;EACnB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF;;;;;;;;;;;;;;;;AAiBA,MAAa,cAAc;CACzB,eAAe;CACf,gBAAgB;CAChB,eAAe;CACf,kBAAkB;CAClB,iBAAiB;CACjB,oBAAoB;CACpB,YAAY;CACZ,eAAe;CACf,kBAAkB;CAClB,iBAAiB;CACjB,gBAAgB;CAChB,iBAAiB;CACjB,iBAAiB;CACjB,gBAAgB;CAChB,WAAW;CACX,kBAAkB;CAClB,mBAAmB;CACnB,kBAAkB;CAClB,M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