@syncfusion/ej2-querybuilder 25.2.7 → 26.1.35

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 (109) hide show
  1. package/.eslintrc.json +3 -2
  2. package/dist/ej2-querybuilder.min.js +2 -2
  3. package/dist/ej2-querybuilder.umd.min.js +2 -2
  4. package/dist/ej2-querybuilder.umd.min.js.map +1 -1
  5. package/dist/es6/ej2-querybuilder.es2015.js +1326 -290
  6. package/dist/es6/ej2-querybuilder.es2015.js.map +1 -1
  7. package/dist/es6/ej2-querybuilder.es5.js +1319 -282
  8. package/dist/es6/ej2-querybuilder.es5.js.map +1 -1
  9. package/dist/global/ej2-querybuilder.min.js +2 -2
  10. package/dist/global/ej2-querybuilder.min.js.map +1 -1
  11. package/dist/global/index.d.ts +1 -1
  12. package/package.json +12 -12
  13. package/src/query-builder/query-builder-model.d.ts +45 -6
  14. package/src/query-builder/query-builder.d.ts +102 -5
  15. package/src/query-builder/query-builder.js +1311 -262
  16. package/src/query-builder/query-library.js +2 -2
  17. package/styles/bootstrap-dark.css +194 -21
  18. package/styles/bootstrap-dark.scss +15 -1
  19. package/styles/bootstrap.css +194 -21
  20. package/styles/bootstrap.scss +15 -1
  21. package/styles/bootstrap4.css +198 -22
  22. package/styles/bootstrap4.scss +15 -1
  23. package/styles/bootstrap5-dark.css +198 -30
  24. package/styles/bootstrap5-dark.scss +15 -1
  25. package/styles/bootstrap5.css +198 -30
  26. package/styles/bootstrap5.scss +15 -1
  27. package/styles/fabric-dark.css +192 -20
  28. package/styles/fabric-dark.scss +15 -1
  29. package/styles/fabric.css +192 -20
  30. package/styles/fabric.scss +15 -1
  31. package/styles/fluent-dark.css +196 -28
  32. package/styles/fluent-dark.scss +15 -1
  33. package/styles/fluent.css +196 -28
  34. package/styles/fluent.scss +15 -1
  35. package/styles/fluent2.css +2052 -0
  36. package/styles/fluent2.scss +15 -0
  37. package/styles/highcontrast-light.css +195 -20
  38. package/styles/highcontrast-light.scss +15 -1
  39. package/styles/highcontrast.css +195 -20
  40. package/styles/highcontrast.scss +15 -1
  41. package/styles/material-dark.css +205 -24
  42. package/styles/material-dark.scss +15 -1
  43. package/styles/material.css +207 -24
  44. package/styles/material.scss +15 -1
  45. package/styles/material3-dark.css +211 -26
  46. package/styles/material3-dark.scss +15 -1
  47. package/styles/material3.css +211 -26
  48. package/styles/material3.scss +15 -1
  49. package/styles/query-builder/_bds-definition.scss +7 -1
  50. package/styles/query-builder/_bootstrap-dark-definition.scss +7 -0
  51. package/styles/query-builder/_bootstrap-definition.scss +7 -0
  52. package/styles/query-builder/_bootstrap4-definition.scss +7 -0
  53. package/styles/query-builder/_bootstrap5-definition.scss +7 -1
  54. package/styles/query-builder/_bootstrap5.3-definition.scss +114 -0
  55. package/styles/query-builder/_fabric-dark-definition.scss +7 -0
  56. package/styles/query-builder/_fabric-definition.scss +7 -0
  57. package/styles/query-builder/_fluent-definition.scss +7 -1
  58. package/styles/query-builder/_fluent2-definition.scss +114 -0
  59. package/styles/query-builder/_fusionnew-definition.scss +7 -1
  60. package/styles/query-builder/_highcontrast-definition.scss +7 -0
  61. package/styles/query-builder/_highcontrast-light-definition.scss +7 -0
  62. package/styles/query-builder/_layout.scss +275 -12
  63. package/styles/query-builder/_material-dark-definition.scss +7 -0
  64. package/styles/query-builder/_material-definition.scss +7 -0
  65. package/styles/query-builder/_material3-definition.scss +7 -1
  66. package/styles/query-builder/_tailwind-definition.scss +7 -1
  67. package/styles/query-builder/_theme.scss +34 -22
  68. package/styles/query-builder/bootstrap-dark.css +194 -21
  69. package/styles/query-builder/bootstrap.css +194 -21
  70. package/styles/query-builder/bootstrap4.css +198 -22
  71. package/styles/query-builder/bootstrap5-dark.css +198 -30
  72. package/styles/query-builder/bootstrap5.css +198 -30
  73. package/styles/query-builder/fabric-dark.css +192 -20
  74. package/styles/query-builder/fabric.css +192 -20
  75. package/styles/query-builder/fluent-dark.css +196 -28
  76. package/styles/query-builder/fluent.css +196 -28
  77. package/styles/query-builder/fluent2.css +2052 -0
  78. package/styles/query-builder/fluent2.scss +15 -0
  79. package/styles/query-builder/highcontrast-light.css +195 -20
  80. package/styles/query-builder/highcontrast.css +195 -20
  81. package/styles/query-builder/icons/_bds.scss +4 -0
  82. package/styles/query-builder/icons/_bootstrap-dark.scss +4 -0
  83. package/styles/query-builder/icons/_bootstrap.scss +4 -0
  84. package/styles/query-builder/icons/_bootstrap4.scss +4 -0
  85. package/styles/query-builder/icons/_bootstrap5.3.scss +11 -0
  86. package/styles/query-builder/icons/_bootstrap5.scss +4 -0
  87. package/styles/query-builder/icons/_fabric-dark.scss +4 -0
  88. package/styles/query-builder/icons/_fabric.scss +4 -0
  89. package/styles/query-builder/icons/_fluent.scss +4 -0
  90. package/styles/query-builder/icons/_fluent2.scss +11 -0
  91. package/styles/query-builder/icons/_fusionnew.scss +4 -0
  92. package/styles/query-builder/icons/_highcontrast-light.scss +4 -0
  93. package/styles/query-builder/icons/_highcontrast.scss +4 -0
  94. package/styles/query-builder/icons/_material-dark.scss +4 -0
  95. package/styles/query-builder/icons/_material.scss +4 -0
  96. package/styles/query-builder/icons/_material3.scss +4 -0
  97. package/styles/query-builder/icons/_tailwind-dark.scss +4 -0
  98. package/styles/query-builder/icons/_tailwind.scss +4 -0
  99. package/styles/query-builder/material-dark.css +205 -24
  100. package/styles/query-builder/material.css +207 -24
  101. package/styles/query-builder/material3-dark.css +211 -26
  102. package/styles/query-builder/material3.css +211 -26
  103. package/styles/query-builder/tailwind-dark.css +205 -24
  104. package/styles/query-builder/tailwind.css +205 -24
  105. package/styles/tailwind-dark.css +205 -24
  106. package/styles/tailwind-dark.scss +15 -1
  107. package/styles/tailwind.css +205 -24
  108. package/styles/tailwind.scss +15 -1
  109. package/CHANGELOG.md +0 -828
@@ -1,11 +1,11 @@
1
1
  /*!
2
2
  * filename: ej2-querybuilder.min.js
3
- * version : 25.2.7
3
+ * version : 26.1.35
4
4
  * Copyright Syncfusion Inc. 2001 - 2023. All rights reserved.
5
5
  * Use of this code is subject to the terms of our license.
6
6
  * A copy of the current license can be obtained at any time by e-mailing
7
7
  * licensing@syncfusion.com. Any infringement will be prosecuted under
8
8
  * applicable laws.
9
9
  */
10
- this.ej=this.ej||{},this.ej.querybuilder=function(e,t,l,i,o,n,r,s,a){"use strict";var u=function(){var e=function(t,l){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var l in t)t.hasOwnProperty(l)&&(e[l]=t[l])})(t,l)};return function(t,l){function i(){this.constructor=t}e(t,l),t.prototype=null===l?Object.create(l):(i.prototype=l.prototype,new i)}}(),d=function(){return(d=Object.assign||function(e){for(var t,l=1,i=arguments.length;l<i;l++){t=arguments[l];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e}).apply(this,arguments)},p=function(e,t,l,i){var o,n=arguments.length,r=n<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,l):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,l,i);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(r=(n<3?o(r):n>3?o(t,l,r):o(t,l))||r);return n>3&&r&&Object.defineProperty(t,l,r),r},c=function(e){function l(){return null!==e&&e.apply(this,arguments)||this}return u(l,e),p([t.Property(null)],l.prototype,"field",void 0),p([t.Property(null)],l.prototype,"label",void 0),p([t.Property(null)],l.prototype,"type",void 0),p([t.Property(null)],l.prototype,"values",void 0),p([t.Property(null)],l.prototype,"operators",void 0),p([t.Property()],l.prototype,"ruleTemplate",void 0),p([t.Property(null)],l.prototype,"template",void 0),p([t.Property({isRequired:!0,min:0,max:Number.MAX_VALUE})],l.prototype,"validation",void 0),p([t.Property(null)],l.prototype,"format",void 0),p([t.Property(null)],l.prototype,"step",void 0),p([t.Property(null)],l.prototype,"value",void 0),p([t.Property(null)],l.prototype,"category",void 0),p([t.Property(null)],l.prototype,"columns",void 0),l}(t.ChildProperty),h=function(e){function l(){return null!==e&&e.apply(this,arguments)||this}return u(l,e),p([t.Property(null)],l.prototype,"condition",void 0),p([t.Collection([],l)],l.prototype,"rules",void 0),p([t.Property(null)],l.prototype,"field",void 0),p([t.Property(null)],l.prototype,"label",void 0),p([t.Property(null)],l.prototype,"type",void 0),p([t.Property(null)],l.prototype,"operator",void 0),p([t.Property(null)],l.prototype,"value",void 0),p([t.Property(!1)],l.prototype,"not",void 0),p([t.Property(null)],l.prototype,"isLocked",void 0),l}(t.ChildProperty),m=function(e){function l(){return null!==e&&e.apply(this,arguments)||this}return u(l,e),p([t.Property(null)],l.prototype,"numericTextBoxModel",void 0),p([t.Property(null)],l.prototype,"multiSelectModel",void 0),p([t.Property(null)],l.prototype,"datePickerModel",void 0),p([t.Property(null)],l.prototype,"textBoxModel",void 0),p([t.Property(null)],l.prototype,"radioButtonModel",void 0),l}(t.ChildProperty),g=function(e){function l(){return null!==e&&e.apply(this,arguments)||this}return u(l,e),p([t.Property(!1)],l.prototype,"cloneRule",void 0),p([t.Property(!1)],l.prototype,"cloneGroup",void 0),p([t.Property(!1)],l.prototype,"lockRule",void 0),p([t.Property(!1)],l.prototype,"lockGroup",void 0),p([t.Property(!0)],l.prototype,"ruleDelete",void 0),p([t.Property(!0)],l.prototype,"groupInsert",void 0),p([t.Property(!0)],l.prototype,"groupDelete",void 0),l}(t.ChildProperty),f=function(e){function c(t,l){var o=e.call(this,t,l)||this;return o.isReadonly=!0,o.fields={text:"label",value:"field"},o.updatedRule={not:!1,condition:"and",isLocked:!1},o.isLocale=!1,o.isRefreshed=!1,o.isNotified=!1,o.isAddSuccess=!1,o.isNotValueChange=!1,o.isFieldChange=!1,o.isFieldClose=!1,o.isDestroy=!1,o.isGetNestedData=!1,o.isCustomOprCols=[],o.groupCounter=0,o.lockItems=[],o.groupIndex=-1,o.ruleIndex=-1,o.isLastGroup=!1,o.cloneGrpBtnClick=!1,o.isMiddleGroup=!1,o.cloneRuleBtnClick=!1,i.MultiSelect.Inject(i.CheckBoxSelection),o}return u(c,e),c.prototype.getPersistData=function(){return this.addOnPersist(["rule"])},c.prototype.reset=function(){this.isImportRules=!1;for(var e=this.element.querySelector(".e-group-body"),l=this.element.querySelectorAll("input.e-control"),i=0,o=l.length;i<o;i++)l[i].className.indexOf("e-tooltip")>-1?t.getComponent(l[i],"tooltip").destroy():l[i].parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(l[i].parentElement,"tooltip").destroy();if(e)e.innerHTML="";else{var n=this.createElement("div",{attrs:{class:"e-group-container"}}),r=this.createElement("div",{attrs:{class:"e-group-header"}}),s=this.createElement("div",{attrs:{class:"e-group-body"}});n.appendChild(r).appendChild(s),this.element.appendChild(n),e=this.element.querySelector(".e-group-body")}this.headerTemplate&&this.isRoot&&(this.element.innerHTML="",this.isRoot=!1),this.enableNotCondition&&t.removeClass(this.element.querySelectorAll(".e-qb-toggle"),"e-active-toggle"),e.appendChild(this.createElement("div",{attrs:{class:"e-rule-list"}})),this.levelColl[this.element.id+"_group0"]=[0],this.setProperties({rule:{condition:"and",not:!1,rules:[]}},!0),this.disableRuleCondition(e.parentElement)},c.prototype.getWrapper=function(){return this.element},c.prototype.getModuleName=function(){return"query-builder"},c.prototype.requiredModules=function(){var e=[];return e.push({member:"query-library",args:[this]}),e},c.prototype.GetRootColumnName=function(e){return this.separator?e.split(this.separator)[0]:e},c.prototype.initialize=function(){if(this.dataColl.length){var e=Object.keys(this.dataColl[0]),t=[],l=[],i=void 0,o=!1,n=!1,r=void 0,s={isRequired:!0,min:0,max:Number.MAX_VALUE};if(this.columns.length){this.columnSort();for(var a=0,u=(d=this.columns).length;a<u;a++)this.updateCustomOperator(d[a],"initial"),d[a].type||(e.indexOf(d[a].field)>-1&&("string"===(i=typeof(r=this.dataColl[0][d[a].field]))?n=!isNaN(Date.parse(r)):"object"===i&&(n=r instanceof Date&&!isNaN(r.getTime()),i="string"),d[a].type=i,n=!1),i="string"),d[a].validation||(d[a].validation=s),d[a].category?o=!0:d[a].category=this.l10n.getConstant("OtherFields"),l.indexOf(d[a].category)<0&&l.push(d[a].category),(!d[a].operators||this.isLocale&&0!==this.isCustomOprCols.indexOf(d[a].field))&&(d[a].operators=this.customOperators[d[a].type+"Operator"]);o&&(l.length>1||l[0]!==this.l10n.getConstant("OtherFields"))&&(this.fields={text:"label",value:"field",groupBy:"category"}),this.updateSubFieldsFromColumns(this.columns)}else{for(var a=0,u=e.length;a<u;a++)"string"===(i=typeof(r=this.dataColl[0][e[a]]))?n=!isNaN(Date.parse(r)):"object"!==i||Object.keys(r).length||(n=r instanceof Date&&!isNaN(r.getTime()),i="string"),t[a]={field:e[a],label:e[a],type:n?"date":i,validation:s},n=!1,t[a].operators=this.customOperators[t[a].type+"Operator"],"object"===i&&this.updateSubFields(r,t[a]);this.columns=t}}else if(this.columns.length){for(var d=this.columns,a=0,u=d.length;a<u;a++)d[a].category?this.fields={text:"label",value:"field",groupBy:"category"}:d[a].category=this.l10n.getConstant("OtherFields"),this.updateCustomOperator(d[a]),d[a].operators&&!this.isLocale||(d[a].operators=this.customOperators[d[a].type+"Operator"]);this.updateSubFieldsFromColumns(this.columns)}this.trigger("dataBound",{type:"dataBound"})},c.prototype.updateSubFieldsFromColumns=function(e,t){for(var l=0;l<e.length;l++)""!==this.separator&&e[l].field.indexOf(this.separator)<0&&(e[l].field=t?t+this.separator+e[l].field:e[l].field),e[l].operators?this.updateCustomOperator(e[l]):e[l].type&&"object"!==e[l].type&&(e[l].operators=this.customOperators[e[l].type+"Operator"]),e[l].columns&&(e[l].type="object",this.updateSubFieldsFromColumns(e[l].columns,e[l].field))},c.prototype.updateSubFields=function(e,t,l){var i;t.columns=[];var o,n,r=Object.keys(e);l=l||this.dataColl[0];for(var s=0,a=r.length;s<a;s++){var u=t.field.split(".");n=l?l[u[u.length-1]][r[s]]:this.dataColl[0][t.field][r[s]];var d=l[t.field.split(this.separator)[t.field.split(this.separator).length-1]];o=typeof n,i={field:t.field+this.separator+r[s],label:r[s],type:o="object"!==o||isNaN(Date.parse(n))?o:"date"},"object"!==o&&(i.operators=this.customOperators[o+"Operator"]),t.columns.push(i),"object"===o&&this.updateSubFields(n,i,d)}},c.prototype.updateCustomOperator=function(e,l){if(e.operators){this.isLocale||"initial"!==l||t.isNullOrUndefined(this.isCustomOprCols)||this.isCustomOprCols.push(e.field);for(var i=this,o=0;o<e.operators.length;o++)!function(t){var l=Object.keys(e.operators[t]).indexOf("sqlOperator");if(l>-1){var o=e.operators[t],n=Object.keys(o),r=n.map(function(e){return o[""+e]}).join(",").split(","),s=n.indexOf("value");i.operators[r[s]]=r[l]}}(o)}},c.prototype.focusEventHandler=function(e){this.target=e.target},c.prototype.clickEventHandler=function(e){var l,i=this,o=e.target;this.isImportRules=!1;var n;if("SPAN"===o.tagName&&(o=o.parentElement),o.className.indexOf("e-collapse-rule")>-1){var r=new t.Animation({duration:1e3,delay:0});this.element.querySelectorAll(".e-summary-content").length<1&&this.renderSummary();var s=document.getElementById(this.element.id+"_summary_content"),a=s.querySelector(".e-summary-text");r.animate(".e-query-builder",{name:"SlideLeftIn"}),(d=this.element.querySelector(".e-group-container")).style.display="none",a.textContent=this.getSqlFromRules(this.rule),s.style.display="block",a.style.height=a.scrollHeight+"px"}if("BUTTON"===o.tagName&&o.className.indexOf("e-qb-toggle")<0)switch(!0){case o.className.indexOf("e-removerule")>-1:this.actionButton=o,this.deleteRule(o);break;case o.className.indexOf("e-clone-rule-btn")>-1:this.actionButton=o,this.cloneRuleBtnClick=!0,this.ruleClone(o);break;case o.className.indexOf("e-lock-rule-btn")>-1:this.actionButton=o,this.ruleLock(o);break;case o.className.indexOf("e-lock-grp-btn")>-1:this.actionButton=o,this.groupLock(o);break;case o.className.indexOf("e-clone-grp-btn")>-1:this.actionButton=o,this.cloneGrpBtnClick=!0,this.groupClone(t.closest(o,".e-group-container"));break;case o.className.indexOf("e-deletegroup")>-1:this.actionButton=o,this.deleteGroup(t.closest(o,".e-group-container"));break;case o.className.indexOf("e-edit-rule")>-1:if((r=new t.Animation({duration:1e3,delay:0})).animate(".e-query-builder",{name:"SlideLeftIn"}),document.getElementById(this.element.id+"_summary_content").style.display="none",this.element.querySelectorAll(".e-group-container").length<1){this.addGroupElement(!1,this.element,this.rule.condition,!1,this.rule.not);var u=t.extend({},this.rule,{},!0);this.setGroupRules(u),this.renderSummaryCollapse()}else{var d=this.element.querySelector(".e-group-container");d.querySelectorAll(".e-collapse-rule").length<1&&this.renderSummaryCollapse(),d.style.display="block"}}else if("LABEL"===o.tagName&&o.parentElement.className.indexOf("e-btn-group")>-1||o.className.indexOf("e-qb-toggle")>-1){var p=t.closest(o,".e-group-container");if(!this.headerTemplate){var c=o.getAttribute("for"),h=void 0;c&&(h=document.getElementById(c).getAttribute("value")),n=p.id.replace(this.element.id+"_","");var m=this.getGroup(n),g=void 0;if(this.enableNotCondition)if(o.className.indexOf("e-qb-toggle")>-1){var f=p.getElementsByClassName("e-qb-toggle")[0];f.className.indexOf("e-active-toggle")>-1?(t.removeClass([f],"e-active-toggle"),g=!1):(t.addClass([f],"e-active-toggle"),g=!0),h=m.condition}else g=m.not;l={groupID:n,cancel:!1,type:"condition",value:h.toLowerCase()},this.enableNotCondition&&(l={groupID:n,cancel:!1,type:"condition",value:h.toLowerCase(),not:g})}this.isImportRules?this.beforeSuccessCallBack(l,o):this.trigger("beforeChange",l,function(e){i.beforeSuccessCallBack(e,o)}),this.target=o}},c.prototype.beforeSuccessCallBack=function(e,l){if(e&&!e.cancel){var i=t.closest(l,".e-group-container"),o=i.id.replace(this.element.id+"_",""),n=this.getValidRules(this.rule),r=this.getParentGroup(i);r.condition=e.value,this.enableNotCondition&&(r.not=e.not),this.isImportRules||this.trigger("change",{groupID:o,type:"condition",value:r.condition}),this.filterRules(n,this.getValidRules(this.rule),"condition")}},c.prototype.selectBtn=function(e,l){"beforeOpen"===l.name?this.showButtons.groupInsert||t.isNullOrUndefined(this.showButtons.groupInsert)?(this.element.querySelectorAll(".e-group-container").length>=this.maxGroupCount+1?t.addClass([l.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"):t.removeClass([l.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"),this.enableRtl&&t.addClass([l.element.querySelector("li").parentElement],"e-rtl")):t.addClass([l.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"):l.element.children[0].className.indexOf("e-addrule")>-1?this.addRuleElement(t.closest(e,".e-group-container"),{}):l.element.children[0].className.indexOf("e-addgroup")>-1&&this.addGroupElement(!0,t.closest(e,".e-group-container"),"",!0)},c.prototype.appendRuleElem=function(e,l,i,o,n,r){var s,a,u,d=e.querySelector(".e-rule-list");if("change"===i?s=t.select("#"+o,e):((s=this.createElement("div",{attrs:{class:"e-rule-container"}})).setAttribute("id",e.id+"_rule"+this.ruleIdCounter),this.showButtons.cloneRule&&this.cloneRuleBtnClick?(this.ruleIndex<0?d.appendChild(s):d.insertBefore(s,d.children[this.ruleIndex+1]),this.cloneRuleBtnClick=!1):d.appendChild(s),this.ruleIdCounter++),l&&l.ruleTemplate&&r){u={requestType:"template-initialize",ruleID:s.id,action:n,fields:this.fields,rule:r},this.trigger("actionBegin",u),this.ruleTemplateFn=this.templateParser(l.ruleTemplate);var p=this.element.id+l.field;if(u.fields=this.fields,u.columns=this.columns,""===r.field&&(r.field=l.field),u.operators=this.getOperators(r.field),u.operatorFields={text:"key",value:"value"},this.isReact)(a=this.ruleTemplateFn(u,this,s.id,p)[0]).className+=" e-rule-field",s.appendChild(a);else if(this.isAngular){var c=this.ruleTemplateFn(u,this,s.id,p);(a=3===c[0].nodeType?c[1]:c[0]).className+=" e-rule-field",s.appendChild(a)}else this.isVue3?(a=this.ruleTemplateFn(u,this,"Template",p),t.append(a,s),s.children[s.children.length-1].className+=" e-rule-field"):((a=this.ruleTemplateFn(u,this,"Template",p)[0]).className+=" e-rule-field",s.appendChild(a))}else a=this.ruleElem.querySelector(".e-rule-field").cloneNode(!0),s.appendChild(a);return this.showButtons.lockGroup&&t.removeClass(s.querySelectorAll(".e-lock-grp-btn"),"e-button-hide"),this.showButtons.lockRule&&t.removeClass(s.querySelectorAll(".e-lock-rule-btn"),"e-button-hide"),this.showButtons.cloneGroup&&t.removeClass(s.querySelectorAll(".e-clone-grp-btn"),"e-button-hide"),this.showButtons.cloneRule&&t.removeClass(s.querySelectorAll(".e-clone-rule-btn"),"e-button-hide"),this.showButtons.ruleDelete&&t.removeClass(s.querySelectorAll(".e-lock-grp-btn"),"e-button-hide"),l&&l.ruleTemplate&&r&&this.renderReactTemplates(),s},c.prototype.addRuleElement=function(e,t,l,i,o,n){var r=this;if(e){var s={groupID:e.id.replace(this.element.id+"_",""),cancel:!1,type:"insertRule"};this.isImportRules||this.isInitialLoad?(this.isInitialLoad=!1,this.addRuleSuccessCallBack(s,e,t,l,i,o,n)):this.trigger("beforeChange",s,function(s){r.addRuleSuccessCallBack(s,e,t,l,i,o,n)})}},c.prototype.addRuleSuccessCallBack=function(e,l,o,n,r,s,a){var u,p,c,h,m=this.element.className.indexOf("e-device")>-1?"250px":"200px",g=o&&o.field?this.getColumn(o.field):n||this.columns[0],f={label:"",field:"",type:"",operator:""};if(!e.cancel){if(g&&g.ruleTemplate&&o.field){this.selectedColumn=g,p=this.selectedColumn.operators,f={label:g.label,field:g.field,type:g.type,operator:p[0].value};var v=Object.keys(o).length?o:f,y={requestType:"template-create",action:"insert-rule",ruleID:(h=this.appendRuleElem(l,g,r,s,"field",v)).id,fields:this.fields,rule:v};this.trigger("actionBegin",y)}else{(h=this.appendRuleElem(l,g,r,s,"field")).querySelector(".e-filter-input").setAttribute("id",h.id+"_filterkey");var b=h.querySelector(".e-rule-delete");if(this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode)b.textContent=this.l10n.getConstant("Remove"),t.addClass([b],"e-flat"),t.addClass([b],"e-primary");else{t.addClass([b],"e-round"),t.addClass([b],"e-icon-btn"),b.setAttribute("title",this.l10n.getConstant("DeleteRule"));var C=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-delete-icon"}});h.querySelector(".e-rule-delete").appendChild(C)}this.showButtons.ruleDelete||b.classList.add("e-button-hide")}if("Vertical"===this.displayMode||this.element.className.indexOf("e-device")>-1?h.className="e-rule-container e-vertical-mode":h.className="e-rule-container e-horizontal-mode",h.previousElementSibling&&h.previousElementSibling.className.indexOf("e-rule-container")>-1&&(h.className.indexOf("e-joined-rule")<0&&(h.className+=" e-joined-rule"),h.previousElementSibling.className.indexOf("e-prev-joined-rule")<0&&(h.previousElementSibling.className+=" e-prev-joined-rule")),h.previousElementSibling&&h.previousElementSibling.className.indexOf("e-group-container")>-1&&h.className.indexOf("e-separate-rule")<0&&(h.className+=" e-separate-rule"),this.isImportRules||this.updateAddedRule(l,o,f,a,s),!g||g&&!g.ruleTemplate||!o.field)if("Default"===this.fieldMode){var S=void 0,x=void 0;x=this.separator&&o.field?this.GetRootColumnName(o.field):this.autoSelectField?this.GetRootColumnName(o.field):this.isImportRules?this.GetRootColumnName(o.field):o.field,S={dataSource:this.columns,fields:this.fields,placeholder:this.l10n.getConstant("SelectField"),popupHeight:this.columns.length>5?m:"auto",close:this.fieldClose.bind(this,h.id+"_filterkey"),change:this.changeField.bind(this),value:o?x:null,open:this.popupOpen.bind(this,!0),cssClass:"qb-dropdownlist"},this.fieldModel&&(S=d({},S,this.fieldModel)),(c=new i.DropDownList(S)).appendTo("#"+h.id+"_filterkey");w=void 0;w=this.separator&&o.field?this.GetRootColumnName(o.field):this.isImportRules?this.GetRootColumnName(o.field):c.value,this.selectedColumn=c.getDataByValue(w),Object.keys(o).length&&this.changeRule(o,{element:c.element,itemData:this.selectedColumn})}else{var S=void 0,x=(this.isImportRules,o.field);this.dummyDropdownTreeDs=t.extend([],this.columns,[],!0),this.updateDropdowntreeDS(this.dummyDropdownTreeDs),S={fields:{dataSource:this.dummyDropdownTreeDs,value:"field",text:"label",child:"columns",expanded:"expanded",selectable:"selectable"},placeholder:this.l10n.getConstant("SelectField"),showClearButton:!1,popupHeight:this.columns.length>5?m:"auto",changeOnBlur:!1,change:this.changeField.bind(this),value:t.isNullOrUndefined(x)?null:[x],open:this.popupOpen.bind(this,!1),treeSettings:{expandOn:"Click"},cssClass:"e-qb-ddt"},this.fieldModel&&(S=d({},S,this.fieldModel));var O=new i.DropDownTree(S);if(O.appendTo("#"+h.id+"_filterkey"),!t.isNullOrUndefined(O.value)){var k=this.getLabelFromColumn(O.value[0]);O.element.value=k}var w=t.isNullOrUndefined(o.field)?O.value:this.GetRootColumnName(o.field);this.selectedColumn=this.getColumn(w),Object.keys(o).length&&this.changeRule(o,{element:O.element,itemData:this.selectedColumn})}u=h.id.replace(this.element.id+"_",""),this.isImportRules||this.trigger("change",{groupID:l.id.replace(this.element.id+"_",""),ruleID:u,type:"insertRule"})}},c.prototype.updateDropdowntreeDS=function(e){for(var t=0;t<e.length;t++)"object"===e[parseInt(t.toString(),10)].type&&(e[parseInt(t.toString(),10)].selectable=!1,this.updateDropdowntreeDS(e[parseInt(t.toString(),10)].columns))},c.prototype.updateAddedRule=function(e,l,i,o,n){var r,s,a,u=0;if(o){for(r=t.select("#"+n,e),s=t.closest(e,".e-group-container"),a=this.getParentGroup(s);r&&null!==r.previousElementSibling;)r=r.previousElementSibling,u++;a.rules[u]=l}else{s=t.closest(e,".e-group-container"),a=this.getParentGroup(s);var d=l.custom;Object.keys(l).length?this.ruleIndex<0?(a.rules.push({field:l.field,type:l.type,label:l.label,operator:l.operator,value:l.value}),d&&(a.rules[a.rules.length-1].custom=d)):(a.rules.splice(this.ruleIndex+1,0,{field:l.field,type:l.type,label:l.label,operator:l.operator,value:l.value}),d&&(a.rules[this.ruleIndex+1].custom=d)):(d&&(i.custom=d),this.autoSelectField&&(l.field=i.field=this.rule.rules[0].field),a.rules.push(i))}this.disableRuleCondition(e,a)},c.prototype.changeRuleTemplate=function(e,l){var i=this.selectedColumn.operators;if(!e.ruleTemplate){var o=t.closest(l,".e-group-container"),n=t.closest(l,".e-rule-container").id;if(this.previousColumn&&this.previousColumn.ruleTemplate&&(t.detach(l.closest('[id="'+n+'"]').querySelector(".e-rule-field")),this.clearQBTemplate([n])),e){var r={field:e.field,label:e.label,operator:i[0].value,value:""};this.addRuleElement(o,r,e,"change",n,!0)}}},c.prototype.renderToolTip=function(e){var t=new a.Tooltip({content:this.l10n.getConstant("ValidationMessage"),isSticky:!0,position:"BottomCenter",cssClass:"e-querybuilder-error",afterClose:function(){t.destroy()},beforeOpen:function(e){var t=e.element.querySelector(".e-tooltip-close");t&&(t.style.display="none")}});t.appendTo(e),t.open(e)},c.prototype.validateFields=function(){var e,l=!0;if(this.allowValidation){var i=["isnull","isnotnull","isempty","isnotempty"],o=void 0,n=void 0,r=void 0,s=void 0,a=[],u=void 0,d=void 0,p=void 0,c=void 0,h=void 0,m=this.element.querySelectorAll(".e-rule-container");for(o=0,n=m.length;o<n;o++){var g=void 0;if(u=t.closest(m[o],".e-group-container"),h=this.getParentGroup(u),d=0,s=c=m[o],"DropdownTree"===this.fieldMode?(e=t.getComponent(m[o].querySelector(".e-rule-filter input.e-dropdowntree"),"dropdowntree"))&&e.value&&e.value.length&&(this.selectedColumn=this.getColumn(e.value[0]),g=this.selectedColumn.validation):(p=t.getComponent(m[o].querySelector(".e-rule-filter input.e-dropdownlist"),"dropdownlist"))&&p.value&&(this.selectedColumn=p.getDataByValue(p.value),g=!t.isNullOrUndefined(p.index)&&this.selectedColumn.validation),r=c.querySelector(".e-rule-field input.e-control"),g&&g.isRequired){for(;s&&null!==s.previousElementSibling;)s=s.previousElementSibling,d++;if(r=c.querySelector(".e-rule-operator .e-control"),h.rules[d].operator||(r.parentElement.className.indexOf("e-tooltip")<0&&r.className.indexOf("e-tooltip")<0&&this.renderToolTip(r.parentElement),l=!1),h.rules[d].value instanceof Array&&(a=h.rules[d].value),i.indexOf(h.rules[d].operator)<-1&&t.isNullOrUndefined(h.rules[d].value)&&"date"!==h.rules[d].type||""===h.rules[d].value||h.rules[d].value instanceof Array&&a.length<1){var f=c.querySelectorAll(".e-rule-value .e-control");l=!1;for(var v=0,y=f.length;v<y;v++){var b=f[v],C=void 0;b.parentElement.className.indexOf("e-searcher")>-1?(C=t.closest(b,".e-multi-select-wrapper")).className.indexOf("e-tooltip")<0&&this.renderToolTip(C):f[v].parentElement.className.indexOf("e-tooltip")<0&&f[v].className.indexOf("e-tooltip")<0&&this.renderToolTip(f[v].parentElement),v++}}}else(p&&p.element&&t.isNullOrUndefined(p.index)||e&&e.element&&(t.isNullOrUndefined(e.value)||e.value.length<1))&&(r.parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(r.parentElement),l=!1)}}return l},c.prototype.refreshLevelColl=function(){this.levelColl={};var e=this.element.querySelector(".e-group-container");if(e){this.levelColl[e.id]=[0];var t={groupElement:e,level:[0]};this.refreshLevel(t)}},c.prototype.refreshLevel=function(e){var l,i,o=e.groupElement.querySelector(".e-rule-list").children,n=e.groupElement,r=o.length,s=0;for(i=0;i<r;i++)(l=o[i]).className.indexOf("e-group-container")>-1&&(e.level.push(s),this.levelColl[l.id]=e.level.slice(),s++,e.groupElement=l,e=this.refreshLevel(e));var a=t.closest(n,".e-rule-list");return e.groupElement=a?t.closest(a,".e-group-container"):n,e.level=this.levelColl[e.groupElement.id].slice(),e},c.prototype.groupTemplate=function(){var e,t,l,i,o,n=this.createElement("div",{attrs:{class:"e-group-container"}}),r=this.createElement("div",{attrs:{class:"e-group-header"}}),s=this.createElement("div",{attrs:{class:"e-group-body"}}),a=this.createElement("div",{attrs:{class:"e-rule-list"}});return n.appendChild(r),s.appendChild(a),n.appendChild(s),this.headerTemplate||(e=this.createElement("div",{attrs:{class:"e-lib e-btn-group",role:"group"}}),this.enableNotCondition&&(t=this.createElement("button",{attrs:{type:"button",class:"e-qb-toggle"}}),e.appendChild(t)),t=this.createElement("input",{attrs:{type:"radio",class:"e-btngroup-and",value:"AND"}}),e.appendChild(t),l=this.createElement("label",{attrs:{class:"e-lib e-btn e-btngroup-and-lbl e-small"},innerHTML:this.l10n.getConstant("AND")}),e.appendChild(l),t=this.createElement("input",{attrs:{type:"radio",class:"e-btngroup-or",value:"OR"}}),e.appendChild(t),l=this.createElement("label",{attrs:{class:"e-lib e-btn e-btngroup-or-lbl e-small"},innerHTML:this.l10n.getConstant("OR")}),e.appendChild(l),r.appendChild(e),i=this.createElement("div",{attrs:{class:"e-group-action"}}),o=this.createElement("button",{attrs:{type:"button",class:"e-add-btn"}}),i.appendChild(o),r.appendChild(i)),n},c.prototype.ruleTemplate=function(){var e,l,i,o,n=this.createElement("div"),r=this.createElement("div",{attrs:{class:"e-rule-field"}});e=this.createElement("div",{attrs:{class:"e-rule-filter"}});var s=this.createElement("input",{attrs:{type:"text",class:"e-filter-input"}});e.appendChild(s),r.appendChild(e),e=this.createElement("div",{attrs:{class:"e-rule-operator"}}),r.appendChild(e),e=this.createElement("div",{attrs:{class:"e-rule-value"}}),r.appendChild(e),e=this.createElement("div",{attrs:{class:"e-rule-value-delete"}}),i=this.showButtons.cloneRule?"e-clone-rule-btn e-clone-rule e-css e-btn e-small e-round e-icon-btn":"e-clone-rule-btn e-clone-rule e-css e-btn e-small e-round e-icon-btn e-button-hide",o=this.showButtons.lockRule?"e-lock-rule-btn e-lock-rule e-css e-btn e-small e-round e-icons e-icon-btn":"e-lock-rule-btn e-lock-rule e-css e-btn e-small e-round e-icons e-icon-btn e-button-hide";var a=this.createElement("button",{attrs:{title:this.l10n.getConstant("CloneRule"),type:"button",class:i}}),u=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-copy"}});a.appendChild(u);var d=this.createElement("button",{attrs:{title:this.l10n.getConstant("LockRule"),type:"button",class:o}});u=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-unlock"}}),d.appendChild(u),l=this.showButtons.ruleDelete||t.isNullOrUndefined(this.showButtons.ruleDelete)?"e-removerule e-rule-delete e-css e-btn e-small":"e-removerule e-rule-delete e-css e-btn e-small e-button-hide";var p=this.createElement("button",{attrs:{type:"button",class:l}});return e.appendChild(a),e.appendChild(d),e.appendChild(p),r.appendChild(e),n.appendChild(r),n},c.prototype.addGroupElement=function(e,t,l,i,o,n,r){var s=this,a={groupID:t.id.replace(this.element.id+"_",""),cancel:!1,type:"insertGroup"};this.isImportRules||this.isInitialLoad?(this.isInitialLoad=!1,this.addGroupSuccess(a,e,t,l,i,o,n,r)):this.trigger("beforeChange",a,function(a){s.addGroupSuccess(a,e,t,l,i,o,n,r)})},c.prototype.addGroupSuccess=function(e,i,o,n,r,a,u,d){if(!e.cancel&&this.element.querySelectorAll(".e-group-container").length<=this.maxGroupCount){var p=o,c=void 0,h="";h=p.className.indexOf("e-group-container")<0?p.querySelector(".e-group-container")&&p.querySelector(".e-group-container").id:p.id;var m=this.groupElem.cloneNode(!0);if(m.setAttribute("id",this.element.id+"_group"+this.groupIdCounter),this.headerTemplate&&(u?(i=!1,m.setAttribute("id",this.element.id+"_group0"),this.headerTemplateFn(m,a,n,d,h),this.groupIdCounter=0):this.headerTemplateFn(m,a,n,d,h)),this.groupIdCounter++,!this.headerTemplate){var g=m.querySelector(".e-btngroup-and"),f=m.querySelector(".e-btngroup-or"),v=m.querySelector(".e-btngroup-and-lbl"),y=m.querySelector(".e-btngroup-or-lbl");g.setAttribute("id",this.element.id+"_and"+this.btnGroupId),f.setAttribute("id",this.element.id+"_or"+this.btnGroupId),g.setAttribute("name",this.element.id+"_and"+this.btnGroupId),f.setAttribute("name",this.element.id+"_and"+this.btnGroupId),v.setAttribute("for",this.element.id+"_and"+this.btnGroupId),y.setAttribute("for",this.element.id+"_or"+this.btnGroupId),this.btnGroupId++}if(i){var b=void 0;b=this.showButtons.groupDelete||t.isNullOrUndefined(this.showButtons.groupDelete)?"e-deletegroup":"e-deletegroup e-button-hide",c=this.createElement("button",{attrs:{type:"button",class:b}}),new l.Button({iconCss:"e-icons e-delete-icon",cssClass:"e-small e-round"}).appendTo(c),c.setAttribute("title",this.l10n.getConstant("DeleteGroup")),t.rippleEffect(c,{selector:".deletegroup"});for(var C=p.querySelector(".e-rule-list"),S=C.children,x=0,O=0,k=S.length;O<k;O++)S[O].className.indexOf("e-group-container")>-1&&(x+=1);this.showButtons.cloneGroup&&this.cloneGrpBtnClick?this.groupIndex===S.length-1?(C.appendChild(m),this.isLastGroup=!0):(S[this.groupIndex+1].parentNode.insertBefore(m,S[this.groupIndex+1]),this.isMiddleGroup=!0):C.appendChild(m);var w=this.levelColl[p.id].slice(0);if(w.push(x),this.levelColl[m.id]=w,this.groupIndex>-1&&this.refreshLevelColl(),this.isImportRules||(this.isAddSuccess=!0,this.addGroups([],p.id.replace(this.element.id+"_","")),this.isAddSuccess=!1,r&&this.addRuleToNewGroups&&this.addRuleElement(m,{})),!this.headerTemplate){I="";I=this.showButtons.cloneGroup?"e-clone-grp-btn e-css e-btn e-small e-round e-icons e-icon-btn":"e-clone-grp-btn e-css e-btn e-small e-round e-icons e-icon-btn e-button-hide";var q=this.createElement("button",{attrs:{title:this.l10n.getConstant("CloneGroup"),type:"button",class:I}}),N=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-copy"}});q.appendChild(N),m.querySelector(".e-group-action").appendChild(q),I=this.showButtons.lockGroup?"e-lock-grp-btn e-css e-btn e-small e-round e-icons e-icon-btn":"e-lock-grp-btn e-css e-btn e-small e-round e-icons e-icon-btn e-button-hide";var E=this.createElement("button",{attrs:{title:this.l10n.getConstant("LockGroup"),type:"button",class:I}}),R=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-unlock"}});E.appendChild(R),m.querySelector(".e-group-action").appendChild(E),m.querySelector(".e-group-action").appendChild(c)}}else{if(!this.headerTemplate){var I="";I=this.showButtons.lockGroup?"e-lock-grp-btn e-css e-btn e-small e-round e-icons e-icon-btn":"e-lock-grp-btn e-css e-btn e-small e-round e-icons e-icon-btn e-button-hide";var E=this.createElement("button",{attrs:{title:this.l10n.getConstant("LockGroup"),type:"button",class:I}}),N=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-unlock"}});E.appendChild(N),m.querySelector(".e-group-action").appendChild(E)}p.appendChild(m),this.levelColl[m.id]=[0]}if(this.enableNotCondition&&!this.headerTemplate){var L=m.querySelector(".e-qb-toggle");new l.Button({content:this.l10n.getConstant("NOT"),cssClass:"e-btn e-small"}).appendTo(L),m.querySelector(".e-btngroup-and-lbl").classList.add("e-not"),this.updatedRule&&this.updatedRule.not&&t.addClass([L],"e-active-toggle")}if(this.updatedRule=null,this.headerTemplate){var T={requestType:"header-template-create",ruleID:m.id,condition:n,notCondition:this.enableNotCondition?a:void 0};this.trigger("actionBegin",T)}else{var D=m.querySelector(".e-add-btn");new s.DropDownButton({items:this.items,cssClass:"e-round e-small e-caret-hide e-addrulegroup",iconCss:"e-icons e-add-icon",beforeOpen:this.selectBtn.bind(this,D),select:this.selectBtn.bind(this,D)}).appendTo(D),D.setAttribute("title",this.l10n.getConstant("AddButton"))}if(!this.isImportRules){var B=p.id.replace(this.element.id+"_",""),P=m.id.replace(this.element.id+"_","");this.trigger("change",{groupID:B,type:"insertGroup",childGroupID:P})}}},c.prototype.headerTemplateFn=function(e,l,i,o,n){var r,s,a=this.element.id+"_header",u=e.querySelector(".e-group-header");if(this.headerTemplate){if(s={requestType:"header-template-initialize",ruleID:e.id,notCondition:this.enableNotCondition?l:void 0,condition:i,rule:this.getRuleCollection(o,!0),groupID:n},this.trigger("actionBegin",s),this.headerFn=this.templateParser(this.headerTemplate),this.isReact)r=this.headerFn(s,this,e.id,a)[0],u.appendChild(r);else if(this.isAngular){var d=this.headerFn(s,this,e.id,a);r=3===d[0].nodeType?d[1]:d[0],u.appendChild(r)}else this.isVue3?(r=this.headerFn(s,this,e.id,a),t.append(r,u)):(r=this.headerFn(s,this,"Template",a)[0],u.appendChild(r));this.renderReactTemplates()}return e},c.prototype.notifyChange=function(e,l,i){var o=t.closest(l,".e-group-container"),n=this.getParentGroup(o),r=t.closest(l,".e-rule-container"),s=0;if("not"===i)return void(n.not=e);if("condition"===i)return void(n.condition=e);for(;r&&null!==r.previousElementSibling;)r=r.previousElementSibling,s++;var a=n.rules[s],u=this.getColumn(a.field),d=this.getFormat(u.format);if("date"===u.type)if(e instanceof Date)e=this.intl.formatDate(e,d);else if(e instanceof Array)for(var p=0;p<e.length;p++)e[p]&&e[p]instanceof Date&&(e[p]=this.intl.formatDate(e[p],d));u.ruleTemplate?this.templateChange(l,e,i):(this.isNotified=!0,this.updateRules(l,e),this.isNotified=!1)},c.prototype.templateChange=function(e,l,i){var o,n=t.closest(e,".e-group-container"),r=this.getParentGroup(n),s=t.closest(e,".e-rule-container"),a=0;for(this.allowValidation&&this.validateValue(r,s);s&&null!==s.previousElementSibling;)s=s.previousElementSibling,a++;var u=r.rules[a];"field"===i?this.selectedColumn=this.getColumn(l):u&&(this.selectedColumn=this.getColumn(u.field));var d;this.previousColumn=this.getColumn(u.field);var p=this.getValidRules(this.rule);this.selectedColumn&&(d=this.selectedColumn.operators?this.selectedColumn.operators:this.customOperators[this.selectedColumn.type+"Operator"]);var c,h=["in","notin","between","notbetween"];switch(i){case"field":u.field=l,u.label=this.selectedColumn.label,u.type=this.selectedColumn.type,u.value="",u.operator=d[0].value;break;case"operator":c=u.operator,u.operator=l,h.indexOf(u.operator)>-1?u.value=[]:h.indexOf(c)>-1&&(u.value="");break;case"value":u.value=l}if(this.changeRuleTemplate(this.selectedColumn,e),this.filterRules(p,this.getValidRules(this.rule),i),this.selectedColumn&&this.selectedColumn.ruleTemplate&&("field"===i||"operator"===i)){var m=t.closest(e,".e-rule-container");this.destroyControls(m,!0),t.detach(m.querySelector(".e-rule-field"));var g=this.appendRuleElem(t.closest(m,".e-group-container"),this.selectedColumn,"change",m.id,i,u);"Vertical"===this.displayMode||this.element.className.indexOf("e-device")>-1?g.className="e-rule-container e-vertical-mode":g.className="e-rule-container e-horizontal-mode",g.previousElementSibling&&g.previousElementSibling.className.indexOf("e-rule-container")>-1&&(g.className.indexOf("e-joined-rule")<0&&(g.className+=" e-joined-rule"),g.previousElementSibling.className.indexOf("e-prev-joined-rule")<0&&(g.previousElementSibling.className+=" e-prev-joined-rule")),g.previousElementSibling&&g.previousElementSibling.className.indexOf("e-group-container")>-1&&g.className.indexOf("e-separate-rule")<0&&(g.className+=" e-separate-rule");var f={requestType:"template-create",action:i,ruleID:m.id,fields:this.fields,rule:u};o={groupID:n.id.replace(this.element.id+"_",""),ruleID:m.id.replace(this.element.id+"_",""),value:u.field,type:"field"},this.trigger("actionBegin",f),this.trigger("change",o)}},c.prototype.changeValue=function(e,l){var i,o=this;if(this.isNumInput&&"number"==typeof l.value)return void(this.isNumInput=!1);((i=l.element&&l.element.classList.contains("e-multiselect")?l.element:l.event?l.event.target:"input"===l.type&&l.currentTarget?l.currentTarget:l.element).className.indexOf("e-day")>-1||i.className.indexOf("e-today")>-1||i.className.indexOf("e-cell")>-1)&&(i=l.element);var r,s=t.closest(i,".e-group-container"),a=t.closest(i,".e-rule-container"),u=s&&s.id.replace(this.element.id+"_",""),d=a.id.replace(this.element.id+"_",""),p=l;p.element&&p.element.className.indexOf("e-datepicker")>-1&&(i=p.element,(r=t.getComponent(t.closest(i,".e-rule-container").querySelector(".e-filter-input"),"dropdownlist"))&&(this.selectedColumn=r.getDataByValue(r.value)),(r=t.getComponent(t.closest(i,".e-rule-container").querySelector(".e-filter-input"),"dropdowntree"))&&(this.selectedColumn=this.getColumn(r.value[0])));var c,h;i.className.indexOf("e-radio")>-1?(h=parseInt(i.id.split("valuekey")[1],0),"Default"===this.fieldMode?(r=t.getComponent(t.closest(i,".e-rule-container").querySelector(".e-filter-input"),"dropdownlist"),this.selectedColumn=r.getDataByValue(r.value),this.selectedColumn.columns&&(r=t.getComponent(t.closest(i,".e-rule-container").querySelector(".e-rule-sub-filter .e-dropdownlist"),"dropdownlist"),this.selectedColumn=this.getColumn(r.value))):(r=t.getComponent(t.closest(i,".e-rule-container").querySelector(".e-filter-input"),"dropdowntree"),this.selectedColumn=this.getColumn(r.value[0])),c=this.selectedColumn.values?this.selectedColumn.values[h]:[!0,!1][h]):i.className.indexOf("e-multiselect")>-1?c=t.getComponent(i,"multiselect").value:(c=l.value,"input"===l.type&&l.currentTarget&&(c=Number(l.currentTarget.value),t.getInstance(l.currentTarget,n.NumericTextBox).value=c,this.isNumInput=!0)),"input"===l.name&&this.immediateModeDelay?(window.clearInterval(this.timer),this.timer=window.setInterval(function(){o.filterValue(u,d,c,e,i)},this.immediateModeDelay)):this.filterValue(u,d,c,e,i)},c.prototype.filterValue=function(e,t,l,i,o){var n=this,r={groupID:e,ruleID:t,value:l,cancel:!1,type:"value"};window.clearInterval(this.timer),this.isImportRules?this.changeValueSuccessCallBack(r,o,i,e,t):this.trigger("beforeChange",r,function(l){n.changeValueSuccessCallBack(l,o,i,e,t)})},c.prototype.changeValueSuccessCallBack=function(e,t,l,i,o){e.cancel||(this.updateRules(t,e.value,l),this.isImportRules||this.trigger("change",{groupID:i,ruleID:o,value:e.value,cancel:!1,type:"value"}))},c.prototype.fieldClose=function(e){if(!this.isFieldChange&&!this.isDestroy){this.isFieldClose=!0;var l=t.getComponent(e,"dropdownlist"),i=l.popupObj.element.querySelector(".e-active"),o=l.getItemData();l.value=o.value;var n={element:l.element,value:o.value,isInteracted:!0,previousItemData:this.prevItemData,previousItem:null,item:i,itemData:o,event:null,e:null};l.previousValue!==l.value&&this.changeField(n),this.isFieldChange=!1}},c.prototype.changeField=function(e){if(e.isInteracted){if(t.isNullOrUndefined(e.value))return;this.isFieldChange=!0,this.prevItemData=e.itemData;var l=t.closest(e.element,".e-rule-filter")||t.closest(e.element,".e-rule-sub-filter"),i="DropdownTree"===this.fieldMode?this.getColumn(e.value[0]):this.getColumn(e.value);if("DropdownTree"===this.fieldMode&&null!==l){var o=l.querySelector(".e-dropdowntree.e-control"),n=t.getComponent(o,"dropdowntree");if(!i)return;if("object"===i.type){if(n.value=e.oldValue,n.dataBind(),t.isNullOrUndefined(e.oldValue))o.value="";else{r=this.getLabelFromColumn(e.oldValue[0]);o.value=r}return}if(!t.isNullOrUndefined(e.value[0])){n.value=e.value[0],n.dataBind();var r=this.getLabelFromColumn(e.value[0]);o.value=r}}if(this.destroySubFields(l),this.subFieldElem=null,this.isNotValueChange=!0,i&&i.ruleTemplate)this.templateChange(e.element,i.field,"field");else if(i&&i.columns&&i.columns[0].ruleTemplate)this.templateChange(e.element,i.columns[0].field,"field");else{for(var s=t.closest(e.element,".e-group-container"),a=this.getParentGroup(s),u=t.closest(e.element,".e-rule-container"),d=0;u&&null!==u.previousElementSibling;)u=u.previousElementSibling,d++;a.rules[d].value="",this.changeRule(a.rules[d],e)}}},c.prototype.changeRule=function(e,l){if(!l.itemData){if("DropdownTree"!==this.fieldMode)return;if(null==t.getComponent(l.element,"dropdowntree").value)return}var i={},o=t.closest(l.element,".e-rule-filter");o=o||t.closest(l.element,".e-rule-sub-filter");var n=t.getComponent(l.element,"dropdownlist");"DropdownTree"===this.fieldMode&&null!==o&&(n=t.getComponent(l.element,"dropdowntree"));var r=t.closest(l.element,".e-group-container").id.replace(this.element.id+"_","");this.changeFilter(o,n,r,e,i,l)},c.prototype.changeFilter=function(e,l,i,o,n,r){var s=this;if(e){var a=void 0;a="DropdownTree"===this.fieldMode?l.value[0]:this.isImportRules?this.GetRootColumnName(l.value):l.value,this.selectedColumn=this.getColumn(a);var u={groupID:i,ruleID:t.closest(e,".e-rule-container").id.replace(this.element.id+"_",""),selectedField:"DropdownTree"===this.fieldMode?l.value[0]:l.value,cancel:!1,type:"field"};this.isImportRules?this.fieldChangeSuccess(u,n,e,o,r):this.trigger("beforeChange",u,function(t){s.fieldChangeSuccess(t,n,e,o,r)})}else{var d=t.closest(r.element,".e-rule-operator");this.changeOperator(e,d,l,i,o,n,r)}},c.prototype.changeOperator=function(e,l,i,o,n,r,s){var a,u=this;l?(a={groupID:o,ruleID:t.closest(l,".e-rule-container").id.replace(this.element.id+"_",""),selectedIndex:i.index,cancel:!1,type:"operator"},this.isImportRules?this.operatorChangeSuccess(a,e,r,n,s):this.trigger("beforeChange",a,function(t){u.operatorChangeSuccess(t,e,r,n,s)})):this.changeRuleValues(e,n,r,s)},c.prototype.fieldChangeSuccess=function(e,l,i,o,n){for(var r=t.closest(i,".e-rule-container"),s=t.closest(n.element,".e-rule-operator"),a=t.closest(n.element,".e-group-container").id.replace(this.element.id+"_",""),u=t.getComponent(n.element,"dropdownlist"),d=r.querySelectorAll(".e-tooltip.e-input-group"),p=0;p<d.length;p++)t.getComponent(d[p],"tooltip").destroy();if(e.cancel)this.changeOperator(i,s,u,a,o,l,n);else{if(t.isNullOrUndefined(this.selectedColumn))return;if(l.type=this.selectedColumn.type,r.querySelector(".e-template")&&(o.value=""),"object"===this.selectedColumn.type&&"Default"===this.fieldMode)for(l.type=this.selectedColumn.columns[0].type;this.selectedColumn.columns;)this.createSubFields(i,o,l,n);else this.destroySubFields(i),this.changeOperator(i,s,u,a,o,l,n)}},c.prototype.destroySubFields=function(e){for(;e&&e.nextElementSibling.classList.contains("e-rule-sub-filter");)this.destroyControls(e),e.nextElementSibling.remove()},c.prototype.createSubFields=function(e,l,o,n){var r=!1,s=t.closest(e,".e-rule-field"),a=this.createElement("div",{attrs:{class:"e-rule-sub-filter",id:"subfilter"+this.subFilterCounter}});s.insertBefore(a,s.querySelector(".e-rule-operator"));var u=t.closest(a,".e-rule-container").id,p=this.createElement("input",{attrs:{type:"text",id:u+"_subfilterkey"+this.subFilterCounter}});a.appendChild(p);var c,h=this.element.className.indexOf("e-device")>-1?"250px":"200px";c={dataSource:this.selectedColumn.columns,fields:this.fields,placeholder:this.l10n.getConstant("SelectField"),popupHeight:this.selectedColumn.columns.length>5?h:"auto",change:this.changeField.bind(this),index:0,open:this.popupOpen.bind(this,!1)},this.fieldModel&&(c=d({},c,this.fieldModel));var m=new i.DropDownList(c);if(m.appendTo("#"+u+"_subfilterkey"+this.subFilterCounter),this.isImportRules||this.previousColumn&&this.previousColumn.ruleTemplate&&this.GetRootColumnName(l.field)===this.GetRootColumnName(this.previousColumn.field))for(var g=this.selectedColumn.columns,f=0;f<g.length;f++)if(l.field===g[f].field||l.field.indexOf(g[f].field+this.separator)>-1){m.value=g[f].field,this.selectedColumn=g[f],r=!0;break}this.subFilterCounter++,this.subFieldElem=p,n.itemData=n.itemData,!r&&this.selectedColumn.columns&&(!r&&this.isImportRules&&(m.value=null),this.selectedColumn=this.selectedColumn.columns[0]),this.previousColumn=this.selectedColumn,this.selectedColumn.columns||this.changeRuleValues(a,l,o,n)},c.prototype.operatorChangeSuccess=function(e,l,i,o,n){if(!e.cancel){var r=t.closest(n.element,".e-rule-operator"),s=r.nextElementSibling,a=t.getComponent(n.element,"dropdownlist"),u=o.operator?o.operator.toString().toLowerCase():"";i.operator=a.value.toString();var d=i.operator.toLowerCase();if(i.operator.toLowerCase().indexOf("between")>-1||i.operator.toLowerCase().indexOf("in")>-1&&i.operator.toLowerCase().indexOf("contains")<0?(l=r.previousElementSibling,i.type=o.type,(i.operator.toLowerCase().indexOf("in")<0||u.indexOf("in")<0)&&(o.value=[])):"object"==typeof o.value&&null!==o.value&&(o.value=o.value.length>0?o.value[0]:"number"===o.type?0:""),n.previousItemData){var p=n.previousItemData.value.toString().toLowerCase();(p.indexOf("between")>-1||(p.indexOf("in")>-1||p.indexOf("null")>-1||p.indexOf("empty")>-1)&&p.indexOf("contains")<0)&&(l=r.previousElementSibling,i.type=o.type)}if(u.indexOf("in")>-1&&u.indexOf("in")<5&&d.indexOf("in")>-1&&d.indexOf("in")<5&&(l=null),i.operator.indexOf("null")>-1||i.operator.indexOf("empty")>-1){var c=r.parentElement.querySelector(".e-rule-value"),h=c.querySelector(".e-tooltip.e-input-group");h&&t.getComponent(h,"tooltip").destroy(),t.removeClass([c],"e-show"),t.addClass([c],"e-hide")}s&&this.getColumn(o.field).template&&(l=r.previousElementSibling),0==s.children.length&&(l=r.previousElementSibling),this.changeRuleValues(l,o,i,n)}},c.prototype.changeRuleValues=function(e,l,o,n){var r,s,a,u=t.closest(n.element,".e-rule-operator");if(e)if(u=e.nextElementSibling,e.classList.contains("e-rule-sub-filter")&&(o.type=this.selectedColumn.type,u=u.classList.contains("e-rule-sub-filter")?u.nextElementSibling:u),t.addClass([u],"e-operator"),u.childElementCount){r=t.getComponent(u.querySelector(".e-dropdownlist"),"dropdownlist"),o.operator=r.value;var p=void 0;p="DropdownTree"===this.fieldMode?t.getComponent(e.querySelector(".e-dropdowntree"),"dropdowntree"):t.getComponent(e.querySelector(".e-dropdownlist"),"dropdownlist"),o.type="DropdownTree"===this.fieldMode?this.getColumn(p.value[0]).type:this.getColumn(p.value).type;var c=n.itemData;""!==r.value&&this.renderValues(u,c,n.previousItemData,!0,l,o,n.element)}else{var h=t.closest(u,".e-rule-container").id;a=this.createElement("input",{attrs:{type:"text",id:h+"_operatorkey"}}),u.appendChild(a),this.selectedColumn.operators?s=this.selectedColumn.operators:n.itemData&&(s=this.customOperators[this.selectedColumn.type+"Operator"]);var m=this.element.className.indexOf("e-device")>-1?"250px":"200px",g=s[0].value,f=0;this.autoSelectOperator||(g="",f=-1),(this.isImportRules||this.ruleIndex>-1||this.groupIndex>-1)&&(g=l&&l.operator?l.operator:g);var v=void 0;v={dataSource:s,fields:{text:"key",value:"value"},placeholder:this.l10n.getConstant("SelectOperator"),popupHeight:s.length>5?m:"auto",change:this.changeField.bind(this),index:f,value:g,open:this.popupOpen.bind(this,!1)},this.operatorModel&&(v=d({},v,this.operatorModel)),new i.DropDownList(v).appendTo("#"+h+"_operatorkey"),o.operator=l&&""!==l.operator&&!t.isNullOrUndefined(l.operator)?l.operator:s[0].value,this.isImportRules&&(o.type=this.selectedColumn.type,o.operator=l.operator),t.isNullOrUndefined(g)||""===g?this.autoSelectField&&this.autoSelectOperator&&this.renderValues(u,this.selectedColumn,n.previousItemData,!1,l,o,n.element):this.renderValues(u,this.selectedColumn,n.previousItemData,!1,l,o,n.element)}this.isImportRules||this.updateRules(n.element,n.item)},c.prototype.popupOpen=function(e,l){this.enableRtl&&t.addClass([l.popup.element],"e-rtl"),e&&(this.isFieldClose=!1)},c.prototype.destroyControls=function(e,l){for(var i=l?e:e.nextElementSibling,o=i.querySelectorAll("input.e-control"),n=i.querySelectorAll("div.e-control:not(.e-handle)"),r=this.columns,s=0,a=o.length;s<a;s++){if(o[s].classList.contains("e-textbox"))t.getComponent(o[s],"textbox").destroy(),t.detach(t.select("input#"+o[s].id,i));else if(o[s].classList.contains("e-dropdownlist"))this.allowValidation&&o[s].parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(o[s].parentElement,"tooltip").destroy(),t.getComponent(o[s],"dropdownlist").destroy();else if(o[s].classList.contains("e-radio"))t.getComponent(o[s],"radio").destroy();else if(o[s].classList.contains("e-numerictextbox"))t.getComponent(o[s],"numerictextbox").destroy(),t.detach(t.select("input#"+o[s].id,i));else if(o[s].classList.contains("e-datepicker"))t.getComponent(o[s],"datepicker").destroy();else if(o[s].classList.contains("e-multiselect"))t.getComponent(o[s],"multiselect").destroy();else if(o[s].className.indexOf("e-template")>-1)for(var u=o[s].className,d=0,p=r.length;d<p;d++)if(r[d].template&&u.indexOf(r[d].field)>-1){this.templateDestroy(r[d],o[s].id);break}document.getElementById(o[s].id)&&t.detach(o[s])}for(var s=0,a=n.length;s<a;s++){if(n[s].className.indexOf("e-template")>-1)for(var u=n[s].className,d=0,p=r.length;d<p;d++)if(r[d].template&&u.indexOf(r[d].field)>-1){this.templateDestroy(r[d],n[s].id);break}t.detach(n[s])}for(var c=i.querySelectorAll(".e-template:not(.e-control)"),s=0,a=c.length;s<a;s++)t.detach(c[s])},c.prototype.templateDestroy=function(e,l){var i;if("string"!=typeof e.template||void 0===e.template.destroy){var o=(i=e.template).destroy;if(i.destroy){var n=void 0;document.getElementById(l)&&(n=t.closest(document.getElementById(l),".e-rule-field").querySelectorAll(".e-template")),"string"==typeof o?(o=t.getValue(o,window))({field:e.field,elementId:l,elements:n}):i.destroy({field:e.field,elementId:l,elements:n})}}},c.prototype.getValues=function(e){var t,l={},i=[],o=[];this.separator.length>0&&(o=e.split(this.separator));var n=this.dataColl;if(this.dataColl[1])for(var r=0,s=n.length;r<s;r++){var a={};if(o.length>1)for(var u=n[r],d=void 0,p=0,c=o.length;p<c;p++)d=o[p],o.length===p+1?(t=u[""+d],Number(u[""+d])===u[""+d]&&u[""+d]%1!=0&&(t=u[""+d].toString())):u=u[""+d];else t=n[r][""+e],Number(n[r][""+e])===n[r][""+e]&&n[r][""+e]%1!=0&&(t=n[r][""+e].toString());t in l||(l[""+t]=1,o.length>1?this.createNestedObject(a,o,t):a[""+e]=t,i.push(a))}return i},c.prototype.createNestedObject=function(e,t,l){for(var i,o=t.length-1,n=0;n<o;++n)(i=t[n])in e||(e[""+i]={}),e=e[""+i];e[t[o]]=l},c.prototype.getDistinctValues=function(e,t){for(var l={},i=[],o=[],n="",r=t.indexOf(this.separator),s=this,a=0,u=e.length;a<u;a++)!function(a,u){0===r?n=e[a][""+t]:(o=t.split(s.separator)).forEach(function(t){n=n?n[""+t]:e[a][""+t]}),Number(e[a][""+t])===e[a][""+t]&&e[a][""+t]%1!=0&&(n=e[a][""+t].toString());var d={};n in l||(l[""+n]=1,0===r?d[""+t]=n:d[o[o.length-1]]=n,i.push(d))}(a);return i},c.prototype.renderMultiSelect=function(e,t,l,n,r){var s,a=!1,u=!1;this.isGetNestedData=!1,this.dataColl[1]&&Object.keys(this.dataColl[1]).indexOf(e.field)>-1&&(a=!0,s=this.getDistinctValues(this.dataColl,e.field)),a=!e.columns&&a,!this.dataColl.length&&r.length&&(u=!0);var p;p={dataSource:u?r:a?s:this.dataManager,query:new o.Query([e.field]),fields:{text:this.selectedRule.field,value:this.selectedRule.field},placeholder:this.l10n.getConstant("SelectValue"),value:n,mode:"CheckBox",width:"100%",change:this.changeValue.bind(this,l),close:this.closePopup.bind(this,l),actionBegin:this.multiSelectOpen.bind(this,t+"_valuekey"+l),open:this.popupOpen.bind(this,!1)},this.valueModel&&this.valueModel.multiSelectModel&&(p=d({},p,this.valueModel.multiSelectModel));var c=new i.MultiSelect(p);c.appendTo("#"+t+"_valuekey"+l),this.updateRules(c.element,n,0)},c.prototype.multiSelectOpen=function(e,l){if(this.dataSource instanceof o.DataManager){var i=document.getElementById(e),n=t.getComponent(t.closest(i,".e-rule-container").querySelector(".e-filter-input"),"dropdownlist");this.selectedColumn=n.getDataByValue(n.value);var r=this.selectedColumn.field,s=!1;this.dataColl[1]&&(Object.keys(this.dataColl[1]).indexOf(r)>-1&&(s=!0),0!==r.indexOf(this.separator)&&this.isGetNestedData&&(s=!0)),s||(l.cancel=!0,this.bindMultiSelectData(i,r))}},c.prototype.bindMultiSelectData=function(e,t){this.getMultiSelectData(e,t)},c.prototype.getMultiSelectData=function(e,l){var i,n=this,r=new o.Deferred,s=this.dataManager.executeQuery((new o.Query).select(l)),u=t.getComponent(e,"multiselect");u.hideSpinner(),this.createSpinner(t.closest(e,".e-multi-select-wrapper").parentElement),a.showSpinner(t.closest(e,".e-multi-select-wrapper").parentElement),s.then(function(o){i=o.actual&&o.actual.result?o.actual.result:o.result,n.dataColl=t.extend(n.dataColl,i,[],!0),u.dataSource=n.getDistinctValues(n.dataColl,l),n.isGetNestedData=!0,a.hideSpinner(t.closest(e,".e-multi-select-wrapper").parentElement)}).catch(function(e){r.reject(e)})},c.prototype.createSpinner=function(e){var l=this.createElement("span",{attrs:{class:"e-qb-spinner"}});e.appendChild(l),a.createSpinner({target:l,width:t.Browser.isDevice?"16px":"14px"})},c.prototype.closePopup=function(e,l){var i=document.getElementById(l.popup.element.id.replace("_popup",""));if(i){var o=t.getComponent(i,"multiselect").value;this.updateRules(i,o,e)}},c.prototype.processTemplate=function(e,l,i,o){var n=t.closest(e,".e-rule-container"),r=n.querySelectorAll(".e-template"),s=n.querySelector(".e-rule-filter .e-filter-input"),a="DropdownTree"===this.fieldMode?t.getComponent(s,"dropdowntree"):t.getComponent(n.querySelector(".e-rule-filter .e-filter-input"),"dropdownlist"),u="DropdownTree"===this.fieldMode?this.getColumn(a.value[0]):this.getColumn(a.value);if("string"==typeof l.template||void 0===l.template.write){var d={rule:i,ruleID:n.id,operator:o.operator,field:u.field,requestType:"value-template-create"};this.trigger("actionBegin",d)}else{var p=l.template;"string"==typeof p.write?t.getValue(p.write,window)({elements:r.length>1?r:r[0],values:i.value,operator:o.operator,field:u.field,dataSource:u.values}):"function"!=typeof l.template&&l.template.write({elements:r.length>1?r:r[0],values:i.value,operator:o.operator,field:u.field,dataSource:u.values})}},c.prototype.getItemData=function(e){var l=t.getComponent(document.getElementById(e+"_filterkey"),"dropdownlist");return"DropdownTree"===this.fieldMode&&(l=t.getComponent(document.getElementById(e+"_filterkey"),"dropdowntree")),"DropdownTree"===this.fieldMode?this.getColumn(l.value[0]):this.getColumn(l.value)},c.prototype.setDefaultValue=function(e,l,i){var o=this.getItemData(e);if(t.isNullOrUndefined(o.value))return i?l?[0,0]:0:l?[]:"";if(l){if(!(o.value instanceof Array))return[o.value]}else if(o.value instanceof Array)return o.value[0];return o.value},c.prototype.renderStringValue=function(e,t,l,i,o){var r,s,a=this.getItemData(e),u="string"==typeof a.template;if(s=this.isImportRules||this.ruleIndex>-1||this.groupIndex>-1||this.isPublic||u||""!=t.value?t.value:this.setDefaultValue(e,!1,!1),"in"!==l&&"notin"!==l||!this.dataColl.length&&!a.values){"in"!==l&&"notin"!==l||(s=(r=this.isImportRules||this.ruleIndex>-1||this.groupIndex>-1?t.value:this.setDefaultValue(e,!0,!1)).join(","));var p=void 0;p={placeholder:this.l10n.getConstant("SelectValue"),input:this.changeValue.bind(this,i)},this.valueModel&&this.valueModel.textBoxModel&&(p=d({},p,this.valueModel.textBoxModel));var c=new n.TextBox(p);c.appendTo("#"+e+"_valuekey"+i),c.value=s,c.dataBind()}else r=this.isImportRules||this.ruleIndex>-1||this.groupIndex>-1?t.value:this.setDefaultValue(e,!0,!1),this.renderMultiSelect(a,e,i,r,a.values),"Vertical"===this.displayMode||this.element.className.indexOf("e-device")>-1?o.style.width="100%":(o.style.width=null,o.style.minWidth="200px")},c.prototype.renderNumberValue=function(e,t,l,i,o,r,s){var a=this.getItemData(e),u="string"==typeof a.template,p=this.isImportRules||this.ruleIndex>-1||this.groupIndex>-1||this.isPublic||u||"number"==typeof t.value?t.value:this.setDefaultValue(e,!1,!0);if("in"!==l&&"notin"!==l||!this.dataColl.length&&!a.values)if("in"===l||"notin"===l){var c=(p=this.isImportRules||this.ruleIndex>-1||this.groupIndex>-1?t.value:this.setDefaultValue(e,!0,!1)).join(","),h=void 0;h={placeholder:this.l10n.getConstant("SelectValue"),input:this.changeValue.bind(this,i)},this.valueModel&&this.valueModel.textBoxModel&&(h=d({},h,this.valueModel.textBoxModel));var m=new n.TextBox(h);m.appendTo("#"+e+"_valuekey"+i),m.value=c,m.dataBind()}else{var g=(r=a).validation&&r.validation.min?r.validation.min:0,f=r.validation&&r.validation.max?r.validation.max:Number.MAX_VALUE,v=r.format?r.format:"n";s>1&&t&&(p=t.value[i]?t.value[i]:this.setDefaultValue(e,!0,!0));var y=void 0;y={value:p instanceof Array?p[i]:p,format:v,min:g,max:f,width:"100%",step:r.step?r.step:1,change:this.changeValue.bind(this,i)},this.valueModel&&this.valueModel.numericTextBoxModel&&(y=d({},y,this.valueModel.numericTextBoxModel));var b=new n.NumericTextBox(y);b.appendTo("#"+e+"_valuekey"+i),b.element.setAttribute("aria-label",r.label+" Value"),b.element.oninput=this.changeValue.bind(this,i)}else p=this.isImportRules||this.ruleIndex>-1||this.groupIndex>-1?t.value:this.setDefaultValue(e,!0,!1),this.renderMultiSelect(a,e,i,p,a.values),this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?o.style.width="100%":(o.style.minWidth="200px",o.style.width=null)},c.prototype.processValueString=function(e,t){var l=[],i=e.split(",");if("string"===t)return i;for(var o=0,n=i.length;o<n;o++)l.push(Number(i[o]));return l},c.prototype.parseDate=function(e,l){var i,o;if(l){var n=this.intl.getDateParser({skeleton:"full",type:"dateTime"});i=this.getFormat(l),o=n(e),t.isNullOrUndefined(o)&&(o=this.intl.parseDate(e,i))}else o=new Date(e);return o},c.prototype.renderControls=function(e,l,i,o,n){if(t.addClass([e.parentElement.querySelector(".e-rule-value")],"e-value"),t.removeClass([e.parentElement.querySelector(".e-rule-value")],"e-hide"),t.addClass([e.parentElement.querySelector(".e-rule-value")],"e-show"),l.template&&(l.template.create||n))this.processTemplate(e,l,i,o);else{var s;s="boolean"===o.type?this.selectedColumn.values?this.selectedColumn.values.length:2:o.operator&&o.operator.toString().toLowerCase().indexOf("between")>-1?2:1;var a=t.closest(e,".e-rule-container").id,u=void 0,p=o.operator.toString();if(e.className.indexOf("e-rule-operator")>-1||e.className.indexOf("e-rule-filter")>-1){u=e.parentElement.querySelector(".e-rule-value"),this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?u.style.width="100%":"in"!==p&&"notin"!==p?t.addClass([u],"e-custom-value"):t.removeClass([u],"e-custom-value");for(var c=0;c<s;c++)switch(o.type){case"string":this.renderStringValue(a,i,p,c,u);break;case"number":this.renderNumberValue(a,i,p,c,u,l,s);break;case"boolean":this.processBoolValues(l,i,a,c);break;case"date":var h=new Date,m=void 0,g=void 0,f=l.format,v=void 0,y=void 0,b=this.l10n.getConstant("SelectValue"),C="string"==typeof l.template;if(i.value&&!t.isNullOrUndefined(f)&&(m=s>1?i.value[c]:i.value,h=this.parseDate(m,f)||new Date),l.field||l.key||!l.value||(h=l.value instanceof Date?l.value:this.parseDate(l.value,l.format)),!l.format&&i&&""!==i.field&&(f=(g=this.getColumn(i.field)).format),(this.isImportRules||this.isPublic||C)&&i&&(f=(g=this.getColumn(i.field)).format,i.value?(m=s>1?i.value[c]:i.value,h=this.parseDate(m,g.format)):h=i.value),f){var S=this.getFormat(f);S.skeleton?(y={locale:this.getLocale(),value:h,placeholder:b,format:S,change:this.changeValue.bind(this,c)},this.valueModel&&this.valueModel.datePickerModel&&(y=d({},y,this.valueModel.datePickerModel)),v=new r.DatePicker(y)):(y={value:h,locale:this.getLocale(),placeholder:b,format:S.format,change:this.changeValue.bind(this,c)},this.valueModel&&this.valueModel.datePickerModel&&(y=d({},y,this.valueModel.datePickerModel)),v=new r.DatePicker(y))}else y={locale:this.getLocale(),value:h,placeholder:b,change:this.changeValue.bind(this,c)},this.valueModel&&this.valueModel.datePickerModel&&(y=d({},y,this.valueModel.datePickerModel)),v=new r.DatePicker(y);if(v.appendTo("#"+a+"_valuekey"+c),!i.value){var x=document.getElementById(a+"_valuekey"+c);this.updateRules(x,h,null,this.isNotValueChange),this.isNotValueChange=!1}}}}},c.prototype.processBoolValues=function(e,i,o,n){var r,s,a=!1;t.isNullOrUndefined(i.type)&&e&&(i.type=e.type);var u;if(e.values){p=e.values;"boolean"!==i.type||t.isNullOrUndefined(i.value)?e.value?a=p[n].toLowerCase()===e.value.toString().toLowerCase():0===n&&(a=!0):a=p[n].toLowerCase()===i.value.toString().toLowerCase(),s=r=u=p[n]}else{var p=[!0,!1];"boolean"!==i.type||t.isNullOrUndefined(i.value)?e.value?a=p[n].toString().toLowerCase()===e.value.toString().toLowerCase():0===n&&(a="boolean"!=typeof i.value||!!i.value):a=p[n].toString().toLowerCase()===i.value.toString().toLowerCase(),"boolean"==typeof i.value&&1===n&&(a=!i.value),r=p[n].toString(),s=p[n],u=this.l10n.getConstant(["True","False"][n])}var c;c={label:u,name:o+"default",checked:a,value:r,change:this.changeValue.bind(this,n)},this.valueModel&&this.valueModel.radioButtonModel&&(c=d({},c,this.valueModel.radioButtonModel));var h=new l.RadioButton(c);h.appendTo("#"+o+"_valuekey"+n),a&&this.updateRules(h.element,s,0,!0)},c.prototype.getOperatorIndex=function(e,t){var l,i=e.dataSource.length;for(l=0;l<i;l++)if(t.operator===e.dataSource[l].value)return l;return 0},c.prototype.getPreviousItemData=function(e,t){return this.isFieldClose&&e&&(e=this.getColumn(e.value)),t&&t.template&&e&&Object.keys(e).length<4&&(e.template=t.template),e},c.prototype.renderValues=function(e,l,i,o,n,r,s){var a=e.previousElementSibling.getElementsByTagName("input")[0],u="DropdownTree"===this.fieldMode?t.getComponent(a,"dropdowntree"):t.getComponent(a,"dropdownlist"),d="DropdownTree"===this.fieldMode?this.getColumn(u.value[0]):this.getColumn(u.value);this.selectedRule=d;var p=t.getComponent(e.querySelector("input"),"dropdownlist");o&&(l=s.id.indexOf("operator")>-1?l:this.selectedRule).operators&&(p.value=null,p.dataBind(),p.dataSource=l.operators,p.index=this.getOperatorIndex(p,n),p.value=r.operator=p.dataSource[p.index].value,this.autoSelectOperator?p.dataBind():(p.index=-1,r.operator=p.value=""));var c=r.operator.toString(),h=!1;if(c.indexOf("null")>-1||c.indexOf("isempty")>-1||c.indexOf("isnotempty")>-1)(f=e.parentElement.querySelector(".e-rule-value"))&&(t.removeClass([f],"e-show"),t.addClass([f],"e-hide"));else{var m=t.closest(e,".e-rule-container").id;if(i=this.getPreviousItemData(i,d),i&&void 0===i.template?i.columns&&(i=this.getColumn(n.field)):"DropdownTree"===this.fieldMode&&void 0===i&&(i=this.getColumn(n.field)),i&&i.template){this.templateDestroy(i,m+"_valuekey0");var g=t.select("#"+m+"_valuekey0",e.nextElementSibling);g&&!g.classList.contains("e-control")&&t.detach(t.select("#"+m+"_valuekey0",e.nextElementSibling)),"string"!=typeof i.template&&void 0!==i.template.create||(e.nextElementSibling.classList.contains("e-template-value")&&this.clearQBTemplate([m]),e.nextElementSibling.innerHTML="")}if(o&&(this.validateValue(n,t.closest(e,".e-rule-container")),this.destroyControls(e)),this.isImportRules||p&&""!==p.value){if(d&&(l.template=d.template),l.template&&(t.addClass([e.nextElementSibling],"e-template-value"),l.template=d.template,h=this.setColumnTemplate(l,m,d.field,l.value||c,e,n)),h){var f=e.parentElement.querySelector(".e-rule-value");this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?f.style.width="100%":f.style.width="200px"}else{t.removeClass([e.nextElementSibling],"e-template-value");var v=1;v="boolean"===r.type?this.selectedColumn.values?this.selectedColumn.values.length:2:c&&c.toLowerCase().indexOf("between")>-1?2:1;for(var y=0;y<v;y++){var b=this.createElement("input",{attrs:{type:"text",id:m+"_valuekey"+y}});e.nextElementSibling.appendChild(b)}}this.renderControls(e,l,n,r,h)}}},c.prototype.setColumnTemplate=function(e,l,i,o,n,r){var s,a=this,u=!0;if(e.template){if("string"==typeof e.template||void 0===e.template.create)return s={requestType:"value-template-initialize",ruleID:l,field:i,operator:o,rule:r,renderTemplate:!0},this.trigger("actionBegin",s,function(t){u=a.actionBeginSuccessCallBack(t,e,l,i,n)}),u;var d=void 0,p=e.template;if((d="string"==typeof p.create?t.getValue(p.create,window)({field:i,operator:o}):p.create({field:i,operator:o}))instanceof Element)d.id=l+"_valuekey0",t.addClass([d],"e-template"),n.nextElementSibling.appendChild(d),i.indexOf(" ")<0&&t.addClass([d],"e-"+i);else if(d instanceof Array){t.addClass(d,"e-template");for(var c=0,h=d.length;c<h;c++)d[c].id=l+"_valuekey"+c,n.nextElementSibling.appendChild(d[c])}return t.addClass([n.nextElementSibling],"e-template-value"),!0}return!0},c.prototype.actionBeginSuccessCallBack=function(e,l,i,o,n){if(e.renderTemplate){var r=void 0;this.columnTemplateFn=this.templateParser((l.template,l.template));var s=this.element.id+o;if(this.isReact)r=this.columnTemplateFn(e,this,i,s)[0],n.nextElementSibling.appendChild(r);else if(this.isAngular){var a=this.columnTemplateFn(e,this,i,s);r=3===a[0].nodeType?a[1]:a[0],n.nextElementSibling.appendChild(r)}else this.isVue3?(r=this.columnTemplateFn(e,this,"Template",s),t.append(r,n.nextElementSibling)):(r=this.columnTemplateFn(e,this,"Template",s)[0],n.nextElementSibling.appendChild(r));return t.addClass([n.nextElementSibling],"e-template-value"),this.renderReactTemplates(),!0}return!1},c.prototype.updateValues=function(e,l){var i=1;e.className.indexOf("e-template")>-1&&(i=3);var o=e.className.split(" e-")[i],n=parseInt(e.id.slice(-1),2);switch(o){case"checkbox":var r=t.getComponent(e,o).value;l.value=""!==r?r:void 0;break;case"textbox":case"dropdownlist":l.value=t.getComponent(e,o).value;break;case"radio":var s=t.getComponent(e,o);s.checked&&("boolean"==typeof l.value?l.value="true"===s.value:this.getColumn(l.field).values?l.value=s.value:l.value="true"===s.value),s.refresh();break;case"numerictextbox":l.operator.indexOf("between")>-1?("string"==typeof l.value&&(l.value=[]),l.value[n]=t.getComponent(e,o).value):l.value=t.getComponent(e,o).value;break;case"datepicker":var a=this.getColumn(l.field),u=this.getFormat(a.format),d=t.getComponent(e,o).value;l.operator.indexOf("between")>-1?("string"==typeof l.value&&(l.value=[]),l.value[n]=this.intl.formatDate(d,u)):t.isNullOrUndefined(u.format)&&d?l.value=this.intl.formatDate(d):l.value=d?this.intl.formatDate(d,u):d;break;case"multiselect":l.value=t.getComponent(e,o).value}},c.prototype.updateRules=function(e,l,i,o){for(var n,r,s=t.closest(e,".e-group-container"),a=this.getParentGroup(s),u=t.closest(e,".e-rule-container"),d=0,p=s.id.replace(this.element.id+"_",""),c=this.getValidRules(this.rule);u&&null!==u.previousElementSibling;)u=u.previousElementSibling,d++;var h=a.rules[d].operator?a.rules[d].operator.toString():"",m=(u=t.closest(e,".e-rule-container")).id.replace(this.element.id+"_","");if(t.closest(e,".e-rule-filter")||t.closest(e,".e-rule-sub-filter")){this.subFieldElem&&(e=this.subFieldElem),n="DropdownTree"===this.fieldMode?t.getComponent(e,"dropdowntree"):t.getComponent(e,"dropdownlist");var g="DropdownTree"===this.fieldMode?this.getColumn(n.value[0]):this.getColumn(n.value);!this.isImportRules&&a.rules[d].field&&a.rules[d].field.toLowerCase()!==g.field.toLowerCase()&&(!u.querySelectorAll(".e-template")&&!(h.indexOf("null")>-1)||h.indexOf("empty")>-1)&&(a.rules[d].value=""),this.selectedColumn=this.getColumn(this.selectedColumn.field),a.rules[d].field=this.selectedColumn.field,a.rules[d].type=this.selectedColumn.type,a.rules[d].label=this.selectedColumn.label;var f=t.closest(e,".e-rule-filter"),v=(f=f||t.closest(e,".e-rule-sub-filter")).nextElementSibling.querySelector("input.e-control");v=v||f.nextElementSibling.nextElementSibling.querySelector("input.e-control"),h=t.getComponent(v,"dropdownlist").value.toString(),a.rules[d].operator=h;var y=f.nextElementSibling.nextElementSibling,b=y.querySelectorAll("input.e-control");b.length<1&&(b=y.querySelectorAll("div.e-control")),b.length<1&&(b=y.querySelectorAll(".e-template")),r={groupID:p,ruleID:m,value:a.rules[d].field,type:"field"};for(var C=0;C<b.length;C++)h.indexOf("null")>-1||h.indexOf("empty")>-1?a.rules[d].value=null:this.updateValues(b[C],a.rules[d]);this.isImportRules||this.trigger("change",r),this.allowValidation&&a.rules[d].field&&e.parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(e.parentElement,"tooltip").destroy(),this.filterRules(c,this.getValidRules(this.rule),"field")}else if(t.closest(e,".e-rule-operator")){n=t.getComponent(e,"dropdownlist"),a.rules[d].operator=n.value.toString();var S=u.querySelectorAll(".e-rule-value input.e-control");r={groupID:p,ruleID:m,value:n.value,type:"operator"},this.allowValidation&&a.rules[d].operator&&e.parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(e.parentElement,"tooltip").destroy(),S.length>1&&!(S[0].className.indexOf("e-template")>-1)&&(a.rules[d].value=[]);for(var x=0;x<S.length;x++)a.rules[d].operator.indexOf("null")>-1||a.rules[d].operator.indexOf("empty")>-1?a.rules[d].value=null:S[x].classList.contains("e-template")||this.updateValues(S[x],a.rules[d]);this.isImportRules||this.trigger("change",r),this.filterRules(c,this.getValidRules(this.rule),"operator")}else t.closest(e,".e-rule-value")&&(this.ruleValueUpdate(e,l,a,d,s,u,i),o||this.filterRules(c,this.getValidRules(this.rule),"value"))},c.prototype.filterRules=function(e,t,l){JSON.stringify({condition:e.condition,not:e.not,rule:e.rules})!==JSON.stringify({condition:t.condition,not:t.not,rule:t.rules})&&(this.isImportRules||this.trigger("ruleChange",{previousRule:e,rule:t,type:l}))},c.prototype.ruleValueUpdate=function(e,t,l,i,o,n,r){var s,a,u=["in","between","notin","notbetween"];if(l.rules[i].operator&&(a=l.rules[i].operator.toString().toLowerCase()),null!==t){if(e.className.indexOf("e-multiselect")>-1&&"number"===l.rules[i].type&&!this.isNotified){for(var d=[],p=t,c=0,h=p.length;c<h;c++)"string"==typeof p[c]&&d.push(parseFloat(p[c]));d.length&&(t=d)}if(this.isNotified)l.rules[i].value=t,s={groupID:o.id,ruleID:n.id,value:l.rules[i].value,type:"value"},this.isImportRules||this.trigger("change",s);else if(e.className.indexOf("e-spin")>-1||e.className.indexOf("e-numeric")>-1)u.indexOf(a)>-1?l.rules[i].value[r]=t:l.rules[i].value=t;else if(e.className.indexOf("e-radio")>-1)l.rules[i].value=t;else if(e.className.indexOf("e-multiselect")>-1)l.rules[i].value=t;else if(e.className.indexOf("e-textbox")>-1)"in"===a||"notin"===a?(l.rules[i].type,l.rules[i].value=this.processValueString(t,l.rules[i].type)):l.rules[i].value=t;else if(e.className.indexOf("e-datepicker")>-1){var m=this.getFormat(this.getColumn(this.selectedColumn.field).format);m.type&&(u.indexOf(a)>-1?("string"==typeof l.rules[i].value&&(l.rules[i].value=[]),l.rules[i].value[r]=this.intl.formatDate(t,m)):l.rules[i].value=this.intl.formatDate(t,m))}this.validateValue(l,n,i)}else e.className.indexOf("e-datepicker")>-1&&u.indexOf(a)>-1?("string"==typeof l.rules[i].value&&(l.rules[i].value=[]),l.rules[i].value[r]=t):l.rules[i].value=t},c.prototype.validateValue=function(e,l,i){t.isNullOrUndefined(i)||(e=e.rules[i]);var o="object"==typeof e.value;if(this.allowValidation&&(t.isNullOrUndefined(i)||(o?e.value.length>0:e.value))){var n=l.querySelectorAll(".e-rule-value .e-control");n.length>0&&(n[0].className.indexOf("e-tooltip")>-1?t.getComponent(n[0],"tooltip").destroy():n[0].parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(n[0].parentElement,"tooltip").destroy(),n[1]&&n[1].parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(n[1].parentElement,"tooltip").destroy())}},c.prototype.getFormat=function(e){var t;return e?"string"==typeof e?(t={type:"dateTime"},"short"===e||"yMd"===e?(t.type="date",t.skeleton=e):t.format=e):t={type:"dateTime",skeleton:e.skeleton}:t={type:"date",skeleton:"yMd"},t},c.prototype.findGroupByIdx=function(e,t,l){var i=t.rules,o=[];if(!l){for(var n=0,r=i.length;n<r;n++)(t=i[n]).rules&&o.push(t);return o[e]}return t},c.prototype.destroy=function(){if(this.isDestroy=!0,this.element){var l,i,o,n;e.prototype.destroy.call(this);var r;for(o=(l=this.element.querySelectorAll(".e-addrulegroup")).length,i=0;i<o;i++)t.getComponent(l[i],"dropdown-btn").destroy(),t.detach(l[i]);for(n=this.element.querySelectorAll(".e-rule-filter .e-control.e-tooltip"),i=0;i<n.length;i++)t.getComponent(n[i],"tooltip").destroy();for(o=(l=this.element.querySelectorAll(".e-rule-filter .e-control:not(.e-tooltip)")).length,i=0;i<o;i++)t.getComponent(l[i],"dropdownlist")?t.getComponent(l[i],"dropdownlist").destroy():t.getComponent(l[i],"dropdowntree").destroy(),t.detach(l[i]);for(n=this.element.querySelectorAll(".e-rule-operator .e-control.e-tooltip"),i=0;i<n.length;i++)t.getComponent(n[i],"tooltip").destroy();for(o=(l=this.element.querySelectorAll(".e-rule-operator .e-control:not(.e-tooltip)")).length,i=0;i<o;i++)t.getComponent(l[i],"dropdownlist")&&(t.getComponent(l[i],"dropdownlist").destroy(),t.detach(l[i]));for(n=this.element.querySelectorAll(".e-rule-value .e-control.e-tooltip"),i=0;i<n.length;i++)t.getComponent(n[i],"tooltip").destroy();if(this.isImportRules=!1,this.unWireEvents(),this.levelColl[this.element.id+"_group0"]=[0],this.element.innerHTML="",this.portals&&this.portals.length&&this.clearQBTemplate(),r=document.querySelectorAll(".qb-dropdownlist.e-popup"))for(i=0;i<r.length;i++)r[i].remove();t.classList(this.element,[],["e-rtl","e-responsive","e-device"]),this.isDestroy=!1}},c.prototype.addRules=function(e,t){t=this.element.id+"_"+t,this.isPublic=!0;for(var l=0,i=e.length;l<i;l++)this.addRuleElement(document.getElementById(t),e[l]);this.isPublic=!1},c.prototype.addGroups=function(e,t){if(this.isAddSuccess||this.element.querySelectorAll(".e-group-container").length<=this.maxGroupCount){t=this.element.id+"_"+t;var l=document.getElementById(t),i=this.getParentGroup(l);if(e.length){this.isPublic=!0;for(var o=0,n=e.length;o<n;o++)this.updatedRule={isLocked:e[o].isLocked,condition:e[o].condition,not:e[o].not},this.importRules(e[o],l,!1,e[o].not);this.isPublic=!1}else{var r="and",s=!1,a=!1;this.updatedRule&&(r=this.updatedRule.condition,s=this.updatedRule.not,a=this.updatedRule.isLocked),this.groupIndex<0?this.enableNotCondition?i.rules.push({condition:r,not:s,rules:[]}):i.rules.push({condition:r,rules:[]}):this.enableNotCondition?i.rules.splice(this.groupIndex+1,0,{condition:r,not:s,rules:[],isLocked:a}):i.rules.splice(this.groupIndex+1,0,{condition:r,rules:[],isLocked:a})}this.headerTemplate||this.disableRuleCondition(l,i)}},c.prototype.initWrapper=function(){if(this.isInitialLoad=!0,this.cssClass&&t.addClass([this.element],this.cssClass.replace(/\s+/g," ").trim().split(" ")),this.enableRtl&&t.addClass([this.element],"e-rtl"),this.width&&(this.element.style.width=this.width),this.height&&(this.element.style.height=this.height),this.rule.rules.length?this.isImportRules=!0:this.addGroupElement(!1,this.element),t.Browser.isDevice||"Vertical"===this.displayMode?(t.Browser.isDevice&&(this.element.style.width="100%",this.element.classList.add("e-device")),t.removeClass(this.element.querySelectorAll(".e-rule-container"),"e-horizontal-mode"),t.addClass(this.element.querySelectorAll(".e-rule-container"),"e-vertical-mode"),this.displayMode="Vertical"):this.displayMode="Horizontal",this.summaryView)this.isImportRules?this.renderSummary():this.renderSummaryCollapse();else{if(this.columns.length&&this.isImportRules){this.addGroupElement(!1,this.element,this.rule.condition,!1,this.rule.not,!1,this.rule);var e=t.extend({},this.rule,{},!0);this.isRefreshed=!0,this.setGroupRules(e),this.isRefreshed=!1}else this.columns.length&&this.addRuleElement(this.element.querySelector(".e-group-container"),{});this.notGroupRtl(),this.readonly&&this.enableReadonly();for(var l=this.element.querySelectorAll("label.e-btn"),i=void 0,o=0;o<l.length;o++)i=l.item(o),t.rippleEffect(i,{selector:".e-btn"})}},c.prototype.renderSummary=function(){var e=this.createElement("div",{attrs:{class:"e-summary-content",id:this.element.id+"_summary_content"}}),t=this.createElement("textarea",{attrs:{class:"e-summary-text",readonly:"true"},styles:"max-height:500px"}),l=this.createElement("button",{attrs:{type:"button",class:"e-edit-rule e-css e-btn e-small e-flat e-primary"}}),i=this.createElement("div",{attrs:{class:"e-summary-btndiv"}});e.appendChild(t),t.textContent=this.getSqlFromRules(this.rule),l.textContent=this.l10n.getConstant("Edit"),i.appendChild(l),e.appendChild(i),this.element.appendChild(e)},c.prototype.renderSummaryCollapse=function(){var e=this.createElement("div",{attrs:{class:"e-collapse-rule e-icons",title:this.l10n.getConstant("SummaryViewTitle")}});this.element.querySelector(".e-group-header").appendChild(e)},c.prototype.columnSort=function(){"descending"===this.sortDirection.toLowerCase()?this.columns=new o.DataManager(this.columns).executeLocal((new o.Query).sortByDesc("field")):"ascending"===this.sortDirection.toLowerCase()&&(this.columns=new o.DataManager(this.columns).executeLocal((new o.Query).sortBy("field")))},c.prototype.onChangeNotGroup=function(){if(this.element.innerHTML="",this.groupIdCounter=0,!this.headerTemplate)if(this.enableNotCondition){if(this.enableNotCondition){var e=this.createElement("button",{attrs:{type:"button",class:"e-qb-toggle"}});this.groupElem.querySelector(".e-btn-group").insertBefore(e,this.groupElem.querySelector(".e-btngroup-and"))}}else this.groupElem.querySelector(".e-qb-toggle").remove();this.setProperties({rule:this.checkNotGroup(this.rule)},!0),this.initWrapper()},c.prototype.notGroupRtl=function(){this.enableRtl?t.addClass(this.element.querySelectorAll(".e-btn-group"),"e-rtl"):t.removeClass(this.element.querySelectorAll(".e-btn-group"),"e-rtl")},c.prototype.checkNotGroup=function(e){var l;if(e.rules)for(var i=0;i<e.rules.length;i++)l=e.rules[i],l=this.checkNotGroup(l),e.rules[i]=l;return t.isNullOrUndefined(e.not)?this.enableNotCondition&&!t.isNullOrUndefined(e.condition)&&(e.not=!1):(this.enableNotCondition&&(e.not=!1),delete e.not),e},c.prototype.onPropertyChanged=function(e,l){for(var i=0,o=Object.keys(e);i<o.length;i++)switch(o[i]){case"summaryView":var n=this.element.querySelector(".e-group-container"),r=this.element.querySelector(".e-summary-content");e.summaryView?(n.style.display="none",this.element.querySelectorAll(".e-summary-content").length<1?(this.renderSummary(),r=this.element.querySelector(".e-summary-content")):this.element.querySelector(".e-summary-text").textContent=this.getSqlFromRules(this.rule),r.style.display="block"):(n.querySelectorAll(".e-collapse-rule").length>-1&&this.renderSummaryCollapse(),n.style.display="block",r.style.display="none");break;case"displayMode":this.refresh();break;case"showButtons":t.isNullOrUndefined(e.showButtons.lockGroup)||(e.showButtons.lockGroup?t.removeClass(this.element.querySelectorAll(".e-lock-grp-btn"),"e-button-hide"):t.addClass(this.element.querySelectorAll(".e-lock-grp-btn"),"e-button-hide")),t.isNullOrUndefined(e.showButtons.lockRule)||(e.showButtons.lockRule?t.removeClass(this.element.querySelectorAll(".e-lock-rule-btn"),"e-button-hide"):t.addClass(this.element.querySelectorAll(".e-lock-rule-btn"),"e-button-hide")),t.isNullOrUndefined(e.showButtons.cloneGroup)||(e.showButtons.cloneGroup?t.removeClass(this.element.querySelectorAll(".e-clone-grp-btn"),"e-button-hide"):t.addClass(this.element.querySelectorAll(".e-clone-grp-btn"),"e-button-hide")),t.isNullOrUndefined(e.showButtons.cloneRule)||(e.showButtons.cloneRule?t.removeClass(this.element.querySelectorAll(".e-clone-rule-btn"),"e-button-hide"):t.addClass(this.element.querySelectorAll(".e-clone-rule-btn"),"e-button-hide")),t.isNullOrUndefined(e.showButtons.ruleDelete)||(e.showButtons.ruleDelete?t.removeClass(this.element.querySelectorAll(".e-rule-delete"),"e-button-hide"):t.addClass(this.element.querySelectorAll(".e-rule-delete"),"e-button-hide")),t.isNullOrUndefined(e.showButtons.groupDelete)||(e.showButtons.groupDelete?t.removeClass(this.element.querySelectorAll(".e-deletegroup"),"e-button-hide"):t.addClass(this.element.querySelectorAll(".e-deletegroup"),"e-button-hide"));break;case"cssClass":l.cssClass&&t.removeClass([this.element],l.cssClass.split(" ")),e.cssClass&&t.addClass([this.element],e.cssClass.replace(/\s+/g," ").trim().split(" "));break;case"enableRtl":e.enableRtl?(t.addClass([this.element],"e-rtl"),this.notGroupRtl()):(t.removeClass([this.element],"e-rtl"),this.notGroupRtl());break;case"enablePersistence":this.enablePersistence=e.enablePersistence;break;case"dataSource":this.dataSource=e.dataSource,this.refresh();break;case"columns":this.columns=e.columns,this.columnSort(),this.updateSubFieldsFromColumns(this.columns);break;case"sortDirection":this.sortDirection=e.sortDirection,this.columnSort();break;case"maxGroupCount":this.maxGroupCount=e.maxGroupCount;break;case"height":this.height=e.height,this.element.style.height=this.height;break;case"rule":0!==this.rule.rules.length||t.isNullOrUndefined(this.rule)||this.reset(),this.setProperties({rule:e.rule},!0),e.rule=this.getRuleCollection(this.rule,!1),this.setRules(this.rule);break;case"width":this.width=e.width,this.element.style.width=this.width;break;case"locale":this.locale=e.locale,this.intl=new t.Internationalization(this.locale),this.isLocale=!0,this.refresh(),this.isLocale=!1;break;case"enableNotCondition":this.onChangeNotGroup();break;case"readonly":this.isReadonly=e.readonly,this.enableReadonly()}},c.prototype.preRender=function(){this.element.id=this.element.id||t.getUniqueID("ej2-querybuilder"),this.defaultLocale={StartsWith:"Starts With",DoesNotStartWith:"Does Not Start With",EndsWith:"Ends With",DoesNotEndWith:"Does Not End With",Contains:"Contains",DoesNotContain:"Does Not Contain",NotLike:"Not Like",Like:"Like",Equal:"Equal",NotEqual:"Not Equal",LessThan:"Less Than",LessThanOrEqual:"Less Than Or Equal",GreaterThan:"Greater Than",GreaterThanOrEqual:"Greater Than Or Equal",Between:"Between",NotBetween:"Not Between",In:"In",NotIn:"Not In",Remove:"REMOVE",SelectField:"Select a field",SelectOperator:"Select operator",DeleteRule:"Remove this condition",DeleteGroup:"Delete group",AddGroup:"Add Group",AddCondition:"Add Condition",Edit:"EDIT",ValidationMessage:"This field is required",SummaryViewTitle:"Summary View",OtherFields:"Other Fields",AND:"AND",OR:"OR",NOT:"NOT",SelectValue:"Enter Value",IsEmpty:"Is Empty",IsNotEmpty:"Is Not Empty",IsNull:"Is Null",IsNotNull:"Is Not Null",True:"true",False:"false",AddButton:"Add Group/Condition",CloneGroup:"Clone Group",LockGroup:"Lock Group",CloneRule:"Clone Rule",LockRule:"Lock Rule",UnlockRule:"Unlock Rule",UnlockGroup:"Unlock Group"},this.l10n=new t.L10n("querybuilder",this.defaultLocale,this.locale),this.intl=new t.Internationalization(this.locale),this.groupIdCounter=0,this.subFilterCounter=0,this.ruleIdCounter=0,this.btnGroupId=0,this.isImportRules=!1,this.parser=[],this.customOperators={stringOperator:[{value:"startswith",key:this.l10n.getConstant("StartsWith")},{value:"notstartswith",key:this.l10n.getConstant("DoesNotStartWith")},{value:"endswith",key:this.l10n.getConstant("EndsWith")},{value:"notendswith",key:this.l10n.getConstant("DoesNotEndWith")},{value:"contains",key:this.l10n.getConstant("Contains")},{value:"notcontains",key:this.l10n.getConstant("DoesNotContain")},{value:"equal",key:this.l10n.getConstant("Equal")},{value:"notequal",key:this.l10n.getConstant("NotEqual")},{value:"in",key:this.l10n.getConstant("In")},{value:"notin",key:this.l10n.getConstant("NotIn")},{value:"isempty",key:this.l10n.getConstant("IsEmpty")},{value:"isnotempty",key:this.l10n.getConstant("IsNotEmpty")}],dateOperator:[{value:"equal",key:this.l10n.getConstant("Equal")},{value:"greaterthan",key:this.l10n.getConstant("GreaterThan")},{value:"greaterthanorequal",key:this.l10n.getConstant("GreaterThanOrEqual")},{value:"lessthan",key:this.l10n.getConstant("LessThan")},{value:"lessthanorequal",key:this.l10n.getConstant("LessThanOrEqual")},{value:"notequal",key:this.l10n.getConstant("NotEqual")},{value:"between",key:this.l10n.getConstant("Between")},{value:"notbetween",key:this.l10n.getConstant("NotBetween")}],booleanOperator:[{value:"equal",key:this.l10n.getConstant("Equal")},{value:"notequal",key:this.l10n.getConstant("NotEqual")}],numberOperator:[{value:"equal",key:this.l10n.getConstant("Equal")},{value:"greaterthanorequal",key:this.l10n.getConstant("GreaterThanOrEqual")},{value:"greaterthan",key:this.l10n.getConstant("GreaterThan")},{value:"between",key:this.l10n.getConstant("Between")},{value:"lessthan",key:this.l10n.getConstant("LessThan")},{value:"notbetween",key:this.l10n.getConstant("NotBetween")},{value:"lessthanorequal",key:this.l10n.getConstant("LessThanOrEqual")},{value:"notequal",key:this.l10n.getConstant("NotEqual")},{value:"in",key:this.l10n.getConstant("In")},{value:"notin",key:this.l10n.getConstant("NotIn")}]},this.operators={equal:"=",notequal:"!=",greaterthan:">",greaterthanorequal:">=",lessthan:"<",in:"IN",notin:"NOT IN",lessthanorequal:"<=",startswith:"LIKE",endswith:"LIKE",between:"BETWEEN",notbetween:"NOT BETWEEN",contains:"LIKE",isnull:"IS NULL",isnotnull:"IS NOT NULL",isempty:"IS EMPTY",isnotempty:"IS NOT EMPTY",notstartswith:"NOT LIKE",notendswith:"NOT LIKE",notcontains:"NOT LIKE"},this.sqlOperators={equal:"=",notequal:"!=",greaterthan:">",greaterthanorequal:">=",lessthan:"<",in:this.l10n.getConstant("In").toUpperCase(),notin:this.l10n.getConstant("NotIn").toUpperCase(),lessthanorequal:"<=",startswith:this.l10n.getConstant("Like").toUpperCase(),endswith:this.l10n.getConstant("Like").toUpperCase(),between:this.l10n.getConstant("Between").toUpperCase(),notbetween:this.l10n.getConstant("NotBetween").toUpperCase(),contains:this.l10n.getConstant("Like").toUpperCase(),isnull:this.l10n.getConstant("IsNull").toUpperCase(),isnotnull:this.l10n.getConstant("IsNotNull").toUpperCase(),isempty:this.l10n.getConstant("IsEmpty").toUpperCase(),isnotempty:this.l10n.getConstant("IsNotEmpty").toUpperCase(),notstartswith:this.l10n.getConstant("NotLike").toUpperCase(),notendswith:this.l10n.getConstant("NotLike").toUpperCase(),notcontains:this.l10n.getConstant("NotLike").toUpperCase()},this.fields||(this.fields={text:"label",value:"field"})},c.prototype.render=function(){this.levelColl={},this.items=[{text:this.l10n.getConstant("AddGroup"),iconCss:"e-icons e-add-icon e-addgroup"},{text:this.l10n.getConstant("AddCondition"),iconCss:"e-icons e-add-icon e-addrule"}],this.ruleElem=this.ruleTemplate(),this.groupElem=this.groupTemplate();var e=[{value:"isnull",key:this.l10n.getConstant("IsNull")},{value:"isnotnull",key:this.l10n.getConstant("IsNotNull")}],t=[{value:"isnull",key:this.l10n.getConstant("IsNull")},{value:"isnotnull",key:this.l10n.getConstant("IsNotNull")}];this.customOperators.stringOperator=this.customOperators.stringOperator.concat(e),this.customOperators.numberOperator=this.customOperators.numberOperator.concat(t),this.dataSource instanceof o.DataManager?(this.dataManager=this.dataSource,this.executeDataManager((new o.Query).take(1))):(this.dataManager=new o.DataManager(this.dataSource),this.dataColl=this.dataManager.executeLocal(new o.Query),this.initControl()),this.renderComplete()},c.prototype.templateParser=function(e){if(e)try{return"function"!=typeof e&&document.querySelectorAll(e).length?t.compile(document.querySelector(e).innerHTML.trim()):t.compile(e)}catch(l){return t.compile(e)}},c.prototype.executeDataManager=function(e){var t=this,l=this.dataManager.executeQuery(e),i=new o.Deferred;l.then(function(e){e.actual&&e.actual.result?t.dataColl=e.actual.result:t.dataColl=e.result,t.initControl()}).catch(function(e){i.reject(e)})},c.prototype.initControl=function(){this.initialize(),this.initWrapper(),this.wireEvents()},c.prototype.wireEvents=function(){var e=this.getWrapper();t.EventHandler.add(e,"click",this.clickEventHandler,this),t.EventHandler.add(e,"focusout",this.focusEventHandler,this),t.EventHandler.add(e,"focusin",this.focusEventHandler,this),t.EventHandler.add(this.element,"keydown",this.keyBoardHandler,this)},c.prototype.unWireEvents=function(){var e=this.getWrapper();t.EventHandler.remove(e,"click",this.clickEventHandler),t.EventHandler.remove(e,"focusout",this.focusEventHandler),t.EventHandler.remove(e,"focusin",this.focusEventHandler),t.EventHandler.remove(this.element,"keydown",this.keyBoardHandler)},c.prototype.getParentGroup=function(e,t){for(var l=e instanceof Element?this.levelColl[e.id]:this.levelColl[""+e],i=t?l.length-1:l.length,o=this.rule,n=0;n<i;n++)o=this.findGroupByIdx(l[n],o,0===n);return o},c.prototype.deleteGroup=function(e){var t,l=this,i=e;"string"==typeof e?(t=this.element.id+"_"+e,e=document.getElementById(t)):t=i.id.replace(this.element.id+"_","");var o={groupID:t,cancel:!1,type:"deleteGroup"};this.isImportRules?this.deleteGroupSuccessCallBack(o,e):this.trigger("beforeChange",o,function(t){l.deleteGroupSuccessCallBack(t,e)})},c.prototype.deleteGroupSuccessCallBack=function(e,l){if(!e.cancel){var i=l,o=this.getParentGroup(i,!0),n=0,r=void 0,s=void 0,a=this.getValidRules(this.rule),u=i.nextElementSibling,d=i.previousElementSibling,p=i.querySelectorAll(".e-group-container"),c=i.querySelectorAll(".e-tooltip");for(s=c.length,r=0;r<s;r++)t.getComponent(c[r],"tooltip").destroy();for(r=0,s=p.length;r<s;r++)delete this.levelColl[p[r].id];for(;null!==i.previousElementSibling;)i=i.previousElementSibling,n++;u&&u.className.indexOf("e-separate-rule")>-1&&(t.removeClass([u],"e-separate-rule"),t.addClass([u],"e-joined-rule"),d&&d.className.indexOf("e-rule-container")>-1&&t.addClass([d],"e-prev-joined-rule"));var h=i.parentElement.parentElement.parentElement,m=[];if(this.isReact||this.isAngular){var g=o.rules[n],f=l.querySelectorAll(".e-rule-container");if(g&&g.rules)for(var v=0;v<g.rules.length;v++){var y=this.getColumn(g.rules[v].field);if(f[v]){var b=f[v].querySelector(".e-template-value");y&&(y.ruleTemplate||this.isPlatformTemplate(y)&&b)&&m.push(f[v].id)}}}t.detach(l),this.headerTemplate&&this.clearQBTemplate([l.id]),m.length&&this.clearQBTemplate(m),o.rules.splice(n,1),delete this.levelColl[e.groupID],this.refreshLevelColl(),this.disableRuleCondition(h,o),this.isImportRules||this.trigger("change",e),this.filterRules(a,this.getValidRules(this.rule),"deleteGroup")}},c.prototype.isPlatformTemplate=function(e){return e.template&&("string"==typeof e.template||void 0===e.template.create)},c.prototype.deleteRule=function(e){var l=this,i={groupID:t.closest(e,".e-group-container").id.replace(this.element.id+"_",""),ruleID:t.closest(e,".e-rule-container").id.replace(this.element.id+"_",""),cancel:!1,type:"deleteRule"};this.isImportRules?this.deleteRuleSuccessCallBack(i,e):this.trigger("beforeChange",i,function(t){l.deleteRuleSuccessCallBack(t,e)})},c.prototype.deleteRuleSuccessCallBack=function(e,l){if(!e.cancel){var i=t.closest(l,".e-group-container"),o=this.getParentGroup(i),n=t.closest(l,".e-rule-container"),r=this.getValidRules(this.rule),s=n,a=n.nextElementSibling,u=n.previousElementSibling,d=0,p=n.querySelectorAll(".e-tooltip"),c=void 0,h=p.length;for(c=0;c<h;c++)t.getComponent(p[c],"tooltip").destroy();for(;null!==n.previousElementSibling;)n=n.previousElementSibling,d++;var m=this.getColumn(o.rules[d].field);m&&m.template&&s.querySelector(".e-template")&&this.templateDestroy(m,s.querySelector(".e-template").id),(!u||u.className.indexOf("e-rule-container")<0)&&a&&t.removeClass([a],"e-joined-rule"),(!a||a.className.indexOf("e-rule-container")<0)&&u&&t.removeClass([u],"e-prev-joined-rule");var g=s.querySelector(".e-template-value");try{t.detach(s)}catch(e){(e=[]).error="error"}m&&m.ruleTemplate&&this.clearQBTemplate([s.id]),m&&this.isPlatformTemplate(m)&&g&&this.clearQBTemplate([s.id]),o.rules.splice(d,1),o.rules[0]&&o.rules[0].rules||this.disableRuleCondition(i,o);for(var f=this.element.querySelectorAll(".e-tooltip"),v=0;v<f.length;v++)t.getComponent(f[v],"tooltip").refresh(f[v]);this.isImportRules||this.trigger("change",e),this.filterRules(r,this.getValidRules(this.rule),"deleteRule")}},c.prototype.setGroupRules=function(e,t){if(this.headerTemplate&&t&&(this.isRoot=!0),this.reset(),this.groupIdCounter=1,this.ruleIdCounter=0,this.isImportRules=!0,this.setProperties({rule:e},!0),e=this.getRuleCollection(this.rule,!1),this.importRules(this.rule,this.element.querySelector(".e-group-container"),!0,this.rule.not,t),e.isLocked){var l=this.element.querySelector(".e-group-container").querySelector(".e-lock-grp-btn");this.groupLock(l)}this.isImportRules=!1},c.prototype.keyBoardHandler=function(e){!this.readonly||38!==e.keyCode&&40!==e.keyCode&&13!==e.keyCode||e.preventDefault()},c.prototype.clearQBTemplate=function(e){(this.isReact||this.isAngular)&&this.clearTemplate(e)},c.prototype.disableRuleCondition=function(e,t){if(!this.headerTemplate){if(this.readonly)return;var l=e.querySelector(".e-rule-list").childElementCount,i=e.querySelector(".e-btngroup-and"),o=e.querySelector(".e-btngroup-or");l>1?(i.disabled=!1,o.disabled=!1,(o.nextElementSibling.classList.contains("e-btn-disable")||i.nextElementSibling.classList.contains("e-btn-disable"))&&(o.nextElementSibling.classList.remove("e-btn-disable"),i.nextElementSibling.classList.remove("e-btn-disable")),t&&"or"===t.condition?o.checked=!0:i.checked=!0):(i.checked=!1,i.disabled=!0,o.checked=!1,o.disabled=!0,t&&(o.nextElementSibling.classList.add("e-btn-disable"),i.nextElementSibling.classList.add("e-btn-disable")))}},c.prototype.getValidRules=function(e){e||(e=this.getRules());var l=e.condition,i=e.not,o=t.extend([],e.rules,[],!0);return t.isNullOrUndefined(e.isLocked)?this.getRuleCollection({condition:l,rules:o,not:i},!0):this.getRuleCollection({condition:l,rules:o,not:i,isLocked:e.isLocked},!0)},c.prototype.getRuleCollection=function(e,l){if(t.isNullOrUndefined(e))return null;var i;if(e.rules&&e.rules.length&&(Object.keys(e.rules[0]).length>6||l))for(var o=e.rules.length,n=0;n<o;n++)i=e.rules[n],i=this.getRuleCollection(i,l),e.rules[n]=i,Object.keys(i).length<1&&l&&(e.rules.splice(n,1),n--,o--);var r=e.custom;if(e.field&&""!==e.field&&(t.isNullOrUndefined(r)||r&&"question"!==r.type&&"answer"!==r.type))if(e.operator&&(e.operator.toString().indexOf("null")>-1||e.operator.toString().indexOf("empty")>-1)&&(e.value=null),this.isRefreshed&&this.enablePersistence||""!==e.field&&""!==e.operator&&""!==e.value&&void 0!==e.value||r&&r.isQuestion){var s=e.condition,a=e.isLocked;e={label:e.label,field:e.field,operator:e.operator,type:e.type,value:e.value},t.isNullOrUndefined(a)||(e.isLocked=a),s&&(e.condition=s),r&&(e.custom=r),"in"!==e.operator&&"notin"!==e.operator||!e.value||0!==e.value.length||(e={})}else e={};else if(!r||"question"!==r.type&&"answer"!==r.type)if(t.isNullOrUndefined(e.condition)&&t.isNullOrUndefined(e.rules))e={};else{var u=e.isLocked;e=this.enableNotCondition?{condition:e.condition,rules:e.rules,not:e.not}:{condition:e.condition,rules:e.rules},t.isNullOrUndefined(u)||(e.isLocked=u),r&&(e.custom=r),0===e.rules.length&&(e={})}else{var d=e.not;(e={label:e.label,field:e.field,operator:e.operator,type:e.type,value:e.value,condition:e.condition,rules:e.rules}).custom=r,this.enableNotCondition&&(e.not=d)}return e},c.prototype.setRules=function(e){var l=t.extend({},e,{},!0);this.headerTemplate?this.setGroupRules(l,!0):this.setGroupRules(l)},c.prototype.getRules=function(){var e;return e=this.enableNotCondition?{condition:this.rule.condition,rules:this.rule.rules,not:this.rule.not}:{condition:this.rule.condition,rules:this.rule.rules},t.isNullOrUndefined(this.rule.isLocked)||(e.isLocked=this.rule.isLocked),this.rule.custom&&(e.custom=this.rule.custom),e},c.prototype.getRule=function(e){var l,i,o=0;if(e instanceof HTMLElement?l=t.closest(e,".e-rule-container"):(i=this.element.id+"_"+e,l=document.getElementById(i)),t.isNullOrUndefined(l))return null;for(var n=t.closest(l,".e-group-container"),r=this.getParentGroup(n);null!==l.previousElementSibling;)l=l.previousElementSibling,o++;return r.rules[o]},c.prototype.getGroup=function(e){e instanceof Element&&e.className.indexOf("e-group-container")<1&&(e=t.closest(e,".e-group-container"));var l=e instanceof Element?e.id:this.element.id+"_"+e;return this.getParentGroup(l)},c.prototype.deleteGroups=function(e){var t,l,i=e.length;for(t=0;t<i;t++)l=this.element.id+"_"+e[t],this.deleteGroup(document.getElementById(l))},c.prototype.getFilteredRecords=function(){var e=this.getPredicate(this.getValidRules(this.rule)),l=t.isNullOrUndefined(e)?new o.Query:(new o.Query).where(e);return this.dataManager.executeQuery(l)},c.prototype.deleteRules=function(e){var t,l,i=e.length;for(t=0;t<i;t++)l=this.element.id+"_"+e[t],this.deleteRule(document.getElementById(l))},c.prototype.getDataManagerQuery=function(e){for(var t=this.getPredicate(e),l=[],i=0,n=Object.keys(this.columns);i<n.length;i++)l.push(this.columns[i].field);return e.rules.length?(new o.Query).select(l).where(t):(new o.Query).select(l)},c.prototype.getPredicate=function(e){var l,i,n,r,s=e.rules,a=!1;if(!s)return l;for(var u=0,d=s.length;u<d;u++){var p=s[u].operator;if("notstartswith"===p?p="doesnotstartwith":"notendswith"===p?p="doesnotendwith":"notcontains"===p&&(p="doesnotcontain"),a=!1,Object.keys(s[u]).indexOf("rules")>-1&&s[u].rules)(i=this.getPredicate(s[u]))&&(l=l?"and"===e.condition?l.and(i):l.or(i):i);else if(!t.isNullOrUndefined(p)&&!t.isNullOrUndefined(p.length)){var c=s[u].operator.toLowerCase(),h=!1,m=["equal","notequal","greaterthan","greaterthanorequal","lessthan","lessthanorequal"];if("string"===s[u].type&&(a=!this.matchCase),"date"===s[u].type&&m.indexOf(c)>-1&&(a=!0),r=this.getColumn(s[u].field),c.indexOf("null")>-1||c.indexOf("empty")>-1)s[u].value=null;else if("date"!==s[u].type||s[u].value instanceof Array)n=s[u].value;else{var g=this.getFormat(r.format);t.isNullOrUndefined(s[u].value)?n=null:(n=this.getDate(s[u].value,g),m.indexOf(c)>-1&&!this.isTime(s[u].value)&&(h=!0))}if(0===u)h||(c.indexOf("in")>-1||c.indexOf("between")>-1||c.indexOf("null")>-1||c.indexOf("empty")>-1)&&c.indexOf("contain")<0?l=h?this.datePredicate(s[u],n):this.arrayPredicate(s[u]):""!==(f=n)&&(l=new o.Predicate(s[u].field,p,n,a));else if(h||(c.indexOf("in")>-1||c.indexOf("between")>-1||c.indexOf("null")>-1||c.indexOf("empty")>-1)&&c.indexOf("contain")<0)l=h?this.datePredicate(s[u],n,l,e.condition):this.arrayPredicate(s[u],l,e.condition);else if("and"===e.condition){f=n;l&&""!==f?l=l.and(s[u].field,p,n,a):""!==f&&(l=new o.Predicate(s[u].field,p,n,a))}else{var f=n;l&&""!==f?l=l.or(s[u].field,p,n,a):""!==f&&(l=new o.Predicate(s[u].field,p,n,a))}}}return this.dataSource instanceof o.DataManager&&(t.isNullOrUndefined(l)||"isnull"!==l.operator&&"isnotnull"!==l.operator||(l.operator="isnull"===l.operator?"equal":"notequal")),l},c.prototype.getLocale=function(){var e=this.locale;return t.getValue("main."+this.locale+".dates.calendars.gregorian.days.format.short",t.cldrData)||(e="en"),e},c.prototype.getColumn=function(e,t){for(var l,i=this.columns,o=0,n=(i=t||i).length;o<n;o++){if(i[o].field===e){l=i[o];break}if(i[o].columns){if(l=this.getColumn(e,i[o].columns))break}else if(e&&e.indexOf(this.separator)>-1&&""!==this.separator&&i[o].field===e.split(this.separator)[0]){l=i[o];break}}return l},c.prototype.getOperators=function(e){return this.getColumn(e).operators},c.prototype.setTime=function(e,t){return t?e.setHours(0,0,0):e.setHours(23,59,59),e},c.prototype.datePredicate=function(e,t,l,i){var n,r=this.setTime(new Date(t.getTime()),!0),s=this.setTime(t);switch(e.operator){case"equal":n=(n=new o.Predicate(e.field,"greaterthanorequal",r)).and(e.field,"lessthanorequal",s);break;case"notequal":n=(n=new o.Predicate(e.field,"lessthan",r)).or(e.field,"greaterthan",s);break;case"greaterthan":n=new o.Predicate(e.field,"greaterthan",s);break;case"greaterthanorequal":n=new o.Predicate(e.field,"greaterthanorequal",r);break;case"lessthan":n=new o.Predicate(e.field,"lessthan",r);break;case"lessthanorequal":n=new o.Predicate(e.field,"lessthanorequal",s)}return n&&(l?"and"===i?l=l.and(n):"or"===i&&(l=l.or(n)):l=n),l},c.prototype.arrayPredicate=function(e,t,l){var i,n=e.value,r=e.operator.toString(),s=e.value,a=this.getColumn(e.field),u=this.getFormat(a.format);if(r.indexOf("null")>-1||r.indexOf("empty")>-1)switch(r){case"isnull":i=new o.Predicate(e.field,"isnull",s);break;case"isnotnull":i=new o.Predicate(e.field,"isnotnull",s);break;case"isempty":i=new o.Predicate(e.field,"equal","");break;case"isnotempty":i=new o.Predicate(e.field,"notequal","")}if(!(r.indexOf("null")>-1||r.indexOf("empty")>-1))for(var d=0,p=n.length;d<p;d++)if(""!==n[d]||("in"===r||"notin"===r)&&"string"===a.type)if(0===d){var c="greaterthanorequal";switch(r){case"between":i="date"!==a.type?new o.Predicate(e.field,c,n[d]):new o.Predicate(e.field,c,n[d]?this.isTime(n[d])?this.getDate(n[d],u):this.setTime(this.getDate(n[d],u),!0):null);break;case"notbetween":i="date"===a.type?new o.Predicate(e.field,"lessthan",n[d]?this.isTime(n[d])?this.getDate(n[d],u):this.setTime(this.getDate(n[d],u),!0):null):new o.Predicate(e.field,"lessthan",n[d]);break;case"in":i=new o.Predicate(e.field,"equal",n[d]);break;case"notin":i=new o.Predicate(e.field,"notequal",n[d])}}else{switch(e.operator){case"between":i="date"===a.type?i.and(e.field,"lessthanorequal",n[d]?this.isTime(n[d])?this.getDate(n[d],u):this.setTime(this.getDate(n[d],u)):n[d]):i.and(e.field,"lessthanorequal",n[d]);break;case"notbetween":i="date"===a.type?i.or(e.field,"greaterthan",n[d]?this.isTime(n[d])?this.getDate(n[d],u):this.setTime(this.getDate(n[d],u)):n[d]):i.or(e.field,"greaterthan",n[d]);break;case"in":i=i.or(e.field,"equal",n[d]);break;case"notin":i=i.and(e.field,"notequal",n[d])}}return i&&(t?"and"===l?t=t.and(i):"or"===l&&(t=t.or(i)):t=i),t},c.prototype.getDate=function(e,t){var l=this.intl.parseDate(e,t);return e.indexOf(":")>-1&&e.indexOf("/")<0&&e.indexOf(",")<0&&e.indexOf("-")<0&&((l=new Date).setHours(parseInt(e.split(":")[0])),l.setMinutes(parseInt(e.split(":")[1])),e.split(":")[2]&&l.setSeconds(parseInt(e.split(":")[2]))),l},c.prototype.isTime=function(e){return!!(e&&e.indexOf(":")>-1)},c.prototype.importRules=function(e,l,i,o,n){if(i){if(e.rules.length>1&&!this.headerTemplate){var r=l.querySelector(".e-btngroup-or"),s=l.querySelector(".e-btngroup-and");r.disabled=!1,s.disabled=!1,"or"===e.condition?r.checked=!0:s.checked=!0}else this.disableRuleCondition(l);if(this.headerTemplate&&n&&(l=this.renderGroup(e,e.condition,this.element,e.not,n)),this.enableNotCondition&&!this.headerTemplate){var a=l.querySelector(".e-qb-toggle");e.not?t.addClass([a],"e-active-toggle"):t.removeClass([a],"e-active-toggle")}}else l=this.renderGroup(e,e.condition,l,o);0===e.rules.length&&this.headerTemplate&&(e.rules[0]={label:"",field:"",operator:"",type:"",value:""});var u=e.rules;if(!t.isNullOrUndefined(u))for(var d=0,p=u.length;d<p;d++){var c=Object.keys(u[d]);if(!t.isNullOrUndefined(u[d].rules)&&c.indexOf("rules")>-1&&0!==u[d].rules.length){if(this.element.querySelectorAll(".e-group-container").length>this.maxGroupCount)return null;l=this.renderGroup(u[d],u[d].condition,l,u[d].not),l=this.importRules(u[d],l,!0)}else this.renderRule(u[d],l);if(!t.isNullOrUndefined(u[d].rules)&&u[d].isLocked){var h=l.querySelector(".e-rule-list").children[d].querySelector(".e-lock-grp-btn");this.groupLock(h)}if(t.isNullOrUndefined(u[d].rules)&&u[d].isLocked){var m=l.querySelector(".e-rule-list").children[d].querySelector(".e-lock-rule-btn");this.ruleLock(m)}}return l&&(l=t.closest(l,".e-rule-list")),l&&(l=t.closest(l,".e-group-container")),l},c.prototype.renderGroup=function(e,t,l,i,o){this.addGroupElement(!0,l,t,!1,i,o,e);var n=l.querySelectorAll(".e-group-container"),r=l.querySelector(".e-rule-list").children;return this.showButtons.cloneGroup&&this.cloneGrpBtnClick&&this.isMiddleGroup?(this.isMiddleGroup=!1,this.cloneGrpBtnClick=!1,r[this.groupIndex+1]):this.showButtons.cloneGroup&&this.cloneGrpBtnClick&&this.isLastGroup?(this.isLastGroup=!1,this.cloneGrpBtnClick=!1,r[r.length-1]):n[n.length-1]},c.prototype.renderRule=function(e,t){t.className.indexOf("e-group-container")>-1?this.addRuleElement(t,e):this.addRuleElement(t.querySelector(".e-group-container"),e)},c.prototype.enableReadonly=function(){for(var e=this.element.querySelectorAll(".e-dropdownlist, .e-dropdowntree, .e-numerictextbox, .e-textbox, .e-datepicker, .e-multiselect .e-lib, .e-radio"),o=0;o<e.length;o++)e[o].classList.contains("e-dropdownlist")?t.getInstance(e[o],i.DropDownList).readonly=this.isReadonly:e[o].classList.contains("e-dropdowntree")?t.getComponent(e[o],"dropdowntree").readonly=this.isReadonly:e[o].classList.contains("e-numerictextbox")?t.getInstance(e[o],n.NumericTextBox).readonly=this.isReadonly:e[o].classList.contains("e-textbox")?t.getInstance(e[o],n.TextBox).readonly=this.isReadonly:e[o].classList.contains("e-datepicker")?t.getInstance(e[o],r.DatePicker).readonly=this.isReadonly:e[o].classList.contains("e-multiselect")?t.getInstance(e[o],i.MultiSelect).readonly=this.isReadonly:e[o].classList.contains("e-radio")&&(t.getInstance(e[o],l.RadioButton).checked||(this.isReadonly?e[o].parentElement.style.display="none":e[o].parentElement.style.display="inherit"));var s=this.element.querySelectorAll(".e-deletegroup"),a=this.element.querySelectorAll(".e-addrulegroup"),u=this.element.querySelectorAll(".e-removerule");!this.isReadonly&&this.ruleElem.classList.contains("e-readonly")&&this.ruleElem.classList.remove("e-readonly");for(var d=[s,a,u],o=0;o<d.length;o++)d[o].forEach(function(e){e.classList.contains("e-readonly")?e.classList.remove("e-readonly"):e.classList.add("e-readonly")});this.enableBtnGroup()},c.prototype.enableBtnGroup=function(){var e=this,t=!1;this.element.querySelectorAll(".e-btngroup-and-lbl, .e-btngroup-or-lbl, .e-qb-toggle").forEach(function(l){!l.classList.contains("e-qb-toggle")||l.classList.contains("e-active-toggle")||l.classList.contains("e-readonly")?l.classList.contains("e-qb-toggle")&&l.classList.contains("e-not-readonly")?l.classList.remove("e-not-readonly"):l.classList.contains("e-qb-toggle")&&l.classList.contains("e-readonly")?l.classList.remove("e-readonly"):l.classList.contains("e-active-toggle")?(l.classList.add("e-not-readonly"),t=!0):l.previousElementSibling.checked||l.classList.contains("e-readonly")?(l.classList.remove("e-readonly"),t?"AND"===l.textContent?l.classList.add("e-readonly-and"):l.classList.add("e-readonly-or"):("AND"===l.textContent&&e.isReadonly?(l.classList.remove("e-not"),l.classList.add("e-readonly-and")):(e.enableNotCondition&&l.classList.add("e-not"),l.classList.remove("e-readonly-and")),"OR"===l.textContent&&e.isReadonly?l.classList.add("e-readonly-or-not"):l.classList.remove("e-readonly-or-not"))):l.classList.contains("e-btn-disable")||l.classList.add("e-readonly"):(l.classList.add("e-readonly"),t=!1)})},c.prototype.isDateFunction=function(e){for(var t=["date","time","day","week","month","year","hour","minute","second","now","quarter","period","extract"],l=0,i=t.length;l<i;l++)if(e.toLowerCase().indexOf(t[l])>-1)return!0;return!1},c.prototype.getSqlString=function(e,t,l,i){var o=!1;l||""===l?l+="(":(l="",o=!0);var n=e.condition;if(e.not){l+=o?i?this.l10n.getConstant("NOT").toUpperCase()+" (":"NOT (":i?" "+this.l10n.getConstant("NOT").toUpperCase()+" (":" NOT ("}if(e.rules)for(var r=0,s=e.rules.length;r<s;r++){if(e.rules[r].rules)l=this.getSqlString(e.rules[r],t,l,i);else{var a=e.rules[r],u="",d=i?this.sqlOperators[a.operator]:this.operators[a.operator];if(a.value instanceof Array)if(a.operator.toString().indexOf("between")>-1){var p=i?" "+this.l10n.getConstant("AND").toUpperCase()+" ":" AND ";"date"!==a.type||this.isDateFunction(a.value[0])?u+=a.value[0]+p+a.value[1]:u+='"'+a.value[0]+'"'+p+'"'+a.value[1]+'"'}else if("string"==typeof a.value[0]&&null!==a.value){u+='("'+a.value[0]+'"';for(var c=1,h=a.value.length;c<h;c++)u+=',"'+a.value[c]+'"';u+=")"}else u+="("+a.value+")";else a.operator.toString().indexOf("startswith")>-1?u+=a.value?'("'+a.value+'%")':"("+a.value+")":a.operator.toString().indexOf("endswith")>-1?u+=a.value?'("%'+a.value+'")':"("+a.value+")":a.operator.toString().indexOf("contains")>-1?u+=a.value?'("%'+a.value+'%")':"("+a.value+")":"number"===a.type||"boolean"==typeof a.value||null===a.value&&a.operator.toString().indexOf("empty")<-1?u+=a.value:a.operator.toString().indexOf("empty")>-1?u+='""':u+='"'+a.value+'"';if(a.operator.toString().indexOf("null")>-1)t?a.field="`"+a.field+"`":a.field.indexOf(" ")>-1&&(a.field='"'+a.field+'"'),l+=a.field+" "+d;else{var m=d;"isempty"===a.operator?m="=":"isnotempty"===a.operator&&(m="!="),t?a.field="`"+a.field+"`":a.field.indexOf(" ")>-1&&(a.field='"'+a.field+'"'),l+=a.field+" "+m+" "+u}a.condition&&""!==a.condition&&(n=a.condition)}if(r!==s-1){a=e.rules[r];(""===n||a&&""!==a.condition&&a.custom&&a.custom.isCustom)&&(n=a.condition),l+=" "+(n=i?this.l10n.getConstant(n.toUpperCase()).toUpperCase():n.toUpperCase())+" "}}return o||(l+=")"),e.not&&(l+=")"),l},c.prototype.setRulesFromSql=function(e,t){e=e.replace(/`/g,"");var l=this.getRulesFromSql(e,t);this.setRules({condition:l.condition,not:l.not,rules:l.rules})},c.prototype.getRulesFromSql=function(e,t){this.parser=[],this.sqlParser(e,t),this.setProperties({rule:{condition:"and",not:!1,rules:[]}},!0);var l=this.processParser(this.parser,this.rule,[0],t);return this.enableNotCondition?{condition:l.condition,not:l.not,rules:l.rules}:{condition:l.condition,rules:l.rules}},c.prototype.getSqlFromRules=function(e,t,l){return e||(e=this.getValidRules()),e=this.getRuleCollection(e,!1),this.getSqlString(this.getValidRules(e),t,null,l).replace(/"/g,"'")},c.prototype.getParameterizedSql=function(e){e||(e=this.getValidRules());var t={sql:null};return this.notify("query-library",{prop:"getParameterSql",onPropertyChange:!1,value:{rule:e,obj:t}}),t.sql},c.prototype.setParameterizedSql=function(e){var t={sql:null};this.notify("query-library",{prop:"convertParamSqlToSql",onPropertyChange:!1,value:{sql:e,obj:t}});var l=t.sql;if(l){l=l.replace(/`/g,"");var i=this.getRulesFromSql(l);this.setRules({condition:i.condition,not:i.not,rules:i.rules})}},c.prototype.getParameterizedNamedSql=function(e){e||(e=this.getValidRules());var t={sql:null};return this.notify("query-library",{prop:"getNamedParameterSql",onPropertyChange:!1,value:{rule:e,obj:t}}),t.sql},c.prototype.setParameterizedNamedSql=function(e){var t={sql:null};this.notify("query-library",{prop:"convertNamedParamSqlToSql",onPropertyChange:!1,value:{sql:e,obj:t}});var l=t.sql;if(l){l=l.replace(/`/g,"");var i=this.getRulesFromSql(l);this.setRules({condition:i.condition,not:i.not,rules:i.rules})}},c.prototype.setMongoQuery=function(e,t){this.rule={condition:"and",not:!1,rules:[]},this.notify("query-library",{prop:"mongoParser",onPropertyChange:!1,value:{mongoQuery:JSON.parse(e),rule:this.rule,mongoLocale:t}})},c.prototype.getMongoQuery=function(e){e||(e=this.getValidRules());var t={mongoQuery:null};return this.notify("query-library",{prop:"getMongoFromRules",onPropertyChange:!1,value:{rule:e,mongoQuery:"",obj:t}}),t.mongoQuery},c.prototype.cloneRule=function(e,t,l){var i=this.getRule(e.replace(this.element.id+"_","")),o=this.showButtons.cloneRule;t=t.replace(this.element.id+"_",""),this.ruleIndex=l,this.cloneRuleBtnClick=!0,this.showButtons.cloneRule=!0,this.addRules([{label:i.label,field:i.field,type:i.type,operator:i.operator,value:i.value}],t),this.ruleIndex=-1,this.cloneRuleBtnClick=!1,this.showButtons.cloneRule=o,o=!1},c.prototype.cloneGroup=function(e,t,l){t=t.replace(this.element.id+"_","");var i=this.getGroup(t),o=this.showButtons.cloneGroup;e=e.replace(this.element.id+"_",""),this.groupIndex=l,this.cloneGrpBtnClick=!0,this.showButtons.cloneGroup=!0,this.addGroups([{condition:i.condition,not:i.not,rules:i.rules}],e),this.groupIndex=-1,this.cloneGrpBtnClick=!1,this.showButtons.cloneGroup=o,o=!1},c.prototype.lockRule=function(e){e.indexOf(this.element.id)<0&&(e=this.element.id+"_"+e);var t=document.getElementById(e).querySelectorAll(".e-lock-rule-btn")[0];this.ruleLock(t)},c.prototype.lockGroup=function(e){e.indexOf(this.element.id)<0&&(e=this.element.id+"_"+e);var t=document.getElementById(e).querySelectorAll(".e-lock-grp-btn")[0];this.groupLock(t)},c.prototype.sqlParser=function(e,t){var l,i=0;do{l=e.slice(i),i+=this.parseSqlStrings(l,t)}while(""!==l);return this.parser},c.prototype.parseSqlStrings=function(e,t){var l,i=["=","!=","<=",">=","<",">"];l=t?[this.l10n.getConstant("AND").toUpperCase(),this.l10n.getConstant("OR").toUpperCase(),this.l10n.getConstant("NOT").toUpperCase()]:["AND","OR","NOT"];var o;o=t?[this.l10n.getConstant("In").toUpperCase(),this.l10n.getConstant("NotIn").toUpperCase(),this.l10n.getConstant("Like").toUpperCase(),this.l10n.getConstant("NotLike").toUpperCase(),this.l10n.getConstant("Between").toUpperCase(),this.l10n.getConstant("NotBetween").toUpperCase(),this.l10n.getConstant("IsNull").toUpperCase(),this.l10n.getConstant("IsNotNull").toUpperCase(),this.l10n.getConstant("IsEmpty").toUpperCase(),this.l10n.getConstant("IsNotEmpty").toUpperCase()]:["IN","NOT IN","LIKE","NOT LIKE","BETWEEN","NOT BETWEEN","IS NULL","IS NOT NULL","IS EMPTY","IS NOT EMPTY"];for(var n,r,s=0,a=i.length;s<a;s++)if(n=/^\w+$/.test(i[s])?"\\b":"",new RegExp("^("+i[s]+")"+n,"ig").exec(e))return this.parser.push(["Operators",i[s].toLowerCase()]),i[s].length;var u=this.parser[this.parser.length-1];if(!u||u&&"Literal"!==u[0])for(var s=0,a=l.length;s<a;s++)if(n=/^\w+$/.test(l[s])?"\\b":"",new RegExp("^("+l[s]+")"+n,"ig").exec(e))return this.parser.push(["Conditions",l[s].toLowerCase()]),l[s].length;for(var s=0,a=o.length;s<a;s++)if(n=/^\w+$/.test(o[s])?"\\b":"",new RegExp("^("+o[s]+")"+n,"ig").exec(e))return this.parser.push(["SubOperators",o[s].toLowerCase()]),o[s].length;if(/^\(/.exec(e))return this.parser.push(["Left","("]),1;if(/^\)/.exec(e))return this.parser.push(["Right",")"]),1;if(/^(true|false)/.exec(e))return r=/^(true|false)/.exec(e)[0],this.parser.push(["String",r]),r.length;if(/^null/.exec(e))return r=/^null/.exec(e)[0],this.parser.push(["String",null]),r.length;if(/^`?([a-z_][a-z0-9_.\[\]\(\)]{0,}(\:(number|float|string|date|boolean))?)`?/i.exec(e))return r=/^`?([a-zåäö_][a-z0-9åäö_.\[\]\(\)]{0,}(\:(number|float|string|date|boolean))?)`?/i.exec(e)[1],this.parser.push(["Literal",r]),r.length;if(this.checkLiteral()&&/^'?([a-z_][a-z0-9 _.\[\]\(\)-]{0,}(\:(number|float|string|date|boolean))?)'?/i.exec(e))return r=/^'?([a-z_][a-z0-9 _.\[\]\(\)-]{0,}(\:(number|float|string|date|boolean))?)'?/i.exec(e)[1],this.parser.push(["Literal",r]),r.length+2;if(this.checkNumberLiteral(e,t))return r=/^[0-9]+(\.[0-9]+)?/.exec(e)[0],this.parser.push(["Literal",r]),r.length;if(/^'((?:[^\\']+?|\\.|'')*)'(?!')/.exec(e)){if("("===(r=/^'((?:[^\\']+?|\\.|'')*)'(?!')/.exec(e)[0])[r.length-2])for(var d=!1,p=r.length;p<e.length&&(r+=e[p],")"===e[p]&&(d=!0),!d||"'"!==e[p]);p++);else e[r.length]&&")"!==e[r.length]&&!this.checkCondition(e,r)&&(r=this.getSingleQuoteString(e,r));return this.parser.push(["String",r]),r.length}return/^"([^\\"]*(?:\\.[^\\"]*)*)"/.exec(e)?(r=/^"([^\\"]*(?:\\.[^\\"]*)*)"/.exec(e)[0],this.parser.push(["DoubleString",r]),r.length):/^[0-9]+(\.[0-9]+)?/.exec(e)?(r=/^[0-9]+(\.[0-9]+)?/.exec(e)[0],this.parser.push(["Number",r]),r.length):/^-?[0-9]+(\.[0-9]+)?/.exec(e)?(r=/^-?[0-9]+(\.[0-9]+)?/.exec(e)[0],this.parser.push(["Number",r]),r.length):1},c.prototype.checkCondition=function(e,t){return"AND"===e.slice(t.length+1,t.length+4)||"OR"===e.slice(t.length+1,t.length+3)},c.prototype.getSingleQuoteString=function(e,l){if(e[l.length]&&")"!==e[l.length]&&!this.checkCondition(e,l)&&","!==e[l.length]){var i=e.replace(l,"");t.isNullOrUndefined(/^'((?:[^\\']+?|\\.|'')*)'(?!')/.exec(i))&&(l+=/^((?:[^\\']+?|\\.|'')*)'(?!')/.exec(i)[0],l=this.getSingleQuoteString(e,l))}return l},c.prototype.checkLiteral=function(){var e=this.parser[this.parser.length-1];if(!e)return!0;var t=this.parser[this.parser.length-2],l=this.parser[this.parser.length-3];if("Left"===e[0]&&t&&"Conditions"===t[0])return!0;return!!("Conditions"===e[0]&&l&&l[1].indexOf("between")<0)},c.prototype.checkNumberLiteral=function(e,t){var l=this.parser[this.parser.length-1];if(!l)return!0;if(/^[0-9]+(\.[0-9]+)?/.exec(e)){var i=this.parser[this.parser.length-2],o=this.parser[this.parser.length-3];if("Left"===l[0]&&i&&"Conditions"===i[0])return!0;var n=t?this.l10n.getConstant("Between").toLowerCase():"between";if("Conditions"===l[0]&&o&&o[1].indexOf(n)<0)return!0}return!1},c.prototype.getOperator=function(e,t,l){var i={"=":"equal","!=":"notequal","<":"lessthan",">":"greaterthan","<=":"lessthanorequal",">=":"greaterthanorequal",in:"in","not in":"notin",between:"between","not between":"notbetween","is empty":"isempty","is null":"isnull","is not null":"isnotnull","is not empty":"isnotempty"};if(l){for(var o=Object.keys(this.sqlOperators),n=0;n<o.length;n++)if(this.sqlOperators[o[n]]===t.toUpperCase())return e&&0===e.indexOf("%")&&"%"===e[e.length-1]?"NOT LIKE"===t.toUpperCase()?"notcontains":"contains":e&&0!==e.indexOf("%")&&e.indexOf("%")===e.length-1?"NOT LIKE"===t.toUpperCase()?"notstartswith":"startswith":e&&0===e.indexOf("%")&&e.indexOf("%")!==e.length-1?"NOT LIKE"===t.toUpperCase()?"notendswith":"endswith":o[n];return null}if(e){if(0===e.indexOf("%")&&"%"===e[e.length-1])return"not like"===t?"notcontains":"contains";if(0!==e.indexOf("%")&&e.indexOf("%")===e.length-1)return"not like"===t?"notstartswith":"startswith";if(0===e.indexOf("%")&&e.indexOf("%")!==e.length-1)return"not like"===t?"notendswith":"endswith"}else{if("not like"===t)return"notequal";if("like"===t)return"equal"}return i[""+t]},c.prototype.getTypeFromColumn=function(e){var l=this.getColumn(e.field);return t.isNullOrUndefined(l)?null:l.type},c.prototype.getLabelFromColumn=function(e){var t="",l=0;if(""!==this.separator){for(var i=e.split(this.separator),o=0;o<i.length;o++)t+=this.getLabelFromField(i,o+1),++l<i.length&&(t+=this.separator);return t}return this.getColumn(e).label},c.prototype.getLabelFromField=function(e,t){for(var l="",i=0,o=0;o<t;o++)l+=e[o],++i<t&&(l+=this.separator);return this.getColumn(l).label},c.prototype.processParser=function(e,t,l,i){for(var o,n,r,s,a,u,d,p,c,h,m=[],g=[],f=!1,v=0,y=e.length;v<y;v++)if("Literal"===e[v][0]){var b=this.getColumn(e[v][1]);if(r={label:b&&b.label?b.label:e[v][1],field:e[v][1]},"SubOperators"===e[v+1][0]){if(e[v+1][1].indexOf("null")>-1||e[v+1][1].indexOf("empty")>-1)r.operator=this.getOperator(" ",e[v+1][1],i),r.value=null,r.type=this.getTypeFromColumn(r);else{var C=e[v+3][1]?e[v+3][1].replace(/'/g,""):e[v+3][1];r.operator=this.getOperator(C,e[v+1][1],i)}for(h=e[v+1][1],o=++v+1,n=y,i&&"contains"===r.operator||"startswith"===r.operator||"endswith"===r.operator?h="like":i&&"notcontains"===r.operator||"notstartswith"===r.operator||"notendswith"===r.operator?h="not like":i&&(h=r.operator),o=v+1;o<n;o++)if(h.indexOf("between")<0&&"Left"===e[o][0])f=!0;else{if("Right"===e[o][0]&&f){v=o,f=!1;break}if(h.indexOf("null")>-1||h.indexOf("empty")>-1)break;if(h.indexOf("like")>-1&&"String"===e[o][0]){S=e[o][1];e[o][1]&&"'"===e[o][1][0]&&(S=e[o][1].substring(1,e[o][1].length-1)),S=S?S.replace(/%/g,""):e[o][1],r.value=S,r.type="string"}else if(h.indexOf("between")>-1){if("Literal"===e[o][0]||"Left"===e[o][0])break;if("Number"===e[o][0])m.push(Number(e[o][1]));else if("String"===e[o][0]){S=e[o][1];e[o][1]&&"'"===e[o][1][0]&&(S=e[o][1].substring(1,e[o][1].length-1)),g.push(S)}}else if("Number"===e[o][0])m.push(Number(e[o][1]));else if("String"===e[o][0]){var S=e[o][1];e[o][1]&&"'"===e[o][1][0]&&(S=e[o][1].substring(1,e[o][1].length-1)),g.push(S)}r.type=this.getTypeFromColumn(r)}h.indexOf("like")<0&&("Number"===e[o-1][0]?(r.value=m,r.type="number"):"String"===e[o-1][0]?(r.value=g,r.type="string"):h.indexOf("between")>-1&&"Conditions"===e[o-1][0]&&(0!==g.length?(r.value=g,r.type="string"):(r.value=m,r.type="number")),m=[],g=[],r.type=this.getTypeFromColumn(r))}else"Operators"===e[v+1][0]&&(r.operator=this.getOperator(e[v+2][1],e[v+1][1],i),"equal"==r.operator&&"String"===e[v+2][0]&&"''"===e[v+2][1]?r.operator="isempty":"notequal"==r.operator&&"String"===e[v+2][0]&&"''"===e[v+2][1]&&(r.operator="isnotempty"),"Number"===e[v+2][0]?(r.type="number",r.value=Number(e[v+2][1])):(r.type="string",(S=e[v+2][1])&&"'"===S[0]&&(S=S.substring(1,S.length-1)),r.value=S),r.type=this.getTypeFromColumn(r));t.rules.push(r)}else{if("Left"===e[v][0]){if("Left"!==e[0][0]&&("not"===e[v-1][1]||i&&this.l10n.getConstant("NOT").toLowerCase()===e[v-1][1]))continue;for(this.parser=e.splice(v+1,y-(v+1)),s=this.enableNotCondition?{condition:"and",rules:[],not:!1}:{condition:"and",rules:[]},c=0,u=t.rules.length,a=0;a<u;a++)t.rules[a].rules&&c++;return l.push(c),t.rules.push(s),s=this.processParser(this.parser,s,l,i),t}if("Conditions"===e[v][0])"not"===e[v][1]||i&&this.l10n.getConstant("NOT").toLowerCase()===e[v][1]?t.not=!0:t.condition=e[v][1];else if("Right"===e[v][0]){for(this.parser=e.splice(v+1,y-(v+1)),l.pop(),t=this.rule,p=l.length,d=0;d<p;d++)t=this.findGroupByIdx(l[d],t,0===d);return this.processParser(this.parser,t,l,i)}}return t},c.prototype.getValueFromParser=function(e,t){var l,i="";for(l=t;l<e.length&&("String"===e[l][0]&&","!==e[l][1]&&", "!==e[l][1]);l++)""!==i&&(t+=1),null!==e[l][1]?i+=e[l][1]:i=null;return{value:i,idx:t}},c.prototype.groupClone=function(e){var t,l,i=e.closest(".e-rule-list").closest(".e-group-container");"string"==typeof e?(l=this.element.id+"_"+e,e=document.getElementById(l)):(t=e.id.replace(this.element.id+"_",""),l=i.id.replace(this.element.id+"_",""));var o=this.getGroup(t);this.groupIndex=Array.prototype.indexOf.call(e.closest(".e-rule-list").children,e.closest(".e-group-container")),this.addGroups([{condition:o.condition,not:o.not,rules:o.rules}],l),this.groupIndex=-1},c.prototype.ruleClone=function(e){for(var l=t.closest(e,".e-rule-container"),i=e.closest(".e-rule-list").closest(".e-group-container"),o=this.getRule(e),n=i.id.replace(this.element.id+"_",""),r=i.querySelectorAll(".e-rule-container"),s=0,a=r.length;s<a;s++)l.id===r[s].id&&(this.ruleIndex=s);this.addRules([{label:o.label,field:o.field,type:o.type,operator:o.operator,value:o.value}],n),this.ruleIndex=-1},c.prototype.ruleLock=function(e){var l=t.closest(e,".e-rule-container"),i=this.getRule(l.id.replace(this.element.id+"_",""));l.classList.contains("e-disable")?(i.isLocked=!1,this.lockItems=this.lockItems.filter(function(e){return e!==l.id}),l.classList.remove("e-disable"),this.disableRuleControls(e,l,!1),e.children[0].classList.add("e-unlock"),e.children[0].classList.remove("e-lock"),e.setAttribute("title",this.l10n.getConstant("LockRule"))):(i.isLocked=!0,this.lockItems.indexOf(l.id)<0&&this.lockItems.splice(this.lockItems.length-1,0,l.id),l.classList.add("e-disable"),this.disableRuleControls(e,l,!0),e.children[0].classList.add("e-lock"),e.children[0].classList.remove("e-unlock"),e.setAttribute("title",this.l10n.getConstant("UnlockRule")))},c.prototype.groupLock=function(e){var l=t.closest(e,".e-group-container"),i=this.getGroup(l.id.replace(this.element.id+"_","")),o=l.id.indexOf("group0")>-1;if(l.classList.contains("e-disable"))o?((n={}).condition=i.condition,n.not=i.not,n.isLocked=!1,this.setProperties({rule:n},!0)):i.isLocked=!1,this.lockItems=this.lockItems.filter(function(e){return e!==l.id}),l.classList.remove("e-disable"),this.disableHeaderControls(e,l,!1),e.children[0].classList.add("e-unlock"),e.children[0].classList.remove("e-lock"),e.setAttribute("title",this.l10n.getConstant("LockGroup")),this.updateLockItems();else{if(o){var n={};n.condition=i.condition,n.not=i.not,n.isLocked=!0,this.setProperties({rule:n},!0)}else i.isLocked=!0;this.lockItems.indexOf(l.id)<0&&this.lockItems.splice(this.lockItems.length-1,0,l.id),l.classList.add("e-disable"),this.disableHeaderControls(e,l,!0),e.children[0].classList.add("e-lock"),e.children[0].classList.remove("e-unlock"),e.setAttribute("title",this.l10n.getConstant("UnlockGroup"))}},c.prototype.updateLockItems=function(){for(var e=0;e<this.lockItems.length;e++)if(this.lockItems[e].split("_").length>2){var l=this.element.querySelector("#"+this.lockItems[e]),i=l.querySelector(".e-lock-rule-btn");(l=t.closest(i,".e-rule-container")).classList.contains("e-disable")||this.ruleLock(i)}else{var o=this.element.querySelector("#"+this.lockItems[e]),i=o.querySelector(".e-lock-grp-btn");(o=t.closest(i,".e-group-container")).classList.contains("e-disable")||this.groupLock(i)}},c.prototype.disableHeaderControls=function(e,t,l){for(var i=t.querySelectorAll(".e-btngroup-and"),o=t.querySelectorAll(".e-btngroup-or"),n=t.querySelectorAll(".e-qb-toggle"),r=t.querySelectorAll(".e-add-btn"),s=t.querySelectorAll(".e-deletegroup"),a=t.querySelectorAll(".e-lock-grp-btn"),u=t.querySelectorAll(".e-clone-grp-btn"),d=t.querySelectorAll(".e-group-container"),p=0;p<i.length;p++)l?(d[p]&&d[p].classList.contains("e-disable")&&d[p].classList.add("e-disable"),i[p].disabled=!0,o[p].disabled=!0,r[p].disabled=!0,n[p]&&(n[p].disabled=!0),s[p]&&(s[p].disabled=!0),u[p]&&(u[p].disabled=!0),i[p].parentElement.classList.add("e-disabled"),a[p]!==e&&(a[p].disabled=!0,a[p].children[0].classList.remove("e-unlock"),a[p].children[0].classList.add("e-lock"))):(d[p]&&d[p].classList.remove("e-disable"),i[p].disabled=!1,o[p].disabled=!1,r[p].disabled=!1,a[p].disabled=!1,n[p]&&(n[p].disabled=!1),s[p]&&(s[p].disabled=!1),u[p]&&(u[p].disabled=!1),i[p].parentElement.classList.remove("e-disabled"),a[p].children[0].classList.remove("e-lock"),a[p].children[0].classList.add("e-unlock"));this.disableRuleControls(e,t,l)},c.prototype.disableRuleControls=function(e,l,i){for(var o=l.querySelectorAll(".e-control.e-dropdownlist"),n=l.querySelectorAll(".e-control.e-numerictextbox"),r=l.querySelectorAll(".e-control.e-textbox"),s=l.querySelectorAll(".e-control.e-datepicker"),a=l.querySelectorAll(".e-control.e-checkbox"),u=l.querySelectorAll(".e-control.e-radio"),d=l.querySelectorAll(".e-control.e-multiselect"),p=l.querySelectorAll(".e-rule-delete"),c=l.querySelectorAll(".e-lock-rule"),h=l.querySelectorAll(".e-clone-rule"),m=l.querySelectorAll(".e-rule-container"),g=0;g<p.length;g++)i?(m[g]&&m[g].classList.contains("e-disable")&&m[g].classList.add("e-disable"),p[g].disabled=!0,h[g]&&(h[g].disabled=!0),c[g]!==e&&(c[g].disabled=!0,c[g].children[0].classList.remove("e-unlock"),c[g].children[0].classList.add("e-lock"))):(m[g]&&m[g].classList.remove("e-disable"),h[g]&&(h[g].disabled=!1),p[g].disabled=!1,c[g].disabled=!1,c[g].children[0].classList.remove("e-lock"),c[g].children[0].classList.add("e-unlock"));for(g=0;g<o.length;g++)t.getComponent(o[g],"dropdownlist").enabled=!i;for(g=0;g<n.length;g++)t.getComponent(n[g],"numerictextbox").enabled=!i;for(g=0;g<r.length;g++)t.getComponent(r[g],"textbox").enabled=!i;for(g=0;g<s.length;g++)t.getComponent(s[g],"datepicker").enabled=!i;for(g=0;g<a.length;g++)t.getComponent(a[g],"checkbox").disabled=!!i;for(g=0;g<u.length;g++)t.getComponent(u[g],"radio").disabled=!!i;for(g=0;g<d.length;g++)t.getComponent(d[g],"multiselect").enabled=!i},p([t.Event()],c.prototype,"created",void 0),p([t.Event()],c.prototype,"actionBegin",void 0),p([t.Event()],c.prototype,"beforeChange",void 0),p([t.Event()],c.prototype,"change",void 0),p([t.Event()],c.prototype,"dataBound",void 0),p([t.Event()],c.prototype,"ruleChange",void 0),p([t.Complex({},g)],c.prototype,"showButtons",void 0),p([t.Property(!1)],c.prototype,"summaryView",void 0),p([t.Property(!1)],c.prototype,"allowValidation",void 0),p([t.Property("Default")],c.prototype,"fieldMode",void 0),p([t.Property([])],c.prototype,"columns",void 0),p([t.Property(null)],c.prototype,"fieldModel",void 0),p([t.Property(null)],c.prototype,"operatorModel",void 0),p([t.Property(null)],c.prototype,"valueModel",void 0),p([t.Property()],c.prototype,"headerTemplate",void 0),p([t.Property("")],c.prototype,"cssClass",void 0),p([t.Property([])],c.prototype,"dataSource",void 0),p([t.Property("Horizontal")],c.prototype,"displayMode",void 0),p([t.Property(!1)],c.prototype,"enablePersistence",void 0),p([t.Property("Default")],c.prototype,"sortDirection",void 0),p([t.Property(5)],c.prototype,"maxGroupCount",void 0),p([t.Property("auto")],c.prototype,"height",void 0),p([t.Property("auto")],c.prototype,"width",void 0),p([t.Property(!1)],c.prototype,"matchCase",void 0),p([t.Property(0)],c.prototype,"immediateModeDelay",void 0),p([t.Property(!1)],c.prototype,"enableNotCondition",void 0),p([t.Property(!1)],c.prototype,"readonly",void 0),p([t.Property(!0)],c.prototype,"addRuleToNewGroups",void 0),p([t.Property(!1)],c.prototype,"autoSelectField",void 0),p([t.Property(!0)],c.prototype,"autoSelectOperator",void 0),p([t.Property("")],c.prototype,"separator",void 0),p([t.Complex({condition:"and",rules:[]},h)],c.prototype,"rule",void 0),c=p([t.NotifyPropertyChanges],c)}(t.Component),v=function(){function e(e){this.parent=e,this.addEventListener()}return e.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},e.prototype.addEventListener=function(){this.parent.isDestroyed||(this.parent.on("query-library",this.queryLibrary,this),this.parent.on("destroyed",this.destroy,this))},e.prototype.removeEventListener=function(){this.parent.off("query-library",this.queryLibrary),this.parent.off("destroyed",this.destroy)},e.prototype.queryLibrary=function(e){switch(e.prop){case"getMongoFromRules":e.value.obj.mongoQuery=this.getMongoFromRules(e.value.rule,e.value.mongoQuery);break;case"mongoParser":this.mongoParser(e.value.mongoQuery,e.value.rule,e.value.mongoLocale);break;case"getParameterSql":e.value.obj.sql=this.getParameterSql(e.value.rule);break;case"getNamedParameterSql":e.value.obj.sql=this.getNamedParameterSql(e.value.rule);break;case"convertParamSqlToSql":e.value.obj.sql=this.convertParamSqlToSql(e.value.sql);break;case"convertNamedParamSqlToSql":e.value.obj.sql=this.convertNamedParamSqlToSql(e.value.sql)}},e.prototype.getMongoFromRules=function(e,t){return t="{","or"===e.condition?(t+='"$or":[',t=this.convertMongoQuery(e.rules,t)+"]"):(t+='"$and":[',t=this.convertMongoQuery(e.rules,t)+"]"),t+="}"},e.prototype.getOperatorFromMongoOperator=function(e){var t;switch(e){case"$ne":t="notequal";break;case"$gt":t="greaterthan";break;case"$gte":t="greaterthanorequal";break;case"$lt":t="lessthan";break;case"$lte":t="lessthanorequal";break;case"$nin":t="notin"}return t},e.prototype.convertMongoQuery=function(e,t){var l=this,i=0;return e.forEach(function(o){i++,t+="{",void 0!==o.rules&&("or"===o.condition?(t+=' "$or":[',t=l.convertMongoQuery(o.rules,t)+"]"):(t+=' "$and":[',t=l.convertMongoQuery(o.rules,t)+"]"));var n="string"===o.type&&"in"!==o.operator&&"notin"!==o.operator&&o.value&&""!==o.value.trim()?o.value.replace(/'/g,"\\"):"";"string"!==o.type||"in"!==o.operator&&"notin"!==o.operator||!o.value||1!==o.value.length||(n=o.value[0].replace(/'/g,"\\"));var r=o.field?o.field.substring(0):"";switch(o.operator){case"contains":t+='"'+r+'":{"$regex":"'+n+'"}';break;case"notcontains":t+='"'+r+'":{"$not":{"$regex":"'+o.value+'"}}';break;case"startswith":t+='"'+r+'":{"$regex":"^'+n+'"}';break;case"notstartswith":t+='"'+r+'":{"$not":{"$regex":"^'+o.value+'"}}';break;case"endswith":t+='"'+r+'":{"$regex":"'+n+'$"}';break;case"notendswith":t+='"'+r+'":{"$not":{"$regex":"'+o.value+'$"}}';break;case"isnull":t+='"'+r+'": null';break;case"isnotnull":t+='"'+r+'":{"$ne": null}';break;case"isempty":t+='"'+r+'": ""';break;case"isnotempty":t+='"'+r+'":{"$ne": ""}';break;case"equal":"string"===o.type?t+='"'+r+'":"'+n+'"':"date"===o.type?t+='"'+r+'":"'+o.value+'"':(o.type,t+='"'+r+'":'+o.value);break;case"notequal":"string"===o.type?t+='"'+r+'":{"$ne":"'+n+'"}':"date"===o.type?t+='"'+r+'":{"$ne":"'+o.value+'"}':t+='"'+r+'":{"$ne":'+o.value+"}";break;case"in":"string"===o.type?o.value.length>1?(s=(s=o.value.map(function(e,t){return t<o.value.length?'"'+e+'"':""}).toString()).endsWith(",")?s.substring(0,s.length-1):s,t+='"'+r+'": { "$in": ['+s+"]}"):t+='"'+r+'": { "$in": ["'+n+'"]}':"number"===o.type&&(o.value.length>1?t+='"'+r+'": { "$in": ['+o.value.toString()+"]}":t+='"'+r+'": { "$in": ['+o.value+"]}");break;case"notin":if("string"===o.type)if(o.value.length>1){var s=o.value.map(function(e,t){return t<o.value.length?'"'+e+'"':""}).toString();s=s.endsWith(",")?s.substring(0,s.length-1):s,t+='"'+r+'": { "$nin": ['+s+"]}"}else t+='"'+r+'": { "$nin": ["'+n+'"]}';else"number"===o.type&&(o.value.length>1?t+='"'+r+'": { "$nin": ['+o.value.toString()+"]}":t+='"'+r+'": { "$nin": ['+o.value+"]}");break;case"greaterthan":"number"===o.type?t+='"'+r+'": { "$gt": '+o.value+"}":t+='"'+r+'": { "$gt": "'+o.value+'"}';break;case"greaterthanorequal":"number"===o.type?t+='"'+r+'": { "$gte": '+o.value+"}":t+='"'+r+'": { "$gte": "'+o.value+'"}';break;case"between":"number"===o.type?t+='"'+r+'": {"$gte":'+o.value[0]+', "$lte":'+o.value[1]+"}":t+='"'+r+'": {"$gte": "'+o.value[0]+'", "$lte": "'+o.value[1]+'"}';break;case"notbetween":"number"===o.type?t+='"$or":[{"'+r+'": {"$lt":'+o.value[0]+'}}, {"'+r+'": {"$gt":'+o.value[1]+"}}]":t+='"$or":[{"'+r+'": {"$lt": "'+o.value[0]+'"}}, {"'+r+'": {"$gt": "'+o.value[1]+'"}}]';break;case"lessthan":"number"===o.type?t+='"'+r+'": { "$lt": '+o.value+"}":t+='"'+r+'": { "$lt": "'+o.value+'"}';break;case"lessthanorequal":"number"===o.type?t+='"'+r+'": { "$lte": '+o.value+"}":t+='"'+r+'": { "$lte": "'+o.value+'"}'}t+="}",e.length!==i&&(t+=",")}),t},e.prototype.mongoParser=function(e,t,l){var i;Object.keys(e).indexOf("$and")>-1?(i=e.$and,t.condition="and"):Object.keys(e).indexOf("$or")>-1&&(i=e.$or,t.condition="or"),t.rules=[],this.mongoRecursion(i,t.rules,l)},e.prototype.mongoRecursion=function(e,l,i){for(var o,n,r,s,a,u,d,p,c,h,m,g=0,f=e.length;g<f;g++){var v=[],y=[];if(u=Object.keys(e[g])[0],d=e[g][u],"$and"===u)p=this.parent.enableNotCondition?{condition:u.replace("$",""),rules:[],not:!1}:{condition:u.replace("$",""),rules:[]},l.push(p),this.mongoRecursion(e[g][u],l[l.length-1].rules,i);else if("$or"===u){var b=void 0,C=[],S=[],x=[],O=[],k=[],w=[],q=[];Array.isArray(d)&&2===d.length&&(w=d[(S=Object.keys(d))[0]],q=d[S[1]],"object"==typeof w&&(C=Object.keys(w)[0],x=Object.keys(w[Object.keys(w)[0]])[0],O=Object.keys(q[Object.keys(q)[0]])[0],"$lt"===x&&"$gt"===O&&(o="notbetween",c={field:C,label:C,value:m=[k=w[C][x],q[C][O]],operator:o,type:n="number"==typeof k?"number":"date"},l.push(c),b=!0))),b||(p=this.parent.enableNotCondition?{condition:u.replace("$",""),rules:[],not:!1}:{condition:u.replace("$",""),rules:[]},l.push(p),this.mongoRecursion(e[g][u],l[l.length-1].rules,i))}else{if(null===(d=e[g][u])&&(o="isnull"),"boolean"==typeof d&&(o="equal",n="boolean",m=d),"number"==typeof d)m=d,n="number",o="equal";else if("object"==typeof d&&null!==d){h=Object.keys(d);for(var N=0;N<h.length;N++)s=h[N],r=d[h[N]],"$ne"===s&&t.isNullOrUndefined(r)&&(o="isnotnull",m=null),"$ne"===s&&"boolean"==typeof r&&(o="notequal",m=r,n="boolean"),h.length>=2&&h[N]?("object"==typeof r?(o="notbetween",u=Object.keys(r)[0],a=[Object.keys(r[u])[0]],v.push(r[u][a]),n="number"):(o="between",v.push(r)),"number"==typeof r&&(n="number")):"object"==typeof r&&null!==r?"$not"===s&&"$regex"===Object.keys(r)[0]?r.$regex.indexOf("^")>-1?(o="notstartswith",m=r.$regex.replace("^","")):r.$regex.indexOf("$")>-1?(o="notendswith",m=r.$regex.replace("$","")):(o="notcontains",m=r.$regex):(o="$in"===s?"in":"notin",y=r,n="number"==typeof r[0]?"number":"string"):"number"==typeof r&&(o=this.getOperatorFromMongoOperator(s),n="number",m=r),"string"==typeof r&&("$regex"===s&&(o="contains",m=r,n="string"),"$ne"===s&&(null!==r&&r.length>0&&isNaN(Date.parse(r))?(o="notequal",m=r):t.isNullOrUndefined(r)?(o="isnotnull",m=r):""===r&&(o="isnotempty",m=r),n="string"),r.indexOf("^")>-1&&(o="startswith",m=r.replace("^",""),n="string"),r.indexOf("$")>-1&&"$not"!==s&&(o="endswith",m=r.replace("$",""),n="string"),isNaN(Date.parse(r))||(o=o||this.getOperatorFromMongoOperator(s),n="date",m=r))}else d&&"string"==typeof d&&!isNaN(Date.parse(d))?(o="equal",m=d,n="date"):"string"==typeof d&&""!==d&&"true"!==d&&"false"!==d?(o="equal",m=d,n="string"):"string"==typeof d&&""===d&&(o="isempty",m=d,n="string");c=v&&v.length>1?{field:u,label:u,value:v,operator:o,type:n}:y&&y.length>1?{field:u,label:u,value:y,operator:o,type:n}:{field:u,label:u,value:m,operator:o,type:n},l.push(c),o=""}}},e.prototype.convertParamSqlToSql=function(e){for(var t=e.sql,l=e.params,i=t.split("?"),o=i[0],n=0;n<l.length;n++)o+="string"==typeof l[n]?"'"+l[n]+"'"+i[n+1]:l[n]+i[n+1];return o.length>=2&&"("===o[0]&&")"===o[o.length-1]&&(o=o.slice(1,-1)),o=o.replace(/!= ''(?! =)/g,"IS NOT EMPTY").replace(/= ''/g,"IS EMPTY")},e.prototype.convertNamedParamSqlToSql=function(e){var t=e.sql,l=e.params,i=t;return Object.keys(l).forEach(function(e){var t=l[e];e=":"+e,i=i.replace(e,"string"==typeof t?"'"+t+"'":String(t))}),i.length>=2&&"("===i[0]&&")"===i[i.length-1]&&(i=i.slice(1,-1)),i=i.replace(/!= ''(?! =)/g,"IS NOT EMPTY").replace(/= ''/g,"IS EMPTY")},e.prototype.getParameterSql=function(e){var l=t.extend({},e,null,!0),i=this.updateRuleValue(l,!1);return this.getParameterSQLVal(this.parent.getSqlFromRules(l),i.ruleVal)},e.prototype.getNamedParameterSql=function(e){var l=t.extend({},e,null,!0),i=this.updateRuleValue(l,!0);return this.getNamedParameterSQLVal(this.parent.getSqlFromRules(l),i.namedRuleVal)},e.prototype.getParameterSQLVal=function(e,t){return{sql:"("+e.replace(/[%']/g,"")+")",params:t}},e.prototype.getNamedParameterSQLVal=function(e,t){return{sql:"("+e.replace(/[%']/g,"")+")",params:t}},e.prototype.updateRuleValue=function(e,t){var l=[],i={},o=[];return this.updateValue(e.rules,t,l,i,o)},e.prototype.updateValue=function(e,l,i,o,n){if(t.isNullOrUndefined(e))return{ruleVal:i,namedRuleVal:o};for(var r=0;r<e.length;r++)if(e[r].rules)i=(u=this.updateValue(e[r].rules,l,i,o,n)).ruleVal,o=u.namedRuleVal;else{var s=void 0;if(e[r].value instanceof Array)for(var a=0;a<e[r].value.length;a++)l&&(s=this.getNamedParameter(e[r].field,n)),t.isNullOrUndefined(e[r].value[a])||("string"===e[r].type||e[r].type,l?o[s]=e[r].value[a]:i.push(e[r].value[a])),e[r].value[a]=l?":"+s:"?";else if(l&&(s=this.getNamedParameter(e[r].field,n)),e[r].operator.indexOf("null")<1&&("string"!==e[r].type||"string"===e[r].type&&(""!==e[r].value||0===e[r].value))){if("string"===e[r].type||"date"===e[r].type)if(e[r].operator.indexOf("empty")<1){var u=e[r].value.toString();switch(e[r].operator){case"startswith":case"notstartswith":u+="%";break;case"endswith":case"notendswith":u="%"+u;break;case"contains":case"notcontains":u="%"+u+"%"}l?o[s]=u:i.push(u)}else l?o[s]="":i.push(""),"isempty"===e[r].operator?e[r].operator="equal":e[r].operator="notequal";else t.isNullOrUndefined(e[r].value)||(l?o[s]=e[r].value:i.push(e[r].value));e[r].value=l?":"+s:"?"}}return{ruleVal:i,namedRuleVal:o}},e.prototype.getNamedParameter=function(e,t){var l=null;if(t.length>0)for(var i=t.length-1;i>=0;i--){var o=t[i];if(o.indexOf(e)>-1){l=e+"_"+(parseInt(o.split("_")[1],10)+1),t.push(l);break}}return l||(l=e+"_1",t.push(l)),l},e.prototype.getModuleName=function(){return"query-library"},e}();return f.Inject(v),e.Columns=c,e.Rule=h,e.Value=m,e.ShowButtons=g,e.QueryBuilder=f,e.QueryLibrary=v,e}({},ej.base,ej.buttons,ej.dropdowns,ej.data,ej.inputs,ej.calendars,ej.splitbuttons,ej.popups),this.ejs=ej;
10
+ this.ej=this.ej||{},this.ej.querybuilder=function(e,t,l,n,r,i,o,s,a){"use strict";var u=function(){var e=function(t,l){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var l in t)t.hasOwnProperty(l)&&(e[l]=t[l])})(t,l)};return function(t,l){function n(){this.constructor=t}e(t,l),t.prototype=null===l?Object.create(l):(n.prototype=l.prototype,new n)}}(),d=function(){return(d=Object.assign||function(e){for(var t,l=1,n=arguments.length;l<n;l++){t=arguments[l];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)},c=function(e,t,l,n){var r,i=arguments.length,o=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,l):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,l,n);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(o=(i<3?r(o):i>3?r(t,l,o):r(t,l))||o);return i>3&&o&&Object.defineProperty(t,l,o),o},p=function(e){function l(){return null!==e&&e.apply(this,arguments)||this}return u(l,e),c([t.Property(null)],l.prototype,"field",void 0),c([t.Property(null)],l.prototype,"label",void 0),c([t.Property(null)],l.prototype,"type",void 0),c([t.Property(null)],l.prototype,"values",void 0),c([t.Property(null)],l.prototype,"operators",void 0),c([t.Property()],l.prototype,"ruleTemplate",void 0),c([t.Property(null)],l.prototype,"template",void 0),c([t.Property({isRequired:!0,min:0,max:Number.MAX_VALUE})],l.prototype,"validation",void 0),c([t.Property(null)],l.prototype,"format",void 0),c([t.Property(null)],l.prototype,"step",void 0),c([t.Property(null)],l.prototype,"value",void 0),c([t.Property(null)],l.prototype,"category",void 0),c([t.Property(null)],l.prototype,"columns",void 0),l}(t.ChildProperty),h=function(e){function l(){return null!==e&&e.apply(this,arguments)||this}return u(l,e),c([t.Property(null)],l.prototype,"condition",void 0),c([t.Collection([],l)],l.prototype,"rules",void 0),c([t.Property(null)],l.prototype,"field",void 0),c([t.Property(null)],l.prototype,"label",void 0),c([t.Property(null)],l.prototype,"type",void 0),c([t.Property(null)],l.prototype,"operator",void 0),c([t.Property(null)],l.prototype,"value",void 0),c([t.Property(!1)],l.prototype,"not",void 0),c([t.Property(null)],l.prototype,"isLocked",void 0),l}(t.ChildProperty),g=function(e){function l(){return null!==e&&e.apply(this,arguments)||this}return u(l,e),c([t.Property(null)],l.prototype,"numericTextBoxModel",void 0),c([t.Property(null)],l.prototype,"multiSelectModel",void 0),c([t.Property(null)],l.prototype,"datePickerModel",void 0),c([t.Property(null)],l.prototype,"textBoxModel",void 0),c([t.Property(null)],l.prototype,"radioButtonModel",void 0),l}(t.ChildProperty),m=function(e){function l(){return null!==e&&e.apply(this,arguments)||this}return u(l,e),c([t.Property(!1)],l.prototype,"cloneRule",void 0),c([t.Property(!1)],l.prototype,"cloneGroup",void 0),c([t.Property(!1)],l.prototype,"lockRule",void 0),c([t.Property(!1)],l.prototype,"lockGroup",void 0),c([t.Property(!0)],l.prototype,"ruleDelete",void 0),c([t.Property(!0)],l.prototype,"groupInsert",void 0),c([t.Property(!0)],l.prototype,"groupDelete",void 0),l}(t.ChildProperty),f=function(e){function p(l,r){var i=e.call(this,l,r)||this;return i.isReadonly=!0,i.fields={text:"label",value:"field"},i.updatedRule={not:!1,condition:"and",isLocked:!1},i.isLocale=!1,i.isRefreshed=!1,i.isNotified=!1,i.isAddSuccess=!1,i.isNotValueChange=!1,i.isFieldChange=!1,i.isFieldClose=!1,i.isDestroy=!1,i.isGetNestedData=!1,i.isCustomOprCols=[],i.groupCounter=0,i.lockItems=[],i.groupIndex=-1,i.ruleIndex=-1,i.isLastGroup=!1,i.cloneGrpBtnClick=!1,i.isMiddleGroup=!1,i.cloneRuleBtnClick=!1,i.dragStopHandler=function(e){if(!i.isDragEventPrevent){var l=t.closest(e.target,".e-rule-container");t.isNullOrUndefined(l)&&e.target.parentElement&&e.target.parentElement.classList.contains("e-btn-group")&&i.enableSeparateConnector&&(l=t.closest(e.target.parentElement.previousElementSibling,".e-rule-container"));var n,r=t.closest(e.helper,".e-notallowedcur");if(!r){var o=t.closest(e.target,".e-group-container"),s={cancel:!1,dropRuleID:null!==l?l.id:null!==o?o.id:null,dropGroupID:null!==o?o.id:null};i.trigger("drop",s),s.cancel&&(r=!0),n=i.getValidRules()}i.prvtEvtTgrDaD=!0;var a=i.enableSeparateConnector&&e.target.parentElement&&e.target.parentElement.classList.contains("e-btn-group")?e.target.parentElement.previousElementSibling:e.target;if(l&&!r){var u=l.id.split(i.element.id+"_")[1].split("_")[0];if(i.draggable.currentStateTarget.parentElement.classList.contains("e-rule-field")||i.draggable.currentStateTarget.parentElement.classList.contains("e-group-header")){m=void 0;i.draggable.currentStateTarget.parentElement.classList.contains("e-group-header")?(m=i.getGroup(i.draggedRule),i.deleteGroup(t.closest(i.draggedRule,".e-group-container"))):(m=i.getRule(i.draggedRule),i.deleteRule(i.draggedRule)),(y=t.extend([],i.getGroup(l),[],!0)).properties&&(y=y.properties),(f=t.closest(l,".e-group-container")).querySelectorAll(".e-group-container").forEach(function(e){i.element.querySelector("#"+e.id)&&i.deleteGroup(e)});for(var d=f.querySelectorAll(".e-rule-container"),c=[],p=void 0,h=0;h<d.length;h++)(d[h].classList.contains("e-drag-rule-top-line")||d[h].classList.contains("e-drag-rule-bottom-line"))&&(p=h),c.push(d[h].id.split(i.element.id+"_")[1]);i.deleteRules(c),l.classList.contains("e-drag-rule-top-line")?y.rules.splice(p,0,m):y.rules.splice(p+1,0,m),y.rules.forEach(function(e){i.enableSeparateConnector?e.rules?i.addGroups([e],u):i.addRules([e],u):e.condition?i.addGroups([e],u):i.addRules([e],u)})}}else if(a.classList.contains("e-rule-list")&&0===a.children.length&&!r){var g=(f=t.closest(a,".e-group-container")).id.split(i.element.id+"_")[1].split("_")[0],m=void 0;i.draggable.currentStateTarget.parentElement.classList.contains("e-group-header")?(m=i.getGroup(i.draggedRule),i.deleteGroup(t.closest(i.draggedRule,".e-group-container"))):(m=i.getRule(i.draggedRule),i.deleteRule(i.draggedRule)),i.enableSeparateConnector?m.rules?i.addGroups([m],g):i.addRules([m],g):m.condition?i.addGroups([m],g):i.addRules([m],g)}else if(a.classList.contains("e-rule-list")&&a.children[0].classList.contains("e-group-container")&&!r){var f=t.closest(a,".e-group-container"),v=f.id.split(i.element.id+"_")[1].split("_")[0],m=void 0;i.draggable.currentStateTarget.parentElement.classList.contains("e-group-header")?(m=i.getGroup(i.draggedRule),i.deleteGroup(t.closest(i.draggedRule,".e-group-container"))):(m=i.getRule(i.draggedRule),i.deleteRule(i.draggedRule));var y=t.extend([],i.getGroup(a),[],!0);y.properties&&(y=y.properties),a.querySelectorAll(".e-group-container").forEach(function(e){i.element.querySelector("#"+e.id)&&i.deleteGroup(e)}),(d=f.querySelectorAll(".e-rule-container")).forEach(function(e){i.element.querySelector("#"+e.id)&&i.deleteRule(e)}),i.draggable.currentStateTarget.parentElement.classList.contains("e-group-header")?i.addGroups([m],v):i.addRules([m],v),y.rules.forEach(function(e){i.enableSeparateConnector?e.rules?i.addGroups([e],v):i.addRules([e],v):e.condition?i.addGroups([e],v):i.addRules([e],v)})}else if((t.closest(e.target,".e-group-container")||e.target.classList.contains("e-group-container"))&&!r){m=void 0;!(l=t.closest(e.target,".e-group-container"))&&e.target.classList.contains("e-group-container")&&(l=e.target),"group0"===(g=l.id.split(i.element.id+"_")[1].split("_")[0])&&(i.draggable.currentStateTarget.parentElement.classList.contains("e-group-header")?(m=i.getGroup(i.draggedRule),i.deleteGroup(t.closest(i.draggedRule,".e-group-container"))):(m=i.getRule(i.draggedRule),i.deleteRule(i.draggedRule)),i.enableSeparateConnector?m.rules?i.addGroups([m],g):i.addRules([m],g):m.condition?i.addGroups([m],g):i.addRules([m],g))}r||i.trigger("ruleChange",{previousRule:n,rule:i.getValidRules(),type:"drag-and-drop"}),i.prvtEvtTgrDaD=!1,document.body.classList.remove("e-prevent-select");var b=i.element.querySelectorAll(".e-drag-rule-bottom-line");b.forEach(function(e){e.classList.remove("e-drag-rule-bottom-line")}),(b=i.element.querySelectorAll(".e-drag-rule-top-line")).forEach(function(e){e.classList.remove("e-drag-rule-top-line")}),(b=i.element.querySelectorAll(".e-qb-dragging-rule")).forEach(function(e){e.classList.remove("e-qb-dragging-rule")}),e.helper.classList.contains("e-cloneproperties")&&document.querySelector("."+e.helper.classList[0])&&t.remove(e.helper),i.enableSeparateConnector&&i.refresh()}},n.MultiSelect.Inject(n.CheckBoxSelection),i}return u(p,e),p.prototype.getPersistData=function(){return this.addOnPersist(["rule"])},p.prototype.reset=function(){this.isImportRules=!1;for(var e=this.element.querySelector(".e-group-body"),l=this.element.querySelectorAll("input.e-control"),n=0,r=l.length;n<r;n++)l[n].className.indexOf("e-tooltip")>-1?t.getComponent(l[n],"tooltip").destroy():l[n].parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(l[n].parentElement,"tooltip").destroy();if(e)e.innerHTML="";else{var i=this.createElement("div",{attrs:{class:"e-group-container"}}),o=this.createElement("div",{attrs:{class:"e-group-header"}}),s=this.createElement("div",{attrs:{class:"e-group-body"}});i.appendChild(o).appendChild(s),this.element.appendChild(i),e=this.element.querySelector(".e-group-body")}this.headerTemplate&&this.isRoot&&(this.element.innerHTML="",this.isRoot=!1),this.enableNotCondition&&t.removeClass(this.element.querySelectorAll(".e-qb-toggle"),"e-active-toggle"),e.appendChild(this.createElement("div",{attrs:{class:"e-rule-list"}})),this.levelColl[this.element.id+"_group0"]=[0],this.setProperties({rule:{condition:"and",not:!1,rules:[]}},!0),this.disableRuleCondition(e.parentElement)},p.prototype.getWrapper=function(){return this.element},p.prototype.getModuleName=function(){return"query-builder"},p.prototype.requiredModules=function(){var e=[];return e.push({member:"query-library",args:[this]}),e},p.prototype.GetRootColumnName=function(e){return this.separator?e.split(this.separator)[0]:e},p.prototype.initialize=function(){if(this.dataColl.length){var e=Object.keys(this.dataColl[0]),t=[],l=[],n=void 0,r=!1,i=!1,o=void 0,s={isRequired:!0,min:0,max:Number.MAX_VALUE};if(this.columns.length){this.columnSort();for(var a=0,u=(d=this.columns).length;a<u;a++)this.updateCustomOperator(d[a],"initial"),d[a].type||(e.indexOf(d[a].field)>-1&&("string"===(n=typeof(o=this.dataColl[0][d[a].field]))?i=!isNaN(Date.parse(o)):"object"===n&&(i=o instanceof Date&&!isNaN(o.getTime()),n="string"),d[a].type=n,i=!1),n="string"),d[a].validation||(d[a].validation=s),d[a].category?r=!0:d[a].category=this.l10n.getConstant("OtherFields"),l.indexOf(d[a].category)<0&&l.push(d[a].category),(!d[a].operators||this.isLocale&&0!==this.isCustomOprCols.indexOf(d[a].field))&&(d[a].operators=this.customOperators[d[a].type+"Operator"]);r&&(l.length>1||l[0]!==this.l10n.getConstant("OtherFields"))&&(this.fields={text:"label",value:"field",groupBy:"category"}),this.updateSubFieldsFromColumns(this.columns)}else{for(var a=0,u=e.length;a<u;a++)"string"===(n=typeof(o=this.dataColl[0][e[a]]))?i=!isNaN(Date.parse(o)):"object"!==n||Object.keys(o).length||(i=o instanceof Date&&!isNaN(o.getTime()),n="string"),t[a]={field:e[a],label:e[a],type:i?"date":n,validation:s},i=!1,t[a].operators=this.customOperators[t[a].type+"Operator"],"object"===n&&this.updateSubFields(o,t[a]);this.columns=t}}else if(this.columns&&this.columns.length){for(var d=this.columns,a=0,u=d.length;a<u;a++)d[a].category?this.fields={text:"label",value:"field",groupBy:"category"}:d[a].category=this.l10n.getConstant("OtherFields"),this.updateCustomOperator(d[a]),d[a].operators&&!this.isLocale||(d[a].operators=this.customOperators[d[a].type+"Operator"]);this.updateSubFieldsFromColumns(this.columns)}this.trigger("dataBound",{type:"dataBound"})},p.prototype.updateSubFieldsFromColumns=function(e,t){for(var l=0;l<e.length;l++)""!==this.separator&&e[l].field.indexOf(this.separator)<0&&(e[l].field=t?t+this.separator+e[l].field:e[l].field),e[l].operators?this.updateCustomOperator(e[l]):e[l].type&&"object"!==e[l].type&&(e[l].operators=this.customOperators[e[l].type+"Operator"]),e[l].columns&&(e[l].type="object",this.updateSubFieldsFromColumns(e[l].columns,e[l].field))},p.prototype.updateSubFields=function(e,t,l){var n;t.columns=[];var r,i,o=Object.keys(e);l=l||this.dataColl[0];for(var s=0,a=o.length;s<a;s++){var u=t.field.split(".");i=l?l[u[u.length-1]][o[s]]:this.dataColl[0][t.field][o[s]];var d=l[t.field.split(this.separator)[t.field.split(this.separator).length-1]];r=typeof i,n={field:t.field+this.separator+o[s],label:o[s],type:r="object"!==r||isNaN(Date.parse(i))?r:"date"},"object"!==r&&(n.operators=this.customOperators[r+"Operator"]),t.columns.push(n),"object"===r&&this.updateSubFields(i,n,d)}},p.prototype.updateCustomOperator=function(e,l){if(e.operators){this.isLocale||"initial"!==l||t.isNullOrUndefined(this.isCustomOprCols)||this.isCustomOprCols.push(e.field);for(var n=this,r=0;r<e.operators.length;r++)!function(t){var l=Object.keys(e.operators[t]).indexOf("sqlOperator");if(l>-1){var r=e.operators[t],i=Object.keys(r),o=i.map(function(e){return r[""+e]}).join(",").split(","),s=i.indexOf("value");n.operators[o[s]]=o[l]}}(r)}},p.prototype.focusEventHandler=function(e){this.target=e.target},p.prototype.clickEventHandler=function(e){var l,n=this,r=e.target;this.isImportRules=!1;var i;if("SPAN"===r.tagName&&(r=r.parentElement),r.className.indexOf("e-collapse-rule")>-1){a=new t.Animation({duration:1e3,delay:0});this.element.querySelectorAll(".e-summary-content").length<1&&this.renderSummary();var o=document.getElementById(this.element.id+"_summary_content"),s=o.querySelector(".e-summary-text");a.animate(".e-query-builder",{name:"SlideLeftIn"}),(d=this.element.querySelector(".e-group-container")).style.display="none",s.textContent=this.getSqlFromRules(this.rule),o.style.display="block",s.style.height=s.scrollHeight+"px"}if("BUTTON"===r.tagName&&r.className.indexOf("e-qb-toggle")<0){var a=new t.Animation({duration:1e3,delay:0});switch(!0){case r.className.indexOf("e-removerule")>-1:this.actionButton=r,this.deleteRule(r);break;case r.className.indexOf("e-clone-rule-btn")>-1:this.actionButton=r,this.cloneRuleBtnClick=!0,this.ruleClone(r);break;case r.className.indexOf("e-lock-rule-btn")>-1:this.actionButton=r,this.ruleLock(r);break;case r.className.indexOf("e-lock-grp-btn")>-1:this.actionButton=r,this.groupLock(r);break;case r.className.indexOf("e-clone-grp-btn")>-1:this.actionButton=r,this.cloneGrpBtnClick=!0,this.groupClone(t.closest(r,".e-group-container"));break;case r.className.indexOf("e-deletegroup")>-1:this.actionButton=r,this.deleteGroup(t.closest(r,".e-group-container"));break;case r.className.indexOf("e-edit-rule")>-1:if(a.animate(".e-query-builder",{name:"SlideLeftIn"}),document.getElementById(this.element.id+"_summary_content").style.display="none",this.element.querySelectorAll(".e-group-container").length<1){this.addGroupElement(!1,this.element,this.rule.condition,!1,this.rule.not);var u=t.extend({},this.rule,{},!0);this.setGroupRules(u),this.renderSummaryCollapse()}else{var d=this.element.querySelector(".e-group-container");d.querySelectorAll(".e-collapse-rule").length<1&&this.renderSummaryCollapse(),d.style.display="block"}}}else if("LABEL"===r.tagName&&r.parentElement.className.indexOf("e-btn-group")>-1||r.className.indexOf("e-qb-toggle")>-1){var c=t.closest(r,".e-group-container");if(!this.headerTemplate){var p=r.getAttribute("for"),h=void 0;p?h=document.getElementById(p).getAttribute("value"):this.enableSeparateConnector&&(h=r.textContent),i=c.id.replace(this.element.id+"_","");var g=this.getGroup(i),m=void 0;if(this.enableNotCondition)if(r.className.indexOf("e-qb-toggle")>-1){var f=c.getElementsByClassName("e-qb-toggle")[0];f.className.indexOf("e-active-toggle")>-1?(t.removeClass([f],"e-active-toggle"),m=!1):(t.addClass([f],"e-active-toggle"),m=!0),h=g.condition}else m=g.not;l={groupID:i,cancel:!1,type:"condition",value:h.toLowerCase()},this.enableNotCondition&&(l={groupID:i,cancel:!1,type:"condition",value:h.toLowerCase(),not:m})}this.isImportRules?this.beforeSuccessCallBack(l,r):this.trigger("beforeChange",l,function(e){n.beforeSuccessCallBack(e,r)}),this.target=r}},p.prototype.beforeSuccessCallBack=function(e,l){if(e&&!e.cancel){var n=t.closest(l,".e-group-container"),r=n.id.replace(this.element.id+"_",""),i=this.getValidRules(this.rule),o=this.getParentGroup(n);if(this.enableSeparateConnector){var s=(n=t.isNullOrUndefined(t.closest(l,".e-rule-container"))&&n.classList.contains("e-group-container")?null!==l.parentElement.previousElementSibling?l.parentElement.previousElementSibling:n:t.closest(l,".e-rule-container")).id.replace(this.element.id+"_","");n.classList.contains("e-rule-container")?(o=this.getRule(n)).condition=e.value:n.classList.contains("e-group-container")&&((o=this.getGroup(n)).condition=e.value),this.enableNotCondition&&(o.not=e.not),this.isImportRules||this.trigger("change",{groupID:r,ruleID:s,type:"condition",value:o.condition})}else o.condition=e.value,this.enableNotCondition&&(o.not=e.not),this.isImportRules||this.trigger("change",{groupID:r,type:"condition",value:o.condition});if(this.filterRules(i,this.getValidRules(this.rule),"condition"),this.enableSeparateConnector){var a=l.parentElement.querySelector(".e-btngroup-and"),u=l.parentElement.querySelector(".e-btngroup-or");a&&u&&("and"===e.value?(a.checked=!0,u.checked=!1):"or"===e.value&&(u.checked=!0,a.checked=!1))}}},p.prototype.selectBtn=function(e,l){"beforeOpen"===l.name?this.showButtons.groupInsert||t.isNullOrUndefined(this.showButtons.groupInsert)?(this.element.querySelectorAll(".e-group-container").length>=this.maxGroupCount+1?t.addClass([l.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"):t.removeClass([l.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"),this.enableRtl&&t.addClass([l.element.querySelector("li").parentElement],"e-rtl")):t.addClass([l.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"):l.element.children[0].className.indexOf("e-addrule")>-1?this.addRuleElement(t.closest(e,".e-group-container"),{}):l.element.children[0].className.indexOf("e-addgroup")>-1&&this.addGroupElement(!0,t.closest(e,".e-group-container"),"",!0)},p.prototype.appendRuleElem=function(e,l,n,r,i,o){var s,a,u,d=e.querySelector(".e-rule-list");if("change"===n)s=t.select("#"+r,e);else{if((s=this.createElement("div",{attrs:{class:"e-rule-container"}})).setAttribute("id",e.id+"_rule"+this.ruleIdCounter),this.showButtons.cloneRule&&this.cloneRuleBtnClick){if(this.ruleIndex<0)d.appendChild(s);else if(this.enableSeparateConnector){for(var c=-1,p=this.ruleIndex+1,h=0;h<p&&h!==d.children.length;h++)d.children[h].classList.contains("e-rule-container")&&(p++,c++);d.insertBefore(s,d.children[this.ruleIndex+c+1])}else d.insertBefore(s,d.children[this.ruleIndex+1]);this.cloneRuleBtnClick=!1}else d.appendChild(s);this.ruleIdCounter++}if(l&&l.ruleTemplate&&o){u={requestType:"template-initialize",ruleID:s.id,action:i,fields:this.fields,rule:o},this.trigger("actionBegin",u),this.ruleTemplateFn=this.templateParser(l.ruleTemplate);var g=this.element.id+l.field;if(u.fields=this.fields,u.columns=this.columns,""===o.field&&(o.field=l.field),u.operators=this.getOperators(o.field),u.operatorFields={text:"key",value:"value"},this.isReact)(a=this.ruleTemplateFn(u,this,s.id,g)[0]).className+=" e-rule-field",s.appendChild(a);else if(this.isAngular){var m=this.ruleTemplateFn(u,this,s.id,g);(a=3===m[0].nodeType?m[1]:m[0]).className+=" e-rule-field",s.appendChild(a)}else this.isVue3?(a=this.ruleTemplateFn(u,this,"Template",g),t.append(a,s),s.children[s.children.length-1].className+=" e-rule-field"):((a=this.ruleTemplateFn(u,this,"Template",g)[0]).className+=" e-rule-field",s.appendChild(a))}else a=this.ruleElem.querySelector(".e-rule-field").cloneNode(!0),s.appendChild(a);return this.showButtons.lockGroup&&t.removeClass(s.querySelectorAll(".e-lock-grp-btn"),"e-button-hide"),this.showButtons.lockRule&&t.removeClass(s.querySelectorAll(".e-lock-rule-btn"),"e-button-hide"),this.showButtons.cloneGroup&&t.removeClass(s.querySelectorAll(".e-clone-grp-btn"),"e-button-hide"),this.showButtons.cloneRule&&t.removeClass(s.querySelectorAll(".e-clone-rule-btn"),"e-button-hide"),this.showButtons.ruleDelete&&t.removeClass(s.querySelectorAll(".e-lock-grp-btn"),"e-button-hide"),this.allowDragAndDrop&&t.removeClass(s.querySelectorAll(".e-drag-qb-rule"),"e-hidden"),l&&l.ruleTemplate&&o&&this.renderReactTemplates(),s},p.prototype.addRuleElement=function(e,t,l,n,r,i){var o=this;if(e){var s={groupID:e.id.replace(this.element.id+"_",""),cancel:!1,type:"insertRule"};this.isImportRules||this.isInitialLoad||this.prvtEvtTgrDaD?(this.isInitialLoad=!1,this.addRuleSuccessCallBack(s,e,t,l,n,r,i)):this.trigger("beforeChange",s,function(s){o.addRuleSuccessCallBack(s,e,t,l,n,r,i)})}},p.prototype.addRuleSuccessCallBack=function(e,l,r,i,o,s,a){var u,c,p,h,g=this.element.className.indexOf("e-device")>-1?"250px":"200px",m=r&&r.field?this.getColumn(r.field):i||this.columns[0],f={label:"",field:"",type:"",operator:""};if(!e.cancel){if(m&&m.ruleTemplate&&r.field){this.selectedColumn=m,c=this.selectedColumn.operators,f={label:m.label,field:m.field,type:m.type,operator:c[0].value};var v=Object.keys(r).length?r:f,y={requestType:"template-create",action:"insert-rule",ruleID:(h=this.appendRuleElem(l,m,o,s,"field",v)).id,fields:this.fields,rule:v};this.trigger("actionBegin",y)}else{(h=this.appendRuleElem(l,m,o,s,"field")).querySelector(".e-filter-input").setAttribute("id",h.id+"_filterkey");var b=h.querySelector(".e-rule-delete");if(this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode)b.textContent=this.l10n.getConstant("Remove"),t.addClass([b],"e-flat"),t.addClass([b],"e-primary");else{t.addClass([b],"e-round"),t.addClass([b],"e-icon-btn"),b.setAttribute("title",this.l10n.getConstant("DeleteRule"));var C=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-delete-icon"}});h.querySelector(".e-rule-delete").appendChild(C)}this.showButtons.ruleDelete||b.classList.add("e-button-hide")}"Vertical"===this.displayMode||this.element.className.indexOf("e-device")>-1?h.className="e-rule-container e-vertical-mode":h.className="e-rule-container e-horizontal-mode";var S=h.previousElementSibling;if(this.enableSeparateConnector){var x=void 0,q=void 0;if(S&&S.classList.contains("e-group-container")&&(S=(q=S.querySelectorAll(".e-rule-container"))[q.length-1]),S&&S.classList.contains("e-rule-container")&&(x=this.getRule(S)),this.headerTemplate&&S&&x)this.headerTemplateFn(S,!1,x.condition,x,S.id);else if(t.isNullOrUndefined(S)&&h.id!==this.element.id+"_group0_rule0")if((B=h.closest(".e-group-container"))&&B.previousElementSibling){var E=(I=B.previousElementSibling).querySelectorAll(".e-rule-container");if(I.classList.contains("e-group-container")&&(I=E[E.length-1]),I.classList.contains("e-rule-container")){var k=this.getRule(I);this.headerTemplateFn(I,!1,k.condition,k,I.id,!0)}}else this.headerTemplateFn(h,!1,r.condition,r,h.id,!0)}else S&&S.className.indexOf("e-rule-container")>-1&&(h.className.indexOf("e-joined-rule")<0&&(h.className+=" e-joined-rule"),S.className.indexOf("e-prev-joined-rule")<0&&(S.className+=" e-prev-joined-rule"));if(S&&S.className.indexOf("e-group-container")>-1&&h.className.indexOf("e-separate-rule")<0&&(h.className+=" e-separate-rule"),this.isImportRules||this.updateAddedRule(l,r,f,a,s,!!this.enableSeparateConnector||null),!m||m&&!m.ruleTemplate||!r.field)if("Default"===this.fieldMode){var O=void 0,w=void 0;w=this.separator&&r.field?this.GetRootColumnName(r.field):this.autoSelectField?this.GetRootColumnName(r.field):this.isImportRules?this.GetRootColumnName(r.field):r.field,O={dataSource:this.columns,fields:this.fields,placeholder:this.l10n.getConstant("SelectField"),popupHeight:this.columns.length>5?g:"auto",close:this.fieldClose.bind(this,h.id+"_filterkey"),change:this.changeField.bind(this),value:r?w:null,open:this.popupOpen.bind(this,!0),cssClass:"qb-dropdownlist"},this.fieldModel&&(O=d({},O,this.fieldModel)),(p=new n.DropDownList(O)).appendTo("#"+h.id+"_filterkey");R=void 0;R=this.separator&&r.field?this.GetRootColumnName(r.field):this.isImportRules?this.GetRootColumnName(r.field):p.value,this.selectedColumn=p.getDataByValue(R),Object.keys(r).length&&this.changeRule(r,{element:p.element,itemData:this.selectedColumn})}else{var O=void 0,w=(this.isImportRules,r.field);this.dummyDropdownTreeDs=t.extend([],this.columns,[],!0),this.updateDropdowntreeDS(this.dummyDropdownTreeDs),O={fields:{dataSource:this.dummyDropdownTreeDs,value:"field",text:"label",child:"columns",expanded:"expanded",selectable:"selectable"},placeholder:this.l10n.getConstant("SelectField"),showClearButton:!1,popupHeight:this.columns.length>5?g:"auto",changeOnBlur:!1,change:this.changeField.bind(this),value:t.isNullOrUndefined(w)?null:[w],open:this.popupOpen.bind(this,!1),treeSettings:{expandOn:"Click"},cssClass:"e-qb-ddt"},this.fieldModel&&(O=d({},O,this.fieldModel));var N=new n.DropDownTree(O);if(N.appendTo("#"+h.id+"_filterkey"),!t.isNullOrUndefined(N.value)){var L=this.getLabelFromColumn(N.value[0]);N.element.value=L}var R=t.isNullOrUndefined(r.field)?N.value:this.GetRootColumnName(r.field);this.selectedColumn=this.getColumn(R),Object.keys(r).length&&this.changeRule(r,{element:N.element,itemData:this.selectedColumn})}if(u=h.id.replace(this.element.id+"_",""),r&&r.isLocked){var D=h.querySelector(".e-lock-rule-btn");this.ruleLock(D)}this.isImportRules||this.prvtEvtTgrDaD||this.trigger("change",{groupID:l.id.replace(this.element.id+"_",""),ruleID:u,type:"insertRule"})}if(this.enableSeparateConnector&&t.isNullOrUndefined(r.condition)&&u&&(r=this.getRule(u)),this.enableSeparateConnector){for(var I=h.previousElementSibling,q=void 0;I&&!I.classList.contains("e-rule-container");){if(I.classList.contains("e-group-container")){I=(q=I.querySelectorAll(".e-rule-container"))[q.length-1];break}I=I.previousElementSibling}if(this.headerTemplate&&I){var x=this.getRule(I),T={requestType:"rule-template-create",ruleID:I.id,condition:x.condition,notCondition:!!this.enableNotCondition||void 0};this.trigger("actionBegin",T)}else if(t.isNullOrUndefined(I)&&h.id!==this.element.id+"_group0_rule0"){var B=h.closest(".e-group-container");if(B&&B.previousElementSibling&&B.previousElementSibling.previousElementSibling){var P=B.previousElementSibling.previousElementSibling;if(P.classList.contains("e-group-container")){var A=P.querySelectorAll(".e-rule-container");P=A[A.length-1]}if(P.classList.contains("e-rule-container")){var x=this.getRule(P),G={requestType:"rule-template-create",ruleID:P.id,condition:x.condition,notCondition:!!this.enableNotCondition||void 0};this.trigger("actionBegin",G)}}}this.setMultiConnector(h)}},p.prototype.updateDropdowntreeDS=function(e){for(var t=0;t<e.length;t++)"object"===e[parseInt(t.toString(),10)].type&&(e[parseInt(t.toString(),10)].selectable=!1,this.updateDropdowntreeDS(e[parseInt(t.toString(),10)].columns))},p.prototype.updateAddedRule=function(e,l,n,r,i,o){var s,a,u,d=0;if(r){for(s=t.select("#"+i,e),a=t.closest(e,".e-group-container"),u=this.getParentGroup(a);s&&null!==s.previousElementSibling;){s=s.previousElementSibling;var c=this.enableSeparateConnector&&(!this.headerTemplate&&!s.classList.contains("e-btn-group")||this.headerTemplate&&(s.classList.contains("e-rule-container")||s.classList.contains("e-group-container")));this.enableSeparateConnector&&!c||d++}u.rules[d]=l}else{a=t.closest(e,".e-group-container"),u=this.getParentGroup(a);var p=l.custom;Object.keys(l).length?this.ruleIndex<0?(u.rules.push({field:l.field,type:l.type,label:l.label,operator:l.operator,value:l.value}),p&&(u.rules[u.rules.length-1].custom=p),this.enableSeparateConnector&&(u.rules[u.rules.length-1].condition=l.condition?l.condition:n.condition)):(u.rules.splice(this.ruleIndex+1,0,{field:l.field,type:l.type,label:l.label,operator:l.operator,value:l.value}),p&&(u.rules[this.ruleIndex+1].custom=p),this.enableSeparateConnector&&(u.rules[this.ruleIndex+1].condition=l.condition?l.condition:n.condition)):(p&&(n.custom=p),this.autoSelectField&&(l.field=n.field=this.rule.rules[0].field),u.rules.push(n))}this.disableRuleCondition(e,u,o)},p.prototype.changeRuleTemplate=function(e,l){var n=this.selectedColumn.operators;if(!e.ruleTemplate){var r=t.closest(l,".e-group-container"),i=t.closest(l,".e-rule-container").id;if(this.previousColumn&&this.previousColumn.ruleTemplate&&(t.detach(l.closest('[id="'+i+'"]').querySelector(".e-rule-field")),this.clearQBTemplate([i])),e){var o={field:e.field,label:e.label,operator:n[0].value,value:""};this.addRuleElement(r,o,e,"change",i,!0)}}},p.prototype.renderToolTip=function(e){var t=new a.Tooltip({content:this.l10n.getConstant("ValidationMessage"),isSticky:!0,position:"BottomCenter",cssClass:"e-querybuilder-error",afterClose:function(){t.destroy()},beforeOpen:function(e){var t=e.element.querySelector(".e-tooltip-close");t&&(t.style.display="none")}});t.appendTo(e),t.open(e)},p.prototype.validateFields=function(){var e,l=!0;if(this.allowValidation){var n=["isnull","isnotnull","isempty","isnotempty"],r=void 0,i=void 0,o=void 0,s=void 0,a=[],u=void 0,d=void 0,c=void 0,p=void 0,h=void 0,g=this.element.querySelectorAll(".e-rule-container");for(r=0,i=g.length;r<i;r++){var m=void 0;if(u=t.closest(g[r],".e-group-container"),h=this.getParentGroup(u),d=0,s=p=g[r],"DropdownTree"===this.fieldMode?(e=t.getComponent(g[r].querySelector(".e-rule-filter input.e-dropdowntree"),"dropdowntree"))&&e.value&&e.value.length&&(this.selectedColumn=this.getColumn(e.value[0]),m=this.selectedColumn.validation):(c=t.getComponent(g[r].querySelector(".e-rule-filter input.e-dropdownlist"),"dropdownlist"))&&c.value&&(this.selectedColumn=c.getDataByValue(c.value),m=!t.isNullOrUndefined(c.index)&&this.selectedColumn.validation),o=p.querySelector(".e-rule-field input.e-control"),m&&m.isRequired){for(;s&&null!==s.previousElementSibling;){s=s.previousElementSibling;var f=this.enableSeparateConnector&&(!this.headerTemplate&&!s.classList.contains("e-btn-group")||this.headerTemplate&&(s.classList.contains("e-rule-container")||s.classList.contains("e-group-container")));this.enableSeparateConnector&&!f||d++}if(o=p.querySelector(".e-rule-operator .e-control"),h.rules[d].operator||(o.parentElement.className.indexOf("e-tooltip")<0&&o.className.indexOf("e-tooltip")<0&&this.renderToolTip(o.parentElement),l=!1),h.rules[d].value instanceof Array&&(a=h.rules[d].value),n.indexOf(h.rules[d].operator)<-1&&t.isNullOrUndefined(h.rules[d].value)&&"date"!==h.rules[d].type||""===h.rules[d].value||h.rules[d].value instanceof Array&&a.length<1){var v=p.querySelectorAll(".e-rule-value .e-control");l=!1;for(var y=0,b=v.length;y<b;y++){var C=v[y],S=void 0;C.parentElement.className.indexOf("e-searcher")>-1?(S=t.closest(C,".e-multi-select-wrapper")).className.indexOf("e-tooltip")<0&&this.renderToolTip(S):v[y].parentElement.className.indexOf("e-tooltip")<0&&v[y].className.indexOf("e-tooltip")<0&&this.renderToolTip(v[y].parentElement),y++}}}else(c&&c.element&&t.isNullOrUndefined(c.index)||e&&e.element&&(t.isNullOrUndefined(e.value)||e.value.length<1))&&(o.parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(o.parentElement),l=!1)}}return l},p.prototype.refreshLevelColl=function(){this.levelColl={};var e=this.element.querySelector(".e-group-container");if(e){this.levelColl[e.id]=[0];var t={groupElement:e,level:[0]};this.refreshLevel(t)}},p.prototype.refreshLevel=function(e){var l,n,r=e.groupElement.querySelector(".e-rule-list").children,i=e.groupElement,o=r.length,s=0;for(n=0;n<o;n++)(l=r[n]).className.indexOf("e-group-container")>-1&&(e.level.push(s),this.levelColl[l.id]=e.level.slice(),s++,e.groupElement=l,e=this.refreshLevel(e));var a=t.closest(i,".e-rule-list");return e.groupElement=a?t.closest(a,".e-group-container"):i,e.level=this.levelColl[e.groupElement.id].slice(),e},p.prototype.groupTemplate=function(e){var t,l,n,r,i,o,s=this.createElement("div",{attrs:{class:"e-group-container"}}),a=this.createElement("div",{attrs:{class:"e-group-header"}}),u=this.createElement("div",{attrs:{class:"e-group-body"}}),d=this.createElement("div",{attrs:{class:"e-rule-list"}});if(s.appendChild(a),u.appendChild(d),s.appendChild(u),!this.headerTemplate){n=this.allowDragAndDrop?"e-icons e-drag-qb-rule":"e-icons e-drag-qb-rule e-hidden";var c=this.createElement("span",{attrs:{class:n,"aria-lable":"drag handle",title:"drag handle"}});a.appendChild(c);var p=this.enableSeparateConnector&&!e?"e-lib e-btn-group e-qb-toggle-btn":"e-lib e-btn-group";t=this.createElement("div",{attrs:{class:p,role:"group"}}),this.enableSeparateConnector&&t.classList.add("e-multi-connector"),this.enableNotCondition&&(l=this.enableSeparateConnector?this.createElement("input",{attrs:{type:"checkbox",class:"e-qb-toggle"}}):this.createElement("button",{attrs:{type:"button",class:"e-qb-toggle"}}),t.appendChild(l)),l=this.createElement("input",{attrs:{type:"radio",class:"e-btngroup-and",value:"AND"}}),t.appendChild(l),r=this.createElement("label",{attrs:{class:"e-lib e-btn e-btngroup-and-lbl e-small"},innerHTML:this.l10n.getConstant("AND")}),t.appendChild(r),l=this.createElement("input",{attrs:{type:"radio",class:"e-btngroup-or",value:"OR"}}),t.appendChild(l),r=this.createElement("label",{attrs:{class:"e-lib e-btn e-btngroup-or-lbl e-small"},innerHTML:this.l10n.getConstant("OR")}),t.appendChild(r),a.appendChild(t),i=this.createElement("div",{attrs:{class:"e-group-action"}}),this.enableSeparateConnector?(o=this.createElement("button",{attrs:{type:"button",class:"e-add-condition-btn"}}),i.appendChild(o),o=this.createElement("button",{attrs:{type:"button",class:"e-add-group-btn"}}),i.appendChild(o)):(o=this.createElement("button",{attrs:{type:"button",class:"e-add-btn"}}),i.appendChild(o)),a.appendChild(i)}return s},p.prototype.ruleTemplate=function(){var e,l,n,r,i,o=this.createElement("div"),s=this.createElement("div",{attrs:{class:"e-rule-field"}});e=this.createElement("div",{attrs:{class:"e-rule-filter"}}),i=this.allowDragAndDrop?"e-icons e-drag-qb-rule":"e-icons e-drag-qb-rule e-hidden";var a=this.createElement("span",{attrs:{class:i,"aria-lable":"drag handle",title:"drag handle"}});s.appendChild(a);var u=this.createElement("input",{attrs:{type:"text",class:"e-filter-input"}});e.appendChild(u),s.appendChild(e),e=this.createElement("div",{attrs:{class:"e-rule-operator"}}),s.appendChild(e),e=this.createElement("div",{attrs:{class:"e-rule-value"}}),s.appendChild(e),e=this.createElement("div",{attrs:{class:"e-rule-value-delete"}}),n=this.showButtons.cloneRule?"e-clone-rule-btn e-clone-rule e-css e-btn e-small e-round e-icon-btn":"e-clone-rule-btn e-clone-rule e-css e-btn e-small e-round e-icon-btn e-button-hide",r=this.showButtons.lockRule?"e-lock-rule-btn e-lock-rule e-css e-btn e-small e-round e-icons e-icon-btn":"e-lock-rule-btn e-lock-rule e-css e-btn e-small e-round e-icons e-icon-btn e-button-hide";var d=this.createElement("button",{attrs:{title:this.l10n.getConstant("CloneRule"),type:"button",class:n}}),c=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-copy"}});d.appendChild(c);var p=this.createElement("button",{attrs:{title:this.l10n.getConstant("LockRule"),type:"button",class:r}});c=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-unlock"}}),p.appendChild(c),l=this.showButtons.ruleDelete||t.isNullOrUndefined(this.showButtons.ruleDelete)?"e-removerule e-rule-delete e-css e-btn e-small":"e-removerule e-rule-delete e-css e-btn e-small e-button-hide";var h=this.createElement("button",{attrs:{type:"button",class:l}});return e.appendChild(d),e.appendChild(p),e.appendChild(h),s.appendChild(e),o.appendChild(s),o},p.prototype.addGroupElement=function(e,t,l,n,r,i,o){var s=this,a={groupID:t.id.replace(this.element.id+"_",""),cancel:!1,type:"insertGroup"};this.isImportRules||this.isInitialLoad||this.prvtEvtTgrDaD?(this.isInitialLoad=!1,this.addGroupSuccess(a,e,t,l,n,r,i,o)):this.trigger("beforeChange",a,function(a){s.addGroupSuccess(a,e,t,l,n,r,i,o)})},p.prototype.addGroupSuccess=function(e,n,r,i,o,a,u,d){var c=this;if(!e.cancel&&this.element.querySelectorAll(".e-group-container").length<=this.maxGroupCount){var p=r,h=void 0,g="";g=p.className.indexOf("e-group-container")<0?p.querySelector(".e-group-container")&&p.querySelector(".e-group-container").id:p.id,this.enableSeparateConnector&&(this.groupElem=this.groupTemplate());var m=this.groupElem.cloneNode(!0);if(m.setAttribute("id",this.element.id+"_group"+this.groupIdCounter),0===this.groupIdCounter&&this.allowDragAndDrop&&m.querySelector(".e-drag-qb-rule")&&(m&&m.children[0]&&m.children[0].classList.add("e-parent-header"),t.addClass([m.querySelector(".e-drag-qb-rule")],"e-hidden")),this.headerTemplate&&(u?(n=!1,m.setAttribute("id",this.element.id+"_group0"),this.headerTemplateFn(m,a,i,d,g),this.groupIdCounter=0):this.headerTemplateFn(m,a,i,d,g)),this.groupIdCounter++,!this.headerTemplate){var f=m.querySelector(".e-btngroup-and"),v=m.querySelector(".e-btngroup-or"),y=m.querySelector(".e-btngroup-and-lbl"),b=m.querySelector(".e-btngroup-or-lbl");f.setAttribute("id",this.element.id+"_and"+this.btnGroupId),v.setAttribute("id",this.element.id+"_or"+this.btnGroupId),f.setAttribute("name",this.element.id+"_and"+this.btnGroupId),v.setAttribute("name",this.element.id+"_and"+this.btnGroupId),y.setAttribute("for",this.element.id+"_and"+this.btnGroupId),b.setAttribute("for",this.element.id+"_or"+this.btnGroupId),this.btnGroupId++}if(n){var C=void 0;C=this.showButtons.groupDelete||t.isNullOrUndefined(this.showButtons.groupDelete)?"e-deletegroup":"e-deletegroup e-button-hide",h=this.createElement("button",{attrs:{type:"button",class:C}}),new l.Button({iconCss:"e-icons e-delete-icon",cssClass:"e-small e-round"}).appendTo(h),h.setAttribute("title",this.l10n.getConstant("DeleteGroup")),t.rippleEffect(h,{selector:".deletegroup"});for(var S=p.querySelector(".e-rule-list"),x=S.children,q=0,E=0,k=x.length;E<k;E++)x[E].className.indexOf("e-group-container")>-1&&(q+=1);if(this.showButtons.cloneGroup&&this.cloneGrpBtnClick)if(this.groupIndex===x.length-1)S.appendChild(m),this.isLastGroup=!0;else{if(this.enableSeparateConnector){for(var O=0,w=this.groupIndex+1,N=0;N<w;N++)x[N].classList.contains("e-rule-container")&&(w++,O++);O>0&&O--,x[L=this.groupIndex+O+1].parentNode.insertBefore(m,x[L])}else{var L=this.groupIndex+1;x[L].parentNode.insertBefore(m,x[L])}this.isMiddleGroup=!0}else S.appendChild(m);var R=this.levelColl[p.id].slice(0);if(R.push(q),this.levelColl[m.id]=R,this.groupIndex>-1&&this.refreshLevelColl(),this.isImportRules||(this.isAddSuccess=!0,this.addGroups([],p.id.replace(this.element.id+"_","")),this.isAddSuccess=!1,o&&this.addRuleToNewGroups&&this.addRuleElement(m,{})),!this.headerTemplate){P="";P=this.showButtons.cloneGroup?"e-clone-grp-btn e-css e-btn e-small e-round e-icons e-icon-btn":"e-clone-grp-btn e-css e-btn e-small e-round e-icons e-icon-btn e-button-hide";var D=this.createElement("button",{attrs:{title:this.l10n.getConstant("CloneGroup"),type:"button",class:P}}),I=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-copy"}});D.appendChild(I),m.querySelector(".e-group-action").appendChild(D),P=this.showButtons.lockGroup?"e-lock-grp-btn e-css e-btn e-small e-round e-icons e-icon-btn":"e-lock-grp-btn e-css e-btn e-small e-round e-icons e-icon-btn e-button-hide";var T=this.createElement("button",{attrs:{title:this.l10n.getConstant("LockGroup"),type:"button",class:P}}),B=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-unlock"}});T.appendChild(B),m.querySelector(".e-group-action").appendChild(T),m.querySelector(".e-group-action").appendChild(h)}}else{if(!this.headerTemplate){var P="";P=this.showButtons.lockGroup?"e-lock-grp-btn e-css e-btn e-small e-round e-icons e-icon-btn":"e-lock-grp-btn e-css e-btn e-small e-round e-icons e-icon-btn e-button-hide";var T=this.createElement("button",{attrs:{title:this.l10n.getConstant("LockGroup"),type:"button",class:P}}),I=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-unlock"}});T.appendChild(I),m.querySelector(".e-group-action").appendChild(T)}p.appendChild(m),this.levelColl[m.id]=[0]}if(this.enableNotCondition&&!this.headerTemplate){var A=m.querySelector(".e-qb-toggle");(this.enableSeparateConnector?new l.CheckBox({label:this.l10n.getConstant("NOT"),cssClass:"e-qb-toggle"}):new l.Button({content:this.l10n.getConstant("NOT"),cssClass:"e-btn e-small"})).appendTo(A),m.querySelector(".e-btngroup-and-lbl").classList.add("e-not"),this.updatedRule&&this.updatedRule.not&&t.addClass([A],"e-active-toggle")}if(this.enableSeparateConnector&&!this.headerTemplate){for(var G=m.querySelector(".e-btngroup-and"),M=m.querySelector(".e-btngroup-or"),V=m.querySelector(".e-btn-group"),N=0;N<V.childNodes.length;N++)"not"===m.querySelector(".e-btn-group").childNodes[N].textContent.toLowerCase()&&this.enableNotCondition?V.childNodes[N].classList.add("e-multiconnector"):V.childNodes[N].style.display="none";if(m.previousElementSibling&&(t.isNullOrUndefined(this.headerTemplate)&&(m.parentElement.insertBefore(this.groupTemplate(!0).querySelector(".e-btn-group"),m),(A=m.previousElementSibling.childNodes[0]).classList.contains("e-qb-toggle")&&(A.style.display="none")),!this.isImportRules)){var _=m.previousElementSibling,F=_.querySelector(".e-btngroup-and"),U=_.querySelector(".e-btngroup-or");if(G.checked||M.checked)this.enableSeparateConnector&&(G.checked&&(F.checked=!0),M.checked&&(U.checked=!0));else{var j=m.nextElementSibling;j&&j.classList.contains("e-btn-group")&&(G=j.querySelector(".e-btngroup-and"),M=j.querySelector(".e-btngroup-or"),F.checked=G.checked,U.checked=M.checked)}}}if(this.updatedRule=null,this.headerTemplate){var $={requestType:"header-template-create",ruleID:m.id,condition:i,notCondition:this.enableNotCondition?a:void 0};this.trigger("actionBegin",$)}else if(this.enableSeparateConnector){var Q=m.querySelector(".e-add-condition-btn");(z=new l.Button({cssClass:this.element.id+"_addConditionbtn",content:this.l10n.getConstant("AddCondition")})).appendTo(Q),z.element.onclick=function(){c.addRuleElement(t.closest(Q,".e-group-container"),{})};var H=m.querySelector(".e-add-group-btn");(z=new l.Button({cssClass:this.element.id+"_addGroupbtn",content:this.l10n.getConstant("AddGroup")})).appendTo(H),z.element.onclick=function(){c.addGroupElement(!0,t.closest(H,".e-group-container"),"",!0)}}else{var W=m.querySelector(".e-add-btn"),z=new s.DropDownButton({items:this.items,cssClass:"e-round e-small e-caret-hide e-addrulegroup",iconCss:"e-icons e-add-icon",beforeOpen:this.selectBtn.bind(this,W),select:this.selectBtn.bind(this,W)});z.appendTo(W),W.setAttribute("title",this.l10n.getConstant("AddButton"))}if(!this.isImportRules&&!this.prvtEvtTgrDaD){var Y=p.id.replace(this.element.id+"_",""),K=m.id.replace(this.element.id+"_","");this.trigger("change",{groupID:Y,type:"insertGroup",childGroupID:K})}}},p.prototype.setMultiConnector=function(e){if(this.enableSeparateConnector&&!this.headerTemplate&&e.previousElementSibling&&this.groupElem.querySelector(".e-btn-group")){e.parentElement.insertBefore(this.groupTemplate(!0).querySelector(".e-btn-group"),e);var t=e.previousElementSibling.childNodes[0];t.classList.contains("e-qb-toggle")&&(t.style.display="none"),this.addHeaderDiv(e)}},p.prototype.addHeaderDiv=function(e){var l,n=e.previousElementSibling.previousElementSibling;if(n){l=n.id.indexOf("rule")>-1?this.getRule(n):this.getGroup(n),t.isNullOrUndefined(l.condition)&&(l.condition="and");var r=e.previousElementSibling.querySelector(".e-btngroup-or"),i=e.previousElementSibling.querySelector(".e-btngroup-and");r.disabled=!1,i.disabled=!1,"or"===l.condition?r.checked=!0:i.checked=!0}},p.prototype.headerTemplateFn=function(e,l,n,r,i,o){var s,a,u=this.element.id+"_header",d=e.querySelector(".e-group-header");if(this.enableSeparateConnector&&-1!==e.id.indexOf("rule")&&(d=e),this.headerTemplate){if(a={requestType:"header-template-initialize",ruleID:e.id,notCondition:this.enableNotCondition?l:void 0,condition:n,rule:this.getRuleCollection(r,!0),groupID:i},this.trigger("actionBegin",a),this.enableSeparateConnector&&-1!==e.id.indexOf("rule")&&(a.requestType="rule-template-create"),this.headerFn=this.templateParser(this.headerTemplate),this.isReact)s=this.headerFn(a,this,e.id,u)[0],this.enableSeparateConnector&&o?this.enableSeparateConnectorInitialRule(e,s):this.enableSeparateConnector&&-1!==e.id.indexOf("rule")?d.parentElement.insertBefore(s,d.nextElementSibling):d.appendChild(s);else if(this.isAngular){var c=this.headerFn(a,this,e.id,u);s=3===c[0].nodeType?c[1]:c[0],this.enableSeparateConnector&&o?this.enableSeparateConnectorInitialRule(e,s):this.enableSeparateConnector&&-1!==e.id.indexOf("rule")?d.parentElement.insertBefore(s,d.nextElementSibling):d.appendChild(s)}else this.isVue3?(s=this.headerFn(a,this,e.id,u),this.enableSeparateConnector&&o?this.enableSeparateConnectorInitialRule(e,s):this.enableSeparateConnector&&-1!==e.id.indexOf("rule")?d.parentElement.insertBefore(s,d.nextElementSibling):t.append(s,d)):(s=this.headerFn(a,this,"Template",u)[0],this.enableSeparateConnector&&o?this.enableSeparateConnectorInitialRule(e,s):this.enableSeparateConnector&&-1!==e.id.indexOf("rule")?d.parentElement.insertBefore(s,d.nextElementSibling):d.appendChild(s));this.renderReactTemplates()}return e},p.prototype.enableSeparateConnectorInitialRule=function(e,t){var l=(e.nextElementSibling?e.nextElementSibling:e).closest(".e-group-container");!e.nextElementSibling&&l&&(l=l.nextElementSibling?l.nextElementSibling:l),l&&l.parentElement.insertBefore(t,l)},p.prototype.notifyChange=function(e,l,n){var r=t.closest(l,".e-group-container"),i=this.getParentGroup(r),o=t.closest(l,".e-rule-container"),s=0;if("not"===n)return void(i.not=e);if("condition"===n)return void(this.enableSeparateConnector?((o=l.parentElement.previousElementSibling)&&o.classList.contains("e-group-container")&&(o=o.querySelectorAll(".e-rule-container")[o.querySelectorAll(".e-rule-container").length-1]),o&&o.classList.contains("e-rule-container")&&(i=this.getRule(o)),i.condition=e):i.condition=e);for(;o&&null!==o.previousElementSibling;)o=o.previousElementSibling,(!this.enableSeparateConnector||this.enableSeparateConnector&&(!this.headerTemplate&&!o.classList.contains("e-btn-group")||this.headerTemplate&&(o.classList.contains("e-rule-container")||o.classList.contains("e-group-container"))))&&s++;var a=i.rules[s],u=this.getColumn(a.field),d=this.getFormat(u.format);if("date"===u.type)if(e instanceof Date)e=this.intl.formatDate(e,d);else if(e instanceof Array)for(var c=0;c<e.length;c++)e[c]&&e[c]instanceof Date&&(e[c]=this.intl.formatDate(e[c],d));u.ruleTemplate?this.templateChange(l,e,n):(this.isNotified=!0,this.updateRules(l,e),this.isNotified=!1)},p.prototype.templateChange=function(e,l,n){var r,i=t.closest(e,".e-group-container"),o=this.getParentGroup(i),s=t.closest(e,".e-rule-container"),a=0;for(this.allowValidation&&this.validateValue(o,s);s&&null!==s.previousElementSibling;)s=s.previousElementSibling,(!this.enableSeparateConnector||this.enableSeparateConnector&&(!this.headerTemplate&&!s.classList.contains("e-btn-group")||this.headerTemplate&&(s.classList.contains("e-rule-container")||s.classList.contains("e-group-container"))))&&a++;var u=o.rules[a];"field"===n?this.selectedColumn=this.getColumn(l):u&&(this.selectedColumn=this.getColumn(u.field));var d;this.previousColumn=this.getColumn(u.field);var c=this.getValidRules(this.rule);this.selectedColumn&&(d=this.selectedColumn.operators?this.selectedColumn.operators:this.customOperators[this.selectedColumn.type+"Operator"]);var p,h=["in","notin","between","notbetween"];switch(n){case"field":u.field=l,u.label=this.selectedColumn.label,u.type=this.selectedColumn.type,u.value="",u.operator=d[0].value;break;case"operator":p=u.operator,u.operator=l,h.indexOf(u.operator)>-1?u.value=[]:h.indexOf(p)>-1&&(u.value="");break;case"value":u.value=l}if(this.changeRuleTemplate(this.selectedColumn,e),this.filterRules(c,this.getValidRules(this.rule),n),this.selectedColumn&&this.selectedColumn.ruleTemplate&&("field"===n||"operator"===n)){var g=t.closest(e,".e-rule-container");this.destroyControls(g,!0),t.detach(g.querySelector(".e-rule-field"));var m=this.appendRuleElem(t.closest(g,".e-group-container"),this.selectedColumn,"change",g.id,n,u);"Vertical"===this.displayMode||this.element.className.indexOf("e-device")>-1?m.className="e-rule-container e-vertical-mode":m.className="e-rule-container e-horizontal-mode",this.enableSeparateConnector||m.previousElementSibling&&m.previousElementSibling.className.indexOf("e-rule-container")>-1&&(m.className.indexOf("e-joined-rule")<0&&(m.className+=" e-joined-rule"),m.previousElementSibling.className.indexOf("e-prev-joined-rule")<0&&(m.previousElementSibling.className+=" e-prev-joined-rule")),m.previousElementSibling&&m.previousElementSibling.className.indexOf("e-group-container")>-1&&m.className.indexOf("e-separate-rule")<0&&(m.className+=" e-separate-rule");var f={requestType:"template-create",action:n,ruleID:g.id,fields:this.fields,rule:u};r={groupID:i.id.replace(this.element.id+"_",""),ruleID:g.id.replace(this.element.id+"_",""),value:u.field,type:"field"},this.trigger("actionBegin",f),this.trigger("change",r)}},p.prototype.changeValue=function(e,l){var n,r=this;if(this.isNumInput&&"number"==typeof l.value)return void(this.isNumInput=!1);((n=l.element&&l.element.classList.contains("e-multiselect")?l.element:l.event?l.event.target:"input"===l.type&&l.currentTarget?l.currentTarget:l.element).className.indexOf("e-day")>-1||n.className.indexOf("e-today")>-1||n.className.indexOf("e-cell")>-1)&&(n=l.element);var o,s=t.closest(n,".e-group-container"),a=t.closest(n,".e-rule-container"),u=s&&s.id.replace(this.element.id+"_",""),d=a.id.replace(this.element.id+"_",""),c=l;c.element&&c.element.className.indexOf("e-datepicker")>-1&&(n=c.element,(o=t.getComponent(t.closest(n,".e-rule-container").querySelector(".e-filter-input"),"dropdownlist"))&&(this.selectedColumn=o.getDataByValue(o.value)),(o=t.getComponent(t.closest(n,".e-rule-container").querySelector(".e-filter-input"),"dropdowntree"))&&(this.selectedColumn=this.getColumn(o.value[0])));var p,h;if(n.className.indexOf("e-radio")>-1)h=parseInt(n.id.split("valuekey")[1],10),"Default"===this.fieldMode?(o=t.getComponent(t.closest(n,".e-rule-container").querySelector(".e-filter-input"),"dropdownlist"),this.selectedColumn=o.getDataByValue(o.value),this.selectedColumn.columns&&(o=t.getComponent(t.closest(n,".e-rule-container").querySelector(".e-rule-sub-filter .e-dropdownlist"),"dropdownlist"),this.selectedColumn=this.getColumn(o.value))):(o=t.getComponent(t.closest(n,".e-rule-container").querySelector(".e-filter-input"),"dropdowntree"),this.selectedColumn=this.getColumn(o.value[0])),p=this.selectedColumn.values?this.selectedColumn.values[h]:[!0,!1][h];else if(n.className.indexOf("e-multiselect")>-1)p=t.getComponent(n,"multiselect").value;else if(p=l.value,"input"===l.type&&l.currentTarget){p=Number(l.currentTarget.value);var g=l.currentTarget;t.getInstance(g,i.NumericTextBox).value=p,this.isNumInput=!0}"input"===l.name&&this.immediateModeDelay?(window.clearInterval(this.timer),this.timer=window.setInterval(function(){r.filterValue(u,d,p,e,n)},this.immediateModeDelay)):this.filterValue(u,d,p,e,n)},p.prototype.filterValue=function(e,t,l,n,r){var i=this,o={groupID:e,ruleID:t,value:l,cancel:!1,type:"value"};window.clearInterval(this.timer),this.isImportRules?this.changeValueSuccessCallBack(o,r,n,e,t):this.trigger("beforeChange",o,function(l){i.changeValueSuccessCallBack(l,r,n,e,t)})},p.prototype.changeValueSuccessCallBack=function(e,t,l,n,r){e.cancel||(this.updateRules(t,e.value,l),this.isImportRules||this.trigger("change",{groupID:n,ruleID:r,value:e.value,cancel:!1,type:"value"}))},p.prototype.fieldClose=function(e){if(!this.isFieldChange&&!this.isDestroy){this.isFieldClose=!0;var l=t.getComponent(e,"dropdownlist"),n=l.popupObj.element.querySelector(".e-active"),r=l.getItemData();l.value=r.value;var i={element:l.element,value:r.value,isInteracted:!0,previousItemData:this.prevItemData,previousItem:null,item:n,itemData:r,event:null,e:null};l.previousValue!==l.value&&this.changeField(i),this.isFieldChange=!1}},p.prototype.changeField=function(e){if(e.isInteracted){if(t.isNullOrUndefined(e.value))return;this.isFieldChange=!0,this.prevItemData=e.itemData;var l=t.closest(e.element,".e-rule-filter")||t.closest(e.element,".e-rule-sub-filter"),n="DropdownTree"===this.fieldMode?this.getColumn(e.value[0]):this.getColumn(e.value);if("DropdownTree"===this.fieldMode&&null!==l){var r=l.querySelector(".e-dropdowntree.e-control"),i=t.getComponent(r,"dropdowntree");if(!n)return;if("object"===n.type){if(i.value=e.oldValue,i.dataBind(),t.isNullOrUndefined(e.oldValue))r.value="";else{o=this.getLabelFromColumn(e.oldValue[0]);r.value=o}return}if(!t.isNullOrUndefined(e.value[0])){i.value=e.value[0],i.dataBind();var o=this.getLabelFromColumn(e.value[0]);r.value=o}}if(this.destroySubFields(l),this.subFieldElem=null,this.isNotValueChange=!0,n&&n.ruleTemplate)this.templateChange(e.element,n.field,"field");else if(n&&n.columns&&n.columns[0].ruleTemplate)this.templateChange(e.element,n.columns[0].field,"field");else{for(var s=t.closest(e.element,".e-group-container"),a=this.getParentGroup(s),u=t.closest(e.element,".e-rule-container"),d=0;u&&null!==u.previousElementSibling;)u=u.previousElementSibling,(!this.enableSeparateConnector||this.enableSeparateConnector&&(!this.headerTemplate&&!u.classList.contains("e-btn-group")||this.headerTemplate&&(u.classList.contains("e-rule-container")||u.classList.contains("e-group-container"))))&&d++;a.rules[d].value="",this.changeRule(a.rules[d],e)}}},p.prototype.changeRule=function(e,l){if(!l.itemData){if("DropdownTree"!==this.fieldMode)return;if(null==t.getComponent(l.element,"dropdowntree").value)return}var n={},r=t.closest(l.element,".e-rule-filter");r=r||t.closest(l.element,".e-rule-sub-filter");var i=t.getComponent(l.element,"dropdownlist");"DropdownTree"===this.fieldMode&&null!==r&&(i=t.getComponent(l.element,"dropdowntree"));var o=t.closest(l.element,".e-group-container").id.replace(this.element.id+"_","");this.changeFilter(r,i,o,e,n,l)},p.prototype.changeFilter=function(e,l,n,r,i,o){var s=this;if(e){var a=void 0;a="DropdownTree"===this.fieldMode?l.value[0]:this.isImportRules?this.GetRootColumnName(l.value):l.value,this.selectedColumn=this.getColumn(a);var u={groupID:n,ruleID:t.closest(e,".e-rule-container").id.replace(this.element.id+"_",""),selectedField:"DropdownTree"===this.fieldMode?l.value[0]:l.value,cancel:!1,type:"field"};this.isImportRules||this.prvtEvtTgrDaD?this.fieldChangeSuccess(u,i,e,r,o):this.trigger("beforeChange",u,function(t){s.fieldChangeSuccess(t,i,e,r,o)})}else{var d=t.closest(o.element,".e-rule-operator");this.changeOperator(e,d,l,n,r,i,o)}},p.prototype.changeOperator=function(e,l,n,r,i,o,s){var a,u=this;l?(a={groupID:r,ruleID:t.closest(l,".e-rule-container").id.replace(this.element.id+"_",""),selectedIndex:n.index,cancel:!1,type:"operator"},this.isImportRules?this.operatorChangeSuccess(a,e,o,i,s):this.trigger("beforeChange",a,function(t){u.operatorChangeSuccess(t,e,o,i,s)})):this.changeRuleValues(e,i,o,s)},p.prototype.fieldChangeSuccess=function(e,l,n,r,i){for(var o=t.closest(n,".e-rule-container"),s=t.closest(i.element,".e-rule-operator"),a=t.closest(i.element,".e-group-container").id.replace(this.element.id+"_",""),u=t.getComponent(i.element,"dropdownlist"),d=o.querySelectorAll(".e-tooltip.e-input-group"),c=0;c<d.length;c++)t.getComponent(d[c],"tooltip").destroy();if(e.cancel)this.changeOperator(n,s,u,a,r,l,i);else{if(t.isNullOrUndefined(this.selectedColumn))return;if(l.type=this.selectedColumn.type,o.querySelector(".e-template")&&(r.value=""),"object"===this.selectedColumn.type&&"Default"===this.fieldMode)for(l.type=this.selectedColumn.columns[0].type;this.selectedColumn.columns;)this.createSubFields(n,r,l,i);else this.destroySubFields(n),this.changeOperator(n,s,u,a,r,l,i)}},p.prototype.destroySubFields=function(e){for(;e&&e.nextElementSibling.classList.contains("e-rule-sub-filter");)this.destroyControls(e),e.nextElementSibling.remove()},p.prototype.createSubFields=function(e,l,r,i){var o=!1,s=t.closest(e,".e-rule-field"),a=this.createElement("div",{attrs:{class:"e-rule-sub-filter",id:"subfilter"+this.subFilterCounter}});s.insertBefore(a,s.querySelector(".e-rule-operator"));var u=t.closest(a,".e-rule-container").id,c=this.createElement("input",{attrs:{type:"text",id:u+"_subfilterkey"+this.subFilterCounter}});a.appendChild(c);var p,h=this.element.className.indexOf("e-device")>-1?"250px":"200px";p={dataSource:this.selectedColumn.columns,fields:this.fields,placeholder:this.l10n.getConstant("SelectField"),popupHeight:this.selectedColumn.columns.length>5?h:"auto",change:this.changeField.bind(this),index:0,open:this.popupOpen.bind(this,!1)},this.fieldModel&&(p=d({},p,this.fieldModel));var g=new n.DropDownList(p);if(g.appendTo("#"+u+"_subfilterkey"+this.subFilterCounter),this.isImportRules||this.previousColumn&&this.previousColumn.ruleTemplate&&this.GetRootColumnName(l.field)===this.GetRootColumnName(this.previousColumn.field))for(var m=this.selectedColumn.columns,f=0;f<m.length;f++)if(l.field===m[f].field||l.field.indexOf(m[f].field+this.separator)>-1){g.value=m[f].field,this.selectedColumn=m[f],o=!0;break}this.subFilterCounter++,this.subFieldElem=c,i.itemData=i.itemData,!o&&this.selectedColumn.columns&&(!o&&this.isImportRules&&(g.value=null),this.selectedColumn=this.selectedColumn.columns[0]),this.previousColumn=this.selectedColumn,this.selectedColumn.columns||this.changeRuleValues(a,l,r,i)},p.prototype.operatorChangeSuccess=function(e,l,n,r,i){if(!e.cancel){var o=t.closest(i.element,".e-rule-operator"),s=o.nextElementSibling,a=t.getComponent(i.element,"dropdownlist"),u=r.operator?r.operator.toString().toLowerCase():"";n.operator=a.value.toString();var d=n.operator.toLowerCase();if(n.operator.toLowerCase().indexOf("between")>-1||n.operator.toLowerCase().indexOf("in")>-1&&n.operator.toLowerCase().indexOf("contains")<0?(l=o.previousElementSibling,n.type=r.type,(n.operator.toLowerCase().indexOf("in")<0||u.indexOf("in")<0)&&(r.value=[])):"object"==typeof r.value&&null!==r.value&&(r.value=r.value.length>0?r.value[0]:"number"===r.type?0:""),i.previousItemData){var c=i.previousItemData.value.toString().toLowerCase();(c.indexOf("between")>-1||(c.indexOf("in")>-1||c.indexOf("null")>-1||c.indexOf("empty")>-1)&&c.indexOf("contains")<0)&&(l=o.previousElementSibling,n.type=r.type)}if(u.indexOf("in")>-1&&u.indexOf("in")<5&&d.indexOf("in")>-1&&d.indexOf("in")<5&&(l=null),n.operator.indexOf("null")>-1||n.operator.indexOf("empty")>-1){var p=o.parentElement.querySelector(".e-rule-value"),h=p.querySelector(".e-tooltip.e-input-group");h&&t.getComponent(h,"tooltip").destroy(),t.removeClass([p],"e-show"),t.addClass([p],"e-hide")}s&&this.getColumn(r.field).template&&(l=o.previousElementSibling),0===s.children.length&&(l=o.previousElementSibling),this.changeRuleValues(l,r,n,i)}},p.prototype.changeRuleValues=function(e,l,r,i){var o,s,a,u=t.closest(i.element,".e-rule-operator");if(e)if(u=e.nextElementSibling,e.classList.contains("e-rule-sub-filter")&&(r.type=this.selectedColumn.type,u=u.classList.contains("e-rule-sub-filter")?u.nextElementSibling:u),t.addClass([u],"e-operator"),u.childElementCount){o=t.getComponent(u.querySelector(".e-dropdownlist"),"dropdownlist"),r.operator=o.value;var c=void 0;c="DropdownTree"===this.fieldMode?t.getComponent(e.querySelector(".e-dropdowntree"),"dropdowntree"):t.getComponent(e.querySelector(".e-dropdownlist"),"dropdownlist"),r.type="DropdownTree"===this.fieldMode?this.getColumn(c.value[0]).type:this.getColumn(c.value).type;var p=i.itemData;""!==o.value&&this.renderValues(u,p,i.previousItemData,!0,l,r,i.element)}else{var h=t.closest(u,".e-rule-container").id;a=this.createElement("input",{attrs:{type:"text",id:h+"_operatorkey"}}),u.appendChild(a),this.selectedColumn.operators?s=this.selectedColumn.operators:i.itemData&&(s=this.customOperators[this.selectedColumn.type+"Operator"]);var g=this.element.className.indexOf("e-device")>-1?"250px":"200px",m=s[0].value,f=0;this.autoSelectOperator||(m="",f=-1),(this.isImportRules||this.ruleIndex>-1||this.groupIndex>-1||this.prvtEvtTgrDaD)&&(m=l&&l.operator?l.operator:m);var v=void 0;v={dataSource:s,fields:{text:"key",value:"value"},placeholder:this.l10n.getConstant("SelectOperator"),popupHeight:s.length>5?g:"auto",change:this.changeField.bind(this),index:f,value:m,open:this.popupOpen.bind(this,!1)},this.operatorModel&&(v=d({},v,this.operatorModel)),new n.DropDownList(v).appendTo("#"+h+"_operatorkey"),r.operator=l&&""!==l.operator&&!t.isNullOrUndefined(l.operator)?l.operator:s[0].value,this.isImportRules&&(r.type=this.selectedColumn.type,r.operator=l.operator),t.isNullOrUndefined(m)||""===m?this.autoSelectField&&this.autoSelectOperator&&this.renderValues(u,this.selectedColumn,i.previousItemData,!1,l,r,i.element):this.renderValues(u,this.selectedColumn,i.previousItemData,!1,l,r,i.element)}this.isImportRules||this.updateRules(i.element,i.item)},p.prototype.popupOpen=function(e,l){this.enableRtl&&t.addClass([l.popup.element],"e-rtl"),e&&(this.isFieldClose=!1)},p.prototype.destroyControls=function(e,l){for(var n=l?e:e.nextElementSibling,r=n.querySelectorAll("input.e-control"),i=n.querySelectorAll("div.e-control:not(.e-handle)"),o=this.columns,s=0,a=r.length;s<a;s++){if(r[s].classList.contains("e-textbox"))t.getComponent(r[s],"textbox").destroy(),t.detach(t.select("input#"+r[s].id,n));else if(r[s].classList.contains("e-dropdownlist"))this.allowValidation&&r[s].parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(r[s].parentElement,"tooltip").destroy(),t.getComponent(r[s],"dropdownlist").destroy();else if(r[s].classList.contains("e-radio"))t.getComponent(r[s],"radio").destroy();else if(r[s].classList.contains("e-numerictextbox"))t.getComponent(r[s],"numerictextbox").destroy(),t.detach(t.select("input#"+r[s].id,n));else if(r[s].classList.contains("e-datepicker"))t.getComponent(r[s],"datepicker").destroy();else if(r[s].classList.contains("e-multiselect"))t.getComponent(r[s],"multiselect").destroy();else if(r[s].className.indexOf("e-template")>-1)for(var u=r[s].className,d=0,c=o.length;d<c;d++)if(o[d].template&&u.indexOf(o[d].field)>-1){this.templateDestroy(o[d],r[s].id);break}document.getElementById(r[s].id)&&t.detach(r[s])}for(var s=0,a=i.length;s<a;s++){if(i[s].className.indexOf("e-template")>-1)for(var u=i[s].className,d=0,c=o.length;d<c;d++)if(o[d].template&&u.indexOf(o[d].field)>-1){this.templateDestroy(o[d],i[s].id);break}t.detach(i[s])}for(var p=n.querySelectorAll(".e-template:not(.e-control)"),s=0,a=p.length;s<a;s++)t.detach(p[s])},p.prototype.templateDestroy=function(e,l){var n;if("string"!=typeof e.template||void 0===e.template.destroy){var r=(n=e.template).destroy;if(n.destroy){var i=void 0;document.getElementById(l)&&(i=t.closest(document.getElementById(l),".e-rule-field").querySelectorAll(".e-template")),"string"==typeof r?(r=t.getValue(r,window))({field:e.field,elementId:l,elements:i}):n.destroy({field:e.field,elementId:l,elements:i})}}},p.prototype.getValues=function(e){var t,l={},n=[],r=[];this.separator.length>0&&(r=e.split(this.separator));var i=this.dataColl;if(this.dataColl[1])for(var o=0,s=i.length;o<s;o++){var a={};if(r.length>1)for(var u=i[o],d=void 0,c=0,p=r.length;c<p;c++)d=r[c],r.length===c+1?(t=u[""+d],Number(u[""+d])===u[""+d]&&u[""+d]%1!=0&&(t=u[""+d].toString())):u=u[""+d];else t=i[o][""+e],Number(i[o][""+e])===i[o][""+e]&&i[o][""+e]%1!=0&&(t=i[o][""+e].toString());t in l||(l[""+t]=1,r.length>1?this.createNestedObject(a,r,t):a[""+e]=t,n.push(a))}return n},p.prototype.createNestedObject=function(e,t,l){for(var n,r=t.length-1,i=0;i<r;++i)(n=t[i])in e||(e[""+n]={}),e=e[""+n];e[t[r]]=l},p.prototype.getDistinctValues=function(e,t){for(var l={},n=[],r=[],i="",o=t.indexOf(this.separator),s=this,a=0,u=e.length;a<u;a++)!function(a,u){0===o?i=e[a][""+t]:(r=t.split(s.separator)).forEach(function(t){i=i?i[""+t]:e[a][""+t]}),Number(e[a][""+t])===e[a][""+t]&&e[a][""+t]%1!=0&&(i=e[a][""+t].toString());var d={};i in l||(l[""+i]=1,0===o?d[""+t]=i:d[r[r.length-1]]=i,n.push(d))}(a);return n},p.prototype.renderMultiSelect=function(e,t,l,i,o){var s,a=!1,u=!1;this.isGetNestedData=!1,this.dataColl[1]&&Object.keys(this.dataColl[1]).indexOf(e.field)>-1&&(a=!0,s=this.getDistinctValues(this.dataColl,e.field)),a=!e.columns&&a,!this.dataColl.length&&o.length&&(u=!0);var c;c={dataSource:u?o:a?s:this.dataManager,query:new r.Query([e.field]),fields:{text:this.selectedRule.field,value:this.selectedRule.field},placeholder:this.l10n.getConstant("SelectValue"),value:i,mode:"CheckBox",width:"100%",change:this.changeValue.bind(this,l),close:this.closePopup.bind(this,l),actionBegin:this.multiSelectOpen.bind(this,t+"_valuekey"+l),open:this.popupOpen.bind(this,!1)},this.valueModel&&this.valueModel.multiSelectModel&&(c=d({},c,this.valueModel.multiSelectModel));var p=new n.MultiSelect(c);p.appendTo("#"+t+"_valuekey"+l),this.updateRules(p.element,i,0)},p.prototype.multiSelectOpen=function(e,l){if(this.dataSource instanceof r.DataManager){var n=document.getElementById(e),i=t.getComponent(t.closest(n,".e-rule-container").querySelector(".e-filter-input"),"dropdownlist");this.selectedColumn=i.getDataByValue(i.value);var o=this.selectedColumn.field,s=!1;this.dataColl[1]&&(Object.keys(this.dataColl[1]).indexOf(o)>-1&&(s=!0),0!==o.indexOf(this.separator)&&this.isGetNestedData&&(s=!0)),s||(l.cancel=!0,this.bindMultiSelectData(n,o))}},p.prototype.bindMultiSelectData=function(e,t){this.getMultiSelectData(e,t)},p.prototype.getMultiSelectData=function(e,l){var n,i=this,o=new r.Deferred,s=this.dataManager.executeQuery((new r.Query).select(l)),u=t.getComponent(e,"multiselect");u.hideSpinner(),this.createSpinner(t.closest(e,".e-multi-select-wrapper").parentElement),a.showSpinner(t.closest(e,".e-multi-select-wrapper").parentElement),s.then(function(r){n=r.actual&&r.actual.result?r.actual.result:r.result,i.dataColl=t.extend(i.dataColl,n,[],!0),u.dataSource=i.getDistinctValues(i.dataColl,l),i.isGetNestedData=!0,a.hideSpinner(t.closest(e,".e-multi-select-wrapper").parentElement)}).catch(function(e){o.reject(e)})},p.prototype.createSpinner=function(e){var l=this.createElement("span",{attrs:{class:"e-qb-spinner"}});e.appendChild(l),a.createSpinner({target:l,width:t.Browser.isDevice?"16px":"14px"})},p.prototype.closePopup=function(e,l){var n=document.getElementById(l.popup.element.id.replace("_popup",""));if(n){var r=t.getComponent(n,"multiselect").value;this.updateRules(n,r,e)}},p.prototype.processTemplate=function(e,l,n,r){var i=t.closest(e,".e-rule-container"),o=i.querySelectorAll(".e-template"),s=i.querySelector(".e-rule-filter .e-filter-input"),a="DropdownTree"===this.fieldMode?t.getComponent(s,"dropdowntree"):t.getComponent(i.querySelector(".e-rule-filter .e-filter-input"),"dropdownlist"),u="DropdownTree"===this.fieldMode?this.getColumn(a.value[0]):this.getColumn(a.value);if("string"==typeof l.template||void 0===l.template.write){var d={rule:n,ruleID:i.id,operator:r.operator,field:u.field,requestType:"value-template-create"};this.trigger("actionBegin",d)}else{var c=l.template;"string"==typeof c.write?t.getValue(c.write,window)({elements:o.length>1?o:o[0],values:n.value,operator:r.operator,field:u.field,dataSource:u.values}):"function"!=typeof l.template&&l.template.write({elements:o.length>1?o:o[0],values:n.value,operator:r.operator,field:u.field,dataSource:u.values})}},p.prototype.getItemData=function(e){var l=t.getComponent(document.getElementById(e+"_filterkey"),"dropdownlist");return"DropdownTree"===this.fieldMode&&(l=t.getComponent(document.getElementById(e+"_filterkey"),"dropdowntree")),"DropdownTree"===this.fieldMode?this.getColumn(l.value[0]):this.getColumn(l.value)},p.prototype.setDefaultValue=function(e,l,n){var r=this.getItemData(e);if(t.isNullOrUndefined(r.value))return n?l?[0,0]:0:l?[]:"";if(l){if(!(r.value instanceof Array))return[r.value]}else if(r.value instanceof Array)return r.value[0];return r.value},p.prototype.renderStringValue=function(e,t,l,n,r){var o,s,a=this.getItemData(e),u="string"==typeof a.template;if(s=this.isImportRules||this.ruleIndex>-1||this.groupIndex>-1||this.isPublic||u||""!==t.value?t.value:this.setDefaultValue(e,!1,!1),"in"!==l&&"notin"!==l||!this.dataColl.length&&!a.values){"in"!==l&&"notin"!==l||(s=(o=this.isImportRules||this.ruleIndex>-1||this.groupIndex>-1?t.value:this.setDefaultValue(e,!0,!1)).join(","));var c=void 0;c={placeholder:this.l10n.getConstant("SelectValue"),input:this.changeValue.bind(this,n)},this.valueModel&&this.valueModel.textBoxModel&&(c=d({},c,this.valueModel.textBoxModel));var p=new i.TextBox(c);p.appendTo("#"+e+"_valuekey"+n),p.value=s,p.dataBind()}else o=this.isImportRules||this.ruleIndex>-1||this.groupIndex>-1||this.isPublic?t.value:this.setDefaultValue(e,!0,!1),this.renderMultiSelect(a,e,n,o,a.values),"Vertical"===this.displayMode||this.element.className.indexOf("e-device")>-1?r.style.width="100%":(r.style.width=null,r.style.minWidth="200px")},p.prototype.renderNumberValue=function(e,t,l,n,r,o,s){var a=this.getItemData(e),u="string"==typeof a.template,c=this.isImportRules||this.ruleIndex>-1||this.groupIndex>-1||this.isPublic||u||"number"==typeof t.value?t.value:this.setDefaultValue(e,!1,!0);if("in"!==l&&"notin"!==l||!this.dataColl.length&&!a.values)if("in"===l||"notin"===l){var p=(c=this.isImportRules||this.ruleIndex>-1||this.groupIndex>-1?t.value:this.setDefaultValue(e,!0,!1)).join(","),h=void 0;h={placeholder:this.l10n.getConstant("SelectValue"),input:this.changeValue.bind(this,n)},this.valueModel&&this.valueModel.textBoxModel&&(h=d({},h,this.valueModel.textBoxModel));var g=new i.TextBox(h);g.appendTo("#"+e+"_valuekey"+n),g.value=p,g.dataBind()}else{var m=(o=a).validation&&o.validation.min?o.validation.min:0,f=o.validation&&o.validation.max?o.validation.max:Number.MAX_VALUE,v=o.format?o.format:"n";s>1&&t&&(c=t.value[n]?t.value[n]:this.setDefaultValue(e,!0,!0));var y=void 0;y={value:c instanceof Array?c[n]:c,format:v,min:m,max:f,width:"100%",step:o.step?o.step:1,change:this.changeValue.bind(this,n)},this.valueModel&&this.valueModel.numericTextBoxModel&&(y=d({},y,this.valueModel.numericTextBoxModel));var b=new i.NumericTextBox(y);b.appendTo("#"+e+"_valuekey"+n),b.element.setAttribute("aria-label",o.label+" Value"),b.element.oninput=this.changeValue.bind(this,n)}else c=this.isImportRules||this.ruleIndex>-1||this.groupIndex>-1||this.isPublic?t.value:this.setDefaultValue(e,!0,!1),this.renderMultiSelect(a,e,n,c,a.values),this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?r.style.width="100%":(r.style.minWidth="200px",r.style.width=null)},p.prototype.processValueString=function(e,t){var l=[],n=e.split(",");if("string"===t)return n;for(var r=0,i=n.length;r<i;r++)l.push(Number(n[r]));return l},p.prototype.parseDate=function(e,l){var n,r;if(l){var i=this.intl.getDateParser({skeleton:"full",type:"dateTime"});n=this.getFormat(l),r=i(e),t.isNullOrUndefined(r)&&(r=this.intl.parseDate(e,n))}else r=new Date(e);return r},p.prototype.renderControls=function(e,l,n,r,i){if(t.addClass([e.parentElement.querySelector(".e-rule-value")],"e-value"),t.removeClass([e.parentElement.querySelector(".e-rule-value")],"e-hide"),t.addClass([e.parentElement.querySelector(".e-rule-value")],"e-show"),l.template&&(l.template.create||i))this.processTemplate(e,l,n,r);else{var s;s="boolean"===r.type?this.selectedColumn.values?this.selectedColumn.values.length:2:r.operator&&r.operator.toString().toLowerCase().indexOf("between")>-1?2:1;var a=t.closest(e,".e-rule-container").id,u=void 0,c=r.operator.toString();if(e.className.indexOf("e-rule-operator")>-1||e.className.indexOf("e-rule-filter")>-1){u=e.parentElement.querySelector(".e-rule-value"),this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?u.style.width="100%":"in"!==c&&"notin"!==c?t.addClass([u],"e-custom-value"):t.removeClass([u],"e-custom-value");for(var p=0;p<s;p++)switch(r.type){case"string":this.renderStringValue(a,n,c,p,u);break;case"number":this.renderNumberValue(a,n,c,p,u,l,s);break;case"boolean":this.processBoolValues(l,n,a,p);break;case"date":var h=new Date,g=void 0,m=void 0,f=l.format,v=void 0,y=void 0,b=this.l10n.getConstant("SelectValue"),C="string"==typeof l.template;if(n.value&&!t.isNullOrUndefined(f)&&(g=s>1?n.value[p]:n.value,h=this.parseDate(g,f)||new Date),l.field||l.key||!l.value||(h=l.value instanceof Date?l.value:this.parseDate(l.value,l.format)),!l.format&&n&&""!==n.field&&(f=(m=this.getColumn(n.field)).format),(this.isImportRules||this.isPublic||C)&&n&&(f=(m=this.getColumn(n.field)).format,n.value?(g=s>1?n.value[p]:n.value,h=this.parseDate(g,m.format)):h=n.value),f){var S=this.getFormat(f);S.skeleton?(y={locale:this.getLocale(),value:h,placeholder:b,format:S,change:this.changeValue.bind(this,p)},this.valueModel&&this.valueModel.datePickerModel&&(y=d({},y,this.valueModel.datePickerModel)),v=new o.DatePicker(y)):(y={value:h,locale:this.getLocale(),placeholder:b,format:S.format,change:this.changeValue.bind(this,p)},this.valueModel&&this.valueModel.datePickerModel&&(y=d({},y,this.valueModel.datePickerModel)),v=new o.DatePicker(y))}else y={locale:this.getLocale(),value:h,placeholder:b,change:this.changeValue.bind(this,p)},this.valueModel&&this.valueModel.datePickerModel&&(y=d({},y,this.valueModel.datePickerModel)),v=new o.DatePicker(y);if(v.appendTo("#"+a+"_valuekey"+p),!n.value){var x=document.getElementById(a+"_valuekey"+p);this.updateRules(x,h,null,this.isNotValueChange),this.isNotValueChange=!1}}}}},p.prototype.processBoolValues=function(e,n,r,i){var o,s,a=!1;t.isNullOrUndefined(n.type)&&e&&(n.type=e.type);var u;if(e.values){c=e.values;"boolean"!==n.type||t.isNullOrUndefined(n.value)?e.value?a=c[i].toLowerCase()===e.value.toString().toLowerCase():0===i&&(a=!0):a=c[i].toLowerCase()===n.value.toString().toLowerCase(),s=o=u=c[i]}else{var c=[!0,!1];"boolean"!==n.type||t.isNullOrUndefined(n.value)?e.value?a=c[i].toString().toLowerCase()===e.value.toString().toLowerCase():0===i&&(a="boolean"!=typeof n.value||!!n.value):a=c[i].toString().toLowerCase()===n.value.toString().toLowerCase(),"boolean"==typeof n.value&&1===i&&(a=!n.value),o=c[i].toString(),s=c[i],u=this.l10n.getConstant(["True","False"][i])}var p;p={label:u,name:r+"default",checked:a,value:o,change:this.changeValue.bind(this,i)},this.valueModel&&this.valueModel.radioButtonModel&&(p=d({},p,this.valueModel.radioButtonModel));var h=new l.RadioButton(p);h.appendTo("#"+r+"_valuekey"+i),a&&this.updateRules(h.element,s,0,!0)},p.prototype.getOperatorIndex=function(e,t){var l,n=e.dataSource.length;for(l=0;l<n;l++)if(t.operator===e.dataSource[l].value)return l;return 0},p.prototype.getPreviousItemData=function(e,t){return this.isFieldClose&&e&&(e=this.getColumn(e.value)),t&&t.template&&e&&Object.keys(e).length<4&&(e.template=t.template),e},p.prototype.renderValues=function(e,l,n,r,i,o,s){var a=e.previousElementSibling.getElementsByTagName("input")[0],u="DropdownTree"===this.fieldMode?t.getComponent(a,"dropdowntree"):t.getComponent(a,"dropdownlist"),d="DropdownTree"===this.fieldMode?this.getColumn(u.value[0]):this.getColumn(u.value);this.selectedRule=d;var c=t.getComponent(e.querySelector("input"),"dropdownlist");r&&(l=s.id.indexOf("operator")>-1?l:this.selectedRule).operators&&(c.value=null,c.dataBind(),c.dataSource=l.operators,c.index=this.getOperatorIndex(c,i),c.value=o.operator=c.dataSource[c.index].value,this.autoSelectOperator?c.dataBind():(c.index=-1,o.operator=c.value=""));var p=o.operator.toString(),h=!1;if(p.indexOf("null")>-1||p.indexOf("isempty")>-1||p.indexOf("isnotempty")>-1)(f=e.parentElement.querySelector(".e-rule-value"))&&(t.removeClass([f],"e-show"),t.addClass([f],"e-hide"));else{var g=t.closest(e,".e-rule-container").id;if(n=this.getPreviousItemData(n,d),n&&void 0===n.template?n.columns&&(n=this.getColumn(i.field)):"DropdownTree"===this.fieldMode&&void 0===n&&(n=this.getColumn(i.field)),n&&n.template){this.templateDestroy(n,g+"_valuekey0");var m=t.select("#"+g+"_valuekey0",e.nextElementSibling);m&&!m.classList.contains("e-control")&&t.detach(t.select("#"+g+"_valuekey0",e.nextElementSibling)),"string"!=typeof n.template&&void 0!==n.template.create||(e.nextElementSibling.classList.contains("e-template-value")&&this.clearQBTemplate([g]),e.nextElementSibling.innerHTML="")}if(r&&(this.validateValue(i,t.closest(e,".e-rule-container")),this.destroyControls(e)),this.isImportRules||c&&""!==c.value){if(d&&(l.template=d.template),l.template&&(t.addClass([e.nextElementSibling],"e-template-value"),l.template=d.template,h=this.setColumnTemplate(l,g,d.field,l.value||p,e,i)),h){var f=e.parentElement.querySelector(".e-rule-value");this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?f.style.width="100%":f.style.width="200px"}else{t.removeClass([e.nextElementSibling],"e-template-value");var v=1;v="boolean"===o.type?this.selectedColumn.values?this.selectedColumn.values.length:2:p&&p.toLowerCase().indexOf("between")>-1?2:1;for(var y=0;y<v;y++){var b=this.createElement("input",{attrs:{type:"text",id:g+"_valuekey"+y}});e.nextElementSibling.appendChild(b)}}this.renderControls(e,l,i,o,h)}}},p.prototype.setColumnTemplate=function(e,l,n,r,i,o){var s,a=this,u=!0;if(e.template){if("string"==typeof e.template||void 0===e.template.create)return s={requestType:"value-template-initialize",ruleID:l,field:n,operator:r,rule:o,renderTemplate:!0},this.trigger("actionBegin",s,function(t){u=a.actionBeginSuccessCallBack(t,e,l,n,i)}),u;var d=void 0,c=e.template;if((d="string"==typeof c.create?t.getValue(c.create,window)({field:n,operator:r}):c.create({field:n,operator:r}))instanceof Element)d.id=l+"_valuekey0",t.addClass([d],"e-template"),i.nextElementSibling.appendChild(d),n.indexOf(" ")<0&&t.addClass([d],"e-"+n);else if(d instanceof Array){t.addClass(d,"e-template");for(var p=0,h=d.length;p<h;p++)d[p].id=l+"_valuekey"+p,i.nextElementSibling.appendChild(d[p])}return t.addClass([i.nextElementSibling],"e-template-value"),!0}return!0},p.prototype.actionBeginSuccessCallBack=function(e,l,n,r,i){if(e.renderTemplate){var o=void 0;this.columnTemplateFn=this.templateParser((l.template,l.template));var s=this.element.id+r;if(this.isReact)o=this.columnTemplateFn(e,this,n,s)[0],i.nextElementSibling.appendChild(o);else if(this.isAngular){var a=this.columnTemplateFn(e,this,n,s);o=3===a[0].nodeType?a[1]:a[0],i.nextElementSibling.appendChild(o)}else this.isVue3?(o=this.columnTemplateFn(e,this,"Template",s),t.append(o,i.nextElementSibling)):(o=this.columnTemplateFn(e,this,"Template",s)[0],i.nextElementSibling.appendChild(o));return t.addClass([i.nextElementSibling],"e-template-value"),this.renderReactTemplates(),!0}return!1},p.prototype.updateValues=function(e,l){var n=1;e.className.indexOf("e-template")>-1&&(n=3);var r,i,o,s,a,u=e.className.split(" e-")[n],d=parseInt(e.id.slice(-1),2);switch(u){case"checkbox":s=t.getComponent(e,u).value,l.value=""!==s?s:void 0;break;case"textbox":case"dropdownlist":l.value=t.getComponent(e,u).value;break;case"radio":(a=t.getComponent(e,u)).checked&&("boolean"==typeof l.value?l.value="true"===a.value:this.getColumn(l.field).values?l.value=a.value:l.value="true"===a.value),a.refresh();break;case"numerictextbox":l.operator.indexOf("between")>-1?("string"==typeof l.value&&(l.value=[]),l.value[d]=t.getComponent(e,u).value):l.value=t.getComponent(e,u).value;break;case"datepicker":r=this.getColumn(l.field),i=this.getFormat(r.format),o=t.getComponent(e,u).value,l.operator.indexOf("between")>-1?("string"==typeof l.value&&(l.value=[]),l.value[d]=this.intl.formatDate(o,i)):t.isNullOrUndefined(i.format)&&o?l.value=this.intl.formatDate(o):l.value=o?this.intl.formatDate(o,i):o;break;case"multiselect":l.value=t.getComponent(e,u).value}},p.prototype.updateRules=function(e,l,n,r){for(var i,o,s=t.closest(e,".e-group-container"),a=this.getParentGroup(s),u=t.closest(e,".e-rule-container"),d=0,c=s.id.replace(this.element.id+"_",""),p=this.getValidRules(this.rule);u&&null!==u.previousElementSibling;)u=u.previousElementSibling,(!this.enableSeparateConnector||this.enableSeparateConnector&&(!this.headerTemplate&&!u.classList.contains("e-btn-group")||this.headerTemplate&&(u.classList.contains("e-rule-container")||u.classList.contains("e-group-container"))))&&d++;var h=a.rules[d].operator?a.rules[d].operator.toString():"",g=(u=t.closest(e,".e-rule-container")).id.replace(this.element.id+"_","");if(t.closest(e,".e-rule-filter")||t.closest(e,".e-rule-sub-filter")){this.subFieldElem&&(e=this.subFieldElem),i="DropdownTree"===this.fieldMode?t.getComponent(e,"dropdowntree"):t.getComponent(e,"dropdownlist");var m="DropdownTree"===this.fieldMode?this.getColumn(i.value[0]):this.getColumn(i.value);!this.isImportRules&&a.rules[d].field&&a.rules[d].field.toLowerCase()!==m.field.toLowerCase()&&(!u.querySelectorAll(".e-template")&&!(h.indexOf("null")>-1)||h.indexOf("empty")>-1)&&(a.rules[d].value=""),this.selectedColumn=this.getColumn(this.selectedColumn.field),a.rules[d].field=this.selectedColumn.field,a.rules[d].type=this.selectedColumn.type,a.rules[d].label=this.selectedColumn.label;var f=t.closest(e,".e-rule-filter"),v=(f=f||t.closest(e,".e-rule-sub-filter")).nextElementSibling.querySelector("input.e-control");v=v||f.nextElementSibling.nextElementSibling.querySelector("input.e-control"),h=t.getComponent(v,"dropdownlist").value.toString(),a.rules[d].operator=h;var y=f.nextElementSibling.nextElementSibling,b=y.querySelectorAll("input.e-control");b.length<1&&(b=y.querySelectorAll("div.e-control")),b.length<1&&(b=y.querySelectorAll(".e-template")),o={groupID:c,ruleID:g,value:a.rules[d].field,type:"field"};for(var C=0;C<b.length;C++)h.indexOf("null")>-1||h.indexOf("empty")>-1?a.rules[d].value=null:this.updateValues(b[C],a.rules[d]);this.isImportRules||this.prvtEvtTgrDaD||this.trigger("change",o),this.allowValidation&&a.rules[d].field&&e.parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(e.parentElement,"tooltip").destroy(),this.filterRules(p,this.getValidRules(this.rule),"field")}else if(t.closest(e,".e-rule-operator")){i=t.getComponent(e,"dropdownlist"),a.rules[d].operator=i.value.toString();var S=u.querySelectorAll(".e-rule-value input.e-control");o={groupID:c,ruleID:g,value:i.value,type:"operator"},this.allowValidation&&a.rules[d].operator&&e.parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(e.parentElement,"tooltip").destroy(),S.length>1&&!(S[0].className.indexOf("e-template")>-1)&&(a.rules[d].value=[]);for(var x=0;x<S.length;x++)a.rules[d].operator.indexOf("null")>-1||a.rules[d].operator.indexOf("empty")>-1?a.rules[d].value=null:S[x].classList.contains("e-template")||this.updateValues(S[x],a.rules[d]);this.isImportRules||this.trigger("change",o),this.filterRules(p,this.getValidRules(this.rule),"operator")}else t.closest(e,".e-rule-value")&&(this.ruleValueUpdate(e,l,a,d,s,u,n),r||this.filterRules(p,this.getValidRules(this.rule),"value"))},p.prototype.filterRules=function(e,t,l){JSON.stringify({condition:e.condition,not:e.not,rule:e.rules})!==JSON.stringify({condition:t.condition,not:t.not,rule:t.rules})&&(this.isImportRules||this.prvtEvtTgrDaD||this.trigger("ruleChange",{previousRule:e,rule:t,type:l}))},p.prototype.ruleValueUpdate=function(e,t,l,n,r,i,o){var s,a,u=["in","between","notin","notbetween"];if(l.rules[n].operator&&(a=l.rules[n].operator.toString().toLowerCase()),null!==t){if(e.className.indexOf("e-multiselect")>-1&&"number"===l.rules[n].type&&!this.isNotified){for(var d=[],c=t,p=0,h=c.length;p<h;p++)"string"==typeof c[p]&&d.push(parseFloat(c[p]));d.length&&(t=d)}if(this.isNotified)l.rules[n].value=t,s={groupID:r.id,ruleID:i.id,value:l.rules[n].value,type:"value"},this.isImportRules||this.trigger("change",s);else if(e.className.indexOf("e-spin")>-1||e.className.indexOf("e-numeric")>-1)u.indexOf(a)>-1?l.rules[n].value[o]=t:l.rules[n].value=t;else if(e.className.indexOf("e-radio")>-1)l.rules[n].value=t;else if(e.className.indexOf("e-multiselect")>-1)l.rules[n].value=t;else if(e.className.indexOf("e-textbox")>-1)"in"===a||"notin"===a?(l.rules[n].type,l.rules[n].value=this.processValueString(t,l.rules[n].type)):l.rules[n].value=t;else if(e.className.indexOf("e-datepicker")>-1){var g=this.getFormat(this.getColumn(this.selectedColumn.field).format);g.type&&(u.indexOf(a)>-1?("string"==typeof l.rules[n].value&&(l.rules[n].value=[]),l.rules[n].value[o]=this.intl.formatDate(t,g)):l.rules[n].value=this.intl.formatDate(t,g))}this.validateValue(l,i,n)}else e.className.indexOf("e-datepicker")>-1&&u.indexOf(a)>-1?("string"==typeof l.rules[n].value&&(l.rules[n].value=[]),l.rules[n].value[o]=t):l.rules[n].value=t},p.prototype.validateValue=function(e,l,n){t.isNullOrUndefined(n)||(e=e.rules[n]);var r="object"==typeof e.value;if(this.allowValidation&&(t.isNullOrUndefined(n)||(r?e.value.length>0:e.value))){var i=l.querySelectorAll(".e-rule-value .e-control");i.length>0&&(i[0].className.indexOf("e-tooltip")>-1?t.getComponent(i[0],"tooltip").destroy():i[0].parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(i[0].parentElement,"tooltip").destroy(),i[1]&&i[1].parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(i[1].parentElement,"tooltip").destroy())}},p.prototype.getFormat=function(e){var t;return e?"string"==typeof e?(t={type:"dateTime"},"short"===e||"yMd"===e?(t.type="date",t.skeleton=e):t.format=e):t={type:"dateTime",skeleton:e.skeleton}:t={type:"date",skeleton:"yMd"},t},p.prototype.findGroupByIdx=function(e,t,l){var n=t.rules,r=[];if(!l){for(var i=0,o=n.length;i<o;i++)(t=n[i]).rules&&r.push(t);return r[e]}return t},p.prototype.destroy=function(){if(this.isDestroy=!0,this.element){var l,n,r,i;for(e.prototype.destroy.call(this),r=(l=this.element.querySelectorAll(".e-addrulegroup")).length,n=0;n<r;n++)t.getComponent(l[n],"dropdown-btn").destroy(),t.detach(l[n]);for(i=this.element.querySelectorAll(".e-rule-filter .e-control.e-tooltip"),n=0;n<i.length;n++)t.getComponent(i[n],"tooltip").destroy();for(r=(l=this.element.querySelectorAll(".e-rule-filter .e-control:not(.e-tooltip)")).length,n=0;n<r;n++)t.getComponent(l[n],"dropdownlist")?t.getComponent(l[n],"dropdownlist").destroy():t.getComponent(l[n],"dropdowntree").destroy(),t.detach(l[n]);for(i=this.element.querySelectorAll(".e-rule-operator .e-control.e-tooltip"),n=0;n<i.length;n++)t.getComponent(i[n],"tooltip").destroy();for(r=(l=this.element.querySelectorAll(".e-rule-operator .e-control:not(.e-tooltip)")).length,n=0;n<r;n++)t.getComponent(l[n],"dropdownlist")&&(t.getComponent(l[n],"dropdownlist").destroy(),t.detach(l[n]));for(i=this.element.querySelectorAll(".e-rule-value .e-control.e-tooltip"),n=0;n<i.length;n++)t.getComponent(i[n],"tooltip").destroy();this.isImportRules=!1,this.unWireEvents(),this.levelColl[this.element.id+"_group0"]=[0],this.element.innerHTML="",this.portals&&this.portals.length&&this.clearQBTemplate();var o=document.querySelectorAll(".qb-dropdownlist.e-popup");if(o)for(n=0;n<o.length;n++)o[n].remove();t.classList(this.element,[],["e-rtl","e-responsive","e-device"]),this.isDestroy=!1}},p.prototype.addRules=function(e,t){t=this.element.id+"_"+t,this.isPublic=!0;for(var l=0,n=e.length;l<n;l++)this.addRuleElement(document.getElementById(t),e[l]);this.isPublic=!1},p.prototype.addGroups=function(e,t){if(this.isAddSuccess||this.element.querySelectorAll(".e-group-container").length<=this.maxGroupCount){t=this.element.id+"_"+t;var l=document.getElementById(t),n=this.getParentGroup(l);if(e.length){this.isPublic=!0;for(var r=0,i=e.length;r<i;r++)this.updatedRule={isLocked:e[r].isLocked,condition:e[r].condition,not:e[r].not},this.importRules(e[r],l,!1,e[r].not);this.isPublic=!1}else{var o="and",s=!1,a=!1;this.updatedRule&&(o=this.updatedRule.condition,s=this.updatedRule.not,a=this.updatedRule.isLocked),this.groupIndex<0?this.enableNotCondition?n.rules.push({condition:o,not:s,rules:[]}):n.rules.push({condition:o,rules:[]}):this.enableNotCondition?n.rules.splice(this.groupIndex+1,0,{condition:o,not:s,rules:[],isLocked:a}):n.rules.splice(this.groupIndex+1,0,{condition:o,rules:[],isLocked:a})}this.headerTemplate||this.disableRuleCondition(l,n,null,!!this.enableSeparateConnector||null)}},p.prototype.initWrapper=function(){if(this.isInitialLoad=!0,this.cssClass&&t.addClass([this.element],this.cssClass.replace(/\s+/g," ").trim().split(" ")),this.enableSeparateConnector&&t.addClass([this.element],"e-multi-connector"),this.enableRtl&&t.addClass([this.element],"e-rtl"),this.width&&(this.element.style.width=this.width),this.height&&(this.element.style.height=this.height),this.rule.rules.length?this.isImportRules=!0:this.addGroupElement(!1,this.element),t.Browser.isDevice||"Vertical"===this.displayMode?(t.Browser.isDevice&&(this.element.style.width="100%",this.element.classList.add("e-device")),t.removeClass(this.element.querySelectorAll(".e-rule-container"),"e-horizontal-mode"),t.addClass(this.element.querySelectorAll(".e-rule-container"),"e-vertical-mode"),this.displayMode="Vertical"):this.displayMode="Horizontal",this.summaryView)this.isImportRules?this.renderSummary():this.renderSummaryCollapse();else{if(this.columns&&this.columns.length&&this.isImportRules){this.addGroupElement(!1,this.element,this.rule.condition,!1,this.rule.not,!1,this.rule);var e=t.extend({},this.rule,{},!0);this.isRefreshed=!0,this.setGroupRules(e),this.isRefreshed=!1}else this.columns&&this.columns.length&&this.addRuleElement(this.element.querySelector(".e-group-container"),{});this.notGroupRtl(),this.readonly&&this.enableReadonly();for(var l=this.element.querySelectorAll("label.e-btn"),n=void 0,r=0;r<l.length;r++)n=l.item(r),t.rippleEffect(n,{selector:".e-btn"})}},p.prototype.renderSummary=function(){var e=this.createElement("div",{attrs:{class:"e-summary-content",id:this.element.id+"_summary_content"}}),t=this.createElement("textarea",{attrs:{class:"e-summary-text",readonly:"true"},styles:"max-height:500px"}),l=this.createElement("button",{attrs:{type:"button",class:"e-edit-rule e-css e-btn e-small e-flat e-primary"}}),n=this.createElement("div",{attrs:{class:"e-summary-btndiv"}});e.appendChild(t),t.textContent=this.getSqlFromRules(this.rule),l.textContent=this.l10n.getConstant("Edit"),n.appendChild(l),e.appendChild(n),this.element.appendChild(e)},p.prototype.renderSummaryCollapse=function(){var e=this.createElement("div",{attrs:{class:"e-collapse-rule e-icons",title:this.l10n.getConstant("SummaryViewTitle")}});this.element.querySelector(".e-group-header").appendChild(e)},p.prototype.columnSort=function(){"descending"===this.sortDirection.toLowerCase()?this.columns=new r.DataManager(this.columns).executeLocal((new r.Query).sortByDesc("field")):"ascending"===this.sortDirection.toLowerCase()&&(this.columns=new r.DataManager(this.columns).executeLocal((new r.Query).sortBy("field")))},p.prototype.onChangeNotGroup=function(){if(this.element.innerHTML="",this.groupIdCounter=0,!this.headerTemplate)if(this.enableNotCondition){var e=this.createElement("button",{attrs:{type:"button",class:"e-qb-toggle"}});this.groupElem.querySelector(".e-btn-group")&&this.groupElem.querySelector(".e-btn-group").insertBefore(e,this.groupElem.querySelector(".e-btngroup-and"))}else this.groupElem.querySelector(".e-qb-toggle").remove();this.setProperties({rule:this.checkNotGroup(this.rule)},!0),this.initWrapper()},p.prototype.notGroupRtl=function(){this.enableRtl?t.addClass(this.element.querySelectorAll(".e-btn-group"),"e-rtl"):t.removeClass(this.element.querySelectorAll(".e-btn-group"),"e-rtl")},p.prototype.checkNotGroup=function(e){var l;if(e.rules)for(var n=0;n<e.rules.length;n++)l=e.rules[n],l=this.checkNotGroup(l),e.rules[n]=l;return t.isNullOrUndefined(e.not)?this.enableNotCondition&&!t.isNullOrUndefined(e.condition)&&(e.not=!1):(this.enableNotCondition&&(e.not=!1),delete e.not),e},p.prototype.onPropertyChanged=function(e,l){for(var n=Object.keys(e),r=this.element.querySelector(".e-group-container"),i=this.element.querySelector(".e-summary-content"),o=0,s=n;o<s.length;o++)switch(s[o]){case"summaryView":e.summaryView?(r.style.display="none",this.element.querySelectorAll(".e-summary-content").length<1?(this.renderSummary(),i=this.element.querySelector(".e-summary-content")):this.element.querySelector(".e-summary-text").textContent=this.getSqlFromRules(this.rule),i.style.display="block"):(r.querySelectorAll(".e-collapse-rule").length>-1&&this.renderSummaryCollapse(),r.style.display="block",i.style.display="none");break;case"displayMode":this.refresh();break;case"showButtons":t.isNullOrUndefined(e.showButtons.lockGroup)||(e.showButtons.lockGroup?t.removeClass(this.element.querySelectorAll(".e-lock-grp-btn"),"e-button-hide"):t.addClass(this.element.querySelectorAll(".e-lock-grp-btn"),"e-button-hide")),t.isNullOrUndefined(e.showButtons.lockRule)||(e.showButtons.lockRule?t.removeClass(this.element.querySelectorAll(".e-lock-rule-btn"),"e-button-hide"):t.addClass(this.element.querySelectorAll(".e-lock-rule-btn"),"e-button-hide")),t.isNullOrUndefined(e.showButtons.cloneGroup)||(e.showButtons.cloneGroup?t.removeClass(this.element.querySelectorAll(".e-clone-grp-btn"),"e-button-hide"):t.addClass(this.element.querySelectorAll(".e-clone-grp-btn"),"e-button-hide")),t.isNullOrUndefined(e.showButtons.cloneRule)||(e.showButtons.cloneRule?t.removeClass(this.element.querySelectorAll(".e-clone-rule-btn"),"e-button-hide"):t.addClass(this.element.querySelectorAll(".e-clone-rule-btn"),"e-button-hide")),t.isNullOrUndefined(e.showButtons.ruleDelete)||(e.showButtons.ruleDelete?t.removeClass(this.element.querySelectorAll(".e-rule-delete"),"e-button-hide"):t.addClass(this.element.querySelectorAll(".e-rule-delete"),"e-button-hide")),t.isNullOrUndefined(e.showButtons.groupDelete)||(e.showButtons.groupDelete?t.removeClass(this.element.querySelectorAll(".e-deletegroup"),"e-button-hide"):t.addClass(this.element.querySelectorAll(".e-deletegroup"),"e-button-hide"));break;case"cssClass":l.cssClass&&t.removeClass([this.element],l.cssClass.split(" ")),e.cssClass&&t.addClass([this.element],e.cssClass.replace(/\s+/g," ").trim().split(" "));break;case"enableRtl":e.enableRtl?(t.addClass([this.element],"e-rtl"),this.notGroupRtl()):(t.removeClass([this.element],"e-rtl"),this.notGroupRtl());break;case"enablePersistence":this.enablePersistence=e.enablePersistence;break;case"dataSource":this.dataSource=e.dataSource,this.refresh();break;case"columns":this.columns=e.columns,this.columnSort(),this.updateSubFieldsFromColumns(this.columns);break;case"sortDirection":this.sortDirection=e.sortDirection,this.columnSort();break;case"maxGroupCount":this.maxGroupCount=e.maxGroupCount;break;case"height":this.height=e.height,this.element.style.height=this.height;break;case"rule":0!==this.rule.rules.length||t.isNullOrUndefined(this.rule)||this.reset(),this.setProperties({rule:e.rule},!0),e.rule=this.getRuleCollection(this.rule,!1),this.setRules(this.rule);break;case"width":this.width=e.width,this.element.style.width=this.width;break;case"locale":this.locale=e.locale,this.intl=new t.Internationalization(this.locale),this.isLocale=!0,this.refresh(),this.isLocale=!1;break;case"enableNotCondition":this.onChangeNotGroup();break;case"readonly":this.isReadonly=e.readonly,this.enableReadonly();break;case"allowDragAndDrop":this.allowDragAndDrop=e.allowDragAndDrop,this.refresh();break;case"enableSeparateConnector":this.enableSeparateConnector=e.enableSeparateConnector,this.refresh()}},p.prototype.preRender=function(){this.element.id=this.element.id||t.getUniqueID("ej2-querybuilder"),this.defaultLocale={StartsWith:"Starts With",DoesNotStartWith:"Does Not Start With",EndsWith:"Ends With",DoesNotEndWith:"Does Not End With",Contains:"Contains",DoesNotContain:"Does Not Contain",NotLike:"Not Like",Like:"Like",Equal:"Equal",NotEqual:"Not Equal",LessThan:"Less Than",LessThanOrEqual:"Less Than Or Equal",GreaterThan:"Greater Than",GreaterThanOrEqual:"Greater Than Or Equal",Between:"Between",NotBetween:"Not Between",In:"In",NotIn:"Not In",Remove:"REMOVE",SelectField:"Select a field",SelectOperator:"Select operator",DeleteRule:"Remove this condition",DeleteGroup:"Delete group",AddGroup:"Add Group",AddCondition:"Add Condition",Edit:"EDIT",ValidationMessage:"This field is required",SummaryViewTitle:"Summary View",OtherFields:"Other Fields",AND:"AND",OR:"OR",NOT:"NOT",SelectValue:"Enter Value",IsEmpty:"Is Empty",IsNotEmpty:"Is Not Empty",IsNull:"Is Null",IsNotNull:"Is Not Null",True:"true",False:"false",AddButton:"Add Group/Condition",CloneGroup:"Clone Group",LockGroup:"Lock Group",CloneRule:"Clone Rule",LockRule:"Lock Rule",UnlockRule:"Unlock Rule",UnlockGroup:"Unlock Group"},this.l10n=new t.L10n("querybuilder",this.defaultLocale,this.locale),this.intl=new t.Internationalization(this.locale),this.groupIdCounter=0,this.subFilterCounter=0,this.ruleIdCounter=0,this.btnGroupId=0,this.isImportRules=!1,this.parser=[],this.customOperators={stringOperator:[{value:"startswith",key:this.l10n.getConstant("StartsWith")},{value:"notstartswith",key:this.l10n.getConstant("DoesNotStartWith")},{value:"endswith",key:this.l10n.getConstant("EndsWith")},{value:"notendswith",key:this.l10n.getConstant("DoesNotEndWith")},{value:"contains",key:this.l10n.getConstant("Contains")},{value:"notcontains",key:this.l10n.getConstant("DoesNotContain")},{value:"equal",key:this.l10n.getConstant("Equal")},{value:"notequal",key:this.l10n.getConstant("NotEqual")},{value:"in",key:this.l10n.getConstant("In")},{value:"notin",key:this.l10n.getConstant("NotIn")},{value:"isempty",key:this.l10n.getConstant("IsEmpty")},{value:"isnotempty",key:this.l10n.getConstant("IsNotEmpty")}],dateOperator:[{value:"equal",key:this.l10n.getConstant("Equal")},{value:"greaterthan",key:this.l10n.getConstant("GreaterThan")},{value:"greaterthanorequal",key:this.l10n.getConstant("GreaterThanOrEqual")},{value:"lessthan",key:this.l10n.getConstant("LessThan")},{value:"lessthanorequal",key:this.l10n.getConstant("LessThanOrEqual")},{value:"notequal",key:this.l10n.getConstant("NotEqual")},{value:"between",key:this.l10n.getConstant("Between")},{value:"notbetween",key:this.l10n.getConstant("NotBetween")}],booleanOperator:[{value:"equal",key:this.l10n.getConstant("Equal")},{value:"notequal",key:this.l10n.getConstant("NotEqual")}],numberOperator:[{value:"equal",key:this.l10n.getConstant("Equal")},{value:"greaterthanorequal",key:this.l10n.getConstant("GreaterThanOrEqual")},{value:"greaterthan",key:this.l10n.getConstant("GreaterThan")},{value:"between",key:this.l10n.getConstant("Between")},{value:"lessthan",key:this.l10n.getConstant("LessThan")},{value:"notbetween",key:this.l10n.getConstant("NotBetween")},{value:"lessthanorequal",key:this.l10n.getConstant("LessThanOrEqual")},{value:"notequal",key:this.l10n.getConstant("NotEqual")},{value:"in",key:this.l10n.getConstant("In")},{value:"notin",key:this.l10n.getConstant("NotIn")}]},this.operators={equal:"=",notequal:"!=",greaterthan:">",greaterthanorequal:">=",lessthan:"<",in:"IN",notin:"NOT IN",lessthanorequal:"<=",startswith:"LIKE",endswith:"LIKE",between:"BETWEEN",notbetween:"NOT BETWEEN",contains:"LIKE",isnull:"IS NULL",isnotnull:"IS NOT NULL",isempty:"IS EMPTY",isnotempty:"IS NOT EMPTY",notstartswith:"NOT LIKE",notendswith:"NOT LIKE",notcontains:"NOT LIKE"},this.sqlOperators={equal:"=",notequal:"!=",greaterthan:">",greaterthanorequal:">=",lessthan:"<",in:this.l10n.getConstant("In").toUpperCase(),notin:this.l10n.getConstant("NotIn").toUpperCase(),lessthanorequal:"<=",startswith:this.l10n.getConstant("Like").toUpperCase(),endswith:this.l10n.getConstant("Like").toUpperCase(),between:this.l10n.getConstant("Between").toUpperCase(),notbetween:this.l10n.getConstant("NotBetween").toUpperCase(),contains:this.l10n.getConstant("Like").toUpperCase(),isnull:this.l10n.getConstant("IsNull").toUpperCase(),isnotnull:this.l10n.getConstant("IsNotNull").toUpperCase(),isempty:this.l10n.getConstant("IsEmpty").toUpperCase(),isnotempty:this.l10n.getConstant("IsNotEmpty").toUpperCase(),notstartswith:this.l10n.getConstant("NotLike").toUpperCase(),notendswith:this.l10n.getConstant("NotLike").toUpperCase(),notcontains:this.l10n.getConstant("NotLike").toUpperCase()},this.fields||(this.fields={text:"label",value:"field"})},p.prototype.render=function(){this.levelColl={},this.items=[{text:this.l10n.getConstant("AddGroup"),iconCss:"e-icons e-add-icon e-addgroup"},{text:this.l10n.getConstant("AddCondition"),iconCss:"e-icons e-add-icon e-addrule"}],this.ruleElem=this.ruleTemplate(),this.groupElem=this.groupTemplate();var e=[{value:"isnull",key:this.l10n.getConstant("IsNull")},{value:"isnotnull",key:this.l10n.getConstant("IsNotNull")}],t=[{value:"isnull",key:this.l10n.getConstant("IsNull")},{value:"isnotnull",key:this.l10n.getConstant("IsNotNull")}];this.customOperators.stringOperator=this.customOperators.stringOperator.concat(e),this.customOperators.numberOperator=this.customOperators.numberOperator.concat(t),this.dataSource instanceof r.DataManager?(this.dataManager=this.dataSource,this.executeDataManager((new r.Query).take(1))):(this.dataManager=new r.DataManager(this.dataSource),this.dataColl=this.dataManager.executeLocal(new r.Query),this.initControl()),this.renderComplete(),this.allowDragAndDrop&&this.initializeDrag()},p.prototype.initializeDrag=function(){this.draggable=new t.Draggable(this.element,{dragTarget:".e-drag-qb-rule",distance:5,helper:this.helper.bind(this),dragStart:this.dragStartHandler.bind(this),drag:this.dragHandler.bind(this),dragStop:this.dragStopHandler.bind(this),isReplaceDragEle:!0,isPreventSelect:!1,abort:".e-parent-header",isDragScroll:!0})},p.prototype.helper=function(e){var l=this.draggable.currentStateTarget;if(!l.classList.contains("e-drag-qb-rule")||l.classList.contains("e-drag-qb-rule")&&t.closest(l,".e-disable"))return!1;var n,r=this.createElement("div",{className:"e-cloneproperties e-draganddrop e-dragclone",styles:'height:"auto", z-index:2, width:'+this.element.offsetWidth});if(this.draggable.currentStateTarget.parentElement.classList.contains("e-group-header"))n=t.closest(l,".e-group-container").cloneNode(!0),t.closest(l,".e-group-container").classList.add("e-qb-dragging-rule");else{r.classList.add("e-group-body"),n=this.createElement("div",{className:"e-rule-container"});var i=t.closest(l,".e-rule-field").cloneNode(!0);n.appendChild(i),t.closest(l,".e-rule-field").classList.add("e-qb-dragging-rule")}return r.appendChild(n),r.querySelectorAll("*").forEach(function(e){e.removeAttribute("id")}),this.element.appendChild(r),r},p.prototype.dragStartHandler=function(e){this.draggedRule=e.target,this.isDragEventPrevent=!1,document.body.classList.add("e-prevent-select"),this.dragElement=e.dragElement;var l=t.closest(e.target,".e-rule-container"),n=t.closest(e.target,".e-group-container"),r={dragRuleID:null!==l?l.id:n.id,dragGroupID:n.id,cancel:!1};this.trigger("dragStart",r),this.isDragEventPrevent=r.cancel},p.prototype.dragHandler=function(e){if(!this.isDragEventPrevent){var l=this.element.querySelectorAll(".e-drag-rule-bottom-line");if(l.forEach(function(e){e.classList.remove("e-drag-rule-bottom-line")}),(l=this.element.querySelectorAll(".e-drag-rule-top-line")).forEach(function(e){e.classList.remove("e-drag-rule-top-line")}),!t.isNullOrUndefined(e.target)){if("HTML"===e.target.nodeName||t.closest(e.target,".e-qb-dragging-rule")||t.closest(e.target,".e-group-header")||!t.closest(e.target,"#"+this.element.id)||t.closest(e.target,".e-disable")||e.target.parentElement&&e.target.parentElement.classList.contains("e-btn-group")&&this.enableSeparateConnector)return void this.dragElement.classList.add("e-notallowedcur");this.dragElement.classList.remove("e-notallowedcur");var n=t.closest(e.target,".e-rule-container"),r=t.closest(e.target,".e-group-container");if(n){var i=n.getBoundingClientRect(),o=(a=e.event.clientY||e.event.changedTouches[0].clientY)-i.top,s=i.bottom-a;o<(u=20)?n.classList.add("e-drag-rule-top-line"):s<u&&n.classList.add("e-drag-rule-bottom-line")}else if(e.target.classList.contains("e-rule-list")&&0===e.target.children.length)e.target.classList.add("e-drag-rule-bottom-line");else if(e.target.classList.contains("e-rule-list")&&e.target.children[0].classList.contains("e-group-container")){i=e.target.children[0].getBoundingClientRect();(o=(a=e.event.clientY||e.event.changedTouches[0].clientY)-i.top)<(u=20)&&e.target.classList.add("e-drag-rule-top-line")}else if((t.closest(e.target,".e-group-container")||e.target.classList.contains("e-group-container"))&&(r||(r=e.target),r.id.indexOf("group0")>-1)){var i=e.target.getBoundingClientRect(),a=e.event.clientY||e.event.changedTouches[0].clientY,u=20;(s=i.bottom-a)<u&&e.target.classList.add("e-drag-rule-bottom-line")}var d={dragRuleID:null!==n?n.id:null!==r?r.id:null,dragGroupID:null!==r?r.id:null,cancel:!1};this.trigger("drag",d),this.isDragEventPrevent=d.cancel}}},p.prototype.templateParser=function(e){if(e)try{return"function"!=typeof e&&document.querySelectorAll(e).length?t.compile(document.querySelector(e).innerHTML.trim()):t.compile(e)}catch(l){return t.compile(e)}},p.prototype.executeDataManager=function(e){var t=this,l=this.dataManager.executeQuery(e),n=new r.Deferred;l.then(function(e){e.actual&&e.actual.result?t.dataColl=e.actual.result:t.dataColl=e.result,t.initControl()}).catch(function(e){n.reject(e)})},p.prototype.initControl=function(){this.initialize(),this.initWrapper(),this.wireEvents()},p.prototype.wireEvents=function(){var e=this.getWrapper();t.EventHandler.add(e,"click",this.clickEventHandler,this),t.EventHandler.add(e,"focusout",this.focusEventHandler,this),t.EventHandler.add(e,"focusin",this.focusEventHandler,this),t.EventHandler.add(this.element,"keydown",this.keyBoardHandler,this),t.EventHandler.add(document,"keydown",this.keyBoardHandler,this)},p.prototype.unWireEvents=function(){var e=this.getWrapper();t.EventHandler.remove(e,"click",this.clickEventHandler),t.EventHandler.remove(e,"focusout",this.focusEventHandler),t.EventHandler.remove(e,"focusin",this.focusEventHandler),t.EventHandler.remove(this.element,"keydown",this.keyBoardHandler),t.EventHandler.remove(document,"keydown",this.keyBoardHandler)},p.prototype.getParentGroup=function(e,t){for(var l=e instanceof Element?this.levelColl[e.id]:this.levelColl[""+e],n=t?l.length-1:l.length,r=this.rule,i=0;i<n;i++)r=this.findGroupByIdx(l[i],r,0===i);return r},p.prototype.deleteGroup=function(e){var t,l=this,n=e;"string"==typeof e?(t=this.element.id+"_"+e,e=document.getElementById(t)):t=n.id.replace(this.element.id+"_","");var r={groupID:t,cancel:!1,type:"deleteGroup"};this.isImportRules||this.prvtEvtTgrDaD?this.deleteGroupSuccessCallBack(r,e):this.trigger("beforeChange",r,function(t){l.deleteGroupSuccessCallBack(t,e)})},p.prototype.deleteGroupSuccessCallBack=function(e,l){if(!e.cancel){var n=l,r=this.getParentGroup(n,!0),i=0,o=void 0,s=void 0,a=this.getValidRules(this.rule),u=n.nextElementSibling,d=n.previousElementSibling,c=n.querySelectorAll(".e-group-container"),p=n.querySelectorAll(".e-tooltip");for(s=p.length,o=0;o<s;o++)t.getComponent(p[o],"tooltip").destroy();for(o=0,s=c.length;o<s;o++)delete this.levelColl[c[o].id];for(;null!==n.previousElementSibling;)n=n.previousElementSibling,(!this.enableSeparateConnector||this.enableSeparateConnector&&(!this.headerTemplate&&!n.classList.contains("e-btn-group")||this.headerTemplate&&(n.classList.contains("e-rule-container")||n.classList.contains("e-group-container"))))&&i++;this.enableSeparateConnector||u&&u.className.indexOf("e-separate-rule")>-1&&(t.removeClass([u],"e-separate-rule"),t.addClass([u],"e-joined-rule"),d&&d.className.indexOf("e-rule-container")>-1&&t.addClass([d],"e-prev-joined-rule"));var h=n.parentElement.parentElement.parentElement,g=[];if(this.isReact||this.isAngular){var m=r.rules[i],f=l.querySelectorAll(".e-rule-container");if(m&&m.rules)for(var v=0;v<m.rules.length;v++){var y=this.getColumn(m.rules[v].field);if(f[v]){var b=f[v].querySelector(".e-template-value");y&&(y.ruleTemplate||this.isPlatformTemplate(y)&&b)&&g.push(f[v].id)}}}t.detach(l),this.headerTemplate&&this.clearQBTemplate([l.id]),g.length&&this.clearQBTemplate(g),r.rules.splice(i,1),delete this.levelColl[e.groupID],this.refreshLevelColl(),this.disableRuleCondition(h,r),this.enableSeparateConnector&&d&&(!this.headerTemplate&&d.classList.contains("e-btn-group")||this.headerTemplate&&d.classList.contains("e-custom-group-btn"))&&t.detach(d),this.isImportRules||this.prvtEvtTgrDaD||this.trigger("change",e),this.filterRules(a,this.getValidRules(this.rule),"deleteGroup")}},p.prototype.isPlatformTemplate=function(e){return e.template&&("string"==typeof e.template||void 0===e.template.create)},p.prototype.deleteRule=function(e){var l=this,n={groupID:t.closest(e,".e-group-container").id.replace(this.element.id+"_",""),ruleID:t.closest(e,".e-rule-container").id.replace(this.element.id+"_",""),cancel:!1,type:"deleteRule"};this.isImportRules||this.prvtEvtTgrDaD?this.deleteRuleSuccessCallBack(n,e):this.trigger("beforeChange",n,function(t){l.deleteRuleSuccessCallBack(t,e)})},p.prototype.deleteRuleSuccessCallBack=function(e,l){if(!e.cancel){var n=t.closest(l,".e-group-container"),r=this.getParentGroup(n),i=t.closest(l,".e-rule-container"),o=this.getValidRules(this.rule),s=i.previousElementSibling,a=0,u=i,d=i.nextElementSibling,c=i.querySelectorAll(".e-tooltip"),p=void 0,h=c.length;for(p=0;p<h;p++)t.getComponent(c[p],"tooltip").destroy();for(;null!==i.previousElementSibling;)i=i.previousElementSibling,(!this.enableSeparateConnector||this.enableSeparateConnector&&(!this.headerTemplate&&!i.classList.contains("e-btn-group")||this.headerTemplate&&(i.classList.contains("e-rule-container")||i.classList.contains("e-group-container"))))&&a++;var g=this.getColumn(r.rules[a].field);g&&g.template&&u.querySelector(".e-template")&&this.templateDestroy(g,u.querySelector(".e-template").id),(!s||s.className.indexOf("e-rule-container")<0)&&d&&t.removeClass([d],"e-joined-rule"),(!d||d.className.indexOf("e-rule-container")<0)&&s&&t.removeClass([s],"e-prev-joined-rule");var m=u.querySelector(".e-template-value");try{if(this.enableSeparateConnector&&(u.previousElementSibling||u.nextElementSibling)){var f=u.previousElementSibling,v=u.nextElementSibling;t.isNullOrUndefined(v)&&(!this.headerTemplate&&f.classList.contains("e-btn-group")||this.headerTemplate&&f.classList.contains("e-custom-group-btn"))?(f&&f.previousElementSibling&&f.previousElementSibling.classList.contains("e-rule-container")&&(this.getRule(f.previousElementSibling).condition=null),t.detach(f)):(!this.headerTemplate&&v.classList.contains("e-btn-group")||this.headerTemplate&&v.classList.contains("e-custom-group-btn"))&&t.detach(v)}t.detach(u)}catch(e){return}g&&g.ruleTemplate&&this.clearQBTemplate([u.id]),g&&this.isPlatformTemplate(g)&&m&&this.clearQBTemplate([u.id]),r.rules.splice(a,1),r.rules[0]&&r.rules[0].rules||this.disableRuleCondition(n,r,!!this.enableSeparateConnector);for(var y=this.element.querySelectorAll(".e-tooltip"),b=0;b<y.length;b++)t.getComponent(y[b],"tooltip").refresh(y[b]);this.isImportRules||this.prvtEvtTgrDaD||this.trigger("change",e),this.filterRules(o,this.getValidRules(this.rule),"deleteRule")}},p.prototype.setGroupRules=function(e,t){if(this.headerTemplate&&t&&(this.isRoot=!0),this.reset(),this.groupIdCounter=1,this.ruleIdCounter=0,this.isImportRules=!0,this.setProperties({rule:e},!0),e=this.getRuleCollection(this.rule,!1),this.importRules(this.rule,this.element.querySelector(".e-group-container"),!0,this.rule.not,t),e.isLocked){var l=this.element.querySelector(".e-group-container").querySelector(".e-lock-grp-btn");this.groupLock(l)}this.isImportRules=!1},p.prototype.keyBoardHandler=function(e){if(e.currentTarget!==this.element||!this.readonly||38!==e.keyCode&&40!==e.keyCode&&13!==e.keyCode){if("Escape"===e.code&&this.allowDragAndDrop){this.isDragEventPrevent=!0,document.body.classList.remove("e-prevent-select");var l=this.element.querySelectorAll(".e-drag-rule-bottom-line");l.forEach(function(e){e.classList.remove("e-drag-rule-bottom-line")}),(l=this.element.querySelectorAll(".e-drag-rule-top-line")).forEach(function(e){e.classList.remove("e-drag-rule-top-line")}),(l=this.element.querySelectorAll(".e-qb-dragging-rule")).forEach(function(e){e.classList.remove("e-qb-dragging-rule")});var n=this.element.querySelector(".e-cloneproperties");n&&t.remove(n),this.enableSeparateConnector&&this.refresh()}}else e.preventDefault()},p.prototype.clearQBTemplate=function(e){(this.isReact||this.isAngular)&&this.clearTemplate(e)},p.prototype.disableRuleCondition=function(e,l,n,r){if(!this.headerTemplate){if(this.readonly)return;var i=e.querySelector(".e-rule-list").childElementCount,o=e.querySelector(".e-btngroup-and"),s=e.querySelector(".e-btngroup-or");if(i>1)if(o.disabled=!1,s.disabled=!1,(s.nextElementSibling.classList.contains("e-btn-disable")||o.nextElementSibling.classList.contains("e-btn-disable"))&&(s.nextElementSibling.classList.remove("e-btn-disable"),o.nextElementSibling.classList.remove("e-btn-disable")),this.enableSeparateConnector&&!n){for(var a=0,u=void 0;;){var d=e.parentElement.querySelectorAll(".e-btngroup-and"),c=e.parentElement.querySelectorAll(".e-btngroup-or");if(o=d[d.length-(1+a)],s=c[c.length-(1+a)],!(u=d[d.length-(1+a)])||!u.parentElement||"none"!==u.parentElement.style.display)break;a++}for(p=e.previousElementSibling;p&&!p.classList.contains("e-rule-container");){if(p.classList.contains("e-group-container")){p=p.querySelectorAll(".e-rule-container")[p.querySelectorAll(".e-rule-container").length-1];break}p=p.previousElementSibling}if(r&&e.classList.contains("e-group-container"))p=e,"or"===(m=this.getGroup(p)).condition?s.checked=!0:o.checked=!0;else if(p&&p.classList.contains("e-rule-container")){g=p.id.replace(this.element.id+"_","");"or"===(m=this.getRule(g)).condition?s.checked=!0:o.checked=!0}}else n||(l&&"or"===l.condition?s.checked=!0:o.checked=!0);else if(this.enableSeparateConnector&&!n){for(var a=0,u=void 0;;){var d=e.parentElement.querySelectorAll(".e-btngroup-and"),c=e.parentElement.querySelectorAll(".e-btngroup-or");if(o=d[d.length-(1+a)],s=c[c.length-(1+a)],!(u=d[d.length-(1+a)])||!u.parentElement||"none"!==u.parentElement.style.display)break;a++}for(var p=void 0,h=e.previousElementSibling;h;){if(h.classList.contains("e-group-container")&&(h=h.querySelectorAll(".e-rule-container")[h.querySelectorAll(".e-rule-container").length-1]),h.classList.contains("e-rule-container")){p=h;break}h=h.previousElementSibling}if(t.isNullOrUndefined(p)&&e.querySelectorAll(".e-rule-container")[e.querySelectorAll(".e-rule-container").length-1]&&(p=e.querySelectorAll(".e-rule-container")[e.querySelectorAll(".e-rule-container").length-1]),r&&e.classList.contains("e-group-container"))p=e,"or"===(m=this.getGroup(p)).condition?s.checked=!0:o.checked=!0;else if(p){var g=p.id.replace(this.element.id+"_",""),m=this.getRule(g);"or"===m.condition&&s?s.checked=!0:o&&(o.checked=!0)}}else n||(o.checked=!1,o.disabled=!0,s.checked=!1,s.disabled=!0,l&&(s.nextElementSibling.classList.add("e-btn-disable"),o.nextElementSibling.classList.add("e-btn-disable")))}},p.prototype.getValidRules=function(e){e||(e=this.getRules());var l=e.condition,n=e.not,r=t.extend([],e.rules,[],!0);return t.isNullOrUndefined(e.isLocked)?this.getRuleCollection({condition:l,rules:r,not:n},!0):this.getRuleCollection({condition:l,rules:r,not:n,isLocked:e.isLocked},!0)},p.prototype.getRuleCollection=function(e,l){if(t.isNullOrUndefined(e))return null;var n;if(e.rules&&e.rules.length&&(Object.keys(e.rules[0]).length>6||l))for(var r=e.rules.length,i=0;i<r;i++)n=e.rules[i],n=this.getRuleCollection(n,l),e.rules[i]=n,Object.keys(n).length<1&&l&&(e.rules.splice(i,1),i--,r--);var o=e.custom;if(e.field&&""!==e.field&&(t.isNullOrUndefined(o)||o&&"question"!==o.type&&"answer"!==o.type))if(e.operator&&(e.operator.toString().indexOf("null")>-1||e.operator.toString().indexOf("empty")>-1)&&(e.value=null),this.isRefreshed&&this.enablePersistence||""!==e.field&&""!==e.operator&&""!==e.value&&void 0!==e.value||o&&o.isQuestion){var s=e.condition,a=e.isLocked;e={label:e.label,field:e.field,operator:e.operator,type:e.type,value:e.value},t.isNullOrUndefined(a)||(e.isLocked=a),s&&(e.condition=s),o&&(e.custom=o),"in"!==e.operator&&"notin"!==e.operator||!e.value||0!==e.value.length||(e={})}else e={};else if(!o||"question"!==o.type&&"answer"!==o.type)if(t.isNullOrUndefined(e.condition)&&t.isNullOrUndefined(e.rules))e={};else{var u=e.isLocked;e=this.enableNotCondition?{condition:e.condition,rules:e.rules,not:e.not}:{condition:e.condition,rules:e.rules},t.isNullOrUndefined(u)||(e.isLocked=u),o&&(e.custom=o),e.rules&&0===e.rules.length&&(e={})}else{var d=e.not;(e={label:e.label,field:e.field,operator:e.operator,type:e.type,value:e.value,condition:e.condition,rules:e.rules}).custom=o,this.enableNotCondition&&(e.not=d)}return e},p.prototype.setRules=function(e){var l=t.extend({},e,{},!0);this.headerTemplate?this.setGroupRules(l,!0):this.setGroupRules(l)},p.prototype.getRules=function(){var e;return e=this.enableNotCondition?{condition:this.rule.condition,rules:this.rule.rules,not:this.rule.not}:{condition:this.rule.condition,rules:this.rule.rules},t.isNullOrUndefined(this.rule.isLocked)||(e.isLocked=this.rule.isLocked),this.rule.custom&&(e.custom=this.rule.custom),e},p.prototype.getRule=function(e){var l,n,r=0;if(e instanceof HTMLElement?l=t.closest(e,".e-rule-container"):(n=this.element.id+"_"+e,l=document.getElementById(n)),t.isNullOrUndefined(l))return null;for(var i=t.closest(l,".e-group-container"),o=this.getParentGroup(i);null!==l.previousElementSibling;)l=l.previousElementSibling,(!this.enableSeparateConnector||this.enableSeparateConnector&&(!this.headerTemplate&&!l.classList.contains("e-btn-group")||this.headerTemplate&&(l.classList.contains("e-rule-container")||l.classList.contains("e-group-container"))))&&r++;return o.rules[r]},p.prototype.getGroup=function(e){e instanceof Element&&e.className.indexOf("e-group-container")<1&&(e=t.closest(e,".e-group-container"));var l=e instanceof Element?e.id:this.element.id+"_"+e;return this.getParentGroup(l)},p.prototype.deleteGroups=function(e){var t,l,n=e.length;for(t=0;t<n;t++)l=this.element.id+"_"+e[t],this.deleteGroup(document.getElementById(l))},p.prototype.getFilteredRecords=function(){var e=this.getPredicate(this.getValidRules(this.rule)),l=t.isNullOrUndefined(e)?new r.Query:(new r.Query).where(e);return this.dataManager.executeQuery(l)},p.prototype.deleteRules=function(e){var t,l,n=e.length;for(t=0;t<n;t++)l=this.element.id+"_"+e[t],this.deleteRule(document.getElementById(l))},p.prototype.getDataManagerQuery=function(e){for(var t=this.getPredicate(e),l=[],n=0,i=Object.keys(this.columns);n<i.length;n++)l.push(this.columns[n].field);return e.rules.length?(new r.Query).select(l).where(t):(new r.Query).select(l)},p.prototype.getPredicate=function(e){var l,n,i,o,s=e.rules,a=!1;if(!s)return l;for(var u=0,d=s.length;u<d;u++){var c=s[u].operator;if("notstartswith"===c?c="doesnotstartwith":"notendswith"===c?c="doesnotendwith":"notcontains"===c&&(c="doesnotcontain"),a=!1,Object.keys(s[u]).indexOf("rules")>-1&&s[u].rules)(n=this.getPredicate(s[u]))&&(l=l?"and"===e.condition?l.and(n):l.or(n):n);else if(!t.isNullOrUndefined(c)&&!t.isNullOrUndefined(c.length)){var p=s[u].operator.toLowerCase(),h=!1,g=["equal","notequal","greaterthan","greaterthanorequal","lessthan","lessthanorequal"];if("string"===s[u].type&&(a=!this.matchCase),"date"===s[u].type&&g.indexOf(p)>-1&&(a=!0),o=this.getColumn(s[u].field),p.indexOf("null")>-1||p.indexOf("empty")>-1)s[u].value=null;else if("date"!==s[u].type||s[u].value instanceof Array)i=s[u].value;else{var m=this.getFormat(o.format);t.isNullOrUndefined(s[u].value)?i=null:(i=this.getDate(s[u].value,m),g.indexOf(p)>-1&&!this.isTime(s[u].value)&&(h=!0))}if(0===u)h||(p.indexOf("in")>-1||p.indexOf("between")>-1||p.indexOf("null")>-1||p.indexOf("empty")>-1)&&p.indexOf("contain")<0?l=h?this.datePredicate(s[u],i):this.arrayPredicate(s[u]):""!==(f=i)&&(l=new r.Predicate(s[u].field,c,i,a));else if(h||(p.indexOf("in")>-1||p.indexOf("between")>-1||p.indexOf("null")>-1||p.indexOf("empty")>-1)&&p.indexOf("contain")<0)l=h?this.datePredicate(s[u],i,l,e.condition):this.arrayPredicate(s[u],l,e.condition);else if("and"===e.condition){f=i;l&&""!==f?l=l.and(s[u].field,c,i,a):""!==f&&(l=new r.Predicate(s[u].field,c,i,a))}else{var f=i;l&&""!==f?l=l.or(s[u].field,c,i,a):""!==f&&(l=new r.Predicate(s[u].field,c,i,a))}}}return this.dataSource instanceof r.DataManager&&(t.isNullOrUndefined(l)||"isnull"!==l.operator&&"isnotnull"!==l.operator||(l.operator="isnull"===l.operator?"equal":"notequal")),l},p.prototype.getLocale=function(){var e=this.locale;return t.getValue("main."+this.locale+".dates.calendars.gregorian.days.format.short",t.cldrData)||(e="en"),e},p.prototype.getColumn=function(e,t){for(var l,n=this.columns,r=0,i=(n=t||n).length;r<i;r++){if(n[r].field===e){l=n[r];break}if(n[r].columns){if(l=this.getColumn(e,n[r].columns))break}else if(e&&e.indexOf(this.separator)>-1&&""!==this.separator&&n[r].field===e.split(this.separator)[0]){l=n[r];break}}return l},p.prototype.getOperators=function(e){return this.getColumn(e).operators},p.prototype.setTime=function(e,t){return t?e.setHours(0,0,0):e.setHours(23,59,59),e},p.prototype.datePredicate=function(e,t,l,n){var i,o=this.setTime(new Date(t.getTime()),!0),s=this.setTime(t);switch(e.operator){case"equal":i=(i=new r.Predicate(e.field,"greaterthanorequal",o)).and(e.field,"lessthanorequal",s);break;case"notequal":i=(i=new r.Predicate(e.field,"lessthan",o)).or(e.field,"greaterthan",s);break;case"greaterthan":i=new r.Predicate(e.field,"greaterthan",s);break;case"greaterthanorequal":i=new r.Predicate(e.field,"greaterthanorequal",o);break;case"lessthan":i=new r.Predicate(e.field,"lessthan",o);break;case"lessthanorequal":i=new r.Predicate(e.field,"lessthanorequal",s)}return i&&(l?"and"===n?l=l.and(i):"or"===n&&(l=l.or(i)):l=i),l},p.prototype.arrayPredicate=function(e,t,l){var n,i=e.value,o=e.operator.toString(),s=e.value,a=this.getColumn(e.field),u=this.getFormat(a.format);if(o.indexOf("null")>-1||o.indexOf("empty")>-1)switch(o){case"isnull":n=new r.Predicate(e.field,"isnull",s);break;case"isnotnull":n=new r.Predicate(e.field,"isnotnull",s);break;case"isempty":n=new r.Predicate(e.field,"equal","");break;case"isnotempty":n=new r.Predicate(e.field,"notequal","")}if(!(o.indexOf("null")>-1||o.indexOf("empty")>-1))for(var d=0,c=i.length;d<c;d++)if(""!==i[d]||("in"===o||"notin"===o)&&"string"===a.type)if(0===d){var p="greaterthanorequal";switch(o){case"between":n="date"!==a.type?new r.Predicate(e.field,p,i[d]):new r.Predicate(e.field,p,i[d]?this.isTime(i[d])?this.getDate(i[d],u):this.setTime(this.getDate(i[d],u),!0):null);break;case"notbetween":n="date"===a.type?new r.Predicate(e.field,"lessthan",i[d]?this.isTime(i[d])?this.getDate(i[d],u):this.setTime(this.getDate(i[d],u),!0):null):new r.Predicate(e.field,"lessthan",i[d]);break;case"in":n=new r.Predicate(e.field,"equal",i[d]);break;case"notin":n=new r.Predicate(e.field,"notequal",i[d])}}else{switch(e.operator){case"between":n="date"===a.type?n.and(e.field,"lessthanorequal",i[d]?this.isTime(i[d])?this.getDate(i[d],u):this.setTime(this.getDate(i[d],u)):i[d]):n.and(e.field,"lessthanorequal",i[d]);break;case"notbetween":n="date"===a.type?n.or(e.field,"greaterthan",i[d]?this.isTime(i[d])?this.getDate(i[d],u):this.setTime(this.getDate(i[d],u)):i[d]):n.or(e.field,"greaterthan",i[d]);break;case"in":n=n.or(e.field,"equal",i[d]);break;case"notin":n=n.and(e.field,"notequal",i[d])}}return n&&(t?"and"===l?t=t.and(n):"or"===l&&(t=t.or(n)):t=n),t},p.prototype.getDate=function(e,t){var l=this.intl.parseDate(e,t);return e.indexOf(":")>-1&&e.indexOf("/")<0&&e.indexOf(",")<0&&e.indexOf("-")<0&&((l=new Date).setHours(parseInt(e.split(":")[0],10)),l.setMinutes(parseInt(e.split(":")[1],10)),e.split(":")[2]&&l.setSeconds(parseInt(e.split(":")[2],10))),l},p.prototype.isTime=function(e){return!!(e&&e.indexOf(":")>-1)},p.prototype.importRules=function(e,l,n,r,i){if(n){if(e.rules&&e.rules.length>1&&!this.headerTemplate){var o=l.querySelector(".e-btngroup-or"),s=l.querySelector(".e-btngroup-and");if(this.enableSeparateConnector&&l.previousElementSibling&&(o=l.previousElementSibling.querySelector(".e-btngroup-or"),s=l.previousElementSibling.querySelector(".e-btngroup-and")),o.disabled=!1,s.disabled=!1,this.enableSeparateConnector){for(var a=l.previousElementSibling;a&&!a.classList.contains("e-rule-container");){if(a.classList.contains("e-group-container")){a=a.querySelectorAll(".e-rule-container")[a.querySelectorAll(".e-rule-container").length-1];break}a=a.previousElementSibling}if(a&&a.classList.contains("e-rule-container")){var u=a.id.replace(this.element.id+"_","");"or"===this.getRule(u).condition?o.checked=!0:s.checked=!0}}else"or"===e.condition?o.checked=!0:s.checked=!0}else this.disableRuleCondition(l);if(this.headerTemplate&&i&&(l=this.renderGroup(e,e.condition,this.element,e.not,i)),this.enableNotCondition&&!this.headerTemplate){var d=l.querySelector(".e-qb-toggle");e.not?t.addClass([d],"e-active-toggle"):t.removeClass([d],"e-active-toggle")}}else l=this.renderGroup(e,e.condition,l,r);e.rules&&0===e.rules.length&&this.headerTemplate&&(e.rules[0]={label:"",field:"",operator:"",type:"",value:""});var c=e.rules;if(!t.isNullOrUndefined(c))for(var p=0,h=c.length;p<h;p++){var g=Object.keys(c[p]);if(!t.isNullOrUndefined(c[p].rules)&&g.indexOf("rules")>-1&&0!==c[p].rules.length){if(this.element.querySelectorAll(".e-group-container").length>this.maxGroupCount)return null;l=this.renderGroup(c[p],c[p].condition,l,c[p].not),l=this.importRules(c[p],l,!0)}else this.renderRule(c[p],l);if(!t.isNullOrUndefined(c[p].rules)&&c[p].isLocked){var m=l.querySelector(".e-rule-list").children[p].querySelector(".e-lock-grp-btn");this.groupLock(m)}}return l&&(l=t.closest(l,".e-rule-list")),l&&(l=t.closest(l,".e-group-container")),l},p.prototype.renderGroup=function(e,t,l,n,r){this.addGroupElement(!0,l,t,!1,n,r,e);var i=l.querySelectorAll(".e-group-container"),o=l.querySelector(".e-rule-list").children;if(this.showButtons.cloneGroup&&this.cloneGrpBtnClick&&this.isMiddleGroup){this.isMiddleGroup=!1,this.cloneGrpBtnClick=!1;var s=0,a=this.groupIndex+1;if(this.enableSeparateConnector)for(var u=0;u<a;u++)o[u].classList.contains("e-rule-container")&&(a++,s++);return o[this.groupIndex+s+1]}return this.showButtons.cloneGroup&&this.cloneGrpBtnClick&&this.isLastGroup?(this.isLastGroup=!1,this.cloneGrpBtnClick=!1,o[o.length-1]):i[i.length-1]},p.prototype.renderRule=function(e,t){t.className.indexOf("e-group-container")>-1?this.addRuleElement(t,e):this.addRuleElement(t.querySelector(".e-group-container"),e)},p.prototype.enableReadonly=function(){for(var e=this.element.querySelectorAll(".e-dropdownlist, .e-dropdowntree, .e-numerictextbox, .e-textbox, .e-datepicker, .e-multiselect .e-lib, .e-radio"),r=0;r<e.length;r++)e[r].classList.contains("e-dropdownlist")?t.getInstance(e[r],n.DropDownList).readonly=this.isReadonly:e[r].classList.contains("e-dropdowntree")?t.getComponent(e[r],"dropdowntree").readonly=this.isReadonly:e[r].classList.contains("e-numerictextbox")?t.getInstance(e[r],i.NumericTextBox).readonly=this.isReadonly:e[r].classList.contains("e-textbox")?t.getInstance(e[r],i.TextBox).readonly=this.isReadonly:e[r].classList.contains("e-datepicker")?t.getInstance(e[r],o.DatePicker).readonly=this.isReadonly:e[r].classList.contains("e-multiselect")?t.getInstance(e[r],n.MultiSelect).readonly=this.isReadonly:e[r].classList.contains("e-radio")&&(t.getInstance(e[r],l.RadioButton).checked||(this.isReadonly?e[r].parentElement.style.display="none":e[r].parentElement.style.display="inherit"));var s=this.element.querySelectorAll(".e-deletegroup"),a=this.element.querySelectorAll(".e-addrulegroup"),u=this.element.querySelectorAll(".e-removerule");!this.isReadonly&&this.ruleElem.classList.contains("e-readonly")&&this.ruleElem.classList.remove("e-readonly");for(var d=[s,a,u],r=0;r<d.length;r++)d[r].forEach(function(e){e.classList.contains("e-readonly")?e.classList.remove("e-readonly"):e.classList.add("e-readonly")});this.enableBtnGroup()},p.prototype.enableBtnGroup=function(){var e=this,t=!1;this.element.querySelectorAll(".e-btngroup-and-lbl, .e-btngroup-or-lbl, .e-qb-toggle").forEach(function(l){!l.classList.contains("e-qb-toggle")||l.classList.contains("e-active-toggle")||l.classList.contains("e-readonly")?l.classList.contains("e-qb-toggle")&&l.classList.contains("e-not-readonly")?l.classList.remove("e-not-readonly"):l.classList.contains("e-qb-toggle")&&l.classList.contains("e-readonly")?l.classList.remove("e-readonly"):l.classList.contains("e-active-toggle")?(l.classList.add("e-not-readonly"),t=!0):l.previousElementSibling.checked||l.classList.contains("e-readonly")?(l.classList.remove("e-readonly"),t?"AND"===l.textContent?l.classList.add("e-readonly-and"):l.classList.add("e-readonly-or"):("AND"===l.textContent&&e.isReadonly?(l.classList.remove("e-not"),l.classList.add("e-readonly-and")):(e.enableNotCondition&&l.classList.add("e-not"),l.classList.remove("e-readonly-and")),"OR"===l.textContent&&e.isReadonly?l.classList.add("e-readonly-or-not"):l.classList.remove("e-readonly-or-not"))):l.classList.contains("e-btn-disable")||l.classList.add("e-readonly"):(l.classList.add("e-readonly"),t=!1)})},p.prototype.isDateFunction=function(e){for(var t=["date","time","day","week","month","year","hour","minute","second","now","quarter","period","extract"],l=0,n=t.length;l<n;l++)if(e.toLowerCase().indexOf(t[l])>-1)return!0;return!1},p.prototype.getSqlString=function(e,t,l,n){var r=!1;l||""===l?l+="(":(l="",r=!0);var i=e.condition;if(e.not){l+=r?n?this.l10n.getConstant("NOT").toUpperCase()+" (":"NOT (":n?" "+this.l10n.getConstant("NOT").toUpperCase()+" (":" NOT ("}if(e.rules)for(var o=0,s=e.rules.length;o<s;o++){if(e.rules[o].rules)l=this.getSqlString(e.rules[o],t,l,n),i=e.rules[o].condition;else{var a=e.rules[o],u="",d=n?this.sqlOperators[a.operator]:this.operators[a.operator];if(a.value instanceof Array)if(a.operator.toString().indexOf("between")>-1){var c=n?" "+this.l10n.getConstant("AND").toUpperCase()+" ":" AND ";"date"!==a.type||this.isDateFunction(a.value[0])?u+=a.value[0]+c+a.value[1]:u+='"'+a.value[0]+'"'+c+'"'+a.value[1]+'"'}else if("string"==typeof a.value[0]&&null!==a.value){u+='("'+a.value[0]+'"';for(var p=1,h=a.value.length;p<h;p++)u+=',"'+a.value[p]+'"';u+=")"}else u+="("+a.value+")";else a.operator.toString().indexOf("startswith")>-1?u+=a.value?'("'+a.value+'%")':"("+a.value+")":a.operator.toString().indexOf("endswith")>-1?u+=a.value?'("%'+a.value+'")':"("+a.value+")":a.operator.toString().indexOf("contains")>-1?u+=a.value?'("%'+a.value+'%")':"("+a.value+")":"number"===a.type||"boolean"==typeof a.value||null===a.value&&a.operator.toString().indexOf("empty")<-1?u+=a.value:a.operator.toString().indexOf("empty")>-1?u+='""':u+='"'+a.value+'"';if(a.operator.toString().indexOf("null")>-1)t?a.field="`"+a.field+"`":a.field.indexOf(" ")>-1&&(a.field='"'+a.field+'"'),l+=a.field+" "+d;else{var g=d;"isempty"===a.operator?g="=":"isnotempty"===a.operator&&(g="!="),t?a.field="`"+a.field+"`":a.field.indexOf(" ")>-1&&(a.field='"'+a.field+'"'),l+=a.field+" "+g+" "+u}a.condition&&""!==a.condition&&(i=a.condition)}if(o!==s-1){a=e.rules[o];(""===i||a&&""!==a.condition&&a.custom&&a.custom.isCustom)&&(i=a.condition),i&&(l+=" "+(i=n?this.l10n.getConstant(i.toUpperCase()).toUpperCase():i.toUpperCase())+" ")}}return r||(l+=")"),e.not&&(l+=")"),l},p.prototype.setRulesFromSql=function(e,t){e=e.replace(/`/g,"");var l=this.getRulesFromSql(e,t);this.setRules({condition:l.condition,not:l.not,rules:l.rules})},p.prototype.getRulesFromSql=function(e,t){this.parser=[],this.sqlParser(e,t),this.setProperties({rule:{condition:"and",not:!1,rules:[]}},!0);var l=this.processParser(this.parser,this.rule,[0],t);return this.enableNotCondition?{condition:l.condition,not:l.not,rules:l.rules}:{condition:l.condition,rules:l.rules}},p.prototype.getSqlFromRules=function(e,t,l){return e||(e=this.getValidRules()),e=this.getRuleCollection(e,!1),this.getSqlString(this.getValidRules(e),t,null,l).replace(/"/g,"'")},p.prototype.getParameterizedSql=function(e){if(this.moduleLoader.loadedModules.length){e||(e=this.getValidRules());var t={sql:null};return this.notify("query-library",{prop:"getParameterSql",onPropertyChange:!1,value:{rule:e,obj:t}}),t.sql}return console.warn('[WARNING] :: Module "query-library" is not available in QueryBuilder component! You either misspelled the module name or forgot to load it.'),null},p.prototype.setParameterizedSql=function(e){if(this.moduleLoader.loadedModules.length){var t={sql:null};this.notify("query-library",{prop:"convertParamSqlToSql",onPropertyChange:!1,value:{sql:e,obj:t}});var l=t.sql;if(l){l=l.replace(/`/g,"");var n=this.getRulesFromSql(l);this.setRules({condition:n.condition,not:n.not,rules:n.rules})}}else console.warn('[WARNING] :: Module "query-library" is not available in QueryBuilder component! You either misspelled the module name or forgot to load it.')},p.prototype.getParameterizedNamedSql=function(e){if(this.moduleLoader.loadedModules.length){e||(e=this.getValidRules());var t={sql:null};return this.notify("query-library",{prop:"getNamedParameterSql",onPropertyChange:!1,value:{rule:e,obj:t}}),t.sql}return console.warn('[WARNING] :: Module "query-library" is not available in QueryBuilder component! You either misspelled the module name or forgot to load it.'),null},p.prototype.setParameterizedNamedSql=function(e){if(this.moduleLoader.loadedModules.length){var t={sql:null};this.notify("query-library",{prop:"convertNamedParamSqlToSql",onPropertyChange:!1,value:{sql:e,obj:t}});var l=t.sql;if(l){l=l.replace(/`/g,"");var n=this.getRulesFromSql(l);this.setRules({condition:n.condition,not:n.not,rules:n.rules})}}else console.warn('[WARNING] :: Module "query-library" is not available in QueryBuilder component! You either misspelled the module name or forgot to load it.')},p.prototype.setMongoQuery=function(e,t){this.moduleLoader.loadedModules.length?(this.rule={condition:"and",not:!1,rules:[]},this.notify("query-library",{prop:"mongoParser",onPropertyChange:!1,value:{mongoQuery:JSON.parse(e),rule:this.rule,mongoLocale:t}})):console.warn('[WARNING] :: Module "query-library" is not available in QueryBuilder component! You either misspelled the module name or forgot to load it.')},p.prototype.getMongoQuery=function(e){if(this.moduleLoader.loadedModules.length){e||(e=this.getValidRules());var t={mongoQuery:null};return this.notify("query-library",{prop:"getMongoFromRules",onPropertyChange:!1,value:{rule:e,mongoQuery:"",obj:t}}),t.mongoQuery}return console.warn('[WARNING] :: Module "query-library" is not available in QueryBuilder component! You either misspelled the module name or forgot to load it.'),""},p.prototype.cloneRule=function(e,t,l){var n=this.getRule(e.replace(this.element.id+"_","")),r=this.showButtons.cloneRule;t=t.replace(this.element.id+"_",""),this.ruleIndex=l,this.cloneRuleBtnClick=!0,this.showButtons.cloneRule=!0,this.addRules([{label:n.label,field:n.field,type:n.type,operator:n.operator,value:n.value,condition:n.condition}],t),this.ruleIndex=-1,this.cloneRuleBtnClick=!1,this.showButtons.cloneRule=r,r=!1},p.prototype.cloneGroup=function(e,t,l){t=t.replace(this.element.id+"_","");var n=this.getGroup(t),r=this.showButtons.cloneGroup;e=e.replace(this.element.id+"_",""),this.groupIndex=l,this.cloneGrpBtnClick=!0,this.showButtons.cloneGroup=!0,this.addGroups([{condition:n.condition,not:n.not,rules:n.rules}],e),this.groupIndex=-1,this.cloneGrpBtnClick=!1,this.showButtons.cloneGroup=r,r=!1},p.prototype.lockRule=function(e){e.indexOf(this.element.id)<0&&(e=this.element.id+"_"+e);var t=document.getElementById(e).querySelectorAll(".e-lock-rule-btn")[0];this.ruleLock(t)},p.prototype.lockGroup=function(e){e.indexOf(this.element.id)<0&&(e=this.element.id+"_"+e);var t=document.getElementById(e).querySelectorAll(".e-lock-grp-btn")[0];this.groupLock(t)},p.prototype.sqlParser=function(e,t){var l,n=0;do{l=e.slice(n),n+=this.parseSqlStrings(l,t)}while(""!==l);return this.parser},p.prototype.parseSqlStrings=function(e,t){var l,n=["=","!=","<=",">=","<",">"];l=t?[this.l10n.getConstant("AND").toUpperCase(),this.l10n.getConstant("OR").toUpperCase(),this.l10n.getConstant("NOT").toUpperCase()]:["AND","OR","NOT"];var r;r=t?[this.l10n.getConstant("In").toUpperCase(),this.l10n.getConstant("NotIn").toUpperCase(),this.l10n.getConstant("Like").toUpperCase(),this.l10n.getConstant("NotLike").toUpperCase(),this.l10n.getConstant("Between").toUpperCase(),this.l10n.getConstant("NotBetween").toUpperCase(),this.l10n.getConstant("IsNull").toUpperCase(),this.l10n.getConstant("IsNotNull").toUpperCase(),this.l10n.getConstant("IsEmpty").toUpperCase(),this.l10n.getConstant("IsNotEmpty").toUpperCase()]:["IN","NOT IN","LIKE","NOT LIKE","BETWEEN","NOT BETWEEN","IS NULL","IS NOT NULL","IS EMPTY","IS NOT EMPTY"];for(var i,o,s=0,a=n.length;s<a;s++)if(i=/^\w+$/.test(n[s])?"\\b":"",new(d=RegExp)("^("+n[s]+")"+i,"ig").exec(e))return this.parser.push(["Operators",n[s].toLowerCase()]),n[s].length;var u=this.parser[this.parser.length-1];if(!u||u&&"Literal"!==u[0])for(var s=0,a=l.length;s<a;s++)if(i=/^\w+$/.test(l[s])?"\\b":"",new(d=RegExp)("^("+l[s]+")"+i,"ig").exec(e))return this.parser.push(["Conditions",l[s].toLowerCase()]),l[s].length;for(var s=0,a=r.length;s<a;s++){i=/^\w+$/.test(r[s])?"\\b":"";var d=RegExp;if(new d("^("+r[s]+")"+i,"ig").exec(e))return this.parser.push(["SubOperators",r[s].toLowerCase()]),r[s].length}if(/^\(/.exec(e))return this.parser.push(["Left","("]),1;if(/^\)/.exec(e))return this.parser.push(["Right",")"]),1;if(/^(true|false)/.exec(e))return o=/^(true|false)/.exec(e)[0],this.parser.push(["String",o]),o.length;if(/^null/.exec(e))return o=/^null/.exec(e)[0],this.parser.push(["String",null]),o.length;if(/^`?([a-z_][a-z0-9_.\\[\]\\(\\)]{0,}(\\:(number|float|string|date|boolean))?)`?/i.exec(e))return o=/^`?([a-z_][a-z0-9_.\\[\]\\(\\)]{0,}(\\:(number|float|string|date|boolean))?)`?/i.exec(e)[1],this.parser.push(["Literal",o]),o.length;if(this.checkLiteral()&&/^'?([a-z_][a-z0-9 _.\\[\]\\(\\)-]{0,}(\\:(number|float|string|date|boolean))?)'?/i.exec(e))return o=/^'?([a-z_][a-z0-9 _.\\[\]\\(\\)-]{0,}(\\:(number|float|string|date|boolean))?)'?/i.exec(e)[1],this.parser.push(["Literal",o]),o.length+2;if(this.checkNumberLiteral(e,t))return o=/^[0-9]+(\.[0-9]+)$/.exec(e)[0],this.parser.push(["Literal",o]),o.length;var c=this.getSingleQuoteString(e);if(""!==c){if("("===(o=c)[o.length-2])for(var p=!1,h=o.length;h<e.length&&(o+=e[h],")"===e[h]&&(p=!0),!p||"'"!==e[h]);h++);else e[o.length]&&")"!==e[o.length]&&!this.checkCondition(e,o)&&(o=this.combineSingleQuoteString(e,o));return this.parser.push(["String",o]),o.length}var g=this.getDoubleQuoteString(e);return""!==g?(o=g,this.parser.push(["DoubleString",o]),o.length):/^\d*\.?\d+/.exec(e)?(o=/^\d*\.?\d+/.exec(e)[0],this.parser.push(["Number",o]),o.length):/^-?\d*\.?\d+/.exec(e)?(o=/^-?\d*\.?\d+/.exec(e)[0],this.parser.push(["Number",o]),o.length):1},p.prototype.getDoubleQuoteString=function(e){var t=e.indexOf('"');if(0===t){var l=e.indexOf('"',t+1);if(-1!==l)return e.substring(t,l+1)}return""},p.prototype.checkCondition=function(e,t){return"AND"===e.slice(t.length+1,t.length+4)||"OR"===e.slice(t.length+1,t.length+3)},p.prototype.getSingleQuoteString=function(e,t){var l=e.indexOf("'");if(-1!==l&&t||0===l&&!t){var n=e.indexOf("'",l+1);if(-1!==n)return e.substring(l,n+1)}return""},p.prototype.combineSingleQuoteString=function(e,t){if(e[t.length]&&")"!==e[t.length]&&!this.checkCondition(e,t)&&","!==e[t.length]){var l=t.substring(0,t.length-1),n=e.replace(l,""),r=this.getSingleQuoteString(n,!0);""!==r&&(t+=r.substring(1,r.length),t=this.combineSingleQuoteString(e,t))}return t},p.prototype.checkLiteral=function(){var e=this.parser[this.parser.length-1];if(!e)return!0;var t=this.parser[this.parser.length-2],l=this.parser[this.parser.length-3];if("Left"===e[0]&&t&&"Conditions"===t[0])return!0;return!!("Conditions"===e[0]&&l&&l[1].indexOf("between")<0)},p.prototype.checkNumberLiteral=function(e,t){var l=this.parser[this.parser.length-1];if(!l)return!0;if(/^[0-9]+(?:\.[0-9]+)$/.exec(e)){var n=this.parser[this.parser.length-2],r=this.parser[this.parser.length-3];if("Left"===l[0]&&n&&"Conditions"===n[0])return!0;var i=t?this.l10n.getConstant("Between").toLowerCase():"between";if("Conditions"===l[0]&&r&&r[1].indexOf(i)<0)return!0}return!1},p.prototype.getOperator=function(e,t,l){var n={"=":"equal","!=":"notequal","<":"lessthan",">":"greaterthan","<=":"lessthanorequal",">=":"greaterthanorequal",in:"in","not in":"notin",between:"between","not between":"notbetween","is empty":"isempty","is null":"isnull","is not null":"isnotnull","is not empty":"isnotempty"};if(l){for(var r=Object.keys(this.sqlOperators),i=0;i<r.length;i++)if(this.sqlOperators[r[i]]===t.toUpperCase())return e&&0===e.indexOf("%")&&"%"===e[e.length-1]?"NOT LIKE"===t.toUpperCase()?"notcontains":"contains":e&&0!==e.indexOf("%")&&e.indexOf("%")===e.length-1?"NOT LIKE"===t.toUpperCase()?"notstartswith":"startswith":e&&0===e.indexOf("%")&&e.indexOf("%")!==e.length-1?"NOT LIKE"===t.toUpperCase()?"notendswith":"endswith":r[i];return null}if(e){if(0===e.indexOf("%")&&"%"===e[e.length-1])return"not like"===t?"notcontains":"contains";if(0!==e.indexOf("%")&&e.indexOf("%")===e.length-1)return"not like"===t?"notstartswith":"startswith";if(0===e.indexOf("%")&&e.indexOf("%")!==e.length-1)return"not like"===t?"notendswith":"endswith"}else{if("not like"===t)return"notequal";if("like"===t)return"equal"}return n[""+t]},p.prototype.getTypeFromColumn=function(e){var l=this.getColumn(e.field);return t.isNullOrUndefined(l)?null:l.type},p.prototype.getLabelFromColumn=function(e){var t="",l=0;if(""!==this.separator){for(var n=e.split(this.separator),r=0;r<n.length;r++)t+=this.getLabelFromField(n,r+1),++l<n.length&&(t+=this.separator);return t}return this.getColumn(e).label},p.prototype.getLabelFromField=function(e,t){for(var l="",n=0,r=0;r<t;r++)l+=e[r],++n<t&&(l+=this.separator);return this.getColumn(l).label},p.prototype.processParser=function(e,t,l,n){for(var r,i,o,s,a,u,d,c,p,h,g=[],m=[],f=!1,v=0,y=e.length;v<y;v++)if("Literal"===e[v][0]){var b=this.getColumn(e[v][1]);if(o={label:b&&b.label?b.label:e[v][1],field:e[v][1]},"SubOperators"===e[v+1][0]){if(e[v+1][1].indexOf("null")>-1||e[v+1][1].indexOf("empty")>-1)o.operator=this.getOperator(" ",e[v+1][1],n),o.value=null,o.type=this.getTypeFromColumn(o);else{var C=e[v+3][1]?e[v+3][1].replace(/'/g,""):e[v+3][1];o.operator=this.getOperator(C,e[v+1][1],n)}for(h=e[v+1][1],r=++v+1,i=y,n&&"contains"===o.operator||"startswith"===o.operator||"endswith"===o.operator?h="like":n&&"notcontains"===o.operator||"notstartswith"===o.operator||"notendswith"===o.operator?h="not like":n&&(h=o.operator),r=v+1;r<i;r++)if(h.indexOf("between")<0&&"Left"===e[r][0])f=!0;else{if("Right"===e[r][0]&&f){v=r,f=!1;break}if(h.indexOf("null")>-1||h.indexOf("empty")>-1)break;if(h.indexOf("like")>-1&&"String"===e[r][0]){S=e[r][1];e[r][1]&&"'"===e[r][1][0]&&(S=e[r][1].substring(1,e[r][1].length-1)),S=S?S.replace(/%/g,""):e[r][1],o.value=S,o.type="string"}else if(h.indexOf("between")>-1){if("Literal"===e[r][0]||"Left"===e[r][0])break;if("Number"===e[r][0])g.push(Number(e[r][1]));else if("String"===e[r][0]){S=e[r][1];e[r][1]&&"'"===e[r][1][0]&&(S=e[r][1].substring(1,e[r][1].length-1)),m.push(S)}}else if("Number"===e[r][0])g.push(Number(e[r][1]));else if("String"===e[r][0]){var S=e[r][1];e[r][1]&&"'"===e[r][1][0]&&(S=e[r][1].substring(1,e[r][1].length-1)),m.push(S)}o.type=this.getTypeFromColumn(o)}h.indexOf("like")<0&&("Number"===e[r-1][0]?(o.value=g,o.type="number"):"String"===e[r-1][0]?(o.value=m,o.type="string"):h.indexOf("between")>-1&&"Conditions"===e[r-1][0]&&(0!==m.length?(o.value=m,o.type="string"):(o.value=g,o.type="number")),g=[],m=[],o.type=this.getTypeFromColumn(o)),this.enableSeparateConnector&&"Conditions"===e[v+1][0]&&(o.condition=e[v+1][1])}else"Operators"===e[v+1][0]&&(o.operator=this.getOperator(e[v+2][1],e[v+1][1],n),"equal"===o.operator&&"String"===e[v+2][0]&&"''"===e[v+2][1]?o.operator="isempty":"notequal"===o.operator&&"String"===e[v+2][0]&&"''"===e[v+2][1]&&(o.operator="isnotempty"),"Number"===e[v+2][0]?(o.type="number",o.value=Number(e[v+2][1])):(o.type="string",(S=e[v+2][1])&&"'"===S[0]&&(S=S.substring(1,S.length-1)),o.value=S),this.enableSeparateConnector&&"Conditions"===e[v+3][0]&&(o.condition=e[v+3][1]),o.type=this.getTypeFromColumn(o));t.rules.push(o)}else{if("Left"===e[v][0]){if("Left"!==e[0][0]&&("not"===e[v-1][1]||n&&this.l10n.getConstant("NOT").toLowerCase()===e[v-1][1]))continue;for(this.parser=e.splice(v+1,y-(v+1)),s=this.enableNotCondition?{condition:"and",rules:[],not:!1}:{condition:"and",rules:[]},p=0,u=t.rules.length,a=0;a<u;a++)t.rules[a].rules&&p++;return l.push(p),t.rules.push(s),s=this.processParser(this.parser,s,l,n),t}if("Conditions"!==e[v][0]||this.enableSeparateConnector){if("Right"===e[v][0]){for(this.parser=e.splice(v+1,y-(v+1)),l.pop(),t=this.rule,c=l.length,d=0;d<c;d++)t=this.findGroupByIdx(l[d],t,0===d);return this.processParser(this.parser,t,l,n)}}else"not"===e[v][1]||n&&this.l10n.getConstant("NOT").toLowerCase()===e[v][1]?t.not=!0:t.condition=e[v][1]}return t},p.prototype.groupClone=function(e){var t,l,n=e.closest(".e-rule-list").closest(".e-group-container");"string"==typeof e?(l=this.element.id+"_"+e,e=document.getElementById(l)):(t=e.id.replace(this.element.id+"_",""),l=n.id.replace(this.element.id+"_",""));var r=this.getGroup(t);this.groupIndex=Array.prototype.indexOf.call(e.closest(".e-rule-list").children,e.closest(".e-group-container")),this.addGroups([{condition:r.condition,not:r.not,rules:r.rules}],l),this.groupIndex=-1},p.prototype.ruleClone=function(e){for(var l=t.closest(e,".e-rule-container"),n=e.closest(".e-rule-list").closest(".e-group-container"),r=this.getRule(e),i=n.id.replace(this.element.id+"_",""),o=n.querySelectorAll(".e-rule-container"),s=0,a=o.length;s<a;s++)l.id===o[s].id&&(this.ruleIndex=s);this.enableSeparateConnector?this.addRules([{label:r.label,field:r.field,type:r.type,operator:r.operator,value:r.value,condition:r.condition}],i):this.addRules([{label:r.label,field:r.field,type:r.type,operator:r.operator,value:r.value}],i),this.ruleIndex=-1},p.prototype.ruleLock=function(e){var l=t.closest(e,".e-rule-container"),n=this.getRule(l.id.replace(this.element.id+"_",""));l.classList.contains("e-disable")?(n.isLocked=!1,this.lockItems=this.lockItems.filter(function(e){return e!==l.id}),l.classList.remove("e-disable"),this.disableRuleControls(e,l,!1),e.children[0].classList.add("e-unlock"),e.children[0].classList.remove("e-lock"),e.setAttribute("title",this.l10n.getConstant("LockRule"))):(n.isLocked=!0,this.lockItems.indexOf(l.id)<0&&this.lockItems.splice(this.lockItems.length-1,0,l.id),l.classList.add("e-disable"),this.disableRuleControls(e,l,!0),e.children[0].classList.add("e-lock"),e.children[0].classList.remove("e-unlock"),e.setAttribute("title",this.l10n.getConstant("UnlockRule")))},p.prototype.groupLock=function(e){var l=t.closest(e,".e-group-container"),n=this.getGroup(l.id.replace(this.element.id+"_","")),r=l.id.indexOf("group0")>-1;if(l.classList.contains("e-disable"))r?((i={}).condition=n.condition,i.not=n.not,i.isLocked=!1,this.setProperties({rule:i},!0)):n.isLocked=!1,this.lockItems=this.lockItems.filter(function(e){return e!==l.id}),l.classList.remove("e-disable"),this.disableHeaderControls(e,l,!1),e.children[0].classList.add("e-unlock"),e.children[0].classList.remove("e-lock"),e.setAttribute("title",this.l10n.getConstant("LockGroup")),this.updateLockItems();else{if(r){var i={};i.condition=n.condition,i.not=n.not,i.isLocked=!0,this.setProperties({rule:i},!0)}else n.isLocked=!0;this.lockItems.indexOf(l.id)<0&&this.lockItems.splice(this.lockItems.length-1,0,l.id),l.classList.add("e-disable"),this.disableHeaderControls(e,l,!0),e.children[0].classList.add("e-lock"),e.children[0].classList.remove("e-unlock"),e.setAttribute("title",this.l10n.getConstant("UnlockGroup"))}},p.prototype.updateLockItems=function(){for(var e=0;e<this.lockItems.length;e++)if(this.lockItems[e].split("_").length>2){var l=this.element.querySelector("#"+this.lockItems[e]),n=l.querySelector(".e-lock-rule-btn");(l=t.closest(n,".e-rule-container")).classList.contains("e-disable")||this.ruleLock(n)}else{var r=this.element.querySelector("#"+this.lockItems[e]),n=r.querySelector(".e-lock-grp-btn");(r=t.closest(n,".e-group-container")).classList.contains("e-disable")||this.groupLock(n)}},p.prototype.disableHeaderControls=function(e,t,l){for(var n=t.querySelectorAll(".e-btngroup-and"),r=t.querySelectorAll(".e-btngroup-or"),i=t.querySelectorAll(".e-qb-toggle"),o=t.querySelectorAll(".e-add-btn"),s=t.querySelectorAll(".e-deletegroup"),a=t.querySelectorAll(".e-lock-grp-btn"),u=t.querySelectorAll(".e-clone-grp-btn"),d=t.querySelectorAll(".e-group-container"),c=t.querySelectorAll(".e-add-condition-btn"),p=t.querySelectorAll(".e-add-group-btn"),h=0;h<n.length;h++)l?(d[h]&&d[h].classList.contains("e-disable")&&d[h].classList.add("e-disable"),n[h].disabled=!0,r[h].disabled=!0,o[h]&&(o[h].disabled=!0),c[h]&&(c[h].disabled=!0),p[h]&&(p[h].disabled=!0),i[h]&&(i[h].disabled=!0),s[h]&&(s[h].disabled=!0),u[h]&&(u[h].disabled=!0),n[h].parentElement.classList.add("e-disabled"),a[h]&&a[h]!==e&&(a[h].disabled=!0,a[h].children[0].classList.remove("e-unlock"),a[h].children[0].classList.add("e-lock"))):(d[h]&&d[h].classList.remove("e-disable"),n[h].disabled=!1,r[h].disabled=!1,o[h]&&(o[h].disabled=!1),c[h]&&(c[h].disabled=!1),p[h]&&(p[h].disabled=!1),a[h]&&(a[h].disabled=!1),i[h]&&(i[h].disabled=!1),s[h]&&(s[h].disabled=!1),u[h]&&(u[h].disabled=!1),n[h].parentElement.classList.remove("e-disabled"),a[h]&&a[h].children[0].classList.remove("e-lock"),a[h]&&a[h].children[0].classList.add("e-unlock"));this.disableRuleControls(e,t,l)},p.prototype.disableRuleControls=function(e,l,n){for(var r=l.querySelectorAll(".e-control.e-dropdownlist"),i=l.querySelectorAll(".e-control.e-numerictextbox"),o=l.querySelectorAll(".e-control.e-textbox"),s=l.querySelectorAll(".e-control.e-datepicker"),a=l.querySelectorAll(".e-control.e-checkbox"),u=l.querySelectorAll(".e-control.e-radio"),d=l.querySelectorAll(".e-control.e-multiselect"),c=l.querySelectorAll(".e-rule-delete"),p=l.querySelectorAll(".e-lock-rule"),h=l.querySelectorAll(".e-clone-rule"),g=l.querySelectorAll(".e-rule-container"),m=0;m<c.length;m++)n?(g[m]&&g[m].classList.contains("e-disable")&&g[m].classList.add("e-disable"),c[m].disabled=!0,h[m]&&(h[m].disabled=!0),p[m]!==e&&(p[m].disabled=!0,p[m].children[0].classList.remove("e-unlock"),p[m].children[0].classList.add("e-lock"))):(g[m]&&g[m].classList.remove("e-disable"),h[m]&&(h[m].disabled=!1),c[m].disabled=!1,p[m].disabled=!1,p[m].children[0].classList.remove("e-lock"),p[m].children[0].classList.add("e-unlock"));for(m=0;m<r.length;m++)t.getComponent(r[m],"dropdownlist").enabled=!n;for(m=0;m<i.length;m++)t.getComponent(i[m],"numerictextbox").enabled=!n;for(m=0;m<o.length;m++)t.getComponent(o[m],"textbox").enabled=!n;for(m=0;m<s.length;m++)t.getComponent(s[m],"datepicker").enabled=!n;for(m=0;m<a.length;m++)t.getComponent(a[m],"checkbox").disabled=!!n;for(m=0;m<u.length;m++)t.getComponent(u[m],"radio").disabled=!!n;for(m=0;m<d.length;m++)t.getComponent(d[m],"multiselect").enabled=!n},c([t.Event()],p.prototype,"created",void 0),c([t.Event()],p.prototype,"actionBegin",void 0),c([t.Event()],p.prototype,"beforeChange",void 0),c([t.Event()],p.prototype,"change",void 0),c([t.Event()],p.prototype,"dataBound",void 0),c([t.Event()],p.prototype,"ruleChange",void 0),c([t.Event()],p.prototype,"dragStart",void 0),c([t.Event()],p.prototype,"drag",void 0),c([t.Event()],p.prototype,"drop",void 0),c([t.Complex({},m)],p.prototype,"showButtons",void 0),c([t.Property(!1)],p.prototype,"summaryView",void 0),c([t.Property(!1)],p.prototype,"allowValidation",void 0),c([t.Property("Default")],p.prototype,"fieldMode",void 0),c([t.Property([])],p.prototype,"columns",void 0),c([t.Property(null)],p.prototype,"fieldModel",void 0),c([t.Property(null)],p.prototype,"operatorModel",void 0),c([t.Property(null)],p.prototype,"valueModel",void 0),c([t.Property()],p.prototype,"headerTemplate",void 0),c([t.Property("")],p.prototype,"cssClass",void 0),c([t.Property([])],p.prototype,"dataSource",void 0),c([t.Property("Horizontal")],p.prototype,"displayMode",void 0),c([t.Property(!1)],p.prototype,"enablePersistence",void 0),c([t.Property("Default")],p.prototype,"sortDirection",void 0),c([t.Property(5)],p.prototype,"maxGroupCount",void 0),c([t.Property("auto")],p.prototype,"height",void 0),c([t.Property("auto")],p.prototype,"width",void 0),c([t.Property(!1)],p.prototype,"matchCase",void 0),c([t.Property(0)],p.prototype,"immediateModeDelay",void 0),c([t.Property(!1)],p.prototype,"enableNotCondition",void 0),c([t.Property(!1)],p.prototype,"readonly",void 0),c([t.Property(!0)],p.prototype,"addRuleToNewGroups",void 0),c([t.Property(!1)],p.prototype,"autoSelectField",void 0),c([t.Property(!0)],p.prototype,"autoSelectOperator",void 0),c([t.Property("")],p.prototype,"separator",void 0),c([t.Property(!1)],p.prototype,"enableSeparateConnector",void 0),c([t.Complex({condition:"and",rules:[]},h)],p.prototype,"rule",void 0),c([t.Property(!1)],p.prototype,"allowDragAndDrop",void 0),p=c([t.NotifyPropertyChanges],p)}(t.Component),v=function(){function e(e){this.parent=e,this.addEventListener()}return e.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},e.prototype.addEventListener=function(){this.parent.isDestroyed||(this.parent.on("query-library",this.queryLibrary,this),this.parent.on("destroyed",this.destroy,this))},e.prototype.removeEventListener=function(){this.parent.off("query-library",this.queryLibrary),this.parent.off("destroyed",this.destroy)},e.prototype.queryLibrary=function(e){switch(e.prop){case"getMongoFromRules":e.value.obj.mongoQuery=this.getMongoFromRules(e.value.rule,e.value.mongoQuery);break;case"mongoParser":this.mongoParser(e.value.mongoQuery,e.value.rule,e.value.mongoLocale);break;case"getParameterSql":e.value.obj.sql=this.getParameterSql(e.value.rule);break;case"getNamedParameterSql":e.value.obj.sql=this.getNamedParameterSql(e.value.rule);break;case"convertParamSqlToSql":e.value.obj.sql=this.convertParamSqlToSql(e.value.sql);break;case"convertNamedParamSqlToSql":e.value.obj.sql=this.convertNamedParamSqlToSql(e.value.sql)}},e.prototype.getMongoFromRules=function(e,t){return t="{","or"===e.condition?(t+='"$or":[',t=this.convertMongoQuery(e.rules,t)+"]"):(t+='"$and":[',t=this.convertMongoQuery(e.rules,t)+"]"),t+="}"},e.prototype.getOperatorFromMongoOperator=function(e){var t;switch(e){case"$ne":t="notequal";break;case"$gt":t="greaterthan";break;case"$gte":t="greaterthanorequal";break;case"$lt":t="lessthan";break;case"$lte":t="lessthanorequal";break;case"$nin":t="notin"}return t},e.prototype.convertMongoQuery=function(e,t){var l=this,n=0;return e.forEach(function(r){n++,t+="{",void 0!==r.rules&&("or"===r.condition?(t+=' "$or":[',t=l.convertMongoQuery(r.rules,t)+"]"):(t+=' "$and":[',t=l.convertMongoQuery(r.rules,t)+"]"));var i="string"===r.type&&"in"!==r.operator&&"notin"!==r.operator&&r.value&&""!==r.value.trim()?r.value.replace(/'/g,"\\"):"";"string"!==r.type||"in"!==r.operator&&"notin"!==r.operator||!r.value||1!==r.value.length||(i=r.value[0].replace(/'/g,"\\"));var o=r.field?r.field.substring(0):"";switch(r.operator){case"contains":t+='"'+o+'":{"$regex":"'+i+'"}';break;case"notcontains":t+='"'+o+'":{"$not":{"$regex":"'+r.value+'"}}';break;case"startswith":t+='"'+o+'":{"$regex":"^'+i+'"}';break;case"notstartswith":t+='"'+o+'":{"$not":{"$regex":"^'+r.value+'"}}';break;case"endswith":t+='"'+o+'":{"$regex":"'+i+'$"}';break;case"notendswith":t+='"'+o+'":{"$not":{"$regex":"'+r.value+'$"}}';break;case"isnull":t+='"'+o+'": null';break;case"isnotnull":t+='"'+o+'":{"$ne": null}';break;case"isempty":t+='"'+o+'": ""';break;case"isnotempty":t+='"'+o+'":{"$ne": ""}';break;case"equal":"string"===r.type?t+='"'+o+'":"'+i+'"':"date"===r.type?t+='"'+o+'":"'+r.value+'"':(r.type,t+='"'+o+'":'+r.value);break;case"notequal":"string"===r.type?t+='"'+o+'":{"$ne":"'+i+'"}':"date"===r.type?t+='"'+o+'":{"$ne":"'+r.value+'"}':t+='"'+o+'":{"$ne":'+r.value+"}";break;case"in":"string"===r.type?r.value.length>1?(s=(s=r.value.map(function(e,t){return t<r.value.length?'"'+e+'"':""}).toString()).endsWith(",")?s.substring(0,s.length-1):s,t+='"'+o+'": { "$in": ['+s+"]}"):t+='"'+o+'": { "$in": ["'+i+'"]}':"number"===r.type&&(r.value.length>1?t+='"'+o+'": { "$in": ['+r.value.toString()+"]}":t+='"'+o+'": { "$in": ['+r.value+"]}");break;case"notin":if("string"===r.type)if(r.value.length>1){var s=r.value.map(function(e,t){return t<r.value.length?'"'+e+'"':""}).toString();s=s.endsWith(",")?s.substring(0,s.length-1):s,t+='"'+o+'": { "$nin": ['+s+"]}"}else t+='"'+o+'": { "$nin": ["'+i+'"]}';else"number"===r.type&&(r.value.length>1?t+='"'+o+'": { "$nin": ['+r.value.toString()+"]}":t+='"'+o+'": { "$nin": ['+r.value+"]}");break;case"greaterthan":"number"===r.type?t+='"'+o+'": { "$gt": '+r.value+"}":t+='"'+o+'": { "$gt": "'+r.value+'"}';break;case"greaterthanorequal":"number"===r.type?t+='"'+o+'": { "$gte": '+r.value+"}":t+='"'+o+'": { "$gte": "'+r.value+'"}';break;case"between":"number"===r.type?t+='"'+o+'": {"$gte":'+r.value[0]+', "$lte":'+r.value[1]+"}":t+='"'+o+'": {"$gte": "'+r.value[0]+'", "$lte": "'+r.value[1]+'"}';break;case"notbetween":"number"===r.type?t+='"$or":[{"'+o+'": {"$lt":'+r.value[0]+'}}, {"'+o+'": {"$gt":'+r.value[1]+"}}]":t+='"$or":[{"'+o+'": {"$lt": "'+r.value[0]+'"}}, {"'+o+'": {"$gt": "'+r.value[1]+'"}}]';break;case"lessthan":"number"===r.type?t+='"'+o+'": { "$lt": '+r.value+"}":t+='"'+o+'": { "$lt": "'+r.value+'"}';break;case"lessthanorequal":"number"===r.type?t+='"'+o+'": { "$lte": '+r.value+"}":t+='"'+o+'": { "$lte": "'+r.value+'"}'}t+="}",e.length!==n&&(t+=",")}),t},e.prototype.mongoParser=function(e,t,l){var n;Object.keys(e).indexOf("$and")>-1?(n=e.$and,t.condition="and"):Object.keys(e).indexOf("$or")>-1&&(n=e.$or,t.condition="or"),t.rules=[],this.mongoRecursion(n,t.rules,l)},e.prototype.mongoRecursion=function(e,l,n){for(var r,i,o,s,a,u,d,c,p,h,g,m=0,f=e.length;m<f;m++){var v=[],y=[];if(u=Object.keys(e[m])[0],d=e[m][u],"$and"===u)c=this.parent.enableNotCondition?{condition:u.replace("$",""),rules:[],not:!1}:{condition:u.replace("$",""),rules:[]},l.push(c),this.mongoRecursion(e[m][u],l[l.length-1].rules,n);else if("$or"===u){var b=void 0,C=[],S=[],x=[],q=[],E=[],k=[],O=[];Array.isArray(d)&&2===d.length&&(k=d[(S=Object.keys(d))[0]],O=d[S[1]],"object"==typeof k&&(C=Object.keys(k)[0],x=Object.keys(k[Object.keys(k)[0]])[0],q=Object.keys(O[Object.keys(O)[0]])[0],"$lt"===x&&"$gt"===q&&(r="notbetween",p={field:C,label:C,value:g=[E=k[C][x],O[C][q]],operator:r,type:i="number"==typeof E?"number":"date"},l.push(p),b=!0))),b||(c=this.parent.enableNotCondition?{condition:u.replace("$",""),rules:[],not:!1}:{condition:u.replace("$",""),rules:[]},l.push(c),this.mongoRecursion(e[m][u],l[l.length-1].rules,n))}else{if(null===(d=e[m][u])&&(r="isnull"),"boolean"==typeof d&&(r="equal",i="boolean",g=d),"number"==typeof d)g=d,i="number",r="equal";else if("object"==typeof d&&null!==d){h=Object.keys(d);for(var w=0;w<h.length;w++)s=h[w],o=d[h[w]],"$ne"===s&&t.isNullOrUndefined(o)&&(r="isnotnull",g=null),"$ne"===s&&"boolean"==typeof o&&(r="notequal",g=o,i="boolean"),h.length>=2&&h[w]?("object"==typeof o?(r="notbetween",u=Object.keys(o)[0],a=[Object.keys(o[u])[0]],v.push(o[u][a]),i="number"):(r="between",v.push(o)),"number"==typeof o&&(i="number")):"object"==typeof o&&null!==o?"$not"===s&&"$regex"===Object.keys(o)[0]?o.$regex.indexOf("^")>-1?(r="notstartswith",g=o.$regex.replace("^","")):o.$regex.indexOf("$")>-1?(r="notendswith",g=o.$regex.replace("$","")):(r="notcontains",g=o.$regex):(r="$in"===s?"in":"notin",y=o,i="number"==typeof o[0]?"number":"string"):"number"==typeof o&&(r=this.getOperatorFromMongoOperator(s),i="number",g=o),"string"==typeof o&&("$regex"===s&&(r="contains",g=o,i="string"),"$ne"===s&&(null!==o&&o.length>0&&isNaN(Date.parse(o))?(r="notequal",g=o):t.isNullOrUndefined(o)?(r="isnotnull",g=o):""===o&&(r="isnotempty",g=o),i="string"),o.indexOf("^")>-1&&(r="startswith",g=o.replace("^",""),i="string"),o.indexOf("$")>-1&&"$not"!==s&&(r="endswith",g=o.replace("$",""),i="string"),isNaN(Date.parse(o))||(r=r||this.getOperatorFromMongoOperator(s),i="date",g=o))}else d&&"string"==typeof d&&!isNaN(Date.parse(d))?(r="equal",g=d,i="date"):"string"==typeof d&&""!==d&&"true"!==d&&"false"!==d?(r="equal",g=d,i="string"):"string"==typeof d&&""===d&&(r="isempty",g=d,i="string");p=v&&v.length>1?{field:u,label:u,value:v,operator:r,type:i}:y&&y.length>1?{field:u,label:u,value:y,operator:r,type:i}:{field:u,label:u,value:g,operator:r,type:i},l.push(p),r=""}}},e.prototype.convertParamSqlToSql=function(e){for(var t=e.sql,l=e.params,n=t.split("?"),r=n[0],i=0;i<l.length;i++)r+="string"==typeof l[i]?"'"+l[i]+"'"+n[i+1]:l[i]+n[i+1];return r.length>=2&&"("===r[0]&&")"===r[r.length-1]&&(r=r.slice(1,-1)),r=r.replace(/!= ''(?! =)/g,"IS NOT EMPTY").replace(/= ''/g,"IS EMPTY")},e.prototype.convertNamedParamSqlToSql=function(e){var t=e.sql,l=e.params,n=t;return Object.keys(l).forEach(function(e){var t=l[e];e=":"+e,n=n.replace(e,"string"==typeof t?"'"+t+"'":String(t))}),n.length>=2&&"("===n[0]&&")"===n[n.length-1]&&(n=n.slice(1,-1)),n=n.replace(/!= ''(?! =)/g,"IS NOT EMPTY").replace(/= ''/g,"IS EMPTY")},e.prototype.getParameterSql=function(e){var l=t.extend({},e,null,!0),n=this.updateRuleValue(l,!1);return this.getParameterSQLVal(this.parent.getSqlFromRules(l),n.ruleVal)},e.prototype.getNamedParameterSql=function(e){var l=t.extend({},e,null,!0),n=this.updateRuleValue(l,!0);return this.getNamedParameterSQLVal(this.parent.getSqlFromRules(l),n.namedRuleVal)},e.prototype.getParameterSQLVal=function(e,t){return{sql:"("+e.replace(/[%']/g,"")+")",params:t}},e.prototype.getNamedParameterSQLVal=function(e,t){return{sql:"("+e.replace(/[%']/g,"")+")",params:t}},e.prototype.updateRuleValue=function(e,t){var l=[],n={},r=[];return this.updateValue(e.rules,t,l,n,r)},e.prototype.updateValue=function(e,l,n,r,i){if(t.isNullOrUndefined(e))return{ruleVal:n,namedRuleVal:r};for(var o=0;o<e.length;o++)if(e[o].rules)n=(u=this.updateValue(e[o].rules,l,n,r,i)).ruleVal,r=u.namedRuleVal;else{var s=void 0;if(e[o].value instanceof Array)for(var a=0;a<e[o].value.length;a++)l&&(s=this.getNamedParameter(e[o].field,i)),t.isNullOrUndefined(e[o].value[a])||("string"===e[o].type||e[o].type,l?r[s]=e[o].value[a]:n.push(e[o].value[a])),e[o].value[a]=l?":"+s:"?";else if(l&&(s=this.getNamedParameter(e[o].field,i)),e[o].operator.indexOf("null")<1&&("string"!==e[o].type||"string"===e[o].type&&(""!==e[o].value||0===e[o].value))){if("string"===e[o].type||"date"===e[o].type)if(e[o].operator.indexOf("empty")<1){var u=e[o].value.toString();switch(e[o].operator){case"startswith":case"notstartswith":u+="%";break;case"endswith":case"notendswith":u="%"+u;break;case"contains":case"notcontains":u="%"+u+"%"}l?r[s]=u:n.push(u)}else l?r[s]="":n.push(""),"isempty"===e[o].operator?e[o].operator="equal":e[o].operator="notequal";else t.isNullOrUndefined(e[o].value)||(l?r[s]=e[o].value:n.push(e[o].value));e[o].value=l?":"+s:"?"}}return{ruleVal:n,namedRuleVal:r}},e.prototype.getNamedParameter=function(e,t){var l=null;if(t.length>0)for(var n=t.length-1;n>=0;n--){var r=t[n];if(r.indexOf(e)>-1){l=e+"_"+(parseInt(r.split("_")[1],10)+1),t.push(l);break}}return l||(l=e+"_1",t.push(l)),l},e.prototype.getModuleName=function(){return"query-library"},e}();return f.Inject(v),e.Columns=p,e.QueryBuilder=f,e.QueryLibrary=v,e.Rule=h,e.ShowButtons=m,e.Value=g,e}({},ej.base,ej.buttons,ej.dropdowns,ej.data,ej.inputs,ej.calendars,ej.splitbuttons,ej.popups),this.ejs=ej;
11
11
  //# sourceMappingURL=ej2-querybuilder.min.js.map