@react-querybuilder/core 8.23.0 → 8.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/cjs/react-querybuilder_core.cjs.development.d.ts +507 -448
  2. package/dist/cjs/react-querybuilder_core.cjs.development.js +169 -6
  3. package/dist/cjs/react-querybuilder_core.cjs.development.js.map +1 -1
  4. package/dist/cjs/react-querybuilder_core.cjs.production.d.ts +507 -448
  5. package/dist/cjs/react-querybuilder_core.cjs.production.js +1 -1
  6. package/dist/cjs/react-querybuilder_core.cjs.production.js.map +1 -1
  7. package/dist/derivations.d.mts +288 -237
  8. package/dist/derivations.d.ts +288 -237
  9. package/dist/derivations.js +137 -4
  10. package/dist/derivations.js.map +1 -1
  11. package/dist/derivations.mjs +136 -5
  12. package/dist/derivations.mjs.map +1 -1
  13. package/dist/formatQuery.d.mts +1 -1
  14. package/dist/formatQuery.d.ts +1 -1
  15. package/dist/formatQuery.js +7 -4
  16. package/dist/formatQuery.js.map +1 -1
  17. package/dist/formatQuery.mjs +7 -4
  18. package/dist/formatQuery.mjs.map +1 -1
  19. package/dist/{index-OF2Q1gTp.d.mts → index-94yESPHr.d.mts} +4 -2
  20. package/dist/{index-XueTy_XQ.d.ts → index-D41_Ba4j.d.ts} +4 -2
  21. package/dist/parseCEL.d.mts +110 -110
  22. package/dist/parseCEL.d.ts +110 -110
  23. package/dist/parseCEL.js +4 -4
  24. package/dist/parseCEL.js.map +1 -1
  25. package/dist/parseCEL.mjs +4 -4
  26. package/dist/parseCEL.mjs.map +1 -1
  27. package/dist/parseCypher.d.mts +7 -7
  28. package/dist/parseCypher.d.ts +7 -7
  29. package/dist/parseGremlin.d.mts +4 -4
  30. package/dist/parseGremlin.d.ts +4 -4
  31. package/dist/parseJSONata.d.mts +37 -37
  32. package/dist/parseJSONata.d.ts +37 -37
  33. package/dist/parseJSONata.js +2 -2
  34. package/dist/parseJSONata.mjs +2 -2
  35. package/dist/parseJsonLogic.d.mts +8 -8
  36. package/dist/parseJsonLogic.d.ts +8 -8
  37. package/dist/parseJsonLogic.js +3 -3
  38. package/dist/parseJsonLogic.mjs +3 -3
  39. package/dist/parseMongoDB.d.mts +7 -7
  40. package/dist/parseMongoDB.d.ts +7 -7
  41. package/dist/parseMongoDB.js +3 -3
  42. package/dist/parseMongoDB.mjs +3 -3
  43. package/dist/parseSPARQL.d.mts +4 -4
  44. package/dist/parseSPARQL.d.ts +4 -4
  45. package/dist/parseSQL.d.mts +61 -61
  46. package/dist/parseSQL.d.ts +61 -61
  47. package/dist/parseSQL.js +4 -4
  48. package/dist/parseSQL.js.map +1 -1
  49. package/dist/parseSQL.mjs +4 -4
  50. package/dist/parseSQL.mjs.map +1 -1
  51. package/dist/parseSpEL.d.mts +55 -55
  52. package/dist/parseSpEL.d.ts +55 -55
  53. package/dist/parseSpEL.js +4 -4
  54. package/dist/parseSpEL.js.map +1 -1
  55. package/dist/parseSpEL.mjs +4 -4
  56. package/dist/parseSpEL.mjs.map +1 -1
  57. package/dist/{parserUtils-DbBXyAht.js → parserUtils-2VtG7m8L.js} +3 -3
  58. package/dist/{parserUtils-DbBXyAht.js.map → parserUtils-2VtG7m8L.js.map} +1 -1
  59. package/dist/{parserUtils-BKPstAaO.mjs → parserUtils-BlafvoFb.mjs} +3 -3
  60. package/dist/{parserUtils-BKPstAaO.mjs.map → parserUtils-BlafvoFb.mjs.map} +1 -1
  61. package/dist/{prepareQueryObjects-Dj9cTl9D.js → prepareQueryObjects-DJ_VjOLb.js} +2 -2
  62. package/dist/{prepareQueryObjects-Dj9cTl9D.js.map → prepareQueryObjects-DJ_VjOLb.js.map} +1 -1
  63. package/dist/{prepareQueryObjects-Dmyf3Wi_.mjs → prepareQueryObjects-DawsH4e3.mjs} +2 -2
  64. package/dist/{prepareQueryObjects-Dmyf3Wi_.mjs.map → prepareQueryObjects-DawsH4e3.mjs.map} +1 -1
  65. package/dist/react-querybuilder_core.d.mts +507 -448
  66. package/dist/react-querybuilder_core.legacy-esm.d.ts +507 -448
  67. package/dist/react-querybuilder_core.legacy-esm.js +172 -14
  68. package/dist/react-querybuilder_core.legacy-esm.js.map +1 -1
  69. package/dist/react-querybuilder_core.mjs +168 -7
  70. package/dist/react-querybuilder_core.mjs.map +1 -1
  71. package/dist/react-querybuilder_core.production.d.mts +507 -448
  72. package/dist/react-querybuilder_core.production.mjs +1 -1
  73. package/dist/react-querybuilder_core.production.mjs.map +1 -1
  74. package/dist/{utils-e-7KHkjV.js → utils-B4E1-ZvU.js} +12 -2
  75. package/dist/utils-B4E1-ZvU.js.map +1 -0
  76. package/dist/{utils-CP5Jqy1P.mjs → utils-DLZCoyAh.mjs} +12 -2
  77. package/dist/utils-DLZCoyAh.mjs.map +1 -0
  78. package/package.json +20 -19
  79. package/dist/utils-CP5Jqy1P.mjs.map +0 -1
  80. package/dist/utils-e-7KHkjV.js.map +0 -1
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("numeric-quantity"),t=require("immer");const n=`actionElement.addGroupAction.addRuleAction.cloneGroupAction.cloneRuleAction.combinatorSelector.dragHandle.fieldSelector.inlineCombinator.lockGroupAction.lockRuleAction.matchModeEditor.muteGroupAction.muteRuleAction.notToggle.operatorSelector.removeGroupAction.removeRuleAction.rule.ruleGroup.ruleGroupBodyElements.ruleGroupHeaderElements.shiftActions.undoRedoActions.valueEditor.valueSelector.valueSourceSelector`.split(`.`),r={actionElement:[`className`,`context`,`disabled`,`disabledTranslation`,`handleOnClick`,`label`,`level`,`path`,`ruleOrGroup`,`rules`,`schema`,`testID`,`title`,`validation`],addGroupAction:[`className`,`context`,`disabled`,`disabledTranslation`,`handleOnClick`,`label`,`level`,`path`,`ruleOrGroup`,`rules`,`schema`,`testID`,`title`,`validation`],addRuleAction:[`className`,`context`,`disabled`,`disabledTranslation`,`handleOnClick`,`label`,`level`,`path`,`ruleOrGroup`,`rules`,`schema`,`testID`,`title`,`validation`],cloneGroupAction:[`className`,`context`,`disabled`,`disabledTranslation`,`handleOnClick`,`label`,`level`,`path`,`ruleOrGroup`,`rules`,`schema`,`testID`,`title`,`validation`],cloneRuleAction:[`className`,`context`,`disabled`,`disabledTranslation`,`handleOnClick`,`label`,`level`,`path`,`ruleOrGroup`,`rules`,`schema`,`testID`,`title`,`validation`],combinatorSelector:[`className`,`context`,`disabled`,`handleOnChange`,`level`,`options`,`path`,`ruleGroup`,`rules`,`schema`,`testID`,`title`,`validation`,`value`],dragHandle:[`className`,`context`,`disabled`,`dragHandleAttributes`,`label`,`level`,`path`,`ruleOrGroup`,`schema`,`testID`,`title`,`validation`],fieldSelector:[`className`,`context`,`disabled`,`handleOnChange`,`level`,`operator`,`options`,`path`,`rule`,`schema`,`testID`,`title`,`validation`,`value`],inlineCombinator:[`className`,`component`,`context`,`disabled`,`handleOnChange`,`level`,`options`,`path`,`ruleGroup`,`rules`,`schema`,`testID`,`title`,`validation`,`value`],lockGroupAction:[`className`,`context`,`disabled`,`disabledTranslation`,`handleOnClick`,`label`,`level`,`path`,`ruleOrGroup`,`rules`,`schema`,`testID`,`title`,`validation`],lockRuleAction:[`className`,`context`,`disabled`,`disabledTranslation`,`handleOnClick`,`label`,`level`,`path`,`ruleOrGroup`,`rules`,`schema`,`testID`,`title`,`validation`],matchModeEditor:[`className`,`classNames`,`context`,`disabled`,`field`,`fieldData`,`handleOnChange`,`level`,`match`,`numericEditorComponent`,`options`,`path`,`rule`,`schema`,`selectorComponent`,`testID`,`thresholdPlaceholder`,`title`,`validation`,`value`],muteGroupAction:[`className`,`context`,`disabled`,`disabledTranslation`,`handleOnClick`,`label`,`level`,`path`,`ruleOrGroup`,`rules`,`schema`,`testID`,`title`,`validation`],muteRuleAction:[`className`,`context`,`disabled`,`disabledTranslation`,`handleOnClick`,`label`,`level`,`path`,`ruleOrGroup`,`rules`,`schema`,`testID`,`title`,`validation`],notToggle:[`checked`,`className`,`context`,`disabled`,`handleOnChange`,`label`,`level`,`path`,`ruleGroup`,`schema`,`testID`,`title`,`validation`],operatorSelector:[`className`,`context`,`disabled`,`field`,`fieldData`,`handleOnChange`,`level`,`options`,`path`,`rule`,`schema`,`testID`,`title`,`validation`,`value`],removeGroupAction:[`className`,`context`,`disabled`,`disabledTranslation`,`handleOnClick`,`label`,`level`,`path`,`ruleOrGroup`,`rules`,`schema`,`testID`,`title`,`validation`],removeRuleAction:[`className`,`context`,`disabled`,`disabledTranslation`,`handleOnClick`,`label`,`level`,`path`,`ruleOrGroup`,`rules`,`schema`,`testID`,`title`,`validation`],rule:`actions.context.disabled.dndRef.dragHandleAttributes.dragMonitorId.dragRef.dropEffect.dropMonitorId.dropNotAllowed.field.groupItems.id.isDragging.isOver.operator.parentDisabled.parentMuted.path.rule.schema.shiftDownDisabled.shiftUpDisabled.translations.value.valueSource`.split(`.`),ruleGroup:`actions.combinator.context.disabled.dragHandleAttributes.dragMonitorId.dragRef.dropEffect.dropMonitorId.dropNotAllowed.dropRef.groupItems.id.isDragging.isOver.not.parentDisabled.parentMuted.path.previewRef.ruleGroup.rules.schema.shiftDownDisabled.shiftUpDisabled.translations`.split(`.`),ruleGroupBodyElements:`accessibleDescription.actions.addGroup.addRule.classNames.cloneGroup.combinator.context.disabled.dragHandleAttributes.dragMonitorId.dragRef.dropEffect.dropMonitorId.dropNotAllowed.dropRef.groupItems.id.isDragging.isOver.muted.not.onCombinatorChange.onGroupAdd.onIndependentCombinatorChange.onNotToggleChange.outerClassName.parentDisabled.parentMuted.path.pathsMemo.previewRef.removeGroup.ruleGroup.rules.schema.shiftDownDisabled.shiftGroupDown.shiftGroupUp.shiftUpDisabled.toggleLockGroup.toggleMuteGroup.translations.validationClassName.validationResult`.split(`.`),ruleGroupHeaderElements:`accessibleDescription.actions.addGroup.addRule.classNames.cloneGroup.combinator.context.disabled.dragHandleAttributes.dragMonitorId.dragRef.dropEffect.dropMonitorId.dropNotAllowed.dropRef.groupItems.id.isDragging.isOver.muted.not.onCombinatorChange.onGroupAdd.onIndependentCombinatorChange.onNotToggleChange.outerClassName.parentDisabled.parentMuted.path.pathsMemo.previewRef.removeGroup.ruleGroup.rules.schema.shiftDownDisabled.shiftGroupDown.shiftGroupUp.shiftUpDisabled.toggleLockGroup.toggleMuteGroup.translations.validationClassName.validationResult`.split(`.`),shiftActions:[`className`,`context`,`disabled`,`labels`,`level`,`path`,`ruleOrGroup`,`schema`,`shiftDown`,`shiftDownDisabled`,`shiftUp`,`shiftUpDisabled`,`testID`,`title`,`titles`,`validation`],undoRedoActions:[`className`,`classNames`,`context`,`disabled`,`labels`,`level`,`path`,`ruleOrGroup`,`schema`,`testID`,`title`,`titles`,`validation`],valueEditor:[`className`,`context`,`disabled`,`field`,`fieldData`,`handleOnChange`,`inputType`,`level`,`listsAsArrays`,`operator`,`parseNumbers`,`path`,`rule`,`schema`,`selectorComponent`,`separator`,`skipHook`,`testID`,`title`,`type`,`validation`,`value`,`valueSource`,`values`],valueSelector:[`className`,`context`,`disabled`,`handleOnChange`,`level`,`listsAsArrays`,`multiple`,`options`,`path`,`schema`,`testID`,`title`,`validation`,`value`],valueSourceSelector:[`className`,`context`,`disabled`,`field`,`fieldData`,`handleOnChange`,`level`,`options`,`path`,`rule`,`schema`,`testID`,`title`,`validation`,`value`]},i={actionElement:null,addGroupAction:`action`,addRuleAction:`action`,cloneGroupAction:`action`,cloneRuleAction:`action`,combinatorSelector:`selector`,dragHandle:null,fieldSelector:`selector`,inlineCombinator:null,lockGroupAction:`action`,lockRuleAction:`action`,matchModeEditor:null,muteGroupAction:`action`,muteRuleAction:`action`,notToggle:null,operatorSelector:`selector`,removeGroupAction:`action`,removeRuleAction:`action`,rule:null,ruleGroup:null,ruleGroupBodyElements:null,ruleGroupHeaderElements:null,shiftActions:null,undoRedoActions:null,valueEditor:null,valueSelector:null,valueSourceSelector:`selector`},a=`------`,o=a,s=a,c=a,l=a,u=a,d=a,f={fields:{title:`Field`,placeholderName:`~`,placeholderLabel:o,placeholderGroupLabel:s},operators:{title:`Operator`,placeholderName:`~`,placeholderLabel:c,placeholderGroupLabel:l},values:{title:`Values`,placeholderName:`~`,placeholderLabel:u,placeholderGroupLabel:d},matchMode:{title:`Match mode`},matchThreshold:{title:`Match threshold`,placeholderName:`#`},value:{title:`Value`},removeRule:{label:`⨯`,title:`Remove rule`},removeGroup:{label:`⨯`,title:`Remove group`},addRule:{label:`+ Rule`,title:`Add rule`},addGroup:{label:`+ Group`,title:`Add group`},combinators:{title:`Combinator`},notToggle:{label:`Not`,title:`Invert this group`},cloneRule:{label:`⧉`,title:`Clone rule`},cloneRuleGroup:{label:`⧉`,title:`Clone group`},shiftActionUp:{label:`˄`,title:`Shift up`},shiftActionDown:{label:`˅`,title:`Shift down`},undo:{label:`↶`,title:`Undo`},redo:{label:`↷`,title:`Redo`},dragHandle:{label:`⁞⁞`,title:`Drag handle`},lockRule:{label:`🔓`,title:`Lock rule`},lockGroup:{label:`🔓`,title:`Lock group`},lockRuleDisabled:{label:`🔒`,title:`Unlock rule`},lockGroupDisabled:{label:`🔒`,title:`Unlock group`},muteRule:{label:`🔊`,title:`Mute rule`},muteGroup:{label:`🔊`,title:`Mute group`},unmuteRule:{label:`🔇`,title:`Unmute rule`},unmuteGroup:{label:`🔇`,title:`Unmute group`},valueSourceSelector:{title:`Value source`}},p={"=":`=`,"!=":`!=`,"<":`<`,">":`>`,"<=":`<=`,">=":`>=`,contains:`contains`,beginsWith:`begins with`,endsWith:`ends with`,doesNotContain:`does not contain`,doesNotBeginWith:`does not begin with`,doesNotEndWith:`does not end with`,null:`is null`,notNull:`is not null`,in:`in`,notIn:`not in`,between:`between`,notBetween:`not between`},m={and:`AND`,or:`OR`,xor:`XOR`},h=[{name:`=`,value:`=`,label:`=`},{name:`!=`,value:`!=`,label:`!=`},{name:`<`,value:`<`,label:`<`},{name:`>`,value:`>`,label:`>`},{name:`<=`,value:`<=`,label:`<=`},{name:`>=`,value:`>=`,label:`>=`},{name:`contains`,value:`contains`,label:`contains`},{name:`beginsWith`,value:`beginsWith`,label:`begins with`},{name:`endsWith`,value:`endsWith`,label:`ends with`},{name:`doesNotContain`,value:`doesNotContain`,label:`does not contain`},{name:`doesNotBeginWith`,value:`doesNotBeginWith`,label:`does not begin with`},{name:`doesNotEndWith`,value:`doesNotEndWith`,label:`does not end with`},{name:`null`,value:`null`,label:`is null`},{name:`notNull`,value:`notNull`,label:`is not null`},{name:`in`,value:`in`,label:`in`},{name:`notIn`,value:`notIn`,label:`not in`},{name:`between`,value:`between`,label:`between`},{name:`notBetween`,value:`notBetween`,label:`not between`}],g={"=":`!=`,"!=":`=`,"<":`>=`,"<=":`>`,">":`<=`,">=":`<`,beginsWith:`doesNotBeginWith`,doesNotBeginWith:`beginsWith`,endsWith:`doesNotEndWith`,doesNotEndWith:`endsWith`,contains:`doesNotContain`,doesNotContain:`contains`,between:`notBetween`,notBetween:`between`,in:`notIn`,notIn:`in`,notNull:`null`,null:`notNull`},_=new Set([`=`,`!=`,`<`,`>`,`<=`,`>=`]),v=new Set([`contains`,`beginsWith`,`endsWith`,`doesNotContain`,`doesNotBeginWith`,`doesNotEndWith`]),y=new Set([`null`,`notNull`]),b=new Set([`in`,`notIn`]),x=new Set([`between`,`notBetween`]),S=[{name:`and`,value:`and`,label:`AND`},{name:`or`,value:`or`,label:`OR`}],C=[...S,{name:`xor`,value:`xor`,label:`XOR`}],w=[{name:`all`,value:`all`,label:`all`},{name:`some`,value:`some`,label:`some`},{name:`none`,value:`none`,label:`none`},{name:`atLeast`,value:`atLeast`,label:`at least`},{name:`atMost`,value:`atMost`,label:`at most`},{name:`exactly`,value:`exactly`,label:`exactly`}],T={queryBuilder:`queryBuilder`,ruleGroup:`ruleGroup`,header:`ruleGroup-header`,body:`ruleGroup-body`,combinators:`ruleGroup-combinators`,addRule:`ruleGroup-addRule`,addGroup:`ruleGroup-addGroup`,cloneRule:`rule-cloneRule`,cloneGroup:`ruleGroup-cloneGroup`,removeGroup:`ruleGroup-remove`,notToggle:`ruleGroup-notToggle`,rule:`rule`,fields:`rule-fields`,matchMode:`rule-matchMode`,matchThreshold:`rule-matchThreshold`,operators:`rule-operators`,value:`rule-value`,removeRule:`rule-remove`,betweenRules:`betweenRules`,valid:`queryBuilder-valid`,invalid:`queryBuilder-invalid`,shiftActions:`shiftActions`,undoRedoActions:`undoRedoActions`,undoAction:`undoRedoActions-undo`,redoAction:`undoRedoActions-redo`,dndDragging:`dndDragging`,dndOver:`dndOver`,dndCopy:`dndCopy`,dndGroup:`dndGroup`,dndDropNotAllowed:`dndDropNotAllowed`,dndPreviewPosition:`dndPreviewPosition`,dndHidden:`dndHidden`,dragHandle:`queryBuilder-dragHandle`,disabled:`queryBuilder-disabled`,muted:`queryBuilder-muted`,lockRule:`rule-lock`,lockGroup:`ruleGroup-lock`,muteRule:`rule-mute`,muteGroup:`ruleGroup-mute`,valueSource:`rule-valueSource`,valueListItem:`rule-value-list-item`,branches:`queryBuilder-branches`,justified:`queryBuilder-justified`,responsive:`queryBuilder-responsive`,hasSubQuery:`rule-hasSubQuery`,loading:`queryBuilder-loading`,valueDateTimeRelative:`rule-value-dateTimeRelative`},E={queryBuilder:``,ruleGroup:``,header:``,body:``,combinators:``,addRule:``,addGroup:``,cloneRule:``,cloneGroup:``,removeGroup:``,notToggle:``,rule:``,fields:``,matchMode:``,matchThreshold:``,operators:``,value:``,removeRule:``,shiftActions:``,undoRedoActions:``,undoAction:``,redoAction:``,dragHandle:``,lockRule:``,lockGroup:``,muteRule:``,muteGroup:``,muted:``,valueSource:``,actionElement:``,valueSelector:``,betweenRules:``,valid:``,invalid:``,dndDragging:``,dndOver:``,dndGroup:``,dndCopy:``,dndDropNotAllowed:``,dndPreviewPosition:``,dndHidden:``,disabled:``,valueListItem:``,branches:``,hasSubQuery:``,loading:``,valueDateTimeRelative:``},D={empty:`empty`,invalidCombinator:`invalid combinator`,invalidIndependentCombinators:`invalid independent combinators`},O={rule:`rule`,ruleGroup:`rule-group`,inlineCombinator:`inline-combinator`,addGroup:`add-group`,removeGroup:`remove-group`,cloneGroup:`clone-group`,cloneRule:`clone-rule`,addRule:`add-rule`,removeRule:`remove-rule`,combinators:`combinators`,fields:`fields`,operators:`operators`,valueEditor:`value-editor`,notToggle:`not-toggle`,shiftActions:`shift-actions`,undoRedoActions:`undo-redo-actions`,undoAction:`undo-action`,redoAction:`redo-action`,dragHandle:`drag-handle`,lockRule:`lock-rule`,lockGroup:`lock-group`,muteRule:`mute-rule`,muteGroup:`mute-group`,valueSourceSelector:`value-source-selector`,matchModeEditor:`match-mode-editor`},k={parentPathDisabled:`action aborted: parent path disabled`,pathDisabled:`action aborted: path is disabled`,queryUpdate:`query updated`,onAddRuleFalse:`onAddRule callback returned false`,onAddGroupFalse:`onAddGroup callback returned false`,onGroupRuleFalse:`onGroupRule callback returned false`,onGroupGroupFalse:`onGroupGroup callback returned false`,onMoveRuleFalse:`onMoveRule callback returned false`,onMoveGroupFalse:`onMoveGroup callback returned false`,onRemoveFalse:`onRemove callback returned false`,add:`rule or group added`,remove:`rule or group removed`,update:`rule or group updated`,move:`rule or group moved`,group:`rule or group grouped with another`},ee=[],te={addRuleToNewGroups:!1,autoSelectField:!0,autoSelectOperator:!0,autoSelectValue:!1,debugMode:!1,enableDragAndDrop:!1,enableMountQueryChange:!0,listsAsArrays:!1,preserveQueryStateOnUnmount:!1,resetOnFieldChange:!0,resetOnOperatorChange:!1,showCloneButtons:!1,showCombinatorsBetweenRules:!1,showLockButtons:!1,showMuteButtons:!1,showNotToggle:!1,showShiftActions:!1,showUndoRedo:!1,suppressStandardClassnames:!1},ne=[`target-not-found`,`parent-not-found`,`parent-not-a-group`,`destination-not-found`,`root-not-allowed`,`not-a-combinator-slot`,`target-disabled`,`parent-disabled`,`max-levels-exceeded`],re=new Set(ne),ie=(e,t=`,`)=>typeof e==`string`?e.split(`\\${t}`).map(e=>e.split(t)).reduce((e,n,r)=>r===0?n:[...e.slice(0,-1),`${e.at(-1)}${t}${n[0]}`,...n.slice(1)],[]):[],ae=(e,t=`,`)=>e.map(e=>`${e??``}`.replaceAll(t[0],`\\${t[0]}`)).join(t),A=e=>typeof e==`string`?e.trim():e,j=(e,{retainEmptyStrings:t}={})=>Array.isArray(e)?e.map(A):typeof e==`string`?ie(e,`,`).filter(t?()=>!0:e=>!/^\s*$/.test(e)).map(e=>e.trim()):typeof e==`number`?[e]:[],oe=e=>e.every(e=>e===!1||(e??!1)!==!1);function se(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=se(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function ce(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=se(e))&&(r&&(r+=` `),r+=t);return r}const M=e=>typeof e==`string`?e.toLowerCase():e,le=new RegExp(e.numericRegex.source.replace(/^\^/,String.raw`^\s*`).replace(/\$$/,String.raw`\s*$`)),N=e=>typeof e==`object`&&!!e&&Object.getPrototypeOf(e)===Object.prototype,P=e=>e==null||e===``,ue=e=>N(e)&&`field`in e&&typeof e.field==`string`,F=e=>N(e)&&Array.isArray(e.rules),I=e=>F(e)&&typeof e.combinator==`string`,L=e=>F(e)&&e.combinator===void 0,de=`~structural`,fe=(e,t)=>{let n=new Set([...Object.keys(e),...Object.keys(t)]);n.delete(`rules`);let r=[];for(let i of n)Object.is(e[i],t[i])||r.push(i);return r.toSorted()},pe=(e,t,n,r)=>{if(e===t)return``;if(typeof e==`string`||typeof t==`string`)return typeof e==typeof t?`${n}:combinator[${r}]`:de;let i=F(e),a=F(t);if(i!==a)return de;if(!i||!a){let n=fe(e,t);return n.length===0?``:`${t.id??``}:${n.join(`,`)}`}if(e.rules.length!==t.rules.length)return de;let o=fe(e,t),s=-1;for(let[n,r]of e.rules.entries())if(r!==t.rules[n]){if(s!==-1)return de;s=n}return s===-1?o.length===0?``:`${t.id??``}:${o.join(`,`)}`:o.length>0?de:pe(e.rules[s],t.rules[s],t.id??``,s)},me=(e,t)=>pe(e,t,``,-1),he=(e,t,n,r,i=500)=>t!==`~structural`&&t===e&&r>=n&&r-n<i,ge=[`or`,`xor`,`and`],_e=(e,t)=>M(e)===t,ve=(e,t=0)=>{let n=ge[t];if(!e.rules.includes(n))return t<ge.length-2?ve(e,t+1):e;let r=[...e.rules],i=0;for(;i<r.length-2;){if(_e(r[i+1],n)){i+=2;continue}let e=-1;for(let t=i+2;t<r.length;t++)if(typeof r[t]==`string`&&M(r[t])===n){e=t;break}if(e===-1){r.splice(i,r.length,ve({rules:r.slice(i)},t+1));break}r.splice(i,e-i,ve({rules:r.slice(i,e)},t+1))}return{...e,rules:r}},R=e=>{if(I(e))return e;let t=ve(e),n=[],r=`and`;for(let[e,i]of t.rules.entries())typeof i==`string`?e===1&&(r=i):n.push(F(i)?R(i):i);return{...t,combinator:r,rules:n}},ye=e=>{if(L(e))return e;let{combinator:t,...n}=e,r=[],{length:i}=e.rules;for(let n=0;n<i;n++){let a=e.rules[n];F(a)?r.push(ye(a)):r.push(a),t&&n<i-1&&r.push(t)}return{...n,rules:r}};function be(e){return L(e)?R(e):ye(e)}const xe={shiftActions:[`shiftActions`],dragHandle:[`dragHandle`],fields:[`valueSelector`,`fields`],matchMode:[`valueSelector`,`matchMode`],matchThreshold:[`valueSelector`,`matchThreshold`],operators:[`valueSelector`,`operators`],valueSource:[`valueSelector`,`valueSource`],value:[`value`],cloneRule:[`actionElement`,`cloneRule`],lockRule:[`actionElement`,`lockRule`],muteRule:[`actionElement`,`muteRule`],removeRule:[`actionElement`,`removeRule`],valueListItem:[`valueListItem`]},Se={header:{sources:[`header`],conditions:[{key:`dndOver`,when:e=>e.isOver,standardOnly:!0},{key:`dndCopy`,when:e=>e.isOver&&e.dropEffect===`copy`},{key:`dndDropNotAllowed`,when:e=>e.dropNotAllowed}]},shiftActions:[`shiftActions`],undoRedoActions:[`undoRedoActions`],undoAction:[`actionElement`,`undoAction`],redoAction:[`actionElement`,`redoAction`],dragHandle:[`dragHandle`],combinators:[`valueSelector`,`combinators`],notToggle:[`notToggle`],addRule:[`actionElement`,`addRule`],addGroup:[`actionElement`,`addGroup`],cloneGroup:[`actionElement`,`cloneGroup`],lockGroup:[`actionElement`,`lockGroup`],muteGroup:[`actionElement`,`muteGroup`],removeGroup:[`actionElement`,`removeGroup`],body:[`body`]},Ce=[{key:`disabled`,when:e=>e.disabled},{key:`muted`,when:e=>e.muted},{key:`dndDragging`,when:e=>e.isDragging},{key:`dndOver`,when:e=>e.isOver},{key:`dndCopy`,when:e=>e.isOver&&e.dropEffect===`copy`},{key:`dndGroup`,when:e=>e.isOver&&e.groupItems},{key:`dndDropNotAllowed`,when:e=>e.dropNotAllowed},{key:`hasSubQuery`,when:e=>e.hasSubQuery}],we=[{key:`disabled`,when:e=>e.disabled},{key:`muted`,when:e=>e.muted},{key:`dndDragging`,when:e=>e.isDragging},{key:`dndGroup`,when:e=>e.isOver&&e.groupItems}],Te=[{key:`disabled`,when:e=>e.disabled},{key:`valid`,when:e=>typeof e.validationResult==`boolean`&&e.validationResult},{key:`invalid`,when:e=>typeof e.validationResult==`boolean`&&!e.validationResult}],Ee=(e,t,{classNames:n,suppressStandardClassnames:r})=>{let i=e.map(e=>[e,!!e.when(t)]);return[...i.filter(([e])=>!e.standardOnly).map(([e,t])=>t&&n?.[e.key]),r||Object.fromEntries(i.map(([e,t])=>[T[e.key],t]))]},De=(e,t,n,r)=>{let{sources:i,conditions:a}=Array.isArray(t)?{sources:t}:t;return ce(r.suppressStandardClassnames||T[e],...i.map(e=>r.classNames?.[e]),...a?Ee(a,n,r):[])},Oe=(e,t,n)=>{let r={};for(let[i,a]of Object.entries(e))r[i]=De(i,a,t,n);return r},ke=e=>Oe(xe,{},e),Ae=(e,t)=>De(e,xe[e],{},t),je=e=>Oe(Se,e,e),Me=(e,t,n)=>{let{classNames:r,suppressStandardClassnames:i,leadingClassNames:a=[],validationClassName:o}=n;return ce(...a,i||T[e],r?.[e],...Ee(t,n,n),o)},Ne=e=>Me(`rule`,Ce,e),Pe=e=>Me(`ruleGroup`,we,e),Fe=e=>Me(`queryBuilder`,Te,e),Ie=e=>{let t={},n=e=>{e.id&&t[e.id]},r=e=>{let i=[];if(e.rules.length===0)i.push(D.empty);else if(!I(e)){let t=!1;for(let n=0;n<e.rules.length&&!t;n++)(n%2==0&&typeof e.rules[n]==`string`||n%2==1&&typeof e.rules[n]!=`string`||n%2==1&&typeof e.rules[n]==`string`&&!S.map(e=>e.name).includes(e.rules[n]))&&(t=!0);t&&i.push(D.invalidIndependentCombinators)}I(e)&&!S.map(e=>e.name).includes(e.combinator)&&e.rules.length>1&&i.push(D.invalidCombinator),e.id&&(t[e.id]=i.length>0?{valid:!1,reasons:i}:!0);for(let t of e.rules)typeof t==`string`||(F(t)?r(t):n(t))};return r(e),t},Le=Object.keys,Re=Object.entries,ze=e=>e===`__proto__`||e===`constructor`||e===`prototype`,Be=e=>N(e)&&`name`in e&&typeof e.name==`string`,Ve=e=>N(e)&&`value`in e&&typeof e.value==`string`;function z(e,t,n){if(typeof e==`string`)return{...t,name:e,value:e,label:n?.[e]??e};let r={},i=!!t;return Be(e)&&!Ve(e)?(r.value=e.name,i=!0):!Be(e)&&Ve(e)&&(r.name=e.value,i=!0),i?Object.assign({},t,e,r):e}function B(e,t,n){if(!Array.isArray(e))return[];let r=e;return Je(r)?r.map(e=>({...e,options:e.options.map(e=>z(e,t,n))})):r.map(e=>z(e,t,n))}function He(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,z(n,t)]))}const Ue=e=>We(e),We=e=>{let t=new Set,n=[];for(let r of e)t.has(r.value??r.name)||(t.add(r.value??r.name),n.push(r));return e.length===n.length?e:n},Ge=e=>Array.isArray(e)&&e.length>0&&N(e[0])&&`options`in e[0]&&Array.isArray(e[0].options),Ke=e=>{let t=!1;if(Array.isArray(e))for(let n of e)if(Be(n)||Ve(n))t=!0;else return!1;return t},qe=e=>{let t=!1;if(Array.isArray(e))for(let n of e)if(Be(n)&&Ve(n))t=!0;else return!1;return t},Je=(e,{allowEmpty:t=!1}={})=>{let n=!1;if(Array.isArray(e))for(let r of e)if(N(r)&&`options`in r&&(Ke(r.options)||t&&Array.isArray(r.options)&&r.options.length===0))n=!0;else return!1;return n},Ye=(e,{allowEmpty:t=!1}={})=>{let n=!1;if(Array.isArray(e))for(let r of e)if(N(r)&&`options`in r&&(qe(r.options)||t&&Array.isArray(r.options)&&r.options.length===0))n=!0;else return!1;return n};function V(e,t){return(Je(e,{allowEmpty:!0})?e.flatMap(e=>e.options):e).find(e=>e.value===t||e.name===t)}function H(e){if(!Array.isArray(e)||e.length===0)return null;if(Je(e,{allowEmpty:!0})){for(let t of e)if(t.options.length>0)return t.options[0].value??t.options[0].name;return null}return e[0].value??e[0].name}const Xe=e=>We(Ge(e)?e.flatMap(e=>e.options):e),Ze=e=>{let t=new Set,n=new Set,r=[];for(let i of e)if(!t.has(i.label)){t.add(i.label);let e=[];for(let t of i.options)n.has(t.value??t.name)||(n.add(t.value??t.name),e.push(z(t)));r.push({...i,options:e})}return r},Qe=e=>Je(e)?Ze(e):We(e.map(e=>z(e))),$e=e=>{let{optionList:t,baseOption:n={},labelMap:r={},placeholder:{placeholderName:i=`~`,placeholderLabel:o=a,placeholderGroupLabel:s=a}={},autoSelectOption:c=!0}=e,l={id:i,name:i,value:i,label:o},u=t??[l],d,f=Array.isArray(u)?B(u,n,r):Le(He(u,n)).map(e=>({...u[e],name:e,value:e})).sort((e,t)=>e.label.localeCompare(t.label));d=Je(f)?Ze(c?f:[{label:s,options:[l]},...f]):We(c?f:[l,...f]);let p={};if(!Array.isArray(u)){let e=He(u,n);p=c?e:{...e,[i]:l}}else if(Je(d))for(let e of d)for(let t of e.options)p[t.value??t.name]=z(t,n);else for(let e of d)p[e.value??e.name]=z(e,n);return{defaultOption:l,optionList:d,optionsMap:p}},et=(e,t,n)=>{let r=z(e),i=z(n);return r.value===i.value?!1:typeof r.comparator==`string`?r[r.comparator]===i[r.comparator]:r.comparator?.(i,t)??!1},tt=(e,t,n)=>{if(!e.comparator){let n=t=>(t.value??t.name)!==(e.value??e.name);return Je(t)?t.map(e=>({...e,options:e.options.filter(e=>n(e))})):t.filter(e=>n(e))}return Je(t)?t.map(t=>({...t,options:t.options.filter(t=>et(e,n,t))})).filter(e=>e.options.length>0):t.filter(t=>et(e,n,t))},nt=(e,t)=>t?.[e]??{name:e,value:e,label:e},rt=(e,t,n,r)=>n.inputType??r(e,t,{fieldData:n}),it=e=>{let t=e?.arity;return typeof t==`string`&&t===`unary`||typeof t==`number`&&t<2},at=(e,t,n)=>{let r=n(e.field,e.operator,{fieldData:t});return e.valueSource&&!V(r,e.valueSource)?[...r,{name:e.valueSource,value:e.valueSource,label:e.valueSource}]:r},ot=e=>e&&e.length>0?e:null,st=(e,t,n,r)=>e.valueSource===`field`?`select`:e.valueSource===`parameter`?n?M(e.operator)===`in`||M(e.operator)===`notin`?`multiselect`:`select`:`text`:r(e.field,e.operator,{fieldData:t}),ct=(e,t,n,r,i)=>{let a=e.valueSource===`field`?tt(t,n,e.operator):e.valueSource===`parameter`?r??[]:i(e.field,e.operator,{fieldData:t});return Ke(a)||Je(a)?B(a):a},lt=(e,t,n={},r=e.id??``)=>n[r]??(typeof t.validator==`function`?t.validator(e):null),ut=(e,t,n={})=>{let{fields:r,fieldMap:i,getInputType:a,getMatchModes:o,getOperators:s,getParameters:c,getValueEditorType:l,getValues:u,getValueSources:d,getSubQueryBuilderProps:f}=t,p=nt(e.field,i),m=p.inputType??a(e.field,e.operator,{fieldData:p}),h=o(e.field,{fieldData:p}),g=s(e.field,{fieldData:p}),_=V(g,e.operator),v=at(e,p,d),y=ot(c(e.field,e.operator,{fieldData:p}));return{fieldData:p,hideValueControls:it(_),inputType:m,matchModes:h,operatorObject:_,operators:g,parameters:y,validationResult:lt(e,p,n.validationMap,n.id),valueEditorType:st(e,p,y,l),values:ct(e,p,r,y,u),valueSourceOptions:v,valueSources:v.map(({value:e})=>e),subQueryBuilderProps:f?.(e.field,{fieldData:p})??{}}},dt=(e,t)=>I(e)?e.combinator:H(t)??``,ft=(e,t,n={})=>{let r=L(e),i=dt(e,t),a=V(t,i);return{combinator:i,combinatorObject:a,combinators:t,combinatorBasedClassName:r?null:a?.className??``,independentCombinators:r,validationResult:(n.validationMap??{})[n.id??e.id??``]??null}},U=(t,{parseNumbers:n,bigIntOnOverflow:r}={})=>{if(!n||typeof t==`bigint`||typeof t==`number`)return t;if(n===`native`)return Number.parseFloat(t);let i=(0,e.numericQuantity)(t,{allowTrailingInvalid:n===`enhanced`,bigIntOnOverflow:r,romanNumerals:!1,round:!1});return typeof i==`bigint`||!Number.isNaN(i)?i:t},pt=new Set([`between`,`notBetween`,`in`,`notIn`]),mt=e=>e===`between`||e===`notBetween`,ht=({skipHook:e,type:t,operator:n,value:r,inputType:i})=>!e&&t!==`multiselect`&&!pt.has(n)&&(Array.isArray(r)||i===`number`&&typeof r==`string`&&r.includes(`,`))?{reset:!0,value:j(r,{retainEmptyStrings:!0})[0]??``}:{reset:!1,value:r},gt=({value:e,index:t,valueAsArray:n,operator:r,values:i,listsAsArrays:a,parseNumberMethod:o})=>{let s=U(e,{parseNumbers:o}),c=t===0&&mt(r)&&(n.length<2||n[1]===void 0);if(n[t]===s&&!c)return a?n:ae(n,`,`);let l=[...n];return l[t]=s,c&&(l[1]=H(i)??``),a?l:ae(l,`,`)},_t=(e,t)=>{let n=U(e,{parseNumbers:t,bigIntOnOverflow:!0});try{return BigInt(n)}catch{return n}},vt=(e,t)=>e===`bigint`||t===`in`||t===`notIn`?`text`:e||`text`,yt=(e,{multiple:t,listsAsArrays:n}={})=>{if(!t)return e;let r=j(e);return n?r:ae(r,`,`)},bt=(e,t)=>t?j(e).map(String):e,xt=(e,t,n)=>{let r={};for(let i in e){if(ze(i))continue;let a=t[i];a!==!1&&(a&&i!==a?(ze(a)||(r[a]=e[i]),n||(r[i]=e[i])):r[i]=e[i])}return r};function W(e,t={}){let{ruleProcessor:n=e=>e,ruleGroupProcessor:r=e=>e,propertyMap:i={},combinatorMap:a={},operatorMap:o={},omitPath:s=!1,deleteRemappedProperties:c=!0}=t,l=e=>({...r(xt({...e,...I(e)?{combinator:a[e.combinator]??e.combinator}:{}},i,c)),...i.rules===!1?null:{[i.rules??`rules`]:e.rules.map((t,r)=>{let u=s?null:{path:[...e.path,r]};return typeof t==`string`?a[t]??t:F(t)?l({...t,...u}):n(xt({...t,...u,...`operator`in t?{operator:o[t.operator]??t.operator}:{}},i,c))})}});return l({...e,...s?null:{path:[]}})}const St=e=>N(e)&&typeof e.valid==`boolean`,G=(e,t,n)=>{if(e.muted)return!1;if(typeof t==`boolean`)return t;if(St(t))return t.valid;if(typeof n==`function`&&!F(e)){let t=n(e);if(typeof t==`boolean`)return t;if(St(t))return t.valid}return!0},Ct=({parseNumbers:e,inputType:t})=>{if(typeof e==`string`){let[n,r]=e.split(`-`);return r===`limited`?t===`number`&&n:n}return e?`strict`:!1},wt=e=>{switch(M(e)){case`null`:return`is null`;case`notnull`:return`is not null`;case`notin`:return`not in`;case`notbetween`:return`not between`;case`contains`:case`beginswith`:case`endswith`:return`like`;case`doesnotcontain`:case`doesnotbeginwith`:case`doesnotendwith`:return`not like`;default:return e}},Tt=(e=`||`)=>(...t)=>e.toUpperCase()===`CONCAT`?`CONCAT(${t.join(`, `)})`:t.join(` ${e} `),Et=e=>{switch(e){case`contains`:case`doesnotcontain`:return[`%`,`%`];case`beginswith`:case`doesnotbeginwith`:return[``,`%`];case`endswith`:case`doesnotendwith`:return[`%`,``];default:return[``,``]}},Dt=(e,t,{concatOperator:n=`||`,quoteValuesWith:r,wrapValueWith:i=[``,``]}={})=>{let[a,o]=Et(t),s=r||`'`,c=e=>`${i[0]}${s}${e}${s}${i[1]}`,l=[a&&c(a),e,o&&c(o)].filter(Boolean);return l.length>1?Tt(n)(...l):e},Ot={"=":`$eq`,"!=":`$ne`,"<":`$lt`,"<=":`$lte`,">":`$gt`,">=":`$gte`,in:`$in`,notin:`$nin`,notIn:`$nin`},kt={"=":`equals`,"!=":`not`,"<":`lt`,"<=":`lte`,">":`gt`,">=":`gte`,in:`in`,notin:`notIn`},At={and:`&&`,or:`||`},jt={startsWith:(e,t)=>typeof e==`string`&&e.startsWith(t),endsWith:(e,t)=>typeof e==`string`&&e.endsWith(t)},Mt=(e,t)=>({...e,rules:e.rules.map(e=>{if(typeof e==`string`)return e;if(F(e))return Mt(e,t);let n=V(t.fields,e.field),r=Ct({parseNumbers:t.parseNumbers,inputType:n?.inputType});if(Array.isArray(e.value))return{...e,value:e.value.map(e=>U(e,{parseNumbers:r}))};let i=j(e.value,{retainEmptyStrings:!0}).map(e=>U(e,{parseNumbers:r}));if(i.every(e=>typeof e==`number`)){if(i.length>1)return{...e,value:i};if(i.length===1)return{...e,value:i[0]}}return e})}),K=e=>typeof e==`string`&&e.length>0||typeof e==`number`&&!Number.isNaN(e)||typeof e!=`string`&&typeof e!=`number`,q=(e,t)=>!!t&&(typeof e==`number`||typeof e==`bigint`||typeof e==`string`&&le.test(e)),Nt=e=>e.length>=3,Pt=(e=[``,``])=>Array.isArray(e)?e:typeof e==`string`?[e,e]:e??[``,``],Ft=(e,{quoteFieldNamesWith:t,fieldIdentifierSeparator:n})=>{let[r,i]=Pt(t);return typeof n==`string`&&n.length>0?ae(ie(e,n).map(e=>`${r}${e}${i}`),n):`${r}${e}${i}`},It=[`S`,`V`,`O`],Lt=e=>{let t=[],n=new Set(It);for(let r of e.toUpperCase())if(n.has(r)&&(t.push(r),n.delete(r),n.size===0))break;for(let e of It)n.has(e)&&t.push(e);return t},Rt=(e,t=`:`)=>{let n=`${e??``}`;return t&&n.startsWith(t)?n:`${t}${n}`},zt=(e,t=`:`)=>{let n=`${e??``}`;return t&&n.startsWith(t)?n.slice(t.length):n},Bt={groupPrefix:``,groupPrefix_not_xor:`either zero or more than one of`,groupPrefix_xor:`exactly one of`,groupSuffix:`is true`,groupSuffix_not:`is not true`},Vt=(e,t,n)=>t.startsWith(e)&&n.every(e=>t.includes(`_${e}`)&&t.match(/_/g)?.length===n.length),Ht=(e,t,n=[])=>n.length===0?t[e]??Bt[e]??``:Object.entries(t).find(([t])=>Vt(e,t,n))?.[1]??Object.entries(Bt).find(([t])=>Vt(e,t,n))?.[1]??Bt[e]??``,J=e=>{let{mode:t,threshold:n}=e.match??{};if(!t)return null;if(!F(e.value))return!1;let r=M(t),i=r===`atleast`&&n===1?`some`:r===`atmost`&&n===0?`none`:r;return(i===`atleast`||i===`atmost`||i===`exactly`)&&(typeof n!=`number`||n<0)?!1:{mode:i,threshold:n}},Ut=`elem_alias`,Wt=(e=0)=>e>0?`${Ut}_${e}`:Ut,Gt=(e,t)=>typeof t==`bigint`?{$bigint:t.toString()}:t,Kt=(e,t)=>N(t)&&Object.keys(t).length===1&&typeof t.$bigint==`string`?BigInt(t.$bigint):t,qt=(e,t)=>{let{fields:n,fallbackExpression:r,getParseNumberBoolean:i,placeholderFieldName:a,placeholderOperatorName:o,placeholderValueName:s,ruleProcessor:c,validateRule:l,validationMap:u}=t,d=(e,f)=>{if(!G(e,u[e.id??``]))return f?r:``;let p=[],m=``,h=!0;for(let r of e.rules){if(typeof r==`string`){m=At[r];continue}if(F(r)){let e=d(r);e&&(!h&&m&&(p.push(m),m=``),h=!1,p.push(e));continue}let[e,u]=l(r);if(!G(r,e,u)||r.field===a||r.operator===o||s!==void 0&&r.value===s)continue;let f=V(n,r.field),g=c(r,{...t,parseNumbers:i(f?.inputType),escapeQuotes:(r.valueSource??`value`)===`value`,fieldData:f});g&&(!h&&m&&(p.push(m),m=``),h=!1,p.push(g))}let g=p.join(I(e)?` ${At[e.combinator]} `:` `),[_,v]=e.not||!f?[`${e.not?`!`:``}(`,`)`]:[``,``];return g?`${_}${g}${v}`:r};return d(e,!0)},Jt=e=>e.startsWith(`not`)||e.startsWith(`doesnot`),Yt=(e,t)=>typeof e!=`string`||!t?`${e}`:e.replaceAll(`"`,`\\"`),Xt=(e,t={})=>{let{escapeQuotes:n,parseNumbers:r,preserveValueOrder:i}=t,{field:a,operator:o,value:s,valueSource:c}=e,l=c===`field`||c===`parameter`,u=M(o===`=`?`==`:o),d=typeof s==`number`||typeof s==`boolean`||typeof s==`bigint`||q(s,r),f=J(e);if(f===!1)return``;if(f){let{mode:n,threshold:r}=f,i=t.subqueryDepth??0,o=Wt(i),s=W(e.value,{ruleProcessor:e=>({...e,field:`${o}${e.field?`.${e.field}`:``}`})}),c=qt(s,{...t,subqueryDepth:i+1});switch(n){case`all`:return`${a}.all(${o}, ${c})`;case`none`:case`some`:return`${n===`none`?`!`:``}${a}.exists(${o}, ${c})`;case`atleast`:case`atmost`:case`exactly`:{let e=`double(${a}.size())`,t=`${a}.filter(${o}, ${c}).size()`,i=n===`atleast`?`>=`:n===`atmost`?`<=`:`==`;return r>0&&r<1?`double(${t}) ${i} (${e} * ${r})`:`${t} ${i} ${r}`}}}switch(u){case`<`:case`<=`:case`==`:case`!=`:case`>`:case`>=`:return`${a} ${u} ${l||d?A(s):`"${Yt(s,n)}"`}`;case`contains`:case`doesnotcontain`:return`${Jt(u)?`!`:``}${a}.contains(${l?A(s):`"${Yt(s,n)}"`})`;case`beginswith`:case`doesnotbeginwith`:return`${Jt(u)?`!`:``}${a}.startsWith(${l?A(s):`"${Yt(s,n)}"`})`;case`endswith`:case`doesnotendwith`:return`${Jt(u)?`!`:``}${a}.endsWith(${l?A(s):`"${Yt(s,n)}"`})`;case`null`:return`${a} == null`;case`notnull`:return`${a} != null`;case`in`:case`notin`:{let[e,t]=Jt(u)?[`!(`,`)`]:[``,``];return`${e}${a} in [${j(s).map(e=>l||q(e,r)?`${A(e)}`:`"${Yt(e,n)}"`).join(`, `)}]${t}`}case`between`:case`notbetween`:{let e=j(s);if(e.length>=2&&!P(e[0])&&!P(e[1])){let[t,o]=e,s=r!==!1,c=q(t,s)?U(t,{parseNumbers:s}):NaN,d=q(o,s)?U(o,{parseNumbers:s}):NaN,f=Number.isNaN(c)?l?`${t}`:`"${Yt(t,n)}"`:c,p=Number.isNaN(d)?l?`${o}`:`"${Yt(o,n)}"`:d;if(!i&&f===c&&p===d&&d<c){let e=d;p=c,f=e}return u===`between`?`(${a} >= ${f} && ${a} <= ${p})`:`(${a} < ${f} || ${a} > ${p})`}return``}}return``},Zt={$and:[{$expr:!0}]},Qt=(e,t,n)=>{let{context:r,fields:i,getParseNumberBoolean:a,placeholderFieldName:o,placeholderOperatorName:s,placeholderValueName:c,ruleProcessor:l,validateRule:u,validationMap:d}=t,{inExpressionContext:f}=r??{},p=(e,r)=>{if(!G(e,d[e.id??``]))return r?Zt:!1;let m=`$${M(e.combinator)}`,h=!1,g=e.rules.map(e=>{if(F(e)){let t=p(e);return t?(h=!0,t):!1}let[r,d]=u(e);if(!G(e,r,d)||e.field===o||e.operator===s||c!==void 0&&e.value===c)return!1;let f=V(i,e.field);return l(e,{...t,parseNumbers:a(f?.inputType),fieldData:f},n)}).filter(Boolean),_=g.length>0?g.length===1&&!h?g[0]:{[m]:g}:Zt;return e.not?f?{$not:_}:{$nor:[_]}:_};return p(R(e),!0)},$t=(e,t,n=!1)=>q(e,n||typeof e==`bigint`)?Number(U(e,{parseNumbers:`strict`})):t,en=(e,t={})=>{let{field:n,operator:r,value:i,valueSource:a}=e,{parseNumbers:o,preserveValueOrder:s,context:c}=t,l=a===`field`,{avoidFieldsAsKeys:u}=c??{},d=J(e);if(d===!1)return;if(d){let{mode:e,threshold:r}=d,a={$size:{$ifNull:[`$${n}`,[]]}},o=Qt(W(i,{ruleProcessor:e=>({...e,field:e.field?`${n}.${e.field}`:n})}),{...t,ruleProcessor:en,context:{...t.context,avoidFieldsAsKeys:!1}}),s=Qt(W(i,{ruleProcessor:e=>({...e,field:e.field?`$item.${e.field}`:`$item`})}),{...t,ruleProcessor:en,context:{...t.context,avoidFieldsAsKeys:!0,inExpressionContext:!0}}),c={$size:{$ifNull:[{$filter:{input:`$${n}`,as:`item`,cond:{$and:[s]}}},[]]}};switch(e){case`all`:return{$expr:{$eq:[c,a]}};case`none`:return{$nor:[o]};case`some`:return o;case`atleast`:case`atmost`:case`exactly`:{let t=e===`atleast`?Ot[`>=`]:e===`atmost`?Ot[`<=`]:Ot[`=`];return r>0&&r<1?{$expr:{[t]:[c,{$multiply:[a,r]}]}}:{$expr:{[t]:[c,r]}}}}}if(r===`=`&&!l)return u?{$eq:[`$${n}`,$t(i,i,o)]}:{[n]:$t(i,i,o)};let f=M(r);switch(f){case`<`:case`<=`:case`=`:case`!=`:case`>`:case`>=`:{let e=Ot[f];return l?{[e]:[`$${n}`,`$${i}`]}:u?{$and:[{$ne:[`$${n}`,null]},{[e]:[`$${n}`,$t(i,i,o)]}]}:{[n]:{[e]:$t(i,i,o)}}}case`contains`:return l?{$where:`this.${n}.includes(this.${i})`}:u?{$regexMatch:{input:`$${n}`,regex:i}}:{[n]:{$regex:i}};case`beginswith`:return l?{$where:`this.${n}.startsWith(this.${i})`}:u?{$regexMatch:{input:`$${n}`,regex:`^${i}`}}:{[n]:{$regex:`^${i}`}};case`endswith`:return l?{$where:`this.${n}.endsWith(this.${i})`}:u?{$regexMatch:{input:`$${n}`,regex:`${i}$`}}:{[n]:{$regex:`${i}$`}};case`doesnotcontain`:return l?{$where:`!this.${n}.includes(this.${i})`}:u?{$not:{$regexMatch:{input:`$${n}`,regex:i}}}:{[n]:{$not:{$regex:i}}};case`doesnotbeginwith`:return l?{$where:`!this.${n}.startsWith(this.${i})`}:u?{$not:{$regexMatch:{input:`$${n}`,regex:`^${i}`}}}:{[n]:{$not:{$regex:`^${i}`}}};case`doesnotendwith`:return l?{$where:`!this.${n}.endsWith(this.${i})`}:u?{$not:{$regexMatch:{input:`$${n}`,regex:`${i}$`}}}:{[n]:{$not:{$regex:`${i}$`}}};case`null`:return u?{$eq:[`$${n}`,null]}:{[n]:null};case`notnull`:return u?{$ne:[`$${n}`,null]}:{[n]:{$ne:null}};case`in`:case`notin`:{let e=j(i);return l?{$where:`${f===`notin`?`!`:``}[${e.map(e=>`this.${e}`).join(`,`)}].includes(this.${n})`}:u?f===`notin`?{$not:{[Ot.in]:[`$${n}`,e.map(e=>$t(e,e,o))]}}:{[Ot[f]]:[`$${n}`,e.map(e=>$t(e,e,o))]}:{[n]:{[Ot[f]]:e.map(e=>$t(e,e,o))}}}case`between`:case`notbetween`:{let e=j(i);if(e.length>=2&&K(e[0])&&K(e[1])){let[t,r]=e,i=$t(t,NaN,!0),a=$t(r,NaN,!0),o=l||Number.isNaN(i)?t:i,c=l||Number.isNaN(a)?r:a;if(!s&&o===i&&c===a&&a<i){let e=a;c=i,o=e}return f===`between`?l?{$gte:[`$${n}`,`$${o}`],$lte:[`$${n}`,`$${c}`]}:u?{$and:[{$gte:[`$${n}`,o]},{$lte:[`$${n}`,c]}]}:{[n]:{$gte:o,$lte:c}}:l?{$or:[{$lt:[`$${n}`,`$${o}`]},{$gt:[`$${n}`,`$${c}`]}]}:u?{$or:[{$lt:[`$${n}`,o]},{$gt:[`$${n}`,c]}]}:{$or:[{[n]:{$lt:o}},{[n]:{$gt:c}}]}}return``}}return``},tn=(e,t)=>{let n=en(e,t);return n?JSON.stringify(n):``},nn=(e,t)=>{let{fields:n,fallbackExpression:r,getParseNumberBoolean:i,placeholderFieldName:a,placeholderOperatorName:o,placeholderValueName:s,ruleProcessor:c,validateRule:l,validationMap:u}=t,d=(e,f)=>{if(!G(e,u[e.id??``]))return f?r:``;let p=[],m=``,h=!0;for(let r of e.rules){if(typeof r==`string`){m=r;continue}if(F(r)){let e=d(r);e&&(!h&&m&&(p.push(m),m=``),h=!1,p.push(e));continue}let[e,u]=l(r);if(!G(r,e,u)||r.field===a||r.operator===o||s!==void 0&&r.value===s)continue;let f=V(n,r.field),g=c(r,{...t,parseNumbers:i(f?.inputType),escapeQuotes:(r.valueSource??`value`)===`value`,fieldData:f});g&&(!h&&m&&(p.push(m),m=``),h=!1,p.push(g))}let g=p.join(I(e)?` ${e.combinator} `:` `),[_,v]=e.not||!f?[`${e.not?`!`:``}(`,`)`]:[``,``];return g?`${_}${g}${v}`:r};return d(e,!0)},rn=e=>e.startsWith(`not`)||e.startsWith(`doesnot`),an=(e,t)=>t?`!(${e})`:e,on=(e,t)=>typeof e!=`string`||!t?`${e}`:e.replaceAll(`'`,`\\'`),sn=(e,t={})=>{let{field:n,operator:r,value:i,valueSource:a}=e,{escapeQuotes:o,parseNumbers:s,preserveValueOrder:c}=t,l=a===`field`||a===`parameter`,u=M(r===`=`?`==`:r),d=typeof i==`number`||typeof i==`boolean`||typeof i==`bigint`||q(i,s),f=J(e);if(f===!1)return``;if(f){let{mode:r,threshold:i}=f,a=nn(W(e.value,{ruleProcessor:e=>({...e,field:e.field||`#this`})}),t),o=`${n}.size()`,s=`${n}.?[${a}].size()`;switch(r){case`all`:return`${s} == ${o}`;case`none`:return`${s} == 0`;case`some`:return`${s} >= 1`;case`atleast`:case`atmost`:case`exactly`:{let e=r===`atleast`?`>=`:r===`atmost`?`<=`:`==`;return i>0&&i<1?`${s} ${e} (${o} * ${i})`:`${s} ${e} ${i}`}}}switch(u){case`<`:case`<=`:case`==`:case`!=`:case`>`:case`>=`:return`${n} ${u} ${l||d?A(i):`'${on(i,o)}'`}`;case`contains`:case`doesnotcontain`:{let e=l?`'.*'.concat(${A(i)}).concat('.*')`:`'.*${on(i,o)}.*'`;return an(`${n} matches ${e}`,rn(u))}case`beginswith`:case`doesnotbeginwith`:{let e=l?`'^'.concat(${A(i)}).concat('.*')`:`'${typeof i==`string`&&!i.startsWith(`^`)||d?`^`:``}${on(i,o)}.*'`;return an(`${n} matches ${e}`,rn(u))}case`endswith`:case`doesnotendwith`:{let e=l?`'.*'.concat(${A(i)}).concat('$')`:`'.*${on(i,o)}${typeof i==`string`&&!i.endsWith(`$`)||d?`$`:``}'`;return an(`${n} matches ${e}`,rn(u))}case`null`:return`${n} == null`;case`notnull`:return`${n} != null`;case`in`:case`notin`:{let e=rn(u)?`!`:``,t=j(i);return t.length>0?`${e}(${t.map(e=>`${n} == ${l||q(e,s)?`${A(e)}`:`'${on(e,o)}'`}`).join(` or `)})`:``}case`between`:case`notbetween`:{let e=j(i);if(e.length>=2&&!P(e[0])&&!P(e[1])){let[t,r]=e,i=s!==!1,a=q(t,i)?U(t,{parseNumbers:i}):NaN,d=q(r,i)?U(r,{parseNumbers:i}):NaN,f=Number.isNaN(a)?l?`${t}`:`'${on(t,o)}'`:a,p=Number.isNaN(d)?l?`${r}`:`'${on(r,o)}'`:d;if(!c&&f===a&&p===d&&d<a){let e=d;p=a,f=e}return u===`between`?`(${n} >= ${f} and ${n} <= ${p})`:`(${n} < ${f} or ${n} > ${p})`}return``}}return``},cn=(e,t,n)=>n&&typeof e==`string`?e.replaceAll(`${t}`,`${t}${t}`):e,ln=({operator:e,value:t,valueSource:n},{escapeQuotes:r,parseNumbers:i,preserveValueOrder:a,quoteFieldNamesWith:o,quoteValuesWith:s,concatOperator:c=`||`,fieldIdentifierSeparator:l,paramPrefix:u,wrapValueWith:d=[``,``],translations:f}={})=>{if(n===`parameter`){let n=M(e);if(n===`between`||n===`notbetween`){let e=j(t,{retainEmptyStrings:!0});if(e.length<2||!K(e[0])||!K(e[1]))return``;let[n,r]=e;return[Rt(n,u),Rt(r,u)].join(` ${f?.betweenAnd??f?.and??`and`} `)}if(n===`in`||n===`notin`){let e=j(t);return e.length===0?``:`(${e.map(e=>Rt(e,u)).join(`, `)})`}let r=Rt(t,u);switch(n){case`contains`:case`doesnotcontain`:case`beginswith`:case`doesnotbeginwith`:case`endswith`:case`doesnotendwith`:return Dt(r,n,{concatOperator:c,quoteValuesWith:s,wrapValueWith:d})}return r}let p=n===`field`,m=M(e),h=s||`'`,g=e=>`${d[0]}${h}${e}${h}${d[1]}`,_=e=>cn(e,h,r),v=e=>g(_(e)),y=e=>Ft(e,{quoteFieldNamesWith:o,fieldIdentifierSeparator:l}),b={concatOperator:c,quoteValuesWith:s,wrapValueWith:d};switch(m){case`null`:case`notnull`:return``;case`in`:case`notin`:{let e=j(t);return e.length>0?`(${e.map(e=>p?y(e):q(e,i)?`${A(e)}`:`${v(e)}`).join(`, `)})`:``}case`between`:case`notbetween`:{let e=j(t,{retainEmptyStrings:!0});if(e.length<2||!K(e[0])||!K(e[1]))return``;let[n,r]=e,o=q(n,i)?U(n,{parseNumbers:`strict`}):NaN,s=q(r,i)?U(r,{parseNumbers:`strict`}):NaN,c=Number.isNaN(o)?p?`${n}`:n:o,l=Number.isNaN(s)?p?`${r}`:r:s,u=[c,l];return!a&&c===o&&l===s&&s<o&&(u[0]=s,u[1]=o),(p?u.map(e=>y(e)):u.every(e=>q(e,i))?u.map(e=>U(e,{parseNumbers:`strict`})):u.map(e=>v(e))).join(` ${f?.betweenAnd??f?.and??`and`} `)}case`contains`:case`doesnotcontain`:return p?Dt(y(t),m,b):g(`%${_(t)}%`);case`beginswith`:case`doesnotbeginwith`:return p?Dt(y(t),m,b):g(`${_(t)}%`);case`endswith`:case`doesnotendwith`:return p?Dt(y(t),m,b):g(`%${_(t)}`)}return typeof t==`boolean`?t?`TRUE`:`FALSE`:p?y(t):q(t,i)?`${A(t)}`:`${v(t)}`},un={and:`AND`,or:`OR`},dn=(e,t)=>{let{fields:n,fallbackExpression:r,getParseNumberBoolean:i,placeholderFieldName:a,placeholderOperatorName:o,placeholderValueName:s,ruleProcessor:c,validateRule:l,validationMap:u}=t,d=(e,f)=>{if(!G(e,u[e.id??``]))return f?r:``;let p=[],m=``,h=!0;for(let r of e.rules){if(typeof r==`string`){m=un[r];continue}if(F(r)){let e=d(r);e&&(!h&&m&&(p.push(m),m=``),h=!1,p.push(e));continue}let[e,u]=l(r);if(!G(r,e,u)||r.field===a||r.operator===o||s!==void 0&&r.value===s)continue;let f=V(n,r.field),g=c(r,{...t,parseNumbers:i(f?.inputType),escapeQuotes:(r.valueSource??`value`)===`value`,fieldData:f});g&&(!h&&m&&(p.push(m),m=``),h=!1,p.push(g))}let g=p.join(I(e)?` ${un[e.combinator]} `:` `),[_,v]=e.not||!f?[`${e.not?`NOT `:``}(`,`)`]:[``,``];return g?`${_}${g}${v}`:r};return d(e,!0)},fn=(e,t,n)=>((n,r)=>{let{fields:i,getParseNumberBoolean:a,placeholderFieldName:o,placeholderOperatorName:s,placeholderValueName:c,validateRule:l,validationMap:u,ruleProcessor:d}=t;if(!n||!r)return;let{and:f,not:p,or:m}=r,h=(e,g)=>{if(!G(e,u[e.id??``]))return;let _=e.rules.map(e=>{if(F(e))return h(e);let[u,f]=l(e);if(!G(e,u,f)||e.field===o||e.operator===s||c!==void 0&&e.value===c)return;let p=V(i,e.field);return d(e,{...t,parseNumbers:a(p?.inputType),fieldData:p,context:{...t.context,columns:n,drizzleOperators:r}})}).filter(Boolean);if(_.length===0)return;let v=e.combinator===`or`?m(..._):f(..._);return e.not?p(v):v};return h(R(e),!0)}),pn=(e,t)=>{let{fields:n,getParseNumberBoolean:r,placeholderFieldName:i,placeholderOperatorName:a,placeholderValueName:o,ruleProcessor:s,validateRule:c,validationMap:l}=t,u=e=>{if(!G(e,l[e.id??``]))return!1;let d=e.rules.map(e=>{if(F(e))return u(e);let[l,d]=c(e);if(!G(e,l,d)||e.field===i||e.operator===a||o!==void 0&&e.value===o)return!1;let f=V(n,e.field);return s(e,{...t,parseNumbers:r(f?.inputType),fieldData:f})}).filter(Boolean);return d.length!==0&&{bool:e.not?{must_not:/^or$/i.test(e.combinator)?{bool:{should:d}}:d}:{[/^or$/i.test(e.combinator)?`should`:`must`]:d}}},d=u(R(e));return d===!1?{}:d},mn=(e,t)=>{let{fields:n,fallbackExpression:r,getParseNumberBoolean:i,placeholderFieldName:a,placeholderOperatorName:o,placeholderValueName:s,ruleProcessor:c,validateRule:l,validationMap:u}=t,d=e=>{if(typeof e==`string`||F(e))return;let[r,u]=l(e);if(!G(e,r,u)||e.field===a||e.operator===o||s!==void 0&&e.value===s)return;let d=V(n,e.field);return c(e,{...t,parseNumbers:i(d?.inputType),escapeQuotes:(e.valueSource??`value`)===`value`,fieldData:d})},f=e=>{if(!G(e,u[e.id??``]))return``;let t=[];for(let n of e.rules){if(typeof n==`string`)continue;if(F(n)){let e=f(n);e&&t.push(e);continue}let e=d(n);e&&t.push(e)}if(t.length===0)return``;let n=e.combinator??`and`,r=e.not?`not`:n;return t.length===1&&!e.not?t[0]:`.${r}(${t.map(e=>e.startsWith(`.`)?`__${e}`:e).join(`, `)})`};if(!G(e,u[e.id??``]))return r;let p=[];for(let t of e.rules){if(typeof t==`string`)continue;if(F(t)){let e=f(t);e&&p.push(e);continue}let e=d(t);e&&p.push(e)}return p.length===0?r:p.join(``)},hn=(e,t)=>{let{fields:n,fallbackExpression:r,getParseNumberBoolean:i,placeholderFieldName:a,placeholderOperatorName:o,placeholderValueName:s,ruleProcessor:c,validateRule:l,validationMap:u}=t,d=(e,f)=>{if(!G(e,u[e.id??``]))return f?r:``;let p=[],m=``,h=!0;for(let r of e.rules){if(typeof r==`string`){m=r;continue}if(F(r)){let e=d(r);e&&(!h&&m&&(p.push(m),m=``),h=!1,p.push(e));continue}let[e,u]=l(r);if(!G(r,e,u)||r.field===a||r.operator===o||s!==void 0&&r.value===s)continue;let f=V(n,r.field),g=c(r,{...t,parseNumbers:i(f?.inputType),escapeQuotes:(r.valueSource??`value`)===`value`,fieldData:f});g&&(!h&&m&&(p.push(m),m=``),h=!1,p.push(g))}let g=p.join(I(e)?` ${e.combinator} `:` `),[_,v]=e.not||!f?[`${e.not?`$not`:``}(`,`)`]:[``,``];return g?`${_}${g}${v}`:r};return d(e,!0)},gn=(e,t)=>{let{fields:n,getParseNumberBoolean:r,placeholderFieldName:i,placeholderOperatorName:a,placeholderValueName:o,ruleProcessor:s,validateRule:c,validationMap:l}=t,u=R(e),d=(e,u)=>{if(!G(e,l[e.id??``]))return!1;let f=e.rules.map(e=>{if(F(e))return d(e);let[l,u]=c(e);if(!G(e,l,u)||e.field===i||e.operator===a||o!==void 0&&e.value===o)return!1;let f=V(n,e.field);return s(e,{...t,parseNumbers:r(f?.inputType),fieldData:f})}).filter(Boolean);if(f.length===0)return!1;let p={[e.combinator]:f};return e.not?{"!":p}:p};return d(u,!0)},_n=(e,t)=>{let{fields:n,fallbackExpression:r,getParseNumberBoolean:i,placeholderFieldName:a,placeholderOperatorName:o,placeholderValueName:s,ruleProcessor:c,validateRule:l,validationMap:u}=t,d=(e,f)=>{if(!G(e,u[e.id??``]))return f?r:``;let p=e.rules.map(e=>{if(F(e))return d(e);let[r,u]=l(e);if(!G(e,r,u)||e.field===a||e.operator===o||s!==void 0&&e.value===s)return``;let f=V(n,e.field);return c(e,{...t,parseNumbers:i(f?.inputType),escapeQuotes:(e.valueSource??`value`)===`value`,fieldData:f})}).filter(Boolean),m=p.join(``),[h,g]=e.not?[`(!`,`)`]:[``,``],[_,v]=p.length>1?[`${h}(${e.combinator===`or`?`|`:`&`}`,`)${g}`]:[h,g];return m?`${_}${m}${v}`:r};return d(R(e),!0)},vn=e=>e.startsWith(`{`)&&e.endsWith(`}`),yn=(e,t,n)=>{let{fields:r,fallbackExpression:i,getParseNumberBoolean:a,placeholderFieldName:o,placeholderOperatorName:s,placeholderValueName:c,ruleProcessor:l,validateRule:u,validationMap:d}=t,f=(e,p)=>{if(!G(e,d[e.id??``]))return p?i:``;let m=`"$${M(e.combinator)}"`,h=!1,g=e.rules.map(e=>{if(F(e)){let t=f(e);return t?(h=!0,vn(t)?t:`{${t}}`):``}let[i,d]=u(e);if(!G(e,i,d)||e.field===o||e.operator===s||c!==void 0&&e.value===c)return``;let p=V(r,e.field);return l(e,{...t,parseNumbers:a(p?.inputType),fieldData:p},n)}).filter(Boolean),_=g.length>0?g.length===1&&!h?g[0]:`${m}:[${g.join(`,`)}]`:i;return e.not?`"$nor":[${vn(_)?_:`{${_}}`}]`:_},p=f(R(e),!0);return vn(p)?p:`{${p}}`},bn=(e,t)=>{let{fields:n,fallbackExpression:r,getParseNumberBoolean:i,placeholderFieldName:a,placeholderOperatorName:o,placeholderValueName:s,ruleProcessor:c,translations:l,validateRule:u,validationMap:d}=t,f=(e,p)=>{if(!G(e,d[e.id??``]))return p?r:``;let m=L(e)&&e.rules.some(e=>typeof e==`string`&&M(e)===`xor`)?R(e):e,h=[],g=``,_=!0;for(let e of m.rules){if(typeof e==`string`){g=`${l.ruleSeparator??`, `}${l[e]??e} `;continue}if(F(e)){let t=f(e,m.rules.length===1&&!(m.not||/^xor$/i.test(m.combinator??``)));t&&(!_&&g&&(h.push(g),g=``),_=!1,h.push(t));continue}let[r,d]=u(e);if(!G(e,r,d)||e.field===a||e.operator===o||s!==void 0&&e.value===s)continue;let p=(e.valueSource??`value`)===`value`,v=V(n,e.field),y=c(e,{...t,parseNumbers:i(v?.inputType),escapeQuotes:p,fieldData:v});y&&(!_&&g&&(h.push(g),g=``),_=!1,h.push(y))}if(h.length===0)return r;let v=M(m.combinator??``)===`xor`,y=v?m.combinator.slice(1):m.combinator,b=m.not||!p||v&&h.length>1,[x,S]=[`groupPrefix`,`groupSuffix`].map(e=>m.not?v?Ht(e,l,[`not`,`xor`]):Ht(e,l,[`not`]):v?Ht(e,l,[`xor`]):Ht(e,l)),C=b?`${x} (`.trim():``,w=b?`) ${S}`.trim():``,T=l.ruleSeparator??`, `;return`${C}${h.join(I(m)?`${T}${l[y]??y} `:``)}${w}`};return f(e,!0)},xn=(e,t)=>{let{format:n,fields:r,fallbackExpression:i,getParseNumberBoolean:a,placeholderFieldName:o,placeholderOperatorName:s,placeholderValueName:c,ruleProcessor:l,validateRule:u,validationMap:d}=t,f=n===`parameterized`,p=[],m={},h=new Map,g=e=>{h.has(e)||h.set(e,new Set);let t=`${e}_${h.get(e).size+1}`;return h.get(e).add(t),t},_=e=>{let[i,d]=u(e);if(!G(e,i,d)||e.field===o||e.operator===s||c!==void 0&&e.value===c)return``;let f=V(r,e.field),_=Object.fromEntries([...h.entries()].map(([e,t])=>[e,[...t]])),v=l(e,{...t,parseNumbers:a(f?.inputType),getNextNamedParam:g,fieldParamNames:_,fieldData:f},{processedParams:p});if(!N(v))return``;let{sql:y,params:b}=v;if(typeof y!=`string`||!y)return``;if(n===`parameterized`&&Array.isArray(b))p.push(...b);else if(n===`parameterized_named`&&N(b)){Object.assign(m,b);for(let t of Object.keys(b))h.get(e.field)?.add(t)}return y},v=(e,t)=>{if(!G(e,d[e.id??``]))return t?i:``;let n=[],r=``,a=!0;for(let t of e.rules){if(typeof t==`string`){r=t;continue}if(F(t)){let i=v(t,e.rules.length===1);i&&(!a&&r&&(n.push(r),r=``),a=!1,n.push(i));continue}let i=_(t);i&&(!a&&r&&(n.push(r),r=``),a=!1,n.push(i))}return n.length===0?i:`${e.not?`NOT `:``}(${n.join(I(e)?` ${e.combinator} `:` `)})`};return f?{sql:v(e,!0),params:p}:{sql:v(e,!0),params:m}},Sn={},Cn=(e,t)=>{let{fields:n,getParseNumberBoolean:r,placeholderFieldName:i,placeholderOperatorName:a,placeholderValueName:o,ruleProcessor:s,validateRule:c,validationMap:l}=t,u=(e,d)=>{if(!G(e,l[e.id??``]))return d?Sn:void 0;let f=e.combinator.toUpperCase(),p=!1,m=e.rules.map(e=>{if(F(e)){let t=u(e);return t?(p=!0,t):void 0}let[l,d]=c(e);if(!G(e,l,d)||e.field===i||e.operator===a||o!==void 0&&e.value===o)return;let f=V(n,e.field);return s(e,{...t,parseNumbers:r(f?.inputType),fieldData:f})}).filter(Boolean);return m.length>0?m.length===1&&!p?m[0]:{[f]:m}:Sn},d=u(R(e),!0);return e.not?{NOT:d}:d},wn=(e,t)=>{let{fields:n,getParseNumberBoolean:r,placeholderFieldName:i,placeholderOperatorName:a,placeholderValueName:o,ruleProcessor:s,validateRule:c,validationMap:l,context:u={}}=t,{sequelizeOperators:d}=u;if(!d)return;let f=(e,u)=>{if(!G(e,l[e.id??``]))return;let p=e.combinator.toUpperCase(),m=!1,h=e.rules.map(e=>{if(F(e)){let t=f(e);return t?(m=!0,t):void 0}let[l,u]=c(e);if(!G(e,l,u)||e.field===i||e.operator===a||o!==void 0&&e.value===o)return;let d=V(n,e.field);return s(e,{...t,parseNumbers:r(d?.inputType),fieldData:d})}).filter(Boolean);if(h.length===0)return;let g=h.length===1&&!m?h[0]:{[M(p)===`or`?d.or:d.and]:h};return e.not?{[d.not]:g}:g};return f(R(e),!0)},Tn=(e,t)=>{let{fields:n,fallbackExpression:r,getParseNumberBoolean:i,placeholderFieldName:a,placeholderOperatorName:o,placeholderValueName:s,ruleProcessor:c,validateRule:l,validationMap:u}=t,d=(e,f)=>{if(!G(e,u[e.id??``]))return f?r:``;let p=[],m=``,h=!0;for(let r of e.rules){if(typeof r==`string`){m=At[r];continue}if(F(r)){let e=d(r);e&&(!h&&m&&(p.push(m),m=``),h=!1,p.push(e));continue}let[e,u]=l(r);if(!G(r,e,u)||r.field===a||r.operator===o||s!==void 0&&r.value===s)continue;let f=V(n,r.field),g=c(r,{...t,parseNumbers:i(f?.inputType),escapeQuotes:(r.valueSource??`value`)===`value`,fieldData:f});g&&(!h&&m&&(p.push(m),m=``),h=!1,p.push(g))}let g=p.join(I(e)?` ${At[e.combinator]} `:` `),[_,v]=e.not||!f?[`${e.not?`!`:``}(`,`)`]:[``,``];return g?`${_}${g}${v}`:r};return d(e,!0)},En=(e,t)=>{let{fields:n,fallbackExpression:r,getParseNumberBoolean:i,placeholderFieldName:a,placeholderOperatorName:o,placeholderValueName:s,ruleProcessor:c,validateRule:l,validationMap:u}=t,d=(e,f)=>{if(!G(e,u[e.id??``]))return f?r:``;let p=[],m=``,h=!0;for(let r of e.rules){if(typeof r==`string`){m=r;continue}if(F(r)){let t=d(r,e.rules.length===1);t&&(!h&&m&&(p.push(m),m=``),h=!1,p.push(t));continue}let[u,f]=l(r);if(!G(r,u,f)||r.field===a||r.operator===o||s!==void 0&&r.value===s)continue;let g=(r.valueSource??`value`)===`value`,_=V(n,r.field),v=c(r,{...t,parseNumbers:i(_?.inputType),escapeQuotes:g,fieldData:_});v&&(!h&&m&&(p.push(m),m=``),h=!1,p.push(v))}return p.length===0?r:`${e.not?`NOT `:``}(${p.join(I(e)?` ${e.combinator} `:` `)})`};return d(e,!0)},Dn=(e,t)=>n=>{let{fields:r,getParseNumberBoolean:i,placeholderFieldName:a,placeholderOperatorName:o,placeholderValueName:s,validateRule:c,validationMap:l,context:u={},ruleProcessor:d}=t,f=u.tanStackDbOperators;if(!f)return;let{and:p,eq:m,not:h,or:g}=f,_=m(1,1),v=Object.keys(n);if(v.length===0)return _;let y=e=>{if(!G(e,l[e.id??``]))return;let f=e.rules.map(e=>{if(F(e))return y(e);let[l,f]=c(e);if(!G(e,l,f)||e.field===a||e.operator===o||s!==void 0&&e.value===s)return;let p=V(r,e.field);return d(e,{...t,parseNumbers:i(p?.inputType),fieldData:p,context:{...u,_tanstackDbRefs:n,_tanstackDbPrimaryRef:v[0]}})}).filter(Boolean);if(f.length===0)return _;let m=f.length===1?f[0]:e.combinator===`or`?g(...f):p(...f);return e.not?h(m):m};return y(R(e))??_},On=new Set([`number`,`range`,`bigint`]),kn=/^\d{4}-\d{2}-\d{2}$/,An=/^\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/,jn=/^\d{4}-\d{2}$/,Mn=/^\d{4}-W\d{2}$/,Nn=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i,Pn=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Fn=(e,t,n)=>{let r=new Date(Date.UTC(e,t-1,n));return r.getUTCFullYear()===e&&r.getUTCMonth()===t-1&&r.getUTCDate()===n},In=e=>{let t=e.split(`:`),n=Number(t[0]),r=Number(t[1]),i=t[2]?Number.parseFloat(t[2]):0;return n>=0&&n<=23&&r>=0&&r<=59&&i>=0&&i<60},Ln=(e,t)=>{if(e!=null&&e!==``){if(On.has(t)){let t=typeof e==`string`?e.trim():e;return typeof t==`number`||typeof t==`bigint`||typeof t==`string`&&le.test(t)?void 0:`VALUE_TYPE_MISMATCH`}if(t===`date`){if(typeof e!=`string`)return`VALUE_TYPE_MISMATCH`;let t=e.trim();if(!kn.test(t))return`VALUE_TYPE_MISMATCH`;let[n,r,i]=t.split(`-`).map(Number);return Fn(n,r,i)?void 0:`VALUE_TYPE_MISMATCH`}if(t===`datetime-local`){if(typeof e!=`string`)return`VALUE_TYPE_MISMATCH`;let t=e.trim().replace(/(Z|[+-]\d{2}:?\d{2}|[+-]\d{2})$/,``),n=t.indexOf(`T`);if(n===-1)return`VALUE_TYPE_MISMATCH`;let r=t.slice(0,n),i=t.slice(n+1);if(!kn.test(r)||!An.test(i))return`VALUE_TYPE_MISMATCH`;let[a,o,s]=r.split(`-`).map(Number);return Fn(a,o,s)&&In(i)?void 0:`VALUE_TYPE_MISMATCH`}if(t===`time`){if(typeof e!=`string`)return`VALUE_TYPE_MISMATCH`;let t=e.trim();return An.test(t)&&In(t)?void 0:`VALUE_TYPE_MISMATCH`}if(t===`month`){if(typeof e!=`string`)return`VALUE_TYPE_MISMATCH`;let t=e.trim();if(!jn.test(t))return`VALUE_TYPE_MISMATCH`;let n=Number(t.slice(5));return n>=1&&n<=12?void 0:`VALUE_TYPE_MISMATCH`}if(t===`week`){if(typeof e!=`string`)return`VALUE_TYPE_MISMATCH`;let t=e.trim();if(!Mn.test(t))return`VALUE_TYPE_MISMATCH`;let n=Number(t.slice(6));return n>=1&&n<=53?void 0:`VALUE_TYPE_MISMATCH`}if(t===`color`)return typeof e==`string`&&Nn.test(e.trim())?void 0:`VALUE_TYPE_MISMATCH`;if(t===`url`){if(typeof e!=`string`)return`VALUE_TYPE_MISMATCH`;try{new URL(e.trim());return}catch{return`VALUE_TYPE_MISMATCH`}}if(t===`email`)return typeof e==`string`&&Pn.test(e.trim())?void 0:`VALUE_TYPE_MISMATCH`}},Rn=(e,t)=>{let{fields:n,placeholderFieldName:r,placeholderOperatorName:i,placeholderValueName:a,validateRule:o,validationMap:s}=t,c=[],l={totalRules:0,totalGroups:0,validRules:0,invalidRules:0,validGroups:0,invalidGroups:0},u={},d=Xe(n),f=new Map;for(let e of d)f.set(e.name,e);let p=f.size>0,m=(e,t)=>{l.totalGroups++;let n=t.length,d=s[e.id??``],h=G(e,d),g=Bn(d);e.muted?c.push({id:e.id??``,path:t,code:`MUTED`,message:`Group is muted`,source:`muted`}):!h&&d!==void 0&&c.push({id:e.id??``,path:t,code:`CUSTOM_VALIDATOR`,message:g?`Invalid: ${g.join(`, `)}`:`Group failed validation`,source:`query-validator`});let _=!0,v=0,y=[];for(let n of e.rules){if(typeof n==`string`){y.push(n),v++;continue}let e=[...t,v];if(F(n)){let t=m(n,e);t.valid||(_=!1),y.push(t),v++;continue}l.totalRules++;let s=e.length,[d,h]=o(n),g=G(n,d,h)&&n.field!==r&&n.operator!==i&&(a===void 0||n.value!==a);zn(n,e,d,h,g,c,r,i,a,p,f),g?l.validRules++:(_=!1,l.invalidRules++);let b=n.field;u[b]||(u[b]={ruleCount:0,invalidCount:0}),u[b].ruleCount++,g||u[b].invalidCount++;let x=Bn(d)??Vn(n,h),S={...n,valid:g,...x?{reasons:x}:null,path:e,level:s};y.push(S),v++}let b=h&&_;return b?l.validGroups++:l.invalidGroups++,I(e),{...e,valid:b,...g?{reasons:g}:null,path:t,level:n,rules:y}},h=m(e,[]);if(p){let e=new Set(Object.keys(u));for(let[t]of f)e.has(t)||c.push({id:``,path:[],code:`UNREFERENCED_FIELD`,message:`Field "${t}" is defined in the fields config but not used in the query`,source:`field-check`})}return{query:h,diagnostics:c,stats:l,fieldSummary:u}},zn=(e,t,n,r,i,a,o,s,c,l,u)=>{let d=e.id??``;if(e.muted&&a.push({id:d,path:t,code:`MUTED`,message:`Rule is muted`,source:`muted`}),e.field===o&&a.push({id:d,path:t,code:`PLACEHOLDER_FIELD`,message:`Rule has a placeholder field`,source:`placeholder`}),e.operator===s&&a.push({id:d,path:t,code:`PLACEHOLDER_OPERATOR`,message:`Rule has a placeholder operator`,source:`placeholder`}),c!==void 0&&e.value===c&&a.push({id:d,path:t,code:`PLACEHOLDER_VALUE`,message:`Rule has a placeholder value`,source:`placeholder`}),!e.muted&&e.field!==o&&e.operator!==s&&(c===void 0||e.value!==c)){if(typeof n==`boolean`&&!n)a.push({id:d,path:t,code:`CUSTOM_VALIDATOR`,message:`Rule failed validation`,source:`query-validator`});else if(typeof n!=`boolean`&&St(n)&&!n.valid){let e=n.reasons;a.push({id:d,path:t,code:`CUSTOM_VALIDATOR`,message:e?`Invalid: ${e.join(`, `)}`:`Rule failed validation`,source:`query-validator`})}else if(!i&&typeof r==`function`){let n=r(e),i=typeof n!=`boolean`&&St(n)&&!n.valid?n.reasons:void 0;a.push({id:d,path:t,code:`CUSTOM_VALIDATOR`,message:i?`Invalid: ${i.join(`, `)}`:`Rule failed field validation`,source:`field-validator`})}}if(l&&!u.has(e.field)&&e.field!==o&&a.push({id:d,path:t,code:`UNDEFINED_FIELD`,message:`Field "${e.field}" is not defined in the fields config`,source:`field-check`}),l){let n=u.get(e.field);if(n?.inputType){let r=Ln(e.value,n.inputType);r&&a.push({id:d,path:t,code:r,message:`Value "${e.value}" is not compatible with input type "${n.inputType}"`,source:`type-check`})}}},Bn=e=>{if(typeof e!=`boolean`&&St(e)&&!e.valid&&e.reasons)return e.reasons},Vn=(e,t)=>{if(typeof t==`function`){let n=t(e);if(typeof n!=`boolean`&&St(n)&&!n.valid&&n.reasons)return n.reasons}},Hn=(e,t)=>typeof e!=`string`||!t?`${e}`:e.replaceAll(`'`,`\\'`),Un=(e,t={})=>{let{escapeQuotes:n,parseNumbers:r}=t,{field:i,operator:a,value:o,valueSource:s}=e,c=s===`field`,l=a.toLowerCase(),u=e=>e==null?`null`:typeof e==`boolean`||typeof e==`bigint`?String(e):c||typeof e==`number`||q(e,r)?A(e):`'${Hn(e,n)}'`;switch(l){case`=`:return`${i} = ${u(o)}`;case`!=`:case`<>`:return`${i} <> ${u(o)}`;case`<`:case`>`:case`<=`:case`>=`:return`${i} ${l} ${u(o)}`;case`contains`:return`${i} CONTAINS ${u(o)}`;case`doesnotcontain`:return`NOT ${i} CONTAINS ${u(o)}`;case`beginswith`:return`${i} STARTS WITH ${u(o)}`;case`doesnotbeginwith`:return`NOT ${i} STARTS WITH ${u(o)}`;case`endswith`:return`${i} ENDS WITH ${u(o)}`;case`doesnotendwith`:return`NOT ${i} ENDS WITH ${u(o)}`;case`null`:return`${i} IS NULL`;case`notnull`:return`${i} IS NOT NULL`;case`in`:case`notin`:{let e=j(o).map(u);return e.length?`${l===`notin`?`NOT `:``}${i} IN [${e.join(`, `)}]`:``}case`between`:case`notbetween`:{let e=j(o);if(e.length<2)return``;let[t,n]=[u(e[0]),u(e[1])],r=`${t} <= ${i} AND ${i} <= ${n}`;return l===`notbetween`?`NOT (${r})`:r}default:return`${i} ${a} ${u(o)}`}},Wn=(e,t)=>{let n=t??{},{parseNumbers:r,preserveValueOrder:i,context:a={}}=n,{columns:o,drizzleOperators:s,useRawFields:c}=a;if(!o||!s)return;let{between:l,eq:u,gt:d,gte:f,inArray:p,isNotNull:m,isNull:h,like:g,lt:_,lte:v,ne:y,notBetween:b,notInArray:x,notLike:S,sql:C}=s,{field:w,operator:T,value:E,valueSource:D}=e,O=c&&/^[a-z_][a-z0-9_.]*$/i.test(w)?C.raw(w):o[w],k=M(T),ee=D===`field`,te=e=>ee?o[e]:e,ne=e=>ee||!r?te(e):q(e,!0)?U(e,{parseNumbers:!0}):e;if(!O)return;let re=J(e);if(re!==!1){if(re){if(n.preset!==`postgresql`)return;let{mode:t,threshold:r}=re,i=n.subqueryDepth??0,a=Wt(i),o=W(e.value,{ruleProcessor:e=>({...e,field:a})}),c=fn(o,{...n,context:{...n.context,useRawFields:!0},subqueryDepth:i+1});switch(t){case`all`:return C`(select count(*) from unnest(${O}) as ${C.raw(a)} where ${c({},s)}) = array_length(${O}, 1)`;case`none`:return C`not exists (select 1 from unnest(${O}) as ${C.raw(a)} where ${c({},s)})`;case`some`:return C`exists (select 1 from unnest(${O}) as ${C.raw(a)} where ${c({},s)})`;case`atleast`:case`atmost`:case`exactly`:{let e=t===`atleast`?`>=`:t===`atmost`?`<=`:`=`;return r>0&&r<1?C`(select count(*)::float / array_length(${O}, 1) from unnest(${O}) as ${C.raw(a)} where ${c({},s)}) ${C.raw(`${e} ${r}`)}`:C`(select count(*) from unnest(${O}) as ${C.raw(a)} where ${c({},s)}) ${C.raw(`${e} ${r}`)}`}}}switch(k){case`=`:return u(O,ne(E));case`!=`:return y(O,ne(E));case`>`:return d(O,ne(E));case`<`:return _(O,ne(E));case`>=`:return f(O,ne(E));case`<=`:return v(O,ne(E));case`beginswith`:case`doesnotbeginwith`:return(k===`doesnotbeginwith`?S:g)(O,ee?C`${te(E)} || '%'`:`${E}%`);case`contains`:case`doesnotcontain`:return(k===`doesnotcontain`?S:g)(O,ee?C`'%' || ${te(E)} || '%'`:`%${E}%`);case`endswith`:case`doesnotendwith`:return(k===`doesnotendwith`?S:g)(O,ee?C`'%' || ${te(E)}`:`%${E}`);case`null`:return h(O);case`notnull`:return m(O);case`in`:case`notin`:{let e=j(E).map(e=>ne(e));return k===`notin`?x(O,e):p(O,e)}case`between`:case`notbetween`:{let e=j(E);if(e.length>=2&&K(e[0])&&K(e[1])){let[t,n]=e,a=r!==!1;if(!ee&&q(t,a)&&q(n,a)){let e=U(t,{parseNumbers:a}),r=U(n,{parseNumbers:a});if(!i&&r<e){let i=r;n=e,t=i}else t=e,n=r}else ee&&(t=te(t),n=te(n));return k===`notbetween`?b(O,t,n):l(O,t,n)}return}default:return}}},Gn={"<":`lt`,"<=":`lte`,">":`gt`,">=":`gte`},Kn=(e,t)=>e.startsWith(`not`)||e.startsWith(`doesnot`)?{bool:{must_not:t}}:t,qn=e=>e?.replace(/('|\\)/g,`\\$1`),Jn={beginswith:`startsWith`,doesnotbeginwith:`startsWith`,doesnotcontain:`contains`,doesnotendwith:`endsWith`,endswith:`endsWith`},Yn=(e,t,n)=>{let r=`doc['${e}'].value.${Jn[t]??t}(doc['${n}'].value)`;return t.startsWith(`d`)?`!${r}`:r},Xn=(e,t)=>typeof e==`boolean`?e:q(e,t)?U(e,{parseNumbers:t}):e,Zn=(e,t={})=>{let{field:n,operator:r,value:i,valueSource:a}=e,{parseNumbers:o,preserveValueOrder:s}=t,c=M(r),l=J(e);if(l===!1)return!1;if(l){let{mode:r}=l,i=pn(W(e.value,{ruleProcessor:e=>({...e,field:e.field?`${n}.${e.field}`:n})}),t);if(Object.keys(i).length===0)return!1;switch(r){case`some`:return{nested:{path:n,query:i}};case`none`:return{bool:{must_not:{nested:{path:n,query:i}}}};case`all`:case`atleast`:case`atmost`:case`exactly`:return!1}}if(a===`field`){if(j(i).some(e=>typeof e!=`string`))return!1;let e=qn(n);switch(c){case`=`:case`!=`:case`>`:case`>=`:case`<`:case`<=`:{let t=c===`=`?`==`:c,n=qn(i);return n?{bool:{filter:{script:{script:`doc['${e}'].value ${t} doc['${n}'].value`}}}}:!1}case`in`:case`notin`:{let t=j(i);if(t.length>0){let n=t.map(t=>({bool:{filter:{script:{script:`doc['${e}'].value == doc['${t}'].value`}}}}));return{bool:c===`in`?{should:n}:{must_not:n}}}return!1}case`between`:case`notbetween`:{let t=j(i);if(t.length>=2&&t[0]&&t[1]){let n=`doc['${e}'].value >= doc['${t[0]}'].value && doc['${e}'].value <= doc['${t[1]}'].value`;return{bool:{filter:{script:{script:c===`notbetween`?`!(${n})`:n}}}}}return!1}case`contains`:case`doesnotcontain`:case`beginswith`:case`doesnotbeginwith`:case`endswith`:case`doesnotendwith`:{let t=qn(i);return t?{bool:{filter:{script:{script:Yn(e,c,t)}}}}:!1}}}switch(c){case`<`:case`<=`:case`>`:case`>=`:return{range:{[n]:{[Gn[c]]:Xn(i,o)}}};case`=`:return{term:{[n]:Xn(i,o)}};case`!=`:return{bool:{must_not:{term:{[n]:Xn(i,o)}}}};case`null`:return{bool:{must_not:{exists:{field:n}}}};case`notnull`:return{exists:{field:n}};case`in`:case`notin`:{let e=j(i).map(e=>Xn(e,o));if(e.length>0){let t=e.map(e=>({term:{[n]:Xn(e,o)}}));return{bool:c===`in`?{should:t}:{must_not:t}}}return!1}case`between`:case`notbetween`:{let e=j(i);if(e.length>=2&&K(e[0])&&K(e[1])){let[t,r]=e,i=o!==!1;if(q(t,i)&&q(r,i)){let e=U(t,{parseNumbers:i}),n=U(r,{parseNumbers:i});if(!s&&n<e){let i=n;r=e,t=i}else t=e,r=n}return Kn(c,{range:{[n]:{gte:t,lte:r}}})}return!1}case`contains`:case`doesnotcontain`:return Kn(c,{regexp:{[n]:{value:`.*${i}.*`}}});case`beginswith`:case`doesnotbeginwith`:return Kn(c,{regexp:{[n]:{value:`${i}.*`}}});case`endswith`:case`doesnotendwith`:return Kn(c,{regexp:{[n]:{value:`.*${i}`}}})}return!1},Qn=(e,t)=>typeof e!=`string`||!t?`${e}`:e.replaceAll(`'`,`\\'`),$n=(e,t={})=>{let{escapeQuotes:n,parseNumbers:r}=t,{field:i,operator:a,value:o,valueSource:s}=e,c=s===`field`,l=a.toLowerCase(),u=i.includes(`.`)?i.split(`.`).pop():i,d=e=>e==null?`null`:typeof e==`boolean`||typeof e==`bigint`?String(e):c||typeof e==`number`||q(e,r)?A(e):`'${Qn(e,n)}'`;switch(l){case`=`:return`.has('${u}', ${d(o)})`;case`!=`:case`<>`:return`.has('${u}', neq(${d(o)}))`;case`<`:return`.has('${u}', lt(${d(o)}))`;case`>`:return`.has('${u}', gt(${d(o)}))`;case`<=`:return`.has('${u}', lte(${d(o)}))`;case`>=`:return`.has('${u}', gte(${d(o)}))`;case`contains`:return`.has('${u}', containing(${d(o)}))`;case`doesnotcontain`:return`.has('${u}', notContaining(${d(o)}))`;case`beginswith`:return`.has('${u}', startingWith(${d(o)}))`;case`doesnotbeginwith`:return`.has('${u}', notStartingWith(${d(o)}))`;case`endswith`:return`.has('${u}', endingWith(${d(o)}))`;case`doesnotendwith`:return`.has('${u}', notEndingWith(${d(o)}))`;case`null`:return`.hasNot('${u}')`;case`notnull`:return`.has('${u}')`;case`in`:{let e=j(o).map(d);return e.length?`.has('${u}', within(${e.join(`, `)}))`:``}case`notin`:{let e=j(o).map(d);return e.length?`.has('${u}', without(${e.join(`, `)}))`:``}case`between`:{let e=j(o);return e.length<2?``:`.has('${u}', between(${d(e[0])}, ${d(e[1])}))`}case`notbetween`:{let e=j(o);return e.length<2?``:`.has('${u}', outside(${d(e[0])}, ${d(e[1])}))`}default:return`.has('${u}', ${d(o)})`}},er=e=>e.startsWith(`not`)||e.startsWith(`doesnot`),tr=(e,t)=>`"${typeof e!=`string`||!t?`${e}`:e.replaceAll(`"`,`\\"`)}"`,nr=(e,t)=>t?`$not(${e})`:e,rr=e=>`${e}`.replaceAll(/[/$()*+.?[\\\]^{|}]/g,String.raw`\$&`).replaceAll(`-`,String.raw`\x2d`),ir=(e,t={})=>{let{field:n,operator:r,value:i,valueSource:a}=e,{escapeQuotes:o,parseNumbers:s,preserveValueOrder:c,quoteFieldNamesWith:l=[``,``],fieldIdentifierSeparator:u=``}=t,d=a===`field`,f=typeof i==`number`||typeof i==`boolean`||typeof i==`bigint`||q(i,s),p=e=>Ft(e,{quoteFieldNamesWith:l,fieldIdentifierSeparator:u}),m=J(e);if(m===!1)return;if(m){let{mode:e,threshold:r}=m,a=`$count(${p(n)})`,o=`$count($filter(${p(n)}, function($v) {${hn(W(i,{ruleProcessor:e=>({...e,field:e.field?`$v.${e.field}`:`$v`})}),t)}}))`;switch(e){case`all`:return`${o} = ${a}`;case`none`:return`${o} = 0`;case`some`:return`${o} > 0`;case`atleast`:case`atmost`:case`exactly`:{let t=e===`atleast`?`>=`:e===`atmost`?`<=`:`=`;return r>0&&r<1?`${o} ${t} (${a} * ${r})`:`${o} ${t} ${r}`}}}let h=M(r);switch(h){case`<`:case`<=`:case`=`:case`!=`:case`>`:case`>=`:return`${p(n)} ${h} ${d?p(A(i)):f?A(i):tr(i,o)}`;case`contains`:case`doesnotcontain`:return nr(`$contains(${p(n)}, ${d?p(A(i)):tr(i,o)})`,er(h));case`beginswith`:case`doesnotbeginwith`:return nr(d?`$substring(${p(n)}, 0, $length(${p(A(i))})) = ${p(A(i))}`:`$contains(${p(n)}, /^${rr(i)}/)`,er(h));case`endswith`:case`doesnotendwith`:return nr(d?`$substring(${p(n)}, $length(${p(n)}) - $length(${p(A(i))})) = ${p(A(i))}`:`$contains(${p(n)}, /${rr(i)}$/)`,er(h));case`null`:return`${p(n)} = null`;case`notnull`:return`${p(n)} != null`;case`in`:case`notin`:{let e=j(i);return nr(`${p(n)} in [${e.map(e=>d?`${p(A(e))}`:q(e,s)?`${A(e)}`:tr(e,o)).join(`, `)}]`,er(h))}case`between`:case`notbetween`:{let e=j(i);if(e.length<2||P(e[0])||P(e[1]))return``;let[t,r]=e,a=s!==!1,l=q(t,a)?U(t,{parseNumbers:a}):NaN,u=q(r,a)?U(r,{parseNumbers:a}):NaN,f=Number.isNaN(l)?d?`${t}`:t:l,m=Number.isNaN(u)?d?`${r}`:r:u;if(!c&&f===l&&m===u&&u<l){let e=u;m=l,f=e}let g=q(t,s)&&q(r,s),_=(e,t)=>d?p(e):g?t:tr(t,o),v=`${p(n)} >= ${_(t,f)} and ${p(n)} <= ${_(r,m)}`;return h===`between`?`(${v})`:nr(v,!0)}}return``},ar=e=>e.replace(/^(=)$/,`$1=`).replace(/^notnull$/i,`!=`).replace(/^null$/i,`==`),or=(e,t)=>e.startsWith(`not`)||e.startsWith(`doesnot`)?{"!":t}:t,sr=(e,t={})=>{let{field:n,operator:r,value:i,valueSource:a}=e,{parseNumbers:o,preserveValueOrder:s}=t,c=a===`field`,l={var:n},u=e=>c?{var:`${e}`}:q(e,o)?U(e,{parseNumbers:o}):e,d=J(e);if(d===!1)return!1;if(d){let{mode:e,threshold:r}=d;switch(e){case`all`:case`none`:case`some`:return{[e]:[{var:n},i.rules.length===1&&!F(i.rules[0])?sr(i.rules[0],t):gn(i,t)]};case`atleast`:case`atmost`:case`exactly`:{let a=e===`atleast`?`>=`:e===`atmost`?`<=`:`==`,o={reduce:[{filter:[{var:n},i.rules.length===1&&!F(i.rules[0])?sr(i.rules[0],t):gn(i,t)]},{"+":[1,{var:`accumulator`}]},0]};if(r>0&&r<1){let e={reduce:[{var:n},{"+":[1,{var:`accumulator`}]},0]};return{[a]:[o,{"*":[e,r]}]}}return{[a]:[o,r]}}}}let f=M(r);switch(f){case`<`:case`<=`:case`=`:case`!=`:case`>`:case`>=`:return{[ar(f)]:[l,u(i)]};case`null`:case`notnull`:return{[`${f===`notnull`?`!`:`=`}=`]:[l,null]};case`in`:case`notin`:{let e=j(i).map(e=>u(e));return or(f,{in:[l,e]})}case`between`:case`notbetween`:{let e=j(i);if(e.length>=2&&K(e[0])&&K(e[1])){let[t,n]=e,r=o!==!1;if(!c&&q(t,r)&&q(n,r)){let e=U(t,{parseNumbers:r}),i=U(n,{parseNumbers:r});if(!s&&i<e){let r=i;n=e,t=r}else t=e,n=i}else c&&(t={var:t},n={var:n});return or(f,{"<=":[t,l,n]})}return!1}case`contains`:case`doesnotcontain`:{let e={in:[u(i),l]};return or(f,e)}case`beginswith`:case`doesnotbeginwith`:{let e={startsWith:[l,u(i)]};return or(f,e)}case`endswith`:case`doesnotendwith`:{let e={endsWith:[l,u(i)]};return or(f,e)}}return!1},cr=(e,t)=>t?`(!${e})`:`${e}`,lr=e=>`${A(e)}`.replaceAll(/[()&|=<>~*\\/]/g,e=>`\\${e.codePointAt(0).toString(16)}`),ur=(e,t={})=>{let{field:n,operator:r,value:i,valueSource:a}=e,{preserveValueOrder:o}=t,s=M(r);if(a===`field`||P(i)&&s!==`null`&&s!==`notnull`||J(e))return``;switch(s){case`=`:case`!=`:return cr(`(${n}=${lr(i)})`,s===`!=`);case`>`:case`>=`:return`(${n}>=${lr(i)})`;case`<`:case`<=`:return`(${n}<=${lr(i)})`;case`contains`:case`doesnotcontain`:return cr(`(${n}=*${lr(i)}*)`,s===`doesnotcontain`);case`beginswith`:case`doesnotbeginwith`:return cr(`(${n}=${lr(i)}*)`,s===`doesnotbeginwith`);case`endswith`:case`doesnotendwith`:return cr(`(${n}=*${lr(i)})`,s===`doesnotendwith`);case`null`:case`notnull`:return cr(`(${n}=*)`,s===`notnull`);case`in`:case`notin`:{let e=j(i);return cr(`(|${e.map(e=>`(${n}=${lr(e)})`).join(``)})`,s===`notin`)}case`between`:case`notbetween`:{let e=j(i);if(e.length<2||P(e[0])||P(e[1]))return``;let[t,r]=e,a=q(t,!0)?U(t,{parseNumbers:!0}):NaN,c=q(r,!0)?U(r,{parseNumbers:!0}):NaN,l=Number.isNaN(a)?t:a,u=Number.isNaN(c)?r:c;if(!o&&l===a&&u===c&&c<a){let e=c;u=a,l=e}return cr(`(&(${n}>=${lr(l)})(${n}<=${lr(u)}))`,s===`notbetween`)}}return``},dr=(e,t,n)=>n&&typeof e==`string`?e.replaceAll(`${t}`,`${t}${t}`):e,fr=(e,t={})=>{let{escapeQuotes:n,fields:r,parseNumbers:i,quoteFieldNamesWith:a,quoteValuesWith:o,fieldIdentifierSeparator:s,translations:c}=t,l=e.valueSource===`field`,u=M(e.operator),d=o||`'`,f=e=>`${d}${e}${d}`,p=e=>dr(e,d,n),m=e=>f(p(e)),h=e=>Ft(e,{quoteFieldNamesWith:a,fieldIdentifierSeparator:s}),g=c??{},_=g.or??`or`,v=g.true??`true`,y=g.false??`false`,b=g.listSeparator??`, `,x=!g.listSeparator;switch(u){case`null`:case`notnull`:return``;case`between`:case`notbetween`:{if(!l)return ln(e,t);let n=j(e.value,{retainEmptyStrings:!0}).slice(0,2).map(e=>h(V(r??[],e)?.label??e));return n.length<2||!K(n[0])||!K(n[1])?``:ln({...e,value:n},t)}case`in`:case`notin`:{let t=j(e.value);if(t.length===0)return``;let n=t.map(e=>l?h(V(r??[],e)?.label??e):q(e,i)?`${A(e)}`:`${m(e)}`);if(n.length===1)return n[0];let a=x&&n.length>2?`,`:``;return`(${`${n.slice(0,-1).join(b)}${a} ${_} ${n.at(-1)}`})`}}return typeof e.value==`boolean`?e.value?v:y:l?h(V(r??[],e.value)?.label??e.value):q(e.value,i)?`${A(e.value)}`:`${m(e.value)}`},pr={"=":[`is`,`is the same as the value in`],"!=":[`is not`,`is not the same as the value in`],"<":[`is less than`,`is less than the value in`],">":[`is greater than`,`is greater than the value in`],"<=":[`is less than or equal to`,`is less than or equal to the value in`],">=":[`is greater than or equal to`,`is greater than or equal to the value in`],contains:[`contains`,`contains the value in`],beginswith:[`starts with`,`starts with the value in`],endswith:[`ends with`,`ends with the value in`],doesnotcontain:[`does not contain`,`does not contain the value in`],doesnotbeginwith:[`does not start with`,`does not start with the value in`],doesnotendwith:[`does not end with`,`does not end with the value in`],null:`is null`,notnull:`is not null`,in:[`is one of the values`,`is the same as a value in`],notin:[`is not one of the values`,`is not the same as any value in`],between:[`is between`,`is between the values in`],notbetween:[`is not between`,`is not between the values in`]},mr=()=>[],hr=(e,t={})=>{let{field:n,operator:r,valueSource:i=`value`}=e,{getOperators:a=mr,operatorMap:o=pr}=t,s=new Map(Object.entries(pr));for(let[e,t]of Object.entries(o))s.set(M(e),t);let c=Object.fromEntries(s),l=M(r);var u=r;let d=j(e.value).length===1;l===`in`&&d?u=`=`:l===`notin`&&d&&(u=`!=`);let{value:f,label:p}=V(B(a(n,{fieldData:t.fieldData??{name:n,value:n,label:n}})??[]),u)??{name:u,value:u,label:u},m=c[f]??c[M(f)]??[p,p];return typeof m==`string`?m:m[+(i===`field`)]},gr=(e,t)=>{let{field:n,operator:r}=e,{fieldData:i,quoteFieldNamesWith:a=[``,``],fieldIdentifierSeparator:o=``,quoteValuesWith:s=`'`,operatorProcessor:c=hr,valueProcessor:l=fr,concatOperator:u=`||`,wordOrder:d=`SVO`}=t??{},f=Ft(i?.label??n,{quoteFieldNamesWith:a,fieldIdentifierSeparator:o}),p=J(e);if(p===!1)return``;if(p){let{mode:n,threshold:r}=p,a=bn(e.value,{...t,fields:B(i?.subproperties??[])}),o=(i?.subproperties?.length??0)>0;switch(n){case`all`:return`(${o?`for `:``}every item in ${f}${o?`,`:``} ${a})`;case`none`:return`(${o?`for `:``}no item in ${f}${o?`,`:``} ${a})`;case`some`:return`(${o?`for `:``}at least one item in ${f}${o?`,`:``} ${a})`;case`atleast`:case`atmost`:case`exactly`:{let e=n.replace(`at`,`at `);return r>0&&r<1?`(${o?`for `:``}${e} ${r*100}% of the items in ${f}${o?`,`:``} ${a})`:`(${o?`for `:``}${e} ${r} of the items in ${f}${o?`,`:``} ${a})`}}}let m=l(e,{...t,quoteFieldNamesWith:a,fieldIdentifierSeparator:o,quoteValuesWith:s,concatOperator:u}),h=M(r);if((h===`in`||h===`notin`||h===`between`||h===`notbetween`)&&!m)return``;let g={S:f,V:c(e,t),O:m},_=t?.translations??{},v={S:_.afterSubject??` `,V:_.afterVerb??` `,O:_.afterObject??` `},y=Lt(d).filter(e=>g[e]!==``);return y.map((e,t)=>`${g[e]}${t<y.length-1?v[e]:``}`).join(``).trim()},_r=e=>M(wt(e.operator)),vr=(e,t={})=>{let{quoteFieldNamesWith:n=[``,``],fieldIdentifierSeparator:r=``,quoteValuesWith:i=`'`,operatorProcessor:a=_r,valueProcessor:o=ln,concatOperator:s=`||`}=t,c=e=>Ft(e,{quoteFieldNamesWith:n,fieldIdentifierSeparator:r}),l=c(e.field),u=J(e);if(u===!1)return;if(u){if(t?.preset!==`postgresql`)return``;let{mode:n,threshold:r}=u,i=t.subqueryDepth??0,a=Wt(i),o=En(W(e.value,{ruleProcessor:e=>({...e,field:a})}),{...t,subqueryDepth:i+1});switch(n){case`all`:return`(select count(*) from unnest(${l}) as ${c(a)} where ${o}) = array_length(${l}, 1)`;case`none`:return`not exists (select 1 from unnest(${l}) as ${c(a)} where ${o})`;case`some`:return`exists (select 1 from unnest(${l}) as ${c(a)} where ${o})`;case`atleast`:case`atmost`:case`exactly`:{let e=n===`atleast`?`>=`:n===`atmost`?`<=`:`=`;return`(select count(*)${r>0&&r<1?`::float / array_length(${l}, 1)`:``} from unnest(${l}) as ${c(a)} where ${o}) ${e} ${r}`}}}let d=o(e,{...t,quoteFieldNamesWith:n,fieldIdentifierSeparator:r,quoteValuesWith:i,concatOperator:s}),f=a(e,t),p=M(f);return(p===`in`||p===`not in`||p===`between`||p===`not between`)&&!d?``:`${l} ${f} ${d}`.trim()},yr=(e,t,n)=>{let{fieldData:r,format:i,getNextNamedParam:a,parseNumbers:o,paramPrefix:s,paramsKeepPrefix:c,numberedParams:l,quoteFieldNamesWith:u=[``,``],fieldIdentifierSeparator:d,concatOperator:f,operatorProcessor:p=_r,valueProcessor:m=ln}=t??{},{processedParams:h=[]}=n??{},g=i===`parameterized`,_=[],v={},y=e=>g?{sql:e,params:_}:{sql:e,params:v},b=e=>Ft(e,{quoteFieldNamesWith:u,fieldIdentifierSeparator:d}),x=b(e.field),S=J(e);if(S===!1)return;if(S){if(t?.preset!==`postgresql`)return y(``);let{mode:n,threshold:r}=S,i=t.subqueryDepth??0,a=Wt(i),{sql:o,params:s}=xn(W(e.value,{ruleProcessor:e=>({...e,field:a})}),{...t,fields:[],subqueryDepth:i+1});switch(Array.isArray(s)?_.push(...s):Object.assign(v,s),n){case`all`:return y(`(select count(*) from unnest(${x}) as ${b(a)} where ${o}) = array_length(${x}, 1)`);case`none`:return y(`not exists (select 1 from unnest(${x}) as ${b(a)} where ${o})`);case`some`:return y(`exists (select 1 from unnest(${x}) as ${b(a)} where ${o})`);case`atleast`:case`atmost`:case`exactly`:{let e=n===`atleast`?`>=`:n===`atmost`?`<=`:`=`;return y(`(select count(*)${r>0&&r<1?`::float / array_length(${x}, 1)`:``} from unnest(${x}) as ${b(a)} where ${o}) ${e} ${r}`)}}}let C=m(e,{parseNumbers:o,quoteFieldNamesWith:u,concatOperator:f,fieldData:r,format:i}),w=p(e,t),T=M(w),[E,D]=u;if((T===`in`||T===`not in`||T===`between`||T===`not between`)&&!C)return y(``);if(T===`is null`||T===`is not null`)return y(`${E}${e.field}${D} ${w}`);if(e.valueSource===`parameter`){let t=e=>{let t=Rt(e,s);return g||(v[c?t:zt(e,s)]=null),t};if(T===`between`||T===`not between`){let[n,r]=j(e.value,{retainEmptyStrings:!0}).slice(0,2);return y(`${E}${e.field}${D} ${w} ${t(n)} and ${t(r)}`.trim())}if(T===`in`||T===`not in`){let n=j(e.value);return y(`${E}${e.field}${D} ${w} (${n.map(e=>t(e)).join(`, `)})`)}return y(`${E}${e.field}${D} ${w} ${Dt(t(e.value),M(e.operator),{concatOperator:f})}`.trim())}if(e.valueSource===`field`)return y(`${E}${e.field}${D} ${w} ${C}`.trim());if(T===`in`||T===`not in`){let t=j(e.value);if(g){for(let e of t)_.push(q(e,o)?U(e,{parseNumbers:o}):e);return y(`${E}${e.field}${D} ${w} (${t.map((e,n)=>l?`${s}${h.length+1+t.length-(t.length-n)}`:`?`).join(`, `)})`)}let n=[];for(let r of t){let t=a(e.field);n.push(`${s}${t}`),v[`${c?s:``}${t}`]=q(r,o)?U(r,{parseNumbers:o}):r}return y(`${E}${e.field}${D} ${w} (${n.join(`, `)})`)}if(T===`between`||T===`not between`){let[t,n]=j(e.value,{retainEmptyStrings:!0}).slice(0,2).map(e=>q(e,o)?U(e,{parseNumbers:o}):e);if(g)return _.push(t,n),y(`${E}${e.field}${D} ${w} ${l?`${s}${h.length+1}`:`?`} and ${l?`${s}${h.length+2}`:`?`}`);let r=a(e.field),i=a(e.field);return v[`${c?s:``}${r}`]=t,v[`${c?s:``}${i}`]=n,y(`${E}${e.field}${D} ${w} ${s}${r} and ${s}${i}`)}let O=e.value;typeof e.value==`string`&&(O=q(e.value,o)?U(e.value,{parseNumbers:o}):/^'.*'$/g.test(C)?C.replaceAll(/(^'|'$)/g,``):C);let k=``;return g?_.push(O):(k=a(e.field),v[`${c?s:``}${k}`]=O),y(`${E}${e.field}${D} ${w} ${g?l?`${s}${h.length+1}`:`?`:`${s}${k}`}`.trim())},br=(e,t,n)=>q(e,!!n||typeof e==`bigint`)?Number(U(e,{parseNumbers:!!n})):t,xr=(e,t={})=>{let{field:n,operator:r,value:i,valueSource:a}=e,{parseNumbers:o,preserveValueOrder:s}=t;if(a===`field`||J(e))return;let c=M(r);switch(c){case`=`:return{[n]:br(i,i,o)};case`!=`:case`<`:case`<=`:case`>`:case`>=`:{let e=kt[c];return{[n]:{[e]:br(i,i,o)}}}case`contains`:return{[n]:{contains:i}};case`beginswith`:return{[n]:{startsWith:i}};case`endswith`:return{[n]:{endsWith:i}};case`doesnotcontain`:return{NOT:{[n]:{contains:i}}};case`doesnotbeginwith`:return{NOT:{[n]:{startsWith:i}}};case`doesnotendwith`:return{NOT:{[n]:{endsWith:i}}};case`null`:return{[n]:null};case`notnull`:return{[n]:{not:null}};case`in`:case`notin`:{let e=j(i);return{[n]:{[kt[c]]:e.map(e=>br(e,e,o))}}}case`between`:case`notbetween`:{let e=j(i);if(e.length>=2&&K(e[0])&&K(e[1])){let[t,r]=e,i=o!==!1,a=q(t,i)?U(t,{parseNumbers:o}):NaN,l=q(r,i)?U(r,{parseNumbers:o}):NaN,u=Number.isNaN(a)?t:a,d=Number.isNaN(l)?r:l;if(!s&&u===a&&d===l&&l<a){let e=l;d=a,u=e}return c===`between`?{[n]:{gte:u,lte:d}}:{OR:[{[n]:{lt:u}},{[n]:{gt:d}}]}}return``}}return``},Sr=(e,{parseNumbers:t,preserveValueOrder:n,context:r={}}={})=>{let{sequelizeOperators:i,sequelizeCol:a,sequelizeFn:o}=r;if(J(e))return;let{field:s,operator:c,value:l,valueSource:u}=e,d=u===`field`,f=M(c);if(!(!i||d&&(!a||!o&&[`contains`,`doesnotcontain`,`beginswith`,`doesnotbeginwith`,`endswith`,`doesnotendwith`].includes(f))))switch(f){case`=`:case`!=`:case`<`:case`<=`:case`>`:case`>=`:{let e={"=":i.eq,"!=":i.ne,"<":i.lt,"<=":i.lte,">":i.gt,">=":i.gte}[f];return{[s]:d&&f===`=`?{[i.col]:l}:{[e]:d?a(l):q(l,t)?U(l,{parseNumbers:`strict`}):l}}}case`contains`:return{[s]:{[d?i.like:i.substring]:d?o(`CONCAT`,`%`,a(l),`%`):`${l}`}};case`beginswith`:return{[s]:{[d?i.like:i.startsWith]:d?o(`CONCAT`,a(l),`%`):`${l}`}};case`endswith`:return{[s]:{[d?i.like:i.endsWith]:d?o(`CONCAT`,`%`,a(l)):`${l}`}};case`doesnotcontain`:return{[s]:{[i.notLike]:d?o(`CONCAT`,`%`,a(l),`%`):`%${l}%`}};case`doesnotbeginwith`:return{[s]:{[i.notLike]:d?o(`CONCAT`,a(l),`%`):`${l}%`}};case`doesnotendwith`:return{[s]:{[i.notLike]:d?o(`CONCAT`,`%`,a(l)):`%${l}`}};case`null`:return{[s]:{[i.is]:null}};case`notnull`:return{[s]:{[i.not]:null}};case`in`:case`notin`:{let e=j(l);return{[s]:{[f===`in`?i.in:i.notIn]:e.map(e=>d?a(e):q(e,t)?U(e,{parseNumbers:`strict`}):e)}}}case`between`:case`notbetween`:{let e=j(l,{retainEmptyStrings:!0});if(e.length<2||!K(e[0])||!K(e[1]))return;let[r,o]=e,c=q(r,t)?U(r,{parseNumbers:`strict`}):NaN,u=q(o,t)?U(o,{parseNumbers:`strict`}):NaN,p=Number.isNaN(c)?r:c,m=Number.isNaN(u)?o:u,h=[p,m];return!n&&p===c&&m===u&&u<c&&(h[0]=u,h[1]=c),{[s]:{[f===`between`?i.between:i.notBetween]:d?h.map(e=>a(e)):h.every(e=>q(e,t))?h.map(e=>U(e,{parseNumbers:`strict`})):h}}}}},Cr=(e,t)=>typeof e!=`string`||!t?`${e}`:e.replaceAll(`"`,`\\"`),wr=e=>/^[?<]/.test(e)||e.includes(`:`)?e:`?${e}`,Tr=(e,t={})=>{let{escapeQuotes:n,parseNumbers:r}=t,{field:i,operator:a,value:o,valueSource:s}=e,c=s===`field`,l=a.toLowerCase(),u=wr(i),d=e=>{if(e==null)return`""`;if(typeof e==`boolean`)return`"${e}"^^xsd:boolean`;if(typeof e==`bigint`)return String(e);if(c)return wr(A(e));if(typeof e==`number`||q(e,r))return A(e);let t=typeof e==`string`?e:JSON.stringify(e)??``;return t.startsWith(`?`)||t.startsWith(`<`)||t.includes(`:`)?t:`"${Cr(t,n)}"`};switch(l){case`=`:case`!=`:case`<`:case`>`:case`<=`:case`>=`:return`${u} ${l} ${d(o)}`;case`<>`:return`${u} != ${d(o)}`;case`contains`:return`CONTAINS(${u}, ${d(o)})`;case`doesnotcontain`:return`!CONTAINS(${u}, ${d(o)})`;case`beginswith`:return`STRSTARTS(${u}, ${d(o)})`;case`doesnotbeginwith`:return`!STRSTARTS(${u}, ${d(o)})`;case`endswith`:return`STRENDS(${u}, ${d(o)})`;case`doesnotendwith`:return`!STRENDS(${u}, ${d(o)})`;case`null`:return`!BOUND(${u})`;case`notnull`:return`BOUND(${u})`;case`in`:{let e=j(o).map(d);return e.length?`${u} IN (${e.join(`, `)})`:``}case`notin`:{let e=j(o).map(d);return e.length?`${u} NOT IN (${e.join(`, `)})`:``}case`between`:{let e=j(o);return e.length<2?``:`${u} >= ${d(e[0])} && ${u} <= ${d(e[1])}`}case`notbetween`:{let e=j(o);return e.length<2?``:`(${u} < ${d(e[0])} || ${u} > ${d(e[1])})`}default:return`${u} ${a} ${d(o)}`}},Er=(e,t)=>{let{parseNumbers:n,preserveValueOrder:r,context:i={}}=t??{},a=i.tanStackDbOperators,o=i._tanstackDbRefs,s=i._tanstackDbPrimaryRef;if(!a||!o||!s)return;let{and:c,eq:l,gt:u,gte:d,inArray:f,isNull:p,like:m,lt:h,lte:g,not:_}=a,v=e=>{let t=e.indexOf(`.`);if(t>0){let n=e.slice(0,t),r=e.slice(t+1);if(o[n])return o[n][r]}return o[s][e]},{field:y,operator:b,value:x,valueSource:S}=e,C=v(y),w=M(b),T=S===`field`,E=e=>T?v(e):e,D=e=>T||!n?E(e):q(e,!0)?U(e,{parseNumbers:!0}):e;switch(w){case`=`:return l(C,D(x));case`!=`:return _(l(C,D(x)));case`>`:return u(C,D(x));case`<`:return h(C,D(x));case`>=`:return d(C,D(x));case`<=`:return g(C,D(x));case`beginswith`:case`doesnotbeginwith`:{let e=m(C,T?void 0:`${x}%`);return w===`doesnotbeginwith`?_(e):e}case`contains`:case`doesnotcontain`:{let e=m(C,T?void 0:`%${x}%`);return w===`doesnotcontain`?_(e):e}case`endswith`:case`doesnotendwith`:{let e=m(C,T?void 0:`%${x}`);return w===`doesnotendwith`?_(e):e}case`null`:return p(C);case`notnull`:return _(p(C));case`in`:case`notin`:{let e=f(C,j(x).map(e=>D(e)));return w===`notin`?_(e):e}case`between`:case`notbetween`:{let e=j(x);if(e.length>=2&&K(e[0])&&K(e[1])){let[t,i]=e,a=n!==!1;if(!T&&q(t,a)&&q(i,a)){let e=U(t,{parseNumbers:a}),n=U(i,{parseNumbers:a});if(!r&&n<e){let r=n;i=e,t=r}else t=e,i=n}else T&&(t=E(t),i=E(i));let o=c(d(C,t),g(C,i));return w===`notbetween`?_(o):o}return}default:return}},Dr={ansi:{},sqlite:{paramsKeepPrefix:!0},oracle:{},mssql:{concatOperator:`+`,quoteFieldNamesWith:[`[`,`]`],fieldIdentifierSeparator:`.`,paramPrefix:`@`},mysql:{concatOperator:`CONCAT`},postgresql:{quoteFieldNamesWith:`"`,numberedParams:!0,paramPrefix:`$`}},Or={...Dr},kr={cel:Xt,drizzle:Wn,elasticsearch:Zn,json_without_ids:vr,json:vr,jsonata:ir,jsonlogic:sr,ldap:ur,mongodb_query:en,mongodb:tn,natural_language:gr,parameterized_named:yr,parameterized:yr,prisma:xr,sequelize:Sr,spel:sn,sql:vr,tanstack_db:Er,cypher:Un,gql:Un,sparql:Tr,gremlin:$n,diagnostics:vr},Y=e=>e.operator,Ar={cel:Y,drizzle:Y,elasticsearch:Y,json_without_ids:Y,json:Y,jsonata:Y,jsonlogic:Y,ldap:Y,mongodb_query:Y,mongodb:Y,natural_language:hr,parameterized_named:_r,parameterized:_r,prisma:Y,sequelize:Y,spel:Y,sql:_r,tanstack_db:Y,cypher:Y,gql:Y,sparql:Y,gremlin:Y,diagnostics:Y},jr={cel:`1 == 1`,ldap:``,mongodb:`"$and":[{"$expr":true}]`,natural_language:`1 is 1`,sparql:`1 = 1`,gremlin:``,spel:`1 == 1`,sql:`(1 = 1)`},Mr={format:`json`,fields:[],quoteFieldNamesWith:[``,``],fieldIdentifierSeparator:``,getOperators:()=>[],paramPrefix:`:`,paramsKeepPrefix:!1,numberedParams:!1,preserveValueOrder:!1,placeholderFieldName:`~`,placeholderOperatorName:`~`,quoteValuesWith:`'`,concatOperator:`||`,preset:`ansi`,wordOrder:`SVO`,translations:{},operatorMap:{}},Nr=new Set([`cel`,`drizzle`,`elasticsearch`,`jsonata`,`jsonlogic`,`ldap`,`mongodb_query`,`mongodb`,`prisma`,`sequelize`,`spel`,`tanstack_db`]),Pr=new Set([`sql`,`parameterized`,`parameterized_named`,`drizzle`,`prisma`,`sequelize`]);function Fr(e,t={}){let n=typeof t==`string`?{format:M(t)}:t,r={...Mr,...!n.format||Pr.has(n.format)?Dr[n.preset??`ansi`]??null:null,...n,...!n.format&&(Object.keys(Dr).includes(n.preset??``)?{format:`sql`}:null)},i=M(r.format),{fallbackExpression:a,getOperators:o,operatorProcessor:s,parseNumbers:c,quoteFieldNamesWith:l,ruleGroupProcessor:u,ruleProcessor:d,validator:f,valueProcessor:p,context:m}=r,h=e=>typeof Ct({parseNumbers:c,inputType:e})==`string`?!0:typeof c==`boolean`?c:void 0,g=typeof s==`function`?s:Ar[i]??Y,_=typeof p==`function`?Nt(p)?e=>p(e.field,e.operator,e.value,e.valueSource):p:i===`natural_language`?fr:Nr.has(i)?d??kr[i]:ln,v=(typeof d==`function`?d:null)??(Nr.has(i)&&typeof d!=`function`&&p?_:null)??kr[i]??vr,y=Pt(l),b=B(r.fields),x=(e,t)=>B(o(e,t)??[]),S=a??jr[i]??jr.sql,C={};if(typeof f==`function`){let t=f(e);if(typeof t==`boolean`){if(!t&&i!==`diagnostics`)return i===`parameterized`?{sql:S,params:[]}:i===`parameterized_named`?{sql:S,params:{}}:i===`mongodb`?`{${S}}`:i===`mongodb_query`?Zt:i===`prisma`?Sn:i===`jsonlogic`?!1:i===`elasticsearch`?{}:i===`drizzle`||i===`sequelize`||i===`tanstack_db`?void 0:S}else C=t}let w={},T=Xe(b);for(let e of T)typeof e.validator==`function`&&(w[e.value??e.name]=e.validator);let E=e=>{let t,n;if(e.id&&(t=C[e.id]),T.length>0){let t=T.filter(t=>t.name===e.field);if(t.length>0){let e=t[0];typeof e.validator==`function`&&(n=e.validator)}}if(e.valueSource===`parameter`&&typeof r.getParameters==`function`){let n=V(b,e.field);new Set(Xe(B(r.getParameters(e.field,e.operator,{fieldData:n}))).map(e=>zt(e.value,r.paramPrefix))).has(zt(e.value,r.paramPrefix))||(t=!1)}return[t,n]},D={...r,fallbackExpression:S,fields:b,format:i,getOperators:x,getParseNumberBoolean:h,quoteFieldNamesWith:y,operatorProcessor:g,ruleProcessor:v,valueProcessor:_,validateRule:E,validationMap:C,context:m};if(typeof u==`function`)return u(e,D);switch(i){case`json`:case`json_without_ids`:{let t=c?Mt(e,D):e;return i===`json_without_ids`?JSON.stringify(t,(e,t)=>e===`id`||e===`path`?void 0:Gt(e,t)):JSON.stringify(t,Gt,2)}case`sql`:return En(e,D);case`parameterized`:case`parameterized_named`:return xn(e,D);case`mongodb`:return yn(e,D);case`mongodb_query`:return Qt(e,D);case`cel`:return qt(e,D);case`spel`:return nn(e,D);case`jsonata`:return hn(e,D);case`jsonlogic`:return gn(e,D);case`elasticsearch`:return pn(e,D);case`natural_language`:return bn(e,D);case`ldap`:return _n(e,D);case`prisma`:return Cn(e,D);case`drizzle`:return fn(e,D);case`tanstack_db`:return Dn(e,D);case`sequelize`:return wn(e,D);case`cypher`:case`gql`:return dn(e,D);case`sparql`:return Tn(e,D);case`gremlin`:return mn(e,D);case`diagnostics`:return Rn(e,D);default:return``}}const Ir=e=>(t,n,r,i)=>e({field:t,operator:n,value:r,valueSource:i},{parseNumbers:!1}),Lr=Ir(ln),Rr=Ir(tn),zr=Ir(Xt),Br=Ir(sn),Vr=Xt,Hr=tn,Ur=sn,X=(e,t)=>{let n=t,r=0;for(;r<e.length&&n&&F(n);){let t=n.rules[e[r]];n=typeof t==`string`?null:t,r++}return r<e.length?null:n},Wr=(e,t)=>{if(t.id===e)return t;for(let n of t.rules)if(typeof n!=`string`){if(n.id===e)return n;if(F(n)){let t=Wr(e,n);if(t)return t}}return null},Gr=(e,t)=>{if(t.id===e)return[];let n=t.rules.findIndex(t=>typeof t!=`string`&&t.id===e);if(n>=0)return[n];for(let[n,r]of Object.entries(t.rules))if(F(r)){let t=Gr(e,r);if(Array.isArray(t))return[Number.parseInt(n),...t]}return null},Z=e=>e.slice(0,-1),Kr=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0},qr=(e,t)=>{if(e.length>=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0},Jr=(e,t)=>{let n=[],r=Z(e),i=Z(t),a=0;for(;a<r.length&&a<i.length&&r[a]===i[a];)n.push(i[a]),a++;return n},Yr=(e,t)=>{let n=!!t.disabled,r=t,i=0;for(;i<e.length&&!n&&F(r);){let t=r.rules[e[i]];N(t)&&(F(t)||`field`in t&&t.field)&&(n=!!t.disabled,r=t),i++}return n},Xr=(e,t=[])=>t.some(t=>Kr(t,e)||qr(t,e)),Zr=(e,t,{disabled:n=!1,disabledPaths:r=[]}={})=>{let i=[];for(let a=0;a<t;a++){let t=[...e,a];i[a]={path:t,disabled:n||r.some(e=>Kr(t,e))}}return i},Qr=e=>Kr([],e.path)?`Query builder`:`Rule group at path ${e.path.join(`-`)}`,$r=globalThis.crypto,ei=/^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i;let Q=()=>`00-0-4-2-000`.replaceAll(/[^-]/g,e=>((Math.random()+Math.trunc(e))*65536>>Number.parseInt(e)).toString(16).padStart(4,`0`));if($r){if(typeof $r.randomUUID==`function`)Q=()=>$r.randomUUID();else if(typeof $r.getRandomValues==`function`){let e=new Uint32Array(32);Q=()=>{$r.getRandomValues(e);let t=(e[0]%16).toString(16);for(let n=1;n<32;n++)t=n===12?`${t}4`:n===16?`${t}${`89ab`[e[17]%4]}`:`${t}${(e[n]%16).toString(16)}`,(n===7||n===11||n===15||n===19)&&(t=`${t}-`);return t}}}const ti=t.setAutoFreeze,ni=new t.Immer({autoFreeze:!1}),ri=(e=!0)=>e?t.produce:ni.produce,ii={name:`name`,value:`name`,matchModes:null,label:`label`},ai=(e,t)=>{let n=e?z(e):ii,r=n.matchModes??!1;return!r&&t&&(r=t(n.value,{fieldData:n})),r===!0?w:r===!1?[]:Ke(r)?B(r):r?.map(e=>w.find(t=>t.value===M(e))??{name:e,value:e,label:e})??[]},oi=(e,t,n)=>{let r=H(e);if(t.operator===`between`||t.operator===`notBetween`){let e=[r,r];return n?e:ae(e.map(e=>e??``),`,`)}return r},si=(e,t)=>{let{fieldData:n,fields:r,getValueEditorType:i,getValues:a,getDefaultValue:o,getParameters:s,listsAsArrays:c}=t;if(n?.defaultValue!==void 0&&n.defaultValue!==null)return n.defaultValue;if(o)return o(e,{fieldData:n});let l=``,u=a(e.field,e.operator,{fieldData:n});if(e.valueSource===`field`){let t=tt(n,r,e.operator);l=t.length>0?oi(t,e,c):``}else if(e.valueSource===`parameter`){let t=s?s(e.field,e.operator,{fieldData:n}):null;l=t&&t.length>0?H(t):``}else if(u.length>0){let t=i(e.field,e.operator,{fieldData:n});t===`multiselect`?l=c?[]:``:(t===`select`||t===`radio`)&&(l=oi(u,e,c))}else i(e.field,e.operator,{fieldData:n})===`checkbox`&&(l=!1);return l},ci=e=>{let t=typeof e==`boolean`?e:typeof e==`object`&&e?e.valid:null;return typeof t==`boolean`?t?T.valid:T.invalid:``},li=[{name:`value`,value:`value`,label:`value`}],ui={name:`name`,value:`name`,valueSources:null,label:`label`},di=(e,t,n)=>{let r=e?z(e):ui,i=r.valueSources??!1;return typeof i==`function`&&(i=i(t)),!i&&n&&(i=n(r.value,t,{fieldData:r})),i?Ke(i)?B(i):i.map(e=>li.find(t=>t.value===M(e))??{name:e,value:e,label:e}):li},fi=(e,...t)=>{let n={...e};for(let e of t)if(e)for(let t of Le(e))ze(t)||(n[t]=n[t]?{...n[t],...e[t]}:{...e[t]});return n},pi=(e,t,n)=>{if(ze(e))return;let r=Re(t).map(([t,[r,i]])=>[t,r??i??n?.[e]?.[t]]).filter(e=>!ze(e[0])&&!!e[1]);if(r.length>0||n){let t=n?.[e]??{},i=Object.assign({},t,Object.fromEntries(r));return{[e]:i}}},$=(e,t)=>{let n=``;for(let r=0;r<t.length;r++){let i=t[r]?.[e];if(!i)continue;let a=typeof i==`string`?i:ce(i);a&&(n=n?`${n} ${a}`:a)}return n},mi=(...e)=>({queryBuilder:$(`queryBuilder`,e),ruleGroup:$(`ruleGroup`,e),header:$(`header`,e),body:$(`body`,e),combinators:$(`combinators`,e),addRule:$(`addRule`,e),addGroup:$(`addGroup`,e),cloneRule:$(`cloneRule`,e),cloneGroup:$(`cloneGroup`,e),removeGroup:$(`removeGroup`,e),rule:$(`rule`,e),fields:$(`fields`,e),operators:$(`operators`,e),value:$(`value`,e),removeRule:$(`removeRule`,e),notToggle:$(`notToggle`,e),shiftActions:$(`shiftActions`,e),undoRedoActions:$(`undoRedoActions`,e),undoAction:$(`undoAction`,e),redoAction:$(`redoAction`,e),dragHandle:$(`dragHandle`,e),lockRule:$(`lockRule`,e),lockGroup:$(`lockGroup`,e),muteRule:$(`muteRule`,e),muteGroup:$(`muteGroup`,e),muted:$(`muted`,e),valueSource:$(`valueSource`,e),actionElement:$(`actionElement`,e),valueSelector:$(`valueSelector`,e),betweenRules:$(`betweenRules`,e),valid:$(`valid`,e),invalid:$(`invalid`,e),dndDragging:$(`dndDragging`,e),dndOver:$(`dndOver`,e),dndCopy:$(`dndCopy`,e),dndGroup:$(`dndGroup`,e),dndDropNotAllowed:$(`dndDropNotAllowed`,e),dndPreviewPosition:$(`dndPreviewPosition`,e),dndHidden:$(`dndHidden`,e),disabled:$(`disabled`,e),valueListItem:$(`valueListItem`,e),matchMode:$(`matchMode`,e),matchThreshold:$(`matchThreshold`,e),branches:$(`branches`,e),hasSubQuery:$(`hasSubQuery`,e),loading:$(`loading`,e),valueDateTimeRelative:$(`valueDateTimeRelative`,e)}),hi=({field:e,fieldData:t,getOperators:n,operators:r,placeholder:i,baseOption:a,autoSelectOption:o})=>$e({optionList:t?.operators??n?.(e,{fieldData:t})??r,placeholder:i,baseOption:a,labelMap:p,autoSelectOption:o}).optionList,gi=({field:e,fieldData:t,getDefaultOperator:n,getOperators:r})=>t?.defaultOperator?t.defaultOperator:n?typeof n==`function`?n(e,{fieldData:t}):n:H(r(e,{fieldData:t}))??``,_i=({field:e,operator:t,fieldData:n,getValueEditorType:r})=>n?.valueEditorType?typeof n.valueEditorType==`function`?n.valueEditorType(t):n.valueEditorType:r?.(e,t,{fieldData:n})??`text`,vi=({field:e,operator:t,fieldData:n,getValues:r,placeholder:i,baseOption:a,autoSelectOption:o})=>$e({optionList:n?.values??r?.(e,t,{fieldData:n})??[],placeholder:i,baseOption:a,autoSelectOption:o}).optionList,yi=e=>{let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype},bi=(e,t)=>{if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((e,n)=>bi(e,t[n]));if(typeof e!=`object`||typeof t!=`object`||e===null||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)||!yi(e))return!1;let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>bi(e[n],t[n]))},xi=(e,t)=>bi(e,t),Si=(e,t)=>e===!1?!1:e?!0:t!==!1,Ci=(e,t)=>e?!0:e!==!1&&!!t,wi=(e,t,n,r)=>r?t??n:e?Si(t,n):Ci(t,n),Ti=(e,t,n)=>t!==void 0&&t!=null?t:n!==void 0&&n!=null?n:e,Ei=(e={},t={},n)=>Re(te).reduce((r,[i,a])=>(r[i]=wi(a,e[i],t[i],!n),r),{}),Di=(e,{idGenerator:t=Q}={})=>{let n=!e.id,r=J(e);return!n&&!r?e:{...e,...n&&{id:t()},...r&&{value:Oi(e.value,{idGenerator:t})}}},Oi=(e,{idGenerator:t=Q}={})=>{let n=!e.id,r=!1,i=[];for(let n=0;n<e.rules.length;n++){let a=e.rules[n];if(typeof a==`string`)i.push(a);else{let e=F(a)?Oi(a,{idGenerator:t}):Di(a,{idGenerator:t});i.push(e),e!==a&&(r=!0)}}return!n&&!r?e:{...e,...n&&{id:t()},rules:i}},ki=(e,{idGenerator:t=Q}={})=>F(e)?Oi(e,{idGenerator:t}):Di(e,{idGenerator:t}),Ai=(e,t)=>{let n=e.query??e.storeQuery??e.defaultQuery??e.fallbackQuery;return n.id?n:Oi(n,t)},ji=(e,{idGenerator:t=Q}={})=>structuredClone({...e,id:t()}),Mi=(e,{idGenerator:t=Q}={})=>{if(!N(e))return e;if(!F(e))return structuredClone({...e,id:t()});let n={...e,id:t()};return Array.isArray(n.rules)&&(n.rules=e.rules.map(e=>typeof e==`string`?e:F(e)?Mi(e,{idGenerator:t}):ji(e,{idGenerator:t}))),n},Ni=(e,t,n={},{asParent:r=!1}={})=>{if(n.queryDisabled)return r?`parent-disabled`:`target-disabled`;if(!n.respectDisabled||t===void 0)return null;let i=Array.isArray(t)?t:Gr(t,e);return i&&(Yr(i,e)||Xr(i,n.disabledPaths))?r?`parent-disabled`:`target-disabled`:null},Pi=(e,{maxLevels:t=1/0}={})=>!!e&&e.length>=t,Fi=(e,t,n,r={})=>ri(r.freeze)(e,e=>Ii(e,t,n,r)),Ii=(e,t,n,r={})=>{let{combinators:i=S,combinatorPreceding:a,idGenerator:o=Q,onAbort:s}=r,c=Array.isArray(n)?X(n,e):Wr(n,e);if(!c)return s?.({reason:`parent-not-found`,operation:`add`,pathOrID:n}),e;if(!F(c))return s?.({reason:`parent-not-a-group`,operation:`add`,pathOrID:n}),e;let l=Array.isArray(n)?n:Gr(n,e),u=Ni(e,l,r,{asParent:!0});if(u)return s?.({reason:u,operation:`add`,pathOrID:n}),e;if(F(t)&&Pi(l,r))return s?.({reason:`max-levels-exceeded`,operation:`add`,pathOrID:n}),e;if(L(c)&&c.rules.length>0){let e=c.rules.at(-2);c.rules.push(a??(typeof e==`string`?e:H(i)))}return c.rules.push(ki(t,{idGenerator:o})),e},Li={field:0,operator:1,valueSource:2,value:4},Ri=e=>e.toSorted((e,t)=>(Li[e[0]]??3)-(Li[t[0]]??3)),zi=(e,t,n,r)=>{if(typeof e==`string`)return{entries:[[e,t]],pathOrID:n,options:r??{}};if(Array.isArray(e)){let i=t;return{entries:Ri(e.map((e,t)=>[e,i[t]])),pathOrID:n,options:r??{}}}return{entries:Ri(Object.entries(e)),pathOrID:t,options:n??{}}},Bi=(e,t,n,r)=>(typeof e==`string`||Array.isArray(e)?r:n)??{},Vi=(e,t,n,r,i)=>{let{entries:a,pathOrID:o,options:s}=zi(t,n,r,i);for(let[t,n]of a)Wi(e,t,n,o,s);return e},Hi=((e,t,n,r,i)=>ri(Bi(t,n,r,i).freeze)(e,e=>{Vi(e,t,n,r,i)})),Ui=((e,t,n,r,i)=>Vi(e,t,n,r,i)),Wi=(e,t,n,r,i={})=>{let{resetOnFieldChange:a=!0,resetOnOperatorChange:o=!1,getRuleDefaultOperator:s=()=>`=`,getValueSources:c=()=>[`value`],getRuleDefaultValue:l=()=>``,getMatchModes:u=()=>[],onAbort:d}=i,f=a,p=Array.isArray(r)?r:Gr(r,e);if(!p)return d?.({reason:`target-not-found`,operation:`update`,pathOrID:r}),e;let m=t===`disabled`?{queryDisabled:i.queryDisabled}:i,h=Ni(e,p,m);if(h)return d?.({reason:h,operation:`update`,pathOrID:r}),e;if(t===`combinator`&&!I(e)){let t=X(Z(p),e);if(!t||!F(t))return d?.({reason:`target-not-found`,operation:`update`,pathOrID:r}),e;let i=t.rules;return p.at(-1)%2==1?i[p.at(-1)]===n?d?.({reason:`no-change`,operation:`update`,pathOrID:r}):i[p.at(-1)]=n:d?.({reason:`not-a-combinator-slot`,operation:`update`,pathOrID:r}),e}let g=X(p,e);if(!g)return d?.({reason:`target-not-found`,operation:`update`,pathOrID:r}),e;let _=F(g);if(g[t]===n)return d?.({reason:`no-change`,operation:`update`,pathOrID:r}),e;if(t!==`valueSource`&&(g[t]=n),_)return e;let v=!1,y=!1;if(t===`field`){let e=u(g.field),t=u(n);if(t.length===0)delete g.match;else{let e=g.match?.mode&&V(t,g.match.mode)?null:H(t);e&&(g.match={mode:e,threshold:1})}(e.length>0||t.length>0)&&(f=!0)}f&&t===`field`&&(g.operator=s(n),v=!0,y=!0),o&&t===`operator`&&(v=!0,y=!0);let b=H(di({name:g.field,value:g.field,label:``},g.operator,c));return(v&&g.valueSource&&b!==g.valueSource||t===`valueSource`&&n!==g.valueSource)&&(y=!!g.valueSource||!g.valueSource&&n!==b,g.valueSource=v?b:n),y&&(g.value=l(g)),e},Gi=(e,t,n={})=>ri(n.freeze)(e,e=>Ki(e,t,n)),Ki=(e,t,n={})=>{let{onAbort:r}=n,i=Array.isArray(t)?t:Gr(t,e);if(!i)return r?.({reason:`target-not-found`,operation:`remove`,pathOrID:t}),e;if(i.length===0)return r?.({reason:`root-not-allowed`,operation:`remove`,pathOrID:t}),e;let a=Ni(e,i,n);if(a)return r?.({reason:a,operation:`remove`,pathOrID:t}),e;if(!X(i,e))return r?.({reason:`target-not-found`,operation:`remove`,pathOrID:t}),e;let o=i.at(-1),s=X(Z(i),e);if(!I(s)&&s.rules.length>1){let e=o===0?0:o-1;s.rules.splice(e,2)}else s.rules.splice(o,1);return e},qi=(e,t,n)=>{if(Array.isArray(n))return n;let r=L(e);if(n===`up`){if(Kr(t,[0]))return t;if(t.at(-1)===0){let e=Z(t);return[...Z(e),Math.max(0,e.at(-1)-+!!r)]}{let n=[...Z(t),Math.max(0,t.at(-1)-(r?2:1))],i=X(n,e);return F(i)?[...n,i.rules.length]:[...Z(t),Math.max(0,t.at(-1)-(r?3:1))]}}if(n===`down`){if(Kr([e.rules.length-1],t))return t;if(t.at(-1)===X(Z(t),e).rules.length-1){let e=Z(t);return[...Z(e),e.at(-1)+1]}{let n=[...Z(t),t.at(-1)+(r?2:1)],i=X(n,e);return F(i)?[...n,0]:[...Z(t),t.at(-1)+(r?3:2)]}}return t},Ji=(e,t,n,r={})=>ri(r.freeze)(e,e=>Yi(e,t,n,r)),Yi=(e,n,r,i={})=>{let{clone:a=!1,combinators:o=S,idGenerator:s=Q,onAbort:c}=i,l=Array.isArray(n)?n:Gr(n,e);if(!l)return c?.({reason:`target-not-found`,operation:`move`,pathOrID:n}),e;let u=X(l,e);if(!u)return c?.({reason:`target-not-found`,operation:`move`,pathOrID:n}),e;let d=qi(e,l,r);if(l.length===0)return c?.({reason:`root-not-allowed`,operation:`move`,pathOrID:n}),e;let f=Ni(e,l,i);if(f)return c?.({reason:f,operation:`move`,pathOrID:n}),e;if(Kr(l,d))return c?.({reason:`same-location`,operation:`move`,pathOrID:n}),e;if(!X(Z(d),e)||!a&&qr(l,d))return c?.({reason:`destination-not-found`,operation:`move`,pathOrID:r}),e;let p=a?Mi((0,t.isDraft)(u)?(0,t.current)(u):u,{idGenerator:s}):u,m=L(e),h=X(Z(l),e),g=l.at(-1),_=m&&g>0?h.rules[g-1]:null,v=m&&g<h.rules.length-1?h.rules[g+1]:null;if(!a){let e=m?Math.max(0,g-1):g,t=m?2:1;h.rules.splice(e,t)}let y=[...d];m&&y.at(-1)%2==1&&(y[y.length-1]+=1);let b=Jr(l,d);!a&&l.length===b.length+1&&y[b.length]>l[b.length]&&(y[b.length]-=m?2:1);let x=Z(y),C=X(x,e),w=y.at(-1),T=m&&w>0?w-1:w,E=(...e)=>C.rules.splice(T,0,...e);return C.rules.length===0||!m?E(p):w===0?g===0&&v?E(p,v):E(p,C.rules[1]??_??H(o)):E(_||(C.rules[T-2]??v??H(o)),p),e},Xi=(e,t,n,r={})=>ri(r.freeze)(e,e=>Zi(e,t,n,r)),Zi=(e,t,n,r={})=>{let{combinators:i=S,combinatorPreceding:a,combinatorSucceeding:o,idGenerator:s=Q,replace:c=!1,onAbort:l}=r,u=X(Z(n),e);if(!u)return l?.({reason:`parent-not-found`,operation:`insert`,pathOrID:n}),e;if(!F(u))return l?.({reason:`parent-not-a-group`,operation:`insert`,pathOrID:n}),e;let d=Z(n),f=Ni(e,d,r,{asParent:!0});if(f)return l?.({reason:f,operation:`insert`,pathOrID:n}),e;if(F(t)&&Pi(d,r))return l?.({reason:`max-levels-exceeded`,operation:`insert`,pathOrID:n}),e;let p=Mi(t,{idGenerator:s}),m=L(e),h=n.at(-1),g=(e,...t)=>u.rules.splice(e,c?t.length:0,...t);if(u.rules.length===0||!m)g(h,p);else if(c&&m)g(h+h%2,p);else if(h===0)p.path?.at(-1)===0&&o?g(h,p,o):g(h,p,u.rules[1]??a??H(i));else{let e=h%2==0?h-1:h;a?g(e,a,p):g(e,u.rules[e-2]??o??H(i),p)}return e},Qi=(e,t,n,r={})=>ri(r.freeze)(e,e=>$i(e,t,n,r)),$i=(e,n,r,i={})=>{let{clone:a=!1,combinators:o=S,idGenerator:s=Q,onAbort:c}=i,l=Array.isArray(n)?n:Gr(n,e),u=Array.isArray(r)?r:Gr(r,e);if(!l)return c?.({reason:`target-not-found`,operation:`group`,pathOrID:n}),e;if(!u)return c?.({reason:`target-not-found`,operation:`group`,pathOrID:r}),e;let d=qi(e,l,u);if(l.length===0)return c?.({reason:`root-not-allowed`,operation:`group`,pathOrID:n}),e;let f=Ni(e,l,i);if(f)return c?.({reason:f,operation:`group`,pathOrID:n}),e;if(Kr(l,d))return c?.({reason:`same-location`,operation:`group`,pathOrID:n}),e;if(!X(Z(d),e)||!a&&qr(l,d))return c?.({reason:`destination-not-found`,operation:`group`,pathOrID:r}),e;let p=X(l,e),m=X(u,e);if(!p)return c?.({reason:`target-not-found`,operation:`group`,pathOrID:n}),e;if(!m)return c?.({reason:`target-not-found`,operation:`group`,pathOrID:r}),e;let h=a?Mi((0,t.isDraft)(p)?(0,t.current)(p):p,{idGenerator:s}):p,g=L(e),_=X(Z(l),e),v=l.at(-1);if(!a){let e=g?Math.max(0,v-1):v,t=g?2:1;_.rules.splice(e,t)}let y=[...d],b=Jr(l,d);!a&&l.length===b.length+1&&d[b.length]>l[b.length]&&(y[b.length]-=g?2:1);let x=Z(y),C=X(x,e),w=y.at(-1);return C.rules.splice(w,1,ki(g?{rules:[m,H(o),h]}:{combinator:H(o),rules:[m,h]},{idGenerator:s})),e},ea=(e={})=>{let{qbId:t,combinators:n,idGenerator:r,maxLevels:i=1/0,queryDisabled:a,respectDisabled:o=!0,disabledPaths:s,resetOnFieldChange:c,resetOnOperatorChange:l,getRuleDefaultOperator:u,getValueSources:d,getRuleDefaultValue:f,getMatchModes:p,freeze:m,onAddRule:h,onAddGroup:g,onRemove:_,onMoveRule:v,onMoveGroup:y,onGroupRule:b,onGroupGroup:x,onLog:S}=e,C=e=>S?.({qbId:t,...e}),w={respectDisabled:o,queryDisabled:a,disabledPaths:s},T=(e,t,n=!1)=>!!Ni(e,t,w,{asParent:n});return{addRule:(e,t,i,a)=>{if(T(e,i,!0)){C({type:k.parentPathDisabled,rule:t,parentPath:i,query:e});return}let o=!h||h(t,i,e,a);if(!o){C({type:k.onAddRuleFalse,rule:t,parentPath:i,query:e});return}let s=o===!0?t:o,c=Fi(e,s,i,{combinators:n,combinatorPreceding:s.combinatorPreceding,idGenerator:r,freeze:m});return C({type:k.add,query:e,newQuery:c,newRule:s,parentPath:i}),c},addGroup:(e,t,a,o)=>{if(a.length>=i)return;if(T(e,a,!0)){C({type:k.parentPathDisabled,ruleGroup:t,parentPath:a,query:e});return}let s=!g||g(t,a,e,o);if(!s){C({type:k.onAddGroupFalse,ruleGroup:t,parentPath:a,query:e});return}let c=s===!0?t:s,l=Fi(e,c,a,{combinators:n,combinatorPreceding:c.combinatorPreceding??void 0,idGenerator:r,freeze:m});return C({type:k.add,query:e,newQuery:l,newGroup:c,parentPath:a}),l},propChange:(e,t,n,r)=>{if(Ni(e,r,t===`disabled`?{queryDisabled:a}:w)){C({type:k.pathDisabled,path:r,prop:t,value:n,query:e});return}let i=Hi(e,t,n,r,{resetOnFieldChange:c,resetOnOperatorChange:l,getRuleDefaultOperator:u,getValueSources:d,getRuleDefaultValue:f,getMatchModes:p,freeze:m});return C({type:k.update,query:e,newQuery:i,prop:t,value:n,path:r}),i},removeRuleOrGroup:(e,t,n)=>{if(T(e,t)){C({type:k.pathDisabled,path:t,query:e});return}let r=X(t,e);if(!r)return;if(_&&!_(r,t,e,n)){C({type:k.onRemoveFalse,ruleOrGroup:r,path:t,query:e});return}let i=Gi(e,t,{freeze:m});return C({type:k.remove,query:e,newQuery:i,path:t,ruleOrGroup:r}),i},moveRule:(e,t,i,a,o)=>{if(T(e,t)){C({type:k.pathDisabled,oldPath:t,newPath:i,query:e});return}let s=X(t,e);if(!s)return;let c=Ji(e,t,i,{clone:a,combinators:n,idGenerator:r,freeze:m}),l=F(s),u=l?y:v,d=!u||u(s,t,i,e,c,{clone:a,combinators:n},o);if(!d){C({type:l?k.onMoveGroupFalse:k.onMoveRuleFalse,ruleOrGroup:s,oldPath:t,newPath:i,clone:a,query:e,nextQuery:c});return}let f=F(d)?d:c;return C({type:k.move,query:e,newQuery:f,oldPath:t,newPath:i,clone:a}),f},groupRule:(e,t,i,a,o)=>{if(T(e,t)){C({type:k.pathDisabled,sourcePath:t,targetPath:i,query:e});return}let s=X(t,e);if(!s)return;let c=Qi(e,t,i,{clone:a,combinators:n,idGenerator:r,freeze:m}),l=F(s),u=l?x:b,d=!u||u(s,t,i,e,c,{clone:a,combinators:n},o);if(!d){C({type:l?k.onGroupGroupFalse:k.onGroupRuleFalse,ruleOrGroup:s,sourcePath:t,targetPath:i,clone:a,query:e,nextQuery:c});return}let f=F(d)?d:c;return C({type:k.group,query:e,newQuery:f,sourcePath:t,targetPath:i,clone:a}),f}}},ta=({fields:e,getDefaultField:t,getRuleDefaultOperator:n,getValueSources:r,getMatchModes:i,getRuleDefaultValue:a,idGenerator:o=Q})=>{let s=H(e)??``;if(t){if(typeof t==`function`){let n=t(e);n&&(s=n)}else s=t}let c=V(e,s),l=n(s),u=H(r(s,l,{fieldData:c}))??`value`,d=H(i(s,{fieldData:c})),f={id:o(),field:s,operator:l,valueSource:u,value:``,...d?{match:{mode:d,threshold:1}}:null};return{...f,value:a(f)}},na=({combinators:e,addRuleToNewGroups:t,createRule:n,idGenerator:r=Q},i)=>{let a=r(),o=t?[n()]:[];return i?{id:a,rules:o,not:!1}:{id:a,rules:o,combinator:H(e)??``,not:!1}};var ra=class e extends Error{code;info;constructor(t){super(`QueryManager: "${t.operation}" aborted (${t.reason})${t.pathOrID===void 0?``:` for target ${JSON.stringify(t.pathOrID)}`}.`),this.name=`QueryManagerError`,this.code=t.reason,this.info=t,Object.setPrototypeOf(this,e.prototype)}};const ia=Symbol(`QueryManager.state`),aa=(0,t.freeze)({query:!0,config:!1}),oa=(0,t.freeze)({query:!1,config:!0}),sa=(0,t.freeze)({query:!0,config:!0}),ca=()=>{let e={listeners:new Set,configVersion:0,past:[],future:[],lastAt:0,batchDepth:0,historyBypassed:!1,pendingConfigNotify:!1};return Object.defineProperty(e,"__v_skip",{value:!0,enumerable:!1}),e};var la=class e{get state(){return this[ia]}constructor(e,t={}){Object.defineProperty(this,ia,{value:ca(),enumerable:!1,writable:!1,configurable:!1}),this.applyOptions(t),this.state.query=this.freeze(e?Oi(e,{idGenerator:this.state.idGenerator}):this.createRuleGroup())}freeze(e){return this.state.freezeEnabled?(0,t.freeze)(e,!0):e}applyOptions(e){this.state.options=e,this.state.freezeEnabled=e.freeze??!0,this.state.idGenerator=e.idGenerator??Q,this.state.validator=e.validator??Ie,this.state.strict=e.strict??!1,this.state.respectDisabled=e.respectDisabled??!0,this.state.onInvalidTarget=e.onInvalidTarget;let t=e.history??!1,n=typeof t==`object`?t:{};this.state.historyEnabled=t!==!1,this.state.maxHistory=n.maxHistory??50,this.state.coalesceMs=n.coalesceMs??500,this.state.now=e.now??Date.now;let{optionList:r,optionsMap:i}=$e({optionList:e.fields,baseOption:e.baseField,autoSelectOption:e.autoSelectField,placeholder:e.translations?.fields});this.state.fields=this.freeze(r),this.state.fieldMap=this.freeze(i),this.state.operators=$e({optionList:e.operators??h,baseOption:e.baseOperator,labelMap:p,autoSelectOption:e.autoSelectOperator,placeholder:e.translations?.operators}).optionList,this.state.combinators=this.freeze($e({optionList:e.combinators??S,baseOption:e.baseCombinator}).optionList)}fieldData(e){return this.state.fieldMap[e]??{}}operatorsFor(e){return hi({field:e,fieldData:this.fieldData(e),getOperators:this.state.options.getOperators,operators:this.state.operators,baseOption:this.state.options.baseOperator,autoSelectOption:this.state.options.autoSelectOperator,placeholder:this.state.options.translations?.operators})}defaultOperator(e){return gi({field:e,fieldData:this.fieldData(e),getDefaultOperator:this.state.options.getDefaultOperator,getOperators:e=>this.operatorsFor(e)})}valueSourcesFor(e,t){return di(this.fieldData(e),t,this.state.options.getValueSources)}matchModesFor(e){return ai(this.fieldData(e),this.state.options.getMatchModes)}valuesFor(e,t){return vi({field:e,operator:t,fieldData:this.fieldData(e),getValues:this.state.options.getValues,autoSelectOption:this.state.options.autoSelectValue,placeholder:this.state.options.translations?.values})}valueEditorTypeFor(e,t){return _i({field:e,operator:t,fieldData:this.fieldData(e),getValueEditorType:this.state.options.getValueEditorType})}defaultValue(e){let{getDefaultValue:t,getParameters:n,listsAsArrays:r}=this.state.options;return si(e,{fieldData:this.fieldData(e.field),fields:this.state.fields,listsAsArrays:r,getValueEditorType:(e,t)=>this.valueEditorTypeFor(e,t),getValues:(e,t)=>this.valuesFor(e,t),getDefaultValue:t&&((e,n)=>t(e,n)),getParameters:n&&((e,t,n)=>this.parametersFor(e,t,n))})}parametersFor(e,t,n){return $e({optionList:this.state.options.getParameters?.(e,t,n)??[],autoSelectOption:this.state.options.autoSelectValue}).optionList}guardOptions(){let{maxLevels:e}=this.state.options;return{freeze:this.state.freezeEnabled,maxLevels:(e??0)>0?Number(e):1/0,respectDisabled:this.state.respectDisabled,disabledPaths:this.state.options.disabledPaths,queryDisabled:this.state.options.queryDisabled}}toolOptions(){return{combinators:this.state.combinators,idGenerator:this.state.idGenerator,...this.guardOptions()}}onAbort({strict:e,onInvalidTarget:t}){let n=e??this.state.strict,r=t??this.state.onInvalidTarget;return e=>{if(r?.(e),n&&re.has(e.reason))throw new ra(e)}}updateOptions(){return{getRuleDefaultOperator:e=>this.defaultOperator(e),getRuleDefaultValue:e=>this.defaultValue(e),getValueSources:(e,t)=>this.valueSourcesFor(e,t),getMatchModes:e=>this.matchModesFor(e),resetOnFieldChange:this.state.options.resetOnFieldChange,resetOnOperatorChange:this.state.options.resetOnOperatorChange,...this.guardOptions()}}commit(e){let t=this.state.query;t!==e&&(this.state.query=e,!(this.state.batchDepth>0)&&(this.record(t,e),this.notify(aa)))}record(e,t){if(!this.state.historyEnabled)return;let n=me(e,t);if(n===``)return;let r=this.state.now();he(this.state.lastSig,n,this.state.lastAt,r,this.state.coalesceMs)||(this.state.past.push(e),this.state.past.length>this.state.maxHistory&&this.state.past.shift(),this.state.future=[]),this.state.lastSig=n,this.state.lastAt=r}notify(e){for(let t of this.state.listeners)t(e)}markHistoryBypassed(){this.state.batchDepth>0&&(this.state.historyBypassed=!0)}ensureCache(){this.state.cacheFor!==this.state.query&&(this.state.cacheFor=this.state.query,this.state.idPathIndex=void 0,this.state.validation=void 0)}*walkFrom(e,t,n){if(yield{node:e,path:t,parent:n},!F(e))return;let r=e;for(let[e,n]of r.rules.entries())typeof n!=`string`&&(yield*this.walkFrom(n,[...t,e],r))}index(){if(this.ensureCache(),!this.state.idPathIndex){let e=new Map;for(let{node:t,path:n}of this.walkFrom(this.state.query,[],null))t.id!==void 0&&!e.has(t.id)&&e.set(t.id,n);this.state.idPathIndex=e}return this.state.idPathIndex}toPath(e){return typeof e==`string`?this.index().get(e)??null:e}getQuery=()=>this.state.query;setQuery(e){return this.commit(this.freeze(Oi(e,{idGenerator:this.state.idGenerator}))),this}createRule(){return ta({fields:this.state.fields,getDefaultField:this.state.options.getDefaultField,getRuleDefaultOperator:e=>this.defaultOperator(e),getValueSources:(e,t)=>this.valueSourcesFor(e,t),getMatchModes:e=>this.matchModesFor(e),getRuleDefaultValue:e=>this.defaultValue(e),idGenerator:this.state.idGenerator})}createRuleGroup(e){return na({combinators:this.state.combinators,addRuleToNewGroups:this.state.options.addRuleToNewGroups,createRule:()=>this.createRule(),idGenerator:this.state.idGenerator},e)}add(e,t=[],n={}){let{strict:r,onInvalidTarget:i,...a}=n;return this.commit(Fi(this.state.query,e,t,{...this.toolOptions(),...a,onAbort:this.onAbort({strict:r,onInvalidTarget:i})})),this}remove(e,t={}){let{strict:n,onInvalidTarget:r,...i}=t;return this.commit(Gi(this.state.query,e,{...this.guardOptions(),...i,onAbort:this.onAbort({strict:n,onInvalidTarget:r})})),this}update(e,t,n,r){let i=typeof e==`string`||Array.isArray(e)?3:2,a=[e,t,n,r],{strict:o,onInvalidTarget:s,...c}=a[i]??{};return a[i]={...this.updateOptions(),...c,onAbort:this.onAbort({strict:o,onInvalidTarget:s})},this.commit(Hi(this.state.query,...a.slice(0,i+1))),this}move(e,t,n={}){let{strict:r,onInvalidTarget:i,...a}=n;return this.commit(Ji(this.state.query,e,t,{...this.toolOptions(),...a,onAbort:this.onAbort({strict:r,onInvalidTarget:i})})),this}insert(e,t,n={}){let{strict:r,onInvalidTarget:i,...a}=n;return this.commit(Xi(this.state.query,e,t,{...this.toolOptions(),...a,onAbort:this.onAbort({strict:r,onInvalidTarget:i})})),this}group(e,t,n={}){let{strict:r,onInvalidTarget:i,...a}=n;return this.commit(Qi(this.state.query,e,t,{...this.toolOptions(),...a,onAbort:this.onAbort({strict:r,onInvalidTarget:i})})),this}getOptions(){return(0,t.freeze)({...this.state.options})}reconfigure(e,n){let r=n?.replace?{...e}:{...this.state.options,...e};return xi(this.state.options,r)?this:(this.applyOptions((0,t.freeze)(r)),this.state.validation=void 0,this.reconcileHistoryConfig(),++this.state.configVersion,this.state.batchDepth>0?this.state.pendingConfigNotify=!0:this.notify(oa),this)}reconcileHistoryConfig(){this.state.historyEnabled?this.state.past.length>this.state.maxHistory&&this.state.past.splice(0,this.state.past.length-this.state.maxHistory):(this.state.past=[],this.state.future=[],this.state.lastSig=void 0)}getConfigVersion=()=>this.state.configVersion;clone(t){let n=t?.regenerateIDs?Mi(this.state.query,{idGenerator:this.state.idGenerator}):this.state.query;return new e(n,this.state.options)}subscribe=e=>(this.state.listeners.add(e),()=>{this.state.listeners.delete(e)});batch(e){this.state.batchDepth++,this.state.batchDepth===1&&(this.state.batchSnapshot={query:this.state.query,past:[...this.state.past],future:[...this.state.future],lastSig:this.state.lastSig,lastAt:this.state.lastAt});try{e()}catch(e){if(this.state.batchDepth===1){let e=this.state.batchSnapshot;this.state.query=e.query,this.state.past=e.past,this.state.future=e.future,this.state.lastSig=e.lastSig,this.state.lastAt=e.lastAt,this.reconcileHistoryConfig()}throw e}finally{if(this.state.batchDepth--,this.state.batchDepth===0){let{query:e}=this.state.batchSnapshot;this.state.batchSnapshot=void 0;let t=e!==this.state.query,n=this.state.pendingConfigNotify;this.state.pendingConfigNotify=!1,t&&(this.state.historyBypassed||this.record(e,this.state.query)),(t||n)&&this.notify(t?n?sa:aa:oa),this.state.historyBypassed=!1}}return this}canUndo(){return this.state.past.length>0}canRedo(){return this.state.future.length>0}undo(){return this.state.past.length===0?this:(this.state.future.unshift(this.state.query),this.state.query=this.state.past.pop(),this.state.lastSig=void 0,this.markHistoryBypassed(),this.state.batchDepth===0&&this.notify(aa),this)}redo(){return this.state.future.length===0?this:(this.state.past.push(this.state.query),this.state.query=this.state.future.shift(),this.state.lastSig=void 0,this.markHistoryBypassed(),this.state.batchDepth===0&&this.notify(aa),this)}clearHistory(){return this.markHistoryBypassed(),this.state.past=[],this.state.future=[],this.state.lastSig=void 0,this}getHistory(){return{past:[...this.state.past],future:[...this.state.future]}}validate(){return this.ensureCache(),this.state.validation??=this.state.validator(this.state.query),this.state.validation}format(e){return Fr(this.state.query,e)}*walk(e={}){let{from:t,rulesOnly:n,groupsOnly:r}=e,i=this.state.query,a=[],o=null;if(t!==void 0){let e=this.toPath(t),n=e&&X(e,this.state.query);if(!e||!n)return;i=n,a=e,o=e.length===0?null:X(Z(e),this.state.query)}for(let e of this.walkFrom(i,a,o))n&&F(e.node)||r&&!F(e.node)||(yield e)}rules(e={}){return this.walk({...e,rulesOnly:!0})}groups(e={}){return this.walk({...e,groupsOnly:!0})}find(e,t={}){for(let n of this.walk(t))if(e(n))return n;return null}filter(e,t={}){let n=[];for(let r of this.walk(t))e(r)&&n.push(r);return n}[Symbol.iterator](){return this.walk()}findPath(e){return X(e,this.state.query)??null}findID(e){let t=this.index().get(e);return t===void 0?null:X(t,this.state.query)}getPathOfID(e){return this.index().get(e)??null}pathIsDisabled(e){return Yr(e,this.state.query)}getNode(e){let t=this.toPath(e);return t===null?null:X(t,this.state.query)??null}getRule(e){let t=this.getNode(e);return t&&!F(t)?t:null}getGroup(e){let t=this.getNode(e);return t&&F(t)?t:null}getParent(e){let t=this.toPath(e);return t===null||t.length===0||!X(t,this.state.query)?null:X(Z(t),this.state.query)}getFields(){return this.state.fields}getCombinators(){return this.state.combinators}getFieldData(e){return nt(e,this.state.fieldMap)}getOperators(e){return this.operatorsFor(e)}getValueSources(e,t){return this.valueSourcesFor(e,t)}getMatchModes(e){return this.matchModesFor(e)}getValues(e,t){return this.valuesFor(e,t)}getValueEditorType(e,t){return this.valueEditorTypeFor(e,t)}getRuleDefaultOperator(e){return this.defaultOperator(e)}getRuleDefaultValue(e){return this.defaultValue(e)}getFieldMap(){return this.state.fieldMap}getRuleContext(e){let t=this.getRule(e);if(!t)return null;let n=this.validate();return ut(t,{fields:this.state.fields,fieldMap:this.state.fieldMap,getInputType:(e,t,n)=>this.state.options.getInputType?.(e,t,n)??null,getMatchModes:e=>this.matchModesFor(e),getOperators:e=>this.operatorsFor(e),getParameters:(e,t,n)=>this.parametersFor(e,t,n),getValueEditorType:(e,t)=>this.valueEditorTypeFor(e,t),getValues:(e,t)=>this.valuesFor(e,t),getValueSources:(e,t)=>this.getValueSources(e,t),getSubQueryBuilderProps:(e,t)=>this.state.options.getSubQueryBuilderProps?.(e,t)??{}},{validationMap:typeof n==`boolean`?{}:n,id:t.id})}getRuleGroupContext(e=[]){let t=this.getGroup(e);if(!t)return null;let n=this.validate();return ft(t,this.state.combinators,{validationMap:typeof n==`boolean`?{}:n,id:t.id})}isIC(){return L(this.state.query)}signatureOf(e){return me(this.state.query,e)}diagnostics(){return Fr(this.state.query,`diagnostics`)}toJSON(){return this.state.query}toIC(){return new e(ye(this.state.query),this.state.options)}fromIC(){return new e(R(this.state.query),this.state.options)}transform(e){return W(this.state.query,e)}};exports.LogType=k,exports.QueryManager=la,exports.QueryManagerError=ra,exports.TestID=O,exports.add=Fi,exports.addInPlace=Ii,exports.betweenOperators=x,exports.bigIntJsonParseReviver=Kt,exports.bigIntJsonStringifyReplacer=Gt,exports.celCombinatorMap=At,exports.clsx=ce,exports.coerceBigIntValue=_t,exports.coerceInputType=vt,exports.controlKeys=n,exports.controlKind=i,exports.controlPropKeys=r,exports.convertFromIC=R,exports.convertQuery=be,exports.convertToIC=ye,exports.createQueryActions=ea,exports.createRule=ta,exports.createRuleGroup=na,exports.cypherCombinatorMap=un,exports.defaultCELValueProcessor=zr,exports.defaultCoalesceMs=500,exports.defaultCombinatorLabelMap=m,exports.defaultCombinators=S,exports.defaultCombinatorsExtended=C,exports.defaultControlClassnames=E,exports.defaultExportOperatorMap=pr,exports.defaultJoinChar=`,`,exports.defaultMatchModes=w,exports.defaultMaxHistory=50,exports.defaultMongoDBValueProcessor=Rr,exports.defaultNLTranslations=Bt,exports.defaultOperatorLabelMap=p,exports.defaultOperatorNegationMap=g,exports.defaultOperatorProcessorNL=hr,exports.defaultOperatorProcessorSQL=_r,exports.defaultOperators=h,exports.defaultPlaceholderFieldGroupLabel=s,exports.defaultPlaceholderFieldLabel=o,exports.defaultPlaceholderFieldName=`~`,exports.defaultPlaceholderLabel=a,exports.defaultPlaceholderName=`~`,exports.defaultPlaceholderOperatorGroupLabel=l,exports.defaultPlaceholderOperatorLabel=c,exports.defaultPlaceholderOperatorName=`~`,exports.defaultPlaceholderValueGroupLabel=d,exports.defaultPlaceholderValueLabel=u,exports.defaultPlaceholderValueName=`~`,exports.defaultRuleGroupProcessorCEL=qt,exports.defaultRuleGroupProcessorCypher=dn,exports.defaultRuleGroupProcessorDiagnostics=Rn,exports.defaultRuleGroupProcessorDrizzle=fn,exports.defaultRuleGroupProcessorElasticSearch=pn,exports.defaultRuleGroupProcessorGremlin=mn,exports.defaultRuleGroupProcessorJSONata=hn,exports.defaultRuleGroupProcessorJsonLogic=gn,exports.defaultRuleGroupProcessorLDAP=_n,exports.defaultRuleGroupProcessorMongoDB=yn,exports.defaultRuleGroupProcessorMongoDBQuery=Qt,exports.defaultRuleGroupProcessorNL=bn,exports.defaultRuleGroupProcessorParameterized=xn,exports.defaultRuleGroupProcessorPrisma=Cn,exports.defaultRuleGroupProcessorSPARQL=Tn,exports.defaultRuleGroupProcessorSQL=En,exports.defaultRuleGroupProcessorSequelize=wn,exports.defaultRuleGroupProcessorSpEL=nn,exports.defaultRuleGroupProcessorTanStackDB=Dn,exports.defaultRuleProcessorCEL=Xt,exports.defaultRuleProcessorCypher=Un,exports.defaultRuleProcessorDrizzle=Wn,exports.defaultRuleProcessorElasticSearch=Zn,exports.defaultRuleProcessorGremlin=$n,exports.defaultRuleProcessorJSONata=ir,exports.defaultRuleProcessorJsonLogic=sr,exports.defaultRuleProcessorLDAP=ur,exports.defaultRuleProcessorMongoDB=tn,exports.defaultRuleProcessorMongoDBQuery=en,exports.defaultRuleProcessorNL=gr,exports.defaultRuleProcessorParameterized=yr,exports.defaultRuleProcessorPrisma=xr,exports.defaultRuleProcessorSPARQL=Tr,exports.defaultRuleProcessorSQL=vr,exports.defaultRuleProcessorSequelize=Sr,exports.defaultRuleProcessorSpEL=sn,exports.defaultRuleProcessorTanStackDB=Er,exports.defaultSpELValueProcessor=Br,exports.defaultTranslations=f,exports.defaultValidator=Ie,exports.defaultValueProcessor=Lr,exports.defaultValueProcessorByRule=ln,exports.defaultValueProcessorCELByRule=Vr,exports.defaultValueProcessorMongoDBByRule=Hr,exports.defaultValueProcessorNL=fr,exports.defaultValueProcessorSpELByRule=Ur,exports.derivePathInfo=Zr,exports.deriveQueryBuilderClassNames=Fe,exports.deriveRuleClassName=Ae,exports.deriveRuleClassNames=ke,exports.deriveRuleContext=ut,exports.deriveRuleGroupClassNames=je,exports.deriveRuleGroupContext=ft,exports.deriveRuleGroupOuterClassName=Pe,exports.deriveRuleOuterClassName=Ne,exports.exceedsMaxLevels=Pi,exports.filterFieldsByComparator=tt,exports.findID=Wr,exports.findPath=X,exports.formatQuery=Fr,exports.formatQueryOptionPresets=Or,exports.generateAccessibleDescription=Qr,Object.defineProperty(exports,"generateID",{enumerable:!0,get:function(){return Q}}),exports.getCommonAncestorPath=Jr,exports.getFieldData=nt,exports.getFirstOption=H,exports.getGuardAbortReason=Ni,exports.getLikeWildcards=Et,exports.getMatchModesUtil=ai,exports.getMultiValueUpdate=gt,exports.getNLTranslataion=Ht,exports.getOption=V,exports.getParametersAsList=ot,exports.getParentPath=Z,exports.getParseNumberMethod=Ct,exports.getPathOfID=Gr,exports.getQuoteFieldNamesWithArray=Pt,exports.getQuotedFieldName=Ft,exports.getRuleDefaultValue=si,exports.getRuleGroupCombinator=dt,exports.getRuleInputType=rt,exports.getRuleValidationResult=lt,exports.getRuleValueEditorType=st,exports.getRuleValueSourceOptions=at,exports.getRuleValues=ct,exports.getSQLConcat=Tt,exports.getSubqueryElementAlias=Wt,exports.getValidationClassNames=ci,exports.getValueEditorReset=ht,exports.getValueSelectorUpdate=yt,exports.getValueSourcesUtil=di,exports.group=Qi,exports.groupInPlace=$i,exports.groupInvalidReasons=D,exports.hideValueControlsForOperator=it,exports.inOperators=b,exports.insert=Xi,exports.insertInPlace=Zi,exports.isAncestor=qr,exports.isBetweenOperator=mt,exports.isFlexibleOptionArray=Ke,exports.isFlexibleOptionGroupArray=Je,exports.isFullOptionArray=qe,exports.isFullOptionGroupArray=Ye,exports.isOptionGroupArray=Ge,exports.isPojo=N,exports.isRuleGroup=F,exports.isRuleGroupType=I,exports.isRuleGroupTypeIC=L,exports.isRuleOrGroupValid=G,exports.isRuleType=ue,exports.isUnsafeKey=ze,exports.isValidValue=K,exports.isValidationResult=St,exports.isValueProcessorLegacy=Nt,exports.joinWith=ae,exports.jsonLogicAdditionalOperators=jt,exports.lc=M,exports.mapSQLOperator=wt,exports.mergeAnyTranslation=pi,exports.mergeAnyTranslations=fi,exports.mergeClassnames=mi,exports.mongoDbFallback=Zt,exports.mongoOperators=Ot,exports.move=Ji,exports.moveInPlace=Yi,exports.normalizeConstituentWordOrder=Lt,exports.normalizeValueSelectorValue=bt,exports.nullFreeArray=oe,exports.nullOperators=y,exports.nullOrUndefinedOrEmpty=P,exports.numericRegex=le,exports.numerifyValues=Mt,exports.objectEntries=Re,exports.objectKeys=Le,exports.optionsEqual=xi,exports.parseNumber=U,exports.pathIsDisabled=Yr,exports.pathIsDisabledByPaths=Xr,exports.pathsAreEqual=Kr,exports.preferAnyProp=Ti,exports.preferFlagProps=Ei,exports.preferProp=wi,exports.prepareOptionList=$e,exports.prepareRule=Di,exports.prepareRuleGroup=Oi,exports.prepareRuleOrGroup=ki,exports.prismaFallback=Sn,exports.prismaOperators=kt,exports.processMatchMode=J,exports.queryBuilderFlagDefaults=te,exports.regenerateID=ji,exports.regenerateIDs=Mi,exports.relationalOperators=_,exports.remove=Gi,exports.removeInPlace=Ki,exports.resolveCandidateQuery=Ai,exports.resolveDefaultOperator=gi,exports.resolveOperatorList=hi,exports.resolveValueEditorType=_i,exports.resolveValueList=vi,exports.rootPath=ee,exports.setAutoFreeze=ti,exports.shouldCoalesce=he,exports.shouldRenderAsNumber=q,exports.signatureOf=me,exports.sparqlVar=wr,exports.splitBy=ie,exports.sqlDialectPresets=Dr,exports.standardClassnames=T,exports.strictAbortReasons=ne,exports.stripParamPrefix=zt,exports.structuralSignature=de,exports.subqueryElementAliasBase=Ut,exports.substringOperators=v,exports.toArray=j,exports.toFlatOptionArray=Xe,exports.toFullOption=z,exports.toFullOptionList=B,exports.toFullOptionMap=He,exports.transformQuery=W,exports.trimIfString=A,exports.unchangedSignature=``,exports.uniqByIdentifier=We,exports.uniqByName=Ue,exports.uniqOptGroups=Ze,exports.uniqOptList=Qe,exports.update=Hi,exports.updateInPlace=Ui,exports.uuidV4regex=ei,exports.valuesEqual=bi,exports.withParamPrefix=Rt,exports.wrapLikeFragment=Dt;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("numeric-quantity"),t=require("immer");const n=`actionElement.addGroupAction.addRuleAction.cloneGroupAction.cloneRuleAction.combinatorSelector.dragHandle.fieldSelector.inlineCombinator.lockGroupAction.lockRuleAction.matchModeEditor.muteGroupAction.muteRuleAction.notToggle.operatorSelector.removeGroupAction.removeRuleAction.rule.ruleGroup.ruleGroupBodyElements.ruleGroupHeaderElements.shiftActions.undoRedoActions.ungroupAction.valueEditor.valueSelector.valueSourceSelector`.split(`.`),r={actionElement:[`className`,`context`,`disabled`,`disabledTranslation`,`handleOnClick`,`label`,`level`,`path`,`ruleOrGroup`,`rules`,`schema`,`testID`,`title`,`validation`],addGroupAction:[`className`,`context`,`disabled`,`disabledTranslation`,`handleOnClick`,`label`,`level`,`path`,`ruleOrGroup`,`rules`,`schema`,`testID`,`title`,`validation`],addRuleAction:[`className`,`context`,`disabled`,`disabledTranslation`,`handleOnClick`,`label`,`level`,`path`,`ruleOrGroup`,`rules`,`schema`,`testID`,`title`,`validation`],cloneGroupAction:[`className`,`context`,`disabled`,`disabledTranslation`,`handleOnClick`,`label`,`level`,`path`,`ruleOrGroup`,`rules`,`schema`,`testID`,`title`,`validation`],cloneRuleAction:[`className`,`context`,`disabled`,`disabledTranslation`,`handleOnClick`,`label`,`level`,`path`,`ruleOrGroup`,`rules`,`schema`,`testID`,`title`,`validation`],combinatorSelector:[`className`,`context`,`disabled`,`handleOnChange`,`level`,`options`,`path`,`ruleGroup`,`rules`,`schema`,`testID`,`title`,`validation`,`value`],dragHandle:[`className`,`context`,`disabled`,`dragHandleAttributes`,`label`,`level`,`path`,`ruleOrGroup`,`schema`,`testID`,`title`,`validation`],fieldSelector:[`className`,`context`,`disabled`,`handleOnChange`,`level`,`operator`,`options`,`path`,`rule`,`schema`,`testID`,`title`,`validation`,`value`],inlineCombinator:[`className`,`component`,`context`,`disabled`,`handleOnChange`,`level`,`options`,`path`,`ruleGroup`,`rules`,`schema`,`testID`,`title`,`validation`,`value`],lockGroupAction:[`className`,`context`,`disabled`,`disabledTranslation`,`handleOnClick`,`label`,`level`,`path`,`ruleOrGroup`,`rules`,`schema`,`testID`,`title`,`validation`],lockRuleAction:[`className`,`context`,`disabled`,`disabledTranslation`,`handleOnClick`,`label`,`level`,`path`,`ruleOrGroup`,`rules`,`schema`,`testID`,`title`,`validation`],matchModeEditor:[`className`,`classNames`,`context`,`disabled`,`field`,`fieldData`,`handleOnChange`,`level`,`match`,`numericEditorComponent`,`options`,`path`,`rule`,`schema`,`selectorComponent`,`testID`,`thresholdPlaceholder`,`title`,`validation`,`value`],muteGroupAction:[`className`,`context`,`disabled`,`disabledTranslation`,`handleOnClick`,`label`,`level`,`path`,`ruleOrGroup`,`rules`,`schema`,`testID`,`title`,`validation`],muteRuleAction:[`className`,`context`,`disabled`,`disabledTranslation`,`handleOnClick`,`label`,`level`,`path`,`ruleOrGroup`,`rules`,`schema`,`testID`,`title`,`validation`],notToggle:[`checked`,`className`,`context`,`disabled`,`handleOnChange`,`label`,`level`,`path`,`ruleGroup`,`schema`,`testID`,`title`,`validation`],operatorSelector:[`className`,`context`,`disabled`,`field`,`fieldData`,`handleOnChange`,`level`,`options`,`path`,`rule`,`schema`,`testID`,`title`,`validation`,`value`],removeGroupAction:[`className`,`context`,`disabled`,`disabledTranslation`,`handleOnClick`,`label`,`level`,`path`,`ruleOrGroup`,`rules`,`schema`,`testID`,`title`,`validation`],removeRuleAction:[`className`,`context`,`disabled`,`disabledTranslation`,`handleOnClick`,`label`,`level`,`path`,`ruleOrGroup`,`rules`,`schema`,`testID`,`title`,`validation`],rule:`actions.context.disabled.dndRef.dragHandleAttributes.dragMonitorId.dragRef.dropEffect.dropMonitorId.dropNotAllowed.field.groupItems.id.isDragging.isOver.operator.parentDisabled.parentMuted.path.rule.schema.shiftDownDisabled.shiftUpDisabled.translations.value.valueSource`.split(`.`),ruleGroup:`actions.combinator.context.disabled.dragHandleAttributes.dragMonitorId.dragRef.dropEffect.dropMonitorId.dropNotAllowed.dropRef.groupItems.id.isDragging.isOver.not.parentDisabled.parentMuted.path.previewRef.ruleGroup.rules.schema.shiftDownDisabled.shiftUpDisabled.translations`.split(`.`),ruleGroupBodyElements:`accessibleDescription.actions.addGroup.addRule.classNames.cloneGroup.combinator.context.disabled.dragHandleAttributes.dragMonitorId.dragRef.dropEffect.dropMonitorId.dropNotAllowed.dropRef.groupItems.id.isDragging.isOver.muted.not.onCombinatorChange.onGroupAdd.onIndependentCombinatorChange.onNotToggleChange.outerClassName.parentDisabled.parentMuted.path.pathsMemo.previewRef.removeGroup.ruleGroup.rules.schema.shiftDownDisabled.shiftGroupDown.shiftGroupUp.shiftUpDisabled.toggleLockGroup.toggleMuteGroup.translations.ungroup.validationClassName.validationResult`.split(`.`),ruleGroupHeaderElements:`accessibleDescription.actions.addGroup.addRule.classNames.cloneGroup.combinator.context.disabled.dragHandleAttributes.dragMonitorId.dragRef.dropEffect.dropMonitorId.dropNotAllowed.dropRef.groupItems.id.isDragging.isOver.muted.not.onCombinatorChange.onGroupAdd.onIndependentCombinatorChange.onNotToggleChange.outerClassName.parentDisabled.parentMuted.path.pathsMemo.previewRef.removeGroup.ruleGroup.rules.schema.shiftDownDisabled.shiftGroupDown.shiftGroupUp.shiftUpDisabled.toggleLockGroup.toggleMuteGroup.translations.ungroup.validationClassName.validationResult`.split(`.`),shiftActions:[`className`,`context`,`disabled`,`labels`,`level`,`path`,`ruleOrGroup`,`schema`,`shiftDown`,`shiftDownDisabled`,`shiftUp`,`shiftUpDisabled`,`testID`,`title`,`titles`,`validation`],undoRedoActions:[`className`,`classNames`,`context`,`disabled`,`labels`,`level`,`path`,`ruleOrGroup`,`schema`,`testID`,`title`,`titles`,`validation`],ungroupAction:[`className`,`context`,`disabled`,`disabledTranslation`,`handleOnClick`,`label`,`level`,`path`,`ruleOrGroup`,`rules`,`schema`,`testID`,`title`,`validation`],valueEditor:[`className`,`context`,`disabled`,`field`,`fieldData`,`handleOnChange`,`inputType`,`level`,`listsAsArrays`,`operator`,`parseNumbers`,`path`,`rule`,`schema`,`selectorComponent`,`separator`,`skipHook`,`testID`,`title`,`type`,`validation`,`value`,`valueSource`,`values`],valueSelector:[`className`,`context`,`disabled`,`handleOnChange`,`level`,`listsAsArrays`,`multiple`,`options`,`path`,`schema`,`testID`,`title`,`validation`,`value`],valueSourceSelector:[`className`,`context`,`disabled`,`field`,`fieldData`,`handleOnChange`,`level`,`options`,`path`,`rule`,`schema`,`testID`,`title`,`validation`,`value`]},i={actionElement:null,addGroupAction:`action`,addRuleAction:`action`,cloneGroupAction:`action`,cloneRuleAction:`action`,combinatorSelector:`selector`,dragHandle:null,fieldSelector:`selector`,inlineCombinator:null,lockGroupAction:`action`,lockRuleAction:`action`,matchModeEditor:null,muteGroupAction:`action`,muteRuleAction:`action`,notToggle:null,operatorSelector:`selector`,removeGroupAction:`action`,removeRuleAction:`action`,rule:null,ruleGroup:null,ruleGroupBodyElements:null,ruleGroupHeaderElements:null,shiftActions:null,undoRedoActions:null,ungroupAction:`action`,valueEditor:null,valueSelector:null,valueSourceSelector:`selector`},a=`------`,o=a,s=a,c=a,l=a,u=a,d=a,f={fields:{title:`Field`,placeholderName:`~`,placeholderLabel:o,placeholderGroupLabel:s},operators:{title:`Operator`,placeholderName:`~`,placeholderLabel:c,placeholderGroupLabel:l},values:{title:`Values`,placeholderName:`~`,placeholderLabel:u,placeholderGroupLabel:d},matchMode:{title:`Match mode`},matchThreshold:{title:`Match threshold`,placeholderName:`#`},value:{title:`Value`},removeRule:{label:`⨯`,title:`Remove rule`},removeGroup:{label:`⨯`,title:`Remove group`},addRule:{label:`+ Rule`,title:`Add rule`},addGroup:{label:`+ Group`,title:`Add group`},combinators:{title:`Combinator`},notToggle:{label:`Not`,title:`Invert this group`},cloneRule:{label:`⧉`,title:`Clone rule`},cloneRuleGroup:{label:`⧉`,title:`Clone group`},ungroupRuleGroup:{label:`⊟`,title:`Ungroup`},shiftActionUp:{label:`˄`,title:`Shift up`},shiftActionDown:{label:`˅`,title:`Shift down`},undo:{label:`↶`,title:`Undo`},redo:{label:`↷`,title:`Redo`},dragHandle:{label:`⁞⁞`,title:`Drag handle`},lockRule:{label:`🔓`,title:`Lock rule`},lockGroup:{label:`🔓`,title:`Lock group`},lockRuleDisabled:{label:`🔒`,title:`Unlock rule`},lockGroupDisabled:{label:`🔒`,title:`Unlock group`},muteRule:{label:`🔊`,title:`Mute rule`},muteGroup:{label:`🔊`,title:`Mute group`},unmuteRule:{label:`🔇`,title:`Unmute rule`},unmuteGroup:{label:`🔇`,title:`Unmute group`},valueSourceSelector:{title:`Value source`}},p={"=":`=`,"!=":`!=`,"<":`<`,">":`>`,"<=":`<=`,">=":`>=`,contains:`contains`,beginsWith:`begins with`,endsWith:`ends with`,doesNotContain:`does not contain`,doesNotBeginWith:`does not begin with`,doesNotEndWith:`does not end with`,null:`is null`,notNull:`is not null`,in:`in`,notIn:`not in`,between:`between`,notBetween:`not between`},m={and:`AND`,or:`OR`,xor:`XOR`},h=[{name:`=`,value:`=`,label:`=`},{name:`!=`,value:`!=`,label:`!=`},{name:`<`,value:`<`,label:`<`},{name:`>`,value:`>`,label:`>`},{name:`<=`,value:`<=`,label:`<=`},{name:`>=`,value:`>=`,label:`>=`},{name:`contains`,value:`contains`,label:`contains`},{name:`beginsWith`,value:`beginsWith`,label:`begins with`},{name:`endsWith`,value:`endsWith`,label:`ends with`},{name:`doesNotContain`,value:`doesNotContain`,label:`does not contain`},{name:`doesNotBeginWith`,value:`doesNotBeginWith`,label:`does not begin with`},{name:`doesNotEndWith`,value:`doesNotEndWith`,label:`does not end with`},{name:`null`,value:`null`,label:`is null`},{name:`notNull`,value:`notNull`,label:`is not null`},{name:`in`,value:`in`,label:`in`},{name:`notIn`,value:`notIn`,label:`not in`},{name:`between`,value:`between`,label:`between`},{name:`notBetween`,value:`notBetween`,label:`not between`}],g={"=":`!=`,"!=":`=`,"<":`>=`,"<=":`>`,">":`<=`,">=":`<`,beginsWith:`doesNotBeginWith`,doesNotBeginWith:`beginsWith`,endsWith:`doesNotEndWith`,doesNotEndWith:`endsWith`,contains:`doesNotContain`,doesNotContain:`contains`,between:`notBetween`,notBetween:`between`,in:`notIn`,notIn:`in`,notNull:`null`,null:`notNull`},_=new Set([`=`,`!=`,`<`,`>`,`<=`,`>=`]),v=new Set([`contains`,`beginsWith`,`endsWith`,`doesNotContain`,`doesNotBeginWith`,`doesNotEndWith`]),y=new Set([`null`,`notNull`]),b=new Set([`in`,`notIn`]),x=new Set([`between`,`notBetween`]),S=[{name:`and`,value:`and`,label:`AND`},{name:`or`,value:`or`,label:`OR`}],C=[...S,{name:`xor`,value:`xor`,label:`XOR`}],w=[{name:`all`,value:`all`,label:`all`},{name:`some`,value:`some`,label:`some`},{name:`none`,value:`none`,label:`none`},{name:`atLeast`,value:`atLeast`,label:`at least`},{name:`atMost`,value:`atMost`,label:`at most`},{name:`exactly`,value:`exactly`,label:`exactly`}],T={queryBuilder:`queryBuilder`,ruleGroup:`ruleGroup`,header:`ruleGroup-header`,body:`ruleGroup-body`,combinators:`ruleGroup-combinators`,addRule:`ruleGroup-addRule`,addGroup:`ruleGroup-addGroup`,cloneRule:`rule-cloneRule`,cloneGroup:`ruleGroup-cloneGroup`,ungroup:`ruleGroup-ungroup`,removeGroup:`ruleGroup-remove`,notToggle:`ruleGroup-notToggle`,rule:`rule`,fields:`rule-fields`,matchMode:`rule-matchMode`,matchThreshold:`rule-matchThreshold`,operators:`rule-operators`,value:`rule-value`,removeRule:`rule-remove`,betweenRules:`betweenRules`,valid:`queryBuilder-valid`,invalid:`queryBuilder-invalid`,shiftActions:`shiftActions`,undoRedoActions:`undoRedoActions`,undoAction:`undoRedoActions-undo`,redoAction:`undoRedoActions-redo`,dndDragging:`dndDragging`,dndOver:`dndOver`,dndCopy:`dndCopy`,dndGroup:`dndGroup`,dndDropNotAllowed:`dndDropNotAllowed`,dndPreviewPosition:`dndPreviewPosition`,dndHidden:`dndHidden`,dragHandle:`queryBuilder-dragHandle`,disabled:`queryBuilder-disabled`,muted:`queryBuilder-muted`,lockRule:`rule-lock`,lockGroup:`ruleGroup-lock`,muteRule:`rule-mute`,muteGroup:`ruleGroup-mute`,valueSource:`rule-valueSource`,valueListItem:`rule-value-list-item`,branches:`queryBuilder-branches`,justified:`queryBuilder-justified`,responsive:`queryBuilder-responsive`,hasSubQuery:`rule-hasSubQuery`,loading:`queryBuilder-loading`,valueDateTimeRelative:`rule-value-dateTimeRelative`},E={queryBuilder:``,ruleGroup:``,header:``,body:``,combinators:``,addRule:``,addGroup:``,cloneRule:``,cloneGroup:``,ungroup:``,removeGroup:``,notToggle:``,rule:``,fields:``,matchMode:``,matchThreshold:``,operators:``,value:``,removeRule:``,shiftActions:``,undoRedoActions:``,undoAction:``,redoAction:``,dragHandle:``,lockRule:``,lockGroup:``,muteRule:``,muteGroup:``,muted:``,valueSource:``,actionElement:``,valueSelector:``,betweenRules:``,valid:``,invalid:``,dndDragging:``,dndOver:``,dndGroup:``,dndCopy:``,dndDropNotAllowed:``,dndPreviewPosition:``,dndHidden:``,disabled:``,valueListItem:``,branches:``,hasSubQuery:``,loading:``,valueDateTimeRelative:``},D={empty:`empty`,invalidCombinator:`invalid combinator`,invalidIndependentCombinators:`invalid independent combinators`},O={rule:`rule`,ruleGroup:`rule-group`,inlineCombinator:`inline-combinator`,addGroup:`add-group`,removeGroup:`remove-group`,cloneGroup:`clone-group`,ungroup:`ungroup`,cloneRule:`clone-rule`,addRule:`add-rule`,removeRule:`remove-rule`,combinators:`combinators`,fields:`fields`,operators:`operators`,valueEditor:`value-editor`,notToggle:`not-toggle`,shiftActions:`shift-actions`,undoRedoActions:`undo-redo-actions`,undoAction:`undo-action`,redoAction:`redo-action`,dragHandle:`drag-handle`,lockRule:`lock-rule`,lockGroup:`lock-group`,muteRule:`mute-rule`,muteGroup:`mute-group`,valueSourceSelector:`value-source-selector`,matchModeEditor:`match-mode-editor`},k={parentPathDisabled:`action aborted: parent path disabled`,pathDisabled:`action aborted: path is disabled`,queryUpdate:`query updated`,onAddRuleFalse:`onAddRule callback returned false`,onAddGroupFalse:`onAddGroup callback returned false`,onGroupRuleFalse:`onGroupRule callback returned false`,onGroupGroupFalse:`onGroupGroup callback returned false`,onMoveRuleFalse:`onMoveRule callback returned false`,onMoveGroupFalse:`onMoveGroup callback returned false`,onRemoveFalse:`onRemove callback returned false`,onUngroupFalse:`onUngroup callback returned false`,add:`rule or group added`,remove:`rule or group removed`,update:`rule or group updated`,move:`rule or group moved`,group:`rule or group grouped with another`,ungroup:`group replaced by its own rules`},ee=[],te={addRuleToNewGroups:!1,autoSelectField:!0,autoSelectOperator:!0,autoSelectValue:!1,debugMode:!1,enableDragAndDrop:!1,enableMountQueryChange:!0,listsAsArrays:!1,preserveQueryStateOnUnmount:!1,resetOnFieldChange:!0,resetOnOperatorChange:!1,showCloneButtons:!1,showCombinatorsBetweenRules:!1,showLockButtons:!1,showMuteButtons:!1,showNotToggle:!1,showShiftActions:!1,showUndoRedo:!1,showUngroupButtons:!1,suppressStandardClassnames:!1},ne=[`target-not-found`,`parent-not-found`,`parent-not-a-group`,`target-not-a-group`,`destination-not-found`,`root-not-allowed`,`not-a-combinator-slot`,`target-disabled`,`parent-disabled`,`max-levels-exceeded`],re=new Set(ne),ie=(e,t=`,`)=>typeof e==`string`?e.split(`\\${t}`).map(e=>e.split(t)).reduce((e,n,r)=>r===0?n:[...e.slice(0,-1),`${e.at(-1)}${t}${n[0]}`,...n.slice(1)],[]):[],ae=(e,t=`,`)=>e.map(e=>`${e??``}`.replaceAll(t[0],`\\${t[0]}`)).join(t),A=e=>typeof e==`string`?e.trim():e,j=(e,{retainEmptyStrings:t}={})=>Array.isArray(e)?e.map(A):typeof e==`string`?ie(e,`,`).filter(t?()=>!0:e=>!/^\s*$/.test(e)).map(e=>e.trim()):typeof e==`number`?[e]:[],oe=e=>e.every(e=>e===!1||(e??!1)!==!1);function se(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=se(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function ce(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=se(e))&&(r&&(r+=` `),r+=t);return r}const M=e=>typeof e==`string`?e.toLowerCase():e,le=new RegExp(e.numericRegex.source.replace(/^\^/,String.raw`^\s*`).replace(/\$$/,String.raw`\s*$`)),N=e=>typeof e==`object`&&!!e&&Object.getPrototypeOf(e)===Object.prototype,ue=e=>e==null||e===``,de=e=>N(e)&&`field`in e&&typeof e.field==`string`,P=e=>N(e)&&Array.isArray(e.rules),F=e=>P(e)&&typeof e.combinator==`string`,I=e=>P(e)&&e.combinator===void 0,fe=`~structural`,pe=(e,t)=>{let n=new Set([...Object.keys(e),...Object.keys(t)]);n.delete(`rules`);let r=[];for(let i of n)Object.is(e[i],t[i])||r.push(i);return r.toSorted()},me=(e,t,n,r)=>{if(e===t)return``;if(typeof e==`string`||typeof t==`string`)return typeof e==typeof t?`${n}:combinator[${r}]`:fe;let i=P(e),a=P(t);if(i!==a)return fe;if(!i||!a){let n=pe(e,t);return n.length===0?``:`${t.id??``}:${n.join(`,`)}`}if(e.rules.length!==t.rules.length)return fe;let o=pe(e,t),s=-1;for(let[n,r]of e.rules.entries())if(r!==t.rules[n]){if(s!==-1)return fe;s=n}return s===-1?o.length===0?``:`${t.id??``}:${o.join(`,`)}`:o.length>0?fe:me(e.rules[s],t.rules[s],t.id??``,s)},he=(e,t)=>me(e,t,``,-1),ge=(e,t,n,r,i=500)=>t!==`~structural`&&t===e&&r>=n&&r-n<i,_e=[`or`,`xor`,`and`],ve=(e,t)=>M(e)===t,ye=(e,t=0)=>{let n=_e[t];if(!e.rules.includes(n))return t<_e.length-2?ye(e,t+1):e;let r=[...e.rules],i=0;for(;i<r.length-2;){if(ve(r[i+1],n)){i+=2;continue}let e=-1;for(let t=i+2;t<r.length;t++)if(typeof r[t]==`string`&&M(r[t])===n){e=t;break}if(e===-1){r.splice(i,r.length,ye({rules:r.slice(i)},t+1));break}r.splice(i,e-i,ye({rules:r.slice(i,e)},t+1))}return{...e,rules:r}},L=e=>{if(F(e))return e;let t=ye(e),n=[],r=`and`;for(let[e,i]of t.rules.entries())typeof i==`string`?e===1&&(r=i):n.push(P(i)?L(i):i);return{...t,combinator:r,rules:n}},be=e=>{if(I(e))return e;let{combinator:t,...n}=e,r=[],{length:i}=e.rules;for(let n=0;n<i;n++){let a=e.rules[n];P(a)?r.push(be(a)):r.push(a),t&&n<i-1&&r.push(t)}return{...n,rules:r}};function xe(e){return I(e)?L(e):be(e)}const Se={shiftActions:[`shiftActions`],dragHandle:[`dragHandle`],fields:[`valueSelector`,`fields`],matchMode:[`valueSelector`,`matchMode`],matchThreshold:[`valueSelector`,`matchThreshold`],operators:[`valueSelector`,`operators`],valueSource:[`valueSelector`,`valueSource`],value:[`value`],cloneRule:[`actionElement`,`cloneRule`],lockRule:[`actionElement`,`lockRule`],muteRule:[`actionElement`,`muteRule`],removeRule:[`actionElement`,`removeRule`],valueListItem:[`valueListItem`]},Ce={header:{sources:[`header`],conditions:[{key:`dndOver`,when:e=>e.isOver,standardOnly:!0},{key:`dndCopy`,when:e=>e.isOver&&e.dropEffect===`copy`},{key:`dndDropNotAllowed`,when:e=>e.dropNotAllowed}]},shiftActions:[`shiftActions`],undoRedoActions:[`undoRedoActions`],undoAction:[`actionElement`,`undoAction`],redoAction:[`actionElement`,`redoAction`],dragHandle:[`dragHandle`],combinators:[`valueSelector`,`combinators`],notToggle:[`notToggle`],addRule:[`actionElement`,`addRule`],addGroup:[`actionElement`,`addGroup`],cloneGroup:[`actionElement`,`cloneGroup`],ungroup:[`actionElement`,`ungroup`],lockGroup:[`actionElement`,`lockGroup`],muteGroup:[`actionElement`,`muteGroup`],removeGroup:[`actionElement`,`removeGroup`],body:[`body`]},we=[{key:`disabled`,when:e=>e.disabled},{key:`muted`,when:e=>e.muted},{key:`dndDragging`,when:e=>e.isDragging},{key:`dndOver`,when:e=>e.isOver},{key:`dndCopy`,when:e=>e.isOver&&e.dropEffect===`copy`},{key:`dndGroup`,when:e=>e.isOver&&e.groupItems},{key:`dndDropNotAllowed`,when:e=>e.dropNotAllowed},{key:`hasSubQuery`,when:e=>e.hasSubQuery}],Te=[{key:`disabled`,when:e=>e.disabled},{key:`muted`,when:e=>e.muted},{key:`dndDragging`,when:e=>e.isDragging},{key:`dndGroup`,when:e=>e.isOver&&e.groupItems}],Ee=[{key:`disabled`,when:e=>e.disabled},{key:`valid`,when:e=>typeof e.validationResult==`boolean`&&e.validationResult},{key:`invalid`,when:e=>typeof e.validationResult==`boolean`&&!e.validationResult}],De=(e,t,{classNames:n,suppressStandardClassnames:r})=>{let i=e.map(e=>[e,!!e.when(t)]);return[...i.filter(([e])=>!e.standardOnly).map(([e,t])=>t&&n?.[e.key]),r||Object.fromEntries(i.map(([e,t])=>[T[e.key],t]))]},Oe=(e,t,n,r)=>{let{sources:i,conditions:a}=Array.isArray(t)?{sources:t}:t;return ce(r.suppressStandardClassnames||T[e],...i.map(e=>r.classNames?.[e]),...a?De(a,n,r):[])},ke=(e,t,n)=>{let r={};for(let[i,a]of Object.entries(e))r[i]=Oe(i,a,t,n);return r},Ae=e=>ke(Se,{},e),je=(e,t)=>Oe(e,Se[e],{},t),Me=e=>ke(Ce,e,e),Ne=(e,t,n)=>{let{classNames:r,suppressStandardClassnames:i,leadingClassNames:a=[],validationClassName:o}=n;return ce(...a,i||T[e],r?.[e],...De(t,n,n),o)},Pe=e=>Ne(`rule`,we,e),Fe=e=>Ne(`ruleGroup`,Te,e),Ie=e=>Ne(`queryBuilder`,Ee,e),Le=e=>{let t={},n=e=>{e.id&&t[e.id]},r=e=>{let i=[];if(e.rules.length===0)i.push(D.empty);else if(!F(e)){let t=!1;for(let n=0;n<e.rules.length&&!t;n++)(n%2==0&&typeof e.rules[n]==`string`||n%2==1&&typeof e.rules[n]!=`string`||n%2==1&&typeof e.rules[n]==`string`&&!S.map(e=>e.name).includes(e.rules[n]))&&(t=!0);t&&i.push(D.invalidIndependentCombinators)}F(e)&&!S.map(e=>e.name).includes(e.combinator)&&e.rules.length>1&&i.push(D.invalidCombinator),e.id&&(t[e.id]=i.length>0?{valid:!1,reasons:i}:!0);for(let t of e.rules)typeof t==`string`||(P(t)?r(t):n(t))};return r(e),t},Re=Object.keys,ze=Object.entries,Be=e=>e===`__proto__`||e===`constructor`||e===`prototype`,Ve=e=>N(e)&&`name`in e&&typeof e.name==`string`,He=e=>N(e)&&`value`in e&&typeof e.value==`string`;function R(e,t,n){if(typeof e==`string`)return{...t,name:e,value:e,label:n?.[e]??e};let r={},i=!!t;return Ve(e)&&!He(e)?(r.value=e.name,i=!0):!Ve(e)&&He(e)&&(r.name=e.value,i=!0),i?Object.assign({},t,e,r):e}function z(e,t,n){if(!Array.isArray(e))return[];let r=e;return B(r)?r.map(e=>({...e,options:e.options.map(e=>R(e,t,n))})):r.map(e=>R(e,t,n))}function Ue(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,R(n,t)]))}const We=e=>Ge(e),Ge=e=>{let t=new Set,n=[];for(let r of e)t.has(r.value??r.name)||(t.add(r.value??r.name),n.push(r));return e.length===n.length?e:n},Ke=e=>Array.isArray(e)&&e.length>0&&N(e[0])&&`options`in e[0]&&Array.isArray(e[0].options),qe=e=>{let t=!1;if(Array.isArray(e))for(let n of e)if(Ve(n)||He(n))t=!0;else return!1;return t},Je=e=>{let t=!1;if(Array.isArray(e))for(let n of e)if(Ve(n)&&He(n))t=!0;else return!1;return t},B=(e,{allowEmpty:t=!1}={})=>{let n=!1;if(Array.isArray(e))for(let r of e)if(N(r)&&`options`in r&&(qe(r.options)||t&&Array.isArray(r.options)&&r.options.length===0))n=!0;else return!1;return n},Ye=(e,{allowEmpty:t=!1}={})=>{let n=!1;if(Array.isArray(e))for(let r of e)if(N(r)&&`options`in r&&(Je(r.options)||t&&Array.isArray(r.options)&&r.options.length===0))n=!0;else return!1;return n};function V(e,t){return(B(e,{allowEmpty:!0})?e.flatMap(e=>e.options):e).find(e=>e.value===t||e.name===t)}function H(e){if(!Array.isArray(e)||e.length===0)return null;if(B(e,{allowEmpty:!0})){for(let t of e)if(t.options.length>0)return t.options[0].value??t.options[0].name;return null}return e[0].value??e[0].name}const Xe=e=>Ge(Ke(e)?e.flatMap(e=>e.options):e),Ze=e=>{let t=new Set,n=new Set,r=[];for(let i of e)if(!t.has(i.label)){t.add(i.label);let e=[];for(let t of i.options)n.has(t.value??t.name)||(n.add(t.value??t.name),e.push(R(t)));r.push({...i,options:e})}return r},Qe=e=>B(e)?Ze(e):Ge(e.map(e=>R(e))),$e=e=>{let{optionList:t,baseOption:n={},labelMap:r={},placeholder:{placeholderName:i=`~`,placeholderLabel:o=a,placeholderGroupLabel:s=a}={},autoSelectOption:c=!0}=e,l={id:i,name:i,value:i,label:o},u=t??[l],d,f=Array.isArray(u)?z(u,n,r):Re(Ue(u,n)).map(e=>({...u[e],name:e,value:e})).sort((e,t)=>e.label.localeCompare(t.label));d=B(f)?Ze(c?f:[{label:s,options:[l]},...f]):Ge(c?f:[l,...f]);let p={};if(!Array.isArray(u)){let e=Ue(u,n);p=c?e:{...e,[i]:l}}else if(B(d))for(let e of d)for(let t of e.options)p[t.value??t.name]=R(t,n);else for(let e of d)p[e.value??e.name]=R(e,n);return{defaultOption:l,optionList:d,optionsMap:p}},et=(e,t,n)=>{let r=R(e),i=R(n);return r.value===i.value?!1:typeof r.comparator==`string`?r[r.comparator]===i[r.comparator]:r.comparator?.(i,t)??!1},tt=(e,t,n)=>{if(!e.comparator){let n=t=>(t.value??t.name)!==(e.value??e.name);return B(t)?t.map(e=>({...e,options:e.options.filter(e=>n(e))})):t.filter(e=>n(e))}return B(t)?t.map(t=>({...t,options:t.options.filter(t=>et(e,n,t))})).filter(e=>e.options.length>0):t.filter(t=>et(e,n,t))},nt=(e,t)=>t?.[e]??{name:e,value:e,label:e},rt=(e,t,n,r)=>n.inputType??r(e,t,{fieldData:n}),it=e=>{let t=e?.arity;return typeof t==`string`&&t===`unary`||typeof t==`number`&&t<2},at=(e,t,n)=>{let r=n(e.field,e.operator,{fieldData:t});return e.valueSource&&!V(r,e.valueSource)?[...r,{name:e.valueSource,value:e.valueSource,label:e.valueSource}]:r},ot=e=>e&&e.length>0?e:null,st=(e,t,n,r)=>e.valueSource===`field`?`select`:e.valueSource===`parameter`?n?M(e.operator)===`in`||M(e.operator)===`notin`?`multiselect`:`select`:`text`:r(e.field,e.operator,{fieldData:t}),ct=(e,t,n,r,i)=>{let a=e.valueSource===`field`?tt(t,n,e.operator):e.valueSource===`parameter`?r??[]:i(e.field,e.operator,{fieldData:t});return qe(a)||B(a)?z(a):a},lt=(e,t,n={},r=e.id??``)=>n[r]??(typeof t.validator==`function`?t.validator(e):null),ut=(e,t,n={})=>{let{fields:r,fieldMap:i,getInputType:a,getMatchModes:o,getOperators:s,getParameters:c,getValueEditorType:l,getValues:u,getValueSources:d,getSubQueryBuilderProps:f}=t,p=nt(e.field,i),m=p.inputType??a(e.field,e.operator,{fieldData:p}),h=o(e.field,{fieldData:p}),g=s(e.field,{fieldData:p}),_=V(g,e.operator),v=at(e,p,d),y=ot(c(e.field,e.operator,{fieldData:p}));return{fieldData:p,hideValueControls:it(_),inputType:m,matchModes:h,operatorObject:_,operators:g,parameters:y,validationResult:lt(e,p,n.validationMap,n.id),valueEditorType:st(e,p,y,l),values:ct(e,p,r,y,u),valueSourceOptions:v,valueSources:v.map(({value:e})=>e),subQueryBuilderProps:f?.(e.field,{fieldData:p})??{}}},dt=(e,t)=>F(e)?e.combinator:H(t)??``,ft=(e,t,n={})=>{let r=I(e),i=dt(e,t),a=V(t,i);return{combinator:i,combinatorObject:a,combinators:t,combinatorBasedClassName:r?null:a?.className??``,independentCombinators:r,validationResult:(n.validationMap??{})[n.id??e.id??``]??null}},U=(t,{parseNumbers:n,bigIntOnOverflow:r}={})=>{if(!n||typeof t==`bigint`||typeof t==`number`)return t;if(n===`native`)return Number.parseFloat(t);let i=(0,e.numericQuantity)(t,{allowTrailingInvalid:n===`enhanced`,bigIntOnOverflow:r,romanNumerals:!1,round:!1});return typeof i==`bigint`||!Number.isNaN(i)?i:t},pt=new Set([`between`,`notBetween`,`in`,`notIn`]),mt=e=>e===`between`||e===`notBetween`,ht=({skipHook:e,type:t,operator:n,value:r,inputType:i})=>!e&&t!==`multiselect`&&!pt.has(n)&&(Array.isArray(r)||i===`number`&&typeof r==`string`&&r.includes(`,`))?{reset:!0,value:j(r,{retainEmptyStrings:!0})[0]??``}:{reset:!1,value:r},gt=({value:e,index:t,valueAsArray:n,operator:r,values:i,listsAsArrays:a,parseNumberMethod:o})=>{let s=U(e,{parseNumbers:o}),c=t===0&&mt(r)&&(n.length<2||n[1]===void 0);if(n[t]===s&&!c)return a?n:ae(n,`,`);let l=[...n];return l[t]=s,c&&(l[1]=H(i)??``),a?l:ae(l,`,`)},_t=(e,t)=>{let n=U(e,{parseNumbers:t,bigIntOnOverflow:!0});try{return BigInt(n)}catch{return n}},vt=(e,t)=>e===`bigint`||t===`in`||t===`notIn`?`text`:e||`text`,yt=(e,{multiple:t,listsAsArrays:n}={})=>{if(!t)return e;let r=j(e);return n?r:ae(r,`,`)},bt=(e,t)=>t?j(e).map(String):e,xt=(e,t,n)=>{let r={};for(let i in e){if(Be(i))continue;let a=t[i];a!==!1&&(a&&i!==a?(Be(a)||(r[a]=e[i]),n||(r[i]=e[i])):r[i]=e[i])}return r};function W(e,t={}){let{ruleProcessor:n=e=>e,ruleGroupProcessor:r=e=>e,propertyMap:i={},combinatorMap:a={},operatorMap:o={},omitPath:s=!1,deleteRemappedProperties:c=!0}=t,l=e=>({...r(xt({...e,...F(e)?{combinator:a[e.combinator]??e.combinator}:{}},i,c)),...i.rules===!1?null:{[i.rules??`rules`]:e.rules.map((t,r)=>{let u=s?null:{path:[...e.path,r]};return typeof t==`string`?a[t]??t:P(t)?l({...t,...u}):n(xt({...t,...u,...`operator`in t?{operator:o[t.operator]??t.operator}:{}},i,c))})}});return l({...e,...s?null:{path:[]}})}const St=e=>N(e)&&typeof e.valid==`boolean`,G=(e,t,n)=>{if(e.muted)return!1;if(typeof t==`boolean`)return t;if(St(t))return t.valid;if(typeof n==`function`&&!P(e)){let t=n(e);if(typeof t==`boolean`)return t;if(St(t))return t.valid}return!0},Ct=({parseNumbers:e,inputType:t})=>{if(typeof e==`string`){let[n,r]=e.split(`-`);return r===`limited`?t===`number`&&n:n}return e?`strict`:!1},wt=e=>{switch(M(e)){case`null`:return`is null`;case`notnull`:return`is not null`;case`notin`:return`not in`;case`notbetween`:return`not between`;case`contains`:case`beginswith`:case`endswith`:return`like`;case`doesnotcontain`:case`doesnotbeginwith`:case`doesnotendwith`:return`not like`;default:return e}},Tt=(e=`||`)=>(...t)=>e.toUpperCase()===`CONCAT`?`CONCAT(${t.join(`, `)})`:t.join(` ${e} `),Et=e=>{switch(e){case`contains`:case`doesnotcontain`:return[`%`,`%`];case`beginswith`:case`doesnotbeginwith`:return[``,`%`];case`endswith`:case`doesnotendwith`:return[`%`,``];default:return[``,``]}},Dt=(e,t,{concatOperator:n=`||`,quoteValuesWith:r,wrapValueWith:i=[``,``]}={})=>{let[a,o]=Et(t),s=r||`'`,c=e=>`${i[0]}${s}${e}${s}${i[1]}`,l=[a&&c(a),e,o&&c(o)].filter(Boolean);return l.length>1?Tt(n)(...l):e},Ot={"=":`$eq`,"!=":`$ne`,"<":`$lt`,"<=":`$lte`,">":`$gt`,">=":`$gte`,in:`$in`,notin:`$nin`,notIn:`$nin`},kt={"=":`equals`,"!=":`not`,"<":`lt`,"<=":`lte`,">":`gt`,">=":`gte`,in:`in`,notin:`notIn`},At={and:`&&`,or:`||`},jt={startsWith:(e,t)=>typeof e==`string`&&e.startsWith(t),endsWith:(e,t)=>typeof e==`string`&&e.endsWith(t)},Mt=(e,t)=>({...e,rules:e.rules.map(e=>{if(typeof e==`string`)return e;if(P(e))return Mt(e,t);let n=V(t.fields,e.field),r=Ct({parseNumbers:t.parseNumbers,inputType:n?.inputType});if(Array.isArray(e.value))return{...e,value:e.value.map(e=>U(e,{parseNumbers:r}))};let i=j(e.value,{retainEmptyStrings:!0}).map(e=>U(e,{parseNumbers:r}));if(i.every(e=>typeof e==`number`)){if(i.length>1)return{...e,value:i};if(i.length===1)return{...e,value:i[0]}}return e})}),K=e=>typeof e==`string`&&e.length>0||typeof e==`number`&&!Number.isNaN(e)||typeof e!=`string`&&typeof e!=`number`,q=(e,t)=>!!t&&(typeof e==`number`||typeof e==`bigint`||typeof e==`string`&&le.test(e)),Nt=e=>e.length>=3,Pt=(e=[``,``])=>Array.isArray(e)?e:typeof e==`string`?[e,e]:e??[``,``],Ft=(e,{quoteFieldNamesWith:t,fieldIdentifierSeparator:n})=>{let[r,i]=Pt(t);return typeof n==`string`&&n.length>0?ae(ie(e,n).map(e=>`${r}${e}${i}`),n):`${r}${e}${i}`},It=[`S`,`V`,`O`],Lt=e=>{let t=[],n=new Set(It);for(let r of e.toUpperCase())if(n.has(r)&&(t.push(r),n.delete(r),n.size===0))break;for(let e of It)n.has(e)&&t.push(e);return t},Rt=(e,t=`:`)=>{let n=`${e??``}`;return t&&n.startsWith(t)?n:`${t}${n}`},zt=(e,t=`:`)=>{let n=`${e??``}`;return t&&n.startsWith(t)?n.slice(t.length):n},Bt={groupPrefix:``,groupPrefix_not_xor:`either zero or more than one of`,groupPrefix_xor:`exactly one of`,groupSuffix:`is true`,groupSuffix_not:`is not true`},Vt=(e,t,n)=>t.startsWith(e)&&n.every(e=>t.includes(`_${e}`)&&t.match(/_/g)?.length===n.length),Ht=(e,t,n=[])=>n.length===0?t[e]??Bt[e]??``:Object.entries(t).find(([t])=>Vt(e,t,n))?.[1]??Object.entries(Bt).find(([t])=>Vt(e,t,n))?.[1]??Bt[e]??``,J=e=>{let{mode:t,threshold:n}=e.match??{};if(!t)return null;if(!P(e.value))return!1;let r=M(t),i=r===`atleast`&&n===1?`some`:r===`atmost`&&n===0?`none`:r;return(i===`atleast`||i===`atmost`||i===`exactly`)&&(typeof n!=`number`||n<0)?!1:{mode:i,threshold:n}},Ut=`elem_alias`,Wt=(e=0)=>e>0?`${Ut}_${e}`:Ut,Gt=(e,t)=>typeof t==`bigint`?{$bigint:t.toString()}:t,Kt=(e,t)=>N(t)&&Object.keys(t).length===1&&typeof t.$bigint==`string`?BigInt(t.$bigint):t,qt=(e,t)=>{let{fields:n,fallbackExpression:r,getParseNumberBoolean:i,placeholderFieldName:a,placeholderOperatorName:o,placeholderValueName:s,ruleProcessor:c,validateRule:l,validationMap:u}=t,d=(e,f)=>{if(!G(e,u[e.id??``]))return f?r:``;let p=[],m=``,h=!0;for(let r of e.rules){if(typeof r==`string`){m=At[r];continue}if(P(r)){let e=d(r);e&&(!h&&m&&(p.push(m),m=``),h=!1,p.push(e));continue}let[e,u]=l(r);if(!G(r,e,u)||r.field===a||r.operator===o||s!==void 0&&r.value===s)continue;let f=V(n,r.field),g=c(r,{...t,parseNumbers:i(f?.inputType),escapeQuotes:(r.valueSource??`value`)===`value`,fieldData:f});g&&(!h&&m&&(p.push(m),m=``),h=!1,p.push(g))}let g=p.join(F(e)?` ${At[e.combinator]} `:` `),[_,v]=e.not||!f?[`${e.not?`!`:``}(`,`)`]:[``,``];return g?`${_}${g}${v}`:r};return d(e,!0)},Jt=e=>e.startsWith(`not`)||e.startsWith(`doesnot`),Yt=(e,t)=>typeof e!=`string`||!t?`${e}`:e.replaceAll(`"`,`\\"`),Xt=(e,t={})=>{let{escapeQuotes:n,parseNumbers:r,preserveValueOrder:i}=t,{field:a,operator:o,value:s,valueSource:c}=e,l=c===`field`||c===`parameter`,u=M(o===`=`?`==`:o),d=typeof s==`number`||typeof s==`boolean`||typeof s==`bigint`||q(s,r),f=J(e);if(f===!1)return``;if(f){let{mode:n,threshold:r}=f,i=t.subqueryDepth??0,o=Wt(i),s=W(e.value,{ruleProcessor:e=>({...e,field:`${o}${e.field?`.${e.field}`:``}`})}),c=qt(s,{...t,subqueryDepth:i+1});switch(n){case`all`:return`${a}.all(${o}, ${c})`;case`none`:case`some`:return`${n===`none`?`!`:``}${a}.exists(${o}, ${c})`;case`atleast`:case`atmost`:case`exactly`:{let e=`double(${a}.size())`,t=`${a}.filter(${o}, ${c}).size()`,i=n===`atleast`?`>=`:n===`atmost`?`<=`:`==`;return r>0&&r<1?`double(${t}) ${i} (${e} * ${r})`:`${t} ${i} ${r}`}}}switch(u){case`<`:case`<=`:case`==`:case`!=`:case`>`:case`>=`:return`${a} ${u} ${l||d?A(s):`"${Yt(s,n)}"`}`;case`contains`:case`doesnotcontain`:return`${Jt(u)?`!`:``}${a}.contains(${l?A(s):`"${Yt(s,n)}"`})`;case`beginswith`:case`doesnotbeginwith`:return`${Jt(u)?`!`:``}${a}.startsWith(${l?A(s):`"${Yt(s,n)}"`})`;case`endswith`:case`doesnotendwith`:return`${Jt(u)?`!`:``}${a}.endsWith(${l?A(s):`"${Yt(s,n)}"`})`;case`null`:return`${a} == null`;case`notnull`:return`${a} != null`;case`in`:case`notin`:{let[e,t]=Jt(u)?[`!(`,`)`]:[``,``];return`${e}${a} in [${j(s).map(e=>l||q(e,r)?`${A(e)}`:`"${Yt(e,n)}"`).join(`, `)}]${t}`}case`between`:case`notbetween`:{let e=j(s);if(e.length>=2&&!ue(e[0])&&!ue(e[1])){let[t,o]=e,s=r!==!1,c=q(t,s)?U(t,{parseNumbers:s}):NaN,d=q(o,s)?U(o,{parseNumbers:s}):NaN,f=Number.isNaN(c)?l?`${t}`:`"${Yt(t,n)}"`:c,p=Number.isNaN(d)?l?`${o}`:`"${Yt(o,n)}"`:d;if(!i&&f===c&&p===d&&d<c){let e=d;p=c,f=e}return u===`between`?`(${a} >= ${f} && ${a} <= ${p})`:`(${a} < ${f} || ${a} > ${p})`}return``}}return``},Zt={$and:[{$expr:!0}]},Qt=(e,t,n)=>{let{context:r,fields:i,getParseNumberBoolean:a,placeholderFieldName:o,placeholderOperatorName:s,placeholderValueName:c,ruleProcessor:l,validateRule:u,validationMap:d}=t,{inExpressionContext:f}=r??{},p=(e,r)=>{if(!G(e,d[e.id??``]))return r?Zt:!1;let m=`$${M(e.combinator)}`,h=!1,g=e.rules.map(e=>{if(P(e)){let t=p(e);return t?(h=!0,t):!1}let[r,d]=u(e);if(!G(e,r,d)||e.field===o||e.operator===s||c!==void 0&&e.value===c)return!1;let f=V(i,e.field);return l(e,{...t,parseNumbers:a(f?.inputType),fieldData:f},n)}).filter(Boolean),_=g.length>0?g.length===1&&!h?g[0]:{[m]:g}:Zt;return e.not?f?{$not:_}:{$nor:[_]}:_};return p(L(e),!0)},$t=(e,t,n=!1)=>q(e,n||typeof e==`bigint`)?Number(U(e,{parseNumbers:`strict`})):t,en=(e,t={})=>{let{field:n,operator:r,value:i,valueSource:a}=e,{parseNumbers:o,preserveValueOrder:s,context:c}=t,l=a===`field`,{avoidFieldsAsKeys:u}=c??{},d=J(e);if(d===!1)return;if(d){let{mode:e,threshold:r}=d,a={$size:{$ifNull:[`$${n}`,[]]}},o=Qt(W(i,{ruleProcessor:e=>({...e,field:e.field?`${n}.${e.field}`:n})}),{...t,ruleProcessor:en,context:{...t.context,avoidFieldsAsKeys:!1}}),s=Qt(W(i,{ruleProcessor:e=>({...e,field:e.field?`$item.${e.field}`:`$item`})}),{...t,ruleProcessor:en,context:{...t.context,avoidFieldsAsKeys:!0,inExpressionContext:!0}}),c={$size:{$ifNull:[{$filter:{input:`$${n}`,as:`item`,cond:{$and:[s]}}},[]]}};switch(e){case`all`:return{$expr:{$eq:[c,a]}};case`none`:return{$nor:[o]};case`some`:return o;case`atleast`:case`atmost`:case`exactly`:{let t=e===`atleast`?Ot[`>=`]:e===`atmost`?Ot[`<=`]:Ot[`=`];return r>0&&r<1?{$expr:{[t]:[c,{$multiply:[a,r]}]}}:{$expr:{[t]:[c,r]}}}}}if(r===`=`&&!l)return u?{$eq:[`$${n}`,$t(i,i,o)]}:{[n]:$t(i,i,o)};let f=M(r);switch(f){case`<`:case`<=`:case`=`:case`!=`:case`>`:case`>=`:{let e=Ot[f];return l?{[e]:[`$${n}`,`$${i}`]}:u?{$and:[{$ne:[`$${n}`,null]},{[e]:[`$${n}`,$t(i,i,o)]}]}:{[n]:{[e]:$t(i,i,o)}}}case`contains`:return l?{$where:`this.${n}.includes(this.${i})`}:u?{$regexMatch:{input:`$${n}`,regex:i}}:{[n]:{$regex:i}};case`beginswith`:return l?{$where:`this.${n}.startsWith(this.${i})`}:u?{$regexMatch:{input:`$${n}`,regex:`^${i}`}}:{[n]:{$regex:`^${i}`}};case`endswith`:return l?{$where:`this.${n}.endsWith(this.${i})`}:u?{$regexMatch:{input:`$${n}`,regex:`${i}$`}}:{[n]:{$regex:`${i}$`}};case`doesnotcontain`:return l?{$where:`!this.${n}.includes(this.${i})`}:u?{$not:{$regexMatch:{input:`$${n}`,regex:i}}}:{[n]:{$not:{$regex:i}}};case`doesnotbeginwith`:return l?{$where:`!this.${n}.startsWith(this.${i})`}:u?{$not:{$regexMatch:{input:`$${n}`,regex:`^${i}`}}}:{[n]:{$not:{$regex:`^${i}`}}};case`doesnotendwith`:return l?{$where:`!this.${n}.endsWith(this.${i})`}:u?{$not:{$regexMatch:{input:`$${n}`,regex:`${i}$`}}}:{[n]:{$not:{$regex:`${i}$`}}};case`null`:return u?{$eq:[`$${n}`,null]}:{[n]:null};case`notnull`:return u?{$ne:[`$${n}`,null]}:{[n]:{$ne:null}};case`in`:case`notin`:{let e=j(i);return l?{$where:`${f===`notin`?`!`:``}[${e.map(e=>`this.${e}`).join(`,`)}].includes(this.${n})`}:u?f===`notin`?{$not:{[Ot.in]:[`$${n}`,e.map(e=>$t(e,e,o))]}}:{[Ot[f]]:[`$${n}`,e.map(e=>$t(e,e,o))]}:{[n]:{[Ot[f]]:e.map(e=>$t(e,e,o))}}}case`between`:case`notbetween`:{let e=j(i);if(e.length>=2&&K(e[0])&&K(e[1])){let[t,r]=e,i=$t(t,NaN,!0),a=$t(r,NaN,!0),o=l||Number.isNaN(i)?t:i,c=l||Number.isNaN(a)?r:a;if(!s&&o===i&&c===a&&a<i){let e=a;c=i,o=e}return f===`between`?l?{$gte:[`$${n}`,`$${o}`],$lte:[`$${n}`,`$${c}`]}:u?{$and:[{$gte:[`$${n}`,o]},{$lte:[`$${n}`,c]}]}:{[n]:{$gte:o,$lte:c}}:l?{$or:[{$lt:[`$${n}`,`$${o}`]},{$gt:[`$${n}`,`$${c}`]}]}:u?{$or:[{$lt:[`$${n}`,o]},{$gt:[`$${n}`,c]}]}:{$or:[{[n]:{$lt:o}},{[n]:{$gt:c}}]}}return``}}return``},tn=(e,t)=>{let n=en(e,t);return n?JSON.stringify(n):``},nn=(e,t)=>{let{fields:n,fallbackExpression:r,getParseNumberBoolean:i,placeholderFieldName:a,placeholderOperatorName:o,placeholderValueName:s,ruleProcessor:c,validateRule:l,validationMap:u}=t,d=(e,f)=>{if(!G(e,u[e.id??``]))return f?r:``;let p=[],m=``,h=!0;for(let r of e.rules){if(typeof r==`string`){m=r;continue}if(P(r)){let e=d(r);e&&(!h&&m&&(p.push(m),m=``),h=!1,p.push(e));continue}let[e,u]=l(r);if(!G(r,e,u)||r.field===a||r.operator===o||s!==void 0&&r.value===s)continue;let f=V(n,r.field),g=c(r,{...t,parseNumbers:i(f?.inputType),escapeQuotes:(r.valueSource??`value`)===`value`,fieldData:f});g&&(!h&&m&&(p.push(m),m=``),h=!1,p.push(g))}let g=p.join(F(e)?` ${e.combinator} `:` `),[_,v]=e.not||!f?[`${e.not?`!`:``}(`,`)`]:[``,``];return g?`${_}${g}${v}`:r};return d(e,!0)},rn=e=>e.startsWith(`not`)||e.startsWith(`doesnot`),an=(e,t)=>t?`!(${e})`:e,on=(e,t)=>typeof e!=`string`||!t?`${e}`:e.replaceAll(`'`,`\\'`),sn=(e,t={})=>{let{field:n,operator:r,value:i,valueSource:a}=e,{escapeQuotes:o,parseNumbers:s,preserveValueOrder:c}=t,l=a===`field`||a===`parameter`,u=M(r===`=`?`==`:r),d=typeof i==`number`||typeof i==`boolean`||typeof i==`bigint`||q(i,s),f=J(e);if(f===!1)return``;if(f){let{mode:r,threshold:i}=f,a=nn(W(e.value,{ruleProcessor:e=>({...e,field:e.field||`#this`})}),t),o=`${n}.size()`,s=`${n}.?[${a}].size()`;switch(r){case`all`:return`${s} == ${o}`;case`none`:return`${s} == 0`;case`some`:return`${s} >= 1`;case`atleast`:case`atmost`:case`exactly`:{let e=r===`atleast`?`>=`:r===`atmost`?`<=`:`==`;return i>0&&i<1?`${s} ${e} (${o} * ${i})`:`${s} ${e} ${i}`}}}switch(u){case`<`:case`<=`:case`==`:case`!=`:case`>`:case`>=`:return`${n} ${u} ${l||d?A(i):`'${on(i,o)}'`}`;case`contains`:case`doesnotcontain`:{let e=l?`'.*'.concat(${A(i)}).concat('.*')`:`'.*${on(i,o)}.*'`;return an(`${n} matches ${e}`,rn(u))}case`beginswith`:case`doesnotbeginwith`:{let e=l?`'^'.concat(${A(i)}).concat('.*')`:`'${typeof i==`string`&&!i.startsWith(`^`)||d?`^`:``}${on(i,o)}.*'`;return an(`${n} matches ${e}`,rn(u))}case`endswith`:case`doesnotendwith`:{let e=l?`'.*'.concat(${A(i)}).concat('$')`:`'.*${on(i,o)}${typeof i==`string`&&!i.endsWith(`$`)||d?`$`:``}'`;return an(`${n} matches ${e}`,rn(u))}case`null`:return`${n} == null`;case`notnull`:return`${n} != null`;case`in`:case`notin`:{let e=rn(u)?`!`:``,t=j(i);return t.length>0?`${e}(${t.map(e=>`${n} == ${l||q(e,s)?`${A(e)}`:`'${on(e,o)}'`}`).join(` or `)})`:``}case`between`:case`notbetween`:{let e=j(i);if(e.length>=2&&!ue(e[0])&&!ue(e[1])){let[t,r]=e,i=s!==!1,a=q(t,i)?U(t,{parseNumbers:i}):NaN,d=q(r,i)?U(r,{parseNumbers:i}):NaN,f=Number.isNaN(a)?l?`${t}`:`'${on(t,o)}'`:a,p=Number.isNaN(d)?l?`${r}`:`'${on(r,o)}'`:d;if(!c&&f===a&&p===d&&d<a){let e=d;p=a,f=e}return u===`between`?`(${n} >= ${f} and ${n} <= ${p})`:`(${n} < ${f} or ${n} > ${p})`}return``}}return``},cn=(e,t,n)=>n&&typeof e==`string`?e.replaceAll(`${t}`,`${t}${t}`):e,ln=({operator:e,value:t,valueSource:n},{escapeQuotes:r,parseNumbers:i,preserveValueOrder:a,quoteFieldNamesWith:o,quoteValuesWith:s,concatOperator:c=`||`,fieldIdentifierSeparator:l,paramPrefix:u,wrapValueWith:d=[``,``],translations:f}={})=>{if(n===`parameter`){let n=M(e);if(n===`between`||n===`notbetween`){let e=j(t,{retainEmptyStrings:!0});if(e.length<2||!K(e[0])||!K(e[1]))return``;let[n,r]=e;return[Rt(n,u),Rt(r,u)].join(` ${f?.betweenAnd??f?.and??`and`} `)}if(n===`in`||n===`notin`){let e=j(t);return e.length===0?``:`(${e.map(e=>Rt(e,u)).join(`, `)})`}let r=Rt(t,u);switch(n){case`contains`:case`doesnotcontain`:case`beginswith`:case`doesnotbeginwith`:case`endswith`:case`doesnotendwith`:return Dt(r,n,{concatOperator:c,quoteValuesWith:s,wrapValueWith:d})}return r}let p=n===`field`,m=M(e),h=s||`'`,g=e=>`${d[0]}${h}${e}${h}${d[1]}`,_=e=>cn(e,h,r),v=e=>g(_(e)),y=e=>Ft(e,{quoteFieldNamesWith:o,fieldIdentifierSeparator:l}),b={concatOperator:c,quoteValuesWith:s,wrapValueWith:d};switch(m){case`null`:case`notnull`:return``;case`in`:case`notin`:{let e=j(t);return e.length>0?`(${e.map(e=>p?y(e):q(e,i)?`${A(e)}`:`${v(e)}`).join(`, `)})`:``}case`between`:case`notbetween`:{let e=j(t,{retainEmptyStrings:!0});if(e.length<2||!K(e[0])||!K(e[1]))return``;let[n,r]=e,o=q(n,i)?U(n,{parseNumbers:`strict`}):NaN,s=q(r,i)?U(r,{parseNumbers:`strict`}):NaN,c=Number.isNaN(o)?p?`${n}`:n:o,l=Number.isNaN(s)?p?`${r}`:r:s,u=[c,l];return!a&&c===o&&l===s&&s<o&&(u[0]=s,u[1]=o),(p?u.map(e=>y(e)):u.every(e=>q(e,i))?u.map(e=>U(e,{parseNumbers:`strict`})):u.map(e=>v(e))).join(` ${f?.betweenAnd??f?.and??`and`} `)}case`contains`:case`doesnotcontain`:return p?Dt(y(t),m,b):g(`%${_(t)}%`);case`beginswith`:case`doesnotbeginwith`:return p?Dt(y(t),m,b):g(`${_(t)}%`);case`endswith`:case`doesnotendwith`:return p?Dt(y(t),m,b):g(`%${_(t)}`)}return typeof t==`boolean`?t?`TRUE`:`FALSE`:p?y(t):q(t,i)?`${A(t)}`:`${v(t)}`},un={and:`AND`,or:`OR`},dn=(e,t)=>{let{fields:n,fallbackExpression:r,getParseNumberBoolean:i,placeholderFieldName:a,placeholderOperatorName:o,placeholderValueName:s,ruleProcessor:c,validateRule:l,validationMap:u}=t,d=(e,f)=>{if(!G(e,u[e.id??``]))return f?r:``;let p=[],m=``,h=!0;for(let r of e.rules){if(typeof r==`string`){m=un[r];continue}if(P(r)){let e=d(r);e&&(!h&&m&&(p.push(m),m=``),h=!1,p.push(e));continue}let[e,u]=l(r);if(!G(r,e,u)||r.field===a||r.operator===o||s!==void 0&&r.value===s)continue;let f=V(n,r.field),g=c(r,{...t,parseNumbers:i(f?.inputType),escapeQuotes:(r.valueSource??`value`)===`value`,fieldData:f});g&&(!h&&m&&(p.push(m),m=``),h=!1,p.push(g))}let g=p.join(F(e)?` ${un[e.combinator]} `:` `),[_,v]=e.not||!f?[`${e.not?`NOT `:``}(`,`)`]:[``,``];return g?`${_}${g}${v}`:r};return d(e,!0)},fn=(e,t,n)=>((n,r)=>{let{fields:i,getParseNumberBoolean:a,placeholderFieldName:o,placeholderOperatorName:s,placeholderValueName:c,validateRule:l,validationMap:u,ruleProcessor:d}=t;if(!n||!r)return;let{and:f,not:p,or:m}=r,h=(e,g)=>{if(!G(e,u[e.id??``]))return;let _=e.rules.map(e=>{if(P(e))return h(e);let[u,f]=l(e);if(!G(e,u,f)||e.field===o||e.operator===s||c!==void 0&&e.value===c)return;let p=V(i,e.field);return d(e,{...t,parseNumbers:a(p?.inputType),fieldData:p,context:{...t.context,columns:n,drizzleOperators:r}})}).filter(Boolean);if(_.length===0)return;let v=e.combinator===`or`?m(..._):f(..._);return e.not?p(v):v};return h(L(e),!0)}),pn=(e,t)=>{let{fields:n,getParseNumberBoolean:r,placeholderFieldName:i,placeholderOperatorName:a,placeholderValueName:o,ruleProcessor:s,validateRule:c,validationMap:l}=t,u=e=>{if(!G(e,l[e.id??``]))return!1;let d=e.rules.map(e=>{if(P(e))return u(e);let[l,d]=c(e);if(!G(e,l,d)||e.field===i||e.operator===a||o!==void 0&&e.value===o)return!1;let f=V(n,e.field);return s(e,{...t,parseNumbers:r(f?.inputType),fieldData:f})}).filter(Boolean);return d.length!==0&&{bool:e.not?{must_not:/^or$/i.test(e.combinator)?{bool:{should:d}}:d}:{[/^or$/i.test(e.combinator)?`should`:`must`]:d}}},d=u(L(e));return d===!1?{}:d},mn=(e,t)=>{let{fields:n,fallbackExpression:r,getParseNumberBoolean:i,placeholderFieldName:a,placeholderOperatorName:o,placeholderValueName:s,ruleProcessor:c,validateRule:l,validationMap:u}=t,d=e=>{if(typeof e==`string`||P(e))return;let[r,u]=l(e);if(!G(e,r,u)||e.field===a||e.operator===o||s!==void 0&&e.value===s)return;let d=V(n,e.field);return c(e,{...t,parseNumbers:i(d?.inputType),escapeQuotes:(e.valueSource??`value`)===`value`,fieldData:d})},f=e=>{if(!G(e,u[e.id??``]))return``;let t=[];for(let n of e.rules){if(typeof n==`string`)continue;if(P(n)){let e=f(n);e&&t.push(e);continue}let e=d(n);e&&t.push(e)}if(t.length===0)return``;let n=e.combinator??`and`;if(t.length===1&&!e.not)return t[0];let r=t.map(e=>e.startsWith(`.`)?`__${e}`:e).join(`, `);return e.not?t.length===1?`.not(${r})`:`.not(__.${n}(${r}))`:`.${n}(${r})`};if(!G(e,u[e.id??``]))return r;let p=[];for(let t of e.rules){if(typeof t==`string`)continue;if(P(t)){let e=f(t);e&&p.push(e);continue}let e=d(t);e&&p.push(e)}return p.length===0?r:p.join(``)},hn=(e,t)=>{let{fields:n,fallbackExpression:r,getParseNumberBoolean:i,placeholderFieldName:a,placeholderOperatorName:o,placeholderValueName:s,ruleProcessor:c,validateRule:l,validationMap:u}=t,d=(e,f)=>{if(!G(e,u[e.id??``]))return f?r:``;let p=[],m=``,h=!0;for(let r of e.rules){if(typeof r==`string`){m=r;continue}if(P(r)){let e=d(r);e&&(!h&&m&&(p.push(m),m=``),h=!1,p.push(e));continue}let[e,u]=l(r);if(!G(r,e,u)||r.field===a||r.operator===o||s!==void 0&&r.value===s)continue;let f=V(n,r.field),g=c(r,{...t,parseNumbers:i(f?.inputType),escapeQuotes:(r.valueSource??`value`)===`value`,fieldData:f});g&&(!h&&m&&(p.push(m),m=``),h=!1,p.push(g))}let g=p.join(F(e)?` ${e.combinator} `:` `),[_,v]=e.not||!f?[`${e.not?`$not`:``}(`,`)`]:[``,``];return g?`${_}${g}${v}`:r};return d(e,!0)},gn=(e,t)=>{let{fields:n,getParseNumberBoolean:r,placeholderFieldName:i,placeholderOperatorName:a,placeholderValueName:o,ruleProcessor:s,validateRule:c,validationMap:l}=t,u=L(e),d=(e,u)=>{if(!G(e,l[e.id??``]))return!1;let f=e.rules.map(e=>{if(P(e))return d(e);let[l,u]=c(e);if(!G(e,l,u)||e.field===i||e.operator===a||o!==void 0&&e.value===o)return!1;let f=V(n,e.field);return s(e,{...t,parseNumbers:r(f?.inputType),fieldData:f})}).filter(Boolean);if(f.length===0)return!1;let p={[e.combinator]:f};return e.not?{"!":p}:p};return d(u,!0)},_n=(e,t)=>{let{fields:n,fallbackExpression:r,getParseNumberBoolean:i,placeholderFieldName:a,placeholderOperatorName:o,placeholderValueName:s,ruleProcessor:c,validateRule:l,validationMap:u}=t,d=(e,f)=>{if(!G(e,u[e.id??``]))return f?r:``;let p=e.rules.map(e=>{if(P(e))return d(e);let[r,u]=l(e);if(!G(e,r,u)||e.field===a||e.operator===o||s!==void 0&&e.value===s)return``;let f=V(n,e.field);return c(e,{...t,parseNumbers:i(f?.inputType),escapeQuotes:(e.valueSource??`value`)===`value`,fieldData:f})}).filter(Boolean),m=p.join(``),[h,g]=e.not?[`(!`,`)`]:[``,``],[_,v]=p.length>1?[`${h}(${e.combinator===`or`?`|`:`&`}`,`)${g}`]:[h,g];return m?`${_}${m}${v}`:r};return d(L(e),!0)},vn=e=>e.startsWith(`{`)&&e.endsWith(`}`),yn=(e,t,n)=>{let{fields:r,fallbackExpression:i,getParseNumberBoolean:a,placeholderFieldName:o,placeholderOperatorName:s,placeholderValueName:c,ruleProcessor:l,validateRule:u,validationMap:d}=t,f=(e,p)=>{if(!G(e,d[e.id??``]))return p?i:``;let m=`"$${M(e.combinator)}"`,h=!1,g=e.rules.map(e=>{if(P(e)){let t=f(e);return t?(h=!0,vn(t)?t:`{${t}}`):``}let[i,d]=u(e);if(!G(e,i,d)||e.field===o||e.operator===s||c!==void 0&&e.value===c)return``;let p=V(r,e.field);return l(e,{...t,parseNumbers:a(p?.inputType),fieldData:p},n)}).filter(Boolean),_=g.length>0?g.length===1&&!h?g[0]:`${m}:[${g.join(`,`)}]`:i;return e.not?`"$nor":[${vn(_)?_:`{${_}}`}]`:_},p=f(L(e),!0);return vn(p)?p:`{${p}}`},bn=(e,t)=>{let{fields:n,fallbackExpression:r,getParseNumberBoolean:i,placeholderFieldName:a,placeholderOperatorName:o,placeholderValueName:s,ruleProcessor:c,translations:l,validateRule:u,validationMap:d}=t,f=(e,p)=>{if(!G(e,d[e.id??``]))return p?r:``;let m=I(e)&&e.rules.some(e=>typeof e==`string`&&M(e)===`xor`)?L(e):e,h=[],g=``,_=!0;for(let e of m.rules){if(typeof e==`string`){g=`${l.ruleSeparator??`, `}${l[e]??e} `;continue}if(P(e)){let t=f(e,m.rules.length===1&&!(m.not||/^xor$/i.test(m.combinator??``)));t&&(!_&&g&&(h.push(g),g=``),_=!1,h.push(t));continue}let[r,d]=u(e);if(!G(e,r,d)||e.field===a||e.operator===o||s!==void 0&&e.value===s)continue;let p=(e.valueSource??`value`)===`value`,v=V(n,e.field),y=c(e,{...t,parseNumbers:i(v?.inputType),escapeQuotes:p,fieldData:v});y&&(!_&&g&&(h.push(g),g=``),_=!1,h.push(y))}if(h.length===0)return r;let v=M(m.combinator??``)===`xor`,y=v?m.combinator.slice(1):m.combinator,b=m.not||!p||v&&h.length>1,[x,S]=[`groupPrefix`,`groupSuffix`].map(e=>m.not?v?Ht(e,l,[`not`,`xor`]):Ht(e,l,[`not`]):v?Ht(e,l,[`xor`]):Ht(e,l)),C=b?`${x} (`.trim():``,w=b?`) ${S}`.trim():``,T=l.ruleSeparator??`, `;return`${C}${h.join(F(m)?`${T}${l[y]??y} `:``)}${w}`};return f(e,!0)},xn=(e,t)=>{let{format:n,fields:r,fallbackExpression:i,getParseNumberBoolean:a,placeholderFieldName:o,placeholderOperatorName:s,placeholderValueName:c,ruleProcessor:l,validateRule:u,validationMap:d}=t,f=n===`parameterized`,p=[],m={},h=new Map,g=e=>{h.has(e)||h.set(e,new Set);let t=`${e}_${h.get(e).size+1}`;return h.get(e).add(t),t},_=e=>{let[i,d]=u(e);if(!G(e,i,d)||e.field===o||e.operator===s||c!==void 0&&e.value===c)return``;let f=V(r,e.field),_=Object.fromEntries([...h.entries()].map(([e,t])=>[e,[...t]])),v=l(e,{...t,parseNumbers:a(f?.inputType),getNextNamedParam:g,fieldParamNames:_,fieldData:f},{processedParams:p});if(!N(v))return``;let{sql:y,params:b}=v;if(typeof y!=`string`||!y)return``;if(n===`parameterized`&&Array.isArray(b))p.push(...b);else if(n===`parameterized_named`&&N(b)){Object.assign(m,b);for(let t of Object.keys(b))h.get(e.field)?.add(t)}return y},v=(e,t)=>{if(!G(e,d[e.id??``]))return t?i:``;let n=[],r=``,a=!0;for(let t of e.rules){if(typeof t==`string`){r=t;continue}if(P(t)){let i=v(t,e.rules.length===1);i&&(!a&&r&&(n.push(r),r=``),a=!1,n.push(i));continue}let i=_(t);i&&(!a&&r&&(n.push(r),r=``),a=!1,n.push(i))}return n.length===0?i:`${e.not?`NOT `:``}(${n.join(F(e)?` ${e.combinator} `:` `)})`};return f?{sql:v(e,!0),params:p}:{sql:v(e,!0),params:m}},Sn={},Cn=(e,t)=>{let{fields:n,getParseNumberBoolean:r,placeholderFieldName:i,placeholderOperatorName:a,placeholderValueName:o,ruleProcessor:s,validateRule:c,validationMap:l}=t,u=(e,d)=>{if(!G(e,l[e.id??``]))return d?Sn:void 0;let f=e.combinator.toUpperCase(),p=!1,m=e.rules.map(e=>{if(P(e)){let t=u(e);return t?(p=!0,t):void 0}let[l,d]=c(e);if(!G(e,l,d)||e.field===i||e.operator===a||o!==void 0&&e.value===o)return;let f=V(n,e.field);return s(e,{...t,parseNumbers:r(f?.inputType),fieldData:f})}).filter(Boolean);return m.length>0?m.length===1&&!p?m[0]:{[f]:m}:Sn},d=u(L(e),!0);return e.not?{NOT:d}:d},wn=(e,t)=>{let{fields:n,getParseNumberBoolean:r,placeholderFieldName:i,placeholderOperatorName:a,placeholderValueName:o,ruleProcessor:s,validateRule:c,validationMap:l,context:u={}}=t,{sequelizeOperators:d}=u;if(!d)return;let f=(e,u)=>{if(!G(e,l[e.id??``]))return;let p=e.combinator.toUpperCase(),m=!1,h=e.rules.map(e=>{if(P(e)){let t=f(e);return t?(m=!0,t):void 0}let[l,u]=c(e);if(!G(e,l,u)||e.field===i||e.operator===a||o!==void 0&&e.value===o)return;let d=V(n,e.field);return s(e,{...t,parseNumbers:r(d?.inputType),fieldData:d})}).filter(Boolean);if(h.length===0)return;let g=h.length===1&&!m?h[0]:{[M(p)===`or`?d.or:d.and]:h};return e.not?{[d.not]:g}:g};return f(L(e),!0)},Tn=(e,t)=>{let{fields:n,fallbackExpression:r,getParseNumberBoolean:i,placeholderFieldName:a,placeholderOperatorName:o,placeholderValueName:s,ruleProcessor:c,validateRule:l,validationMap:u}=t,d=(e,f)=>{if(!G(e,u[e.id??``]))return f?r:``;let p=[],m=``,h=!0;for(let r of e.rules){if(typeof r==`string`){m=At[r];continue}if(P(r)){let e=d(r);e&&(!h&&m&&(p.push(m),m=``),h=!1,p.push(e));continue}let[e,u]=l(r);if(!G(r,e,u)||r.field===a||r.operator===o||s!==void 0&&r.value===s)continue;let f=V(n,r.field),g=c(r,{...t,parseNumbers:i(f?.inputType),escapeQuotes:(r.valueSource??`value`)===`value`,fieldData:f});g&&(!h&&m&&(p.push(m),m=``),h=!1,p.push(g))}let g=p.join(F(e)?` ${At[e.combinator]} `:` `),[_,v]=e.not||!f?[`${e.not?`!`:``}(`,`)`]:[``,``];return g?`${_}${g}${v}`:r};return d(e,!0)},En=(e,t)=>{let{fields:n,fallbackExpression:r,getParseNumberBoolean:i,placeholderFieldName:a,placeholderOperatorName:o,placeholderValueName:s,ruleProcessor:c,validateRule:l,validationMap:u}=t,d=(e,f)=>{if(!G(e,u[e.id??``]))return f?r:``;let p=[],m=``,h=!0;for(let r of e.rules){if(typeof r==`string`){m=r;continue}if(P(r)){let t=d(r,e.rules.length===1);t&&(!h&&m&&(p.push(m),m=``),h=!1,p.push(t));continue}let[u,f]=l(r);if(!G(r,u,f)||r.field===a||r.operator===o||s!==void 0&&r.value===s)continue;let g=(r.valueSource??`value`)===`value`,_=V(n,r.field),v=c(r,{...t,parseNumbers:i(_?.inputType),escapeQuotes:g,fieldData:_});v&&(!h&&m&&(p.push(m),m=``),h=!1,p.push(v))}return p.length===0?r:`${e.not?`NOT `:``}(${p.join(F(e)?` ${e.combinator} `:` `)})`};return d(e,!0)},Dn=(e,t)=>n=>{let{fields:r,getParseNumberBoolean:i,placeholderFieldName:a,placeholderOperatorName:o,placeholderValueName:s,validateRule:c,validationMap:l,context:u={},ruleProcessor:d}=t,f=u.tanStackDbOperators;if(!f)return;let{and:p,eq:m,not:h,or:g}=f,_=m(1,1),v=Object.keys(n);if(v.length===0)return _;let y=e=>{if(!G(e,l[e.id??``]))return;let f=e.rules.map(e=>{if(P(e))return y(e);let[l,f]=c(e);if(!G(e,l,f)||e.field===a||e.operator===o||s!==void 0&&e.value===s)return;let p=V(r,e.field);return d(e,{...t,parseNumbers:i(p?.inputType),fieldData:p,context:{...u,_tanstackDbRefs:n,_tanstackDbPrimaryRef:v[0]}})}).filter(Boolean);if(f.length===0)return _;let m=f.length===1?f[0]:e.combinator===`or`?g(...f):p(...f);return e.not?h(m):m};return y(L(e))??_},On=new Set([`number`,`range`,`bigint`]),kn=/^\d{4}-\d{2}-\d{2}$/,An=/^\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/,jn=/^\d{4}-\d{2}$/,Mn=/^\d{4}-W\d{2}$/,Nn=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i,Pn=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Fn=(e,t,n)=>{let r=new Date(Date.UTC(e,t-1,n));return r.getUTCFullYear()===e&&r.getUTCMonth()===t-1&&r.getUTCDate()===n},In=e=>{let t=e.split(`:`),n=Number(t[0]),r=Number(t[1]),i=t[2]?Number.parseFloat(t[2]):0;return n>=0&&n<=23&&r>=0&&r<=59&&i>=0&&i<60},Ln=(e,t)=>{if(e!=null&&e!==``){if(On.has(t)){let t=typeof e==`string`?e.trim():e;return typeof t==`number`||typeof t==`bigint`||typeof t==`string`&&le.test(t)?void 0:`VALUE_TYPE_MISMATCH`}if(t===`date`){if(typeof e!=`string`)return`VALUE_TYPE_MISMATCH`;let t=e.trim();if(!kn.test(t))return`VALUE_TYPE_MISMATCH`;let[n,r,i]=t.split(`-`).map(Number);return Fn(n,r,i)?void 0:`VALUE_TYPE_MISMATCH`}if(t===`datetime-local`){if(typeof e!=`string`)return`VALUE_TYPE_MISMATCH`;let t=e.trim().replace(/(Z|[+-]\d{2}:?\d{2}|[+-]\d{2})$/,``),n=t.indexOf(`T`);if(n===-1)return`VALUE_TYPE_MISMATCH`;let r=t.slice(0,n),i=t.slice(n+1);if(!kn.test(r)||!An.test(i))return`VALUE_TYPE_MISMATCH`;let[a,o,s]=r.split(`-`).map(Number);return Fn(a,o,s)&&In(i)?void 0:`VALUE_TYPE_MISMATCH`}if(t===`time`){if(typeof e!=`string`)return`VALUE_TYPE_MISMATCH`;let t=e.trim();return An.test(t)&&In(t)?void 0:`VALUE_TYPE_MISMATCH`}if(t===`month`){if(typeof e!=`string`)return`VALUE_TYPE_MISMATCH`;let t=e.trim();if(!jn.test(t))return`VALUE_TYPE_MISMATCH`;let n=Number(t.slice(5));return n>=1&&n<=12?void 0:`VALUE_TYPE_MISMATCH`}if(t===`week`){if(typeof e!=`string`)return`VALUE_TYPE_MISMATCH`;let t=e.trim();if(!Mn.test(t))return`VALUE_TYPE_MISMATCH`;let n=Number(t.slice(6));return n>=1&&n<=53?void 0:`VALUE_TYPE_MISMATCH`}if(t===`color`)return typeof e==`string`&&Nn.test(e.trim())?void 0:`VALUE_TYPE_MISMATCH`;if(t===`url`){if(typeof e!=`string`)return`VALUE_TYPE_MISMATCH`;try{new URL(e.trim());return}catch{return`VALUE_TYPE_MISMATCH`}}if(t===`email`)return typeof e==`string`&&Pn.test(e.trim())?void 0:`VALUE_TYPE_MISMATCH`}},Rn=(e,t)=>{let{fields:n,placeholderFieldName:r,placeholderOperatorName:i,placeholderValueName:a,validateRule:o,validationMap:s}=t,c=[],l={totalRules:0,totalGroups:0,validRules:0,invalidRules:0,validGroups:0,invalidGroups:0},u={},d=Xe(n),f=new Map;for(let e of d)f.set(e.name,e);let p=f.size>0,m=(e,t)=>{l.totalGroups++;let n=t.length,d=s[e.id??``],h=G(e,d),g=Bn(d);e.muted?c.push({id:e.id??``,path:t,code:`MUTED`,message:`Group is muted`,source:`muted`}):!h&&d!==void 0&&c.push({id:e.id??``,path:t,code:`CUSTOM_VALIDATOR`,message:g?`Invalid: ${g.join(`, `)}`:`Group failed validation`,source:`query-validator`});let _=!0,v=0,y=[];for(let n of e.rules){if(typeof n==`string`){y.push(n),v++;continue}let e=[...t,v];if(P(n)){let t=m(n,e);t.valid||(_=!1),y.push(t),v++;continue}l.totalRules++;let s=e.length,[d,h]=o(n),g=G(n,d,h)&&n.field!==r&&n.operator!==i&&(a===void 0||n.value!==a);zn(n,e,d,h,g,c,r,i,a,p,f),g?l.validRules++:(_=!1,l.invalidRules++);let b=n.field;u[b]||(u[b]={ruleCount:0,invalidCount:0}),u[b].ruleCount++,g||u[b].invalidCount++;let x=Bn(d)??Vn(n,h),S={...n,valid:g,...x?{reasons:x}:null,path:e,level:s};y.push(S),v++}let b=h&&_;return b?l.validGroups++:l.invalidGroups++,F(e),{...e,valid:b,...g?{reasons:g}:null,path:t,level:n,rules:y}},h=m(e,[]);if(p){let e=new Set(Object.keys(u));for(let[t]of f)e.has(t)||c.push({id:``,path:[],code:`UNREFERENCED_FIELD`,message:`Field "${t}" is defined in the fields config but not used in the query`,source:`field-check`})}return{query:h,diagnostics:c,stats:l,fieldSummary:u}},zn=(e,t,n,r,i,a,o,s,c,l,u)=>{let d=e.id??``;if(e.muted&&a.push({id:d,path:t,code:`MUTED`,message:`Rule is muted`,source:`muted`}),e.field===o&&a.push({id:d,path:t,code:`PLACEHOLDER_FIELD`,message:`Rule has a placeholder field`,source:`placeholder`}),e.operator===s&&a.push({id:d,path:t,code:`PLACEHOLDER_OPERATOR`,message:`Rule has a placeholder operator`,source:`placeholder`}),c!==void 0&&e.value===c&&a.push({id:d,path:t,code:`PLACEHOLDER_VALUE`,message:`Rule has a placeholder value`,source:`placeholder`}),!e.muted&&e.field!==o&&e.operator!==s&&(c===void 0||e.value!==c)){if(typeof n==`boolean`&&!n)a.push({id:d,path:t,code:`CUSTOM_VALIDATOR`,message:`Rule failed validation`,source:`query-validator`});else if(typeof n!=`boolean`&&St(n)&&!n.valid){let e=n.reasons;a.push({id:d,path:t,code:`CUSTOM_VALIDATOR`,message:e?`Invalid: ${e.join(`, `)}`:`Rule failed validation`,source:`query-validator`})}else if(!i&&typeof r==`function`){let n=r(e),i=typeof n!=`boolean`&&St(n)&&!n.valid?n.reasons:void 0;a.push({id:d,path:t,code:`CUSTOM_VALIDATOR`,message:i?`Invalid: ${i.join(`, `)}`:`Rule failed field validation`,source:`field-validator`})}}if(l&&!u.has(e.field)&&e.field!==o&&a.push({id:d,path:t,code:`UNDEFINED_FIELD`,message:`Field "${e.field}" is not defined in the fields config`,source:`field-check`}),l){let n=u.get(e.field);if(n?.inputType){let r=Ln(e.value,n.inputType);r&&a.push({id:d,path:t,code:r,message:`Value "${e.value}" is not compatible with input type "${n.inputType}"`,source:`type-check`})}}},Bn=e=>{if(typeof e!=`boolean`&&St(e)&&!e.valid&&e.reasons)return e.reasons},Vn=(e,t)=>{if(typeof t==`function`){let n=t(e);if(typeof n!=`boolean`&&St(n)&&!n.valid&&n.reasons)return n.reasons}},Hn=(e,t)=>typeof e!=`string`||!t?`${e}`:e.replaceAll(`'`,`\\'`),Un=(e,t={})=>{let{escapeQuotes:n,parseNumbers:r}=t,{field:i,operator:a,value:o,valueSource:s}=e,c=s===`field`,l=a.toLowerCase(),u=e=>e==null?`null`:typeof e==`boolean`||typeof e==`bigint`?String(e):c||typeof e==`number`||q(e,r)?A(e):`'${Hn(e,n)}'`;switch(l){case`=`:return`${i} = ${u(o)}`;case`!=`:case`<>`:return`${i} <> ${u(o)}`;case`<`:case`>`:case`<=`:case`>=`:return`${i} ${l} ${u(o)}`;case`contains`:return`${i} CONTAINS ${u(o)}`;case`doesnotcontain`:return`NOT ${i} CONTAINS ${u(o)}`;case`beginswith`:return`${i} STARTS WITH ${u(o)}`;case`doesnotbeginwith`:return`NOT ${i} STARTS WITH ${u(o)}`;case`endswith`:return`${i} ENDS WITH ${u(o)}`;case`doesnotendwith`:return`NOT ${i} ENDS WITH ${u(o)}`;case`null`:return`${i} IS NULL`;case`notnull`:return`${i} IS NOT NULL`;case`in`:case`notin`:{let e=j(o).map(u);return e.length?`${l===`notin`?`NOT `:``}${i} IN [${e.join(`, `)}]`:``}case`between`:case`notbetween`:{let e=j(o);if(e.length<2)return``;let[t,n]=[u(e[0]),u(e[1])],r=`${t} <= ${i} AND ${i} <= ${n}`;return l===`notbetween`?`NOT (${r})`:r}default:return`${i} ${a} ${u(o)}`}},Wn=(e,t)=>{let n=t??{},{parseNumbers:r,preserveValueOrder:i,context:a={}}=n,{columns:o,drizzleOperators:s,useRawFields:c}=a;if(!o||!s)return;let{between:l,eq:u,gt:d,gte:f,inArray:p,isNotNull:m,isNull:h,like:g,lt:_,lte:v,ne:y,notBetween:b,notInArray:x,notLike:S,sql:C}=s,{field:w,operator:T,value:E,valueSource:D}=e,O=c&&/^[a-z_][a-z0-9_.]*$/i.test(w)?C.raw(w):o[w],k=M(T),ee=D===`field`,te=e=>ee?o[e]:e,ne=e=>ee||!r?te(e):q(e,!0)?U(e,{parseNumbers:!0}):e;if(!O)return;let re=J(e);if(re!==!1){if(re){if(n.preset!==`postgresql`)return;let{mode:t,threshold:r}=re,i=n.subqueryDepth??0,a=Wt(i),o=W(e.value,{ruleProcessor:e=>({...e,field:a})}),c=fn(o,{...n,context:{...n.context,useRawFields:!0},subqueryDepth:i+1});switch(t){case`all`:return C`(select count(*) from unnest(${O}) as ${C.raw(a)} where ${c({},s)}) = array_length(${O}, 1)`;case`none`:return C`not exists (select 1 from unnest(${O}) as ${C.raw(a)} where ${c({},s)})`;case`some`:return C`exists (select 1 from unnest(${O}) as ${C.raw(a)} where ${c({},s)})`;case`atleast`:case`atmost`:case`exactly`:{let e=t===`atleast`?`>=`:t===`atmost`?`<=`:`=`;return r>0&&r<1?C`(select count(*)::float / array_length(${O}, 1) from unnest(${O}) as ${C.raw(a)} where ${c({},s)}) ${C.raw(`${e} ${r}`)}`:C`(select count(*) from unnest(${O}) as ${C.raw(a)} where ${c({},s)}) ${C.raw(`${e} ${r}`)}`}}}switch(k){case`=`:return u(O,ne(E));case`!=`:return y(O,ne(E));case`>`:return d(O,ne(E));case`<`:return _(O,ne(E));case`>=`:return f(O,ne(E));case`<=`:return v(O,ne(E));case`beginswith`:case`doesnotbeginwith`:return(k===`doesnotbeginwith`?S:g)(O,ee?C`${te(E)} || '%'`:`${E}%`);case`contains`:case`doesnotcontain`:return(k===`doesnotcontain`?S:g)(O,ee?C`'%' || ${te(E)} || '%'`:`%${E}%`);case`endswith`:case`doesnotendwith`:return(k===`doesnotendwith`?S:g)(O,ee?C`'%' || ${te(E)}`:`%${E}`);case`null`:return h(O);case`notnull`:return m(O);case`in`:case`notin`:{let e=j(E).map(e=>ne(e));return k===`notin`?x(O,e):p(O,e)}case`between`:case`notbetween`:{let e=j(E);if(e.length>=2&&K(e[0])&&K(e[1])){let[t,n]=e,a=r!==!1;if(!ee&&q(t,a)&&q(n,a)){let e=U(t,{parseNumbers:a}),r=U(n,{parseNumbers:a});if(!i&&r<e){let i=r;n=e,t=i}else t=e,n=r}else ee&&(t=te(t),n=te(n));return k===`notbetween`?b(O,t,n):l(O,t,n)}return}default:return}}},Gn={"<":`lt`,"<=":`lte`,">":`gt`,">=":`gte`},Kn=(e,t)=>e.startsWith(`not`)||e.startsWith(`doesnot`)?{bool:{must_not:t}}:t,qn=e=>e?.replace(/('|\\)/g,`\\$1`),Jn={beginswith:`startsWith`,doesnotbeginwith:`startsWith`,doesnotcontain:`contains`,doesnotendwith:`endsWith`,endswith:`endsWith`},Yn=(e,t,n)=>{let r=`doc['${e}'].value.${Jn[t]??t}(doc['${n}'].value)`;return t.startsWith(`d`)?`!${r}`:r},Xn=(e,t)=>typeof e==`boolean`?e:q(e,t)?U(e,{parseNumbers:t}):e,Zn=(e,t={})=>{let{field:n,operator:r,value:i,valueSource:a}=e,{parseNumbers:o,preserveValueOrder:s}=t,c=M(r),l=J(e);if(l===!1)return!1;if(l){let{mode:r}=l,i=pn(W(e.value,{ruleProcessor:e=>({...e,field:e.field?`${n}.${e.field}`:n})}),t);if(Object.keys(i).length===0)return!1;switch(r){case`some`:return{nested:{path:n,query:i}};case`none`:return{bool:{must_not:{nested:{path:n,query:i}}}};case`all`:case`atleast`:case`atmost`:case`exactly`:return!1}}if(a===`field`){if(j(i).some(e=>typeof e!=`string`))return!1;let e=qn(n);switch(c){case`=`:case`!=`:case`>`:case`>=`:case`<`:case`<=`:{let t=c===`=`?`==`:c,n=qn(i);return n?{bool:{filter:{script:{script:`doc['${e}'].value ${t} doc['${n}'].value`}}}}:!1}case`in`:case`notin`:{let t=j(i);if(t.length>0){let n=t.map(t=>({bool:{filter:{script:{script:`doc['${e}'].value == doc['${t}'].value`}}}}));return{bool:c===`in`?{should:n}:{must_not:n}}}return!1}case`between`:case`notbetween`:{let t=j(i);if(t.length>=2&&t[0]&&t[1]){let n=`doc['${e}'].value >= doc['${t[0]}'].value && doc['${e}'].value <= doc['${t[1]}'].value`;return{bool:{filter:{script:{script:c===`notbetween`?`!(${n})`:n}}}}}return!1}case`contains`:case`doesnotcontain`:case`beginswith`:case`doesnotbeginwith`:case`endswith`:case`doesnotendwith`:{let t=qn(i);return t?{bool:{filter:{script:{script:Yn(e,c,t)}}}}:!1}}}switch(c){case`<`:case`<=`:case`>`:case`>=`:return{range:{[n]:{[Gn[c]]:Xn(i,o)}}};case`=`:return{term:{[n]:Xn(i,o)}};case`!=`:return{bool:{must_not:{term:{[n]:Xn(i,o)}}}};case`null`:return{bool:{must_not:{exists:{field:n}}}};case`notnull`:return{exists:{field:n}};case`in`:case`notin`:{let e=j(i).map(e=>Xn(e,o));if(e.length>0){let t=e.map(e=>({term:{[n]:Xn(e,o)}}));return{bool:c===`in`?{should:t}:{must_not:t}}}return!1}case`between`:case`notbetween`:{let e=j(i);if(e.length>=2&&K(e[0])&&K(e[1])){let[t,r]=e,i=o!==!1;if(q(t,i)&&q(r,i)){let e=U(t,{parseNumbers:i}),n=U(r,{parseNumbers:i});if(!s&&n<e){let i=n;r=e,t=i}else t=e,r=n}return Kn(c,{range:{[n]:{gte:t,lte:r}}})}return!1}case`contains`:case`doesnotcontain`:return Kn(c,{regexp:{[n]:{value:`.*${i}.*`}}});case`beginswith`:case`doesnotbeginwith`:return Kn(c,{regexp:{[n]:{value:`${i}.*`}}});case`endswith`:case`doesnotendwith`:return Kn(c,{regexp:{[n]:{value:`.*${i}`}}})}return!1},Qn=(e,t)=>typeof e!=`string`||!t?`${e}`:e.replaceAll(`'`,`\\'`),$n=(e,t={})=>{let{escapeQuotes:n,parseNumbers:r}=t,{field:i,operator:a,value:o,valueSource:s}=e,c=s===`field`,l=a.toLowerCase(),u=i.includes(`.`)?i.split(`.`).pop():i,d=e=>e==null?`null`:typeof e==`boolean`||typeof e==`bigint`?String(e):c||typeof e==`number`||q(e,r)?A(e):`'${Qn(e,n)}'`;switch(l){case`=`:return`.has('${u}', ${d(o)})`;case`!=`:case`<>`:return`.has('${u}', neq(${d(o)}))`;case`<`:return`.has('${u}', lt(${d(o)}))`;case`>`:return`.has('${u}', gt(${d(o)}))`;case`<=`:return`.has('${u}', lte(${d(o)}))`;case`>=`:return`.has('${u}', gte(${d(o)}))`;case`contains`:return`.has('${u}', containing(${d(o)}))`;case`doesnotcontain`:return`.has('${u}', notContaining(${d(o)}))`;case`beginswith`:return`.has('${u}', startingWith(${d(o)}))`;case`doesnotbeginwith`:return`.has('${u}', notStartingWith(${d(o)}))`;case`endswith`:return`.has('${u}', endingWith(${d(o)}))`;case`doesnotendwith`:return`.has('${u}', notEndingWith(${d(o)}))`;case`null`:return`.hasNot('${u}')`;case`notnull`:return`.has('${u}')`;case`in`:{let e=j(o).map(d);return e.length?`.has('${u}', within(${e.join(`, `)}))`:``}case`notin`:{let e=j(o).map(d);return e.length?`.has('${u}', without(${e.join(`, `)}))`:``}case`between`:{let e=j(o);return e.length<2?``:`.has('${u}', between(${d(e[0])}, ${d(e[1])}))`}case`notbetween`:{let e=j(o);return e.length<2?``:`.has('${u}', outside(${d(e[0])}, ${d(e[1])}))`}default:return`.has('${u}', ${d(o)})`}},er=e=>e.startsWith(`not`)||e.startsWith(`doesnot`),tr=(e,t)=>`"${typeof e!=`string`||!t?`${e}`:e.replaceAll(`"`,`\\"`)}"`,nr=(e,t)=>t?`$not(${e})`:e,rr=e=>`${e}`.replaceAll(/[/$()*+.?[\\\]^{|}]/g,String.raw`\$&`).replaceAll(`-`,String.raw`\x2d`),ir=(e,t={})=>{let{field:n,operator:r,value:i,valueSource:a}=e,{escapeQuotes:o,parseNumbers:s,preserveValueOrder:c,quoteFieldNamesWith:l=[``,``],fieldIdentifierSeparator:u=``}=t,d=a===`field`,f=typeof i==`number`||typeof i==`boolean`||typeof i==`bigint`||q(i,s),p=e=>Ft(e,{quoteFieldNamesWith:l,fieldIdentifierSeparator:u}),m=J(e);if(m===!1)return;if(m){let{mode:e,threshold:r}=m,a=`$count(${p(n)})`,o=`$count($filter(${p(n)}, function($v) {${hn(W(i,{ruleProcessor:e=>({...e,field:e.field?`$v.${e.field}`:`$v`})}),t)}}))`;switch(e){case`all`:return`${o} = ${a}`;case`none`:return`${o} = 0`;case`some`:return`${o} > 0`;case`atleast`:case`atmost`:case`exactly`:{let t=e===`atleast`?`>=`:e===`atmost`?`<=`:`=`;return r>0&&r<1?`${o} ${t} (${a} * ${r})`:`${o} ${t} ${r}`}}}let h=M(r);switch(h){case`<`:case`<=`:case`=`:case`!=`:case`>`:case`>=`:return`${p(n)} ${h} ${d?p(A(i)):f?A(i):tr(i,o)}`;case`contains`:case`doesnotcontain`:return nr(`$contains(${p(n)}, ${d?p(A(i)):tr(i,o)})`,er(h));case`beginswith`:case`doesnotbeginwith`:return nr(d?`$substring(${p(n)}, 0, $length(${p(A(i))})) = ${p(A(i))}`:`$contains(${p(n)}, /^${rr(i)}/)`,er(h));case`endswith`:case`doesnotendwith`:return nr(d?`$substring(${p(n)}, $length(${p(n)}) - $length(${p(A(i))})) = ${p(A(i))}`:`$contains(${p(n)}, /${rr(i)}$/)`,er(h));case`null`:return`${p(n)} = null`;case`notnull`:return`${p(n)} != null`;case`in`:case`notin`:{let e=j(i);return nr(`${p(n)} in [${e.map(e=>d?`${p(A(e))}`:q(e,s)?`${A(e)}`:tr(e,o)).join(`, `)}]`,er(h))}case`between`:case`notbetween`:{let e=j(i);if(e.length<2||ue(e[0])||ue(e[1]))return``;let[t,r]=e,a=s!==!1,l=q(t,a)?U(t,{parseNumbers:a}):NaN,u=q(r,a)?U(r,{parseNumbers:a}):NaN,f=Number.isNaN(l)?d?`${t}`:t:l,m=Number.isNaN(u)?d?`${r}`:r:u;if(!c&&f===l&&m===u&&u<l){let e=u;m=l,f=e}let g=q(t,s)&&q(r,s),_=(e,t)=>d?p(e):g?t:tr(t,o),v=`${p(n)} >= ${_(t,f)} and ${p(n)} <= ${_(r,m)}`;return h===`between`?`(${v})`:nr(v,!0)}}return``},ar=e=>e.replace(/^(=)$/,`$1=`).replace(/^notnull$/i,`!=`).replace(/^null$/i,`==`),or=(e,t)=>e.startsWith(`not`)||e.startsWith(`doesnot`)?{"!":t}:t,sr=(e,t={})=>{let{field:n,operator:r,value:i,valueSource:a}=e,{parseNumbers:o,preserveValueOrder:s}=t,c=a===`field`,l={var:n},u=e=>c?{var:`${e}`}:q(e,o)?U(e,{parseNumbers:o}):e,d=J(e);if(d===!1)return!1;if(d){let{mode:e,threshold:r}=d;switch(e){case`all`:case`none`:case`some`:return{[e]:[{var:n},i.rules.length===1&&!P(i.rules[0])?sr(i.rules[0],t):gn(i,t)]};case`atleast`:case`atmost`:case`exactly`:{let a=e===`atleast`?`>=`:e===`atmost`?`<=`:`==`,o={reduce:[{filter:[{var:n},i.rules.length===1&&!P(i.rules[0])?sr(i.rules[0],t):gn(i,t)]},{"+":[1,{var:`accumulator`}]},0]};if(r>0&&r<1){let e={reduce:[{var:n},{"+":[1,{var:`accumulator`}]},0]};return{[a]:[o,{"*":[e,r]}]}}return{[a]:[o,r]}}}}let f=M(r);switch(f){case`<`:case`<=`:case`=`:case`!=`:case`>`:case`>=`:return{[ar(f)]:[l,u(i)]};case`null`:case`notnull`:return{[`${f===`notnull`?`!`:`=`}=`]:[l,null]};case`in`:case`notin`:{let e=j(i).map(e=>u(e));return or(f,{in:[l,e]})}case`between`:case`notbetween`:{let e=j(i);if(e.length>=2&&K(e[0])&&K(e[1])){let[t,n]=e,r=o!==!1;if(!c&&q(t,r)&&q(n,r)){let e=U(t,{parseNumbers:r}),i=U(n,{parseNumbers:r});if(!s&&i<e){let r=i;n=e,t=r}else t=e,n=i}else c&&(t={var:t},n={var:n});return or(f,{"<=":[t,l,n]})}return!1}case`contains`:case`doesnotcontain`:{let e={in:[u(i),l]};return or(f,e)}case`beginswith`:case`doesnotbeginwith`:{let e={startsWith:[l,u(i)]};return or(f,e)}case`endswith`:case`doesnotendwith`:{let e={endsWith:[l,u(i)]};return or(f,e)}}return!1},cr=(e,t)=>t?`(!${e})`:`${e}`,lr=e=>`${A(e)}`.replaceAll(/[()&|=<>~*\\/]/g,e=>`\\${e.codePointAt(0).toString(16)}`),ur=(e,t={})=>{let{field:n,operator:r,value:i,valueSource:a}=e,{preserveValueOrder:o}=t,s=M(r);if(a===`field`||ue(i)&&s!==`null`&&s!==`notnull`||J(e))return``;switch(s){case`=`:case`!=`:return cr(`(${n}=${lr(i)})`,s===`!=`);case`>`:case`>=`:return`(${n}>=${lr(i)})`;case`<`:case`<=`:return`(${n}<=${lr(i)})`;case`contains`:case`doesnotcontain`:return cr(`(${n}=*${lr(i)}*)`,s===`doesnotcontain`);case`beginswith`:case`doesnotbeginwith`:return cr(`(${n}=${lr(i)}*)`,s===`doesnotbeginwith`);case`endswith`:case`doesnotendwith`:return cr(`(${n}=*${lr(i)})`,s===`doesnotendwith`);case`null`:case`notnull`:return cr(`(${n}=*)`,s===`notnull`);case`in`:case`notin`:{let e=j(i);return cr(`(|${e.map(e=>`(${n}=${lr(e)})`).join(``)})`,s===`notin`)}case`between`:case`notbetween`:{let e=j(i);if(e.length<2||ue(e[0])||ue(e[1]))return``;let[t,r]=e,a=q(t,!0)?U(t,{parseNumbers:!0}):NaN,c=q(r,!0)?U(r,{parseNumbers:!0}):NaN,l=Number.isNaN(a)?t:a,u=Number.isNaN(c)?r:c;if(!o&&l===a&&u===c&&c<a){let e=c;u=a,l=e}return cr(`(&(${n}>=${lr(l)})(${n}<=${lr(u)}))`,s===`notbetween`)}}return``},dr=(e,t,n)=>n&&typeof e==`string`?e.replaceAll(`${t}`,`${t}${t}`):e,fr=(e,t={})=>{let{escapeQuotes:n,fields:r,parseNumbers:i,quoteFieldNamesWith:a,quoteValuesWith:o,fieldIdentifierSeparator:s,translations:c}=t,l=e.valueSource===`field`,u=M(e.operator),d=o||`'`,f=e=>`${d}${e}${d}`,p=e=>dr(e,d,n),m=e=>f(p(e)),h=e=>Ft(e,{quoteFieldNamesWith:a,fieldIdentifierSeparator:s}),g=c??{},_=g.or??`or`,v=g.true??`true`,y=g.false??`false`,b=g.listSeparator??`, `,x=!g.listSeparator;switch(u){case`null`:case`notnull`:return``;case`between`:case`notbetween`:{if(!l)return ln(e,t);let n=j(e.value,{retainEmptyStrings:!0}).slice(0,2).map(e=>h(V(r??[],e)?.label??e));return n.length<2||!K(n[0])||!K(n[1])?``:ln({...e,value:n},t)}case`in`:case`notin`:{let t=j(e.value);if(t.length===0)return``;let n=t.map(e=>l?h(V(r??[],e)?.label??e):q(e,i)?`${A(e)}`:`${m(e)}`);if(n.length===1)return n[0];let a=x&&n.length>2?`,`:``;return`(${`${n.slice(0,-1).join(b)}${a} ${_} ${n.at(-1)}`})`}}return typeof e.value==`boolean`?e.value?v:y:l?h(V(r??[],e.value)?.label??e.value):q(e.value,i)?`${A(e.value)}`:`${m(e.value)}`},pr={"=":[`is`,`is the same as the value in`],"!=":[`is not`,`is not the same as the value in`],"<":[`is less than`,`is less than the value in`],">":[`is greater than`,`is greater than the value in`],"<=":[`is less than or equal to`,`is less than or equal to the value in`],">=":[`is greater than or equal to`,`is greater than or equal to the value in`],contains:[`contains`,`contains the value in`],beginswith:[`starts with`,`starts with the value in`],endswith:[`ends with`,`ends with the value in`],doesnotcontain:[`does not contain`,`does not contain the value in`],doesnotbeginwith:[`does not start with`,`does not start with the value in`],doesnotendwith:[`does not end with`,`does not end with the value in`],null:`is null`,notnull:`is not null`,in:[`is one of the values`,`is the same as a value in`],notin:[`is not one of the values`,`is not the same as any value in`],between:[`is between`,`is between the values in`],notbetween:[`is not between`,`is not between the values in`]},mr=()=>[],hr=(e,t={})=>{let{field:n,operator:r,valueSource:i=`value`}=e,{getOperators:a=mr,operatorMap:o=pr}=t,s=new Map(Object.entries(pr));for(let[e,t]of Object.entries(o))s.set(M(e),t);let c=Object.fromEntries(s),l=M(r);var u=r;let d=j(e.value).length===1;l===`in`&&d?u=`=`:l===`notin`&&d&&(u=`!=`);let{value:f,label:p}=V(z(a(n,{fieldData:t.fieldData??{name:n,value:n,label:n}})??[]),u)??{name:u,value:u,label:u},m=c[f]??c[M(f)]??[p,p];return typeof m==`string`?m:m[+(i===`field`)]},gr=(e,t)=>{let{field:n,operator:r}=e,{fieldData:i,quoteFieldNamesWith:a=[``,``],fieldIdentifierSeparator:o=``,quoteValuesWith:s=`'`,operatorProcessor:c=hr,valueProcessor:l=fr,concatOperator:u=`||`,wordOrder:d=`SVO`}=t??{},f=Ft(i?.label??n,{quoteFieldNamesWith:a,fieldIdentifierSeparator:o}),p=J(e);if(p===!1)return``;if(p){let{mode:n,threshold:r}=p,a=bn(e.value,{...t,fields:z(i?.subproperties??[])}),o=(i?.subproperties?.length??0)>0;switch(n){case`all`:return`(${o?`for `:``}every item in ${f}${o?`,`:``} ${a})`;case`none`:return`(${o?`for `:``}no item in ${f}${o?`,`:``} ${a})`;case`some`:return`(${o?`for `:``}at least one item in ${f}${o?`,`:``} ${a})`;case`atleast`:case`atmost`:case`exactly`:{let e=n.replace(`at`,`at `);return r>0&&r<1?`(${o?`for `:``}${e} ${r*100}% of the items in ${f}${o?`,`:``} ${a})`:`(${o?`for `:``}${e} ${r} of the items in ${f}${o?`,`:``} ${a})`}}}let m=l(e,{...t,quoteFieldNamesWith:a,fieldIdentifierSeparator:o,quoteValuesWith:s,concatOperator:u}),h=M(r);if((h===`in`||h===`notin`||h===`between`||h===`notbetween`)&&!m)return``;let g={S:f,V:c(e,t),O:m},_=t?.translations??{},v={S:_.afterSubject??` `,V:_.afterVerb??` `,O:_.afterObject??` `},y=Lt(d).filter(e=>g[e]!==``);return y.map((e,t)=>`${g[e]}${t<y.length-1?v[e]:``}`).join(``).trim()},_r=e=>M(wt(e.operator)),vr=(e,t={})=>{let{quoteFieldNamesWith:n=[``,``],fieldIdentifierSeparator:r=``,quoteValuesWith:i=`'`,operatorProcessor:a=_r,valueProcessor:o=ln,concatOperator:s=`||`}=t,c=e=>Ft(e,{quoteFieldNamesWith:n,fieldIdentifierSeparator:r}),l=c(e.field),u=J(e);if(u===!1)return;if(u){if(t?.preset!==`postgresql`)return``;let{mode:n,threshold:r}=u,i=t.subqueryDepth??0,a=Wt(i),o=En(W(e.value,{ruleProcessor:e=>({...e,field:a})}),{...t,subqueryDepth:i+1});switch(n){case`all`:return`(select count(*) from unnest(${l}) as ${c(a)} where ${o}) = array_length(${l}, 1)`;case`none`:return`not exists (select 1 from unnest(${l}) as ${c(a)} where ${o})`;case`some`:return`exists (select 1 from unnest(${l}) as ${c(a)} where ${o})`;case`atleast`:case`atmost`:case`exactly`:{let e=n===`atleast`?`>=`:n===`atmost`?`<=`:`=`;return`(select count(*)${r>0&&r<1?`::float / array_length(${l}, 1)`:``} from unnest(${l}) as ${c(a)} where ${o}) ${e} ${r}`}}}let d=o(e,{...t,quoteFieldNamesWith:n,fieldIdentifierSeparator:r,quoteValuesWith:i,concatOperator:s}),f=a(e,t),p=M(f);return(p===`in`||p===`not in`||p===`between`||p===`not between`)&&!d?``:`${l} ${f} ${d}`.trim()},yr=(e,t,n)=>{let{fieldData:r,format:i,getNextNamedParam:a,parseNumbers:o,paramPrefix:s,paramsKeepPrefix:c,numberedParams:l,quoteFieldNamesWith:u=[``,``],fieldIdentifierSeparator:d,concatOperator:f,operatorProcessor:p=_r,valueProcessor:m=ln}=t??{},{processedParams:h=[]}=n??{},g=i===`parameterized`,_=[],v={},y=e=>g?{sql:e,params:_}:{sql:e,params:v},b=e=>Ft(e,{quoteFieldNamesWith:u,fieldIdentifierSeparator:d}),x=b(e.field),S=J(e);if(S===!1)return;if(S){if(t?.preset!==`postgresql`)return y(``);let{mode:n,threshold:r}=S,i=t.subqueryDepth??0,a=Wt(i),{sql:o,params:s}=xn(W(e.value,{ruleProcessor:e=>({...e,field:a})}),{...t,fields:[],subqueryDepth:i+1});switch(Array.isArray(s)?_.push(...s):Object.assign(v,s),n){case`all`:return y(`(select count(*) from unnest(${x}) as ${b(a)} where ${o}) = array_length(${x}, 1)`);case`none`:return y(`not exists (select 1 from unnest(${x}) as ${b(a)} where ${o})`);case`some`:return y(`exists (select 1 from unnest(${x}) as ${b(a)} where ${o})`);case`atleast`:case`atmost`:case`exactly`:{let e=n===`atleast`?`>=`:n===`atmost`?`<=`:`=`;return y(`(select count(*)${r>0&&r<1?`::float / array_length(${x}, 1)`:``} from unnest(${x}) as ${b(a)} where ${o}) ${e} ${r}`)}}}let C=m(e,{parseNumbers:o,quoteFieldNamesWith:u,concatOperator:f,fieldData:r,format:i}),w=p(e,t),T=M(w),[E,D]=u;if((T===`in`||T===`not in`||T===`between`||T===`not between`)&&!C)return y(``);if(T===`is null`||T===`is not null`)return y(`${E}${e.field}${D} ${w}`);if(e.valueSource===`parameter`){let t=e=>{let t=Rt(e,s);return g||(v[c?t:zt(e,s)]=null),t};if(T===`between`||T===`not between`){let[n,r]=j(e.value,{retainEmptyStrings:!0}).slice(0,2);return y(`${E}${e.field}${D} ${w} ${t(n)} and ${t(r)}`.trim())}if(T===`in`||T===`not in`){let n=j(e.value);return y(`${E}${e.field}${D} ${w} (${n.map(e=>t(e)).join(`, `)})`)}return y(`${E}${e.field}${D} ${w} ${Dt(t(e.value),M(e.operator),{concatOperator:f})}`.trim())}if(e.valueSource===`field`)return y(`${E}${e.field}${D} ${w} ${C}`.trim());if(T===`in`||T===`not in`){let t=j(e.value);if(g){for(let e of t)_.push(q(e,o)?U(e,{parseNumbers:o}):e);return y(`${E}${e.field}${D} ${w} (${t.map((e,n)=>l?`${s}${h.length+1+t.length-(t.length-n)}`:`?`).join(`, `)})`)}let n=[];for(let r of t){let t=a(e.field);n.push(`${s}${t}`),v[`${c?s:``}${t}`]=q(r,o)?U(r,{parseNumbers:o}):r}return y(`${E}${e.field}${D} ${w} (${n.join(`, `)})`)}if(T===`between`||T===`not between`){let[t,n]=j(e.value,{retainEmptyStrings:!0}).slice(0,2).map(e=>q(e,o)?U(e,{parseNumbers:o}):e);if(g)return _.push(t,n),y(`${E}${e.field}${D} ${w} ${l?`${s}${h.length+1}`:`?`} and ${l?`${s}${h.length+2}`:`?`}`);let r=a(e.field),i=a(e.field);return v[`${c?s:``}${r}`]=t,v[`${c?s:``}${i}`]=n,y(`${E}${e.field}${D} ${w} ${s}${r} and ${s}${i}`)}let O=e.value;typeof e.value==`string`&&(O=q(e.value,o)?U(e.value,{parseNumbers:o}):/^'.*'$/g.test(C)?C.replaceAll(/(^'|'$)/g,``):C);let k=``;return g?_.push(O):(k=a(e.field),v[`${c?s:``}${k}`]=O),y(`${E}${e.field}${D} ${w} ${g?l?`${s}${h.length+1}`:`?`:`${s}${k}`}`.trim())},br=(e,t,n)=>q(e,!!n||typeof e==`bigint`)?Number(U(e,{parseNumbers:!!n})):t,xr=(e,t={})=>{let{field:n,operator:r,value:i,valueSource:a}=e,{parseNumbers:o,preserveValueOrder:s}=t;if(a===`field`||J(e))return;let c=M(r);switch(c){case`=`:return{[n]:br(i,i,o)};case`!=`:case`<`:case`<=`:case`>`:case`>=`:{let e=kt[c];return{[n]:{[e]:br(i,i,o)}}}case`contains`:return{[n]:{contains:i}};case`beginswith`:return{[n]:{startsWith:i}};case`endswith`:return{[n]:{endsWith:i}};case`doesnotcontain`:return{NOT:{[n]:{contains:i}}};case`doesnotbeginwith`:return{NOT:{[n]:{startsWith:i}}};case`doesnotendwith`:return{NOT:{[n]:{endsWith:i}}};case`null`:return{[n]:null};case`notnull`:return{[n]:{not:null}};case`in`:case`notin`:{let e=j(i);return{[n]:{[kt[c]]:e.map(e=>br(e,e,o))}}}case`between`:case`notbetween`:{let e=j(i);if(e.length>=2&&K(e[0])&&K(e[1])){let[t,r]=e,i=o!==!1,a=q(t,i)?U(t,{parseNumbers:o}):NaN,l=q(r,i)?U(r,{parseNumbers:o}):NaN,u=Number.isNaN(a)?t:a,d=Number.isNaN(l)?r:l;if(!s&&u===a&&d===l&&l<a){let e=l;d=a,u=e}return c===`between`?{[n]:{gte:u,lte:d}}:{OR:[{[n]:{lt:u}},{[n]:{gt:d}}]}}return``}}return``},Sr=(e,{parseNumbers:t,preserveValueOrder:n,context:r={}}={})=>{let{sequelizeOperators:i,sequelizeCol:a,sequelizeFn:o}=r;if(J(e))return;let{field:s,operator:c,value:l,valueSource:u}=e,d=u===`field`,f=M(c);if(!(!i||d&&(!a||!o&&[`contains`,`doesnotcontain`,`beginswith`,`doesnotbeginwith`,`endswith`,`doesnotendwith`].includes(f))))switch(f){case`=`:case`!=`:case`<`:case`<=`:case`>`:case`>=`:{let e={"=":i.eq,"!=":i.ne,"<":i.lt,"<=":i.lte,">":i.gt,">=":i.gte}[f];return{[s]:d&&f===`=`?{[i.col]:l}:{[e]:d?a(l):q(l,t)?U(l,{parseNumbers:`strict`}):l}}}case`contains`:return{[s]:{[d?i.like:i.substring]:d?o(`CONCAT`,`%`,a(l),`%`):`${l}`}};case`beginswith`:return{[s]:{[d?i.like:i.startsWith]:d?o(`CONCAT`,a(l),`%`):`${l}`}};case`endswith`:return{[s]:{[d?i.like:i.endsWith]:d?o(`CONCAT`,`%`,a(l)):`${l}`}};case`doesnotcontain`:return{[s]:{[i.notLike]:d?o(`CONCAT`,`%`,a(l),`%`):`%${l}%`}};case`doesnotbeginwith`:return{[s]:{[i.notLike]:d?o(`CONCAT`,a(l),`%`):`${l}%`}};case`doesnotendwith`:return{[s]:{[i.notLike]:d?o(`CONCAT`,`%`,a(l)):`%${l}`}};case`null`:return{[s]:{[i.is]:null}};case`notnull`:return{[s]:{[i.not]:null}};case`in`:case`notin`:{let e=j(l);return{[s]:{[f===`in`?i.in:i.notIn]:e.map(e=>d?a(e):q(e,t)?U(e,{parseNumbers:`strict`}):e)}}}case`between`:case`notbetween`:{let e=j(l,{retainEmptyStrings:!0});if(e.length<2||!K(e[0])||!K(e[1]))return;let[r,o]=e,c=q(r,t)?U(r,{parseNumbers:`strict`}):NaN,u=q(o,t)?U(o,{parseNumbers:`strict`}):NaN,p=Number.isNaN(c)?r:c,m=Number.isNaN(u)?o:u,h=[p,m];return!n&&p===c&&m===u&&u<c&&(h[0]=u,h[1]=c),{[s]:{[f===`between`?i.between:i.notBetween]:d?h.map(e=>a(e)):h.every(e=>q(e,t))?h.map(e=>U(e,{parseNumbers:`strict`})):h}}}}},Cr=(e,t)=>typeof e!=`string`||!t?`${e}`:e.replaceAll(`"`,`\\"`),wr=e=>/^[?<]/.test(e)||e.includes(`:`)?e:`?${e}`,Tr=(e,t={})=>{let{escapeQuotes:n,parseNumbers:r}=t,{field:i,operator:a,value:o,valueSource:s}=e,c=s===`field`,l=a.toLowerCase(),u=wr(i),d=e=>{if(e==null)return`""`;if(typeof e==`boolean`)return`"${e}"^^xsd:boolean`;if(typeof e==`bigint`)return String(e);if(c)return wr(A(e));if(typeof e==`number`||q(e,r))return A(e);let t=typeof e==`string`?e:JSON.stringify(e)??``;return t.startsWith(`?`)||t.startsWith(`<`)||t.includes(`:`)?t:`"${Cr(t,n)}"`};switch(l){case`=`:case`!=`:case`<`:case`>`:case`<=`:case`>=`:return`${u} ${l} ${d(o)}`;case`<>`:return`${u} != ${d(o)}`;case`contains`:return`CONTAINS(${u}, ${d(o)})`;case`doesnotcontain`:return`!CONTAINS(${u}, ${d(o)})`;case`beginswith`:return`STRSTARTS(${u}, ${d(o)})`;case`doesnotbeginwith`:return`!STRSTARTS(${u}, ${d(o)})`;case`endswith`:return`STRENDS(${u}, ${d(o)})`;case`doesnotendwith`:return`!STRENDS(${u}, ${d(o)})`;case`null`:return`!BOUND(${u})`;case`notnull`:return`BOUND(${u})`;case`in`:{let e=j(o).map(d);return e.length?`${u} IN (${e.join(`, `)})`:``}case`notin`:{let e=j(o).map(d);return e.length?`${u} NOT IN (${e.join(`, `)})`:``}case`between`:{let e=j(o);return e.length<2?``:`${u} >= ${d(e[0])} && ${u} <= ${d(e[1])}`}case`notbetween`:{let e=j(o);return e.length<2?``:`(${u} < ${d(e[0])} || ${u} > ${d(e[1])})`}default:return`${u} ${a} ${d(o)}`}},Er=(e,t)=>{let{parseNumbers:n,preserveValueOrder:r,context:i={}}=t??{},a=i.tanStackDbOperators,o=i._tanstackDbRefs,s=i._tanstackDbPrimaryRef;if(!a||!o||!s)return;let{and:c,eq:l,gt:u,gte:d,inArray:f,isNull:p,like:m,lt:h,lte:g,not:_}=a,v=e=>{let t=e.indexOf(`.`);if(t>0){let n=e.slice(0,t),r=e.slice(t+1);if(o[n])return o[n][r]}return o[s][e]},{field:y,operator:b,value:x,valueSource:S}=e,C=v(y),w=M(b),T=S===`field`,E=e=>T?v(e):e,D=e=>T||!n?E(e):q(e,!0)?U(e,{parseNumbers:!0}):e;switch(w){case`=`:return l(C,D(x));case`!=`:return _(l(C,D(x)));case`>`:return u(C,D(x));case`<`:return h(C,D(x));case`>=`:return d(C,D(x));case`<=`:return g(C,D(x));case`beginswith`:case`doesnotbeginwith`:{let e=m(C,T?void 0:`${x}%`);return w===`doesnotbeginwith`?_(e):e}case`contains`:case`doesnotcontain`:{let e=m(C,T?void 0:`%${x}%`);return w===`doesnotcontain`?_(e):e}case`endswith`:case`doesnotendwith`:{let e=m(C,T?void 0:`%${x}`);return w===`doesnotendwith`?_(e):e}case`null`:return p(C);case`notnull`:return _(p(C));case`in`:case`notin`:{let e=f(C,j(x).map(e=>D(e)));return w===`notin`?_(e):e}case`between`:case`notbetween`:{let e=j(x);if(e.length>=2&&K(e[0])&&K(e[1])){let[t,i]=e,a=n!==!1;if(!T&&q(t,a)&&q(i,a)){let e=U(t,{parseNumbers:a}),n=U(i,{parseNumbers:a});if(!r&&n<e){let r=n;i=e,t=r}else t=e,i=n}else T&&(t=E(t),i=E(i));let o=c(d(C,t),g(C,i));return w===`notbetween`?_(o):o}return}default:return}},Dr={ansi:{},sqlite:{paramsKeepPrefix:!0},oracle:{},mssql:{concatOperator:`+`,quoteFieldNamesWith:[`[`,`]`],fieldIdentifierSeparator:`.`,paramPrefix:`@`},mysql:{concatOperator:`CONCAT`},postgresql:{quoteFieldNamesWith:`"`,numberedParams:!0,paramPrefix:`$`}},Or={...Dr},kr={cel:Xt,drizzle:Wn,elasticsearch:Zn,json_without_ids:vr,json:vr,jsonata:ir,jsonlogic:sr,ldap:ur,mongodb_query:en,mongodb:tn,natural_language:gr,parameterized_named:yr,parameterized:yr,prisma:xr,sequelize:Sr,spel:sn,sql:vr,tanstack_db:Er,cypher:Un,gql:Un,sparql:Tr,gremlin:$n,diagnostics:vr},Y=e=>e.operator,Ar={cel:Y,drizzle:Y,elasticsearch:Y,json_without_ids:Y,json:Y,jsonata:Y,jsonlogic:Y,ldap:Y,mongodb_query:Y,mongodb:Y,natural_language:hr,parameterized_named:_r,parameterized:_r,prisma:Y,sequelize:Y,spel:Y,sql:_r,tanstack_db:Y,cypher:Y,gql:Y,sparql:Y,gremlin:Y,diagnostics:Y},jr={cel:`1 == 1`,ldap:``,mongodb:`"$and":[{"$expr":true}]`,natural_language:`1 is 1`,sparql:`1 = 1`,gremlin:``,spel:`1 == 1`,sql:`(1 = 1)`},Mr={format:`json`,fields:[],quoteFieldNamesWith:[``,``],fieldIdentifierSeparator:``,getOperators:()=>[],paramPrefix:`:`,paramsKeepPrefix:!1,numberedParams:!1,preserveValueOrder:!1,placeholderFieldName:`~`,placeholderOperatorName:`~`,quoteValuesWith:`'`,concatOperator:`||`,preset:`ansi`,wordOrder:`SVO`,translations:{},operatorMap:{}},Nr=new Set([`cel`,`drizzle`,`elasticsearch`,`jsonata`,`jsonlogic`,`ldap`,`mongodb_query`,`mongodb`,`prisma`,`sequelize`,`spel`,`tanstack_db`]),Pr=new Set([`sql`,`parameterized`,`parameterized_named`,`drizzle`,`prisma`,`sequelize`]);function Fr(e,t={}){let n=typeof t==`string`?{format:M(t)}:t,r={...Mr,...!n.format||Pr.has(n.format)?Dr[n.preset??`ansi`]??null:null,...n,...!n.format&&(Object.keys(Dr).includes(n.preset??``)?{format:`sql`}:null)},i=M(r.format),{fallbackExpression:a,getOperators:o,operatorProcessor:s,parseNumbers:c,quoteFieldNamesWith:l,ruleGroupProcessor:u,ruleProcessor:d,validator:f,valueProcessor:p,context:m}=r,h=e=>typeof Ct({parseNumbers:c,inputType:e})==`string`?!0:typeof c==`boolean`?c:void 0,g=typeof s==`function`?s:Ar[i]??Y,_=typeof p==`function`?Nt(p)?e=>p(e.field,e.operator,e.value,e.valueSource):p:i===`natural_language`?fr:Nr.has(i)?d??kr[i]:ln,v=(typeof d==`function`?d:null)??(Nr.has(i)&&typeof d!=`function`&&p?_:null)??kr[i]??vr,y=Pt(l),b=z(r.fields),x=(e,t)=>z(o(e,t)??[]),S=a??jr[i]??jr.sql,C={};if(typeof f==`function`){let t=f(e);if(typeof t==`boolean`){if(!t&&i!==`diagnostics`)return i===`parameterized`?{sql:S,params:[]}:i===`parameterized_named`?{sql:S,params:{}}:i===`mongodb`?`{${S}}`:i===`mongodb_query`?Zt:i===`prisma`?Sn:i===`jsonlogic`?!1:i===`elasticsearch`?{}:i===`drizzle`||i===`sequelize`||i===`tanstack_db`?void 0:S}else C=t}let w={},T=Xe(b);for(let e of T)typeof e.validator==`function`&&(w[e.value??e.name]=e.validator);let E=e=>{let t,n;if(e.id&&(t=C[e.id]),T.length>0){let t=T.filter(t=>t.name===e.field);if(t.length>0){let e=t[0];typeof e.validator==`function`&&(n=e.validator)}}if(e.valueSource===`parameter`&&typeof r.getParameters==`function`){let n=V(b,e.field);new Set(Xe(z(r.getParameters(e.field,e.operator,{fieldData:n}))).map(e=>zt(e.value,r.paramPrefix))).has(zt(e.value,r.paramPrefix))||(t=!1)}return[t,n]},D={...r,fallbackExpression:S,fields:b,format:i,getOperators:x,getParseNumberBoolean:h,quoteFieldNamesWith:y,operatorProcessor:g,ruleProcessor:v,valueProcessor:_,validateRule:E,validationMap:C,context:m};if(typeof u==`function`)return u(e,D);switch(i){case`json`:case`json_without_ids`:{let t=c?Mt(e,D):e;return i===`json_without_ids`?JSON.stringify(t,(e,t)=>e===`id`||e===`path`?void 0:Gt(e,t)):JSON.stringify(t,Gt,2)}case`sql`:return En(e,D);case`parameterized`:case`parameterized_named`:return xn(e,D);case`mongodb`:return yn(e,D);case`mongodb_query`:return Qt(e,D);case`cel`:return qt(e,D);case`spel`:return nn(e,D);case`jsonata`:return hn(e,D);case`jsonlogic`:return gn(e,D);case`elasticsearch`:return pn(e,D);case`natural_language`:return bn(e,D);case`ldap`:return _n(e,D);case`prisma`:return Cn(e,D);case`drizzle`:return fn(e,D);case`tanstack_db`:return Dn(e,D);case`sequelize`:return wn(e,D);case`cypher`:case`gql`:return dn(e,D);case`sparql`:return Tn(e,D);case`gremlin`:return mn(e,D);case`diagnostics`:return Rn(e,D);default:return``}}const Ir=e=>(t,n,r,i)=>e({field:t,operator:n,value:r,valueSource:i},{parseNumbers:!1}),Lr=Ir(ln),Rr=Ir(tn),zr=Ir(Xt),Br=Ir(sn),Vr=Xt,Hr=tn,Ur=sn,X=(e,t)=>{let n=t,r=0;for(;r<e.length&&n&&P(n);){let t=n.rules[e[r]];n=typeof t==`string`?null:t,r++}return r<e.length?null:n},Wr=(e,t)=>{if(t.id===e)return t;for(let n of t.rules)if(typeof n!=`string`){if(n.id===e)return n;if(P(n)){let t=Wr(e,n);if(t)return t}}return null},Gr=(e,t)=>{if(t.id===e)return[];let n=t.rules.findIndex(t=>typeof t!=`string`&&t.id===e);if(n>=0)return[n];for(let[n,r]of Object.entries(t.rules))if(P(r)){let t=Gr(e,r);if(Array.isArray(t))return[Number.parseInt(n),...t]}return null},Z=e=>e.slice(0,-1),Kr=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0},qr=(e,t)=>{if(e.length>=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0},Jr=(e,t)=>{let n=[],r=Z(e),i=Z(t),a=0;for(;a<r.length&&a<i.length&&r[a]===i[a];)n.push(i[a]),a++;return n},Yr=(e,t)=>{let n=!!t.disabled,r=t,i=0;for(;i<e.length&&!n&&P(r);){let t=r.rules[e[i]];N(t)&&(P(t)||`field`in t&&t.field)&&(n=!!t.disabled,r=t),i++}return n},Xr=(e,t=[])=>t.some(t=>Kr(t,e)||qr(t,e)),Zr=(e,t,{disabled:n=!1,disabledPaths:r=[]}={})=>{let i=[];for(let a=0;a<t;a++){let t=[...e,a];i[a]={path:t,disabled:n||r.some(e=>Kr(t,e))}}return i},Qr=e=>Kr([],e.path)?`Query builder`:`Rule group at path ${e.path.join(`-`)}`,$r=globalThis.crypto,ei=/^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i;let Q=()=>`00-0-4-2-000`.replaceAll(/[^-]/g,e=>((Math.random()+Math.trunc(e))*65536>>Number.parseInt(e)).toString(16).padStart(4,`0`));if($r){if(typeof $r.randomUUID==`function`)Q=()=>$r.randomUUID();else if(typeof $r.getRandomValues==`function`){let e=new Uint32Array(32);Q=()=>{$r.getRandomValues(e);let t=(e[0]%16).toString(16);for(let n=1;n<32;n++)t=n===12?`${t}4`:n===16?`${t}${`89ab`[e[17]%4]}`:`${t}${(e[n]%16).toString(16)}`,(n===7||n===11||n===15||n===19)&&(t=`${t}-`);return t}}}const ti=t.setAutoFreeze,ni=new t.Immer({autoFreeze:!1}),ri=(e=!0)=>e?t.produce:ni.produce,ii={name:`name`,value:`name`,matchModes:null,label:`label`},ai=(e,t)=>{let n=e?R(e):ii,r=n.matchModes??!1;return!r&&t&&(r=t(n.value,{fieldData:n})),r===!0?w:r===!1?[]:qe(r)?z(r):r?.map(e=>w.find(t=>t.value===M(e))??{name:e,value:e,label:e})??[]},oi=(e,t,n)=>{let r=H(e);if(t.operator===`between`||t.operator===`notBetween`){let e=[r,r];return n?e:ae(e.map(e=>e??``),`,`)}return r},si=(e,t)=>{let{fieldData:n,fields:r,getValueEditorType:i,getValues:a,getDefaultValue:o,getParameters:s,listsAsArrays:c}=t;if(n?.defaultValue!==void 0&&n.defaultValue!==null)return n.defaultValue;if(o)return o(e,{fieldData:n});let l=``,u=a(e.field,e.operator,{fieldData:n});if(e.valueSource===`field`){let t=tt(n,r,e.operator);l=t.length>0?oi(t,e,c):``}else if(e.valueSource===`parameter`){let t=s?s(e.field,e.operator,{fieldData:n}):null;l=t&&t.length>0?H(t):``}else if(u.length>0){let t=i(e.field,e.operator,{fieldData:n});t===`multiselect`?l=c?[]:``:(t===`select`||t===`radio`)&&(l=oi(u,e,c))}else i(e.field,e.operator,{fieldData:n})===`checkbox`&&(l=!1);return l},ci=e=>{let t=typeof e==`boolean`?e:typeof e==`object`&&e?e.valid:null;return typeof t==`boolean`?t?T.valid:T.invalid:``},li=[{name:`value`,value:`value`,label:`value`}],ui={name:`name`,value:`name`,valueSources:null,label:`label`},di=(e,t,n)=>{let r=e?R(e):ui,i=r.valueSources??!1;return typeof i==`function`&&(i=i(t)),!i&&n&&(i=n(r.value,t,{fieldData:r})),i?qe(i)?z(i):i.map(e=>li.find(t=>t.value===M(e))??{name:e,value:e,label:e}):li},fi=(e,...t)=>{let n={...e};for(let e of t)if(e)for(let t of Re(e))Be(t)||(n[t]=n[t]?{...n[t],...e[t]}:{...e[t]});return n},pi=(e,t,n)=>{if(Be(e))return;let r=ze(t).map(([t,[r,i]])=>[t,r??i??n?.[e]?.[t]]).filter(e=>!Be(e[0])&&!!e[1]);if(r.length>0||n){let t=n?.[e]??{},i=Object.assign({},t,Object.fromEntries(r));return{[e]:i}}},$=(e,t)=>{let n=``;for(let r=0;r<t.length;r++){let i=t[r]?.[e];if(!i)continue;let a=typeof i==`string`?i:ce(i);a&&(n=n?`${n} ${a}`:a)}return n},mi=(...e)=>({queryBuilder:$(`queryBuilder`,e),ruleGroup:$(`ruleGroup`,e),header:$(`header`,e),body:$(`body`,e),combinators:$(`combinators`,e),addRule:$(`addRule`,e),addGroup:$(`addGroup`,e),cloneRule:$(`cloneRule`,e),cloneGroup:$(`cloneGroup`,e),ungroup:$(`ungroup`,e),removeGroup:$(`removeGroup`,e),rule:$(`rule`,e),fields:$(`fields`,e),operators:$(`operators`,e),value:$(`value`,e),removeRule:$(`removeRule`,e),notToggle:$(`notToggle`,e),shiftActions:$(`shiftActions`,e),undoRedoActions:$(`undoRedoActions`,e),undoAction:$(`undoAction`,e),redoAction:$(`redoAction`,e),dragHandle:$(`dragHandle`,e),lockRule:$(`lockRule`,e),lockGroup:$(`lockGroup`,e),muteRule:$(`muteRule`,e),muteGroup:$(`muteGroup`,e),muted:$(`muted`,e),valueSource:$(`valueSource`,e),actionElement:$(`actionElement`,e),valueSelector:$(`valueSelector`,e),betweenRules:$(`betweenRules`,e),valid:$(`valid`,e),invalid:$(`invalid`,e),dndDragging:$(`dndDragging`,e),dndOver:$(`dndOver`,e),dndCopy:$(`dndCopy`,e),dndGroup:$(`dndGroup`,e),dndDropNotAllowed:$(`dndDropNotAllowed`,e),dndPreviewPosition:$(`dndPreviewPosition`,e),dndHidden:$(`dndHidden`,e),disabled:$(`disabled`,e),valueListItem:$(`valueListItem`,e),matchMode:$(`matchMode`,e),matchThreshold:$(`matchThreshold`,e),branches:$(`branches`,e),hasSubQuery:$(`hasSubQuery`,e),loading:$(`loading`,e),valueDateTimeRelative:$(`valueDateTimeRelative`,e)}),hi=({field:e,fieldData:t,getOperators:n,operators:r,placeholder:i,baseOption:a,autoSelectOption:o})=>$e({optionList:t?.operators??n?.(e,{fieldData:t})??r,placeholder:i,baseOption:a,labelMap:p,autoSelectOption:o}).optionList,gi=({field:e,fieldData:t,getDefaultOperator:n,getOperators:r})=>t?.defaultOperator?t.defaultOperator:n?typeof n==`function`?n(e,{fieldData:t}):n:H(r(e,{fieldData:t}))??``,_i=({field:e,operator:t,fieldData:n,getValueEditorType:r})=>n?.valueEditorType?typeof n.valueEditorType==`function`?n.valueEditorType(t):n.valueEditorType:r?.(e,t,{fieldData:n})??`text`,vi=({field:e,operator:t,fieldData:n,getValues:r,placeholder:i,baseOption:a,autoSelectOption:o})=>$e({optionList:n?.values??r?.(e,t,{fieldData:n})??[],placeholder:i,baseOption:a,autoSelectOption:o}).optionList,yi=e=>{let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype},bi=(e,t)=>{if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((e,n)=>bi(e,t[n]));if(typeof e!=`object`||typeof t!=`object`||e===null||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)||!yi(e))return!1;let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>bi(e[n],t[n]))},xi=(e,t)=>bi(e,t),Si=(e,t)=>e===!1?!1:e?!0:t!==!1,Ci=(e,t)=>e?!0:e!==!1&&!!t,wi=(e,t,n,r)=>r?t??n:e?Si(t,n):Ci(t,n),Ti=(e,t,n)=>t!==void 0&&t!=null?t:n!==void 0&&n!=null?n:e,Ei=(e={},t={},n)=>ze(te).reduce((r,[i,a])=>(r[i]=wi(a,e[i],t[i],!n),r),{}),Di=(e,{idGenerator:t=Q}={})=>{let n=!e.id,r=J(e);return!n&&!r?e:{...e,...n&&{id:t()},...r&&{value:Oi(e.value,{idGenerator:t})}}},Oi=(e,{idGenerator:t=Q}={})=>{let n=!e.id,r=!1,i=[];for(let n=0;n<e.rules.length;n++){let a=e.rules[n];if(typeof a==`string`)i.push(a);else{let e=P(a)?Oi(a,{idGenerator:t}):Di(a,{idGenerator:t});i.push(e),e!==a&&(r=!0)}}return!n&&!r?e:{...e,...n&&{id:t()},rules:i}},ki=(e,{idGenerator:t=Q}={})=>P(e)?Oi(e,{idGenerator:t}):Di(e,{idGenerator:t}),Ai=(e,t)=>{let n=e.query??e.storeQuery??e.defaultQuery??e.fallbackQuery;return n.id?n:Oi(n,t)},ji=(e,{idGenerator:t=Q}={})=>structuredClone({...e,id:t()}),Mi=(e,{idGenerator:t=Q}={})=>{if(!N(e))return e;if(!P(e))return structuredClone({...e,id:t()});let n={...e,id:t()};return Array.isArray(n.rules)&&(n.rules=e.rules.map(e=>typeof e==`string`?e:P(e)?Mi(e,{idGenerator:t}):ji(e,{idGenerator:t}))),n},Ni=(e,t,n={},{asParent:r=!1}={})=>{if(n.queryDisabled)return r?`parent-disabled`:`target-disabled`;if(!n.respectDisabled||t===void 0)return null;let i=Array.isArray(t)?t:Gr(t,e);return i&&(Yr(i,e)||Xr(i,n.disabledPaths))?r?`parent-disabled`:`target-disabled`:null},Pi=(e,{maxLevels:t=1/0}={})=>!!e&&e.length>=t,Fi=(e,t,n,r={})=>ri(r.freeze)(e,e=>Ii(e,t,n,r)),Ii=(e,t,n,r={})=>{let{combinators:i=S,combinatorPreceding:a,idGenerator:o=Q,onAbort:s}=r,c=Array.isArray(n)?X(n,e):Wr(n,e);if(!c)return s?.({reason:`parent-not-found`,operation:`add`,pathOrID:n}),e;if(!P(c))return s?.({reason:`parent-not-a-group`,operation:`add`,pathOrID:n}),e;let l=Array.isArray(n)?n:Gr(n,e),u=Ni(e,l,r,{asParent:!0});if(u)return s?.({reason:u,operation:`add`,pathOrID:n}),e;if(P(t)&&Pi(l,r))return s?.({reason:`max-levels-exceeded`,operation:`add`,pathOrID:n}),e;if(I(c)&&c.rules.length>0){let e=c.rules.at(-2);c.rules.push(a??(typeof e==`string`?e:H(i)))}return c.rules.push(ki(t,{idGenerator:o})),e},Li={field:0,operator:1,valueSource:2,value:4},Ri=e=>e.toSorted((e,t)=>(Li[e[0]]??3)-(Li[t[0]]??3)),zi=(e,t,n,r)=>{if(typeof e==`string`)return{entries:[[e,t]],pathOrID:n,options:r??{}};if(Array.isArray(e)){let i=t;return{entries:Ri(e.map((e,t)=>[e,i[t]])),pathOrID:n,options:r??{}}}return{entries:Ri(Object.entries(e)),pathOrID:t,options:n??{}}},Bi=(e,t,n,r)=>(typeof e==`string`||Array.isArray(e)?r:n)??{},Vi=(e,t,n,r,i)=>{let{entries:a,pathOrID:o,options:s}=zi(t,n,r,i);for(let[t,n]of a)Wi(e,t,n,o,s);return e},Hi=((e,t,n,r,i)=>ri(Bi(t,n,r,i).freeze)(e,e=>{Vi(e,t,n,r,i)})),Ui=((e,t,n,r,i)=>Vi(e,t,n,r,i)),Wi=(e,t,n,r,i={})=>{let{resetOnFieldChange:a=!0,resetOnOperatorChange:o=!1,getRuleDefaultOperator:s=()=>`=`,getValueSources:c=()=>[`value`],getRuleDefaultValue:l=()=>``,getMatchModes:u=()=>[],onAbort:d}=i,f=a,p=Array.isArray(r)?r:Gr(r,e);if(!p)return d?.({reason:`target-not-found`,operation:`update`,pathOrID:r}),e;let m=t===`disabled`?{queryDisabled:i.queryDisabled}:i,h=Ni(e,p,m);if(h)return d?.({reason:h,operation:`update`,pathOrID:r}),e;if(t===`combinator`&&!F(e)){let t=X(Z(p),e);if(!t||!P(t))return d?.({reason:`target-not-found`,operation:`update`,pathOrID:r}),e;let i=t.rules;return p.at(-1)%2==1?i[p.at(-1)]===n?d?.({reason:`no-change`,operation:`update`,pathOrID:r}):i[p.at(-1)]=n:d?.({reason:`not-a-combinator-slot`,operation:`update`,pathOrID:r}),e}let g=X(p,e);if(!g)return d?.({reason:`target-not-found`,operation:`update`,pathOrID:r}),e;let _=P(g);if(g[t]===n)return d?.({reason:`no-change`,operation:`update`,pathOrID:r}),e;if(t!==`valueSource`&&(g[t]=n),_)return e;let v=!1,y=!1;if(t===`field`){let e=u(g.field),t=u(n);if(t.length===0)delete g.match;else{let e=g.match?.mode&&V(t,g.match.mode)?null:H(t);e&&(g.match={mode:e,threshold:1})}(e.length>0||t.length>0)&&(f=!0)}f&&t===`field`&&(g.operator=s(n),v=!0,y=!0),o&&t===`operator`&&(v=!0,y=!0);let b=H(di({name:g.field,value:g.field,label:``},g.operator,c));return(v&&g.valueSource&&b!==g.valueSource||t===`valueSource`&&n!==g.valueSource)&&(y=!!g.valueSource||!g.valueSource&&n!==b,g.valueSource=v?b:n),y&&(g.value=l(g)),e},Gi=(e,t,n={})=>ri(n.freeze)(e,e=>Ki(e,t,n)),Ki=(e,t,n={})=>{let{onAbort:r}=n,i=Array.isArray(t)?t:Gr(t,e);if(!i)return r?.({reason:`target-not-found`,operation:`remove`,pathOrID:t}),e;if(i.length===0)return r?.({reason:`root-not-allowed`,operation:`remove`,pathOrID:t}),e;let a=Ni(e,i,n);if(a)return r?.({reason:a,operation:`remove`,pathOrID:t}),e;if(!X(i,e))return r?.({reason:`target-not-found`,operation:`remove`,pathOrID:t}),e;let o=i.at(-1),s=X(Z(i),e);if(!F(s)&&s.rules.length>1){let e=o===0?0:o-1;s.rules.splice(e,2)}else s.rules.splice(o,1);return e},qi=(e,t,n={})=>ri(n.freeze)(e,e=>Ji(e,t,n)),Ji=(e,t,n={})=>{let{onAbort:r}=n,i=Array.isArray(t)?t:Gr(t,e);if(!i)return r?.({reason:`target-not-found`,operation:`ungroup`,pathOrID:t}),e;if(i.length===0)return r?.({reason:`root-not-allowed`,operation:`ungroup`,pathOrID:t}),e;let a=Ni(e,i,n);if(a)return r?.({reason:a,operation:`ungroup`,pathOrID:t}),e;let o=X(i,e);if(!o)return r?.({reason:`target-not-found`,operation:`ungroup`,pathOrID:t}),e;if(!P(o))return r?.({reason:`target-not-a-group`,operation:`ungroup`,pathOrID:t}),e;let s=i.at(-1),c=X(Z(i),e);if(o.rules.length===0){if(!F(c)&&c.rules.length>1){let e=s===0?0:s-1;c.rules.splice(e,2)}else c.rules.splice(s,1);return e}return c.rules.splice(s,1,...o.rules),e},Yi=(e,t,n)=>{if(Array.isArray(n))return n;let r=I(e);if(n===`up`){if(Kr(t,[0]))return t;if(t.at(-1)===0){let e=Z(t);return[...Z(e),Math.max(0,e.at(-1)-+!!r)]}{let n=[...Z(t),Math.max(0,t.at(-1)-(r?2:1))],i=X(n,e);return P(i)?[...n,i.rules.length]:[...Z(t),Math.max(0,t.at(-1)-(r?3:1))]}}if(n===`down`){if(Kr([e.rules.length-1],t))return t;if(t.at(-1)===X(Z(t),e).rules.length-1){let e=Z(t);return[...Z(e),e.at(-1)+1]}{let n=[...Z(t),t.at(-1)+(r?2:1)],i=X(n,e);return P(i)?[...n,0]:[...Z(t),t.at(-1)+(r?3:2)]}}return t},Xi=(e,t,n,r={})=>ri(r.freeze)(e,e=>Zi(e,t,n,r)),Zi=(e,n,r,i={})=>{let{clone:a=!1,combinators:o=S,idGenerator:s=Q,onAbort:c}=i,l=Array.isArray(n)?n:Gr(n,e);if(!l)return c?.({reason:`target-not-found`,operation:`move`,pathOrID:n}),e;let u=X(l,e);if(!u)return c?.({reason:`target-not-found`,operation:`move`,pathOrID:n}),e;let d=Yi(e,l,r);if(l.length===0)return c?.({reason:`root-not-allowed`,operation:`move`,pathOrID:n}),e;let f=Ni(e,l,i);if(f)return c?.({reason:f,operation:`move`,pathOrID:n}),e;if(Kr(l,d))return c?.({reason:`same-location`,operation:`move`,pathOrID:n}),e;if(!X(Z(d),e)||!a&&qr(l,d))return c?.({reason:`destination-not-found`,operation:`move`,pathOrID:r}),e;let p=a?Mi((0,t.isDraft)(u)?(0,t.current)(u):u,{idGenerator:s}):u,m=I(e),h=X(Z(l),e),g=l.at(-1),_=m&&g>0?h.rules[g-1]:null,v=m&&g<h.rules.length-1?h.rules[g+1]:null;if(!a){let e=m?Math.max(0,g-1):g,t=m?2:1;h.rules.splice(e,t)}let y=[...d];m&&y.at(-1)%2==1&&(y[y.length-1]+=1);let b=Jr(l,d);!a&&l.length===b.length+1&&y[b.length]>l[b.length]&&(y[b.length]-=m?2:1);let x=Z(y),C=X(x,e),w=y.at(-1),T=m&&w>0?w-1:w,E=(...e)=>C.rules.splice(T,0,...e);return C.rules.length===0||!m?E(p):w===0?g===0&&v?E(p,v):E(p,C.rules[1]??_??H(o)):E(_||(C.rules[T-2]??v??H(o)),p),e},Qi=(e,t,n,r={})=>ri(r.freeze)(e,e=>$i(e,t,n,r)),$i=(e,t,n,r={})=>{let{combinators:i=S,combinatorPreceding:a,combinatorSucceeding:o,idGenerator:s=Q,replace:c=!1,onAbort:l}=r,u=X(Z(n),e);if(!u)return l?.({reason:`parent-not-found`,operation:`insert`,pathOrID:n}),e;if(!P(u))return l?.({reason:`parent-not-a-group`,operation:`insert`,pathOrID:n}),e;let d=Z(n),f=Ni(e,d,r,{asParent:!0});if(f)return l?.({reason:f,operation:`insert`,pathOrID:n}),e;if(P(t)&&Pi(d,r))return l?.({reason:`max-levels-exceeded`,operation:`insert`,pathOrID:n}),e;let p=Mi(t,{idGenerator:s}),m=I(e),h=n.at(-1),g=(e,...t)=>u.rules.splice(e,c?t.length:0,...t);if(u.rules.length===0||!m)g(h,p);else if(c&&m)g(h+h%2,p);else if(h===0)p.path?.at(-1)===0&&o?g(h,p,o):g(h,p,u.rules[1]??a??H(i));else{let e=h%2==0?h-1:h;a?g(e,a,p):g(e,u.rules[e-2]??o??H(i),p)}return e},ea=(e,t,n,r={})=>ri(r.freeze)(e,e=>ta(e,t,n,r)),ta=(e,n,r,i={})=>{let{clone:a=!1,combinators:o=S,idGenerator:s=Q,onAbort:c}=i,l=Array.isArray(n)?n:Gr(n,e),u=Array.isArray(r)?r:Gr(r,e);if(!l)return c?.({reason:`target-not-found`,operation:`group`,pathOrID:n}),e;if(!u)return c?.({reason:`target-not-found`,operation:`group`,pathOrID:r}),e;let d=Yi(e,l,u);if(l.length===0)return c?.({reason:`root-not-allowed`,operation:`group`,pathOrID:n}),e;let f=Ni(e,l,i);if(f)return c?.({reason:f,operation:`group`,pathOrID:n}),e;if(Kr(l,d))return c?.({reason:`same-location`,operation:`group`,pathOrID:n}),e;if(!X(Z(d),e)||!a&&qr(l,d))return c?.({reason:`destination-not-found`,operation:`group`,pathOrID:r}),e;let p=X(l,e),m=X(u,e);if(!p)return c?.({reason:`target-not-found`,operation:`group`,pathOrID:n}),e;if(!m)return c?.({reason:`target-not-found`,operation:`group`,pathOrID:r}),e;let h=a?Mi((0,t.isDraft)(p)?(0,t.current)(p):p,{idGenerator:s}):p,g=I(e),_=X(Z(l),e),v=l.at(-1);if(!a){let e=g?Math.max(0,v-1):v,t=g?2:1;_.rules.splice(e,t)}let y=[...d],b=Jr(l,d);!a&&l.length===b.length+1&&d[b.length]>l[b.length]&&(y[b.length]-=g?2:1);let x=Z(y),C=X(x,e),w=y.at(-1);return C.rules.splice(w,1,ki(g?{rules:[m,H(o),h]}:{combinator:H(o),rules:[m,h]},{idGenerator:s})),e},na=(e={})=>{let{qbId:t,combinators:n,idGenerator:r,maxLevels:i=1/0,queryDisabled:a,respectDisabled:o=!0,disabledPaths:s,resetOnFieldChange:c,resetOnOperatorChange:l,getRuleDefaultOperator:u,getValueSources:d,getRuleDefaultValue:f,getMatchModes:p,freeze:m,onAddRule:h,onAddGroup:g,onRemove:_,onMoveRule:v,onMoveGroup:y,onGroupRule:b,onGroupGroup:x,onUngroup:S,onLog:C}=e,w=e=>C?.({qbId:t,...e}),T={respectDisabled:o,queryDisabled:a,disabledPaths:s},E=(e,t,n=!1)=>!!Ni(e,t,T,{asParent:n});return{addRule:(e,t,i,a)=>{if(E(e,i,!0)){w({type:k.parentPathDisabled,rule:t,parentPath:i,query:e});return}let o=!h||h(t,i,e,a);if(!o){w({type:k.onAddRuleFalse,rule:t,parentPath:i,query:e});return}let s=o===!0?t:o,c=Fi(e,s,i,{combinators:n,combinatorPreceding:s.combinatorPreceding,idGenerator:r,freeze:m});return w({type:k.add,query:e,newQuery:c,newRule:s,parentPath:i}),c},addGroup:(e,t,a,o)=>{if(a.length>=i)return;if(E(e,a,!0)){w({type:k.parentPathDisabled,ruleGroup:t,parentPath:a,query:e});return}let s=!g||g(t,a,e,o);if(!s){w({type:k.onAddGroupFalse,ruleGroup:t,parentPath:a,query:e});return}let c=s===!0?t:s,l=Fi(e,c,a,{combinators:n,combinatorPreceding:c.combinatorPreceding??void 0,idGenerator:r,freeze:m});return w({type:k.add,query:e,newQuery:l,newGroup:c,parentPath:a}),l},propChange:(e,t,n,r)=>{if(Ni(e,r,t===`disabled`?{queryDisabled:a}:T)){w({type:k.pathDisabled,path:r,prop:t,value:n,query:e});return}let i=Hi(e,t,n,r,{resetOnFieldChange:c,resetOnOperatorChange:l,getRuleDefaultOperator:u,getValueSources:d,getRuleDefaultValue:f,getMatchModes:p,freeze:m});return w({type:k.update,query:e,newQuery:i,prop:t,value:n,path:r}),i},removeRuleOrGroup:(e,t,n)=>{if(E(e,t)){w({type:k.pathDisabled,path:t,query:e});return}let r=X(t,e);if(!r)return;if(_&&!_(r,t,e,n)){w({type:k.onRemoveFalse,ruleOrGroup:r,path:t,query:e});return}let i=Gi(e,t,{freeze:m});return w({type:k.remove,query:e,newQuery:i,path:t,ruleOrGroup:r}),i},moveRule:(e,t,i,a,o)=>{if(E(e,t)){w({type:k.pathDisabled,oldPath:t,newPath:i,query:e});return}let s=X(t,e);if(!s)return;let c=Xi(e,t,i,{clone:a,combinators:n,idGenerator:r,freeze:m}),l=P(s),u=l?y:v,d=!u||u(s,t,i,e,c,{clone:a,combinators:n},o);if(!d){w({type:l?k.onMoveGroupFalse:k.onMoveRuleFalse,ruleOrGroup:s,oldPath:t,newPath:i,clone:a,query:e,nextQuery:c});return}let f=P(d)?d:c;return w({type:k.move,query:e,newQuery:f,oldPath:t,newPath:i,clone:a}),f},groupRule:(e,t,i,a,o)=>{if(E(e,t)){w({type:k.pathDisabled,sourcePath:t,targetPath:i,query:e});return}let s=X(t,e);if(!s)return;let c=ea(e,t,i,{clone:a,combinators:n,idGenerator:r,freeze:m}),l=P(s),u=l?x:b,d=!u||u(s,t,i,e,c,{clone:a,combinators:n},o);if(!d){w({type:l?k.onGroupGroupFalse:k.onGroupRuleFalse,ruleOrGroup:s,sourcePath:t,targetPath:i,clone:a,query:e,nextQuery:c});return}let f=P(d)?d:c;return w({type:k.group,query:e,newQuery:f,sourcePath:t,targetPath:i,clone:a}),f},ungroupRuleGroup:(e,t,n)=>{if(E(e,t)){w({type:k.pathDisabled,path:t,query:e});return}let r=X(t,e);if(t.length===0||!P(r))return;let i=qi(e,t,{freeze:m}),a=!S||S(r,t,e,i,n);if(!a){w({type:k.onUngroupFalse,ruleGroup:r,path:t,query:e,nextQuery:i});return}let o=P(a)?a:i;return w({type:k.ungroup,query:e,newQuery:o,path:t,ruleGroup:r}),o}}},ra=({fields:e,getDefaultField:t,getRuleDefaultOperator:n,getValueSources:r,getMatchModes:i,getRuleDefaultValue:a,idGenerator:o=Q})=>{let s=H(e)??``;if(t){if(typeof t==`function`){let n=t(e);n&&(s=n)}else s=t}let c=V(e,s),l=n(s),u=H(r(s,l,{fieldData:c}))??`value`,d=H(i(s,{fieldData:c})),f={id:o(),field:s,operator:l,valueSource:u,value:``,...d?{match:{mode:d,threshold:1}}:null};return{...f,value:a(f)}},ia=({combinators:e,addRuleToNewGroups:t,createRule:n,idGenerator:r=Q},i)=>{let a=r(),o=t?[n()]:[];return i?{id:a,rules:o,not:!1}:{id:a,rules:o,combinator:H(e)??``,not:!1}};var aa=class e extends Error{code;info;constructor(t){super(`QueryManager: "${t.operation}" aborted (${t.reason})${t.pathOrID===void 0?``:` for target ${JSON.stringify(t.pathOrID)}`}.`),this.name=`QueryManagerError`,this.code=t.reason,this.info=t,Object.setPrototypeOf(this,e.prototype)}};const oa=Symbol(`QueryManager.state`),sa=(0,t.freeze)({query:!0,config:!1}),ca=(0,t.freeze)({query:!1,config:!0}),la=(0,t.freeze)({query:!0,config:!0}),ua=()=>{let e={listeners:new Set,configVersion:0,past:[],future:[],lastAt:0,batchDepth:0,historyBypassed:!1,pendingConfigNotify:!1};return Object.defineProperty(e,"__v_skip",{value:!0,enumerable:!1}),e};var da=class e{get state(){return this[oa]}constructor(e,t={}){Object.defineProperty(this,oa,{value:ua(),enumerable:!1,writable:!1,configurable:!1}),this.applyOptions(t),this.state.query=this.freeze(e?Oi(e,{idGenerator:this.state.idGenerator}):this.createRuleGroup())}freeze(e){return this.state.freezeEnabled?(0,t.freeze)(e,!0):e}applyOptions(e){this.state.options=e,this.state.freezeEnabled=e.freeze??!0,this.state.idGenerator=e.idGenerator??Q,this.state.validator=e.validator??Le,this.state.strict=e.strict??!1,this.state.respectDisabled=e.respectDisabled??!0,this.state.onInvalidTarget=e.onInvalidTarget;let t=e.history??!1,n=typeof t==`object`?t:{};this.state.historyEnabled=t!==!1,this.state.maxHistory=n.maxHistory??50,this.state.coalesceMs=n.coalesceMs??500,this.state.now=e.now??Date.now;let{optionList:r,optionsMap:i}=$e({optionList:e.fields,baseOption:e.baseField,autoSelectOption:e.autoSelectField,placeholder:e.translations?.fields});this.state.fields=this.freeze(r),this.state.fieldMap=this.freeze(i),this.state.operators=$e({optionList:e.operators??h,baseOption:e.baseOperator,labelMap:p,autoSelectOption:e.autoSelectOperator,placeholder:e.translations?.operators}).optionList,this.state.combinators=this.freeze($e({optionList:e.combinators??S,baseOption:e.baseCombinator}).optionList)}fieldData(e){return this.state.fieldMap[e]??{}}operatorsFor(e){return hi({field:e,fieldData:this.fieldData(e),getOperators:this.state.options.getOperators,operators:this.state.operators,baseOption:this.state.options.baseOperator,autoSelectOption:this.state.options.autoSelectOperator,placeholder:this.state.options.translations?.operators})}defaultOperator(e){return gi({field:e,fieldData:this.fieldData(e),getDefaultOperator:this.state.options.getDefaultOperator,getOperators:e=>this.operatorsFor(e)})}valueSourcesFor(e,t){return di(this.fieldData(e),t,this.state.options.getValueSources)}matchModesFor(e){return ai(this.fieldData(e),this.state.options.getMatchModes)}valuesFor(e,t){return vi({field:e,operator:t,fieldData:this.fieldData(e),getValues:this.state.options.getValues,autoSelectOption:this.state.options.autoSelectValue,placeholder:this.state.options.translations?.values})}valueEditorTypeFor(e,t){return _i({field:e,operator:t,fieldData:this.fieldData(e),getValueEditorType:this.state.options.getValueEditorType})}defaultValue(e){let{getDefaultValue:t,getParameters:n,listsAsArrays:r}=this.state.options;return si(e,{fieldData:this.fieldData(e.field),fields:this.state.fields,listsAsArrays:r,getValueEditorType:(e,t)=>this.valueEditorTypeFor(e,t),getValues:(e,t)=>this.valuesFor(e,t),getDefaultValue:t&&((e,n)=>t(e,n)),getParameters:n&&((e,t,n)=>this.parametersFor(e,t,n))})}parametersFor(e,t,n){return $e({optionList:this.state.options.getParameters?.(e,t,n)??[],autoSelectOption:this.state.options.autoSelectValue}).optionList}guardOptions(){let{maxLevels:e}=this.state.options;return{freeze:this.state.freezeEnabled,maxLevels:(e??0)>0?Number(e):1/0,respectDisabled:this.state.respectDisabled,disabledPaths:this.state.options.disabledPaths,queryDisabled:this.state.options.queryDisabled}}toolOptions(){return{combinators:this.state.combinators,idGenerator:this.state.idGenerator,...this.guardOptions()}}onAbort({strict:e,onInvalidTarget:t}){let n=e??this.state.strict,r=t??this.state.onInvalidTarget;return e=>{if(r?.(e),n&&re.has(e.reason))throw new aa(e)}}updateOptions(){return{getRuleDefaultOperator:e=>this.defaultOperator(e),getRuleDefaultValue:e=>this.defaultValue(e),getValueSources:(e,t)=>this.valueSourcesFor(e,t),getMatchModes:e=>this.matchModesFor(e),resetOnFieldChange:this.state.options.resetOnFieldChange,resetOnOperatorChange:this.state.options.resetOnOperatorChange,...this.guardOptions()}}commit(e){let t=this.state.query;t!==e&&(this.state.query=e,!(this.state.batchDepth>0)&&(this.record(t,e),this.notify(sa)))}record(e,t){if(!this.state.historyEnabled)return;let n=he(e,t);if(n===``)return;let r=this.state.now();ge(this.state.lastSig,n,this.state.lastAt,r,this.state.coalesceMs)||(this.state.past.push(e),this.state.past.length>this.state.maxHistory&&this.state.past.shift(),this.state.future=[]),this.state.lastSig=n,this.state.lastAt=r}notify(e){for(let t of this.state.listeners)t(e)}markHistoryBypassed(){this.state.batchDepth>0&&(this.state.historyBypassed=!0)}ensureCache(){this.state.cacheFor!==this.state.query&&(this.state.cacheFor=this.state.query,this.state.idPathIndex=void 0,this.state.validation=void 0)}*walkFrom(e,t,n){if(yield{node:e,path:t,parent:n},!P(e))return;let r=e;for(let[e,n]of r.rules.entries())typeof n!=`string`&&(yield*this.walkFrom(n,[...t,e],r))}index(){if(this.ensureCache(),!this.state.idPathIndex){let e=new Map;for(let{node:t,path:n}of this.walkFrom(this.state.query,[],null))t.id!==void 0&&!e.has(t.id)&&e.set(t.id,n);this.state.idPathIndex=e}return this.state.idPathIndex}toPath(e){return typeof e==`string`?this.index().get(e)??null:e}getQuery=()=>this.state.query;setQuery(e){return this.commit(this.freeze(Oi(e,{idGenerator:this.state.idGenerator}))),this}createRule(){return ra({fields:this.state.fields,getDefaultField:this.state.options.getDefaultField,getRuleDefaultOperator:e=>this.defaultOperator(e),getValueSources:(e,t)=>this.valueSourcesFor(e,t),getMatchModes:e=>this.matchModesFor(e),getRuleDefaultValue:e=>this.defaultValue(e),idGenerator:this.state.idGenerator})}createRuleGroup(e){return ia({combinators:this.state.combinators,addRuleToNewGroups:this.state.options.addRuleToNewGroups,createRule:()=>this.createRule(),idGenerator:this.state.idGenerator},e)}add(e,t=[],n={}){let{strict:r,onInvalidTarget:i,...a}=n;return this.commit(Fi(this.state.query,e,t,{...this.toolOptions(),...a,onAbort:this.onAbort({strict:r,onInvalidTarget:i})})),this}remove(e,t={}){let{strict:n,onInvalidTarget:r,...i}=t;return this.commit(Gi(this.state.query,e,{...this.guardOptions(),...i,onAbort:this.onAbort({strict:n,onInvalidTarget:r})})),this}update(e,t,n,r){let i=typeof e==`string`||Array.isArray(e)?3:2,a=[e,t,n,r],{strict:o,onInvalidTarget:s,...c}=a[i]??{};return a[i]={...this.updateOptions(),...c,onAbort:this.onAbort({strict:o,onInvalidTarget:s})},this.commit(Hi(this.state.query,...a.slice(0,i+1))),this}move(e,t,n={}){let{strict:r,onInvalidTarget:i,...a}=n;return this.commit(Xi(this.state.query,e,t,{...this.toolOptions(),...a,onAbort:this.onAbort({strict:r,onInvalidTarget:i})})),this}insert(e,t,n={}){let{strict:r,onInvalidTarget:i,...a}=n;return this.commit(Qi(this.state.query,e,t,{...this.toolOptions(),...a,onAbort:this.onAbort({strict:r,onInvalidTarget:i})})),this}group(e,t,n={}){let{strict:r,onInvalidTarget:i,...a}=n;return this.commit(ea(this.state.query,e,t,{...this.toolOptions(),...a,onAbort:this.onAbort({strict:r,onInvalidTarget:i})})),this}ungroup(e,t={}){let{strict:n,onInvalidTarget:r,...i}=t;return this.commit(qi(this.state.query,e,{...this.toolOptions(),...i,onAbort:this.onAbort({strict:n,onInvalidTarget:r})})),this}getOptions(){return(0,t.freeze)({...this.state.options})}reconfigure(e,n){let r=n?.replace?{...e}:{...this.state.options,...e};return xi(this.state.options,r)?this:(this.applyOptions((0,t.freeze)(r)),this.state.validation=void 0,this.reconcileHistoryConfig(),++this.state.configVersion,this.state.batchDepth>0?this.state.pendingConfigNotify=!0:this.notify(ca),this)}reconcileHistoryConfig(){this.state.historyEnabled?this.state.past.length>this.state.maxHistory&&this.state.past.splice(0,this.state.past.length-this.state.maxHistory):(this.state.past=[],this.state.future=[],this.state.lastSig=void 0)}getConfigVersion=()=>this.state.configVersion;clone(t){let n=t?.regenerateIDs?Mi(this.state.query,{idGenerator:this.state.idGenerator}):this.state.query;return new e(n,this.state.options)}subscribe=e=>(this.state.listeners.add(e),()=>{this.state.listeners.delete(e)});batch(e){this.state.batchDepth++,this.state.batchDepth===1&&(this.state.batchSnapshot={query:this.state.query,past:[...this.state.past],future:[...this.state.future],lastSig:this.state.lastSig,lastAt:this.state.lastAt});try{e()}catch(e){if(this.state.batchDepth===1){let e=this.state.batchSnapshot;this.state.query=e.query,this.state.past=e.past,this.state.future=e.future,this.state.lastSig=e.lastSig,this.state.lastAt=e.lastAt,this.reconcileHistoryConfig()}throw e}finally{if(this.state.batchDepth--,this.state.batchDepth===0){let{query:e}=this.state.batchSnapshot;this.state.batchSnapshot=void 0;let t=e!==this.state.query,n=this.state.pendingConfigNotify;this.state.pendingConfigNotify=!1,t&&(this.state.historyBypassed||this.record(e,this.state.query)),(t||n)&&this.notify(t?n?la:sa:ca),this.state.historyBypassed=!1}}return this}canUndo(){return this.state.past.length>0}canRedo(){return this.state.future.length>0}undo(){return this.state.past.length===0?this:(this.state.future.unshift(this.state.query),this.state.query=this.state.past.pop(),this.state.lastSig=void 0,this.markHistoryBypassed(),this.state.batchDepth===0&&this.notify(sa),this)}redo(){return this.state.future.length===0?this:(this.state.past.push(this.state.query),this.state.query=this.state.future.shift(),this.state.lastSig=void 0,this.markHistoryBypassed(),this.state.batchDepth===0&&this.notify(sa),this)}clearHistory(){return this.markHistoryBypassed(),this.state.past=[],this.state.future=[],this.state.lastSig=void 0,this}getHistory(){return{past:[...this.state.past],future:[...this.state.future]}}validate(){return this.ensureCache(),this.state.validation??=this.state.validator(this.state.query),this.state.validation}format(e){return Fr(this.state.query,e)}*walk(e={}){let{from:t,rulesOnly:n,groupsOnly:r}=e,i=this.state.query,a=[],o=null;if(t!==void 0){let e=this.toPath(t),n=e&&X(e,this.state.query);if(!e||!n)return;i=n,a=e,o=e.length===0?null:X(Z(e),this.state.query)}for(let e of this.walkFrom(i,a,o))n&&P(e.node)||(!r||P(e.node))&&(yield e)}rules(e={}){return this.walk({...e,rulesOnly:!0})}groups(e={}){return this.walk({...e,groupsOnly:!0})}find(e,t={}){for(let n of this.walk(t))if(e(n))return n;return null}filter(e,t={}){let n=[];for(let r of this.walk(t))e(r)&&n.push(r);return n}[Symbol.iterator](){return this.walk()}findPath(e){return X(e,this.state.query)??null}findID(e){let t=this.index().get(e);return t===void 0?null:X(t,this.state.query)}getPathOfID(e){return this.index().get(e)??null}pathIsDisabled(e){return Yr(e,this.state.query)}getNode(e){let t=this.toPath(e);return t===null?null:X(t,this.state.query)??null}getRule(e){let t=this.getNode(e);return t&&!P(t)?t:null}getGroup(e){let t=this.getNode(e);return t&&P(t)?t:null}getParent(e){let t=this.toPath(e);return t===null||t.length===0||!X(t,this.state.query)?null:X(Z(t),this.state.query)}getFields(){return this.state.fields}getCombinators(){return this.state.combinators}getFieldData(e){return nt(e,this.state.fieldMap)}getOperators(e){return this.operatorsFor(e)}getValueSources(e,t){return this.valueSourcesFor(e,t)}getMatchModes(e){return this.matchModesFor(e)}getValues(e,t){return this.valuesFor(e,t)}getValueEditorType(e,t){return this.valueEditorTypeFor(e,t)}getRuleDefaultOperator(e){return this.defaultOperator(e)}getRuleDefaultValue(e){return this.defaultValue(e)}getFieldMap(){return this.state.fieldMap}getRuleContext(e){let t=this.getRule(e);if(!t)return null;let n=this.validate();return ut(t,{fields:this.state.fields,fieldMap:this.state.fieldMap,getInputType:(e,t,n)=>this.state.options.getInputType?.(e,t,n)??null,getMatchModes:e=>this.matchModesFor(e),getOperators:e=>this.operatorsFor(e),getParameters:(e,t,n)=>this.parametersFor(e,t,n),getValueEditorType:(e,t)=>this.valueEditorTypeFor(e,t),getValues:(e,t)=>this.valuesFor(e,t),getValueSources:(e,t)=>this.getValueSources(e,t),getSubQueryBuilderProps:(e,t)=>this.state.options.getSubQueryBuilderProps?.(e,t)??{}},{validationMap:typeof n==`boolean`?{}:n,id:t.id})}getRuleGroupContext(e=[]){let t=this.getGroup(e);if(!t)return null;let n=this.validate();return ft(t,this.state.combinators,{validationMap:typeof n==`boolean`?{}:n,id:t.id})}isIC(){return I(this.state.query)}signatureOf(e){return he(this.state.query,e)}diagnostics(){return Fr(this.state.query,`diagnostics`)}toJSON(){return this.state.query}toIC(){return new e(be(this.state.query),this.state.options)}fromIC(){return new e(L(this.state.query),this.state.options)}transform(e){return W(this.state.query,e)}};exports.LogType=k,exports.QueryManager=da,exports.QueryManagerError=aa,exports.TestID=O,exports.add=Fi,exports.addInPlace=Ii,exports.betweenOperators=x,exports.bigIntJsonParseReviver=Kt,exports.bigIntJsonStringifyReplacer=Gt,exports.celCombinatorMap=At,exports.clsx=ce,exports.coerceBigIntValue=_t,exports.coerceInputType=vt,exports.controlKeys=n,exports.controlKind=i,exports.controlPropKeys=r,exports.convertFromIC=L,exports.convertQuery=xe,exports.convertToIC=be,exports.createQueryActions=na,exports.createRule=ra,exports.createRuleGroup=ia,exports.cypherCombinatorMap=un,exports.defaultCELValueProcessor=zr,exports.defaultCoalesceMs=500,exports.defaultCombinatorLabelMap=m,exports.defaultCombinators=S,exports.defaultCombinatorsExtended=C,exports.defaultControlClassnames=E,exports.defaultExportOperatorMap=pr,exports.defaultJoinChar=`,`,exports.defaultMatchModes=w,exports.defaultMaxHistory=50,exports.defaultMongoDBValueProcessor=Rr,exports.defaultNLTranslations=Bt,exports.defaultOperatorLabelMap=p,exports.defaultOperatorNegationMap=g,exports.defaultOperatorProcessorNL=hr,exports.defaultOperatorProcessorSQL=_r,exports.defaultOperators=h,exports.defaultPlaceholderFieldGroupLabel=s,exports.defaultPlaceholderFieldLabel=o,exports.defaultPlaceholderFieldName=`~`,exports.defaultPlaceholderLabel=a,exports.defaultPlaceholderName=`~`,exports.defaultPlaceholderOperatorGroupLabel=l,exports.defaultPlaceholderOperatorLabel=c,exports.defaultPlaceholderOperatorName=`~`,exports.defaultPlaceholderValueGroupLabel=d,exports.defaultPlaceholderValueLabel=u,exports.defaultPlaceholderValueName=`~`,exports.defaultRuleGroupProcessorCEL=qt,exports.defaultRuleGroupProcessorCypher=dn,exports.defaultRuleGroupProcessorDiagnostics=Rn,exports.defaultRuleGroupProcessorDrizzle=fn,exports.defaultRuleGroupProcessorElasticSearch=pn,exports.defaultRuleGroupProcessorGremlin=mn,exports.defaultRuleGroupProcessorJSONata=hn,exports.defaultRuleGroupProcessorJsonLogic=gn,exports.defaultRuleGroupProcessorLDAP=_n,exports.defaultRuleGroupProcessorMongoDB=yn,exports.defaultRuleGroupProcessorMongoDBQuery=Qt,exports.defaultRuleGroupProcessorNL=bn,exports.defaultRuleGroupProcessorParameterized=xn,exports.defaultRuleGroupProcessorPrisma=Cn,exports.defaultRuleGroupProcessorSPARQL=Tn,exports.defaultRuleGroupProcessorSQL=En,exports.defaultRuleGroupProcessorSequelize=wn,exports.defaultRuleGroupProcessorSpEL=nn,exports.defaultRuleGroupProcessorTanStackDB=Dn,exports.defaultRuleProcessorCEL=Xt,exports.defaultRuleProcessorCypher=Un,exports.defaultRuleProcessorDrizzle=Wn,exports.defaultRuleProcessorElasticSearch=Zn,exports.defaultRuleProcessorGremlin=$n,exports.defaultRuleProcessorJSONata=ir,exports.defaultRuleProcessorJsonLogic=sr,exports.defaultRuleProcessorLDAP=ur,exports.defaultRuleProcessorMongoDB=tn,exports.defaultRuleProcessorMongoDBQuery=en,exports.defaultRuleProcessorNL=gr,exports.defaultRuleProcessorParameterized=yr,exports.defaultRuleProcessorPrisma=xr,exports.defaultRuleProcessorSPARQL=Tr,exports.defaultRuleProcessorSQL=vr,exports.defaultRuleProcessorSequelize=Sr,exports.defaultRuleProcessorSpEL=sn,exports.defaultRuleProcessorTanStackDB=Er,exports.defaultSpELValueProcessor=Br,exports.defaultTranslations=f,exports.defaultValidator=Le,exports.defaultValueProcessor=Lr,exports.defaultValueProcessorByRule=ln,exports.defaultValueProcessorCELByRule=Vr,exports.defaultValueProcessorMongoDBByRule=Hr,exports.defaultValueProcessorNL=fr,exports.defaultValueProcessorSpELByRule=Ur,exports.derivePathInfo=Zr,exports.deriveQueryBuilderClassNames=Ie,exports.deriveRuleClassName=je,exports.deriveRuleClassNames=Ae,exports.deriveRuleContext=ut,exports.deriveRuleGroupClassNames=Me,exports.deriveRuleGroupContext=ft,exports.deriveRuleGroupOuterClassName=Fe,exports.deriveRuleOuterClassName=Pe,exports.exceedsMaxLevels=Pi,exports.filterFieldsByComparator=tt,exports.findID=Wr,exports.findPath=X,exports.formatQuery=Fr,exports.formatQueryOptionPresets=Or,exports.generateAccessibleDescription=Qr,Object.defineProperty(exports,"generateID",{enumerable:!0,get:function(){return Q}}),exports.getCommonAncestorPath=Jr,exports.getFieldData=nt,exports.getFirstOption=H,exports.getGuardAbortReason=Ni,exports.getLikeWildcards=Et,exports.getMatchModesUtil=ai,exports.getMultiValueUpdate=gt,exports.getNLTranslataion=Ht,exports.getOption=V,exports.getParametersAsList=ot,exports.getParentPath=Z,exports.getParseNumberMethod=Ct,exports.getPathOfID=Gr,exports.getQuoteFieldNamesWithArray=Pt,exports.getQuotedFieldName=Ft,exports.getRuleDefaultValue=si,exports.getRuleGroupCombinator=dt,exports.getRuleInputType=rt,exports.getRuleValidationResult=lt,exports.getRuleValueEditorType=st,exports.getRuleValueSourceOptions=at,exports.getRuleValues=ct,exports.getSQLConcat=Tt,exports.getSubqueryElementAlias=Wt,exports.getValidationClassNames=ci,exports.getValueEditorReset=ht,exports.getValueSelectorUpdate=yt,exports.getValueSourcesUtil=di,exports.group=ea,exports.groupInPlace=ta,exports.groupInvalidReasons=D,exports.hideValueControlsForOperator=it,exports.inOperators=b,exports.insert=Qi,exports.insertInPlace=$i,exports.isAncestor=qr,exports.isBetweenOperator=mt,exports.isFlexibleOptionArray=qe,exports.isFlexibleOptionGroupArray=B,exports.isFullOptionArray=Je,exports.isFullOptionGroupArray=Ye,exports.isOptionGroupArray=Ke,exports.isPojo=N,exports.isRuleGroup=P,exports.isRuleGroupType=F,exports.isRuleGroupTypeIC=I,exports.isRuleOrGroupValid=G,exports.isRuleType=de,exports.isUnsafeKey=Be,exports.isValidValue=K,exports.isValidationResult=St,exports.isValueProcessorLegacy=Nt,exports.joinWith=ae,exports.jsonLogicAdditionalOperators=jt,exports.lc=M,exports.mapSQLOperator=wt,exports.mergeAnyTranslation=pi,exports.mergeAnyTranslations=fi,exports.mergeClassnames=mi,exports.mongoDbFallback=Zt,exports.mongoOperators=Ot,exports.move=Xi,exports.moveInPlace=Zi,exports.normalizeConstituentWordOrder=Lt,exports.normalizeValueSelectorValue=bt,exports.nullFreeArray=oe,exports.nullOperators=y,exports.nullOrUndefinedOrEmpty=ue,exports.numericRegex=le,exports.numerifyValues=Mt,exports.objectEntries=ze,exports.objectKeys=Re,exports.optionsEqual=xi,exports.parseNumber=U,exports.pathIsDisabled=Yr,exports.pathIsDisabledByPaths=Xr,exports.pathsAreEqual=Kr,exports.preferAnyProp=Ti,exports.preferFlagProps=Ei,exports.preferProp=wi,exports.prepareOptionList=$e,exports.prepareRule=Di,exports.prepareRuleGroup=Oi,exports.prepareRuleOrGroup=ki,exports.prismaFallback=Sn,exports.prismaOperators=kt,exports.processMatchMode=J,exports.queryBuilderFlagDefaults=te,exports.regenerateID=ji,exports.regenerateIDs=Mi,exports.relationalOperators=_,exports.remove=Gi,exports.removeInPlace=Ki,exports.resolveCandidateQuery=Ai,exports.resolveDefaultOperator=gi,exports.resolveOperatorList=hi,exports.resolveValueEditorType=_i,exports.resolveValueList=vi,exports.rootPath=ee,exports.setAutoFreeze=ti,exports.shouldCoalesce=ge,exports.shouldRenderAsNumber=q,exports.signatureOf=he,exports.sparqlVar=wr,exports.splitBy=ie,exports.sqlDialectPresets=Dr,exports.standardClassnames=T,exports.strictAbortReasons=ne,exports.stripParamPrefix=zt,exports.structuralSignature=fe,exports.subqueryElementAliasBase=Ut,exports.substringOperators=v,exports.toArray=j,exports.toFlatOptionArray=Xe,exports.toFullOption=R,exports.toFullOptionList=z,exports.toFullOptionMap=Ue,exports.transformQuery=W,exports.trimIfString=A,exports.unchangedSignature=``,exports.ungroup=qi,exports.ungroupInPlace=Ji,exports.uniqByIdentifier=Ge,exports.uniqByName=We,exports.uniqOptGroups=Ze,exports.uniqOptList=Qe,exports.update=Hi,exports.updateInPlace=Ui,exports.uuidV4regex=ei,exports.valuesEqual=bi,exports.withParamPrefix=Rt,exports.wrapLikeFragment=Dt;
2
2
  //# sourceMappingURL=react-querybuilder_core.cjs.production.js.map